Skip to content

Commit

Permalink
nix: pin nixpkgs, pin clang 4.0, run test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Mar 20, 2017
1 parent 010a99b commit c025664
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 15 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ bootstrapping (see [default.nix](default.nix)). The recommended way to
build RaptorJIT is with nix, which provides the dependencies
automatically, but you can build manually if you prefer.

Building with nix will be slow the first time due to downloading
toolchains and related dependencies. This is all cached for future
builds.

#### Build with nix

Install nix:
Expand All @@ -84,12 +88,18 @@ Install nix:
$ curl https://nixos.org/nix/install | sh
```

Build in batch-mode (option 1):
Build in batch-mode and run the test suite (option 1a):

```shell
$ nix-build # produces result/bin/raptorjit
```

Build in batch-mode without the test suite (option 1b):

```shell
$ nix-build -A raptorjit
```

Build interactively (option 2):

```shell
Expand Down
28 changes: 14 additions & 14 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@
#
# See README.md for usage instructions.

{ pkgs ? (import <nixpkgs> {}) # Use default nix distro (for now...)
args @ {
pkgs ? (import ./pkgs.nix) {}
, source ? ./.
, version ? "dev"
}:

with pkgs;
with clangStdenv; # Clang instead of GCC
let
callPackage = (pkgs.lib.callPackageWith { inherit pkgs; inherit source; inherit version; });
raptorjit = (callPackage ./raptorjit.nix {});
test = name: args: (callPackage ./test.nix { inherit raptorjit; inherit name; inherit args; });
in

mkDerivation rec {
name = "raptorjit-${version}";
inherit version;
src = lib.cleanSource source;
buildInputs = [ luajit ]; # LuaJIT to bootstrap DynASM
installPhase = ''
mkdir -p $out/bin
cp src/luajit $out/bin/raptorjit
'';

enableParallelBuilding = true; # Do 'make -j'
# Build RaptorJIT and run mulitple test suites.
{
raptorjit = raptorjit;
test-O3 = test "O3" "-O3";
test-O2 = test "O2" "-O2";
test-O1 = test "O1" "-O1";
test-nojit = test "nojit" "-joff";
}

1 change: 1 addition & 0 deletions pkgs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import (fetchTarball https://github.com/NixOS/nixpkgs-channels/archive/6a0155d2b7cb10aef1c63b654a2b172d78fd89b4.tar.gz)
29 changes: 29 additions & 0 deletions raptorjit.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# default.nix - define the build environment for RaptorJIT
#
# This file can be used by 'nix-build' or 'nix-shell' to create a
# pristine build environment with precisely the expected software in
# $PATH. This makes it possible to build raptorjit in the same way on
# any machine.
#
# See README.md for usage instructions.

{ pkgs ? (import ./pkgs.nix) {}
, source ? ./.
, version ? "dev" }:

with pkgs;
with llvmPackages_4.stdenv; # Use clang 4.0

mkDerivation rec {
name = "raptorjit-${version}";
inherit version;
src = source;
buildInputs = [ luajit ]; # LuaJIT to bootstrap DynASM
installPhase = ''
mkdir -p $out/bin
cp src/luajit $out/bin/raptorjit
'';

enableParallelBuilding = true; # Do 'make -j'
}

19 changes: 19 additions & 0 deletions test.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ pkgs, raptorjit, source, name, args }:

pkgs.stdenv.mkDerivation {
name = "test-${name}";
src = source;
buildInputs = [ raptorjit ];
phases = "unpackPhase buildPhase";
buildPhase = ''
mkdir $out
cd testsuite/test
echo "Running testsuite with ${args} and output to $out/log.txt"
raptorjit ${args} test.lua 2>&1 > $out/log.txt
result=$?
echo -n "*** TEST RESULTS (${args}): "
tail -1 $out/log.txt
exit $result
'';
}

0 comments on commit c025664

Please sign in to comment.