Create the associated platform at demand.
This commit is contained in:
parent
daad1c98c6
commit
41d23b6249
|
@ -14,14 +14,6 @@ from . import _global
|
||||||
|
|
||||||
class Builder:
|
class Builder:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
platformClass = PlatformInfo.all_platforms[option('target_platform')]
|
|
||||||
if neutralEnv('distname') not in platformClass.compatible_hosts:
|
|
||||||
print(('ERROR: The target platform {} cannot be build on host {}.\n'
|
|
||||||
'Select another target platform, or change your host system.'
|
|
||||||
).format(option('target_platform'), self.distname))
|
|
||||||
sys.exit(-1)
|
|
||||||
self.platform = platform = platformClass()
|
|
||||||
|
|
||||||
_targets = {}
|
_targets = {}
|
||||||
targetDef = (option('target_platform'), option('targets'))
|
targetDef = (option('target_platform'), option('targets'))
|
||||||
self.add_targets(targetDef, _targets)
|
self.add_targets(targetDef, _targets)
|
||||||
|
@ -40,7 +32,7 @@ class Builder:
|
||||||
if targetDef in targets:
|
if targetDef in targets:
|
||||||
return
|
return
|
||||||
targetPlatformName, targetName = targetDef
|
targetPlatformName, targetName = targetDef
|
||||||
targetPlatform = PlatformInfo.all_platforms[targetPlatformName]
|
targetPlatform = PlatformInfo.get_platform(targetPlatformName)
|
||||||
targetClass = Dependency.all_deps[targetName]
|
targetClass = Dependency.all_deps[targetName]
|
||||||
targets[('source', targetName)] = targetClass.Source
|
targets[('source', targetName)] = targetClass.Source
|
||||||
targets[targetDef] = targetClass.Builder
|
targets[targetDef] = targetClass.Builder
|
||||||
|
@ -58,7 +50,7 @@ class Builder:
|
||||||
# build step two lines later.
|
# build step two lines later.
|
||||||
return
|
return
|
||||||
target = _targets[targetDef]
|
target = _targets[targetDef]
|
||||||
targetPlatform = PlatformInfo.all_platforms[targetPlatformName]
|
targetPlatform = PlatformInfo.get_platform(targetPlatformName)
|
||||||
yield ('source', targetName)
|
yield ('source', targetName)
|
||||||
for dep in target.get_dependencies(targetPlatform):
|
for dep in target.get_dependencies(targetPlatform):
|
||||||
try:
|
try:
|
||||||
|
@ -100,7 +92,7 @@ class Builder:
|
||||||
if tlbuilderDef[0] == 'neutral':
|
if tlbuilderDef[0] == 'neutral':
|
||||||
env = _global._neutralEnv
|
env = _global._neutralEnv
|
||||||
else:
|
else:
|
||||||
env = PlatformInfo.all_running_platforms[tlbuilderDef[0]].buildEnv
|
env = PlatformInfo.get_platform(tlbuilderDef[0]).buildEnv
|
||||||
builder = get_plt_step(tlbuilderDef)(toolchainClass, source, env)
|
builder = get_plt_step(tlbuilderDef)(toolchainClass, source, env)
|
||||||
add_plt_step(tlbuilderDef, builder)
|
add_plt_step(tlbuilderDef, builder)
|
||||||
builder.build()
|
builder.build()
|
||||||
|
@ -110,7 +102,7 @@ class Builder:
|
||||||
for builderDef in builderDefs:
|
for builderDef in builderDefs:
|
||||||
depClass = Dependency.all_deps[builderDef[1]]
|
depClass = Dependency.all_deps[builderDef[1]]
|
||||||
source = get_target_step(builderDef[1], 'source')
|
source = get_target_step(builderDef[1], 'source')
|
||||||
env = PlatformInfo.all_running_platforms[builderDef[0]].buildEnv
|
env = PlatformInfo.get_platform(builderDef[0]).buildEnv
|
||||||
builder = get_target_step(builderDef)(depClass, source, env)
|
builder = get_target_step(builderDef)(depClass, source, env)
|
||||||
if option('make_dist') and builderDef[1] == option('targets'):
|
if option('make_dist') and builderDef[1] == option('targets'):
|
||||||
print("make dist {}:".format(builder.name))
|
print("make dist {}:".format(builder.name))
|
||||||
|
@ -126,9 +118,11 @@ class Builder:
|
||||||
print("[SETUP PLATFORMS]")
|
print("[SETUP PLATFORMS]")
|
||||||
self.prepare_toolchain_sources()
|
self.prepare_toolchain_sources()
|
||||||
self.build_toolchains()
|
self.build_toolchains()
|
||||||
self.platform.finalize_setup()
|
for platform in PlatformInfo.all_running_platforms.values():
|
||||||
|
platform.finalize_setup()
|
||||||
print("[INSTALL PACKAGES]")
|
print("[INSTALL PACKAGES]")
|
||||||
self.platform.install_packages()
|
for platform in PlatformInfo.all_running_platforms.values():
|
||||||
|
platform.install_packages()
|
||||||
print("[PREPARE]")
|
print("[PREPARE]")
|
||||||
self.prepare_sources()
|
self.prepare_sources()
|
||||||
print("[BUILD]")
|
print("[BUILD]")
|
||||||
|
@ -136,7 +130,8 @@ class Builder:
|
||||||
# No error, clean intermediate file at end of build if needed.
|
# No error, clean intermediate file at end of build if needed.
|
||||||
print("[CLEAN]")
|
print("[CLEAN]")
|
||||||
if option('clean_at_end'):
|
if option('clean_at_end'):
|
||||||
self.platform.clean_intermediate_directories()
|
for platform in PlatformInfo.all_running_platforms.values():
|
||||||
|
platform.clean_intermediate_directories()
|
||||||
else:
|
else:
|
||||||
print("SKIP")
|
print("SKIP")
|
||||||
except StopBuild:
|
except StopBuild:
|
||||||
|
|
|
@ -27,7 +27,18 @@ class PlatformInfo(metaclass=_MetaPlatform):
|
||||||
toolchain_names = []
|
toolchain_names = []
|
||||||
configure_option = ""
|
configure_option = ""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_platform(cls, name):
|
||||||
|
if name not in cls.all_running_platforms:
|
||||||
|
cls.all_running_platforms[name] = cls.all_platforms[name]()
|
||||||
|
return cls.all_running_platforms[name]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
if neutralEnv('distname') not in self.compatible_hosts:
|
||||||
|
print(('ERROR: The target platform {} cannot be build on host {}.\n'
|
||||||
|
'Select another target platform, or change your host system.'
|
||||||
|
).format(self.name, neutralEnv('distname')))
|
||||||
|
sys.exit(-1)
|
||||||
self.all_running_platforms[self.name] = self
|
self.all_running_platforms[self.name] = self
|
||||||
self.buildEnv = BuildEnv(self)
|
self.buildEnv = BuildEnv(self)
|
||||||
self.setup_toolchains()
|
self.setup_toolchains()
|
||||||
|
|
Loading…
Reference in New Issue