@@ -300,26 +300,43 @@ def build_library(src_paths, build_path, target, toolchain_name,
300
300
toolchain .info ("Building library %s (%s, %s)" % (name , target .name , toolchain_name ))
301
301
302
302
# Scan Resources
303
- resources = []
304
- for src_path in src_paths :
305
- resources .append (toolchain .scan_resources (src_path ))
303
+ resources = None
304
+ for path in src_paths :
305
+ # Scan resources
306
+ resource = toolchain .scan_resources (path )
307
+
308
+ # Copy headers, objects and static libraries - all files needed for static lib
309
+ toolchain .copy_files (resource .headers , build_path , rel_path = resource .base_path )
310
+ toolchain .copy_files (resource .objects , build_path , rel_path = resource .base_path )
311
+ toolchain .copy_files (resource .libraries , build_path , rel_path = resource .base_path )
312
+ if resource .linker_script :
313
+ toolchain .copy_files (resource .linker_script , build_path , rel_path = resource .base_path )
314
+
315
+ # Extend resources collection
316
+ if not resources :
317
+ resources = resource
318
+ else :
319
+ resources .add (resource )
320
+
321
+ # We need to add if necessary additional include directories
322
+ if inc_dirs :
323
+ if type (inc_dirs ) == ListType :
324
+ resources .inc_dirs .extend (inc_dirs )
325
+ else :
326
+ resources .inc_dirs .append (inc_dirs )
306
327
307
328
# Add extra include directories / files which are required by library
308
329
# This files usually are not in the same directory as source files so
309
330
# previous scan will not include them
310
331
if inc_dirs_ext is not None :
311
332
for inc_ext in inc_dirs_ext :
312
- resources .append (toolchain .scan_resources (inc_ext ))
333
+ resources .add (toolchain .scan_resources (inc_ext ))
313
334
314
335
# Dependencies Include Paths
315
- dependencies_include_dir = []
316
336
if dependencies_paths is not None :
317
337
for path in dependencies_paths :
318
338
lib_resources = toolchain .scan_resources (path )
319
- dependencies_include_dir .extend (lib_resources .inc_dirs )
320
-
321
- if inc_dirs :
322
- dependencies_include_dir .extend (inc_dirs )
339
+ resources .inc_dirs .extend (lib_resources .inc_dirs )
323
340
324
341
if archive :
325
342
# Use temp path when building archive
@@ -330,25 +347,19 @@ def build_library(src_paths, build_path, target, toolchain_name,
330
347
331
348
# Handle configuration
332
349
config = Config (target )
333
-
334
- # Copy headers, objects and static libraries
335
- for resource in resources :
336
- toolchain .copy_files (resource .headers , build_path , rel_path = resource .base_path )
337
- toolchain .copy_files (resource .objects , build_path , rel_path = resource .base_path )
338
- toolchain .copy_files (resource .libraries , build_path , rel_path = resource .base_path )
339
- if resource .linker_script :
340
- toolchain .copy_files (resource .linker_script , build_path , rel_path = resource .base_path )
341
- config .add_config_files (resource .json_files )
342
-
350
+ # Update the configuration with any .json files found while scanning
351
+ config .add_config_files (resources .json_files )
352
+ # And add the configuration macros to the toolchain
343
353
toolchain .add_macros (config .get_config_data_macros ())
344
354
345
355
# Compile Sources
346
- objects = []
347
- for resource in resources :
348
- objects .extend (toolchain .compile_sources (resource , abspath (tmp_path ), dependencies_include_dir ))
356
+ for path in src_paths :
357
+ src = toolchain .scan_resources (path )
358
+ objects = toolchain .compile_sources (src , abspath (tmp_path ), resources .inc_dirs )
359
+ resources .objects .extend (objects )
349
360
350
361
if archive :
351
- needed_update = toolchain .build_library (objects , build_path , name )
362
+ needed_update = toolchain .build_library (resources . objects , build_path , name )
352
363
else :
353
364
needed_update = True
354
365
0 commit comments