@@ -480,7 +480,6 @@ def build_project(src_paths, build_path, target, toolchain_name,
480
480
stats_depth - depth level for memap to display file/dirs
481
481
ignore - list of paths to add to mbedignore
482
482
"""
483
-
484
483
# Convert src_path to a list if needed
485
484
if not isinstance (src_paths , list ):
486
485
src_paths = [src_paths ]
@@ -628,6 +627,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
628
627
# Convert src_path to a list if needed
629
628
if not isinstance (src_paths , list ):
630
629
src_paths = [src_paths ]
630
+ src_paths = [relpath (s ) for s in src_paths ]
631
631
632
632
# Build path
633
633
if archive :
@@ -679,28 +679,25 @@ def build_library(src_paths, build_path, target, toolchain_name,
679
679
raise Exception (error_msg )
680
680
681
681
try :
682
- resources = Resources (notify ).scan_with_toolchain (
682
+ res = Resources (notify ).scan_with_toolchain (
683
683
src_paths , toolchain , dependencies_paths , inc_dirs = inc_dirs )
684
684
685
685
# Copy headers, objects and static libraries - all files needed for
686
686
# static lib
687
- toolchain .copy_files (resources .headers , build_path , resources = resources )
688
- toolchain .copy_files (resources .objects , build_path , resources = resources )
689
- toolchain .copy_files (resources .libraries , build_path ,
690
- resources = resources )
691
- toolchain .copy_files (resources .json_files , build_path ,
692
- resources = resources )
693
- if resources .linker_script :
694
- toolchain .copy_files (resources .linker_script , build_path ,
695
- resources = resources )
696
-
697
- if resources .hex_files :
698
- toolchain .copy_files (resources .hex_files , build_path ,
699
- resources = resources )
700
-
687
+ to_copy = (
688
+ res .get_file_refs (FileType .HEADER ) +
689
+ res .get_file_refs (FileType .OBJECT ) +
690
+ res .get_file_refs (FileType .LIB ) +
691
+ res .get_file_refs (FileType .JSON ) +
692
+ res .get_file_refs (FileType .LD_SCRIPT ) +
693
+ res .get_file_refs (FileType .HEX ) +
694
+ res .get_file_refs (FileType .BIN )
695
+ )
696
+ toolchain .copy_files (to_copy , build_path )
701
697
# Compile Sources
702
- objects = toolchain .compile_sources (resources , resources .inc_dirs )
703
- resources .objects .extend (objects )
698
+ objects = toolchain .compile_sources (
699
+ res , res .get_file_paths (FileType .INC_DIR ))
700
+ res .add_files_to_type (FileType .OBJECT , objects )
704
701
705
702
if archive :
706
703
toolchain .build_library (objects , build_path , name )
@@ -714,8 +711,6 @@ def build_library(src_paths, build_path, target, toolchain_name,
714
711
end = time ()
715
712
cur_result ["elapsed_time" ] = end - start
716
713
cur_result ["result" ] = "OK"
717
-
718
-
719
714
add_result_to_report (report , cur_result )
720
715
return True
721
716
@@ -840,8 +835,8 @@ def build_lib(lib_id, target, toolchain_name, clean=False, macros=None,
840
835
inc_dirs = inc_dirs , dependencies_paths = dependencies_paths )
841
836
842
837
# Copy Headers
843
- toolchain .copy_files (resources . headers , build_path ,
844
- resources = resources )
838
+ toolchain .copy_files (
839
+ resources . get_file_refs ( FileType . HEADER ), build_path )
845
840
846
841
dependencies_include_dir = Resources (notify ).sacn_with_toolchain ([build_path ], toolchain ).inc_dirs
847
842
@@ -968,14 +963,18 @@ def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
968
963
toolchain .set_config_data (toolchain .config .get_config_data ())
969
964
970
965
# distribute header files
971
- toolchain .copy_files ([MBED_HEADER ], MBED_LIBRARIES )
966
+ toolchain .copy_files (
967
+ [FileRef (basename (MBED_HEADER ),MBED_HEADER )], MBED_LIBRARIES )
972
968
library_incdirs = [dirname (MBED_LIBRARIES ), MBED_LIBRARIES ]
973
969
974
970
for dir , dest in [(MBED_DRIVERS , MBED_LIBRARIES_DRIVERS ),
975
971
(MBED_PLATFORM , MBED_LIBRARIES_PLATFORM ),
976
972
(MBED_HAL , MBED_LIBRARIES_HAL )]:
977
973
resources = Resources (notify ).scan_with_toolchain ([dir ], toolchain )
978
- toolchain .copy_files (resources .headers , dest )
974
+ toolchain .copy_files (
975
+ [FileRef (basename (p ), p ) for p
976
+ in resources .get_file_paths (FileType .HEADER )] ,
977
+ dest )
979
978
library_incdirs .append (dest )
980
979
981
980
# collect resources of the libs to compile
@@ -1011,7 +1010,7 @@ def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
1011
1010
hal_objects = toolchain .compile_sources (hal_res , incdirs + [tmp_path ])
1012
1011
1013
1012
# Copy everything into the build directory
1014
- to_copy = sum ([
1013
+ to_copy = [ FileRef ( basename ( p ), p ) for p in sum ([
1015
1014
hal_res .headers ,
1016
1015
hal_res .hex_files ,
1017
1016
hal_res .bin_files ,
@@ -1022,7 +1021,7 @@ def build_mbed_libs(target, toolchain_name, clean=False, macros=None,
1022
1021
cmsis_objects ,
1023
1022
hal_objects ,
1024
1023
separate_objects ,
1025
- ], [])
1024
+ ], [])]
1026
1025
toolchain .copy_files (to_copy , build_toolchain )
1027
1026
1028
1027
if report is not None :
0 commit comments