1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

patch from Tianchao Li to fix bug # 136136

This commit is contained in:
David Inglis 2006-05-25 14:33:29 +00:00
parent f721770c5e
commit 634cd9cbf1
12 changed files with 217 additions and 204 deletions

View file

@ -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$

View file

@ -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;
}
}

View file

@ -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);
}

View file

@ -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());

View file

@ -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;

View file

@ -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});

View file

@ -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);
}

View file

@ -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);

View file

@ -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

View file

@ -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);

View file

@ -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,7 +47,6 @@ 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_CONSOLE_ID = MakeCorePlugin.getUniqueIdentifier() + ".ExternalScannerInfoProviderConsole"; //$NON-NLS-1$
private static final String LANG_ENV_VAR = "LANG"; //$NON-NLS-1$
@ -155,6 +152,7 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
return true;
}
/**
* Initialization of protected fields.
* Subclasses are most likely to override default implementation.
@ -165,31 +163,13 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
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.
@ -239,10 +219,10 @@ public class DefaultRunSIProvider implements IExternalScannerInfoProvider {
Enumeration names = props.propertyNames();
if (names != null) {
while (names.hasMoreElements()) {
String key = (String)names.nextElement();
String key = (String) names.nextElement();
envList.add(key + "=" + props.getProperty(key)); //$NON-NLS-1$
}
env = (String[])envList.toArray(new String[envList.size()]);
env = (String[]) envList.toArray(new String[envList.size()]);
}
return env;
}

View file

@ -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);