Custom build_flags by feature (#20692)
This commit is contained in:
parent
d2969d2326
commit
3dd1fe4211
|
@ -75,7 +75,7 @@ def add_to_feat_cnf(feature, flines):
|
||||||
parts = dep.split('=')
|
parts = dep.split('=')
|
||||||
name = parts.pop(0)
|
name = parts.pop(0)
|
||||||
rest = '='.join(parts)
|
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
|
feat[name] = rest
|
||||||
else:
|
else:
|
||||||
feat['lib_deps'] += [dep]
|
feat['lib_deps'] += [dep]
|
||||||
|
@ -132,8 +132,7 @@ def force_ignore_unused_libs():
|
||||||
known_libs = get_all_known_libs()
|
known_libs = get_all_known_libs()
|
||||||
diff = (list(set(known_libs) - set(env_libs)))
|
diff = (list(set(known_libs) - set(env_libs)))
|
||||||
lib_ignore = env.GetProjectOption('lib_ignore') + diff
|
lib_ignore = env.GetProjectOption('lib_ignore') + diff
|
||||||
if verbose:
|
blab(f'Ignore libraries: {lib_ignore}')
|
||||||
print("Ignore libraries:", lib_ignore)
|
|
||||||
set_env_field('lib_ignore', lib_ignore)
|
set_env_field('lib_ignore', lib_ignore)
|
||||||
|
|
||||||
def apply_features_config():
|
def apply_features_config():
|
||||||
|
@ -145,7 +144,7 @@ def apply_features_config():
|
||||||
feat = FEATURE_CONFIG[feature]
|
feat = FEATURE_CONFIG[feature]
|
||||||
|
|
||||||
if 'lib_deps' in feat and len(feat['lib_deps']):
|
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
|
# feat to add
|
||||||
deps_to_add = {}
|
deps_to_add = {}
|
||||||
|
@ -172,12 +171,18 @@ def apply_features_config():
|
||||||
# Only add the missing dependencies
|
# Only add the missing dependencies
|
||||||
set_env_field('lib_deps', deps + list(deps_to_add.values()))
|
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:
|
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")
|
env.SConscript(feat['extra_scripts'], exports="env")
|
||||||
|
|
||||||
if 'src_filter' in feat:
|
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'))
|
src_filter = ' '.join(env.GetProjectOption('src_filter'))
|
||||||
# first we need to remove the references to the same folder
|
# first we need to remove the references to the same folder
|
||||||
my_srcs = re.findall( r'[+-](<.*?>)', feat['src_filter'])
|
my_srcs = re.findall( r'[+-](<.*?>)', feat['src_filter'])
|
||||||
|
@ -191,7 +196,7 @@ def apply_features_config():
|
||||||
env.Replace(SRC_FILTER=src_filter)
|
env.Replace(SRC_FILTER=src_filter)
|
||||||
|
|
||||||
if 'lib_ignore' in feat:
|
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']]
|
lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
|
||||||
set_env_field('lib_ignore', lib_ignore)
|
set_env_field('lib_ignore', lib_ignore)
|
||||||
|
|
||||||
|
@ -243,7 +248,7 @@ def search_compiler():
|
||||||
return filepath
|
return filepath
|
||||||
|
|
||||||
filepath = env.get('CXX')
|
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
|
return filepath
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue