From 9e7e197da035c122f556ca024f5602ba77d0d407 Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sun, 16 Dec 2001 17:52:31 +0000 Subject: [PATCH] tools/build/boost-base.jam * Handle different spellings of the PATH environment variable for Windows * Ungristed elements of a target's requirements are now treated as rules which transform the target's property set. The rules must have the following signature: transform-properties ( toolset variant : properties * ) and should return the new property set. * Added target name adjustment feature for Python debugging targets. tools/build/borland-tools.jam tools/build/gcc-tools.jam tools/build/intel-linux.jam tools/build/metrowerks-tools.jam tools/build/msvc-tools.jam tools/build/mingw-tools.jam * Adjustments to better support Python targets tools/build/python.jam * Lots of adjustments for building / testing Python targets: PYTHON_LAUNCH variable prefixes Python executable name -- can be used to invoke debugger. PYTHON_ARGS variable postfixes Python executable name CYGWIN_ROOT variable can be used to specify root of cygwin installation [SVN r12071] --- boost-base.jam | 45 ++++++++++++++++------ borland-tools.jam | 6 +-- gcc-tools.jam | 4 +- intel-linux-tools.jam | 2 +- metrowerks-tools.jam | 5 ++- msvc-tools.jam | 2 +- python.jam | 80 +++++++++++++++++++++++----------------- v1/boost-base.jam | 45 ++++++++++++++++------ v1/borland-tools.jam | 6 +-- v1/gcc-tools.jam | 4 +- v1/intel-linux-tools.jam | 2 +- v1/metrowerks-tools.jam | 5 ++- v1/msvc-tools.jam | 2 +- v1/python.jam | 80 +++++++++++++++++++++++----------------- 14 files changed, 180 insertions(+), 108 deletions(-) diff --git a/boost-base.jam b/boost-base.jam index d20ca5d76..e99530db3 100644 --- a/boost-base.jam +++ b/boost-base.jam @@ -100,7 +100,7 @@ rule executable-file main-from-objects $(<) : [ Objects $(>) ] : EXE ; } -rule dll-files +rule dll-files ( module implib ? : sources * : target-type ? ) { type-DEPENDS dll : $(<) ; @@ -110,7 +110,8 @@ rule dll-files INCLUDES $(<[1]) : $(<[2-]) ; INCLUDES $(<[2-]) : $(<[1]) ; } - main-from-objects $(<) : [ Objects $(>) ] : DLL ; + target-type ?= DLL ; + main-from-objects $(<) : [ Objects $(>) ] : $(target-type) ; } # main-from-objects exe-target : obj-target... : ("EXE"|"DLL") @@ -156,6 +157,14 @@ rule Link-DLL # This also allows the user to customize the base path for running built # products from the command-line RUN_PATH ?= $(PATH) ; +if $(NT) +{ + # Try some other likely spellings + RUN_PATH ?= $(Path) ; + RUN_PATH ?= $(path) ; +} +# Now set this, just in case someone tries to use it. +PATH = $(RUN_PATH) ; # A simple action to run an executable target actions Run @@ -1071,10 +1080,10 @@ rule is-link-compatible } # find-compatible-subvariant main-target : toolset variant : dependent-simple-properties -rule find-compatible-subvariant +rule find-compatible-subvariant ( main-target : toolset variant : dependent-simple-properties * ) { - local requirements = [ select-properties $(>) - : $(gTARGET_REQUIREMENTS($(<))) ] ; + local requirements = [ select-properties $(toolset) $(variant) + : $(gTARGET_REQUIREMENTS($(main-target))) ] ; local free-properties = [ segregate-free-properties requirements ] ; @@ -1083,7 +1092,7 @@ rule find-compatible-subvariant # add properties from build-request, checking for compatibility local p ; - for p in [ difference $(3) : $(requirements) ] + for p in [ difference $(dependent-simple-properties) : $(requirements) ] { local f = $(p:G) ; if $(f) in $(requirements:G) @@ -1093,7 +1102,7 @@ rule find-compatible-subvariant if ! [ is-link-compatible $(f) : $(required-value) : $(p:G=) ] { - EXIT $(<): required property $(f)$(required-value) + EXIT $(main-target): required property $(f)$(required-value) incompatible with requested $(p) ; } } @@ -1103,17 +1112,25 @@ rule find-compatible-subvariant } } - local base-properties = $(gBASE_PROPERTIES($(>[1]),$(>[2]))) ; + local base-properties = $(gBASE_PROPERTIES($(toolset),$(variant))) ; segregate-overrides override-properties : base-properties ; + local all-properties = $(base-properties) $(free-properties) ; + + local rules = [ select-ungristed $(gTARGET_REQUIREMENTS($(<))) ] ; + for local r in $(rules) + { + all-properties = [ $(r) $(toolset) $(variant) : $(all-properties) ] ; + } + # build the path identifying the subvariant local subvariant-id - = [ join $(>) # toolset variant + = [ join $(toolset) $(variant) [ ungrist-properties [ sort $(override-properties) ] ] : $(SLASH) ] ; return $(subvariant-id) - [ fixup-path-properties $(base-properties) $(free-properties) ] + [ fixup-path-properties $(all-properties) ] $(override-properties) ; } @@ -1226,7 +1243,7 @@ rule depend-on-libraries # To run these targets, we need everything needed to run the libraries for local dir in $(gRUN_PATH($(>))) { - if ! $(dir) in $(gRUN_PATH($(<))) + if ! ( $(dir) in $(gRUN_PATH($(<))) ) { gRUN_PATH($(<)) += $(dir) ; } @@ -1267,6 +1284,10 @@ rule subvariant-target = [ join-path $(LOCATE_TARGET) $(BIN_DIRECTORY) $(<:G=) $(>[1]) ] ; local target-files = [ FAppendSuffix $(subvariant) : $(SUF$(target-type)) ] ; + if $(gNAME_ADJUST($(target-type))) + { + target-files = [ $(gNAME_ADJUST($(target-type))) $(target-files) : $(2) : $(3) ] ; + } gTARGET_FILES($(subvariant)) = $(target-files) ; gTARGET_FILES($(<)) += $(target-files) ; @@ -1360,6 +1381,8 @@ rule main-target } } +SHARED_TYPES = DLL ; + gGENERATOR_FUNCTION(EXE) = executable-file ; # exe target : sources : requirements : local-build # diff --git a/borland-tools.jam b/borland-tools.jam index d76ed9e19..62f53397d 100644 --- a/borland-tools.jam +++ b/borland-tools.jam @@ -33,12 +33,12 @@ flags borland CFLAGS full : -vi -w-inl ; local flag-vars = USER-INTERFACE TARGET-TYPE THREADING RUNTIME-LINK ; local $(flag-vars) ; - if [ get-values : $(gBUILD_PROPERTIES) ] != DLL + if ! [ get-values : $(gBUILD_PROPERTIES) ] in $(SHARED_TYPES) { flags borland USER-INTERFACE console : -tWC ; } - flags borland TARGET-TYPE DLL : -tWD ; + flags borland TARGET-TYPE $(SHARED_TYPES) : -tWD ; flags borland THREADING multi : -tWM ; flags borland RUNTIME-LINK dynamic : -tWR ; @@ -78,7 +78,7 @@ rule Link-action with-command-file borland-Link-action $(<) : $(>) $(NEEDLIBS) ; - if $(3) = DLL + if $(3) in $(SHARED_TYPES) { borland-IMPLIB-action $(<) : $(>) ; } diff --git a/gcc-tools.jam b/gcc-tools.jam index 5db20e56f..8cf88866d 100644 --- a/gcc-tools.jam +++ b/gcc-tools.jam @@ -52,11 +52,11 @@ if ! $(NT) # The compiler complains about -fPIC on NT if $(BETOOLS) { - flags gcc LINKFLAGS DLL : -nostart ; + flags gcc LINKFLAGS DLL PYD : -nostart ; } else { - flags gcc LINKFLAGS DLL : -shared ; + flags gcc LINKFLAGS DLL PYD : -shared ; } flags gcc LIBPATH ; diff --git a/intel-linux-tools.jam b/intel-linux-tools.jam index 34a86f3bc..1b6576a99 100644 --- a/intel-linux-tools.jam +++ b/intel-linux-tools.jam @@ -43,7 +43,7 @@ flags intel-linux CFLAGS true : -KPIC ; flags intel-linux LINKFLAGS true : -KPIC ; # dynamic link library -flags intel-linux LINKFLAGS DLL : -shared ; +flags intel-linux LINKFLAGS $(SHARED_TYPES) : -shared ; # library linking flags intel-linux LINKFLAGS static : -static ; diff --git a/metrowerks-tools.jam b/metrowerks-tools.jam index 8f1245904..62101af91 100644 --- a/metrowerks-tools.jam +++ b/metrowerks-tools.jam @@ -28,7 +28,7 @@ flags metrowerks HDRS ; flags metrowerks CFLAGS on : -g ; flags metrowerks LINKFLAGS on : -g ; -flags metrowerks LINKFLAGS DLL : -shared ; +flags metrowerks LINKFLAGS $(SHARED_TYPES) : -shared ; flags metrowerks CFLAGS off : -O0 ; flags metrowerks CFLAGS speed : -opt full ; flags metrowerks CFLAGS space : -O4,s intrinsics ; @@ -75,7 +75,8 @@ rule Link-action gRUN_PATH($(<)) += $(METROWERKS_ROOT)"\\Win32-X86 Support\\Libraries\\Runtime" ; IMPLIB_COMMAND on $(<) = "-implib " ; # will be "multiplied away" if not # needed. - with-command-file metrowerks-Link-action $(<) : $(>) $(NEEDLIBS) ; + with-command-file metrowerks-Link-action $(<) : $(>) $(NEEDLIBS) # $(NEEDLIBS) + ; } # Here we set the environment variable MWWinx86LibraryFiles (customize for other diff --git a/msvc-tools.jam b/msvc-tools.jam index eefcefd70..d62721323 100644 --- a/msvc-tools.jam +++ b/msvc-tools.jam @@ -57,7 +57,7 @@ flags msvc STDLIBPATH : $(MSVCDir)$(SLASH)lib ; flags msvc LIBPATH ; flags msvc NEEDLIBS ; flags msvc FINDLIBS ; -flags msvc LINKFLAGS DLL : /DLL ; +flags msvc LINKFLAGS $(SHARED_TYPES) : /DLL ; #### Link #### diff --git a/python.jam b/python.jam index 13ce1129c..e9830defc 100644 --- a/python.jam +++ b/python.jam @@ -18,6 +18,8 @@ PYTHON_VERSION_NODOT = [ SUBST $(PYTHON_VERSION) ([0-9]*)\.([0-9]*) $1$2 ] ; +local RUN_PATH = $(RUN_PATH) ; + if $(NT) { PYTHON_ROOT ?= c:/tools/python ; @@ -57,11 +59,11 @@ else if $(UNIX) # Locate the python executable PYTHON ?= python$(SUFEXE) ; -SEARCH on $(PYTHON) = $(PATH) ; +SEARCH on $(PYTHON) = $(RUN_PATH) ; # And the debugging version PYTHON_D ?= $(PYTHON:S=)_d$(PYTHON:S) ; -SEARCH on $(PYTHON_D) = $(PATH) ; +SEARCH on $(PYTHON_D) = $(RUN_PATH) ; # select-python-library # @@ -99,7 +101,8 @@ PYTHON_PROPERTIES += <*>python$(PYTHON_VERSION).dll <*>/usr/local/lib/python$(PYTHON_VERSION)/config - <*>/usr/include/python$(PYTHON_VERSION) + <*>/usr/local/include/python$(PYTHON_VERSION) + <*>/usr/include/python$(PYTHON_VERSION) $(BOOST_ROOT) select-python-library # These two compilers pick up implicit directions from #pragmas @@ -130,46 +133,55 @@ rule python-files ( module implib ? : sources * ) { local actual-module = $(module) ; - if BOOST_DEBUG_PYTHON in $(gBUILD_PROPERTIES) - { - # build the actual module name - actual-module = $(module:S=)_d$(module:S) ; - - # be sure not to create a dependency loop - if $(actual-module) != $(module) - { - # now the original module name is just a fake target - NOTFILE $(module) ; - DEPENDS $(module) : $(actual-module) ; - set-target-variables $(actual-module) ; - } - } - - dll-files $(actual-module) $(implib) : $(sources) ; + dll-files $(actual-module) $(implib) : $(sources) : PYD ; if $(NT) && ( $(gCURRENT_TOOLSET) = gcc ) { add-cygwin-python-run-path $(<[-1]) ; } - - gRUN_PATH($(module:S=)) = $(gRUN_PATH($(module))) ; } +if $(NT) +{ + # Adjust the name of Python modules so that they have the _d + # suffix when compiled with python debugging enabled. + gNAME_ADJUST(PYD) = name-adjust-PYD ; + + rule name-adjust-PYD ( pyd implib ? : properties * : toolset variant ) + { + if BOOST_DEBUG_PYTHON in $(properties) + { + pyd = $(pyd:S=)_d$(pyd:S) ; + } + return $(pyd) $(implib) ; + } +} + +rule Link-PYD +{ + if $(<[2]) + { + MODE on $(<[2]) = $(IMPMODE) ; + Chmod $(<[2]) ; + } + + gRUN_PATH($(<)) += $(gLOCATE($(<[1]))) ; + Link-action $(<) : $(>) : PYD ; +} + +declare-target-type PYD : true ; +gGENERATOR_FUNCTION(PYD) = python-files ; +SUFPYD = .pyd $(SUFDLL[2-]) ; +PYDMODE = $(DLLMODE) ; +SHARED_TYPES += PYD ; + # Declare a python extension. rule extension ( name : sources + : requirements * : default-BUILD * ) { requirements += $(PYTHON_PROPERTIES) ; - # Temporarily hijack the generator function for DLLs to handle - # some python extension-specific things. - local gGENERATOR_FUNCTION(DLL) = python-files ; - local SUFDLL = .pyd $(SUFDLL[2-]) ; - - dll $(name) : - $(sources) - : $(requirements) - : $(default-BUILD) - ; + + declare-local-target $(name) : $(sources) : $(requirements) : $(default-BUILD) : PYD ; } # boost-python-runtest target : python-script sources : requirements : local-build : args @@ -219,7 +231,7 @@ actions python-test-target bind PYTHON $(SHELL_EXPORT)PATH $(SHELL_SET)PYTHONPATH=$(PYTHONPATH) $(SHELL_EXPORT)PYTHONPATH - $(PYTHON) "$(>)" $(ARGS) > "$(<)" + $(PYTHON_LAUNCH) $(PYTHON) $(PYTHON_ARGS) "$(>)" $(ARGS) > "$(<)" } SUFPYTHON_RUNTEST = .run ; @@ -236,7 +248,7 @@ actions python-runtest-target bind PYTHON $(SHELL_EXPORT)PATH $(SHELL_SET)PYTHONPATH=$(PYTHONPATH) $(SHELL_EXPORT)PYTHONPATH - $(PYTHON) "$(>)" $(ARGS) + $(PYTHON_LAUNCH) $(PYTHON) $(PYTHON_ARGS) "$(>)" $(ARGS) } # This is the rule that actually causes the test to run. It is used by @@ -262,7 +274,7 @@ rule python-runtest-aux ( target : sources + ) if $(NT) && ( $(gCURRENT_TOOLSET) = gcc ) { python = python$(PYTHON_VERSION)$(SUFEXE) ; - SEARCH on $(python) = $(CYGWIN_ROOT)/usr/local/bin ; + SEARCH on $(python) = $(RUN_PATH) $(CYGWIN_ROOT)/usr/local/bin ; # Fix up path splitter for cygwin. splitpath = ":" ; } diff --git a/v1/boost-base.jam b/v1/boost-base.jam index d20ca5d76..e99530db3 100644 --- a/v1/boost-base.jam +++ b/v1/boost-base.jam @@ -100,7 +100,7 @@ rule executable-file main-from-objects $(<) : [ Objects $(>) ] : EXE ; } -rule dll-files +rule dll-files ( module implib ? : sources * : target-type ? ) { type-DEPENDS dll : $(<) ; @@ -110,7 +110,8 @@ rule dll-files INCLUDES $(<[1]) : $(<[2-]) ; INCLUDES $(<[2-]) : $(<[1]) ; } - main-from-objects $(<) : [ Objects $(>) ] : DLL ; + target-type ?= DLL ; + main-from-objects $(<) : [ Objects $(>) ] : $(target-type) ; } # main-from-objects exe-target : obj-target... : ("EXE"|"DLL") @@ -156,6 +157,14 @@ rule Link-DLL # This also allows the user to customize the base path for running built # products from the command-line RUN_PATH ?= $(PATH) ; +if $(NT) +{ + # Try some other likely spellings + RUN_PATH ?= $(Path) ; + RUN_PATH ?= $(path) ; +} +# Now set this, just in case someone tries to use it. +PATH = $(RUN_PATH) ; # A simple action to run an executable target actions Run @@ -1071,10 +1080,10 @@ rule is-link-compatible } # find-compatible-subvariant main-target : toolset variant : dependent-simple-properties -rule find-compatible-subvariant +rule find-compatible-subvariant ( main-target : toolset variant : dependent-simple-properties * ) { - local requirements = [ select-properties $(>) - : $(gTARGET_REQUIREMENTS($(<))) ] ; + local requirements = [ select-properties $(toolset) $(variant) + : $(gTARGET_REQUIREMENTS($(main-target))) ] ; local free-properties = [ segregate-free-properties requirements ] ; @@ -1083,7 +1092,7 @@ rule find-compatible-subvariant # add properties from build-request, checking for compatibility local p ; - for p in [ difference $(3) : $(requirements) ] + for p in [ difference $(dependent-simple-properties) : $(requirements) ] { local f = $(p:G) ; if $(f) in $(requirements:G) @@ -1093,7 +1102,7 @@ rule find-compatible-subvariant if ! [ is-link-compatible $(f) : $(required-value) : $(p:G=) ] { - EXIT $(<): required property $(f)$(required-value) + EXIT $(main-target): required property $(f)$(required-value) incompatible with requested $(p) ; } } @@ -1103,17 +1112,25 @@ rule find-compatible-subvariant } } - local base-properties = $(gBASE_PROPERTIES($(>[1]),$(>[2]))) ; + local base-properties = $(gBASE_PROPERTIES($(toolset),$(variant))) ; segregate-overrides override-properties : base-properties ; + local all-properties = $(base-properties) $(free-properties) ; + + local rules = [ select-ungristed $(gTARGET_REQUIREMENTS($(<))) ] ; + for local r in $(rules) + { + all-properties = [ $(r) $(toolset) $(variant) : $(all-properties) ] ; + } + # build the path identifying the subvariant local subvariant-id - = [ join $(>) # toolset variant + = [ join $(toolset) $(variant) [ ungrist-properties [ sort $(override-properties) ] ] : $(SLASH) ] ; return $(subvariant-id) - [ fixup-path-properties $(base-properties) $(free-properties) ] + [ fixup-path-properties $(all-properties) ] $(override-properties) ; } @@ -1226,7 +1243,7 @@ rule depend-on-libraries # To run these targets, we need everything needed to run the libraries for local dir in $(gRUN_PATH($(>))) { - if ! $(dir) in $(gRUN_PATH($(<))) + if ! ( $(dir) in $(gRUN_PATH($(<))) ) { gRUN_PATH($(<)) += $(dir) ; } @@ -1267,6 +1284,10 @@ rule subvariant-target = [ join-path $(LOCATE_TARGET) $(BIN_DIRECTORY) $(<:G=) $(>[1]) ] ; local target-files = [ FAppendSuffix $(subvariant) : $(SUF$(target-type)) ] ; + if $(gNAME_ADJUST($(target-type))) + { + target-files = [ $(gNAME_ADJUST($(target-type))) $(target-files) : $(2) : $(3) ] ; + } gTARGET_FILES($(subvariant)) = $(target-files) ; gTARGET_FILES($(<)) += $(target-files) ; @@ -1360,6 +1381,8 @@ rule main-target } } +SHARED_TYPES = DLL ; + gGENERATOR_FUNCTION(EXE) = executable-file ; # exe target : sources : requirements : local-build # diff --git a/v1/borland-tools.jam b/v1/borland-tools.jam index d76ed9e19..62f53397d 100644 --- a/v1/borland-tools.jam +++ b/v1/borland-tools.jam @@ -33,12 +33,12 @@ flags borland CFLAGS full : -vi -w-inl ; local flag-vars = USER-INTERFACE TARGET-TYPE THREADING RUNTIME-LINK ; local $(flag-vars) ; - if [ get-values : $(gBUILD_PROPERTIES) ] != DLL + if ! [ get-values : $(gBUILD_PROPERTIES) ] in $(SHARED_TYPES) { flags borland USER-INTERFACE console : -tWC ; } - flags borland TARGET-TYPE DLL : -tWD ; + flags borland TARGET-TYPE $(SHARED_TYPES) : -tWD ; flags borland THREADING multi : -tWM ; flags borland RUNTIME-LINK dynamic : -tWR ; @@ -78,7 +78,7 @@ rule Link-action with-command-file borland-Link-action $(<) : $(>) $(NEEDLIBS) ; - if $(3) = DLL + if $(3) in $(SHARED_TYPES) { borland-IMPLIB-action $(<) : $(>) ; } diff --git a/v1/gcc-tools.jam b/v1/gcc-tools.jam index 5db20e56f..8cf88866d 100644 --- a/v1/gcc-tools.jam +++ b/v1/gcc-tools.jam @@ -52,11 +52,11 @@ if ! $(NT) # The compiler complains about -fPIC on NT if $(BETOOLS) { - flags gcc LINKFLAGS DLL : -nostart ; + flags gcc LINKFLAGS DLL PYD : -nostart ; } else { - flags gcc LINKFLAGS DLL : -shared ; + flags gcc LINKFLAGS DLL PYD : -shared ; } flags gcc LIBPATH ; diff --git a/v1/intel-linux-tools.jam b/v1/intel-linux-tools.jam index 34a86f3bc..1b6576a99 100644 --- a/v1/intel-linux-tools.jam +++ b/v1/intel-linux-tools.jam @@ -43,7 +43,7 @@ flags intel-linux CFLAGS true : -KPIC ; flags intel-linux LINKFLAGS true : -KPIC ; # dynamic link library -flags intel-linux LINKFLAGS DLL : -shared ; +flags intel-linux LINKFLAGS $(SHARED_TYPES) : -shared ; # library linking flags intel-linux LINKFLAGS static : -static ; diff --git a/v1/metrowerks-tools.jam b/v1/metrowerks-tools.jam index 8f1245904..62101af91 100644 --- a/v1/metrowerks-tools.jam +++ b/v1/metrowerks-tools.jam @@ -28,7 +28,7 @@ flags metrowerks HDRS ; flags metrowerks CFLAGS on : -g ; flags metrowerks LINKFLAGS on : -g ; -flags metrowerks LINKFLAGS DLL : -shared ; +flags metrowerks LINKFLAGS $(SHARED_TYPES) : -shared ; flags metrowerks CFLAGS off : -O0 ; flags metrowerks CFLAGS speed : -opt full ; flags metrowerks CFLAGS space : -O4,s intrinsics ; @@ -75,7 +75,8 @@ rule Link-action gRUN_PATH($(<)) += $(METROWERKS_ROOT)"\\Win32-X86 Support\\Libraries\\Runtime" ; IMPLIB_COMMAND on $(<) = "-implib " ; # will be "multiplied away" if not # needed. - with-command-file metrowerks-Link-action $(<) : $(>) $(NEEDLIBS) ; + with-command-file metrowerks-Link-action $(<) : $(>) $(NEEDLIBS) # $(NEEDLIBS) + ; } # Here we set the environment variable MWWinx86LibraryFiles (customize for other diff --git a/v1/msvc-tools.jam b/v1/msvc-tools.jam index eefcefd70..d62721323 100644 --- a/v1/msvc-tools.jam +++ b/v1/msvc-tools.jam @@ -57,7 +57,7 @@ flags msvc STDLIBPATH : $(MSVCDir)$(SLASH)lib ; flags msvc LIBPATH ; flags msvc NEEDLIBS ; flags msvc FINDLIBS ; -flags msvc LINKFLAGS DLL : /DLL ; +flags msvc LINKFLAGS $(SHARED_TYPES) : /DLL ; #### Link #### diff --git a/v1/python.jam b/v1/python.jam index 13ce1129c..e9830defc 100644 --- a/v1/python.jam +++ b/v1/python.jam @@ -18,6 +18,8 @@ PYTHON_VERSION_NODOT = [ SUBST $(PYTHON_VERSION) ([0-9]*)\.([0-9]*) $1$2 ] ; +local RUN_PATH = $(RUN_PATH) ; + if $(NT) { PYTHON_ROOT ?= c:/tools/python ; @@ -57,11 +59,11 @@ else if $(UNIX) # Locate the python executable PYTHON ?= python$(SUFEXE) ; -SEARCH on $(PYTHON) = $(PATH) ; +SEARCH on $(PYTHON) = $(RUN_PATH) ; # And the debugging version PYTHON_D ?= $(PYTHON:S=)_d$(PYTHON:S) ; -SEARCH on $(PYTHON_D) = $(PATH) ; +SEARCH on $(PYTHON_D) = $(RUN_PATH) ; # select-python-library # @@ -99,7 +101,8 @@ PYTHON_PROPERTIES += <*>python$(PYTHON_VERSION).dll <*>/usr/local/lib/python$(PYTHON_VERSION)/config - <*>/usr/include/python$(PYTHON_VERSION) + <*>/usr/local/include/python$(PYTHON_VERSION) + <*>/usr/include/python$(PYTHON_VERSION) $(BOOST_ROOT) select-python-library # These two compilers pick up implicit directions from #pragmas @@ -130,46 +133,55 @@ rule python-files ( module implib ? : sources * ) { local actual-module = $(module) ; - if BOOST_DEBUG_PYTHON in $(gBUILD_PROPERTIES) - { - # build the actual module name - actual-module = $(module:S=)_d$(module:S) ; - - # be sure not to create a dependency loop - if $(actual-module) != $(module) - { - # now the original module name is just a fake target - NOTFILE $(module) ; - DEPENDS $(module) : $(actual-module) ; - set-target-variables $(actual-module) ; - } - } - - dll-files $(actual-module) $(implib) : $(sources) ; + dll-files $(actual-module) $(implib) : $(sources) : PYD ; if $(NT) && ( $(gCURRENT_TOOLSET) = gcc ) { add-cygwin-python-run-path $(<[-1]) ; } - - gRUN_PATH($(module:S=)) = $(gRUN_PATH($(module))) ; } +if $(NT) +{ + # Adjust the name of Python modules so that they have the _d + # suffix when compiled with python debugging enabled. + gNAME_ADJUST(PYD) = name-adjust-PYD ; + + rule name-adjust-PYD ( pyd implib ? : properties * : toolset variant ) + { + if BOOST_DEBUG_PYTHON in $(properties) + { + pyd = $(pyd:S=)_d$(pyd:S) ; + } + return $(pyd) $(implib) ; + } +} + +rule Link-PYD +{ + if $(<[2]) + { + MODE on $(<[2]) = $(IMPMODE) ; + Chmod $(<[2]) ; + } + + gRUN_PATH($(<)) += $(gLOCATE($(<[1]))) ; + Link-action $(<) : $(>) : PYD ; +} + +declare-target-type PYD : true ; +gGENERATOR_FUNCTION(PYD) = python-files ; +SUFPYD = .pyd $(SUFDLL[2-]) ; +PYDMODE = $(DLLMODE) ; +SHARED_TYPES += PYD ; + # Declare a python extension. rule extension ( name : sources + : requirements * : default-BUILD * ) { requirements += $(PYTHON_PROPERTIES) ; - # Temporarily hijack the generator function for DLLs to handle - # some python extension-specific things. - local gGENERATOR_FUNCTION(DLL) = python-files ; - local SUFDLL = .pyd $(SUFDLL[2-]) ; - - dll $(name) : - $(sources) - : $(requirements) - : $(default-BUILD) - ; + + declare-local-target $(name) : $(sources) : $(requirements) : $(default-BUILD) : PYD ; } # boost-python-runtest target : python-script sources : requirements : local-build : args @@ -219,7 +231,7 @@ actions python-test-target bind PYTHON $(SHELL_EXPORT)PATH $(SHELL_SET)PYTHONPATH=$(PYTHONPATH) $(SHELL_EXPORT)PYTHONPATH - $(PYTHON) "$(>)" $(ARGS) > "$(<)" + $(PYTHON_LAUNCH) $(PYTHON) $(PYTHON_ARGS) "$(>)" $(ARGS) > "$(<)" } SUFPYTHON_RUNTEST = .run ; @@ -236,7 +248,7 @@ actions python-runtest-target bind PYTHON $(SHELL_EXPORT)PATH $(SHELL_SET)PYTHONPATH=$(PYTHONPATH) $(SHELL_EXPORT)PYTHONPATH - $(PYTHON) "$(>)" $(ARGS) + $(PYTHON_LAUNCH) $(PYTHON) $(PYTHON_ARGS) "$(>)" $(ARGS) } # This is the rule that actually causes the test to run. It is used by @@ -262,7 +274,7 @@ rule python-runtest-aux ( target : sources + ) if $(NT) && ( $(gCURRENT_TOOLSET) = gcc ) { python = python$(PYTHON_VERSION)$(SUFEXE) ; - SEARCH on $(python) = $(CYGWIN_ROOT)/usr/local/bin ; + SEARCH on $(python) = $(RUN_PATH) $(CYGWIN_ROOT)/usr/local/bin ; # Fix up path splitter for cygwin. splitpath = ":" ; }