Skip to content

Commit

Permalink
[nix] split omreader from T1
Browse files Browse the repository at this point in the history
Signed-off-by: Avimitin <[email protected]>
  • Loading branch information
Avimitin committed Apr 24, 2024
1 parent 146baee commit ca46cbd
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 8 deletions.
2 changes: 1 addition & 1 deletion nix/t1/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions nix/t1/om.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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.";
Expand Down
88 changes: 88 additions & 0 deletions nix/t1/omreader.nix
Original file line number Diff line number Diff line change
@@ -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
8 changes: 3 additions & 5 deletions nix/t1/t1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ let
./../../elaborator
./../../configgen
./../../omreader
./../../omreaderlib
];
};

Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand Down
File renamed without changes.

0 comments on commit ca46cbd

Please sign in to comment.