diff --git a/nix/t1/default.nix b/nix/t1/default.nix index 6be4711aa4..cc6958c72f 100644 --- a/nix/t1/default.nix +++ b/nix/t1/default.nix @@ -25,9 +25,9 @@ lib.makeScope newScope elaborator = _millOutput.elaborator // { meta.mainProgram = "elaborator"; }; configgen = _millOutput.configgen // { meta.mainProgram = "configgen"; }; - omreader = _millOutput.omreader // { meta.mainProgram = "omreader"; }; t1package = _millOutput.t1package; + omreader = self.callPackage ./omreader.nix { }; submodules = self.callPackage ./submodules.nix { }; riscv-opcodes-src = self.submodules.sources.riscv-opcodes.src; diff --git a/nix/t1/om.nix b/nix/t1/om.nix index 8c4361df5d..eb76a5a3fe 100644 --- a/nix/t1/om.nix +++ b/nix/t1/om.nix @@ -15,10 +15,10 @@ in stdenvNoCC.mkDerivation { name = "t1-${mlirbc.elaborateConfig}-${mlirbc.elaborateTarget}-om"; - nativeBuildInputs = [ circt ]; + nativeBuildInputs = [ circt omreader ]; buildCommand = '' - ${omreader}/bin/omreader ${lib.escapeShellArgs omReaderArgs} + omreader ${lib.escapeShellArgs omReaderArgs} ''; meta.description = "TODO."; diff --git a/nix/t1/omreader.nix b/nix/t1/omreader.nix new file mode 100644 index 0000000000..e8e4db402b --- /dev/null +++ b/nix/t1/omreader.nix @@ -0,0 +1,88 @@ +{ lib +, stdenv +, fetchMillDeps +, makeWrapper + + # chisel deps +, mill +, espresso +, circt-full +, jextract +, strip-nondeterminism + +, submodules +}: + +let + self = stdenv.mkDerivation rec { + name = "omreader"; + + src = with lib.fileset; toSource { + root = ./../..; + fileset = unions [ + ./../../build.sc + ./../../common.sc + ./../../omreader + ./../../omreaderlib + ]; + }; + + passthru.millDeps = fetchMillDeps { + inherit name; + src = with lib.fileset; toSource { + root = ./../..; + fileset = unions [ + ./../../build.sc + ./../../common.sc + ]; + }; + millDepsHash = "sha256-rkS/bTDnjnyzdQyTIhfLj3e0mMdDn4fzv/660rO3qYg="; + nativeBuildInputs = [ submodules.setupHook ]; + }; + + passthru.editable = self.overrideAttrs (_: { + shellHook = '' + setupSubmodulesEditable + mill mill.bsp.BSP/install 0 + ''; + }); + + shellHook = '' + setupSubmodules + ''; + + nativeBuildInputs = [ + mill + jextract + strip-nondeterminism + circt-full + + makeWrapper + passthru.millDeps.setupHook + + submodules.setupHook + ]; + + env = { + CIRCT_INSTALL_PATH = circt-full; + JAVA_TOOL_OPTIONS = "--enable-preview"; + }; + + buildPhase = '' + mill -i 'omreader.assembly' + ''; + + installPhase = '' + mkdir -p "$out"/bin "$out"/share/java + strip-nondeterminism out/omreader/assembly.dest/out.jar + mv out/omreader/assembly.dest/out.jar "$out"/share/java/omreader.jar + makeWrapper ${mill.jre}/bin/java "$out"/bin/omreader --add-flags "--enable-preview -Djava.library.path=${circt-full}/lib -jar $out/share/java/omreader.jar" + ''; + + meta = { + description = "omreader"; + mainProgram = "omreader"; + }; + }; +in +self diff --git a/nix/t1/t1.nix b/nix/t1/t1.nix index 581c88a28f..5e7c240626 100644 --- a/nix/t1/t1.nix +++ b/nix/t1/t1.nix @@ -31,6 +31,7 @@ let ./../../elaborator ./../../configgen ./../../omreader + ./../../omreaderlib ]; }; @@ -72,7 +73,7 @@ let env.CIRCT_INSTALL_PATH = circt-full; - outputs = [ "out" "configgen" "elaborator" "t1package" "omreader" ]; + outputs = [ "out" "configgen" "elaborator" "t1package" ]; buildPhase = '' mill -i '__.assembly' @@ -86,24 +87,21 @@ let strip-nondeterminism out/elaborator/assembly.dest/out.jar strip-nondeterminism out/configgen/assembly.dest/out.jar - strip-nondeterminism out/omreader/assembly.dest/out.jar strip-nondeterminism out/t1package/assembly.dest/out.jar strip-nondeterminism out/t1package/sourceJar.dest/out.jar strip-nondeterminism out/t1package/chiselPluginJar.dest/out.jar mv out/configgen/assembly.dest/out.jar $out/share/java/configgen.jar mv out/elaborator/assembly.dest/out.jar $out/share/java/elaborator.jar - mv out/omreader/assembly.dest/out.jar $out/share/java/omreader.jar mkdir -p $t1package/share/java mv out/t1package/sourceJar.dest/out.jar $t1package/share/java/t1package-sources.jar mv out/t1package/assembly.dest/out.jar $t1package/share/java/t1package.jar mv out/t1package/chiselPluginJar.dest/out.jar $t1package/share/java/chiselPluginJar.jar - mkdir -p $configgen/bin $elaborator/bin $omreader/bin + mkdir -p $configgen/bin $elaborator/bin makeWrapper ${jdk21}/bin/java $configgen/bin/configgen --add-flags "-jar $out/share/java/configgen.jar" makeWrapper ${jdk21}/bin/java $elaborator/bin/elaborator --add-flags "--enable-preview -Djava.library.path=${circt-full}/lib -jar $out/share/java/elaborator.jar" - makeWrapper ${jdk21}/bin/java $omreader/bin/omreader --add-flags "--enable-preview -Djava.library.path=${circt-full}/lib -jar $out/share/java/omreader.jar" ''; }; in diff --git a/omreaderlib/Interface.scala b/omreaderlib/src/Interface.scala similarity index 100% rename from omreaderlib/Interface.scala rename to omreaderlib/src/Interface.scala