15
15
limitations under the License.
16
16
"""
17
17
from exporters import Exporter
18
- from os .path import splitext , basename
19
- from os import curdir
18
+ from os .path import splitext , basename , relpath , join , abspath
19
+ from os import curdir , getcwd
20
20
21
21
22
22
class GccArm (Exporter ):
@@ -133,7 +133,7 @@ class GccArm(Exporter):
133
133
def generate (self ):
134
134
# "make" wants Unix paths
135
135
self .resources .win_to_unix ()
136
- self .resources .relative_to (curdir )
136
+ self .resources .relative_to (self . prj_paths [ 0 ] )
137
137
138
138
to_be_compiled = []
139
139
for r_type in ['s_sources' , 'c_sources' , 'cpp_sources' ]:
@@ -148,6 +148,7 @@ def generate(self):
148
148
l , _ = splitext (basename (lib ))
149
149
libraries .append (l [3 :])
150
150
151
+ build_dir = abspath (join (self .inputDir , ".build" ))
151
152
ctx = {
152
153
'name' : self .program_name ,
153
154
'to_be_compiled' : to_be_compiled ,
@@ -157,7 +158,20 @@ def generate(self):
157
158
'linker_script' : self .resources .linker_script ,
158
159
'libraries' : libraries ,
159
160
'symbols' : self .get_symbols (),
160
- 'cpu_flags' : self .toolchain .cpu
161
+ 'cpu_flags' : self .toolchain .cpu ,
162
+ 'vpath' : [relpath (s , build_dir ) for s in self .prj_paths ] if self .sources_relative else ["../" ]
161
163
}
164
+
165
+ for key in ['include_paths' , 'library_paths' , 'linker_script' ]:
166
+ if isinstance (ctx [key ], list ):
167
+ ctx [key ] = [ctx ['vpath' ][0 ] + "/" + t for t in ctx [key ]]
168
+ else :
169
+ ctx [key ] = ctx ['vpath' ][0 ] + "/" + ctx [key ]
170
+ if "../." not in ctx ["include_paths" ]:
171
+ ctx ["include_paths" ] += ['../.' ]
162
172
ctx .update (self .progen_flags )
163
173
self .gen_file ('gcc_arm_%s.tmpl' % self .target .lower (), ctx , 'Makefile' )
174
+
175
+ def scan_and_copy_resources (self , prj_paths , trg_path , relative = False ):
176
+ self .prj_paths = prj_paths
177
+ Exporter .scan_and_copy_resources (self , prj_paths , trg_path , relative )
0 commit comments