diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java index 387e07ea8c8..d6feb81fd49 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/language/settings/providers/AbstractBuiltinSpecsDetector.java @@ -326,9 +326,9 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti @Override protected URI getBuildDirURI(URI mappedRootURI) { - // Do not calculate buildDirURI for each line if (buildDirURI == null) { - buildDirURI = super.getBuildDirURI(mappedRootURI); + // do not use build directory from MBS which could be not-existent when the provider runs + buildDirURI = currentProject != null ? currentProject.getLocationURI() : null; } return buildDirURI; } @@ -353,7 +353,7 @@ public abstract class AbstractBuiltinSpecsDetector extends AbstractLanguageSetti super.startup(cfgDescription, cwdTracker); mappedRootURI = null; - buildDirURI = super.getBuildDirURI(mappedRootURI); + buildDirURI = getBuildDirURI(mappedRootURI); } @Override diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 42387484aef..22a22903a2e 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -1331,6 +1331,34 @@ public class CCorePlugin extends Plugin { log(createStatus(e)); } + /** + * Print a message in the log + * + * @param severity - desired severity of the message in the log, + * one of {@link IStatus#INFO}, {@link IStatus#WARNING} or {@link IStatus#ERROR} + * @param msg - message + * + * @since 5.5 + * @noreference This method is not intended to be referenced by clients. + */ + public static void log(int severity, String msg) { + log(new Status(severity, PLUGIN_ID, msg)); + } + + /** + * Print a message in the log accompanied by stack trace + * + * @param severity - desired severity of the message in the log, + * one of {@link IStatus#INFO}, {@link IStatus#WARNING} or {@link IStatus#ERROR} + * @param msg - message + * + * @since 5.5 + * @noreference This method is not intended to be referenced by clients. + */ + public static void logStackTrace(int severity, String msg) { + log(new Status(severity, PLUGIN_ID, msg, new Exception())); + } + /** * @noreference This method is not intended to be referenced by clients. */ 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 a5e0555717e..b93f723cb34 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 @@ -25,6 +25,7 @@ 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.IStatus; import org.eclipse.core.runtime.Platform; import org.eclipse.osgi.util.NLS; @@ -184,6 +185,10 @@ public class CommandLauncher implements ICommandLauncher { } File dir = workingDirectory != null ? workingDirectory.toFile() : null; + if (dir != null && !dir.isDirectory()) { + CCorePlugin.logStackTrace(IStatus.ERROR, NLS.bind(Messages.CommandLauncher_InvalidWorkingDirectory, dir)); + dir = null; + } try { fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir); diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java index 56fead20b7e..c63c806cecb 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/Messages.java @@ -17,6 +17,7 @@ public class Messages extends NLS { public static String Util_unexpectedError; public static String Addr_valueOutOfRange; public static String CommandLauncher_CommandCancelled; + public static String CommandLauncher_InvalidWorkingDirectory; public static String CommandLauncher_ProgramNotFoundInPath; public static String convention_illegalIdentifier; public static String convention_invalid; diff --git a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties index 9c51cb755e7..0dcb682ba7b 100644 --- a/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties +++ b/core/org.eclipse.cdt.core/utils/org/eclipse/cdt/internal/core/messages.properties @@ -48,6 +48,7 @@ Util_unexpectedError=Unexpected error Addr_valueOutOfRange=Address is outside valid range. CommandLauncher_CommandCancelled=Command canceled +CommandLauncher_InvalidWorkingDirectory=Launch attempt in non existent working directory "{0}" CommandLauncher_ProgramNotFoundInPath=Error: Program "{0}" not found in PATH XmlUtil_InternalErrorLoading=Internal error while trying to load XML document