Skip to content

Commit 080da79

Browse files
committed
Fix for the compiler path in compile_commands.json file
Compiler path was wrongly created when anything was set on the "Prefix" option from "Cross Settings". The code needs to check if anything is set there before creating the default path for the compiler.
1 parent 04105c2 commit 080da79

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/jsoncdb/generator/CompilationDatabaseGenerator.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ private List<CompilationDatabaseInformation> populateObjList(IProject project, I
229229
outputLocation + "", inputStrings, sourceLocation, outputLocation); //$NON-NLS-1$
230230

231231
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
232-
String compilerName = CompilationDatabaseGenerator.getCompilerName(tool);
232+
String compilerName = CompilationDatabaseGenerator.getCompilerName(tool, config, cmdLInfo);
233233
String commandLine = cmdLInfo.getCommandLine();
234234
commandLine = commandLine.replace(compilerName, "").trim(); //$NON-NLS-1$
235-
String compilerPath = findCompilerInPath(tool, config);
235+
String compilerPath = findCompilerInPath(tool, config, cmdLInfo);
236236
String resolvedOptionFileContents;
237237
if (compilerPath != null && !compilerPath.isEmpty()) {
238238
resolvedOptionFileContents = provider.resolveValueToMakefileFormat(compilerPath + " " + commandLine, //$NON-NLS-1$
@@ -438,11 +438,11 @@ public boolean visit(IResourceProxy proxy) throws CoreException {
438438

439439
}
440440

441-
private String findCompilerInPath(ITool tool, IConfiguration config) {
441+
private String findCompilerInPath(ITool tool, IConfiguration config, IManagedCommandLineInfo cmdLInfo) {
442442
if (toolMap.containsKey(tool)) {
443443
return "\"" + toolMap.get(tool) + "\""; //$NON-NLS-1$//$NON-NLS-2$
444444
}
445-
String compilerName = CompilationDatabaseGenerator.getCompilerName(tool);
445+
String compilerName = CompilationDatabaseGenerator.getCompilerName(tool, config, cmdLInfo);
446446
File pathToCompiler = new File(compilerName);
447447

448448
if (pathToCompiler.isAbsolute()) {
@@ -469,9 +469,9 @@ private String findCompilerInPath(ITool tool, IConfiguration config) {
469469
return null;
470470
}
471471

472-
private static String getCompilerName(ITool tool) {
473-
String compilerCommand = tool.getToolCommand();
474-
String[] arguments = CommandLineUtil.argumentsToArray(compilerCommand);
472+
private static String getCompilerName(ITool tool, IConfiguration config, IManagedCommandLineInfo cmdLInfo) {
473+
String commandLine = cmdLInfo.getCommandLine();
474+
String[] arguments = CommandLineUtil.argumentsToArray(commandLine);
475475
if (arguments.length == 0) {
476476
return ""; //$NON-NLS-1$
477477
}

0 commit comments

Comments
 (0)