#!/usr/bin/env python3 """ Fix include paths for project_defines.h Changes: #include to: #include """ import os import re import sys def fix_includes(root_dir): """Fix include paths in all .h and .cpp files""" pattern = re.compile(r'#include\s*') replacement = '#include ' files_fixed = 0 for dirpath, dirnames, filenames in os.walk(root_dir): # Skip hidden directories and build directories if '.git' in dirpath or 'build' in dirpath: continue for filename in filenames: if filename.endswith(('.h', '.cpp', '.cc', '.cxx')): filepath = os.path.join(dirpath, filename) try: with open(filepath, 'r', encoding='utf-8', errors='ignore') as f: content = f.read() # Check if file needs fixing if pattern.search(content): new_content = pattern.sub(replacement, content) with open(filepath, 'w', encoding='utf-8') as f: f.write(new_content) files_fixed += 1 print(f"Fixed: {filepath}") except Exception as e: print(f"Error processing {filepath}: {e}", file=sys.stderr) print(f"\nTotal files fixed: {files_fixed}") return files_fixed if __name__ == '__main__': root_dir = sys.argv[1] if len(sys.argv) > 1 else '.' fix_includes(root_dir)