pants
pants copied to clipboard
[WIP] go: add "pure" field to go_binary to disable cgo when set
Add a pure
field to go_binary
which disables cgo when set. I.e., the binary is built "purely" with Go sources.
Introduces GoBuildContext
to carry build-related options like whether to permit cgo or not (and eventually compiler flags to use etc.)
[ci skip-rust]
[ci skip-build-wheels]
Rule graph error: foo.log
@stuhood: I'm trying to use the multi-parameter selector syntax. Am I using it correctly? Is there a preferred way to have a build context like I do in this PR?
Why didn't the engine make use of the rule providing GoBuildContext
then?
@rule
async def go_global_context(golang_subsystem: GolangSubsystem) -> GoBuildContext:
return GoBuildContext(cgo_allowed=golang_subsystem.cgo_allowed)
Why didn't the engine make use of the rule providing
GoBuildContext
then?@rule async def go_global_context(golang_subsystem: GolangSubsystem) -> GoBuildContext: return GoBuildContext(cgo_allowed=golang_subsystem.cgo_allowed)
Hm... maybe it would: sorry, I missed that. Try with only the second edit?
But I will say: having a singleton like that as well as a parameter that you're expecting to be propagated seems pretty error prone: it seems fairly likely to forget to pass the override and get a default instead. I'd suggest removing the singleton, explicitly initializing (without a rule) and passing it down instead.
Closing in favor of https://github.com/pantsbuild/pants/pull/17475.