Quantcast
Channel: OCaml - Topics tagged dune
Viewing all articles
Browse latest Browse all 520

Is it possible to refer to the current display mode in a dune rule?

$
0
0

A subdirectory of my dune project contains C++ code that is compiled through cmake. This can be done easily via a custom rule, and I can translate dune’s profile into cmake’s BUILD_TYPE with an appropriate env stanza, as in:

(env
 (dev (env-vars (CMAKE_BUILD_TYPE "Debug")))
 (release (env-vars (CMAKE_BUILD_TYPE "Release")))
)

(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)
      )
    )
  )
)

However, I’d like to set a VERBOSE environment variable for the cmake runs if dune display mode is itself verbose, in order to see the actual options given to the C++ compiler. I could of course set another profile for that, but this has some drawbacks:

  • I would in fact need two profiles, dev-verbose and release-verbose
  • I’d prefer not having to write dune build --profile dev-verbose --display verbose

Thus, I’d like to know if it’s possible to set an environment variable in a user action conditionally on the chosen display mode. I haven’t found anything in dune’s documentation yet.

5 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 520

Trending Articles