simplify Jamfile by determining whether to use boost from source or from system installed version based on the BOOST_ROOT environment variable. This removes the build feature boost=source/boost=system

This commit is contained in:
arvidn 2015-08-08 19:18:05 -04:00
parent 3963d47385
commit a854fed12b
8 changed files with 79 additions and 97 deletions

140
Jamfile
View File

@ -13,14 +13,49 @@ BOOST_ROOT = [ modules.peek : BOOST_ROOT ] ;
CXXFLAGS = [ modules.peek : CXXFLAGS ] ;
LDFLAGS = [ modules.peek : LDFLAGS ] ;
ECHO "BOOST_ROOT =" $(BOOST_ROOT) ;
ECHO "CXXFLAGS =" $(CXXFLAGS) ;
ECHO "LDFLAGS =" $(LDFLAGS) ;
ECHO "OS =" [ os.name ] ;
if $(BOOST_ROOT)
{
ECHO "building boost from source directory: " $(BOOST_ROOT) ;
use-project /boost : $(BOOST_ROOT) ;
alias boost_chrono : /boost/chrono//boost_chrono : : : <include>$(BOOST_ROOT) ;
alias boost_system : /boost/system//boost_system : : : <include>$(BOOST_ROOT) ;
alias boost_random : /boost/random//boost_random : : : <include>$(BOOST_ROOT) ;
}
else
{
local boost-lib-search-path =
<search>/opt/local/lib
<search>/usr/lib
<search>/usr/local/lib
<search>/sw/lib
<search>/usr/g++/lib
;
local boost-include-path =
<include>/opt/local/include
<include>/usr/local/include
<include>/usr/sfw/include
;
# the names are decorated in MacPorts
lib boost_chrono : : <target-os>darwin <name>boost_chrono-mt $(boost-lib-search-path)
: : $(boost-include-path) ;
lib boost_system : : <target-os>darwin <name>boost_system-mt $(boost-lib-search-path)
: : $(boost-include-path) ;
lib boost_random : : <target-os>darwin <name>boost_random-mt $(boost-lib-search-path)
: : $(boost-include-path) ;
lib boost_chrono : : <name>boost_chrono $(boost-lib-search-path)
: : $(boost-include-path) ;
lib boost_system : : <name>boost_system $(boost-lib-search-path)
: : $(boost-include-path) ;
lib boost_random : : <name>boost_random $(boost-lib-search-path)
: : $(boost-include-path) ;
}
VERSION = 1.1.0 ;
@ -171,71 +206,43 @@ rule linking ( properties * )
result += <linkflags>-export-dynamic <linkflags>-rdynamic ;
}
if <boost>source in $(properties)
if <boost-link>static in $(properties)
{
if <boost-link>static in $(properties)
if <link>shared in $(properties)
{
if <link>shared in $(properties)
{
# if libtorrent is being built as a shared library
# but we're linking against boost statically, we still
# need to make boost think it's being built as a shared
# library, so that it properly exports its symbols
result += <define>BOOST_ALL_DYN_LINK ;
result += <library>/boost/system//boost_system/<link>static/<define>BOOST_ALL_DYN_LINK ;
result += <library>/boost/chrono//boost_chrono/<link>static/<define>BOOST_ALL_DYN_LINK ;
result += <library>/boost/random//boost_random/<link>static/<define>BOOST_ALL_DYN_LINK ;
}
else
{
result += <library>/boost/system//boost_system/<link>static ;
result += <library>/boost/chrono//boost_chrono/<link>static ;
result += <library>/boost/random//boost_random/<link>static ;
}
if <toolset>gcc in $(properties)
&& ! <target-os>windows in $(properties)
&& <link>shared in $(properties)
{
result += <fpic>on ;
}
# if libtorrent is being built as a shared library
# but we're linking against boost statically, we still
# need to make boost think it's being built as a shared
# library, so that it properly exports its symbols
result += <define>BOOST_ALL_DYN_LINK ;
result += <library>boost_system/<link>static/<define>BOOST_ALL_DYN_LINK ;
result += <library>boost_chrono/<link>static/<define>BOOST_ALL_DYN_LINK ;
result += <library>boost_random/<link>static/<define>BOOST_ALL_DYN_LINK ;
}
else
{
result += <library>/boost/system//boost_system/<link>shared ;
result += <library>/boost/chrono//boost_chrono/<link>shared ;
result += <library>/boost/random//boost_random/<link>shared ;
}
result += <include>$(BOOST_ROOT)
<define>BOOST_ALL_NO_LIB
<define>BOOST_MULTI_INDEX_DISABLE_SERIALIZATION
;
}
else
{
if <boost-link>static in $(properties)
{
result += <library>boost_system/<link>static ;
result += <library>boost_chrono/<link>static ;
result += <library>boost_random/<link>static ;
}
else
if <toolset>gcc in $(properties)
&& ! <target-os>windows in $(properties)
&& <link>shared in $(properties)
{
result += <library>boost_system/<link>shared ;
result += <library>boost_chrono/<link>shared ;
result += <library>boost_random/<link>shared ;
result += <fpic>on ;
}
# on mac the boost headers are installed in
# a directory that isn't automatically accessable
# on open indiana, boost is install at /usr/g++/include
result += <include>/opt/local/include/boost-1_35
<include>/opt/local/include
<include>/usr/g++/include
;
}
else
{
result += <library>boost_system/<link>shared ;
result += <library>boost_chrono/<link>shared ;
result += <library>boost_random/<link>shared ;
}
result += <define>BOOST_ALL_NO_LIB
<define>BOOST_MULTI_INDEX_DISABLE_SERIALIZATION
;
return $(result) ;
}
@ -486,7 +493,6 @@ feature.compose <character-set>unicode : <define>_UNICODE <define>UNICODE ;
feature deprecated-functions : on off : composite propagated link-incompatible ;
feature.compose <deprecated-functions>off : <define>TORRENT_NO_DEPRECATE ;
feature boost : system source : link-incompatible propagated ;
feature boost-link : static shared : propagated composite ;
feature debug-iterators : off on : composite propagated link-incompatible ;
@ -543,26 +549,6 @@ lib gcc : : <name>gcc <link>static ;
# when using iconv
lib libiconv : : <name>iconv <link>shared <search>/usr/local/lib ;
local boost-library-search-path =
<search>/opt/local/lib
<search>/usr/lib
<search>/usr/local/lib
<search>/sw/lib
<search>/usr/g++/lib
;
lib boost_system : : <target-os>darwin <name>boost_system-mt $(boost-library-search-path) ;
lib boost_system : : <target-os>solaris <name>boost_system $(boost-library-search-path) ;
lib boost_system : : <name>boost_system ;
lib boost_chrono : : <target-os>darwin <name>boost_chrono-mt $(boost-library-search-path) ;
lib boost_chrono : : <target-os>solaris <name>boost_chrono $(boost-library-search-path) ;
lib boost_chrono : : <name>boost_chrono ;
lib boost_random : : <target-os>darwin <name>boost_random-mt $(boost-library-search-path) ;
lib boost_random : : <target-os>solaris <name>boost_random $(boost-library-search-path) ;
lib boost_random : : <name>boost_random ;
# openssl on linux/bsd/macos etc.
lib gcrypt : : <name>gcrypt <link>shared <search>/opt/local/lib ;
lib z : : <link>shared <name>z <search>/usr/lib ;
@ -748,8 +734,8 @@ local usage-requirements =
<toolset>msvc,<variant>release:<linkflags>/OPT:ICF=5
<toolset>msvc,<variant>release:<linkflags>/OPT:REF
<boost>system:<cxxflags>$(CXXFLAGS)
<boost>system:<linkflags>$(LDFLAGS)
<cxxflags>$(CXXFLAGS)
<linkflags>$(LDFLAGS)
# this works around a bug in asio in boost-1.39
<define>BOOST_ASIO_HASH_MAP_BUCKETS=1021
<tag>@tag
@ -775,7 +761,7 @@ lib torrent
<conditional>@building
<conditional>@warnings
<boost>system:<cxxflags>$(CXXFLAGS)
<cxxflags>$(CXXFLAGS)
# disable bogus deprecation warnings on msvc8
<toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE

View File

@ -42,4 +42,4 @@ cache:
- C:\OpenSSL-Win32
build_script:
- cd %ROOT_DIRECTORY%\test
- b2.exe -j2 %compiler% boost=source variant=%variant% link=shared linkflags=%linkflags% include="C:\\OpenSSL-Win32\\include" warnings=off --abbreviate-paths
- b2.exe -j2 %compiler% variant=%variant% link=shared linkflags=%linkflags% include="C:\\OpenSSL-Win32\\include" warnings=off --abbreviate-paths

View File

@ -71,7 +71,7 @@ if '--bjam' in sys.argv or ldflags == None or extra_cmd == None:
parallel_builds = ' -j%d' % multiprocessing.cpu_count()
# build libtorrent using bjam and build the installer with distutils
cmdline = 'b2 boost=source libtorrent-link=static boost-link=static release optimization=space stage_module --abbreviate-paths' + toolset + parallel_builds
cmdline = 'b2 libtorrent-link=static boost-link=static release optimization=space stage_module --abbreviate-paths' + toolset + parallel_builds
print(cmdline)
if os.system(cmdline) != 0:
print('build failed')

View File

@ -155,11 +155,15 @@ Then the only thing left is simply to invoke ``bjam``. If you want to specify
a specific toolset to use (compiler) you can just add that to the commandline.
For example::
bjam msvc-7.1 boost=source
bjam gcc-3.3 boost=source
bjam darwin-4.0 boost=source
bjam msvc-7.1
bjam gcc-3.3
bjam darwin-4.0
If you're building against a system installed boost, specify ``boost=system``.
.. note::
If the environment variable ``BOOST_ROOT`` is not set, the jamfile will
attempt to link against "installed" boost libraries. i.e. assume the headers
and libraries are available in default search paths.
To build different versions you can also just add the name of the build
variant. Some default build variants in BBv2 are ``release``, ``debug``,
@ -173,7 +177,7 @@ can set the ``runtime-link`` feature on the commandline, either to ``shared``
or ``static``. Most operating systems will only allow linking shared against
the runtime, but on windows you can do both. Example::
bjam msvc-7.1 link=static runtime-link=static boost=source
bjam msvc-7.1 link=static runtime-link=static
.. note::
@ -236,14 +240,6 @@ Build features:
+--------------------------+----------------------------------------------------+
| boost build feature | values |
+==========================+====================================================+
| ``boost`` | * ``system`` - default. Tells the Jamfile that |
| | boost is installed and should be linked against |
| | the system libraries. |
| | * ``source`` - Specifies that boost is to be built |
| | from source. The environment variable |
| | ``BOOST_ROOT`` must be defined to point to the |
| | boost directory. |
+--------------------------+----------------------------------------------------+
| ``boost-link`` | * ``static`` - links statically against the boost |
| | libraries. |
| | * ``shared`` - links dynamically against the boost |

View File

@ -67,7 +67,7 @@ build variants, see `libtorrent build options`_.
For example::
$ bjam dht-support=on boost=source release link=static
$ bjam dht-support=on link=static
On Mac OS X, this will produce the following python module::

View File

@ -1,5 +1,5 @@
REM this is just to get libtorrent built
bjam -j8 msvc-12.0 boost=source invariant-checks=off asserts=off link=shared boost-link=shared test_primitives linkflags=/profile deprecated-functions=off
bjam -j8 msvc-12.0 invariant-checks=off asserts=off link=shared boost-link=shared test_primitives linkflags=/profile deprecated-functions=off
Vsinstr -coverage ..\bin\msvc-12.0\debug\asserts-off\boost-link-shared\boost-source\debug-iterators-on\deprecated-functions-off\export-extra-on\invariant-checks-off\threading-multi\torrent.dll @vsinstr_excludes.rsp
@ -13,7 +13,7 @@ set path=%path%;c:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\P
Start vsperfmon -coverage -output:test.coverage
REM Now we run all the unit tests to record test coverage
bjam -j8 msvc-12.0 boost=source invariant-checks=off asserts=off link=shared boost-link=shared linkflags=/profile deprecated-functions=off
bjam -j8 msvc-12.0 invariant-checks=off asserts=off link=shared boost-link=shared linkflags=/profile deprecated-functions=off
vsperfcmd -shutdown

View File

@ -203,7 +203,7 @@ def main(argv):
test_dirs = []
build_dirs = []
configs = []
options = ['boost=source', 'preserve-test-targets=on']
options = ['preserve-test-targets=on']
time_limit = 1200
for arg in argv:

View File

@ -13,7 +13,7 @@ function run_test {
cd test
set +e
bjam asserts=off invariant-checks=off link=static boost=source deprecated-functions=off debug-iterators=off test-coverage=on picker-debugging=off -j4 $1
bjam asserts=off invariant-checks=off link=static deprecated-functions=off debug-iterators=off test-coverage=on picker-debugging=off -j4 $1
set -e
cd ..