2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-14 12:42:11 +00:00

Miscellaneous improvements from Aaron Boman.

feature.py:

Use the feature's name in the error output. This helps in understanding the
error message.

project.py:

The original looked like the result of a bad merge as the return value was the
exact same as the return within the try...except block. The try...except
produces a better error message upon failure.

property_set.py:

The string module is unused.

virtual_target.py:

ARM's ar.exe would fail when passed a path to the -via file that had both
POSIX and Windows path separators. Normalizing the path on the target solved
the problem.

common.py:

The requirement parameter in check_init_parameters should be a container. The
original Jam signature marks it as a list with zero or more items. These
changes convert the requirement parameter to using only a container.

msvc.py:

The call to to_seq asserts that command is always some container. So, extend()
should always be used.

tools/rc.py:

Old style exceptions aren't allowed (at least in Python 2.7). This change just
uses the existing AlreadyDefined exception.

testing.py:

loaded_tool_module_path_ is empty upon initial import. Using the __file__
variable instead will always work (provided the import system doesn't change).
This commit is contained in:
Vladimir Prus
2014-10-07 11:24:20 +04:00
8 changed files with 16 additions and 15 deletions

View File

@@ -442,7 +442,7 @@ def validate_value_string (f, value_string):
# An empty value is allowed for optional features
if not values[0] in f.values() and \
(values[0] or not f.optional()):
raise InvalidValue ("'%s' is not a known value of feature '%s'\nlegal values: '%s'" % (values [0], feature, f.values()))
raise InvalidValue ("'%s' is not a known value of feature '%s'\nlegal values: '%s'" % (values [0], f.name(), f.values()))
for v in values [1:]:
# this will validate any subfeature values in value-string

View File

@@ -529,7 +529,6 @@ actual value %s""" % (jamfile_module, saved_project, self.current_project))
def attribute(self, project, attribute):
"""Returns the value of the specified attribute in the
specified jamfile module."""
return self.module2attributes[project].get(attribute)
try:
return self.module2attributes[project].get(attribute)
except:
@@ -708,6 +707,7 @@ actual value %s""" % (jamfile_module, saved_project, self.current_project))
__import__(mname)
module = sys.modules[mname]
self.loaded_tool_modules_[name] = module
self.loaded_tool_module_path_[mname] = module.__file__
return module
self.manager.errors()("Cannot find module '%s'" % name)

View File

@@ -9,7 +9,7 @@
import hashlib
from b2.util.utility import *
import property, feature, string
import property, feature
import b2.build.feature
from b2.exceptions import *
from b2.util.sequence import unique

View File

@@ -708,7 +708,7 @@ class FileTarget (AbstractFileTarget):
# any more
self.path_ = target_path
return self.path_
return os.path.normpath(self.path_)
class NotFileTarget(AbstractFileTarget):

View File

@@ -174,14 +174,17 @@ def check_init_parameters(toolset, requirement, *args):
The return value from this rule is a condition to be used for flags settings.
"""
from b2.build import toolset as b2_toolset
if requirement is None:
requirement = []
# The type checking here is my best guess about
# what the types should be.
assert(isinstance(toolset, str))
assert(isinstance(requirement, str) or requirement is None)
# iterable and not a string, allows for future support of sets
assert(not isinstance(requirement, basestring) and hasattr(requirement, '__contains__'))
sig = toolset
condition = replace_grist(toolset, '<toolset>')
subcondition = []
for arg in args:
assert(isinstance(arg, tuple))
assert(len(arg) == 2)
@@ -237,7 +240,7 @@ def check_init_parameters(toolset, requirement, *args):
# if a requirement is specified, the signature should be unique
# with that requirement
if requirement:
sig += '-' + requirement
sig += '-' + '-'.join(requirement)
if __all_signatures.has_key(sig):
message = "duplicate initialization of '%s' with the following parameters: " % toolset
@@ -259,7 +262,7 @@ def check_init_parameters(toolset, requirement, *args):
# condition. To accomplish this we add a toolset requirement that imposes
# the toolset subcondition, which encodes the version.
if requirement:
r = ['<toolset>' + toolset, requirement]
r = ['<toolset>' + toolset] + requirement
r = ','.join(r)
b2_toolset.add_requirements([r + ':' + c for c in subcondition])
@@ -267,7 +270,7 @@ def check_init_parameters(toolset, requirement, *args):
# variables and options to this specific version.
condition = [condition]
if requirement:
condition += [requirement]
condition += requirement
if __show_configuration:
print "notice:", condition

View File

@@ -115,10 +115,7 @@ def init(version = None, command = None, options = None):
command = to_seq(command)
if command:
if isinstance(command, str):
options.append('<command>' + command)
else:
options.extend("<command>"+cmd for cmd in command)
options.extend("<command>"+cmd for cmd in command)
configure(version,options)
def configure(version=None, options=None):

View File

@@ -27,6 +27,7 @@ import re
import bjam
from b2.build import type, toolset, generators, scanner, feature
from b2.exceptions import AlreadyDefined
from b2.tools import builtin
from b2.util import regex
from b2.build.toolset import flags
@@ -91,7 +92,7 @@ class RCAction:
def rc_register_action(action_name, function = None):
global engine
if engine.actions.has_key(action_name):
raise "Bjam action %s is already defined" % action_name
raise AlreadyDefined("Bjam action %s is already defined" % action_name)
engine.actions[action_name] = RCAction(action_name, function)
def rc_compile_resource(targets, sources, properties):

View File

@@ -322,7 +322,7 @@ get_manager().engine().register_bjam_action("testing.capture-output",
capture_output_setup)
path = os.path.dirname(get_manager().projects().loaded_tool_module_path_[__name__])
path = os.path.dirname(__file__)
import b2.util.os_j
get_manager().projects().project_rules()._import_rule("testing", "os.name",
b2.util.os_j.name)