Merge pull request #1959 from screamerbg/exporter-features

Fixed exporters to support features
pull/1966/merge
Sam Grove 2016-06-17 00:01:36 +01:00 committed by GitHub
commit 40d4599431
3 changed files with 41 additions and 42 deletions

View File

@ -214,23 +214,8 @@ def build_project(src_path, build_path, target, toolchain_name,
else:
resources.inc_dirs.append(inc_dirs)
# Update configuration files until added features creates no changes
prev_features = set()
while True:
# Update the configuration with any .json files found while scanning
config.add_config_files(resources.json_files)
# Add features while we find new ones
features = config.get_features()
if features == prev_features:
break
for feature in features:
if feature in resources.features:
resources.add(resources.features[feature])
prev_features = features
config.validate_config()
# Load resources into the config system which might expand/modify resources based on config data
resources = config.load_resources(resources)
# Set the toolchain's config header with the config data
toolchain.set_config_header_content(config.get_config_data_header())
@ -373,23 +358,8 @@ def build_library(src_paths, build_path, target, toolchain_name,
# Handle configuration
config = Config(target)
# Update configuration files until added features creates no changes
prev_features = set()
while True:
# Update the configuration with any .json files found while scanning
config.add_config_files(resources.json_files)
# Add features while we find new ones
features = config.get_features()
if features == prev_features:
break
for feature in features:
if feature in resources.features:
resources.add(resources.features[feature])
prev_features = features
config.validate_config()
# Load resources into the config system which might expand/modify resources based on config data
resources = config.load_resources(resources)
# Set the toolchain's config header with the config data
toolchain.set_config_header_content(config.get_config_data_header())

View File

@ -396,6 +396,30 @@ class Config:
raise self.config_errors[0]
return True
# Loads configuration data from resources. Also expands resources based on defined features settings
def load_resources(self, resources):
# Update configuration files until added features creates no changes
prev_features = set()
while True:
# Add/update the configuration with any .json files found while scanning
self.add_config_files(resources.json_files)
# Add features while we find new ones
features = self.get_features()
if features == prev_features:
break
for feature in features:
if feature in resources.features:
resources.add(resources.features[feature])
prev_features = features
self.validate_config()
return resources
# Return the configuration data converted to the content of a C header file,
# meant to be included to a C/C++ file. The content is returned as a string.
# If 'fname' is given, the content is also written to the file called "fname".

View File

@ -129,7 +129,7 @@ class Exporter(object):
# Copy only the file for the required target and toolchain
lib_builds = []
# Create the configuration object
cfg = Config(self.target, prj_paths)
config = Config(self.target, prj_paths)
for src in ['lib', 'src']:
resources = reduce(add, [self.__scan_and_copy(join(path, src), trg_path) for path in prj_paths])
lib_builds.extend(resources.lib_builds)
@ -155,15 +155,20 @@ class Exporter(object):
if not relative:
# Final scan of the actual exported resources
self.resources = self.toolchain.scan_resources(trg_path)
self.resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
resources = self.toolchain.scan_resources(trg_path)
resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
else:
# use the prj_dir (source, not destination)
self.resources = reduce(add, [self.toolchain.scan_resources(path) for path in prj_paths])
# Add all JSON files discovered during scanning to the configuration object
cfg.add_config_files(self.resources.json_files)
# Get data from the configuration system
self.config_macros = cfg.get_config_data_macros()
resources = self.toolchain.scan_resources(prj_paths[0])
for path in prj_paths[1:]:
resources.add(toolchain.scan_resources(path))
# Loads the resources into the config system which might expand/modify resources based on config data
self.resources = config.load_resources(resources)
# And add the configuration macros to the toolchain
self.config_macros = config.get_config_data_macros()
# Check the existence of a binary build of the mbed library for the desired target
# This prevents exporting the mbed libraries from source
# if not self.toolchain.mbed_libs: