Skip to content

Commit

Permalink
[script] use graalvm for t1-helper
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Apr 17, 2024
1 parent 95b68a4 commit c19e1f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
2 changes: 1 addition & 1 deletion nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ in
fetchMillDeps = final.callPackage ./pkgs/mill-builder.nix { };
circt-full = final.callPackage ./pkgs/circt-full.nix { };

mill = let jre = final.jdk21; in
mill = let jre = final.graalvm-ce; in
(prev.mill.override { inherit jre; }).overrideAttrs (_: {
passthru = { inherit jre; };
});
Expand Down
17 changes: 17 additions & 0 deletions script/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,21 @@ object script extends RootModule with ScalaModule {
def scalaVersion = v.scala3
def scalacOptions = Seq("-new-syntax")
override def ivyDeps = Agg(v.mainargs, v.oslib, v.upickle)

def nativeImage = T {
val jar = super.assembly()
val nativeImageArgs = Seq(
// don't fallback to using JRE, so that we can get a minimal size binary.
"--no-fallback"
)
val outputArgs = Seq(
"-jar",
jar.path.toString(),
(T.dest / "out.elf").toString()
)
os.proc(
Seq("native-image") ++ nativeImageArgs ++ outputArgs
).call(stdout = os.Inherit, stderr = os.Inherit)
PathRef(T.dest / "out.elf")
}
}
18 changes: 5 additions & 13 deletions script/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
, makeWrapper

, metals
, gnugrep
, jre
, mill
, strip-nondeterminism
}:

let
Expand Down Expand Up @@ -36,7 +33,8 @@ let
passthru.dev = self.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [
metals
gnugrep
# Metals require java to work correctly
mill.passthru.jre
];

shellHook = ''
Expand All @@ -50,24 +48,18 @@ let

nativeBuildInputs = [
mill
strip-nondeterminism

makeWrapper
passthru.millDeps.setupHook
];

buildPhase = ''
mill -i assembly
mill -i nativeImage
'';

installPhase = ''
mkdir -p $out/share/java "$out"/bin
strip-nondeterminism out/assembly.dest/out.jar
mv out/assembly.dest/out.jar $out/share/java/"$name".jar
makeWrapper ${jre}/bin/java "$out"/bin/"$name" --add-flags "-jar $out/share/java/$name.jar"
mkdir -p "$out"/bin
cp out/nativeImage.dest/out.elf "$out"/bin/"$name"
'';
};
in
Expand Down

0 comments on commit c19e1f1

Please sign in to comment.