Support for passing git version as a argument to runMain
?
#143
-
I'm trying to pass the git version string generated by this plugin to a main class on invocation, but somehow mill doesn't allow me to do so: trait HwProjModule extends Module {
def variant: String
def generatedSourcesPath = millSourcePath / "hw" / "gen" / variant
override def millSourcePath = os.pwd
def gitVersion = T { VcsVersion.vcsState().format() }
def generateVerilog = T {
val v = gitVersion()
gen.runMain("pionic.GenEngineVerilog",
"--name", variant,
"--version", v)()
Seq("NicEngine_ips.v", "NicEngine.v", "NicEngine.xdc").map(fn => PathRef(generatedSourcesPath / fn))
}
// ...
} Results in the following error: $ mill eci.generateVerilog
[build.sc] [49/53] compile
[info] compiling 1 Scala source to /local/home/pengxu/work-local/enzian-pio-nic/out/mill-build/compile.dest/classes ...
[error] /local/home/pengxu/work-local/enzian-pio-nic/build.sc:60:20: Target#apply() call cannot use `value v` defined within the T{...} block
[error] "--version", v)()
[error] ^
[error] one error found
1 targets failed
compile Compilation failed Is this a supported use case of the module? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
lefou
Apr 29, 2024
Replies: 1 comment 4 replies
-
Since the version comes from a target, you need a def generateVerilog = T {
gen.runForkedTask(
mainClass = T.task { "pionic.GenEngineVerilog" },
args = T.task {
val v = gitVersion()
Args("--name", variant, "--version", v)
}
)()
Seq("NicEngine_ips.v", "NicEngine.v", "NicEngine.xdc").map(fn => PathRef(generatedSourcesPath / fn))
} I'm referring to Mill |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
KireinaHoro
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since the version comes from a target, you need a
run
-version that has receives aTask
for the run arguments. Unfortunatelly,runMain
isn't one of them (only in the next major Mill version, due to compatibility reasons). Either you userun
or the underlyingrunForkedTask
.I'm referring to Mill
0.11.7-70-654f58