From a949830dd36a84297cac39452f725dad9ef9875c Mon Sep 17 00:00:00 2001 From: John Dallaway Date: Sun, 15 Jan 2023 16:52:20 +0000 Subject: [PATCH] Support multiple MSYS2 64-bit registry names (#243) --- .../org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF | 2 +- .../build/gcc/core/internal/Msys2ToolChainProvider.java | 8 ++++++-- .../utils/org/eclipse/cdt/internal/core/MinGW.java | 9 ++++++--- 3 files changed, 13 insertions(+), 6 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 283cb8d6643..c46ce153216 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 @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.cdt.build.gcc.core;singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.0.100.qualifier Bundle-Activator: org.eclipse.cdt.build.gcc.core.internal.Activator Bundle-Vendor: %providerName Require-Bundle: org.eclipse.core.runtime, 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 bafc645fbb6..7263b690743 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016 QNX Software Systems and others. + * Copyright (c) 2016, 2023 QNX Software Systems and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -7,6 +7,8 @@ * https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 + * Contributors: + * John Dallaway - Support multiple MSYS2 64-bit registry names (#237) *******************************************************************************/ package org.eclipse.cdt.build.gcc.core.internal; @@ -14,6 +16,7 @@ import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Set; import org.eclipse.cdt.build.gcc.core.GCCToolChain; import org.eclipse.cdt.core.build.IToolChain; @@ -27,6 +30,7 @@ import org.eclipse.core.runtime.Platform; public class Msys2ToolChainProvider implements IToolChainProvider { private static final String ID = "org.eclipse.cdt.build.gcc.core.msys2Provider"; //$NON-NLS-1$ + private static final Set MSYS2_64BIT_NAMES = Set.of("MSYS2", "MSYS2 64bit"); //$NON-NLS-1$ //$NON-NLS-2$ @Override public String getId() { @@ -45,7 +49,7 @@ public class Msys2ToolChainProvider implements IToolChainProvider { String compKey = uninstallKey + '\\' + subkey; String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ if (on64bit) { - if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$ + if (MSYS2_64BIT_NAMES.contains(displayName)) { if (addToolChain64(manager, registry, compKey)) { key32bit = null; break; 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 5a2d1cd604a..eadd6110bcb 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Andrew Gvozdev and others. + * Copyright (c) 2012, 2023 Andrew Gvozdev and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -10,6 +10,7 @@ * * Contributors: * Andrew Gvozdev - Initial API and implementation + * John Dallaway - Support multiple MSYS2 64-bit registry names (#237) *******************************************************************************/ package org.eclipse.cdt.internal.core; @@ -18,6 +19,7 @@ import java.util.Collections; import java.util.Map; import java.util.Objects; import java.util.Optional; +import java.util.Set; import java.util.WeakHashMap; import org.eclipse.cdt.core.CCorePlugin; @@ -36,6 +38,7 @@ public class MinGW { public static final String ENV_MINGW_HOME = "MINGW_HOME"; //$NON-NLS-1$ public static final String ENV_MSYS_HOME = "MSYS_HOME"; //$NON-NLS-1$ private static final String ENV_PATH = "PATH"; //$NON-NLS-1$ + private static final Set MSYS2_64BIT_NAMES = Set.of("MSYS2", "MSYS2 64bit"); //$NON-NLS-1$ //$NON-NLS-2$ private static final boolean isWindowsPlatform = Platform.getOS().equals(Platform.OS_WIN32); @@ -93,7 +96,7 @@ public class MinGW { String compKey = uninstallKey + '\\' + subkey; String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ if (on64bit) { - if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$ + if (MSYS2_64BIT_NAMES.contains(displayName)) { String installLocation = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ String mingwLocation = installLocation + "\\mingw64"; //$NON-NLS-1$ File gccFile = new File(mingwLocation + "\\bin\\gcc.exe"); //$NON-NLS-1$ @@ -228,7 +231,7 @@ public class MinGW { String compKey = uninstallKey + '\\' + subkey; String displayName = registry.getCurrentUserValue(compKey, "DisplayName"); //$NON-NLS-1$ if (on64bit) { - if ("MSYS2 64bit".equals(displayName)) { //$NON-NLS-1$ + if (MSYS2_64BIT_NAMES.contains(displayName)) { String home = registry.getCurrentUserValue(compKey, "InstallLocation"); //$NON-NLS-1$ if (new File(home).isDirectory()) { msysHome = home;