-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgcd.nix
106 lines (85 loc) · 2.12 KB
/
gcd.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: 2024 Jiuyang Liu <[email protected]>
{ lib
, stdenv
, fetchMillDeps
, makeWrapper
, jdk21
, git
# chisel deps
, mill
, espresso
, circt-full
, jextract-21
, add-determinism
, projectDependencies
, target
}:
let
self = stdenv.mkDerivation rec {
name = "gcd";
mainClass = "org.chipsalliance.gcd.elaborator.${target}Main";
src = with lib.fileset;
toSource {
root = ./../..;
fileset = unions [
./../../build.sc
./../../common.sc
./../../gcd
./../../elaborator
];
};
passthru = {
millDeps = fetchMillDeps {
inherit name;
src = with lib.fileset;
toSource {
root = ./../..;
fileset = unions [ ./../../build.sc ./../../common.sc ];
};
millDepsHash = "sha256-5VTgJ1JaIxP3wk/WsFj+W1VGFE2xoPKu3XbmTVOvMdk=";
nativeBuildInputs = [ projectDependencies.setupHook ];
};
editable = self.overrideAttrs (_: {
shellHook = ''
setupSubmodulesEditable
mill mill.bsp.BSP/install 0
'';
});
inherit target;
inherit env;
};
shellHook = ''
setupSubmodules
'';
nativeBuildInputs = [
mill
circt-full
jextract-21
add-determinism
espresso
git
makeWrapper
passthru.millDeps.setupHook
projectDependencies.setupHook
];
env = {
CIRCT_INSTALL_PATH = circt-full;
JEXTRACT_INSTALL_PATH = jextract-21;
};
outputs = [ "out" "elaborator" ];
meta.mainProgram = "elaborator";
buildPhase = ''
mill -i '__.assembly'
'';
installPhase = ''
mkdir -p $out/share/java
add-determinism -j $NIX_BUILD_CORES out/elaborator/assembly.dest/out.jar
mv out/elaborator/assembly.dest/out.jar $out/share/java/elaborator.jar
mkdir -p $elaborator/bin
makeWrapper ${jdk21}/bin/java $elaborator/bin/elaborator \
--add-flags "--enable-preview -Djava.library.path=${circt-full}/lib -cp $out/share/java/elaborator.jar ${mainClass}"
'';
};
in
self