mirror of https://github.com/ARMmbed/mbed-os.git
Fixed exporters to support features
Unified how resources are loaded into the configuration system (Config.load_resources) and applied it to build_api and exporterspull/1959/head
parent
1e18ea230a
commit
89bb38f683
|
@ -214,23 +214,8 @@ def build_project(src_path, build_path, target, toolchain_name,
|
||||||
else:
|
else:
|
||||||
resources.inc_dirs.append(inc_dirs)
|
resources.inc_dirs.append(inc_dirs)
|
||||||
|
|
||||||
# Update configuration files until added features creates no changes
|
# Load resources into the config system which might expand/modify resources based on config data
|
||||||
prev_features = set()
|
resources = config.load_resources(resources)
|
||||||
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()
|
|
||||||
|
|
||||||
# Set the toolchain's config header with the config data
|
# Set the toolchain's config header with the config data
|
||||||
toolchain.set_config_header_content(config.get_config_data_header())
|
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
|
# Handle configuration
|
||||||
config = Config(target)
|
config = Config(target)
|
||||||
|
|
||||||
# Update configuration files until added features creates no changes
|
# Load resources into the config system which might expand/modify resources based on config data
|
||||||
prev_features = set()
|
resources = config.load_resources(resources)
|
||||||
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()
|
|
||||||
|
|
||||||
# Set the toolchain's config header with the config data
|
# Set the toolchain's config header with the config data
|
||||||
toolchain.set_config_header_content(config.get_config_data_header())
|
toolchain.set_config_header_content(config.get_config_data_header())
|
||||||
|
|
|
@ -396,6 +396,30 @@ class Config:
|
||||||
raise self.config_errors[0]
|
raise self.config_errors[0]
|
||||||
return True
|
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,
|
# 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.
|
# 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".
|
# If 'fname' is given, the content is also written to the file called "fname".
|
||||||
|
|
|
@ -129,7 +129,7 @@ class Exporter(object):
|
||||||
# Copy only the file for the required target and toolchain
|
# Copy only the file for the required target and toolchain
|
||||||
lib_builds = []
|
lib_builds = []
|
||||||
# Create the configuration object
|
# Create the configuration object
|
||||||
cfg = Config(self.target, prj_paths)
|
config = Config(self.target, prj_paths)
|
||||||
for src in ['lib', 'src']:
|
for src in ['lib', 'src']:
|
||||||
resources = reduce(add, [self.__scan_and_copy(join(path, src), trg_path) for path in prj_paths])
|
resources = reduce(add, [self.__scan_and_copy(join(path, src), trg_path) for path in prj_paths])
|
||||||
lib_builds.extend(resources.lib_builds)
|
lib_builds.extend(resources.lib_builds)
|
||||||
|
@ -155,15 +155,20 @@ class Exporter(object):
|
||||||
|
|
||||||
if not relative:
|
if not relative:
|
||||||
# Final scan of the actual exported resources
|
# Final scan of the actual exported resources
|
||||||
self.resources = self.toolchain.scan_resources(trg_path)
|
resources = self.toolchain.scan_resources(trg_path)
|
||||||
self.resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
|
resources.relative_to(trg_path, self.DOT_IN_RELATIVE_PATH)
|
||||||
else:
|
else:
|
||||||
# use the prj_dir (source, not destination)
|
# use the prj_dir (source, not destination)
|
||||||
self.resources = reduce(add, [self.toolchain.scan_resources(path) for path in prj_paths])
|
resources = self.toolchain.scan_resources(prj_paths[0])
|
||||||
# Add all JSON files discovered during scanning to the configuration object
|
for path in prj_paths[1:]:
|
||||||
cfg.add_config_files(self.resources.json_files)
|
resources.add(toolchain.scan_resources(path))
|
||||||
# Get data from the configuration system
|
|
||||||
self.config_macros = cfg.get_config_data_macros()
|
# 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
|
# Check the existence of a binary build of the mbed library for the desired target
|
||||||
# This prevents exporting the mbed libraries from source
|
# This prevents exporting the mbed libraries from source
|
||||||
# if not self.toolchain.mbed_libs:
|
# if not self.toolchain.mbed_libs:
|
||||||
|
|
Loading…
Reference in New Issue