Skip to content

Commit

Permalink
check-generated-code.nix: Check if in-tree VM code is stale
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Jul 8, 2017
1 parent 726cc9c commit 2cf9924
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
31 changes: 31 additions & 0 deletions check-generated-code.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Check that generated sources match the repo version.
{ pkgs, raptorjit }:
with pkgs; with lib;

# Generated files that are kept in tree.
let generatedFiles =
"lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h host/buildvm_arch.h";
in

overrideDerivation raptorjit (as:
{
preBuild = ''
pushd src
mkdir old
for f in ${generatedFiles}; do
cp $f old/
done
popd
'' + as.preBuild;
checkPhase = ''
pushd src
mkdir new
for f in ${generatedFiles}; do
cp $f new/
done
echo "Checking that in-tree generated VM code is up-to-date..."
diff -u old new || (echo "Error: Stale generated code"; exit 1)
popd
'';
doCheck = true;
})
11 changes: 7 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@

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

let
callPackage = (pkgs.lib.callPackageWith { inherit pkgs; inherit source; inherit version; });
callPackage = (pkgs.lib.callPackageWith { inherit pkgs source version; });
raptorjit = (callPackage ./raptorjit.nix {});
test = name: args: (callPackage ./test.nix { inherit raptorjit; inherit name; inherit args; });
test = name: args: (callPackage ./test.nix { inherit raptorjit name args; });
check-generated-code = (callPackage ./check-generated-code.nix { inherit raptorjit; });
in

# Build RaptorJIT and run mulitple test suites.
Expand All @@ -24,5 +26,6 @@ in
test-O2 = test "O2" "-O2";
test-O1 = test "O1" "-O1";
test-nojit = test "nojit" "-joff";
}
} //
(if check then { inherit check-generated-code; } else {})

0 comments on commit 2cf9924

Please sign in to comment.