diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/IBuildDescription.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/IBuildDescription.java index 72272144d20..cc33a61de62 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/IBuildDescription.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/buildmodel/IBuildDescription.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.buildmodel; +import java.net.URI; + import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; @@ -77,10 +79,20 @@ public interface IBuildDescription { /** * Returns the default build directory location - * * @return IPath */ IPath getDefaultBuildDirLocation(); + /** + * Returns the default build directory location URI + * @return URI build dir location or null if one couldn't be found + * @since 6.0 + */ + URI getDefaultBuildDirLocationURI(); + + /** + * The Workspace FullPath of the build directory + * @return + */ IPath getDefaultBuildDirFullPath(); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index 4483b03c7b7..62f4fc0ffde 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -16,6 +16,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; @@ -126,6 +127,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.PluginVersionIdentifier; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.URIUtil; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.swt.widgets.Shell; @@ -4103,7 +4105,34 @@ public class ManagedBuildManager extends AbstractCExtension { } return buildDirectory; } - + + /** + * Return the Build Location URI or null if one couldn't be found + * @param cfg + * @param builder + * @return build location URI or null if one couldn't be found + * @since 6.0 + */ + public static URI getBuildLocationURI(IConfiguration cfg, IBuilder builder) { + if(cfg.getOwner() == null) + return null; + + IProject project = cfg.getOwner().getProject(); + IPath buildDirectory = builder.getBuildLocation(); + if (buildDirectory != null && !buildDirectory.isEmpty()) { + IResource res = project.getParent().findMember(buildDirectory); + if (res instanceof IContainer && res.exists()) { + return res.getLocationURI(); + } + } else { + URI uri = project.getLocationURI(); + if (buildDirectory != null && builder.isManagedBuildOn()) + return URIUtil.append(uri, cfg.getName()); + return uri; + } + return org.eclipse.core.filesystem.URIUtil.toURI(buildDirectory); + } + private static IPath getPathForResource(IResource resource) { return new Path(resource.getLocationURI().getPath()); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java index 05edfea353a..60060654f3e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildmodel/BuildDescription.java @@ -1013,7 +1013,12 @@ public class BuildDescription implements IBuildDescription { IPath projLocation = getProjectLocation(); return projLocation.append(getTopBuildDirFullPath().removeFirstSegments(1)); } - + + private URI getTopBuildDirLocationURI(){ + return org.eclipse.core.runtime.URIUtil.makeAbsolute(URIUtil.toURI(getTopBuildDirFullPath().removeFirstSegments(1)), + fProject.getLocationURI()); + } + private IPath getProjectLocation() { return new Path(fProject.getLocationURI().getPath()); } @@ -2225,6 +2230,10 @@ public class BuildDescription implements IBuildDescription { return getTopBuildDirLocation(); } + public URI getDefaultBuildDirLocationURI() { + return getTopBuildDirLocationURI(); + } + public IPath getDefaultBuildDirFullPath() { return getTopBuildDirFullPath(); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java index 6d5356386eb..23657033760 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/CommonBuilder.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.managedbuilder.internal.core; import java.io.IOException; import java.io.OutputStream; +import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -1011,7 +1012,7 @@ public class CommonBuilder extends ACBuilder { // Hook up an error parser manager String[] errorParsers = builder.getErrorParsers(); - ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocation(), this, errorParsers); + 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. @@ -1227,7 +1228,7 @@ public class CommonBuilder extends ACBuilder { // Hook up an error parser manager String[] errorParsers = cfg.getErrorParserList(); - ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocation(), this, errorParsers); + 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. @@ -1928,6 +1929,7 @@ public class CommonBuilder extends ACBuilder { removeAllMarkers(currProject); IPath workingDirectory = ManagedBuildManager.getBuildLocation(cfg, builder); + URI workingDirectoryURI = ManagedBuildManager.getBuildLocationURI(cfg, builder); String[] targets = getTargets(kind, builder); if (targets.length != 0 && targets[targets.length - 1].equals(builder.getCleanBuildTarget())) //$NON-NLS-1$ @@ -1957,7 +1959,7 @@ public class CommonBuilder extends ACBuilder { last = new Integer(100); } StreamMonitor streamMon = new StreamMonitor(new SubProgressMonitor(monitor, 100), cos, last.intValue()); - ErrorParserManager epm = new ErrorParserManager(currProject, workingDirectory, this, builder.getErrorParsers()); + ErrorParserManager epm = new ErrorParserManager(currProject, workingDirectoryURI, this, builder.getErrorParsers()); epm.setOutputStream(streamMon); OutputStream stdout = epm.getOutputStream(); OutputStream stderr = epm.getOutputStream(); 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 bb4d6a4d0fa..180ad899bfa 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 @@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.internal.core; import java.io.IOException; import java.io.OutputStream; +import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -64,6 +65,7 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.core.runtime.URIUtil; /** * This is the incremental builder associated with a managed build project. It dynamically @@ -874,6 +876,8 @@ public class GeneratedMakefileBuilder extends ACBuilder { try { // Figure out the working directory for the build and make sure there is a makefile there IPath workingDirectory = getWorkingDirectory().append(buildDir); + final URI workingDirectoryURI = URIUtil.append(getProject().getLocationURI(), buildDir.toOSString()); + IWorkspace workspace = currentProject.getWorkspace(); if (workspace == null) { return; @@ -964,7 +968,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { // Hook up an error parser manager String[] errorParsers = info.getDefaultConfiguration().getErrorParserList(); - ErrorParserManager epm = new ErrorParserManager(getProject(), workingDirectory, this, errorParsers); + 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. @@ -1262,7 +1266,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { // Hook up an error parser manager String[] errorParsers = cfg.getErrorParserList(); - ErrorParserManager epm = new ErrorParserManager(getProject(), des.getDefaultBuildDirLocation(), this, errorParsers); + 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. @@ -1455,7 +1459,7 @@ public class GeneratedMakefileBuilder extends ACBuilder { // Hook up an error parser manager String[] errorParsers = cfg.getErrorParserList(); - ErrorParserManager epm = new ErrorParserManager(currentProject, des.getDefaultBuildDirLocation(), this, errorParsers); + 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.