MCPcopy Create free account
hub / github.com/VSCodeConfigHelper/v4 / c_cpp_properties_json

Function c_cpp_properties_json

src-tauri/src/tasks/dotvscode.rs:277–326  ·  view source on GitHub ↗
(args: &TaskArgs)

Source from the content-addressed store, hash-verified

275}
276
277pub fn c_cpp_properties_json(args: &TaskArgs) -> Result<()> {
278 let im_compiler = match args.setup.ty {
279 CompilerType::GCC => "gcc",
280 CompilerType::LLVM => "clang",
281 CompilerType::MSVC => "msvc",
282 };
283 let im_platform = std::env::consts::OS;
284 let name = match im_platform {
285 "windows" => "Win32",
286 "macos" => "Mac",
287 "linux" => "Linux",
288 _ => return Err(anyhow!("unknown platform")),
289 };
290
291 #[cfg(not(target_os = "macos"))]
292 let im_arch = "x64";
293
294 #[cfg(target_os = "macos")]
295 let im_arch = match sysctl::get_arch()? {
296 sysctl::Aarch64 => "arm64",
297 sysctl::X64 => "x64",
298 };
299
300 let standard_key = if args.is_c {
301 "cStandard"
302 } else {
303 "cppStandard"
304 };
305
306 let json = json!({
307 "version": 4i32,
308 "configurations": [
309 {
310 "name": name,
311 "includePath": [
312 "${{workspaceFolder}}/**"
313 ],
314 "compilerPath": args.compiler_path.to_string(),
315 standard_key: args.standard.to_ascii_lowercase(),
316 "intelliSenseMode": format!("{}-{}-{}", im_platform, im_compiler, im_arch),
317 }
318 ]
319 });
320
321 debug!("c_cpp_properties.json: {}", json);
322
323 let path = args.workspace.join(".vscode").join("c_cpp_properties.json");
324 fs::write(path, serde_json::to_string_pretty(&json)?)?;
325 Ok(())
326}
327
328pub fn create_folder(args: &TaskArgs) -> Result<()> {
329 let path = args.workspace.join(".vscode");

Callers

nothing calls this directly

Calls 1

get_archFunction · 0.85

Tested by

no test coverage detected