Skip to content

Commit 008b694

Browse files
committed
[build] bump to mill 0.12.5 and refactor build scripts
Signed-off-by: unlsycn <[email protected]>
1 parent 6a8222a commit 008b694

File tree

12 files changed

+160
-105
lines changed

12 files changed

+160
-105
lines changed

templates/chisel/build.mill

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: 2024 Jiuyang Liu <[email protected]>
3+
package build
4+
5+
import mill._
6+
import mill.scalalib._
7+
import mill.define.{Command, TaskModule}
8+
import mill.scalalib.publish._
9+
import mill.scalalib.scalafmt._
10+
import mill.scalalib.TestModule.Utest
11+
import mill.util.Jvm
12+
import coursier.maven.MavenRepository
13+
14+
object deps {
15+
val scalaVer = "2.13.15"
16+
val mainargs = ivy"com.lihaoyi::mainargs:0.5.0"
17+
val oslib = ivy"com.lihaoyi::os-lib:0.9.1"
18+
val upickle = ivy"com.lihaoyi::upickle:3.3.1"
19+
val chisel = ivy"org.chipsalliance::chisel::0.0.0+0-no-vcs-SNAPSHOT"
20+
val chiselPlugin = ivy"org.chipsalliance:chisel-plugin_${scalaVer}:0.0.0+0-no-vcs-SNAPSHOT"
21+
}
22+
23+
object gcd extends GCD
24+
trait GCD extends common.HasChisel with ScalafmtModule {
25+
def scalaVersion = Task(deps.scalaVer)
26+
27+
def chiselModule = None
28+
def chiselPluginJar = Task(None)
29+
def chiselPluginIvy = Some(deps.chiselPlugin)
30+
def chiselIvy = Some(deps.chisel)
31+
}
32+
33+
object elaborator extends Elaborator
34+
trait Elaborator extends common.ElaboratorModule with ScalafmtModule {
35+
def scalaVersion = Task(deps.scalaVer)
36+
37+
def circtInstallPath =
38+
Task.Input(PathRef(os.Path(T.ctx().env("CIRCT_INSTALL_PATH"))))
39+
40+
def generators = Seq(gcd)
41+
42+
def mainargsIvy = deps.mainargs
43+
44+
def chiselModule = None
45+
def chiselPluginJar = Task(None)
46+
def chiselPluginIvy = Some(deps.chiselPlugin)
47+
def chiselIvy = Some(deps.chisel)
48+
}

templates/chisel/build.sc

Lines changed: 0 additions & 66 deletions
This file was deleted.

templates/chisel/common.sc renamed to templates/chisel/common.mill

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// SPDX-FileCopyrightText: 2024 Jiuyang Liu <[email protected]>
3+
package build
34

