-
Notifications
You must be signed in to change notification settings - Fork 470
Allow more variables for enabled_if #4455
Copy link
Copy link
Closed
Milestone
Description
enabled_if is currently pretty limited. In particular, it is not possible to enable a library depending on run-time configuration as, for instance, determined by dune-configurator.
In the case at hand, we want to optionally compile a library that implements support for OSS sound output. We have this configuration binary:
module C = Configurator.V1
let oss_test = {|
#include <sys/soundcard.h>
int main() {
return 0;
}
|}
let () =
C.main ~name:"liquidsoap" (fun c ->
let oc = open_out "oss_enabled" in
output_string oc (string_of_bool (C.c_test oss_test));
close_out oc)Then this dune configuration:
(library
(name liquidsoap_oss)
(libraries liquidsoap_core)
(enabled_if (= "true" %{read:oss_enabled}))
(library_flags -linkall)
(optional)
(foreign_stubs
(language c)
(names oss_io_c))
(modules oss_io))
But this is currently impossible:
File "src/lib/dune", line 472, characters 25-42:
472 | (enabled_if (= "true" %{read:oss_enabled}))
^^^^^^^^^^^^^^^^^
Error: Only architecture, system, model, os_type, ccomp_type, profile,
ocaml_version and context_name variables are allowed in this 'enabled_if'
field. If you think that read should also be allowed, please file an issue
about it.Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels