mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-16 12:45:41 +02:00
A few cygwin simplifications
This commit is contained in:
parent
e219640575
commit
c97867bc23
3 changed files with 5 additions and 88 deletions
|
@ -617,7 +617,7 @@
|
||||||
class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin"
|
class="org.eclipse.cdt.managedbuilder.internal.language.settings.providers.GCCBuiltinSpecsDetectorCygwin"
|
||||||
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin"
|
id="org.eclipse.cdt.managedbuilder.core.GCCBuiltinSpecsDetectorCygwin"
|
||||||
name="CDT GCC Builtin Compiler Settings Cygwin"
|
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.gcc"/>
|
||||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||||
</provider>
|
</provider>
|
||||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.managedbuilder.internal.language.settings.providers;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,19 +32,6 @@ public class GCCBuiltinSpecsDetectorCygwin extends GCCBuiltinSpecsDetector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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
|
@Override
|
||||||
protected URI getMappedRootURI(IResource sourceFile, String parsedResourceName) {
|
protected URI getMappedRootURI(IResource sourceFile, String parsedResourceName) {
|
||||||
if (mappedRootURI==null) {
|
if (mappedRootURI==null) {
|
||||||
|
|
|
@ -11,14 +11,11 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.resources;
|
package org.eclipse.cdt.internal.core.resources;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.EFSExtensionProvider;
|
import org.eclipse.cdt.core.EFSExtensionProvider;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.cdt.internal.core.Cygwin;
|
||||||
|
|
||||||
public class CygwinEFSExtensionProvider extends EFSExtensionProvider {
|
public class CygwinEFSExtensionProvider extends EFSExtensionProvider {
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,76 +23,10 @@ public class CygwinEFSExtensionProvider extends EFSExtensionProvider {
|
||||||
String cygwinPath = getPathFromURI(locationURI);
|
String cygwinPath = getPathFromURI(locationURI);
|
||||||
String windowsPath = null;
|
String windowsPath = null;
|
||||||
try {
|
try {
|
||||||
windowsPath = cygwinToWindowsPath(cygwinPath);
|
windowsPath = Cygwin.cygwinToWindowsPath(cygwinPath);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
return windowsPath;
|
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue