From 7d9005721f2047a88be59506ff4fb1a6e2ff8afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jurko=20Gospodneti=C4=87?= Date: Thu, 14 Jun 2012 08:49:50 +0000 Subject: Merged Boost library build system changes from the trunk. Fixes ticket #6027 - unversioned Boost library targets not getting installed or staged on Windows or Unix with versioned layout. Covers the following trunk revisions: --- [78934] --- Minor stylistic changes made to the boostcpp.jam Boost library build module - wrapped comments and some code lines to 80 characters, removed duplicate imports, ordered imports alphabetically, corrected comment & end-user message typos, removed redundant quoting & trimmed trailing spaces. --- [78935] --- Made Boost library build script's '--with-...' & '--without-...' parameter checking more strict so e.g. '--run--with--system' is not interpreted as one of those options. --- [78936] --- Minor stylistic changes. --- [78937] --- Boost library build system code cleanup - removed a non-existing 'explicit' target being declared as explicit. --- [78938] --- Corrected a syntax error in Boost library's build system that was preventing unversioned library targets from being staged or installed on Windows & Unix when versioned layout is used. Closes ticket #6027 (https://svn.boost.org/trac/boost/ticket/6027). --- [78939] --- Boost library build system code cleanup - refactored the make-unversioned-links() rule. [SVN r78941] --- boostcpp.jam | 462 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 217 insertions(+), 245 deletions(-) (limited to 'boostcpp.jam') diff --git a/boostcpp.jam b/boostcpp.jam index db7360dd97..4ad461b4c7 100644 --- a/boostcpp.jam +++ b/boostcpp.jam @@ -8,27 +8,27 @@ # (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -import option ; -import regex ; +import "class" : new ; import common ; - +import configure ; +import build-system ; +import generate ; import modules ; +import option ; import os ; -import path ; -import build-system ; -import configure ; -import set ; import package ; +import path ; import project ; +import regex ; +import set ; import targets ; -import generate ; -import package ; + ############################################################################## -# +# # 0. General setup. Parse options, check them. # -############################################################################## +############################################################################## BOOST_ROOT = [ modules.binding $(__name__) ] ; BOOST_ROOT = $(BOOST_ROOT:D) ; @@ -36,32 +36,31 @@ BOOST_ROOT = $(BOOST_ROOT:D) ; rule set-version ( version ) { BOOST_VERSION = $(version) ; - - local version-tag = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" : $(BOOST_VERSION) ] - ; + + local version-tag = [ MATCH ^([^.]+)[.]([^.]+)[.]([^.]+) : $(BOOST_VERSION) + ] ; if $(version-tag[3]) = 0 { version-tag = $(version-tag[1-2]) ; } - - BOOST_VERSION_TAG = $(version-tag:J="_") ; + BOOST_VERSION_TAG = $(version-tag:J=_) ; } # Option to choose how many variants to build. The default is "minimal". -build-type = [ option.get "build-type" ] ; +build-type = [ option.get build-type ] ; build-type ?= minimal ; -if ! ( $(build-type) in minimal complete ) +if ! ( $(build-type) in complete minimal ) { - ECHO "The value of the --build-type option should be either 'complete' or 'minimal'" ; - EXIT ; + EXIT The value of the --build-type option should be either 'complete' or + 'minimal' ; } # 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 +# 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 the Windows check is static, and will not be affected +# by specific build properties used. if ! $(layout) { if [ os.name ] = NT @@ -77,42 +76,43 @@ 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." ; + ECHO error: Cannot use --layout=system with --build-type complete. ; + ECHO error: Please use either --layout=versioned or --layout=tagged ; + ECHO error: if you wish to build multiple variants. ; if [ os.name ] != NT - { - ECHO "error: Note that --layout=system is default on Unix starting with Boost 1.40." ; - } + { + ECHO error: Note that --layout=system is used by default on Unix + starting with Boost 1.40. ; + } EXIT ; } # Possible stage only location. -stage-locate = [ option.get "stagedir" ] ; +stage-locate = [ option.get stagedir ] ; stage-locate ?= stage ; BOOST_STAGE_LOCATE = $(stage-locate) ; # Custom build ID. -build-id = [ option.get "buildid" ] ; +build-id = [ option.get buildid ] ; if $(build-id) { - BUILD_ID = [ regex.replace $(build-id) "[*\\/:.\"\' ]" "_" ] ; + BUILD_ID = [ regex.replace $(build-id) "[*\\/:.\"\' ]" _ ] ; } -# Python build id (only for Python libraries) +# Python build id (for Python libraries only). python-id = [ option.get "python-buildid" ] ; if $(python-id) { - PYTHON_ID = [ regex.replace $(python-id) "[*\\/:.\"\']" "_" ] ; + PYTHON_ID = [ regex.replace $(python-id) [*\\/:.\"\'] _ ] ; } -############################################################################## + +################################################################################ # -# 1. The 'tag' function that adds decoration suitable to the properties if -# versioned or tagged layout is requested. This function is called from -# Jamroot +# 1. 'tag' function adding decorations suitable to the properties if versioned +# or tagged layout is requested. Called from Jamroot. # -############################################################################## +################################################################################ rule tag ( name : type ? : property-set ) { @@ -125,113 +125,86 @@ rule tag ( name : type ? : property-set ) -$(BOOST_VERSION_TAG) -$(BUILD_ID) : $(name) : $(type) : $(property-set) ] ; - } + } else if $(layout) = tagged { result = [ common.format-name -$(BUILD_ID) - : $(name) : $(type) : $(property-set) ] ; + : $(name) : $(type) : $(property-set) ] ; } else if $(layout) = system { result = [ common.format-name - + -$(BUILD_ID) : $(name) : $(type) : $(property-set) ] ; } else { - ECHO "error: invalid layout '$(layout:E=)'" ; - EXIT ; + EXIT error: invalid layout '$(layout:E=)' ; } - - # 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. + + # 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 a library with version suffix. if $(type) = SHARED_LIB && - ( ! ( [ $(property-set).get ] in windows cygwin darwin aix ) && - ! ( [ $(property-set).get ] in pgi ) ) + ! [ $(property-set).get ] in windows cygwin darwin aix && + ! [ $(property-set).get ] in pgi { result = $(result).$(BOOST_VERSION) ; } return $(result) ; - } + } } -############################################################################## + +################################################################################ # # 2. Declare targets that build and install all libraries. Specifically: # # - 'stage-proper' that puts all libraries in stage/lib # - 'install-proper' that install libraries and headers to system location -# - 'stage-unversioned' that creates links to libraries without boost veriosn +# - 'stage-unversioned' that creates links to libraries without boost version # in name # - 'install-unversioned' which creates unversioned linked to installed # libraries. # -############################################################################## +################################################################################ -# Worker function suitable to the 'generate' metatarget. Creates a link -# to 'source', striping any version number from the name. +# Worker function suitable to the 'generate' metatarget. Creates a link to +# 'source', striping any version number information from the name. 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 filter ; + if [ modules.peek : NT ] { - local m ; - if $(nt) - { - m = [ MATCH "(.*[.]lib)" : [ $(s).name ] ] ; - } - else - { - m = [ MATCH "(.*[.]so[.0-9]+)" "(.*[.]dylib)" "(.*[.]a)" : - [ $(s).name ] ] ; - } - if $(m) - { - filtered += $(s) ; - } + filter = (.*[.]lib) ; } - - # Create links without version. - for local s in $(filtered) + else { - local name = [ $(s).name ] ; - local ea = [ $(s).action ] ; - local ep = [ $(ea).properties ] ; - local a = [ new non-scanning-action $(s) : symlink.ln : $(ep) ] ; + filter = + (.*[.]so)[.0-9]* + (.*[.]dylib) + (.*[.]a) ; + } - local noversion-file ; - if $(nt) - { - noversion-file = [ MATCH "(.*)-[0-9_]+(.*[.]lib)" : $(name) ] ; - } - else + local result ; + for local s in $(sources) + { + local m = [ MATCH ^(.*)-[0-9_]+$(filter)$ : [ $(s).name ] ] ; + if $(m) { - 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 ea = [ $(s).action ] ; + local ep = [ $(ea).properties ] ; + local a = [ new non-scanning-action $(s) : symlink.ln : $(ep) ] ; + result += [ new file-target $(m:J=) exact : [ $(s).type ] : + $(project) : $(a) ] ; } - - local new-name = - $(noversion-file[1])$(noversion-file[2]) ; - result += [ new file-target $(new-name) exact : [ $(s).type ] : $(project) - : $(a) ] ; - } return $(result) ; } @@ -242,13 +215,14 @@ rule declare_install_and_stage_proper_targets ( libraries * : headers * ) if $(layout-versioned) { - install-requirements += boost-$(BOOST_VERSION_TAG)/boost ; + install-requirements += + boost-$(BOOST_VERSION_TAG)/boost ; } else { install-requirements += boost ; } - + if [ os.name ] = NT { install-requirements += C:/Boost ; @@ -257,37 +231,36 @@ rule declare_install_and_stage_proper_targets ( libraries * : headers * ) { install-requirements += /usr/local ; } - + p = [ project.current ] ; - + # Complete install. package.install install-proper - : $(install-requirements) on - : - : libs/$(libraries)/build - : $(headers) - ; - + : $(install-requirements) on + : + : libs/$(libraries)/build + : $(headers) + ; $(p).mark-target-as-explicit install-proper ; # Install just library. install stage-proper - : libs/$(libraries)/build - : $(stage-locate)/lib - on LIB - on - ; + : libs/$(libraries)/build + : $(stage-locate)/lib + on LIB + on + ; $(p).mark-target-as-explicit stage-proper ; if $(layout-versioned) && ( [ modules.peek : NT ] || [ modules.peek : UNIX ] ) { generate stage-unversioned : stage-proper : - boostcpp.make-unversioned-links ; + @boostcpp.make-unversioned-links ; $(p).mark-target-as-explicit stage-unversioned ; generate install-unversioned : install-proper : - boostcpp.make-unversioned-links ; - $(p).mark-target-as-explicit explicit install-unversioned ; + @boostcpp.make-unversioned-links ; + $(p).mark-target-as-explicit install-unversioned ; } else { @@ -299,41 +272,41 @@ rule declare_install_and_stage_proper_targets ( libraries * : headers * ) } } -############################################################################## + +################################################################################ # -# 3. Declare top-level targets 'stage' and 'install'. These examine -# the --build-type option and, in case it's 'complete', build the -# 'install-proper' and 'stage-proper' targets with a number of -# property sets. +# 3. Declare top-level targets 'stage' and 'install'. These examine the +# --build-type option and, in case it is 'complete', build the 'install-proper' +# and 'stage-proper' targets with a number of property sets. # -############################################################################## +################################################################################ 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) ; - + self.build-type = [ modules.peek boostcpp : 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 Linux, we build the release variant by default, since few users + # will ever want to debug C++ Boost libraries, and there is no ABI + # incompatibility between debug and release variants. We build shared + # and static libraries since that is 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.minimal-properties-win = [ property-set.create debug + release multi static shared + ] ; self.complete-properties = [ property-set.create debug release @@ -341,65 +314,66 @@ class top-level-target : alias-target-class shared static shared static ] ; } - + rule generate ( property-set ) { - local x = [ modules.peek : top-level-targets ] ; - x += $(self.name) ; - modules.poke : top-level-targets : $(x) ; + modules.poke : top-level-targets : [ modules.peek : top-level-targets ] + $(self.name) ; 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. + # Because we completely override the parent's 'generate' we need to + # check for default feature values ourselves. if ! $(os) { os = [ feature.defaults ] ; os = $(os:G=) ; } - + if $(os) = windows - { + { expanded = [ targets.apply-default-build $(property-set) - : $(self.minimal-properties-win) ] ; + : $(self.minimal-properties-win) ] ; } else { expanded = [ targets.apply-default-build $(property-set) - : $(self.minimal-properties) ] ; - } + : $(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 + : $(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 + if [ $(p).get ] = shared + && [ $(p).get ] = static + && [ $(p).get ] != cw { - # Skip this + # Skip this. } else { filtered += $(p) ; } - } - return [ build-multiple $(filtered) ] ; + } + return [ build-multiple $(filtered) ] ; } else { - errors.error "Unknown build type" ; - } + import errors ; + errors.error "Unknown build type" ; + } } - + rule build-multiple ( property-sets * ) { local usage-requirements = [ property-set.empty ] ; @@ -414,27 +388,27 @@ class top-level-target : alias-target-class } } return $(usage-requirements) [ sequence.unique $(result) ] ; - } + } } rule declare_top_level_targets ( libraries * : headers * ) { declare_install_and_stage_proper_targets $(libraries) : $(headers) ; - + targets.create-metatarget top-level-target : [ project.current ] : install - : install-proper install-unversioned + : install-proper install-unversioned ; targets.create-metatarget top-level-target : [ project.current ] : stage - : stage-proper stage-unversioned + : stage-proper stage-unversioned ; p = [ project.current ] ; $(p).mark-target-as-explicit install stage ; - - # This target is built by default, and will forward to 'stage' - # after producing some explanations. + + # 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 @@ -444,16 +418,16 @@ rule declare_top_level_targets ( libraries * : headers * ) stage-abs = [ path.native [ path.root $(stage-locate)/lib [ path.pwd ] ] ] ; -############################################################################## + +################################################################################ # -# 4. Add hook to report configuration before the build, and confirmation -# with setup instructions after the build +# 4. Add hook to report configuration before the build, and confirmation with +# setup instructions after the build. # -############################################################################## +################################################################################ -message explain : -"\nBuilding the Boost C++ Libraries.\n\n" ; -p = [ project.current ] ; +message explain : "\nBuilding the Boost C++ Libraries.\n\n" ; +local p = [ project.current ] ; $(p).mark-target-as-explicit explain ; rule pre-build ( ) @@ -461,109 +435,107 @@ 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. + # FIXME: Remove 'if' when Boost regression tests start using 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 ; -# FIXME: revive stage_abs -rule post-build ( ok ? ) +# FIXME: Revise stage_abs. +rule post-build ( ok ? ) { - if forward in [ modules.peek : top-level-targets ] - { + if forward in [ modules.peek : top-level-targets ] + { if $(ok) { - ECHO -"\n\nThe Boost C++ Libraries were successfully built! - + ECHO " + +The 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) " ; - } - } + } + } } IMPORT $(__name__) : post-build : : $(__name__).post-build ; build-system.set-post-build-hook $(__name__).post-build ; -############################################################################## -# -# 5. Top-level setup +################################################################################ # -############################################################################## - +# 5. Top-level setup. +# +################################################################################ # 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 * ) +rule libraries-to-install ( existing-libs * ) { - 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) ] ; - } + 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 libs = [ modules.peek project-config : libraries ] ; + with-parameter = [ MATCH ^--with-(.*) : $(libs) ] ; + without-parameter = [ MATCH ^--without-(.*) : $(libs) ] ; + } + + # Do some checks. + if $(with-parameter) && $(without-parameter) + { + EXIT error: both --with- and --without- specified ; + } + + local wrong = [ set.difference $(with-parameter) : $(existing-libs) ] ; + if $(wrong) + { + EXIT error: wrong library name '$(wrong[1])' in the --with- + option. ; + } + local wrong = [ set.difference $(without-parameter) : $(existing-libs) ] ; + if $(wrong) + { + EXIT error: wrong library name '$(wrong[1])' in the --without- + option. ; + } + + if $(with-parameter) + { + return [ set.intersection $(existing-libs) : $(with-parameter) ] ; + } + else + { + return [ set.difference $(existing-libs) : $(without-parameter) ] ; + } } rule declare-targets ( all-libraries * : headers * ) { configure.register-components $(all-libraries) ; - + # Select the libraries to install. libraries = [ libraries-to-install $(all-libraries) ] ; configure.components-building $(libraries) ; if [ option.get "show-libraries" : : true ] { - ECHO "The following libraries require building:" ; + ECHO The following libraries require building: ; for local l in $(libraries) { ECHO " - $(l)" ; -- cgit v1.2.1