From 084030b085d9cb586ca4d043bd530d54e1e4b724 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 24 Jan 2024 08:44:34 -0600 Subject: [PATCH] Support cross-compile install of B2. Because we use the bootstrap exe for the install it was not possible to cross-compile install B2. This change dynamically chooses which b2.exe to install based on target-os and host-os. When in a cross-compile context, i.e. host-os != target-os, the b2 installed is built from source (and using target-os) instead of using the bootstrap exe. fixes #358 --- Jamroot.jam | 25 +++++++++++++++++-------- doc/src/history.adoc | 2 ++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Jamroot.jam b/Jamroot.jam index f96fcd4a21..afe7421c71 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -1,4 +1,4 @@ -# Copyright 2019 Rene Rivera +# Copyright 2019-2024 Rene Rivera # Copyright 2017 Steven Watanabe # Copyright 2016 Vladimir Prus # Copyright 2017 Edward Diener @@ -13,7 +13,6 @@ import errors ; import feature ; import indirect ; import os ; -# import package ; import path ; import set ; import stage : add-install-dir ; @@ -130,7 +129,7 @@ obj jamgram.obj explicit jamgram.obj ; local b2_src = - [ glob src/engine/*.cpp src/engine/modules/*.cpp : + [ glob src/engine/*.cpp : src/engine/*nt.cpp src/engine/*unix.cpp src/engine/*vms.cpp src/engine/yyacc.cpp src/engine/mkjambase.cpp src/engine/check_*.cpp @@ -180,15 +179,25 @@ add-install-dir b2bindir-portable : : b2prefix-portable ; add-install-dir b2coredir-portable : .b2 : b2prefix-portable ; add-install-dir b2examplesdir-portable : .b2/examples : b2prefix-portable ; -local ext = "" ; -if [ os.on-windows ] || [ os.on-vms ] +rule b2-exe ( props * ) { - ext = ".exe" ; + local target-os = [ feature.get-values : $(props) ] ; + local host-os = [ feature.get-values : $(props) ] ; + if $(target-os) != $(host-os) + { + return b2 ; + } + else if $(target-os) in windows vms + { + return src/engine/b2.exe ; + } + return src/engine/b2 ; } install b2-engine - : $(SELF)/src/engine/b2$(ext) - : standard:(b2bindir-standard) + : + : @b2-exe + standard:(b2bindir-standard) portable:(b2bindir-portable) ; explicit b2-engine ; diff --git a/doc/src/history.adoc b/doc/src/history.adoc index 1146aad184..0d56386dad 100644 --- a/doc/src/history.adoc +++ b/doc/src/history.adoc @@ -9,6 +9,8 @@ * Fix `import-search` failing to find imports on Windows bacause of incorrect native vs. non-native path handling. -- _René Ferdinand Rivera Morell_ +* Support cross-compile install of B2, using `target-os=xyz`. + -- _René Ferdinand Rivera Morell_ == Version 5.0.0