Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorDoug Schaefer2017-09-28 00:27:40 +0000
committerDoug Schaefer2017-09-28 17:42:58 +0000
commit5228d193004a8001632385127f5b45a3a5243f7e (patch)
tree58b418f969732f94b12054aa58bba475e579bbd2 /build
parent80dc8d9c2517e738be2e16a6f98375266259bd0d (diff)
downloadorg.eclipse.cdt-5228d193004a8001632385127f5b45a3a5243f7e.tar.gz
org.eclipse.cdt-5228d193004a8001632385127f5b45a3a5243f7e.tar.xz
org.eclipse.cdt-5228d193004a8001632385127f5b45a3a5243f7e.zip
UI for adding toolchains for Core Build. New Generic Target Wizard.
Provide a way to add new toolchains. Also start of UI to allow for reordering them to help with toolchain selection for targets. New Generic Target Wizard for the new wizard2 extension point for the Launch Bar Target UI. Change-Id: I60635ab27dad5b69df72c339337473183dcf711a
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF3
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/plugin.xml4
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java249
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCUserToolChainProvider.java219
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Activator.java6
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java104
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Messages.java25
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/messages.properties11
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/.classpath7
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/.project28
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/META-INF/MANIFEST.MF14
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/build.properties5
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/plugin.xml13
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Activator.java71
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/GCCToolChainSettingsPage.java128
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Messages.java54
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewEnvVarDialog.java212
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java74
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/ToolChainEnvironmentPage.java205
-rw-r--r--build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/messages.properties40
-rw-r--r--build/org.eclipse.cdt.cmake.core/META-INF/MANIFEST.MF2
-rw-r--r--build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java23
-rw-r--r--build/org.eclipse.cdt.cmake.ui/META-INF/MANIFEST.MF5
-rw-r--r--build/org.eclipse.cdt.cmake.ui/plugin.properties1
-rw-r--r--build/org.eclipse.cdt.cmake.ui/plugin.xml6
-rw-r--r--build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/NewCMakeToolChainFilePage.java5
27 files changed, 1365 insertions, 156 deletions
diff --git a/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF
index 07c5abe6db2..182b4d4d518 100644
--- a/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF
@@ -7,7 +7,8 @@ Bundle-Activator: org.eclipse.cdt.build.gcc.core.internal.Activator
Bundle-Vendor: Eclipse CDT
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources;bundle-version="3.10.0",
- org.eclipse.cdt.core;bundle-version="5.12.0"
+ org.eclipse.cdt.core;bundle-version="5.12.0",
+ com.google.gson
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.cdt.build.gcc.core
diff --git a/build/org.eclipse.cdt.build.gcc.core/plugin.xml b/build/org.eclipse.cdt.build.gcc.core/plugin.xml
index 596c7623f67..036b2b8f894 100644
--- a/build/org.eclipse.cdt.build.gcc.core/plugin.xml
+++ b/build/org.eclipse.cdt.build.gcc.core/plugin.xml
@@ -11,6 +11,10 @@
class="org.eclipse.cdt.build.gcc.core.internal.Msys2ToolChainProvider"
id="org.eclipse.cdt.build.gcc.core.msys2Provider">
</provider>
+ <provider
+ class="org.eclipse.cdt.build.gcc.core.GCCUserToolChainProvider"
+ id="org.eclipse.cdt.build.gcc.core.provider.user">
+ </provider>
</extension>
</plugin>
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 51373ff7d84..f5cd6b21b64 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 QNX Software Systems and others.
+ * Copyright (c) 2015, 2017 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -16,10 +16,10 @@ 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;
+import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -45,23 +45,21 @@ import org.eclipse.core.runtime.PlatformObject;
/**
* The GCC toolchain. This is the base class for all GCC toolchains. It
- * represents GCC as found on the user's PATH. It can be overriden to change
+ * represents GCC as found on the user's PATH. It can be overridden to change
* environment variable settings.
*/
public class GCCToolChain extends PlatformObject implements IToolChain {
private final IToolChainProvider provider;
private final String id;
- private final String version;
- private final String name;
- private final Path[] path;
- private final String prefix;
+ private final Path path;
private final IEnvironmentVariable pathVar;
private final IEnvironmentVariable[] envVars;
private final Map<String, String> properties = new HashMap<>();
+
+ private String cCommand;
+ private String cppCommand;
private String[] commands;
- private String[] cCommands;
- private String[] cppCommands;
public GCCToolChain(IToolChainProvider provider, String id, String version) {
this(provider, id, version, null, null);
@@ -74,12 +72,8 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
public GCCToolChain(IToolChainProvider provider, String id, String version, Path[] path, String prefix) {
this.provider = provider;
this.id = id;
- this.version = version;
- this.name = id + " - " + version; //$NON-NLS-1$
- this.path = path;
- this.prefix = prefix != null ? prefix : ""; //$NON-NLS-1$
- if (path != null) {
+ if (path != null && path.length > 0) {
StringBuilder pathString = new StringBuilder();
for (int i = 0; i < path.length; ++i) {
pathString.append(path[i].toString());
@@ -87,15 +81,67 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
pathString.append(File.pathSeparator);
}
}
- pathVar = new EnvironmentVariable("PATH", pathString.toString(), IEnvironmentVariable.ENVVAR_PREPEND, //$NON-NLS-1$
+ this.path = path[0];
+ this.pathVar = new EnvironmentVariable("PATH", pathString.toString(), IEnvironmentVariable.ENVVAR_PREPEND, //$NON-NLS-1$
File.pathSeparator);
- envVars = new IEnvironmentVariable[] { pathVar };
+ this.envVars = new IEnvironmentVariable[] { pathVar };
} else {
- pathVar = null;
- envVars = new IEnvironmentVariable[0];
+ this.path = null;
+ this.pathVar = null;
+ this.envVars = new IEnvironmentVariable[0];
}
}
+ public GCCToolChain(IToolChainProvider provider, Path pathToToolChain, String arch,
+ IEnvironmentVariable[] envVars) {
+ this.provider = provider;
+ this.path = pathToToolChain;
+
+ // We include arch in the id since a compiler can support multiple arches.
+ StringBuilder idBuilder = new StringBuilder("gcc-"); //$NON-NLS-1$
+ if (arch != null) {
+ idBuilder.append(arch);
+ }
+ idBuilder.append('-');
+ idBuilder.append(pathToToolChain.toString());
+ this.id = idBuilder.toString();
+
+ IEnvironmentVariable pathVar = null;
+ if (envVars != null) {
+ for (IEnvironmentVariable envVar : envVars) {
+ if (envVar.getName().equalsIgnoreCase("PATH")) { //$NON-NLS-1$
+ pathVar = envVar;
+ }
+ }
+ }
+
+ if (pathVar == null) {
+ // Make one with the directory containing out tool
+ String name;
+ // if (System.getenv("Path") != null) { //$NON-NLS-1$
+ // name = "Path"; //$NON-NLS-1$
+ // } else {
+ name = "PATH"; //$NON-NLS-1$
+ // }
+ pathVar = new EnvironmentVariable(name, this.path.getParent().toString(),
+ IEnvironmentVariable.ENVVAR_PREPEND, File.pathSeparator);
+ if (envVars == null) {
+ envVars = new IEnvironmentVariable[] { pathVar };
+ } else {
+ IEnvironmentVariable[] newVars = new IEnvironmentVariable[envVars.length + 1];
+ System.arraycopy(envVars, 0, newVars, 0, envVars.length);
+ newVars[envVars.length] = pathVar;
+ envVars = newVars;
+ }
+ }
+ this.pathVar = pathVar;
+ this.envVars = envVars;
+ }
+
+ public Path getPath() {
+ return path;
+ }
+
@Override
public IToolChainProvider getProvider() {
return provider;
@@ -108,12 +154,30 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
@Override
public String getVersion() {
- return version;
+ return ""; //$NON-NLS-1$
}
@Override
public String getName() {
- return name;
+ StringBuilder name = new StringBuilder("GCC"); //$NON-NLS-1$
+ String os = getProperty(ATTR_OS);
+ if (os != null) {
+ name.append(' ');
+ name.append(os);
+ }
+
+ String arch = getProperty(ATTR_ARCH);
+ if (arch != null) {
+ name.append(' ');
+ name.append(arch);
+ }
+
+ if (path != null) {
+ name.append(' ');
+ name.append(path.toString());
+ }
+
+ return name.toString();
}
@Override
@@ -122,18 +186,24 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
if (value != null) {
return value;
}
-
+
// By default, we're a local GCC
switch (key) {
case ATTR_OS:
return Platform.getOS();
case ATTR_ARCH:
- return Platform.getOSArch();
+ if (Platform.getOS().equals(getProperty(ATTR_OS))) {
+ return Platform.getOSArch();
+ }
}
-
+
return null;
}
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
@Override
public void setProperty(String key, String value) {
properties.put(key, value);
@@ -359,7 +429,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
@Override
public IEnvironmentVariable getVariable(String name) {
- if (path != null && name.equals("PATH")) { //$NON-NLS-1$
+ if (pathVar != null && (name.equals("PATH") || name.equals("Path"))) { //$NON-NLS-1$ //$NON-NLS-2$
return pathVar;
}
return null;
@@ -377,20 +447,11 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
}
if (Platform.getOS().equals(Platform.OS_WIN32)) {
- if (!command.toString().endsWith(".exe")) { //$NON-NLS-1$
+ if (!command.toString().endsWith(".exe") && !command.toString().endsWith(".bat")) { //$NON-NLS-1$ //$NON-NLS-2$
command = Paths.get(command.toString() + ".exe"); //$NON-NLS-1$
}
}
- if (path != null) {
- for (Path p : path) {
- Path c = p.resolve(command);
- if (Files.isExecutable(c)) {
- return c;
- }
- }
- }
-
// Look for it in the path environment var
IEnvironmentVariable myPath = getVariable("PATH"); //$NON-NLS-1$
String path = myPath != null ? myPath.getValue() : System.getenv("PATH"); //$NON-NLS-1$
@@ -405,44 +466,35 @@ 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));
+ private void initCompileCommands() {
+ if (commands == null) {
+ cCommand = path.getFileName().toString();
+ cppCommand = null;
+ if (cCommand.contains("gcc")) { //$NON-NLS-1$
+ cppCommand = cCommand.replace("gcc", "g++"); //$NON-NLS-1$ //$NON-NLS-2$
+ commands = new String[] { cCommand, cppCommand };
+ } else if (cCommand.contains("clang")) { //$NON-NLS-1$
+ cppCommand = cCommand.replace("clang", "clang++"); //$NON-NLS-1$ //$NON-NLS-2$
+ commands = new String[] { cCommand, cppCommand };
+ } else {
+ commands = new String[] { cCommand };
+ }
+ }
}
@Override
public String[] getCompileCommands() {
- 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()]);
- }
+ initCompileCommands();
return commands;
}
@Override
public String[] getCompileCommands(ILanguage language) {
- if (commands == null) {
- getCompileCommands();
- }
+ initCompileCommands();
if (GPPLanguage.ID.equals(language.getId())) {
- return cppCommands;
+ return new String[] { cppCommand != null ? cppCommand : cCommand };
} else if (GCCLanguage.ID.equals(language.getId())) {
- return cCommands;
+ return new String[] { cCommand };
} else {
return new String[0];
}
@@ -498,4 +550,79 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
return newCommand;
}
+ public static class GCCInfo {
+ private static final Pattern versionPattern = Pattern.compile(".*(gcc|LLVM) version .*"); //$NON-NLS-1$
+ private static final Pattern targetPattern = Pattern.compile("Target: (.*)"); //$NON-NLS-1$
+
+ public String target;
+ public String version;
+
+ public GCCInfo(String command) throws IOException {
+ this(command, null);
+ }
+
+ public GCCInfo(String command, Map<String, String> env) throws IOException {
+ ProcessBuilder builder = new ProcessBuilder(new String[] { command, "-v" }).redirectErrorStream(true); //$NON-NLS-1$
+ if (env != null) {
+ Map<String, String> procEnv = builder.environment();
+ for (Entry<String, String> entry : env.entrySet()) {
+ if ("PATH".equals(entry.getKey())) { //$NON-NLS-1$
+ // prepend the path
+ String path = entry.getValue() + File.pathSeparator + procEnv.get("PATH"); //$NON-NLS-1$
+ procEnv.put("PATH", path); //$NON-NLS-1$
+ } else {
+ // replace
+ procEnv.put(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+ Process proc = builder.start();
+ try (BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()))) {
+ for (String line = reader.readLine(); line != null; line = reader.readLine()) {
+ Matcher versionMatcher = versionPattern.matcher(line);
+ if (versionMatcher.matches()) {
+ version = line.trim();
+ continue;
+ }
+ Matcher targetMatcher = targetPattern.matcher(line);
+ if (targetMatcher.matches()) {
+ target = targetMatcher.group(1);
+ continue;
+ }
+ }
+ }
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ GCCInfo other = (GCCInfo) obj;
+ if (target == null) {
+ if (other.target != null)
+ return false;
+ } else if (!target.equals(other.target))
+ return false;
+ if (version == null) {
+ if (other.version != null)
+ return false;
+ } else if (!version.equals(other.version))
+ return false;
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((target == null) ? 0 : target.hashCode());
+ result = prime * result + ((version == null) ? 0 : version.hashCode());
+ return result;
+ }
+
+ }
}
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCUserToolChainProvider.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCUserToolChainProvider.java
new file mode 100644
index 00000000000..b7b25e9d993
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCUserToolChainProvider.java
@@ -0,0 +1,219 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.core;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.cdt.build.gcc.core.internal.Activator;
+import org.eclipse.cdt.build.gcc.core.internal.Messages;
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.core.build.IToolChainManager;
+import org.eclipse.cdt.core.build.IUserToolChainProvider;
+import org.eclipse.cdt.core.envvar.EnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+
+public class GCCUserToolChainProvider implements IUserToolChainProvider {
+
+ public static final String PROVIDER_ID = "org.eclipse.cdt.build.gcc.core.provider.user"; //$NON-NLS-1$
+
+ private static final String ARCH = "arch"; //$NON-NLS-1$
+ private static final String DELIMITER = "delimiter"; //$NON-NLS-1$
+ private static final String ENVIRONMENT = "environment"; //$NON-NLS-1$
+ private static final String ID = "id"; //$NON-NLS-1$
+ private static final String NAME = "name"; //$NON-NLS-1$
+ private static final String OPERATION = "operation"; //$NON-NLS-1$
+ private static final String PATH = "path"; //$NON-NLS-1$
+ private static final String PROPERTIES = "properties"; //$NON-NLS-1$
+ private static final String VALUE = "value"; //$NON-NLS-1$
+
+ private IToolChainManager manager;
+ private JsonArray toolChains;
+
+ @Override
+ public String getId() {
+ return PROVIDER_ID;
+ }
+
+ private File getJsonFile() {
+ return Activator.getPlugin().getStateLocation().append("toolchains.json").toFile(); //$NON-NLS-1$
+ }
+
+ @Override
+ public void init(IToolChainManager manager) throws CoreException {
+ this.manager = manager;
+
+ // Load up the magic JSON file which contains our toolchain defs
+ try {
+ File jsonFile = getJsonFile();
+ if (jsonFile.exists()) {
+ toolChains = new JsonParser().parse(new FileReader(jsonFile)).getAsJsonArray();
+ for (JsonElement element : toolChains) {
+ JsonObject tc = element.getAsJsonObject();
+ String arch;
+ if (tc.has(ARCH)) {
+ arch = tc.get(ARCH).getAsString();
+ } else {
+ arch = null;
+ }
+ Path path = Paths.get(tc.get(PATH).getAsString());
+ IEnvironmentVariable[] envvars = null;
+ if (tc.has(ENVIRONMENT)) {
+ List<IEnvironmentVariable> envlist = new ArrayList<>();
+ for (JsonElement var : tc.get(ENVIRONMENT).getAsJsonArray()) {
+ JsonObject varobj = var.getAsJsonObject();
+ String name = varobj.get(NAME).getAsString();
+ int operation = varobj.get(OPERATION).getAsInt();
+ String value = null;
+ if (varobj.has(VALUE)) {
+ value = varobj.get(VALUE).getAsString();
+ }
+ String delimiter = null;
+ if (varobj.has(DELIMITER)) {
+ delimiter = varobj.get(DELIMITER).getAsString();
+ }
+ envlist.add(new EnvironmentVariable(name, value, operation, delimiter));
+ }
+ envvars = envlist.toArray(new IEnvironmentVariable[0]);
+ }
+
+ GCCToolChain gcc = new GCCToolChain(this, path, arch, envvars);
+ if (tc.has(PROPERTIES)) {
+ for (JsonElement prop : tc.get(PROPERTIES).getAsJsonArray()) {
+ JsonObject propobj = prop.getAsJsonObject();
+ gcc.setProperty(propobj.get(NAME).getAsString(), propobj.get(VALUE).getAsString());
+ }
+ }
+ manager.addToolChain(gcc);
+ }
+ }
+ } catch (IOException | IllegalStateException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), Messages.GCCUserToolChainProvider_Loading, e));
+ }
+ }
+
+ @Override
+ public void addToolChain(IToolChain toolChain) throws CoreException {
+ if (!(toolChain instanceof GCCToolChain)) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), Messages.GCCUserToolChainProvider_NotOurs));
+ }
+
+ GCCToolChain gcc = (GCCToolChain) toolChain;
+
+ // Persist the toolchain
+ if (toolChains == null) {
+ toolChains = new JsonArray();
+ }
+
+ JsonObject newtc = new JsonObject();
+ toolChains.add(newtc);
+
+ newtc.addProperty(ID, gcc.getId());
+ newtc.addProperty(ARCH, gcc.getProperty(IToolChain.ATTR_ARCH));
+ newtc.addProperty(PATH, gcc.getPath().toString());
+
+ Map<String, String> properties = gcc.getProperties();
+ if (properties != null && !properties.isEmpty()) {
+ JsonArray props = new JsonArray();
+ newtc.add(PROPERTIES, props);
+ for (Entry<String, String> entry : gcc.getProperties().entrySet()) {
+ JsonObject prop = new JsonObject();
+ props.add(prop);
+ prop.addProperty(NAME, entry.getKey());
+ prop.addProperty(VALUE, entry.getValue());
+ }
+ }
+
+ IEnvironmentVariable[] envvars = gcc.getVariables();
+ if (envvars != null && envvars.length > 0) {
+ JsonArray env = new JsonArray();
+ newtc.add(ENVIRONMENT, env);
+ for (IEnvironmentVariable var : gcc.getVariables()) {
+ JsonObject envvar = new JsonObject();
+ env.add(envvar);
+
+ envvar.addProperty(NAME, var.getName());
+ envvar.addProperty(OPERATION, var.getOperation());
+ String value = var.getValue();
+ if (value != null) {
+ envvar.addProperty(VALUE, value);
+ }
+
+ String delimiter = var.getDelimiter();
+ if (delimiter != null) {
+ envvar.addProperty(DELIMITER, delimiter);
+ }
+ }
+ }
+
+ try {
+ saveJsonFile();
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), Messages.GCCUserToolChainProvider_Saving, e));
+ }
+
+ manager.addToolChain(toolChain);
+ }
+
+ @Override
+ public void removeToolChain(IToolChain toolChain) throws CoreException {
+ if (toolChains != null) {
+ String id = toolChain.getId();
+ JsonArray copy = new JsonArray();
+ copy.addAll(toolChains);
+ for (JsonElement element : copy) {
+ JsonObject tc = element.getAsJsonObject();
+ if (id.equals(tc.get(ID).getAsString())) {
+ toolChains.remove(element);
+ }
+ }
+
+ try {
+ saveJsonFile();
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, Activator.getId(), Messages.GCCUserToolChainProvider_Saving1, e));
+ }
+ }
+ manager.removeToolChain(toolChain);
+ }
+
+ @Override
+ public IToolChain getToolChain(String id) throws CoreException {
+ Collection<IToolChain> tcs = manager.getToolChains(PROVIDER_ID, id);
+ if (tcs.isEmpty()) {
+ return null;
+ } else {
+ return tcs.iterator().next();
+ }
+ }
+
+ private void saveJsonFile() throws IOException {
+ try (Writer writer = new FileWriter(getJsonFile())) {
+ writer.write(new Gson().toJson(toolChains));
+ }
+ }
+}
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Activator.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Activator.java
index c9f26e7d2d9..d50a8b19fdb 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Activator.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Activator.java
@@ -18,10 +18,12 @@ public class Activator extends Plugin {
private static Plugin plugin;
+ @Override
public void start(BundleContext bundleContext) throws Exception {
plugin = this;
}
+ @Override
public void stop(BundleContext bundleContext) throws Exception {
plugin = null;
}
@@ -48,4 +50,8 @@ public class Activator extends Plugin {
return ref != null ? context.getService(ref) : null;
}
+ public static Plugin getPlugin() {
+ return plugin;
+ }
+
}
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 11944cbca88..d44607af45b 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
@@ -7,17 +7,13 @@
*******************************************************************************/
package org.eclipse.cdt.build.gcc.core.internal;
-import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.file.Path;
-import java.util.HashSet;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.cdt.build.gcc.core.GCCToolChain;
+import org.eclipse.cdt.build.gcc.core.GCCToolChain.GCCInfo;
import org.eclipse.cdt.core.build.IToolChain;
import org.eclipse.cdt.core.build.IToolChainManager;
import org.eclipse.cdt.core.build.IToolChainProvider;
@@ -28,12 +24,9 @@ import org.eclipse.core.runtime.Platform;
*/
public class GCCPathToolChainProvider implements IToolChainProvider {
- private static final String ID = "org.eclipse.cdt.build.gcc.core.gccPathProvider"; //$NON-NLS-1$
+ public static final String ID = "org.eclipse.cdt.build.gcc.core.gccPathProvider"; //$NON-NLS-1$
- private static final Pattern gppPattern = Pattern.compile("(.*-)?(g\\+\\+|clang\\+\\+)"); //$NON-NLS-1$
- private static final Pattern gccPattern = Pattern.compile("(.*-)?(gcc|clang)"); //$NON-NLS-1$
- private static final Pattern versionPattern = Pattern.compile(".*(gcc|LLVM) version .*"); //$NON-NLS-1$
- private static final Pattern targetPattern = Pattern.compile("Target: (.*)"); //$NON-NLS-1$
+ private static final Pattern gccPattern = Pattern.compile("(.*-)?((gcc|clang)(\\.exe)?)"); //$NON-NLS-1$
@Override
public String getId() {
@@ -42,86 +35,33 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
@Override
public void init(IToolChainManager manager) {
- Set<String> names = new HashSet<>();
-
String path = System.getenv("PATH"); //$NON-NLS-1$
for (String dirStr : path.split(File.pathSeparator)) {
File dir = new File(dirStr);
if (dir.isDirectory()) {
- for (String file : dir.list()) {
- String prefix = null;
- boolean hasAltCmd = false;
-
- Matcher matcher = gccPattern.matcher(file);
+ for (File file : dir.listFiles()) {
+ Matcher matcher = gccPattern.matcher(file.getName());
if (matcher.matches()) {
- prefix = matcher.group(1);
- String cmd = matcher.group(2);
- 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();
- }
- else {
- matcher = gppPattern.matcher(file);
- if (matcher.matches()) {
- prefix = matcher.group(1);
- String cmd = matcher.group(2);
- 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();
- }
- }
- if (prefix != null && hasAltCmd) {
- String command = dirStr + File.separatorChar + file;
try {
- Process proc = new ProcessBuilder(new String[] { command, "-v" }).redirectErrorStream(true) //$NON-NLS-1$
- .start();
- String version = null;
- String target = null;
- try (BufferedReader reader = new BufferedReader(
- new InputStreamReader(proc.getInputStream()))) {
- for (String line = reader.readLine(); line != null; line = reader.readLine()) {
- Matcher versionMatcher = versionPattern.matcher(line);
- if (versionMatcher.matches()) {
- version = line.trim();
- continue;
- }
- Matcher targetMatcher = targetPattern.matcher(line);
- if (targetMatcher.matches()) {
- target = targetMatcher.group(1);
- continue;
- }
- }
- }
- if (target != null && version != null) {
- String name = target + " - " + version; //$NON-NLS-1$
- if (!names.contains(name)) {
- names.add(name);
- GCCToolChain toolChain = new GCCToolChain(this, target, version,
- new Path[] { dir.toPath() }, prefix);
- String[] tuple = target.split("-"); //$NON-NLS-1$
- if (tuple.length > 2) {
- // Arch
- if ("x86_64".equals(tuple[0])) { //$NON-NLS-1$
- toolChain.setProperty(IToolChain.ATTR_ARCH, tuple[0]);
- } else {
- toolChain.setProperty(IToolChain.ATTR_ARCH, "x86"); // default //$NON-NLS-1$
- }
+ GCCInfo info = new GCCInfo(file.toString());
+ if (info.target != null && info.version != null) {
+ String[] tuple = info.target.split("-"); //$NON-NLS-1$
+ if (tuple.length > 2) {
+ GCCToolChain gcc = new GCCToolChain(this, file.toPath(), tuple[0], null);
- // OS
- switch (tuple[1]) {
- case "w64": //$NON-NLS-1$
- toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_WIN32);
- break;
- case "linux": //$NON-NLS-1$
- toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_LINUX);
- break;
- case "apple": //$NON-NLS-1$
- toolChain.setProperty(IToolChain.ATTR_OS, Platform.OS_MACOSX);
- break;
- }
+ // OS
+ switch (tuple[1]) {
+ case "w64": //$NON-NLS-1$
+ gcc.setProperty(IToolChain.ATTR_OS, Platform.OS_WIN32);
+ break;
+ case "linux": //$NON-NLS-1$
+ gcc.setProperty(IToolChain.ATTR_OS, Platform.OS_LINUX);
+ break;
+ case "apple": //$NON-NLS-1$
+ gcc.setProperty(IToolChain.ATTR_OS, Platform.OS_MACOSX);
+ break;
}
- toolChain.setProperty(IToolChain.ATTR_PACKAGE, "system"); //$NON-NLS-1$
- manager.addToolChain(toolChain);
+ manager.addToolChain(gcc);
}
}
} catch (IOException e) {
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Messages.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Messages.java
new file mode 100644
index 00000000000..a4018d3fc24
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Messages.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.core.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.build.gcc.core.internal.messages"; //$NON-NLS-1$
+ public static String GCCUserToolChainProvider_Loading;
+ public static String GCCUserToolChainProvider_NotOurs;
+ public static String GCCUserToolChainProvider_Saving;
+ public static String GCCUserToolChainProvider_Saving1;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/messages.properties b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/messages.properties
new file mode 100644
index 00000000000..baaae03267d
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/messages.properties
@@ -0,0 +1,11 @@
+################################################################################
+# Copyright (c) 2017 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+################################################################################
+GCCUserToolChainProvider_Loading=Loading toolchains file
+GCCUserToolChainProvider_NotOurs=Not our toolchain
+GCCUserToolChainProvider_Saving=Saving toolchains file
+GCCUserToolChainProvider_Saving1=Saving toolchains file
diff --git a/build/org.eclipse.cdt.build.gcc.ui/.classpath b/build/org.eclipse.cdt.build.gcc.ui/.classpath
new file mode 100644
index 00000000000..eca7bdba8f0
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/build/org.eclipse.cdt.build.gcc.ui/.project b/build/org.eclipse.cdt.build.gcc.ui/.project
new file mode 100644
index 00000000000..4142880ab75
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.cdt.build.gcc.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/build/org.eclipse.cdt.build.gcc.ui/.settings/org.eclipse.jdt.core.prefs b/build/org.eclipse.cdt.build.gcc.ui/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000000..0c68a61dca8
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/build/org.eclipse.cdt.build.gcc.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.build.gcc.ui/META-INF/MANIFEST.MF
new file mode 100644
index 00000000000..9e2e81bf1f1
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,14 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: GCC ToolChain Support UI
+Bundle-SymbolicName: org.eclipse.cdt.build.gcc.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.cdt.build.gcc.ui.internal.Activator
+Bundle-Vendor: Eclipse CDT
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.cdt.ui;bundle-version="6.3.0",
+ org.eclipse.cdt.build.gcc.core;bundle-version="1.0.0",
+ org.eclipse.cdt.core;bundle-version="6.4.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Bundle-ActivationPolicy: lazy
diff --git a/build/org.eclipse.cdt.build.gcc.ui/build.properties b/build/org.eclipse.cdt.build.gcc.ui/build.properties
new file mode 100644
index 00000000000..e9863e281ea
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
diff --git a/build/org.eclipse.cdt.build.gcc.ui/plugin.xml b/build/org.eclipse.cdt.build.gcc.ui/plugin.xml
new file mode 100644
index 00000000000..44d67046d7a
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/plugin.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.cdt.ui.newToolChainWizards">
+ <wizard
+ class="org.eclipse.cdt.build.gcc.ui.internal.NewGCCToolChainWizard"
+ name="GCC or Compatible ToolChain"
+ providerId="org.eclipse.cdt.build.gcc.core.provider.user">
+ </wizard>
+ </extension>
+
+</plugin>
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Activator.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Activator.java
new file mode 100644
index 00000000000..30daf1ee42a
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Activator.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.eclipse.cdt.build.gcc.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ public static void log(IStatus status) {
+ plugin.getLog().log(status);
+ }
+
+ public static <T> T getService(Class<T> service) {
+ BundleContext context = plugin.getBundle().getBundleContext();
+ ServiceReference<T> ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/GCCToolChainSettingsPage.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/GCCToolChainSettingsPage.java
new file mode 100644
index 00000000000..22af1c0dc81
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/GCCToolChainSettingsPage.java
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.eclipse.cdt.build.gcc.core.GCCToolChain;
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+
+public class GCCToolChainSettingsPage extends WizardPage {
+
+ private final GCCToolChain toolChain;
+ private Text compilerText;
+ private Text osText;
+ private Text archText;
+
+ public GCCToolChainSettingsPage(GCCToolChain toolChain) {
+ super(GCCToolChainSettingsPage.class.getName());
+ this.toolChain = toolChain;
+ setTitle(Messages.GCCToolChainSettingsPage_Title);
+ setDescription(Messages.GCCToolChainSettingsPage_Description);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ comp.setLayout(new GridLayout(2, false));
+
+ Label label = new Label(comp, SWT.NONE);
+ label.setText(Messages.GCCToolChainSettingsPage_Compiler);
+
+ Composite compilerComp = new Composite(comp, SWT.NONE);
+ compilerComp.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = layout.marginWidth = 0;
+ compilerComp.setLayout(layout);
+
+ compilerText = new Text(compilerComp, SWT.BORDER);
+ compilerText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ compilerText.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ updateComplete();
+ }
+ });
+ compilerText.addModifyListener(e -> updateComplete());
+ if (toolChain != null) {
+ compilerText.setText(toolChain.getPath().toString());
+ }
+
+ Button compilerBrowse = new Button(compilerComp, SWT.PUSH);
+ compilerBrowse.setText(Messages.GCCToolChainSettingsPage_Browse);
+ compilerBrowse.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog fileDialog = new FileDialog(getShell());
+ String newText = fileDialog.open();
+ if (newText != null) {
+ compilerText.setText(newText);
+ }
+ }
+ });
+
+ label = new Label(comp, SWT.NONE);
+ label.setText(Messages.GCCToolChainSettingsPage_OS);
+
+ osText = new Text(comp, SWT.BORDER);
+ osText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (toolChain != null) {
+ String os = toolChain.getProperty(IToolChain.ATTR_OS);
+ if (os != null) {
+ osText.setText(os);
+ }
+ }
+
+ label = new Label(comp, SWT.NONE);
+ label.setText(Messages.GCCToolChainSettingsPage_Arch);
+
+ archText = new Text(comp, SWT.BORDER);
+ archText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (toolChain != null) {
+ String arch = toolChain.getProperty(IToolChain.ATTR_ARCH);
+ if (arch != null) {
+ archText.setText(arch);
+ }
+ }
+
+ updateComplete();
+
+ setControl(comp);
+ }
+
+ private void updateComplete() {
+ setPageComplete(!compilerText.getText().trim().isEmpty());
+ }
+
+ public Path getPath() {
+ return Paths.get(compilerText.getText().trim());
+ }
+
+ public String getOS() {
+ return osText.getText().trim();
+ }
+
+ public String getArch() {
+ return archText.getText().trim();
+ }
+
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Messages.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Messages.java
new file mode 100644
index 00000000000..4edba7647a9
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/Messages.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.build.gcc.ui.internal.messages"; //$NON-NLS-1$
+ public static String GCCToolChainSettingsPage_Arch;
+ public static String GCCToolChainSettingsPage_Browse;
+ public static String GCCToolChainSettingsPage_Compiler;
+ public static String GCCToolChainSettingsPage_Description;
+ public static String GCCToolChainSettingsPage_OS;
+ public static String GCCToolChainSettingsPage_Title;
+ public static String NewEnvVarDialog_Append;
+ public static String NewEnvVarDialog_Delimiter;
+ public static String NewEnvVarDialog_Edit;
+ public static String NewEnvVarDialog_Name;
+ public static String NewEnvVarDialog_New;
+ public static String NewEnvVarDialog_Operation;
+ public static String NewEnvVarDialog_Prepend;
+ public static String NewEnvVarDialog_Replace;
+ public static String NewEnvVarDialog_Select;
+ public static String NewEnvVarDialog_Unset;
+ public static String NewEnvVarDialog_Value;
+ public static String NewGCCToolChainWizard_Add;
+ public static String NewGCCToolChainWizard_New;
+ public static String ToolChainEnvironmentPage_Add;
+ public static String ToolChainEnvironmentPage_Append;
+ public static String ToolChainEnvironmentPage_Description;
+ public static String ToolChainEnvironmentPage_Edit;
+ public static String ToolChainEnvironmentPage_Name;
+ public static String ToolChainEnvironmentPage_Operation;
+ public static String ToolChainEnvironmentPage_Prepend;
+ public static String ToolChainEnvironmentPage_Remove;
+ public static String ToolChainEnvironmentPage_RemoveMessage;
+ public static String ToolChainEnvironmentPage_RemoveTitle;
+ public static String ToolChainEnvironmentPage_Replace;
+ public static String ToolChainEnvironmentPage_Title;
+ public static String ToolChainEnvironmentPage_Unset;
+ public static String ToolChainEnvironmentPage_Value;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewEnvVarDialog.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewEnvVarDialog.java
new file mode 100644
index 00000000000..c1348b1c781
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewEnvVarDialog.java
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import org.eclipse.cdt.core.envvar.EnvironmentVariable;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class NewEnvVarDialog extends Dialog {
+
+ private Text nameText;
+ private Label valueLabel;
+ private Text valueText;
+ private Label delimiterLabel;
+ private Text delimiterText;
+ private Button replaceButton;
+ private Button prependButton;
+ private Button appendButton;
+ private Button removeButton;
+
+ private IEnvironmentVariable envvar;
+
+ public NewEnvVarDialog(Shell parentShell) {
+ super(parentShell);
+ }
+
+ public NewEnvVarDialog(Shell parentShell, IEnvironmentVariable var) {
+ super(parentShell);
+ this.envvar = var;
+ }
+
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ if (envvar == null) {
+ getShell().setText(Messages.NewEnvVarDialog_New);
+ } else {
+ getShell().setText(Messages.NewEnvVarDialog_Edit);
+ }
+
+ Composite comp = new Composite(parent, SWT.NONE);
+ GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+ layoutData.widthHint = 400;
+ comp.setLayoutData(layoutData);
+ comp.setLayout(new GridLayout(3, false));
+
+ Group opGroup = new Group(comp, SWT.NONE);
+ opGroup.setText(Messages.NewEnvVarDialog_Operation);
+ opGroup.setLayout(new GridLayout(4, false));
+ layoutData = new GridData(SWT.FILL, SWT.FILL, true, false);
+ layoutData.horizontalSpan = 3;
+ opGroup.setLayoutData(layoutData);
+
+ replaceButton = new Button(opGroup, SWT.RADIO);
+ replaceButton.setText(Messages.NewEnvVarDialog_Replace);
+
+ prependButton = new Button(opGroup, SWT.RADIO);
+ prependButton.setText(Messages.NewEnvVarDialog_Prepend);
+ prependButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateEnablement();
+ }
+ });
+
+ appendButton = new Button(opGroup, SWT.RADIO);
+ appendButton.setText(Messages.NewEnvVarDialog_Append);
+ appendButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateEnablement();
+ }
+ });
+
+ removeButton = new Button(opGroup, SWT.RADIO);
+ removeButton.setText(Messages.NewEnvVarDialog_Unset);
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateEnablement();
+ }
+ });
+
+ if (envvar == null) {
+ replaceButton.setSelection(true);
+ } else {
+ switch (envvar.getOperation()) {
+ case IEnvironmentVariable.ENVVAR_REPLACE:
+ replaceButton.setSelection(true);
+ break;
+ case IEnvironmentVariable.ENVVAR_PREPEND:
+ prependButton.setSelection(true);
+ break;
+ case IEnvironmentVariable.ENVVAR_APPEND:
+ appendButton.setSelection(true);
+ break;
+ default:
+ removeButton.setSelection(true);
+ }
+ }
+
+ Label label = new Label(comp, SWT.NONE);
+ label.setText(Messages.NewEnvVarDialog_Name);
+
+ nameText = new Text(comp, SWT.BORDER);
+ nameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ if (envvar != null) {
+ nameText.setText(envvar.getName());
+ }
+
+ Button selectButton = new Button(comp, SWT.PUSH);
+ selectButton.setText(Messages.NewEnvVarDialog_Select);
+
+ valueLabel = new Label(comp, SWT.NONE);
+ valueLabel.setText(Messages.NewEnvVarDialog_Value);
+
+ valueText = new Text(comp, SWT.BORDER);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ layoutData.horizontalSpan = 2;
+ valueText.setLayoutData(layoutData);
+ if (envvar != null && envvar.getValue() != null) {
+ valueText.setText(envvar.getValue());
+ }
+
+ delimiterLabel = new Label(comp, SWT.NONE);
+ delimiterLabel.setText(Messages.NewEnvVarDialog_Delimiter);
+
+ delimiterText = new Text(comp, SWT.BORDER);
+ layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ layoutData.horizontalSpan = 2;
+ delimiterText.setLayoutData(layoutData);
+ if (envvar != null && envvar.getDelimiter() != null) {
+ delimiterText.setText(envvar.getDelimiter());
+ }
+
+ updateEnablement();
+ return comp;
+ }
+
+ private void updateEnablement() {
+ valueLabel.setEnabled(!removeButton.getSelection());
+ valueText.setEnabled(!removeButton.getSelection());
+
+ delimiterLabel.setEnabled(prependButton.getSelection() || appendButton.getSelection());
+ delimiterText.setEnabled(prependButton.getSelection() || appendButton.getSelection());
+ }
+
+ @Override
+ protected void okPressed() {
+ String name = nameText.getText().trim();
+
+ int operation;
+ if (replaceButton.getSelection()) {
+ operation = IEnvironmentVariable.ENVVAR_REPLACE;
+ } else if (prependButton.getSelection()) {
+ operation = IEnvironmentVariable.ENVVAR_PREPEND;
+ } else if (appendButton.getSelection()) {
+ operation = IEnvironmentVariable.ENVVAR_APPEND;
+ } else {
+ operation = IEnvironmentVariable.ENVVAR_REMOVE;
+ }
+
+ String value;
+ if (valueText.isEnabled()) {
+ value = valueText.getText().trim();
+ if (value.isEmpty()) {
+ value = null;
+ }
+ } else {
+ value = null;
+ }
+
+ String delimiter;
+ if (delimiterText.isEnabled()) {
+ delimiter = delimiterText.getText().trim();
+ if (delimiter.isEmpty()) {
+ delimiter = null;
+ }
+ } else {
+ delimiter = null;
+ }
+
+ envvar = new EnvironmentVariable(name, value, operation, delimiter);
+
+ super.okPressed();
+ }
+
+ public IEnvironmentVariable getEnvVar() {
+ return envvar;
+ }
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java
new file mode 100644
index 00000000000..b6fcb97fa04
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/NewGCCToolChainWizard.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import java.nio.file.Path;
+
+import org.eclipse.cdt.build.gcc.core.GCCToolChain;
+import org.eclipse.cdt.build.gcc.core.GCCUserToolChainProvider;
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.core.build.IToolChainManager;
+import org.eclipse.cdt.core.build.IUserToolChainProvider;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.cdt.ui.build.ToolChainWizard;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+
+public class NewGCCToolChainWizard extends ToolChainWizard {
+
+ private GCCToolChainSettingsPage settingsPage;
+ private ToolChainEnvironmentPage envPage;
+
+ @Override
+ public boolean performFinish() {
+ Path path = settingsPage.getPath();
+ String os = settingsPage.getOS();
+ String arch = settingsPage.getArch();
+ IEnvironmentVariable[] envvars = envPage.getEnvVars();
+
+ new Job(Messages.NewGCCToolChainWizard_Add) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ IToolChainManager manager = Activator.getService(IToolChainManager.class);
+ IUserToolChainProvider provider = (IUserToolChainProvider) manager
+ .getProvider(GCCUserToolChainProvider.PROVIDER_ID);
+
+ if (toolChain != null) {
+ provider.removeToolChain(toolChain);
+ }
+
+ GCCToolChain gcc = new GCCToolChain(provider, path, arch, envvars);
+ gcc.setProperty(IToolChain.ATTR_OS, os);
+ provider.addToolChain(gcc);
+ return Status.OK_STATUS;
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ }
+ }.schedule();
+ return true;
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+
+ settingsPage = new GCCToolChainSettingsPage((GCCToolChain) toolChain);
+ addPage(settingsPage);
+
+ envPage = new ToolChainEnvironmentPage(toolChain);
+ addPage(envPage);
+
+ setWindowTitle(Messages.NewGCCToolChainWizard_New);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/ToolChainEnvironmentPage.java b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/ToolChainEnvironmentPage.java
new file mode 100644
index 00000000000..cbe4bb8e66a
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/ToolChainEnvironmentPage.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Copyright (c) 2017 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.cdt.build.gcc.ui.internal;
+
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.cdt.core.build.IToolChain;
+import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.BaseLabelProvider;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.window.Window;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+
+public class ToolChainEnvironmentPage extends WizardPage {
+
+ private TableViewer tableViewer;
+ private Button editButton;
+ private Button removeButton;
+
+ private List<IEnvironmentVariable> envvars;
+
+ public ToolChainEnvironmentPage(IToolChain toolChain) {
+ super(ToolChainEnvironmentPage.class.getName());
+ setTitle(Messages.ToolChainEnvironmentPage_Title);
+ setDescription(Messages.ToolChainEnvironmentPage_Description);
+
+ if (toolChain != null && toolChain.getVariables() != null) {
+ this.envvars = new LinkedList<>(Arrays.asList(toolChain.getVariables()));
+ } else {
+ this.envvars = new LinkedList<>();
+ }
+ }
+
+ private static abstract class TableLabelProvider extends BaseLabelProvider implements ITableLabelProvider {
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ comp.setLayout(new GridLayout(2, false));
+
+ Table table = new Table(comp, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.FULL_SELECTION);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumn column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.ToolChainEnvironmentPage_Name);
+ column.setWidth(150);
+
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.ToolChainEnvironmentPage_Value);
+ column.setWidth(150);
+
+ column = new TableColumn(table, SWT.LEFT);
+ column.setText(Messages.ToolChainEnvironmentPage_Operation);
+ column.setWidth(75);
+
+ tableViewer = new TableViewer(table);
+ tableViewer.setContentProvider(new IStructuredContentProvider() {
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return envvars.toArray();
+ }
+ });
+ tableViewer.setLabelProvider(new TableLabelProvider() {
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ IEnvironmentVariable var = (IEnvironmentVariable) element;
+ switch (columnIndex) {
+ case 0:
+ return var.getName();
+ case 1:
+ return var.getValue();
+ case 2:
+ switch (var.getOperation()) {
+ case IEnvironmentVariable.ENVVAR_REPLACE:
+ return Messages.ToolChainEnvironmentPage_Replace;
+ case IEnvironmentVariable.ENVVAR_PREPEND:
+ return Messages.ToolChainEnvironmentPage_Prepend;
+ case IEnvironmentVariable.ENVVAR_APPEND:
+ return Messages.ToolChainEnvironmentPage_Append;
+ case IEnvironmentVariable.ENVVAR_REMOVE:
+ return Messages.ToolChainEnvironmentPage_Unset;
+ }
+ }
+ return null;
+ }
+ });
+
+ Composite buttonComp = new Composite(comp, SWT.NONE);
+ buttonComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+ buttonComp.setLayout(new GridLayout());
+
+ Button addButton = new Button(buttonComp, SWT.PUSH);
+ addButton.setText(Messages.ToolChainEnvironmentPage_Add);
+ addButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ addButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ NewEnvVarDialog dialog = new NewEnvVarDialog(getShell());
+ if (dialog.open() == Window.OK) {
+ envvars.add(dialog.getEnvVar());
+ tableViewer.refresh();
+ }
+ }
+ });
+
+ editButton = new Button(buttonComp, SWT.PUSH);
+ editButton.setText(Messages.ToolChainEnvironmentPage_Edit);
+ editButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ editButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleEdit();
+ }
+ });
+
+ removeButton = new Button(buttonComp, SWT.PUSH);
+ removeButton.setText(Messages.ToolChainEnvironmentPage_Remove);
+ removeButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ removeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (MessageDialog.openConfirm(getShell(), Messages.ToolChainEnvironmentPage_RemoveTitle,
+ Messages.ToolChainEnvironmentPage_RemoveMessage)) {
+ @SuppressWarnings("rawtypes")
+ Iterator i = tableViewer.getStructuredSelection().iterator();
+ while (i.hasNext()) {
+ IEnvironmentVariable var = (IEnvironmentVariable) i.next();
+ envvars.remove(var);
+ }
+ tableViewer.refresh();
+ }
+ }
+ });
+
+ table.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateButtons();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ updateButtons();
+ if (table.getSelectionCount() == 1) {
+ handleEdit();
+ }
+ }
+ });
+
+ tableViewer.setInput(envvars);
+ setControl(comp);
+ }
+
+ private void updateButtons() {
+ int n = tableViewer.getTable().getSelectionCount();
+ editButton.setEnabled(n == 1);
+ removeButton.setEnabled(n > 0);
+ }
+
+ private void handleEdit() {
+ IEnvironmentVariable var = (IEnvironmentVariable) tableViewer.getStructuredSelection().getFirstElement();
+ NewEnvVarDialog dialog = new NewEnvVarDialog(getShell(), var);
+ if (dialog.open() == Window.OK) {
+ envvars.remove(var);
+ envvars.add(dialog.getEnvVar());
+ tableViewer.refresh();
+ tableViewer.setSelection(new StructuredSelection(dialog.getEnvVar()));
+ }
+ }
+
+ public IEnvironmentVariable[] getEnvVars() {
+ return !envvars.isEmpty() ? envvars.toArray(new IEnvironmentVariable[0]) : null;
+ }
+
+}
diff --git a/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/messages.properties b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/messages.properties
new file mode 100644
index 00000000000..da97717652f
--- /dev/null
+++ b/build/org.eclipse.cdt.build.gcc.ui/src/org/eclipse/cdt/build/gcc/ui/internal/messages.properties
@@ -0,0 +1,40 @@
+################################################################################
+# Copyright (c) 2017 QNX Software Systems and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+################################################################################
+GCCToolChainSettingsPage_Arch=CPU Architecture:
+GCCToolChainSettingsPage_Browse=Browse...
+GCCToolChainSettingsPage_Compiler=Compiler:
+GCCToolChainSettingsPage_Description=Enter the path to the compiler and properties for the toolchain.
+GCCToolChainSettingsPage_OS=Operating System:
+GCCToolChainSettingsPage_Title=GCC ToolChain Settings
+NewEnvVarDialog_Append=Append
+NewEnvVarDialog_Delimiter=Delimiter:
+NewEnvVarDialog_Edit=Edit Environment Variable
+NewEnvVarDialog_Name=Name:
+NewEnvVarDialog_New=New Environment Variable
+NewEnvVarDialog_Operation=Operation
+NewEnvVarDialog_Prepend=Prepend
+NewEnvVarDialog_Replace=Replace
+NewEnvVarDialog_Select=Select...
+NewEnvVarDialog_Unset=Unset
+NewEnvVarDialog_Value=Value:
+NewGCCToolChainWizard_Add=Add ToolChain
+NewGCCToolChainWizard_New=New GCC ToolChain
+ToolChainEnvironmentPage_Add=Add...
+ToolChainEnvironmentPage_Append=Append
+ToolChainEnvironmentPage_Description=Environment variables to set when using toolchain.
+ToolChainEnvironmentPage_Edit=Edit...
+ToolChainEnvironmentPage_Name=Name
+ToolChainEnvironmentPage_Operation=Operation
+ToolChainEnvironmentPage_Prepend=Prepend
+ToolChainEnvironmentPage_Remove=Remove
+ToolChainEnvironmentPage_RemoveMessage=Are you sure you would like to remove the selected environment variable(s)
+ToolChainEnvironmentPage_RemoveTitle=Remove
+ToolChainEnvironmentPage_Replace=Replace
+ToolChainEnvironmentPage_Title=Environment Variables
+ToolChainEnvironmentPage_Unset=Unset
+ToolChainEnvironmentPage_Value=Value
diff --git a/build/org.eclipse.cdt.cmake.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.cmake.core/META-INF/MANIFEST.MF
index 76fde2680d3..3a4b5e98c24 100644
--- a/build/org.eclipse.cdt.cmake.core/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.cmake.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CDT CMake Core
Bundle-SymbolicName: org.eclipse.cdt.cmake.core;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.2.0.qualifier
Bundle-Activator: org.eclipse.cdt.cmake.core.internal.Activator
Bundle-Vendor: Eclipse CDT
Require-Bundle: org.eclipse.core.runtime,
diff --git a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
index 4fe7a6d5bef..c09b0850d2e 100644
--- a/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
+++ b/build/org.eclipse.cdt.cmake.core/src/org/eclipse/cdt/cmake/core/internal/CMakeBuildConfigurationProvider.java
@@ -92,7 +92,7 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
properties.put(IToolChain.ATTR_OS, os);
}
String arch = toolChain.getProperty(IToolChain.ATTR_ARCH);
- if (!arch.isEmpty()) {
+ if (arch != null && !arch.isEmpty()) {
properties.put(IToolChain.ATTR_ARCH, arch);
}
ICMakeToolChainFile file = null;
@@ -102,9 +102,24 @@ public class CMakeBuildConfigurationProvider implements ICBuildConfigurationProv
}
// create config
- String configName = "cmake." + launchMode + '.' + toolChain.getId(); //$NON-NLS-1$
- IBuildConfiguration config = configManager.createBuildConfiguration(this, project, configName, monitor);
- CMakeBuildConfiguration cmakeConfig = new CMakeBuildConfiguration(config, configName, toolChain, file,
+ StringBuilder configName = new StringBuilder("cmake."); //$NON-NLS-1$
+ configName.append(launchMode);
+ if (os != null) {
+ configName.append('.');
+ configName.append(os);
+ }
+ if (arch != null) {
+ configName.append('.');
+ configName.append(arch);
+ }
+ String name = configName.toString();
+ int i = 0;
+ while (project.hasBuildConfig(name)) {
+ name = configName.toString() + '.' + (++i);
+ }
+
+ IBuildConfiguration config = configManager.createBuildConfiguration(this, project, name, monitor);
+ CMakeBuildConfiguration cmakeConfig = new CMakeBuildConfiguration(config, name, toolChain, file,
launchMode);
configManager.addBuildConfiguration(config, cmakeConfig);
return cmakeConfig;
diff --git a/build/org.eclipse.cdt.cmake.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.cmake.ui/META-INF/MANIFEST.MF
index 2d8ec068d1b..78e0949d57f 100644
--- a/build/org.eclipse.cdt.cmake.ui/META-INF/MANIFEST.MF
+++ b/build/org.eclipse.cdt.cmake.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: CDT CMake UI
Bundle-SymbolicName: org.eclipse.cdt.cmake.ui;singleton:=true
-Bundle-Version: 1.1.0.qualifier
+Bundle-Version: 1.2.0.qualifier
Bundle-Activator: org.eclipse.cdt.cmake.ui.internal.Activator
Bundle-Vendor: Eclipse CDT
Require-Bundle: org.eclipse.core.runtime,
@@ -14,7 +14,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.cdt.core;bundle-version="6.1.0",
org.eclipse.debug.ui;bundle-version="3.11.200",
org.eclipse.cdt.launch;bundle-version="9.1.0",
- org.eclipse.cdt.debug.core;bundle-version="8.1.0"
+ org.eclipse.cdt.debug.core;bundle-version="8.1.0",
+ org.eclipse.cdt.ui;bundle-version="6.2.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
diff --git a/build/org.eclipse.cdt.cmake.ui/plugin.properties b/build/org.eclipse.cdt.cmake.ui/plugin.properties
index e4c6c7270fa..d0466c4342a 100644
--- a/build/org.eclipse.cdt.cmake.ui/plugin.properties
+++ b/build/org.eclipse.cdt.cmake.ui/plugin.properties
@@ -7,3 +7,4 @@
###############################################################################
cmake.preferences.name = CMake
+toolchains.preferences.name = Toolchains
diff --git a/build/org.eclipse.cdt.cmake.ui/plugin.xml b/build/org.eclipse.cdt.cmake.ui/plugin.xml
index 042d05e8d13..781213fbb00 100644
--- a/build/org.eclipse.cdt.cmake.ui/plugin.xml
+++ b/build/org.eclipse.cdt.cmake.ui/plugin.xml
@@ -28,6 +28,12 @@
id="org.eclipse.cdt.cmake.ui.page1"
name="%cmake.preferences.name">
</page>
+ <page
+ category="org.eclipse.cdt.cmake.ui.page1"
+ class="org.eclipse.cdt.ui.build.ToolChainPreferencePage"
+ id="org.eclipse.cdt.cmake.ui.page.toolchains"
+ name="%toolchains.preferences.name">
+ </page>
</extension>
<extension
point="org.eclipse.tools.templates.ui.templates">
diff --git a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/NewCMakeToolChainFilePage.java b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/NewCMakeToolChainFilePage.java
index bc66767f9fc..b40c60a2d86 100644
--- a/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/NewCMakeToolChainFilePage.java
+++ b/build/org.eclipse.cdt.cmake.ui/src/org/eclipse/cdt/cmake/ui/internal/NewCMakeToolChainFilePage.java
@@ -107,11 +107,6 @@ public class NewCMakeToolChainFilePage extends WizardPage {
return;
}
- if (archText.getText().isEmpty()) {
- setErrorMessage("Please set the target CPU architecture.");
- return;
- }
-
setPageComplete(true);
setErrorMessage(null);
}

Back to the top