summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorAustin Seipp <aseipp@pobox.com>2019-09-19 00:26:48 -0500
committerAustin Seipp <aseipp@pobox.com>2019-09-19 00:26:48 -0500
commitd5e1d57ceeb06f9d4b465453116c5911264310cd (patch)
tree2dc4566456c378f7621926a04deaf057a7574660 /pkgs
parent52d3655c3d5fcb83b6dbb054b272007270849bb3 (diff)
downloadnixpkgs-d5e1d57ceeb06f9d4b465453116c5911264310cd.tar
nixpkgs-d5e1d57ceeb06f9d4b465453116c5911264310cd.tar.gz
nixpkgs-d5e1d57ceeb06f9d4b465453116c5911264310cd.tar.bz2
nixpkgs-d5e1d57ceeb06f9d4b465453116c5911264310cd.tar.lz
nixpkgs-d5e1d57ceeb06f9d4b465453116c5911264310cd.tar.xz
nixpkgs-d5e1d57ceeb06f9d4b465453116c5911264310cd.tar.zst
nixpkgs-d5e1d57ceeb06f9d4b465453116c5911264310cd.zip
terra: include libc headers by default, run tests
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/compilers/terra/default.nix19
-rw-r--r--pkgs/development/compilers/terra/nix-cflags.patch7
2 files changed, 17 insertions, 9 deletions
diff --git a/pkgs/development/compilers/terra/default.nix b/pkgs/development/compilers/terra/default.nix
index edab1cb0df2..6d87d4bbd49 100644
--- a/pkgs/development/compilers/terra/default.nix
+++ b/pkgs/development/compilers/terra/default.nix
@@ -9,7 +9,6 @@ let
     sha256 = "0yg9q4q6v028bgh85317ykc9whgxgysp76qzaqgq55y6jy11yjw7";
   };
 in
-
 stdenv.mkDerivation rec {
   pname = "terra";
   version = "1.0.0pre1175_${builtins.substring 0 7 src.rev}";
@@ -21,15 +20,21 @@ stdenv.mkDerivation rec {
     sha256 = "0aky17vbv3d9zng34hp17p9zb00dbzwhvzsdjzrrqvk9lmyvix0s";
   };
 
-  hardeningDisable = [ "fortify" ];
+  nativeBuildInputs = [ lua ];
+  buildInputs = with llvmPackages; [ llvm clang-unwrapped ncurses ];
 
+  doCheck = true;
+  enableParallelBuilding = true;
+  hardeningDisable = [ "fortify" ];
   outputs = [ "bin" "dev" "out" "static" ];
 
   patches = [ ./nix-cflags.patch ];
-
   postPatch = ''
-    substituteInPlace Makefile --replace \
-      '-lcurses' '-lncurses'
+    substituteInPlace Makefile \
+      --replace '-lcurses' '-lncurses'
+
+    substituteInPlace src/terralib.lua \
+      --subst-var-by NIX_LIBC_INCLUDE ${stdenv.cc.libc.dev}/include
   '';
 
   preBuild = ''
@@ -42,6 +47,8 @@ stdenv.mkDerivation rec {
     cp ${luajitSrc} build/${luajitArchive}
   '';
 
+  checkPhase = "(cd tests && ../terra run)";
+
   installPhase = ''
     install -Dm755 -t $bin/bin release/bin/terra
     install -Dm755 -t $out/lib release/lib/terra${stdenv.hostPlatform.extensions.sharedLibrary}
@@ -51,8 +58,6 @@ stdenv.mkDerivation rec {
     cp -rv release/include/terra $dev/include
   '';
 
-  buildInputs = with llvmPackages; [ lua llvm clang-unwrapped ncurses ];
-
   meta = with stdenv.lib; {
     description = "A low-level counterpart to Lua";
     homepage    = http://terralang.org/;
diff --git a/pkgs/development/compilers/terra/nix-cflags.patch b/pkgs/development/compilers/terra/nix-cflags.patch
index be9b6a61088..339ae23cef6 100644
--- a/pkgs/development/compilers/terra/nix-cflags.patch
+++ b/pkgs/development/compilers/terra/nix-cflags.patch
@@ -1,13 +1,16 @@
 diff --git a/src/terralib.lua b/src/terralib.lua
-index 351238d..f26591b 100644
+index 351238d..e638c90 100644
 --- a/src/terralib.lua
 +++ b/src/terralib.lua
-@@ -3395,6 +3395,14 @@ function terra.includecstring(code,cargs,target)
+@@ -3395,6 +3395,17 @@ function terra.includecstring(code,cargs,target)
      	args:insert("-internal-isystem")
      	args:insert(path)
      end
 +
 +    -- NOTE(aseipp): include relevant Nix header files
++    args:insert("-isystem")
++    args:insert("@NIX_LIBC_INCLUDE@")
++
 +    local nix_cflags = os.getenv('NIX_CFLAGS_COMPILE')
 +    if nix_cflags ~= nil then
 +        for w in nix_cflags:gmatch("%S+") do