@@ -20,11 +20,13 @@ def create_dependency_graph(self, header, include_paths=None):
2020 if include_paths is None :
2121 include_paths = []
2222
23+ header = os .path .abspath (header ) # Normalize here
24+
2325 if header in self .dependencies :
2426 return # Already processed
2527
2628 self .dependencies [header ] = set ()
27- base_path = os .path .dirname (os . path . abspath ( header ) ) # Base directory of the current header
29+ base_path = os .path .dirname (header ) # Base directory of the current header
2830
2931 try :
3032 with open (header , 'r' ) as file :
@@ -34,10 +36,10 @@ def create_dependency_graph(self, header, include_paths=None):
3436 included_file = include_match .group (1 )
3537
3638 if included_file != self .config_file :
37- resolved_path = self .resolve_path (
38- included_file , base_path , include_paths )
39+ resolved_path = self .resolve_path ( included_file , base_path , include_paths )
3940
4041 if resolved_path :
42+ resolved_path = os .path .abspath (resolved_path )
4143 self .dependencies [header ].add (resolved_path )
4244
4345 if os .path .exists (resolved_path ):
@@ -82,16 +84,21 @@ def resolve_path(self, included_file, base_path, include_paths):
8284
8385 return None # Return None if no resolution was possible
8486
87+
8588 def generate_header_list (self ):
8689 remaining_dependencies = self .dependencies .copy ()
8790 size_of_remaining_dependencies = len (remaining_dependencies )
91+ unique_files = set () # Track unique files by absolute path
8892
8993 while size_of_remaining_dependencies > 0 :
9094 local_included = []
9195
9296 for key in remaining_dependencies :
9397 if len (remaining_dependencies [key ]) == 0 :
94- self .included_list .append (key )
98+ abs_key = os .path .abspath (key )
99+ if abs_key not in unique_files :
100+ self .included_list .append (abs_key )
101+ unique_files .add (abs_key )
95102 local_included .append (key )
96103
97104 for included_key in local_included :
@@ -111,6 +118,7 @@ def process_header(header_path, output):
111118 """
112119 Processes a single header file, commenting out includes and pragmas.
113120 """
121+ header_path = os .path .abspath (header_path )
114122 if header_path in self .included :
115123 return # Avoid duplicate processing
116124 self .included .add (header_path )
@@ -133,6 +141,7 @@ def process_header(header_path, output):
133141
134142 with open (output_file , 'w' ) as output :
135143 for header in headers :
144+ header = os .path .abspath (header )
136145 self .create_dependency_graph (header , include_paths )
137146
138147 for header in self .dependencies :
0 commit comments