diff --git a/v2/kernel/errors.jam b/v2/kernel/errors.jam
index d220466d8..7fae6385b 100755
--- a/v2/kernel/errors.jam
+++ b/v2/kernel/errors.jam
@@ -222,6 +222,7 @@ rule nearest-user-location ( )
return $(result) ;
}
+
# If optimized rule is available in Jam, use it.
if NEAREST_USER_LOCATION in [ RULENAMES ]
{
@@ -233,7 +234,6 @@ if NEAREST_USER_LOCATION in [ RULENAMES ]
}
-
rule __test__ ( )
{
# Show that we can correctly catch an expected error.
diff --git a/v2/test/conditionals.py b/v2/test/conditionals.py
index ec31d4412..35651be73 100644
--- a/v2/test/conditionals.py
+++ b/v2/test/conditionals.py
@@ -1,55 +1,47 @@
#!/usr/bin/python
-# Copyright 2003 Dave Abrahams
-# Copyright 2002, 2003, 2004 Vladimir Prus
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+# Copyright 2003 Dave Abrahams
+# Copyright 2002, 2003, 2004 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
-# Test conditional properties
+# Test conditional properties.
-from BoostBuild import Tester, List
-import os
-from string import strip
+import BoostBuild
-t = Tester()
+t = BoostBuild.Tester()
-# Arrange a project which will build only if
-# 'a.cpp' is compiled with "STATIC" define.
-t.write("project-root.jam", "import gcc ;")
+# Arrange a project which will build only if 'a.cpp' is compiled with "STATIC"
+# define.
t.write("a.cpp", """
#ifdef STATIC
-int main() { return 0; }
+int main() { return 0; }
#endif
""")
-t.write("Jamfile", "exe a : a.cpp : static:STATIC ;")
+
+# Test conditionals in target requirements.
+t.write("Jamroot.jam", "exe a : a.cpp : static:STATIC ;")
t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/a.exe")
+t.rm("bin")
-t.write("Jamfile", """
+# Test conditionals in project requirements.
+t.write("Jamroot.jam", """
project : requirements static:STATIC ;
exe a : a.cpp ;
""")
-t.rm("bin")
t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/a.exe")
+t.rm("bin")
-# Regression test for a bug found by Ali Azarbayejani.
-# Conditionals inside usage requirement were not evaluated.
-# This breaks
-
-t.write("Jamfile", """
+# Regression test for a bug found by Ali Azarbayejani. Conditionals inside usage
+# requirement were not being evaluated.
+t.write("Jamroot.jam", """
lib l : l.cpp : : : static:STATIC ;
exe a : a.cpp l ;
""")
-t.write("l.cpp", "")
-t.write("l.cpp", """
-int i;
-""")
-
-t.rm("bin")
+t.write("l.cpp", "int i;")
t.run_build_system("link=static")
t.expect_addition("bin/$toolset/debug/link-static/a.exe")
-
-
t.cleanup()
diff --git a/v2/test/conditionals2.py b/v2/test/conditionals2.py
index 88877573a..59e62a9aa 100644
--- a/v2/test/conditionals2.py
+++ b/v2/test/conditionals2.py
@@ -1,35 +1,33 @@
#!/usr/bin/python
-# Copyright 2003 Vladimir Prus
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+# Copyright 2003 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
# Regression test: it was possible that due to evaluation of conditional
# requirements, two different values of non-free features were present in
# property set.
-from BoostBuild import Tester, List
+import BoostBuild
-t = Tester()
-
-t.write("project-root.jam", "")
+t = BoostBuild.Tester()
t.write("a.cpp", "")
-t.write("Jamfile", """
-import feature : feature ;
-import common : file-creation-command ;
+t.write("Jamroot.jam", """
+import feature ;
+import common ;
-feature the_feature : false true : propagated ;
+feature.feature the_feature : false true : propagated ;
rule maker ( targets * : sources * : properties * )
{
- if false in $(properties)
- && true in $(properties)
+ if false in $(properties) &&
+ true in $(properties)
{
EXIT "Oops, two different values of non-free feature" ;
- }
- CMD on $(targets) = [ file-creation-command ] ;
+ }
+ CMD on $(targets) = [ common.file-creation-command ] ;
}
actions maker
@@ -37,12 +35,9 @@ actions maker
$(CMD) $(<) ;
}
-make a : a.cpp : maker : debug:true ;
+make a : a.cpp : maker : debug:true ;
""")
t.run_build_system()
t.cleanup()
-
-
-
diff --git a/v2/test/conditionals3.py b/v2/test/conditionals3.py
index fefb97798..8144dd990 100644
--- a/v2/test/conditionals3.py
+++ b/v2/test/conditionals3.py
@@ -1,19 +1,17 @@
#!/usr/bin/python
-# Copyright 2003 Vladimir Prus
-# Distributed under the Boost Software License, Version 1.0.
-# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
+# Copyright 2003 Vladimir Prus
+# Distributed under the Boost Software License, Version 1.0.
+# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
-# Test that conditional properties work, even if property is free, and
-# value includes colon.
-from BoostBuild import Tester, List
+# Test that conditional properties work, even if property is free, and value
+# includes a colon.
+import BoostBuild
-t = Tester()
+t = BoostBuild.Tester()
-# Create the needed files
-t.write("project-root.jam", "")
-t.write("Jamfile", """
+t.write("Jamroot.jam", """
exe hello : hello.cpp : debug:CLASS=Foo::Bar ;
""")
t.write("hello.cpp", """
@@ -21,12 +19,11 @@ namespace Foo { class Bar { } ; }
int main()
{
CLASS c;
+ c; // Disables the unused variable warning.
return 0;
}
-
""")
-# Don't check stderr, which can include warning about unused 'c'.
t.run_build_system(stdout=None, stderr=None)
t.expect_addition("bin/$toolset/debug/hello.exe")
diff --git a/v2/test/test_all.py b/v2/test/test_all.py
index 6b9bccd15..7ecac843f 100644
--- a/v2/test/test_all.py
+++ b/v2/test/test_all.py
@@ -106,6 +106,9 @@ tests = [ "rebuilds",
"default_build",
"use_requirements",
"conditionals",
+ "conditionals2",
+ "conditionals3",
+ "indirect_conditional",
"stage",
"prebuilt",
"project_dependencies",
@@ -124,10 +127,8 @@ tests = [ "rebuilds",
"bad_dirname",
"c_file",
"inline",
- "conditionals2",
"property_expansion",
"loop",
- "conditionals3",
"tag",
"suffix",
"inherit_toolset",
@@ -154,7 +155,6 @@ tests = [ "rebuilds",
"project_root_rule",
"resolution",
"build_file",
- "indirect_conditional",
"build_no",
"disambiguation",
"clean",
diff --git a/v2/tools/intel.jam b/v2/tools/intel.jam
index 81865281e..67038aa28 100644
--- a/v2/tools/intel.jam
+++ b/v2/tools/intel.jam
@@ -30,6 +30,5 @@ rule init ( * : * )
{
toolset.using intel-win :
$(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
-
}
}
diff --git a/v2/tools/msvc.jam b/v2/tools/msvc.jam
index 0ceb565ab..8068c190f 100644
--- a/v2/tools/msvc.jam
+++ b/v2/tools/msvc.jam
@@ -9,17 +9,16 @@
# License Version 1.0. (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)
+import "class" : new ;
import property ;
import generators ;
import os ;
import type ;
import toolset : flags ;
-import errors : error ;
-import feature : feature get-values ;
+import errors ;
+import feature ;
import path ;
-import sequence : unique ;
import common ;
-import "class" : new ;
import rc ;
import midl ;
import mc ;
@@ -126,10 +125,10 @@ rule configure ( version ? : options * )
case all :
if $(options)
{
- error "msvc: options should be empty when 'all' is specified" ;
+ errors.error "msvc: options should be empty when 'all' is specified" ;
}
- # use all detected versions
+ # Use all detected versions.
for local v in [ $(.versions).all ]
{
configure-really $(v) ;
@@ -190,7 +189,7 @@ local rule configure-really ( version ? : options * )
# if the identical sets of options are used
if $(options) && ( $(options) != [ $(.versions).get $(version) : options ] )
{
- error "msvc: the toolset version '$(version)' is configured already" ;
+ errors.error "msvc: the toolset version '$(version)' is configured already" ;
}
}
else
@@ -209,7 +208,7 @@ local rule configure-really ( version ? : options * )
$(.versions).set $(version) : condition : $(condition) ;
- local command = [ get-values : $(options) ] ;
+ local command = [ feature.get-values : $(options) ] ;
# If version is specified, we try to search first in default paths, and
# only then in PATH.
@@ -265,9 +264,9 @@ local rule configure-really ( version ? : options * )
parent = [ path.parent $(parent) ] ;
parent = [ path.native $(parent) ] ;
- # setup will be used if the script name has been specified. If setup
+ # Setup will be used if the script name has been specified. If setup
# is not specified, a default script will be used instead.
- setup = [ get-values : $(options) ] ;
+ setup = [ feature.get-values : $(options) ] ;
if ! $(setup)
{
@@ -325,32 +324,32 @@ local rule configure-really ( version ? : options * )
command = $(prefix)$(setup)" "$(setup-option:E="")$(suffix) ;
- # Setup script is not required in some configurations
+ # Setup script is not required in some configurations.
command ?= "" ;
# Get tool names (if any) and finish setup.
- compiler = [ get-values : $(options) ] ;
+ compiler = [ feature.get-values : $(options) ] ;
compiler ?= cl ;
- linker = [ get-values : $(options) ] ;
+ linker = [ feature.get-values : $(options) ] ;
linker ?= link ;
- resource-compiler = [ get-values : $(options) ] ;
+ resource-compiler = [ feature.get-values : $(options) ] ;
resource-compiler ?= rc ;
- assembler = [ get-values : $(options) ] ;
+ assembler = [ feature.get-values : $(options) ] ;
assembler ?= ml ;
- idl-compiler = [ get-values : $(options) ] ;
+ idl-compiler = [ feature.get-values : $(options) ] ;
idl-compiler ?= midl ;
- mc-compiler = [ get-values : $(options) ] ;
+ mc-compiler = [ feature.get-values : $(options) ] ;
mc-compiler ?= mc ;
manifest-tool = mt ;
- local cc-filter = [ get-values : $(options) ] ;
+ local cc-filter = [ feature.get-values : $(options) ] ;
for local i in 1 2 3
{
@@ -366,30 +365,30 @@ local rule configure-really ( version ? : options * )
"command: '$(command[$(i)])'" ;
}
- flags msvc.compile .CC $(cond) : $(command[$(i)])$(compiler) /Zm800 -nologo ;
- flags msvc.compile .RC $(cond) : $(command[$(i)])$(resource-compiler) ;
- flags msvc.compile .ASM $(cond) : $(command[$(i)])$(assembler) ;
- flags msvc.link .LD $(cond) : $(command[$(i)])$(linker) /NOLOGO /INCREMENTAL:NO ;
- flags msvc.archive .LD $(cond) : $(command[$(i)])$(linker) /lib /NOLOGO ;
- flags msvc.compile .IDL $(cond) : $(command[$(i)])$(idl-compiler) ;
- flags msvc.compile .MC $(cond) : $(command[$(i)])$(mc-compiler) ;
+ toolset.flags msvc.compile .CC $(cond) : $(command[$(i)])$(compiler) /Zm800 -nologo ;
+ toolset.flags msvc.compile .RC $(cond) : $(command[$(i)])$(resource-compiler) ;
+ toolset.flags msvc.compile .ASM $(cond) : $(command[$(i)])$(assembler) ;
+ toolset.flags msvc.link .LD $(cond) : $(command[$(i)])$(linker) /NOLOGO /INCREMENTAL:NO ;
+ toolset.flags msvc.archive .LD $(cond) : $(command[$(i)])$(linker) /lib /NOLOGO ;
+ toolset.flags msvc.compile .IDL $(cond) : $(command[$(i)])$(idl-compiler) ;
+ toolset.flags msvc.compile .MC $(cond) : $(command[$(i)])$(mc-compiler) ;
if ! [ os.name ] in NT
{
- flags msvc.link .MT $(cond) : $(command[$(i)])$(manifest-tool) -nologo ;
+ toolset.flags msvc.link .MT $(cond) : $(command[$(i)])$(manifest-tool) -nologo ;
}
else
{
- flags msvc.link .MT $(cond) : $(manifest-tool) -nologo ;
+ toolset.flags msvc.link .MT $(cond) : $(manifest-tool) -nologo ;
}
if $(cc-filter)
{
- flags msvc .CC.FILTER $(cond) : "|" $(cc-filter) ;
+ toolset.flags msvc .CC.FILTER $(cond) : "|" $(cc-filter) ;
}
}
}
- # Set version-specific flags
+ # Set version-specific flags.
configure-version-specific msvc : $(version) : $(condition) ;
}
}
@@ -430,14 +429,14 @@ rule configure-version-specific ( toolset : version : condition )
# 7.* explicitly, or if the installation path contain 7.* (checked above).
if ! [ MATCH ^(6\\.) : $(version) ]
{
- flags $(toolset).compile CFLAGS $(condition) : /Zc:forScope /Zc:wchar_t ;
- flags $(toolset).compile.c++ C++FLAGS $(condition) : /wd4675 ;
+ toolset.flags $(toolset).compile CFLAGS $(condition) : /Zc:forScope /Zc:wchar_t ;
+ toolset.flags $(toolset).compile.c++ C++FLAGS $(condition) : /wd4675 ;
# disable the function is deprecated warning
# Some version of msvc have a bug, that cause deprecation
# warning to be emitted even with /W0
- flags $(toolset).compile CFLAGS $(condition)/off : /wd4996 ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/off : /wd4996 ;
# 64-bit compatibility warning
- flags $(toolset).compile CFLAGS $(condition)/all : /Wp64 ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/all : /Wp64 ;
}
#
@@ -447,35 +446,35 @@ rule configure-version-specific ( toolset : version : condition )
if [ MATCH ^([67]) : $(version) ]
{
# 8.0 deprecates some of the options.
- flags $(toolset).compile CFLAGS $(condition)/speed $(condition)/space : /Ogiy /Gs ;
- flags $(toolset).compile CFLAGS $(condition)/speed : /Ot ;
- flags $(toolset).compile CFLAGS $(condition)/space : /Os ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/speed $(condition)/space : /Ogiy /Gs ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/speed : /Ot ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/space : /Os ;
- flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/ : /GB ;
- flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/i386 : /G3 ;
- flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/i486 : /G4 ;
- flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g5) : /G5 ;
- flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g6) : /G6 ;
- flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g7) : /G7 ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/ : /GB ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/i386 : /G3 ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/i486 : /G4 ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g5) : /G5 ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g6) : /G6 ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-i386)/$(cpu-type-g7) : /G7 ;
# Improve floating-point accuracy. Otherwise, some of C++ Boost's "math"
# tests will fail.
- flags $(toolset).compile CFLAGS $(condition) : /Op ;
+ toolset.flags $(toolset).compile CFLAGS $(condition) : /Op ;
# 7.1 and below have single-threaded static RTL.
- flags $(toolset).compile CFLAGS $(condition)/off/static/single : /ML ;
- flags $(toolset).compile CFLAGS $(condition)/on/static/single : /MLd ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/off/static/single : /ML ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/on/static/single : /MLd ;
}
else
{
# 8.0 and above adds some more options.
- flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-amd64)/ : /favor:blend ;
- flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-amd64)/$(cpu-type-em64t) : /favor:EM64T ;
- flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-amd64)/$(cpu-type-amd64) : /favor:AMD64 ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-amd64)/ : /favor:blend ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-amd64)/$(cpu-type-em64t) : /favor:EM64T ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/$(cpu-arch-amd64)/$(cpu-type-amd64) : /favor:AMD64 ;
# 8.0 and above only has multi-threaded static RTL.
- flags $(toolset).compile CFLAGS $(condition)/off/static/single : /MT ;
- flags $(toolset).compile CFLAGS $(condition)/on/static/single : /MTd ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/off/static/single : /MT ;
+ toolset.flags $(toolset).compile CFLAGS $(condition)/on/static/single : /MTd ;
}
toolset.pop-checking-for-flags-module ;
}
@@ -485,7 +484,7 @@ rule configure-version-specific ( toolset : version : condition )
local rule default-path ( version )
{
# Use auto-detected path if possible
- local path = [ get-values :
+ local path = [ feature.get-values :
[ $(.versions).get $(version) : options ] ] ;
if $(path)
@@ -565,7 +564,7 @@ generators.override msvc.compile.mc : mc.compile ;
# pch support
-feature pch-source : : free dependency ;
+feature.feature pch-source : : free dependency ;
class msvc-pch-generator : pch-generator
{
@@ -595,24 +594,18 @@ class msvc-pch-generator : pch-generator
errors.user-error "can't build pch without pch-header" ;
}
- # If we don't have PCH source, it's fine, we'll
- # create temporary .cpp file in the action.
+ # If we don't have PCH source - that's fine. We'll just create a
+ # temporary .cpp file in the action.
- local generated =
- [
- # Passing of is a dirty trick,
- # needed because non-composing generators
- # with multiple inputs are subtly broken:
- # https://zigzag.cs.msu.su:7813/boost.build/ticket/111
- generator.run $(project) $(name)
- : [
- property-set.create
- $(pch-source)
- [ $(property-set).raw ]
- ]
- : $(pch-header)
- ]
- ;
+ local generated = [ generator.run $(project) $(name)
+ : [ property-set.create
+ # Passing of is a dirty trick, needed because
+ # non-composing generators with multiple inputs are subtly
+ # broken. For more detailed information see:
+ # https://zigzag.cs.msu.su:7813/boost.build/ticket/111
+ $(pch-source)
+ [ $(property-set).raw ] ]
+ : $(pch-header) ] ;
local pch-file ;
for local g in $(generated)
@@ -623,14 +616,8 @@ class msvc-pch-generator : pch-generator
}
}
- return
- [
- property-set.create
- $(pch-header)
- $(pch-file)
- ]
- $(generated)
- ;
+ return [ property-set.create $(pch-header)
+ $(pch-file) ] $(generated) ;
}
}
diff --git a/v2/util/doc.jam b/v2/util/doc.jam
index e7c4006ad..627c03d76 100644
--- a/v2/util/doc.jam
+++ b/v2/util/doc.jam
@@ -311,8 +311,7 @@ local rule print-help-usage ( )
print.section "Debug Levels"
Each debug level shows a different set of information. Usually with
higher levels producing more verbose information. The following levels
- are supported:
- ;
+ are supported: ;
print.list-start ;
print.list-item 0;
Turn off all diagnostic output. Only errors are reported. ;
diff --git a/v2/util/os.jam b/v2/util/os.jam
index 71c10e0a4..0cca9da88 100644
--- a/v2/util/os.jam
+++ b/v2/util/os.jam
@@ -7,17 +7,20 @@
import modules ;
import string ;
-# Return the value(s) of the given environment variable(s) at the time
-# bjam was invoked.
+
+# Return the value(s) of the given environment variable(s) at the time bjam was
+# invoked.
rule environ ( variable-names + )
{
return [ modules.peek .ENVIRON : $(variable-names) ] ;
}
+
.name = [ modules.peek : OS ] ;
.platform = [ modules.peek : OSPLAT ] ;
.version = [ modules.peek : OSVER ] ;
+
local rule constant ( c : os ? )
{
os ?= $(.name) ;
@@ -27,10 +30,10 @@ local rule constant ( c : os ? )
return $(result[1]) ;
}
-rule get-constant ( os ? )
+rule get-constant ( os ? )
{
- # Find the name of the constant being accessed, which is
- # equal to the name used to invoke us.
+ # Find the name of the constant being accessed, which is equal to the name
+ # used to invoke us.
local bt = [ BACKTRACE 1 ] ;
local rulename = [ MATCH ([^.]*)$ : $(bt[4]) ] ;
return [ constant $(rulename) : $(os) ] ;
@@ -46,8 +49,8 @@ for local constant in $(.constants)
EXPORT $(__name__) : $(.constants) ;
.executable-path-variable-NT = PATH ;
-# On Windows the case and capitalization of PATH is not always
-# predictable, so let's find out what variable name was really set.
+# On Windows the case and capitalization of PATH is not always predictable, so
+# let's find out what variable name was really set.
if $(.name) = NT
{
for local n in [ VARNAMES .ENVIRON ]
@@ -59,8 +62,8 @@ if $(.name) = NT
}
}
-# Specific constants for various platforms. There's no need to define
-# any constant whose value would be the same as the default, below.
+# Specific constants for various platforms. There's no need to define any
+# constant whose value would be the same as the default, below.
.shared-library-path-variable-NT = $(.executable-path-variable-NT) ;
.path-separator-NT = ";" ;
.expand-variable-prefix-NT = % ;
diff --git a/v2/util/path.jam b/v2/util/path.jam
index 989b5649e..6cd6a6e7e 100644
--- a/v2/util/path.jam
+++ b/v2/util/path.jam
@@ -6,7 +6,7 @@
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-# Performs various path manipulations. Path are always in a 'normilized'
+# Performs various path manipulations. Paths are always in a 'normalized'
# representation. In it, a path may be either:
#
# - '.', or
@@ -17,10 +17,10 @@
# at the beginning, and it never ends in slash, except for path consisting
# of slash only.
+import errors ;
import modules ;
-import sequence ;
import regex ;
-import errors : error ;
+import sequence ;
import set ;
@@ -30,15 +30,11 @@ if [ modules.peek : UNIX ]
local uname = [ modules.peek : JAMUNAME ] ;
switch $(uname)
{
- case CYGWIN* :
- os = CYGWIN ;
-
- case * :
- os = UNIX ;
+ case CYGWIN* : os = CYGWIN ;
+ case * : os = UNIX ;
}
}
-#
# Converts the native path into normalized form.
#
rule make ( native )
@@ -46,7 +42,7 @@ rule make ( native )
return [ make-$(os) $(native) ] ;
}
-#
+
# Builds native representation of the path.
#
rule native ( path )
@@ -54,7 +50,7 @@ rule native ( path )
return [ native-$(os) $(path) ] ;
}
-#
+
# Tests if a path is rooted.
#
rule is-rooted ( path )
@@ -62,19 +58,22 @@ rule is-rooted ( path )
return [ MATCH "^(/)" : $(path) ] ;
}
-#
+
# Tests if a path has a parent.
#
rule has-parent ( path )
{
- if $(path) != / {
+ if $(path) != /
+ {
return 1 ;
- } else {
+ }
+ else
+ {
return ;
}
}
-#
+
# Returns the path without any directory components.
#
rule basename ( path )
@@ -82,41 +81,52 @@ rule basename ( path )
return [ MATCH "([^/]+)$" : $(path) ] ;
}
-#
+
# Returns parent directory of the path. If no parent exists, error is issued.
#
rule parent ( path )
{
- if [ has-parent $(path) ] {
-
- if $(path) = . {
+ if [ has-parent $(path) ]
+ {
+ if $(path) = .
+ {
return .. ;
- } else {
-
+ }
+ else
+ {
# Strip everything at the end of path up to and including
# the last slash
local result = [ regex.match "((.*)/)?([^/]+)" : $(path) : 2 3 ] ;
# Did we strip what we shouldn't?
- if $(result[2]) = ".." {
+ if $(result[2]) = ".."
+ {
return $(path)/.. ;
- } else {
- if ! $(result[1]) {
- if [ is-rooted $(path) ] {
+ }
+ else
+ {
+ if ! $(result[1])
+ {
+ if [ is-rooted $(path) ]
+ {
result = / ;
- } else {
+ }
+ else
+ {
result = . ;
}
}
return $(result[1]) ;
}
}
- } else {
- error "Path '$(path)' has no parent" ;
+ }
+ else
+ {
+ errors.error "Path '$(path)' has no parent" ;
}
}
-#
+
# Returns path2 such that "[ join path path2 ] = .".
# The path may not contain ".." element or be rooted.
#
@@ -130,14 +140,15 @@ rule reverse ( path )
{
local tokens = [ regex.split $(path) "/" ] ;
local tokens2 ;
- for local i in $(tokens) {
+ for local i in $(tokens)
+ {
tokens2 += .. ;
}
return [ sequence.join $(tokens2) : "/" ] ;
}
}
-#
+
# Auxillary rule: does all the semantic of 'join', except for error cheching.
# The error checking is separated because this rule is recursive, and I don't
# like the idea of checking the same input over and over.
@@ -156,7 +167,7 @@ local rule join-imp ( elements + )
return $(result) ;
}
-#
+
# Contanenates the passed path elements. Generates an error if
# any element other than the first one is rooted.
#
@@ -172,7 +183,7 @@ rule join ( elements + )
{
if [ is-rooted $(e) ]
{
- error only first element may be rooted ;
+ errors.error only first element may be rooted ;
}
}
return [ join-imp $(elements) ] ;
@@ -180,7 +191,6 @@ rule join ( elements + )
}
-#
# If 'path' is relative, it is rooted at 'root'. Otherwise, it's unchanged.
#
rule root ( path root )
@@ -192,7 +202,7 @@ rule root ( path root )
}
}
-#
+
# Returns the current working directory.
#
rule pwd ( )
@@ -208,7 +218,7 @@ rule pwd ( )
}
}
-#
+
# Returns the list of files matching the given pattern in the
# specified directory. Both directories and patterns are
# supplied as portable paths. Each pattern should be non-absolute
@@ -251,6 +261,7 @@ rule glob ( dirs * : patterns + : exclude-patterns * )
[ set.difference $(inc) : $(exc) ] ] ;
}
+
# Recursive version of GLOB. Builds the glob of files while
# also searching in the subdirectories of the given roots. An
# optional set of exclusion patterns will filter out the
@@ -267,6 +278,7 @@ rule glob-tree ( roots * : patterns + : exclude-patterns * )
] ] ;
}
+
local rule .glob-tree ( roots * : patterns * : exclude-patterns * )
{
local excluded ;
@@ -290,7 +302,6 @@ local rule .glob-tree ( roots * : patterns * : exclude-patterns * )
}
-#
# Returns true is the specified file exists.
#
rule exists ( file )
@@ -300,8 +311,6 @@ rule exists ( file )
NATIVE_RULE path : exists ;
-
-#
# Find out the absolute name of path and returns the list of all the parents,
# starting with the immediate one. Parents are returned as relative names.
# If 'upper_limit' is specified, directories above it will be pruned.
@@ -323,7 +332,8 @@ rule all-parents ( path : upper_limit ? : cwd ? )
}
# All upper elements removed ?
- if ! $(upper_ele) {
+ if ! $(upper_ele)
+ {
# Create the relative paths to parents, number of elements in 'path_ele'
local result ;
for local i in $(path_ele) {
@@ -332,13 +342,13 @@ rule all-parents ( path : upper_limit ? : cwd ? )
}
return $(result) ;
}
- else {
- error "$(upper_limit) is not prefix of $(path)" ;
+ else
+ {
+ errors.error "$(upper_limit) is not prefix of $(path)" ;
}
}
-#
# Search for 'pattern' in parent directories of 'dir', up till and including
# 'upper_limit', if it is specified, or till the filesystem root otherwise.
#
@@ -355,7 +365,7 @@ rule glob-in-parents ( dir : patterns + : upper-limit ? )
return $(result) ;
}
-#
+
# Assuming 'child' is a subdirectory of 'parent', return the relative
# path from 'parent' to 'child'
#
@@ -393,6 +403,7 @@ rule relative ( child parent )
}
}
+
# Returns the minimal path to path2 that is relative path1.
#
rule relative-to ( path1 path2 )
@@ -417,6 +428,7 @@ rule relative-to ( path1 path2 )
return [ join . $(root_1) $(split2) ] ;
}
+
# Returns the list of paths which are used by the operating system
# for looking up programs
rule programs-path ( )
@@ -433,6 +445,7 @@ rule programs-path ( )
return $(result) ;
}
+
rule make-NT ( native )
{
local tokens = [ regex.split $(native) "[/\\]" ] ;
@@ -459,6 +472,7 @@ rule make-NT ( native )
return $(result) ;
}
+
rule native-NT ( path )
{
local result = [ MATCH "^/?(.*)" : $(path) ] ;
@@ -466,6 +480,7 @@ rule native-NT ( path )
return $(result) ;
}
+
rule make-UNIX ( native )
{
# VP: I have no idea now 'native' can be empty here! But it can!
@@ -479,16 +494,19 @@ rule make-UNIX ( native )
}
}
+
rule native-UNIX ( path )
{
return $(path) ;
}
+
rule make-CYGWIN ( path )
{
return [ make-NT $(path) ] ;
}
+
rule native-CYGWIN ( path )
{
local result = $(path) ;
@@ -499,7 +517,7 @@ rule native-CYGWIN ( path )
return [ native-UNIX $(result) ] ;
}
-#
+
# split-VMS: splits input native path into
# device dir file (each part is optional),
# example:
@@ -516,7 +534,7 @@ rule split-path-VMS ( native )
return $(device) $(dir) $(file) ;
}
-#
+
# Converts a native VMS path into a portable path spec.
#
# Does not handle current-device absolute paths such
@@ -592,7 +610,7 @@ rule make-VMS ( native )
return $(portable) ;
}
-#
+
# Converts a portable path spec into a native VMS path.
#
# Relies on having at least one dot (".") included in the file
@@ -663,8 +681,8 @@ rule native-VMS ( path )
}
-rule __test__ ( ) {
-
+rule __test__ ( )
+{
import assert ;
import errors : try catch ;
@@ -694,7 +712,6 @@ rule __test__ ( ) {
assert.result ".." : parent "../foo" ;
assert.result "../../foo" : parent "../../foo/bar" ;
-
assert.result "." : reverse "." ;
assert.result ".." : reverse "foo" ;
assert.result "../../.." : reverse "foo/bar/giz" ;
@@ -820,5 +837,4 @@ rule __test__ ( ) {
assert.result "disk:[my_docs.work]Jamfile." : native "/disk:/my_docs/work/Jamfile." ;
modules.poke path : os : $(save-os) ;
-
}