1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-03-28 14:56:28 +01:00

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 <evil_bandit_betamax@yahoo.co.uk>
This commit is contained in:
Jonah Graham 2025-02-25 21:54:44 -05:00 committed by GitHub
parent 5135c9fc85
commit 6f818cdffe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -237,6 +237,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration implements ICMa
}
// parse compile_commands.json file
getCompileCommandsFile().refreshLocal(IResource.DEPTH_ZERO, monitor);
processCompileCommandsFile(console, monitor);
infoStream.write(String.format(Messages.CMakeBuildConfiguration_BuildingIn, buildDir.toString()));
@ -346,6 +347,10 @@ public class CMakeBuildConfiguration extends CBuildConfiguration implements ICMa
}
}
private IFile getCompileCommandsFile() throws CoreException {
return getBuildContainer().getFile(new org.eclipse.core.runtime.Path("compile_commands.json")); //$NON-NLS-1$
}
/**
* @param console the console to print the compiler output during built-ins detection to or
* <code>null</code> if no separate console is to be allocated. Ignored if
@ -353,7 +358,7 @@ public class CMakeBuildConfiguration extends CBuildConfiguration implements ICMa
* @param monitor the job's progress monitor
*/
private void processCompileCommandsFile(IConsole console, IProgressMonitor monitor) throws CoreException {
IFile file = getBuildContainer().getFile(new org.eclipse.core.runtime.Path("compile_commands.json")); //$NON-NLS-1$
IFile file = getCompileCommandsFile();
CompileCommandsJsonParser parser = new CompileCommandsJsonParser(
new ParseRequest(file, new CMakeIndexerInfoConsumer(this::setScannerInformation),
CommandLauncherManager.getInstance().getCommandLauncher(this), console));