@@ -59,6 +59,10 @@ def __init__(self, base_path=None):
59
59
60
60
# mbed special files
61
61
self .lib_builds = []
62
+ self .lib_refs = []
63
+
64
+ self .repo_dirs = []
65
+ self .repo_files = []
62
66
63
67
self .linker_script = None
64
68
@@ -75,21 +79,27 @@ def add(self, resources):
75
79
self .libraries += resources .libraries
76
80
77
81
self .lib_builds += resources .lib_builds
82
+ self .lib_refs += resources .lib_refs
83
+
84
+ self .repo_dirs += resources .repo_dirs
85
+ self .repo_files += resources .repo_files
78
86
79
87
if resources .linker_script is not None :
80
88
self .linker_script = resources .linker_script
81
89
82
90
def relative_to (self , base , dot = False ):
83
91
for field in ['inc_dirs' , 'headers' , 's_sources' , 'c_sources' ,
84
- 'cpp_sources' , 'lib_dirs' , 'objects' , 'libraries' ]:
92
+ 'cpp_sources' , 'lib_dirs' , 'objects' , 'libraries' ,
93
+ 'lib_builds' , 'lib_refs' , 'repo_dirs' , 'repo_files' ]:
85
94
v = [rel_path (f , base , dot ) for f in getattr (self , field )]
86
95
setattr (self , field , v )
87
96
if self .linker_script is not None :
88
97
self .linker_script = rel_path (self .linker_script , base , dot )
89
98
90
99
def win_to_unix (self ):
91
100
for field in ['inc_dirs' , 'headers' , 's_sources' , 'c_sources' ,
92
- 'cpp_sources' , 'lib_dirs' , 'objects' , 'libraries' ]:
101
+ 'cpp_sources' , 'lib_dirs' , 'objects' , 'libraries' ,
102
+ 'lib_builds' , 'lib_refs' , 'repo_dirs' , 'repo_files' ]:
93
103
v = [f .replace ('\\ ' , '/' ) for f in getattr (self , field )]
94
104
setattr (self , field , v )
95
105
if self .linker_script is not None :
@@ -244,6 +254,11 @@ def scan_resources(self, path):
244
254
for root , dirs , files in walk (path ):
245
255
# Remove ignored directories
246
256
for d in copy (dirs ):
257
+ if d == '.hg' :
258
+ dir_path = join (root , d )
259
+ resources .repo_dirs .append (dir_path )
260
+ resources .repo_files .extend (self .scan_repository (dir_path ))
261
+
247
262
if ((d .startswith ('.' ) or d in self .legacy_ignore_dirs ) or
248
263
(d .startswith ('TARGET_' ) and d [7 :] not in labels ['TARGET' ]) or
249
264
(d .startswith ('TOOLCHAIN_' ) and d [10 :] not in labels ['TOOLCHAIN' ])):
@@ -281,11 +296,30 @@ def scan_resources(self, path):
281
296
elif ext == self .LINKER_EXT :
282
297
resources .linker_script = file_path
283
298
299
+ elif ext == '.lib' :
300
+ resources .lib_refs .append (file_path )
284
301
elif ext == '.bld' :
285
302
resources .lib_builds .append (file_path )
303
+ elif file == '.hgignore' :
304
+ resources .repo_files .append (file_path )
286
305
287
306
return resources
288
-
307
+
308
+ def scan_repository (self , path ):
309
+ resources = []
310
+
311
+ for root , dirs , files in walk (path ):
312
+ # Remove ignored directories
313
+ for d in copy (dirs ):
314
+ if d == '.' or d == '..' :
315
+ dirs .remove (d )
316
+
317
+ for file in files :
318
+ file_path = join (root , file )
319
+ resources .append (file_path )
320
+
321
+ return resources
322
+
289
323
def copy_files (self , files_paths , trg_path , rel_path = None ):
290
324
# Handle a single file
291
325
if type (files_paths ) != ListType : files_paths = [files_paths ]
0 commit comments