mirror of
https://github.com/boostorg/build.git
synced 2026-02-15 13:02:11 +00:00
Major update of top level 'build_system.py' module.
[SVN r64351]
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
# all copies. This software is provided "as is" without express or implied
|
||||
# warranty, and with no claim as to its suitability for any purpose.
|
||||
|
||||
import feature
|
||||
import b2.build.feature
|
||||
feature = b2.build.feature
|
||||
|
||||
from b2.util.utility import *
|
||||
import b2.build.property_set as property_set
|
||||
|
||||
@@ -145,7 +147,7 @@ def convert_command_line_element(e):
|
||||
else:
|
||||
result = [e1 + "/" + e2 for e1 in result for e2 in lresult]
|
||||
|
||||
return result
|
||||
return [property_set.create(b2.build.feature.split(r)) for r in result]
|
||||
|
||||
###
|
||||
### rule __test__ ( )
|
||||
|
||||
@@ -81,9 +81,11 @@ import property, project, virtual_target, property_set, feature, generators, too
|
||||
from virtual_target import Subvariant
|
||||
from b2.exceptions import *
|
||||
from b2.util.sequence import unique
|
||||
from b2.util import set, path, bjam_signature
|
||||
from b2.util import path, bjam_signature
|
||||
from b2.build.errors import user_error_checkpoint
|
||||
|
||||
import b2.util.set
|
||||
|
||||
_re_separate_target_from_properties = re.compile (r'^([^<]*)(/(<.*))?$')
|
||||
|
||||
class TargetRegistry:
|
||||
@@ -357,7 +359,7 @@ class ProjectTarget (AbstractTarget):
|
||||
self.main_target_ = {}
|
||||
|
||||
# Targets marked as explicit.
|
||||
self.explicit_targets_ = []
|
||||
self.explicit_targets_ = set()
|
||||
|
||||
# The constants defined for this project.
|
||||
self.constants_ = {}
|
||||
@@ -426,7 +428,7 @@ class ProjectTarget (AbstractTarget):
|
||||
|
||||
# Record the name of the target, not instance, since this
|
||||
# rule is called before main target instaces are created.
|
||||
self.explicit_.append(target_name)
|
||||
self.explicit_targets_.add(target_name)
|
||||
|
||||
def add_alternative (self, target_instance):
|
||||
""" Add new target alternative.
|
||||
@@ -575,7 +577,7 @@ class ProjectTarget (AbstractTarget):
|
||||
if not rules:
|
||||
rules = []
|
||||
user_rules = [x for x in rules
|
||||
if x not in self.manager().projects().project_rules()]
|
||||
if x not in self.manager().projects().project_rules().all_names()]
|
||||
if user_rules:
|
||||
bjam.call("import-rules-from-parent", parent_module, this_module, user_rules)
|
||||
|
||||
@@ -636,14 +638,14 @@ class MainTarget (AbstractTarget):
|
||||
best_properties = properties
|
||||
|
||||
else:
|
||||
if set.equal (properties, best_properties):
|
||||
if b2.util.set.equal (properties, best_properties):
|
||||
return None
|
||||
|
||||
elif set.contains (properties, best_properties):
|
||||
elif b2.util.set.contains (properties, best_properties):
|
||||
# Do nothing, this alternative is worse
|
||||
pass
|
||||
|
||||
elif set.contains (best_properties, properties):
|
||||
elif b2.util.set.contains (best_properties, properties):
|
||||
best = v
|
||||
best_properties = properties
|
||||
|
||||
@@ -1006,12 +1008,12 @@ class BasicTarget (AbstractTarget):
|
||||
# build request just to select this variant.
|
||||
bcondition = self.requirements_.base ()
|
||||
ccondition = self.requirements_.conditional ()
|
||||
condition = set.difference (bcondition, ccondition)
|
||||
condition = b2.util.set.difference (bcondition, ccondition)
|
||||
|
||||
if debug:
|
||||
print " next alternative: required properties:", str(condition)
|
||||
|
||||
if set.contains (condition, property_set.raw ()):
|
||||
if b2.util.set.contains (condition, property_set.raw ()):
|
||||
|
||||
if debug:
|
||||
print " matched"
|
||||
|
||||
1025
v2/build_system.py
1025
v2/build_system.py
File diff suppressed because it is too large
Load Diff
@@ -668,6 +668,8 @@ class Tester(TestCmd.TestCmd):
|
||||
|
||||
self.ignore("bin/config.log")
|
||||
|
||||
self.ignore("*.pyc")
|
||||
|
||||
if not self.unexpected_difference.empty():
|
||||
annotation('failure', 'Unexpected changes found')
|
||||
output = StringIO.StringIO()
|
||||
|
||||
@@ -29,10 +29,10 @@ int main() {}
|
||||
""")
|
||||
|
||||
t.write("jamroot.jam", """
|
||||
using dll-paths ;
|
||||
using dll_paths ;
|
||||
""")
|
||||
|
||||
t.write("dll-paths.jam", """
|
||||
t.write("dll_paths.jam", """
|
||||
import type ;
|
||||
import generators ;
|
||||
import feature ;
|
||||
|
||||
@@ -8,9 +8,7 @@ import BoostBuild
|
||||
|
||||
t = BoostBuild.Tester()
|
||||
|
||||
t.write("jamroot.jam", "")
|
||||
|
||||
t.write("jamfile.jam", """
|
||||
t.write("jamroot.jam", """
|
||||
exe hello : hello.cpp ;
|
||||
exe hello2 : hello.cpp ;
|
||||
explicit hello2 ;
|
||||
|
||||
34
v2/util/option.py
Normal file
34
v2/util/option.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Copyright (c) 2005-2010 Vladimir Prus.
|
||||
#
|
||||
# Use, modification and distribution is subject to the Boost Software
|
||||
# License Version 1.0. (See accompanying file LICENSE_1_0.txt or
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
import sys
|
||||
import b2.util.regex
|
||||
|
||||
options = {}
|
||||
|
||||
# Set a value for a named option, to be used when not overridden on the command
|
||||
# line.
|
||||
def set(name, value=None):
|
||||
|
||||
global options
|
||||
|
||||
options[name] = value
|
||||
|
||||
def get(name, default_value=None, implied_value=None):
|
||||
|
||||
global options
|
||||
|
||||
matches = b2.util.regex.transform(sys.argv, "--$(name)=(.*)")
|
||||
if matches:
|
||||
return matches[-1]
|
||||
else:
|
||||
m = b2.util.regex.transform(sys.argv, "--$(name)")
|
||||
if m and implied_value:
|
||||
return implied_value
|
||||
elif options.has_key(name):
|
||||
return options[name]
|
||||
else:
|
||||
return default_value
|
||||
105
v2/util/path.py
105
v2/util/path.py
@@ -303,70 +303,47 @@ def glob (dirs, patterns):
|
||||
result.extend (glob.glob (p))
|
||||
return result
|
||||
|
||||
# #
|
||||
# # Returns true is the specified file exists.
|
||||
# #
|
||||
# rule exists ( file )
|
||||
# {
|
||||
# return [ path.glob $(file:D) : $(file:D=) ] ;
|
||||
# }
|
||||
# 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.
|
||||
# #
|
||||
# rule all-parents ( path : upper_limit ? : cwd ? )
|
||||
# {
|
||||
# cwd ?= [ pwd ] ;
|
||||
# local path_ele = [ regex.split [ root $(path) $(cwd) ] "/" ] ;
|
||||
#
|
||||
# if ! $(upper_limit) {
|
||||
# upper_limit = / ;
|
||||
# }
|
||||
# local upper_ele = [ regex.split [ root $(upper_limit) $(cwd) ] "/" ] ;
|
||||
#
|
||||
# # Leave only elements in 'path_ele' below 'upper_ele'
|
||||
# while $(path_ele) && $(upper_ele[1]) = $(path_ele[1]) {
|
||||
# upper_ele = $(upper_ele[2-]) ;
|
||||
# path_ele = $(path_ele[2-]) ;
|
||||
# }
|
||||
#
|
||||
# # All upper elements removed ?
|
||||
# if ! $(upper_ele) {
|
||||
# # Create the relative paths to parents, number of elements in 'path_ele'
|
||||
# local result ;
|
||||
# for local i in $(path_ele) {
|
||||
# path = [ parent $(path) ] ;
|
||||
# result += $(path) ;
|
||||
# }
|
||||
# return $(result) ;
|
||||
# }
|
||||
# else {
|
||||
# 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.
|
||||
# #
|
||||
# rule glob-in-parents ( dir : patterns + : upper-limit ? )
|
||||
# {
|
||||
# local result ;
|
||||
# local parent-dirs = [ all-parents $(dir) : $(upper-limit) ] ;
|
||||
#
|
||||
# while $(parent-dirs) && ! $(result)
|
||||
# {
|
||||
# result = [ glob $(parent-dirs[1]) : $(patterns) ] ;
|
||||
# parent-dirs = $(parent-dirs[2-]) ;
|
||||
# }
|
||||
# return $(result) ;
|
||||
# }
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
def all_parents(path, upper_limit=None, cwd=None):
|
||||
|
||||
if not cwd:
|
||||
cwd = os.getcwd()
|
||||
|
||||
path_abs = os.path.join(cwd, path)
|
||||
|
||||
if upper_limit:
|
||||
upper_limit = os.path.join(cwd, upper_limit)
|
||||
|
||||
result = []
|
||||
while path_abs and path_abs != upper_limit:
|
||||
(head, tail) = os.path.split(path)
|
||||
path = os.path.join(path, "..")
|
||||
result.append(path)
|
||||
path_abs = head
|
||||
|
||||
if upper_limit and path_abs != upper_limit:
|
||||
raise BaseException("'%s' is not a prefix of '%s'" % (upper_limit, path))
|
||||
|
||||
return result
|
||||
|
||||
# Search for 'pattern' in parent directories of 'dir', up till and including
|
||||
# 'upper_limit', if it is specified, or till the filesystem root otherwise.
|
||||
#
|
||||
def glob_in_parents(dir, patterns, upper_limit=None):
|
||||
|
||||
result = []
|
||||
parent_dirs = all_parents(dir, upper_limit)
|
||||
|
||||
for p in parent_dirs:
|
||||
result = glob(p, patterns)
|
||||
if result: break
|
||||
|
||||
return result
|
||||
|
||||
#
|
||||
# #
|
||||
# # Assuming 'child' is a subdirectory of 'parent', return the relative
|
||||
|
||||
Reference in New Issue
Block a user