-
Notifications
You must be signed in to change notification settings - Fork 711
Rebuild source directories added to the sandbox. #1118
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
Conversation
@dcoutts I'd really like your input on this one. @23Skidoo To avoid UI discussion issues, couldn't this all be done internally, instead of calling some command with some new command line flags? Here's how I imagine what needs to be done. Each of these could be implemented as a function or two:
I realize that this is probably what you're already doing (I haven't reviewed the code in depth yet). I think it would be useful to be able to do this internally in cabal, by calling functions such as |
This is basically how it is done. In
Now, |
@23Skidoo What could happen if we didn't use the |
The |
OK. So I guess we want this behavior until/if we decide to have |
Yes, then it won't be needed (though we might allow the users to enable offline mode explicitly). |
Yes. Explicitly disabling package downloads using a flag is something that would be nice to support. |
Regarding this part of your comment:
This is done by the solver itself because the current package and all add-source dependencies are install targets. The only thing that remains is to remove the current package from the install plan (achieved with |
Sorry for the radio silence on this issue. I'm still trying to wrap my head around it. There's something about the way we're implementing this that doesn't rub me the right way. Let me try to explain my current thinking: I think (part of) the issue is that
mean if the current package doesn't depend on I think what we're actually doing when we're rebuilding add-source packages is:
I don't have a good understanding if the above |
Isn't what we want to do, to make an install plan for the whole sandbox, so that we know we're always doing everything consistently. Then we prune that install plan graph back to the dependencies of the target(s). I don't see why we need an offline mode for that (though I have considered it in the past as an independently useful feature, but I'm pretty sure it ought to be orthogonal here). I also don't think we need to add any command line flags for this. We ought to be able to do it just as manipulations of the install plan. |
I think it might help if you called the individual parts/phases of install directly, rather than going via the high-level That is, call the planner directly, get back the |
No, it has the same effect - create an install plan and then prune the install targets:
This will make the install plan invalid and
If someone can point me in the right direction, I can try my hand at it.
So that to prohibit
Can you advise me how to implement this without unnecessarily reinstalling everything? By default, we already refuse to proceed if the reinstall is likely to break something.
Just to clarify: the only command-line flag I added is
Maybe. Should I break up |
I think so. I think we want to create the functions necessary to be able to create the |
OK. It will take me some time. |
I appreciate that this is more difficult and perhaps not as easy as you hoped, but I do think it's the right thing to do and it will make cabal better overall. |
Should I still leave the |
@dcoutts |
debugNoWrap :: Verbosity -> String -> IO () | ||
debugNoWrap verbosity msg = | ||
when (verbosity >= deafening) $ do | ||
putStrLn msg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug
doesn't add an extra newline. Do we really want to add one here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debug
itself doesn't, but wrapText
does.
I'm inclined to merge this. @dcoutts any objections? |
I don't see why we're moving the 'install' code into Main. It's fine to export the component parts from the |
I still don't think we need an offline mode for this. The way I think it should work is that we construct the install plan when we configure, then we keep that install plan as long as it remains valid (ie until someone changes one of the .cabal files in the source trees). Then build always just uses the same install plan, but we adjust which bits of it we actually want to build, given the current target(s). That said, an offline mode is independently useful, though I think we would implement it differently. We'd tell the solver to avoid all packages that are not already fetched. Ok, lets talk interim solutions since perhaps my suggestion to shift the planning into the configure phase and reusing the same plan (without re-running the solver) during build is too big a step to do immediately. Lets commit what we have now with the following changes:
|
@dcoutts I've added offline mode because @kosmikus was against having commands other than |
In a context where we're handling a whole set of local packages, I don't see a sensible alternative to making 'build' build dependencies and that may involve getting them from the network. Perhaps we could move the network part earlier to the configure phase, so it fetches them at that point. That may well be a good idea but that doesn't seem like a very significant difference, since if you do a 'build' and the configuration is out of date (because the user changed a .cabal file) then we're going to want to automatically reconfigure anyway. If we default to an offline mode by default for that, then it just means we're likely to fail instead. As a longer term thing, I've been thinking of making some of the UI interactive by default, so that it gets confirmation for some things, like confirming when new packages will be installed. |
I'll remove the offline mode then. |
The name 'InstallContext' will be used for common data shared between lower-level install functions.
Splits 'D.C.Install.install' into three parts: * makeInstallContext - load common data * makeInstallPlan - produce the install plan * processInstallPlan - actually perform the installations This allows to manipulate the install plan produced with 'makeInstallPlan' before performing the installations with 'processInstallPlan'. The high-level 'install' action is still present; most clients should use it instead.
Implemented by creating an install plan for ["add-source-dep-1", ..., "add-source-dep-N", "."], pruning "." from this plan and then doing all remaining installs in the plan before building the current package. This way, all reverse dependencies of add-source packages needed to install the current package are also reinstalled.
logMsg message rest = debugNoWrap verbosity message >> rest | ||
|
||
-- | Common context for makeInstallPlan and processInstallPlan. | ||
type InstallContext = ( PackageIndex, SourcePackageDb |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A TODO for the future: we probably want to make InstallContext and InstallArgs into proper data types with documented fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought about this. Not that hard to change.
Overall the change looks good to me. |
Ok, looks fine to me too. About those type aliases, they're fine when the thing is basically an internal api, but we could look at them again when we consider making it more of a public api. For now it's fine. |
Adds an offline mode for the
install
command and anonlyDepsOf
flag that allows to remove a subset of targets from the install plan (see also my message to the mailing list).Rebuilding of add-source deps themselves is implemented by running
before
cabal build
.