Skip to content

Commit

Permalink
Support cross-compile install of B2.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
grafikrobot committed Jan 24, 2024
1 parent ac4ab7e commit 084030b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 17 additions & 8 deletions Jamroot.jam
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,7 +13,6 @@ import errors ;
import feature ;
import indirect ;
import os ;
# import package ;
import path ;
import set ;
import stage : add-install-dir ;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <target-os> : $(props) ] ;
local host-os = [ feature.get-values <host-os> : $(props) ] ;
if $(target-os) != $(host-os)
{
return <source>b2 ;
}
else if $(target-os) in windows vms
{
return <source>src/engine/b2.exe ;
}
return <source>src/engine/b2 ;
}

install b2-engine
: $(SELF)/src/engine/b2$(ext)
: <b2-install-layout>standard:<location>(b2bindir-standard)
:
: <conditional>@b2-exe
<b2-install-layout>standard:<location>(b2bindir-standard)
<b2-install-layout>portable:<location>(b2bindir-portable)
;
explicit b2-engine ;
Expand Down
2 changes: 2 additions & 0 deletions doc/src/history.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 084030b

Please sign in to comment.