From 416ea3389acc47731368a0511331b784909a1cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Sch=C3=B6pflin?= Date: Wed, 2 Aug 2006 08:05:44 +0000 Subject: [PATCH 01/82] Added librt when linking on Tru64/gcc. [SVN r34802] --- v2/tools/python.jam | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 2c8486d78..69b0f7c0f 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -160,12 +160,18 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) # way to refactor it. # Note that for 'sun' toolset, rt is already unconditionally # added. + + # (MS) Question: Why not [ os.name ] in the next statement? switch [ modules.peek : JAMUNAME ] { case SunOS* : { extra-libs-conditional += gcc:rt ; } + case OSF* : + { + extra-libs-conditional += gcc:rt ; + } } # On Linux, we don't want to link either Boost.Python or From a2e4712a4ef8fd2aea7ca8e999ca61b19a20294e Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 2 Aug 2006 18:26:30 +0000 Subject: [PATCH 02/82] Skip targets that can't be generated like BBv1 does. [SVN r34806] --- v2/build/generators.jam | 40 +++++++++++++++-------- v2/build/targets.jam | 68 ++++++++++++++++++++------------------ v2/tools/gcc.jam | 72 +++++++++++++++++++++++++---------------- 3 files changed, 108 insertions(+), 72 deletions(-) diff --git a/v2/build/generators.jam b/v2/build/generators.jam index 66588a715..b46a91c67 100644 --- a/v2/build/generators.jam +++ b/v2/build/generators.jam @@ -1,7 +1,9 @@ -# Copyright (C) Vladimir Prus 2002. Permission to copy, use, modify, sell and -# distribute this software is granted provided this copyright notice appears in -# all copies. This software is provided "as is" without express or implied -# warranty, and with no claim as to its suitability for any purpose. +# Copyright Vladimir Prus 2002. +# Copyright Rene Rivera 2006. +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) # Manages 'generators' --- objects which can do transformation between different # target types and contain algorithm for finding transformation from sources @@ -219,6 +221,13 @@ class generator return ; } } + + # Indicates if this generator can handle building the given target + # combination. + rule can-build ( target-type : property-set : sources * ) + { + return true ; + } # Returns another generator which differers from $(self) in # - id @@ -928,7 +937,7 @@ local rule ensure-type ( targets * ) # # Note: this algorithm explicitly ignores generators for base classes if there's # at least one generator for requested target-type. -local rule find-viable-generators-aux ( target-type : property-set ) +local rule find-viable-generators-aux ( target-type : property-set : sources * ) { # Select generators that can create the required target type. local viable-generators = ; @@ -981,25 +990,28 @@ local rule find-viable-generators-aux ( target-type : property-set ) for local g in $(generators) { generators.dout [ indent ] "trying generator" [ $(g).id ] "(" [ $(g).source-types ] -> [ $(g).target-types ] ")" ; - - local m = [ $(g).match-rank $(property-set) ] ; - if $(m) + + if [ $(g).can-build $(target-type) : $(property-set) : $(sources) ] { - generators.dout [ indent ] " is viable" ; - viable-generators += $(g) ; - } + local m = [ $(g).match-rank $(property-set) ] ; + if $(m) + { + generators.dout [ indent ] " is viable" ; + viable-generators += $(g) ; + } + } } return $(viable-generators) ; } -rule find-viable-generators ( target-type : property-set ) +rule find-viable-generators ( target-type : property-set : sources * ) { local key = $(target-type).$(property-set) ; local l = $(.fv.$(key)) ; if ! $(l) { - l = [ find-viable-generators-aux $(target-type) : $(property-set) ] ; + l = [ find-viable-generators-aux $(target-type) : $(property-set) : $(sources) ] ; if ! $(l) { l = none ; @@ -1059,7 +1071,7 @@ rule find-viable-generators ( target-type : property-set ) local rule construct-really ( project name ? : target-type : property-set : sources * ) { - viable-generators = [ find-viable-generators $(target-type) : $(property-set) ] ; + viable-generators = [ find-viable-generators $(target-type) : $(property-set) : $(sources) ] ; generators.dout [ indent ] "*** " [ sequence.length $(viable-generators) ] " viable generators" ; diff --git a/v2/build/targets.jam b/v2/build/targets.jam index a5685f0c5..b898f815b 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -1,7 +1,9 @@ -# Copyright (C) Vladimir Prus 2002. Permission to copy, use, modify, sell and -# distribute this software is granted provided this copyright notice appears in -# all copies. This software is provided "as is" without express or implied -# warranty, and with no claim as to its suitability for any purpose. +# Copyright Vladimir Prus 2002. +# Copyright Rene Rivera 2006. +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) # Supports 'abstract' targets, which are targets explicitly defined in Jamfile. @@ -733,8 +735,11 @@ class main-target : abstract-target for local p in $(all-property-sets) { local r = [ generate-really $(p) ] ; - usage-requirements = [ $(usage-requirements).add $(r[1]) ] ; - result += $(r[2-]) ; + if $(r) + { + usage-requirements = [ $(usage-requirements).add $(r[1]) ] ; + result += $(r[2-]) ; + } } end-building $(__name__) ; return $(usage-requirements) [ sequence.unique $(result) ] ; @@ -1184,28 +1189,30 @@ class basic-target : abstract-target [ construct $(self.name) : $(source-targets) : $(rproperties) ] ; - local gur = $(result[1]) ; - result = $(result[2-]) ; - - local s = [ create-subvariant - $(result) : - [ virtual-target.recent-targets ] - : $(property-set) : $(source-targets) - : $(rproperties) : $(usage-requirements) ] ; - virtual-target.clear-recent-targets ; - - local ur = [ compute-usage-requirements $(s) ] ; - ur = [ $(ur).add $(gur) ] ; - $(s).set-usage-requirements $(ur) ; - if [ modules.peek : .debug-building ] + if $(result) { - ECHO [ targets.indent ] - "Usage requirements from $(self.name) are " - [ $(ur).raw ] ; + local gur = $(result[1]) ; + result = $(result[2-]) ; + + local s = [ create-subvariant + $(result) : + [ virtual-target.recent-targets ] + : $(property-set) : $(source-targets) + : $(rproperties) : $(usage-requirements) ] ; + virtual-target.clear-recent-targets ; + + local ur = [ compute-usage-requirements $(s) ] ; + ur = [ $(ur).add $(gur) ] ; + $(s).set-usage-requirements $(ur) ; + if [ modules.peek : .debug-building ] + { + ECHO [ targets.indent ] + "Usage requirements from $(self.name) are " + [ $(ur).raw ] ; + } + + self.generated.$(property-set) = $(ur) $(result) ; } - - - self.generated.$(property-set) = $(ur) $(result) ; } else { @@ -1339,20 +1346,19 @@ class typed-target : basic-target : $(source-targets) ] ; if ! $(r) { - ECHO "error: unable to construct " [ full-name ] ; + ECHO "warn: Unable to construct" [ full-name ] ; # Are there any top-level generators for this type/property set. if ! [ generators.find-viable-generators - $(self.type) : $(property-set) ] + $(self.type) : $(property-set) : $(source-targets) ] { ECHO "error: no generators were found for type '$(self.type)'" ; ECHO "error: and the requested properties" ; ECHO "error: make sure you've configured the needed tools" ; ECHO "See http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html" ; + + ECHO "To debug this problem, try the --debug-generators option." ; } - - ECHO "To debug this problem, try the --debug-generators option." ; - EXIT ; } return $(r) ; diff --git a/v2/tools/gcc.jam b/v2/tools/gcc.jam index c6d182bc9..393b7978d 100644 --- a/v2/tools/gcc.jam +++ b/v2/tools/gcc.jam @@ -1,10 +1,10 @@ -# Copyright (c) 2001 David Abrahams. -# Copyright (c) 2002-2003 Rene Rivera. -# Copyright (c) 2002-2003 Vladimir Prus. +# Copyright 2001 David Abrahams. +# Copyright 2002-2006 Rene Rivera. +# Copyright 2002-2003 Vladimir Prus. # -# Use, modification and distribution is subject to the Boost Software -# License Version 1.0. (See accompanying file LICENSE_1_0.txt or -# http://www.boost.org/LICENSE_1_0.txt) +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) import toolset : flags ; import property ; @@ -254,36 +254,54 @@ actions compile.asm # since it's not supported by gcc/libc. class gcc-linking-generator : unix-linking-generator { - rule generated-targets ( sources + : property-set : project name ? ) + rule can-build ( target-type : property-set : sources * ) { - if static in [ $(property-set).raw ] + local no-static-link = ; + if [ modules.peek : UNIX ] { - local m ; - if [ id ] = "gcc.link.dll" + switch [ modules.peek : JAMUNAME ] + { + case * : no-static-link = true ; + } + } + + local properties = [ $(property-set).raw ] ; + local reason ; + if $(no-static-link) && static in $(properties) + { + if shared in $(properties) + { + reason = + "On gcc, DLL can't be build with 'static'." ; + } + else if [ type.is-derived $(target-type) EXE ] { - m = "on gcc, DLL can't be build with static" ; - } - if ! $(m) { for local s in $(sources) { local type = [ $(s).type ] ; - if $(type) && [ type.is-derived $(type) SHARED_LIB ] + if $(type) && [ type.is-derived $(type) SHARED_LIB ] { - m = "on gcc, using DLLS together with the static options is not possible " ; - } - } + reason = + "On gcc, using DLLS together with the" + "static options is not possible " ; + } + } } - if $(m) - { - errors.user-error $(m) : - "it's suggested to use static together with the static" ; - } - } - - return [ unix-linking-generator.generated-targets - $(sources) : $(property-set) : $(project) $(name) ] ; - } + if $(reason) + { + ECHO warn: + $(reason) ; + ECHO warn: + "It's suggested to use 'static' together" + "with the 'static'." ; + return ; + } + else + { + return true ; + } + } } generators.register [ new gcc-linking-generator gcc.link : LIB OBJ : EXE From c2c245b5df2c7a9b56b200ccbc417ee98c10bedf Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 7 Aug 2006 05:27:15 +0000 Subject: [PATCH 03/82] Undo addition of generator.can-build. Use generator.run to get the same effect. [SVN r34834] --- v2/build/generators.jam | 28 ++++++++++------------------ v2/build/targets.jam | 3 ++- v2/tools/gcc.jam | 12 +++++++----- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/v2/build/generators.jam b/v2/build/generators.jam index b46a91c67..b538d210b 100644 --- a/v2/build/generators.jam +++ b/v2/build/generators.jam @@ -222,13 +222,6 @@ class generator } } - # Indicates if this generator can handle building the given target - # combination. - rule can-build ( target-type : property-set : sources * ) - { - return true ; - } - # Returns another generator which differers from $(self) in # - id # - value to feature in properties @@ -273,6 +266,8 @@ class generator # Tries to invoke this generator on the given sources. Returns a # list of generated targets (instances of 'virtual-target'). + # Returning nothing from run indicates that the generator was + # unable to create the target. rule run ( project # Project for which the targets are generated name ? # Determines the name of 'name' attribute for # all generated targets. See 'generated-targets' method. @@ -937,7 +932,7 @@ local rule ensure-type ( targets * ) # # Note: this algorithm explicitly ignores generators for base classes if there's # at least one generator for requested target-type. -local rule find-viable-generators-aux ( target-type : property-set : sources * ) +local rule find-viable-generators-aux ( target-type : property-set ) { # Select generators that can create the required target type. local viable-generators = ; @@ -991,27 +986,24 @@ local rule find-viable-generators-aux ( target-type : property-set : sources * ) { generators.dout [ indent ] "trying generator" [ $(g).id ] "(" [ $(g).source-types ] -> [ $(g).target-types ] ")" ; - if [ $(g).can-build $(target-type) : $(property-set) : $(sources) ] + local m = [ $(g).match-rank $(property-set) ] ; + if $(m) { - local m = [ $(g).match-rank $(property-set) ] ; - if $(m) - { - generators.dout [ indent ] " is viable" ; - viable-generators += $(g) ; - } + generators.dout [ indent ] " is viable" ; + viable-generators += $(g) ; } } return $(viable-generators) ; } -rule find-viable-generators ( target-type : property-set : sources * ) +rule find-viable-generators ( target-type : property-set ) { local key = $(target-type).$(property-set) ; local l = $(.fv.$(key)) ; if ! $(l) { - l = [ find-viable-generators-aux $(target-type) : $(property-set) : $(sources) ] ; + l = [ find-viable-generators-aux $(target-type) : $(property-set) ] ; if ! $(l) { l = none ; @@ -1071,7 +1063,7 @@ rule find-viable-generators ( target-type : property-set : sources * ) local rule construct-really ( project name ? : target-type : property-set : sources * ) { - viable-generators = [ find-viable-generators $(target-type) : $(property-set) : $(sources) ] ; + viable-generators = [ find-viable-generators $(target-type) : $(property-set) ] ; generators.dout [ indent ] "*** " [ sequence.length $(viable-generators) ] " viable generators" ; diff --git a/v2/build/targets.jam b/v2/build/targets.jam index b898f815b..c23c87fcc 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -1350,7 +1350,7 @@ class typed-target : basic-target # Are there any top-level generators for this type/property set. if ! [ generators.find-viable-generators - $(self.type) : $(property-set) : $(source-targets) ] + $(self.type) : $(property-set) ] { ECHO "error: no generators were found for type '$(self.type)'" ; ECHO "error: and the requested properties" ; @@ -1358,6 +1358,7 @@ class typed-target : basic-target ECHO "See http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html" ; ECHO "To debug this problem, try the --debug-generators option." ; + EXIT ; } } diff --git a/v2/tools/gcc.jam b/v2/tools/gcc.jam index 393b7978d..0c5d4edda 100644 --- a/v2/tools/gcc.jam +++ b/v2/tools/gcc.jam @@ -254,8 +254,9 @@ actions compile.asm # since it's not supported by gcc/libc. class gcc-linking-generator : unix-linking-generator { - rule can-build ( target-type : property-set : sources * ) + rule run ( project name ? : property-set : sources + ) { + #~ TODO: Replace this with the use of a target-os property. local no-static-link = ; if [ modules.peek : UNIX ] { @@ -274,7 +275,7 @@ class gcc-linking-generator : unix-linking-generator reason = "On gcc, DLL can't be build with 'static'." ; } - else if [ type.is-derived $(target-type) EXE ] + else if [ type.is-derived $(self.target-types[1]) EXE ] { for local s in $(sources) { @@ -290,16 +291,17 @@ class gcc-linking-generator : unix-linking-generator } if $(reason) { - ECHO warn: + ECHO warning: $(reason) ; - ECHO warn: + ECHO warning: "It's suggested to use 'static' together" "with the 'static'." ; return ; } else { - return true ; + return [ unix-linking-generator.run $(project) $(name) + : $(property-set) : $(sources) ] ; } } } From 459d888b5ff4893e2c9e92a81ee9b3d44298d4a8 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 8 Aug 2006 17:55:56 +0000 Subject: [PATCH 04/82] Partial fix for not finding the Python library on NT. [SVN r34852] --- v2/tools/python.jam | 2 ++ 1 file changed, 2 insertions(+) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 69b0f7c0f..9ab611ebf 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -34,6 +34,7 @@ import "class" : new ; import os ; import common ; import toolset : flags ; +import regex ; # Make this module a project project.initialize $(__name__) ; @@ -296,6 +297,7 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? PYTHON_INCLUDES ?= $(root)/include [ GLOB $(root) : PC ] ; + local PYTHON_VERSION_NODOT = [ regex.match ([0-9]+[.][0-9]+).* : $(version) : 1 ] ; PYTHON_DLL ?= [ GLOB $(PATH) $(Path) : python$(PYTHON_VERSION_NODOT).dll ] ; PYTHON_DEBUG_DLL ?= [ GLOB $(PATH) $(Path) : python$(PYTHON_VERSION_NODOT)_d.dll ] ; PYTHON_IMPORT_LIB ?= [ GLOB $(PYTHON_LIB_PATH) : libpython$(PYTHON_VERSION_NODOT).* ] ; From ca74fca08a1c31ca12951fd314f038f16c1b293f Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Fri, 11 Aug 2006 15:45:25 +0000 Subject: [PATCH 05/82] Fix detection of QNX for inclusion of libutil [SVN r34869] --- v2/tools/python.jam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 9ab611ebf..d0cbf81a4 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -141,7 +141,7 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) { case SOLARIS : extra-libs = dl ; case OSF : extra-libs = ; - case QNXTO : extra-libs = util ; + case QNX* : extra-libs = util ; case * : extra-libs = dl util ; } From 041fab5e8ea8938651f5c1e7a7e82ddc4c528bd4 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 15 Aug 2006 05:55:22 +0000 Subject: [PATCH 06/82] Add usage requirements for make targets. [SVN r34884] --- v2/tools/make.jam | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/v2/tools/make.jam b/v2/tools/make.jam index bd00ae92e..4880eeee1 100644 --- a/v2/tools/make.jam +++ b/v2/tools/make.jam @@ -19,10 +19,11 @@ class make-target-class : basic-target import type regex virtual-target ; import "class" : new ; - rule __init__ ( name : project : sources * : requirements * : default-build * ) + rule __init__ ( name : project : sources * : requirements * + : default-build * : usage-requirements * ) { basic-target.__init__ $(name) : $(project) : $(sources) - : $(requirements) : $(default-build) ; + : $(requirements) : $(default-build) : $(usage-requirements) ; } rule construct ( name : source-targets * : property-set ) @@ -41,7 +42,8 @@ class make-target-class : basic-target } # Declares the 'make' main target. -rule make ( target-name : sources * : generating-rule + : requirements * ) +rule make ( target-name : sources * : generating-rule + : requirements * + : usage-requirements * ) { local project = [ project.current ] ; @@ -59,6 +61,7 @@ rule make ( target-name : sources * : generating-rule + : requirements * ) : [ targets.main-target-sources $(sources) : $(target-name) ] : [ targets.main-target-requirements $(requirements) : $(project) ] : [ targets.main-target-default-build : $(project) ] + : [ targets.main-target-usage-requirements $(usage-requirements) : $(project) ] ] ; } From 2852cfab5e69bbda80d7b29c298a128f5e338e1c Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 15 Aug 2006 05:56:56 +0000 Subject: [PATCH 07/82] Add property to properties passed to name adjustment rules. [SVN r34885] --- v2/build/virtual-target.jam | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/v2/build/virtual-target.jam b/v2/build/virtual-target.jam index 3c52b32d5..fb30279d5 100644 --- a/v2/build/virtual-target.jam +++ b/v2/build/virtual-target.jam @@ -402,6 +402,14 @@ class abstract-file-target : virtual-target ps = [ property-set.empty ] ; } + #~ We add ourselves to the properties so that any tag rule can get + #~ more direct information about the target than just that available + #~ through the properties. This is useful in implementing + #~ name changes based on the sources of the target. For example to + #~ make unique names of object files based on the source file. + #~ --grafik + ps = [ property-set.create [ $(ps).raw ] $(__name__) ] ; + local tag = [ $(ps).get ] ; if $(tag) From 8b761c9e3787cc4076c5024e7361b54f5dacf489 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 15 Aug 2006 17:35:24 +0000 Subject: [PATCH 08/82] Attempted QNX workaround [SVN r34887] --- v2/tools/python.jam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index d0cbf81a4..25ad9ac7a 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -141,7 +141,7 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) { case SOLARIS : extra-libs = dl ; case OSF : extra-libs = ; - case QNX* : extra-libs = util ; + case QNX* : extra-libs = ; case * : extra-libs = dl util ; } From 28d52b1e89060cb5d5468ba54da40846b72dc283 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 15 Aug 2006 18:46:13 +0000 Subject: [PATCH 09/82] Add host-os and target-os features. [SVN r34889] --- v2/tools/builtin.jam | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 4e1bba72e..74e81e5d7 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -25,9 +25,60 @@ import project ; # This feature is used to determine which OS we're on. # In future, this may become and +# The future is now... local os = [ modules.peek : OS ] ; feature os : $(os) : propagated link-incompatible ; +# Translates from bjam current OS to the os tags used +# in host-os and target-os. I.e. it returns the +# running host-os. +local rule default-host-os ( ) +{ + local host-os ; + local os-list = [ feature.values host-os ] ; + if [ os.name ] in $(os-list:U) + { + host-os = [ os.name ] ; + } + else + { + switch [ os.name ] + { + case NT : host-os = windows ; + case AS400 : host-os = unix ; + case MINGW : host-os = windows ; + case BSDI : host-os = bsd ; + case COHERENT : host-os = unix ; + case DRAGONFLYBSD : host-os = bsd ; + case IRIX : host-os = sgi ; + case MACOSX : host-os = darwin ; + case KFREEBSD : host-os = freebsd ; + case * : host-os = unix ; + } + } + return $(host-os:L) ; +} + +# The two OS features define a known set of abstract OS +# names. The host-os is the OS under which bjam is running. +# Even though this should really be a fixed property we need +# to list all the values to prevent unkown value errors. +# Both set the default value to the current OS to account for +# the default use case of building on the target OS. +feature host-os + : amiga aix bsd cygwin darwin dos emx freebsd hpux + linux netbsd openbsd osf qnx qnxnto sgi solaris sun sunos + svr4 sysv ultrix unixware vms windows + : optional ; + feature.set-default host-os : [ default-host-os ] ; +feature target-os + : amiga aix bsd cygwin darwin dos emx freebsd hpux + linux netbsd openbsd osf qnx qnxnto sgi solaris sun sunos + svr4 sysv ultrix unixware vms windows + : propagated link-incompatible ; + feature.set-default target-os : [ default-host-os ] ; + + feature toolset : : implicit propagated symmetric ; feature stdlib : native : propagated composite ; From dd8d2f36561601a2efa07bf2178a5cccc7f043e1 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 15 Aug 2006 18:48:28 +0000 Subject: [PATCH 10/82] Add "project.extension" utility for declaring standalone extension projects. Add "conditional" project utility for simplifying conditional requirements. [SVN r34890] --- v2/build/project.jam | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/v2/build/project.jam b/v2/build/project.jam index feecab007..1455b6f5e 100644 --- a/v2/build/project.jam +++ b/v2/build/project.jam @@ -740,6 +740,29 @@ rule use ( id : location ) .current-project = $(saved-project) ; } +# Defines a Boost.Build extension project. Such extensions usually +# contain library targets and features that can be used by many people. +# Even though extensions are really projects, they can be initialize as +# a module would be with the "using" (project.project-rules.using) +# mechanism. +rule extension ( id : options * : * ) +{ + # The caller is a standalone module for the extension. + local mod = [ CALLER_MODULE ] ; + + # We need to do the rest within the extension module. + module $(mod) + { + # Create the project data, and bring in the project rules + # into the module. + project.initialize $(__name__) ; + + # Create the project itself, i.e. the attributes. + # All extensions are created in the "/ext" project space. + project /ext/$(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; + } +} + # This module defines rules common to all projects module project-rules { @@ -942,7 +965,19 @@ module project-rules } return $(result) ; - } + } + + # Calculates conditional requirements for multiple requirements + # at once. This is a shorthand to be reduce duplication and to + # keep an inline declarative syntax. For example: + # + # lib x : x.cpp : [ gcc debug : + # DEBUG_EXCEPTION DEBUG_TRACE ] ; + # + rule conditional ( condition + : requirements * ) + { + return $(condition:J=,):$(requirements) ; + } } From d48877e786cf776dd1cc6d2236376b8749857be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Wed, 16 Aug 2006 06:27:26 +0000 Subject: [PATCH 11/82] Add "unix" as default value for target-os and host-os. Add detection of "linux" in default-host-os. [SVN r34893] --- v2/tools/builtin.jam | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 74e81e5d7..5663d6cf5 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -53,6 +53,7 @@ local rule default-host-os ( ) case IRIX : host-os = sgi ; case MACOSX : host-os = darwin ; case KFREEBSD : host-os = freebsd ; + case LINUX : host-os = linux ; case * : host-os = unix ; } } @@ -68,13 +69,13 @@ local rule default-host-os ( ) feature host-os : amiga aix bsd cygwin darwin dos emx freebsd hpux linux netbsd openbsd osf qnx qnxnto sgi solaris sun sunos - svr4 sysv ultrix unixware vms windows + svr4 sysv ultrix unix unixware vms windows : optional ; feature.set-default host-os : [ default-host-os ] ; feature target-os : amiga aix bsd cygwin darwin dos emx freebsd hpux linux netbsd openbsd osf qnx qnxnto sgi solaris sun sunos - svr4 sysv ultrix unixware vms windows + svr4 sysv ultrix unix unixware vms windows : propagated link-incompatible ; feature.set-default target-os : [ default-host-os ] ; From cbc99070e0dee1de15c781cb1b4552d67a6df339 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 25 Aug 2006 07:22:22 +0000 Subject: [PATCH 12/82] Replace with as the former is old spelling that has no effect. [SVN r34946] --- v2/tools/python.jam | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 25ad9ac7a..d7a893b26 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -361,7 +361,7 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? : : $(PYTHON_LIB_PATH) $(PYTHON_INCLUDES) - $(lib) ; + $(lib) ; } else { @@ -390,7 +390,7 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? #else #{ properties += $(CYGWIN_PYTHON_LIB_PATH) - python$(CYGWIN_PYTHON_VERSION).dll ; + python$(CYGWIN_PYTHON_VERSION).dll ; properties += $(root)/include/python$(version) ; From bc17d322f8bca086d66638b5d59ceaba640e5071 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 28 Aug 2006 19:23:59 +0000 Subject: [PATCH 13/82] Add the output of @() generated files to the debug output of "-n" and "-d+2". The output is added as an additional pseudo action right before the command that uses the generated files. [SVN r34986] --- historic/jam/src/variable.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/historic/jam/src/variable.c b/historic/jam/src/variable.c index 4938fe989..c66ec53bd 100644 --- a/historic/jam/src/variable.c +++ b/historic/jam/src/variable.c @@ -291,8 +291,7 @@ var_string( } /* expand the file value into the file reference */ - if ( !globs.noexec ) - var_string_to_file( split+3, ine-split-4, file_name_s, lol ); + var_string_to_file( split+3, ine-split-4, file_name_s, lol ); /* continue on with the expansion */ out += strlen(out); @@ -352,7 +351,12 @@ void var_string_to_file( const char * in, int insize, const char * out, LOL * lo { const char * ine = in+insize; FILE * out_file = 0; - if ( strcmp( out, "STDOUT" ) == 0 ) + int out_debug = DEBUG_EXEC ? 1 : 0; + if ( globs.noexec ) + { + out_debug = 1; + } + else if ( strcmp( out, "STDOUT" ) == 0 ) { out_file = stdout; } @@ -382,6 +386,8 @@ void var_string_to_file( const char * in, int insize, const char * out, LOL * lo string_free(&out_name); } + if ( out_debug ) printf("\nfile %s\n",out); + while( *in && in < ine ) { int dollar = 0; @@ -396,7 +402,8 @@ void var_string_to_file( const char * in, int insize, const char * out, LOL * lo } if ( output_0 < output_1 ) { - fwrite(output_0,output_1-output_0,1,out_file); + if ( out_file ) fwrite(output_0,output_1-output_0,1,out_file); + if ( out_debug ) fwrite(output_0,output_1-output_0,1,stdout); } output_0 = output_1; @@ -411,7 +418,7 @@ void var_string_to_file( const char * in, int insize, const char * out, LOL * lo ++output_1; } - /* If a variable encountered, expand it and and embed the */ + /* If a variable encountered, expand it and embed the */ /* space-separated members of the list in the output. */ if( dollar ) @@ -422,26 +429,34 @@ void var_string_to_file( const char * in, int insize, const char * out, LOL * lo while ( l ) { - fputs( l->string, out_file ); + if ( out_file ) fputs( l->string, out_file ); + if ( out_debug ) puts( l->string ); l = list_next( l ); - if ( l ) fputc( ' ', out_file ); + if ( l ) + { + if ( out_file ) fputc( ' ', out_file ); + if ( out_debug ) fputc( ' ', stdout ); + } } list_free( l ); } else if ( output_0 < output_1 ) { - fwrite(output_0,output_1-output_0,1,out_file); + if ( out_file ) fwrite(output_0,output_1-output_0,1,out_file); + if ( out_debug ) fwrite(output_0,output_1-output_0,1,stdout); } in = output_1; } - if ( out_file != stdout && out_file != stderr ) + if ( out_file && out_file != stdout && out_file != stderr ) { fflush( out_file ); fclose( out_file ); } + + if ( out_debug ) fputc('\n',stdout); } /* From 38e6e08970861c91ed586b592cab7c613285f53b Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 28 Aug 2006 19:31:34 +0000 Subject: [PATCH 14/82] Applied path from Yakov Markovitch: [ 1538176 ] VARNAMES bjam rule doesn't work for global module. [SVN r34987] --- historic/jam/src/builtins.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/historic/jam/src/builtins.c b/historic/jam/src/builtins.c index 20d413b7c..30aa649ad 100644 --- a/historic/jam/src/builtins.c +++ b/historic/jam/src/builtins.c @@ -937,6 +937,17 @@ static void add_hash_key( void* np, void* result_ ) *result = list_new( *result, copystr( *(char**)np ) ); } +static struct hash *get_running_module_vars() +{ + struct hash *dummy, *vars = NULL; + /* Get the global variables pointer (that of the currently running module) */ + var_hash_swap(&vars); + dummy = vars; + /* Put the global variables pointer in its right place */ + var_hash_swap(&dummy); + return vars; +} + LIST * builtin_varnames( PARSE *parse, @@ -946,8 +957,14 @@ builtin_varnames( LIST *result = L0; module_t* source_module = bindmodule( arg0 ? arg0->string : 0 ); - if ( source_module->variables ) - hashenumerate( source_module->variables, add_hash_key, &result ); + /* The running module _always_ has its 'variables' member set to NULL + * due to the way enter_module and var_hash_swap work */ + struct hash *vars = + source_module == frame->module ? + get_running_module_vars() : source_module->variables; + + if ( vars ) + hashenumerate( vars, add_hash_key, &result ); return result; } From 78b73ef471459295c5278bdbd307c6af16dba966 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 29 Aug 2006 14:58:17 +0000 Subject: [PATCH 15/82] Output generated files only when debug output is on, -n turns this on but -d+10 doesn't. [SVN r34992] --- historic/jam/src/variable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/historic/jam/src/variable.c b/historic/jam/src/variable.c index c66ec53bd..596e360a2 100644 --- a/historic/jam/src/variable.c +++ b/historic/jam/src/variable.c @@ -354,7 +354,7 @@ void var_string_to_file( const char * in, int insize, const char * out, LOL * lo int out_debug = DEBUG_EXEC ? 1 : 0; if ( globs.noexec ) { - out_debug = 1; + /* out_debug = 1; */ } else if ( strcmp( out, "STDOUT" ) == 0 ) { From c31700979c3635fb015ad2ccf223ec3d555bca21 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 29 Aug 2006 20:59:37 +0000 Subject: [PATCH 16/82] Merge tab removal. [SVN r34995] --- v2/test/indirect_conditional.py | 2 +- v2/test/project-test3/lib3/Jamfile | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/v2/test/indirect_conditional.py b/v2/test/indirect_conditional.py index 0b16b1b61..b877e37cc 100644 --- a/v2/test/indirect_conditional.py +++ b/v2/test/indirect_conditional.py @@ -17,7 +17,7 @@ rule a1-rule ( properties * ) { if debug in $(properties) { - return OK ; + return OK ; } } diff --git a/v2/test/project-test3/lib3/Jamfile b/v2/test/project-test3/lib3/Jamfile index 4cecf63ac..a6e61f6b6 100644 --- a/v2/test/project-test3/lib3/Jamfile +++ b/v2/test/project-test3/lib3/Jamfile @@ -11,10 +11,10 @@ rule properties-as-path ( properties * ) local r ; for local p in $(properties) { - if $(p:G) != - { - r += $(p) ; - } + if $(p:G) != + { + r += $(p) ; + } } return [ property.as-path [ property.remove incidental : $(r) ] ] ; From 695e72261022e4aae900460688f26d3b3a91b6fb Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Wed, 30 Aug 2006 20:56:26 +0000 Subject: [PATCH 17/82] Fix QNX's dependency on pthread (which doesn't exist on those systems). Clean up the comments a bit. [SVN r35002] --- v2/tools/python.jam | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index d7a893b26..31dab7505 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -139,22 +139,12 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) switch [ os.name ] { - case SOLARIS : extra-libs = dl ; - case OSF : extra-libs = ; - case QNX* : extra-libs = ; - case * : extra-libs = dl util ; + case SOLARIS : extra-libs = pthread dl ; + case OSF : extra-libs = pthread ; + case QNX* : extra-libs = ; + case * : extra-libs = pthread dl util ; } - # Depending on system, Python library is either static - # or shared. When it's static, we need to add 'pthread' - # to link line of all clients, otherwise we'll get - # unresolved symbols. Same effect can be accomplished - # by using multi on the client, but - # that can have performance overhead, and is not really - # necessary, as Python interface has nothing that's - # affected by threading mode. - extra-libs += pthread ; - extra-libs-conditional = ; # Add 'rt' option on Sun. While we duplicate the # logic already in sun.jam and gcc.jam, I see no easy @@ -175,12 +165,11 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) } } - # On Linux, we don't want to link either Boost.Python or - # Python extensions to libpython, so that when extensions - # loaded in the interpreter, the symbols in the interpreter - # are used. If we linked to libpython, we'd get duplicate - # symbols. So declare two targets -- one for headers and another - # for library. + # On *nix, we don't want to link either Boost.Python or Python + # extensions to libpython, because the Python interpreter itself + # provides all those symbols. If we linked to libpython, we'd get + # duplicate symbols. So declare two targets -- one for building + # extensions and another embedding alias python_for_extensions : : $(condition) @@ -188,6 +177,7 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) : $(includes) ; + # This should really be called python_for_embedding alias python : $(extra-libs) : $(condition) $(extra-libs-conditional) From 940223299430416dce6050e25fb71e1c2e576f0a Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 31 Aug 2006 02:48:23 +0000 Subject: [PATCH 18/82] Added missing cygwin support. [SVN r35004] --- v2/tools/python.jam | 50 ++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 31dab7505..e59beeada 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -45,6 +45,8 @@ project python ; # not in whatever project we were called by. .project = [ project.current ] ; +.alias-defined = ; + # Dynamic linker lib. Necessary to specify it explicitly # on some platforms. lib dl ; @@ -95,6 +97,13 @@ rule init ( version ? : root ? : includes ? : libraries ? init-unix $(version) : $(root) : $(includes) : $(libraries) : $(cygwin-condition) ; } + if [ os.on-windows ] && ! $(.alias-defined) + { + .alias-defined = true ; + alias python_for_extensions : python ; + } + + project.pop-current ; } @@ -164,18 +173,22 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) extra-libs-conditional += gcc:rt ; } } - - # On *nix, we don't want to link either Boost.Python or Python - # extensions to libpython, because the Python interpreter itself - # provides all those symbols. If we linked to libpython, we'd get - # duplicate symbols. So declare two targets -- one for building - # extensions and another embedding - alias python_for_extensions - : - : $(condition) - : - : $(includes) - ; + + if ! [ os.on-windows ] + { + # On *nix, we don't want to link either Boost.Python or Python + # extensions to libpython, because the Python interpreter itself + # provides all those symbols. If we linked to libpython, we'd get + # duplicate symbols. So declare two targets -- one for building + # extensions and another embedding + alias python_for_extensions + : + : $(condition) + : + : $(includes) + ; + } + # This should really be called python_for_embedding alias python @@ -187,6 +200,7 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) python$(version) ; + # NOTES: # - V1 had logic to force intel to use gcc's runtime. # Note sure why that was needed, with icc 8.0 extensions @@ -265,7 +279,6 @@ rule init-mac ( version : root ? : includes ? : libraries ? ) ; } -.alias-defined = ; rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? ) { # PYTHON_PROPERTIES = @@ -392,12 +405,6 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? : $(properties) ; } - - if ! $(.alias-defined) - { - .alias-defined = true ; - alias python_for_extensions : python ; - } } @@ -407,13 +414,14 @@ rule configured ( ) } type.register PYTHON_EXTENSION : : SHARED_LIB ; + # We can't give "dll" suffix to PYTHON_EXTENSION, because # we would not know what "a.dll" is: python extenstion or # ordinary library. Therefore, we specify only suffixes # used for generation of targets. type.set-generated-target-suffix PYTHON_EXTENSION : : so ; -type.set-generated-target-suffix PYTHON_EXTENSION : NT : dll ; -type.set-generated-target-suffix PYTHON_EXTENSION : CYGWIN : so ; +type.set-generated-target-suffix PYTHON_EXTENSION : NT : pyd ; +type.set-generated-target-suffix PYTHON_EXTENSION : CYGWIN : dll ; # Unset 'lib' prefix for PYTHON_EXTENSION type.set-generated-target-prefix PYTHON_EXTENSION : : "" ; From 8120e440ab89985ee5ba313b43196b3840cfd83c Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 31 Aug 2006 08:01:13 +0000 Subject: [PATCH 19/82] Really remove the dot from the Python version when forming library name. [SVN r35007] --- v2/tools/python.jam | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index e59beeada..16dbe3217 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -300,7 +300,22 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? PYTHON_INCLUDES ?= $(root)/include [ GLOB $(root) : PC ] ; - local PYTHON_VERSION_NODOT = [ regex.match ([0-9]+[.][0-9]+).* : $(version) : 1 ] ; + # The name of Python library file does not have a dot between + # major and minor version. + local PYTHON_VERSION_NODOT = [ regex.match ([0-9]+)[.]([0-9]+).* : $(version) : 1 2 ] ; + if $(PYTHON_VERSION_NODOT) + { + PYTHON_VERSION_NODOT = $(PYTHON_VERSION_NODOT[1])$(PYTHON_VERSION_NODOT[2]) ; + } + else + { + # Try to link to 'python' lib, without version. Probably won't + # work, but better that not passing any library name at all. + PYTHON_VERSION_NODOT = "" ; + } + + + PYTHON_DLL ?= [ GLOB $(PATH) $(Path) : python$(PYTHON_VERSION_NODOT).dll ] ; PYTHON_DEBUG_DLL ?= [ GLOB $(PATH) $(Path) : python$(PYTHON_VERSION_NODOT)_d.dll ] ; PYTHON_IMPORT_LIB ?= [ GLOB $(PYTHON_LIB_PATH) : libpython$(PYTHON_VERSION_NODOT).* ] ; @@ -318,6 +333,7 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? ECHO "notice: Python include path is" $(includes) ; ECHO "notice: Python library path is" $(libraries) ; ECHO "notice: Python interpreter is" $(interpreter) ; + ECHO "notice: Python library name is" python$(PYTHON_VERSION_NODOT) ; } flags python.capture-output PYTHON : $(interpreter) ; From b7eeee0488fbd4c3474d40d5a7c9e9cf8d1767c1 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 31 Aug 2006 08:08:15 +0000 Subject: [PATCH 20/82] Revive pthread & python comment [SVN r35009] --- v2/tools/python.jam | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 16dbe3217..3f266d905 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -145,7 +145,15 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) local extra-libs ; - + + # Depending on system, Python library is either static + # or shared. When it's static, we need to add 'pthread' + # to link line of all clients, otherwise we'll get + # unresolved symbols. Same effect can be accomplished + # by using multi on the client, but + # that can have performance overhead, and is not really + # necessary, as Python interface has nothing that's + # affected by threading mode. switch [ os.name ] { case SOLARIS : extra-libs = pthread dl ; From ac30f01631e3743fcdeb2a599812b81b1b111f80 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Thu, 7 Sep 2006 03:57:02 +0000 Subject: [PATCH 21/82] Cleanup memory allocation calls to use macros defined in new mem.h header. This new header will handle configuration of both memory allocator to use, and memory profiling. [SVN r35029] --- historic/jam/src/build.jam | 1 + historic/jam/src/builtins.c | 1 - historic/jam/src/command.c | 17 +++----- historic/jam/src/compile.c | 6 +-- historic/jam/src/debug.c | 1 - historic/jam/src/execnt.c | 33 +++++--------- historic/jam/src/execunix.c | 4 +- historic/jam/src/filent.c | 5 +-- historic/jam/src/fileunix.c | 7 +-- historic/jam/src/hash.c | 24 +++-------- historic/jam/src/hcache.c | 2 +- historic/jam/src/jam.c | 9 ++-- historic/jam/src/jam.h | 6 +++ historic/jam/src/lists.c | 5 +-- historic/jam/src/make.c | 6 +++ historic/jam/src/make1.c | 8 ++-- historic/jam/src/mem.h | 74 ++++++++++++++++++++++++++++++++ historic/jam/src/modules.c | 1 - historic/jam/src/modules/order.c | 23 ++++------ historic/jam/src/modules/regex.c | 6 +-- historic/jam/src/newstr.c | 9 ++-- historic/jam/src/parse.c | 7 +-- historic/jam/src/regexp.c | 6 +-- historic/jam/src/rules.c | 35 +++++---------- historic/jam/src/scan.c | 7 +-- historic/jam/src/strings.c | 10 ++--- historic/jam/src/timestamp.c | 1 - 27 files changed, 160 insertions(+), 154 deletions(-) create mode 100644 historic/jam/src/mem.h diff --git a/historic/jam/src/build.jam b/historic/jam/src/build.jam index 43c024173..f95b31c91 100644 --- a/historic/jam/src/build.jam +++ b/historic/jam/src/build.jam @@ -418,6 +418,7 @@ if ! $(debug) || --noassert in $(ARGV) --defs += OPT_GRAPH_DEBUG_EXT ; --defs += OPT_SEMAPHORE ; --defs += OPT_AT_FILES ; +--defs += OPT_DEBUG_PROFILE ; # Bug fixes --defs += OPT_FIX_TARGET_VARIABLES_EXT ; diff --git a/historic/jam/src/builtins.c b/historic/jam/src/builtins.c index 30aa649ad..6be62b9d2 100644 --- a/historic/jam/src/builtins.c +++ b/historic/jam/src/builtins.c @@ -5,7 +5,6 @@ */ # include "jam.h" -# include "debug.h" # include "lists.h" # include "parse.h" diff --git a/historic/jam/src/command.c b/historic/jam/src/command.c index 727a3278c..712bd211e 100644 --- a/historic/jam/src/command.c +++ b/historic/jam/src/command.c @@ -20,7 +20,6 @@ # include "parse.h" # include "variable.h" # include "rules.h" -# include "debug.h" # include "command.h" # include @@ -37,15 +36,12 @@ cmd_new( LIST *sources, LIST *shell ) { - CMD *cmd = (CMD *)malloc( sizeof( CMD ) ); + CMD *cmd = (CMD *)BJAM_MALLOC( sizeof( CMD ) ); /* lift line-length limitation entirely when JAMSHELL is just "%" */ int no_limit = ( shell && !strcmp(shell->string,"%") && !list_next(shell) ); int max_line = MAXLINE; int allocated = -1; - if ( DEBUG_PROFILE ) - profile_memory( sizeof( CMD ) ); - cmd->rule = rule; cmd->shell = shell; cmd->next = 0; @@ -57,12 +53,9 @@ cmd_new( do { - free(cmd->buf); /* free any buffer from previous iteration */ + BJAM_FREE(cmd->buf); /* free any buffer from previous iteration */ - cmd->buf = (char*)malloc(max_line + 1); - - if ( DEBUG_PROFILE ) - profile_memory( max_line + 1 ); + cmd->buf = (char*)BJAM_MALLOC(max_line + 1); if (cmd->buf == 0) break; @@ -106,6 +99,6 @@ cmd_free( CMD *cmd ) { lol_free( &cmd->args ); list_free( cmd->shell ); - free( cmd->buf ); - free( (char *)cmd ); + BJAM_FREE( cmd->buf ); + BJAM_FREE( (char *)cmd ); } diff --git a/historic/jam/src/compile.c b/historic/jam/src/compile.c index 75464cf75..f44eb1213 100644 --- a/historic/jam/src/compile.c +++ b/historic/jam/src/compile.c @@ -11,7 +11,6 @@ */ # include "jam.h" -# include "debug.h" # include "lists.h" # include "parse.h" @@ -1007,12 +1006,9 @@ evaluate_rule( /* The action is associated with this instance of this rule */ - action = (ACTION *)malloc( sizeof( ACTION ) ); + action = (ACTION *)BJAM_MALLOC( sizeof( ACTION ) ); memset( (char *)action, '\0', sizeof( *action ) ); - if ( DEBUG_PROFILE ) - profile_memory( sizeof( ACTION ) ); - action->rule = rule; action->targets = targetlist( (TARGETS *)0, lol_get( frame->args, 0 ) ); action->sources = targetlist( (TARGETS *)0, lol_get( frame->args, 1 ) ); diff --git a/historic/jam/src/debug.c b/historic/jam/src/debug.c index d3f5ef04f..c6635d0d1 100644 --- a/historic/jam/src/debug.c +++ b/historic/jam/src/debug.c @@ -5,7 +5,6 @@ */ # include "jam.h" -# include "debug.h" # include "hash.h" diff --git a/historic/jam/src/execnt.c b/historic/jam/src/execnt.c index 081bc56ef..930ac3c11 100644 --- a/historic/jam/src/execnt.c +++ b/historic/jam/src/execnt.c @@ -14,7 +14,6 @@ # include "lists.h" # include "execcmd.h" # include "pathsys.h" -# include "debug.h" # include # include # include @@ -116,8 +115,8 @@ int maxline() static void free_argv( char** args ) { - free( args[0] ); - free( args ); + BJAM_FREE( args[0] ); + BJAM_FREE( args ); } /* Convert a command string into arguments for spawnvp. The original @@ -150,27 +149,21 @@ string_to_args( const char* string ) /* Copy the input string into a buffer we can modify */ - line = (char*)malloc( src_len+1 ); + line = (char*)BJAM_MALLOC( src_len+1 ); if (!line) return 0; - if ( DEBUG_PROFILE ) - profile_memory( src_len+1 ); - /* allocate the argv array. * element 0: stores the path to the executable * element 1: stores the command-line arguments to the executable * element 2: NULL terminator */ - argv = (char**)malloc( 3 * sizeof(char*) ); + argv = (char**)BJAM_MALLOC( 3 * sizeof(char*) ); if (!argv) { - free( line ); + BJAM_FREE( line ); return 0; } - - if ( DEBUG_PROFILE ) - profile_memory( 3 * sizeof(char*) ); /* Strip quotes from the first command-line argument and find * where it ends. Quotes are illegal in Win32 pathnames, so we @@ -287,11 +280,9 @@ process_del( char* command ) if ( len <= 0 ) return 1; - line = (char*)malloc( len+4+1 ); + line = (char*)BJAM_MALLOC( len+4+1 ); if (!line) return 1; - if ( DEBUG_PROFILE ) - profile_memory( len+4+1 ); strncpy( line, "del ", 4 ); strncpy( line+4, q, len ); @@ -302,7 +293,7 @@ process_del( char* command ) else result = !DeleteFile( line+4 ); - free( line ); + BJAM_FREE( line ); if (result) return 1; @@ -419,12 +410,12 @@ void execnt_unit_test() } { - char* long_command = malloc(MAXLINE + 10); + char* long_command = BJAM_MALLOC(MAXLINE + 10); assert( long_command != 0 ); memset( long_command, 'x', MAXLINE + 9 ); long_command[MAXLINE + 9] = 0; assert( can_spawn( long_command ) == MAXLINE + 9); - free( long_command ); + BJAM_FREE( long_command ); } { @@ -554,9 +545,7 @@ execcmd( DWORD procID = GetCurrentProcessId(); /* SVA - allocate 64 other just to be safe */ - cmdtab[ slot ].tempfile = malloc( strlen( tempdir ) + 64 ); - if ( DEBUG_PROFILE ) - profile_memory( strlen( tempdir ) + 64 ); + cmdtab[ slot ].tempfile = BJAM_MALLOC( strlen( tempdir ) + 64 ); sprintf( cmdtab[ slot ].tempfile, "%s\\jam%d-%02d.bat", tempdir, procID, slot ); @@ -840,7 +829,7 @@ execwait() /* SVA don't leak temp files */ if(cmdtab[i].tempfile != NULL) { - free(cmdtab[i].tempfile); + BJAM_FREE(cmdtab[i].tempfile); cmdtab[i].tempfile = NULL; } (*cmdtab[ i ].func)( cmdtab[ i ].closure, rstat, &time ); diff --git a/historic/jam/src/execunix.c b/historic/jam/src/execunix.c index 812dfeb8d..b543fbff9 100644 --- a/historic/jam/src/execunix.c +++ b/historic/jam/src/execunix.c @@ -256,9 +256,7 @@ my_wait( int *status ) if (!active_handles) { - active_handles = (HANDLE *)malloc(globs.jobs * sizeof(HANDLE) ); - if ( DEBUG_PROFILE ) - profile_memory( globs.jobs * sizeof(HANDLE) ); + active_handles = (HANDLE *)BJAM_MALLOC(globs.jobs * sizeof(HANDLE) ); } /* first see if any non-waited-for processes are dead, diff --git a/historic/jam/src/filent.c b/historic/jam/src/filent.c index 170a992d4..9c37b4e45 100644 --- a/historic/jam/src/filent.c +++ b/historic/jam/src/filent.c @@ -12,7 +12,6 @@ */ # include "jam.h" -# include "debug.h" # include "filesys.h" # include "pathsys.h" @@ -306,9 +305,7 @@ file_archscan( ** 15 characters (ie. don't fit into a ar_name */ - string_table = malloc(lar_size+1); - if ( DEBUG_PROFILE ) - profile_memory( lar_size+1 ); + string_table = BJAM_MALLOC(lar_size+1); if (read(fd, string_table, lar_size) != lar_size) printf("error reading string table\n"); string_table[lar_size] = '\0'; diff --git a/historic/jam/src/fileunix.c b/historic/jam/src/fileunix.c index 01eaad398..1f86d7d0f 100644 --- a/historic/jam/src/fileunix.c +++ b/historic/jam/src/fileunix.c @@ -12,7 +12,6 @@ */ # include "jam.h" -# include "debug.h" # include "filesys.h" # include "strings.h" # include "pathsys.h" @@ -326,9 +325,7 @@ file_archscan( ** 15 characters (ie. don't fit into a ar_name */ - string_table = (char *)malloc(lar_size); - if ( DEBUG_PROFILE ) - profile_memory( lar_size ); + string_table = (char *)BJAM_MALLOC(lar_size); lseek(fd, offset + SARHDR, 0); if (read(fd, string_table, lar_size) != lar_size) printf("error reading string table\n"); @@ -365,7 +362,7 @@ file_archscan( } if (string_table) - free(string_table); + BJAM_FREE(string_table); close( fd ); diff --git a/historic/jam/src/hash.c b/historic/jam/src/hash.c index dda649381..5e28dd1f9 100644 --- a/historic/jam/src/hash.c +++ b/historic/jam/src/hash.c @@ -7,7 +7,6 @@ # include "jam.h" # include "hash.h" # include "compile.h" -#include "debug.h" # include /* @@ -225,24 +224,18 @@ static void hashrehash( register struct hash *hp ) { int i = ++hp->items.list; hp->items.more = i ? 2 * hp->items.nel : hp->inel; - hp->items.next = (char *)malloc( hp->items.more * hp->items.size ); + hp->items.next = (char *)BJAM_MALLOC( hp->items.more * hp->items.size ); hp->items.free = 0; - - if ( DEBUG_PROFILE ) - profile_memory( hp->items.more * hp->items.size ); hp->items.lists[i].nel = hp->items.more; hp->items.lists[i].base = hp->items.next; hp->items.nel += hp->items.more; if( hp->tab.base ) - free( (char *)hp->tab.base ); + BJAM_FREE( (char *)hp->tab.base ); hp->tab.nel = hp->items.nel * hp->bloat; - hp->tab.base = (ITEM **)malloc( hp->tab.nel * sizeof(ITEM **) ); - - if ( DEBUG_PROFILE ) - profile_memory( hp->tab.nel * sizeof(ITEM **) ); + hp->tab.base = (ITEM **)BJAM_MALLOC( hp->tab.nel * sizeof(ITEM **) ); memset( (char *)hp->tab.base, '\0', hp->tab.nel * sizeof( ITEM * ) ); @@ -297,10 +290,7 @@ hashinit( int datalen, char *name ) { - struct hash *hp = (struct hash *)malloc( sizeof( *hp ) ); - - if ( DEBUG_PROFILE ) - profile_memory( sizeof( *hp ) ); + struct hash *hp = (struct hash *)BJAM_MALLOC( sizeof( *hp ) ); hp->bloat = 3; hp->tab.nel = 0; @@ -333,10 +323,10 @@ hashdone( struct hash *hp ) hashstat( hp ); if( hp->tab.base ) - free( (char *)hp->tab.base ); + BJAM_FREE( (char *)hp->tab.base ); for( i = 0; i <= hp->items.list; i++ ) - free( hp->items.lists[i].base ); - free( (char *)hp ); + BJAM_FREE( hp->items.lists[i].base ); + BJAM_FREE( (char *)hp ); } /* ---- */ diff --git a/historic/jam/src/hcache.c b/historic/jam/src/hcache.c index 091254684..5d2f24140 100644 --- a/historic/jam/src/hcache.c +++ b/historic/jam/src/hcache.c @@ -137,7 +137,7 @@ read_netstring(FILE* f) unsigned long new_len = buf_len * 2; if (new_len < len) new_len = len; - buf = (char*)realloc(buf, new_len + 1); + buf = (char*)BJAM_REALLOC(buf, new_len + 1); if (buf) buf_len = new_len; } diff --git a/historic/jam/src/jam.c b/historic/jam/src/jam.c index 633f19b1d..a8d4d920d 100644 --- a/historic/jam/src/jam.c +++ b/historic/jam/src/jam.c @@ -121,7 +121,6 @@ # include "make.h" # include "strings.h" # include "expand.h" -# include "debug.h" # include "filesys.h" /* Macintosh is "special" */ @@ -218,6 +217,8 @@ int main( int argc, char **argv, char **arg_environ ) int arg_c = argc; char ** arg_v = argv; const char *progname = argv[0]; + + BJAM_MEM_INIT(); # ifdef OS_MAC InitGraf(&qd.thePort); @@ -485,10 +486,8 @@ int main( int argc, char **argv, char **arg_environ ) else { int targets_count = list_length(targets); - const char **targets2 = (const char **)malloc(targets_count * sizeof(char *)); + const char **targets2 = (const char **)BJAM_MALLOC(targets_count * sizeof(char *)); int n = 0; - if ( DEBUG_PROFILE ) - profile_memory( targets_count * sizeof(char *) ); for ( ; targets; targets = list_next(targets) ) { targets2[n++] = targets->string; @@ -522,6 +521,8 @@ int main( int argc, char **argv, char **arg_environ ) #ifdef HAVE_PYTHON Py_Finalize(); #endif + + BJAM_MEM_CLOSE(); return status ? EXITBAD : EXITOK; diff --git a/historic/jam/src/jam.h b/historic/jam/src/jam.h index 5ecc3ac83..c15df9292 100644 --- a/historic/jam/src/jam.h +++ b/historic/jam/src/jam.h @@ -556,4 +556,10 @@ extern struct globs globs; # define DEBUG_GRAPH ( globs.debug[ 12 ] ) /* debug dependencies */ # define DEBUG_FATE ( globs.debug[ 13 ] ) /* show changes to fate in make0() */ +/* Everyone gets the memory definitions. */ +#include "mem.h" + +/* They also get the profile functions. */ +#include "debug.h" + #endif diff --git a/historic/jam/src/lists.c b/historic/jam/src/lists.c index 92440288c..205c9777b 100644 --- a/historic/jam/src/lists.c +++ b/historic/jam/src/lists.c @@ -7,7 +7,6 @@ # include "jam.h" # include "newstr.h" # include "lists.h" -# include "debug.h" /* * lists.c - maintain lists of strings @@ -81,9 +80,7 @@ list_new( } else { - l = (LIST *)malloc( sizeof( LIST ) ); - if ( DEBUG_PROFILE ) - profile_memory( sizeof( LIST ) ); + l = (LIST *)BJAM_MALLOC( sizeof( LIST ) ); } /* If first on chain, head points here. */ diff --git a/historic/jam/src/make.c b/historic/jam/src/make.c index a112855af..5bb5dc34b 100644 --- a/historic/jam/src/make.c +++ b/historic/jam/src/make.c @@ -126,12 +126,14 @@ make( */ bind_explicitly_located_targets(); + { PROFILE_ENTER(MAKE_MAKE0); for( i = 0; i < n_targets; i++ ) { TARGET *t = bindtarget( targets[i] ); make0( t, 0, 0, counts, anyhow ); } + PROFILE_EXIT(MAKE_MAKE0); } #ifdef OPT_GRAPH_DEBUG_EXT if( DEBUG_GRAPH ) @@ -169,8 +171,10 @@ make( status = counts->cantfind || counts->cantmake; + { PROFILE_ENTER(MAKE_MAKE1); for( i = 0; i < n_targets; i++ ) status |= make1( bindtarget( targets[i] ) ); + PROFILE_EXIT(MAKE_MAKE1); } return status; } @@ -795,6 +799,7 @@ dependGraphOutput( TARGET *t, int depth ) static TARGETS * make0sort( TARGETS *chain ) { + PROFILE_ENTER(MAKE_MAKE0SORT); TARGETS *result = 0; /* We walk chain, taking each item and inserting it on the */ @@ -829,6 +834,7 @@ make0sort( TARGETS *chain ) s->tail = c; /* make next's prev us */ } + PROFILE_EXIT(MAKE_MAKE0SORT); return result; } diff --git a/historic/jam/src/make1.c b/historic/jam/src/make1.c index 030009e78..2636ad116 100644 --- a/historic/jam/src/make1.c +++ b/historic/jam/src/make1.c @@ -127,9 +127,7 @@ static state *alloc_state() } else { - if ( DEBUG_PROFILE ) - profile_memory( sizeof(state) ); - return (state *)malloc(sizeof(state)); + return (state *)BJAM_MALLOC(sizeof(state)); } } @@ -145,7 +143,7 @@ static void clear_state_freelist() { state *pState = state_freelist; state_freelist = state_freelist->prev; - free(pState); + BJAM_FREE(pState); } } @@ -650,7 +648,7 @@ make1c( state *pState ) if( DEBUG_EXECCMD ) printf( "SEM: placing %s on stack\n", first->target->name); push_state(&temp_stack, first->target, NULL, T_STATE_MAKE1B); - free( first ); + BJAM_FREE( first ); } } #endif diff --git a/historic/jam/src/mem.h b/historic/jam/src/mem.h new file mode 100644 index 000000000..ed6f2ea52 --- /dev/null +++ b/historic/jam/src/mem.h @@ -0,0 +1,74 @@ +/* +Copyright Rene Rivera 2006. +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) +*/ + +#ifndef BJAM_MEM_H +#define BJAM_MEM_H + + +#ifdef OPT_BOEHM_GC + + /* Use Boehm GC memory allocator. */ + #include + #define bjam_malloc_x(s) GC_malloc(s) + #define bjam_malloc_atomic_x(s) GC_malloc_atomic(s) + #define bjam_calloc_x(n,s) memset(GC_malloc((n)*(s)),0,(n)*(s)) + #define bjam_calloc_atomic_x(n,s) memset(GC_malloc_atomic((n)*(s)),0,(n)*(s)) + #define bjam_realloc_x(p,s) GC_realloc(p,s) + #define bjam_free_x(p) GC_free(p) + #define bjam_mem_init_x() GC_init() + +#else + + /* Standard C memory allocation. */ + #define bjam_malloc_x(s) malloc(s) + #define bjam_calloc_x(n,s) calloc(n,s) + #define bjam_realloc_x(p,s) realloc(p,s) + #define bjam_free_x(p) free(p) + +#endif + +#ifndef bjam_malloc_atomic_x + #define bjam_malloc_atomic_x(s) bjam_malloc_x(s) +#endif +#ifndef bjam_calloc_atomic_x + #define bjam_calloc_atomic_x(s) bjam_calloc_x(s) +#endif +#ifndef bjam_mem_init_x + #define bjam_mem_init_x() +#endif +#ifndef bjam_mem_close_x + #define bjam_mem_close_x() +#endif + +#ifdef OPT_DEBUG_PROFILE + + /* Profile tracing of memory allocations. */ + #define BJAM_MALLOC(s) (profile_memory(s), bjam_malloc_x(s)) + #define BJAM_MALLOC_ATOMIC(s) (profile_memory(s), bjam_malloc_atomic_x(s)) + #define BJAM_CALLOC(n,s) (profile_memory(n*s), bjam_calloc_x(n,s)) + #define BJAM_CALLOC_ATOMIC(n,s) (profile_memory(n*s), bjam_calloc_atomic_x(n,s)) + #define BJAM_REALLOC(p,s) (profile_memory(s), bjam_realloc_x(p,s)) + #define BJAM_FREE(p) bjam_free_x(p) + #define BJAM_MEM_INIT() bjam_mem_init_x() + #define BJAM_MEM_CLOSE() bjam_mem_close_x() + +#else + + /* No mem tracing. */ + #define BJAM_MALLOC(s) bjam_malloc_x(s) + #define BJAM_MALLOC_ATOMIC(s) bjam_malloc_atomic_x(s) + #define BJAM_CALLOC(n,s) bjam_calloc_x(n,s) + #define BJAM_CALLOC_ATOMIC(n,s) bjam_calloc_atomic_x(n,s) + #define BJAM_REALLOC(p,s) bjam_realloc_x(p,s) + #define BJAM_FREE(p) bjam_free_x(p) + #define BJAM_MEM_INIT() bjam_mem_init_x() + #define BJAM_MEM_CLOSE() bjam_mem_close_x() + +#endif + + +#endif diff --git a/historic/jam/src/modules.c b/historic/jam/src/modules.c index ea874b640..938802ae0 100644 --- a/historic/jam/src/modules.c +++ b/historic/jam/src/modules.c @@ -4,7 +4,6 @@ * (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) */ #include "jam.h" -#include "debug.h" #include "modules.h" #include "string.h" diff --git a/historic/jam/src/modules/order.c b/historic/jam/src/modules/order.c index 848c35ee1..48761e80d 100644 --- a/historic/jam/src/modules/order.c +++ b/historic/jam/src/modules/order.c @@ -7,7 +7,6 @@ #include "../strings.h" #include "../newstr.h" #include "../variable.h" -#include "../debug.h" /* Use quite klugy approach: when we add order dependency from 'a' to 'b', @@ -62,9 +61,7 @@ void do_ts(int** graph, int current_vertex, int* colors, int** result_ptr) void topological_sort(int** graph, int num_vertices, int* result) { int i; - int* colors = (int*)calloc(num_vertices, sizeof(int)); - if ( DEBUG_PROFILE ) - profile_memory( num_vertices*sizeof(int) ); + int* colors = (int*)BJAM_CALLOC(num_vertices, sizeof(int)); for (i = 0; i < num_vertices; ++i) colors[i] = white; @@ -72,7 +69,7 @@ void topological_sort(int** graph, int num_vertices, int* result) if (colors[i] == white) do_ts(graph, i, colors, &result); - free(colors); + BJAM_FREE(colors); } LIST *order( PARSE *parse, FRAME *frame ) @@ -87,10 +84,8 @@ LIST *order( PARSE *parse, FRAME *frame ) passed to 'add_pair'. */ int length = list_length(arg); - int** graph = (int**)calloc(length, sizeof(int*)); - int* order = (int*)malloc((length+1)*sizeof(int)); - if ( DEBUG_PROFILE ) - profile_memory( length*sizeof(int*) + (length+1)*sizeof(int) ); + int** graph = (int**)BJAM_CALLOC(length, sizeof(int*)); + int* order = (int*)BJAM_MALLOC((length+1)*sizeof(int)); for(tmp = arg, src = 0; tmp; tmp = tmp->next, ++src) { /* For all object this one depend upon, add elements @@ -98,9 +93,7 @@ LIST *order( PARSE *parse, FRAME *frame ) LIST* dependencies = var_get(tmp->string); int index = 0; - graph[src] = (int*)calloc(list_length(dependencies)+1, sizeof(int)); - if ( DEBUG_PROFILE ) - profile_memory( (list_length(dependencies)+1)*sizeof(int) ); + graph[src] = (int*)BJAM_CALLOC(list_length(dependencies)+1, sizeof(int)); for(; dependencies; dependencies = dependencies->next) { int dst = list_index(arg, dependencies->string); if (dst != -1) @@ -125,9 +118,9 @@ LIST *order( PARSE *parse, FRAME *frame ) { int i; for(i = 0; i < length; ++i) - free(graph[i]); - free(graph); - free(order); + BJAM_FREE(graph[i]); + BJAM_FREE(graph); + BJAM_FREE(order); } return result; diff --git a/historic/jam/src/modules/regex.c b/historic/jam/src/modules/regex.c index 4f3cc8f46..d048ba1de 100644 --- a/historic/jam/src/modules/regex.c +++ b/historic/jam/src/modules/regex.c @@ -41,7 +41,7 @@ LIST *regex_transform( PARSE *parse, FRAME *frame ) if (indices_list) { size = list_length(indices_list); - indices = (int*)malloc(size*sizeof(int)); + indices = (int*)BJAM_MALLOC(size*sizeof(int)); for(p = indices; indices_list; indices_list = indices_list->next) { *p++ = atoi(indices_list->string); @@ -50,7 +50,7 @@ LIST *regex_transform( PARSE *parse, FRAME *frame ) else { size = 1; - indices = (int*)malloc(sizeof(int)); + indices = (int*)BJAM_MALLOC(sizeof(int)); *indices = 1; } @@ -82,7 +82,7 @@ LIST *regex_transform( PARSE *parse, FRAME *frame ) string_free( buf ); } - free(indices); + BJAM_FREE(indices); return result; } diff --git a/historic/jam/src/newstr.c b/historic/jam/src/newstr.c index 670cee504..c7265c1b9 100644 --- a/historic/jam/src/newstr.c +++ b/historic/jam/src/newstr.c @@ -68,7 +68,7 @@ static char* storage_finish = 0; static char* allocate(size_t n) { #if SIMPLE_ALLOC - return (char*)malloc(n); + return (char*)BJAM_MALLOC(n); #else /* See if we can grab storage from an existing block */ size_t remaining = storage_finish - storage_start; @@ -86,7 +86,7 @@ static char* allocate(size_t n) nalloc = STRING_BLOCK; /* allocate a new block and link into the chain */ - new_block = (strblock*)malloc( offsetof( strblock, data[0] ) + nalloc * sizeof(new_block->data[0]) ); + new_block = (strblock*)BJAM_MALLOC( offsetof( strblock, data[0] ) + nalloc * sizeof(new_block->data[0]) ); if ( new_block == 0 ) return 0; new_block->next = strblock_chain; @@ -125,9 +125,6 @@ newstr( char *string ) strtotal += l + 1; memcpy( m, string, l + 1 ); *s = m; - - if ( DEBUG_PROFILE ) - profile_memory( l+1 ); } strcount_in += 1; @@ -166,7 +163,7 @@ donestr() while ( strblock_chain != 0 ) { strblock* n = strblock_chain->next; - free(strblock_chain); + BJAM_FREE(strblock_chain); strblock_chain = n; } diff --git a/historic/jam/src/parse.c b/historic/jam/src/parse.c index 606112ec8..fc92ce95f 100644 --- a/historic/jam/src/parse.c +++ b/historic/jam/src/parse.c @@ -17,7 +17,6 @@ # include "newstr.h" # include "modules.h" # include "frames.h" -# include "debug.h" /* * parse.c - make and destroy parse trees as driven by the parser @@ -78,9 +77,7 @@ parse_make( char *string1, int num ) { - PARSE *p = (PARSE *)malloc( sizeof( PARSE ) ); - if ( DEBUG_PROFILE ) - profile_memory( sizeof( PARSE ) ); + PARSE *p = (PARSE *)BJAM_MALLOC( sizeof( PARSE ) ); p->func = func; p->left = left; @@ -130,7 +127,7 @@ parse_free( PARSE *p ) if ( p->rulename ) freestr( p->rulename ); - free( (char *)p ); + BJAM_FREE( (char *)p ); } LIST* parse_evaluate( PARSE *p, FRAME* frame ) diff --git a/historic/jam/src/regexp.c b/historic/jam/src/regexp.c index 33cd9f968..ea2875109 100644 --- a/historic/jam/src/regexp.c +++ b/historic/jam/src/regexp.c @@ -41,8 +41,8 @@ * precedence is structured in regular expressions. Serious changes in * regular-expression syntax might require a total rethink. */ +#include "jam.h" #include "regexp.h" -#include "debug.h" #include #include #ifndef ultrix @@ -239,11 +239,9 @@ regcomp( char *exp ) FAIL("regexp too big"); /* Allocate space. */ - r = (regexp *)malloc(sizeof(regexp) + (unsigned)regsize); + r = (regexp *)BJAM_MALLOC(sizeof(regexp) + (unsigned)regsize); if (r == NULL) FAIL("out of space"); - if ( DEBUG_PROFILE ) - profile_memory( sizeof(regexp) + (unsigned)regsize ); /* Second pass: emit code. */ regparse = (char *)exp; diff --git a/historic/jam/src/rules.c b/historic/jam/src/rules.c index 2902995c3..0c044aba5 100644 --- a/historic/jam/src/rules.c +++ b/historic/jam/src/rules.c @@ -16,7 +16,6 @@ # include "lists.h" # include "pathsys.h" # include "timestamp.h" -# include "debug.h" /* This file is ALSO: * Copyright 2001-2004 David Abrahams. @@ -265,9 +264,7 @@ copytarget( const TARGET *ot ) { TARGET *t; - t = (TARGET *)malloc( sizeof( *t ) ); - if ( DEBUG_PROFILE ) - profile_memory( sizeof( *t ) ); + t = (TARGET *)BJAM_MALLOC( sizeof( *t ) ); memset( (char *)t, '\0', sizeof( *t ) ); t->name = copystr( ot->name ); t->boundname = t->name; @@ -321,9 +318,7 @@ targetentry( { TARGETS *c; - c = (TARGETS *)malloc( sizeof( TARGETS ) ); - if ( DEBUG_PROFILE ) - profile_memory( sizeof( TARGETS ) ); + c = (TARGETS *)BJAM_MALLOC( sizeof( TARGETS ) ); c->target = target; if( !chain ) chain = c; @@ -369,9 +364,7 @@ actionlist( ACTIONS *chain, ACTION *action ) { - ACTIONS *actions = (ACTIONS *)malloc( sizeof( ACTIONS ) ); - if ( DEBUG_PROFILE ) - profile_memory( sizeof( ACTIONS ) ); + ACTIONS *actions = (ACTIONS *)BJAM_MALLOC( sizeof( ACTIONS ) ); actions->action = action; @@ -421,9 +414,7 @@ addsettings( settings_freelist = v->next; else { - v = (SETTINGS *)malloc( sizeof( *v ) ); - if ( DEBUG_PROFILE ) - profile_memory( sizeof( *v ) ); + v = (SETTINGS *)BJAM_MALLOC( sizeof( *v ) ); } v->symbol = newstr( symbol ); @@ -489,7 +480,7 @@ void freetargets( TARGETS *chain ) while( chain ) { TARGETS* n = chain->next; - free( chain ); + BJAM_FREE( chain ); chain = n; } } @@ -502,7 +493,7 @@ void freeactions( ACTIONS *chain ) while( chain ) { ACTIONS* n = chain->next; - free( chain ); + BJAM_FREE( chain ); chain = n; } } @@ -553,7 +544,7 @@ donerules() while ( settings_freelist ) { SETTINGS* n = settings_freelist->next; - free( settings_freelist ); + BJAM_FREE( settings_freelist ); settings_freelist = n; } } @@ -563,9 +554,7 @@ donerules() */ argument_list* args_new() { - argument_list* r = (argument_list*)malloc( sizeof(argument_list) ); - if ( DEBUG_PROFILE ) - profile_memory( sizeof(argument_list) ); + argument_list* r = (argument_list*)BJAM_MALLOC( sizeof(argument_list) ); r->reference_count = 0; lol_init(r->data); return r; @@ -587,7 +576,7 @@ void args_free( argument_list* a ) if (--a->reference_count <= 0) { lol_free(a->data); - free(a); + BJAM_FREE(a); } } @@ -608,7 +597,7 @@ void actions_free(rule_actions* a) { freestr(a->command); list_free(a->bindlist); - free(a); + BJAM_FREE(a); } } @@ -702,9 +691,7 @@ static void set_rule_actions( RULE* rule, rule_actions* actions ) static rule_actions* actions_new( char* command, LIST* bindlist, int flags ) { - rule_actions* result = (rule_actions*)malloc(sizeof(rule_actions)); - if ( DEBUG_PROFILE ) - profile_memory( sizeof(rule_actions) ); + rule_actions* result = (rule_actions*)BJAM_MALLOC(sizeof(rule_actions)); result->command = copystr( command ); result->bindlist = bindlist; result->flags = flags; diff --git a/historic/jam/src/scan.c b/historic/jam/src/scan.c index 1145ac858..fd198b68d 100644 --- a/historic/jam/src/scan.c +++ b/historic/jam/src/scan.c @@ -11,7 +11,6 @@ # include "jamgram.h" # include "jambase.h" # include "newstr.h" -# include "debug.h" /* * scan.c - the jam yacc scanner @@ -82,9 +81,7 @@ yyanyerrors() void yyfparse( char *s ) { - struct include *i = (struct include *)malloc( sizeof( *i ) ); - if ( DEBUG_PROFILE ) - profile_memory( sizeof( *i ) ); + struct include *i = (struct include *)BJAM_MALLOC( sizeof( *i ) ); /* Push this onto the incp chain. */ @@ -171,7 +168,7 @@ yyline() if( i->file && i->file != stdin ) fclose( i->file ); freestr( i->fname ); - free( (char *)i ); + BJAM_FREE( (char *)i ); return EOF; } diff --git a/historic/jam/src/strings.c b/historic/jam/src/strings.c index 6c093c6b7..67c8dc75e 100644 --- a/historic/jam/src/strings.c +++ b/historic/jam/src/strings.c @@ -2,8 +2,8 @@ /* Software License, Version 1.0. (See accompanying */ /* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ +#include "jam.h" #include "strings.h" -#include "debug.h" #include #include #include @@ -48,23 +48,21 @@ void string_free( string* s ) { assert_invariants( s ); if ( s->value != s->opt ) - free( s->value ); + BJAM_FREE( s->value ); } static void string_reserve_internal( string* self, size_t capacity ) { if ( self->value == self->opt ) { - self->value = (char*)malloc( capacity + JAM_STRING_MAGIC_SIZE ); - if ( DEBUG_PROFILE ) - profile_memory( capacity + JAM_STRING_MAGIC_SIZE ); + self->value = (char*)BJAM_MALLOC( capacity + JAM_STRING_MAGIC_SIZE ); self->value[0] = 0; strncat( self->value, self->opt, sizeof(self->opt) ); assert( strlen( self->value ) <= self->capacity ); /* This is a regression test */ } else { - self->value = (char*)realloc( self->value, capacity + JAM_STRING_MAGIC_SIZE ); + self->value = (char*)BJAM_REALLOC( self->value, capacity + JAM_STRING_MAGIC_SIZE ); } #ifndef NDEBUG memcpy( self->value + capacity, self->magic, JAM_STRING_MAGIC_SIZE ); diff --git a/historic/jam/src/timestamp.c b/historic/jam/src/timestamp.c index 3c5643108..14a16d9af 100644 --- a/historic/jam/src/timestamp.c +++ b/historic/jam/src/timestamp.c @@ -11,7 +11,6 @@ */ # include "jam.h" -# include "debug.h" # include "hash.h" # include "filesys.h" From ac312e65887c8e21c4c5de8140dca8c948c3c8f2 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Thu, 7 Sep 2006 04:25:58 +0000 Subject: [PATCH 22/82] Add defs for accessing the raw allocation functions. [SVN r35030] --- historic/jam/src/mem.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/historic/jam/src/mem.h b/historic/jam/src/mem.h index ed6f2ea52..db7a0779f 100644 --- a/historic/jam/src/mem.h +++ b/historic/jam/src/mem.h @@ -19,7 +19,12 @@ http://www.boost.org/LICENSE_1_0.txt) #define bjam_calloc_atomic_x(n,s) memset(GC_malloc_atomic((n)*(s)),0,(n)*(s)) #define bjam_realloc_x(p,s) GC_realloc(p,s) #define bjam_free_x(p) GC_free(p) - #define bjam_mem_init_x() GC_init() + #define bjam_mem_init_x() GC_init(); GC_enable_incremental() + + #define bjam_malloc_raw_x(s) malloc(s) + #define bjam_calloc_raw_x(n,s) calloc(n,s) + #define bjam_realloc_raw_x(p,s) realloc(p,s) + #define bjam_free_raw_x(p) free(p) #else @@ -43,6 +48,18 @@ http://www.boost.org/LICENSE_1_0.txt) #ifndef bjam_mem_close_x #define bjam_mem_close_x() #endif +#ifndef bjam_malloc_raw_x + #define bjam_malloc_raw_x(s) bjam_malloc_x(s) +#endif +#ifndef bjam_calloc_raw_x + #define bjam_calloc_raw_x(n,s) bjam_calloc_x(n,s) +#endif +#ifndef bjam_realloc_raw_x + #define bjam_realloc_raw_x(p,s) bjam_realloc_x(p,s) +#endif +#ifndef bjam_free_raw_x + #define bjam_free_raw_x(p) bjam_free_x(p) +#endif #ifdef OPT_DEBUG_PROFILE @@ -56,6 +73,11 @@ http://www.boost.org/LICENSE_1_0.txt) #define BJAM_MEM_INIT() bjam_mem_init_x() #define BJAM_MEM_CLOSE() bjam_mem_close_x() + #define BJAM_MALLOC_RAW(s) (profile_memory(s), bjam_malloc_raw_x(s)) + #define BJAM_CALLOC_RAW(n,s) (profile_memory(n*s), bjam_calloc_raw_x(n,s)) + #define BJAM_REALLOC_RAW(p,s) (profile_memory(s), bjam_realloc_raw_x(p,s)) + #define BJAM_FREE_RAW(p) bjam_free_raw_x(p) + #else /* No mem tracing. */ @@ -68,6 +90,11 @@ http://www.boost.org/LICENSE_1_0.txt) #define BJAM_MEM_INIT() bjam_mem_init_x() #define BJAM_MEM_CLOSE() bjam_mem_close_x() + #define BJAM_MALLOC_RAW(s) bjam_malloc_raw_x(s) + #define BJAM_CALLOC_RAW(n,s) bjam_calloc_raw_x(n,s) + #define BJAM_REALLOC_RAW(p,s) bjam_realloc_raw_x(p,s) + #define BJAM_FREE_RAW(p) bjam_free_raw_x(p) + #endif From ad1e042a9cc5ec22c587846159101e6207f14cbb Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Thu, 7 Sep 2006 05:39:37 +0000 Subject: [PATCH 23/82] Add "--gc" option to build in Boehm GC allocator. [SVN r35031] --- historic/jam/src/build.jam | 60 ++++++++++++++++++++++++-------------- historic/jam/src/mem.c | 60 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 22 deletions(-) create mode 100644 historic/jam/src/mem.c diff --git a/historic/jam/src/build.jam b/historic/jam/src/build.jam index f95b31c91..3dea7c2ed 100644 --- a/historic/jam/src/build.jam +++ b/historic/jam/src/build.jam @@ -84,6 +84,16 @@ if $(with-python) } } +# Boehm GC? +if --gc in $(ARGV) +{ + --boehm-gc = true ; +} +if $(--boehm-gc) +{ + --boehm-gc-include = [ .path [ PWD ] "boehm_gc" "include" ] ; +} + # An explicit root for the toolset? (trim spaces) toolset-root = [ MATCH --toolset-root=(.*) : $(ARGV) ] ; { @@ -119,14 +129,14 @@ toolset acc cc : "-o " : -D : -Ae [ opt --release : -s -O3 ] [ opt --debug : -g -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Borland C++ 5.5.x toolset borland bcc32 : -e -n : /D : -WC -w- -q "-I$(toolset-root)Include" "-L$(toolset-root)Lib" [ opt --release : -O2 -vi -w-inl ] [ opt --debug : -v -Od -vi- ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : $(--python-lib[1]) ; ## Generic Unix cc if ! $(CC) { CC = cc ; } @@ -134,63 +144,63 @@ toolset cc $(CC) : "-o " : -D : $(CFLAGS) [ opt --release : -s -O ] [ opt --debug : -g ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : $(LIBS) -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Comeau C/C++ 4.x toolset como como : "-o " : -D : --c [ opt --release : --inlining ] [ opt --debug : --no_inlining ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## MacOSX Darwin, using GCC 2.9.x, 3.x toolset darwin cc : "-o " : -D : [ opt --release : -Wl,-x -O3 -finline-functions ] [ opt --debug : -g -O0 -fno-inline -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## GCC 2.x, 3.x, 4.x toolset gcc gcc : "-o " : -D : -pedantic [ opt --release : [ opt --symbols : -g : -s ] -O3 ] [ opt --debug : -g -O0 -fno-inline ] - -I$(--python-include) -Wno-long-long + -I$(--python-include) -I$(--boehm-gc-include) -Wno-long-long : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## GCC 2.x, 3.x on CYGWIN but without cygwin1.dll toolset gcc-nocygwin gcc : "-o " : -D : -s -O3 -mno-cygwin [ opt --release : -finline-functions ] [ opt --debug : -s -O3 -fno-inline -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Intel C/C++ for Linux toolset intel-linux icc : "-o " : -D : [ opt --release : -Xlinker -s -O3 ] [ opt --debug : -g -O0 -p ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Intel C/C++ for Win32 toolset intel-win32 icl : /Fe : -D : /nologo [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ] [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## KCC ? toolset kcc KCC : "-o " : -D : [ opt --release : -s +K2 ] [ opt --debug : -g +K0 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Borland Kylix toolset kylix bc++ : -o : -D : -tC -q [ opt --release : -O2 -vi -w-inl ] [ opt --debug : -v -Od -vi- ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Metrowerks CodeWarrior 8.x { @@ -201,7 +211,7 @@ toolset kylix bc++ : -o : -D : -c -lang c -subsystem console -cwd include [ opt --release : -runtime ss -opt full -inline all ] [ opt --debug : -runtime ssd -opt none -inline off ] - -I$(--python-include) ; + -I$(--python-include) -I$(--boehm-gc-include) ; toolset metrowerks $(mwcc) .link : "-o " : : -subsystem console -lkernel32.lib -ladvapi32.lib -luser32.lib [ opt --release : -runtime ss ] @@ -213,28 +223,28 @@ toolset mingw gcc : "-o " : -D : [ opt --release : -s -O3 -finline-functions ] [ opt --debug : -g -O0 -fno-inline -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : $(--python-lib[2]) ; ## MIPS Pro toolset mipspro cc : "-o " : -D : [ opt --release : -s -O3 -g0 -INLINE:none ] [ opt --debug : -g -O0 -INLINE ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Microsoft Visual Studio C++ 6.x toolset msvc cl : /Fe : -D : /nologo [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ] [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## QNX 6.x GCC 3.x/2.95.3 toolset qcc qcc : "-o " : -D : -Wc,-pedantic [ opt --release : [ opt --symbols : -g ] -O3 -Wc,-finline-functions ] [ opt --debug : -g -O0 -Wc,-fno-inline ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Sun Workshop 6 C++ toolset sunpro cc : "-o " : -D @@ -242,35 +252,35 @@ toolset sunpro cc : "-o " : -D [ opt --release : -s -fast -xO4 ] [ opt --debug : -g ] -xarch=generic - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Compaq Alpha CXX toolset tru64cxx cc : "-o " : -D : [ opt --release : -s -O5 -inline speed ] [ opt --debug : -g -O0 -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## IBM VisualAge C++ toolset vacpp xlc : "-o " : -D : [ opt --release : -s -O3 -qstrict -qinline ] [ opt --debug : -g -qNOOPTimize -qnoinline -pg ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Microsoft Visual C++ .NET 7.x toolset vc7 cl : /Fe : -D : /nologo [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ] [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## Microsoft Visual C++ 2005 toolset vc8 cl : /Fe : -D : /nologo [ opt --release : /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ] [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] - -I$(--python-include) + -I$(--python-include) -I$(--boehm-gc-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## VMS/OpenVMS DEC C toolset vmsdecc cc : /OBJECT= : "/DEFINES=(" "," ")" @@ -378,7 +388,7 @@ jam.source = command.c compile.c debug.c expand.c glob.c hash.c hcache.c headers.c hdrmacro.c jam.c jambase.c jamgram.c - lists.c make.c make1.c newstr.c + lists.c make.c make1.c mem.c newstr.c option.c parse.c regexp.c rules.c scan.c search.c subst.c w32_getreg.c timestamp.c variable.c modules.c strings.c filesys.c @@ -427,6 +437,12 @@ if ! $(debug) || --noassert in $(ARGV) # Improvements --defs += OPT_IMPROVED_PATIENCE_EXT ; +# Use Boehm GC memory allocator? +if $(--boehm-gc) +{ + --defs += OPT_BOEHM_GC ; +} + if ( $(OS) = NT || $(NT) ) && ! NT in $(--defs) { --defs += NT ; diff --git a/historic/jam/src/mem.c b/historic/jam/src/mem.c new file mode 100644 index 000000000..5457bffee --- /dev/null +++ b/historic/jam/src/mem.c @@ -0,0 +1,60 @@ +/* +Copyright Rene Rivera 2006. +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) +*/ + +#include "mem.h" + +#ifdef OPT_BOEHM_GC + + /* Compile the Boehm GC as one big chunk of code. It's much easier + this way, than trying to make radical changes to the bjam build + scripts. */ + + #define ATOMIC_UNCOLLECTABLE + #define NO_SIGNALS + #define NO_EXECUTE_PERMISSION + #define SILENT + #define ALL_INTERIOR_POINTERS + #define LARGE_CONFIG + #define NO_DEBUGGING + + #include "boehm_gc/reclaim.c" + #include "boehm_gc/allchblk.c" + #include "boehm_gc/misc.c" + #include "boehm_gc/alloc.c" + #include "boehm_gc/mach_dep.c" + #include "boehm_gc/os_dep.c" + #include "boehm_gc/mark_rts.c" + #include "boehm_gc/headers.c" + #include "boehm_gc/mark.c" + #include "boehm_gc/obj_map.c" + #include "boehm_gc/pcr_interface.c" + #include "boehm_gc/blacklst.c" + #include "boehm_gc/new_hblk.c" + #include "boehm_gc/real_malloc.c" + #include "boehm_gc/dyn_load.c" + #include "boehm_gc/dbg_mlc.c" + #include "boehm_gc/malloc.c" + #include "boehm_gc/stubborn.c" + #include "boehm_gc/checksums.c" + #include "boehm_gc/solaris_threads.c" + #include "boehm_gc/pthread_support.c" + #include "boehm_gc/pthread_stop_world.c" + #include "boehm_gc/darwin_stop_world.c" + #include "boehm_gc/typd_mlc.c" + #include "boehm_gc/ptr_chck.c" + #include "boehm_gc/mallocx.c" + #include "boehm_gc/solaris_pthreads.c" + #include "boehm_gc/gcj_mlc.c" + #include "boehm_gc/specific.c" + #include "boehm_gc/gc_dlopen.c" + #include "boehm_gc/backgraph.c" + #include "boehm_gc/win32_threads.c" + + /* Needs to be last. */ + #include "boehm_gc/finalize.c" + +#endif From efdbfe6adf13c87321d32f4140e7c97ac9b0590f Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Thu, 7 Sep 2006 07:50:38 +0000 Subject: [PATCH 24/82] * build/toolset.jam (push-checking-for-flags-module): New. (pop-checking-for-flags-module): New. (flags): Don't error out if 'unchecked' was last pushed. (inherit-flags): Improve comments. * tools/intel-win.jam (init): Add /lib for intel-win.archive command. Call msvc.configure-version-specific at the end. * tools/msvc.jam (configure-version-specific): New parameter 'toolset'. (configure-really): Adjust for above. [SVN r35032] --- v2/build/toolset.jam | 36 ++++++++++++++++++++++++--- v2/tools/intel-win.jam | 13 +++++++++- v2/tools/msvc.jam | 56 +++++++++++++++++++++++------------------- 3 files changed, 75 insertions(+), 30 deletions(-) diff --git a/v2/build/toolset.jam b/v2/build/toolset.jam index b2f9f453a..db94c9bba 100644 --- a/v2/build/toolset.jam +++ b/v2/build/toolset.jam @@ -44,6 +44,23 @@ local rule normalize-condition ( property-sets * ) } +# Specifies if the 'flags' rule should do checking that +# the invoking module is the same as module we're setting +# flag for. +# 'v' can be either 'checked' or 'unchecked'. +# Subsequent call to 'pop-checking-for-flags-module' +# will restore the behaviour that was in effect before +# calling this rule. +rule push-checking-for-flags-module ( v ) +{ + .flags-module-checking = $(v) $(.flags-module-checking) ; +} + +rule pop-checking-for-flags-module ( ) +{ + .flags-module-checking = $(.flags-module-checking[2-]) ; +} + # Specifies the flags (variables) that must be set on targets under certain # conditions, described by arguments. rule flags ( rule-or-module # If contains dot, should be a rule name. @@ -104,7 +121,9 @@ rule flags ( rule-or-module # If contains dot, should be a rule name. else { local module_ = [ MATCH "([^.]*).*" : $(rule-or-module) ] ; - if $(unchecked) != unchecked && $(module_) != $(caller) + if $(unchecked) != unchecked + && $(.flags-module-checking[1]) != unchecked + && $(module_) != $(caller) { errors.error "Module $(caller) attempted to set flags for module $(module_)" ; } @@ -387,9 +406,18 @@ rule inherit-generators ( toolset properties * : base : generators-to-ignore * ) } } -# properties listed in prohibited-properties won't -# be inherited. Note that on and -# off are two different properties +# Brings all flag definitions from 'base' toolset into +# other toolset 'toolset'. Flag definitions which +# condition make use of properties in 'prohibited-properties' +# are ignored. Don't confuse property and feature, for +# example on and off, so blocking +# one of them does not block the other one. +# +# The flag conditions are not altered at all, so if condition +# includes name, or version of base toolset, it won't ever match +# the inheriting toolset. When such flag settings must be +# inherited, define a rule in base toolset module and call it +# as needed. rule inherit-flags ( toolset : base : prohibited-properties * ) { for local f in $(.module-flags.$(base)) diff --git a/v2/tools/intel-win.jam b/v2/tools/intel-win.jam index cfe82b284..ca3359586 100644 --- a/v2/tools/intel-win.jam +++ b/v2/tools/intel-win.jam @@ -63,7 +63,7 @@ rule init ( version ? : # the compiler version flags intel-win.compile .CC $(condition) : $(setup)icl ; flags intel-win.link .LD $(condition) : $(setup)xilink ; - flags intel-win.archive .LD $(condition) : $(setup)xilink ; + flags intel-win.archive .LD $(condition) : $(setup)xilink /lib ; local m = [ MATCH (.).* : $(version) ] ; local major = $(m[1]) ; @@ -109,6 +109,8 @@ rule init ( version ? : # the compiler version ; } } + + if $(compatibility) && $(compatibility) != native { C++FLAGS += /Q$(base-vc) ; @@ -131,6 +133,15 @@ rule init ( version ? : # the compiler version flags intel-win CFLAGS $(condition) : $(C++FLAGS) ; + if ! $(compatibility) + { + # If there's no backend version, assume 7.1. + compatibility = 7.1 ; + } + + msvc.configure-version-specific intel-win : $(compatibility) : $(condition) ; } flags intel-win.link LIBRARY_OPTION intel : "" ; + + diff --git a/v2/tools/msvc.jam b/v2/tools/msvc.jam index 661c2d185..119e8e23f 100644 --- a/v2/tools/msvc.jam +++ b/v2/tools/msvc.jam @@ -362,9 +362,8 @@ local rule configure-really ( } } } - # Set version-specific flags - configure-version-specific $(version) : $(condition) ; + configure-version-specific msvc : $(version) : $(condition) ; } } @@ -385,9 +384,15 @@ cpu-type-g7 = cpu-type-itanium = itanium itanium1 merced ; cpu-type-itanium2 = itanium2 mckinley ; - -local rule configure-version-specific ( version : condition ) +# Sets up flag definitions that are dependent on the version ot +# compiler. +# - 'version' is the version of compiler in N.M format. +# - 'condition' is the property set to be used as condition for flag +# - 'toolset' is the toolset for which flag settings are to be defined +# This makes the rule reusable for other msvc-option-compatible compilers. +rule configure-version-specific ( toolset : version : condition ) { + toolset.push-checking-for-flags-module unchecked ; # Starting with versions 7.0, the msvc compiler have the /Zc:forScope # and /Zc:wchar_t options that improve C++ standard conformance, but # those options are off by default. @@ -396,14 +401,14 @@ local rule configure-version-specific ( version : condition ) # or if the installation path contain 7.* (this is checked above). if ! [ MATCH ^(6\\.) : $(version) ] { - flags msvc.compile CFLAGS $(condition) : /Zc:forScope /Zc:wchar_t ; - flags msvc.compile.c++ C++FLAGS $(condition) : /wd4675 ; + flags $(toolset).compile CFLAGS $(condition) : /Zc:forScope /Zc:wchar_t ; + flags $(toolset).compile.c++ C++FLAGS $(condition) : /wd4675 ; # disable the function is deprecated warning # Some version of msvc have a bug, that cause deprecation # warning to be emitted even with /W0 - flags msvc.compile CFLAGS $(condition)/off : /wd4996 ; + flags $(toolset).compile CFLAGS $(condition)/off : /wd4996 ; # 64-bit compatibility warning - flags msvc.compile CFLAGS $(condition)/all : /Wp64 ; + flags $(toolset).compile CFLAGS $(condition)/all : /Wp64 ; } # @@ -413,36 +418,37 @@ local rule configure-version-specific ( version : condition ) if [ MATCH ^([67]\\.) : $(version) ] { # 8.0 deprecates some of the options - flags msvc.compile CFLAGS $(condition)/speed $(condition)/space : /Ogiy /Gs ; - flags msvc.compile CFLAGS $(condition)/speed : /Ot ; - flags msvc.compile CFLAGS $(condition)/space : /Os ; + flags $(toolset).compile CFLAGS $(condition)/speed $(condition)/space : /Ogiy /Gs ; + flags $(toolset).compile CFLAGS $(condition)/speed : /Ot ; + flags $(toolset).compile CFLAGS $(condition)/space : /Os ; - flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/ : /GB ; - flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/i386 : /G3 ; - flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/i486 : /G4 ; - flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g5) : /G5 ; - flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g6) : /G6 ; - flags msvc.compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g7) : /G7 ; + flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/ : /GB ; + flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/i386 : /G3 ; + flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/i486 : /G4 ; + flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g5) : /G5 ; + flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g6) : /G6 ; + flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g7) : /G7 ; # Improve floating-point accuracy. Otherwise, some of C++ Boost's # "math" tests will fail. - flags msvc.compile CFLAGS $(condition) : /Op ; + flags $(toolset).compile CFLAGS $(condition) : /Op ; # 7.1 and below have single-threaded static RTL - flags msvc.compile CFLAGS $(condition)/off/static/single : /ML ; - flags msvc.compile CFLAGS $(condition)/on/static/single : /MLd ; + flags $(toolset).compile CFLAGS $(condition)/off/static/single : /ML ; + flags $(toolset).compile CFLAGS $(condition)/on/static/single : /MLd ; } else { # 8.0 adds some more options - flags msvc.compile CFLAGS $(condition)/$(cpu-arch-amd64)/ : /favor:blend ; - flags msvc.compile CFLAGS $(condition)/$(cpu-arch-amd64)/$(cpu-type-em64t) : /favor:EM64T ; - flags msvc.compile CFLAGS $(condition)/$(cpu-arch-amd64)/$(cpu-type-amd64) : /favor:AMD64 ; + flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-amd64)/ : /favor:blend ; + flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-amd64)/$(cpu-type-em64t) : /favor:EM64T ; + flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-amd64)/$(cpu-type-amd64) : /favor:AMD64 ; # 8.0 only has multi-threaded static RTL - flags msvc.compile CFLAGS $(condition)/off/static/single : /MT ; - flags msvc.compile CFLAGS $(condition)/on/static/single : /MTd ; + flags $(toolset).compile CFLAGS $(condition)/off/static/single : /MT ; + flags $(toolset).compile CFLAGS $(condition)/on/static/single : /MTd ; } + toolset.pop-checking-for-flags-module ; } From 91c713cc1a83ae2e4fff09c3a8b2bc12fb4f1043 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Thu, 7 Sep 2006 18:33:04 +0000 Subject: [PATCH 25/82] Implement gc of string only hash entries (note, doesn't work likely because a buffer overrun in var expand). Allocate all character data as atomic. [SVN r35036] --- historic/jam/src/command.c | 2 +- historic/jam/src/execnt.c | 8 ++--- historic/jam/src/filent.c | 2 +- historic/jam/src/fileunix.c | 2 +- historic/jam/src/hash.c | 59 ++++++++++++++++++++++++++++++++----- historic/jam/src/mem.h | 4 +-- historic/jam/src/newstr.c | 10 ++----- historic/jam/src/strings.c | 2 +- 8 files changed, 64 insertions(+), 25 deletions(-) diff --git a/historic/jam/src/command.c b/historic/jam/src/command.c index 712bd211e..ef8830601 100644 --- a/historic/jam/src/command.c +++ b/historic/jam/src/command.c @@ -55,7 +55,7 @@ cmd_new( { BJAM_FREE(cmd->buf); /* free any buffer from previous iteration */ - cmd->buf = (char*)BJAM_MALLOC(max_line + 1); + cmd->buf = (char*)BJAM_MALLOC_ATOMIC(max_line + 1); if (cmd->buf == 0) break; diff --git a/historic/jam/src/execnt.c b/historic/jam/src/execnt.c index 930ac3c11..e8ec2444e 100644 --- a/historic/jam/src/execnt.c +++ b/historic/jam/src/execnt.c @@ -149,7 +149,7 @@ string_to_args( const char* string ) /* Copy the input string into a buffer we can modify */ - line = (char*)BJAM_MALLOC( src_len+1 ); + line = (char*)BJAM_MALLOC_ATOMIC( src_len+1 ); if (!line) return 0; @@ -280,7 +280,7 @@ process_del( char* command ) if ( len <= 0 ) return 1; - line = (char*)BJAM_MALLOC( len+4+1 ); + line = (char*)BJAM_MALLOC_ATOMIC( len+4+1 ); if (!line) return 1; @@ -410,7 +410,7 @@ void execnt_unit_test() } { - char* long_command = BJAM_MALLOC(MAXLINE + 10); + char* long_command = BJAM_MALLOC_ATOMIC(MAXLINE + 10); assert( long_command != 0 ); memset( long_command, 'x', MAXLINE + 9 ); long_command[MAXLINE + 9] = 0; @@ -545,7 +545,7 @@ execcmd( DWORD procID = GetCurrentProcessId(); /* SVA - allocate 64 other just to be safe */ - cmdtab[ slot ].tempfile = BJAM_MALLOC( strlen( tempdir ) + 64 ); + cmdtab[ slot ].tempfile = BJAM_MALLOC_ATOMIC( strlen( tempdir ) + 64 ); sprintf( cmdtab[ slot ].tempfile, "%s\\jam%d-%02d.bat", tempdir, procID, slot ); diff --git a/historic/jam/src/filent.c b/historic/jam/src/filent.c index 9c37b4e45..7ec01c3ae 100644 --- a/historic/jam/src/filent.c +++ b/historic/jam/src/filent.c @@ -305,7 +305,7 @@ file_archscan( ** 15 characters (ie. don't fit into a ar_name */ - string_table = BJAM_MALLOC(lar_size+1); + string_table = BJAM_MALLOC_ATOMIC(lar_size+1); if (read(fd, string_table, lar_size) != lar_size) printf("error reading string table\n"); string_table[lar_size] = '\0'; diff --git a/historic/jam/src/fileunix.c b/historic/jam/src/fileunix.c index 1f86d7d0f..313040dd3 100644 --- a/historic/jam/src/fileunix.c +++ b/historic/jam/src/fileunix.c @@ -325,7 +325,7 @@ file_archscan( ** 15 characters (ie. don't fit into a ar_name */ - string_table = (char *)BJAM_MALLOC(lar_size); + string_table = (char *)BJAM_MALLOC_ATOMIC(lar_size); lseek(fd, offset + SARHDR, 0); if (read(fd, string_table, lar_size) != lar_size) printf("error reading string table\n"); diff --git a/historic/jam/src/hash.c b/historic/jam/src/hash.c index 5e28dd1f9..74a9aec45 100644 --- a/historic/jam/src/hash.c +++ b/historic/jam/src/hash.c @@ -90,6 +90,11 @@ struct hash static void hashrehash( struct hash *hp ); static void hashstat( struct hash *hp ); +static void * hash_mem_alloc(size_t datalen, size_t size); +static void hash_mem_free(size_t datalen, void * data); +#ifdef OPT_BOEHM_GC +static void hash_mem_finalizer(char * key, struct hash * hp); +#endif /* * hash_free() - remove the given item from the table if it's there. @@ -207,6 +212,12 @@ hashitem( i->hdr.next = *base; *base = i; *data = &i->data; + #ifdef OPT_BOEHM_GC + if (sizeof(HASHDATA) == hp->items.datalen) + { + GC_REGISTER_FINALIZER(i->data.key,&hash_mem_finalizer,hp,0,0); + } + #endif } #ifdef HASH_DEBUG_PROFILE @@ -224,7 +235,7 @@ static void hashrehash( register struct hash *hp ) { int i = ++hp->items.list; hp->items.more = i ? 2 * hp->items.nel : hp->inel; - hp->items.next = (char *)BJAM_MALLOC( hp->items.more * hp->items.size ); + hp->items.next = (char *)hash_mem_alloc( hp->items.datalen, hp->items.more * hp->items.size ); hp->items.free = 0; hp->items.lists[i].nel = hp->items.more; @@ -232,10 +243,10 @@ static void hashrehash( register struct hash *hp ) hp->items.nel += hp->items.more; if( hp->tab.base ) - BJAM_FREE( (char *)hp->tab.base ); + hash_mem_free( hp->items.datalen, (char *)hp->tab.base ); hp->tab.nel = hp->items.nel * hp->bloat; - hp->tab.base = (ITEM **)BJAM_MALLOC( hp->tab.nel * sizeof(ITEM **) ); + hp->tab.base = (ITEM **)hash_mem_alloc( hp->items.datalen, hp->tab.nel * sizeof(ITEM **) ); memset( (char *)hp->tab.base, '\0', hp->tab.nel * sizeof( ITEM * ) ); @@ -290,7 +301,7 @@ hashinit( int datalen, char *name ) { - struct hash *hp = (struct hash *)BJAM_MALLOC( sizeof( *hp ) ); + struct hash *hp = (struct hash *)hash_mem_alloc( datalen, sizeof( *hp ) ); hp->bloat = 3; hp->tab.nel = 0; @@ -323,12 +334,46 @@ hashdone( struct hash *hp ) hashstat( hp ); if( hp->tab.base ) - BJAM_FREE( (char *)hp->tab.base ); + hash_mem_free( hp->items.datalen, (char *)hp->tab.base ); for( i = 0; i <= hp->items.list; i++ ) - BJAM_FREE( hp->items.lists[i].base ); - BJAM_FREE( (char *)hp ); + hash_mem_free( hp->items.datalen, hp->items.lists[i].base ); + hash_mem_free( hp->items.datalen, (char *)hp ); } +static void * hash_mem_alloc(size_t datalen, size_t size) +{ + if (sizeof(HASHDATA) == datalen) + { + return BJAM_MALLOC_RAW(size); + } + else + { + return BJAM_MALLOC(size); + } +} + +static void hash_mem_free(size_t datalen, void * data) +{ + if (sizeof(HASHDATA) == datalen) + { + BJAM_FREE_RAW(data); + } + else + { + BJAM_FREE(data); + } +} + +#ifdef OPT_BOEHM_GC +static void hash_mem_finalizer(char * key, struct hash * hp) +{ + HASHDATA d; + d.key = (char*)key; + hash_free(hp,&d); +} +#endif + + /* ---- */ static void diff --git a/historic/jam/src/mem.h b/historic/jam/src/mem.h index db7a0779f..c29a04251 100644 --- a/historic/jam/src/mem.h +++ b/historic/jam/src/mem.h @@ -13,8 +13,8 @@ http://www.boost.org/LICENSE_1_0.txt) /* Use Boehm GC memory allocator. */ #include - #define bjam_malloc_x(s) GC_malloc(s) - #define bjam_malloc_atomic_x(s) GC_malloc_atomic(s) + #define bjam_malloc_x(s) memset(GC_malloc(s),0,s) + #define bjam_malloc_atomic_x(s) memset(GC_malloc_atomic(s),0,s) #define bjam_calloc_x(n,s) memset(GC_malloc((n)*(s)),0,(n)*(s)) #define bjam_calloc_atomic_x(n,s) memset(GC_malloc_atomic((n)*(s)),0,(n)*(s)) #define bjam_realloc_x(p,s) GC_realloc(p,s) diff --git a/historic/jam/src/newstr.c b/historic/jam/src/newstr.c index c7265c1b9..e4dfbe6c6 100644 --- a/historic/jam/src/newstr.c +++ b/historic/jam/src/newstr.c @@ -56,19 +56,13 @@ static strblock* strblock_chain = 0; static char* storage_start = 0; static char* storage_finish = 0; -/* */ -#define SIMPLE_ALLOC 0 -/*/ -#define SIMPLE_ALLOC 1 -/* */ - /* * allocate() - Allocate n bytes of immortal string storage */ static char* allocate(size_t n) { - #if SIMPLE_ALLOC - return (char*)BJAM_MALLOC(n); + #ifdef OPT_BOEHM_GC + return (char*)BJAM_MALLOC_ATOMIC(n); #else /* See if we can grab storage from an existing block */ size_t remaining = storage_finish - storage_start; diff --git a/historic/jam/src/strings.c b/historic/jam/src/strings.c index 67c8dc75e..e54434bfc 100644 --- a/historic/jam/src/strings.c +++ b/historic/jam/src/strings.c @@ -55,7 +55,7 @@ static void string_reserve_internal( string* self, size_t capacity ) { if ( self->value == self->opt ) { - self->value = (char*)BJAM_MALLOC( capacity + JAM_STRING_MAGIC_SIZE ); + self->value = (char*)BJAM_MALLOC_ATOMIC( capacity + JAM_STRING_MAGIC_SIZE ); self->value[0] = 0; strncat( self->value, self->opt, sizeof(self->opt) ); assert( strlen( self->value ) <= self->capacity ); /* This is a regression test */ From 5c73310d3bd79bb1333e9822ba9896450356b131 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 8 Sep 2006 10:51:40 +0000 Subject: [PATCH 26/82] Another intel fix [SVN r35045] --- v2/tools/intel-win.jam | 1 + 1 file changed, 1 insertion(+) diff --git a/v2/tools/intel-win.jam b/v2/tools/intel-win.jam index ca3359586..f138607a0 100644 --- a/v2/tools/intel-win.jam +++ b/v2/tools/intel-win.jam @@ -64,6 +64,7 @@ rule init ( version ? : # the compiler version flags intel-win.compile .CC $(condition) : $(setup)icl ; flags intel-win.link .LD $(condition) : $(setup)xilink ; flags intel-win.archive .LD $(condition) : $(setup)xilink /lib ; + flags intel-win.link .MT $(condition) : mt -nologo ; local m = [ MATCH (.).* : $(version) ] ; local major = $(m[1]) ; From 01a888195da05e0c27f2c941a8c358be7d2e03e7 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sun, 10 Sep 2006 17:04:21 +0000 Subject: [PATCH 27/82] Add support for compiling with Duma memory checking library. [SVN r35058] --- historic/jam/src/build.jam | 59 ++++++++++++++++++++++++-------------- historic/jam/src/hash.c | 4 +-- historic/jam/src/mem.c | 10 ++++++- historic/jam/src/mem.h | 29 +++++++++++++++++++ historic/jam/src/newstr.c | 2 +- 5 files changed, 78 insertions(+), 26 deletions(-) diff --git a/historic/jam/src/build.jam b/historic/jam/src/build.jam index 3dea7c2ed..6c010d108 100644 --- a/historic/jam/src/build.jam +++ b/historic/jam/src/build.jam @@ -91,7 +91,17 @@ if --gc in $(ARGV) } if $(--boehm-gc) { - --boehm-gc-include = [ .path [ PWD ] "boehm_gc" "include" ] ; + --extra-include += [ .path [ PWD ] "boehm_gc" "include" ] ; +} + +# Duma? +if --duma in $(ARGV) +{ + --duma = true ; +} +if $(--duma) +{ + --extra-include += [ .path [ PWD ] "duma" ] ; } # An explicit root for the toolset? (trim spaces) @@ -129,14 +139,14 @@ toolset acc cc : "-o " : -D : -Ae [ opt --release : -s -O3 ] [ opt --debug : -g -pg ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Borland C++ 5.5.x toolset borland bcc32 : -e -n : /D : -WC -w- -q "-I$(toolset-root)Include" "-L$(toolset-root)Lib" [ opt --release : -O2 -vi -w-inl ] [ opt --debug : -v -Od -vi- ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : $(--python-lib[1]) ; ## Generic Unix cc if ! $(CC) { CC = cc ; } @@ -144,63 +154,63 @@ toolset cc $(CC) : "-o " : -D : $(CFLAGS) [ opt --release : -s -O ] [ opt --debug : -g ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : $(LIBS) -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Comeau C/C++ 4.x toolset como como : "-o " : -D : --c [ opt --release : --inlining ] [ opt --debug : --no_inlining ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## MacOSX Darwin, using GCC 2.9.x, 3.x toolset darwin cc : "-o " : -D : [ opt --release : -Wl,-x -O3 -finline-functions ] [ opt --debug : -g -O0 -fno-inline -pg ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## GCC 2.x, 3.x, 4.x toolset gcc gcc : "-o " : -D : -pedantic [ opt --release : [ opt --symbols : -g : -s ] -O3 ] [ opt --debug : -g -O0 -fno-inline ] - -I$(--python-include) -I$(--boehm-gc-include) -Wno-long-long + -I$(--python-include) -I$(--extra-include) -Wno-long-long : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## GCC 2.x, 3.x on CYGWIN but without cygwin1.dll toolset gcc-nocygwin gcc : "-o " : -D : -s -O3 -mno-cygwin [ opt --release : -finline-functions ] [ opt --debug : -s -O3 -fno-inline -pg ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Intel C/C++ for Linux toolset intel-linux icc : "-o " : -D : [ opt --release : -Xlinker -s -O3 ] [ opt --debug : -g -O0 -p ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Intel C/C++ for Win32 toolset intel-win32 icl : /Fe : -D : /nologo [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ] [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## KCC ? toolset kcc KCC : "-o " : -D : [ opt --release : -s +K2 ] [ opt --debug : -g +K0 ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Borland Kylix toolset kylix bc++ : -o : -D : -tC -q [ opt --release : -O2 -vi -w-inl ] [ opt --debug : -v -Od -vi- ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Metrowerks CodeWarrior 8.x { @@ -211,7 +221,7 @@ toolset kylix bc++ : -o : -D : -c -lang c -subsystem console -cwd include [ opt --release : -runtime ss -opt full -inline all ] [ opt --debug : -runtime ssd -opt none -inline off ] - -I$(--python-include) -I$(--boehm-gc-include) ; + -I$(--python-include) -I$(--extra-include) ; toolset metrowerks $(mwcc) .link : "-o " : : -subsystem console -lkernel32.lib -ladvapi32.lib -luser32.lib [ opt --release : -runtime ss ] @@ -223,28 +233,28 @@ toolset mingw gcc : "-o " : -D : [ opt --release : -s -O3 -finline-functions ] [ opt --debug : -g -O0 -fno-inline -pg ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : $(--python-lib[2]) ; ## MIPS Pro toolset mipspro cc : "-o " : -D : [ opt --release : -s -O3 -g0 -INLINE:none ] [ opt --debug : -g -O0 -INLINE ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Microsoft Visual Studio C++ 6.x toolset msvc cl : /Fe : -D : /nologo [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ] [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## QNX 6.x GCC 3.x/2.95.3 toolset qcc qcc : "-o " : -D : -Wc,-pedantic [ opt --release : [ opt --symbols : -g ] -O3 -Wc,-finline-functions ] [ opt --debug : -g -O0 -Wc,-fno-inline ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Sun Workshop 6 C++ toolset sunpro cc : "-o " : -D @@ -252,35 +262,35 @@ toolset sunpro cc : "-o " : -D [ opt --release : -s -fast -xO4 ] [ opt --debug : -g ] -xarch=generic - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Compaq Alpha CXX toolset tru64cxx cc : "-o " : -D : [ opt --release : -s -O5 -inline speed ] [ opt --debug : -g -O0 -pg ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## IBM VisualAge C++ toolset vacpp xlc : "-o " : -D : [ opt --release : -s -O3 -qstrict -qinline ] [ opt --debug : -g -qNOOPTimize -qnoinline -pg ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : -L$(--python-lib[1]) -l$(--python-lib[2]) ; ## Microsoft Visual C++ .NET 7.x toolset vc7 cl : /Fe : -D : /nologo [ opt --release : /ML /O2 /Ob2 /Gy /GF /GA /GB ] [ opt --debug : /MLd /DEBUG /Z7 /Od /Ob0 ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## Microsoft Visual C++ 2005 toolset vc8 cl : /Fe : -D : /nologo [ opt --release : /MT /O2 /Ob2 /Gy /GF /GA /wd4996 ] [ opt --debug : /MTd /DEBUG /Z7 /Od /Ob0 /wd4996 ] - -I$(--python-include) -I$(--boehm-gc-include) + -I$(--python-include) -I$(--extra-include) : kernel32.lib advapi32.lib user32.lib $(--python-lib[1]) ; ## VMS/OpenVMS DEC C toolset vmsdecc cc : /OBJECT= : "/DEFINES=(" "," ")" @@ -443,6 +453,11 @@ if $(--boehm-gc) --defs += OPT_BOEHM_GC ; } +if $(--duma) +{ + --defs += OPT_DUMA ; +} + if ( $(OS) = NT || $(NT) ) && ! NT in $(--defs) { --defs += NT ; diff --git a/historic/jam/src/hash.c b/historic/jam/src/hash.c index 74a9aec45..c1d7a02cd 100644 --- a/historic/jam/src/hash.c +++ b/historic/jam/src/hash.c @@ -330,7 +330,7 @@ hashdone( struct hash *hp ) if( !hp ) return; - if( DEBUG_MEM ) + if( DEBUG_MEM || DEBUG_PROFILE ) hashstat( hp ); if( hp->tab.base ) @@ -368,7 +368,7 @@ static void hash_mem_free(size_t datalen, void * data) static void hash_mem_finalizer(char * key, struct hash * hp) { HASHDATA d; - d.key = (char*)key; + d.key = key; hash_free(hp,&d); } #endif diff --git a/historic/jam/src/mem.c b/historic/jam/src/mem.c index 5457bffee..44c0e5a84 100644 --- a/historic/jam/src/mem.c +++ b/historic/jam/src/mem.c @@ -5,7 +5,7 @@ Distributed under the Boost Software License, Version 1.0. http://www.boost.org/LICENSE_1_0.txt) */ -#include "mem.h" +#include "jam.h" #ifdef OPT_BOEHM_GC @@ -57,4 +57,12 @@ http://www.boost.org/LICENSE_1_0.txt) /* Needs to be last. */ #include "boehm_gc/finalize.c" +#elif defined(OPT_DUMA) + + #ifdef OS_NT + #define WIN32 + #endif + #include "duma/duma.c" + #include "duma/print.c" + #endif diff --git a/historic/jam/src/mem.h b/historic/jam/src/mem.h index c29a04251..49318cd15 100644 --- a/historic/jam/src/mem.h +++ b/historic/jam/src/mem.h @@ -25,6 +25,35 @@ http://www.boost.org/LICENSE_1_0.txt) #define bjam_calloc_raw_x(n,s) calloc(n,s) #define bjam_realloc_raw_x(p,s) realloc(p,s) #define bjam_free_raw_x(p) free(p) + + #define BJAM_NEWSTR_NO_ALLOCATE + +#elif defined(OPT_DUMA) + + /* Use Duma memory debugging library. */ + #include + #define _DUMA_CONFIG_H_ + #define DUMA_NO_GLOBAL_MALLOC_FREE + #define DUMA_EXPLICIT_INIT + #define DUMA_NO_THREAD_SAFETY + #define DUMA_NO_CPP_SUPPORT + /* #define DUMA_NO_LEAKDETECTION */ + /* #define DUMA_USE_FRAMENO */ + /* #define DUMA_PREFER_ATEXIT */ + /* #define DUMA_OLD_DEL_MACRO */ + /* #define DUMA_NO_HANG_MSG */ + #define DUMA_PAGE_SIZE 4096 + #define DUMA_MIN_ALIGNMENT 1 + /* #define DUMA_GNU_INIT_ATTR 0 */ + typedef unsigned int DUMA_ADDR; + typedef unsigned int DUMA_SIZE; + #include + #define bjam_malloc_x(s) malloc(s) + #define bjam_calloc_x(n,s) calloc(n,s) + #define bjam_realloc_x(p,s) realloc(p,s) + #define bjam_free_x(p) free(p) + + #define BJAM_NEWSTR_NO_ALLOCATE #else diff --git a/historic/jam/src/newstr.c b/historic/jam/src/newstr.c index e4dfbe6c6..47eabd69f 100644 --- a/historic/jam/src/newstr.c +++ b/historic/jam/src/newstr.c @@ -61,7 +61,7 @@ static char* storage_finish = 0; */ static char* allocate(size_t n) { - #ifdef OPT_BOEHM_GC + #ifdef BJAM_NEWSTR_NO_ALLOCATE return (char*)BJAM_MALLOC_ATOMIC(n); #else /* See if we can grab storage from an existing block */ From 84df8eb0e86b4f4136a0aa7630b32f47cfdb92a3 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sun, 10 Sep 2006 18:14:50 +0000 Subject: [PATCH 28/82] Patch implementing new W32_GETREGNAMES builting by Bojan Resnik. Added a corresponding test for the new builtin. And cleaned up some of the documentation. [SVN r35061] --- historic/jam/doc/bjam.qbk | 136 ++++++++++++++++-- historic/jam/src/builtins.c | 7 + historic/jam/src/w32_getreg.c | 127 ++++++++++++---- historic/jam/test/builtin_w32_getregnames.jam | 46 ++++++ historic/jam/test/test.bat | 1 + 5 files changed, 280 insertions(+), 37 deletions(-) create mode 100644 historic/jam/test/builtin_w32_getregnames.jam diff --git a/historic/jam/doc/bjam.qbk b/historic/jam/doc/bjam.qbk index 3bb9bcaef..cef647050 100644 --- a/historic/jam/doc/bjam.qbk +++ b/historic/jam/doc/bjam.qbk @@ -618,14 +618,20 @@ If you omit the list of formal arguments, all checking is bypassed as in "classi [section Dependency Building] +[section =DEPENDS= ] + [pre -DEPENDS /targets1/ : /targets2/ ; +rule DEPENDS ( /targets1/ * : /targets2/ * ) ] Builds a direct dependency: makes each of /targets1/ depend on each of /targets2/. Generally, /targets1/ will be rebuilt if /targets2/ are themselves rebuilt are or are newer than /targets1/. +[endsect] + +[section =INCLUDES= ] + [pre -INCLUDES /targets1/ : /targets2/ ; +rule INCLUDES ( /targets1/ * : /targets2/ * ) ] Builds a sibling dependency: makes any target that depends on any of /targets1/ also depend on each of /targets2/. This reflects the dependencies that arise when one source file includes another: the object built from the source file depends both on the original and included source file, but the two sources files don't depend on each other. For example: @@ -639,60 +645,96 @@ INCLUDES foo.c : foo.h ; [endsect] +[endsect] + [section Modifying Binding] The six rules =ALWAYS=, =LEAVES=, =NOCARE=, =NOTFILE=, =NOUPDATE=, and =TEMPORARY= modify the dependency graph so that =bjam= treats the targets differently during its target binding phase. See Binding above. Normally, =bjam= updates a target if it is missing, if its filesystem modification time is older than any of its dependencies (recursively), or if any of its dependencies are being updated. This basic behavior can be changed by invoking the following rules: +[section =ALWAYS= ] + [pre -ALWAYS /targets/ ; +rule ALWAYS ( /targets/ * ) ] Causes /targets/ to be rebuilt regardless of whether they are up-to-date (they must still be in the dependency graph). This is used for the clean and uninstall targets, as they have no dependencies and would otherwise appear never to need building. It is best applied to targets that are also =NOTFILE= targets, but it can also be used to force a real file to be updated as well. +[endsect] + +[section =LEAVES= ] + [pre -LEAVES /targets/ ; +rule LEAVES ( /targets/ * ) ] Makes each of /targets/ depend only on its leaf sources, and not on any intermediate targets. This makes it immune to its dependencies being updated, as the "leaf" dependencies are those without their own dependencies and without updating actions. This allows a target to be updated only if original source files change. +[endsect] + +[section =NOCARE= ] + [pre -NOCARE /targets/ ; +rule NOCARE ( /targets/ * ) ] Causes =bjam= to ignore /targets/ that neither can be found nor have updating actions to build them. Normally for such targets =bjam= issues a warning and then skips other targets that depend on these missing targets. The =HdrRule= in =Jambase= uses =NOCARE= on the header file names found during header file scanning, to let =bjam= know that the included files may not exist. For example, if an `#include` is within an `#ifdef`, the included file may not actually be around. [warning For targets with build actions: if their build actions exit with a nonzero return code, dependent targets will still be built.] +[endsect] + +[section =NOTFILE= ] + [pre -NOTFILE /targets/ ; +rule NOTFILE ( /targets/ * ) ] Marks /targets/ as pseudotargets and not real files. No timestamp is checked, and so the actions on such a target are only executed if the target's dependencies are updated, or if the target is also marked with =ALWAYS=. The default =bjam= target "=all=" is a pseudotarget. In =Jambase=, =NOTFILE= is used to define several addition convenient pseudotargets. +[endsect] + +[section =NOUPDATE= ] + [pre -NOUPDATE /targets/ ; +rule NOUPDATE ( /targets/ * ) ] Causes the timestamps on /targets/ to be ignored. This has two effects: first, once the target has been created it will never be updated; second, manually updating target will not cause other targets to be updated. In =Jambase=, for example, this rule is applied to directories by the =MkDir= rule, because =MkDir= only cares that the target directory exists, not when it has last been updated. +[endsect] + +[section =TEMPORARY= ] + [pre -TEMPORARY /targets/ ; +rule TEMPORARY ( /targets/ * ) ] Marks /targets/ as temporary, allowing them to be removed after other targets that depend upon them have been updated. If a =TEMPORARY= target is missing, =bjam= uses the timestamp of the target's parent. =Jambase= uses =TEMPORARY= to mark object files that are archived in a library after they are built, so that they can be deleted after they are archived. +[endsect] + +[section =FAIL_EXPECTED= ] + [pre -FAIL_EXPECTED /targets/ ; +rule FAIL_EXPECTED ( /targets/ * ) ] For handling targets whose build actions are expected to fail (e.g. when testing that assertions or compile-time type checkin work properly), Boost Jam supplies the =FAIL_EXPECTED= rule in the same style as =NOCARE=, et. al. During target updating, the return code of the build actions for arguments to =FAIL_EXPECTED= is inverted: if it fails, building of dependent targets continues as though it succeeded. If it succeeds, dependent targets are skipped. +[endsect] + +[section =RMOLD= ] + [pre -RMOLD /targets/ ; +rule RMOLD ( /targets/ * ) ] =BJam= removes any target files that may exist on disk when the rule used to build those targets fails. However, targets whose dependencies fail to build are not removed by default. The =RMOLD= rule causes its arguments to be removed if any of their dependencies fail to build. +[endsect] + +[section =ISFILE= ] + [pre rule ISFILE ( /targets/ * ) ] @@ -703,16 +745,24 @@ rule ISFILE ( /targets/ * ) [endsect] +[endsect] + [section Utility] The two rules =ECHO= and =EXIT= are utility rules, used only in =bjam='s parsing phase. +[section =ECHO= ] + [pre -ECHO /args/ ; +rule ECHO ( /args/ * ) ] Blurts out the message /args/ to stdout. +[endsect] + +[section =EXIT= ] + [pre rule EXIT ( /message/ * : /result-value/ ? ) ] @@ -721,30 +771,46 @@ Blurts out the /message/ to stdout and then exits with a failure status if no /r "=Echo=", "=echo=", "=Exit=", and "=exit=" are accepted as aliases for =ECHO= and =EXIT=, since it is hard to tell that these are built-in rules and not part of the language, like "=include=". +[endsect] + +[section =GLOB= ] + The =GLOB= rule does filename globbing. [pre -GLOB /directories/ : /patterns/ : /downcase-opt/ +rule GLOB ( /directories/ * : /patterns/ * : /downcase-opt/ ? ) ] Using the same wildcards as for the patterns in the switch statement. It is invoked by being used as an argument to a rule invocation inside of "=[ ]=". For example: "[^FILES = \[ GLOB dir1 dir2 : *.c *.h \]]" sets =FILES= to the list of C source and header files in =dir1= and =dir2=. The resulting filenames are the full pathnames, including the directory, but the pattern is applied only to the file name without the directory. If /downcase-opt/ is supplied, filenames are converted to all-lowercase before matching against the pattern; you can use this to do case-insensitive matching using lowercase patterns. The paths returned will still have mixed case if the OS supplies them. On Windows NT and Cygwin, filenames are always downcased before matching. +[endsect] + +[section =MATCH= ] + The =MATCH= rule does pattern matching. [pre -MATCH /regexps/ : /list/ +rule MATCH ( /regexps/ + : /list/ * ) ] Matches the =egrep=(1) style regular expressions /regexps/ against the strings in /list/. The result is the concatenation of matching =()= subexpressions for each string in /list/, and for each regular expression in /regexps/. Only useful within the "=[ ]=" construct, to change the result into a list. +[endsect] + +[section =BACKTRACE= ] + [pre rule BACKTRACE ( ) ] Returns a list of quadruples: /filename/ /line/ /module/ /rulename/..., describing each shallower level of the call stack. This rule can be used to generate useful diagnostic messages from Jam rules. +[endsect] + +[section =UPDATE= ] + [pre rule UPDATE ( /targets/ * ) ] @@ -761,6 +827,10 @@ local previous-updates = \[ UPDATE \] ; UPDATE $(previous-updates) a-new-target ; ] +[endsect] + +[section =W32_GETREG= ] + [pre rule W32_GETREG ( /path/ : /data/ ? ) ] @@ -780,6 +850,44 @@ local PSDK-location = \[ W32_GETREG HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\MicrosoftSDK\\\\Directories : "Install Dir" \] ; ] +[endsect] + +[section =W32_GETREGNAMES= ] + +[pre +rule W32_GETREGNAMES ( /path/ : /result-type/ ) +] + +Defined only for win32 platform. It reads the registry of Windows. '/path/' is the location of the information, and '/result-type/' is either '=subkeys=' or '=values='. For more information on '/path/' format and constraints, please see =W32_GETREG=. + +Depending on '/result-type/', the rule returns one of the following: + +[variablelist + [[=subkeys=] [Names of all direct subkeys of '/path/'.]] + [[=values=] [Names of values contained in registry key given by '/path/'. The "default" value of the key appears in the returned list only if its value has been set in the registry.]] +] + +If '/result-type/' is not recognized, or requested data cannot be retrieved, the rule returns an empty list. +Example: + +[pre +local key = "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths" ; +local subkeys = \[ W32_GETREGNAMES "$(key)" : subkeys \] ; +for local subkey in $(subkeys) +{ + local values = \[ W32_GETREGNAMES "$(key)\\\\$(subkey)" : values \] ; + for local value in $(values) + { + local data = \[ W32_GETREG "$(key)\\\\$(subkey)" : "$(value)" \] ; + ECHO "Registry path: " $(key)\\\\$(subkey) ":" $(value) "=" $(data) ; + } +} +] + +[endsect] + +[section =SHELL= ] + [pre rule SHELL ( /command/ : * ) ] @@ -800,6 +908,8 @@ builtin rule, =COMMAND= can be used as an alias for =SHELL= in such a case. [endsect] +[endsect] + [section Flow-of-Control] =BJam= has several simple flow-of-control statements: diff --git a/historic/jam/src/builtins.c b/historic/jam/src/builtins.c index 6be62b9d2..02ae5908d 100644 --- a/historic/jam/src/builtins.c +++ b/historic/jam/src/builtins.c @@ -53,6 +53,7 @@ # if defined( OS_NT ) || defined( OS_CYGWIN ) LIST* builtin_system_registry( PARSE *parse, FRAME *frame ); +LIST* builtin_system_registry_names( PARSE *parse, FRAME *frame ); # endif int glob( char *s, char *c ); @@ -327,6 +328,12 @@ load_builtins() bind_builtin( "W32_GETREG", builtin_system_registry, 0, args ); } + + { + char * args[] = { "key_path", ":", "result-type", 0 }; + bind_builtin( "W32_GETREGNAMES", + builtin_system_registry_names, 0, args ); + } # endif { diff --git a/historic/jam/src/w32_getreg.c b/historic/jam/src/w32_getreg.c index 506d1e20e..8da65a558 100644 --- a/historic/jam/src/w32_getreg.c +++ b/historic/jam/src/w32_getreg.c @@ -1,6 +1,8 @@ -/* Copyright Paul Lin 2003. Distributed under the Boost */ -/* Software License, Version 1.0. (See accompanying */ -/* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ +/* +Copyright Paul Lin 2003. Copyright 2006 Bojan Resnik. +Distributed under the Boost Software License, Version 1.0. (See accompanying +file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +*/ # include "jam.h" @@ -15,7 +17,9 @@ # define WIN32_LEAN_AND_MEAN # include -# define MAX_REGISTRY_DATA_LENGTH 4096 +# define MAX_REGISTRY_DATA_LENGTH 4096 +# define MAX_REGISTRY_KEYNAME_LENGTH 256 +# define MAX_REGISTRY_VALUENAME_LENGTH 16384 typedef struct { @@ -33,6 +37,26 @@ static const KeyMap dlRootKeys[] = { { 0, 0 } }; +static HKEY get_key(char const** path) +{ + const KeyMap *p; + + for (p = dlRootKeys; p->name; ++p) + { + int n = strlen(p->name); + if (!strncmp(*path,p->name,n)) + { + if ((*path)[n] == '\\' || (*path)[n] == 0) + { + *path += n + 1; + break; + } + } + } + + return p->value; +} + LIST* builtin_system_registry( PARSE *parse, @@ -40,27 +64,8 @@ builtin_system_registry( { char const* path = lol_get(frame->args, 0)->string; LIST* result = L0; - HKEY key; + HKEY key = get_key(&path); - { - const KeyMap *p; - - for (p = dlRootKeys; p->name; ++p) - { - int n = strlen(p->name); - if (!strncmp(path,p->name,n)) - { - if (path[n] == '\\' || path[n] == 0) - { - path += n + 1; - break; - } - } - } - - key = p->value; - } - if ( key != 0 && ERROR_SUCCESS == RegOpenKeyEx(key, path, 0, KEY_QUERY_VALUE, &key) @@ -125,4 +130,78 @@ builtin_system_registry( return result; } +static LIST* get_subkey_names(HKEY key, char const* path) +{ + LIST* result = 0; + + if ( ERROR_SUCCESS == + RegOpenKeyEx(key, path, 0, KEY_ENUMERATE_SUB_KEYS, &key) + ) + { + char name[MAX_REGISTRY_KEYNAME_LENGTH]; + DWORD name_size = sizeof(name); + DWORD index; + FILETIME last_write_time; + + for ( index = 0; + ERROR_SUCCESS == RegEnumKeyEx( + key, index, name, &name_size, 0, 0, 0, &last_write_time); + ++index, + name_size = sizeof(name) + ) + { + name[name_size] = 0; + result = list_append(result, list_new(0, newstr(name))); + } + + RegCloseKey(key); + } + + return result; +} + +static LIST* get_value_names(HKEY key, char const* path) +{ + LIST* result = 0; + + if ( ERROR_SUCCESS == RegOpenKeyEx(key, path, 0, KEY_QUERY_VALUE, &key) ) + { + char name[MAX_REGISTRY_VALUENAME_LENGTH]; + DWORD name_size = sizeof(name); + DWORD index; + + for ( index = 0; + ERROR_SUCCESS == RegEnumValue( + key, index, name, &name_size, 0, 0, 0, 0); + ++index, + name_size = sizeof(name) + ) + { + name[name_size] = 0; + result = list_append(result, list_new(0, newstr(name))); + } + + RegCloseKey(key); + } + + return result; +} + +LIST* +builtin_system_registry_names( + PARSE *parse, + FRAME *frame ) +{ + char const* path = lol_get(frame->args, 0)->string; + char const* result_type = lol_get(frame->args, 1)->string; + + HKEY key = get_key(&path); + + if ( !strcmp(result_type, "subkeys") ) + return get_subkey_names(key, path); + if ( !strcmp(result_type, "values") ) + return get_value_names(key, path); + return 0; +} + # endif diff --git a/historic/jam/test/builtin_w32_getregnames.jam b/historic/jam/test/builtin_w32_getregnames.jam new file mode 100644 index 000000000..fdcdde8cb --- /dev/null +++ b/historic/jam/test/builtin_w32_getregnames.jam @@ -0,0 +1,46 @@ +#~ Copyright 2006 Rene Rivera. +#~ Distributed under the Boost Software License, Version 1.0. +#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + +ECHO --- Testing W32_GETREGNAMES builtin... ; + +local result = 0 ; +local rule error ( message * ) +{ + local b = [ BACKTRACE ] ; + ECHO "$(b[9]):$(b[10]): error:" $(message) ; +} +local rule assert ( expected * : test ? : obtained * ) +{ + test ?= "(==)" ; + local r = 0 ; + if $(test) = "(==)" && $(expected) != $(obtained) + { + error [FAILED] '$(expected)' $(test) '$(obtained)' ; + r = 1 ; + } + else if $(test) = "(!=)" && $(expected) = $(obtained) + { + error [FAILED] '$(expected)' $(test) '$(obtained)' ; + r = 1 ; + } + result = [ CALC $(result) + $(r) ] ; +} + +#~ --------------------------------------------------------------------- + +if $(NT) +{ + assert "Beep" "ExtendedSounds" + : (==) : [ W32_GETREGNAMES "HKEY_CURRENT_USER\\Control Panel\\Sound" : values ] ; + assert "Beep" "ExtendedSounds" + : (==) : [ W32_GETREGNAMES "HKCU\\Control Panel\\Sound" : values ] ; + assert "Control" "Enum" "Hardware Profiles" "Services" + : (==) : [ W32_GETREGNAMES "HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet" : subkeys ] ; + assert "Control" "Enum" "Hardware Profiles" "Services" + : (==) : [ W32_GETREGNAMES "HKLM\\SYSTEM\\CurrentControlSet" : subkeys ] ; +} + +#~ --------------------------------------------------------------------- + +EXIT --- Complete : $(result) ; diff --git a/historic/jam/test/test.bat b/historic/jam/test/test.bat index 7a058f3d0..d30203037 100644 --- a/historic/jam/test/test.bat +++ b/historic/jam/test/test.bat @@ -9,3 +9,4 @@ set BJAM=..\src\bin.ntx86\bjam @ECHO ON %BJAM% -f builtin_shell.jam +%BJAM% -f builtin_w32_getregnames.jam From ee98ebd218c09f2077dfc427083eda33605c6656 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 10 Sep 2006 23:33:21 +0000 Subject: [PATCH 29/82] -Lpath isn't treated as a search path for libraries on the command-line unless we add -search. So added. [SVN r35063] --- v2/tools/cw.jam | 1 + 1 file changed, 1 insertion(+) diff --git a/v2/tools/cw.jam b/v2/tools/cw.jam index 88b111625..32bce5a1d 100644 --- a/v2/tools/cw.jam +++ b/v2/tools/cw.jam @@ -188,6 +188,7 @@ actions compile.c++ flags cw.link DEF_FILE ; +flags cw LINKFLAGS : -search ; flags cw LINKFLAGS on : -g ; flags cw LINKFLAGS console : -subsystem console ; flags cw LINKFLAGS gui : -subsystem windows ; From 538de7b8785169f18a7d291eba4629d082d24968 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 10 Sep 2006 23:45:20 +0000 Subject: [PATCH 30/82] Fix CodeWarrior compatibility [SVN r35064] --- v2/tools/python.jam | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 3f266d905..118ba9123 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -311,18 +311,7 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? # The name of Python library file does not have a dot between # major and minor version. local PYTHON_VERSION_NODOT = [ regex.match ([0-9]+)[.]([0-9]+).* : $(version) : 1 2 ] ; - if $(PYTHON_VERSION_NODOT) - { - PYTHON_VERSION_NODOT = $(PYTHON_VERSION_NODOT[1])$(PYTHON_VERSION_NODOT[2]) ; - } - else - { - # Try to link to 'python' lib, without version. Probably won't - # work, but better that not passing any library name at all. - PYTHON_VERSION_NODOT = "" ; - } - - + PYTHON_VERSION_NODOT = $(PYTHON_VERSION_NODOT:J="") ; PYTHON_DLL ?= [ GLOB $(PATH) $(Path) : python$(PYTHON_VERSION_NODOT).dll ] ; PYTHON_DEBUG_DLL ?= [ GLOB $(PATH) $(Path) : python$(PYTHON_VERSION_NODOT)_d.dll ] ; From 698d25a4743a9b3811aeb3f5af06594eba7f3af0 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 12 Sep 2006 09:28:11 +0000 Subject: [PATCH 31/82] Properly generated flag for intel/vc. * intel-win.jam (init): Strip 'vc' from the version passed to msvc.configure-verion-specific. * msvc.jam (configure-version-specific): Accept '6' and '7', not just 6.N and 7.N. [SVN r35071] --- v2/tools/intel-win.jam | 12 ++++++++++-- v2/tools/msvc.jam | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/v2/tools/intel-win.jam b/v2/tools/intel-win.jam index f138607a0..68d707298 100644 --- a/v2/tools/intel-win.jam +++ b/v2/tools/intel-win.jam @@ -7,6 +7,7 @@ import toolset ; import feature ; import toolset : flags ; import os ; +import errors ; # This is needed because the rule we import here depend on 'common' # That's nasty. @@ -137,10 +138,17 @@ rule init ( version ? : # the compiler version if ! $(compatibility) { # If there's no backend version, assume 7.1. - compatibility = 7.1 ; + compatibility = vc7.1 ; } - msvc.configure-version-specific intel-win : $(compatibility) : $(condition) ; + local extract-version = [ MATCH ^vc(.*) : $(compatibility) ] ; + if ! $(extract-version) + { + errors.user-error "Invalid value for compatibility option:" + $(compatibility) ; + } + + msvc.configure-version-specific intel-win : $(extract-version[1]) : $(condition) ; } flags intel-win.link LIBRARY_OPTION intel : "" ; diff --git a/v2/tools/msvc.jam b/v2/tools/msvc.jam index 119e8e23f..98fbac877 100644 --- a/v2/tools/msvc.jam +++ b/v2/tools/msvc.jam @@ -415,7 +415,7 @@ rule configure-version-specific ( toolset : version : condition ) # Processor-specific optimization # - if [ MATCH ^([67]\\.) : $(version) ] + if [ MATCH ^([67]) : $(version) ] { # 8.0 deprecates some of the options flags $(toolset).compile CFLAGS $(condition)/speed $(condition)/space : /Ogiy /Gs ; From 18f843cf321f3b195c62d46d9daf5b86eb8a755e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 12 Sep 2006 22:31:14 +0000 Subject: [PATCH 32/82] Workaround to get -shared in the link line for Python extensions [SVN r35073] --- v2/tools/cw.jam | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/v2/tools/cw.jam b/v2/tools/cw.jam index 32bce5a1d..4c3a2f03a 100644 --- a/v2/tools/cw.jam +++ b/v2/tools/cw.jam @@ -197,7 +197,6 @@ flags cw LINKFLAGS native : -subsystem native ; flags cw LINKFLAGS auto : -subsystem auto ; flags cw LINKFLAGS LIB/static : -library ; -flags cw LINKFLAGS LIB/shared : -shared ; flags cw.link USER_LINKFLAGS ; flags cw.link LINKPATH ; @@ -239,6 +238,6 @@ actions link bind DEF_FILE actions link.dll bind DEF_FILE { - $(.LD) -o "$(<[1]:W)" -implib "$(<[2]:W)" -L"$(LINKPATH)" $(LINKFLAGS) -f"$(DEF_FILE)" $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" + $(.LD) -shared -o "$(<[1]:W)" -implib "$(<[2]:W)" -L"$(LINKPATH)" $(LINKFLAGS) -f"$(DEF_FILE)" $(USER_LINKFLAGS) @"@($(<[1]:W).rsp:E=$(nl)"$(>)" $(nl)$(LIBRARIES_MENTIONED_BY_FILE) $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_ST:S=.lib)" $(nl)"$(LIBRARY_OPTION)$(FINDLIBS_SA:S=.lib)")" } From 35798dd5660fa89e476e569fae0a336e17fca633 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 12 Sep 2006 23:53:34 +0000 Subject: [PATCH 33/82] Find frameworks properly [SVN r35077] --- v2/tools/darwin.jam | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/tools/darwin.jam b/v2/tools/darwin.jam index 557424d5f..74cc2f0d4 100644 --- a/v2/tools/darwin.jam +++ b/v2/tools/darwin.jam @@ -62,13 +62,13 @@ _ = " " ; actions link bind LIBRARIES { - $(CONFIG_COMMAND) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) -framework$(_)$(FRAMEWORK) $(OPTIONS) $(USER_OPTIONS) + $(CONFIG_COMMAND) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) -F$(FRAMEWORK:D) -framework$(_)$(FRAMEWORK:D=) $(OPTIONS) $(USER_OPTIONS) $(NEED_STRIP)strip $(NEED_STRIP)"$(<)" } actions link.dll bind LIBRARIES { - $(CONFIG_COMMAND) -dynamiclib -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) -framework$(_)$(FRAMEWORK) $(OPTIONS) $(USER_OPTIONS) + $(CONFIG_COMMAND) -dynamiclib -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) -F$(FRAMEWORK:D) -framework$(_)$(FRAMEWORK:D=) $(OPTIONS) $(USER_OPTIONS) } actions piecemeal archive From 14295c86d669dcee9220737d84f5fa41ea55489f Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 13 Sep 2006 11:58:47 +0000 Subject: [PATCH 34/82] Clarify installation from distributors point of view [SVN r35088] --- v2/doc/src/install.xml | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/v2/doc/src/install.xml b/v2/doc/src/install.xml index 12f3e6aaa..86041f8e2 100644 --- a/v2/doc/src/install.xml +++ b/v2/doc/src/install.xml @@ -167,4 +167,72 @@ boost-build /path/to/boost.build ; Boost.Build v2, you have to add the command line option to all bjam invocations. + + + Information for distributors + + + If you're planning to package Boost.Build for a Linux distribution, + please follow these guidelines: + + + Create a separate package for Boost.Jam. + + + Create another package for Boost.Build, and make + this package install all Boost.Build files to + /usr/share/boost-build directory. After + install, that directory should contain everything you see in + Boost.Build release package, except for + jam_src directory. If you're using Boost CVS + to obtain Boost.Build, as opposed to release package, take + everything from the tools/build/v2 directory. + For a check, make sure that + /usr/share/boost-build/boost-build.jam is installed. + + + Placing Boost.Build into /usr/share/boost-build + will make sure that bjam will find Boost.Build + without any additional setup. + + + Provide a + /etc/site-config.jam configuration file that will + contain: + +using gcc ; + + You might want to add dependency from Boost.Build package to gcc, + to make sure that users can always build Boost.Build examples. + + + + + If those guidelines are met, users will be able to invoke + bjam without any explicit configuration. + + + + + + + + From f067c15692d65d7ae035aeb278f140afb096d558 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 16 Sep 2006 18:43:53 +0000 Subject: [PATCH 35/82] Default to Python 2.4 in Unix builds Applied contributed patches http://tinyurl.com/ndljr and http://tinyurl.com/18r [SVN r35138] --- v2/tools/python.jam | 1 + 1 file changed, 1 insertion(+) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 118ba9123..0cba5b0d5 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -109,6 +109,7 @@ rule init ( version ? : root ? : includes ? : libraries ? rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) { + version ?= 2.4 ; root ?= /usr ; includes ?= $(root)/include/python$(version) ; libraries ?= $(root)/lib/python$(version)/config ; From 4d0121bd63462196b8d3c1b37412427ed1a4916f Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 17 Sep 2006 02:41:20 +0000 Subject: [PATCH 36/82] More informative error messages Better autoconfiguration [SVN r35140] --- v2/tools/python.jam | 123 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 104 insertions(+), 19 deletions(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 0cba5b0d5..c279ed34e 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -107,30 +107,115 @@ rule init ( version ? : root ? : includes ? : libraries ? project.pop-current ; } -rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) +local rule python-version ( cmd ) { - version ?= 2.4 ; - root ?= /usr ; - includes ?= $(root)/include/python$(version) ; - libraries ?= $(root)/lib/python$(version)/config ; + cmd ?= python ; + local version = [ SHELL $(cmd)" -c 'import sys; print sys.version'" : exit-status ] ; - # Find the 'python' binary, which is used for testing. - # Look first in $(root)/bin, then in PATH. - local interpreter = [ common.get-invocation-command - python : python : : $(root)/bin : path-last ] ; - - if $(interpreter:D) != $(root)/bin - { - ECHO "warning: was expecting Python interpreter in " $(root)/bin ; - ECHO "warning: found only in PATH:" $(interpreter) ; - } - + if $(version[2]) = 0 + { + return [ MATCH ^([0-9]+.[0-9]+) : $(version[1]) : 1 ] ; + } + else + { + return ; + } +} + +local rule python-interpreter ( cmd ) +{ + local which = [ SHELL "which "$(cmd) : exit-status ] ; + if $(which[2]) = 0 + { + return $(which[1]) ; + } + else + { + return ; + } +} + +local rule python-root ( cmd ) +{ + return [ MATCH (.*)/bin/[^/]* : [ SHELL "which "$(cmd) ] : 1 ] ; +} + + +local rule debug-message ( message * ) +{ if --debug-configuration in [ modules.peek : ARGV ] { - ECHO "notice: Python include path is" $(includes) ; - ECHO "notice: Python library path is" $(libraries) ; - ECHO "notice: Python interpreter is" $(interpreter) ; + ECHO notice: $(message) ; } +} + +rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) +{ + # + # Autoconfiguration sequence + # + if $(version) + { + if ! [ MATCH ^[0-9]+\.[0-9]+$ : $(version) : 0 ] + { + ECHO "Warning: \"using python\" expects a two part (major, minor) version number; got" $(version) instead ; + } + debug-message looking for python $(version) ; + } + + # if root is explicitly specified, look in its bin subdirectory + local bin = $(bin/:R=(root)) ; + if $(bin) + { + debug-message searching for python binaries in $(bin) ; + } + + # Form the python commands to try in order. First look for python + # with the explicit version number, then without it + local cmds = $(bin:E="")python$(version:E="") $(bin:E="")python ; + + local interpreter ; + while $(cmds) + { + # pop a command + interpreter = $(cmds[0]) ; cmds = $(cmds[2-]) ; + debug-message trying Python interpreter command $(interpreter) ; + + # Check to see what version that command actually runs, if any + local true-version = [ python-version $(interpreter) ] ; + + if ! $(true-version) + { + debug-message $(interpreter) does not invoke a working Python interpreter ; + } + else + { + debug-message $(interpreter) invokes actual Python (major,minor) version $(true-version) ; + + # if no version was specified, assume that's OK + version ?= $(true-version) ; + + # if the version is a match, stop searching + if $(version) = $(true-version) + { + debug-message qualifying Python interpreter found ; + root ?= [ python-root $(interpreter) ] ; + cmds = ; # break + } + } + } + debug-message "Python interpreter command is" $(interpreter) ; + + includes ?= $(root)/include/python$(version) ; + debug-message "Python include path is" $(includes) ; + + libraries ?= $(root)/lib/python$(version)/config ; + debug-message "Python library path is" $(includes) ; + + # + # End autoconfiguration sequence + # + # If not specific condition is specified, set global value # If condition is specified, set PYTHON on target. It will From f062d49c4b560cee09c8f69d7674f69d0a53e273 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sun, 17 Sep 2006 17:17:10 +0000 Subject: [PATCH 37/82] Mention target requirements in --debug-building output. * build/targets.jam (basic-target.generate): Print requirements. [SVN r35145] --- v2/build/targets.jam | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/v2/build/targets.jam b/v2/build/targets.jam index c23c87fcc..2c8689ec0 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -1142,11 +1142,12 @@ class basic-target : abstract-target { ECHO [ targets.indent ] "Building target '$(self.name)'" ; ECHO [ targets.indent ] "Build request: " [ $(property-set).raw ] ; + ECHO [ targets.indent ] "Target requirements: " [ $(self.requirements).raw ] ; targets.increase-indent ; } if ! $(self.generated.$(property-set)) - { + { local rproperties = [ targets.common-properties $(property-set) $(self.requirements) ] ; From 6900b5680c48f2e8dcce2dc95d2168757804c10b Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sun, 17 Sep 2006 18:35:43 +0000 Subject: [PATCH 38/82] * tools/stage.jam (rename): Generate 'vc6' and 'vc7' suffixes instead of 'vc60' and 'vc70', to match V1 behaviour. [SVN r35147] --- v2/tools/stage.jam | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/v2/tools/stage.jam b/v2/tools/stage.jam index c775c35ba..18c38f022 100644 --- a/v2/tools/stage.jam +++ b/v2/tools/stage.jam @@ -516,6 +516,22 @@ rule rename ( name : type ? : property-set : unversioned ? ) case vacpp* : toolset-tag += xlc ; } local version = [ MATCH "([0123456789]+)[.]([0123456789]*)" : $(properties) ] ; + # For historical reasons, vc6.0 and vc7.0 use different + # naming. + if $(toolset-tag) = vc + { + if $(version[1]) = 6 + { + # Cancel minor version. + version = 6 ; + } + else if $(version[1]) = 7 && $(version[2]) = 0 + { + version = 7 ; + } + } + + toolset-tag += $(version) ; } From a3a6db940a69f35252fad171de4dd20f64628cfd Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 18 Sep 2006 04:00:34 +0000 Subject: [PATCH 39/82] Minor cleanup of hash code, to make reduce the likelyhood of bugs in it. Made debug build not use the custom string allocator to allow using valgrind to detect access errors. [SVN r35154] --- historic/jam/src/build.jam | 4 ++ historic/jam/src/hash.c | 139 +++++++++++++++++++++---------------- historic/jam/src/mem.h | 4 ++ 3 files changed, 89 insertions(+), 58 deletions(-) diff --git a/historic/jam/src/build.jam b/historic/jam/src/build.jam index 6c010d108..6228a8ceb 100644 --- a/historic/jam/src/build.jam +++ b/historic/jam/src/build.jam @@ -473,6 +473,10 @@ if $(with-python) --defs += HAVE_PYTHON ; } +if $(debug) +{ + --defs += BJAM_NEWSTR_NO_ALLOCATE ; +} # The basic symbolic targets... diff --git a/historic/jam/src/hash.c b/historic/jam/src/hash.c index c1d7a02cd..40cb7d817 100644 --- a/historic/jam/src/hash.c +++ b/historic/jam/src/hash.c @@ -96,6 +96,47 @@ static void hash_mem_free(size_t datalen, void * data); static void hash_mem_finalizer(char * key, struct hash * hp); #endif +static unsigned int hash_keyval( const unsigned char * key ) +{ + unsigned int keyval = *key; + while( *key ) + keyval = keyval * 2147059363 + *key++; + return keyval; +} + +#define hash_bucket(hp,keyval) ((hp)->tab.base + ( (keyval) % (hp)->tab.nel )) + +/* Find the hash item for the given data. Returns pointer to the + item and if given a pointer to the item before the found item. + If it's the first item in a bucket, there is no previous item, + and zero is returned for the previous item instead. +*/ +static ITEM * hash_search( + struct hash *hp, + unsigned int keyval, + const unsigned char * keydata, + ITEM ** previous ) +{ + ITEM * i = *hash_bucket(hp,keyval); + ITEM * p = 0; + + for ( ; i; i = i->hdr.next ) + { + if( keyval == i->hdr.keyval && + !strcmp( i->data.key, keydata ) ) + { + if (previous) + { + *previous = p; + } + return i; + } + p = i; + } + + return 0; +} + /* * hash_free() - remove the given item from the table if it's there. * Returns 1 if found, 0 otherwise. @@ -104,38 +145,28 @@ static void hash_mem_finalizer(char * key, struct hash * hp); */ int hash_free( - register struct hash *hp, - HASHDATA *data) + register struct hash *hp, + HASHDATA *data) { - ITEM **prev; - register ITEM **i; - unsigned char *b = (unsigned char*)data->key; - unsigned int keyval; - - keyval = *b; - - while( *b ) - keyval = keyval * 2147059363 + *b++; - - prev = hp->tab.base + ( keyval % hp->tab.nel ); - while(*prev ) + ITEM * i = 0; + ITEM * prev = 0; + unsigned int keyval = hash_keyval((unsigned char*)data->key); + + i = hash_search( hp, keyval, (unsigned char*)data->key, &prev ); + if (i) { - register ITEM* i = *prev; - if( keyval == i->hdr.keyval && - !strcmp( i->data.key, data->key ) ) - { - /* unlink the record from the hash chain */ - *prev = i->hdr.next; - /* link it into the freelist */ - i->hdr.next = hp->items.free; - hp->items.free = i; - /* mark it free so we skip it during enumeration */ - i->data.key = 0; - /* we have another item */ - hp->items.more++; - return 1; - } - prev = &i->hdr.next; + /* mark it free so we skip it during enumeration */ + i->data.key = 0; + /* unlink the record from the hash chain */ + if (prev) prev->hdr.next = i->hdr.next; + else *hash_bucket(hp,keyval) = i->hdr.next; + /* link it into the freelist */ + i->hdr.next = hp->items.free; + hp->items.free = i; + /* we have another item */ + hp->items.more++; + + return 1; } return 0; } @@ -150,10 +181,9 @@ hashitem( HASHDATA **data, int enter ) { - ITEM **base; register ITEM *i; unsigned char *b = (unsigned char*)(*data)->key; - unsigned int keyval; + unsigned int keyval = hash_keyval(b); #ifdef HASH_DEBUG_PROFILE profile_frame prof[1]; @@ -172,28 +202,21 @@ hashitem( #endif return 0; } - - keyval = *b; - - while( *b ) - keyval = keyval * 2147059363 + *b++; - - base = hp->tab.base + ( keyval % hp->tab.nel ); - - for( i = *base; i; i = i->hdr.next ) - if( keyval == i->hdr.keyval && - !strcmp( i->data.key, (*data)->key ) ) - { - *data = &i->data; + + i = hash_search( hp, keyval, (unsigned char*)(*data)->key, 0 ); + if (i) + { + *data = &i->data; #ifdef HASH_DEBUG_PROFILE - if ( DEBUG_PROFILE ) - profile_exit( prof ); + if ( DEBUG_PROFILE ) profile_exit( prof ); #endif - return !0; - } + return !0; + } - if( enter ) - { + if( enter ) + { + ITEM **base = hash_bucket(hp,keyval); + /* try to grab one from the free list */ if ( hp->items.free ) { @@ -206,19 +229,19 @@ hashitem( i = (ITEM *)hp->items.next; hp->items.next += hp->items.size; } - hp->items.more--; - memcpy( (char *)&i->data, (char *)*data, hp->items.datalen ); - i->hdr.keyval = keyval; - i->hdr.next = *base; - *base = i; - *data = &i->data; + hp->items.more--; + memcpy( (char *)&i->data, (char *)*data, hp->items.datalen ); + i->hdr.keyval = keyval; + i->hdr.next = *base; + *base = i; + *data = &i->data; #ifdef OPT_BOEHM_GC if (sizeof(HASHDATA) == hp->items.datalen) { GC_REGISTER_FINALIZER(i->data.key,&hash_mem_finalizer,hp,0,0); } #endif - } + } #ifdef HASH_DEBUG_PROFILE if ( DEBUG_PROFILE ) diff --git a/historic/jam/src/mem.h b/historic/jam/src/mem.h index 49318cd15..a3cb5ff31 100644 --- a/historic/jam/src/mem.h +++ b/historic/jam/src/mem.h @@ -26,7 +26,9 @@ http://www.boost.org/LICENSE_1_0.txt) #define bjam_realloc_raw_x(p,s) realloc(p,s) #define bjam_free_raw_x(p) free(p) + #ifndef BJAM_NEWSTR_NO_ALLOCATE #define BJAM_NEWSTR_NO_ALLOCATE + #endif #elif defined(OPT_DUMA) @@ -53,7 +55,9 @@ http://www.boost.org/LICENSE_1_0.txt) #define bjam_realloc_x(p,s) realloc(p,s) #define bjam_free_x(p) free(p) + #ifndef BJAM_NEWSTR_NO_ALLOCATE #define BJAM_NEWSTR_NO_ALLOCATE + #endif #else From 160c7c18e9c5f17ffa8ef362b64879597aac994b Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 18 Sep 2006 05:31:51 +0000 Subject: [PATCH 40/82] Add glob-tree which gobs complete directory trees. [SVN r35155] --- v2/util/path.jam | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/v2/util/path.jam b/v2/util/path.jam index cedff58a8..c63ddb2da 100644 --- a/v2/util/path.jam +++ b/v2/util/path.jam @@ -236,6 +236,30 @@ rule glob ( dirs * : patterns + ) } +# Recursive version of GLOB. Builds the glob of files while +# also searching in the subdirectories of the given roots. +# +rule glob-tree ( roots * : patterns + ) +{ + return [ sequence.transform path.make : [ .glob-tree + [ sequence.transform path.native : $(roots) ] : $(patterns) ] ] ; +} + +local rule .glob-tree ( roots * : patterns * ) +{ + local result = [ GLOB $(roots) : $(patterns) ] ; + local subdirs ; + for local d in [ GLOB $(roots) : * ] + { + if ! ( $(d:D=) in . .. ) && ! [ CHECK_IF_FILE $(d) ] { subdirs += $(d) ; } + } + if $(subdirs) + { + result += [ .glob-tree $(subdirs) : $(patterns) ] ; + } + return $(result) ; +} + # # Returns true is the specified file exists. From ec1e0896f0236d0f863fa5ad37966580644a2c91 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 18 Sep 2006 08:51:08 +0000 Subject: [PATCH 41/82] * build/property-set.jam (refine-from-user-input): New, extracted from main-target-requirements, with extra code to handle "-value" syntax. * build/targets.jam (main-target-requirements): Use the above. * build/project.jam (project-attributes.set): Likewise. [SVN r35159] --- v2/build/project.jam | 13 +++------- v2/build/property-set.jam | 53 +++++++++++++++++++++++++++++++++++++++ v2/build/targets.jam | 9 +++---- 3 files changed, 59 insertions(+), 16 deletions(-) diff --git a/v2/build/project.jam b/v2/build/project.jam index 1455b6f5e..08565be90 100644 --- a/v2/build/project.jam +++ b/v2/build/project.jam @@ -568,16 +568,9 @@ class project-attributes } else if $(attribute) = "requirements" { - local result = [ property-set.create-from-user-input - $(specification) : $(self.project-module) $(self.location) ] ; - - # If we have inherited properties, need to refine them with the - # specified. - local current = $(self.requirements) ; - if $(current) - { - result = [ $(current).refine $(result) ] ; - } + local result = [ property-set.refine-from-user-input + $(self.requirements) : $(specification) + : $(self.project-module) : $(self.location) ] ; if $(result[1]) = "@error" { diff --git a/v2/build/property-set.jam b/v2/build/property-set.jam index 3fda5e8f7..00e8383e6 100644 --- a/v2/build/property-set.jam +++ b/v2/build/property-set.jam @@ -7,6 +7,7 @@ import "class" : new ; import feature ; import property ; import sequence ; +import set ; # Class for storing a set of properties. # - there's 1<->1 correspondence between identity and value. No @@ -386,6 +387,58 @@ rule create-from-user-input ( raw-properties * : jamfile-module location ) return $(result) ; } +# Refines requirements with requirements provided by the user. +# Specially handles "-value" syntax in specification +# to remove given requirements. +# - parent-requirements -- property-set object with requirements +# to refine +# - specification -- string list of requirements provided by the use +# - project-module -- the module to which context indirect features +# will be bound. +# - location -- the path to which path features are relative. +# +# +rule refine-from-user-input ( parent-requirements : specification * + : project-module : location ) +{ + if ! $(specification) + { + return $(parent-requirements) ; + } + else + { + local add-requirements ; + local remove-requirements ; + + for local r in $(specification) + { + local m = [ MATCH "^-(.*)" : $(r) ] ; + if $(m) + { + remove-requirements += $(m) ; + } + else + { + add-requirements += $(r) ; + } + } + + if $(remove-requirements) + { + parent-requirements = [ property-set.create + [ set.difference [ $(parent-requirements).raw ] + : $(remove-requirements) ] ] ; + specification = $(add-requirements) ; + } + + local requirements = [ property-set.create-from-user-input + $(specification) : $(project-module) $(location) ] ; + + requirements = [ $(parent-requirements).refine $(requirements) ] ; + return $(requirements) ; + } +} + # Returns property-set with empty set of properties. diff --git a/v2/build/targets.jam b/v2/build/targets.jam index 2c8689ec0..94bfc6b28 100644 --- a/v2/build/targets.jam +++ b/v2/build/targets.jam @@ -1400,13 +1400,10 @@ rule main-target-requirements ( : project # Project where the main target is to be declared ) { - local loc = [ $(project).get location ] ; - local jamfile-module = [ $(project).project-module ] ; - local requirements = [ property-set.create-from-user-input $(specification) - : $(jamfile-module) $(loc) ] ; + local requirements = [ property-set.refine-from-user-input + [ $(project).get requirements ] : $(specification) : + [ $(project).project-module ] : [ $(project).get location ] ] ; - local project-requirements = [ $(project).get requirements ] ; - requirements = [ $(project-requirements).refine $(requirements) ] ; if $(requirements[1]) = "@error" { errors.error "Conflicting requirements for target:" $(requirements) ; From a18d9df30cea416f96f60d410ca9718849f9ae8f Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Mon, 18 Sep 2006 19:56:19 +0000 Subject: [PATCH 42/82] Test for 'cancel requirement' feature [SVN r35169] --- v2/test/remove_requirement.py | 82 +++++++++++++++++++++++++++++++++++ v2/test/test_all.py | 1 + 2 files changed, 83 insertions(+) create mode 100644 v2/test/remove_requirement.py diff --git a/v2/test/remove_requirement.py b/v2/test/remove_requirement.py new file mode 100644 index 000000000..5f49baeb0 --- /dev/null +++ b/v2/test/remove_requirement.py @@ -0,0 +1,82 @@ +#!/usr/bin/python + +# Copyright (C) Vladimir Prus 2006. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +from BoostBuild import Tester, List +import string + +t = Tester() + +t.write("Jamroot", """ +project : requirements multi debug:static ; + +build-project sub ; +build-project sub2 ; +build-project sub3 ; +build-project sub4 ; +""") + +t.write("sub/Jamfile", """ +exe hello : hello.cpp : -multi ; +""") + +t.write("sub/hello.cpp", """ +int main() +{ + return 0; +} + +""") + +t.write("sub2/Jamfile", """ +project : requirements -multi ; +exe hello : hello.cpp ; +""") + +t.write("sub2/hello.cpp", """ +int main() +{ + return 0; +} + +""") + +t.write("sub3/hello.cpp", """ +int main() +{ + return 0; +} + +""") + +t.write("sub3/Jamfile", """ +exe hello : hello.cpp : -debug:static ; +""") + +t.write("sub4/hello.cpp", """ +int main() +{ + return 0; +} + +""") + +t.write("sub4/Jamfile", """ +project : requirements -debug:static ; +exe hello : hello.cpp ; +""") + + + +t.run_build_system() + +t.expect_addition("sub/bin/$toolset/debug/link-static/hello.exe") +t.expect_addition("sub2/bin/$toolset/debug/link-static/hello.exe") +t.expect_addition("sub3/bin/$toolset/debug/threading-multi/hello.exe") +t.expect_addition("sub4/bin/$toolset/debug/threading-multi/hello.exe") + +t.cleanup() + diff --git a/v2/test/test_all.py b/v2/test/test_all.py index 6f856e782..81b6a14e7 100644 --- a/v2/test/test_all.py +++ b/v2/test/test_all.py @@ -142,6 +142,7 @@ tests = [ "rebuilds", "implicit_dependency", "example_libraries", "example_make", + "remove_requirement", ] if os.name == 'posix': From 8255d852654dad1812039ee31b8459b805109561 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Tue, 19 Sep 2006 03:53:15 +0000 Subject: [PATCH 43/82] Order of magnitude speed and memory improvement on sequence.unique. [SVN r35190] --- v2/util/sequence.jam | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/v2/util/sequence.jam b/v2/util/sequence.jam index 9482934c8..187e192a6 100644 --- a/v2/util/sequence.jam +++ b/v2/util/sequence.jam @@ -179,12 +179,14 @@ rule length ( s * ) rule unique ( list * ) { local result ; - for local f in $(list) + local prev ; + for local i in [ SORT $(list) ] { - if ! $(f) in $(result) + if $(i) != $(prev) { - result += $(f) ; + result += $(i) ; } + prev = $(i) ; } return $(result) ; } From 1c7f75cfa3d63960d856342bd757ae43e429eca7 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 19 Sep 2006 13:54:57 +0000 Subject: [PATCH 44/82] Fix version syntax checking [SVN r35200] --- v2/tools/python.jam | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index c279ed34e..5c5b14546 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -156,9 +156,14 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) # if $(version) { - if ! [ MATCH ^[0-9]+\.[0-9]+$ : $(version) : 0 ] + local v = [ MATCH ^([0-9]+\.[0-9]+)(.*)$ : $(version) : 1 2 ] ; + if ! $(v) || $(v[2]) { ECHO "Warning: \"using python\" expects a two part (major, minor) version number; got" $(version) instead ; + if $(v) + { + version = $(v[1]) ; + } } debug-message looking for python $(version) ; } From a994e940dfc3376e6522e5587724d2a1fb9a2ccd Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 19 Sep 2006 19:02:40 +0000 Subject: [PATCH 45/82] Make tags for intel compiler match V1. [SVN r35216] --- v2/tools/stage.jam | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/v2/tools/stage.jam b/v2/tools/stage.jam index 18c38f022..e98083e61 100644 --- a/v2/tools/stage.jam +++ b/v2/tools/stage.jam @@ -503,8 +503,15 @@ rule rename ( name : type ? : property-set : unversioned ? ) case darwin* : toolset-tag += ; case edg* : toolset-tag += edg ; case gcc* : toolset-tag += gcc ; - case intel-linux* : toolset-tag += il ; - case intel-win* : toolset-tag += iw ; + case intel : + if [ $(property-set).get ] = win + { + toolset-tag += iw ; + } + else + { + toolset-tag += il ; + } case kcc* : toolset-tag += kcc ; case kylix* : toolset-tag += bck ; #case metrowerks* : toolset-tag += cw ; @@ -530,7 +537,15 @@ rule rename ( name : type ? : property-set : unversioned ? ) version = 7 ; } } - + # On intel, version is not added, because it does not + # matter and it's the version of vc used as backend + # that matters. Ideally, we'd encode the backend + # version but that will break compatibility with + # V1. + if $(toolset-tag) = iw + { + version = ; + } toolset-tag += $(version) ; } From 21085a508615417bc690ab72c47bd8102bd47e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Tue, 19 Sep 2006 19:40:03 +0000 Subject: [PATCH 46/82] Fix include path for QtAssistantClient library. [SVN r35218] --- v2/tools/qt4.jam | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/tools/qt4.jam b/v2/tools/qt4.jam index 0ca818109..1c0410420 100644 --- a/v2/tools/qt4.jam +++ b/v2/tools/qt4.jam @@ -286,13 +286,13 @@ rule init ( prefix ) : QtAssistantClient$(suffix_version) release : : # usage-requirements - $(.prefix)/include/QtAssistantClient + $(.prefix)/include/QtAssistant ; lib QtAssistantClient : QtGui : QtAssistantClient$(suffix_debug)$(suffix_version) debug : : # usage-requirements - $(.prefix)/include/QtAssistantClient + $(.prefix)/include/QtAssistant ; # Support for dynamic Widgets (Qt 4.1) From e592c9606757a849b13e4a048307f6fd2bdcd426 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 20 Sep 2006 04:03:20 +0000 Subject: [PATCH 47/82] Display seconds in perf data times to help in multi-platform comparison and human comprehension. [SVN r35221] --- historic/jam/src/debug.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/historic/jam/src/debug.c b/historic/jam/src/debug.c index c6635d0d1..df8f4b6c5 100644 --- a/historic/jam/src/debug.c +++ b/historic/jam/src/debug.c @@ -99,14 +99,21 @@ static void dump_profile_entry(void* p_, void* ignored) { profile_info* p = (profile_info*)p_; unsigned long mem_each = (p->memory/(p->num_entries ? p->num_entries : 1)); - double q = p->net; q /= (p->num_entries ? p->num_entries : 1); + double cumulative = p->cumulative; + double net = p->net; + double q = p->net; + q /= (p->num_entries ? p->num_entries : 1); + cumulative /= CLOCKS_PER_SEC; + net /= CLOCKS_PER_SEC; + q /= CLOCKS_PER_SEC; if (!ignored) { profile_total.cumulative += p->net; profile_total.memory += p->memory; } - printf("%10d %10d %10d %12.6f %10d %10d %s\n", - p->num_entries, p->cumulative, p->net, q, + printf("%10d %12.6f %12.6f %12.8f %10d %10d %s\n", + p->num_entries, + cumulative,net,q, p->memory, mem_each, p->name); } @@ -115,7 +122,7 @@ void profile_dump() { if ( profile_hash ) { - printf("%10s %10s %10s %12s %10s %10s %s\n", + printf("%10s %12s %12s %12s %10s %10s %s\n", "--count--", "--gross--", "--net--", "--each--", "--mem--", "--each--", "--name--"); From 4e2d9e6458ba147787cc25c953af9af84e187a47 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 20 Sep 2006 16:09:19 +0000 Subject: [PATCH 48/82] Apply patch from Yakov Markovitch; [ 1558580 ] jam:"VAR on TARGET ?= values" unconditionally assigns values. Add corresponding test. [SVN r35229] --- historic/jam/src/compile.c | 43 ++++++++++++++-------- historic/jam/src/make1.c | 2 +- historic/jam/src/rules.c | 15 +++++--- historic/jam/src/rules.h | 2 +- historic/jam/test/stress_var_expand.jam | 47 ++++++++++++++++++++++++ historic/jam/test/target_var.jam | 49 +++++++++++++++++++++++++ historic/jam/test/test.bat | 3 ++ 7 files changed, 138 insertions(+), 23 deletions(-) create mode 100644 historic/jam/test/stress_var_expand.jam create mode 100644 historic/jam/test/target_var.jam diff --git a/historic/jam/src/compile.c b/historic/jam/src/compile.c index f44eb1213..4886f8898 100644 --- a/historic/jam/src/compile.c +++ b/historic/jam/src/compile.c @@ -266,7 +266,7 @@ compile_foreach( if ( parse->num ) { - s = addsettings( s, 0, parse->string, L0 ); + s = addsettings( s, VAR_SET, parse->string, L0 ); pushsettings( s ); } @@ -492,7 +492,7 @@ compile_local( /* Initial value is ns */ for( l = nt; l; l = list_next( l ) ) - s = addsettings( s, 0, l->string, list_copy( (LIST*)0, ns ) ); + s = addsettings( s, VAR_SET, l->string, list_copy( (LIST*)0, ns ) ); list_free( ns ); list_free( nt ); @@ -783,7 +783,7 @@ collect_arguments( RULE* rule, FRAME* frame ) } } - locals = addsettings( locals, 0, name, value ); + locals = addsettings( locals, VAR_SET, name, value ); type_check( type_name, value, frame, rule, arg_name ); type_name = 0; } @@ -1111,6 +1111,26 @@ compile_rules( return parse_evaluate( parse, frame ); } +/* + * assign_var_mode() - convert ASSIGN_XXX compilation flag into + * corresponding VAR_XXX variable set flag. + */ +static int assign_var_mode(int parsenum, const char **tracetext) +{ + const char *trace; + int setflag; + switch( parsenum ) + { + case ASSIGN_SET: setflag = VAR_SET; trace = "="; break; + case ASSIGN_APPEND: setflag = VAR_APPEND; trace = "+="; break; + case ASSIGN_DEFAULT: setflag = VAR_DEFAULT; trace = "?="; break; + default: setflag = VAR_SET; trace = ""; break; + } + if (tracetext) + *tracetext = trace ; + return setflag; +} + /* * compile_set() - compile the "set variable" statement * @@ -1127,16 +1147,8 @@ compile_set( LIST *nt = parse_evaluate( parse->left, frame ); LIST *ns = parse_evaluate( parse->right, frame ); LIST *l; - int setflag; char *trace; - - switch( parse->num ) - { - case ASSIGN_SET: setflag = VAR_SET; trace = "="; break; - case ASSIGN_APPEND: setflag = VAR_APPEND; trace = "+="; break; - case ASSIGN_DEFAULT: setflag = VAR_DEFAULT; trace = "?="; break; - default: setflag = VAR_SET; trace = ""; break; - } + int setflag = assign_var_mode( parse->num, &trace ); if( DEBUG_COMPILE ) { @@ -1228,7 +1240,8 @@ compile_settings( LIST *ns = parse_evaluate( parse->third, frame ); LIST *targets = parse_evaluate( parse->right, frame ); LIST *ts; - int append = parse->num == ASSIGN_APPEND; + char *trace; + int setflag = assign_var_mode( parse->num, &trace ); if( DEBUG_COMPILE ) { @@ -1236,7 +1249,7 @@ compile_settings( list_print( nt ); printf( " on " ); list_print( targets ); - printf( " %s ", append ? "+=" : "=" ); + printf( " %s ", trace ); list_print( ns ); printf( "\n" ); } @@ -1251,7 +1264,7 @@ compile_settings( LIST *l; for( l = nt; l; l = list_next( l ) ) - t->settings = addsettings( t->settings, append, + t->settings = addsettings( t->settings, setflag, l->string, list_copy( (LIST*)0, ns ) ); } diff --git a/historic/jam/src/make1.c b/historic/jam/src/make1.c index 2636ad116..e62b72293 100644 --- a/historic/jam/src/make1.c +++ b/historic/jam/src/make1.c @@ -1064,7 +1064,7 @@ make1settings( LIST *vars ) /* Add to settings chain */ - settings = addsettings( settings, 0, vars->string, nl ); + settings = addsettings( settings, VAR_SET, vars->string, nl ); } return settings; diff --git a/historic/jam/src/rules.c b/historic/jam/src/rules.c index 0c044aba5..40d54b53f 100644 --- a/historic/jam/src/rules.c +++ b/historic/jam/src/rules.c @@ -382,15 +382,16 @@ static SETTINGS* settings_freelist; * addsettings() - add a deferred "set" command to a target * * Adds a variable setting (varname=list) onto a chain of settings - * for a particular target. Replaces the previous previous value, - * if any, unless 'append' says to append the new list onto the old. + * for a particular target. + * 'flag' controls the relationship between new and old values in the same + * way as in var_set() function (see variable.c). * Returns the head of the chain of settings. */ SETTINGS * addsettings( SETTINGS *head, - int append, + int flag, char *symbol, LIST *value ) { @@ -422,15 +423,17 @@ addsettings( v->next = head; head = v; } - else if( append ) + else if( flag == VAR_APPEND ) { v->value = list_append( v->value, value ); } - else + else if( flag != VAR_DEFAULT ) { list_free( v->value ); v->value = value; } + else + list_free( value ); /* Return (new) head of list. */ @@ -467,7 +470,7 @@ copysettings( SETTINGS *head ) SETTINGS *copy = 0, *v; for (v = head; v; v = v->next) - copy = addsettings(copy, 0, v->symbol, list_copy(0, v->value)); + copy = addsettings(copy, VAR_SET, v->symbol, list_copy(0, v->value)); return copy; } diff --git a/historic/jam/src/rules.h b/historic/jam/src/rules.h index 91a9c4aaf..563808252 100644 --- a/historic/jam/src/rules.h +++ b/historic/jam/src/rules.h @@ -246,7 +246,7 @@ TARGETS *targetchain( TARGETS *chain, TARGETS *targets ); void freetargets( TARGETS *chain ); ACTIONS *actionlist( ACTIONS *chain, ACTION *action ); void freeactions( ACTIONS *chain ); -SETTINGS *addsettings( SETTINGS *head, int append, char *symbol, LIST *value ); +SETTINGS *addsettings( SETTINGS *head, int flag, char *symbol, LIST *value ); void pushsettings( SETTINGS *v ); void popsettings( SETTINGS *v ); SETTINGS *copysettings( SETTINGS *v ); diff --git a/historic/jam/test/stress_var_expand.jam b/historic/jam/test/stress_var_expand.jam new file mode 100644 index 000000000..30064e02a --- /dev/null +++ b/historic/jam/test/stress_var_expand.jam @@ -0,0 +1,47 @@ +#~ Copyright 2006 Rene Rivera. +#~ Distributed under the Boost Software License, Version 1.0. +#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + +ECHO --- Testing var expansion builtin... ; + +local result = 0 ; +local rule error ( message * ) +{ + local b = [ BACKTRACE ] ; + ECHO "$(b[9]):$(b[10]): error:" $(message) ; +} +local rule assert ( expected * : test ? : obtained * ) +{ + test ?= "(==)" ; + local r = 0 ; + if $(test) = "(==)" && $(expected) != $(obtained) + { + error [FAILED] '$(expected)' $(test) '$(obtained)' ; + r = 1 ; + } + else if $(test) = "(!=)" && $(expected) = $(obtained) + { + error [FAILED] '$(expected)' $(test) '$(obtained)' ; + r = 1 ; + } + else + { + error [PASSED] '$(expected)' $(test) '$(obtained)' ; + } + result = [ CALC $(result) + $(r) ] ; +} + +#~ --------------------------------------------------------------------- + +local i = 0 ; +local v = one two ; +while $(i) != 4 +{ + i = [ CALC $(i) + 1 ] ; + v = $(v)$(v) ; + assert $(i) : (==) : $(i) ; +} + +#~ --------------------------------------------------------------------- + +EXIT --- Complete : $(result) ; diff --git a/historic/jam/test/target_var.jam b/historic/jam/test/target_var.jam new file mode 100644 index 000000000..0d4a4922c --- /dev/null +++ b/historic/jam/test/target_var.jam @@ -0,0 +1,49 @@ +#~ Copyright 2006 Rene Rivera. +#~ Distributed under the Boost Software License, Version 1.0. +#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + +ECHO --- Testing var expansion builtin... ; + +local result = 0 ; +local rule error ( message * ) +{ + local b = [ BACKTRACE ] ; + ECHO "$(b[9]):$(b[10]): error:" $(message) ; +} +local rule assert ( expected * : test ? : obtained * ) +{ + test ?= "(==)" ; + local r = 0 ; + if $(test) = "(==)" && $(expected) != $(obtained) + { + error [FAILED] '$(expected)' $(test) '$(obtained)' ; + r = 1 ; + } + else if $(test) = "(!=)" && $(expected) = $(obtained) + { + error [FAILED] '$(expected)' $(test) '$(obtained)' ; + r = 1 ; + } + #~ else + #~ { + #~ error [PASSED] '$(expected)' $(test) '$(obtained)' ; + #~ } + result = [ CALC $(result) + $(r) ] ; +} + +#~ --------------------------------------------------------------------- + +v on a = 1 ; +v on b = 1 2 ; +v on c = 1 2 3 ; +v on d ?= 1 2 3 4 ; +v on d ?= 5 6 7 8 ; +v on a ?= 2 ; +assert [ on a return $(v) ] : (==) : 1 ; +assert [ on b return $(v) ] : (==) : 1 2 ; +assert [ on c return $(v) ] : (==) : 1 2 3 ; +assert [ on d return $(v) ] : (==) : 1 2 3 4 ; + +#~ --------------------------------------------------------------------- + +EXIT --- Complete : $(result) ; diff --git a/historic/jam/test/test.bat b/historic/jam/test/test.bat index d30203037..0566f2c81 100644 --- a/historic/jam/test/test.bat +++ b/historic/jam/test/test.bat @@ -5,8 +5,11 @@ 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) set BJAM=..\src\bin.ntx86\bjam +REM ~ set BJAM=..\src\bin.ntx86.debug\bjam @ECHO ON %BJAM% -f builtin_shell.jam %BJAM% -f builtin_w32_getregnames.jam +%BJAM% -f stress_var_expand.jam +%BJAM% -f target_var.jam From f7969af4529ad14e1abc178d1d9954b595a11d2c Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 20 Sep 2006 21:39:43 +0000 Subject: [PATCH 49/82] Minor improvement in memory and complexity of sequence length calculation. [SVN r35233] --- v2/util/sequence.jam | 37 +++++-------------------------------- 1 file changed, 5 insertions(+), 32 deletions(-) diff --git a/v2/util/sequence.jam b/v2/util/sequence.jam index 187e192a6..3e2ca72b5 100644 --- a/v2/util/sequence.jam +++ b/v2/util/sequence.jam @@ -138,42 +138,15 @@ rule join ( s * : joint ? ) return $(s:J=$(joint)) ; } -# Find the length of any sequence in log(N) time. +# Find the length of any sequence. rule length ( s * ) { - local length = "" ; - local zeros p10 d z ; # declared once for speed - - # Find the power of 10 that is just less than length(s) - zeros = "" ; - p10 = 1 ; - while $(s[$(p10)0]) + local result = 0 ; + for local i in $(s) { - p10 = $(p10)0 ; - zeros = $(zeros[1])0 $(zeros) ; + result = [ CALC $(result) + 1 ] ; } - - # zeros is a list of the form ... 000 00 0 "" - for z in $(zeros) # for each digit in the result - { - # Find the next digit - d = 0 1 2 3 4 5 6 7 8 9 ; - while $(s[$(d[2])$(z)]) - { - d = $(d[2-]) ; - } - - # append it to the result - length = $(length)$(d[1]) ; - - # Explanation: $(d[1])$(z) the largest number x of the form - # n000..., where n is a digit, such that x <= length(s). Here - # we're deleting x elements from the list. Since $(s[n]-) - # removes n - 1 elements from the list, we chop an additional - # one off the end. - s = $(s[$(d[1])$(z)--2]) ; - } - return $(length) ; + return $(result) ; } rule unique ( list * ) From 4b197ae0e9831a0daeae930373d95e8e0b2d4787 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 21 Sep 2006 02:40:19 +0000 Subject: [PATCH 50/82] Fix inspection issues [SVN r35239] --- v2/tools/docutils.jam | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/v2/tools/docutils.jam b/v2/tools/docutils.jam index 747c02619..30aaf7f0c 100755 --- a/v2/tools/docutils.jam +++ b/v2/tools/docutils.jam @@ -33,7 +33,7 @@ type.set-scanner ReST : rst-scanner ; generators.register-standard docutils.html : ReST : HTML ; -rule init ( docutils-dir ) +rule init ( docutils-dir ? ) { docutils-dir ?= [ modules.peek : DOCUTILS_DIR ] ; @@ -50,7 +50,8 @@ rule init ( docutils-dir ) rule html ( target : source : properties * ) { - docutils-dir on $(target) = $(.docutils-dir) ; + local command-prefix = "python "$(.docutils-dir)/tools/ ; + command-prefix on $(target) = $(command-prefix:E="") ; } @@ -62,6 +63,6 @@ toolset.flags docutils HTML-FLAGS : ; actions html { $(.setup) - python $(docutils-dir)/tools/rst2html.py $(COMMON-FLAGS) $(HTML-FLAGS) $(>) $(<) + $(command-prefix)rst2html.py $(COMMON-FLAGS) $(HTML-FLAGS) $(>) $(<) } From fc137a52e34fbc759c747877fcd7ed9080e9c114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Thu, 21 Sep 2006 20:05:26 +0000 Subject: [PATCH 51/82] Add missing QtDesigner library. Improve control of Qt3Support library. [SVN r35266] --- v2/tools/qt4.jam | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/v2/tools/qt4.jam b/v2/tools/qt4.jam index 1c0410420..f96459c54 100644 --- a/v2/tools/qt4.jam +++ b/v2/tools/qt4.jam @@ -47,6 +47,24 @@ import toolset : flags ; import os ; import virtual-target ; +# Qt3Support control feature +# +# Qt4 configure defaults to build Qt4 libraries with Qt3Support. +# The autodetection is missing, so we default to disable Qt3Support. +# This prevents the user from inadvertedly using a deprecated API. +# +# The Qt3Support library can be activated by adding +# "on" to requirements +# +# Use "on:QT3_SUPPORT_WARNINGS" +# to get warnings about deprecated Qt3 support funtions and classes. +# Files ported by the "qt3to4" conversion tool contain _tons_ of +# warnings, so this define is not set as default. +# +# Todo: Detect Qt3Support from Qt's configure data. +# Or add more auto-configuration (like python). +feature.feature qt3support : off on : propagated link-incompatible ; + project.initialize $(__name__) ; project qt ; @@ -96,7 +114,7 @@ rule init ( prefix ) if [ glob $(.prefix)/Jamroot ] { # Import all Qt Modules - local all-libraries = QtCore QtGui QtNetwork QtXml QtSql QtSvg QtOpenGL Qt3Support QtTest QtAssistantClient QtUiTools ; + local all-libraries = QtCore QtGui QtNetwork QtXml QtSql QtSvg QtOpenGL Qt3Support QtTest QtAssistantClient QtDesigner QtUiTools ; for local l in $(all-libraries) { alias $(l) @@ -219,21 +237,26 @@ rule init ( prefix ) ; lib Qt3Support : QtGui QtNetwork QtXml QtSql - : Qt3Support$(suffix_version) release + : Qt3Support$(suffix_version) release on : : # usage-requirements QT_QT3SUPPORT_LIB QT3_SUPPORT $(.prefix)/include/Qt3Support ; + lib Qt3Support : QtGui QtNetwork QtXml QtSql - : Qt3Support$(suffix_debug)$(suffix_version) debug + : Qt3Support$(suffix_debug)$(suffix_version) debug on : : # usage-requirements QT_QT3SUPPORT_LIB QT3_SUPPORT $(.prefix)/include/Qt3Support ; + + # Dummy target to enable "off" and "/qt//Qt3Support" at the same time. + # This enables quick switching from one to the other for test/porting purposes. + alias Qt3Support : : off ; # OpenGl Support lib QtOpenGL : QtGui @@ -295,6 +318,21 @@ rule init ( prefix ) $(.prefix)/include/QtAssistant ; + # Qt designer library + lib QtDesigner : QtGui QtXml + : QtDesigner$(suffix_version) release + : + : # usage-requirements + $(.prefix)/include/QtDesigner + ; + + lib QtDesigner : QtGui QtXml + : QtDesigner$(suffix_debug)$(suffix_version) debug + : + : # usage-requirements + $(.prefix)/include/QtDesigner + ; + # Support for dynamic Widgets (Qt 4.1) lib QtUiTools : QtGui QtXml : QtUiTools$(suffix_version) release From e7f80224334a9c720d1e5562111834e2b62cae8e Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Fri, 22 Sep 2006 16:07:59 +0000 Subject: [PATCH 52/82] Cleanup. [SVN r35279] --- historic/jam/test/builtin_shell.jam | 29 ----------- historic/jam/test/builtin_w32_getregnames.jam | 29 ----------- historic/jam/test/stress_var_expand.jam | 35 +------------ historic/jam/test/target_var.jam | 35 +------------ historic/jam/test/test.bat | 5 +- historic/jam/test/test.jam | 49 +++++++++++++++++++ 6 files changed, 52 insertions(+), 130 deletions(-) create mode 100644 historic/jam/test/test.jam diff --git a/historic/jam/test/builtin_shell.jam b/historic/jam/test/builtin_shell.jam index 91761a042..3094cc5a1 100644 --- a/historic/jam/test/builtin_shell.jam +++ b/historic/jam/test/builtin_shell.jam @@ -4,31 +4,6 @@ ECHO --- Testing SHELL builtin... ; -local result = 0 ; -local rule error ( message * ) -{ - local b = [ BACKTRACE ] ; - ECHO "$(b[9]):$(b[10]): error:" $(message) ; -} -local rule assert ( expected + : test ? : obtained + ) -{ - test ?= "(==)" ; - local r = 0 ; - if $(test) = "(==)" && $(expected) != $(obtained) - { - error [FAILED] '$(expected)' $(test) '$(obtained)' ; - r = 1 ; - } - else if $(test) = "(!=)" && $(expected) = $(obtained) - { - error [FAILED] '$(expected)' $(test) '$(obtained)' ; - r = 1 ; - } - result = [ CALC $(result) + $(r) ] ; -} - -#~ --------------------------------------------------------------------- - local c = "date" ; if $(NT) { c = "PATH" ; } @@ -40,7 +15,3 @@ assert "" : (!=) : [ COMMAND $(c) ] ; assert "" : (==) : [ COMMAND $(c) : no-output ] ; assert "" 0 : (!=) : [ COMMAND $(c) : exit-status ] ; assert "" 0 : (==) : [ COMMAND $(c) : no-output : exit-status ] ; - -#~ --------------------------------------------------------------------- - -EXIT --- Complete : $(result) ; diff --git a/historic/jam/test/builtin_w32_getregnames.jam b/historic/jam/test/builtin_w32_getregnames.jam index fdcdde8cb..1082f4ad7 100644 --- a/historic/jam/test/builtin_w32_getregnames.jam +++ b/historic/jam/test/builtin_w32_getregnames.jam @@ -4,31 +4,6 @@ ECHO --- Testing W32_GETREGNAMES builtin... ; -local result = 0 ; -local rule error ( message * ) -{ - local b = [ BACKTRACE ] ; - ECHO "$(b[9]):$(b[10]): error:" $(message) ; -} -local rule assert ( expected * : test ? : obtained * ) -{ - test ?= "(==)" ; - local r = 0 ; - if $(test) = "(==)" && $(expected) != $(obtained) - { - error [FAILED] '$(expected)' $(test) '$(obtained)' ; - r = 1 ; - } - else if $(test) = "(!=)" && $(expected) = $(obtained) - { - error [FAILED] '$(expected)' $(test) '$(obtained)' ; - r = 1 ; - } - result = [ CALC $(result) + $(r) ] ; -} - -#~ --------------------------------------------------------------------- - if $(NT) { assert "Beep" "ExtendedSounds" @@ -40,7 +15,3 @@ if $(NT) assert "Control" "Enum" "Hardware Profiles" "Services" : (==) : [ W32_GETREGNAMES "HKLM\\SYSTEM\\CurrentControlSet" : subkeys ] ; } - -#~ --------------------------------------------------------------------- - -EXIT --- Complete : $(result) ; diff --git a/historic/jam/test/stress_var_expand.jam b/historic/jam/test/stress_var_expand.jam index 30064e02a..e76b36ab3 100644 --- a/historic/jam/test/stress_var_expand.jam +++ b/historic/jam/test/stress_var_expand.jam @@ -2,36 +2,7 @@ #~ Distributed under the Boost Software License, Version 1.0. #~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) -ECHO --- Testing var expansion builtin... ; - -local result = 0 ; -local rule error ( message * ) -{ - local b = [ BACKTRACE ] ; - ECHO "$(b[9]):$(b[10]): error:" $(message) ; -} -local rule assert ( expected * : test ? : obtained * ) -{ - test ?= "(==)" ; - local r = 0 ; - if $(test) = "(==)" && $(expected) != $(obtained) - { - error [FAILED] '$(expected)' $(test) '$(obtained)' ; - r = 1 ; - } - else if $(test) = "(!=)" && $(expected) = $(obtained) - { - error [FAILED] '$(expected)' $(test) '$(obtained)' ; - r = 1 ; - } - else - { - error [PASSED] '$(expected)' $(test) '$(obtained)' ; - } - result = [ CALC $(result) + $(r) ] ; -} - -#~ --------------------------------------------------------------------- +ECHO --- Testing var expansion... ; local i = 0 ; local v = one two ; @@ -41,7 +12,3 @@ while $(i) != 4 v = $(v)$(v) ; assert $(i) : (==) : $(i) ; } - -#~ --------------------------------------------------------------------- - -EXIT --- Complete : $(result) ; diff --git a/historic/jam/test/target_var.jam b/historic/jam/test/target_var.jam index 0d4a4922c..d4fdae631 100644 --- a/historic/jam/test/target_var.jam +++ b/historic/jam/test/target_var.jam @@ -2,36 +2,7 @@ #~ Distributed under the Boost Software License, Version 1.0. #~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) -ECHO --- Testing var expansion builtin... ; - -local result = 0 ; -local rule error ( message * ) -{ - local b = [ BACKTRACE ] ; - ECHO "$(b[9]):$(b[10]): error:" $(message) ; -} -local rule assert ( expected * : test ? : obtained * ) -{ - test ?= "(==)" ; - local r = 0 ; - if $(test) = "(==)" && $(expected) != $(obtained) - { - error [FAILED] '$(expected)' $(test) '$(obtained)' ; - r = 1 ; - } - else if $(test) = "(!=)" && $(expected) = $(obtained) - { - error [FAILED] '$(expected)' $(test) '$(obtained)' ; - r = 1 ; - } - #~ else - #~ { - #~ error [PASSED] '$(expected)' $(test) '$(obtained)' ; - #~ } - result = [ CALC $(result) + $(r) ] ; -} - -#~ --------------------------------------------------------------------- +ECHO --- Testing var on target semantics... ; v on a = 1 ; v on b = 1 2 ; @@ -43,7 +14,3 @@ assert [ on a return $(v) ] : (==) : 1 ; assert [ on b return $(v) ] : (==) : 1 2 ; assert [ on c return $(v) ] : (==) : 1 2 3 ; assert [ on d return $(v) ] : (==) : 1 2 3 4 ; - -#~ --------------------------------------------------------------------- - -EXIT --- Complete : $(result) ; diff --git a/historic/jam/test/test.bat b/historic/jam/test/test.bat index 0566f2c81..30c6474cd 100644 --- a/historic/jam/test/test.bat +++ b/historic/jam/test/test.bat @@ -9,7 +9,4 @@ REM ~ set BJAM=..\src\bin.ntx86.debug\bjam @ECHO ON -%BJAM% -f builtin_shell.jam -%BJAM% -f builtin_w32_getregnames.jam -%BJAM% -f stress_var_expand.jam -%BJAM% -f target_var.jam +%BJAM% -f test.jam diff --git a/historic/jam/test/test.jam b/historic/jam/test/test.jam new file mode 100644 index 000000000..b6d36b174 --- /dev/null +++ b/historic/jam/test/test.jam @@ -0,0 +1,49 @@ +#~ Copyright 2006 Rene Rivera. +#~ Distributed under the Boost Software License, Version 1.0. +#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + +fail-count = 0 ; +pass-count = 0 ; + +rule message ( message * ) +{ + local b = [ BACKTRACE ] ; + ECHO "$(b[-4]):$(b[-3]):" $(message) ; +} +rule fail ( message * ) +{ + fail-count = [ CALC $(fail-count) + 1 ] ; + message "error:" [FAILED] $(message) ; +} +rule pass ( message * ) +{ + pass-count = [ CALC $(pass-count) + 1 ] ; + if --verbose in $(ARGV) + { + message "info:" [PASSED] $(message) ; + } +} +rule assert ( expected * : test ? : obtained * ) +{ + test ?= "(==)" ; + local r = 0 ; + if $(test) = "(==)" && $(expected) != $(obtained) + { + fail '$(expected)' $(test) '$(obtained)' ; + } + else if $(test) = "(!=)" && $(expected) = $(obtained) + { + fail '$(expected)' $(test) '$(obtained)' ; + } + else + { + pass '$(expected)' $(test) '$(obtained)' ; + } +} + +include builtin_shell.jam ; +include builtin_w32_getregnames.jam ; +include stress_var_expand.jam ; +include target_var.jam ; + +EXIT --- Complete: PASSED($(pass-count)) *FAILED($(fail-count))* : $(fail-count) ; From 0c4edbe5fcb9b5104cedc8fe01dfccb5d8c396d7 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sun, 24 Sep 2006 09:38:46 +0000 Subject: [PATCH 53/82] Robustify PCH generator. * pch.jam (pch-generator.run): Don't insist on specific order of source targets. [SVN r35302] --- v2/tools/pch.jam | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/v2/tools/pch.jam b/v2/tools/pch.jam index 60ee10f66..28ef70b2f 100644 --- a/v2/tools/pch.jam +++ b/v2/tools/pch.jam @@ -50,18 +50,26 @@ class pch-generator : generator rule run ( project name ? : property-set : sources * ) { + local cpp = $(sources[2]) ; + local h = $(sources[1]) ; + if [ $(sources[2]).type ] = PCHEADER + { + cpp = $(sources[1]) ; + h = $(sources[2]) ; + } + local r = [ generator.run $(project) $(name) : [ property-set.create - $(sources[2]) # mypch.cpp + $(cpp) # mypch.cpp [ $(property-set).raw ] ] : $(sources) ] ; return [ property-set.create - $(sources[1]) # mypch.h[pp] + $(h) # mypch.h[pp] $(r[2]) # mypch.pch ] $(r) ; } From cd345eb3a8b1928890c8ffd1c8e5ceb14b44ca21 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sun, 24 Sep 2006 09:40:40 +0000 Subject: [PATCH 54/82] Add comment [SVN r35303] --- v2/tools/pch.jam | 3 +++ 1 file changed, 3 insertions(+) diff --git a/v2/tools/pch.jam b/v2/tools/pch.jam index 28ef70b2f..370ba67a4 100644 --- a/v2/tools/pch.jam +++ b/v2/tools/pch.jam @@ -50,6 +50,9 @@ class pch-generator : generator rule run ( project name ? : property-set : sources * ) { + # The two sources are cpp file and PCHEADER, but they + # can be passed in any order. Figure out which source + # is what. local cpp = $(sources[2]) ; local h = $(sources[1]) ; if [ $(sources[2]).type ] = PCHEADER From a88ed548936cc4883848bad3f7c5ea499ad822e8 Mon Sep 17 00:00:00 2001 From: Roland Schwarz Date: Sun, 24 Sep 2006 11:38:46 +0000 Subject: [PATCH 55/82] Fixed a bug that prevented using path-global from external projects, when specified as a relative path, e.g. path-global BOOST_ROOT : ../../boost The fix should not interfere with the build of the boost library at all. If there are problems though, simply remove everything between ... again, and drop me a note. [SVN r35305] --- v1/allyourbase.jam | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/v1/allyourbase.jam b/v1/allyourbase.jam index a7e0938d9..4b4e28f5b 100644 --- a/v1/allyourbase.jam +++ b/v1/allyourbase.jam @@ -1280,6 +1280,20 @@ rule project ( name : location ? ) else { gPROJECT($(name)) = [ root-paths $(location) : [ root-paths $($(gTOP)) : [ PWD ] ] ] ; + # + # Root the path globals to fix a bug which prevented to use them from an external + # project. The fix is as as uninvasive as possible, as it will only trigger when + # an external project is declared. So it will not interfere with the build of the + # boost library. I took this route, as at the time of this fix, the bbv1 is expected + # to be retired soon. + # N.B.: The path-globals rule is expected to be invoked from Jamrules files only. + local val ; + for val in $(gPATH_GLOBALS) { + gPATH_GLOBAL_VALUE($(val)) = [ root-paths $(gPATH_GLOBAL_VALUE($(val))) : + [ root-paths $($(gTOP)) : [ PWD ] ] + ] ; + } + # local [ protect-subproject ] ; enter-subproject @$(name) ; } From 8fa3e7630493b6832248a2eeeabac4aeffcd7352 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 24 Sep 2006 12:36:22 +0000 Subject: [PATCH 56/82] Fix linking of libboost_python on Mac OS X [SVN r35307] --- v2/tools/python.jam | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 5c5b14546..aa819e9a3 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -363,19 +363,20 @@ rule init-mac ( version : root ? : includes ? : libraries ? ) } PYTHON_FRAMEWORK = $(PYTHON_FRAMEWORK:D)/Python ; - alias python_for_extensions - : - : - : - : $(includes) - ; - alias python : : MACOSX darwin : : $(includes) $(PYTHON_FRAMEWORK) ; + + # Unlike most *nix systems, Mac OS X's linker does not permit undefined + # symbols when linking a shared library. So, we still need to link + # against the Python framework, even when building extensions. + # Note that framework builds of Python always use shared libraries, + # so we do not need to worry about duplicate Python symbols. + .alias-defined = true ; + alias python_for_extensions : python ; } rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? ) From 79047105e6cf67a6ecf570f2c55902b0535099a4 Mon Sep 17 00:00:00 2001 From: "K. Noel Belcourt" Date: Mon, 25 Sep 2006 21:48:04 +0000 Subject: [PATCH 57/82] Add this option to vacpp when building bjam (-bmaxdata:0x40000000). This option increases the amount of heap / stack space available to bjam when it runs. By default on IBM SP2 clusters, the available stack is limited to 256 Mb which is insufficient for building larger applications. -bmaxdata= Sets the maximum size of the area shared by the static data (both initialized and uninitialized) and the heap to bytes. The default is -bmaxdata=0. [SVN r35323] --- historic/jam/src/build.jam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/historic/jam/src/build.jam b/historic/jam/src/build.jam index 6228a8ceb..49af13c5a 100644 --- a/historic/jam/src/build.jam +++ b/historic/jam/src/build.jam @@ -277,7 +277,7 @@ toolset vacpp xlc : "-o " : -D [ opt --release : -s -O3 -qstrict -qinline ] [ opt --debug : -g -qNOOPTimize -qnoinline -pg ] -I$(--python-include) -I$(--extra-include) - : -L$(--python-lib[1]) -l$(--python-lib[2]) ; + : -L$(--python-lib[1]) -l$(--python-lib[2]) -bmaxdata:0x40000000 ; ## Microsoft Visual C++ .NET 7.x toolset vc7 cl : /Fe : -D : /nologo From 08bebc57f838fb5650d7217c5fb27fcacd11640c Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 27 Sep 2006 14:52:19 +0000 Subject: [PATCH 58/82] Minor edits. Add var expansion test that veryfies that "$(x:D)" is broken. [SVN r35351] --- historic/jam/test/test.jam | 5 +++-- historic/jam/test/test.sh | 2 +- historic/jam/test/var_expand.jam | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 historic/jam/test/var_expand.jam diff --git a/historic/jam/test/test.jam b/historic/jam/test/test.jam index b6d36b174..066862ce4 100644 --- a/historic/jam/test/test.jam +++ b/historic/jam/test/test.jam @@ -27,11 +27,11 @@ rule assert ( expected * : test ? : obtained * ) { test ?= "(==)" ; local r = 0 ; - if $(test) = "(==)" && $(expected) != $(obtained) + if $(test) = "(==)" && "*$(expected)*" != "*$(obtained)*" { fail '$(expected)' $(test) '$(obtained)' ; } - else if $(test) = "(!=)" && $(expected) = $(obtained) + else if $(test) = "(!=)" && "*$(expected)*" = "*$(obtained)*" { fail '$(expected)' $(test) '$(obtained)' ; } @@ -45,5 +45,6 @@ include builtin_shell.jam ; include builtin_w32_getregnames.jam ; include stress_var_expand.jam ; include target_var.jam ; +include var_expand.jam ; EXIT --- Complete: PASSED($(pass-count)) *FAILED($(fail-count))* : $(fail-count) ; diff --git a/historic/jam/test/test.sh b/historic/jam/test/test.sh index d9087100a..68872a389 100644 --- a/historic/jam/test/test.sh +++ b/historic/jam/test/test.sh @@ -6,4 +6,4 @@ BJAM=`ls -1 ../src/bin.*/bjam` -${BJAM} -f builtin_shell.jam +${BJAM} -f test.jam diff --git a/historic/jam/test/var_expand.jam b/historic/jam/test/var_expand.jam new file mode 100644 index 000000000..cacacf33d --- /dev/null +++ b/historic/jam/test/var_expand.jam @@ -0,0 +1,16 @@ +#~ Copyright 2006 Rene Rivera. +#~ Distributed under the Boost Software License, Version 1.0. +#~ (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + +ECHO --- Testing var expansion... ; + +local p0 = name ; +local p1 = dir/name ; +local p2 = dir/sub/name ; + +assert $(p0:D=) : (==) : name ; +assert $(p1:D=) : (==) : name ; +assert $(p2:D=) : (==) : name ; +assert $(p0:D) : (==) : ; +assert $(p1:D) : (==) : dir ; +assert $(p2:D) : (==) : dir/sub ; From d7180b312414fe2f1115631b99fc150f4f1b3146 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 27 Sep 2006 15:01:52 +0000 Subject: [PATCH 59/82] Swap test values to correct expected-obtained order. [SVN r35352] --- historic/jam/test/var_expand.jam | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/historic/jam/test/var_expand.jam b/historic/jam/test/var_expand.jam index cacacf33d..4dbdacdfa 100644 --- a/historic/jam/test/var_expand.jam +++ b/historic/jam/test/var_expand.jam @@ -8,9 +8,9 @@ local p0 = name ; local p1 = dir/name ; local p2 = dir/sub/name ; -assert $(p0:D=) : (==) : name ; -assert $(p1:D=) : (==) : name ; -assert $(p2:D=) : (==) : name ; -assert $(p0:D) : (==) : ; -assert $(p1:D) : (==) : dir ; -assert $(p2:D) : (==) : dir/sub ; +assert name : (==) : $(p0:D=) ; +assert name : (==) : $(p1:D=) ; +assert name : (==) : $(p2:D=) ; +assert : (==) : $(p0:D) ; +assert dir : (==) : $(p1:D) ; +assert dir/sub : (==) : $(p2:D) ; From c65b20e190c934a9c28fd053bc54ca036807487d Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Wed, 27 Sep 2006 15:39:42 +0000 Subject: [PATCH 60/82] Seems any $(x:X) expansion will expand to empty string as opposed to empty list. [SVN r35353] --- historic/jam/test/var_expand.jam | 1 + 1 file changed, 1 insertion(+) diff --git a/historic/jam/test/var_expand.jam b/historic/jam/test/var_expand.jam index 4dbdacdfa..6133cf1d2 100644 --- a/historic/jam/test/var_expand.jam +++ b/historic/jam/test/var_expand.jam @@ -14,3 +14,4 @@ assert name : (==) : $(p2:D=) ; assert : (==) : $(p0:D) ; assert dir : (==) : $(p1:D) ; assert dir/sub : (==) : $(p2:D) ; +assert : (==) : $(p0:S) ; From b6a0e636f808c42c9004a158124bb49961b6d234 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 28 Sep 2006 17:13:35 +0000 Subject: [PATCH 61/82] Attempt to get tests linking on OSF again by adding missing -lz. Strip out loads of detritus. [SVN r35390] --- v2/tools/python.jam | 141 ++++++++------------------------------------ 1 file changed, 26 insertions(+), 115 deletions(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index aa819e9a3..a5eb79a8d 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -21,9 +21,6 @@ # SHARED_LIB, not PYTHON_EXTENSION. That's because we reuse # 'lib-target-class', which creates SHARED_LIB explicitly. - - - import type ; import testing ; import generators ; @@ -235,7 +232,7 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) } - local extra-libs ; + local extra-libs extra-libs-conditional ; # Depending on system, Python library is either static # or shared. When it's static, we need to add 'pthread' @@ -247,32 +244,32 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) # affected by threading mode. switch [ os.name ] { - case SOLARIS : extra-libs = pthread dl ; - case OSF : extra-libs = pthread ; - case QNX* : extra-libs = ; + case SOLARIS : + { + extra-libs = pthread dl ; + + # Add 'rt' option on Sun. While we duplicate the + # logic already in sun.jam and gcc.jam, I see no easy + # way to refactor it -- Volodya. + # Note that for 'sun' toolset, rt is already unconditionally + # added. + extra-libs-conditional = gcc:rt ; + } + + case OSF : + { + extra-libs = pthread z ; + extra-libs-conditional = gcc:rt ; + } + + case QNX* : + { + extra-libs = ; + } + case * : extra-libs = pthread dl util ; } - extra-libs-conditional = ; - # Add 'rt' option on Sun. While we duplicate the - # logic already in sun.jam and gcc.jam, I see no easy - # way to refactor it. - # Note that for 'sun' toolset, rt is already unconditionally - # added. - - # (MS) Question: Why not [ os.name ] in the next statement? - switch [ modules.peek : JAMUNAME ] - { - case SunOS* : - { - extra-libs-conditional += gcc:rt ; - } - case OSF* : - { - extra-libs-conditional += gcc:rt ; - } - } - if ! [ os.on-windows ] { # On *nix, we don't want to link either Boost.Python or Python @@ -298,29 +295,6 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) $(libraries) python$(version) ; - - - # NOTES: - # - V1 had logic to force intel to use gcc's runtime. - # Note sure why that was needed, with icc 8.0 extensions - # built with intel are loaded by python without problems. - # - There was 'python-static-multithread' logic. Don't know - # what it affected, so can't test. - - # TODO: need to figure out when the following code is needed: - # for builtin extensions only or in some other cases too. - - - # if [ modules.peek $(OS) ] = OSF - # { - # PYTHON_PROPERTIES += <*><*>"-expect_unresolved 'Py*' -expect_unresolved '_Py*'" ; - # } - # else if [ modules.peek $(OS) ] = AIX - # { - # PYTHON_PROPERTIES - # += <*><*>"-Wl,-bI:$(PYTHON_LIB_PATH)/python.exp" - # <*><*>pthreads ; - # } } rule init-mac ( version : root ? : includes ? : libraries ? ) @@ -381,14 +355,6 @@ rule init-mac ( version : root ? : includes ? : libraries ? ) rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? ) { -# PYTHON_PROPERTIES = -# boost-python-disable-borland -# select-nt-python-includes -# dynamic -# @boost -# <$(gcc-compilers)><*>USE_DL_IMPORT -# ; - if ! $(cygwin-condition) { root ?= c:/tools/python ; @@ -428,21 +394,6 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? flags python.capture-output PYTHON : $(interpreter) ; - # This is mingw-specific V1 code. I don't yet understand - # why mingw must be specially-cased. - #local lib = $(PYTHON_IMPORT_LIB) ; - #if BOOST_DEBUG_PYTHON in $(properties) - #{ - # lib = $(PYTHON_DEBUG_IMPORT_LIB) ; - #} - #lib ?= $(PYTHON_DLL) ; - #if BOOST_DEBUG_PYTHON in $(properties) - #{ - # lib ?= $(PYTHON_DEBUG_DLL) ; - #} - #properties += $(lib) ; - #} - properties += $(PYTHON_LIB_PATH) ; # msvc compilers auto-find the python library @@ -457,11 +408,6 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? ; local lib = python$(PYTHON_VERSION_NODOT) ; - # TODO: don't support BOOST_DEBUG_PYTHON yet. - # if BOOST_DEBUG_PYTHON in $(properties) - # { - # lib = python$(PYTHON_VERSION_NODOT)_d ; - # } alias python : @@ -490,19 +436,12 @@ rule init-nt ( version : root ? : includes ? : libraries ? : cygwin-condition ? CYGWIN_PYTHON_DEBUG_LIB_PATH ?= $(CYGWIN_PYTHON_DEBUG_ROOT)/lib/python$(CYGWIN_PYTHON_DEBUG_VERSION)/config ; local properties ; - # TODO: don't support BOOST_DEBUG_PYTHON yet. - #if BOOST_DEBUG_PYTHON in $(properties) - #{ - # properties += $(CYGWIN_PYTHON_DEBUG_LIB_PATH) python$(CYGWIN_PYTHON_DEBUG_VERSION).dll ; - #} - #else - #{ + properties += $(CYGWIN_PYTHON_LIB_PATH) python$(CYGWIN_PYTHON_VERSION).dll ; properties += $(root)/include/python$(version) ; - #} alias python : : $(cygwin-condition) @@ -535,35 +474,7 @@ rule python-extension ( name : sources * : requirements * : default-build * : usage-requirements * ) { requirements += /python//python_for_extensions ; - - # TODO: handle the following V1 code - #if $(OS) = MACOSX && $(toolset) = darwin - #{ - # if PYD in $(properties) - # { - # properties += bundle ; - # } - # properties += $(PYTHON_FRAMEWORK) ; - #} - -# <*>"-inline deferred" -# <*>"-inline deferred" # added for internal testing purposes -# <*>@boost/boost/compatibility/cpp_c_headers -# BOOST_PYTHON_DYNAMIC_LIB - - -# PYTHON_PROPERTIES += -# @boost -# on -# select-python-library - -# boost-python-disable-borland -# select-nt-python-includes -# dynamic -# @boost -# <$(gcc-compilers)><*>USE_DL_IMPORT -# $(PYTHON_INCLUDES) - + local project = [ project.current ] ; From 05edca84da2080aeaa56c33ee5511cc241401d9d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 28 Sep 2006 17:15:52 +0000 Subject: [PATCH 62/82] Correctly report python library path [SVN r35391] --- v2/tools/python.jam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index a5eb79a8d..836a6edf6 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -212,7 +212,7 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) debug-message "Python include path is" $(includes) ; libraries ?= $(root)/lib/python$(version)/config ; - debug-message "Python library path is" $(includes) ; + debug-message "Python library path is" $(libraries) ; # # End autoconfiguration sequence From de04c65ce9aa4bd4259120739149d4f53dccdd2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Thu, 28 Sep 2006 19:00:12 +0000 Subject: [PATCH 63/82] Added missing/changed to Boost Software license. Changed tests to use qt3 toolset. [SVN r35399] --- v2/test/railsys/libx/project-root.jam | 13 ++++++++++--- v2/test/railsys/libx/src/Jamfile | 9 +++++---- v2/test/railsys/program/Jamfile | 13 ++++++------- v2/test/railsys/program/liba/Jamfile | 10 +++++----- v2/test/railsys/program/main/Jamfile | 10 +++++----- v2/test/railsys/program/project-root.jam | 13 ++++++++++--- 6 files changed, 41 insertions(+), 27 deletions(-) diff --git a/v2/test/railsys/libx/project-root.jam b/v2/test/railsys/libx/project-root.jam index 0dc0d99eb..d09982dd1 100644 --- a/v2/test/railsys/libx/project-root.jam +++ b/v2/test/railsys/libx/project-root.jam @@ -1,6 +1,13 @@ +# Copyright (c) 2002 Institute of Transport, +# Railway Construction and Operation, +# University of Hanover, Germany +# Copyright (c) 2006 Jrgen Hunold +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) -# Tell that QT should be used. QTDIR will give installation -# prefix. -using qt ; +# Tell that Qt3 should be used. QTDIR will give installation prefix. +using qt3 ; diff --git a/v2/test/railsys/libx/src/Jamfile b/v2/test/railsys/libx/src/Jamfile index 89a910a97..639e0cc90 100644 --- a/v2/test/railsys/libx/src/Jamfile +++ b/v2/test/railsys/libx/src/Jamfile @@ -2,10 +2,11 @@ # Railway Construction and Operation, # University of Hanover, Germany # -# Permission to copy, use, modify, sell and distribute this software is -# granted provided this copyright notice appears in all copies. This -# software is provided "as is" without express or implied warranty, and -# with no claim as to its suitability for any purpose. +# Copyright (c) 2006 Jrgen Hunold +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) project libx : requirements diff --git a/v2/test/railsys/program/Jamfile b/v2/test/railsys/program/Jamfile index 1b311e988..9e36f408f 100644 --- a/v2/test/railsys/program/Jamfile +++ b/v2/test/railsys/program/Jamfile @@ -6,11 +6,11 @@ # Copyright (c) 2002 Institute of Transport, # Railway Construction and Operation, # University of Hanover, Germany +# Copyright (c) 2006 Jrgen Hunold # -# Permission to copy, use, modify, sell and distribute this software is -# granted provided this copyright notice appears in all copies. This -# software is provided "as is" without express or implied warranty, and -# with no claim as to its suitability for any purpose. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) # # 02/21/02! Jrgen Hunold # @@ -26,7 +26,7 @@ project program : requirements $(BOOST_ROOT) multi - /qt//qt + /qt3//qt true stlport /libx @@ -37,10 +37,9 @@ project program : default-build release multi - /qt//qt + /qt3//qt true ; - build-project main ; diff --git a/v2/test/railsys/program/liba/Jamfile b/v2/test/railsys/program/liba/Jamfile index 3e79425e3..f74311d0d 100644 --- a/v2/test/railsys/program/liba/Jamfile +++ b/v2/test/railsys/program/liba/Jamfile @@ -1,14 +1,14 @@ # Copyright (c) 2003 Institute of Transport, # Railway Construction and Operation, # University of Hanover, Germany +# Copyright (c) 2006 Jrgen Hunold # -# Permission to copy, use, modify, sell and distribute this software is -# granted provided this copyright notice appears in all copies. This -# software is provided "as is" without express or implied warranty, and -# with no claim as to its suitability for any purpose. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) project liba ; lib liba : test ../include/test_a.h ; -obj test : test_a.cpp : off ; \ No newline at end of file +obj test : test_a.cpp : off ; diff --git a/v2/test/railsys/program/main/Jamfile b/v2/test/railsys/program/main/Jamfile index b780da08a..095978eaf 100644 --- a/v2/test/railsys/program/main/Jamfile +++ b/v2/test/railsys/program/main/Jamfile @@ -1,12 +1,12 @@ # Copyright (c) 2002 Institute of Transport, # Railway Construction and Operation, # University of Hanover, Germany +# Copyright (c) 2006 Jrgen Hunold # -# Permission to copy, use, modify, sell and distribute this software is -# granted provided this copyright notice appears in all copies. This -# software is provided "as is" without express or implied warranty, and -# with no claim as to its suitability for any purpose. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) project main ; -exe test_a : main.cpp ../liba//liba /libx ; \ No newline at end of file +exe test_a : main.cpp ../liba//liba /libx ; diff --git a/v2/test/railsys/program/project-root.jam b/v2/test/railsys/program/project-root.jam index 6c08ebfe7..23d42195f 100644 --- a/v2/test/railsys/program/project-root.jam +++ b/v2/test/railsys/program/project-root.jam @@ -1,7 +1,14 @@ +# Copyright (c) 2002 Institute of Transport, +# Railway Construction and Operation, +# University of Hanover, Germany +# Copyright (c) 2006 Jrgen Hunold +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) -# Tell that QT should be used. QTDIR will give installation -# prefix. -using qt ; +# Tell that Qt3 should be used. QTDIR will give installation prefix. +using qt3 ; # Not that good, but sufficient for testing using stlport : : /path/to/stlport ; From 320031246cc536977cda94dea6630b0ce44aeec0 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Thu, 28 Sep 2006 22:27:50 +0000 Subject: [PATCH 64/82] Stop generating illegal argumentless -F option in the link line. [SVN r35402] --- v2/tools/darwin.jam | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/v2/tools/darwin.jam b/v2/tools/darwin.jam index 74cc2f0d4..14dd0008e 100644 --- a/v2/tools/darwin.jam +++ b/v2/tools/darwin.jam @@ -60,15 +60,40 @@ flags darwin.link FRAMEWORK ; _ = " " ; +# set up the -F option to include the paths to any frameworks used. +local rule prepare-framework-path ( target + ) +{ + local framework-path = [ on $(target) return $(FRAMEWORK:D) ] ; + + if $(framework-path) + { + FRAMEWORK_PATH on $(target) += -F$(framework-path) ; + } + else + { + FRAMEWORK_PATH on $(target) = ; + } +} + +rule link +{ + prepare-framework-path $(<) ; +} + actions link bind LIBRARIES { - $(CONFIG_COMMAND) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) -F$(FRAMEWORK:D) -framework$(_)$(FRAMEWORK:D=) $(OPTIONS) $(USER_OPTIONS) + $(CONFIG_COMMAND) -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(FRAMEWORK_PATH) -framework$(_)$(FRAMEWORK:D=) $(OPTIONS) $(USER_OPTIONS) $(NEED_STRIP)strip $(NEED_STRIP)"$(<)" } +rule link.dll +{ + prepare-framework-path $(<) ; +} + actions link.dll bind LIBRARIES { - $(CONFIG_COMMAND) -dynamiclib -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) -F$(FRAMEWORK:D) -framework$(_)$(FRAMEWORK:D=) $(OPTIONS) $(USER_OPTIONS) + $(CONFIG_COMMAND) -dynamiclib -L"$(LINKPATH)" -o "$(<)" "$(>)" "$(LIBRARIES)" -l$(FINDLIBS-SA) -l$(FINDLIBS-ST) $(FRAMEWORK_PATH) -framework$(_)$(FRAMEWORK:D=) $(OPTIONS) $(USER_OPTIONS) } actions piecemeal archive From 27b06619c5be9cf667d1669fb901e0a9de51ec03 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 30 Sep 2006 09:30:46 +0000 Subject: [PATCH 65/82] Add comment [SVN r35430] --- v2/tools/python.jam | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 836a6edf6..a8d300ac0 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -231,7 +231,10 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) flags python.capture-output PYTHON $(condition:J=/) : $(interpreter) ; } - + # Depending on system, or on toolset used, we need extra libraries. + # Libraries which are needed depending on system are added to + # 'extra-libs' and for libraries which depend on toolset we need + # conditional requirements to 'extra-libs-conditional'. local extra-libs extra-libs-conditional ; # Depending on system, Python library is either static From ddda4d167e6f8272fcdce940c9ef8f3688a1c1ea Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sat, 30 Sep 2006 19:11:04 +0000 Subject: [PATCH 66/82] Fix incorrect macro def. [SVN r35433] --- historic/jam/src/mem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/historic/jam/src/mem.h b/historic/jam/src/mem.h index a3cb5ff31..afc653f37 100644 --- a/historic/jam/src/mem.h +++ b/historic/jam/src/mem.h @@ -73,7 +73,7 @@ http://www.boost.org/LICENSE_1_0.txt) #define bjam_malloc_atomic_x(s) bjam_malloc_x(s) #endif #ifndef bjam_calloc_atomic_x - #define bjam_calloc_atomic_x(s) bjam_calloc_x(s) + #define bjam_calloc_atomic_x(n,s) bjam_calloc_x(n,s) #endif #ifndef bjam_mem_init_x #define bjam_mem_init_x() From 2f92974d9997f475b68bf5d173a426985d81c668 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 2 Oct 2006 15:14:48 +0000 Subject: [PATCH 67/82] Fix bug in the generation of the path to the python binary for unix. Also make the comments clearer. [SVN r35442] --- v2/tools/python.jam | 55 ++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 20 deletions(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index a8d300ac0..2cadcdbef 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -146,6 +146,7 @@ local rule debug-message ( message * ) } } +# condition is a list of properties for which this python initialization applies. rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) { # @@ -166,7 +167,9 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) } # if root is explicitly specified, look in its bin subdirectory - local bin = $(bin/:R=(root)) ; + local bin = bin/ ; + bin = $(bin:R=$(root)) ; # will null out $(bin) if $(root) is empty. + if $(bin) { debug-message searching for python binaries in $(bin) ; @@ -219,7 +222,8 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) # - # If not specific condition is specified, set global value + # Set up the PYTHON variable to point at the interpreter. + # If no specific condition is specified, set global value # If condition is specified, set PYTHON on target. It will # override the global value. if ! $(condition) @@ -231,31 +235,42 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) flags python.capture-output PYTHON $(condition:J=/) : $(interpreter) ; } - # Depending on system, or on toolset used, we need extra libraries. - # Libraries which are needed depending on system are added to - # 'extra-libs' and for libraries which depend on toolset we need - # conditional requirements to 'extra-libs-conditional'. + # Provide system library dependencies for targets linking with + # static Python libraries. + # + # On many systems, Python uses libraries such as pthreads or + # libdl. Since static libraries carry no library dependency + # information of their own that the linker can extract, these + # extra dependencies have to be given explicitly on the link line + # of the client. The information about these dependencies is + # packaged into the "python" target below. + + # Even where Python itself uses pthreads, it never allows + # extension modules to be entered concurrently (unless they + # explicitly give up the interpreter lock). Therefore, extension + # modules don't need the efficiency overhead of threadsafe code as + # produced by multi, and we handle libpthread along + # with other libraries here. Note: this optimization is based on + # an assumption that the compiler generates link-compatible code + # in both the single- and multi-threaded cases, and that system + # libraries don't change their ABIs either. + + # Most libraries are added to 'extra-libs'. Those that depend on + # the toolset are added to 'extra-libs-conditional', which will be + # used to form more specific target alternatives. + local extra-libs extra-libs-conditional ; - # Depending on system, Python library is either static - # or shared. When it's static, we need to add 'pthread' - # to link line of all clients, otherwise we'll get - # unresolved symbols. Same effect can be accomplished - # by using multi on the client, but - # that can have performance overhead, and is not really - # necessary, as Python interface has nothing that's - # affected by threading mode. switch [ os.name ] { case SOLARIS : { extra-libs = pthread dl ; - # Add 'rt' option on Sun. While we duplicate the - # logic already in sun.jam and gcc.jam, I see no easy - # way to refactor it -- Volodya. - # Note that for 'sun' toolset, rt is already unconditionally - # added. + # Add a librt dependency for the gcc toolset on SunOS (the + # sun toolset adds -lrt unconditionally). While this + # appears to duplicate the logic already in gcc.jam, it + # doesn't as long as we're not forcing multi. extra-libs-conditional = gcc:rt ; } @@ -279,7 +294,7 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) # extensions to libpython, because the Python interpreter itself # provides all those symbols. If we linked to libpython, we'd get # duplicate symbols. So declare two targets -- one for building - # extensions and another embedding + # extensions and another for embedding alias python_for_extensions : : $(condition) From b6fcbb22544ce687a4e30a64b4deccd38e4944e0 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Tue, 3 Oct 2006 13:45:22 +0000 Subject: [PATCH 68/82] Fix more python configuration bugs [SVN r35455] --- v2/tools/python.jam | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 2cadcdbef..9f1389fce 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -177,7 +177,8 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) # Form the python commands to try in order. First look for python # with the explicit version number, then without it - local cmds = $(bin:E="")python$(version:E="") $(bin:E="")python ; + local python = python ; + local cmds = $(python:D=$(bin:E=""))$(version:E="") $(python:D=$(bin:E="")) ; local interpreter ; while $(cmds) @@ -276,7 +277,7 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) case OSF : { - extra-libs = pthread z ; + extra-libs = pthread ; extra-libs-conditional = gcc:rt ; } From f76acdeb4252ccd8fa4a2c1cfc94fef39a8b70d8 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Fri, 6 Oct 2006 07:21:36 +0000 Subject: [PATCH 69/82] Revive nightly build [SVN r35502] --- v2/nightly.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/v2/nightly.sh b/v2/nightly.sh index 07f33de5a..8ccb1cda4 100644 --- a/v2/nightly.sh +++ b/v2/nightly.sh @@ -5,12 +5,21 @@ # Create the packages set -e +trap "echo 'Nightly build failed'" ERR + +export QTDIR=/usr/share/qt3 +export LC_ALL=C +export LC_MESSAGES=C +export LANG=C cd /tmp rm -rf boost-build +echo "Checking out sources" cvs -d :ext:vladimir_prus@boost.cvs.sourceforge.net:/cvsroot/boost co -P -d boost-build boost/tools > /tmp/boost_build_checkout_log mv /tmp/boost_build_checkout_log boost-build/checkout-log cd boost-build/build/v2 -./roll.sh > ../roll-log +echo "Building packages and uploading docs" +./roll.sh > ../roll-log 2>&1 cd .. -scp boost-build.zip boost-build.tar.bz2 vladimir_prus@shell.sf.net:/home/groups/b/bo/boost/htdocs/boost-build2 > scp-log -echo "Upload successfull" +echo "Uploading packages" +scp boost-build.zip boost-build.tar.bz2 vladimir_prus@shell.sourceforge.net:/home/groups/b/bo/boost/htdocs/boost-build2 > scp-log +echo "Nightly build successful" From c9f08718a94a0304888bad7994d63f9eb37cb337 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 7 Oct 2006 09:31:19 +0000 Subject: [PATCH 70/82] Implement precompiled headers on gcc and improve same on msvc. Notable changes: 1. There's no need to cast header to the PCHHEADER type. 2. There are two separate type "C_PCH" and "CPP_PCH", that use C and C++ compilation respectively. Most of the patch sumbitted by Ilya Sokolov. tools/ * builtin.jam (class dummy-generator): New. * gcc.jam: Override extension of the PCH type. (class gcc-pch-generator): New. Register generators for C_PCH and CPP_PCH. (compile.c++.pch, compile.c.pch): New. * msvc.jam (class msvc-pch-generator): New. Register generators for C_PCH and CPP_PCH. * pch.jam: Remove 'PCHHEADER' type. (pch-generator): Fail unlress it's used at top-level generator. Register catch-all produce-nothing generators for PCH-less toolsets. [SVN r35508] --- v2/tools/builtin.jam | 12 +++++ v2/tools/gcc.jam | 99 ++++++++++++++++++++++++++++++++---- v2/tools/msvc.jam | 108 +++++++++++++++++++++++++++++++++++---- v2/tools/pch.jam | 117 ++++++++++++++++++++++++------------------- 4 files changed, 267 insertions(+), 69 deletions(-) diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 5663d6cf5..0446ee353 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -894,6 +894,18 @@ rule register-archiver ( id composing ? : source-types + : target-types + : generators.register $(g) ; } +# Generators that accepts everything, and produces nothing. +# Usefull as general fallback for toolset-specific actions, like +# PCH generation. +class dummy-generator : generator +{ + rule run ( project name ? : property-set : sources + ) + { + return [ property-set.empty ] ; + } +} + + IMPORT $(__name__) : register-linker register-archiver : : generators.register-linker generators.register-archiver ; diff --git a/v2/tools/gcc.jam b/v2/tools/gcc.jam index 0c5d4edda..b67e9001e 100644 --- a/v2/tools/gcc.jam +++ b/v2/tools/gcc.jam @@ -1,6 +1,8 @@ # Copyright 2001 David Abrahams. # Copyright 2002-2006 Rene Rivera. # Copyright 2002-2003 Vladimir Prus. +# Copyright (c) 2005 Reece H. Dunn. +# Copyright 2006 Ilya Sokolov. # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at @@ -16,6 +18,8 @@ import "class" : new ; import set ; import common ; import errors ; +import property-set ; +import pch ; if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] { @@ -144,6 +148,73 @@ generators.register-c-compiler gcc.compile.c++ : CPP : OBJ : gcc ; generators.register-c-compiler gcc.compile.c : C : OBJ : gcc ; generators.register-c-compiler gcc.compile.asm : ASM : OBJ : gcc ; +# pch support + +# The compiler looks for a precompiled header in each directory just +# before it looks for the include file in that directory. +# The name searched for is the name specified in the #include directive +# with ".gch" suffix appended. +# The logic in gcc-pch-generator will make sure that BASE_PCH suffix is +# appended to full name of the header. + +type.set-generated-target-suffix PCH : gcc : gch ; + +# GCC-specific pch generator. +class gcc-pch-generator : pch-generator +{ + import project ; + import property-set ; + + rule run-pch ( project name ? : property-set : header ) + { + # error handling + # base name of header file should be the same as the base name + # of precompiled header. + local header-name = [ $(header).name ] ; + local header-basename = $(header-name:B) ; + if $(header-basename) != $(name) + { + local location = [ $(project).project-module ] ; + errors.user-error "in" $(location)": pch target name `"$(name)"' should be the same as the base name of header file `"$(header-name)"'" ; + } + + local pch-file = + [ + generator.run $(project) $(name) + : $(property-set) + : $(header) + ] + ; + + # return result of base class and pch-file property as usage-requirements + return + [ property-set.create $(pch-file) ] + $(pch-file) + ; + } + + # Calls the base version specifying source's name as the + # name of the created target. As result, the PCH will be named + # whatever.hpp.gch, and not whatever.gch. + rule generated-targets ( sources + : property-set : project name ? ) + { + name = [ $(sources[1]).name ] ; + return [ generator.generated-targets $(sources) + : $(property-set) : $(project) $(name) ] ; + } +} + +# Note: the 'H' source type will catch both '.h' header and '.hpp' header. The latter +# have HPP type, but HPP type is derived from H. The type of compilation is determined +# entirely by the destination type. +generators.register [ new gcc-pch-generator gcc.compile.c.pch : H : C_PCH : on gcc ] ; +generators.register [ new gcc-pch-generator gcc.compile.c++.pch : H : CPP_PCH : on gcc ] ; + +# Override default do-nothing generators. +generators.override gcc.compile.c.pch : pch.default-c-pch-generator ; +generators.override gcc.compile.c++.pch : pch.default-cpp-pch-generator ; + +flags gcc.compile PCH_FILE on : ; # Declare flags and action for compilation flags gcc.compile OPTIONS off : -O0 ; @@ -205,6 +276,16 @@ flags gcc.compile.c++ USER_OPTIONS ; flags gcc.compile DEFINES ; flags gcc.compile INCLUDES ; +actions compile.c++.pch +{ + "$(CONFIG_COMMAND)" -x c++-header $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + +actions compile.c.pch +{ + "$(CONFIG_COMMAND)" -x c-header $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" +} + rule compile.c++ { # Some extensions are compiled as C++ by default. For others, we need @@ -214,12 +295,7 @@ rule compile.c++ { LANG on $(<) = "-x c++" ; } -} - - -actions compile.c++ -{ - "$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-128 $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" + DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ; } rule compile.c @@ -231,12 +307,17 @@ rule compile.c #{ LANG on $(<) = "-x c" ; #} + DEPENDS $(<) : [ on $(<) return $(PCH_FILE) ] ; } - -actions compile.c +actions compile.c++ bind PCH_FILE { - "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)" + "$(CONFIG_COMMAND)" $(LANG) -ftemplate-depth-128 $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<:W)" "$(>:W)" +} + +actions compile.c bind PCH_FILE +{ + "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) $(USER_OPTIONS) -D$(DEFINES) -I"$(PCH_FILE:D)" -I"$(INCLUDES)" -c -o "$(<)" "$(>)" } rule compile.asm diff --git a/v2/tools/msvc.jam b/v2/tools/msvc.jam index 98fbac877..c80f5f98e 100644 --- a/v2/tools/msvc.jam +++ b/v2/tools/msvc.jam @@ -2,6 +2,7 @@ # Copyright (c) 2005 Vladimir Prus. # Copyright (c) 2005 Alexey Pakhunov. # Copyright (c) 2006 Bojan Resnik. +# Copyright (c) 2006 Ilya Sokolov. # # Use, modification and distribution is subject to the Boost Software # License Version 1.0. (See accompanying file LICENSE_1_0.txt or @@ -534,7 +535,92 @@ generators.override msvc.compile.idl : midl.compile.idl ; generators.register-standard msvc.compile.mc : MC : H RC : msvc ; generators.override msvc.compile.mc : mc.compile ; -generators.register [ new pch-generator msvc.compile.pch : PCHEADER : OBJ PCH : msvc ] ; +# pch support + +feature pch-source : : free dependency ; + +class msvc-pch-generator : pch-generator +{ + import property-set ; + + rule run-pch ( project name ? : property-set : source-1 source-2 ) + { + # searching header and source file in the sources + local sources = $(source-1) $(source-2) ; + local pch-header ; + local pch-source ; + for local s in $(sources) + { + if [ type.is-derived [ $(s).type ] H ] + { + pch-header = $(s) ; + } + else if + [ type.is-derived [ $(s).type ] CPP ] + || [ type.is-derived [ $(s).type ] C ] + { + pch-source = $(s) ; + } + } + + if ! $(pch-header) + { + errors.user-error "can't build pch without pch-header" ; + } + + if ! $(pch-source) + { + errors.user-error "can't build pch without pch-source" ; + } + + local generated = + [ + # Passing of is a dirty trick, + # needed because non-composing generators + # with multiple inputs are subtly broken: + # https://zigzag.cs.msu.su:7813/boost.build/ticket/111 + generator.run $(project) $(name) + : [ + property-set.create + $(pch-source) + [ $(property-set).raw ] + ] + : $(pch-header) + ] + ; + + local pch-file ; + for local g in $(generated) + { + if [ type.is-derived [ $(g).type ] PCH ] + { + pch-file = $(g) ; + } + } + + return + [ + property-set.create + $(pch-header) + $(pch-file) + ] + $(generated) + ; + } +} + +# Note: the 'H' source type will catch both '.h' header and '.hpp' header. The latter +# have HPP type, but HPP type is derived from H. The type of compilation is determined +# entirely by the destination type. +generators.register [ new msvc-pch-generator msvc.compile.c.pch : H : C_PCH OBJ : on msvc ] ; +generators.register [ new msvc-pch-generator msvc.compile.c++.pch : H : CPP_PCH OBJ : on msvc ] ; + +generators.override msvc.compile.c.pch : pch.default-c-pch-generator ; +generators.override msvc.compile.c++.pch : pch.default-cpp-pch-generator ; + +flags msvc.compile PCH_FILE on : ; +flags msvc.compile PCH_SOURCE on : ; +flags msvc.compile PCH_HEADER on : ; # # Declare flags and action for compilation @@ -580,10 +666,6 @@ flags msvc.compile DEFINES ; flags msvc.compile UNDEFS ; flags msvc.compile INCLUDES ; -flags msvc.compile PCH_SOURCE ; -flags msvc.compile PCH_HEADER on : ; -flags msvc.compile PCH_FILE on : ; - rule get-rspline ( target : lang-opt ) { CC_RSPLINE on $(target) = [ on $(target) return $(lang-opt) -U$(UNDEFS) $(CFLAGS) $(C++FLAGS) $(OPTIONS) -c $(nl)-D$(DEFINES) $(nl)\"-I$(INCLUDES)\" ] ; @@ -613,16 +695,24 @@ rule compile.c++ ( targets + : sources * : properties * ) compile-c-c++ $(<) : $(>) [ on $(<) return $(PCH_FILE) ] [ on $(<) return $(PCH_HEADER) ] ; } -actions compile-pch +actions compile-c-c++-pch { - $(.CC) @"@($(<[1]:W).rsp:E="$(>[2]:W)" -Fo"$(<[1]:W)" -Yc"$(>[1]:D=)" -Yl"__bjam_pch_symbol_$(>[1]:D=)" -Fp"$(<[2]:W)" $(CC_RSPLINE))" + $(.CC) @"@($(<[1]:W).rsp:E="$(>[2]:W)" -Fo"$(<[2]:W)" -Yc"$(>[1]:D=)" -Yl"__bjam_pch_symbol_$(>[1]:D=)" -Fp"$(<[1]:W)" $(CC_RSPLINE))" } -rule compile.pch ( targets + : sources * : properties * ) +rule compile.c.pch ( targets + : sources * : properties * ) +{ + C++FLAGS on $(targets[1]) = ; + DEPENDS $(<) : [ on $(<) return $(PCH_SOURCE) ] ; + get-rspline $(targets[1]) : -TC ; + compile-c-c++-pch $(targets) : $(sources) [ on $(<) return $(PCH_SOURCE) ] ; +} + +rule compile.c++.pch ( targets + : sources * : properties * ) { DEPENDS $(<) : [ on $(<) return $(PCH_SOURCE) ] ; get-rspline $(targets[1]) : -TP ; - compile-pch $(targets) : $(sources) [ on $(<) return $(PCH_SOURCE) ] ; + compile-c-c++-pch $(targets) : $(sources) [ on $(<) return $(PCH_SOURCE) ] ; } actions compile.rc diff --git a/v2/tools/pch.jam b/v2/tools/pch.jam index 370ba67a4..4cd41be2f 100644 --- a/v2/tools/pch.jam +++ b/v2/tools/pch.jam @@ -1,79 +1,94 @@ # Copyright (c) 2005 Reece H. Dunn. +# Copyright 2006 Ilya Sokolov # # Use, modification and distribution is subject to the Boost Software # License Version 1.0. (See accompanying file LICENSE_1_0.txt or # http://www.boost.org/LICENSE_1_0.txt) +##### Using Precompiled Headers (Quick Guide) ##### +# +# Make precompiled mypch.hpp: +# +# import pch ; +# +# cpp-pch mypch +# : # sources +# mypch.hpp +# : # requiremnts +# msvc:mypch.cpp +# ; +# +# Add cpp-pch to sources: +# +# exe hello +# : main.cpp hello.cpp mypch +# ; + +import "class" : new ; import type ; -import feature : feature ; +import feature ; import generators ; -##### Using Pre-compiled Headers (Quick Guide) ##### -# -# Make mypch.hpp a pre-compiled header (PCH) using mypch.cpp as the source file: -# import cast ; -# pch mypch : [ cast _ pcheader : pch.hpp ] pch.cpp ; -# -# Enable PCHs in a target: -# exe hello : mypch main.cpp hello.cpp ; -# ^^^^^ -- mypch.hpp is a PCH -# -# Don't use PCHs for a specific source: -# obj nopch : nopch.cpp : off ; -# +type.register PCH : pch ; -type.register PCH : pch ; -type.register PCHEADER : pcheader ; +type.register C_PCH : : PCH ; +type.register CPP_PCH : : PCH ; -feature pch : # control precompiled header (PCH) generation - on # this file has support for using PCHs (if available) - off # this file doesn't use PCHs +# control precompiled header (PCH) generation +feature.feature pch : + on + off ; -feature pch-source : : free dependency ; # mypch.cpp -feature pch-header : : free dependency ; # mypch.h[pp] -feature pch-file : : free dependency ; # mypch.pch +feature.feature pch-header : : free dependency ; +feature.feature pch-file : : free dependency ; +# Base PCH generator. The 'run' method has the logic to +# prevent this generator from being run unless it's used +# in top-level PCH target. class pch-generator : generator { import property-set ; - rule __init__ ( * : * ) - { - generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ; - } - rule action-class ( ) { return compile-action ; } - rule run ( project name ? : property-set : sources * ) + rule run ( project name ? : property-set : sources + ) { - # The two sources are cpp file and PCHEADER, but they - # can be passed in any order. Figure out which source - # is what. - local cpp = $(sources[2]) ; - local h = $(sources[1]) ; - if [ $(sources[2]).type ] = PCHEADER + if ! $(name) { - cpp = $(sources[1]) ; - h = $(sources[2]) ; + # Unless this generator is invoked as the top-most + # generator for a main target, fail. This allows using + # 'H' type as input type for this generator, while + # preventing Boost.Build to try this generator when not + # explicitly asked for. + # + # One bad example is msvc, where pch generator produces + # both PCH target and OBJ target, so if there's any + # header generated (like by bison, or by msidl), we'd + # try to use pch generator to get OBJ from that H, which + # is completely wrong. By restricting this generator + # only to pch main target, such problem is solved. + return [ property-set.empty ] ; } - - local r = - [ generator.run $(project) $(name) : - [ - property-set.create - $(cpp) # mypch.cpp - [ $(property-set).raw ] - ] : $(sources) - ] ; - - return - [ property-set.create - $(h) # mypch.h[pp] - $(r[2]) # mypch.pch - ] $(r) ; + else + { + return [ run-pch $(project) $(name) : $(property-set) + : $(sources) ] ; + } } + + # This rule must be overridden by the derived classes. + rule run-pch ( project name ? : property-set : sources + ) + { + } } + +# NOTE: requiremetns are empty, +# default pch generator can be applied when pch=off +generators.register [ + new dummy-generator pch.default-c-pch-generator : : C_PCH ] ; +generators.register [ + new dummy-generator pch.default-cpp-pch-generator : : CPP_PCH ] ; From 1d1ab035c1ba31ab17b35677aaaef69068357528 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 7 Oct 2006 10:08:19 +0000 Subject: [PATCH 71/82] Test for PCH * BoostBuild.py (Tester.copy_preserving_timestap): New. * pch.py: New. * test_all.py: Register pch.py on gcc. [SVN r35512] --- v2/test/BoostBuild.py | 7 +++++ v2/test/pch.py | 70 +++++++++++++++++++++++++++++++++++++++++++ v2/test/test_all.py | 1 + 3 files changed, 78 insertions(+) create mode 100644 v2/test/pch.py diff --git a/v2/test/BoostBuild.py b/v2/test/BoostBuild.py index 239f76975..2aa2822f2 100644 --- a/v2/test/BoostBuild.py +++ b/v2/test/BoostBuild.py @@ -234,6 +234,13 @@ class Tester(TestCmd.TestCmd): self.wait_for_time_change() self.write(dst, self.read(src)) + def copy_preserving_timestamp(self, src, dst): + src_name = self.native_file_name(src) + dst_name = self.native_file_name(dst) + stats = os.stat(src_name) + self.write(dst, self.read(src)) + os.utime(dst_name, (stats.st_atime, stats.st_mtime)) + def touch(self, names): self.wait_for_time_change() for name in self.adjust_names(names): diff --git a/v2/test/pch.py b/v2/test/pch.py new file mode 100644 index 000000000..b304241f1 --- /dev/null +++ b/v2/test/pch.py @@ -0,0 +1,70 @@ +#!/usr/bin/python + +# Copyright 2006 Vladimir Prus. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +from BoostBuild import Tester, List +import string +import os + +t = Tester() + +t.write("Jamroot", """ + +import pch ; + +cpp-pch pch : pch.hpp : msvc:pch.cpp ; + +exe hello : hello.cpp pch : . ; +""") + +t.write("pch.hpp.bad", """ +THIS WON'T COMPILE +""") + +# Note that pch.hpp is written after pch.hpp.bad, so its timestamp won't +# be less than timestamp of pch.hpp.bad. +t.write("pch.hpp", """ +class TestClass { +public: + TestClass(int, int) {} +}; + +""") + + + +t.write("pch.cpp", """ #include + +""") + +t.write("hello.cpp", """ #include + +int main() +{ + TestClass c(1, 2); + return 0; +} + +""") + +t.run_build_system() + +t.expect_addition("bin/$toolset/debug/hello.exe") + +# Now make the header unusable, without changing timestamp. +# If everything is OK, Boost.Build won't recreate PCH, and +# compiler will happily use pre-compiled header, not noticing +# that the real header is bad. + +t.copy_preserving_timestamp("pch.hpp.bad", "pch.hpp") + +t.rm("bin/$toolset/debug/hello.obj") + +t.run_build_system() +t.expect_addition("bin/$toolset/debug/hello.obj") + +t.cleanup() + diff --git a/v2/test/test_all.py b/v2/test/test_all.py index 81b6a14e7..e89e10594 100644 --- a/v2/test/test_all.py +++ b/v2/test/test_all.py @@ -157,6 +157,7 @@ if os.name == 'posix': if string.find(get_toolset(), 'gcc') == 0: tests.append("gcc_runtime") + tests.append("pch") if "--extras" in sys.argv: tests.append("boostbook") From fa61b68c56648dc1f8e1142dc6fe36792ec38c1d Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 7 Oct 2006 10:09:07 +0000 Subject: [PATCH 72/82] Add PCH example. [SVN r35513] --- v2/example/pch/Jamroot | 29 +++++++++++++++++++++++++++ v2/example/pch/include/pch.hpp | 11 ++++++++++ v2/example/pch/source/hello_world.cpp | 15 ++++++++++++++ v2/example/pch/source/pch.cpp | 8 ++++++++ 4 files changed, 63 insertions(+) create mode 100644 v2/example/pch/Jamroot create mode 100644 v2/example/pch/include/pch.hpp create mode 100644 v2/example/pch/source/hello_world.cpp create mode 100644 v2/example/pch/source/pch.cpp diff --git a/v2/example/pch/Jamroot b/v2/example/pch/Jamroot new file mode 100644 index 000000000..509de203a --- /dev/null +++ b/v2/example/pch/Jamroot @@ -0,0 +1,29 @@ +# Copyright 2006 Ilya Sokolov +# +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +# pch ########################################################################## + +import pch ; + +cpp-pch pch + : # sources + include/pch.hpp + : # requirements + include + msvc:source/pch.cpp + ; + +# exe ########################################################################## + +exe hello_world + : # sources + pch + source/hello_world.cpp + : # requirements + include + : # default build + : # usage requirements + ; diff --git a/v2/example/pch/include/pch.hpp b/v2/example/pch/include/pch.hpp new file mode 100644 index 000000000..22df8443f --- /dev/null +++ b/v2/example/pch/include/pch.hpp @@ -0,0 +1,11 @@ +/* Copyright 2006 Vladimir Prus + + Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +*/ + +class TestClass { +public: + TestClass(int, int) {} +}; diff --git a/v2/example/pch/source/hello_world.cpp b/v2/example/pch/source/hello_world.cpp new file mode 100644 index 000000000..f618056a0 --- /dev/null +++ b/v2/example/pch/source/hello_world.cpp @@ -0,0 +1,15 @@ +/* Copyright 2006 Ilya Sokolov + Copyright 2006 Vladimir Prus + + Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +*/ + +#include + +int main() +{ + TestClass c(1, 2); + return 0; +} diff --git a/v2/example/pch/source/pch.cpp b/v2/example/pch/source/pch.cpp new file mode 100644 index 000000000..995e1f803 --- /dev/null +++ b/v2/example/pch/source/pch.cpp @@ -0,0 +1,8 @@ +/* Copyright 2006 Ilya Sokolov + + Distributed under the Boost Software License, Version 1.0. (See + accompanying file LICENSE_1_0.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +*/ + +#include From 8843823a1c1875c83d9f2e544a611b49fd80ba3a Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 7 Oct 2006 12:38:50 +0000 Subject: [PATCH 73/82] Missing import [SVN r35514] --- v2/tools/builtin.jam | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/v2/tools/builtin.jam b/v2/tools/builtin.jam index 0446ee353..e96fcc645 100644 --- a/v2/tools/builtin.jam +++ b/v2/tools/builtin.jam @@ -457,8 +457,8 @@ class lib-generator : generator local properties = [ $(property-set).raw ] ; # Determine the needed target type local actual-type ; - # files can be generated by @rule feature - # in which case we don't consider it a SEARCHED_LIB type. + # files can be generated by @rule feature + # in which case we don't consider it a SEARCHED_LIB type. if ! in $(properties:G) && ( in $(properties:G) || in $(properties:G) ) { @@ -899,6 +899,8 @@ rule register-archiver ( id composing ? : source-types + : target-types + : # PCH generation. class dummy-generator : generator { + import property-set ; + rule run ( project name ? : property-set : sources + ) { return [ property-set.empty ] ; From dffc92138b961e327f1e794895faad81ac0dc827 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 7 Oct 2006 19:11:03 +0000 Subject: [PATCH 74/82] build/ * generators.jam (try-one-generator-really): If generator returns a property set but no targets, consider it a success. [SVN r35520] --- v2/build/generators.jam | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/v2/build/generators.jam b/v2/build/generators.jam index b538d210b..e037bab77 100644 --- a/v2/build/generators.jam +++ b/v2/build/generators.jam @@ -825,22 +825,28 @@ local rule try-one-generator-really ( project name ? : generator : ] ; local usage-requirements ; - if $(targets) && [ class.is-a $(targets[1]) : property-set ] + local success ; + if $(targets) { - usage-requirements = $(targets[1]) ; - targets = $(targets[2-]) ; - } - else - { - usage-requirements = [ property-set.empty ] ; + success = true ; + + if [ class.is-a $(targets[1]) : property-set ] + { + usage-requirements = $(targets[1]) ; + targets = $(targets[2-]) ; + } + else + { + usage-requirements = [ property-set.empty ] ; + } } generators.dout [ indent ] " generator" [ $(generator).id ] " spawned " ; generators.dout [ indent ] " " $(targets) ; - if $(targets) + if $(success) { return $(usage-requirements) $(targets) ; - } + } } # Checks if generator invocation can be pruned, because it's guaranteed From 618a4bfdf2ff6d1dd608c2719d736810dbd7a1aa Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Sat, 7 Oct 2006 20:09:22 +0000 Subject: [PATCH 75/82] Rearrange docs a bit [SVN r35521] --- v2/doc/src/advanced.xml | 857 +------------------------------------- v2/doc/src/reference.xml | 117 ++++-- v2/doc/src/standalone.xml | 15 +- v2/doc/src/tasks.xml | 710 +++++++++++++++++++++++++++++++ v2/doc/src/userman.xml | 6 +- v2/doc/src/v1_vs_v2.xml | 107 +++++ 6 files changed, 917 insertions(+), 895 deletions(-) create mode 100644 v2/doc/src/tasks.xml create mode 100644 v2/doc/src/v1_vs_v2.xml diff --git a/v2/doc/src/advanced.xml b/v2/doc/src/advanced.xml index 8187a1f9e..ac7fb615c 100644 --- a/v2/doc/src/advanced.xml +++ b/v2/doc/src/advanced.xml @@ -3,7 +3,7 @@ "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd"> - User documentation + Overview This section will provide the information necessary to create your own projects using Boost.Build. The information provided here is relatively @@ -73,7 +73,7 @@
- Boost.Jam language + Boost.Jam Language This section will describe the basics of the Boost.Jam language—just enough for writing Jamfiles. For more information, @@ -536,7 +536,7 @@ bjam optimization=space
- Declaring targets + Declaring Targets A Main target is a user-defined named @@ -769,7 +769,7 @@ rule my-rule ( properties * )
- Default build + Default Build The default-build parameter is a set of properties to be used if the build request does @@ -785,7 +785,7 @@ exe hello : hello.cpp : : <threading>multi ;
- Additional information + Additional Information The ways a target is built can be so different that @@ -826,7 +826,7 @@ exe hello : hello.cpp explicit request, this can be expressed by the explicit rule: - explicit install_programs ; +explicit install_programs ;
@@ -1028,90 +1028,6 @@ project tennis perfectly appropriate to start a user guide with that kind of material. --> - - -
- Jamfile Utility Rules - - The following table describes utility rules that can be - used in Jamfiles. Detailed information for any of these rules can - be obtained by running: - -bjam --help project.rulename - - - - - - <tgroup cols="2"> - <thead> - <row> - <entry>Rule</entry> - - <entry>Semantics</entry> - </row> - </thead> - - <tbody> - <row> - <entry><link linkend= - "bbv2.advanced.projects.attributes.projectrule">project</link> - </entry> - - <entry>Define this project's symbolic ID or attributes.</entry> - </row> - - <row> - <entry><xref linkend= - "bbv2.advanced.projects.relationships.useprojectrule">use-project</xref></entry> - - <entry>Make another project known so that it can be referred to by symbolic ID.</entry> - </row> - - <row> - <entry><xref linkend= - "bbv2.advanced.projects.relationships.buildprojectrule">build-project</xref></entry> - - <entry>Cause another project to be built when this one is built.</entry> - </row> - - <row> - <entry><xref linkend= - "bbv2.reference.buildprocess.explict">explicit</xref></entry> - - <entry>State that a target should be built only by explicit - request.</entry> - </row> - - <row> - <entry>glob</entry> - - <entry>Translate a list of shell-style wildcards into a - corresponding list of files.</entry> - </row> - - <row> - <entry>constant</entry> - - <entry>Injects a variable setting into this project's - Jamfile module and those of all its subprojects.</entry> - </row> - - <row> - <entry>path-constant</entry> - - <entry>Injects a variable set to a path value into - this project's Jamfile module and those of all its subprojects. - If the value is a relative path it will be adjusted for - each subproject so that it refers to the same - directory.</entry> - </row> - - - </tbody> - </tgroup> - </table> - </section> <section id="bbv2.advanced.build_process"> <title>The Build Process @@ -1147,7 +1063,7 @@ bjam --help project.rulename
- Build request + Build Request The command line specifies which targets to build and with which @@ -1253,7 +1169,7 @@ bjam app1 lib1//lib1 gcc debug optimization=full
-
Building a project +
Building a Project Often, a user builds a complete project, not just one main target. In fact, invoking bjam without @@ -1287,763 +1203,6 @@ explicit hello_test ;
- -
- Builtin target types - - This section describes main targets types that Boost.Build supports - of-of-the-box. Unless otherwise noted, all mentioned main target rules - have the common signature, described in . - - -
- Programs - - Builtin - rulesexe - Programs are created using the exe rule, which - follows the common - syntax. For example: - -exe hello : hello.cpp some_library.lib /some_project//library - : <threading>multi - ; - - This will create an executable file from the sources -- in this case, - one C++ file, one library file present in the same directory, and - another library that is created by Boost.Build. Generally, sources - can include C and C++ files, object files and libraries. Boost.Build - will automatically try to convert targets of other types. - - - - - On Windows, if an application uses dynamic libraries, and both - the application and the libraries are built by Boost.Build, its not - possible to immediately run the application, because the - PATH environment variable should include the path - to the libraries. It means you have to either add the paths - manually, or place the application and the libraries to the same - directory, for example using the - stage rule. - - - -
- -
- Libraries - - Libraries are created using the lib rule, which - follows the common - syntax. For example: - -lib helpers : helpers.cpp : <include>boost : : <include>. ; - - - - In the most common case, the lib creates a library - from the specified sources. Depending on the value of - <link> feature the library will be either static or - shared. There are two other cases. First is when the library is - installed somewhere in compiler's search paths, and should be - searched by the compiler (typically, using the - option). The second case is where the library is available as a - prebuilt file and the full path is known. - - - - - The syntax for these case is given below: - -lib z : : <name>z <search>/home/ghost ; -lib compress : : <file>/opt/libs/compress.a ; - - The name property specifies the name that should be - passed to the option, and the file - property specifies the file location. The search feature - specifies paths in which to search for the library. That feature can - be specified several times, or it can be omitted, in which case only - default compiler paths will be searched. - - - The difference between using the file feature as - opposed to the name feature together with the - search feature is that file is more - precise. A specific file will be used. On the other hand, the - search feature only adds a library path, and the - name feature gives the basic name of the library. The - search rules are specific to the linker. For example, given these - definition: - -lib a : : <variant>release <file>/pool/release/a.so ; -lib a : : <variant>debug <file>/pool/debug/a.so ; -lib b : : <variant>release <file>/pool/release/b.so ; -lib b : : <variant>debug <file>/pool/debug/b.so ; - - It's possible to use release version of a and debug - version of b. Had we used the name and - search features, the linker would always pick either - release or debug versions. - - - - - For convenience, the following syntax is allowed: - -lib z ; -lib gui db aux ; - - and is does exactly the same as: - -lib z : : <name>z ; -lib gui : : <name>gui ; -lib db : : <name>db ; -lib aux : : <name>aux ; - - - - When a library uses another library you should put that other - library in the list of sources. This will do the right thing in all - cases. For portability, you should specify library dependencies even - for searched and prebuilt libraries, othewise, static linking on - Unix won't work. For example: - -lib z ; -lib png : z : <name>png ; - - - - - When a library (say, a), that has another - library, (say, b) - - is linked dynamically, the b - library will be incorporated - - in a. (If b - is dynamic library as well, then a will only refer to - it, and not include any extra code.) - - When the a - library is linked statically, Boost.Build will assure that all - executables that link to a will also link to - b. - - - - One feature of Boost.Build that is very important for libraries - is usage requirements. - - For example, if you write: - -lib helpers : helpers.cpp : : : <include>. ; - - then the compiler include path for all targets that use - helpers will contain the directory - - where the target is defined.path to "helpers.cpp". The user - only needs to add helpers to the list of sources, - and needn't consider the requirements its use imposes on a - dependent target. This feature greatly simplifies Jamfiles. - - - - - If you don't want shared libraries to include all libraries - that are specified in sources (especially statically linked ones), - you'd need to use the following: - -lib b : a.cpp ; -lib a : a.cpp : <use>b : : <library>b ; - - This specifies that a uses b, and causes - all executables that link to a also link to - b. In this case, even for shared linking, the - a library won't even refer to b. - - - -
- -
- Alias - - - The alias rule gives alternative name to - a group of targets. For example, to give the name - core to a group of three other targets with the - following code: - -alias core : im reader writer ; - Using core on the command line, or in the source list - of any other target is the same as explicitly using - im, reader, and - writer, but it is just more convenient. - - - - - - Another use of the alias rule is to change build - properties. For example, if you always want static linking for a - specific C++ Boost library, you can write the following: - -alias threads : /boost/thread//boost_thread : <link>static ; - - and use only the threads alias in your Jamfiles. - - - - - You can also specify usage requirements for the - alias target. If you write the following: - -alias header_only_library : : : : <include>/usr/include/header_only_library ; - - then using header_only_library in sources will only add an - include path. Also note that when there are some sources, their usage - requirements are propagated, too. For example: - -lib lib : lib.cpp : : : <include>. ; -alias lib_alias ; -exe main : main.cpp lib_alias ; - - will compile main.cpp with the additional include. - - -
- -
- Installing - - For installing a built target you should use the - install rule, which follows the common syntax. For - example: - -install dist : hello helpers ; - - will cause the targets hello and helpers to - be moved to the dist directory, relative to - Jamfile's directory. The directory can - be changed with the location property: - -install dist : hello helpers : <location>/usr/bin ; - - While you can achieve the same effect by changing the target name to - /usr/bin, using the location - property is better, because it allows you to use a mnemonic target - name. - - - The location property is especially handy when the location - is not fixed, but depends on build variant or environment variables: - -install dist : hello helpers : <variant>release:<location>dist/release - <variant>debug:<location>dist/debug ; -install dist2 : hello helpers : <location>$(DIST) ; - - See also conditional - properties and environment variables - - - - Specifying the names of all libraries to install can be boring. The - install allows you to specify only the top-level executable - targets to install, and automatically install all dependencies: - -install dist : hello - : <install-dependencies>on <install-type>EXE - <install-type>LIB - ; - - will find all targets that hello depends on, and install - all of those which are either executables or libraries. More - specifically, for each target, other targets that were specified as - sources or as dependency properties, will be recursively found. One - exception is that targets referred with the use feature - are not considered, because that feature is typically used to refer to - header-only libraries. - If the set of target types is specified, only targets of that type - will be installed, otherwise, all found target will be installed. - - - The alias - rule can be used when targets must be installed into several - directories: - -alias install : install-bin install-lib ; -install install-bin : applications : /usr/bin ; -install install-lib : helper : /usr/lib ; - - - - Because the install rule just copies targets, most - free features see the definition of "free" in . - have no effect when used in requirements of the install rule. - The only two which matter are - - dependency and, on Unix, - dll-path. - - - - - (Unix specific). On Unix, executables built with Boost.Build typically - contain the list of paths to all used dynamic libraries. For - installing, this is not desired, so Boost.Build relinks the executable - with an empty list of paths. You can also specify additional paths for - installed executables with the dll-path feature. - - - - -
- -
- - Testing - - Boost.Build has convenient support for running unit tests. The - simplest way is the unit-test rule, which follows the - common syntax. For - example: - -unit-test helpers_test : helpers_test.cpp helpers ; - - - - The unit-test rule behaves like the - exe rule, but after the executable is created it is - run. If the executable returns an error code, the build system will also - return an error and will try running the executable on the next - invocation until it runs successfully. This behaviour ensures that you - can't miss a unit test failure. - - - By default, the executable is run directly. Sometimes, it's - desirable to run the executable using some helper command. You should use the - testing.launcher property to specify the name of the - helper command. For example, if you write: - - -unit-test helpers_test - : helpers_test.cpp helpers - : <testing.launcher>valgrind - ; - - The command used to run the executable will be: - -valgrind bin/$toolset/debug/helpers_test - - - - - There are rules for more elaborate testing: compile, - compile-fail, run and - run-fail. They are more suitable for automated testing, and - are not covered here. - -
- -
- - Raw commands: 'make' and 'notfile' - - Sometimes, the builtin target types are not enough, and you - want Boost.Build to just run specific commands. There are two main - target rules that make it possible: make - and notfile. - - - The make rule is used when you want to - create one file from a number of sources using some specific command. - The notfile is used to unconditionally run - a command. - - - - Suppose you want to create file file.out from - file file.in by running command - in2out. Here's how you'd do this in Boost.Build: - -actions in2out -{ - in2out $(<) $(>) -} -make file.out : file.in : @in2out ; - - If you run bjam and file.out - does not exist, Boost.Build will run the in2out - command to create that file. For more details on specifying actions, - see . - - - - - The make rule is useful to express custom - transformation that are used just once or twice in your project. For - transformations that are used often, you are advised to declare - new generator, as described in . - - - - - It could be that you just want to run some command unconditionally, - and that command does not create any specific files. The, you can use - the notfile rule. For example: - -notfile echo_something : @echo ; -actions echo -{ - echo "something" -} - - The only difference from the make rule is - that the name of the target is not considered a name of a file, so - Boost.Build will unconditionally run the action. - - -
- -
- -
- Builtin features - - - variant - - - - A feature that combines several low-level features, making - it easy to request common build configurations. - - - Allowed values: debug, release, - profile. - - The value debug expands to - - -<optimization>off <debug-symbols>on <inlining>off <runtime-debugging>on - - - The value release expands to - - -<optimization>speed <debug-symbols>off <inlining>full <runtime-debugging>off - - - The value profile expands to the same as - release, plus: - - -<profiling>on <debug-symbols>on - - - User can define his own build variants using the variant rule from the common - module. - - Notee: Runtime - debugging is on in debug builds to suit the expectations of - people used to various IDEs. - - - - - - link - - - - A feature that controls how libraries are built. - - - Allowed values: shared, - static - - - source - - - - The <source>X feature has the same effect on - building a target as putting X in the list of sources. - It's useful when you want to add - the same source to all targets in the project - (you can put <source> in requirements) or to conditionally - include a source (using conditional requirements, see ) - See also the <library> feature. - - - - - library - - - - This feature is almost equivalent to the <source> feature, - except that it takes effect only for linking. When you want to - link all targets in a Jamfile to certain library, the - <library> feature is preferred over - <source>X -- the latter will add the library to - all targets, even those that have nothing to do with libraries. - - - - - - dependency - - - - Introduces a dependency on the target named by the - value of this feature (so it will be brought - up-to-date whenever the target being declared is). - The dependency is not used in any other way. For example, in - application with plugins, the plugins are not used when linking - the application, - application might have dependency on its plugins, even though - - - , and - adds its usage requirements to the build properties - of the target being declared. - - The primary use case is when you want - the usage requirements (such as #include paths) of some - library to be applied, but don't want to link to it. - - - - - - - - use - - - - Introduces a dependency on the target named by the - value of this feature (so it will be brought - up-to-date whenever the target being declared is), and - adds its usage requirements to the build properties - - of the target being declared. The dependency is not used - in any other way. The primary use case is when you want - the usage requirements (such as #include paths) of some - library to be applied, but don't want to link to it. - - - - - - - dll-path - - - - Specify an additional directory where the system should - look for shared libraries when the executable or shared - library is run. This feature only affects Unix - compilers. Plase see - in for details. - - - - hardcode-dll-paths - - - - Controls automatic generation of dll-path properties. - - - Allowed values: - true, false. This property - is specific to Unix systems. If an executable is built with - <hardcode-dll-paths>true, the generated binary - will contain the list of all the paths to the used shared - libraries. As the result, the executable can be run without - changing system paths to shared libraries or installing the - libraries to system paths. This - - is very convenient during - development. Plase see the FAQ entry for details. - Note that on Mac OSX, the paths are unconditionally hardcoded by - the linker, and it's not possible to disable that behaviour. - - - - - cflags - cxxflags - linkflags - - - - The value of those features is passed without modification to the - corresponding tools. For cflags that's both the C and C++ - compilers, for cxxflags that's the C++ compiler and for - linkflags that's the linker. The features are handy when - you're trying to do something special that cannot be achieved by - higher-level feature in Boost.Build. - - - - - warnings - - - - The <warnings> feature controls the warning level of compilers. It has the following values: - - off - disables all warnings. - on - enables default warning level for the tool. - all - enables all warnings. - - Default value is all. - - - - - warnings-as-errors - - - - The <warnings-as-errors> makes it possible to treat warnings as errors and abort - compilation on a warning. The value on enables this behaviour. The default value is - off. - - - - - build - - - Allowed values: no - - - The build feature is used to conditionally disable build of a target. If <build>no - is in properties when building a target, build of that target is skipped. Combined with conditional requirements this - allows to skip building some target in configurations where the build is known to fail. - - - - - - - - - -
- -
- Differences to Boost.Build V1 - - - While Boost.Build V2 is based on the same ideas as Boost.Build V1, - some of the syntax was changed, and some new important features were - added. This chapter describes most of the changes. - -
- Configuration - - In V1, toolsets were configured by environment variables. If you - wanted to use two versions of the same toolset, you had to create a new - toolset module that would set the variables and then invoke the base - toolset. In V2, toolsets are configured by the - using, and you can easily configure several - versions of a toolset. See for details. - - -
- -
- Writing Jamfiles - - Probably one of the most important differences in V2 Jamfiles is - the use of project requirements. In V1, if several targets had the same - requirements (for example, a common #include path), it was necessary to - manually write the requirements or use a helper rule or template target. In V2, the - common properties can be specified with the requirements project - attribute, as documented in . - - - Usage requirements - also help to simplify Jamfiles. - - If a library requires - all clients to use specific #include paths or macros when compiling - code that depends on the library, that information can be cleanly - represented. - - The difference between lib and dll targets in V1 is completely - eliminated in V2. There's only one library target type, lib, which can create - either static or shared libraries depending on the value of the - <link> - feature. If your target should be only built in one way, you - can add <link>shared or <link>static to its requirements. - - - The syntax for referring to other targets was changed a bit. While - in V1 one would use: - -exe a : a.cpp <lib>../foo/bar ; - - the V2 syntax is: - -exe a : a.cpp ../foo//bar ; - - Note that you don't need to specify the type of other target, but the - last element should be separated from the others by a double slash to indicate that - you're referring to target bar in project ../foo, and not to - project ../foo/bar. - - - -
- -
- Build process - - The command line syntax in V2 is completely different. For example - -bjam -sTOOLS=msvc -sBUILD=release some_target - - now becomes: - -bjam toolset=msvc variant=release some_target - - or, using implicit features, just: - -bjam msvc release some_target - - See the reference for a - complete description of the syntax. - - - -
- -
diff --git a/v2/doc/src/reference.xml b/v2/doc/src/reference.xml index ceaa9c98c..d3c6796f6 100644 --- a/v2/doc/src/reference.xml +++ b/v2/doc/src/reference.xml @@ -228,49 +228,90 @@ target1 debug gcc/runtime-link=dynamic,static -
- Writing Jamfiles +
+ Jamfile Utility Rules - This section describes specific information about writing Jamfiles. - -
- Generated headers - - Usually, Boost.Build handles implicit dependendies completely - automatically. For example, for C++ files, all #include - statements are found and handled. The only aspect where user help - might be needed is implicit dependency on generated files. - - By default, Boost.Build handles such dependencies within one - main target. For example, assume that main target "app" has two - sources, "app.cpp" and "parser.y". The latter source is converted - into "parser.c" and "parser.h". Then, if "app.cpp" includes - "parser.h", Boost.Build will detect this dependency. Moreover, - since "parser.h" will be generated into a build directory, the - path to that directory will automatically added to include - path. - - Making this mechanism work across main target boundaries is - possible, but imposes certain overhead. For that reason, if - there's implicit dependency on files from other main targets, the - <implicit-dependency> [ link ] feature must - be used, for example: - - -lib parser : parser.y ; -exe app : app.cpp : <implicit-dependency>parser ; - - - - The above example tells the build system that when scanning - all sources of "app" for implicit-dependencies, it should consider - targets from "parser" as potential dependencies. + The following table describes utility rules that can be + used in Jamfiles. Detailed information for any of these rules can + be obtained by running: + +bjam --help project.rulename + + +
+ + <tgroup cols="2"> + <thead> + <row> + <entry>Rule</entry> + + <entry>Semantics</entry> + </row> + </thead> + + <tbody> + <row> + <entry><link linkend= + "bbv2.advanced.projects.attributes.projectrule">project</link> + </entry> + + <entry>Define this project's symbolic ID or attributes.</entry> + </row> + + <row> + <entry><xref linkend= + "bbv2.advanced.projects.relationships.useprojectrule">use-project</xref></entry> + + <entry>Make another project known so that it can be referred to by symbolic ID.</entry> + </row> + + <row> + <entry><xref linkend= + "bbv2.advanced.projects.relationships.buildprojectrule">build-project</xref></entry> + + <entry>Cause another project to be built when this one is built.</entry> + </row> + + <row> + <entry><xref linkend= + "bbv2.reference.buildprocess.explict">explicit</xref></entry> + + <entry>State that a target should be built only by explicit + request.</entry> + </row> + + <row> + <entry>glob</entry> + + <entry>Translate a list of shell-style wildcards into a + corresponding list of files.</entry> + </row> + + <row> + <entry>constant</entry> + + <entry>Injects a variable setting into this project's + Jamfile module and those of all its subprojects.</entry> + </row> + + <row> + <entry>path-constant</entry> + + <entry>Injects a variable set to a path value into + this project's Jamfile module and those of all its subprojects. + If the value is a relative path it will be adjusted for + each subproject so that it refers to the same + directory.</entry> + </row> + + + </tbody> + </tgroup> + </table> </section> - </section> - <section id="bbv2.reference.buildprocess"> <title>Build process diff --git a/v2/doc/src/standalone.xml b/v2/doc/src/standalone.xml index c16af5dfe..527237274 100644 --- a/v2/doc/src/standalone.xml +++ b/v2/doc/src/standalone.xml @@ -1,27 +1,30 @@ - - - Boost.Build v2 User Manual + Boost.Build V2 User Manual + - + - Boost.Jam documentation + Boost.Jam Documentation - + + + diff --git a/v2/doc/src/tasks.xml b/v2/doc/src/tasks.xml new file mode 100644 index 000000000..eaabf6167 --- /dev/null +++ b/v2/doc/src/tasks.xml @@ -0,0 +1,710 @@ + + + + + Common tasks + + This section describes main targets types that Boost.Build supports + of-of-the-box. Unless otherwise noted, all mentioned main target rules + have the common signature, described in . + + +
+ Programs + + Builtin + rulesexe + Programs are created using the exe rule, which + follows the common + syntax. For example: + +exe hello : hello.cpp some_library.lib /some_project//library + : <threading>multi + ; + + This will create an executable file from the sources -- in this case, + one C++ file, one library file present in the same directory, and + another library that is created by Boost.Build. Generally, sources + can include C and C++ files, object files and libraries. Boost.Build + will automatically try to convert targets of other types. + + + + + On Windows, if an application uses dynamic libraries, and both + the application and the libraries are built by Boost.Build, its not + possible to immediately run the application, because the + PATH environment variable should include the path + to the libraries. It means you have to either add the paths + manually, or place the application and the libraries to the same + directory, for example using the + stage rule. + + + +
+ +
+ Libraries + + Libraries are created using the lib rule, which + follows the common + syntax. For example: + +lib helpers : helpers.cpp : <include>boost : : <include>. ; + + + + In the most common case, the lib creates a library + from the specified sources. Depending on the value of + <link> feature the library will be either static or + shared. There are two other cases. First is when the library is + installed somewhere in compiler's search paths, and should be + searched by the compiler (typically, using the + option). The second case is where the library is available as a + prebuilt file and the full path is known. + + + + + The syntax for these case is given below: + +lib z : : <name>z <search>/home/ghost ; +lib compress : : <file>/opt/libs/compress.a ; + + The name property specifies the name that should be + passed to the option, and the file + property specifies the file location. The search feature + specifies paths in which to search for the library. That feature can + be specified several times, or it can be omitted, in which case only + default compiler paths will be searched. + + + The difference between using the file feature as + opposed to the name feature together with the + search feature is that file is more + precise. A specific file will be used. On the other hand, the + search feature only adds a library path, and the + name feature gives the basic name of the library. The + search rules are specific to the linker. For example, given these + definition: + +lib a : : <variant>release <file>/pool/release/a.so ; +lib a : : <variant>debug <file>/pool/debug/a.so ; +lib b : : <variant>release <file>/pool/release/b.so ; +lib b : : <variant>debug <file>/pool/debug/b.so ; + + It's possible to use release version of a and debug + version of b. Had we used the name and + search features, the linker would always pick either + release or debug versions. + + + + + For convenience, the following syntax is allowed: + +lib z ; +lib gui db aux ; + + and is does exactly the same as: + +lib z : : <name>z ; +lib gui : : <name>gui ; +lib db : : <name>db ; +lib aux : : <name>aux ; + + + + When a library uses another library you should put that other + library in the list of sources. This will do the right thing in all + cases. For portability, you should specify library dependencies even + for searched and prebuilt libraries, othewise, static linking on + Unix won't work. For example: + +lib z ; +lib png : z : <name>png ; + + + + + When a library (say, a), that has another + library, (say, b) + + is linked dynamically, the b + library will be incorporated + + in a. (If b + is dynamic library as well, then a will only refer to + it, and not include any extra code.) + + When the a + library is linked statically, Boost.Build will assure that all + executables that link to a will also link to + b. + + + + One feature of Boost.Build that is very important for libraries + is usage requirements. + + For example, if you write: + +lib helpers : helpers.cpp : : : <include>. ; + + then the compiler include path for all targets that use + helpers will contain the directory + + where the target is defined.path to "helpers.cpp". The user + only needs to add helpers to the list of sources, + and needn't consider the requirements its use imposes on a + dependent target. This feature greatly simplifies Jamfiles. + + + + + If you don't want shared libraries to include all libraries + that are specified in sources (especially statically linked ones), + you'd need to use the following: + +lib b : a.cpp ; +lib a : a.cpp : <use>b : : <library>b ; + + This specifies that a uses b, and causes + all executables that link to a also link to + b. In this case, even for shared linking, the + a library won't even refer to b. + + + +
+ +
+ Alias + + + The alias rule gives alternative name to + a group of targets. For example, to give the name + core to a group of three other targets with the + following code: + +alias core : im reader writer ; + Using core on the command line, or in the source list + of any other target is the same as explicitly using + im, reader, and + writer, but it is just more convenient. + + + + + + Another use of the alias rule is to change build + properties. For example, if you always want static linking for a + specific C++ Boost library, you can write the following: + +alias threads : /boost/thread//boost_thread : <link>static ; + + and use only the threads alias in your Jamfiles. + + + + + You can also specify usage requirements for the + alias target. If you write the following: + +alias header_only_library : : : : <include>/usr/include/header_only_library ; + + then using header_only_library in sources will only add an + include path. Also note that when there are some sources, their usage + requirements are propagated, too. For example: + +lib lib : lib.cpp : : : <include>. ; +alias lib_alias ; +exe main : main.cpp lib_alias ; + + will compile main.cpp with the additional include. + + +
+ +
+ Installing + + For installing a built target you should use the + install rule, which follows the common syntax. For + example: + +install dist : hello helpers ; + + will cause the targets hello and helpers to + be moved to the dist directory, relative to + Jamfile's directory. The directory can + be changed with the location property: + +install dist : hello helpers : <location>/usr/bin ; + + While you can achieve the same effect by changing the target name to + /usr/bin, using the location + property is better, because it allows you to use a mnemonic target + name. + + + The location property is especially handy when the location + is not fixed, but depends on build variant or environment variables: + +install dist : hello helpers : <variant>release:<location>dist/release + <variant>debug:<location>dist/debug ; +install dist2 : hello helpers : <location>$(DIST) ; + + See also conditional + properties and environment variables + + + + Specifying the names of all libraries to install can be boring. The + install allows you to specify only the top-level executable + targets to install, and automatically install all dependencies: + +install dist : hello + : <install-dependencies>on <install-type>EXE + <install-type>LIB + ; + + will find all targets that hello depends on, and install + all of those which are either executables or libraries. More + specifically, for each target, other targets that were specified as + sources or as dependency properties, will be recursively found. One + exception is that targets referred with the use feature + are not considered, because that feature is typically used to refer to + header-only libraries. + If the set of target types is specified, only targets of that type + will be installed, otherwise, all found target will be installed. + + + The alias + rule can be used when targets must be installed into several + directories: + +alias install : install-bin install-lib ; +install install-bin : applications : /usr/bin ; +install install-lib : helper : /usr/lib ; + + + + Because the install rule just copies targets, most + free features see the definition of "free" in . + have no effect when used in requirements of the install rule. + The only two which matter are + + dependency and, on Unix, + dll-path. + + + + + (Unix specific). On Unix, executables built with Boost.Build typically + contain the list of paths to all used dynamic libraries. For + installing, this is not desired, so Boost.Build relinks the executable + with an empty list of paths. You can also specify additional paths for + installed executables with the dll-path feature. + + + + +
+ +
+ + Testing + + Boost.Build has convenient support for running unit tests. The + simplest way is the unit-test rule, which follows the + common syntax. For + example: + +unit-test helpers_test : helpers_test.cpp helpers ; + + + + The unit-test rule behaves like the + exe rule, but after the executable is created it is + run. If the executable returns an error code, the build system will also + return an error and will try running the executable on the next + invocation until it runs successfully. This behaviour ensures that you + can't miss a unit test failure. + + + By default, the executable is run directly. Sometimes, it's + desirable to run the executable using some helper command. You should use the + testing.launcher property to specify the name of the + helper command. For example, if you write: + + +unit-test helpers_test + : helpers_test.cpp helpers + : <testing.launcher>valgrind + ; + + The command used to run the executable will be: + +valgrind bin/$toolset/debug/helpers_test + + + + + There are rules for more elaborate testing: compile, + compile-fail, run and + run-fail. They are more suitable for automated testing, and + are not covered here. + +
+ +
+ + Raw commands: 'make' and 'notfile' + + Sometimes, the builtin target types are not enough, and you + want Boost.Build to just run specific commands. There are two main + target rules that make it possible: make + and notfile. + + + The make rule is used when you want to + create one file from a number of sources using some specific command. + The notfile is used to unconditionally run + a command. + + + + Suppose you want to create file file.out from + file file.in by running command + in2out. Here's how you'd do this in Boost.Build: + +actions in2out +{ + in2out $(<) $(>) +} +make file.out : file.in : @in2out ; + + If you run bjam and file.out + does not exist, Boost.Build will run the in2out + command to create that file. For more details on specifying actions, + see . + + + + + The make rule is useful to express custom + transformation that are used just once or twice in your project. For + transformations that are used often, you are advised to declare + new generator, as described in . + + + + + It could be that you just want to run some command unconditionally, + and that command does not create any specific files. The, you can use + the notfile rule. For example: + +notfile echo_something : @echo ; +actions echo +{ + echo "something" +} + + The only difference from the make rule is + that the name of the target is not considered a name of a file, so + Boost.Build will unconditionally run the action. + + +
+ +
+ Generated headers + + Usually, Boost.Build handles implicit dependendies completely + automatically. For example, for C++ files, all #include + statements are found and handled. The only aspect where user help + might be needed is implicit dependency on generated files. + + By default, Boost.Build handles such dependencies within one + main target. For example, assume that main target "app" has two + sources, "app.cpp" and "parser.y". The latter source is converted + into "parser.c" and "parser.h". Then, if "app.cpp" includes + "parser.h", Boost.Build will detect this dependency. Moreover, + since "parser.h" will be generated into a build directory, the + path to that directory will automatically added to include + path. + + Making this mechanism work across main target boundaries is + possible, but imposes certain overhead. For that reason, if + there's implicit dependency on files from other main targets, the + <implicit-dependency> [ link ] feature must + be used, for example: + + +lib parser : parser.y ; +exe app : app.cpp : <implicit-dependency>parser ; + + + + The above example tells the build system that when scanning + all sources of "app" for implicit-dependencies, it should consider + targets from "parser" as potential dependencies. + +
+ + +
+ Builtin features + + + variant + + + + A feature that combines several low-level features, making + it easy to request common build configurations. + + + Allowed values: debug, release, + profile. + + The value debug expands to + + +<optimization>off <debug-symbols>on <inlining>off <runtime-debugging>on + + + The value release expands to + + +<optimization>speed <debug-symbols>off <inlining>full <runtime-debugging>off + + + The value profile expands to the same as + release, plus: + + +<profiling>on <debug-symbols>on + + + User can define his own build variants using the variant rule from the common + module. + + Notee: Runtime + debugging is on in debug builds to suit the expectations of + people used to various IDEs. + + + + + + link + + + + A feature that controls how libraries are built. + + + Allowed values: shared, + static + + + source + + + + The <source>X feature has the same effect on + building a target as putting X in the list of sources. + It's useful when you want to add + the same source to all targets in the project + (you can put <source> in requirements) or to conditionally + include a source (using conditional requirements, see ) + See also the <library> feature. + + + + + library + + + + This feature is almost equivalent to the <source> feature, + except that it takes effect only for linking. When you want to + link all targets in a Jamfile to certain library, the + <library> feature is preferred over + <source>X -- the latter will add the library to + all targets, even those that have nothing to do with libraries. + + + + + + dependency + + + + Introduces a dependency on the target named by the + value of this feature (so it will be brought + up-to-date whenever the target being declared is). + The dependency is not used in any other way. For example, in + application with plugins, the plugins are not used when linking + the application, + application might have dependency on its plugins, even though + + + , and + adds its usage requirements to the build properties + of the target being declared. + + The primary use case is when you want + the usage requirements (such as #include paths) of some + library to be applied, but don't want to link to it. + + + + + + + + use + + + + Introduces a dependency on the target named by the + value of this feature (so it will be brought + up-to-date whenever the target being declared is), and + adds its usage requirements to the build properties + + of the target being declared. The dependency is not used + in any other way. The primary use case is when you want + the usage requirements (such as #include paths) of some + library to be applied, but don't want to link to it. + + + + + + + dll-path + + + + Specify an additional directory where the system should + look for shared libraries when the executable or shared + library is run. This feature only affects Unix + compilers. Plase see + in for details. + + + + hardcode-dll-paths + + + + Controls automatic generation of dll-path properties. + + + Allowed values: + true, false. This property + is specific to Unix systems. If an executable is built with + <hardcode-dll-paths>true, the generated binary + will contain the list of all the paths to the used shared + libraries. As the result, the executable can be run without + changing system paths to shared libraries or installing the + libraries to system paths. This + + is very convenient during + development. Plase see the FAQ entry for details. + Note that on Mac OSX, the paths are unconditionally hardcoded by + the linker, and it's not possible to disable that behaviour. + + + + + cflags + cxxflags + linkflags + + + + The value of those features is passed without modification to the + corresponding tools. For cflags that's both the C and C++ + compilers, for cxxflags that's the C++ compiler and for + linkflags that's the linker. The features are handy when + you're trying to do something special that cannot be achieved by + higher-level feature in Boost.Build. + + + + + warnings + + + + The <warnings> feature controls the warning level of compilers. It has the following values: + + off - disables all warnings. + on - enables default warning level for the tool. + all - enables all warnings. + + Default value is all. + + + + + warnings-as-errors + + + + The <warnings-as-errors> makes it possible to treat warnings as errors and abort + compilation on a warning. The value on enables this behaviour. The default value is + off. + + + + + build + + + Allowed values: no + + + The build feature is used to conditionally disable build of a target. If <build>no + is in properties when building a target, build of that target is skipped. Combined with conditional requirements this + allows to skip building some target in configurations where the build is known to fail. + + + + + + + + + +
+
+ + + diff --git a/v2/doc/src/userman.xml b/v2/doc/src/userman.xml index f4a9202f1..d57e05653 100644 --- a/v2/doc/src/userman.xml +++ b/v2/doc/src/userman.xml @@ -5,18 +5,20 @@ - Boost.Build v2 User Manual + Boost.Build V2 User Manual + - + + diff --git a/v2/doc/src/v1_vs_v2.xml b/v2/doc/src/v1_vs_v2.xml new file mode 100644 index 000000000..7223175e7 --- /dev/null +++ b/v2/doc/src/v1_vs_v2.xml @@ -0,0 +1,107 @@ + + + + + Differences to Boost.Build V1 + + + While Boost.Build V2 is based on the same ideas as Boost.Build V1, + some of the syntax was changed, and some new important features were + added. This chapter describes most of the changes. + +
+ Configuration + + In V1, toolsets were configured by environment variables. If you + wanted to use two versions of the same toolset, you had to create a new + toolset module that would set the variables and then invoke the base + toolset. In V2, toolsets are configured by the + using, and you can easily configure several + versions of a toolset. See for details. + + +
+ +
+ Writing Jamfiles + + Probably one of the most important differences in V2 Jamfiles is + the use of project requirements. In V1, if several targets had the same + requirements (for example, a common #include path), it was necessary to + manually write the requirements or use a helper rule or template target. In V2, the + common properties can be specified with the requirements project + attribute, as documented in . + + + Usage requirements + also help to simplify Jamfiles. + + If a library requires + all clients to use specific #include paths or macros when compiling + code that depends on the library, that information can be cleanly + represented. + + The difference between lib and dll targets in V1 is completely + eliminated in V2. There's only one library target type, lib, which can create + either static or shared libraries depending on the value of the + <link> + feature. If your target should be only built in one way, you + can add <link>shared or <link>static to its requirements. + + + The syntax for referring to other targets was changed a bit. While + in V1 one would use: + +exe a : a.cpp <lib>../foo/bar ; + + the V2 syntax is: + +exe a : a.cpp ../foo//bar ; + + Note that you don't need to specify the type of other target, but the + last element should be separated from the others by a double slash to indicate that + you're referring to target bar in project ../foo, and not to + project ../foo/bar. + + + +
+ +
+ Build process + + The command line syntax in V2 is completely different. For example + +bjam -sTOOLS=msvc -sBUILD=release some_target + + now becomes: + +bjam toolset=msvc variant=release some_target + + or, using implicit features, just: + +bjam msvc release some_target + + See the reference for a + complete description of the syntax. + + + +
+
+ + + From e7657608f4df466dcba568fe643e475b38de8478 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Sat, 7 Oct 2006 22:05:03 +0000 Subject: [PATCH 76/82] Support the slower order stable sequence.unique with an extra flag argument. [SVN r35522] --- v2/util/sequence.jam | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/v2/util/sequence.jam b/v2/util/sequence.jam index 3e2ca72b5..4b2d4e935 100644 --- a/v2/util/sequence.jam +++ b/v2/util/sequence.jam @@ -149,17 +149,30 @@ rule length ( s * ) return $(result) ; } -rule unique ( list * ) +rule unique ( list * : stable ? ) { local result ; local prev ; - for local i in [ SORT $(list) ] + if $(stable) { - if $(i) != $(prev) + for local f in $(list) { - result += $(i) ; + if ! $(f) in $(result) + { + result += $(f) ; + } + } + } + else + { + for local i in [ SORT $(list) ] + { + if $(i) != $(prev) + { + result += $(i) ; + } + prev = $(i) ; } - prev = $(i) ; } return $(result) ; } From 6a9aac8a793c06d3ae0c234de730e4b7dc827c64 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Mon, 9 Oct 2006 04:26:41 +0000 Subject: [PATCH 77/82] Make the variant and toolset tag logic common. Add generic tag formating rule that can be used from specific tag rules to generate a variety of target names. [SVN r35529] --- v2/tools/common.jam | 143 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/v2/tools/common.jam b/v2/tools/common.jam index 0c42a15d3..5ad6ce235 100644 --- a/v2/tools/common.jam +++ b/v2/tools/common.jam @@ -16,6 +16,7 @@ import errors ; import path ; import sequence ; import toolset ; +import virtual-target ; if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ] { @@ -565,6 +566,148 @@ actions quietly updated piecemeal together RmTemps $(RM) "$(>)" $(IGNORE) } +rule format-name ( format * : name : type ? : property-set ) +{ + if [ type.is-derived $(type) LIB ] + { + local result = "" ; + for local f in $(format) + { + switch $(f:G) + { + case : + result += $(name:B) ; + + case : + result += [ join-tag $(f:G=) : + [ toolset-tag $(name) : $(type) : $(property-set) ] ] ; + + case : + result += [ join-tag $(f:G=) : + [ threading-tag $(name) : $(type) : $(property-set) ] ] ; + + case : + result += [ join-tag $(f:G=) : + [ runtime-tag $(name) : $(type) : $(property-set) ] ] ; + + case : + local key = [ MATCH : $(f:G) ] ; + local version = [ $(property-set).get <$(key)> ] ; + version ?= $(key) ; + version = [ MATCH "^([^.]+)[.]([^.]+)[.]([^.]+)" + : $(version) ] ; + result += [ join-tag $(f:G=) : $(version[1])_$(version[2]) ] ; + + case : + local key = [ MATCH : $(f:G) ] ; + local p = [ $(property-set).get [ MATCH : $(f:G) ] ] ; + if $(p) + { + result += [ join-tag $(f:G=) : $(p) ] ; + } + + case * : + result += $(f:G=) ; + } + } + result = [ virtual-target.add-prefix-and-suffix + $(result:J=) : $(type) : $(property-set) ] ; + return $(result) ; + } +} + +local rule join-tag ( joiner ? : tag ? ) +{ + if ! $(joinder) { joiner = - ; } + return $(joiner)$(tag) ; +} + +local rule toolset-tag ( name : type ? : property-set ) +{ + local tag = ; + + local properties = [ $(property-set).raw ] ; + switch [ $(property-set).get ] + { + case borland* : tag += bcb ; + case como* : tag += como ; + case cw : tag += cw ; + case darwin* : tag += ; + case edg* : tag += edg ; + case gcc* : tag += gcc ; + case intel : + if [ $(property-set).get ] = win + { + tag += iw ; + } + else + { + tag += il ; + } + case kcc* : tag += kcc ; + case kylix* : tag += bck ; + #case metrowerks* : tag += cw ; + #case mingw* : tag += mgw ; + case mipspro* : tag += mp ; + case msvc* : tag += vc ; + case sun* : tag += sw ; + case tru64cxx* : tag += tru ; + case vacpp* : tag += xlc ; + } + local version = [ MATCH "([0123456789]+)[.]([0123456789]*)" + : $(properties) ] ; + # For historical reasons, vc6.0 and vc7.0 use different + # naming. + if $(tag) = vc + { + if $(version[1]) = 6 + { + # Cancel minor version. + version = 6 ; + } + else if $(version[1]) = 7 && $(version[2]) = 0 + { + version = 7 ; + } + } + # On intel, version is not added, because it does not + # matter and it's the version of vc used as backend + # that matters. Ideally, we'd encode the backend + # version but that will break compatibility with + # V1. + if $(tag) = iw + { + version = ; + } + tag += $(version) ; + + return $(tag:J=) ; +} + +local rule threading-tag ( name : type ? : property-set ) +{ + local tag = ; + if multi in $(properties) { tag = mt ; } + + return $(tag:J=) ; +} + +local rule runtime-tag ( name : type ? : property-set ) +{ + local tag = ; + + local properties = [ $(property-set).raw ] ; + if static in $(properties) { tag += s ; } + if on in $(properties) { tag += g ; } + + if debug-python in $(properties) { tag += y ; } + if debug in $(properties) { tag += d ; } + if stlport in $(properties) { tag += p ; } + if hostios in $(properties) { tag += n ; } + + return $(tag:J=) ; +} + rule __test__ ( ) { import assert ; From 0ebd162541bc1e1203dd041281ccd838ec65c1d8 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 10 Oct 2006 07:48:33 +0000 Subject: [PATCH 78/82] Fix for msvc [SVN r35533] --- v2/test/pch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2/test/pch.py b/v2/test/pch.py index b304241f1..87ca0846b 100644 --- a/v2/test/pch.py +++ b/v2/test/pch.py @@ -15,7 +15,7 @@ t.write("Jamroot", """ import pch ; -cpp-pch pch : pch.hpp : msvc:pch.cpp ; +cpp-pch pch : pch.hpp : msvc:pch.cpp . ; exe hello : hello.cpp pch : . ; """) From fe40b02b29b07d1e0d2b89cf6875c73ad461e0c4 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 11 Oct 2006 06:38:22 +0000 Subject: [PATCH 79/82] tools/ * pch.jam: (pch-generator.run): Really fail when not used at top-level. [SVN r35544] --- v2/tools/pch.jam | 1 - 1 file changed, 1 deletion(-) diff --git a/v2/tools/pch.jam b/v2/tools/pch.jam index 4cd41be2f..575cbf568 100644 --- a/v2/tools/pch.jam +++ b/v2/tools/pch.jam @@ -71,7 +71,6 @@ class pch-generator : generator # try to use pch generator to get OBJ from that H, which # is completely wrong. By restricting this generator # only to pch main target, such problem is solved. - return [ property-set.empty ] ; } else { From c3c1e63780fce923005ee074b0665950cefeaed5 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 11 Oct 2006 06:43:12 +0000 Subject: [PATCH 80/82] Fix boost install. Thanks to Tiziano Mueller for the bug report. tools/ * stage.jam (copy-file): Use 'path.root' instead of jam primitives to avoid "." element showing up in path and blowing up 'mkdir'. [SVN r35545] --- v2/tools/stage.jam | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/v2/tools/stage.jam b/v2/tools/stage.jam index e98083e61..cb3806eab 100644 --- a/v2/tools/stage.jam +++ b/v2/tools/stage.jam @@ -286,11 +286,19 @@ rule copy-file ( project name ? : source : properties ) # path. The 'source-root' is already absolute, see the # 'adjust-properties' method above. path = [ path.root $(path) [ path.pwd ] ] ; - - relative = [ path.relative-to $(source-root) $(path) ] ; - targets = [ new file-target $(name:D=$(relative)) exact : [ $(source).type ] + relative = [ path.relative-to $(source-root) $(path) ] ; + # Note: using $(name:D=$(relative)) might be faster + # here, but then we need to explicitly check that + # relative is not ".", otherwise we might get paths like + # + # /boost/. + # + # try to create it, and mkdir will obviously fail. + name = [ path.root $(name:D=) $(relative) ] ; + targets = [ new file-target $(name) exact : [ $(source).type ] : $(project) : $(new-a) ] ; + } else { From 39233c7c9aa51c893279856e8290c0fd744278e0 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Wed, 11 Oct 2006 08:05:31 +0000 Subject: [PATCH 81/82] Document 'install-source-root' feature [SVN r35547] --- v2/doc/src/tasks.xml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/v2/doc/src/tasks.xml b/v2/doc/src/tasks.xml index eaabf6167..d92ec2ebf 100644 --- a/v2/doc/src/tasks.xml +++ b/v2/doc/src/tasks.xml @@ -237,6 +237,11 @@ exe main : main.cpp lib_alias ;
Installing + This section describes various ways to install built target + and arbitrary files. + + Basic install + For installing a built target you should use the install rule, which follows the common syntax. For @@ -267,6 +272,8 @@ install dist2 : hello helpers : <location>$(DIST) ; See also conditional properties and environment variables + + Installing with all dependencies Specifying the names of all libraries to install can be boring. The @@ -290,6 +297,28 @@ install dist : hello will be installed, otherwise, all found target will be installed. + Preserving Directory Hierarchy + + By default, the install rules will stip paths from + it's sources. So, if sources include a/b/c.hpp, + the a/b part will be ignored. To make the + install rule preserve the directory hierarchy you need + to use the install-source-root feature to specify the + root of the hierarchy you are installing. Relative paths from that + root will be preserved. For example, if you write: + + +install headers + : a/b/c.h + : <location>/tmp <install-source-root>a + ; + + + the a file named /tmp/b/c.h will be created. + + + Installing into Several Directories + The alias rule can be used when targets must be installed into several directories: From 806868ce2e41fd4e6e9cf1c82b76aade38d53618 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Hunold?= Date: Thu, 12 Oct 2006 14:13:38 +0000 Subject: [PATCH 82/82] Fix: Remove suffix_version for QtUiTools. [SVN r35575] --- v2/tools/qt4.jam | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/tools/qt4.jam b/v2/tools/qt4.jam index f96459c54..7b3baa4fb 100644 --- a/v2/tools/qt4.jam +++ b/v2/tools/qt4.jam @@ -335,13 +335,13 @@ rule init ( prefix ) # Support for dynamic Widgets (Qt 4.1) lib QtUiTools : QtGui QtXml - : QtUiTools$(suffix_version) release + : QtUiTools release : : # usage-requirements $(.prefix)/include/QtUiTools ; lib QtUiTools : QtGui QtXml - : QtUiTools$(suffix_debug)$(suffix_version) debug + : QtUiTools$(suffix_debug) debug : : # usage-requirements $(.prefix)/include/QtUiTools