Make all variables accessible in jbuild files
This commit is contained in:
parent
21a980a5d1
commit
cc845e5fdb
|
@ -694,8 +694,13 @@ Jbuilder supports the following variables:
|
||||||
- ``null`` is ``/dev/null`` on Unix or ``nul`` on Windows
|
- ``null`` is ``/dev/null`` on Unix or ``nul`` on Windows
|
||||||
- ``ext_obj``, ``ext_asm``, ``ext_lib``, ``ext_dll`` and ``ext_exe``
|
- ``ext_obj``, ``ext_asm``, ``ext_lib``, ``ext_dll`` and ``ext_exe``
|
||||||
are the file extension used for various artifacts
|
are the file extension used for various artifacts
|
||||||
- ``bytecomp_c_libraries`` and ``native_c_libraries`` are list of C libraries
|
- ``ocaml-config:v`` for every variable ``v`` in the output of
|
||||||
used by the OCaml runtimes
|
``ocamlc -config``. Note that output Jbuilder processes the output
|
||||||
|
of ``ocamlc -config`` in order to make it a bit more stable across
|
||||||
|
versions, so the exact set of variables accessible this way might
|
||||||
|
not be exactly the same as what you can see in the output of
|
||||||
|
``ocamlc -config``. In particular, variables added in new versions
|
||||||
|
of OCaml needs to be registered in Jbuilder before they can be used
|
||||||
|
|
||||||
In addition, ``(action ...)`` fields support the following special variables:
|
In addition, ``(action ...)`` fields support the following special variables:
|
||||||
|
|
||||||
|
|
|
@ -144,32 +144,43 @@ let create
|
||||||
let strings l = Strings (l , Split) in
|
let strings l = Strings (l , Split) in
|
||||||
let string s = Strings ([s], Split) in
|
let string s = Strings ([s], Split) in
|
||||||
let path p = Paths ([p], Split) in
|
let path p = Paths ([p], Split) in
|
||||||
[ "-verbose" , Strings ([] (*"-verbose";*), Concat)
|
let vars =
|
||||||
; "CPP" , strings (context.c_compiler :: cflags @ ["-E"])
|
[ "-verbose" , Strings ([] (*"-verbose";*), Concat)
|
||||||
; "PA_CPP" , strings (context.c_compiler :: cflags
|
; "CPP" , strings (context.c_compiler :: cflags @ ["-E"])
|
||||||
@ ["-undef"; "-traditional"; "-x"; "c"; "-E"])
|
; "PA_CPP" , strings (context.c_compiler :: cflags
|
||||||
; "CC" , strings (context.c_compiler :: cflags)
|
@ ["-undef"; "-traditional";
|
||||||
; "CXX" , strings (context.c_compiler :: cxx_flags)
|
"-x"; "c"; "-E"])
|
||||||
; "ocaml_bin" , path context.ocaml_bin
|
; "CC" , strings (context.c_compiler :: cflags)
|
||||||
; "OCAML" , path context.ocaml
|
; "CXX" , strings (context.c_compiler :: cxx_flags)
|
||||||
; "OCAMLC" , path context.ocamlc
|
; "ocaml_bin" , path context.ocaml_bin
|
||||||
; "OCAMLOPT" , path ocamlopt
|
; "OCAML" , path context.ocaml
|
||||||
; "ocaml_version" , string context.version_string
|
; "OCAMLC" , path context.ocamlc
|
||||||
; "ocaml_where" , string (Path.to_string context.stdlib_dir)
|
; "OCAMLOPT" , path ocamlopt
|
||||||
; "ARCH_SIXTYFOUR" , string (string_of_bool context.arch_sixtyfour)
|
; "ocaml_version" , string context.version_string
|
||||||
; "MAKE" , make
|
; "ocaml_where" , string (Path.to_string context.stdlib_dir)
|
||||||
; "null" , string (Path.to_string Config.dev_null)
|
; "ARCH_SIXTYFOUR" , string (string_of_bool context.arch_sixtyfour)
|
||||||
; "ext_obj" , string context.ext_obj
|
; "MAKE" , make
|
||||||
; "ext_asm" , string context.ext_asm
|
; "null" , string (Path.to_string Config.dev_null)
|
||||||
; "ext_lib" , string context.ext_lib
|
; "ext_obj" , string context.ext_obj
|
||||||
; "ext_dll" , string context.ext_dll
|
; "ext_asm" , string context.ext_asm
|
||||||
; "ext_exe" , string context.ext_exe
|
; "ext_lib" , string context.ext_lib
|
||||||
; "bytecomp_c_libraries", strings context.bytecomp_c_libraries
|
; "ext_dll" , string context.ext_dll
|
||||||
; "native_c_libraries" , strings context.bytecomp_c_libraries
|
; "ext_exe" , string context.ext_exe
|
||||||
]
|
]
|
||||||
|> String_map.of_list
|
in
|
||||||
|> function
|
let vars =
|
||||||
| Ok x -> x
|
vars @
|
||||||
|
List.map (Ocaml_config.to_list context.ocaml_config) ~f:(fun (k, v) ->
|
||||||
|
("ocaml-config:" ^ k,
|
||||||
|
match (v : Ocaml_config.Value.t) with
|
||||||
|
| Bool x -> string (string_of_bool x)
|
||||||
|
| Int x -> string (string_of_int x)
|
||||||
|
| String x -> string x
|
||||||
|
| Words x -> strings x
|
||||||
|
| Prog_and_args x -> strings (x.prog :: x.args)))
|
||||||
|
in
|
||||||
|
match String_map.of_list vars with
|
||||||
|
| Ok x -> x
|
||||||
| Error _ -> assert false
|
| Error _ -> assert false
|
||||||
in
|
in
|
||||||
{ context
|
{ context
|
||||||
|
|
Loading…
Reference in New Issue