Skip to content

Commit

Permalink
[test] use nix to build the codegen binary
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <dev@avimit.in>
  • Loading branch information
Avimitin committed Jul 28, 2023
1 parent f8589d9 commit 46692e9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
25 changes: 18 additions & 7 deletions tests/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,26 @@ class CodeGenCase(val config: String) extends Case {
object codegenCaseGenerator extends CodegenCaseGenerator
// standalone unit to compile the codegen
class CodegenCaseGenerator extends Module { u =>
override def millSourcePath = os.pwd / "codegen"
// TODO: How to use the old implementation as fallback

/* override def millSourcePath = os.pwd / "codegen"
def allGoSources = T.sources(os.walk(millSourcePath).filter(f => f.ext == "go" || f.last == "go.mod").map(PathRef(_)))
def asmGenerator = T {
// depends on GO
allGoSources()
val elf = T.dest / "generator"
os.proc("go", "build", "-o", elf, "single/single.go").call(cwd = millSourcePath)
PathRef(elf)
}
sys.env.get("CODEGEN_BIN_PATH") match {
case Some(elf) => PathRef(os.Path(elf))
case None => {
// depends on GO
allGoSources()
val elf = T.dest / "generator"
os.proc("go", "build", "-o", elf, "single/single.go").call(cwd = millSourcePath)
PathRef(elf)
}
}
} */

def asmGenerator = T {
PathRef(os.Path(sys.env("CODEGEN_BIN_PATH")))
}
}

// Intrinsic Cases
Expand Down
22 changes: 20 additions & 2 deletions tests/default.nix
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
{ stdenv, rv32-clang, glibc_multi, llvmForDev, go, buddy-mlir, ammonite, mill }:
{ stdenv, rv32-clang, glibc_multi, llvmForDev, go, buddy-mlir, ammonite, mill, fetchFromGitHub, buildGoModule }:

let
build-script = ../.github/scripts/ci.sc;

# We need the codegen/config, so we need to store the source code
riscv-vector-tests = fetchFromGitHub {
owner = "ksco";
repo = "riscv-vector-tests";
rev = "3fb992b1dc7f89231b27ae4a1e8d50492dde4f5b";
hash = "sha256-BNbK8+KUwhqk3XfFgKsaeUpX0NuApl8mN/URKwYTYtE=";
};

codegen = buildGoModule {
pname = "riscv-vector-test";
version = "unstable-2023-04-12";
src = riscv-vector-tests;
doCheck = false;
vendorHash = "sha256-9cQlivpHg6IDYpmgBp34n6BR/I0FIYnmrXCuiGmAhNE=";
};
in
stdenv.mkDerivation {
pname = "test-case-output";
version = "07dc6e099ee9feebb187685b488eee176a6450fd";
version = "ae358e0c6000aa34bffb3b2424fd8ff499418e9";
src = ./.;
unpackPhase = ''
mkdir -p tests-src
cp -r $src/* tests-src/
cp -r ${riscv-vector-tests} tests-src/codegen
'';
nativeBuildInputs =
[ rv32-clang glibc_multi llvmForDev.bintools go buddy-mlir ammonite mill ];
buildPhase = ''
mkdir -p tests-out
export CODEGEN_BIN_PATH=${codegen}/bin/single
amm ${build-script} genTestElf tests-src ./tests-out
'';
installPhase = ''
Expand Down

0 comments on commit 46692e9

Please sign in to comment.