Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authorDavid Inglis2006-05-25 14:33:29 +0000
committerDavid Inglis2006-05-25 14:33:29 +0000
commit634cd9cbf1ad5299122fe1b7f36e53ea269864d5 (patch)
treef08393e77a8354266b4f08c6a8833b23cf9ea80a /build
parentf721770c5ef696c48b7cfe27e811ae2d85b67189 (diff)
downloadorg.eclipse.cdt-634cd9cbf1ad5299122fe1b7f36e53ea269864d5.tar.gz
org.eclipse.cdt-634cd9cbf1ad5299122fe1b7f36e53ea269864d5.tar.xz
org.eclipse.cdt-634cd9cbf1ad5299122fe1b7f36e53ea269864d5.zip
patch from Tianchao Li to fix bug # 136136
Diffstat (limited to 'build')
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilder.java15
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilderUtil.java49
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java4
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java8
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java1
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java8
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java8
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java5
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java3
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java7
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultRunSIProvider.java298
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java25
12 files changed, 222 insertions, 209 deletions
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 21a81605cfd..90310522913 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 QNX Software Systems and others.
+ * Copyright (c) 2000, 2005, 2006 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -29,7 +29,6 @@ import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
import org.eclipse.cdt.make.internal.core.MakeMessages;
import org.eclipse.cdt.make.internal.core.StreamMonitor;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -121,6 +120,8 @@ public class MakeBuilder extends ACBuilder {
}
}
+
+
protected boolean invokeMake(int kind, IMakeBuilderInfo info, IProgressMonitor monitor) {
boolean isClean = false;
IProject currProject = getProject();
@@ -141,15 +142,7 @@ public class MakeBuilder extends ACBuilder {
// remove all markers for this project
removeAllMarkers(currProject);
- IPath workingDirectory = info.getBuildLocation();
- if (!workingDirectory.isEmpty()) {
- IResource res = currProject.getParent().findMember(workingDirectory);
- if (res instanceof IContainer && res.exists()) {
- workingDirectory = res.getLocation();
- }
- } else {
- workingDirectory = currProject.getLocation();
- }
+ IPath workingDirectory = MakeBuilderUtil.getBuildDirectory(currProject, info);
String[] targets = getTargets(kind, info);
if (targets.length != 0 && targets[targets.length - 1].equals(info.getCleanBuildTarget())) //$NON-NLS-1$
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilderUtil.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilderUtil.java
new file mode 100644
index 00000000000..a95a8eec695
--- /dev/null
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuilderUtil.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2006 QNX Software Systems and others.
+ * All rights reserved. This program and the accompanying materials
+ * 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:
+ * QNX Software Systems - Initial implementation
+ * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
+ *******************************************************************************/
+package org.eclipse.cdt.make.core;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+public class MakeBuilderUtil {
+
+ public static IPath getBuildDirectory(IProject project, IPath subPath, String builderID) {
+ IPath rootPath = getBuildDirectory(project, builderID);
+ return rootPath.append(subPath);
+ }
+
+ public static IPath getBuildDirectory(IProject project, String builderID) {
+ IMakeBuilderInfo info;
+ try {
+ info = MakeCorePlugin.createBuildInfo(project, builderID);
+ } catch (CoreException e) {
+ return project.getLocation();
+ }
+ return getBuildDirectory(project, info);
+ }
+
+ public static IPath getBuildDirectory(IProject project, IMakeBuilderInfo info) {
+ IPath buildDirectory = info.getBuildLocation();
+ if (!buildDirectory.isEmpty()) {
+ IResource res = project.getParent().findMember(buildDirectory);
+ if (res instanceof IContainer && res.exists()) {
+ buildDirectory = res.getLocation();
+ }
+ } else {
+ buildDirectory = project.getLocation();
+ }
+ return buildDirectory;
+ }
+}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
index 0089d2bd60a..9cfcd3c0a3d 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/scannerconfig/ScannerConfigBuilder.java
@@ -41,7 +41,7 @@ public class ScannerConfigBuilder extends ACBuilder {
*/
protected IProject [] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
// If auto discovery is disabled, do nothing
- boolean autodiscoveryEnabled;
+// boolean autodiscoveryEnabled;
boolean autodiscoveryEnabled2;
IScannerConfigBuilderInfo2 buildInfo2 = null;
try {
@@ -72,7 +72,7 @@ public class ScannerConfigBuilder extends ACBuilder {
}
catch (CoreException e) {
// builder not installed or disabled
- autodiscoveryEnabled = false;
+// autodiscoveryEnabled = false;
autodiscoveryEnabled2 = false;
MakeCorePlugin.log(e);
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java
index 86cea6b6405..bf3516c4525 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 QNX Software Systems and others.
+ * Copyright (c) 2000, 2005, 2006 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
*******************************************************************************/
package org.eclipse.cdt.make.internal.core;
@@ -14,6 +15,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import org.eclipse.cdt.make.core.MakeBuilderUtil;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.IMakeTarget;
@@ -171,7 +173,7 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
}
public IPath getBuildLocation() {
- return container.getLocation();
+ return MakeBuilderUtil.getBuildDirectory(container.getProject(), container.getProjectRelativePath(), manager.getBuilderID(targetBuilderID));
}
public void setBuildLocation(IPath location) throws CoreException {
@@ -292,7 +294,7 @@ public class MakeTarget extends PlatformObject implements IMakeTarget {
info.setEnvironment(getExpandedEnvironment());
info.setAppendEnvironment(appendEnvironment());
if (container != null) {
- info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, container.getFullPath().toString());
+ info.setBuildAttribute(IMakeCommonBuildInfo.BUILD_LOCATION, getBuildLocation().toString());
}
IMakeBuilderInfo projectInfo = MakeCorePlugin.createBuildInfo(getProject(), builderID);
info.setErrorParsers(projectInfo.getErrorParsers());
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
index e60357b2b8e..6253d927075 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/DiscoveredPathManager.java
@@ -18,7 +18,6 @@ import java.util.List;
import java.util.Map;
import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.model.CModelException;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.PathEntryContainerChanged;
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
index 506673ca5ee..e72c2475f7f 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/ScannerInfoConsoleParserFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2005, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
*******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig;
@@ -14,6 +15,8 @@ import java.io.OutputStream;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
+import org.eclipse.cdt.make.core.MakeBuilderUtil;
+import org.eclipse.cdt.make.core.MakeBuilder;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
@@ -58,7 +61,8 @@ public class ScannerInfoConsoleParserFactory {
SCProfileInstance profileInstance = ScannerConfigProfileManager.getInstance().
getSCProfileInstance(currentProject, scBuildInfo.getSelectedProfileId());
IScannerInfoConsoleParser clParser = profileInstance.createExternalScannerInfoParser(providerId);
- clParser.startup(currentProject, currentProject.getLocation(), collector, markerGenerator);
+ IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(currentProject, MakeBuilder.BUILDER_ID);
+ clParser.startup(currentProject, buildDirectory, collector, markerGenerator);
// create an output stream sniffer
return new ConsoleOutputSniffer(outputStream, errorStream, new
IScannerInfoConsoleParser[] {clParser});
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java
index a365051cff6..fd9ec4ec499 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/GCCPerFileBOPConsoleParser.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2005, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
*******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
@@ -146,13 +147,14 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
}
CCommandDSC cmd = fUtil.getNewCCommandDSC(genericLine.toString(), extensionsIndex > 0);
- if (getProject().getLocation().isPrefixOf(pFilePath)) {
+ IPath buildDirectory = fUtil.getWorkingDirectory();
+ if (buildDirectory.isPrefixOf(pFilePath)) {
List cmdList = new ArrayList();
cmdList.add(cmd);
Map sc = new HashMap(1);
sc.put(ScannerInfoTypes.COMPILER_COMMAND, cmdList);
- IPath relPath = pFilePath.removeFirstSegments(getProject().getLocation().segmentCount());
+ IPath relPath = pFilePath.removeFirstSegments(buildDirectory.segmentCount());
IFile file = getProject().getFile(relPath);
getCollector().contributeToScannerConfig(file, sc);
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java
index 93b9cb1c7ce..231861dc4ce 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/gnu/ScannerInfoConsoleParserUtility.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2005, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
*******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig.gnu;
@@ -189,7 +190,7 @@ public class ScannerInfoConsoleParserUtility extends AbstractGCCBOPConsoleParser
// First try the current working directory
IPath cwd = getWorkingDirectory();
if (!cwd.isAbsolute()) {
- cwd = getProject().getLocation().append(cwd);
+ cwd = getBaseDirectory().append(cwd);
}
IPath filePath = new Path(fileName);
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java
index a8420244ecc..f32187a7e6d 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/jobs/BuildOutputReaderJob.java
@@ -28,11 +28,8 @@ import org.eclipse.core.runtime.jobs.Job;
public class BuildOutputReaderJob extends Job {
private static final String JOB_NAME = "Build Output Reader"; //$NON-NLS-1$
- private String inputFileName;
-
private IResource resource;
private IScannerConfigBuilderInfo2 buildInfo;
- private boolean rc;
/**
* @param project
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java
index f08bc270b2f..ec151453a3d 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig/util/SymbolEntry.java
@@ -70,9 +70,10 @@ public class SymbolEntry {
public void replace(String value, boolean active) {
values.put(value, Boolean.valueOf(active));
}
- private void addAll(SymbolEntry se) {
- values.putAll(se.values);
- }
+
+// private void addAll(SymbolEntry se) {
+// values.putAll(se.values);
+// }
public void remove(String value) {
values.remove(value);
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 d4e9773137a..5f455a24a36 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2005, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -22,8 +22,8 @@ import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.MakeBuilder;
+import org.eclipse.cdt.make.core.MakeBuilderUtil;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
@@ -33,10 +33,8 @@ 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.make.internal.core.scannerconfig.util.TraceUtil;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
@@ -49,202 +47,184 @@ import org.eclipse.core.runtime.SubProgressMonitor;
* @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 EXTERNAL_SI_PROVIDER_ERROR = "ExternalScannerInfoProvider.Provider_Error"; //$NON-NLS-1$
private static final String EXTERNAL_SI_PROVIDER_CONSOLE_ID = MakeCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
- private static final String LANG_ENV_VAR = "LANG"; //$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;
-
- private SCMarkerGenerator markerGenerator = new SCMarkerGenerator();
+ private static final String LANG_ENV_VAR = "LANG"; //$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;
+
+ private SCMarkerGenerator markerGenerator = new SCMarkerGenerator();
/* (non-Javadoc)
* @see org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider#invokeProvider(org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.resources.IResource, java.lang.String, org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2, org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector2)
- */
+ */
public boolean invokeProvider(IProgressMonitor monitor,
IResource resource,
String providerId,
IScannerConfigBuilderInfo2 buildInfo,
IScannerInfoCollector collector) {
- // 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$
-
- try {
- IConsole console = CCorePlugin.getDefault().getConsole(EXTERNAL_SI_PROVIDER_CONSOLE_ID);
- 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$
-
- String errMsg = null;
- CommandLauncher launcher = new CommandLauncher();
- // Print the command for visual interaction.
- launcher.showCommand(true);
-
- // add additional arguments
- // subclass can change default behavior
+ // 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$
+
+ try {
+ IConsole console = CCorePlugin.getDefault().getConsole(EXTERNAL_SI_PROVIDER_CONSOLE_ID);
+ 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$
+
+ String errMsg = null;
+ CommandLauncher launcher = new CommandLauncher();
+ // Print the command for visual interaction.
+ launcher.showCommand(true);
+
+ // add additional arguments
+ // subclass can change default behavior
String[] compileArguments = prepareArguments(
buildInfo.isUseDefaultProviderCommand(providerId));
- String ca = coligate(compileArguments);
-
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Invoking_Command") //$NON-NLS-1$
- + fCompileCommand.toString() + ca);
- cos = new StreamMonitor(new SubProgressMonitor(monitor, 70), cos, 100);
+ String ca = coligate(compileArguments);
+ monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Invoking_Command") //$NON-NLS-1$
+ + fCompileCommand.toString() + ca);
+ cos = new StreamMonitor(new SubProgressMonitor(monitor, 70), cos, 100);
+
ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.getESIProviderOutputSniffer(
cos, cos, currentProject, providerId, buildInfo, collector, markerGenerator);
- OutputStream consoleOut = (sniffer == null ? cos : sniffer.getOutputStream());
- OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream());
- TraceUtil.outputTrace("Default provider is executing command:", fCompileCommand.toString() + ca, ""); //$NON-NLS-1$ //$NON-NLS-2$
- Process p = launcher.execute(fCompileCommand, compileArguments, setEnvironment(launcher), fWorkingDirectory);
- 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)) != CommandLauncher.OK) {
- errMsg = launcher.getErrorMessage();
- }
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Parsing_Output")); //$NON-NLS-1$
+ OutputStream consoleOut = (sniffer == null ? cos : sniffer.getOutputStream());
+ OutputStream consoleErr = (sniffer == null ? cos : sniffer.getErrorStream());
+ TraceUtil.outputTrace("Default provider is executing command:", fCompileCommand.toString() + ca, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ Process p = launcher.execute(fCompileCommand, compileArguments, setEnvironment(launcher), fWorkingDirectory);
+ 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)) != CommandLauncher.OK) {
+ errMsg = launcher.getErrorMessage();
+ }
+ monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Parsing_Output")); //$NON-NLS-1$
}
else {
- errMsg = launcher.getErrorMessage();
- }
+ errMsg = launcher.getErrorMessage();
+ }
- if (errMsg != null) {
+ if (errMsg != null) {
String errorDesc = MakeMessages.getFormattedString(EXTERNAL_SI_PROVIDER_ERROR,
fCompileCommand.toString() + ca);
- markerGenerator.addMarker(currentProject, -1, errorDesc, IMarkerGenerator.SEVERITY_WARNING, null);
- }
+ markerGenerator.addMarker(currentProject, -1, errorDesc, IMarkerGenerator.SEVERITY_WARNING, null);
+ }
- monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Creating_Markers")); //$NON-NLS-1$
- consoleOut.close();
- consoleErr.close();
- cos.close();
+ monitor.subTask(MakeMessages.getString("ExternalScannerInfoProvider.Creating_Markers")); //$NON-NLS-1$
+ consoleOut.close();
+ consoleErr.close();
+ cos.close();
}
catch (Exception e) {
- CCorePlugin.log(e);
+ CCorePlugin.log(e);
}
finally {
- monitor.done();
- }
- return true;
- }
+ monitor.done();
+ }
+ return true;
+ }
+
- /**
+ /**
* Initialization of protected fields.
* Subclasses are most likely to override default implementation.
- *
- * @param currentProject
- * @return boolean
- */
- protected boolean initialize() {
+ *
+ * @param currentProject
+ * @return boolean
+ */
+ protected boolean initialize() {
IProject currProject = resource.getProject();
- IPath workingDirectory = null;
- try {
- IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(resource.getProject(), MakeBuilder.BUILDER_ID);
- workingDirectory = info.getBuildLocation();
- if (!workingDirectory.isEmpty()) {
- IResource res = currProject.getParent().findMember(workingDirectory);
- if (res instanceof IContainer && res.exists()) {
- workingDirectory = res.getLocation();
- }
- }
- } catch (CoreException e) {
- // TODO - FIXME
- // ignore, we need to change this so that the correct
- // working directory can be provided
- }
- if (workingDirectory == null || workingDirectory.isEmpty()) {
- workingDirectory = currProject.getLocation();
- }
-
- // fWorkingDirectory = resource.getProject().getLocation();
- fWorkingDirectory = workingDirectory;
+ //fWorkingDirectory = resource.getProject().getLocation();
+ fWorkingDirectory = MakeBuilderUtil.getBuildDirectory(currProject, MakeBuilder.BUILDER_ID);
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.
- *
- * @param isDefaultCommand
- * @param collector
- * @return
- */
- protected String[] prepareArguments(boolean isDefaultCommand) {
- return fCompileArguments;
- }
-
- /**
- * @param array
- * @return
- */
- 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;
- }
-
- /**
- * @param launcher
- * @return
- */
- protected String[] setEnvironment(CommandLauncher launcher) {
- // Set the environmennt, some scripts may need the CWD var to be set.
- Properties props = launcher.getEnvironment();
- props.put("CWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
- props.put("PWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
+ *
+ * @param isDefaultCommand
+ * @param collector
+ * @return
+ */
+ protected String[] prepareArguments(boolean isDefaultCommand) {
+ return fCompileArguments;
+ }
+
+ /**
+ * @param array
+ * @return
+ */
+ 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;
+ }
+
+ /**
+ * @param launcher
+ * @return
+ */
+ protected String[] setEnvironment(CommandLauncher launcher) {
+ // Set the environmennt, some scripts may need the CWD var to be set.
+ Properties props = launcher.getEnvironment();
+ props.put("CWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
+ props.put("PWD", fWorkingDirectory.toOSString()); //$NON-NLS-1$
// On POSIX (Linux, UNIX) systems reset LANG variable to English with UTF-8 encoding
// since GNU compilers can handle only UTF-8 characters. English language is chosen
// beacuse GNU compilers inconsistently handle different locales when generating
// output of the 'gcc -v' command. Include paths with locale characters will be
// handled properly regardless of the language as long as the encoding is set to UTF-8.
- if (props.containsKey(LANG_ENV_VAR)) {
- props.put(LANG_ENV_VAR, "en_US.UTF-8"); //$NON-NLS-1$
- }
- 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 = (String[])envList.toArray(new String[envList.size()]);
- }
- return env;
- }
+ if (props.containsKey(LANG_ENV_VAR)) {
+ props.put(LANG_ENV_VAR, "en_US.UTF-8"); //$NON-NLS-1$
+ }
+ 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 = (String[]) envList.toArray(new String[envList.size()]);
+ }
+ return env;
+ }
}
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java
index 8aeea5d67a1..16f39b19c6a 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/scannerconfig2/DefaultSIFileReader.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2005, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
*******************************************************************************/
package org.eclipse.cdt.make.internal.core.scannerconfig2;
@@ -21,14 +22,13 @@ import java.io.OutputStream;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.resources.IConsole;
import org.eclipse.cdt.internal.core.ConsoleOutputSniffer;
-import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.MakeBuilder;
+import org.eclipse.cdt.make.core.MakeBuilderUtil;
import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.scannerconfig.IExternalScannerInfoProvider;
import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2;
import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector;
import org.eclipse.cdt.make.internal.core.scannerconfig.ScannerInfoConsoleParserFactory;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -64,7 +64,7 @@ public class DefaultSIFileReader implements IExternalScannerInfoProvider {
// output
IConsole console = CCorePlugin.getDefault().getConsole(EXTERNAL_SI_PROVIDER_CONSOLE_ID);
console.start(project);
- OutputStream ostream, cos;
+ OutputStream ostream;
try {
ostream = console.getOutputStream();
}
@@ -73,22 +73,7 @@ public class DefaultSIFileReader implements IExternalScannerInfoProvider {
}
// get build location
- IPath buildDirectory = null;
- try {
- IMakeBuilderInfo makeInfo = MakeCorePlugin.createBuildInfo(project, MakeBuilder.BUILDER_ID);
- if (!makeInfo.getBuildLocation().isEmpty()) {
- IResource res = project.getParent().findMember(makeInfo.getBuildLocation());
- if (res instanceof IContainer && res.exists()) {
- buildDirectory = res.getLocation();
- }
- }
- if (buildDirectory == null) {
- buildDirectory = project.getLocation();
- }
- }
- catch (CoreException e) {
- MakeCorePlugin.log(e);
- }
+ IPath buildDirectory = MakeBuilderUtil.getBuildDirectory(project, MakeBuilder.BUILDER_ID);
ConsoleOutputSniffer sniffer = ScannerInfoConsoleParserFactory.
getMakeBuilderOutputSniffer(ostream, null, project, buildDirectory, buildInfo, markerGenerator, collector);

Back to the top