diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java index df6f7d2ee5c..79a7880705b 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java @@ -256,24 +256,12 @@ public class MakeBuilder extends ACBuilder { getProject().setSessionProperty(qName, !monitor.isCanceled() && !isClean ? new Integer(streamMon.getWorkDone()) : null); if (errMsg != null) { - StringBuffer buf = new StringBuffer(buildCommand.toString() + " "); //$NON-NLS-1$ - for (String buildArgument : buildArguments) { - buf.append(buildArgument); - buf.append(' '); - } - - String errorDesc = MakeMessages.getFormattedString("MakeBuilder.buildError", buf.toString()); //$NON-NLS-1$ - buf = new StringBuffer(errorDesc); - buf.append(System.getProperty("line.separator", "\n")); //$NON-NLS-1$ //$NON-NLS-2$ - buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$ - cos.write(buf.toString().getBytes()); - cos.flush(); + consoleErr.write((errMsg + '\n').getBytes()); } stdout.close(); stderr.close(); - monitor.subTask(MakeMessages.getString("MakeBuilder.Creating_Markers")); //$NON-NLS-1$ consoleOut.close(); consoleErr.close(); cos.close(); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties index dbeb9de63d2..7509f90aa47 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeMessages.properties @@ -13,7 +13,6 @@ AbstractGCCBOPConsoleParser_EnteringDirectory=Entering directory AbstractGCCBOPConsoleParser_LeavingDirectory=Leaving directory -MakeBuilder.buildError=Error launching builder ({0}) MakeBuilder.Invoking_Make_Builder=Invoking Make Builder... MakeBuilder.Invoking_Command=Invoking Command: MakeBuilder.Updating_project=Updating project... @@ -41,9 +40,7 @@ ExternalScannerInfoProvider.Reading_Specs=Reading specs ... ExternalScannerInfoProvider.Invoking_Command=Invoking Command: ExternalScannerInfoProvider.Parsing_Output=Parsing output ... ExternalScannerInfoProvider.Creating_Markers=Generating markers ... -# Error_Prefix affects generation of markers in the Problems view -ExternalScannerInfoProvider.Error_Prefix=Warning: -ExternalScannerInfoProvider.Provider_Error=Error launching external scanner info generator ({0}) +ExternalScannerInfoProvider.Provider_Error=Warning: Error launching external scanner info generator ({0}) ExternalScannerInfoProvider.Working_Directory=Working directory: {0} ExternalScannerInfoProvider.Program_Not_In_Path=Program ''{0}'' is not found in $PATH diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java index 5dd879706fc..19123121aa0 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java @@ -37,7 +37,6 @@ import org.eclipse.cdt.make.internal.core.StreamMonitor; import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerConfigUtil; import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory; import org.eclipse.cdt.utils.EFSExtensionManager; -import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; @@ -55,55 +54,53 @@ import org.osgi.service.prefs.BackingStoreException; * @author vhirsl */ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { - private static final String EXTERNAL_SI_PROVIDER_ERROR = "ExternalScannerInfoProvider.Provider_Error"; //$NON-NLS-1$ private static final String GMAKE_ERROR_PARSER_ID = "org.eclipse.cdt.core.GmakeErrorParser"; //$NON-NLS-1$ private static final String PREF_CONSOLE_ENABLED = "org.eclipse.cdt.make.core.scanner.discovery.console.enabled"; //$NON-NLS-1$ private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ - private static final String PATH_ENV = "PATH"; //$NON-NLS-1$ - protected IResource resource; - protected String providerId; - protected IScannerConfigBuilderInfo2 buildInfo; - protected IScannerInfoCollector collector; - // To be initialized by a subclass - protected IPath fWorkingDirectory; - protected IPath fCompileCommand; - protected String[] fCompileArguments; + protected IResource resource; + protected String providerId; + protected IScannerConfigBuilderInfo2 buildInfo; + protected IScannerInfoCollector collector; + // To be initialized by a subclass + protected IPath fWorkingDirectory; + protected IPath fCompileCommand; + protected String[] fCompileArguments; - private SCMarkerGenerator markerGenerator = new SCMarkerGenerator(); + private SCMarkerGenerator markerGenerator = new SCMarkerGenerator(); - @Override + @Override public boolean invokeProvider(IProgressMonitor monitor, IResource resource, - String providerId, IScannerConfigBuilderInfo2 buildInfo, - IScannerInfoCollector collector) { - return invokeProvider(monitor, resource, new InfoContext(resource.getProject()), providerId, buildInfo, collector, null); - } + String providerId, IScannerConfigBuilderInfo2 buildInfo, + IScannerInfoCollector collector) { + return invokeProvider(monitor, resource, new InfoContext(resource.getProject()), providerId, buildInfo, collector, null); + } - @Override + @Override public boolean invokeProvider(IProgressMonitor monitor, - IResource resource, - InfoContext context, - String providerId, - IScannerConfigBuilderInfo2 buildInfo, - IScannerInfoCollector collector, - Properties env) { - // initialize fields - this.resource = resource; - this.providerId = providerId; - this.buildInfo = buildInfo; - this.collector = collector; + IResource resource, + InfoContext context, + String providerId, + IScannerConfigBuilderInfo2 buildInfo, + IScannerInfoCollector collector, + Properties env) { + // initialize fields + this.resource = resource; + this.providerId = providerId; + this.buildInfo = buildInfo; + this.collector = collector; - IProject currentProject = resource.getProject(); - // call a subclass to initialize protected fields - if (!initialize()) { - return false; - } - if (monitor == null) { - monitor = new NullProgressMonitor(); - } - monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), 100); //$NON-NLS-1$ + IProject currentProject = resource.getProject(); + // call a subclass to initialize protected fields + if (!initialize()) { + return false; + } + if (monitor == null) { + monitor = new NullProgressMonitor(); + } + monitor.beginTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs"), 100); //$NON-NLS-1$ - try { + try { ILanguage language = context.getLanguage(); IConsole console; if (language!=null && isConsoleEnabled()) { @@ -114,23 +111,24 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { // that looks in extension points registry and won't find the id console = CCorePlugin.getDefault().getConsole(MakeCorePlugin.PLUGIN_ID + ".console.hidden"); //$NON-NLS-1$ } - console.start(currentProject); - OutputStream cos = console.getOutputStream(); + console.start(currentProject); + OutputStream cos = console.getOutputStream(); - // Before launching give visual cues via the monitor - monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs")); //$NON-NLS-1$ + // Before launching give visual cues via the monitor + monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Reading_Specs")); //$NON-NLS-1$ - String errMsg = null; - ICommandLauncher launcher = new CommandLauncher(); - launcher.setProject(currentProject); - // Print the command for visual interaction. - launcher.showCommand(true); + String errMsg = null; + ICommandLauncher launcher = new CommandLauncher(); + launcher.setProject(currentProject); + // Print the command for visual interaction. + launcher.showCommand(true); - String[] comandLineOptions = getCommandLineOptions(); - String params = coligate(comandLineOptions); + String[] comandLineOptions = getCommandLineOptions(); + IPath program = getCommandToLaunch(); + String params = coligate(comandLineOptions); - monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Invoking_Command") //$NON-NLS-1$ - + getCommandToLaunch() + params); + monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Invoking_Command") //$NON-NLS-1$ + + program + params); ErrorParserManager epm = new ErrorParserManager(currentProject, markerGenerator, new String[] {GMAKE_ERROR_PARSER_ID}); epm.setOutputStream(cos); @@ -140,90 +138,66 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getESIProviderOutputSniffer( stdout, stderr, currentProject, context, providerId, buildInfo, collector, markerGenerator); - OutputStream consoleOut = (sniffer == null ? cos : sniffer.getOutputStream()); - OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream()); - Process p = launcher.execute(getCommandToLaunch(), comandLineOptions, setEnvironment(launcher, env), fWorkingDirectory, monitor); - if (p != null) { - try { - // Close the input of the Process explicitely. - // We will never write to it. - p.getOutputStream().close(); - } catch (IOException e) { - } - if (launcher.waitAndRead(consoleOut, consoleErr, new SubProgressMonitor(monitor, 0)) != ICommandLauncher.OK) { - errMsg = launcher.getErrorMessage(); - } - monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Parsing_Output")); //$NON-NLS-1$ - } - else { - errMsg = launcher.getErrorMessage(); - } - - if (errMsg != null) { - String errorPrefix = MakeMessages.getString("ExternalScannerInfoProvider.Error_Prefix"); //$NON-NLS-1$ - String program = fCompileCommand.toString(); - - String msg = MakeMessages.getFormattedString(EXTERNAL_SI_PROVIDER_ERROR, program+params); - printLine(consoleErr, errorPrefix + msg + NEWLINE); - - // Launching failed, trying to figure out possible cause - Properties envMap = getEnvMap(launcher, env); - String envPath = envMap.getProperty(PATH_ENV); - if (envPath == null) { - envPath = System.getenv(PATH_ENV); + OutputStream consoleOut = (sniffer == null ? cos : sniffer.getOutputStream()); + OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream()); + Process p = launcher.execute(program, comandLineOptions, setEnvironment(launcher, env), fWorkingDirectory, monitor); + if (p != null) { + try { + // Close the input of the Process explicitly. + // We will never write to it. + p.getOutputStream().close(); + } catch (IOException e) { } - if (!fCompileCommand.isAbsolute() && PathUtil.findProgramLocation(program, envPath) == null) { - printLine(consoleErr, errMsg); - msg = MakeMessages.getFormattedString("ExternalScannerInfoProvider.Working_Directory", fWorkingDirectory); //$NON-NLS-1$ - msg = MakeMessages.getFormattedString("ExternalScannerInfoProvider.Program_Not_In_Path", program); //$NON-NLS-1$ - printLine(consoleErr, errorPrefix + msg + NEWLINE); - printLine(consoleErr, PATH_ENV + "=[" + envPath + "]" + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - printLine(consoleErr, errorPrefix + errMsg); - msg = MakeMessages.getFormattedString("ExternalScannerInfoProvider.Working_Directory", fWorkingDirectory); //$NON-NLS-1$ - printLine(consoleErr, PATH_ENV + "=[" + envPath + "]" + NEWLINE); //$NON-NLS-1$ //$NON-NLS-2$ + if (launcher.waitAndRead(consoleOut, consoleErr, new SubProgressMonitor(monitor, 0)) != ICommandLauncher.OK) { + errMsg = launcher.getErrorMessage(); } - - monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Creating_Markers")); //$NON-NLS-1$ + monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Parsing_Output")); //$NON-NLS-1$ + } else { + errMsg = launcher.getErrorMessage(); } - consoleOut.close(); - consoleErr.close(); - cos.close(); - } - catch (Exception e) { - MakeCorePlugin.log(e); - } - finally { - monitor.done(); - } - return true; - } + if (errMsg != null) { + printLine(consoleErr, errMsg); + printLine(consoleErr, MakeMessages.getFormattedString("ExternalScannerInfoProvider.Provider_Error", program + params) + NEWLINE); //$NON-NLS-1$ + } - protected IPath getCommandToLaunch() { - return fCompileCommand; - } + consoleOut.close(); + consoleErr.close(); + cos.close(); + } + catch (Exception e) { + MakeCorePlugin.log(e); + } + finally { + monitor.done(); + } + return true; + } - protected String[] getCommandLineOptions() { - // add additional arguments - // subclass can change default behavior - return prepareArguments( - buildInfo.isUseDefaultProviderCommand(providerId)); - } + protected IPath getCommandToLaunch() { + return fCompileCommand; + } - private void printLine(OutputStream stream, String msg) throws IOException { - stream.write((msg + NEWLINE).getBytes()); - stream.flush(); - } + protected String[] getCommandLineOptions() { + // add additional arguments + // subclass can change default behavior + return prepareArguments( + buildInfo.isUseDefaultProviderCommand(providerId)); + } - /** - * Initialization of protected fields. - * Subclasses are most likely to override default implementation. - */ - protected boolean initialize() { + private void printLine(OutputStream stream, String msg) throws IOException { + stream.write((msg + NEWLINE).getBytes()); + stream.flush(); + } + + /** + * Initialization of protected fields. + * Subclasses are most likely to override default implementation. + */ + protected boolean initialize() { IProject currProject = resource.getProject(); - //fWorkingDirectory = resource.getProject().getLocation(); + //fWorkingDirectory = resource.getProject().getLocation(); URI workingDirURI = MakeBuilderUtil.getBuildDirectoryURI(currProject, MakeBuilder.BUILDER_ID); String pathString = EFSExtensionManager.getDefault().getPathFromURI(workingDirURI); if(pathString != null) { @@ -235,34 +209,34 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { throw new IllegalStateException(); } - fCompileCommand = new Path(buildInfo.getProviderRunCommand(providerId)); - fCompileArguments = ScannerConfigUtil.tokenizeStringWithQuotes(buildInfo.getProviderRunArguments(providerId), "\"");//$NON-NLS-1$ - return (fCompileCommand != null); - } + fCompileCommand = new Path(buildInfo.getProviderRunCommand(providerId)); + fCompileArguments = ScannerConfigUtil.tokenizeStringWithQuotes(buildInfo.getProviderRunArguments(providerId), "\"");//$NON-NLS-1$ + return (fCompileCommand != null); + } - /** - * Add additional arguments. For example: tso - target specific options - * Base class implementation returns compileArguments. - * Subclasses are most likely to override default implementation. - */ - protected String[] prepareArguments(boolean isDefaultCommand) { - return fCompileArguments; - } + /** + * Add additional arguments. For example: tso - target specific options + * Base class implementation returns compileArguments. + * Subclasses are most likely to override default implementation. + */ + protected String[] prepareArguments(boolean isDefaultCommand) { + return fCompileArguments; + } - private String coligate(String[] array) { - StringBuffer sb = new StringBuffer(128); - for (int i = 0; i < array.length; ++i) { - sb.append(' '); - sb.append(array[i]); - } - String ca = sb.toString(); - return ca; - } + private String coligate(String[] array) { + StringBuffer sb = new StringBuffer(128); + for (int i = 0; i < array.length; ++i) { + sb.append(' '); + sb.append(array[i]); + } + String ca = sb.toString(); + return ca; + } private Properties getEnvMap(ICommandLauncher launcher, Properties initialEnv) { // Set the environmennt, some scripts may need the CWD var to be set. Properties props = initialEnv != null ? initialEnv : launcher.getEnvironment(); - + if (fWorkingDirectory != null) { props.put("CWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$ props.put("PWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$ @@ -278,20 +252,20 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider { return props; } - protected String[] setEnvironment(ICommandLauncher launcher, Properties initialEnv) { - Properties props = getEnvMap(launcher, initialEnv); - String[] env = null; - ArrayList envList = new ArrayList(); - Enumeration names = props.propertyNames(); - if (names != null) { - while (names.hasMoreElements()) { - String key = (String) names.nextElement(); - envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$ - } - env = envList.toArray(new String[envList.size()]); - } - return env; - } + protected String[] setEnvironment(ICommandLauncher launcher, Properties initialEnv) { + Properties props = getEnvMap(launcher, initialEnv); + String[] env = null; + ArrayList envList = new ArrayList(); + Enumeration names = props.propertyNames(); + if (names != null) { + while (names.hasMoreElements()) { + String key = (String) names.nextElement(); + envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$ + } + env = envList.toArray(new String[envList.size()]); + } + return env; + } /** diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java index 42940a74288..5a2c2dafbbf 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ExternalBuildRunner.java @@ -47,7 +47,6 @@ import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider; import org.eclipse.cdt.newmake.internal.core.StreamMonitor; import org.eclipse.cdt.utils.CommandLineUtil; import org.eclipse.cdt.utils.EFSExtensionManager; -import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -140,7 +139,7 @@ public class ExternalBuildRunner extends AbstractBuildRunner { if(pathFromURI == null) { throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, ManagedMakeMessages.getString("ManagedMakeBuilder.message.error"), null)); //$NON-NLS-1$ } - + IPath workingDirectory = new Path(pathFromURI); String[] targets = getTargets(kind, builder); @@ -197,10 +196,10 @@ public class ExternalBuildRunner extends AbstractBuildRunner { // Do not allow the cancel of the refresh, since the builder is external // to Eclipse, files may have been created/modified and we will be out-of-sync. // The caveat is for huge projects, it may take sometimes at every build. - + // TODO should only refresh output folders //project.refreshLocal(IResource.DEPTH_INFINITE, null); - + // use the refresh scope manager to refresh RefreshScopeManager refreshManager = RefreshScopeManager.getInstance(); IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(project); @@ -208,32 +207,15 @@ public class ExternalBuildRunner extends AbstractBuildRunner { } catch (CoreException e) { } } else { - buf = new StringBuffer(launcher.getCommandLine()).append(NEWLINE); errMsg = launcher.getErrorMessage(); } project.setSessionProperty(qName, !monitor.isCanceled() && !isClean ? new Integer(streamMon.getWorkDone()) : null); if (errMsg != null) { - // Launching failed, trying to figure out possible cause - String errorPrefix = ManagedMakeMessages.getResourceString("ManagedMakeBuilder.error.prefix"); //$NON-NLS-1$ - String buildCommandStr = buildCommand.toString(); - String envPath = envMap.get(PATH_ENV); - if (envPath==null) { - envPath = System.getenv(PATH_ENV); - } - if (PathUtil.findProgramLocation(buildCommandStr, envPath)==null) { - buf.append(errMsg).append(NEWLINE); - errMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.program.not.in.path", buildCommandStr); //$NON-NLS-1$ - buf.append(errorPrefix).append(errMsg).append(NEWLINE); - buf.append(NEWLINE); - buf.append(PATH_ENV+"=["+envPath+"]").append(NEWLINE); //$NON-NLS-1$//$NON-NLS-2$ - } else { - buf.append(errorPrefix).append(errMsg).append(NEWLINE); - } - consoleErr.write(buf.toString().getBytes()); + consoleErr.write(errMsg.getBytes()); consoleErr.flush(); } - + buf = new StringBuffer(NEWLINE); buf.append(ManagedMakeMessages.getResourceString("ManagedMakeBuilder.message.build.finished")).append(NEWLINE); //$NON-NLS-1$ consoleOut.write(buf.toString().getBytes()); @@ -310,15 +292,15 @@ public class ExternalBuildRunner extends AbstractBuildRunner { envMap.put(var.getName(), var.getValue()); } } - + // Add variables from build info Map builderEnv = builder.getExpandedEnvironment(); if (builderEnv != null) envMap.putAll(builderEnv); - + return envMap; } - + protected static String[] getEnvStrings(Map env) { // Convert into env strings List strings= new ArrayList(env.size()); @@ -327,10 +309,10 @@ public class ExternalBuildRunner extends AbstractBuildRunner { buffer.append('=').append(entry.getValue()); strings.add(buffer.toString()); } - + return strings.toArray(new String[strings.size()]); } - + private ConsoleOutputSniffer createBuildOutputSniffer(OutputStream outputStream, OutputStream errorStream, IProject project, diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java index f0ff0a7a194..f4fbfd0244a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/CommandBuilder.java @@ -21,8 +21,6 @@ import java.util.Set; import org.eclipse.cdt.core.CommandLauncher; import org.eclipse.cdt.core.ICommandLauncher; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildCommand; -import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages; -import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; @@ -90,9 +88,7 @@ public class CommandBuilder implements IBuildModelBuilder { * @see org.eclipse.cdt.managedbuilder.internal.builddescription.IBuildDescriptionBuilder#build(java.io.OutputStream, java.io.OutputStream, org.eclipse.core.runtime.IProgressMonitor) */ @Override - public int build(OutputStream out, OutputStream err, - IProgressMonitor monitor){ - + public int build(OutputStream out, OutputStream err, IProgressMonitor monitor){ //TODO: should we display the command line here? monitor.beginTask("", getNumCommands()); //$NON-NLS-1$ monitor.subTask(""/*getCommandLine()*/); //$NON-NLS-1$ @@ -112,17 +108,18 @@ public class CommandBuilder implements IBuildModelBuilder { return STATUS_ERROR_LAUNCH; } + int st = ICommandLauncher.ILLEGAL_COMMAND; if (fProcess != null) { try { // Close the input of the process since we will never write to it fProcess.getOutputStream().close(); } catch (IOException e) { } + //wrapping out and err streams to avoid their closure + st = launcher.waitAndRead(wrap(out), wrap(err), + new SubProgressMonitor(monitor, getNumCommands())); } - //wrapping out and err streams to avoid their closure - int st = launcher.waitAndRead(wrap(out), wrap(err), - new SubProgressMonitor(monitor, getNumCommands())); switch(st){ case ICommandLauncher.OK: if(fProcess.exitValue() != 0) @@ -143,19 +140,7 @@ public class CommandBuilder implements IBuildModelBuilder { if(DbgUtil.DEBUG) DbgUtil.trace("error launching the command: " + fErrMsg); //$NON-NLS-1$ - String program = fCmd.getCommand().toOSString(); - String envPath = fCmd.getEnvironment().get(PATH_ENV); - if (envPath==null) { - envPath = System.getenv(PATH_ENV); - } - if (PathUtil.findProgramLocation(program, envPath)==null) { - printMessage(fErrMsg, out); - String errMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.program.not.in.path", program); //$NON-NLS-1$ - printErrorMessage(errMsg + NEWLINE, out); - printMessage(null, PATH_ENV+"=["+envPath+"]", out); //$NON-NLS-1$//$NON-NLS-2$ - } else { - printErrorMessage(fErrMsg, out); - } + printMessage(fErrMsg, out); break; } @@ -185,14 +170,10 @@ public class CommandBuilder implements IBuildModelBuilder { return list.toArray(new String[list.size()]); } - private void printMessage(String prefix, String msg, OutputStream os){ + protected void printMessage(String msg, OutputStream os){ if (os != null) { - if (prefix==null) { - prefix=""; //$NON-NLS-1$ - } - msg = prefix + msg + NEWLINE; try { - os.write(msg.getBytes()); + os.write((msg + NEWLINE).getBytes()); os.flush(); } catch (IOException e) { // ignore; @@ -201,22 +182,6 @@ public class CommandBuilder implements IBuildModelBuilder { } - protected void printMessage(String msg, OutputStream os){ - if (os != null) { - msg = ManagedMakeMessages.getFormattedString("InternalBuilder.msg.header", msg); //$NON-NLS-1$ - printMessage(null, msg, os); - } - - } - - private void printErrorMessage(String msg, OutputStream os){ - if (os != null) { - String errorPrefix = ManagedMakeMessages.getResourceString("ManagedMakeBuilder.error.prefix"); //$NON-NLS-1$ - printMessage(errorPrefix, msg, os); - } - - } - public int getNumCommands() { return 1; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java index 5446824dae3..1650ca25c24 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/GeneratedMakefileBuilder.java @@ -4,7 +4,7 @@ * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Rational Software - Initial API and implementation *******************************************************************************/ @@ -74,10 +74,10 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; /** - * This is the incremental builder associated with a managed build project. It dynamically + * This is the incremental builder associated with a managed build project. It dynamically * decides the makefile generator it wants to use for a specific target. - * - * @since 1.2 + * + * @since 1.2 */ public class GeneratedMakefileBuilder extends ACBuilder { /** @@ -89,7 +89,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { private boolean incrBuildNeeded = false; private boolean fullBuildNeeded = false; private List reservedNames; - + public ResourceDeltaVisitor(IManagedBuildInfo info) { buildInfo = info; String ext = buildInfo.getBuildArtifactExtension(); @@ -103,7 +103,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { info.getDefaultConfiguration()); } catch (BuildMacroException e){ } - + String name = buildInfo.getBuildArtifactName(); //try to resolve build macros in the build artifact name try{ @@ -140,13 +140,13 @@ public class GeneratedMakefileBuilder extends ACBuilder { } private boolean isProjectFile(IResource resource) { - return reservedNames.contains(resource.getName()); + return reservedNames.contains(resource.getName()); } public boolean shouldBuildIncr() { return incrBuildNeeded; } - + public boolean shouldBuildFull() { return fullBuildNeeded; } @@ -158,15 +158,15 @@ public class GeneratedMakefileBuilder extends ACBuilder { if (resource != null && resource.getProject() == getProject()) { switch(resource.getType()){ case IResource.FILE: - String name = resource.getName(); + String name = resource.getName(); if ((!name.equals(buildGoalName) && // TODO: Also need to check for secondary outputs - (resource.isDerived() || + (resource.isDerived() || (isProjectFile(resource)) || (isGeneratedResource(resource))))) { - // The resource that changed has attributes which make it uninteresting, + // The resource that changed has attributes which make it uninteresting, // so don't do anything - } + } else { // TODO: Should we do extra checks here to determine if a build is really needed, // or do you just do exclusion checks like above? @@ -180,15 +180,15 @@ public class GeneratedMakefileBuilder extends ACBuilder { // o An Option // o An AdditionalInput // - //if (resourceName.equals(buildGoalName) || + //if (resourceName.equals(buildGoalName) || // (buildInfo.buildsFileType(ext) || buildInfo.isHeaderFile(ext))) { - + // We need to do an incremental build, at least incrBuildNeeded = true; if (delta.getKind() == IResourceDelta.REMOVED) { // If a meaningful resource was removed, then force a full build // This is required because an incremental build will trigger make to - // do nothing for a missing source, since the state after the file + // do nothing for a missing source, since the state after the file // removal is uptodate, as far as make is concerned // A full build will clean, and ultimately trigger a relink without // the object generated from the deleted source, which is what we want @@ -197,9 +197,9 @@ public class GeneratedMakefileBuilder extends ACBuilder { // decided to do a full build anyway break; } - + //} - } + } return false; } @@ -213,14 +213,14 @@ public class GeneratedMakefileBuilder extends ACBuilder { IConfiguration configs[]; Configuration otherConfigs[]; int resourceChangeState; - + private static final IPath[] ignoreList = { new Path(".cdtproject"), //$NON-NLS-1$ new Path(".cproject"), //$NON-NLS-1$ new Path(".cdtbuild"), //$NON-NLS-1$ new Path(".settings"), //$NON-NLS-1$ }; - + OtherConfigVerifier(IConfiguration cfg){ config = cfg; configs = cfg.getManagedProject().getConfigurations(); @@ -231,10 +231,10 @@ public class GeneratedMakefileBuilder extends ACBuilder { otherConfigs[counter++] = (Configuration)configs[i]; } } - + @Override public boolean visit(IResourceDelta delta) throws CoreException { - + IResource rc = delta.getResource(); if(rc.getType() == IResource.FILE){ if(isResourceValuable(rc)) @@ -243,7 +243,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { } return !isGeneratedForConfig(rc, config) && isResourceValuable(rc); } - + public void updateOtherConfigs(IResourceDelta delta){ if(delta == null) resourceChangeState = ~0; @@ -254,16 +254,16 @@ public class GeneratedMakefileBuilder extends ACBuilder { resourceChangeState = ~0; } } - + setResourceChangeStateForOtherConfigs(); } - + private void setResourceChangeStateForOtherConfigs(){ for(int i = 0; i < otherConfigs.length; i++){ otherConfigs[i].addResourceChangeState(resourceChangeState); } } - + private boolean isGeneratedForConfig(IResource resource, IConfiguration cfg) { // Is this a generated directory ... IPath path = resource.getProjectRelativePath(); @@ -308,7 +308,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { private static final String TYPE_REBUILD = "ManagedMakeBuider.type.rebuild"; //$NON-NLS-1$ private static final String INTERNAL_BUILDER = "ManagedMakeBuilder.message.internal.builder"; //$NON-NLS-1$ public static boolean VERBOSE = false; - + // Local variables protected Vector generationProblems; protected IProject[] referencedProjects; @@ -365,7 +365,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { } else { consoleHeader[0] = new String(); outputError(getProject().getName(), "The given build type is not supported in this context"); //$NON-NLS-1$ - } + } consoleHeader[1] = configName; consoleHeader[2] = getProject().getName(); buf.append(NEWLINE); @@ -379,20 +379,20 @@ public class GeneratedMakefileBuilder extends ACBuilder { // Throw the exception back to the builder throw e; } catch (IOException io) { // Ignore console failures... - } + } } /** - * + * * This method has been created so that subclasses can override how the builder obtains its * build info. The default implementation retrieves the info from the build manager. - * + * * @return An IManagedBuildInfo object representing the build info. */ protected IManagedBuildInfo getBuildInfo() { return ManagedBuildManager.getBuildInfo(getProject()); } - + /* (non-Javadoc) * @see org.eclipse.core.internal.events.InternalBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor) */ @@ -423,7 +423,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { } else { cfgs = new IConfiguration[] {info.getDefaultConfiguration() }; } - + for (IConfiguration cfg : cfgs) { updateOtherConfigs(cfg, kind); @@ -455,7 +455,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { if(delta == null) fullBuildNeeded = true; if(cfg.needsRebuild() || delta != null){ - //use a build description model to calculate the resources to be cleaned + //use a build description model to calculate the resources to be cleaned //only in case there are some changes to the project sources or build information try{ int flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.DEPFILES | BuildDescriptionManager.DEPS; @@ -535,7 +535,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { // Should only build this project once, for this delta break; } else { - int refKind = refDelta.getKind(); + int refKind = refDelta.getKind(); if (refKind != IResourceDelta.NO_CHANGE) { int refFlags = refDelta.getFlags(); if (!(refKind == IResourceDelta.CHANGED && @@ -546,7 +546,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { break; } } - } + } } } } @@ -561,11 +561,11 @@ public class GeneratedMakefileBuilder extends ACBuilder { private void updateOtherConfigs(IConfiguration cfg, int buildKind){ new OtherConfigVerifier(cfg).updateOtherConfigs(buildKind == FULL_BUILD ? null : getDelta(getProject())); } - + /** - * Check whether the build has been canceled. Cancellation requests + * Check whether the build has been canceled. Cancellation requests * propagated to the caller by throwing OperationCanceledException. - * + * * @see org.eclipse.core.runtime.OperationCanceledException#OperationCanceledException() */ public void checkCancel(IProgressMonitor monitor) { @@ -602,7 +602,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { outputError(buildDir == null ? "null" : buildDir.getName(), "Could not delete the build directory"); //$NON-NLS-1$ //$NON-NLS-2$ return; } - String status; + String status; try { // try the brute force approach first status = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.clean.deleting.output", buildDir.getName()); //$NON-NLS-1$ @@ -635,9 +635,9 @@ public class GeneratedMakefileBuilder extends ACBuilder { IManagedBuilderMakefileGenerator generator = ManagedBuildManager.getBuildfileGenerator(info.getDefaultConfiguration()); generator.initialize(getProject(), info, monitor); cleanBuild(info, generator, monitor); - } catch (IOException io) {} // Ignore console failures... + } catch (IOException io) {} // Ignore console failures... } - + /* (non-Javadoc) * @param info * @param generator @@ -649,11 +649,11 @@ public class GeneratedMakefileBuilder extends ACBuilder { if (buildDir == null) { buildDir = new Path(info.getConfigurationName()); } - IPath makefilePath = getProject().getLocation().append(buildDir.append(generator.getMakefileName())); + IPath makefilePath = getProject().getLocation().append(buildDir.append(generator.getMakefileName())); IWorkspaceRoot root = CCorePlugin.getWorkspace().getRoot(); IFile makefile = root.getFileForLocation(makefilePath); - - if (makefile != null && makefile.isAccessible()) { + + if (makefile != null && makefile.isAccessible()) { // invoke make with the clean argument String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$ monitor.subTask(statusMsg); @@ -672,14 +672,14 @@ public class GeneratedMakefileBuilder extends ACBuilder { if (monitor == null) { monitor = new NullProgressMonitor(); } - + checkCancel(monitor); //If the previous builder invocation was cancelled, generated files might be corrupted - //in case one or more of the generated makefiles (e.g. dep files) are corrupted, - //the builder invocation might fail because of the possible syntax errors, so e.g. "make clean" will not work + //in case one or more of the generated makefiles (e.g. dep files) are corrupted, + //the builder invocation might fail because of the possible syntax errors, so e.g. "make clean" will not work //we need to explicitly clean the generated directories // clean(new SubProgressMonitor(monitor, IProgressMonitor.UNKNOWN)); - + // Regenerate the makefiles for this project checkCancel(monitor); String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.rebuild.makefiles", getProject().getName()); //$NON-NLS-1$ @@ -691,26 +691,26 @@ public class GeneratedMakefileBuilder extends ACBuilder { IStatus[] kids = result.getChildren(); for (int index = 0; index < kids.length; ++index) { // One possibility is that there is nothing to build - IStatus status = kids[index]; + IStatus status = kids[index]; if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) { // Inform the user, via the console, that there is nothing to build // either because there are no buildable sources files or all potentially // buildable files have been excluded from build - try { + try { emitNoSourceMessage(FULL_BUILD, status, info.getConfigurationName()); } catch (CoreException e) { // Throw the exception back to the builder throw e; - } + } // Dude, we're done return; } else { // Stick this in the list of stuff to warn the user about - getGenerationProblems().add(status); - } + getGenerationProblems().add(status); + } } } - + // Now call make checkCancel(monitor); statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.starting", getProject().getName()); //$NON-NLS-1$ @@ -719,11 +719,11 @@ public class GeneratedMakefileBuilder extends ACBuilder { if (topBuildDir != null) { invokeMake(FULL_BUILD, topBuildDir, info, generator, monitor); } else { - statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); + statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); monitor.subTask(statusMsg); return; } - + // Now regenerate the dependencies checkCancel(monitor); statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.regen.deps", getProject().getName()); //$NON-NLS-1$ @@ -736,12 +736,12 @@ public class GeneratedMakefileBuilder extends ACBuilder { } // Build finished message - statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); + statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); monitor.subTask(statusMsg); } - + /* (non-Javadoc) - * + * * @return */ private Vector getGenerationProblems() { @@ -750,11 +750,11 @@ public class GeneratedMakefileBuilder extends ACBuilder { } return generationProblems; } - + /* (non-javadoc) * Answers an array of strings with the proper make targets - * for a build with no custom prebuild/postbuild steps - * + * for a build with no custom prebuild/postbuild steps + * * @param fullBuild * @return */ @@ -771,7 +771,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { } return args.toArray(new String[args.size()]); } - + protected List getResourcesToBuild() { if (resourcesToBuild == null) { resourcesToBuild = new ArrayList(); @@ -797,7 +797,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { if (monitor == null) { monitor = new NullProgressMonitor(); } - + // Ask the makefile generator to generate any makefiles needed to build delta checkCancel(monitor); String statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.update.makefiles", getProject().getName()); //$NON-NLS-1$ @@ -807,23 +807,23 @@ public class GeneratedMakefileBuilder extends ACBuilder { IStatus[] kids = result.getChildren(); for (int index = 0; index < kids.length; ++index) { // One possibility is that there is nothing to build - IStatus status = kids[index]; + IStatus status = kids[index]; if (status.getCode() == IManagedBuilderMakefileGenerator.NO_SOURCE_FOLDERS) { // Inform the user, via the console, that there is nothing to build // either because there are no buildable sources files or all potentially // buildable files have been excluded from build - try { + try { emitNoSourceMessage(INCREMENTAL_BUILD, status, info.getConfigurationName()); } catch (CoreException e) { // Throw the exception back to the builder throw e; - } + } // Dude, we're done return; } else { // Stick this in the list of stuff to warn the user about - getGenerationProblems().add(status); - } + getGenerationProblems().add(status); + } } } @@ -835,11 +835,11 @@ public class GeneratedMakefileBuilder extends ACBuilder { if (buildDir != null) { invokeMake(INCREMENTAL_BUILD, buildDir, info, generator, monitor); } else { - statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); + statusMsg = ManagedMakeMessages.getFormattedString(NOTHING_BUILT, getProject().getName()); monitor.subTask(statusMsg); return; } - + // Generate the dependencies for all changes checkCancel(monitor); statusMsg = ManagedMakeMessages.getFormattedString("ManagedMakeBuilder.message.updating.deps", getProject().getName()); //$NON-NLS-1$ @@ -849,17 +849,17 @@ public class GeneratedMakefileBuilder extends ACBuilder { } catch (CoreException e) { throw e; } - + // Build finished message - statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); + statusMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, getProject().getName()); monitor.subTask(statusMsg); } /* (non-Javadoc) - * @param buildType + * @param buildType * @param buildDir * @param info - * @param generator + * @param generator * @param monitor */ protected void invokeMake(int buildType, IPath buildDir, IManagedBuildInfo info, IManagedBuilderMakefileGenerator generator, IProgressMonitor monitor) { @@ -870,13 +870,13 @@ public class GeneratedMakefileBuilder extends ACBuilder { } try { - // Figure out the working directory for the build and make sure there is a makefile there + // Figure out the working directory for the build and make sure there is a makefile there final URI workingDirectoryURI = getProject().getFolder(buildDir).getLocationURI(); final String pathFromURI = EFSExtensionManager.getDefault().getPathFromURI(workingDirectoryURI); if(pathFromURI == null) { throw new CoreException(new Status(IStatus.ERROR, ManagedBuilderCorePlugin.PLUGIN_ID, ManagedMakeMessages.getString("ManagedMakeBuilder.message.error"), null)); //$NON-NLS-1$ } - + IPath workingDirectory = new Path(pathFromURI); IWorkspace workspace = currentProject.getWorkspace(); @@ -889,7 +889,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { } IPath makefile = workingDirectory.append(generator.getMakefileName()); if (root.getFileForLocation(makefile) == null) { - return; + return; } // Flag to the user that make is about to be called @@ -907,7 +907,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { } catch (BuildMacroException e){ } - IPath makeCommand = new Path(makeCmd); + IPath makeCommand = new Path(makeCmd); String[] msgs = new String[2]; msgs[0] = makeCommand.toString(); msgs[1] = currentProject.getName(); @@ -928,13 +928,13 @@ public class GeneratedMakefileBuilder extends ACBuilder { consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_CLEAN); break; } - + consoleHeader[1] = info.getConfigurationName(); consoleHeader[2] = currentProject.getName(); buf.append(NEWLINE); buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)).append(NEWLINE); buf.append(NEWLINE); - + IConfiguration cfg = info.getDefaultConfiguration(); if(!cfg.isSupported()){ String msg = ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()}); @@ -943,10 +943,10 @@ public class GeneratedMakefileBuilder extends ACBuilder { } consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); - + // Remove all markers for this project removeAllMarkers(currentProject); - + // Get a launcher for the make command String errMsg = null; IBuilder builder = info.getDefaultConfiguration().getBuilder(); @@ -964,20 +964,20 @@ public class GeneratedMakefileBuilder extends ACBuilder { } env = envList.toArray(new String[envList.size()]); } - + // Hook up an error parser manager - String[] errorParsers = info.getDefaultConfiguration().getErrorParserList(); + String[] errorParsers = info.getDefaultConfiguration().getErrorParserList(); ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectoryURI, this, errorParsers); epm.setOutputStream(consoleOutStream); // This variable is necessary to ensure that the EPM stream stay open // until we explicitly close it. See bug#123302. OutputStream epmOutputStream = epm.getOutputStream(); - - // Get the arguments to be passed to make from build model + + // Get the arguments to be passed to make from build model ArrayList makeArgs = new ArrayList(); String arg = info.getBuildArguments(); if (arg.length() > 0) { - String[] args = arg.split("\\s"); //$NON-NLS-1$ + String[] args = arg.split("\\s"); //$NON-NLS-1$ for (int i = 0; i < args.length; ++i) { makeArgs.add(args[i]); } @@ -1005,14 +1005,14 @@ public class GeneratedMakefileBuilder extends ACBuilder { String[] premakeTargets; switch (buildType) { case INCREMENTAL_BUILD: { - // For an incremental build with a prebuild step: - // Check the status of the main build with "make -q main-build" - // If up to date: - // then: don't invoke the prebuild step, which should be run only if - // something needs to be built in the main build - // else: invoke the prebuild step and the main build step - premakeArgs.add("-q"); //$NON-NLS-1$ - premakeArgs.add("main-build"); //$NON-NLS-1$ + // For an incremental build with a prebuild step: + // Check the status of the main build with "make -q main-build" + // If up to date: + // then: don't invoke the prebuild step, which should be run only if + // something needs to be built in the main build + // else: invoke the prebuild step and the main build step + premakeArgs.add("-q"); //$NON-NLS-1$ + premakeArgs.add("main-build"); //$NON-NLS-1$ premakeTargets = premakeArgs.toArray(new String[premakeArgs.size()]); proc = launcher.execute(makeCommand, premakeTargets, env, workingDirectory, monitor); if (proc != null) { @@ -1032,11 +1032,11 @@ public class GeneratedMakefileBuilder extends ACBuilder { if ((errMsg != null && errMsg.length() > 0) || proc == null) { // Can't tell if the build is needed, so assume it is, and let any errors be triggered - // when the "real" build is invoked below - makeArgs.add("pre-build"); //$NON-NLS-1$ - makeArgs.add("main-build"); //$NON-NLS-1$ + // when the "real" build is invoked below + makeArgs.add("pre-build"); //$NON-NLS-1$ + makeArgs.add("main-build"); //$NON-NLS-1$ } else { - // The "make -q" command launch was successful + // The "make -q" command launch was successful if (proc.exitValue() == 0) { // If the status value returned from "make -q" is 0, then the build state is up-to-date isuptodate = true; @@ -1045,40 +1045,40 @@ public class GeneratedMakefileBuilder extends ACBuilder { buf = new StringBuffer(); buf.append(NEWLINE); buf.append(uptodateMsg).append(NEWLINE); - // Write message on the console + // Write message on the console consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); epmOutputStream.close(); consoleOutStream.close(); } else { // The status value was other than 0, so press on with the build process - makeArgs.add("pre-build"); //$NON-NLS-1$ - makeArgs.add("main-build"); //$NON-NLS-1$ + makeArgs.add("pre-build"); //$NON-NLS-1$ + makeArgs.add("main-build"); //$NON-NLS-1$ } } break; } case FULL_BUILD: { -// makeArgs.add("clean"); //$NON-NLS-1$ - makeArgs.add("pre-build"); //$NON-NLS-1$ - makeArgs.add("main-build"); //$NON-NLS-1$ +// makeArgs.add("clean"); //$NON-NLS-1$ + makeArgs.add("pre-build"); //$NON-NLS-1$ + makeArgs.add("main-build"); //$NON-NLS-1$ break; } case CLEAN_BUILD: { - makeArgs.add("clean"); //$NON-NLS-1$ + makeArgs.add("clean"); //$NON-NLS-1$ break; } } } else { - // No prebuild step - // + // No prebuild step + // makeArgs.addAll(Arrays.asList(getMakeTargets(buildType))); } makeTargets = makeArgs.toArray(new String[makeArgs.size()]); - // Launch make - main invocation + // Launch make - main invocation if (!isuptodate) { proc = launcher.execute(makeCommand, makeTargets, env, workingDirectory, monitor); if (proc != null) { @@ -1093,7 +1093,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { IProgressMonitor.UNKNOWN)); if(state != ICommandLauncher.OK){ errMsg = launcher.getErrorMessage(); - + if(state == ICommandLauncher.COMMAND_CANCELED){ //TODO: the better way of handling cancel is needed //currently the rebuild state is set to true forcing the full rebuild @@ -1102,14 +1102,14 @@ public class GeneratedMakefileBuilder extends ACBuilder { } } - // 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 insure - // the UI is up-to-date with the build results + // 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 insure + // the UI is up-to-date with the build results monitor.subTask(ManagedMakeMessages .getResourceString(REFRESH)); try { //currentProject.refreshLocal(IResource.DEPTH_INFINITE, null); - + // use the refresh scope manager to refresh RefreshScopeManager refreshManager = RefreshScopeManager.getInstance(); IWorkspaceRunnable runnable = refreshManager.getRefreshRunnable(currentProject); @@ -1122,25 +1122,23 @@ public class GeneratedMakefileBuilder extends ACBuilder { errMsg = launcher.getErrorMessage(); } - // Report either the success or failure of our mission + // Report either the success or failure of our mission buf = new StringBuffer(); if (errMsg != null && errMsg.length() > 0) { - String errorDesc = ManagedMakeMessages.getResourceString(BUILD_ERROR); - buf.append(errorDesc).append(NEWLINE); - buf.append("(").append(errMsg).append(")"); //$NON-NLS-1$ //$NON-NLS-2$ + buf.append(errMsg).append(NEWLINE); } else { - // Report a successful build + // Report a successful build String successMsg = ManagedMakeMessages.getFormattedString(BUILD_FINISHED, currentProject.getName()); buf.append(successMsg).append(NEWLINE); } - // Write message on the console + // Write message on the console consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); epmOutputStream.close(); - // Generate any error markers that the build has discovered + // Generate any error markers that the build has discovered monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS)); addBuilderMarkers(epm); consoleOutStream.close(); @@ -1154,8 +1152,8 @@ public class GeneratedMakefileBuilder extends ACBuilder { /* (non-Javadoc) * Removes the IMarkers for the project specified in the argument if the - * project exists, and is open. - * + * project exists, and is open. + * * @param project */ private void removeAllMarkers(IProject project) { @@ -1179,31 +1177,31 @@ public class GeneratedMakefileBuilder extends ACBuilder { } } } - + /** * called to invoke the MBS Internal Builder for building the given configuration - * + * * @param cfg configuration to be built * @param buildIncrementaly if true, incremental build will be performed, * only files that need rebuild will be built. * If false, full rebuild will be performed * @param resumeOnErr if true, build will continue in case of error while building. - * If false the build will stop on the first error + * If false the build will stop on the first error * @param monitor monitor */ - protected void invokeInternalBuilder(IConfiguration cfg, + protected void invokeInternalBuilder(IConfiguration cfg, boolean buildIncrementaly, boolean resumeOnErr, IProgressMonitor monitor) { - + boolean isParallel = ((Configuration)cfg).getParallelDef(); - + // Get the project and make sure there's a monitor to cancel the build IProject currentProject = cfg.getOwner().getProject(); if (monitor == null) { monitor = new NullProgressMonitor(); } - + String[] msgs = new String[2]; msgs[0] = ManagedMakeMessages.getResourceString(INTERNAL_BUILDER); msgs[1] = currentProject.getName(); @@ -1214,14 +1212,14 @@ public class GeneratedMakefileBuilder extends ACBuilder { try { int flags = 0; IResourceDelta delta = null; - + if(buildIncrementaly){ flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS; delta = getDelta(currentProject); } - + IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, delta, flags); - + DescriptionBuilder builder = null; if (!isParallel) builder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr, null); @@ -1236,16 +1234,16 @@ public class GeneratedMakefileBuilder extends ACBuilder { consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_INC); else consoleHeader[0] = ManagedMakeMessages.getResourceString(TYPE_REBUILD); - + consoleHeader[1] = cfg.getName(); consoleHeader[2] = currentProject.getName(); buf.append(NEWLINE); buf.append(ManagedMakeMessages.getFormattedString(CONSOLE_HEADER, consoleHeader)).append(NEWLINE); buf.append(NEWLINE); - + buf.append(ManagedMakeMessages.getResourceString(INTERNAL_BUILDER_HEADER_NOTE)); buf.append("\n"); //$NON-NLS-1$ - + if(!cfg.isSupported()){ String msg = ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()}); buf.append(msg).append(NEWLINE); @@ -1253,31 +1251,31 @@ public class GeneratedMakefileBuilder extends ACBuilder { } consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); - + if(isParallel || builder.getNumCommands() > 0) { // Remove all markers for this project removeAllMarkers(currentProject); - + // Hook up an error parser manager - String[] errorParsers = cfg.getErrorParserList(); + String[] errorParsers = cfg.getErrorParserList(); ErrorParserManager epm = new ErrorParserManager(getProject(), des.getDefaultBuildDirLocationURI(), this, errorParsers); epm.setOutputStream(consoleOutStream); // This variable is necessary to ensure that the EPM stream stay open // until we explicitly close it. See bug#123302. epmOutputStream = epm.getOutputStream(); - + int status = 0; - + long t1 = System.currentTimeMillis(); if (isParallel) status = ParallelBuilder.build(des, null, null, epmOutputStream, epmOutputStream, monitor, resumeOnErr, buildIncrementaly); else status = builder.build(epmOutputStream, epmOutputStream, monitor); long t2 = System.currentTimeMillis(); - - // Report either the success or failure of our mission + + // Report either the success or failure of our mission buf = new StringBuffer(); - + switch(status){ case IBuildModelBuilder.STATUS_OK: buf.append(ManagedMakeMessages @@ -1289,7 +1287,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { .getResourceString(BUILD_CANCELLED)); break; case IBuildModelBuilder.STATUS_ERROR_BUILD: - String msg = resumeOnErr ? + String msg = resumeOnErr ? ManagedMakeMessages.getResourceString(BUILD_FINISHED_WITH_ERRS) : ManagedMakeMessages.getResourceString(BUILD_STOPPED_ERR); buf.append(msg); @@ -1301,7 +1299,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { break; } buf.append(NEWLINE); - + // Report time and number of threads used // buf.append("Time consumed: "); // buf.append(t2 - t1); @@ -1311,7 +1309,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { // buf.append(ParallelBuilder.lastThreadsUsed); // } // buf.append("\n"); - + // Report time and number of threads used buf.append(ManagedMakeMessages.getFormattedString("CommonBuilder.6", Integer.toString((int)(t2 - t1)))); //$NON-NLS-1$ // buf.append(t2 - t1); @@ -1322,12 +1320,12 @@ public class GeneratedMakefileBuilder extends ACBuilder { } buf.append(NEWLINE); - // Write message on the console + // Write message on the console consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); epmOutputStream.close(); epmOutputStream = null; - // Generate any error markers that the build has discovered + // Generate any error markers that the build has discovered monitor.subTask(ManagedMakeMessages.getResourceString(MARKERS)); addBuilderMarkers(epm); } else { @@ -1356,7 +1354,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { try { epmOutputStream.close(); } catch (IOException e) { - } + } } if(consoleOutStream != null){ try { @@ -1368,56 +1366,56 @@ public class GeneratedMakefileBuilder extends ACBuilder { monitor.done(); } } - + /** * Called to invoke the MBS Internal Builder for building the given resources in * the given configuration - * + * * This method is considered experimental. Clients implementing this API should expect * possible changes in the API. - * + * * @param resourcesToBuild resources to be built * @param cfg configuration to be built * @param buildIncrementaly if true, incremental build will be performed, * only files that need rebuild will be built. * If false, full rebuild will be performed * @param resumeOnErr if true, build will continue in case of error while building. - * If false the build will stop on the first error + * If false the build will stop on the first error * @param monitor Progress monitor. For every resource built this monitor will consume one unit of work. */ - public void invokeInternalBuilder(IResource[] resourcesToBuild, IConfiguration cfg, + public void invokeInternalBuilder(IResource[] resourcesToBuild, IConfiguration cfg, boolean buildIncrementaly, boolean resumeOnErr, boolean initNewConsole, boolean printFinishedMessage, IProgressMonitor monitor) { - + OutputStream epmOutputStream = null; // Get the project and make sure there's a monitor to cancel the build IProject currentProject = cfg.getOwner().getProject(); if (monitor == null) { monitor = new NullProgressMonitor(); } - + try { int flags = 0; IResourceDelta delta = null; - + if(buildIncrementaly){ flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED | BuildDescriptionManager.DEPS; delta = getDelta(currentProject); } - - + + String[] msgs = new String[2]; msgs[0] = ManagedMakeMessages.getResourceString(INTERNAL_BUILDER); msgs[1] = currentProject.getName(); if(initNewConsole) initNewBuildConsole(currentProject); - + StringBuffer buf = new StringBuffer(); - + if (initNewConsole) { String msg; if (buildIncrementaly) { @@ -1431,7 +1429,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { buf.append(ManagedMakeMessages.getResourceString(INTERNAL_BUILDER_HEADER_NOTE)).append(NEWLINE); } - + if(!cfg.isSupported()){ String msg = ManagedMakeMessages.getFormattedString(WARNING_UNSUPPORTED_CONFIGURATION,new String[] {cfg.getName(),cfg.getToolChain().getName()}); buf.append(msg).append(NEWLINE); @@ -1439,28 +1437,28 @@ public class GeneratedMakefileBuilder extends ACBuilder { } consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); - + // Remove all markers for this project // TODO remove only necessary markers removeAllMarkers(currentProject); - + IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, delta, flags); - + // Hook up an error parser manager - String[] errorParsers = cfg.getErrorParserList(); + String[] errorParsers = cfg.getErrorParserList(); ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocationURI(), this, errorParsers); epm.setOutputStream(consoleOutStream); // This variable is necessary to ensure that the EPM stream stay open // until we explicitly close it. See bug#123302. epmOutputStream = epm.getOutputStream(); - + boolean errorsFound = false; - + doneBuild: for (int k = 0; k < resourcesToBuild.length; k++) { IBuildResource buildResource = des .getBuildResource(resourcesToBuild[k]); -// step collector +// step collector Set dependentSteps = new HashSet(); // get dependent IO types @@ -1474,36 +1472,36 @@ public class GeneratedMakefileBuilder extends ACBuilder { } monitor.subTask(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildingFile") + resourcesToBuild[k].getProjectRelativePath()); //$NON-NLS-1$ - + // iterate through all build steps Iterator stepIter = dependentSteps.iterator(); - + while(stepIter.hasNext()) { IBuildStep step = stepIter.next(); - + StepBuilder stepBuilder = new StepBuilder(step, null); - + int status = stepBuilder.build(epmOutputStream, epmOutputStream, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); - - // Refresh the output resource without allowing the user to cancel. - // This is probably unkind, but short of this there is no way to ensure - // the UI is up-to-date with the build results + + // Refresh the output resource without allowing the user to cancel. + // This is probably unkind, but short of this there is no way to ensure + // the UI is up-to-date with the build results IBuildIOType[] outputIOTypes = step.getOutputIOTypes(); - + for(int j = 0; j < outputIOTypes.length; j++ ) { IBuildResource[] resources = outputIOTypes[j].getResources(); - + for(int i = 0; i < resources.length; i++) { IFile file = currentProject.getFile(resources[i].getLocation()); file.refreshLocal(IResource.DEPTH_INFINITE, null); } } - + // check status - + switch (status) { case IBuildModelBuilder.STATUS_OK: // don't print anything if the step was successful, @@ -1529,7 +1527,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { } } - + } // check status @@ -1537,7 +1535,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { buf = new StringBuffer(); buf.append(NEWLINE); - + if (printFinishedMessage) { if (errorsFound) { buf.append(ManagedMakeMessages.getResourceString(BUILD_FAILED_ERR)); @@ -1545,12 +1543,12 @@ public class GeneratedMakefileBuilder extends ACBuilder { buf.append(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.buildResourcesFinished")); //$NON-NLS-1$ } } - - // Write message on the console + + // Write message on the console consoleOutStream.write(buf.toString().getBytes()); consoleOutStream.flush(); - // Generate any error markers that the build has discovered + // Generate any error markers that the build has discovered addBuilderMarkers(epm); } catch (Exception e) { if(consoleOutStream != null){ @@ -1571,7 +1569,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { try { epmOutputStream.close(); } catch (IOException e) { - } + } } if(consoleOutStream != null){ try { @@ -1580,10 +1578,10 @@ public class GeneratedMakefileBuilder extends ACBuilder { } } getGenerationProblems().clear(); - monitor.done(); + monitor.done(); } } - + private void removeAllMarkers(IFile file) { IMarker[] markers; try { @@ -1604,7 +1602,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { } } } - + public void cleanFile(IFile file, IProgressMonitor monitor) { monitor.subTask(ManagedMakeMessages.getResourceString("GeneratedMakefileBuilder.0") //$NON-NLS-1$ @@ -1632,14 +1630,14 @@ public class GeneratedMakefileBuilder extends ACBuilder { int flags = BuildDescriptionManager.REBUILD | BuildDescriptionManager.REMOVED; IResourceDelta delta = getDelta(currentProject); - + try { IBuildDescription des = BuildDescriptionManager .createBuildDescription(cfg, delta, flags); IBuildResource buildResource = des.getBuildResource(file); - + if (buildResource != null) { // step collector @@ -1685,7 +1683,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { // TODO Auto-generated catch block e.printStackTrace(); } - + } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java index a68f8df415a..dd7c0d68023 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CommandLauncher.java @@ -35,6 +35,7 @@ public class CommandLauncher implements ICommandLauncher { public final static int OK = ICommandLauncher.OK; private static final String PATH_ENV = "PATH"; //$NON-NLS-1$ + private static final String NEWLINE = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ protected Process fProcess; protected boolean fShowCommand; @@ -42,8 +43,6 @@ public class CommandLauncher implements ICommandLauncher { private Properties fEnvironment = null; protected String fErrorMessage = ""; //$NON-NLS-1$ - - private String lineSeparator; private IProject fProject; /** @@ -59,7 +58,6 @@ public class CommandLauncher implements ICommandLauncher { public CommandLauncher() { fProcess = null; fShowCommand = false; - lineSeparator = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$ } /* (non-Javadoc) @@ -161,22 +159,17 @@ public class CommandLauncher implements ICommandLauncher { * @see org.eclipse.cdt.core.ICommandLauncher#execute(IPath, String[], String[], IPath, IProgressMonitor) */ @Override - public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory, IProgressMonitor monitor) throws CoreException { + public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) throws CoreException { + Boolean isFound = null; + String command = commandPath.toOSString(); + String envPathValue = (String) getEnvironment().get(PATH_ENV); try { - String command = commandPath.toOSString(); fCommandArgs = constructCommandArray(command, args); - fEnvironment = parseEnv(env); - - File file = null; - - if(changeToDirectory != null) - file = changeToDirectory.toFile(); - if (Platform.getOS().equals(Platform.OS_WIN32)) { // Handle cygwin link - String envPathValue = (String) getEnvironment().get(PATH_ENV); IPath location = PathUtil.findProgramLocation(command, envPathValue); - if(location != null) { + isFound = location != null; + if (location != null) { try { fCommandArgs[0] = Cygwin.cygwinToWindowsPath(location.toString(), envPathValue); } catch (Exception e) { @@ -185,11 +178,33 @@ public class CommandLauncher implements ICommandLauncher { } } - fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, file); + fEnvironment = parseEnv(env); + File dir = workingDirectory != null ? workingDirectory.toFile() : null; + + fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir); fCommandArgs[0] = command; // to print original command on the console fErrorMessage = ""; //$NON-NLS-1$ } catch (IOException e) { - setErrorMessage(e.getMessage()); + if (isFound == null) { + IPath location = PathUtil.findProgramLocation(command, envPathValue); + isFound = location != null; + } + + String errorMessage = getCommandLineQuoted(fCommandArgs, true); + String exMsg = e.getMessage(); + if (exMsg != null && !exMsg.isEmpty()) { + errorMessage = errorMessage + exMsg + NEWLINE; + } + + if (!isFound) { + if (envPathValue == null) { + envPathValue = System.getenv(PATH_ENV); + } + errorMessage = errorMessage + NEWLINE + + "Error: Program \"" + command + "\" not found in PATH" + NEWLINE + + "PATH=[" + envPathValue + "]" + NEWLINE; + } + setErrorMessage(errorMessage); fProcess = null; } return fProcess; @@ -254,23 +269,10 @@ public class CommandLauncher implements ICommandLauncher { return state; } - @SuppressWarnings("nls") protected void printCommandLine(OutputStream os) { if (os != null) { - StringBuffer buf = new StringBuffer(); - if (fCommandArgs != null) { - for (String commandArg : getCommandArgs()) { - if (commandArg.contains(" ") || commandArg.contains("\"") || commandArg.contains("\\")) { - commandArg = '"' + commandArg.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\"") + '"'; - } - buf.append(commandArg); - buf.append(' '); - } - buf.append(lineSeparator); - } - try { - os.write(buf.toString().getBytes()); + os.write(getCommandLineQuoted(getCommandArgs(), true).getBytes()); os.flush(); } catch (IOException e) { // ignore; @@ -278,18 +280,26 @@ public class CommandLauncher implements ICommandLauncher { } } - protected String getCommandLine(String[] commandArgs) { + @SuppressWarnings("nls") + private String getCommandLineQuoted(String[] commandArgs, boolean quote) { StringBuffer buf = new StringBuffer(); - if (fCommandArgs != null) { + if (commandArgs != null) { for (String commandArg : commandArgs) { + if (quote && (commandArg.contains(" ") || commandArg.contains("\"") || commandArg.contains("\\"))) { + commandArg = '"' + commandArg.replaceAll("\\\\", "\\\\\\\\").replaceAll("\"", "\\\\\"") + '"'; + } buf.append(commandArg); buf.append(' '); } - buf.append(lineSeparator); + buf.append(NEWLINE); } return buf.toString(); } + protected String getCommandLine(String[] commandArgs) { + return getCommandLineQuoted(commandArgs, false); + } + /** * @since 5.1 diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncher.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncher.java index e0f94d4f315..d6dc229aa41 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncher.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ICommandLauncher.java @@ -55,6 +55,7 @@ public interface ICommandLauncher { * execution. * * @return A String corresponding to the error, or null if there has been no error. + * The message could be multi-line, however it is NOT guaranteed that it ends with end of line. */ public String getErrorMessage(); @@ -95,7 +96,7 @@ public interface ICommandLauncher { * @param env The list of environment variables in variable=value format. * @throws CoreException if there is an error executing the command. */ - public Process execute(IPath commandPath, String[] args, String[] env, IPath changeToDirectory, IProgressMonitor monitor) throws CoreException; + public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) throws CoreException; /** * Reads output form the process to the streams.