Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2016-05-12 13:50:23 -0400
committerGerrit Code Review @ Eclipse.org2016-05-12 15:32:51 -0400
commit0d7ee343e017f753a6bb8e2d3165d6b8fb2e9e9e (patch)
tree7752ffc3ff385d0f3b8a19ae1c34d0fbaec2b16a
parente091657eafa69252ce0777b83d6ef7560dacfd3b (diff)
downloadorg.eclipse.cdt-0d7ee343e017f753a6bb8e2d3165d6b8fb2e9e9e.tar.gz
org.eclipse.cdt-0d7ee343e017f753a6bb8e2d3165d6b8fb2e9e9e.tar.xz
org.eclipse.cdt-0d7ee343e017f753a6bb8e2d3165d6b8fb2e9e9e.zip
Add MSYS2 support for managed build. A few Qt cleanups on Windows.
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java33
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/GCCPathToolChainProvider.java4
-rw-r--r--build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java6
-rw-r--r--build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java37
-rw-r--r--core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java33
-rwxr-xr-xllvm/org.eclipse.cdt.managedbuilder.llvm.ui/src/org/eclipse/cdt/managedbuilder/llvm/ui/LlvmEnvironmentVariableSupplier.java20
-rw-r--r--qt/org.eclipse.cdt.qt.core/plugin.xml11
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java13
-rw-r--r--qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtMinGWToolChainProvider.java2
9 files changed, 104 insertions, 55 deletions
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/GCCToolChain.java
index 460f9508ea..710a8c952e 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
@@ -41,8 +41,9 @@ import org.eclipse.core.runtime.Platform;
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 environment variable settings.
+ * 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
+ * environment variable settings.
*/
public class GCCToolChain extends PlatformObject implements IToolChain {
@@ -50,7 +51,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
private final String id;
private final String version;
private final String name;
- private final Path path;
+ private final Path[] path;
private final String prefix;
private final IEnvironmentVariable pathVar;
private final IEnvironmentVariable[] envVars;
@@ -61,11 +62,11 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
this(provider, id, version, null, null);
}
- public GCCToolChain(IToolChainProvider provider, String id, String version, Path path) {
+ public GCCToolChain(IToolChainProvider provider, String id, String version, Path[] path) {
this(provider, id, version, path, null);
}
- public GCCToolChain(IToolChainProvider provider, String id, String version, Path path, String prefix) {
+ public GCCToolChain(IToolChainProvider provider, String id, String version, Path[] path, String prefix) {
this.provider = provider;
this.id = id;
this.version = version;
@@ -74,7 +75,14 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
this.prefix = prefix;
if (path != null) {
- pathVar = new EnvironmentVariable("PATH", path.toString(), IEnvironmentVariable.ENVVAR_PREPEND, //$NON-NLS-1$
+ StringBuilder pathString = new StringBuilder();
+ for (int i = 0; i < path.length; ++i) {
+ pathString.append(path[i].toString());
+ if (i < path.length - 1) {
+ pathString.append(File.pathSeparator);
+ }
+ }
+ pathVar = new EnvironmentVariable("PATH", pathString.toString(), IEnvironmentVariable.ENVVAR_PREPEND, //$NON-NLS-1$
File.pathSeparator);
envVars = new IEnvironmentVariable[] { pathVar };
} else {
@@ -92,12 +100,12 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
public String getId() {
return id;
}
-
+
@Override
public String getVersion() {
return version;
}
-
+
@Override
public String getName() {
return name;
@@ -114,7 +122,7 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
}
return null;
}
-
+
@Override
public String getBinaryParserId() {
// Assume local builds
@@ -282,7 +290,12 @@ public class GCCToolChain extends PlatformObject implements IToolChain {
}
if (path != null) {
- return path.resolve(command);
+ for (Path p : path) {
+ Path c = p.resolve(command);
+ if (Files.isExecutable(c)) {
+ return c;
+ }
+ }
}
// Look for it in the path environment var
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 f9967defeb..28905b02c9 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
@@ -11,6 +11,7 @@ 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;
@@ -73,7 +74,8 @@ public class GCCPathToolChainProvider implements IToolChainProvider {
String name = target + " - " + version; //$NON-NLS-1$
if (!names.contains(name)) {
names.add(name);
- manager.addToolChain(new GCCToolChain(this, target, version, dir.toPath(), prefix));
+ manager.addToolChain(new GCCToolChain(this, target, version,
+ new Path[] { dir.toPath() }, prefix));
}
}
} catch (IOException e) {
diff --git a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java
index 64dec9b949..ae5b1b7401 100644
--- a/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java
+++ b/build/org.eclipse.cdt.build.gcc.core/src/org/eclipse/cdt/build/gcc/core/internal/Msys2ToolChainProvider.java
@@ -36,9 +36,11 @@ public class Msys2ToolChainProvider implements IToolChainProvider {
String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
- Path gccPath = Paths.get(installLocation + "\\mingw64\\bin\\gcc.exe"); //$NON-NLS-1$
+ Path msysPath = Paths.get(installLocation);
+ Path gccPath = msysPath.resolve("mingw64\\bin\\gcc.exe"); //$NON-NLS-1$
if (Files.exists(gccPath)) {
- manager.addToolChain(new GCCToolChain(this, "msys2.x86_64", "", gccPath.getParent())); //$NON-NLS-1$ //$NON-NLS-2$
+ manager.addToolChain(new GCCToolChain(this, "x86_64-w64-mingw32", "msys2.x86_64", new Path[] { //$NON-NLS-1$ //$NON-NLS-2$
+ gccPath.getParent(), msysPath.resolve("bin"), msysPath.resolve("usr\\bin") })); //$NON-NLS-1$ //$NON-NLS-2$
}
}
}
diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java
index 64f4b897fc..58ef685197 100644
--- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java
+++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/src/org/eclipse/cdt/managedbuilder/gnu/mingw/MingwEnvironmentVariableSupplier.java
@@ -33,40 +33,6 @@ public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironme
private static final String BACKSLASH = java.io.File.separator;
private static final String PATH_DELIMITER = EnvironmentVariableManager.getDefault().getDefaultDelimiter();
- /**
- * @return location of $MINGW_HOME/bin folder on the file-system.
- * @deprecated. Deprecated as of CDT 8.2. Note that MinGW root path in general may depend on configuration.
- *
- * If you use this do not cache results to ensure user preferences are accounted for.
- * Please rely on internal caching.
- */
- @Deprecated
- public static IPath getBinDir() {
- IPath binDir = null;
- String minGWHome = MinGW.getMinGWHome();
- if (minGWHome != null) {
- binDir = new Path(minGWHome).append("bin"); //$NON-NLS-1$
- }
- return binDir;
- }
-
- /**
- * @return location of $MINGW_HOME/msys/bin folder on the file-system.
- * @deprecated. Deprecated as of CDT 8.2. Note that MinGW root path in general may depend on configuration.
- *
- * If you use this do not cache results to ensure user preferences are accounted for.
- * Please rely on internal caching.
- */
- @Deprecated
- public static IPath getMsysBinDir() {
- IPath msysBinDir = null;
- String msysHome = MinGW.getMSysHome();
- if (msysHome != null) {
- msysBinDir = new Path(msysHome).append("bin"); //$NON-NLS-1$
- }
- return msysBinDir;
- }
-
@Override
public IBuildEnvironmentVariable getVariable(String variableName, IConfiguration configuration, IEnvironmentVariableProvider provider) {
if (variableName.equals(MinGW.ENV_MINGW_HOME)) {
@@ -98,7 +64,8 @@ public class MingwEnvironmentVariableSupplier implements IConfigurationEnvironme
} else if (variableName.equals(ENV_PATH)) {
@SuppressWarnings("nls")
String path = "${" + MinGW.ENV_MINGW_HOME + "}" + BACKSLASH + "bin" + PATH_DELIMITER
- + "${" + MinGW.ENV_MSYS_HOME + "}" + BACKSLASH + "bin";
+ + "${" + MinGW.ENV_MSYS_HOME + "}" + BACKSLASH + "bin" + PATH_DELIMITER
+ + "${" + MinGW.ENV_MSYS_HOME + "}" + BACKSLASH + "usr" + BACKSLASH + "bin";
return new BuildEnvVar(ENV_PATH, path, IBuildEnvironmentVariable.ENVVAR_PREPEND);
}
diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java
index b4ceb5070b..cb2784a0d2 100644
--- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java
+++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/MinGW.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core;
+import java.nio.file.Files;
+import java.nio.file.Paths;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
@@ -19,6 +21,7 @@ import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
import org.eclipse.cdt.utils.PathUtil;
+import org.eclipse.cdt.utils.WindowsRegistry;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
@@ -73,6 +76,21 @@ public class MinGW {
rootValue = findMingwInPath(envPathValue);
}
+ // Look in MSYS2
+ if (rootValue == null) {
+ WindowsRegistry registry = WindowsRegistry.getRegistry();
+ String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$
+ String subkey;
+ for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) {
+ String compKey = uninstallKey + '\\' + subkey;
+ String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
+ if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
+ rootValue = registry.getCurrentUserValue(compKey, "InstallLocation") + "\\mingw64"; //$NON-NLS-1$ //$NON-NLS-2$
+ break;
+ }
+ }
+ }
+
// Try the default MinGW install dir
if (rootValue == null) {
IPath mingwBinDir = new Path("C:\\MinGW"); //$NON-NLS-1$
@@ -137,6 +155,21 @@ public class MinGW {
}
}
+ // Try under MSYS2
+ if (msysHome == null) {
+ WindowsRegistry registry = WindowsRegistry.getRegistry();
+ String uninstallKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"; //$NON-NLS-1$
+ String subkey;
+ for (int i = 0; (subkey = registry.getCurrentUserKeyName(uninstallKey, i)) != null; i++) {
+ String compKey = uninstallKey + '\\' + subkey;
+ String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$
+ if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$
+ msysHome = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$
+ break;
+ }
+ }
+ }
+
// Try under default MinGW dir
if (msysHome == null) {
IPath minGwMsysBin = new Path("C:\\MinGW\\msys\\1.0\\bin"); //$NON-NLS-1$
diff --git a/llvm/org.eclipse.cdt.managedbuilder.llvm.ui/src/org/eclipse/cdt/managedbuilder/llvm/ui/LlvmEnvironmentVariableSupplier.java b/llvm/org.eclipse.cdt.managedbuilder.llvm.ui/src/org/eclipse/cdt/managedbuilder/llvm/ui/LlvmEnvironmentVariableSupplier.java
index 64e92c6ebf..4ef05ef20c 100755
--- a/llvm/org.eclipse.cdt.managedbuilder.llvm.ui/src/org/eclipse/cdt/managedbuilder/llvm/ui/LlvmEnvironmentVariableSupplier.java
+++ b/llvm/org.eclipse.cdt.managedbuilder.llvm.ui/src/org/eclipse/cdt/managedbuilder/llvm/ui/LlvmEnvironmentVariableSupplier.java
@@ -16,6 +16,7 @@ package org.eclipse.cdt.managedbuilder.llvm.ui;
import java.io.File;
import java.util.HashMap;
+import org.eclipse.cdt.internal.core.MinGW;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
@@ -302,13 +303,30 @@ public class LlvmEnvironmentVariableSupplier implements IConfigurationEnvironmen
}
/**
+ * @return location of $MINGW_HOME/bin folder on the file-system.
+ * @deprecated. Deprecated as of CDT 8.2. Note that MinGW root path in general may depend on configuration.
+ *
+ * If you use this do not cache results to ensure user preferences are accounted for.
+ * Please rely on internal caching.
+ */
+ @Deprecated
+ private static IPath getBinDir() {
+ IPath binDir = null;
+ String minGWHome = MinGW.getMinGWHome();
+ if (minGWHome != null) {
+ binDir = new Path(minGWHome).append("bin"); //$NON-NLS-1$
+ }
+ return binDir;
+ }
+
+ /**
* Returns stdc++ library path located in MinGW installation.
*
* @return stdc++ library path for MinGW
*/
public static String getMinGWStdLib() {
// get mingw bin path
- IPath mingwBinPath = MingwEnvironmentVariableSupplier.getBinDir();
+ IPath mingwBinPath = getBinDir();
if (mingwBinPath != null) {
StringBuilder sB = new StringBuilder(mingwBinPath.toOSString());
// drop bin
diff --git a/qt/org.eclipse.cdt.qt.core/plugin.xml b/qt/org.eclipse.cdt.qt.core/plugin.xml
index 8a803076e0..b02eec7544 100644
--- a/qt/org.eclipse.cdt.qt.core/plugin.xml
+++ b/qt/org.eclipse.cdt.qt.core/plugin.xml
@@ -221,5 +221,16 @@
value="x86_64">
</property>
</mapping>
+ <mapping
+ spec="win32-g++">
+ <property
+ key="os"
+ value="win32">
+ </property>
+ <property
+ key="arch"
+ value="x86_64">
+ </property>
+ </mapping>
</extension>
</plugin>
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java
index e6bcd016a1..d3e952c274 100644
--- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtLaunchConfigurationDelegate.java
@@ -19,6 +19,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
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.debug.core.ILaunchConfiguration;
import org.eclipse.launchbar.core.target.ILaunchTarget;
import org.eclipse.launchbar.core.target.launch.LaunchConfigurationTargetedDelegate;
@@ -30,16 +32,16 @@ public abstract class QtLaunchConfigurationDelegate extends LaunchConfigurationT
IProgressMonitor monitor) throws CoreException {
IQtBuildConfiguration qtBuildConfig = getQtBuildConfiguration(configuration, mode, target, monitor);
- // Set it as active
+ // If found, set as active, if not just return
if (qtBuildConfig != null) {
IProject project = qtBuildConfig.getBuildConfiguration().getProject();
IProjectDescription desc = project.getDescription();
desc.setActiveBuildConfig(qtBuildConfig.getBuildConfiguration().getName());
project.setDescription(desc, monitor);
+ return superBuildForLaunch(configuration, mode, monitor);
+ } else {
+ return false;
}
-
- // And build
- return superBuildForLaunch(configuration, mode, monitor);
}
@Override
@@ -85,7 +87,8 @@ public abstract class QtLaunchConfigurationDelegate extends LaunchConfigurationT
}
// Couldn't find any
- return null;
+ throw new CoreException(new Status(IStatus.ERROR, Activator.ID,
+ String.format("No suitable SDK found for target %s.", target.getId())));
}
}
diff --git a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtMinGWToolChainProvider.java b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtMinGWToolChainProvider.java
index 5e984911dc..d6918cccde 100644
--- a/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtMinGWToolChainProvider.java
+++ b/qt/org.eclipse.cdt.qt.core/src/org/eclipse/cdt/qt/core/QtMinGWToolChainProvider.java
@@ -44,7 +44,7 @@ public class QtMinGWToolChainProvider implements IToolChainProvider {
try {
Files.walk(Paths.get(installLocation).resolve("Tools"), 1) //$NON-NLS-1$
.filter((path) -> Files.exists(path.resolve(gcc)))
- .map((path) -> new GCCToolChain(this, "qt.mingw", "", path.resolve("bin"))) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ .map((path) -> new GCCToolChain(this, "qt.mingw", "", new Path[] { path.resolve("bin") })) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
.forEach(toolChain -> manager.addToolChain(toolChain));
} catch (IOException e) {
Activator.log(e);

Back to the top