Skip to content

Commit f7fb8df

Browse files
committed
Add DUNE_TARGET_EXEC
Signed-off-by: Romain Beauxis <[email protected]>
1 parent ffb11a4 commit f7fb8df

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

bin/common.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,12 @@ module Builder = struct
877877
Arg.(
878878
value
879879
& opt (some string) None
880-
& info [ "target-exec" ] ~docs ~docv:"TOOLCHAIN=CMD" ~doc:(Some doc))
880+
& info
881+
[ "target-exec" ]
882+
~docs
883+
~docv:"TOOLCHAIN=CMD"
884+
~doc:(Some doc)
885+
~env:(Cmd.Env.info ~doc "DUNE_TARGET_EXEC"))
881886
and+ build_dir =
882887
let doc = "Specified build directory. _build if unspecified" in
883888
Arg.(

test/blackbox-tests/test-cases/custom-cross-compilation/target-exec.t

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,27 @@ Build with -x test_toolchain and --target-exec test_toolchain=test_toolchain_wra
116116
Args: $TESTCASE_ROOT/_build/default.test_toolchain/hello.exe --hello-arg1 --hello-arg2
117117
---- HELLO END ----
118118

119+
Build with -x test_toolchain and environment variable DUNE_TARGET_EXEC=test_toolchain=test_toolchain_wrapper.sh
120+
(should use target binary ./hello.exe wrapped with the wrapper)
121+
122+
$ PATH="$PWD/bin:$PATH" DUNE_TARGET_EXEC=test_toolchain=test_toolchain_wrapper.sh dune build @runhello -x test_toolchain --force
123+
---- HELLO START ----
124+
Hello from OCaml!
125+
PWD: $TESTCASE_ROOT/_build/default
126+
Args: ./hello.exe --hello-arg1 --hello-arg2
127+
---- HELLO END ----
128+
129+
=== TEST_TOOLCHAIN WRAPPER START ===
130+
WRAPPER PWD: $TESTCASE_ROOT/_build/default.test_toolchain
131+
WRAPPER executing: $TESTCASE_ROOT/_build/default.test_toolchain/hello.exe --hello-arg1 --hello-arg2
132+
=== WRAPPER EXEC ===
133+
---- HELLO START ----
134+
Hello from OCaml!
135+
PWD: $TESTCASE_ROOT/_build/default.test_toolchain
136+
Args: $TESTCASE_ROOT/_build/default.test_toolchain/hello.exe --hello-arg1 --hello-arg2
137+
---- HELLO END ----
138+
139+
119140

120141
Build with -x test_toolchain and --target-exec with arguments
121142
(should use target binary ./hello.exe wrapped with the wrapper)

0 commit comments

Comments
 (0)