diff --git a/v2/build/errors.py b/v2/build/errors.py index 83b39e982..8e17a73c0 100644 --- a/v2/build/errors.py +++ b/v2/build/errors.py @@ -97,6 +97,10 @@ class Errors: def __init__(self): self.contexts_ = [] + self._count = 0 + + def count(self): + return self._count def push_user_context(self, message, nested=None): self.contexts_.append(Context(message, nested)) @@ -117,6 +121,7 @@ class Errors: raise ExceptionWithUserContext("unexpected exception", self.contexts_[:], e, sys.exc_info()[2]) def __call__(self, message): + self._count = self._count + 1 raise ExceptionWithUserContext(message, self.contexts_[:], stack=traceback.extract_stack()) diff --git a/v2/build/targets.py b/v2/build/targets.py index 39b127a5c..918c23fd6 100644 --- a/v2/build/targets.py +++ b/v2/build/targets.py @@ -76,6 +76,8 @@ import re import os.path import sys +from b2.manager import get_manager + from b2.util.utility import * import property, project, virtual_target, property_set, feature, generators, toolset from virtual_target import Subvariant @@ -84,6 +86,8 @@ from b2.util.sequence import unique from b2.util import path, bjam_signature from b2.build.errors import user_error_checkpoint +import b2.build.build_request as build_request + import b2.util.set _re_separate_target_from_properties = re.compile (r'^([^<]*)(/(<.*))?$') @@ -594,10 +598,10 @@ class MainTarget (AbstractTarget): d = target.default_build () if self.alternatives_ and self.default_build_ != d: - raise BaseException ("Default build must be identical in all alternatives\n" + get_manager().errors()("default build must be identical in all alternatives\n" "main target is '%s'\n" "with '%s'\n" - "differing from previous default build: '%s'" % (full_name (), d.raw (), self.default_build_.raw ())) + "differing from previous default build: '%s'" % (self.full_name (), d.raw (), self.default_build_.raw ())) else: self.default_build_ = d @@ -687,7 +691,8 @@ class MainTarget (AbstractTarget): # to use here. compressed = feature.compress_subproperties(property_set.all()) - result = build_request.expand_no_defaults (compressed, defaults_to_apply) + result = build_request.expand_no_defaults( + b2.build.property_set.create([p]) for p in (compressed + defaults_to_apply)) else: result.append (property_set) diff --git a/v2/build_system.py b/v2/build_system.py index 1602d5b2e..5bc30c224 100644 --- a/v2/build_system.py +++ b/v2/build_system.py @@ -8,6 +8,8 @@ # 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) + + from b2.build.engine import Engine from b2.manager import Manager from b2.util.path import glob @@ -432,14 +434,14 @@ def main(): if "--profiling" in sys.argv: import cProfile import pstats - cProfile.runctx('main_real()', globals(), locals(), "stones.prof") + return cProfile.runctx('main_real()', globals(), locals(), "stones.prof") stats = pstats.Stats("stones.prof") stats.strip_dirs() stats.sort_stats('time', 'calls') stats.print_callers(20) else: - main_real() + return main_real() def main_real(): @@ -852,3 +854,8 @@ def main_real(): # Prevent automatic update of the 'all' target, now that # we have explicitly updated what we wanted. bjam.call("UPDATE") + + if manager.errors().count() == 0: + return ["ok"] + else: + return [] diff --git a/v2/kernel/bootstrap.jam b/v2/kernel/bootstrap.jam index a629d214f..2a1be1a14 100644 --- a/v2/kernel/bootstrap.jam +++ b/v2/kernel/bootstrap.jam @@ -225,7 +225,11 @@ if ! $(dont-build) module PyBB { - bootstrap $(root) ; + local ok = [ bootstrap $(root) ] ; + if ! $(ok) + { + EXIT ; + } } diff --git a/v2/kernel/bootstrap.py b/v2/kernel/bootstrap.py index cc12add11..2e8dd37b7 100644 --- a/v2/kernel/bootstrap.py +++ b/v2/kernel/bootstrap.py @@ -21,5 +21,5 @@ def bootstrap(root_path): sys.modules["b2"] = m import b2.build_system - b2.build_system.main() + return b2.build_system.main() diff --git a/v2/test/default_build.py b/v2/test/default_build.py index 93d05ae3b..33f2b5bbb 100644 --- a/v2/test/default_build.py +++ b/v2/test/default_build.py @@ -42,7 +42,8 @@ with differing from previous default build debug """ -t.run_build_system("-n --no-error-backtrace", status=1, stdout=expected) +t.run_build_system("-n --no-error-backtrace", status=1) +t.fail_test(t.stdout().find("default build must be identical in all alternatives") == -1) # Test that default-build must be identical in all alternatives. No Error case, # empty default build.