Skip to content

Commit

Permalink
Support multiple MSYS2 64-bit registry names (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
jld01 committed Jan 15, 2023
1 parent c98aae4 commit a949830
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build/org.eclipse.cdt.build.gcc.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
/*******************************************************************************
* 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
* which accompanies this distribution, and is available at
* 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;

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;
Expand All @@ -27,6 +30,7 @@
public class Msys2ToolChainProvider implements IToolChainProvider {

private static final String ID = "org.eclipse.cdt.build.gcc.core.msys2Provider"; //$NON-NLS-1$
private static final Set<String> MSYS2_64BIT_NAMES = Set.of("MSYS2", "MSYS2 64bit"); //$NON-NLS-1$ //$NON-NLS-2$

@Override
public String getId() {
Expand All @@ -45,7 +49,7 @@ public void init(IToolChainManager manager) {
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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;

Expand All @@ -18,6 +19,7 @@
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;
Expand All @@ -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<String> 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);

Expand Down Expand Up @@ -93,7 +96,7 @@ private static String findMinGWRoot(String envPathValue, String envMinGWHomeValu
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$
Expand Down Expand Up @@ -228,7 +231,7 @@ private static String findMSysRoot(String envMinGWHomeValue) {
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;
Expand Down

0 comments on commit a949830

Please sign in to comment.