From ed6079fb3d393fe22dd6e2dc1b8eca89b949bab5 Mon Sep 17 00:00:00 2001 From: Vladimir Prus Date: Tue, 21 Mar 2006 16:26:47 +0000 Subject: [PATCH] Quick fix to allow configure different Python versions for different toolsets. [SVN r33421] --- src/build/project.jam | 16 ++++++++++++++++ src/tools/python.jam | 26 ++++++++++++++++++-------- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/build/project.jam b/src/build/project.jam index 74f901b64..e848cc99f 100644 --- a/src/build/project.jam +++ b/src/build/project.jam @@ -674,6 +674,22 @@ rule current ( ) return $(.current-project) ; } +# Temporary changes the current project to 'project'. Should +# be followed by 'pop-current'. +rule push-current ( project ) +{ + .saved-current-project += $(.current-project) ; + .current-project = $(project) ; +} + +rule pop-current ( ) +{ + .current-project = $(.saved-current-project[-1]) ; + .saved-current-project = $(.saved-current-project[1--2]) ; +} + + + # Returns the project-attribute instance for the specified jamfile module. rule attributes ( project ) { diff --git a/src/tools/python.jam b/src/tools/python.jam index e75a406ac..475976684 100644 --- a/src/tools/python.jam +++ b/src/tools/python.jam @@ -39,6 +39,11 @@ import toolset : flags ; 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. +.project = [ project.current ] ; + # Initializes the Python toolset. # - version -- the version of Python to use. Should be in Major.Minor format, # for example 2.3 @@ -57,9 +62,12 @@ project python ; # using python 2.3 : /usr/local ; # Root specified, include and lib paths # # will be guessed # -rule init ( version ? : root ? : includes ? : libraries ? : cygwin-condition ? ) +rule init ( version ? : root ? : includes ? : libraries ? + : cygwin-condition * ) { .configured = true ; + + project.push-current $(.project) ; if [ os.name ] = NT { @@ -71,11 +79,13 @@ rule init ( version ? : root ? : includes ? : libraries ? : cygwin-condition ? ) } else if [ modules.peek : UNIX ] { - init-unix $(version) : $(root) : $(includes) : $(libraries) ; + init-unix $(version) : $(root) : $(includes) : $(libraries) : $(cygwin-condition) ; } + + project.pop-current ; } -rule init-unix ( version ? : root ? : includes ? : libraries ? ) +rule init-unix ( version ? : root ? : includes ? : libraries ? : condition * ) { root ?= /usr ; includes ?= $(root)/include/python$(version) ; @@ -100,17 +110,17 @@ rule init-unix ( version ? : root ? : includes ? : libraries ? ) # 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. + # for library. alias python_for_extensions - : - : + : + : $(condition) : : $(includes) ; alias python - : - : + : + : $(condition) : : $(includes) $(libraries)