Merge toolchain and dependencies.

Toolchain now became "simple" dependencies.
They are referenced by Platform.

Platform are now created at demande and a neutralPlatform now exists.
This commit is contained in:
Matthieu Gautier
2018-05-29 11:40:42 +02:00
parent 9496ffb86c
commit 4d6b6994bc
17 changed files with 87 additions and 174 deletions

View File

@ -8,8 +8,7 @@ from .utils import remove_duplicates, StopBuild
from .dependencies import Dependency
from ._global import (
neutralEnv, option,
add_target_step, get_target_step, target_steps,
add_plt_step, get_plt_step, plt_steps)
add_target_step, get_target_step, target_steps)
from . import _global
class Builder:
@ -20,6 +19,7 @@ class Builder:
dependencies = self.order_dependencies(_targets, targetDef)
dependencies = list(remove_duplicates(dependencies))
PlatformInfo.get_platform('neutral', _targets)
if option('build_nodeps'):
add_target_step(targetDef, _targets[targetDef])
else:
@ -27,12 +27,13 @@ class Builder:
if option('build_deps_only') and dep == targetDef:
continue
add_target_step(dep, _targets[dep])
self.instanciate_steps()
def add_targets(self, targetDef, targets):
if targetDef in targets:
return
targetPlatformName, targetName = targetDef
targetPlatform = PlatformInfo.get_platform(targetPlatformName)
targetPlatform = PlatformInfo.get_platform(targetPlatformName, targets)
targetClass = Dependency.all_deps[targetName]
targets[('source', targetName)] = targetClass.Source
targets[targetDef] = targetClass.Builder
@ -44,6 +45,12 @@ class Builder:
self.add_targets((depPlatform, depName), targets)
def order_dependencies(self, _targets, targetDef):
for pltName in PlatformInfo.all_running_platforms:
plt = PlatformInfo.all_platforms[pltName]
for tlcName in plt.toolchain_names:
tlc = Dependency.all_deps[tlcName]
yield('source', tlcName)
yield('neutral' if tlc.neutral else pltName, tlcName)
targetPlatformName, targetName = targetDef
if targetPlatformName == 'source':
# Do not try to order sources, they will be added as dep by the
@ -60,14 +67,18 @@ class Builder:
yield from self.order_dependencies(_targets, (depPlatform, depName))
yield targetDef
def prepare_toolchain_sources(self):
tlsourceDefs = (tlDef for tlDef in plt_steps() if tlDef[0]=='source')
for tlsourceDef in tlsourceDefs:
print("prepare sources for toolchain {} :".format(tlsourceDef[1]))
toolchainClass = Toolchain.all_toolchains[tlsourceDef[1]]
source = get_plt_step(tlsourceDef)(toolchainClass)
add_plt_step(tlsourceDef, source)
source.prepare()
def instanciate_steps(self):
for stepDef in list(target_steps()):
stepPlatform, stepName = stepDef
stepClass = Dependency.all_deps[stepName]
if stepPlatform == 'source':
source = get_target_step(stepDef)(stepClass)
add_target_step(stepDef, source)
else:
source = get_target_step(stepName, 'source')
env = PlatformInfo.get_platform(stepPlatform).buildEnv
builder = get_target_step(stepDef)(stepClass, source, env)
add_target_step(stepDef, builder)
def prepare_sources(self):
if option('skip_source_prepare'):
@ -76,36 +87,16 @@ class Builder:
sourceDefs = remove_duplicates(tDef for tDef in target_steps() if tDef[0]=='source')
for sourceDef in sourceDefs:
print("prepare sources {} :".format(sourceDef[1]))
depClass = Dependency.all_deps[sourceDef[1]]
source = get_target_step(sourceDef)(depClass)
add_target_step(sourceDef, source)
source = get_target_step(sourceDef)
source.prepare()
def build_toolchains(self):
tlbuilderDefs = (tlDef for tlDef in plt_steps() if tlDef[0] != 'source')
for tlbuilderDef in tlbuilderDefs:
print("build toolchain {} :".format(tlbuilderDef[1]))
toolchainClass = Toolchain.all_toolchains[tlbuilderDef[1]]
source = get_plt_step(tlbuilderDef[1], 'source')
if tlbuilderDef[0] == 'neutral':
env = _global._neutralEnv
else:
env = PlatformInfo.get_platform(tlbuilderDef[0]).buildEnv
builder = get_plt_step(tlbuilderDef)(toolchainClass, source, env)
add_plt_step(tlbuilderDef, builder)
builder.build()
def build(self):
builderDefs = (tDef for tDef in target_steps() if tDef[0] != 'source')
for builderDef in builderDefs:
depClass = Dependency.all_deps[builderDef[1]]
source = get_target_step(builderDef[1], 'source')
env = PlatformInfo.get_platform(builderDef[0]).buildEnv
builder = get_target_step(builderDef)(depClass, source, env)
if option('make_dist') and builderDef[1] == option('targets'):
print("make dist {}:".format(builder.name))
builder = get_target_step(builderDef)
if option('make_dist') and builderName == option('targets'):
print("make dist {} ({}):".format(builder.name, builderDef[0]))
builder.make_dist()
continue
print("build {} ({}):".format(builder.name, builderDef[0]))
@ -116,8 +107,6 @@ class Builder:
def run(self):
try:
print("[SETUP PLATFORMS]")
self.prepare_toolchain_sources()
self.build_toolchains()
for platform in PlatformInfo.all_running_platforms.values():
platform.finalize_setup()
print("[INSTALL PACKAGES]")