From d99a280ef50c69e5e10a73b574d58e88b077984d Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Mon, 2 Apr 2007 00:51:15 +0000 Subject: [PATCH] Support for --with-pydebug builds. python.jam: Support for the specification of "_d" extension suffix. In compute-default-paths, fixed the check for residence in a "PCBuild.*" directory so we can build against Windows Python built in a source distribution. common.jam: Fixed generation of the "y" tag to look for on rather than the whole debug-python build variant. Fixed some grammar and spelling. virtual-target.jam: Added the ability to forego the prepending of "." to a generated-target-suffix by specifying the suffix enclosed in <...> libs/python/build/Jamfile.v2: #define BOOST_DEBUG_PYTHON when on [SVN r37326] --- v2/build/virtual-target.jam | 13 +++- v2/tools/common.jam | 6 +- v2/tools/python.jam | 114 +++++++++++++++++++++++++++--------- 3 files changed, 100 insertions(+), 33 deletions(-) diff --git a/v2/build/virtual-target.jam b/v2/build/virtual-target.jam index 34ca0475f..c05ca5029 100644 --- a/v2/build/virtual-target.jam +++ b/v2/build/virtual-target.jam @@ -476,7 +476,18 @@ class abstract-file-target : virtual-target rule add-prefix-and-suffix ( specified-name : type ? : property-set ) { local suffix = [ type.generated-target-suffix $(type) : $(property-set) ] ; - suffix = .$(suffix) ; + + # Handle suffixes for which no leading dot is desired. Those are + # specified by enclosing them in <...>. Needed by python so it + # can create "_d.so" extensions, for example. + if $(suffix:G) + { + suffix = [ utility.ungrist $(suffix) ] ; + } + else + { + suffix = .$(suffix) ; + } local prefix = [ type.generated-target-prefix $(type) : $(property-set) ] ; diff --git a/v2/tools/common.jam b/v2/tools/common.jam index c350063ac..0ac715791 100644 --- a/v2/tools/common.jam +++ b/v2/tools/common.jam @@ -605,11 +605,11 @@ actions hard-link # :: The abbreviated toolset tag being used to build the target. # [joiner] # :: Indication of a multi-threaded build. -# [joiner] +# [joiner] # :: Collective tag of the build runtime. # [joiner] # :: Short version tag taken from the given "version-feature" -# in the build properties. Or if not present the literal +# in the build properties. Or if not present, the literal # value as the version number. # [joiner] # :: Direct lookup of the given property-name value in the @@ -790,7 +790,7 @@ local rule runtime-tag ( name : type ? : property-set ) if on in $(properties) { tag += g ; } } - if debug-python in $(properties) { tag += y ; } + if on in $(properties) { tag += y ; } if debug in $(properties) { tag += d ; } if stlport in $(properties) { tag += p ; } if hostios in $(properties) { tag += n ; } diff --git a/v2/tools/python.jam b/v2/tools/python.jam index 0771e6a8c..5057625e1 100644 --- a/v2/tools/python.jam +++ b/v2/tools/python.jam @@ -32,6 +32,8 @@ import property ; import sequence ; import path ; import feature ; +import set ; +import builtin ; # Make this module a project project.initialize $(__name__) ; @@ -77,13 +79,24 @@ lib rt ; # 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 +# 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 +# is set). +# # Example usage: # # using python 2.3 ; # using python 2.3 : /usr/local/bin/python ; -# -rule init ( version ? : cmd-or-prefix ? : includes ? : libraries ? - : condition * ) +# +rule init ( version ? : cmd-or-prefix ? : includes ? : libraries ? + : condition * : extension-suffix ? ) { .configured = true ; @@ -97,8 +110,8 @@ rule init ( version ? : cmd-or-prefix ? : includes ? : libraries ? debug-message " user-specified "$(v): \"$($(v))\" ; } } - - configure $(version) : $(cmd-or-prefix) : $(includes) : $(libraries) : $(condition) ; + + configure $(version) : $(cmd-or-prefix) : $(includes) : $(libraries) : $(condition) : $(extension-suffix) ; project.pop-current ; } @@ -494,7 +507,7 @@ local rule compute-default-paths ( # We ask Python itself what the executable path is # in case of intermediate symlinks or shell # scripts. - local executable-dir = $(executable:D) ; + local executable-dir = $(sys.executable:D) ; if [ MATCH ^(PCBuild) : $(executable-dir:D=) ] { @@ -527,6 +540,12 @@ feature.feature python.interpreter : : free ; flags python.capture-output PYTHON : ; +# +# Support for Python configured --with-pydebug +# +feature.feature python-debugging : off on : propagated ; +builtin.variant debug-python : debug : on ; + # Return a list of candidate commands to try when looking for a Python # interpreter. prefix is expected to be a native path. local rule candidate-interpreters ( version ? : prefix ? : target-os ) @@ -623,6 +642,10 @@ local rule declare-libpython-target ( version ? : requirements * ) { local major-minor = [ split-version $(version) ] ; lib-version = $(major-minor:J="") ; + if on in $(requirements) + { + lib-version = $(lib-version)_d ; + } } if ! $(lib-version) @@ -638,8 +661,8 @@ local rule declare-libpython-target ( version ? : requirements * ) } # implementation of init -local rule configure ( - version ? : cmd-or-prefix ? : includes ? : libraries ? : condition * ) +local rule configure ( + version ? : cmd-or-prefix ? : includes ? : libraries ? : condition * : extension-suffix ? ) { local prefix ; local exec-prefix ; @@ -649,7 +672,13 @@ local rule configure ( local target-os = [ feature.get-values target-os : $(condition) ] ; target-os ?= [ feature.defaults target-os ] ; target-os = $(target-os:G=) ; - + + if $(target-os) = windows && on in $(condition) + { + extension-suffix ?= _d ; + } + extension-suffix ?= "" ; + # Normalize and dissect any version number local major-minor ; if $(version) @@ -797,8 +826,6 @@ local rule configure ( target-requirements += $(target-os) ; - local usage-requirements = [ system-library-dependencies $(target-os) ] ; - # See if we can find a framework directory on darwin local framework-directory ; if $(target-os) = darwin @@ -821,15 +848,36 @@ local rule configure ( } } + local dll-path = $(libraries) ; + # Make sure that we can find the Python DLL on windows - local dll-path ; if $(target-os) = windows && $(exec-prefix) { dll-path += $(exec-prefix) ; } - + + # + # prepare usage requirements + # + local usage-requirements = [ system-library-dependencies $(target-os) ] ; usage-requirements += $(includes) $(interpreter-cmd) ; + if on in $(condition) + { + 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. + usage-requirements += _DEBUG ; + } + else + { + usage-requirements += Py_DEBUG ; + } + } + # Register the right suffix for extensions + register-extension-suffix $(extension-suffix) : $(target-requirements) ; + # # Declare the "python" target. This should really be called # python_for_embedding @@ -892,22 +940,30 @@ rule configured ( ) type.register PYTHON_EXTENSION : : SHARED_LIB ; -# We can't simply assign the "dll" or "so" suffix to PYTHON_EXTENSION, -# because then we wouldn't know whether "x.dll" is a python extension -# or an ordinary library. Therefore, we specify only the suffixes used -# for target generation. -type.set-generated-target-suffix PYTHON_EXTENSION : : so ; -type.set-generated-target-suffix PYTHON_EXTENSION : windows : pyd ; -type.set-generated-target-suffix PYTHON_EXTENSION : cygwin : dll ; - -# Prior to python 2.5, HPUX extension modules had a ".sl" extension -type.set-generated-target-suffix PYTHON_EXTENSION : hpux 2.4 : sl ; -type.set-generated-target-suffix PYTHON_EXTENSION : hpux 2.3 : sl ; -type.set-generated-target-suffix PYTHON_EXTENSION : hpux 2.2 : sl ; -type.set-generated-target-suffix PYTHON_EXTENSION : hpux 2.1 : sl ; -type.set-generated-target-suffix PYTHON_EXTENSION : hpux 2.0 : sl ; -type.set-generated-target-suffix PYTHON_EXTENSION : hpux 1.6 : sl ; -type.set-generated-target-suffix PYTHON_EXTENSION : hpux 1.5 : sl ; +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 ; + } + + type.set-generated-target-suffix PYTHON_EXTENSION : $(condition) : <$(root).$(suffix)> ; +} # Unset 'lib' prefix for PYTHON_EXTENSION type.set-generated-target-prefix PYTHON_EXTENSION : : "" ;