Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Johnston2014-04-01 17:22:28 -0400
committerJeff Johnston2014-04-16 16:04:26 -0400
commitfdba4b05b8fd7967ecac7e1a6b2f25ef31cae5c1 (patch)
tree4e07c182518a90681af5386ff26db93c78340a46 /build/org.eclipse.cdt.autotools.core/src
parent4381cc5da1c1a91c603ce956c8737947170cc3e9 (diff)
downloadorg.eclipse.cdt-fdba4b05b8fd7967ecac7e1a6b2f25ef31cae5c1.tar.gz
org.eclipse.cdt-fdba4b05b8fd7967ecac7e1a6b2f25ef31cae5c1.tar.xz
org.eclipse.cdt-fdba4b05b8fd7967ecac7e1a6b2f25ef31cae5c1.zip
Bug 430831 - add autotools support for PTP synchronized project
- bump up minor version - refresh remote synchronized projects when adding a file or directory - for remote synchronized projects, use remote interfaces to figure out target OS - look for synchronized builder when adding Autotools builder - switch to use RemoteCommandLauncher in autotools core and ui - make autotools.core and autotools.ui friends of CDT remote.core - fix org.eclipse.cdt.remote.core to respect working directory - wait for process exitValue to succeed in try loop before attempting to use the return value Change-Id: I837ecf74c44085e35b7e775250b7e5264051475e Reviewed-on: https://git.eclipse.org/r/24360 Tested-by: Hudson CI Reviewed-by: Jeff Johnston <jjohnstn@redhat.com> Tested-by: Jeff Johnston <jjohnstn@redhat.com>
Diffstat (limited to 'build/org.eclipse.cdt.autotools.core/src')
-rw-r--r--build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java17
-rw-r--r--build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java138
-rw-r--r--build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/PkgconfigErrorResolution.java9
3 files changed, 141 insertions, 23 deletions
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java
index a6b87473ff..56e31b52d3 100644
--- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java
+++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java
@@ -39,6 +39,10 @@ public class AutotoolsNewProjectNature implements IProjectNature {
public static final String AUTOTOOLS_NATURE_ID = "org.eclipse.cdt.autotools.core.autotoolsNatureV2"; //$NON-NLS-1$
public static final String OLD_AUTOTOOLS_NATURE_ID = "org.eclipse.linuxtools.cdt.autotools.core.autotoolsNatureV2"; //$NON-NLS-1$
public final static String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".genmakebuilder"; //$NON-NLS-1$
+ /**
+ * @since 1.3
+ */
+ public final static String REMOTE_BUILDER_ID = "org.eclipse.ptp.rdt.sync.cdt.core.SyncBuilder"; // $NON-NLS-1$
public final static String OLD_AUTOTOOLS_BUILDER_ID = "org.eclipse.linuxtools.cdt.autotools.genmakebuilder"; //$NON-NLS-1$
private IProject project;
@@ -46,6 +50,7 @@ public class AutotoolsNewProjectNature implements IProjectNature {
/* (non-Javadoc)
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
+ @Override
public void configure() throws CoreException {
addAutotoolsBuilder(project, new NullProgressMonitor());
}
@@ -53,6 +58,7 @@ public class AutotoolsNewProjectNature implements IProjectNature {
/* (non-Javadoc)
* @see org.eclipse.core.resources.IProjectNature#deconfigure()
*/
+ @Override
public void deconfigure() throws CoreException {
// TODO remove builder from here
}
@@ -60,6 +66,7 @@ public class AutotoolsNewProjectNature implements IProjectNature {
/* (non-Javadoc)
* @see org.eclipse.core.resources.IProjectNature#getProject()
*/
+ @Override
public IProject getProject() {
return project;
}
@@ -67,6 +74,7 @@ public class AutotoolsNewProjectNature implements IProjectNature {
/* (non-Javadoc)
* @see org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core.resources.IProject)
*/
+ @Override
public void setProject(IProject project) {
this.project = project;
}
@@ -91,11 +99,13 @@ public class AutotoolsNewProjectNature implements IProjectNature {
/* (non-Javadoc)
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
*/
+ @Override
protected IStatus run(IProgressMonitor monitor) {
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
protected boolean savedAutoBuildingValue;
+ @Override
public void run(IProgressMonitor monitor) throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
turnOffAutoBuild(workspace);
@@ -164,7 +174,10 @@ public class AutotoolsNewProjectNature implements IProjectNature {
newCommand.setBuilderName(BUILDER_ID);
command = newCommand;
}
- if (command.getBuilderName().equals(BUILDER_ID)) {
+ // Make sure that the Autotools builder precedes the Managed builder
+ // or the Remote Synchronized builder.
+ if (command.getBuilderName().equals(BUILDER_ID) ||
+ command.getBuilderName().equals(REMOTE_BUILDER_ID)) {
// add Autotools Configuration builder just before builder
ICommand newCommand = description.newCommand();
newCommand.setBuilderName(AutotoolsConfigurationBuilder.BUILDER_ID);
@@ -246,7 +259,7 @@ public class AutotoolsNewProjectNature implements IProjectNature {
String[] prevNatures = description.getNatureIds();
List<String> newNatures = new ArrayList<String>(Arrays.asList(prevNatures));
newNatures.remove(natureId);
- description.setNatureIds((String[])newNatures.toArray(new String[newNatures.size()]));
+ description.setNatureIds(newNatures.toArray(new String[newNatures.size()]));
project.setDescription(description, monitor);
}
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java
index 2d3c410651..fca9628a34 100644
--- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java
+++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java
@@ -18,6 +18,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.net.MalformedURLException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
@@ -30,9 +31,9 @@ import java.util.regex.Pattern;
import org.eclipse.cdt.autotools.core.AutotoolsPlugin;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.ConsoleOutputStream;
import org.eclipse.cdt.core.ICDescriptor;
+import org.eclipse.cdt.core.ICommandLauncher;
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
@@ -58,6 +59,7 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
import org.eclipse.cdt.newmake.core.IMakeCommonBuildInfo;
+import org.eclipse.cdt.remote.core.RemoteCommandLauncher;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IContainer;
@@ -78,6 +80,10 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.remote.core.IRemoteConnection;
+import org.eclipse.remote.core.IRemoteResource;
+import org.eclipse.remote.core.IRemoteServices;
+import org.eclipse.remote.core.RemoteServices;
@SuppressWarnings("deprecation")
@@ -162,6 +168,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
CUIPlugin.getDefault().getPreferenceStore().getString("dummy");
}
+ @Override
public IProject getProject() {
return project;
}
@@ -211,6 +218,12 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
if (!newFile.isDerived()) {
newFile.setDerived(true);
}
+ // if successful, refresh any remote projects to notify them of the new file
+ IRemoteResource remRes =
+ (IRemoteResource)getProject().getAdapter(IRemoteResource.class);
+ if (remRes != null) {
+ remRes.refresh(new NullProgressMonitor());
+ }
} catch (CoreException e) {
// If the file already existed locally, just refresh to get contents
@@ -235,8 +248,18 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
if (dirName.length() == 0 || dirName.equals("."))
path = project.getLocation().append(dirName);
File f = path.toFile();
- if (!f.exists())
+ if (!f.exists()) {
rc = f.mkdirs();
+ if (rc) {
+ // if successful, refresh any remote projects to notify them of the new directory
+ IRemoteResource remRes =
+ (IRemoteResource)project.getAdapter(IRemoteResource.class);
+ if (remRes != null) {
+ remRes.refresh(new NullProgressMonitor());
+ }
+
+ }
+ }
return rc;
}
@@ -876,7 +899,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
consoleOutStream.flush();
// Get a launcher for the config command
- CommandLauncher launcher = new CommandLauncher();
+ RemoteCommandLauncher launcher = new RemoteCommandLauncher();
+ launcher.setProject(project);
// Set the environment
IEnvironmentVariable variables[] =
CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, true);
@@ -887,7 +911,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
envList.add(variables[i].getName()
+ "=" + variables[i].getValue()); //$NON-NLS-1$
}
- env = (String[]) envList.toArray(new String[envList.size()]);
+ env = envList.toArray(new String[envList.size()]);
}
// Hook up an error parser manager
@@ -902,6 +926,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
launcher.showCommand(true);
Process proc = launcher.execute(commandPath, configTargets, env,
runPath, new NullProgressMonitor());
+ int exitValue = 0;
if (proc != null) {
try {
// Close the input of the process since we will never write to
@@ -911,10 +936,26 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
}
if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(
- monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
+ monitor, IProgressMonitor.UNKNOWN)) != ICommandLauncher.OK) {
errMsg = launcher.getErrorMessage();
}
+ // There can be a problem looking at the process exit value,
+ // so prevent an exception from occurring.
+ if (errMsg == null || errMsg.length() == 0) {
+ try {
+ exitValue = proc.exitValue();
+ } catch (IllegalThreadStateException e) {
+ try {
+ proc.waitFor();
+ } catch (InterruptedException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ exitValue = proc.exitValue();
+ }
+ }
+
// Force a resync of the projects without allowing the user to
// cancel.
// This is probably unkind, but short of this there is no way to
@@ -943,7 +984,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
rc = IStatus.ERROR;
- } else if (proc.exitValue() >= 1 || proc.exitValue() < 0) {
+ } else if (exitValue >= 1 || exitValue < 0) {
// We have an invalid return code from configuration.
String[] errArg = new String[2];
errArg[0] = Integer.toString(proc.exitValue());
@@ -990,11 +1031,29 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
return rc;
}
+ // Method to translate paths to various commands to their remote counter-parts
+ private IPath getRemotePath(IPath path) {
+ IRemoteResource remRes = (IRemoteResource) getProject().getAdapter(IRemoteResource.class);
+ if (remRes != null) {
+ IPath relativePath = path.makeRelativeTo(getProject().getLocation());
+ try {
+ IPath remotePath =
+ new Path(remRes.getActiveLocationURI().toURL().getPath()).append(relativePath);
+ return remotePath;
+ } catch (MalformedURLException e) {
+ // fall-through to default action
+ }
+
+ }
+ return path;
+ }
+
// Method to get the Win OS Type to distinguish between Cygwin and MingW
private String getWinOSType() {
if (winOSType.equals("")) {
try {
- CommandLauncher launcher = new CommandLauncher();
+ RemoteCommandLauncher launcher = new RemoteCommandLauncher();
+ launcher.setProject(getProject());
ByteArrayOutputStream out = new ByteArrayOutputStream();
// Fix Bug 423192 - use environment variables when checking the Win OS Type using
// a shell command as the path to sh may be specified there
@@ -1007,7 +1066,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
envList.add(variables[i].getName()
+ "=" + variables[i].getValue()); //$NON-NLS-1$
}
- env = (String[]) envList.toArray(new String[envList.size()]);
+ env = envList.toArray(new String[envList.size()]);
}
launcher.execute(
@@ -1016,7 +1075,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
env,
new Path("."), //$NON-NLS-1$
new NullProgressMonitor());
- if (launcher.waitAndRead(out, out) == CommandLauncher.OK)
+ if (launcher.waitAndRead(out, out) == ICommandLauncher.OK)
winOSType = out.toString().trim();
} catch (CoreException e) {
// do nothing
@@ -1025,12 +1084,30 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
return winOSType;
}
+ // Get OS name either remotely or locally, depending on the project
+ private String getOSName() {
+ IRemoteResource remRes =
+ (IRemoteResource)getProject().getAdapter(IRemoteResource.class);
+ if (remRes != null) {
+ URI uri = remRes.getActiveLocationURI();
+ IRemoteServices remServices = RemoteServices.getRemoteServices(uri);
+ if (remServices != null) {
+ IRemoteConnection conn =
+ remServices.getConnectionManager().getConnection(uri);
+ if (conn != null) {
+ return conn.getProperty(IRemoteConnection.OS_NAME_PROPERTY);
+ }
+ }
+ }
+ return Platform.getOS();
+ }
+
// Get the path string. We add a Win check to handle MingW.
// For MingW, we would rather represent C:\a\b as /C/a/b which
// doesn't cause Makefile to choke. For Cygwin we use /cygdrive/C/a/b
private String getPathString(IPath path) {
String s = path.toString();
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ if (getOSName().equals(Platform.OS_WIN32)) {
if (getWinOSType().equals("cygwin")) {
s = s.replaceAll("^([A-Z])(:)", "/cygdrive/$1");
} else {
@@ -1048,7 +1125,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
return s;
}
- // Run an autotools script (e.g. configure, autogen.sh, config.status).
+ // Run an autotools script (e.g. configure, autogen.sh, config.status).
private int runScript(IPath commandPath, IPath runPath, String[] args,
String jobDescription, String errMsg, IConsole console,
ArrayList<String> additionalEnvs,
@@ -1060,6 +1137,10 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
removeAllMarkers(project);
+ // Convert the command path if we have an absolute path and we are executing this remotely
+ if (commandPath.isAbsolute())
+ commandPath = getRemotePath(commandPath);
+
// We want to run the script via the shell command. So, we add the command
// script as the first argument and expect "sh" to be on the runtime path.
// Any other arguments are placed after the script name.
@@ -1073,8 +1154,9 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
configTargets[0] = getPathString(commandPath);
// Fix for bug #343879
- if (Platform.getOS().equals(Platform.OS_WIN32)
- || Platform.getOS().equals(Platform.OS_MACOSX))
+ String osName = getOSName();
+ if (osName.equals(Platform.OS_WIN32)
+ || osName.equals(Platform.OS_MACOSX))
removePWD = true;
// Fix for bug #343731 and bug #371277
@@ -1155,7 +1237,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
consoleOutStream.flush();
// Get a launcher for the config command
- CommandLauncher launcher = new CommandLauncher();
+ RemoteCommandLauncher launcher = new RemoteCommandLauncher();
+ launcher.setProject(project);
// Set the environment
IEnvironmentVariable variables[] =
CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cdesc, true);
@@ -1183,7 +1266,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
}
if (additionalEnvs != null)
envList.addAll(additionalEnvs); // add any additional environment variables specified ahead of script
- env = (String[]) envList.toArray(new String[envList.size()]);
+ env = envList.toArray(new String[envList.size()]);
}
// Hook up an error parser manager
@@ -1199,6 +1282,8 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
// Run the shell script via shell command.
Process proc = launcher.execute(new Path(SHELL_COMMAND), configTargets, env,
runPath, new NullProgressMonitor());
+
+ int exitValue = 0;
if (proc != null) {
try {
// Close the input of the process since we will never write to
@@ -1208,9 +1293,25 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
}
if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor(
- monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) {
+ monitor, IProgressMonitor.UNKNOWN)) != ICommandLauncher.OK) {
errMsg = launcher.getErrorMessage();
}
+
+ // There can be a problem looking at the process exit value,
+ // so prevent an exception from occurring.
+ if (errMsg == null || errMsg.length() == 0) {
+ try {
+ exitValue = proc.exitValue();
+ } catch (IllegalThreadStateException e) {
+ try {
+ proc.waitFor();
+ } catch (InterruptedException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ exitValue = proc.exitValue();
+ }
+ }
// Force a resync of the projects without allowing the user to
// cancel.
@@ -1240,7 +1341,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$//$NON-NLS-2$
buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
rc = IStatus.ERROR;
- } else if (proc.exitValue() >= 1 || proc.exitValue() < 0) {
+ } else if (exitValue >= 1 || exitValue < 0) {
// We have an invalid return code from configuration.
String[] errArg = new String[2];
errArg[0] = Integer.toString(proc.exitValue());
@@ -1342,6 +1443,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
}
protected static class MakeTargetComparator implements Comparator<Object> {
+ @Override
public int compare(Object a, Object b) {
IMakeTarget make1 = (IMakeTarget)a;
IMakeTarget make2 = (IMakeTarget)b;
@@ -1505,6 +1607,6 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
aList.add(str);
}
}
- return (String[])aList.toArray(new String[aList.size()]);
+ return aList.toArray(new String[aList.size()]);
}
} \ No newline at end of file
diff --git a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/PkgconfigErrorResolution.java b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/PkgconfigErrorResolution.java
index 6519ab4243..125a150a83 100644
--- a/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/PkgconfigErrorResolution.java
+++ b/build/org.eclipse.cdt.autotools.core/src/org/eclipse/cdt/internal/autotools/core/PkgconfigErrorResolution.java
@@ -16,7 +16,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.cdt.autotools.core.AutotoolsPlugin;
-import org.eclipse.cdt.core.CommandLauncher;
+import org.eclipse.cdt.core.ICommandLauncher;
+import org.eclipse.cdt.remote.core.RemoteCommandLauncher;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -65,11 +66,13 @@ public class PkgconfigErrorResolution implements IMarkerResolution {
}
}
+ @Override
public String getLabel() {
// TODO Auto-generated method stub
return AutotoolsPlugin.getFormattedString(PKG_UPDATE_MSG, new String[] {pkgName});
}
+ @Override
public void run(IMarker marker) {
// We have a pkgconfig library missing requirement for "pkg". Now, "pkg" does
// not necessarily match the actual system package needed to be updated (e.g.
@@ -83,7 +86,7 @@ public class PkgconfigErrorResolution implements IMarkerResolution {
IPath pkgconfigPath =
new Path("/usr/lib/pkgconfig").append(pkgName+".pc"); //$NON-NLS-1$ //$NON-NLS-2$
// Get a launcher for the config command
- CommandLauncher launcher = new CommandLauncher();
+ RemoteCommandLauncher launcher = new RemoteCommandLauncher();
IPath commandPath = new Path("rpm"); //$NON-NLS-1$
String[] commandArgs =
new String[] {"-q", //$NON-NLS-1$
@@ -105,7 +108,7 @@ public class PkgconfigErrorResolution implements IMarkerResolution {
} catch (IOException e) {
}
if (launcher.waitAndRead(output, output, new NullProgressMonitor())
- != CommandLauncher.OK) {
+ != ICommandLauncher.OK) {
AutotoolsPlugin.logErrorMessage(launcher.getErrorMessage());
} else {
String result = output.readBuffer();

Back to the top