Update of /cvsroot/boost/boost/tools/build/v2/tools
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29418/tools/build/v2/tools
Modified Files:
Tag: bbv2python
python.jam builtin.jam
Log Message:
python.jam:
* fix cross-NT/CYGWIN build support
* add condition to the build requirements of the python targets
os.jam:
* add the ability to get constants for a particular OS
builtin.jam:
* remove "optional" attribute from host-os
* fix confusing indents
Index: python.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/python.jam,v
retrieving revision 1.12.2.33.2.2
retrieving revision 1.12.2.33.2.3
diff -u -d -r1.12.2.33.2.2 -r1.12.2.33.2.3
--- python.jam 13 Mar 2007 22:12:04 -0000 1.12.2.33.2.2
+++ python.jam 15 Mar 2007 03:29:09 -0000 1.12.2.33.2.3
@@ -215,24 +215,6 @@
}
}
-# Convert an NT path to native
-local rule windows-path-to-native ( path )
-{
- if [ os.name ] = NT
- {
- return $(path) ;
- }
- else
- {
- path = $(path:T) ;
- parts = [ MATCH ^([A-Za-z]):/(.*) : $(path) : 1 2 ] ;
- if $(parts)
- {
- path = /cygdrive/$(parts[1])/$(parts[2]) ;
- }
- }
-}
-
# Like W32_GETREG, except prepend HKEY_CURRENT_USER and
# HKEY_LOCAL_MACHINE to the argument, returning the first result
# found.
@@ -249,62 +231,109 @@
return $(result) ;
}
-# Convert a *nix path to native.
-local rule *nix-path-to-native ( path )
+.windows-drive-letter-re = ^([A-Za-z]):[\\/](.*) ;
+.cygwin-drive-letter-re = ^/cygdrive/([a-z])/(.*) ;
+
+.working-directory = [ PWD ] ;
+.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 [ os.name ] = NT
+ # 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 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.
+local rule cygwin-to-windows-path ( path )
+{
+ path = $(path:R="") ; # strip any trailing slash
+
+ local drive-letter = [ SUBST $(path) $(.cygwin-drive-letter-re) $1:/$2 ] ;
+ if $(drive-letter)
{
- path = $(path:R="") ; # strip any trailing slash
-
- local parts = [ MATCH ^/cygdrive/([a-zA-Z])/(.*) : $(path) : 1 2 ] ;
- if $(parts)
- {
- path = $(parts[1]):/$(parts[2]) ;
- }
- else if $(path:R=/x) = $(path) # already rooted?
- {
- # Look for a cygwin mount that includes each head sequence in
$(path).
- local head = $(path) ;
- local tail = "" ;
+ path = $(drive-letter) ;
+ }
+ else if $(path:R=/x) = $(path) # already rooted?
+ {
+ # Look for a cygwin mount that includes each head sequence in $(path).
+ local head = $(path) ;
+ local tail = "" ;
- while $(head)
+ while $(head)
+ {
+ local root = [
+ registry-value "SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts
v2\\"$(head)
+ : native
+ ] ;
+
+ if $(root)
{
- local root = [
- registry-value "SOFTWARE\\Cygnus Solutions\\Cygwin\\mounts
v2\\"$(head)
- : native
- ] ;
-
- if $(root)
- {
- path = $(tail:R=$(root)) ;
- head = ;
- }
- tail = $(tail:R=$(head:D=)) ;
-
- if $(head) = /
- {
- head = ;
- }
- else
- {
- head = $(head:D) ;
- }
+ path = $(tail:R=$(root)) ;
+ head = ;
+ }
+ tail = $(tail:R=$(head:D=)) ;
+
+ if $(head) = /
+ {
+ head = ;
+ }
+ else
+ {
+ head = $(head:D) ;
}
}
- path = [ regex.replace $(path:R="") / \\ ] ;
+ }
+ return [ regex.replace $(path:R="") / \\ ] ;
+}
+
+# Convert a *nix path to native
+local rule *nix-path-to-native ( path )
+{
+ if [ os.name ] = NT
+ {
+ path = [ cygwin-to-windows-path $(path) ] ;
}
return $(path) ;
}
-local rule path-to-native ( path : source-os )
+# Convert an NT path to native
+local rule windows-path-to-native ( path )
{
- if $(source-os) = windows
+ if [ os.name ] = NT
+ {
+ return $(path) ;
+ }
+ else
+ {
+ return [ windows-to-cygwin-path $(path) ] ;
+ }
+}
+
+# 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 ( path )
+{
+ if [ guess-windows-path $(path) ]
{
return [ windows-path-to-native $(path) ] ;
}
else
{
- return [ *nix-path-to-native $(path) ] ;
+ return [ *nix-path-to-native $(path:T) ] ;
}
}
@@ -348,6 +377,7 @@
if $(install-path)
{
+ install-path = [ windows-path-to-native $(install-path) ] ;
debug-message Registry indicates Python $(v) installed at
\"$(install-path)\" ;
}
@@ -449,6 +479,15 @@
local default-library-path = $(:E=libs:R=$(exec-prefix)) ;
local default-include-path = $(:E=Include:R=$(prefix)) ;
+ if $(default-library-path)
+ {
+ default-library-path = [ path-to-native $(default-library-path) ] ;
+ }
+ if $(default-include-path)
+ {
+ default-include-path = [ path-to-native $(default-include-path) ] ;
+ }
+
# If the interpreter was found in a directory
# called "PCBuild" or "PCBuild8," assume we're
# looking at a Python built from the source
@@ -466,8 +505,12 @@
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-include-path = $(:E=PC:R=$(executable-dir:D))
$(default-include-path) ;
+ default-library-path = [ path-to-native $(executable-dir) ]
+ $(default-library-path) ;
+
+ default-include-path = [ path-to-native
$(:E=PC:R=$(executable-dir:D)) ]
+ $(default-include-path) ;
+
debug-message "and \""$(default-include-path[1])"\" to default
#include path" ;
}
@@ -477,11 +520,12 @@
else
{
# $(prefix)/include/python$(version)
- includes ?= $(:E=python$(version):R=$(:E=include:R=$(prefix))) ;
+ includes ?= [ path-to-native
$(:E=python$(version):R=$(:E=include:R=$(prefix))) ] ;
# $(exec-prefix)/lib/python$(version)/config $(exec-prefix)/lib
- local lib = $(:E=lib:R=$(exec-prefix)) ;
- libraries ?= $(:E=config:R=$(:E=python$(version):R=$(lib))) $(lib) ;
+ local lib = [ path-to-native $(:E=lib:R=$(exec-prefix)) ] ;
+ libraries ?= [ path-to-native
$(:E=config:R=$(:E=python$(version):R=$(lib))) ]
+ [ path-to-native $(lib) ] ;
}
}
@@ -492,6 +536,11 @@
# interpreter.
local rule candidate-interpreters ( version ? : prefix ? : target-os )
{
+ if $(prefix)
+ {
+ prefix = [ path-to-native $(prefix) ] ;
+ }
+
local bin-path = bin ;
if $(target-os) = windows
{
@@ -682,9 +731,9 @@
compute-default-paths
$(target-os) : $(sys.version)
- : [ path-to-native $(sys.prefix) : $(target-os) ]
- : [ path-to-native $(sys.exec_prefix) : $(target-os)
]
- : [ path-to-native $(sys.executable) :
$(target-os) ]
+ : $(sys.prefix)
+ : $(sys.exec_prefix)
+ : $(sys.executable)
;
version = $(sys.version) ;
interpreter-cmd ?= $(cmd) ;
@@ -748,6 +797,8 @@
}
}
+ condition += <target-os>$(target-os) ;
+
# Set up the PYTHON variable to point at the interpreter.
flags python.capture-output PYTHON $(condition:J=/) : $(interpreter-cmd) ;
@@ -934,6 +985,19 @@
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"
+.translate-os-windows = NT ;
+.translate-os-cygwin = CYGWIN ;
+local rule translate-os ( src-os )
+{
+ local x = $(.translate-os-$(src-os)) [ os.name ] ;
+ return $(x[1]) ;
+}
# The flag settings on testing.capture-output do not
# apply to python.capture output at the moment.
@@ -947,13 +1011,32 @@
# 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 = [ on $(sources[2]) return $(LOCATE) ] ;
# After test is run, we remove the Python module, but not the Python
# script.
testing.capture-output $(target) : $(sources[1]) : $(properties)
: $(sources[2]) ;
- local c = [ common.prepend-path-variable-command PYTHONPATH :
$(PYTHONPATH) ] ;
- LAUNCHER on $(target) = $(c) [ on $(target) return $(PYTHON) ] ;
+
+ # 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.
+ 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)
] ;
+ }
+ 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 * )
Index: builtin.jam
===================================================================
RCS file: /cvsroot/boost/boost/tools/build/v2/tools/builtin.jam,v
retrieving revision 1.189.2.7.2.2
retrieving revision 1.189.2.7.2.3
diff -u -d -r1.189.2.7.2.2 -r1.189.2.7.2.3
--- builtin.jam 13 Mar 2007 22:12:05 -0000 1.189.2.7.2.2
+++ builtin.jam 15 Mar 2007 03:29:12 -0000 1.189.2.7.2.3
@@ -73,14 +73,13 @@
# 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
- : $(.os-names)
- : optional ;
- feature.set-default host-os : [ default-host-os ] ;
+feature host-os : $(.os-names) ;
+feature.set-default host-os : [ default-host-os ] ;
+
feature target-os
: $(.os-names)
: propagated link-incompatible ;
- feature.set-default target-os : [ default-host-os ] ;
+feature.set-default target-os : [ default-host-os ] ;
feature toolset : : implicit propagated symmetric ;
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs