Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-04-21 03:38:21 +0000
committerGerrit Code Review @ Eclipse.org2017-04-21 15:10:48 +0000
commitcfdb9c2ad81472e053d8135484ff54e73280547d (patch)
tree8e494ff6e5458bdb1f93c68b80185a2d12deaf95 /build/org.eclipse.cdt.build.gcc.core
parentb6cb6572293ba21fb30922b71ff55d9a457fedf9 (diff)
downloadorg.eclipse.cdt-cfdb9c2ad81472e053d8135484ff54e73280547d.tar.gz
org.eclipse.cdt-cfdb9c2ad81472e053d8135484ff54e73280547d.tar.xz
org.eclipse.cdt-cfdb9c2ad81472e053d8135484ff54e73280547d.zip
Fix issues with CMake. Arguments not passed. Local GCC prefix wrong
I added cmake arguments in the launch configuration for CMake projects but didn't add it to the command line. Also indexing wasn't working on my Mac. llvm-cc overrode the standard local cc. Added the local compile commands if the toolchain is local. Change-Id: I914c52dd42fbf84b87cd0e8c7504f024c2449a82
Diffstat (limited to 'build/org.eclipse.cdt.build.gcc.core')
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java43
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java16
2 files changed, 45 insertions, 14 deletions
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
index 5f5f47986a0..16bbabe0739 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
@@ -16,6 +16,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -58,6 +59,9 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
private final IEnvironmentVariable pathVar;
private final IEnvironmentVariable[] envVars;
private final Map<String, String> properties = new HashMap<>();
+ private String[] commands;
+ private String[] cCommands;
+ private String[] cppCommands;
public GCCToolChain(IToolChainProvider provider, String id, String version) {
this(provider, id, version, null, null);
@@ -73,7 +77,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
this.version = version;
this.name = id + " - " + version; //$NON-NLS-1$
this.path = path;
- this.prefix = prefix != null ? prefix : "";
+ this.prefix = prefix != null ? prefix : ""; //$NON-NLS-1$
if (path != null) {
StringBuilder pathString = new StringBuilder();
@@ -269,9 +273,9 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
// Source is an empty tmp file
String extension;
if (GPPLanguage.ID.equals(language.getId())) {
- extension = ".cpp";
+ extension = ".cpp"; //$NON-NLS-1$
} else if (GCCLanguage.ID.equals(language.getId())) {
- extension = ".c";
+ extension = ".c"; //$NON-NLS-1$
} else {
// In theory we shouldn't get here
return null;
@@ -391,17 +395,44 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
return null;
}
+ private boolean isLocal() {
+ return Platform.getOS().equals(properties.get(ATTR_OS))
+ && Platform.getOSArch().equals(properties.get(ATTR_ARCH));
+ }
+
@Override
public String[] getCompileCommands() {
- return new String[] { prefix + "gcc", prefix + "g++", prefix + "clang", prefix + "clang++", prefix + "cc", prefix + "c++" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ if (commands == null) {
+ boolean local = isLocal();
+
+ List<String> cCommandsList = new ArrayList<>(Arrays.asList(prefix + "gcc", prefix + "clang", prefix + "cc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (local) {
+ cCommandsList.addAll(Arrays.asList("gcc", "clang", "cc")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ cCommands = cCommandsList.toArray(new String[cCommandsList.size()]);
+
+ List<String> cppCommandsList = new ArrayList<>(Arrays.asList(prefix + "g++", prefix + "clang++", prefix + "c++")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (local) {
+ cppCommandsList.addAll(Arrays.asList("g++", "clang++", "c++")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ cppCommands = cppCommandsList.toArray(new String[cppCommandsList.size()]);
+
+ List<String> commandsList = new ArrayList<>(cCommandsList);
+ commandsList.addAll(cppCommandsList);
+ commands = commandsList.toArray(new String[commandsList.size()]);
+ }
+ return commands;
}
@Override
public String[] getCompileCommands(ILanguage language) {
+ if (commands == null) {
+ getCompileCommands();
+ }
if (GPPLanguage.ID.equals(language.getId())) {
- return new String[] { prefix + "g++", prefix + "clang++", prefix + "c++" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return cppCommands;
} else if (GCCLanguage.ID.equals(language.getId())) {
- return new String[] { prefix + "gcc", prefix + "clang", prefix + "cc" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return cCommands;
} else {
return new String[0];
}
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java
index c7beb398884..11944cbca88 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java
@@ -56,7 +56,7 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
if (matcher.matches()) {
prefix = matcher.group(1);
String cmd = matcher.group(2);
- String altFile = prefix + (cmd.startsWith("g") ? "g++" : "clang++");
+ String altFile = prefix + (cmd.startsWith("g") ? "g++" : "clang++"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
File altCmd = new File(dir, altFile);
hasAltCmd = altCmd.exists() && altCmd.canExecute();
}
@@ -65,7 +65,7 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
if (matcher.matches()) {
prefix = matcher.group(1);
String cmd = matcher.group(2);
- String altFile = prefix + (cmd.startsWith("g") ? "gcc" : "clang");
+ String altFile = prefix + (cmd.startsWith("g") ? "gcc" : "clang"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
File altCmd = new File(dir, altFile);
hasAltCmd = altCmd.exists() && altCmd.canExecute();
}
@@ -101,26 +101,26 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
String[] tuple = target.split("-"); //$NON-NLS-1$
if (tuple.length > 2) {
// Arch
- if ("x86_64".equals(tuple[0])) {
+ if ("x86_64".equals(tuple[0])) { //$NON-NLS-1$
toolChain.setProperty(IToolChain.ATTR_ARCH, tuple[0]);
} else {
- toolChain.setProperty(IToolChain.ATTR_ARCH, "x86"); // default
+ toolChain.setProperty(IToolChain.ATTR_ARCH, "x86"); // default //$NON-NLS-1$
}
// OS
switch (tuple[1]) {
- case "w64":
+ case "w64": //$NON-NLS-1$
toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_WIN32);
break;
- case "linux":
+ case "linux": //$NON-NLS-1$
toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_LINUX);
break;
- case "apple":
+ case "apple": //$NON-NLS-1$
toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_MACOSX);
break;
}
}
- toolChain.setProperty(IToolChain.ATTR_PACKAGE, "system");
+ toolChain.setProperty(IToolChain.ATTR_PACKAGE, "system"); //$NON-NLS-1$
manager.addToolChain(toolChain);
}
}

Back to the top