mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Fix for PR 91276: Cygpath on Linux for SCD?
Cygpath is now used only on Win32 platform.
This commit is contained in:
parent
8c5fd6fb3d
commit
47135c2117
3 changed files with 31 additions and 43 deletions
|
@ -33,50 +33,49 @@ import org.eclipse.core.runtime.Platform;
|
||||||
*/
|
*/
|
||||||
public class CygpathTranslator {
|
public class CygpathTranslator {
|
||||||
private IPath cwd;
|
private IPath cwd;
|
||||||
private String orgPath;
|
|
||||||
private String transPath;
|
private String transPath;
|
||||||
|
private boolean isCygpathAvailable;
|
||||||
private boolean status;
|
private boolean status;
|
||||||
|
|
||||||
|
|
||||||
public CygpathTranslator(String path) {
|
public CygpathTranslator() {
|
||||||
this(MakeCorePlugin.getDefault().getStateLocation(), path);
|
this(MakeCorePlugin.getDefault().getStateLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CygpathTranslator(IPath cwd, String path) {
|
public CygpathTranslator(IPath cwd) {
|
||||||
this.cwd = cwd;
|
this.cwd = cwd;
|
||||||
orgPath = path;
|
isCygpathAvailable = Platform.getOS().equals(Platform.OS_WIN32);
|
||||||
status = false;
|
translate("/"); //$NON-NLS-1$
|
||||||
|
isCygpathAvailable = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String translate(final String path) {
|
||||||
* @return Returns the status.
|
if (!isCygpathAvailable)
|
||||||
*/
|
return path;
|
||||||
public boolean isStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String run() {
|
|
||||||
ISafeRunnable runnable = new ISafeRunnable() {
|
ISafeRunnable runnable = new ISafeRunnable() {
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
transPath = platformRun();
|
transPath = platformRun(path);
|
||||||
if (transPath.startsWith("cygpath:")) { //$NON-NLS-1$
|
if (transPath.startsWith("cygpath:")) { //$NON-NLS-1$
|
||||||
transPath = null;
|
transPath = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleException(Throwable exception) {
|
public void handleException(Throwable exception) {
|
||||||
transPath = orgPath;
|
transPath = path;
|
||||||
MakeCorePlugin.log(exception);
|
MakeCorePlugin.log(exception);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Platform.run(runnable);
|
Platform.run(runnable);
|
||||||
|
|
||||||
return transPath;
|
return transPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param path
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String platformRun() {
|
private String platformRun(String path) {
|
||||||
CommandLauncher launcher = new CommandLauncher();
|
CommandLauncher launcher = new CommandLauncher();
|
||||||
launcher.showCommand(false);
|
launcher.showCommand(false);
|
||||||
|
|
||||||
|
@ -84,7 +83,7 @@ public class CygpathTranslator {
|
||||||
|
|
||||||
Process p = launcher.execute(
|
Process p = launcher.execute(
|
||||||
new Path("cygpath"), //$NON-NLS-1$
|
new Path("cygpath"), //$NON-NLS-1$
|
||||||
new String[] {"-m", orgPath}, //$NON-NLS-1$
|
new String[] {"-m", path}, //$NON-NLS-1$
|
||||||
new String[0],//setEnvironment(launcher, "c:/"),//$NON-NLS-1$
|
new String[0],//setEnvironment(launcher, "c:/"),//$NON-NLS-1$
|
||||||
cwd); //$NON-NLS-1$
|
cwd); //$NON-NLS-1$
|
||||||
if (p != null) {
|
if (p != null) {
|
||||||
|
@ -103,7 +102,7 @@ public class CygpathTranslator {
|
||||||
status = true;
|
status = true;
|
||||||
return output.toString().trim();
|
return output.toString().trim();
|
||||||
}
|
}
|
||||||
return orgPath;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,20 +133,16 @@ public class CygpathTranslator {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static List translateIncludePaths(List sumIncludes) {
|
public static List translateIncludePaths(List sumIncludes) {
|
||||||
CygpathTranslator test = new CygpathTranslator("/"); //$NON-NLS-1$
|
CygpathTranslator cygpath = new CygpathTranslator();
|
||||||
test.run();
|
if (!cygpath.isCygpathAvailable) return sumIncludes;
|
||||||
if (!test.isStatus()) return sumIncludes;
|
|
||||||
|
|
||||||
List translatedIncludePaths = new ArrayList();
|
List translatedIncludePaths = new ArrayList();
|
||||||
for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) {
|
for (Iterator i = sumIncludes.iterator(); i.hasNext(); ) {
|
||||||
String includePath = (String) i.next();
|
String includePath = (String) i.next();
|
||||||
IPath realPath = new Path(includePath);
|
IPath realPath = new Path(includePath);
|
||||||
if (!realPath.toFile().exists()) {
|
if (!realPath.toFile().exists()) {
|
||||||
String translatedPath = includePath;
|
String translatedPath = cygpath.translate(includePath);
|
||||||
if (Platform.getOS().equals(Platform.OS_WIN32)) {
|
if (translatedPath != null && cygpath.status == true) {
|
||||||
translatedPath = (new CygpathTranslator(includePath)).run();
|
|
||||||
}
|
|
||||||
if (translatedPath != null) {
|
|
||||||
if (!translatedPath.equals(includePath)) {
|
if (!translatedPath.equals(includePath)) {
|
||||||
// Check if the translated path exists
|
// Check if the translated path exists
|
||||||
IPath transPath = new Path(translatedPath);
|
IPath transPath = new Path(translatedPath);
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2005-05-03 Vladimir Hirsl
|
||||||
|
Fix for PR 91276: Cygpath on Linux for SCD?
|
||||||
|
Changes in CygpathTranslator that affect DefaultGnuWinScannerInfoCollector.
|
||||||
|
|
||||||
|
* src/org/eclipse/cdt/managedbuilder/internal/scannerconfig/DefaultGnuWinScannerInfoCollector.java
|
||||||
|
|
||||||
2005-03-18 Alain Magloire
|
2005-03-18 Alain Magloire
|
||||||
Fix for PR 88110: Importing project that need converting would
|
Fix for PR 88110: Importing project that need converting would
|
||||||
create NPE and ResouceException failures.
|
create NPE and ResouceException failures.
|
||||||
|
|
|
@ -37,10 +37,10 @@ public class DefaultGnuWinScannerInfoCollector extends DefaultGCCScannerInfoColl
|
||||||
List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
List symbols = (List) scannerInfo.get(ScannerInfoTypes.SYMBOL_DEFINITIONS);
|
||||||
|
|
||||||
// This method will be called by the parser each time there is a new value
|
// This method will be called by the parser each time there is a new value
|
||||||
Iterator pathIter = includes.listIterator();
|
List translatedIncludes = CygpathTranslator.translateIncludePaths(includes);
|
||||||
|
Iterator pathIter = translatedIncludes.listIterator();
|
||||||
while (pathIter.hasNext()) {
|
while (pathIter.hasNext()) {
|
||||||
String path = (String) pathIter.next();
|
String convertedPath = (String) pathIter.next();
|
||||||
String convertedPath = convertPath(path);
|
|
||||||
// On MinGW, there is no facility for converting paths
|
// On MinGW, there is no facility for converting paths
|
||||||
if (convertedPath.startsWith("/")) continue; //$NON-NLS-1$
|
if (convertedPath.startsWith("/")) continue; //$NON-NLS-1$
|
||||||
// Add it if it is not a duplicate
|
// Add it if it is not a duplicate
|
||||||
|
@ -61,17 +61,4 @@ public class DefaultGnuWinScannerInfoCollector extends DefaultGCCScannerInfoColl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* Converts the argument from a POSIX-style path to a valid Win32 path.
|
|
||||||
* If the string is already in the proper format it will not be changed.
|
|
||||||
*
|
|
||||||
* @param path <code>String</code> containing path to convert
|
|
||||||
* @return <code>String</code> containing the converted path
|
|
||||||
*/
|
|
||||||
private String convertPath(String includePath) {
|
|
||||||
// Convert a POSIX-style path to Win32
|
|
||||||
String translatedPath = new CygpathTranslator(includePath).run();
|
|
||||||
return translatedPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue