From a854fed12be2443f4b6e90f4b4db98e900b5051d Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 8 Aug 2015 19:18:05 -0400 Subject: [PATCH] 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 --- Jamfile | 140 +++++++++++++++++-------------------- appveyor.yml | 2 +- bindings/python/setup.py | 2 +- docs/building.rst | 22 +++--- docs/python_binding.rst | 2 +- test/test_coverage_win.bat | 4 +- tools/run_tests.py | 2 +- tools/test_coverage.sh | 2 +- 8 files changed, 79 insertions(+), 97 deletions(-) diff --git a/Jamfile b/Jamfile index cae426a55..58f611f3c 100644 --- a/Jamfile +++ b/Jamfile @@ -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 : : : $(BOOST_ROOT) ; + alias boost_system : /boost/system//boost_system : : : $(BOOST_ROOT) ; + alias boost_random : /boost/random//boost_random : : : $(BOOST_ROOT) ; +} +else +{ + local boost-lib-search-path = + /opt/local/lib + /usr/lib + /usr/local/lib + /sw/lib + /usr/g++/lib + ; + + local boost-include-path = + /opt/local/include + /usr/local/include + /usr/sfw/include + ; + + # the names are decorated in MacPorts + lib boost_chrono : : darwin boost_chrono-mt $(boost-lib-search-path) + : : $(boost-include-path) ; + lib boost_system : : darwin boost_system-mt $(boost-lib-search-path) + : : $(boost-include-path) ; + lib boost_random : : darwin boost_random-mt $(boost-lib-search-path) + : : $(boost-include-path) ; + + lib boost_chrono : : boost_chrono $(boost-lib-search-path) + : : $(boost-include-path) ; + lib boost_system : : boost_system $(boost-lib-search-path) + : : $(boost-include-path) ; + lib boost_random : : boost_random $(boost-lib-search-path) + : : $(boost-include-path) ; } VERSION = 1.1.0 ; @@ -171,71 +206,43 @@ rule linking ( properties * ) result += -export-dynamic -rdynamic ; } - if source in $(properties) + if static in $(properties) { - if static in $(properties) + if shared in $(properties) { - if 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 += BOOST_ALL_DYN_LINK ; - result += /boost/system//boost_system/static/BOOST_ALL_DYN_LINK ; - result += /boost/chrono//boost_chrono/static/BOOST_ALL_DYN_LINK ; - result += /boost/random//boost_random/static/BOOST_ALL_DYN_LINK ; - } - else - { - result += /boost/system//boost_system/static ; - result += /boost/chrono//boost_chrono/static ; - result += /boost/random//boost_random/static ; - } - - if gcc in $(properties) - && ! windows in $(properties) - && shared in $(properties) - { - result += 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 += BOOST_ALL_DYN_LINK ; + result += boost_system/static/BOOST_ALL_DYN_LINK ; + result += boost_chrono/static/BOOST_ALL_DYN_LINK ; + result += boost_random/static/BOOST_ALL_DYN_LINK ; } else - { - result += /boost/system//boost_system/shared ; - result += /boost/chrono//boost_chrono/shared ; - result += /boost/random//boost_random/shared ; - } - result += $(BOOST_ROOT) - BOOST_ALL_NO_LIB - BOOST_MULTI_INDEX_DISABLE_SERIALIZATION - ; - - } - else - { - if static in $(properties) { result += boost_system/static ; result += boost_chrono/static ; result += boost_random/static ; } - else + + if gcc in $(properties) + && ! windows in $(properties) + && shared in $(properties) { - result += boost_system/shared ; - result += boost_chrono/shared ; - result += boost_random/shared ; + result += 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 += /opt/local/include/boost-1_35 - /opt/local/include - /usr/g++/include - ; } + else + { + result += boost_system/shared ; + result += boost_chrono/shared ; + result += boost_random/shared ; + } + result += BOOST_ALL_NO_LIB + BOOST_MULTI_INDEX_DISABLE_SERIALIZATION + ; return $(result) ; } @@ -486,7 +493,6 @@ feature.compose unicode : _UNICODE UNICODE ; feature deprecated-functions : on off : composite propagated link-incompatible ; feature.compose off : 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 : : gcc static ; # when using iconv lib libiconv : : iconv shared /usr/local/lib ; -local boost-library-search-path = - /opt/local/lib - /usr/lib - /usr/local/lib - /sw/lib - /usr/g++/lib - ; - -lib boost_system : : darwin boost_system-mt $(boost-library-search-path) ; -lib boost_system : : solaris boost_system $(boost-library-search-path) ; -lib boost_system : : boost_system ; - -lib boost_chrono : : darwin boost_chrono-mt $(boost-library-search-path) ; -lib boost_chrono : : solaris boost_chrono $(boost-library-search-path) ; -lib boost_chrono : : boost_chrono ; - -lib boost_random : : darwin boost_random-mt $(boost-library-search-path) ; -lib boost_random : : solaris boost_random $(boost-library-search-path) ; -lib boost_random : : boost_random ; - # openssl on linux/bsd/macos etc. lib gcrypt : : gcrypt shared /opt/local/lib ; lib z : : shared z /usr/lib ; @@ -748,8 +734,8 @@ local usage-requirements = msvc,release:/OPT:ICF=5 msvc,release:/OPT:REF - system:$(CXXFLAGS) - system:$(LDFLAGS) + $(CXXFLAGS) + $(LDFLAGS) # this works around a bug in asio in boost-1.39 BOOST_ASIO_HASH_MAP_BUCKETS=1021 @tag @@ -775,7 +761,7 @@ lib torrent @building @warnings - system:$(CXXFLAGS) + $(CXXFLAGS) # disable bogus deprecation warnings on msvc8 msvc:_SCL_SECURE_NO_DEPRECATE diff --git a/appveyor.yml b/appveyor.yml index 07fe9e6f4..8a72bb62e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 diff --git a/bindings/python/setup.py b/bindings/python/setup.py index b3b808b6d..f512e9101 100644 --- a/bindings/python/setup.py +++ b/bindings/python/setup.py @@ -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') diff --git a/docs/building.rst b/docs/building.rst index d87a5ca97..61adbd756 100644 --- a/docs/building.rst +++ b/docs/building.rst @@ -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 | diff --git a/docs/python_binding.rst b/docs/python_binding.rst index 18bc1d6d8..c55d8b67c 100644 --- a/docs/python_binding.rst +++ b/docs/python_binding.rst @@ -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:: diff --git a/test/test_coverage_win.bat b/test/test_coverage_win.bat index 3700ac7cb..bb4ed1521 100644 --- a/test/test_coverage_win.bat +++ b/test/test_coverage_win.bat @@ -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 diff --git a/tools/run_tests.py b/tools/run_tests.py index e6eae4b6c..9e6a1994f 100755 --- a/tools/run_tests.py +++ b/tools/run_tests.py @@ -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: diff --git a/tools/test_coverage.sh b/tools/test_coverage.sh index 6f2d66278..fa862cb42 100755 --- a/tools/test_coverage.sh +++ b/tools/test_coverage.sh @@ -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 ..