From c97867bc235e7bc381f22e6d981d6274a88362c1 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Tue, 27 Mar 2012 10:17:47 -0400 Subject: [PATCH] A few cygwin simplifications --- .../plugin.xml | 2 +- .../GCCBuiltinSpecsDetectorCygwin.java | 18 +---- .../resources/CygwinEFSExtensionProvider.java | 73 +------------------ 3 files changed, 5 insertions(+), 88 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml index be9c9532996..bcd5b536211 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core/plugin.xml @@ -617,7 +617,7 @@ class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin" id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin" name="CDT GCC Builtin Compiler Settings Cygwin" - parameter="sh -c "${COMMAND} -E -P -v -dD ${INPUTS}""> + parameter="${COMMAND} -E -P -v -dD ${INPUTS}"> diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/GCCBuiltinSpecsDetectorCygwin.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/GCCBuiltinSpecsDetectorCygwin.java index 6a9aa295188..53ec30d1d43 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/GCCBuiltinSpecsDetectorCygwin.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/GCCBuiltinSpecsDetectorCygwin.java @@ -14,12 +14,11 @@ package org.eclipse.cdt.managedbuilder.internal.language.settings.providers; import java.net.URI; import java.net.URISyntaxException; -import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.core.resources.IResource; /** * Class to detect built-in compiler settings. - * The paths are converted to cygwin "filesystem" representation. Then + * The paths are converted to cygwin "filesystem" representation. Then * */ public class GCCBuiltinSpecsDetectorCygwin extends GCCBuiltinSpecsDetector { @@ -32,19 +31,6 @@ public class GCCBuiltinSpecsDetectorCygwin extends GCCBuiltinSpecsDetector { throw new IllegalStateException(e); } } - - @SuppressWarnings("nls") - private static final AbstractOptionParser[] optionParsers = { - new IncludePathOptionParser("#include \"(\\S.*)\"", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY | ICSettingEntry.LOCAL), - new IncludePathOptionParser("#include <(\\S.*)>", "$1", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), - new MacroOptionParser("#define (\\S*\\(.*?\\)) *(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), - new MacroOptionParser("#define (\\S*) *(.*)", "$1", "$2", ICSettingEntry.BUILTIN | ICSettingEntry.READONLY), - }; - - @Override - protected AbstractOptionParser[] getOptionParsers() { - return optionParsers; - } @Override protected URI getMappedRootURI(IResource sourceFile, String parsedResourceName) { @@ -56,7 +42,7 @@ public class GCCBuiltinSpecsDetectorCygwin extends GCCBuiltinSpecsDetector { } return mappedRootURI; } - + @Override protected URI getBuildDirURI(URI mappedRootURI) { if (buildDirURI==null) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/CygwinEFSExtensionProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/CygwinEFSExtensionProvider.java index 5e78daf609b..d643c9784d7 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/CygwinEFSExtensionProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/resources/CygwinEFSExtensionProvider.java @@ -11,14 +11,11 @@ package org.eclipse.cdt.internal.core.resources; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; import java.net.URI; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.EFSExtensionProvider; -import org.eclipse.core.runtime.Platform; +import org.eclipse.cdt.internal.core.Cygwin; public class CygwinEFSExtensionProvider extends EFSExtensionProvider { @Override @@ -26,76 +23,10 @@ public class CygwinEFSExtensionProvider extends EFSExtensionProvider { String cygwinPath = getPathFromURI(locationURI); String windowsPath = null; try { - windowsPath = cygwinToWindowsPath(cygwinPath); + windowsPath = Cygwin.cygwinToWindowsPath(cygwinPath); } catch (Exception e) { CCorePlugin.log(e); } return windowsPath; } - - /** - * Conversion from Windows path to Cygwin path. - * - * @param windowsPath - Windows path. - * @return Cygwin style converted path. - * @throws UnsupportedOperationException if Cygwin is unavailable. - * @throws IOException on IO problem. - * - * See ResourceHelper.windowsToCygwinPath(...) - */ - public static String windowsToCygwinPath(String windowsPath) throws IOException, UnsupportedOperationException { - if (!Platform.getOS().equals(Platform.OS_WIN32)) { - // Don't run this on non-windows platforms - throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); - } - @SuppressWarnings("nls") - String[] args = {"cygpath", "-u", windowsPath}; - Process cygpath; - try { - cygpath = Runtime.getRuntime().exec(args); - } catch (IOException ioe) { - throw new UnsupportedOperationException("Cygwin utility cygpath is not in the system search path."); - } - BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpath.getInputStream())); - - String cygwinPath = stdout.readLine(); - if (cygwinPath == null) { - throw new UnsupportedOperationException("Cygwin utility cygpath is not available."); - } - return cygwinPath.trim(); - } - - /** - * Conversion from Cygwin path to Windows path. - * - * @param cygwinPath - Cygwin path. - * @return Windows style converted path. - * @throws UnsupportedOperationException if Cygwin is unavailable. - * @throws IOException on IO problem. - * - * * See ResourceHelper.cygwinToWindowsPath(...) - */ - public static String cygwinToWindowsPath(String cygwinPath) throws IOException, UnsupportedOperationException { - if (!Platform.getOS().equals(Platform.OS_WIN32)) { - // Don't run this on non-windows platforms - throw new UnsupportedOperationException("Not a Windows system, Cygwin is unavailable."); - } - @SuppressWarnings("nls") - String[] args = {"cygpath", "-w", cygwinPath}; - Process cygpath; - try { - cygpath = Runtime.getRuntime().exec(args); - } catch (IOException ioe) { - throw new UnsupportedOperationException("Cygwin utility cygpath is not in the system search path."); - } - BufferedReader stdout = new BufferedReader(new InputStreamReader(cygpath.getInputStream())); - - String windowsPath = stdout.readLine(); - if (windowsPath == null) { - throw new UnsupportedOperationException("Cygwin utility cygpath is not available."); - } - return windowsPath.trim(); - } - - }