|
Boost-Commit : |
From: jurko.gospodnetic_at_[hidden]
Date: 2008-06-02 04:12:48
Author: jurko
Date: 2008-06-02 04:12:47 EDT (Mon, 02 Jun 2008)
New Revision: 46040
URL: http://svn.boost.org/trac/boost/changeset/46040
Log:
Minor stylistic Boost Build Jam script cleanup.
Text files modified:
trunk/tools/build/v2/build/toolset.jam | 8
trunk/tools/build/v2/tools/make.jam | 16
trunk/tools/build/v2/tools/python.jam | 617 ++++++++++++++++++++-------------------
3 files changed, 323 insertions(+), 318 deletions(-)
Modified: trunk/tools/build/v2/build/toolset.jam
==============================================================================
--- trunk/tools/build/v2/build/toolset.jam (original)
+++ trunk/tools/build/v2/build/toolset.jam 2008-06-02 04:12:47 EDT (Mon, 02 Jun 2008)
@@ -135,7 +135,6 @@
}
}
-
if $(condition) && ! $(condition:G=) && ! $(hack-hack)
{
# We have condition in the form '<feature>', that is, without value.
@@ -153,8 +152,7 @@
condition = [ normalize-condition $(condition) ] ;
}
- add-flag $(rule-or-module) : $(variable-name)
- : $(condition) : $(values) ;
+ add-flag $(rule-or-module) : $(variable-name) : $(condition) : $(values) ;
}
@@ -327,8 +325,8 @@
local settings = $(.stv.$(key)) ;
if ! $(settings)
{
- settings = [
- set-target-variables-aux $(rule-or-module) : $(property-set) ] ;
+ settings = [ set-target-variables-aux $(rule-or-module) :
+ $(property-set) ] ;
if ! $(settings)
{
Modified: trunk/tools/build/v2/tools/make.jam
==============================================================================
--- trunk/tools/build/v2/tools/make.jam (original)
+++ trunk/tools/build/v2/tools/make.jam 2008-06-02 04:12:47 EDT (Mon, 02 Jun 2008)
@@ -35,14 +35,14 @@
# 'm' will always be set -- we add '@' ourselves in 'make' rule below.
local m = [ MATCH ^@(.*) : $(action-name) ] ;
- local a = [ new action $(source-targets) : $(m[1])
- : $(property-set) ] ;
+ local a = [ new action $(source-targets) : $(m[1]) : $(property-set) ] ;
local t = [ new file-target $(self.name) exact
- : [ type.type $(self.name) ] : $(self.project) : $(a) ] ;
+ : [ type.type $(self.name) ] : $(self.project) : $(a) ] ;
return [ property-set.empty ] [ virtual-target.register $(t) ] ;
}
}
+
# Declares the 'make' main target.
#
rule make ( target-name : sources * : generating-rule + : requirements *
@@ -60,11 +60,11 @@
requirements += <action>$(generating-rule) ;
targets.main-target-alternative
- [ new make-target-class $(target-name) : $(project)
- : [ 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) ]
+ [ new make-target-class $(target-name) : $(project)
+ : [ 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) ]
] ;
}
Modified: trunk/tools/build/v2/tools/python.jam
==============================================================================
--- trunk/tools/build/v2/tools/python.jam (original)
+++ trunk/tools/build/v2/tools/python.jam 2008-06-02 04:12:47 EDT (Mon, 02 Jun 2008)
@@ -7,11 +7,11 @@
#
# This module defines
#
-# - a project 'python' with a target 'python' in it, that corresponds
-# to the python library
+# - a project 'python' with a target 'python' in it, that corresponds to the
+# python library
#
-# - a main target rule 'python-extension' which can be used
-# to build a python extension.
+# - a main target rule 'python-extension' which can be used to build a python
+# extension.
#
# Extensions that use Boost.Python must explicitly link to it.
@@ -24,7 +24,7 @@
import "class" : new ;
import os ;
import common ;
-import toolset : flags ;
+import toolset ;
import regex ;
import numbers ;
import string ;
@@ -35,20 +35,19 @@
import set ;
import builtin ;
-# Make this module a project
+
+# Make this module a project.
project.initialize $(__name__) ;
project python ;
-# Save the project so that if 'init' is called several
-# times we define new targets in the python project,
-# not in whatever project we were called by.
+# Save the project so that if 'init' is called several times we define new
+# targets in the python project, not in whatever project we were called by.
.project = [ project.current ] ;
-# Dynamic linker lib. Necessary to specify it explicitly
-# on some platforms.
+# Dynamic linker lib. Necessary to specify it explicitly on some platforms.
lib dl ;
-# This contains 'openpty' function need by python. Again, on
-# some system need to pass this to linker explicitly.
+# This contains 'openpty' function need by python. Again, on some system need to
+# pass this to linker explicitly.
lib util ;
# Python uses pthread symbols.
lib pthread ;
@@ -56,44 +55,38 @@
lib rt ;
# The pythonpath feature specifies additional elements for the PYTHONPATH
-# environment variable, set by run-pyd. For example, pythonpath can be used
-# to access Python modules that are part of the product being built, but
-# are not installed in the development system's default paths.
+# environment variable, set by run-pyd. For example, pythonpath can be used to
+# access Python modules that are part of the product being built, but are not
+# installed in the development system's default paths.
feature.feature pythonpath : : free optional path ;
-# Initializes the Python toolset. Note that all parameters are
-# optional.
+# Initializes the Python toolset. Note that all parameters are optional.
+#
+# - version -- the version of Python to use. Should be in Major.Minor format,
+# for example 2.3. Do not include the subminor version.
+#
+# - cmd-or-prefix: Preferably, a command that invokes a Python interpreter.
+# Alternatively, the installation prefix for Python libraries and includes. If
+# empty, will be guessed from the version, the platform's installation
+# patterns, and the python executables that can be found in PATH.
+#
+# - includes: the include path to Python headers. If empty, will be guessed.
+#
+# - libraries: the path to Python library binaries. If empty, will be guessed.
+# On MacOS/Darwin, you can also pass the path of the Python framework.
#
-# - version -- the version of Python to use. Should be in Major.Minor
-# format, for example 2.3. Do not include the subminor version.
+# - condition: if specified, should be a set of properties that are matched
+# against the build configuration when Boost.Build selects a Python
+# configuration to use.
#
-# - cmd-or-prefix: Preferably, a command that invokes a Python
-# interpreter. Alternatively, the installation prefix for Python
-# libraries and includes. If empty, will be guessed from the
-# version, the platform's installation patterns, and the python
-# executables that can be found in PATH.
-#
-# - includes: the include path to Python headers. If empty, will be
-# guessed.
-#
-# - libraries: the path to Python library binaries. If empty, will be
-# guessed. On MacOS/Darwin, you can also pass the path of the
-# Python framework.
-#
-# - condition: if specified, should be a set of properties that are
-# matched against the build configuration when Boost.Build selects a
-# Python configuration to use.
-#
-# - extension-suffix: A string to append to the name of extension
-# modules before the true filename extension. Ordinarily we would
-# just compute this based on the value of the <python-debugging>
-# feature. However ubuntu's python-dbg package uses the windows
-# convention of appending _d to debug-build extension modules. We
-# have no way of detecting ubuntu, or of probing python for the "_d"
-# requirement, and if you configure and build python using
-# --with-pydebug, you'll be using the standard *nix convention.
-# Defaults to "" (or "_d" when targeting windows and
-# <python-debugging> is set).
+# - extension-suffix: A string to append to the name of extension modules before
+# the true filename extension. Ordinarily we would just compute this based on
+# the value of the <python-debugging> feature. However ubuntu's python-dbg
+# package uses the windows convention of appending _d to debug-build extension
+# modules. We have no way of detecting ubuntu, or of probing python for the
+# "_d" requirement, and if you configure and build python using
+# --with-pydebug, you'll be using the standard *nix convention. Defaults to ""
+# (or "_d" when targeting windows and <python-debugging> is set).
#
# Example usage:
#
@@ -119,8 +112,9 @@
project.pop-current ;
}
-# A simpler version of SHELL that grabs stderr as well as stdout, but
-# returns nothing if there's an error.
+# A simpler version of SHELL that grabs stderr as well as stdout, but returns
+# nothing if there's an error.
+#
local rule shell-cmd ( cmd )
{
debug-message running command '$(cmd)" 2>&1"' ;
@@ -135,34 +129,34 @@
}
}
-# Try to identify Cygwin symlinks. Invoking such a file directly as
-# an NT executable from a native Windows build of bjam would be fatal
-# to the bjam process. One /can/ invoke them through sh.exe or
-# bash.exe, if you can prove that those aren't also symlinks ;-)
+
+# Try to identify Cygwin symlinks. Invoking such a file directly as an NT
+# executable from a native Windows build of bjam would be fatal to the bjam
+# process. One /can/ invoke them through sh.exe or bash.exe, if you can prove
+# that those aren't also symlinks ;-)
#
-# If a symlink is found returns non-empty; we try to extract the
-# target of the symlink from the file and return that.
+# If a symlink is found returns non-empty; we try to extract the target of the
+# symlink from the file and return that.
#
# Note: 1. only works on NT 2. path is a native path.
local rule is-cygwin-symlink ( path )
{
local is-symlink = ;
- # Look for a file with the given path having the S attribute set,
- # as cygwin symlinks do. /-C means "do not use thousands
- # separators in file sizes."
+ # Look for a file with the given path having the S attribute set, as cygwin
+ # symlinks do. /-C means "do not use thousands separators in file sizes."
local dir-listing = [ shell-cmd "DIR /-C /A:S "$(path) ] ;
if $(dir-listing)
{
- # escape any special regex characters in the base part of the path
+ # Escape any special regex characters in the base part of the path.
local base-pat = [ regex.escape $(path:D=) : ].[()*+?|\\$^ : \\ ] ;
- # extract the file's size from the directory listing
+ # Extract the file's size from the directory listing.
local size-of-system-file = [ MATCH "([0-9]+) "$(base-pat) : $(dir-listing) : 1 ] ;
- # if the file has a reasonably small size, look for the
- # special symlink identification text
+ # If the file has a reasonably small size, look for the special symlink
+ # identification text.
if $(size-of-system-file) && [ numbers.less $(size-of-system-file) 1000 ]
{
local link = [ SHELL "FIND /OFF \"!<symlink>\" \""$(path)"\" 2>&1" ] ;
@@ -184,7 +178,9 @@
return $(is-symlink) ;
}
-# Append ext to each member of names that does not contain '.'
+
+# Append ext to each member of names that does not contain '.'.
+#
local rule default-extension ( names * : ext * )
{
local result ;
@@ -199,10 +195,11 @@
return $(result) ;
}
-# Tries to determine whether invoking "cmd" would actually attempt to
-# launch a cygwin symlink.
+
+# Tries to determine whether invoking "cmd" would actually attempt to launch a
+# cygwin symlink.
#
-# Note: only works on NT
+# Note: only works on NT.
local rule invokes-cygwin-symlink ( cmd )
{
local dirs = $(cmd:D) ;
@@ -220,6 +217,7 @@
}
}
+
local rule debug-message ( message * )
{
if --debug-configuration in [ modules.peek : ARGV ]
@@ -228,11 +226,12 @@
}
}
+
# Like W32_GETREG, except prepend HKEY_CURRENT_USER\SOFTWARE and
-# HKEY_LOCAL_MACHINE\SOFTWARE to the first argument, returning the
-# first result found. Also accounts for the fact that on 64-bit
-# machines, 32-bit software has its own area, under
-# SOFTWARE\Wow6432node.
+# HKEY_LOCAL_MACHINE\SOFTWARE to the first argument, returning the first result
+# found. Also accounts for the fact that on 64-bit machines, 32-bit software has
+# its own area, under SOFTWARE\Wow6432node.
+#
local rule software-registry-value ( path : data ? )
{
local result ;
@@ -250,6 +249,7 @@
return $(result) ;
}
+
.windows-drive-letter-re = ^([A-Za-z]):[\\/](.*) ;
.cygwin-drive-letter-re = ^/cygdrive/([a-z])/(.*) ;
@@ -257,21 +257,23 @@
.working-drive-letter = [ SUBST $(.working-directory) $(.windows-drive-letter-re) $1 ] ;
.working-drive-letter ?= [ SUBST $(.working-directory) $(.cygwin-drive-letter-re) $1 ] ;
+
local rule windows-to-cygwin-path ( path )
{
- # if path is rooted with a drive letter, rewrite it using the
- # /cygdrive mountpoint
+ # If path is rooted with a drive letter, rewrite it using the /cygdrive
+ # mountpoint.
local p = [ SUBST $(path:T) $(.windows-drive-letter-re) /cygdrive/$1/$2 ] ;
- # else if path is rooted without a drive letter, use the working directory
- p ?= [ SUBST $(path:T) ^/(.*) /cygdrive/$(.working-drive-letter:L)/$2 ] ;
+ # Else if path is rooted without a drive letter, use the working directory.
+ p ?= [ SUBST $(path:T) ^/(.*) /cygdrive/$(.working-drive-letter:L)/$2 ] ;
- # else return the path unchanged
+ # Else return the path unchanged.
return $(p:E=$(path:T)) ;
}
-# :W only works in Cygwin builds of bjam. This one works on NT builds
-# as well.
+
+# :W only works in Cygwin builds of bjam. This one works on NT builds as well.
+#
local rule cygwin-to-windows-path ( path )
{
path = $(path:R="") ; # strip any trailing slash
@@ -289,10 +291,8 @@
while $(head)
{
- local root = [
- software-registry-value "Cygnus Solutions\\Cygwin\\mounts v2\\"$(head)
- : native
- ] ;
+ local root = [ software-registry-value
+ "Cygnus Solutions\\Cygwin\\mounts v2\\"$(head) : native ] ;
if $(root)
{
@@ -314,7 +314,9 @@
return [ regex.replace $(path:R="") / \\ ] ;
}
-# Convert a *nix path to native
+
+# Convert a *nix path to native.
+#
local rule *nix-path-to-native ( path )
{
if [ os.name ] = NT
@@ -324,7 +326,9 @@
return $(path) ;
}
-# Convert an NT path to native
+
+# Convert an NT path to native.
+#
local rule windows-path-to-native ( path )
{
if [ os.name ] = NT
@@ -337,13 +341,15 @@
}
}
-# Return nonempty if path looks like a windows path, i.e. it starts
-# with a drive letter or contains backslashes.
+
+# Return nonempty if path looks like a windows path, i.e. it starts with a drive
+# letter or contains backslashes.
local rule guess-windows-path ( path )
{
return [ SUBST $(path) ($(.windows-drive-letter-re)|.*([\\]).*) $1 ] ;
}
+
local rule path-to-native ( paths * )
{
local result ;
@@ -362,8 +368,9 @@
return $(result) ;
}
-# Validate the version string and extract the major/minor part we care
-# about
+
+# Validate the version string and extract the major/minor part we care about.
+#
local rule split-version ( version )
{
local major-minor = [ MATCH ^([0-9]+)\.([0-9]+)(.*)$ : $(version) : 1 2 3 ] ;
@@ -378,16 +385,18 @@
return $(major-minor[1]) $(major-minor[2]) ;
}
-# Build a list of versions from 3.0 down to 1.5. Because bjam
-# can't enumerate registry sub-keys, we have no way of finding
-# a version with a 2-digit minor version, e.g. 2.10 -- let's
-# hope that never happens.
+
+# Build a list of versions from 3.0 down to 1.5. Because bjam can't enumerate
+# registry sub-keys, we have no way of finding a version with a 2-digit minor
+# version, e.g. 2.10 -- let's hope that never happens.
+#
.version-countdown = ;
for local v in [ numbers.range 15 30 ]
{
.version-countdown = [ SUBST $(v) (.)(.*) $1.$2 ] $(.version-countdown) ;
}
+
local rule windows-installed-pythons ( version ? )
{
version ?= $(.version-countdown) ;
@@ -409,6 +418,7 @@
return $(interpreters) ;
}
+
local rule darwin-installed-pythons ( version ? )
{
version ?= $(.version-countdown) ;
@@ -420,12 +430,14 @@
return $(prefix)/Versions/$(version)/bin/python ;
}
-# Assume "python-cmd" invokes a python interpreter and invoke it to
-# extract all the information we care about from its "sys" module.
-# Returns void if unsuccessful.
+
+# Assume "python-cmd" invokes a python interpreter and invoke it to extract all
+# the information we care about from its "sys" module. Returns void if
+# unsuccessful.
+#
local rule probe ( python-cmd )
{
- # Avoid invoking a Cygwin symlink on NT
+ # Avoid invoking a Cygwin symlink on NT.
local skip-symlink ;
if [ os.name ] = NT
{
@@ -447,13 +459,11 @@
}
else
{
- # Prepare a List of Python format strings and expressions that
- # can be used to print the constants we want from the sys
- # module.
-
- # We don't really want sys.version since that's a complicated
- # string, so get the information from sys.version_info
- # instead.
+ # Prepare a List of Python format strings and expressions that can be
+ # used to print the constants we want from the sys module.
+
+ # We don't really want sys.version since that's a complicated string, so
+ # get the information from sys.version_info instead.
local format = "version=%d.%d" ;
local exprs = "version_info[0]" "version_info[1]" ;
@@ -463,22 +473,21 @@
exprs += $(s) ;
}
- # Invoke Python and ask it for all those values
+ # Invoke Python and ask it for all those values.
local full-cmd =
- $(python-cmd)" -c \"from sys import *; print '"$(format:J=\\n)"' % ("$(exprs:J=,)")\"" ;
+ $(python-cmd)" -c \"from sys import *; print '"$(format:J=\\n)"' % ("$(exprs:J=,)")\"" ;
local output = [ shell-cmd $(full-cmd) ] ;
if $(output)
{
- # Parse the output to get all the results
+ # Parse the output to get all the results.
local nl = "
" ;
for s in $(sys-elements)
{
- # These variables are expected to be declared local in
- # the caller, so Jam's dynamic scoping will set their
- # values there.
+ # These variables are expected to be declared local in the
+ # caller, so Jam's dynamic scoping will set their values there.
sys.$(s) = [ SUBST $(output) \\<$(s)=([^$(nl)]+) $1 ] ;
}
}
@@ -486,30 +495,29 @@
}
}
-# Make sure the "libraries" and "includes" variables (in an enclosing
-# scope) have a value based on the information given.
-local rule compute-default-paths (
- target-os : version ? : prefix ? : exec-prefix ? )
+
+# Make sure the "libraries" and "includes" variables (in an enclosing scope)
+# have a value based on the information given.
+#
+local rule compute-default-paths ( target-os : version ? : prefix ? :
+ exec-prefix ? )
{
exec-prefix ?= $(prefix) ;
if $(target-os) = windows
{
- # The exec_prefix is where you're supposed to look for
- # machine-specific libraries.
+ # The exec_prefix is where you're supposed to look for machine-specific
+ # libraries.
local default-library-path = $(exec-prefix)\\libs ;
local default-include-path = $(:E=Include:R=$(prefix)) ;
- # If the interpreter was found in a directory
- # called "PCBuild" or "PCBuild8," assume we're
- # looking at a Python built from the source
- # distro, and go up one additional level to the
- # default root. Otherwise, the default root is
- # the directory where the interpreter was found.
-
- # We ask Python itself what the executable path is
- # in case of intermediate symlinks or shell
- # scripts.
+ # If the interpreter was found in a directory called "PCBuild" or
+ # "PCBuild8," assume we're looking at a Python built from the source
+ # distro, and go up one additional level to the default root. Otherwise,
+ # the default root is the directory where the interpreter was found.
+
+ # We ask Python itself what the executable path is in case of
+ # intermediate symlinks or shell scripts.
local executable-dir = $(sys.executable:D) ;
if [ MATCH ^(PCBuild) : $(executable-dir:D=) ]
@@ -517,8 +525,7 @@
debug-message "This Python appears to reside in a source distribution;" ;
debug-message "prepending \""$(executable-dir)"\" to default library search path" ;
- default-library-path = $(executable-dir)
- $(default-library-path) ;
+ default-library-path = $(executable-dir) $(default-library-path) ;
default-include-path = $(:E=PC:R=$(executable-dir:D)) $(default-include-path) ;
@@ -537,11 +544,11 @@
}
}
-# The version of the python interpreter to use
+# The version of the python interpreter to use.
feature.feature python : : propagated ;
feature.feature python.interpreter : : free ;
-flags python.capture-output PYTHON : <python.interpreter> ;
+toolset.flags python.capture-output PYTHON : <python.interpreter> ;
#
# Support for Python configured --with-pydebug
@@ -549,79 +556,78 @@
feature.feature python-debugging : off on : propagated ;
builtin.variant debug-python : debug : <python-debugging>on ;
+
# Return a list of candidate commands to try when looking for a Python
-# interpreter. prefix is expected to be a native path.
+# interpreter. prefix is expected to be a native path.
+#
local rule candidate-interpreters ( version ? : prefix ? : target-os )
{
local bin-path = bin ;
if $(target-os) = windows
{
- # on Windows, look in the root directory itself and, to work
- # with the result of a build-from-source, the PCBuild directory
- bin-path = PCBuild8 PCBuild "" ;
+ # On Windows, look in the root directory itself and, to work with the
+ # result of a build-from-source, the PCBuild directory.
+ bin-path = PCBuild8 PCBuild "" ;
}
bin-path = $(bin-path:R=$(prefix)) ;
if $(target-os) in windows darwin
{
- return # Search:
- $(:E=python:R=$(bin-path)) # Relative to the prefix, if any
- python # In the PATH
- [ $(target-os)-installed-pythons $(version) ] # Standard install locations
+ return # Search:
+ $(:E=python:R=$(bin-path)) # Relative to the prefix, if any
+ python # In the PATH
+ [ $(target-os)-installed-pythons $(version) ] # Standard install locations
;
}
else
{
- # Search relative to the prefix, or if none supplied, in PATH
+ # Search relative to the prefix, or if none supplied, in PATH.
local unversioned = $(:E=python:R=$(bin-path:E=)) ;
- # if a version was specified, look for a python with that
- # specific version appended before looking for one called,
- # simply, "python"
+ # If a version was specified, look for a python with that specific
+ # version appended before looking for one called, simply, "python"
return $(unversioned)$(version) $(unversioned) ;
}
}
-# Compute system library dependencies for targets linking with
-# static Python libraries.
+
+# Compute 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 <threading>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.
#
-# 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 <threading>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.
+# Returns a list of usage-requirements that link to the necessary system
+# libraries.
#
-# Returns a list of usage-requirements that link to the necessary
-# system libraries.
local rule system-library-dependencies ( target-os )
{
switch $(target-os)
{
case s[uo][nl]* : # solaris, sun, sunos
- # 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 <threading>multi.
-
- # On solaris 10,
- # distutils.sysconfig.get_config_var('LIBS') yields
- # '-lresolv -lsocket -lnsl -lrt -ldl'. However, that
- # doesn't seem to be the right list for extension modules.
- # For example, on my installation, adding -ldl causes at
- # least one test to fail because the library can't be
- # found and removing it causes no failures.
+ # 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 <threading>multi.
+
+ # On solaris 10, distutils.sysconfig.get_config_var('LIBS') yields
+ # '-lresolv -lsocket -lnsl -lrt -ldl'. However, that doesn't seem to
+ # be the right list for extension modules. For example, on my
+ # installation, adding -ldl causes at least one test to fail because
+ # the library can't be found and removing it causes no failures.
# Apparently, though, we need to add -lrt for gcc.
return <toolset>gcc:<library>rt ;
@@ -640,11 +646,13 @@
}
}
+
# Declare a target to represent Python's library.
+#
local rule declare-libpython-target ( version ? : requirements * )
{
- # Compute the representation of Python version in the name of
- # Python's library file.
+ # Compute the representation of Python version in the name of Python's
+ # library file.
local lib-version = $(version) ;
if <target-os>windows in $(requirements)
{
@@ -664,13 +672,14 @@
ECHO *** warning: to 'using python'. ;
}
- # Declare it
+ # Declare it.
lib python.lib : : <name>python$(lib-version) $(requirements) ;
}
-# implementation of init
-local rule configure (
- version ? : cmd-or-prefix ? : includes * : libraries ? : condition * : extension-suffix ? )
+
+# Implementation of init.
+local rule configure ( version ? : cmd-or-prefix ? : includes * : libraries ? :
+ condition * : extension-suffix ? )
{
local prefix ;
local exec-prefix ;
@@ -687,7 +696,7 @@
}
extension-suffix ?= "" ;
- # Normalize and dissect any version number
+ # Normalize and dissect any version number.
local major-minor ;
if $(version)
{
@@ -699,7 +708,7 @@
if ! $(cmd-or-prefix) || [ GLOB $(cmd-or-prefix) : * ]
{
- # if the user didn't pass a command, whatever we got was a prefix
+ # If the user didn't pass a command, whatever we got was a prefix.
prefix = $(cmd-or-prefix) ;
cmds-to-try = [ candidate-interpreters $(version) : $(prefix) : $(target-os) ] ;
}
@@ -708,9 +717,9 @@
# Work with the command the user gave us.
cmds-to-try = $(cmd-or-prefix) ;
- # On windows, don't nail down the interpreter command just yet
- # in case the user specified something that turns out to be a
- # cygwin symlink, which could bring down bjam if we invoke it.
+ # On windows, don't nail down the interpreter command just yet in case
+ # the user specified something that turns out to be a cygwin symlink,
+ # which could bring down bjam if we invoke it.
if $(target-os) != windows
{
interpreter-cmd = $(cmd-or-prefix) ;
@@ -724,15 +733,15 @@
# Anything left to find or check?
if ! ( $(interpreter-cmd) && $(includes) && $(libraries) )
{
- # Values to be extracted from python's sys module. These will
- # be set by the probe rule, above, using Jam's dynamic scoping.
+ # Values to be extracted from python's sys module. These will be set by
+ # the probe rule, above, using Jam's dynamic scoping.
local sys-elements = version platform prefix exec_prefix executable ;
local sys.$(sys-elements) ;
- # compute the string Python's sys.platform needs to match. If
- # not targeting windows or cygwin we'll assume only native
- # builds can possibly run, so we won't require a match and we
- # leave sys.platform blank.
+ # Compute the string Python's sys.platform needs to match. If not
+ # targeting windows or cygwin we'll assume only native builds can
+ # possibly run, so we won't require a match and we leave sys.platform
+ # blank.
local platform ;
switch $(target-os)
{
@@ -742,7 +751,7 @@
while $(cmds-to-try)
{
- # pop top command
+ # Pop top command.
local cmd = $(cmds-to-try[1]) ;
cmds-to-try = $(cmds-to-try[2-]) ;
@@ -751,7 +760,7 @@
{
fallback-version ?= $(sys.version) ;
- # Check for version/platform validity
+ # Check for version/platform validity.
for local x in version platform
{
if $($(x)) && $($(x)) != $(sys.$(x))
@@ -768,15 +777,12 @@
exec-prefix = $(sys.exec_prefix) ;
- compute-default-paths
- $(target-os)
- : $(sys.version)
- : $(sys.prefix)
- : $(sys.exec_prefix) ;
+ compute-default-paths $(target-os) : $(sys.version) :
+ $(sys.prefix) : $(sys.exec_prefix) ;
version = $(sys.version) ;
interpreter-cmd ?= $(cmd) ;
- cmds-to-try = ; # All done.
+ cmds-to-try = ; # All done.
}
}
else
@@ -822,13 +828,12 @@
debug-message " DLL search path:" \"$(exec-prefix:E=<empty>)\" ;
}
-
#
- # End autoconfiguration sequence
+ # End autoconfiguration sequence.
#
local target-requirements = $(condition) ;
- # Add the version, if any, to the target requirements
+ # Add the version, if any, to the target requirements.
if $(version)
{
if ! $(version) in [ feature.values python ]
@@ -840,11 +845,11 @@
target-requirements += <target-os>$(target-os) ;
- # See if we can find a framework directory on darwin
+ # See if we can find a framework directory on darwin.
local framework-directory ;
if $(target-os) = darwin
{
- # Search upward for the framework directory
+ # Search upward for the framework directory.
local framework-directory = $(libraries[-1]) ;
while $(framework-directory:D=) && $(framework-directory:D=) != Python.framework
{
@@ -864,14 +869,14 @@
local dll-path = $(libraries) ;
- # Make sure that we can find the Python DLL on windows
+ # Make sure that we can find the Python DLL on windows.
if $(target-os) = windows && $(exec-prefix)
{
dll-path += $(exec-prefix) ;
}
#
- # prepare usage requirements
+ # Prepare usage requirements.
#
local usage-requirements = [ system-library-dependencies $(target-os) ] ;
usage-requirements += <include>$(includes) <python.interpreter>$(interpreter-cmd) ;
@@ -879,8 +884,8 @@
{
if $(target-os) = windows
{
- # in pyconfig.h, Py_DEBUG is set if _DEBUG is set. If we
- # define Py_DEBUG we'll get multiple definition warnings.
+ # In pyconfig.h, Py_DEBUG is set if _DEBUG is set. If we define
+ # Py_DEBUG we'll get multiple definition warnings.
usage-requirements += <define>_DEBUG ;
}
else
@@ -888,7 +893,7 @@
usage-requirements += <define>Py_DEBUG ;
}
}
-
+
# Global, but conditional, requirements to give access to the interpreter
# for general utilities, like other toolsets, that run Python scripts.
toolset.add-requirements
@@ -899,7 +904,7 @@
#
# Declare the "python" target. This should really be called
- # python_for_embedding
+ # python_for_embedding.
#
if $(framework-directory)
@@ -915,113 +920,115 @@
{
declare-libpython-target $(version) : $(target-requirements) ;
- # This is an evil hack. On, Windows, when Python is embedded,
- # nothing seems to set up sys.path to include Python's
- # standard library
- # (http://article.gmane.org/gmane.comp.python.general/544986). The
- # evil here, aside from the workaround necessitated by
- # Python's bug, is that:
+ # This is an evil hack. On, Windows, when Python is embedded, nothing
+ # seems to set up sys.path to include Python's standard library
+ # (http://article.gmane.org/gmane.comp.python.general/544986). The evil
+ # here, aside from the workaround necessitated by Python's bug, is that:
#
- # a. we're guessing the location of the python standard
- # library from the location of pythonXX.lib
+ # a. we're guessing the location of the python standard library from the
+ # location of pythonXX.lib
#
- # b. we're hijacking the <testing.launcher> property to get
- # the environment variable set up, and the user may want to
- # use it for something else (e.g. launch the debugger).
+ # b. we're hijacking the <testing.launcher> property to get the
+ # environment variable set up, and the user may want to use it for
+ # something else (e.g. launch the debugger).
local set-PYTHONPATH ;
if $(target-os) = windows
{
- set-PYTHONPATH =
- [ common.prepend-path-variable-command PYTHONPATH : $(libraries:D)/Lib ] ;
+ set-PYTHONPATH = [ common.prepend-path-variable-command PYTHONPATH :
+ $(libraries:D)/Lib ] ;
}
alias python
:
: $(target-requirements)
:
- # why python.lib must be listed here instead of along with
- # the system libs is a mystery, but if we don't do it, on
- # cygwin, -lpythonX.Y never appears in the command line
- # (although it does on linux).
+ # Why python.lib must be listed here instead of along with the
+ # system libs is a mystery, but if we don't do it, on cygwin,
+ # -lpythonX.Y never appears in the command line (although it does on
+ # linux).
: $(usage-requirements)
<testing.launcher>$(set-PYTHONPATH)
<library-path>$(libraries) <dll-path>$(dll-path) <library>python.lib
;
}
- # 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 for embedding
+ # 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 for embedding.
#
# 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.
+ # 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.
if $(target-os) in windows cygwin darwin
{
alias python_for_extensions : python : $(target-requirements) ;
}
- # On AIX we need Python extensions and Boost.Python to import symbols
- # from the Python interpreter. Dynamic libraries opened with dlopen()
- # do not inherit the symbols from the Python interpreter.
+ # On AIX we need Python extensions and Boost.Python to import symbols from
+ # the Python interpreter. Dynamic libraries opened with dlopen() do not
+ # inherit the symbols from the Python interpreter.
else if $(target-os) = aix
{
alias python_for_extensions
- :
- : $(target-requirements)
- :
- : $(usage-requirements) <linkflags>-Wl,-bI:$(libraries[1])/python.exp
- ;
+ :
+ : $(target-requirements)
+ :
+ : $(usage-requirements) <linkflags>-Wl,-bI:$(libraries[1])/python.exp
+ ;
}
else
{
alias python_for_extensions
- :
- : $(target-requirements)
- :
- : $(usage-requirements)
- ;
+ :
+ : $(target-requirements)
+ :
+ : $(usage-requirements)
+ ;
}
}
+
rule configured ( )
{
return $(.configured) ;
}
+
type.register PYTHON_EXTENSION : : SHARED_LIB ;
+
local rule register-extension-suffix ( root : condition * )
{
local suffix ;
switch [ feature.get-values target-os : $(condition) ]
{
- case windows : suffix = pyd ;
- case cygwin : suffix = dll ;
- case hpux :
- {
- if [ feature.get-values python : $(condition) ] in 1.5 1.6 2.0 2.1 2.2 2.3 2.4
- {
- suffix = sl ;
- }
- else
- {
- suffix = so ;
- }
- }
- case * : suffix = so ;
+ case windows : suffix = pyd ;
+ case cygwin : suffix = dll ;
+ case hpux :
+ {
+ if [ feature.get-values python : $(condition) ] in 1.5 1.6 2.0 2.1 2.2 2.3 2.4
+ {
+ suffix = sl ;
+ }
+ else
+ {
+ suffix = so ;
+ }
+ }
+ case * : suffix = so ;
}
type.set-generated-target-suffix PYTHON_EXTENSION : $(condition) : <$(root).$(suffix)> ;
}
+
# Unset 'lib' prefix for PYTHON_EXTENSION
type.set-generated-target-prefix PYTHON_EXTENSION : : "" ;
+
rule python-extension ( name : sources * : requirements * : default-build * :
usage-requirements * )
{
@@ -1044,7 +1051,7 @@
IMPORT python : python-extension : : python-extension ;
-# Support for testing
+# Support for testing.
type.register PY : py ;
type.register RUN_PYD_OUTPUT ;
type.register RUN_PYD : : TEST ;
@@ -1113,38 +1120,38 @@
local extension = [ generators.construct $(project) $(name) :
PYTHON_EXTENSION : $(property-set) : $(s) $(libs) ] ;
- # The important part of usage requirements returned
- # from PYTHON_EXTENSION generator are xdll-path
- # properties that will allow us to find the python
- # extension at runtime.
+ # The important part of usage requirements returned from
+ # PYTHON_EXTENSION generator are xdll-path properties that will
+ # allow us to find the python extension at runtime.
property-set = [ $(property-set).add $(extension[1]) ] ;
- # Ignore usage requirements. We're a top-level
- # generator and nobody is going to use what we
- # generate.
+ # Ignore usage requirements. We're a top-level generator and
+ # nobody is going to use what we generate.
new-sources += $(extension[2-]) ;
}
}
property-set = [ $(property-set).add-raw <dependency>$(other-pythons) ] ;
- result = [ construct-result $(python) $(extensions) $(new-sources)
- : $(project) $(name) : $(property-set) ] ;
+ result = [ construct-result $(python) $(extensions) $(new-sources) :
+ $(project) $(name) : $(property-set) ] ;
}
}
+
generators.register
[ new python-test-generator python.capture-output : : RUN_PYD_OUTPUT ] ;
generators.register-standard testing.expect-success
: RUN_PYD_OUTPUT : RUN_PYD ;
-# There are two different ways of spelling OS names. One is used for
-# [ os.name ] and the other is used for the <host-os> and <target-os>
-# properties. Until that is remedied, this sets up a crude mapping
-# from the latter to the former, that will work *for the purposes of
-# cygwin/NT cross-builds only*. Couldn't think of a better name than
-# "translate"
+
+# There are two different ways of spelling OS names. One is used for [ os.name ]
+# and the other is used for the <host-os> and <target-os> properties. Until that
+# is remedied, this sets up a crude mapping from the latter to the former, that
+# will work *for the purposes of cygwin/NT cross-builds only*. Couldn't think of
+# a better name than "translate".
+#
.translate-os-windows = NT ;
.translate-os-cygwin = CYGWIN ;
local rule translate-os ( src-os )
@@ -1153,55 +1160,56 @@
return $(x[1]) ;
}
+
# Extract the path to a single ".pyd" source. This is used to build the
# PYTHONPATH for running bpl tests.
+#
local rule pyd-pythonpath ( source )
{
return [ on $(source) return $(LOCATE) $(SEARCH) ] ;
}
-# The flag settings on testing.capture-output do not
-# apply to python.capture output at the moment.
-# Redo this explicitly.
+
+# The flag settings on testing.capture-output do not apply to python.capture
+# output at the moment. Redo this explicitly.
toolset.flags python.capture-output ARGS <testing.arg> ;
+
+
rule capture-output ( target : sources * : properties * )
{
- # Setup up proper DLL search path.
- # Here, $(sources[1]) is python module and $(sources[2]) is
- # DLL. Only $(sources[1]) is passed to testing.capture-output,
- # so RUN_PATH variable on $(sources[2]) is not consulted. Move it
- # over explicitly.
+ # Setup up proper DLL search path. Here, $(sources[1]) is python module and
+ # $(sources[2]) is DLL. Only $(sources[1]) is passed to
+ # testing.capture-output, so RUN_PATH variable on $(sources[2]) is not
+ # consulted. Move it over explicitly.
RUN_PATH on $(sources[1]) = [ on $(sources[2-]) return $(RUN_PATH) ] ;
PYTHONPATH = [ sequence.transform pyd-pythonpath : $(sources[2-]) ] ;
PYTHONPATH += [ feature.get-values pythonpath : $(properties) ] ;
-
- # After test is run, we remove the Python module, but not the Python
- # script.
- testing.capture-output $(target) : $(sources[1]) : $(properties)
- : $(sources[2-]) ;
-
- # PYTHONPATH is different; it will be interpreted by whichever
- # Python is invoked and so must follow path rules for the target
- # os. The only OSes where we can run pythons for other OSes
- # currently are NT and CYGWIN, so we only need to handle those
- # cases.
+
+ # After test is run, we remove the Python module, but not the Python script.
+ testing.capture-output $(target) : $(sources[1]) : $(properties) :
+ $(sources[2-]) ;
+
+ # PYTHONPATH is different; it will be interpreted by whichever Python is
+ # invoked and so must follow path rules for the target os. The only OSes
+ # where we can run pythons for other OSes currently are NT and CYGWIN, so we
+ # only need to handle those cases.
local target-os = [ feature.get-values target-os : $(properties) ] ;
- # oddly, host-os isn't in properties, so grab the default value.
+ # Oddly, host-os isn't in properties, so grab the default value.
local host-os = [ feature.defaults host-os ] ;
host-os = $(host-os:G=) ;
if $(target-os) != $(host-os)
{
- PYTHONPATH =
- [ sequence.transform $(host-os)-to-$(target-os)-path : $(PYTHONPATH) ] ;
+ PYTHONPATH = [ sequence.transform $(host-os)-to-$(target-os)-path :
+ $(PYTHONPATH) ] ;
}
- local path-separator =
- [ os.path-separator [ translate-os $(target-os) ] ] ;
- local set-PYTHONPATH =
- [ common.variable-setting-command PYTHONPATH : $(PYTHONPATH:J=$(path-separator)) ] ;
+ local path-separator = [ os.path-separator [ translate-os $(target-os) ] ] ;
+ local set-PYTHONPATH = [ common.variable-setting-command PYTHONPATH :
+ $(PYTHONPATH:J=$(path-separator)) ] ;
LAUNCHER on $(target) = $(set-PYTHONPATH) [ on $(target) return $(PYTHON) ] ;
}
+
rule bpl-test ( name : sources * : requirements * )
{
sources ?= $(name).py $(name).cpp ;
@@ -1210,6 +1218,5 @@
: $(requirements) : $(name) ] ;
}
-IMPORT $(__name__) : bpl-test : : bpl-test ;
-
+IMPORT $(__name__) : bpl-test : : bpl-test ;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk