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

Function collectCompilerOutput

src/cppProperties.ts:180–209  ·  view source on GitHub ↗
(rPath: string, workspaceFolder: string, testExtension: 'cpp' | 'c')

Source from the content-addressed store, hash-verified

178}
179
180function collectCompilerOutput(rPath: string, workspaceFolder: string, testExtension: 'cpp' | 'c') {
181
182 const makevarsFiles = ['Makevars', 'Makevars.win', 'Makevars.ucrt'];
183
184 const srcFolder = path.join(workspaceFolder, 'src');
185 const tempFolder = createTempDir(workspaceFolder);
186
187 // Copy makevars
188 if (fs.existsSync(srcFolder)) {
189 const projectMakevarsFiles = fs.readdirSync(srcFolder).filter(fn => makevarsFiles.includes(fn));
190 for (const f of projectMakevarsFiles) {
191 fs.copyFileSync(path.join(srcFolder, f), path.join(tempFolder, f));
192 }
193 }
194
195 // Create dummy source file
196 const testFile = `comp_test.${testExtension}`;
197 fs.writeFileSync(path.join(tempFolder, testFile), '');
198
199 // Compile dummy
200 const command = `"${rPath}" CMD SHLIB ${testFile}`;
201 const compileOutput = execSync(command, {
202 cwd: tempFolder
203 }).toString();
204
205 // Cleanup
206 fs.rmSync(tempFolder, { recursive: true, force: true });
207
208 return compileOutput;
209}

Callers 1

Calls 1

createTempDirFunction · 0.90

Tested by

no test coverage detected