MCPcopy Create free account
hub / github.com/REditorSupport/vscode-R / generateCppPropertiesProc

Function generateCppPropertiesProc

src/cppProperties.ts:38–114  ·  view source on GitHub ↗
(workspaceFolder: string)

Source from the content-addressed store, hash-verified

36
37// See: https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference
38async function generateCppPropertiesProc(workspaceFolder: string) {
39 const rPath = await getRpath();
40 if (!rPath) {
41 return;
42 }
43
44 // Collect information from running the compiler
45 const configureFile = platformChoose('configure.win', 'configure', 'configure');
46 const cleanupFile = platformChoose('cleanup.win', 'cleanup', 'cleanup');
47
48 if (fs.existsSync(path.join(workspaceFolder, configureFile))) {
49 await executeRCommand(`system("sh ./${configureFile}")`, workspaceFolder, (e: Error) => {
50 void window.showErrorMessage(e.message);
51 return '';
52 });
53 }
54
55 const compileOutputCpp = collectCompilerOutput(rPath, workspaceFolder, 'cpp');
56 const compileOutputC = collectCompilerOutput(rPath, workspaceFolder, 'c');
57
58 if (fs.existsSync(path.join(workspaceFolder, cleanupFile))) {
59 await executeRCommand(`system("sh ./${cleanupFile}")`, workspaceFolder, (e: Error) => {
60 void window.showErrorMessage(e.message);
61 return '';
62 });
63 }
64
65 const compileInfo = extractCompilerInfo(compileOutputCpp);
66 const compileStdCpp = extractCompilerStd(compileOutputCpp);
67 const compileStdC = extractCompilerStd(compileOutputC);
68 const compileCall = extractCompilerCall(compileOutputCpp);
69 const compilerPath = compileCall ? await executeRCommand(`cat(Sys.which("${compileCall}"))`, workspaceFolder, (e: Error) => {
70 void window.showErrorMessage(e.message);
71 return '';
72 }) : '';
73
74 const intelliSensePlatform = platformChoose('windows', 'macos', 'linux');
75 const intelliSenseComp = compileCall ? (compileCall.includes('clang') ? 'clang' : 'gcc') : 'gcc';
76 const intelliSense = `${intelliSensePlatform}-${intelliSenseComp}-${process.arch}`;
77
78 // Collect information from 'DESCRIPTION'
79 const linkingToIncludes = await collectRLinkingTo(workspaceFolder);
80
81 // Combine information
82 const envIncludes: string[] = ['${workspaceFolder}/src'];
83 envIncludes.push(...compileInfo.compIncludes.map((v) => path.isAbsolute(v) ? v : `\${workspaceFolder}/${path.join('src', v)}`));
84 envIncludes.push(...linkingToIncludes);
85
86 const envDefines = compileInfo.compDefines;
87
88 // If no standard is set on linux, the C standard seems to default to the c++ one.
89 const envCStd = (!compileStdC || compileStdC.includes('++')) ? '${default}' : compileStdC;
90
91 const platformName = platformChoose('Win32', 'Mac', 'Linux');
92
93 // Build json
94 const re = {
95 'configurations': [{

Callers 1

generateCppPropertiesFunction · 0.85

Calls 8

getRpathFunction · 0.90
executeRCommandFunction · 0.90
platformChooseFunction · 0.85
collectCompilerOutputFunction · 0.85
extractCompilerInfoFunction · 0.85
extractCompilerStdFunction · 0.85
extractCompilerCallFunction · 0.85
collectRLinkingToFunction · 0.85

Tested by

no test coverage detected