@@ -20,6 +20,15 @@ def get_depth_from_parent(project_dir, memfault_dir):
20
20
common_prefix = os .path .commonprefix ([memfault_dir , project_dir ])
21
21
depth = 1
22
22
dirname = project_dir
23
+
24
+ # some projects are in the root of the project dir- if the memfault dir is
25
+ # in the same directory, return a PROJECT_LOC value of 0 for the link
26
+ # position
27
+ if dirname == common_prefix :
28
+ return dirname , 0
29
+
30
+ # for the normal case, walk the directory parents until we find the common
31
+ # parent for the project and memfault dirs
23
32
while True :
24
33
parent_dir = os .path .dirname (dirname )
25
34
if os .path .samefile (parent_dir , common_prefix ):
@@ -100,8 +109,9 @@ def files_to_link(dir_glob, virtual_dir, common_prefix, parent_dir):
100
109
# Note:
101
110
# - xtensa targets (i.e ESP) use CMake/Make so no need to add to eclipse based projects
102
111
# - skip adding "memfault_demo_http" from demo component
103
- if "xtensa" in file_name or "http" in file_name :
112
+ if "xtensa" in file_name or ( "http" in os . path . relpath ( file_name , start = common_prefix )) :
104
113
continue
114
+ logging .debug ("Adding %s" , file_name )
105
115
106
116
yield get_file_element (file_name , virtual_dir , common_prefix , parent_dir )
107
117
@@ -257,7 +267,13 @@ def patch_cproject(
257
267
258
268
def _find_include_nodes (option ):
259
269
return option .get ("id" , "" ).startswith (
260
- "ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths"
270
+ (
271
+ # this is the element id used by Dialog's Smart Snippets Studio
272
+ # IDE (and possibly others)
273
+ "ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" ,
274
+ # this is the element id used by NXP's MCUXpresso IDE
275
+ "gnu.c.compiler.option.include.paths" ,
276
+ )
261
277
)
262
278
263
279
memfault_sdk_include_paths = [
@@ -313,7 +329,11 @@ def _find_linker_flags(option):
313
329
314
330
315
331
if __name__ == "__main__" :
316
- logging .basicConfig (level = logging .INFO )
332
+ logging .basicConfig (
333
+ format = "%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s" ,
334
+ datefmt = "%Y-%m-%d:%H:%M:%S" ,
335
+ level = logging .INFO ,
336
+ )
317
337
parser = argparse .ArgumentParser (
318
338
formatter_class = argparse .ArgumentDefaultsHelpFormatter ,
319
339
description = """
@@ -344,7 +364,10 @@ def _find_linker_flags(option):
344
364
parser .add_argument (
345
365
"-l" ,
346
366
"--location-prefix" ,
347
- help = "The default behavior will add memfault-firmware-sdk files to the eclipse project using paths relative to the project root. This can be used to control the root used instead" ,
367
+ help = (
368
+ "The default behavior will add memfault-firmware-sdk files to the eclipse project using"
369
+ " paths relative to the project root. This can be used to control the root used instead"
370
+ ),
348
371
)
349
372
350
373
parser .add_argument (
@@ -356,7 +379,10 @@ def _find_linker_flags(option):
356
379
357
380
parser .add_argument (
358
381
"--output" ,
359
- help = "The directory to output result to. By default, the .project/.cproject files for the project will be overwritten" ,
382
+ help = (
383
+ "The directory to output result to. By default, the .project/.cproject files for the"
384
+ " project will be overwritten"
385
+ ),
360
386
)
361
387
parser .add_argument (
362
388
"--verbose" ,
@@ -399,5 +425,6 @@ def _find_linker_flags(option):
399
425
)
400
426
401
427
logging .info (
402
- "Hurray, .project & .cproject have been succesfully patched! Be sure to 'Refresh' project to synchronize changes!"
428
+ "Hurray, .project & .cproject have been succesfully patched! Be sure to 'Refresh' project"
429
+ " to synchronize changes!"
403
430
)
0 commit comments