3
3
from types import ListType
4
4
5
5
from workspace_tools .utils import mkdir
6
- from workspace_tools .toolchains import TOOLCHAIN_CLASSES , Resources
6
+ from workspace_tools .toolchains import TOOLCHAIN_CLASSES
7
7
from workspace_tools .paths import MBED_TARGETS_PATH , MBED_LIBRARIES , MBED_API , MBED_HAL , MBED_COMMON
8
8
from workspace_tools .libraries import Library
9
9
@@ -22,7 +22,9 @@ def build_project(src_path, build_path, target, toolchain_name,
22
22
23
23
# Scan src_path and libraries_paths for resources
24
24
resources = toolchain .scan_resources (src_path )
25
+ src_paths = [src_path ]
25
26
if libraries_paths is not None :
27
+ src_paths .extend (libraries_paths )
26
28
for path in libraries_paths :
27
29
resources .add (toolchain .scan_resources (path ))
28
30
@@ -35,8 +37,14 @@ def build_project(src_path, build_path, target, toolchain_name,
35
37
rmtree (build_path )
36
38
mkdir (build_path )
37
39
38
- # Build Program
39
- return toolchain .build_program (resources , build_path , name )
40
+ # Compile Sources
41
+ for path in src_paths :
42
+ src = toolchain .scan_resources (path )
43
+ objects = toolchain .compile_sources (src , build_path , resources .inc_dirs )
44
+ resources .objects .extend (objects )
45
+
46
+ # Link Program
47
+ return toolchain .link_program (resources , build_path , name )
40
48
41
49
42
50
"""
@@ -73,10 +81,11 @@ def build_library(src_paths, build_path, target, toolchain_name,
73
81
resources .append (toolchain .scan_resources (src_path ))
74
82
75
83
# Dependencies Include Paths
76
- dependencies = Resources ()
84
+ dependencies_include_dir = []
77
85
if dependencies_paths is not None :
78
86
for path in dependencies_paths :
79
- dependencies .add (toolchain .scan_resources (path ))
87
+ lib_resources = toolchain .scan_resources (path )
88
+ dependencies_include_dir .extend (lib_resources .inc_dirs )
80
89
81
90
# Create the desired build directory structure
82
91
bin_path = join (build_path , toolchain .obj_path )
@@ -91,21 +100,23 @@ def build_library(src_paths, build_path, target, toolchain_name,
91
100
# Compile Sources
92
101
objects = []
93
102
for resource in resources :
94
- objects .extend (toolchain .compile_sources (resource , tmp_path , dependencies . inc_dirs ))
103
+ objects .extend (toolchain .compile_sources (resource , tmp_path , dependencies_include_dir ))
95
104
96
105
toolchain .build_library (objects , bin_path , name )
97
106
98
107
99
- def build_lib (lib_id , target , toolchain , options = None , verbose = False ):
108
+ def build_lib (lib_id , target , toolchain , options = None , verbose = False , clean = False ):
100
109
lib = Library (lib_id )
101
110
if lib .is_supported (target , toolchain ):
102
- build_library (lib .source_dir , lib .build_dir , target , toolchain , lib .dependencies , options , verbose = verbose )
111
+ build_library (lib .source_dir , lib .build_dir , target , toolchain ,
112
+ lib .dependencies , options ,
113
+ verbose = verbose , clean = clean )
103
114
else :
104
115
print '\n \n Library "%s" is not yet supported on target %s with toolchain %s' % (lib_id , target .name , toolchain )
105
116
106
117
107
118
# We do have unique legacy conventions about how we build and package the mbed library
108
- def build_mbed_libs (target , toolchain_name , options = None , verbose = False ):
119
+ def build_mbed_libs (target , toolchain_name , options = None , verbose = False , clean = False ):
109
120
# Check toolchain support
110
121
if toolchain_name not in target .supported_toolchains :
111
122
print '\n %s target is not yet supported by toolchain %s' % (target .name , toolchain_name )
@@ -114,6 +125,7 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False):
114
125
# Toolchain
115
126
toolchain = TOOLCHAIN_CLASSES [toolchain_name ](target , options )
116
127
toolchain .VERBOSE = verbose
128
+ toolchain .build_all = clean
117
129
118
130
# Source and Build Paths
119
131
BUILD_TARGET = join (MBED_LIBRARIES , "TARGET_" + target .name )
0 commit comments