Skip to content

Commit

Permalink
test-capi.nix: Add basic of C-API linkage
Browse files Browse the repository at this point in the history
Downloads the 'lpty' library, builds it with LuaJIT, links it into
RaptorJIT.
  • Loading branch information
lukego committed Jan 11, 2019
1 parent 572090d commit bd959e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions default.nix
Expand Up @@ -18,6 +18,7 @@ let
raptorjit-assert = raptorjit.overrideAttrs(
old: { NIX_CFLAGS_COMPILE = " -DLUA_USE_ASSERT"; });
test = name: args: (callPackage ./test.nix { inherit name args; raptorjit = raptorjit-assert; });
test-capi = callPackage ./test-capi.nix { inherit pkgs raptorjit; };
check-generated-code = (callPackage ./check-generated-code.nix { inherit raptorjit; });
nowarnings = raptorjit.overrideAttrs(
old: { NIX_CFLAGS_COMPILE = "-Werror"; });
Expand All @@ -30,6 +31,7 @@ in
test-O2 = test "O2" "-O2";
test-O1 = test "O1" "-O1";
test-nojit = test "nojit" "-joff";
test-capi = test-capi;
# Test that generated bytecode is compatible
test-bytecode-compat = pkgs.runCommand "test-bytecode-compat"
{ buildInputs = [ raptorjit ]; }
Expand Down
21 changes: 21 additions & 0 deletions test-capi.nix
@@ -0,0 +1,21 @@
{ pkgs, raptorjit, ... }:
with pkgs;

let lpty =
fetchurl rec {
url = "http://tset.de/downloads/lpty-1.2.2-1.tar.gz";
sha256 = "071mvz79wi9vr6hvrnb1rv19lqp1bh2fi742zkpv2sm1r9gy5rav";
};
in

stdenv.mkDerivation {
name = "test-capi";
src = lpty;
phases = "unpackPhase buildPhase testPhase";
buildInputs = [ luajit raptorjit which ];
testPhase = ''
${raptorjit}/bin/raptorjit -e 'require "lpty" print("Successfully loaded a C library.")' \
> $out
'';
}

0 comments on commit bd959e3

Please sign in to comment.