Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LocalBuildInfo should change at build time when components are selected #2910

Open
enolan opened this issue Nov 4, 2015 · 5 comments
Open

Comments

@enolan
Copy link
Contributor

enolan commented Nov 4, 2015

You can specify which components to build like this: runhaskell Setup.hs build my-testsuite. But since LocalBuildInfo is generated at configure time, the componentsConfigs field list every component that was enabled then. This means you can't check whether certain components are being built.

I ran into this trying to update my PR #2844. cabal-install's Setup.hs builds the manpage in a postBuild hook. If we're haven't built cabal yet and dist/build/cabal doesn't exist, then the openFile call to write dist/build/cabal/cabal.1 will fail. We need to only try to make the manpage when building the executable component but it's impossible to find out at this stage.

@ezyang
Copy link
Contributor

ezyang commented Dec 23, 2015

Hello @enolan, do you have suggested interface for being able to check if components are being built?

@enolan
Copy link
Contributor Author

enolan commented Dec 24, 2015

Hi Edward. My plan was to move the call to readBuildTargets from Distribution.Simple.Build.build to Distribution.Simple.buildAction. Inside the preBuild buildHook and postBuild hooks, the componentsConfigs field of LocalBuildInfo would only include components that were actually being built. I can't think of a reason the build phase would need to know about components that are configured but not actually being built. If anyone can, we'd need a new field in the lbi. I wrote this for cabal-install's Setup.hs:

buildingExecutable :: LocalBuildInfo -> Bool
buildingExecutable lbi = any isCabalExe $ componentsConfigs lbi
  where isCabalExe (cname, _, _) = cname == CExeName "cabal"

@ezyang
Copy link
Contributor

ezyang commented Dec 24, 2015

OK, some thoughts:

  1. If you really want something only to be run per if something else is being built, this suggests we should have a per-component build hook, which gets called for every component being built (even better, you can get a ComponentLocalBuildInfo!) (ditto with postBuild/preBuild, I guess).
  2. I don't think your plan works: componentsInBuildOrder will throw a hissy fit because it expects that executable you "just" wanted to build to depend on a component that is in the componentsConfigs, and it's not.

@enolan
Copy link
Contributor Author

enolan commented Dec 24, 2015

Yes, that makes sense. So we should either change the hooks to take an additional argument of ComponentLocalBuildInfo or add a new set of hooks with that parameter that default to doing nothing?

@ezyang
Copy link
Contributor

ezyang commented Dec 24, 2015

Changing the hooks will break existing hooks in two ways: (1) they won't typecheck anymore, and (2) they'll get run multiple times but most users expect their hooks to run once. I'd add some new hooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants