Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2017-09-27 20:27:40 -0400
committerDoug Schaefer2017-09-28 13:42:58 -0400
commit5228d193004a8001632385127f5b45a3a5243f7e (patch)
tree58b418f969732f94b12054aa58bba475e579bbd2
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
-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
-rw-r--r--core/org.eclipse.cdt.core/.settings/.api_filters28
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java9
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java3
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuilder.java9
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java94
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java20
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IUserToolChainProvider.java41
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java3
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/Messages.java12
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/Messages.properties1
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java44
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/messages.properties12
-rw-r--r--core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF3
-rw-r--r--core/org.eclipse.cdt.ui/plugin.xml1
-rw-r--r--core/org.eclipse.cdt.ui/schema/newToolChainWizards.exsd129
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java22
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizard.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizardSelectionPage.java144
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/project/NewCDTProjectWizard.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java310
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainWizard.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java3
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java13
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java106
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java9
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml6
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java51
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java36
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java61
60 files changed, 2504 insertions, 305 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 07c5abe6db..182b4d4d51 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 596c7623f6..036b2b8f89 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 51373ff7d8..f5cd6b21b6 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 0000000000..b7b25e9d99
--- /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 c9f26e7d2d..d50a8b19fd 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 11944cbca8..d44607af45 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 0000000000..a4018d3fc2
--- /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 0000000000..baaae03267
--- /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 0000000000..eca7bdba8f
--- /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 0000000000..4142880ab7
--- /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 0000000000..0c68a61dca
--- /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 0000000000..9e2e81bf1f
--- /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 0000000000..e9863e281e
--- /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 0000000000..44d67046d7
--- /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 0000000000..30daf1ee42
--- /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 0000000000..22af1c0dc8
--- /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 0000000000..4edba7647a
--- /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 0000000000..c1348b1c78
--- /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 0000000000..b6fcb97fa0
--- /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 0000000000..cbe4bb8e66
--- /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 0000000000..da97717652
--- /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 76fde2680d..3a4b5e98c2 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 4fe7a6d5be..c09b0850d2 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 2d8ec068d1..78e0949d57 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 e4c6c7270f..d0466c4342 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 042d05e8d1..781213fbb0 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 bc66767f9f..b40c60a2d8 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);
}
diff --git a/core/org.eclipse.cdt.core/.settings/.api_filters b/core/org.eclipse.cdt.core/.settings/.api_filters
new file mode 100644
index 0000000000..f95a509891
--- /dev/null
+++ b/core/org.eclipse.cdt.core/.settings/.api_filters
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<component id="org.eclipse.cdt.core" version="2">
+ <resource path="src/org/eclipse/cdt/core/build/IToolChainProvider.java" type="org.eclipse.cdt.core.build.IToolChainProvider">
+ <filter comment="This interface is still pretty new. Assuming low risk." id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
+ <message_argument value="addToolChain(IToolChain)"/>
+ </message_arguments>
+ </filter>
+ <filter id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
+ <message_argument value="getToolChain(String)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="Newish interface. Assuming low risk." id="404000815">
+ <message_arguments>
+ <message_argument value="org.eclipse.cdt.core.build.IToolChainProvider"/>
+ <message_argument value="removeToolChain(IToolChain)"/>
+ </message_arguments>
+ </filter>
+ <filter comment="This is a newish interface. Assuming low risk." id="1211105284">
+ <message_arguments>
+ <message_argument value="removeToolChain(IToolChain)"/>
+ </message_arguments>
+ </filter>
+ </resource>
+</component>
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java
index a4895bdda0..9dd1c4b31a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/SemanticQueries.java
@@ -87,13 +87,14 @@ public class SemanticQueries {
* Returns all pure virtual methods of a class. Inherited pure virtual methods
* that have not been implemented are also returned.
*
- * NOTE: The method produces complete results for template instantiations
- * but doesn't take into account base classes and methods dependent on unspecified
+ * NOTE: The method produces complete results for template instantiations but
+ * doesn't take into account base classes and methods dependent on unspecified
* template parameters.
*
- * @param classType the class whose pure virtual methods should be returned
+ * @param classType
+ * the class whose pure virtual methods should be returned
* @return an array containing all pure virtual methods of the class
- * @since 6.3
+ * @since 6.4
*/
public static ICPPMethod[] getPureVirtualMethods(ICPPClassType classType) {
FinalOverriderMap finalOverriderMap = CPPInheritance.getFinalOverriderMap(classType);
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
index 196eb50a4d..e2adadf98c 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuildConfiguration.java
@@ -92,7 +92,6 @@ import com.google.gson.JsonParseException;
* settings for subclasses.
*
* @since 6.0
- * @noextend This class is provisional and should be subclassed with caution.
*/
public abstract class CBuildConfiguration extends PlatformObject
implements ICBuildConfiguration, IMarkerGenerator, IConsoleParser {
@@ -138,7 +137,7 @@ public abstract class CBuildConfiguration extends PlatformObject
}
toolChain = tc;
- launchMode = settings.get(LAUNCH_MODE, null); // $NON-NLS-1$
+ launchMode = settings.get(LAUNCH_MODE, "run"); //$NON-NLS-1$
}
protected CBuildConfiguration(IBuildConfiguration config, String name, IToolChain toolChain) {
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuilder.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuilder.java
index 47f2eef8f5..a50744deb0 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuilder.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/CBuilder.java
@@ -5,6 +5,7 @@ import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.internal.core.build.Messages;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
@@ -38,14 +39,14 @@ public class CBuilder extends IncrementalProjectBuilder {
// Get the build configuration
ICBuildConfiguration config = getBuildConfig().getAdapter(ICBuildConfiguration.class);
if (config == null) {
- console.getErrorStream().write("Build not configured correctly\n");
+ console.getErrorStream().write(Messages.CBuilder_NotConfiguredCorrectly);
return null;
}
return config.build(kind, args, console, monitor);
} catch (IOException e) {
throw new CoreException(
- new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Exception while building", e));
+ new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.CBuilder_ExceptionWhileBuilding, e));
}
}
@@ -61,14 +62,14 @@ public class CBuilder extends IncrementalProjectBuilder {
// Get the build configuration
ICBuildConfiguration config = getBuildConfig().getAdapter(ICBuildConfiguration.class);
if (config == null) {
- console.getErrorStream().write("Build not configured correctly\n");
+ console.getErrorStream().write(Messages.CBuilder_NotConfiguredCorrectly2);
return;
}
config.clean(console, monitor);
} catch (IOException e) {
throw new CoreException(
- new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, "Exception while building", e));
+ new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, Messages.CBuilder_ExceptionWhileBuilding2, e));
}
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java
index c6e1937953..b1b0ec270b 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainManager.java
@@ -8,23 +8,65 @@
package org.eclipse.cdt.core.build;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.ISafeRunnable;
/**
* The global toolchain manager. Accessed as an OSGi service.
*
+ * @noimplement This interface is not intended to be implemented by clients.
* @since 6.0
*/
public interface IToolChainManager {
+ /**
+ * Return the provider with the given id
+ *
+ * @param providerId
+ * id
+ * @return provider
+ * @throws CoreException
+ */
IToolChainProvider getProvider(String providerId) throws CoreException;
-
+
+ /**
+ * Return the toolchain from the given provider with the given id and version.
+ *
+ * @param providerId
+ * id of provider
+ * @param id
+ * id of toolchain
+ * @param version
+ * version of toolchain
+ * @return the toolchain
+ * @throws CoreException
+ */
IToolChain getToolChain(String providerId, String id, String version) throws CoreException;
+ /**
+ * Return the toolchains provided by the given provider
+ *
+ * @param providerId
+ * id of provider
+ * @return toolchains the provider provides
+ * @throws CoreException
+ */
Collection<IToolChain> getToolChains(String providerId) throws CoreException;
+ /**
+ * Return all versions of toolchains with the given id provided by the given
+ * provider.
+ *
+ * @param providerId
+ * id of provider
+ * @param id
+ * id of toolchains
+ * @return toolchains with the given id provided by the provider
+ * @throws CoreException
+ */
Collection<IToolChain> getToolChains(String providerId, String id) throws CoreException;
/**
@@ -36,8 +78,58 @@ public interface IToolChainManager {
*/
Collection<IToolChain> getToolChainsMatching(Map<String, String> properties) throws CoreException;
+ /**
+ * Return all of the toolchains.
+ *
+ * @since 6.4
+ */
+ Collection<IToolChain> getAllToolChains() throws CoreException;
+
+ /**
+ * Set the preference order of the toolchains. This controls the order
+ * toolchains are returned in the other methods in this interface. Often, the
+ * first toolchain in a list is the default toolchain to use in a build
+ * configuration.
+ *
+ * @param orderedToolchains
+ * @throws CoreException
+ * @since 6.4
+ */
+ void setToolChainOrder(List<IToolChain> orderedToolchains) throws CoreException;
+
+ /**
+ * Add a toolchain.
+ *
+ * @param toolChain
+ * the toolchain
+ */
void addToolChain(IToolChain toolChain);
+ /**
+ * Remove a toolchain
+ *
+ * @param toolChain
+ * the toolchain
+ */
void removeToolChain(IToolChain toolChain);
+ /**
+ * Add a listener for toolchains added or removed. The listener is a simple
+ * runnable that is called when an event occurs.
+ *
+ * @param listener
+ * runnable that is called when a toolchain is added or removed
+ * @since 6.4
+ */
+ void addToolChainListener(ISafeRunnable listener);
+
+ /**
+ * Remove a listener.
+ *
+ * @param listener
+ * the listener to remove
+ * @since 6.4
+ */
+ void removeToolChainListener(ISafeRunnable listener);
+
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java
index 0b9c78ef7c..d1c11e2fbb 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IToolChainProvider.java
@@ -36,15 +36,27 @@ public interface IToolChainProvider {
/**
* Called by the manager to dynamically create the toolchain.
*
- * @param name
- * the name of the toolchain
+ * @deprecated We have dropped the concept of version. All ids must be unique.
+ * @param id
+ * the id of the toolchain
* @param version
* the version of the toolchain
- * @param properties
- * the persisted settings for the toolchain
* @return the toolchain initialized with the settings.
*/
+ @Deprecated
default IToolChain getToolChain(String id, String version) throws CoreException {
+ return getToolChain(id);
+ }
+
+ /**
+ * Called by the manager to dynamically create the toolchain.
+ *
+ * @param id
+ * the id of the toolchain
+ * @return the toolchain initialized with the settings.
+ * @since 6.4
+ */
+ default IToolChain getToolChain(String id) throws CoreException {
// By default, assumes all toolchains were added at init time.
return null;
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IUserToolChainProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IUserToolChainProvider.java
new file mode 100644
index 0000000000..14f2f21c99
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/IUserToolChainProvider.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.core.build;
+
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * A toolchain provider that is managed by the user. The user can manually add
+ * and remove toolchains.
+ *
+ * It is the responsibility of the provider to manage persistence and to
+ * populate the toolchains with the toolchain manager.
+ *
+ * @since 6.4
+ */
+public interface IUserToolChainProvider extends IToolChainProvider {
+
+ /**
+ * Manually add a toolchain to be managed by this provider.
+ *
+ * @param toolChain
+ * toolchain to be added
+ * @since 6.4
+ */
+ void addToolChain(IToolChain toolChain) throws CoreException;
+
+ /**
+ * Manually remove a toolchain managed by this provider.
+ *
+ * @param toolChain
+ * toolchain to be removed
+ * @throws CoreException
+ */
+ void removeToolChain(IToolChain toolChain) throws CoreException;
+
+}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java
index ceeb95c499..50f28769f2 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/build/StandardBuildConfiguration.java
@@ -17,6 +17,7 @@ import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IConsoleParser;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.resources.IConsole;
+import org.eclipse.cdt.internal.core.build.Messages;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
@@ -77,7 +78,7 @@ public class StandardBuildConfiguration extends CBuildConfiguration {
Path buildDir = getBuildDirectory();
- outStream.write(String.format("Building in: %s\n", buildDir.toString()));
+ outStream.write(String.format(Messages.StandardBuildConfiguration_0, buildDir.toString()));
String[] command = new String[buildCommand.length];
Path make = findCommand(buildCommand[0]);
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/Messages.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/Messages.java
index 34174d410f..e94820da9d 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/Messages.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/Messages.java
@@ -1,3 +1,10 @@
+/*******************************************************************************
+ * 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.internal.core.build;
import org.eclipse.osgi.util.NLS;
@@ -5,6 +12,11 @@ import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.cdt.internal.core.build.Messages"; //$NON-NLS-1$
public static String CBuildConfigurationtoolchainMissing;
+ public static String CBuilder_ExceptionWhileBuilding;
+ public static String CBuilder_ExceptionWhileBuilding2;
+ public static String CBuilder_NotConfiguredCorrectly;
+ public static String CBuilder_NotConfiguredCorrectly2;
+ public static String StandardBuildConfiguration_0;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/Messages.properties b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/Messages.properties
deleted file mode 100644
index d1a49530f3..0000000000
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/Messages.properties
+++ /dev/null
@@ -1 +0,0 @@
-CBuildConfigurationtoolchainMissing=Toolchain missing for config: %s
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java
index 7be272a510..2333ee5e06 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/ToolChainManager.java
@@ -21,13 +21,17 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
public class ToolChainManager implements IToolChainManager {
private Map<String, IConfigurationElement> providerElements;
private Map<String, IToolChainProvider> providers;
private Map<List<String>, IToolChain> toolChains;
+ private List<IToolChain> orderedToolChains;
+ private List<ISafeRunnable> listeners = new ArrayList<>();
private void init() {
if (providerElements == null) {
@@ -45,6 +49,7 @@ public class ToolChainManager implements IToolChainManager {
// Load the discovered toolchains
toolChains = new HashMap<>();
+ orderedToolChains = new ArrayList<>();
for (IConfigurationElement element : providerElements.values()) {
// TODO check for enablement
try {
@@ -69,12 +74,16 @@ public class ToolChainManager implements IToolChainManager {
@Override
public void addToolChain(IToolChain toolChain) {
+ orderedToolChains.add(toolChain);
toolChains.put(getId(toolChain), toolChain);
+ fireChange();
}
@Override
public void removeToolChain(IToolChain toolChain) {
+ orderedToolChains.remove(toolChain);
toolChains.remove(getId(toolChain));
+ fireChange();
}
@Override
@@ -172,4 +181,39 @@ public class ToolChainManager implements IToolChainManager {
return tcs;
}
+ @Override
+ public Collection<IToolChain> getAllToolChains() throws CoreException {
+ init();
+ return orderedToolChains;
+ }
+
+ @Override
+ public void setToolChainOrder(List<IToolChain> orderedToolchains) throws CoreException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void addToolChainListener(ISafeRunnable listener) {
+ synchronized (listeners) {
+ listeners.add(listener);
+ }
+ }
+
+ @Override
+ public void removeToolChainListener(ISafeRunnable listener) {
+ synchronized (listeners) {
+ listeners.remove(listener);
+ }
+ }
+
+ private void fireChange() {
+ List<ISafeRunnable> runners;
+ synchronized (listeners) {
+ runners = new ArrayList<>(listeners);
+ }
+ for (ISafeRunnable runner : runners) {
+ SafeRunner.run(runner);
+ }
+ }
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/messages.properties b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/messages.properties
new file mode 100644
index 0000000000..318235d700
--- /dev/null
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/build/messages.properties
@@ -0,0 +1,12 @@
+################################################################################
+# 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
+################################################################################
+CBuilder_ExceptionWhileBuilding=Exception while building
+CBuilder_ExceptionWhileBuilding2=Exception while building
+CBuilder_NotConfiguredCorrectly=Build not configured correctly\n
+CBuilder_NotConfiguredCorrectly2=Build not configured correctly\n
+StandardBuildConfiguration_0=Building in: %s\n
diff --git a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
index 3fe3c4d234..5d48903ebc 100644
--- a/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
+++ b/core/org.eclipse.cdt.ui/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.cdt.ui; singleton:=true
-Bundle-Version: 6.2.0.qualifier
+Bundle-Version: 6.3.0.qualifier
Bundle-Activator: org.eclipse.cdt.ui.CUIPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
@@ -76,6 +76,7 @@ Export-Package: org.eclipse.cdt.internal.corext;x-internal:=true,
org.eclipse.cdt.ui,
org.eclipse.cdt.ui.actions,
org.eclipse.cdt.ui.browser.typeinfo,
+ org.eclipse.cdt.ui.build,
org.eclipse.cdt.ui.dialogs,
org.eclipse.cdt.ui.extensions,
org.eclipse.cdt.ui.internal.templateengine.wizard;x-internal:=true,
diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml
index 20644ae793..b30990a3dd 100644
--- a/core/org.eclipse.cdt.ui/plugin.xml
+++ b/core/org.eclipse.cdt.ui/plugin.xml
@@ -31,6 +31,7 @@
<extension-point id="LanguageSettingsProviderAssociation" name="%LanguageSettingsProviderAssociationExtensionPoint" schema="schema/LanguageSettingsProviderAssociation.exsd"/>
<extension-point id="RefreshExclusionContributor" name="%RefreshExclusionContributorExtensionPoint" schema="schema/RefreshExclusionContributor.exsd"/>
<extension-point id="semanticHighlighting" name="%semanticHighlightingExtensionPoint" schema="schema/semanticHighlighting.exsd"/>
+ <extension-point id="newToolChainWizards" name="New ToolChain Wizards" schema="schema/newToolChainWizards.exsd"/>
<extension
point="org.eclipse.core.runtime.adapters">
diff --git a/core/org.eclipse.cdt.ui/schema/newToolChainWizards.exsd b/core/org.eclipse.cdt.ui/schema/newToolChainWizards.exsd
new file mode 100644
index 0000000000..67dc553f06
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/schema/newToolChainWizards.exsd
@@ -0,0 +1,129 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.cdt.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.cdt.ui" id="newToolChainWizards" name="New ToolChain Wizards"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <annotation>
+ <appInfo>
+ <meta.element />
+ </appInfo>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="wizard"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="wizard">
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="icon" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="resource"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.cdt.ui.build.ToolChainWizard:"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="providerId" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.cdt.core.toolChainProvider/provider/@id"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiinfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+
+</schema>
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java
index f3de9a8f1c..706eec2282 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.java
@@ -65,6 +65,22 @@ public final class CUIMessages extends NLS {
public static String TextEditorDropAdapter_error_message;
public static String TextEditorDropAdapter_unreadableFile;
public static String TextEditorDropAdapter_noFile;
+ public static String ToolChainPreferencePage_Add;
+ public static String ToolChainPreferencePage_Arch;
+ public static String ToolChainPreferencePage_AreYouSure;
+ public static String ToolChainPreferencePage_AvailableToolchains;
+ public static String ToolChainPreferencePage_Down;
+ public static String ToolChainPreferencePage_Edit;
+ public static String ToolChainPreferencePage_EditDot;
+ public static String ToolChainPreferencePage_Name;
+ public static String ToolChainPreferencePage_NoEditor;
+ public static String ToolChainPreferencePage_OS;
+ public static String ToolChainPreferencePage_Remove;
+ public static String ToolChainPreferencePage_Remove1;
+ public static String ToolChainPreferencePage_RemoveToolchain;
+ public static String ToolChainPreferencePage_Toolchains;
+ public static String ToolChainPreferencePage_Up;
+ public static String ToolChainPreferencePage_UserDefinedToolchains;
public static String OptionalMessageDialog_dontShowAgain;
public static String OptionalMessageDialog_rememberDecision;
public static String CStructureCreatorVisitor_translationUnitName;
@@ -72,6 +88,12 @@ public final class CUIMessages extends NLS {
public static String FileTransferDragAdapter_problem;
public static String FileTransferDragAdapter_problemTitle;
public static String CUIPlugin_initPrefs;
+ public static String NewCDTProjectWizard_PageTitle;
+ public static String NewCDTProjectWizard_Title;
+ public static String NewToolChainWizard_Title;
+
+ public static String NewToolChainWizardSelectionPage_Description;
+ public static String NewToolChainWizardSelectionPage_Title;
static {
NLS.initializeMessages(BUNDLE_NAME, CUIMessages.class);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
index 35f54d2a07..523f0e5c22 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CUIMessages.properties
@@ -65,6 +65,22 @@ TextEditorDropAdapter_error_title=Drag and Drop
TextEditorDropAdapter_error_message=A problem occurred during drag and drop.
TextEditorDropAdapter_unreadableFile=Unreadable file: ''{0}''
TextEditorDropAdapter_noFile=Not a file: ''{0}''
+ToolChainPreferencePage_Add=Add...
+ToolChainPreferencePage_Arch=Arch
+ToolChainPreferencePage_AreYouSure=Are you sure you'd like to remove the selected toolchain?
+ToolChainPreferencePage_AvailableToolchains=Available Toolchains
+ToolChainPreferencePage_Down=Down
+ToolChainPreferencePage_Edit=Edit
+ToolChainPreferencePage_EditDot=Edit...
+ToolChainPreferencePage_Name=Name
+ToolChainPreferencePage_NoEditor=No editor found for this toolchain
+ToolChainPreferencePage_OS=OS
+ToolChainPreferencePage_Remove=Remove
+ToolChainPreferencePage_Remove1=Remove
+ToolChainPreferencePage_RemoveToolchain=Remove Toolchain
+ToolChainPreferencePage_Toolchains=Toolchains
+ToolChainPreferencePage_Up=Up
+ToolChainPreferencePage_UserDefinedToolchains=User Defined Toolchains
OptionalMessageDialog_dontShowAgain= Do not show this &message again
OptionalMessageDialog_rememberDecision=Re&member my decision
@@ -75,3 +91,8 @@ FileTransferDragAdapter_problem=Problem while moving or copying files.
FileTransferDragAdapter_problemTitle=Drag & Drop
CUIPlugin_initPrefs=Initialize C/C++ UI Preferences
+NewCDTProjectWizard_PageTitle=Templates for New C/C++ Project
+NewCDTProjectWizard_Title=New C/C++ Project
+NewToolChainWizard_Title=New Toolchain
+NewToolChainWizardSelectionPage_Description=Select the type of toolchain to add.
+NewToolChainWizardSelectionPage_Title=Toolchain Type
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizard.java
new file mode 100644
index 0000000000..01a279bd50
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizard.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * 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.internal.ui.build;
+
+import org.eclipse.jface.wizard.Wizard;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+public class NewToolChainWizard extends Wizard {
+
+ public NewToolChainWizard() {
+ setForcePreviousAndNextButtons(true);
+ }
+
+ @Override
+ public void addPages() {
+ super.addPages();
+ addPage(new NewToolChainWizardSelectionPage());
+ setWindowTitle(CUIMessages.NewToolChainWizard_Title);
+ }
+
+ @Override
+ public boolean performFinish() {
+ // Downstream wizards do finish
+ return false;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizardSelectionPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizardSelectionPage.java
new file mode 100644
index 0000000000..a9a3ee7bd3
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/build/NewToolChainWizardSelectionPage.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * 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.internal.ui.build;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.build.ToolChainWizard;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
+public class NewToolChainWizardSelectionPage extends WizardPage {
+
+ private Table table;
+
+ public NewToolChainWizardSelectionPage() {
+ super(NewToolChainWizardSelectionPage.class.getName());
+
+ setTitle(CUIMessages.NewToolChainWizardSelectionPage_Title);
+ setDescription(CUIMessages.NewToolChainWizardSelectionPage_Description);
+ setPageComplete(false);
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ comp.setLayout(new GridLayout());
+
+ table = new Table(comp, SWT.BORDER | SWT.SINGLE);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ IExtensionPoint point = Platform.getExtensionRegistry()
+ .getExtensionPoint(CUIPlugin.PLUGIN_ID + ".newToolChainWizards"); //$NON-NLS-1$
+ for (IExtension extension : point.getExtensions()) {
+ for (IConfigurationElement element : extension.getConfigurationElements()) {
+ String name = element.getAttribute("name"); //$NON-NLS-1$
+ TableItem item = new TableItem(table, SWT.NONE);
+ item.setText(name);
+
+ String iconFile = element.getAttribute("icon"); //$NON-NLS-1$
+ if (iconFile != null) {
+ ImageDescriptor desc = CUIPlugin
+ .imageDescriptorFromPlugin(element.getNamespaceIdentifier(), iconFile);
+ if (desc != null) {
+ item.setImage(desc.createImage());
+ }
+ }
+
+ item.setData(element);
+ }
+ }
+
+ table.addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ getContainer().updateButtons();
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ if (canFlipToNextPage()) {
+ getContainer().showPage(getNextPage());
+ }
+ }
+ });
+
+ setControl(comp);
+ }
+
+ @Override
+ public void dispose() {
+ for (TableItem item : table.getItems()) {
+ Object obj = item.getData();
+ if (obj instanceof Wizard) {
+ ((Wizard) obj).dispose();
+ }
+ }
+ super.dispose();
+ }
+
+ public ImageDescriptor getDescriptionImage(IConfigurationElement element) {
+ String descImage = element.getAttribute("icon"); //$NON-NLS-1$
+ if (descImage == null) {
+ return null;
+ }
+ return AbstractUIPlugin.imageDescriptorFromPlugin(element.getNamespaceIdentifier(),
+ descImage);
+ }
+
+ @Override
+ public boolean canFlipToNextPage() {
+ return table.getSelectionIndex() >= 0;
+ }
+
+ @Override
+ public IWizardPage getNextPage() {
+ int i = table.getSelectionIndex();
+ if (i >= 0) {
+ TableItem item = table.getItem(i);
+ Object obj = item.getData();
+ ToolChainWizard nextWizard;
+ if (obj instanceof IConfigurationElement) {
+ IConfigurationElement element = (IConfigurationElement) obj;
+ try {
+ nextWizard = (ToolChainWizard) element.createExecutableExtension("class"); //$NON-NLS-1$
+ nextWizard.addPages();
+ item.setData(nextWizard);
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ return null;
+ }
+ } else {
+ nextWizard = (ToolChainWizard) obj;
+ }
+
+ return nextWizard.getStartingPage();
+ }
+ return super.getNextPage();
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java
index a844a0a395..a21044cb8f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java
@@ -54,6 +54,7 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
+
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
@@ -221,7 +222,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB
hoverComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
String rollOverLabel= PreferencesMessages.CEditorHoverConfigurationBlock_annotationRollover;
- addCheckBox(hoverComposite, rollOverLabel, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER, 0); //$NON-NLS-1$
+ addCheckBox(hoverComposite, rollOverLabel, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER, 0);
//addFiller(hoverComposite);
Label label= new Label(hoverComposite, SWT.NONE);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/project/NewCDTProjectWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/project/NewCDTProjectWizard.java
index 17c23314c6..ac12720d1a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/project/NewCDTProjectWizard.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/project/NewCDTProjectWizard.java
@@ -9,14 +9,16 @@ package org.eclipse.cdt.internal.ui.wizards.project;
import org.eclipse.tools.templates.ui.NewWizard;
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
public class NewCDTProjectWizard extends NewWizard {
private static final String cdtTag = "org.eclipse.cdt.ui.cdtTag"; //$NON-NLS-1$
public NewCDTProjectWizard() {
super(cdtTag);
- setWindowTitle("New C/C++ Project");
- setTemplateSelectionPageTitle("Templates for New C/C++ Project");
+ setWindowTitle(CUIMessages.NewCDTProjectWizard_Title);
+ setTemplateSelectionPageTitle(CUIMessages.NewCDTProjectWizard_PageTitle);
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
index 4073e4a4ce..a02051c7bc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java
@@ -73,6 +73,7 @@ import org.eclipse.ui.themes.IThemeManager;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
import com.ibm.icu.text.MessageFormat;
@@ -1090,4 +1091,13 @@ public class CUIPlugin extends AbstractUIPlugin {
IWorkbenchWindow[] windows = getDefault().getWorkbench().getWorkbenchWindows();
return windows[0].getShell();
}
+
+ /**
+ * @since 6.3
+ */
+ public static <T> T getService(Class<T> service) {
+ BundleContext context = fgCPlugin.getBundle().getBundleContext();
+ ServiceReference<T> ref = context.getServiceReference(service);
+ return ref != null ? context.getService(ref) : null;
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java
new file mode 100644
index 0000000000..b0ed4f1a1a
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainPreferencePage.java
@@ -0,0 +1,310 @@
+/*******************************************************************************
+ * 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.ui.build;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.layout.TableColumnLayout;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+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.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+import org.eclipse.cdt.internal.ui.build.NewToolChainWizard;
+
+/**
+ * Preference page to manage Toolchains for Core Build.
+ *
+ * @since 6.3
+ */
+public class ToolChainPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+ private TableViewer availTable;
+ private Button availUp;
+ private Button availDown;
+
+ private TableViewer userTable;
+ private Button userEdit;
+ private Button userRemove;
+
+ private IToolChainManager manager = CUIPlugin.getService(IToolChainManager.class);
+
+ private ISafeRunnable tcListener = () -> Display.getDefault().asyncExec(() -> {
+ availTable.refresh();
+ userTable.refresh();
+ });
+
+ public ToolChainPreferencePage() {
+ super(CUIMessages.ToolChainPreferencePage_Toolchains);
+ }
+
+ @Override
+ public void init(IWorkbench workbench) {
+ }
+
+ private static class TableLabelProvider extends LabelProvider implements ITableLabelProvider {
+ @Override
+ public String getColumnText(Object element, int columnIndex) {
+ IToolChain toolChain = (IToolChain) element;
+ switch (columnIndex) {
+ case 0:
+ return toolChain.getName();
+ case 1:
+ return toolChain.getProperty(IToolChain.ATTR_OS);
+ case 2:
+ return toolChain.getProperty(IToolChain.ATTR_ARCH);
+ }
+ return null;
+ }
+
+ @Override
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ initializeDialogUnits(parent);
+
+ Composite control = new Composite(parent, SWT.NONE);
+ control.setLayout(new GridLayout());
+
+ Group availGroup = new Group(control, SWT.NONE);
+ availGroup.setText(CUIMessages.ToolChainPreferencePage_AvailableToolchains);
+ availGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ availGroup.setLayout(new GridLayout(2, false));
+
+ availTable = createToolChainTable(availGroup);
+ availTable.getTable().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateButtons();
+ }
+ });
+ availTable.setLabelProvider(new TableLabelProvider());
+ availTable.setContentProvider(new IStructuredContentProvider() {
+ @Override
+ public Object[] getElements(Object inputElement) {
+ try {
+ return manager.getAllToolChains().toArray();
+ } catch (CoreException e) {
+ CUIPlugin.log(e.getStatus());
+ return new Object[0];
+ }
+ }
+ });
+
+
+ Composite availButtonComp = new Composite(availGroup, SWT.NONE);
+ availButtonComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+ availButtonComp.setLayout(new GridLayout());
+
+ availUp = new Button(availButtonComp, SWT.PUSH);
+ availUp.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));
+ availUp.setText(CUIMessages.ToolChainPreferencePage_Up);
+
+ availDown = new Button(availButtonComp, SWT.PUSH);
+ availDown.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));
+ availDown.setText(CUIMessages.ToolChainPreferencePage_Down);
+
+ Group userGroup = new Group(control, SWT.NONE);
+ userGroup.setText(CUIMessages.ToolChainPreferencePage_UserDefinedToolchains);
+ userGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ userGroup.setLayout(new GridLayout(2, false));
+
+ userTable = createToolChainTable(userGroup);
+ userTable.getTable().addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateButtons();
+ }
+ });
+ userTable.setLabelProvider(new TableLabelProvider());
+ userTable.setContentProvider(new IStructuredContentProvider() {
+ @Override
+ public Object[] getElements(Object inputElement) {
+ List<IToolChain> tcs = new ArrayList<>();
+ try {
+ for (IToolChain tc : manager.getAllToolChains()) {
+ if (tc.getProvider() instanceof IUserToolChainProvider) {
+ tcs.add(tc);
+ }
+ }
+ } catch (CoreException e) {
+ CUIPlugin.log(e);
+ }
+ return tcs.toArray();
+ }
+ });
+
+ Composite userButtonComp = new Composite(userGroup, SWT.NONE);
+ userButtonComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
+ userButtonComp.setLayout(new GridLayout());
+
+ Button userAdd = new Button(userButtonComp, SWT.PUSH);
+ userAdd.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));
+ userAdd.setText(CUIMessages.ToolChainPreferencePage_Add);
+ userAdd.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Wizard wizard = new NewToolChainWizard();
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ dialog.open();
+ }
+ });
+
+ userEdit = new Button(userButtonComp, SWT.PUSH);
+ userEdit.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
+ userEdit.setText(CUIMessages.ToolChainPreferencePage_EditDot);
+ userEdit.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IToolChain tc = (IToolChain) userTable.getStructuredSelection().getFirstElement();
+ String providerId = tc.getProvider().getId();
+
+ ToolChainWizard wizard = null;
+ IExtensionPoint point = Platform.getExtensionRegistry()
+ .getExtensionPoint(CUIPlugin.PLUGIN_ID + ".newToolChainWizards"); //$NON-NLS-1$
+ loop: for (IExtension extension : point.getExtensions()) {
+ for (IConfigurationElement element : extension.getConfigurationElements()) {
+ if (providerId.equals(element.getAttribute("providerId"))) { //$NON-NLS-1$
+ try {
+ wizard = (ToolChainWizard) element.createExecutableExtension("class"); //$NON-NLS-1$
+ break loop;
+ } catch (CoreException e1) {
+ CUIPlugin.log(e1.getStatus());
+ }
+ }
+ }
+ }
+
+ if (wizard != null) {
+ wizard.setToolChain(tc);
+ WizardDialog dialog = new WizardDialog(getShell(), wizard);
+ dialog.open();
+ } else {
+ MessageDialog.openInformation(getShell(), CUIMessages.ToolChainPreferencePage_Edit, CUIMessages.ToolChainPreferencePage_NoEditor);
+ }
+ }
+ });
+
+ userRemove = new Button(userButtonComp, SWT.PUSH);
+ userRemove.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));
+ userRemove.setText(CUIMessages.ToolChainPreferencePage_Remove);
+ userRemove.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (MessageDialog.openConfirm(getShell(), CUIMessages.ToolChainPreferencePage_Remove1,
+ CUIMessages.ToolChainPreferencePage_AreYouSure)) {
+ IToolChain tc = (IToolChain) userTable.getStructuredSelection().getFirstElement();
+ IUserToolChainProvider provider = (IUserToolChainProvider) tc.getProvider();
+ new Job(CUIMessages.ToolChainPreferencePage_RemoveToolchain) {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ provider.removeToolChain(tc);
+ return Status.OK_STATUS;
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+ }
+ }.schedule();
+ }
+ }
+ });
+
+ availTable.setInput(manager);
+ userTable.setInput(manager);
+ updateButtons();
+ manager.addToolChainListener(tcListener);
+ return control;
+ }
+
+ @Override
+ public void dispose() {
+ manager.removeToolChainListener(tcListener);
+ super.dispose();
+ }
+
+ private TableViewer createToolChainTable(Composite parent) {
+ Composite tableComp = new Composite(parent, SWT.NONE);
+ tableComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ Table table = new Table(tableComp, SWT.BORDER | SWT.V_SCROLL | SWT.FULL_SELECTION);
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+
+ TableColumnLayout tableLayout = new TableColumnLayout();
+
+ TableColumn tableNameColumn = new TableColumn(table, SWT.LEAD);
+ tableNameColumn.setText(CUIMessages.ToolChainPreferencePage_Name);
+ tableLayout.setColumnData(tableNameColumn, new ColumnWeightData(6));
+
+ TableColumn tableOSColumn = new TableColumn(table, SWT.LEAD);
+ tableOSColumn.setText(CUIMessages.ToolChainPreferencePage_OS);
+ tableLayout.setColumnData(tableOSColumn, new ColumnWeightData(2));
+
+ TableColumn tableArchColumn = new TableColumn(table, SWT.LEAD);
+ tableArchColumn.setText(CUIMessages.ToolChainPreferencePage_Arch);
+ tableLayout.setColumnData(tableArchColumn, new ColumnWeightData(2));
+
+ tableComp.setLayout(tableLayout);
+
+ return new TableViewer(table);
+ }
+
+ private void updateButtons() {
+ boolean availSelected = availTable.getTable().getSelectionCount() > 0;
+ availUp.setEnabled(availSelected);
+ availDown.setEnabled(availSelected);
+
+ boolean userSelected = userTable.getTable().getSelectionCount() > 0;
+ userEdit.setEnabled(userSelected);
+ userRemove.setEnabled(userSelected);
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainWizard.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainWizard.java
new file mode 100644
index 0000000000..845628892c
--- /dev/null
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/build/ToolChainWizard.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.ui.build;
+
+import org.eclipse.jface.wizard.Wizard;
+
+import org.eclipse.cdt.core.build.IToolChain;
+
+/**
+ * Parent class for toolChain wizards that create or edit toolchains.
+ *
+ * @since 6.3
+ */
+public abstract class ToolChainWizard extends Wizard {
+
+ protected IToolChain toolChain;
+
+ public void setToolChain(IToolChain toolChain) {
+ this.toolChain = toolChain;
+ }
+
+ public IToolChain getToolChain() {
+ return toolChain;
+ }
+
+}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java
index 55cad28d86..c098dc3b2f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/ReferenceBlock.java
@@ -12,9 +12,6 @@ package org.eclipse.cdt.ui.dialogs;
import java.util.ArrayList;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.internal.ui.CUIMessages;
-import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IWorkspace;
@@ -38,6 +35,11 @@ import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.CUIMessages;
+
/**
* @deprecated as of CDT 4.0. This Block was used for New Project Wizard
* for 3.X style projects.
@@ -47,9 +49,9 @@ import org.eclipse.ui.model.WorkbenchLabelProvider;
@Deprecated
public class ReferenceBlock extends AbstractCOptionPage {
- private static final String PREFIX = "ReferenceBlock"; //$NON-NLS-1$ //$NON-NLS-1$
- private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$ //$NON-NLS-1$
- private static final String DESC = PREFIX + ".desc"; //$NON-NLS-1$ //$NON-NLS-1$
+ private static final String PREFIX = "ReferenceBlock"; //$NON-NLS-1$
+ private static final String LABEL = PREFIX + ".label"; //$NON-NLS-1$
+ private static final String DESC = PREFIX + ".desc"; //$NON-NLS-1$
private CheckboxTableViewer referenceProjectsViewer;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java
index deb69fc56f..321abf1d9f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/newui/EnvDialog.java
@@ -78,7 +78,8 @@ public class EnvDialog extends Dialog {
}
@Override
- protected Control createDialogArea(Composite c) {
+ protected Control createDialogArea(Composite parent) {
+ Composite c = new Composite(parent, SWT.NONE);
c.setLayout(new GridLayout(3, false));
GridData gd;
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
index 78fd598077..68ca1677e2 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugCorePlugin.java
@@ -17,6 +17,7 @@ import java.util.HashSet;
import org.eclipse.cdt.debug.core.breakpointactions.BreakpointActionManager;
import org.eclipse.cdt.debug.core.command.CCommandAdapterFactory;
import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextService;
+import org.eclipse.cdt.debug.core.launch.CoreBuildLaunchBarTracker;
import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.core.model.IRestart;
import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer;
@@ -45,6 +46,7 @@ import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.debug.core.ILaunchDelegate;
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.launchbar.core.ILaunchBarManager;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
@@ -94,6 +96,8 @@ public class CDebugCorePlugin extends Plugin {
*/
private CommonSourceLookupDirector fCommonSourceLookupDirector;
+ private CoreBuildLaunchBarTracker coreBuildLaunchBarTracker;
+
/**
* The constructor.
*/
@@ -227,6 +231,11 @@ public class CDebugCorePlugin extends Plugin {
setDefaultLaunchDelegates();
Platform.getAdapterManager().registerAdapters(new DebugModelProvider(), ICDebugElement.class);
+
+ // Add core build launch bar listener
+ ILaunchBarManager launchBarManager = getService(ILaunchBarManager.class);
+ coreBuildLaunchBarTracker = new CoreBuildLaunchBarTracker();
+ launchBarManager.addListener(coreBuildLaunchBarTracker);
}
/* (non-Javadoc)
@@ -234,6 +243,10 @@ public class CDebugCorePlugin extends Plugin {
*/
@Override
public void stop(BundleContext context) throws Exception {
+ ILaunchBarManager launchBarManager = getService(ILaunchBarManager.class);
+ launchBarManager.removeListener(coreBuildLaunchBarTracker);
+ coreBuildLaunchBarTracker = null;
+
disposeDisassemblyContextService();
disposeBreakpointListenersList();
disposeCommonSourceLookupDirector();
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java
index c59735f9ee..b79da79032 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/CoreBuildLaunchBarTracker.java
@@ -23,7 +23,9 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchMode;
import org.eclipse.launchbar.core.ILaunchBarListener;
@@ -32,9 +34,8 @@ import org.eclipse.launchbar.core.ILaunchDescriptor;
import org.eclipse.launchbar.core.target.ILaunchTarget;
/**
- * A launchbar listener that attempts to set the active build configuration on
- * the project adapted from the launch descriptor that supports the given
- * target.
+ * A launchbar listener that attempts to set the active core build configuration
+ * on the project adapted from the launch descriptor.
*
* @since 8.3
*/
@@ -45,22 +46,20 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
.getService(ICBuildConfigurationManager.class);
private final IToolChainManager toolChainManager = CDebugCorePlugin.getService(IToolChainManager.class);
- private final String targetTypeId;
+ private ILaunchMode lastMode;
+ private ILaunchDescriptor lastDescriptor;
+ private ILaunchTarget lastTarget;
- public CoreBuildLaunchBarTracker(String targetTypeId) {
- this.targetTypeId = targetTypeId;
- }
-
- private void setActiveBuildConfig(String mode, ILaunchDescriptor descriptor, ILaunchTarget target)
+ private void setActiveBuildConfig(ILaunchMode mode, ILaunchDescriptor descriptor, ILaunchTarget target)
throws CoreException {
- if (!targetTypeId.equals(target.getTypeId())) {
- return;
- }
-
IProject project = descriptor.getAdapter(IProject.class);
if (project == null) {
// Can we get the project name from the config
ILaunchConfiguration configuration = launchBarManager.getLaunchConfiguration(descriptor, target);
+ if (configuration == null) {
+ // TODO why is the configuration null?
+ return;
+ }
String projectName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
if (!projectName.isEmpty()) {
project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
@@ -79,43 +78,63 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
return;
}
+ IProject finalProject = project;
+
+ lastMode = mode;
+ lastDescriptor = descriptor;
+ lastTarget = target;
+
// Pick build config based on toolchain for target
- Map<String, String> properties = new HashMap<>();
- properties.putAll(target.getAttributes());
- Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
- if (!tcs.isEmpty()) {
- IToolChain toolChain = tcs.iterator().next();
- IProgressMonitor monitor = new NullProgressMonitor();
- ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(project, toolChain, mode,
- new NullProgressMonitor());
- if (buildConfig != null) {
- IProjectDescription desc = project.getDescription();
- desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
- project.setDescription(desc, monitor);
-
- // Copy over the build attributes from the launch config
- ILaunchConfiguration configuration = launchBarManager.getLaunchConfiguration(descriptor, target);
- Map<String, String> buildProps = configuration.getAttribute(
- CoreBuildLaunchConfigDelegate.getBuildAttributeName(mode),
- buildConfig.getDefaultProperties());
- buildConfig.setProperties(buildProps);
+ // Since this may create a new config, need to run it in a Job
+ Job job = new Job("Change Build Configurations") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ Map<String, String> properties = new HashMap<>();
+ properties.putAll(target.getAttributes());
+ Collection<IToolChain> tcs = toolChainManager.getToolChainsMatching(properties);
+ if (!tcs.isEmpty()) {
+ IToolChain toolChain = tcs.iterator().next();
+ ICBuildConfiguration buildConfig = configManager.getBuildConfiguration(finalProject, toolChain,
+ mode.getIdentifier(), monitor);
+ if (buildConfig != null
+ && !buildConfig.getBuildConfiguration().equals(finalProject.getActiveBuildConfig())) {
+ IProjectDescription desc = finalProject.getDescription();
+ desc.setActiveBuildConfig(buildConfig.getBuildConfiguration().getName());
+ finalProject.setDescription(desc, monitor);
+
+ // Copy over the build attributes from the launch config
+ ILaunchConfiguration configuration = launchBarManager.getLaunchConfiguration(descriptor,
+ target);
+ Map<String, String> buildProps = configuration.getAttribute(
+ CoreBuildLaunchConfigDelegate.getBuildAttributeName(mode.getIdentifier()),
+ buildConfig.getDefaultProperties());
+ buildConfig.setProperties(buildProps);
+ }
+ }
+
+ return Status.OK_STATUS;
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
}
- }
+ };
+ job.setRule(project.getWorkspace().getRoot());
+ job.schedule();
}
@Override
public void activeLaunchTargetChanged(ILaunchTarget target) {
try {
- if (target == null || target.equals(ILaunchTarget.NULL_TARGET)) {
+ if (target == null || target.equals(ILaunchTarget.NULL_TARGET) || target.equals(lastTarget)) {
return;
}
- ILaunchMode launchMode = launchBarManager.getActiveLaunchMode();
- if (launchMode == null) {
+ ILaunchMode mode = launchBarManager.getActiveLaunchMode();
+ if (mode == null) {
return;
}
- String mode = launchMode.getIdentifier();
ILaunchDescriptor descriptor = launchBarManager.getActiveLaunchDescriptor();
setActiveBuildConfig(mode, descriptor, target);
} catch (CoreException e) {
@@ -126,16 +145,15 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
@Override
public void activeLaunchDescriptorChanged(ILaunchDescriptor descriptor) {
try {
- if (descriptor == null) {
+ if (descriptor == null || descriptor.equals(lastDescriptor)) {
return;
}
- ILaunchMode launchMode = launchBarManager.getActiveLaunchMode();
- if (launchMode == null) {
+ ILaunchMode mode = launchBarManager.getActiveLaunchMode();
+ if (mode == null) {
return;
}
- String mode = launchMode.getIdentifier();
ILaunchTarget target = launchBarManager.getActiveLaunchTarget();
setActiveBuildConfig(mode, descriptor, target);
} catch (CoreException e) {
@@ -147,13 +165,13 @@ public class CoreBuildLaunchBarTracker implements ILaunchBarListener {
@Override
public void activeLaunchModeChanged(ILaunchMode mode) {
try {
- if (mode == null) {
+ if (mode == null || mode.equals(lastMode)) {
return;
}
ILaunchDescriptor descriptor = launchBarManager.getActiveLaunchDescriptor();
ILaunchTarget target = launchBarManager.getActiveLaunchTarget();
- setActiveBuildConfig(mode.getIdentifier(), descriptor, target);
+ setActiveBuildConfig(mode, descriptor, target);
} catch (CoreException e) {
CDebugCorePlugin.log(e.getStatus());
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java
index 7426f21398..72e9653523 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/launch/GenericTargetTypeProvider.java
@@ -7,21 +7,22 @@
*******************************************************************************/
package org.eclipse.cdt.debug.core.launch;
-import org.eclipse.cdt.debug.core.CDebugCorePlugin;
-import org.eclipse.launchbar.core.ILaunchBarManager;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetProvider;
import org.eclipse.launchbar.core.target.TargetStatus;
+/**
+ *
+ * @since 8.3
+ */
public class GenericTargetTypeProvider implements ILaunchTargetProvider {
public static final String TYPE_ID = "org.eclipse.cdt.launchTargetType.generic"; //$NON-NLS-1$
@Override
public void init(ILaunchTargetManager targetManager) {
- ILaunchBarManager launchBarManager = CDebugCorePlugin.getService(ILaunchBarManager.class);
- launchBarManager.addListener(new CoreBuildLaunchBarTracker(TYPE_ID));
+ // Nothing to do
}
@Override
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index 30dd0676ed..ce9b8636f3 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -2585,12 +2585,12 @@
id="org.eclipse.cdt.launchTargetType.generic"
labelProvider="org.eclipse.cdt.debug.internal.ui.launch.GenericTargetLabelProvider">
</launchTargetTypeUI>
- <wizard
+ <wizard2
class="org.eclipse.cdt.debug.internal.ui.launch.NewGenericTargetWizard"
icon="icons/obj16/cdt_logo_16.png"
- id="org.eclipse.cdt.debug.ui.newGenericTargetWizard"
+ id="org.eclipse.cdt.launchTargetType.generic"
name="%GenericTarget.name">
- </wizard>
+ </wizard2>
</extension>
</plugin>
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java
deleted file mode 100644
index bc5f6fd689..0000000000
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/GenericTargetPropertiesBlock.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.eclipse.cdt.debug.internal.ui.launch;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-public class GenericTargetPropertiesBlock extends Composite {
-
- private Text nameText;
- private Text osText;
- private Text archText;
-
- public GenericTargetPropertiesBlock(Composite parent, int style) {
- super(parent, style);
- setLayout(new GridLayout(2, false));
-
- Label label = new Label(this, SWT.NONE);
- label.setText("Name:");
-
- nameText = new Text(this, SWT.BORDER);
- nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- label = new Label(this, SWT.NONE);
- label.setText("Operating System:");
-
- osText = new Text(this, SWT.BORDER);
- osText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
-
- label = new Label(this, SWT.NONE);
- label.setText("CPU Architecture:");
-
- archText = new Text(this, SWT.BORDER);
- archText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- }
-
- public String getTargetName() {
- return nameText.getText();
- }
-
- public String getOS() {
- return osText.getText();
- }
-
- public String getArch() {
- return archText.getText();
- }
-
-}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java
index a8f982dc91..1f9e8e0f3e 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizard.java
@@ -9,15 +9,13 @@ package org.eclipse.cdt.debug.internal.ui.launch;
import org.eclipse.cdt.debug.core.launch.GenericTargetTypeProvider;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.ILaunchTargetManager;
import org.eclipse.launchbar.core.target.ILaunchTargetWorkingCopy;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
+import org.eclipse.launchbar.ui.internal.Activator;
+import org.eclipse.launchbar.ui.target.LaunchTargetWizard;
-public class NewGenericTargetWizard extends Wizard implements INewWizard {
+public class NewGenericTargetWizard extends LaunchTargetWizard {
private NewGenericTargetWizardPage page;
@@ -26,15 +24,10 @@ public class NewGenericTargetWizard extends Wizard implements INewWizard {
}
@Override
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- // nothing
- }
-
- @Override
public void addPages() {
super.addPages();
- page = new NewGenericTargetWizardPage();
+ page = new NewGenericTargetWizardPage(getLaunchTarget());
addPage(page);
}
@@ -44,8 +37,13 @@ public class NewGenericTargetWizard extends Wizard implements INewWizard {
String typeId = GenericTargetTypeProvider.TYPE_ID;
String id = page.getTargetName();
- ILaunchTarget target = manager.addLaunchTarget(typeId, id);
+ ILaunchTarget target = getLaunchTarget();
+ if (target == null) {
+ target = manager.addLaunchTarget(typeId, id);
+ }
+
ILaunchTargetWorkingCopy wc = target.getWorkingCopy();
+ wc.setId(id);
wc.setAttribute(ILaunchTarget.ATTR_OS, page.getOS());
wc.setAttribute(ILaunchTarget.ATTR_ARCH, page.getArch());
wc.save();
@@ -53,4 +51,18 @@ public class NewGenericTargetWizard extends Wizard implements INewWizard {
return true;
}
+ @Override
+ public boolean canDelete() {
+ return true;
+ }
+
+ @Override
+ public void performDelete() {
+ ILaunchTargetManager manager = Activator.getService(ILaunchTargetManager.class);
+ ILaunchTarget target = getLaunchTarget();
+ if (target != null) {
+ manager.removeLaunchTarget(getLaunchTarget());
+ }
+ }
+
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java
index 9f3f557d4f..c3a064a879 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/launch/NewGenericTargetWizardPage.java
@@ -8,35 +8,82 @@
package org.eclipse.cdt.debug.internal.ui.launch;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
public class NewGenericTargetWizardPage extends WizardPage {
- private GenericTargetPropertiesBlock propertiesBlock;
+ private final ILaunchTarget launchTarget;
- public NewGenericTargetWizardPage() {
+ private Text nameText;
+ private Text osText;
+ private Text archText;
+
+ public NewGenericTargetWizardPage(ILaunchTarget launchTarget) {
super(NewGenericTargetWizardPage.class.getName());
setTitle("Generic Target");
setDescription("Enter name and properties for the target.");
+ this.launchTarget = launchTarget;
}
@Override
public void createControl(Composite parent) {
- propertiesBlock = new GenericTargetPropertiesBlock(parent, SWT.NONE);
- setControl(propertiesBlock);
+ Composite comp = new Composite(parent, SWT.NONE);
+ comp.setLayout(new GridLayout(2, false));
+
+ Label label = new Label(comp, SWT.NONE);
+ label.setText("Name:");
+
+ nameText = new Text(comp, SWT.BORDER);
+ nameText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ if (launchTarget != null) {
+ nameText.setText(launchTarget.getId());
+ }
+
+ label = new Label(comp, SWT.NONE);
+ label.setText("Operating System:");
+
+ osText = new Text(comp, SWT.BORDER);
+ osText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ if (launchTarget != null) {
+ String os = launchTarget.getAttribute(ILaunchTarget.ATTR_OS, null);
+ if (os != null) {
+ osText.setText(os);
+ }
+ }
+
+ label = new Label(comp, SWT.NONE);
+ label.setText("CPU Architecture:");
+
+ archText = new Text(comp, SWT.BORDER);
+ archText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ if (launchTarget != null) {
+ String arch = launchTarget.getAttribute(ILaunchTarget.ATTR_ARCH, null);
+ if (arch != null) {
+ archText.setText(arch);
+ }
+ }
+
+ setControl(comp);
}
public String getTargetName() {
- return propertiesBlock.getTargetName();
+ return nameText.getText().trim();
}
public String getOS() {
- return propertiesBlock.getOS();
+ String os = osText.getText().trim();
+ return !os.isEmpty() ? os : null;
}
public String getArch() {
- return propertiesBlock.getArch();
+ String arch = archText.getText().trim();
+ return !arch.isEmpty() ? arch : null;
}
}

Back to the top