From e777c152bbdd233f838e011a84a1170c7278a0b4 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 6 Jun 2011 20:36:21 +0000 Subject: Merge Boost.Build from trunk. [SVN r72443] --- Jamroot | 586 +++++----------------------------------------------------- bootstrap.bat | 30 +-- bootstrap.sh | 25 +-- tools/build | 2 +- 4 files changed, 78 insertions(+), 565 deletions(-) diff --git a/Jamroot b/Jamroot index 0d68131ba5..c5557b8dd3 100644 --- a/Jamroot +++ b/Jamroot @@ -93,7 +93,7 @@ # --python-buildid=ID Adds the specified ID to the name of built # libraries that depend on Python. The default # is to not add anything. This ID is added in -# addition t --buildid. +# addition to --buildid. # # # --help This message. @@ -123,66 +123,19 @@ # - handle boost version # - handle python options such as pydebug -import generate ; -import modules ; -import set ; -import stage ; +import boostcpp ; import package ; -import path ; -import common ; -import os ; -import regex ; -import errors ; -import "class" : new ; -import common ; + import sequence ; -import symlink ; -import targets ; -import project ; -import option ; import xsltproc ; -import build-system ; -import configure ; +import set ; +import path ; path-constant BOOST_ROOT : . ; constant BOOST_VERSION : 1.47.0 ; constant BOOST_JAMROOT_MODULE : $(__name__) ; -local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] - ; -if $(version-tag[3]) = 0 -{ - version-tag = $(version-tag[1-2]) ; -} - -constant BOOST_VERSION_TAG : $(version-tag:J="_") ; - -# Option to choose how many variants to build. The default is "minimal". -local build-type = [ MATCH "^--build-type=(.*)" : [ modules.peek : ARGV ] ] ; -build-type ?= minimal ; -if ! ( $(build-type) in minimal complete ) -{ - ECHO "The value of the --build-type option should be either 'complete' or 'minimal'" ; - EXIT ; -} - -rule handle-static-runtime ( properties * ) -{ - # Using static runtime with shared libraries is impossible on Linux, - # and dangerous on Windows. Therefore, we disallow it. This might - # be drastic, but it was disabled for a while with nobody complaining. - - # For CW, static runtime is needed so that std::locale works. - if shared in $(properties) && static in $(properties) && - ! ( cw in $(properties) ) - { - ECHO "error: link=shared together with runtime-link=static is not allowed" ; - ECHO "error: such property combination is either impossible " ; - ECHO "error: or too dangerious to be of any use" ; - EXIT ; - } -} - +boostcpp.set-version $(BOOST_VERSION) ; project boost : requirements . @@ -204,8 +157,31 @@ project boost : build-dir bin.v2 ; +# This rule is called by Boost.Build to determine the name of target. We use it +# to encode the build variant, compiler name and boost version in the target +# name. +# +rule tag ( name : type ? : property-set ) +{ + return [ boostcpp.tag $(name) : $(type) : $(property-set) ] ; +} + +rule handle-static-runtime ( properties * ) +{ + # Using static runtime with shared libraries is impossible on Linux, + # and dangerous on Windows. Therefore, we disallow it. This might + # be drastic, but it was disabled for a while with nobody complaining. -# Setup convenient aliases for all libraries. + # For CW, static runtime is needed so that std::locale works. + if shared in $(properties) && static in $(properties) && + ! ( cw in $(properties) ) + { + ECHO "error: link=shared together with runtime-link=static is not allowed" ; + ECHO "error: such property combination is either impossible " ; + ECHO "error: or too dangerious to be of any use" ; + EXIT ; + } +} all-libraries = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ] [ glob libs/*/build/Jamfile ] ] @@ -216,7 +192,7 @@ all-libraries = [ sequence.unique $(all-libraries) ] ; # purposes, there's no library to build and install. all-libraries = [ set.difference $(all-libraries) : function_types ] ; -configure.register-components $(all-libraries) ; +# Setup convenient aliases for all libraries. local rule explicit-alias ( id : targets + ) { @@ -224,7 +200,6 @@ local rule explicit-alias ( id : targets + ) explicit $(id) ; } - # First, the complicated libraries: where the target name in Jamfile is # different from its directory name. explicit-alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ; @@ -242,485 +217,13 @@ for local l in $(all-libraries) } alias headers : : : : . ; +explicit headers ; - -# Decides which libraries are to be installed by looking at --with- -# --without- arguments. Returns the list of directories under "libs" -# which must be built and installed. -# -rule libraries-to-install ( existing-libraries * ) -{ - local argv = [ modules.peek : ARGV ] ; - local with-parameter = [ MATCH --with-(.*) : $(argv) ] ; - local without-parameter = [ MATCH --without-(.*) : $(argv) ] ; - - if ! $(with-parameter) && ! $(without-parameter) - { - # Nothing is specified on command line. See if maybe - # project-config.jam has some choices. - local project-config-libs = [ modules.peek project-config : libraries ] ; - with-parameter = [ MATCH --with-(.*) : $(project-config-libs) ] ; - without-parameter = [ MATCH --without-(.*) : $(project-config-libs) ] ; - } - - # Do some checks. - if $(with-parameter) && $(without-parameter) - { - ECHO "error: both --with- and --without- specified" ; - EXIT ; - } - - local wrong = [ set.difference $(with-parameter) : $(existing-libraries) ] ; - if $(wrong) - { - ECHO "error: wrong library name '$(wrong[1])' in the --with- option." ; - EXIT ; - } - local wrong = [ set.difference $(without-parameter) : $(existing-libraries) ] ; - if $(wrong) - { - ECHO "error: wrong library name '$(wrong[1])' in the --without- option." ; - EXIT ; - } - - if $(with-parameter) - { - return [ set.intersection $(existing-libraries) : $(with-parameter) ] ; - } - else - { - return [ set.difference $(existing-libraries) : $(without-parameter) ] ; - } -} - - -# What kind of layout are we doing? -layout = [ option.get layout : "" ] ; -# On Windows, we used versioned layout by default in order to -# be compatible with autolink. On other systems, we use system -# layout which is what every other program uses. Note that windows -# check is static, and won't -if ! $(layout) -{ - if [ modules.peek : NT ] - { - layout = versioned ; - } - else - { - layout = system ; - } -} -layout-$(layout) = true ; - -if $(layout) = system && $(build-type) = complete -{ - ECHO "error: Cannot use --layout=system with --build-type complete." ; - ECHO "error: Please used either --layout=versioned or --layout=tagged " ; - ECHO "error: if you wish to build multiple variants." ; - if ! [ modules.peek : NT ] - { - ECHO "error: Note that --layout=system is default on Unix starting with Boost 1.40." ; - } - EXIT ; -} - -# Possible stage only location. -local stage-locate = [ MATCH "^--stagedir=(.*)" : [ modules.peek : ARGV ] ] ; -stage-locate ?= stage ; -path-constant BOOST_STAGE_LOCATE : $(stage-locate) ; - - -# Python location. -local python-root = [ MATCH "^--with-python-root=(.*)" : [ modules.peek : ARGV ] - ] ; -PYTHON_ROOT ?= $(python-root) ; - - -# Select the libraries to install. -libraries = [ libraries-to-install $(all-libraries) ] ; -configure.components-building $(libraries) ; - -if --show-libraries in [ modules.peek : ARGV ] -{ - ECHO "The following libraries require building:" ; - for local l in $(libraries) - { - ECHO " - $(l)" ; - } - EXIT ; -} - -# Custom build ID. -local build-id = [ MATCH "^--buildid=(.*)" : [ modules.peek : ARGV ] ] ; -if $(build-id) -{ - constant BUILD_ID : [ regex.replace $(build-id) "[*\\/:.\"\' ]" "_" ] ; -} - -# Python build id (only for Python libraries) -local python-id = [ MATCH "^--python-buildid=(.*)" : [ modules.peek : ARGV ] ] ; -if $(python-id) -{ - constant PYTHON_ID : [ regex.replace $(python-id) "[*\\/:.\"\']" "_" ] ; -} - -# This rule is called by Boost.Build to determine the name of target. We use it -# to encode the build variant, compiler name and boost version in the target -# name. -# -rule tag ( name : type ? : property-set ) -{ - if $(type) in STATIC_LIB SHARED_LIB IMPORT_LIB - { - local result ; - if $(layout) = versioned - { - result = [ common.format-name - -$(BOOST_VERSION_TAG) - -$(BUILD_ID) - : $(name) : $(type) : $(property-set) ] ; - } - else if $(layout) = tagged - { - result = [ common.format-name - - -$(BUILD_ID) - : $(name) : $(type) : $(property-set) ] ; - } - else if $(layout) = system - { - result = [ common.format-name - - -$(BUILD_ID) - : $(name) : $(type) : $(property-set) ] ; - } - else - { - ECHO "error: invalid layout '$(layout)'" ; - EXIT ; - } - - # Optionally add version suffix. On NT, library with version suffix - # will not be recognized by linkers. On CYGWIN, we get strage - # duplicate symbol errors when library is generated with version - # suffix. On OSX, version suffix is not needed -- the linker expects - # the libFoo.1.2.3.dylib format. AIX linkers do not accept version - # suffixes either. Pgi compilers can not accept library with version - # suffix. - if $(type) = SHARED_LIB && - ( ! ( [ $(property-set).get ] in windows cygwin darwin aix ) && - ! ( [ $(property-set).get ] in pgi ) ) - { - result = $(result).$(BOOST_VERSION) ; - } - - return $(result) ; - } -} - - -# Install to system location. - -install-requirements = $(BOOST_ROOT)/boost ; - -if $(layout-versioned) -{ - install-requirements += boost-$(BOOST_VERSION_TAG)/boost ; -} -else -{ - install-requirements += boost ; -} -if [ modules.peek : NT ] -{ - install-requirements += C:/Boost ; -} -else if [ modules.peek : UNIX ] -{ - install-requirements += /usr/local ; -} - -local headers = - # The .SUNWCCh files are present in tr1 include directory and have to be installed, - # see http://lists.boost.org/Archives/boost/2007/05/121430.php - [ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc *.SUNWCCh : CVS .svn ] - [ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* : CVS .svn ] - [ path.glob boost/tr1/tr1 : * : bcc32 sun CVS .svn ] - ; - -# Complete install. -package.install install-proper - : $(install-requirements) on - : - : libs/$(libraries)/build - : $(headers) - ; -explicit install-proper ; - -# Install just library. -install stage-proper - : libs/$(libraries)/build - : $(stage-locate)/lib - on LIB - on - ; -explicit stage-proper ; - - -if $(layout-versioned) && ( [ modules.peek : NT ] || [ modules.peek : UNIX ] ) -{ - rule make-unversioned-links ( project name ? : property-set : sources * ) - { - local result ; - local filtered ; - local pattern ; - local nt = [ modules.peek : NT ] ; - - # Collect the libraries that have the version number in 'filtered'. - for local s in $(sources) - { - local m ; - if $(nt) - { - m = [ MATCH "(.*[.]lib)" : [ $(s).name ] ] ; - } - else - { - m = [ MATCH "(.*[.]so[.0-9]+)" "(.*[.]dylib)" "(.*[.]a)" : - [ $(s).name ] ] ; - } - if $(m) - { - filtered += $(s) ; - } - } - - # Create links without version. - for local s in $(filtered) - { - local name = [ $(s).name ] ; - local ea = [ $(s).action ] ; - local ep = [ $(ea).properties ] ; - local a = [ new non-scanning-action $(s) : symlink.ln : $(ep) ] ; - - local noversion-file ; - if $(nt) - { - noversion-file = [ MATCH "(.*)-[0-9_]+(.*[.]lib)" : $(name) ] ; - } - else - { - noversion-file = - [ MATCH "(.*)-[0-9_]+(.*[.]so)[.0-9]*" : $(name) ] - [ MATCH "(.*)-[0-9_]+(.*[.]dylib)" : $(name) ] - [ MATCH "(.*)-[0-9_]+(.*[.]a)" : $(name) ] - [ MATCH "(.*)-[0-9_]+(.*[.]dll[.]a)" : $(name) ] ; - } - - local new-name = - $(noversion-file[1])$(noversion-file[2]) ; - result += [ new file-target $(new-name) exact : [ $(s).type ] : $(project) - : $(a) ] ; - - } - return $(result) ; - } - - generate stage-unversioned : stage-proper : - @make-unversioned-links ; - explicit stage-unversioned ; - - generate install-unversioned : install-proper : - @make-unversioned-links ; - explicit install-unversioned ; -} -else -{ - # Create do-nothing aliases. - alias stage-unversioned ; - explicit stage-unversioned ; - alias install-unversioned ; - explicit install-unversioned ; -} - -# This is a special metatarget class that handles the --build-type=complete -# option. -class top-level-target : alias-target-class -{ - import modules ; - import errors ; - - rule __init__ ( name : project : sources * : requirements * - : default-build * : usage-requirements * ) - { - alias-target-class.__init__ $(name) : $(project) : $(sources) : - $(requirements) : $(default-build) : $(usage-requirements) ; - - local m = [ $(project).project-module ] ; - self.build-type = [ modules.peek $(m) : build-type ] ; - # On Linux, we build release variant by default, since few users will - # ever want to debug C++ Boost libraries, and there's no ABI - # incompatibility between debug and release variants. We build - # shared and static libraries since that's what most packages - # seem to provide (.so in libfoo and .a in libfoo-dev). - self.minimal-properties = [ property-set.create - release multi shared static shared ] ; - # On Windows, new IDE projects use: - # - # runtime-link=dynamic, threading=multi, variant=(debug|release) - # - # and in addition, C++ Boost's autolink defaults to static linking. - self.minimal-properties-win = [ property-set.create - debug release multi static shared ] ; - - self.complete-properties = [ property-set.create - debug release - single multi - shared static - shared static ] ; - } - - rule generate ( property-set ) - { - local x = [ modules.peek : top-level-targets ] ; - x += $(self.name) ; - modules.poke : top-level-targets : $(x) ; - if $(self.build-type) = minimal - { - local expanded ; - - local os = [ $(property-set).get ] ; - # Because we completely override parent's 'generate' - # we need to check for default value of feature ourself. - if ! $(os) - { - os = [ feature.defaults ] ; - os = $(os:G=) ; - } - - if $(os) = windows - { - expanded = [ targets.apply-default-build $(property-set) - : $(self.minimal-properties-win) ] ; - } - else - { - expanded = [ targets.apply-default-build $(property-set) - : $(self.minimal-properties) ] ; - } - return [ build-multiple $(expanded) ] ; - } - else if $(self.build-type) = complete - { - local expanded = [ targets.apply-default-build $(property-set) - : $(self.complete-properties) ] ; - - # Filter inappopriate combinations - local filtered ; - for local p in $(expanded) - { - # See comment in handle-static-runtime regarding this logic. - if [ $(p).get ] = shared && [ $(p).get ] = static - && [ $(p).get ] != cw - { - # Skip this - } - else - { - filtered += $(p) ; - } - } - return [ build-multiple $(filtered) ] ; - } - else - { - errors.error "Unknown build type" ; - } - } - - rule build-multiple ( property-sets * ) - { - local usage-requirements = [ property-set.empty ] ; - local result ; - for local p in $(property-sets) - { - local r = [ alias-target-class.generate $(p) ] ; - if $(r) - { - usage-requirements = [ $(usage-requirements).add $(r[1]) ] ; - result += $(r[2-]) ; - } - } - return $(usage-requirements) [ sequence.unique $(result) ] ; - } - -} - -targets.create-metatarget top-level-target : [ project.current ] - : install - : install-proper install-unversioned - ; -targets.create-metatarget top-level-target : [ project.current ] - : stage - : stage-proper stage-unversioned - ; - -explicit install ; -explicit stage ; - -stage-abs = [ path.native [ path.root $(stage-locate)/lib [ path.pwd ] ] ] ; - -# This target is built by default, and will forward to 'stage' -# after producing some explanations. -targets.create-metatarget top-level-target : [ project.current ] - : forward - : explain stage - ; - - -message explain : -"\nBuilding the Boost C++ Libraries.\n\n" ; -explicit explain ; - -rule pre-build ( ) -{ - local tl = [ modules.peek : top-level-targets ] ; - if stage in $(tl) || install in $(tl) - { - # FIXME: remove if when Boost regression tests use trunk - # bjam. - if PAD in [ RULENAMES ] - { - configure.print-component-configuration ; - } - } -} -IMPORT $(__name__) : pre-build : : $(__name__).pre-build ; -build-system.set-pre-build-hook $(__name__).pre-build ; - -rule post-build ( ok ? ) +# Make project ids of all libraries known. +for local l in $(all-libraries) { - if forward in [ modules.peek : top-level-targets ] - { - if $(ok) - { - ECHO -"\n\nThe Boost C++ Libraries were successfully built! - -The following directory should be added to compiler include paths: - - $(BOOST_ROOT) - -The following directory should be added to linker library paths: - - $(stage-abs) -" ; - } - } + use-project /boost/$(l) : libs/$(l)/build ; } -IMPORT $(__name__) : post-build : : $(__name__).post-build ; -build-system.set-post-build-hook $(__name__).post-build ; # This rule should be called from libraries' Jamfiles and will create two # targets, "install" and "stage", that will install or stage that library. The @@ -740,18 +243,21 @@ rule boost-install ( libraries * ) install stage : $(libraries) : $(BOOST_STAGE_LOCATE) ; - local c = [ project.current ] ; - local project-module = [ $(c).project-module ] ; - module $(project-module) + module [ CALLER_MODULE ] { explicit stage ; explicit install ; } } +headers = + # The .SUNWCCh files are present in tr1 include directory and have to be installed, + # see http://lists.boost.org/Archives/boost/2007/05/121430.php + [ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc *.SUNWCCh : CVS .svn ] + [ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* : CVS .svn ] + [ path.glob boost/tr1/tr1 : * : bcc32 sun CVS .svn ] + ; -# Make project ids of all libraries known. -for local l in $(all-libraries) -{ - use-project /boost/$(l) : libs/$(l)/build ; -} +# Declare special top-level targets that build and install the desired variants +# of the libraries. +boostcpp.declare-targets $(all-libraries) : $(headers) ; diff --git a/bootstrap.bat b/bootstrap.bat index d63333fe26..121ff6d4e2 100644 --- a/bootstrap.bat +++ b/bootstrap.bat @@ -6,20 +6,21 @@ REM Distributed under the Boost Software License, Version 1.0. REM (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) ECHO Building Boost.Jam build engine -if exist ".\tools\build\v2\engine\src\bin.ntx86\bjam.exe" del tools\build\v2\engine\src\bin.ntx86\bjam.exe -if exist ".\tools\build\v2\engine\src\bin.ntx86_64\bjam.exe" del tools\build\v2\engine\src\bin.ntx86_64\bjam.exe -cd tools\build\v2\engine\src +if exist ".\tools\build\v2\engine\bin.ntx86\bjam.exe" del tools\build\v2\engine\bin.ntx86\bjam.exe +if exist ".\tools\build\v2\engine\bin.ntx86_64\bjam.exe" del tools\build\v2\engine\bin.ntx86_64\bjam.exe +pushd tools\build\v2\engine -call .\build.bat > ..\..\..\bjam.log +call .\build.bat %* > ..\..\..\..\bootstrap.log @ECHO OFF -cd ..\..\..\..\.. -if exist ".\tools\build\v2\engine\src\bin.ntx86\bjam.exe" ( - copy .\tools\build\v2\engine\src\bin.ntx86\bjam.exe . > nul +popd + +if exist ".\tools\build\v2\engine\bin.ntx86\bjam.exe" ( + copy .\tools\build\v2\engine\bin.ntx86\bjam.exe . > nul goto :bjam_built) -if exist ".\tools\build\v2\engine\src\bin.ntx86_64\bjam.exe" ( - copy .\tools\build\v2\engine\src\bin.ntx86_64\bjam.exe . > nul +if exist ".\tools\build\v2\engine\bin.ntx86_64\bjam.exe" ( + copy .\tools\build\v2\engine\bin.ntx86_64\bjam.exe . > nul goto :bjam_built) goto :bjam_failure @@ -32,7 +33,12 @@ REM export BOOST_JAM_TOOLSET, and I don't know how to do that REM properly. Default to msvc for now. set toolset=msvc -ECHO using %toolset% ; > project-config.jam +ECHO import option ; > project-config.jam +ECHO. >> project-config.jam +ECHO using %toolset% ; >> project-config.jam +ECHO. >> project-config.jam +ECHO option.set keep-going : false ; >> project-config.jam +ECHO. >> project-config.jam ECHO. ECHO Bootstrapping is done. To build, run: @@ -57,14 +63,14 @@ goto :end ECHO. ECHO Failed to build Boost.Jam build engine. -ECHO Please consult bjam.log for furter diagnostics. +ECHO Please consult bootstrap.log for furter diagnostics. ECHO. ECHO You can try to obtain a prebuilt binary from ECHO. ECHO http://sf.net/project/showfiles.php?group_id=7586^&package_id=72941 ECHO. ECHO Also, you can file an issue at http://svn.boost.org -ECHO Please attach bjam.log in that case. +ECHO Please attach bootstrap.log in that case. goto :end diff --git a/bootstrap.sh b/bootstrap.sh index fd4fdd6fad..8dea77f30a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -185,7 +185,7 @@ my_dir="." # Determine the toolset, if not already decided if test "x$TOOLSET" = x; then - guessed_toolset=`$my_dir/tools/build/v2/engine/src/build.sh --guess-toolset` + guessed_toolset=`$my_dir/tools/build/v2/engine/build.sh --guess-toolset` case $guessed_toolset in acc | darwin | gcc | como | mipspro | pathscale | pgi | qcc | vacpp ) TOOLSET=$guessed_toolset @@ -215,7 +215,7 @@ rm -f config.log if test "x$BJAM" = x; then echo -n "Building Boost.Jam with toolset $TOOLSET... " pwd=`pwd` - (cd "$my_dir/tools/build/v2/engine/src" && ./build.sh "$TOOLSET") > bootstrap.log 2>&1 + (cd "$my_dir/tools/build/v2/engine" && ./build.sh "$TOOLSET") > bootstrap.log 2>&1 if [ $? -ne 0 ]; then echo echo "Failed to build Boost.Jam" @@ -223,17 +223,18 @@ if test "x$BJAM" = x; then exit 1 fi cd "$pwd" - arch=`cd $my_dir/tools/build/v2/engine/src && ./bootstrap/jam0 -d0 -f build.jam --toolset=$TOOLSET --toolset-root= --show-locate-target && cd ..` - BJAM="$my_dir/tools/build/v2/engine/src/$arch/bjam" - echo "tools/build/v2/engine/src/$arch/bjam" + arch=`cd $my_dir/tools/build/v2/engine && ./bootstrap/jam0 -d0 -f build.jam --toolset=$TOOLSET --toolset-root= --show-locate-target && cd ..` + BJAM="$my_dir/tools/build/v2/engine/$arch/b2" + echo "tools/build/v2/engine/$arch/b2" cp "$BJAM" . + cp "$my_dir/tools/build/v2/engine/$arch/bjam" . + fi # TBD: Turn BJAM into an absolute path # If there is a list of libraries if test "x$flag_show_libraries" = xyes; then - libraries=`$BJAM -d0 --show-libraries` cat <