Skip to content

Commit 1151c1e

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 1151c1e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
3232
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
3333
import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
34+
import org.eclipse.cdt.managedbuilder.core.IOption;
3435
import org.eclipse.cdt.managedbuilder.core.IOutputType;
3536
import org.eclipse.cdt.managedbuilder.core.IResourceInfo;
3637
import org.eclipse.cdt.managedbuilder.core.ITool;
38+
import org.eclipse.cdt.managedbuilder.core.IToolChain;
3739
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
3840
import org.eclipse.cdt.managedbuilder.core.jsoncdb.CompilationDatabaseInformation;
3941
import org.eclipse.cdt.managedbuilder.core.jsoncdb.ICompilationDatabaseContributor;
@@ -229,7 +231,7 @@ private List<CompilationDatabaseInformation> populateObjList(IProject project, I
229231
outputLocation + "", inputStrings, sourceLocation, outputLocation); //$NON-NLS-1$
230232

231233
IBuildMacroProvider provider = ManagedBuildManager.getBuildMacroProvider();
232-
String compilerName = CompilationDatabaseGenerator.getCompilerName(tool);
234+
String compilerName = CompilationDatabaseGenerator.getCompilerName(tool, config);
233235
String commandLine = cmdLInfo.getCommandLine();
234236
commandLine = commandLine.replace(compilerName, "").trim(); //$NON-NLS-1$
235237
String compilerPath = findCompilerInPath(tool, config);
@@ -442,7 +444,7 @@ private String findCompilerInPath(ITool tool, IConfiguration config) {
442444
if (toolMap.containsKey(tool)) {
443445
return "\"" + toolMap.get(tool) + "\""; //$NON-NLS-1$//$NON-NLS-2$
444446
}
445-
String compilerName = CompilationDatabaseGenerator.getCompilerName(tool);
447+
String compilerName = CompilationDatabaseGenerator.getCompilerName(tool, config);
446448
File pathToCompiler = new File(compilerName);
447449

448450
if (pathToCompiler.isAbsolute()) {
@@ -469,9 +471,14 @@ private String findCompilerInPath(ITool tool, IConfiguration config) {
469471
return null;
470472
}
471473

472-
private static String getCompilerName(ITool tool) {
474+
private static String getCompilerName(ITool tool, IConfiguration config) {
475+
IToolChain toolchain = config.getToolChain();
476+
IOption option = toolchain.getOptionBySuperClassId("cdt.managedbuild.option.gnu.cross.prefix"); //$NON-NLS-1$
473477
String compilerCommand = tool.getToolCommand();
474478
String[] arguments = CommandLineUtil.argumentsToArray(compilerCommand);
479+
if (!("").equals(option.getValue())) { //$NON-NLS-1$
480+
return option.getValue() + arguments[0];
481+
}
475482
if (arguments.length == 0) {
476483
return ""; //$NON-NLS-1$
477484
}

0 commit comments

Comments
 (0)