Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changes/12236.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add support for %{ocaml-config:ox} (#12236, @jonludlam)
12 changes: 10 additions & 2 deletions src/ocaml-config/ocaml_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ type t =
; natdynlink_supported : bool
; supports_shared_libraries : bool
; windows_unicode : bool
; ox : bool
}

let version t = t.version
Expand Down Expand Up @@ -190,6 +191,7 @@ let cmt_magic_number t = t.cmt_magic_number
let natdynlink_supported t = t.natdynlink_supported
let supports_shared_libraries t = t.supports_shared_libraries
let windows_unicode t = t.windows_unicode
let ox t = t.ox

let to_list
{ version = _
Expand Down Expand Up @@ -244,6 +246,7 @@ let to_list
; natdynlink_supported
; supports_shared_libraries
; windows_unicode
; ox
}
: (string * Value.t) list
=
Expand Down Expand Up @@ -298,6 +301,7 @@ let to_list
; "natdynlink_supported", Bool natdynlink_supported
; "supports_shared_libraries", Bool supports_shared_libraries
; "windows_unicode", Bool windows_unicode
; "ox", Bool ox
]
;;

Expand Down Expand Up @@ -357,6 +361,7 @@ let by_name
; natdynlink_supported
; supports_shared_libraries
; windows_unicode
; ox
}
name
: Value.t option
Expand Down Expand Up @@ -413,6 +418,7 @@ let by_name
| "natdynlink_supported" -> Some (Bool natdynlink_supported)
| "supports_shared_libraries" -> Some (Bool supports_shared_libraries)
| "windows_unicode" -> Some (Bool windows_unicode)
| "ox" -> Some (Bool ox)
| _ -> None
;;

Expand Down Expand Up @@ -640,13 +646,14 @@ let make vars =
let stdlib = Path.external_ (Path.External.of_string standard_library) in
Path.relative stdlib "Makefile.config"
in
let vars = Vars.load_makefile_config file in
let ox = get_bool vars "ox" in
let makefile_vars = Vars.load_makefile_config file in
let module Getters =
Vars.Getters (struct
let origin = Origin.Makefile_config file
end)
in
let supports_shared_libraries = get_bool vars "SUPPORTS_SHARED_LIBRARIES" in
let supports_shared_libraries = get_bool makefile_vars "SUPPORTS_SHARED_LIBRARIES" in
{ version
; version_string
; standard_library_default
Expand Down Expand Up @@ -699,6 +706,7 @@ let make vars =
; natdynlink_supported
; supports_shared_libraries
; windows_unicode
; ox
}
with
| t -> Ok t
Expand Down
1 change: 1 addition & 0 deletions src/ocaml-config/ocaml_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ val cmt_magic_number : t -> string
val natdynlink_supported : t -> bool
val supports_shared_libraries : t -> bool
val windows_unicode : t -> bool
val ox : t -> bool

(** {1 Values} *)

Expand Down
14 changes: 14 additions & 0 deletions test/blackbox-tests/test-cases/ocaml-config-ox.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Check that %{ocaml-config:ox} doesn't fail. This test does not explicitly
check the value of the parameter.

$ cat > "dune-project" <<EOF
> (lang dune 1.0)
> EOF

$ cat > "dune" <<EOF
> (rule
> (targets x)
> (action (with-stdout-to %{targets} (echo %{ocaml-config:ox}))))
> EOF

$ dune build x
15 changes: 15 additions & 0 deletions test/blackbox-tests/test-cases/oxcaml/ocaml-config-ox-true.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Check that %{ocaml-config:ox} works and returns true

$ cat > "dune-project" <<EOF
> (lang dune 1.0)
> EOF

$ cat > "dune" <<EOF
> (rule
> (targets x)
> (action (with-stdout-to %{targets} (echo %{ocaml-config:ox}))))
Comment thread
Alizter marked this conversation as resolved.
> EOF

$ dune build x
$ cat _build/default/x
true
Loading