mirror of
https://github.com/boostorg/build.git
synced 2026-02-15 00:52:16 +00:00
Provide help message when generator is handed empty list of sources.
In Jam, the language itself would raise an error when the sources list was empty. In the Python port, it was assumed that sources was never empty and would run into an IndexError when the empty sources list tried to access the first element. This change checks sources first and provides an error message in the event that sources is empty. An empty source list can be passed in when the best alternative evalutates to an empty list of sources. This target is then added to a typed target, e.g. lib, which requires sources.
This commit is contained in:
@@ -53,6 +53,7 @@ import os.path
|
||||
|
||||
from virtual_target import Subvariant
|
||||
from . import virtual_target, type, property_set, property
|
||||
from b2.exceptions import BaseBoostBuildException
|
||||
from b2.util.logger import *
|
||||
from b2.util.utility import *
|
||||
from b2.util import set as set_, is_iterable_typed, is_iterable
|
||||
@@ -158,6 +159,13 @@ def dout(message):
|
||||
if debug():
|
||||
print __indent + message
|
||||
|
||||
|
||||
class InvalidTargetSource(BaseBoostBuildException):
|
||||
"""
|
||||
Should be raised when a target contains a source that is invalid.
|
||||
"""
|
||||
|
||||
|
||||
class Generator:
|
||||
""" Creates a generator.
|
||||
manager: the build manager.
|
||||
@@ -336,11 +344,16 @@ class Generator:
|
||||
assert isinstance(name, basestring) or name is None
|
||||
assert isinstance(prop_set, property_set.PropertySet)
|
||||
assert is_iterable_typed(sources, virtual_target.VirtualTarget)
|
||||
|
||||
if project.manager ().logger ().on ():
|
||||
project.manager ().logger ().log (__name__, " generator '%s'" % self.id_)
|
||||
project.manager ().logger ().log (__name__, " composing: '%s'" % self.composing_)
|
||||
|
||||
if not sources:
|
||||
s = 'An empty source list was passed in to the "{}" generator'.format(self.id_)
|
||||
if name:
|
||||
s += ' for target "{}"'.format(name)
|
||||
raise InvalidTargetSource(s)
|
||||
|
||||
if not self.composing_ and len (sources) > 1 and len (self.source_types_) > 1:
|
||||
raise BaseException ("Unsupported source/source_type combination")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user