-
Notifications
You must be signed in to change notification settings - Fork 413
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
Some notion of "environment" #391
Comments
Will the environment be able to subsume the concept of profile @diml mentioned here #371 (comment) It will be necessary to select the profile from the command line, which doesn't seem possible as an env plugin. |
I think you could implement profiles as just a flag in the environment, set on the command-line and with some form of
so that |
OK, this is nice. I think you can basically take this further and subsume workspace files as well. It's not clear to me what's the logical distinction between them anyway. I'm wondering if we could just implement what diml proposed for profiles today, and then generalize it with this env idea after we make plugins work. It seems like this will all be fairly compatible. |
I'd be a bit cautious there. I think you need some information in the workspace file before you would be able to load any plugins. So it would be quite difficult to include plugins for workspace files.
How I'd been thinking of them, I'd been expecting projects to (optionally) include their own environment file, whilst I expect users to mostly write workspace files. The workspace stuff is very specific to the machine your currently building on, but the environment stuff is just useful development settings for a particular project. Possibly the environment file could replace the |
The environment file could also contain the |
Why do we need separate files? I would expect that users will want to commit the environment files most of the time, and when the settings depend on the local machine, they could just put them in the jbuild-workspace file, a temporary jbuild file or even commit them as a specific profile. As long as the BTW, the term environment might be confused with the unix environment. It seems to me that this mechanism will be used to set the defaults in a given scope, what about calling it |
Well, at the moment there are two kinds of file: I think three separate kinds of file might not be a bad idea. One local one for the current workspace, one file to represent the details of a project, and one in each directory describing how the things in the directory are built. This could avoid the current requirement for an opam file to indicate the bounds of the current project. You could even imagine generating the opam file based on the contents of the project file -- although I'm not sure we want to go that far. I think workspaces could never be written with plugins because they are needed too early in the dependency chain, so that might rule out using them for environments. An alternative would be to allow
That's somewhat deliberate, if we wanted environment variables to affect compilation I would expect them to be made available thought the environment type.
That seems overly specific to me. Defaults are a good use case, but I'm not sure they are the only use. I guess it depends on whether you are talking about the name of the type (
|
I was thinking of something like this. I was thinking to have different stanzas to define the project and the environment, to allow modifying the environment in a sub-tree of a project. Delimiting projects with a special file might be good, so introducing project files might be OK anyway. I guess the question here is how we want the environment changes and project scoping to interact. It seems clear that we don't want environment changes to leak between projects. The other question is whether we want to allow changing the environment only in part of a project:
The latter seems better to me.
I definitely want to have that at some point :). I was thinking of generating the opam files using all the information available to jbuilder when the workspace is self-contained. If we only used the project file, then we'd just end up writing the opam files in a different syntax. Users might not necessarily work with closed workspaces on their machine, but at least the CI could check that the opam files are up to date.
Agreed, and I don't see the need to implement build contexts as plugins anyway. But I don't see how the two are connected. It seems to me that there is a question of whether we want to take environment changes into account when building the plugins, but that seems independent to where we put such environment changes.
Ok, that makes sense to me |
We have something like this in master now |
For my curiosity, which PR has the details of the stuff in master. Or failing that where in the source or examples should I look to see how things are shaping up. |
It's #419. |
A few weeks ago I made a suggestion to @rgrinberg about how
bisect_ppx
and similar problems might be addressed. He suggested that I make an issue containing the suggestion, so that it is at least written down somewhere.The problem of
bisect_ppx
is that you want a single place to change a setting across all the libraries in a single project. That does not fit well into jbuilder's current model. In order to make sure that mutiple packages can be built together in a single workspace, jbuilder insists that thejbuild
file for a library contains all the details of how to build it -- whereas withbisect_ppx
we want to change the build instructions of multiple libraries from a single location.My suggestion is that, if you want to have builds also depend on some things external from the jbuild files, then you should make those things a first-class notion. So:
We add some explicit notion of "environment" to jbuilder and a way for plugins and the implementations of jbuild constructs to query it for information.
The implementations of things like the
library
construct can look up things like the default preprocessors and the default warnings from the environment.Allow the environment to be set using a
jbuild.env
file containing sexps that define entries in the environment. I suggest that there should be a singlejbuild.env
for a "scope" and that it should be required to be at the root of the scope (i.e. next to a.opam
file). A more relaxed scheme could be supported if there is demand for it.Now that we have a sexp file representing the environment, just like we have a sexp file representing the build instructions, we can extend the plugin mechanism (see here) to work on these files as well.
With these changes you could write:
in your
jbuild.env
to add a default warning and to turn on bisecting. The(bisect:on)
part would use a function of typeSexp.t -> Environment.t
provided by thebisect
plugin to make the required changes to the environment to turn on bisecting.The text was updated successfully, but these errors were encountered: