-
Notifications
You must be signed in to change notification settings - Fork 698
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
Add --basedir
flag
#4867
Comments
There's a |
You can provide the |
Figured it'd be more useful for me to comment here rather than the PR, since I can't really give a proper review: Is this feature worth changing the API for Setup.hs hooks? That's going to cause a lot of code to need to change. In particular, why not use |
@mgsloan True. I'm not absolutely happy about changing the hooks. Luckily there is a warning right at the hooks, which put me a bit more at ease:
The idea here is to completely remove any dependence on the CWD (which I consider a defect). The motivation is to make cabal threadable. Right now to you are bound to a single process when dealing with the cabal library, which prevents you from performing multiple cabal lib operations in parallel without careful locking around CWDs. This came up while working on GHC's new hadrian build system and rolling the custom cabal frontend (ghc-cabal) into hadrian directly. @ezyang also remarked, that due to the CWD limitation, cabal currently has to shell out to separate processes to do parallel builds. |
That comment is outdated - we avoid changing the hook interface nowadays, hence weird stuff like passing Maybe you can achieve what you want by passing the info you need inside the |
The primary reason for the hooks change is the |
Yeah, I agree that if changes are made the hooks API then it'd be better to do one big change than little ones. #3600 seems like a lot of work, and there is no design there yet, so it doesn't seem likely to make it into the next release. How about having a record type for each input? So:
So, the idea is that users would be encouraged in the documentation to use the field accessors. Could even try to encourage this even more by only exporting the If you wanted to get real wild you could do
Then again, if this were applied to all the hooks, it would be even more breakage. Would allow for more graceful future extension, though. Could even fold in the other existing arguments like Args / Flags, but that would be more of a pain for the refactoring. This is probably less useful, but may also make sense to have |
While I would like to shave this yak, it's a bit too hairy (#3600) right now. I'll try to jam the needed info into the Flags, to prevent having to break the Hooks API. @mgsloan most of the hooks do have the LocalBuildInfo, which kind of works like what you describe I believe. That however is not available in the |
I see, well how about at least something like data PreInfo = PreInfo
{ preBuildPrefix :: FilePath
} Once again, either documented that fields should be preferred, or better yet, only export the constructor from an internal module. This would allow later extension of |
This was mostly fixed in #4874 |
When executing cabal (or even the library, which I consider even worse), many commands rely on the current working directory to be the one containing the cabal file.
I propose we add a
--basedir
flag, that is part of the local build information of typeMaybe FilePath
, and relative file lookups are done relative to the--basedir
. If the--basedir
isNothing
, the behavior would be identical to the current one. However it would allow to execute cabal from a directory that is not the one that contains the.cabal
file.It looks like the
new-*
commands suffer from this limitation as well.The text was updated successfully, but these errors were encountered: