Skip to content

Commit

Permalink
Generate compile_commands.json into Build config directory
Browse files Browse the repository at this point in the history
This lines up the behaviour of the generator with that
of the code that generates a .clangd file in [ClangdConfigurationFileManager.java](https://github.com/eclipse-cdt/cdt-lsp/blob/ee297ee0ced1747352039e6ee25bcc80c10c7462/bundles/org.eclipse.cdt.lsp.clangd/src/org/eclipse/cdt/lsp/clangd/internal/config/ClangdConfigurationFileManager.java)
This code already supports vendors overriding to supply their
own (or extended) .clangd contents.
  • Loading branch information
jonahgraham committed May 15, 2024
1 parent 1be4ce0 commit deec4b6
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
public final class CompilationDatabaseGenerator {

private static final String CDB_FILENAME = "compile_commands.json"; //$NON-NLS-1$
private static final String BUILD_FOLDER = "build"; //$NON-NLS-1$
private static final String ERROR_MESSAGE = "Can not set contents to compile_commands.json file"; //$NON-NLS-1$

private IProject project;
Expand All @@ -77,14 +76,13 @@ public CompilationDatabaseGenerator(IProject proj, IConfiguration config) {
* @param config
*/
public void generate() {

IPath buildDirectory = project.getFullPath()
.append(IPath.SEPARATOR + CompilationDatabaseGenerator.BUILD_FOLDER);
IPath buildDirectory = ManagedBuildManager.getBuildFullPath(configuration, configuration.getBuilder());
IPath compilationDatabasePath = buildDirectory
.append(IPath.SEPARATOR + CompilationDatabaseGenerator.CDB_FILENAME);
try {
if (!buildDirectory.toFile().exists()) {
createDirectory(CompilationDatabaseGenerator.BUILD_FOLDER);
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (!workspace.getRoot().exists(buildDirectory)) {
createDirectory(workspace.getRoot().getFolder(buildDirectory).getProjectRelativePath().toString());
}
IFile compileCommandsFile = createFile(compilationDatabasePath);
addToCompilationdatabase(project, compileCommandsFile, configuration);
Expand Down

0 comments on commit deec4b6

Please sign in to comment.