45
import mill._
56
import mill.scalalib._
@@ -39,9 +40,8 @@ trait HasChisel extends ScalaModule {
3940

4041
trait ElaboratorModule extends ScalaModule with HasChisel {
4142
def generators: Seq[ScalaModule]
42-
def panamaconverterModule: ScalaModule
4343
def circtInstallPath: T[PathRef]
44-
override def moduleDeps = super.moduleDeps ++ Seq(panamaconverterModule) ++ generators
44+
override def moduleDeps = super.moduleDeps ++ generators
4545
def mainargsIvy: Dep
4646
override def ivyDeps = T(super.ivyDeps() ++ Seq(mainargsIvy))
4747
override def javacOptions = T(super.javacOptions() ++ Seq("--enable-preview", "--release", "21"))

templates/chisel/flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/chisel/flake.nix

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@
2121
inherit system;
2222
};
2323
in
24+
with pkgs;
2425
{
25-
formatter = pkgs.nixpkgs-fmt;
26+
formatter = nixpkgs-fmt;
2627
legacyPackages = pkgs;
27-
devShells.default = pkgs.mkShell ({
28-
inputsFrom = [ pkgs.gcd.gcd-compiled pkgs.gcd.tb-dpi-lib ];
29-
nativeBuildInputs = [ pkgs.cargo pkgs.rustfmt pkgs.rust-analyzer ];
28+
devShells.default = mkShell ({
29+
inputsFrom = [ gcd.gcd-compiled gcd.tb-dpi-lib ];
30+
packages = [ cargo rustfmt rust-analyzer nixd nvfetcher ];
3031
RUST_SRC_PATH =
31-
"${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
32-
} // pkgs.gcd.tb-dpi-lib.env // pkgs.gcd.gcd-compiled.env);
32+
"${rust.packages.stable.rustPlatform.rustLibSrc}";
33+
} // gcd.tb-dpi-lib.env // gcd.gcd-compiled.env);
3334
});
3435
}

templates/chisel/nix/gcd/gcd.nix

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
{ lib
55
, stdenv
66
, fetchMillDeps
7+
, publishMillModule
78
, makeWrapper
89
, jdk21
910
, git
@@ -20,6 +21,15 @@
2021
}:
2122

2223
let
24+
chisel =
25+
publishMillModule {
26+
name = "chisel";
27+
version = "9999";
28+
outputHash = "sha256-ZJGYxmTg4+8UU3V3MTxBSWow4XYKQ4KuCvD/PBxLSEc=";
29+
publishPhase = "mill -i unipublish.publishLocal";
30+
nativeBuildInputs = [ git ];
31+
};
32+
2333
self = stdenv.mkDerivation rec {
2434
name = "gcd";
2535

@@ -29,8 +39,8 @@ let
2939
toSource {
3040
root = ./../..;
3141
fileset = unions [
32-
./../../build.sc
33-
./../../common.sc
42+
./../../build.mill
43+
./../../common.mill
3444
./../../gcd
3545
./../../elaborator
3646
];
@@ -42,9 +52,10 @@ let
4252
src = with lib.fileset;
4353
toSource {
4454
root = ./../..;
45-
fileset = unions [ ./../../build.sc ./../../common.sc ];
55+
fileset = unions [ ./../../build.mill ./../../common.mill ];
4656
};
47-
millDepsHash = "sha256-5VTgJ1JaIxP3wk/WsFj+W1VGFE2xoPKu3XbmTVOvMdk=";
57+
millDepModules = [ chisel ];
58+
millDepsHash = "sha256-cPGkRjKc42dcSOXHAW9JAl/AKgwPdl+T8bVPsWCXxpM=";
4859
nativeBuildInputs = [ projectDependencies.setupHook ];
4960
};
5061

templates/chisel/nix/overlay.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ final: prev: {
2020

2121
fetchMillDeps = final.callPackage ./pkgs/mill-builder.nix { };
2222

23+
publishMillModule = final.callPackage ./pkgs/dependencies { };
24+
2325
circt-full = final.callPackage ./pkgs/circt-full.nix { };
2426

2527
# faster strip-undetereminism
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"chisel": {
33
"cargoLocks": null,
4-
"date": "2024-10-28",
4+
"date": "2025-01-09",
55
"extract": null,
66
"name": "chisel",
77
"passthru": null,
@@ -11,12 +11,12 @@
1111
"fetchSubmodules": false,
1212
"leaveDotGit": false,
1313
"name": null,
14-
"owner": "chipsalliance",
14+
"owner": "unlsycn",
1515
"repo": "chisel",
16-
"rev": "66bab812796eb5a5c0bbe3308ee01fc6752557eb",
17-
"sha256": "sha256-gaaNEGqxm213vQ3er6vn7kC8na0D745IdDnJWwQPgms=",
16+
"rev": "ea01f89d39c138bc4c260baf5e8e088e120f4265",
17+
"sha256": "sha256-KNcAgOA/YBt+1QOVXGpK/33BZ8PpDcHDdAnIBDLfSqI=",
1818
"type": "github"
1919
},
20-
"version": "66bab812796eb5a5c0bbe3308ee01fc6752557eb"
20+
"version": "ea01f89d39c138bc4c260baf5e8e088e120f4265"
2121
}
2222
}

templates/chisel/nix/pkgs/dependencies/_sources/generated.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
{
44
chisel = {
55
pname = "chisel";
6-
version = "66bab812796eb5a5c0bbe3308ee01fc6752557eb";
6+
version = "ea01f89d39c138bc4c260baf5e8e088e120f4265";
77
src = fetchFromGitHub {
8-
owner = "chipsalliance";
8+
owner = "unlsycn";
99
repo = "chisel";
10-
rev = "66bab812796eb5a5c0bbe3308ee01fc6752557eb";
10+
rev = "ea01f89d39c138bc4c260baf5e8e088e120f4265";
1111
fetchSubmodules = false;
12-
sha256 = "sha256-gaaNEGqxm213vQ3er6vn7kC8na0D745IdDnJWwQPgms=";
12+
sha256 = "sha256-KNcAgOA/YBt+1QOVXGpK/33BZ8PpDcHDdAnIBDLfSqI=";
1313
};
14-
date = "2024-10-28";
14+
date = "2025-01-09";
1515
};
1616
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{ pkgs
2+
, stdenv
3+
, mill
4+
, ...
5+
}:
6+
{ name
7+
, version
8+
, outputHash
9+
, publishPhase
10+
, ...
11+
}@args:
12+
let
13+
dependencies = pkgs.callPackage ./_sources/generated.nix { };
14+
in
15+
stdenv.mkDerivation {
16+
pname = name;
17+
src = dependencies.${name}.src;
18+
19+
inherit version outputHash;
20+
21+
outputHashAlgo = "sha256";
22+
outputHashMode = "recursive";
23+
24+
nativeBuildInputs = [ mill ] ++ (args.nativeBuildInputs or [ ]);
25+
26+
impureEnvVars = [ "JAVA_OPTS" ];
27+
28+
buildPhase = ''
29+
runHook preBuild
30+
echo "-Duser.home=$TMPDIR -Divy.home=$TMPDIR/ivy $JAVA_OPTS" | tr ' ' '\n' > mill-java-opts
31+
export MILL_JVM_OPTS_PATH=$PWD/mill-java-opts
32+
33+
# Use "https://repo1.maven.org/maven2/" only to keep dependencies integrity
34+
export COURSIER_REPOSITORIES="ivy2Local|central"
35+
36+
${publishPhase}
37+
38+
runHook postBuild
39+
'';
40+
41+
installPhase = ''
42+
runHook preInstall
43+
mkdir -p $out/.ivy2
44+
mv $TMPDIR/ivy/local $out/.ivy2/local
45+
runHook postInstall
46+
'';
47+
}

0 commit comments

Comments
 (0)