Skip to content

Fixed exporters to support features #1959

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 4 additions & 34 deletions tools/build_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
24 changes: 24 additions & 0 deletions tools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,30 @@ def validate_config(self):
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".
Expand Down
21 changes: 13 additions & 8 deletions tools/export/exporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):
# 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)
Expand All @@ -155,15 +155,20 @@ def scan_and_copy_resources(self, prj_paths, trg_path, relative=False):

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:
Expand Down