Skip to content

Commit 93f9532

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

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

bin/common.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,11 @@ module Builder = struct
865865
=
866866
Options_implied_by_dash_p.term
867867
and+ x =
868+
let doc = "Cross-compile using this toolchain." in
868869
Arg.(
869870
value
870871
& opt (some Arg.context_name) None
871-
& info [ "x" ] ~docs ~doc:(Some "Cross-compile using this toolchain."))
872+
& info [ "x" ] ~docs ~doc:(Some doc) ~env:(Cmd.Env.info ~doc "DUNE_CROSS_TARGET"))
872873
and+ target_exec =
873874
let doc =
874875
"Wrapper command for running target binaries when cross-compiling. Format: \

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,29 @@ Build with -x test_toolchain and environment variable DUNE_TARGET_EXEC=test_tool
137137
---- HELLO END ----
138138

139139

140+
Build with environment variables DUNE_CROSS_TARGET=test_toolchain and DUNE_TARGET_EXEC=test_toolchain=test_toolchain_wrapper.sh
141+
(should cross compile and use target binary ./hello.exe wrapped with the wrapper)
142+
143+
$ PATH="$PWD/bin:$PATH" DUNE_CROSS_TARGET=test_toolchain DUNE_TARGET_EXEC=test_toolchain=test_toolchain_wrapper.sh dune build @runhello --force
144+
---- HELLO START ----
145+
Hello from OCaml!
146+
PWD: $TESTCASE_ROOT/_build/default
147+
Args: ./hello.exe --hello-arg1 --hello-arg2
148+
---- HELLO END ----
149+
150+
=== TEST_TOOLCHAIN WRAPPER START ===
151+
WRAPPER PWD: $TESTCASE_ROOT/_build/default.test_toolchain
152+
WRAPPER executing: $TESTCASE_ROOT/_build/default.test_toolchain/hello.exe --hello-arg1 --hello-arg2
153+
=== WRAPPER EXEC ===
154+
---- HELLO START ----
155+
Hello from OCaml!
156+
PWD: $TESTCASE_ROOT/_build/default.test_toolchain
157+
Args: $TESTCASE_ROOT/_build/default.test_toolchain/hello.exe --hello-arg1 --hello-arg2
158+
---- HELLO END ----
159+
160+
161+
162+
140163

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

0 commit comments

Comments
 (0)