in builder/core/spec.py [0:0]
def __init__(self, **kwargs):
for slot in ('host', 'target', 'arch', 'compiler', 'compiler_version'):
setattr(self, slot, 'default')
self.downstream = False
spec = kwargs.get('spec', None)
if spec:
if spec.startswith('default'): # default or default(-{variant})
_, *rest = spec.split('-')
elif not '-' in spec: # just a variant
rest = [spec]
else: # Parse the spec from a single string
self.host, self.compiler, self.compiler_version, self.target, self.arch, * \
rest = spec.split('-')
for variant in ('downstream',):
if variant in rest:
setattr(self, variant, True)
else:
setattr(self, variant, False)
# Pull out individual fields. Note this is not in an else to support overriding at construction time
for slot in ('host', 'target', 'arch', 'compiler', 'compiler_version', 'downstream'):
if slot in kwargs and kwargs[slot]:
setattr(self, slot, kwargs[slot])
# Convert a target tuple into its component parts
if '-' in self.target:
self.target, self.arch = self.target.split('-')
# Convert defaults to be based on running environment
if self.host == 'default':
self.host = current_host()
if self.target == 'default':
self.target = current_os()
if self.arch == 'default':
self.arch = current_arch()
else:
self.arch = normalize_arch(self.arch)
self.name = '-'.join([self.host, self.compiler,
self.compiler_version, self.target, self.arch])
if self.downstream:
self.name += "-downstream"
validate_spec(self)