1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

A few cygwin simplifications

This commit is contained in:
Andrew Gvozdev 2012-03-27 10:17:47 -04:00
parent e219640575
commit c97867bc23
3 changed files with 5 additions and 88 deletions

View file

@ -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}">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>

View file

@ -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) {

View file

@ -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();
}
}