-
Notifications
You must be signed in to change notification settings - Fork 470
select stanza #397
Copy link
Copy link
Open
Labels
help wantedContributors are welcomed to submit a PR to solve the issueContributors are welcomed to submit a PR to solve the issueruleInternal dune rulesInternal dune rules
Description
It's common to have to choose between several files and/or dependencies depending on some external parameters, such as the version of the compiler, the OS, etc...
Currently one can select between several files and dependencies depending on the existence or non-existence of libraries using a (select ...) form in library dependencies:
(library
((name foo)
(libraries (bar (select file.ml from
(unix -> foo.unix.ml)
(!unix -> foo.no-unix.ml))))))The current solution is:
- limited: one can only dispatch using the fact that some libraries exist or not
- not very nice: it feel weird to do file selection in the middle of a dependency list
The idea would be to introduce a select stanza to support all kind of selection between several files and dependencies.
I haven't though about the syntax in detail, but something like this could do:
(select
((files (file.ml))
(choices
((< ${ocaml_version} 4.05) (file.404.ml))
((>= ${ocaml_version} 4.05) (file.405.ml)))))
(select
((files (backend.ml))
(choices
((= ${os} win32) (backend.win32.ml))
(true (backend.others.ml)))))When we choose between several dependencies, the select stanza would be named and the name would be used as a library name:
(select
((files (x.ml))
(public_name foo.backend)
(choices
((lib-dep unix) (x.unix.ml))
(true (x.no-unix.ml)))))
(library
((name foo)
(libraries (bar foo.backend))))Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedContributors are welcomed to submit a PR to solve the issueContributors are welcomed to submit a PR to solve the issueruleInternal dune rulesInternal dune rules