Skip to content
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

Custom build_flags by feature #20692

Merged
Merged
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
21 changes: 13 additions & 8 deletions buildroot/share/PlatformIO/scripts/common-dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def add_to_feat_cnf(feature, flines):
parts = dep.split('=')
name = parts.pop(0)
rest = '='.join(parts)
if name in ['extra_scripts', 'src_filter', 'lib_ignore']:
if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']:
feat[name] = rest
else:
feat['lib_deps'] += [dep]
Expand Down Expand Up @@ -132,8 +132,7 @@ def force_ignore_unused_libs():
known_libs = get_all_known_libs()
diff = (list(set(known_libs) - set(env_libs)))
lib_ignore = env.GetProjectOption('lib_ignore') + diff
if verbose:
print("Ignore libraries:", lib_ignore)
blab(f'Ignore libraries: {lib_ignore}')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note this syntax breaks python 2.7 support. Maybe a python version check should be done before ? to avoid weird errors later...

Copy link
Contributor

@tpruvot tpruvot Jan 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the problem is not i dont use python3 but ubuntu 18.04 and fedora 29 (at least) symlink "python" to python2 by default

set_env_field('lib_ignore', lib_ignore)

def apply_features_config():
Expand All @@ -145,7 +144,7 @@ def apply_features_config():
feat = FEATURE_CONFIG[feature]

if 'lib_deps' in feat and len(feat['lib_deps']):
blab("Adding lib_deps for %s... " % feature)
blab(f'Adding lib_deps for {feature}...')

# feat to add
deps_to_add = {}
Expand All @@ -172,12 +171,18 @@ def apply_features_config():
# Only add the missing dependencies
set_env_field('lib_deps', deps + list(deps_to_add.values()))

if 'build_flags' in feat:
f = feat['build_flags']
blab(f'Adding build_flags for {feature}: {f}')
new_flags = env.GetProjectOption('build_flags') + [ f ]
env.Replace(BUILD_FLAGS=new_flags)

if 'extra_scripts' in feat:
blab("Running extra_scripts for %s... " % feature)
blab(f'Running extra_scripts for {feature}...')
env.SConscript(feat['extra_scripts'], exports="env")

if 'src_filter' in feat:
blab("Adding src_filter for %s... " % feature)
blab(f'Adding src_filter for {feature}...')
src_filter = ' '.join(env.GetProjectOption('src_filter'))
# first we need to remove the references to the same folder
my_srcs = re.findall( r'[+-](<.*?>)', feat['src_filter'])
Expand All @@ -191,7 +196,7 @@ def apply_features_config():
env.Replace(SRC_FILTER=src_filter)

if 'lib_ignore' in feat:
blab("Adding lib_ignore for %s... " % feature)
blab(f'Adding lib_ignore for {feature}...')
lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
set_env_field('lib_ignore', lib_ignore)

Expand Down Expand Up @@ -243,7 +248,7 @@ def search_compiler():
return filepath

filepath = env.get('CXX')
blab("Couldn't find a compiler! Fallback to %s" % filepath)
blab(f"Couldn't find a compiler! Fallback to {filepath}")
return filepath

#
Expand Down