You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just ran into a case in google/proto-lens#110 (comment) which requires us to specify a build-tool-depend-style dependency for custom-setup, as Setup.hs needs to be able to execute the proto-lens-protoc tool provided by the proto-lens-protoc package.
I originally mistook #4047 for providing this feature, but then I realized this is subtly different (because #4047 is about replacing Setup.hs with an externally provided executable, while this is merely about the ability to specify dependencies on exe components); so we'd like to say something like
-- Setup.hsimportData.ProtoLens.Setup-- from lib:proto-lens-protoc-- executes proto-lens-protoc:exe:proto-lens-protocmain::IO()
main = defaultMainGeneratingProtos "tests"
PS: it appears that build-tool-depends in non-setup stanzas makes an executable available to Setup.hs via $PATH, even though that wasn't obvious to me from the log-output, as the last environment-dump before setup is executed didn't show it in the $PATH. So it seems the environment dumped only applied to the ghc --make Setup.hs invocation, but the setup invocation used a different not-shown environment.
However, this also means we can actually fake #4047 already now with a trivial Setup.hs (which needs at most base and process) which merely re-executes an external executable imported via build-tool-depends
The current guidance is that you should make a setup-helper package which has the build-tools dependency, so that the setup stanza stay simple. Does that work here?
@ezyang but if you run library code living in a setup-helper package (and the setup-helper package depending on some executable), how does cabal know that it needs to propagate the build-tool-depends $PATH entry to your local setup stanza? Afaik, build-tool-depends need to be private to the package that specifies it.
Yeah, the crux of the matter is we need some sort of "runtime" tool-depends for this pattern to work. I feel like we had a ticket for this but I don't know where it is.
PS: it appears that build-tool-depends in non-setup stanzas makes an executable available to Setup.hs via $PATH, even though that wasn't obvious to me from the log-output, as the last environment-dump before setup is executed didn't show it in the $PATH. So it seems the environment dumped only applied to the ghc --make Setup.hs invocation, but the setup invocation used a different not-shown environment.
However, this also means we can actually fake #4047 already now with a trivial Setup.hs (which needs at most base and process) which merely re-executes an external executable imported via build-tool-depends
A caveat here, at least with Cabal 2.4, PATH is only set correctly if performing per-component builds. For example with Qtah, qtah-cpp's Setup.hs needs a binary from qtah-generator, both use Custom builds, and what gets added to PATH is
Activity
ezyang commentedon Jul 31, 2017
The current guidance is that you should make a setup-helper package which has the build-tools dependency, so that the setup stanza stay simple. Does that work here?
hvr commentedon Jul 31, 2017
@ezyang but if you run library code living in a setup-helper package (and the setup-helper package depending on some executable), how does cabal know that it needs to propagate the build-tool-depends $PATH entry to your local setup stanza? Afaik,
build-tool-dependsneed to be private to the package that specifies it.ezyang commentedon Jul 31, 2017
Yeah, the crux of the matter is we need some sort of "runtime" tool-depends for this pattern to work. I feel like we had a ticket for this but I don't know where it is.
hvr commentedon Jul 31, 2017
@ezyang are you referring to the discussion in #4104 (comment) ?
ezyang commentedon Jul 31, 2017
That seems like a pretty good comment :)
Ericson2314 commentedon Jul 4, 2018
I put up a more general alternative here: #5411
khumba commentedon Jul 1, 2020
A caveat here, at least with Cabal 2.4, PATH is only set correctly if performing per-component builds. For example with Qtah,
qtah-cpp's Setup.hs needs a binary fromqtah-generator, both use Custom builds, and what gets added to PATH iswhereas the executable exists at
, there's an extra subdirectory there.