Refer to the Display mode inside an action
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
NB: this feature request stems from a post on discuss.ocaml.org.
Desired Behavior
It would be interesting to have a way to refer to the display mode given to dune (e.g. through dune --display=verbose) in the dune file, notably to enable verbose options on user-defined actions. This could take a form similar to the env stanza, or even being part of it, with a special keyword to indicate that the corresponding form selects a display mode instead of a profile
Example
In the following example, we want to use we use cmake to compile a C++ library whose sources resides in my_cxx_dir. For that, two env forms select a CMAKE_BUILD_TYPE for cmake that corresponds to dune's profile. The proposed third form (whose syntax is very much open to debate) would allow adding an environment variable VERBOSE when --display=verbose is passed to dune (or (display verbose) is present in dune-config). This would then instruct cmake itself to be verbose.
(env
(dev (env-vars (CMAKE_BUILD_TYPE "Debug")))
(release (env-vars (CMAKE_BUILD_TYPE "Release")))
((display verbose) (env-vars (VERBOSE "ON")))
)
(data_only_dirs my_cxx_dir)
(rule
(deps
(source_tree my_cxx_dir)
)
(targets my_cxx_lib.so)
(action
(no-infer
(progn
(echo "C++ build setup" "\n")
(run cmake -S my_cxx_dir -B build -DCMAKE_BUILD_TYPE=%{env:CMAKE_BUILD_TYPE=Release})
(echo "Generating clang plugin and demangler" "\n")
(run cmake --build build)
(copy my_cxx_dir/my_cxx_lib.so my_cxx_lib.so)
)
)
)
)
As profile and display are two orthogonal concepts, it would of course make sense to split the env stanza in two (e.g. (env (profile (dev (...)) ...) (display (verbose (...)) ...)) or introduce e.g. a display-env stanza. Again, I don't have any strong opinion about the actual syntax.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked discuss.ocaml.org post and the existing dune env stanza, display mode, and profile configuration concepts described in the issue. Work out and document a settled syntax for selecting display modes, then verify that user-defined actions can receive the requested verbose setting as shown in the CMake example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, ocaml
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100