diff --git a/check-generated-code.nix b/check-generated-code.nix new file mode 100644 index 0000000000..a408a44b69 --- /dev/null +++ b/check-generated-code.nix @@ -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; + }) diff --git a/default.nix b/default.nix index 552fa8751d..330a8aa3e5 100644 --- a/default.nix +++ b/default.nix @@ -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. @@ -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 {})