From fdba4b05b8fd7967ecac7e1a6b2f25ef31cae5c1 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Tue, 1 Apr 2014 17:22:28 -0400 Subject: 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 Tested-by: Jeff Johnston --- build/org.eclipse.cdt.autotools.core/.gitignore | 43 +++++++ .../META-INF/MANIFEST.MF | 6 +- build/org.eclipse.cdt.autotools.core/pom.xml | 2 +- .../autotools/core/AutotoolsNewProjectNature.java | 17 ++- .../autotools/core/AutotoolsNewMakeGenerator.java | 138 ++++++++++++++++++--- .../autotools/core/PkgconfigErrorResolution.java | 9 +- .../META-INF/MANIFEST.MF | 3 +- .../autotools/ui/actions/InvokeAction.java | 29 +++-- .../META-INF/MANIFEST.MF | 5 +- .../cdt/remote/core/RemoteCommandLauncher.java | 15 +++ 10 files changed, 226 insertions(+), 41 deletions(-) diff --git a/build/org.eclipse.cdt.autotools.core/.gitignore b/build/org.eclipse.cdt.autotools.core/.gitignore index 8d94ef8debe..128a70568e1 100644 --- a/build/org.eclipse.cdt.autotools.core/.gitignore +++ b/build/org.eclipse.cdt.autotools.core/.gitignore @@ -3,3 +3,46 @@ bin javaCompiler...args build.xml target +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin +/bin diff --git a/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF index 8370974706c..b6d504b275b 100644 --- a/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.autotools.core/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name.0 Bundle-SymbolicName: org.eclipse.cdt.autotools.core;singleton:=true -Bundle-Version: 1.2.0.qualifier +Bundle-Version: 1.3.0.qualifier Bundle-Activator: org.eclipse.cdt.autotools.core.AutotoolsPlugin Bundle-Localization: plugin Require-Bundle: org.eclipse.ui;bundle-version="3.4.0", @@ -23,7 +23,9 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.4.0", org.eclipse.help;bundle-version="3.3.100", org.eclipse.core.variables;bundle-version="3.2.100", org.eclipse.ui.views;bundle-version="3.3.0", - org.eclipse.core.filesystem;bundle-version="1.2.0" + org.eclipse.core.filesystem;bundle-version="1.2.0", + org.eclipse.remote.core;bundle-version="1.0.0", + org.eclipse.cdt.remote.core;bundle-version="1.0.0" Bundle-ActivationPolicy: lazy Bundle-Vendor: %provider Export-Package: org.eclipse.cdt.autotools.core, diff --git a/build/org.eclipse.cdt.autotools.core/pom.xml b/build/org.eclipse.cdt.autotools.core/pom.xml index b6d8cebe72b..d0c0ac6aabc 100644 --- a/build/org.eclipse.cdt.autotools.core/pom.xml +++ b/build/org.eclipse.cdt.autotools.core/pom.xml @@ -11,7 +11,7 @@ ../../pom.xml - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT org.eclipse.cdt.autotools.core eclipse-plugin 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 a6b87473fff..56e31b52d34 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 newNatures = new ArrayList(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 2d3c4106517..fca9628a345 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 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 { + @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 6519ab42432..125a150a83d 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(); diff --git a/build/org.eclipse.cdt.autotools.ui/META-INF/MANIFEST.MF b/build/org.eclipse.cdt.autotools.ui/META-INF/MANIFEST.MF index 794ab7f9c29..6592f323a6d 100644 --- a/build/org.eclipse.cdt.autotools.ui/META-INF/MANIFEST.MF +++ b/build/org.eclipse.cdt.autotools.ui/META-INF/MANIFEST.MF @@ -21,7 +21,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.managedbuilder.ui;bundle-version="5.1.0", org.eclipse.core.filesystem;bundle-version="1.2.0", org.eclipse.cdt.make.ui;bundle-version="6.0.0", - org.eclipse.ui.views;bundle-version="3.4.0" + org.eclipse.ui.views;bundle-version="3.4.0", + org.eclipse.cdt.remote.core;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.cdt.autotools.ui, diff --git a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java index 5e94c24c82f..af78197ff8c 100644 --- a/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java +++ b/build/org.eclipse.cdt.autotools.ui/src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java @@ -20,14 +20,15 @@ import java.util.StringTokenizer; import org.eclipse.cdt.autotools.ui.AutotoolsUIPlugin; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.core.ConsoleOutputStream; +import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.internal.autotools.core.AutotoolsNewMakeGenerator; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.remote.core.RemoteCommandLauncher; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IProject; @@ -131,7 +132,7 @@ public abstract class InvokeAction extends AbstractTargetAction { } - return (String[])targetList.toArray(new String[targetList.size()]); + return targetList.toArray(new String[targetList.size()]); } protected String[] separateOptions(String rawArgList) { @@ -156,7 +157,7 @@ public abstract class InvokeAction extends AbstractTargetAction { } } - return (String[])argList.toArray(new String[argList.size()]); + return argList.toArray(new String[argList.size()]); } @@ -227,10 +228,10 @@ public abstract class InvokeAction extends AbstractTargetAction { } private static class ExecuteProgressDialog implements IRunnableWithProgress { - private IPath command; - private String[] argumentList; - private String[] envList; - private IPath execDir; + private final IPath command; + private final String[] argumentList; + private final String[] envList; + private final IPath execDir; private int status; private HashMap outputs = null; @@ -242,11 +243,12 @@ public abstract class InvokeAction extends AbstractTargetAction { this.execDir = execDir; } + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { ByteArrayOutputStream stdout = new ByteArrayOutputStream(); ByteArrayOutputStream stderr = new ByteArrayOutputStream(); - CommandLauncher cmdL = new CommandLauncher(); + RemoteCommandLauncher cmdL = new RemoteCommandLauncher(); outputs = null; // invoke command @@ -258,7 +260,7 @@ public abstract class InvokeAction extends AbstractTargetAction { Process process = cmdL.execute(command, argumentList, envList, execDir, new NullProgressMonitor()); - if (cmdL.waitAndRead(stdout, stderr, new NullProgressMonitor()) == CommandLauncher.OK) { + if (cmdL.waitAndRead(stdout, stderr, new NullProgressMonitor()) == ICommandLauncher.OK) { try { status = 0; monitor.done(); @@ -334,10 +336,12 @@ public abstract class InvokeAction extends AbstractTargetAction { /* (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() { + @Override public void run(IProgressMonitor monitor) throws CoreException { try { String errMsg = null; @@ -370,7 +374,8 @@ public abstract class InvokeAction extends AbstractTargetAction { ArrayList additionalEnvs = new ArrayList(); String strippedCommand = AutotoolsNewMakeGenerator.stripEnvVars(command, additionalEnvs); // Get a launcher for the config command - CommandLauncher launcher = new CommandLauncher(); + RemoteCommandLauncher launcher = new RemoteCommandLauncher(); + launcher.setProject(project); // Set the environment IEnvironmentVariable variables[] = ManagedBuildManager .getEnvironmentVariableProvider().getVariables(cfg, true); @@ -383,7 +388,7 @@ public abstract class InvokeAction extends AbstractTargetAction { } if (additionalEnvs.size() > 0) 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()]); } String[] newArgumentList; @@ -416,7 +421,7 @@ public abstract class InvokeAction extends AbstractTargetAction { } if (launcher.waitAndRead(stdout, stderr, new SubProgressMonitor( - monitor, IProgressMonitor.UNKNOWN)) != CommandLauncher.OK) { + monitor, IProgressMonitor.UNKNOWN)) != ICommandLauncher.OK) { errMsg = launcher.getErrorMessage(); } diff --git a/remote/org.eclipse.cdt.remote.core/META-INF/MANIFEST.MF b/remote/org.eclipse.cdt.remote.core/META-INF/MANIFEST.MF index 6576b05846f..b13e1a5ea86 100644 --- a/remote/org.eclipse.cdt.remote.core/META-INF/MANIFEST.MF +++ b/remote/org.eclipse.cdt.remote.core/META-INF/MANIFEST.MF @@ -6,9 +6,10 @@ Bundle-Version: 1.0.0.qualifier Bundle-Activator: org.eclipse.cdt.remote.internal.core.Activator Require-Bundle: org.eclipse.core.runtime, org.eclipse.cdt.core, - org.eclipse.remote.core + org.eclipse.remote.core, + org.eclipse.core.filesystem Bundle-RequiredExecutionEnvironment: JavaSE-1.7 Bundle-ActivationPolicy: lazy Bundle-Vendor: %pluginProvider Import-Package: org.eclipse.core.resources -Export-Package: org.eclipse.cdt.remote.core;x-internal:=true +Export-Package: org.eclipse.cdt.remote.core;x-friends="org.eclipse.cdt.autotools.core,org.eclipse.cdt.autotools.ui" diff --git a/remote/org.eclipse.cdt.remote.core/src/org/eclipse/cdt/remote/core/RemoteCommandLauncher.java b/remote/org.eclipse.cdt.remote.core/src/org/eclipse/cdt/remote/core/RemoteCommandLauncher.java index aa090eb3c31..222d40f6d3d 100644 --- a/remote/org.eclipse.cdt.remote.core/src/org/eclipse/cdt/remote/core/RemoteCommandLauncher.java +++ b/remote/org.eclipse.cdt.remote.core/src/org/eclipse/cdt/remote/core/RemoteCommandLauncher.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.remote.core; import java.io.IOException; import java.io.OutputStream; +import java.net.MalformedURLException; import java.net.URI; import java.util.Map; import java.util.Properties; @@ -19,10 +20,12 @@ import java.util.Properties; import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.remote.internal.core.messages.Messages; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; import org.eclipse.remote.core.IRemoteConnection; import org.eclipse.remote.core.IRemoteProcess; import org.eclipse.remote.core.IRemoteProcessBuilder; @@ -68,6 +71,18 @@ public class RemoteCommandLauncher implements ICommandLauncher { parseEnvironment(env); fCommandArgs = constructCommandArray(commandPath.toOSString(), args); IRemoteProcessBuilder processBuilder = fConnection.getProcessBuilder(fCommandArgs); + if (workingDirectory != null) { + IPath relativePath = workingDirectory.makeRelativeTo(getProject().getLocation()); + try { + IPath remoteWorkingPath = + new Path(remRes.getActiveLocationURI().toURL().getPath()).append(relativePath); + IFileStore wd = fConnection.getFileManager().getResource(remoteWorkingPath.toString()); + processBuilder.directory(wd); + } catch (MalformedURLException e) { + fLocalLauncher.setErrorMessage(e.getMessage()); + return null; + } + } Map processEnv = processBuilder.environment(); for (String key : fEnvironment.stringPropertyNames()) { processEnv.put(key, fEnvironment.getProperty(key)); -- cgit v1.2.3