Ergonomic, lightweight conditional compilation through attributes inspired by Rust's cfg macro.
Config implements the [@@config] annotation, to conditionally compile modules. You can use a small boolean language to check for conditions including some built-in ones and environment variables.
Currently includes/detects the following platforms:
And the following architectures:
opam install configAnd add it to your dune files:
(library
(name my_lib)
(preprocess (pps config.ppx)))And tag your modules with the @@config attribute:
module A = A_unix [@@config any(target_os = "macos", target_os = "linux")]
module A = A_win32 [@@config any(target_os = "windows")]Currently config relies on C preprocessor definitions to detect different platforms and architectures. They are straightforward to add by extending the file ./config/config_stubs.cl. In there :
caml_config_target_os function to include your OS.caml_config_target_arch function to include your architecture.