Generate c_cpp_properties.json.
(self, vscode_dir: str, context, project_info: Dict)
| 125 | return True |
| 126 | |
| 127 | def _generate_cpp_properties(self, vscode_dir: str, context, project_info: Dict) -> None: |
| 128 | """Generate c_cpp_properties.json.""" |
| 129 | # Get toolchain info |
| 130 | toolchain = context.toolchain_manager.get_current() |
| 131 | compiler_path = "" |
| 132 | if toolchain and toolchain.info: |
| 133 | if toolchain.get_name() == "gcc": |
| 134 | compiler_path = os.path.join(toolchain.info.path, toolchain.info.prefix + "gcc") |
| 135 | |
| 136 | config = { |
| 137 | "configurations": [ |
| 138 | { |
| 139 | "name": "RT-Thread", |
| 140 | "includePath": [ |
| 141 | "${workspaceFolder}/**" |
| 142 | ] + project_info.get('all_includes', []), |
| 143 | "defines": [f"{k}={v}" if v != '1' else k |
| 144 | for k, v in project_info.get('all_defines', {}).items()], |
| 145 | "compilerPath": compiler_path, |
| 146 | "cStandard": "c99", |
| 147 | "cppStandard": "c++11", |
| 148 | "intelliSenseMode": "gcc-arm" if "arm" in compiler_path else "gcc-x64" |
| 149 | } |
| 150 | ], |
| 151 | "version": 4 |
| 152 | } |
| 153 | |
| 154 | output_path = os.path.join(vscode_dir, 'c_cpp_properties.json') |
| 155 | with open(output_path, 'w') as f: |
| 156 | json.dump(config, f, indent=4) |
| 157 | |
| 158 | def _generate_tasks(self, vscode_dir: str, context) -> None: |
| 159 | """Generate tasks.json.""" |