Skip to content

Commit 6f818cd

Browse files
Refresh compile_commands.json during the build (#1098)
CMake compile_commands.json file is not found even though it has been created. During a CMake build's generation stage, it generates the compile_commands.json file inside the build folder. However, when it comes to be used it is not found because it hasn't been reliably refreshed. To solve this, the file resource is refreshed Co-authored-by: John Moule <[email protected]>
1 parent 5135c9f commit 6f818cd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmake/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/CMakeBuildConfiguration.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public IProject[] build(int kind, Map<String, String> args, IConsole console, IP
237237
}
238238

239239
// parse compile_commands.json file
240+
getCompileCommandsFile().refreshLocal(IResource.DEPTH_ZERO, monitor);
240241
processCompileCommandsFile(console, monitor);
241242

242243
infoStream.write(String.format(Messages.CMakeBuildConfiguration_BuildingIn, buildDir.toString()));
@@ -346,14 +347,18 @@ public void clean(IConsole console, IProgressMonitor monitor) throws CoreExcepti
346347
}
347348
}
348349

350+
private IFile getCompileCommandsFile() throws CoreException {
351+
return getBuildContainer().getFile(new org.eclipse.core.runtime.Path("compile_commands.json")); //$NON-NLS-1$
352+
}
353+
349354
/**
350355
* @param console the console to print the compiler output during built-ins detection to or
351356
* <code>null</code> if no separate console is to be allocated. Ignored if
352357
* workspace preferences indicate that no console output is wanted.
353358
* @param monitor the job's progress monitor
354359
*/
355360
private void processCompileCommandsFile(IConsole console, IProgressMonitor monitor) throws CoreException {
356-
IFile file = getBuildContainer().getFile(new org.eclipse.core.runtime.Path("compile_commands.json")); //$NON-NLS-1$
361+
IFile file = getCompileCommandsFile();
357362
CompileCommandsJsonParser parser = new CompileCommandsJsonParser(
358363
new ParseRequest(file, new CMakeIndexerInfoConsumer(this::setScannerInformation),
359364
CommandLauncherManager.getInstance().getCommandLauncher(this), console));

0 commit comments

Comments
 (0)