Explorar el Código

Custom build_flags by feature (#20692)

Scott Lahteine hace 4 años
padre
commit
3dd1fe4211
No account linked to committer's email address
Se han modificado 1 ficheros con 13 adiciones y 8 borrados
  1. 13
    8
      buildroot/share/PlatformIO/scripts/common-dependencies.py

+ 13
- 8
buildroot/share/PlatformIO/scripts/common-dependencies.py Ver fichero

@@ -75,7 +75,7 @@ def add_to_feat_cnf(feature, flines):
75 75
 		parts = dep.split('=')
76 76
 		name = parts.pop(0)
77 77
 		rest = '='.join(parts)
78
-		if name in ['extra_scripts', 'src_filter', 'lib_ignore']:
78
+		if name in ['build_flags', 'extra_scripts', 'src_filter', 'lib_ignore']:
79 79
 			feat[name] = rest
80 80
 		else:
81 81
 			feat['lib_deps'] += [dep]
@@ -132,8 +132,7 @@ def force_ignore_unused_libs():
132 132
 	known_libs = get_all_known_libs()
133 133
 	diff = (list(set(known_libs) - set(env_libs)))
134 134
 	lib_ignore = env.GetProjectOption('lib_ignore') + diff
135
-	if verbose:
136
-		print("Ignore libraries:", lib_ignore)
135
+	blab(f'Ignore libraries: {lib_ignore}')
137 136
 	set_env_field('lib_ignore', lib_ignore)
138 137
 
139 138
 def apply_features_config():
@@ -145,7 +144,7 @@ def apply_features_config():
145 144
 		feat = FEATURE_CONFIG[feature]
146 145
 
147 146
 		if 'lib_deps' in feat and len(feat['lib_deps']):
148
-			blab("Adding lib_deps for %s... " % feature)
147
+			blab(f'Adding lib_deps for {feature}...')
149 148
 
150 149
 			# feat to add
151 150
 			deps_to_add = {}
@@ -172,12 +171,18 @@ def apply_features_config():
172 171
 				# Only add the missing dependencies
173 172
 				set_env_field('lib_deps', deps + list(deps_to_add.values()))
174 173
 
174
+		if 'build_flags' in feat:
175
+			f = feat['build_flags']
176
+			blab(f'Adding build_flags for {feature}: {f}')
177
+			new_flags = env.GetProjectOption('build_flags') + [ f ]
178
+			env.Replace(BUILD_FLAGS=new_flags)
179
+
175 180
 		if 'extra_scripts' in feat:
176
-			blab("Running extra_scripts for %s... " % feature)
181
+			blab(f'Running extra_scripts for {feature}...')
177 182
 			env.SConscript(feat['extra_scripts'], exports="env")
178 183
 
179 184
 		if 'src_filter' in feat:
180
-			blab("Adding src_filter for %s... " % feature)
185
+			blab(f'Adding src_filter for {feature}...')
181 186
 			src_filter = ' '.join(env.GetProjectOption('src_filter'))
182 187
 			# first we need to remove the references to the same folder
183 188
 			my_srcs = re.findall( r'[+-](<.*?>)', feat['src_filter'])
@@ -191,7 +196,7 @@ def apply_features_config():
191 196
 			env.Replace(SRC_FILTER=src_filter)
192 197
 
193 198
 		if 'lib_ignore' in feat:
194
-			blab("Adding lib_ignore for %s... " % feature)
199
+			blab(f'Adding lib_ignore for {feature}...')
195 200
 			lib_ignore = env.GetProjectOption('lib_ignore') + [feat['lib_ignore']]
196 201
 			set_env_field('lib_ignore', lib_ignore)
197 202
 
@@ -243,7 +248,7 @@ def search_compiler():
243 248
 			return filepath
244 249
 
245 250
 	filepath = env.get('CXX')
246
-	blab("Couldn't find a compiler! Fallback to %s" % filepath)
251
+	blab(f"Couldn't find a compiler! Fallback to {filepath}")
247 252
 	return filepath
248 253
 
249 254
 #

Loading…
Cancelar
Guardar