@@ -20,6 +20,15 @@ def get_depth_from_parent(project_dir, memfault_dir):
2020 common_prefix = os .path .commonprefix ([memfault_dir , project_dir ])
2121 depth = 1
2222 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
2332 while True :
2433 parent_dir = os .path .dirname (dirname )
2534 if os .path .samefile (parent_dir , common_prefix ):
@@ -100,8 +109,9 @@ def files_to_link(dir_glob, virtual_dir, common_prefix, parent_dir):
100109 # Note:
101110 # - xtensa targets (i.e ESP) use CMake/Make so no need to add to eclipse based projects
102111 # - 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 )) :
104113 continue
114+ logging .debug ("Adding %s" , file_name )
105115
106116 yield get_file_element (file_name , virtual_dir , common_prefix , parent_dir )
107117
@@ -257,7 +267,13 @@ def patch_cproject(
257267
258268 def _find_include_nodes (option ):
259269 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+ )
261277 )
262278
263279 memfault_sdk_include_paths = [
@@ -313,7 +329,11 @@ def _find_linker_flags(option):
313329
314330
315331if __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+ )
317337 parser = argparse .ArgumentParser (
318338 formatter_class = argparse .ArgumentDefaultsHelpFormatter ,
319339 description = """
@@ -344,7 +364,10 @@ def _find_linker_flags(option):
344364 parser .add_argument (
345365 "-l" ,
346366 "--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+ ),
348371 )
349372
350373 parser .add_argument (
@@ -356,7 +379,10 @@ def _find_linker_flags(option):
356379
357380 parser .add_argument (
358381 "--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+ ),
360386 )
361387 parser .add_argument (
362388 "--verbose" ,
@@ -399,5 +425,6 @@ def _find_linker_flags(option):
399425 )
400426
401427 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!"
403430 )
0 commit comments