(source_dirs,command_json_path,root_path)
| 127 | |
| 128 | |
| 129 | def generate_code_workspace_file(source_dirs,command_json_path,root_path): |
| 130 | current_working_directory = os.getcwd() |
| 131 | current_folder_name = os.path.basename(current_working_directory) |
| 132 | |
| 133 | relative_dirs = [] |
| 134 | for dir_path in source_dirs: |
| 135 | try: |
| 136 | rel_path = os.path.relpath(dir_path, root_path) |
| 137 | relative_dirs.append(rel_path) |
| 138 | except ValueError: |
| 139 | continue |
| 140 | |
| 141 | root_rel_path = os.path.relpath(root_path, current_working_directory) |
| 142 | command_json_path = os.path.relpath(current_working_directory, root_path) + os.sep |
| 143 | workspace_data = { |
| 144 | "folders": [ |
| 145 | { |
| 146 | "path": f"{root_rel_path}" |
| 147 | } |
| 148 | ], |
| 149 | "settings": { |
| 150 | "clangd.arguments": [ |
| 151 | f"--compile-commands-dir={command_json_path}", |
| 152 | "--header-insertion=never" |
| 153 | ], |
| 154 | "files.exclude": {dir.replace('\\','/'): True for dir in sorted(relative_dirs)} |
| 155 | } |
| 156 | } |
| 157 | workspace_filename = f'{current_folder_name}.code-workspace' |
| 158 | with open(workspace_filename, 'w') as f: |
| 159 | json.dump(workspace_data, f, indent=4) |
| 160 | |
| 161 | print(f'Workspace file {workspace_filename} created.') |
| 162 | |
| 163 | def command_json_to_workspace(root_path,command_json_path): |
| 164 |
no test coverage detected