mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 06:32:10 +02:00
Fix for [Bug 162143] [MBS] Internal builder forgets about deltas when failures occur
This commit is contained in:
parent
2fac395f97
commit
40e01a45ce
23 changed files with 915 additions and 49 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation and others.
|
||||
* Copyright (c) 2006, 2007 Intel 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
|
||||
|
@ -21,10 +21,9 @@ import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildMultiStatus;
|
|||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStatus;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DbgUtil;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DefaultBuildDescriptionFactory;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.IConfigurationBuildState;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceDelta;
|
||||
import org.eclipse.core.resources.IWorkspace;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -95,6 +94,13 @@ public class BuildDescriptionManager {
|
|||
return DefaultBuildDescriptionFactory.getInstance().createBuildDescription(cfg, delta, flags);
|
||||
}
|
||||
|
||||
static public IBuildDescription createBuildDescription(IConfiguration cfg,
|
||||
IConfigurationBuildState bs,
|
||||
IResourceDelta delta,
|
||||
int flags) throws CoreException {
|
||||
return DefaultBuildDescriptionFactory.getInstance().createBuildDescription(cfg, bs, delta, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs though all steps in build description in the dependency order
|
||||
* and notifies the visitor callback
|
||||
|
|
|
@ -14,6 +14,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStateManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DbgUtil;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.GeneratedMakefileBuilder;
|
||||
|
@ -97,6 +98,8 @@ public class ManagedBuilderCorePlugin extends Plugin {
|
|||
| IResourceChangeEvent.PRE_DELETE
|
||||
| IResourceChangeEvent.PRE_CLOSE
|
||||
/*| IResourceChangeEvent.POST_BUILD*/);
|
||||
|
||||
BuildStateManager.getInstance().startup();
|
||||
/* try {
|
||||
jobManager.beginRule(root, null);
|
||||
|
||||
|
@ -165,6 +168,8 @@ public class ManagedBuilderCorePlugin extends Plugin {
|
|||
* @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
BuildStateManager.getInstance().shutdown();
|
||||
|
||||
CfgDiscoveredPathManager.stop();
|
||||
// if (fDiscoveryPathManager != null) {
|
||||
// fDiscoveryPathManager.shutdown();
|
||||
|
|
|
@ -87,6 +87,7 @@ public class BuildDescription implements IBuildDescription {
|
|||
|
||||
private Configuration fCfg;
|
||||
private IResourceDelta fDelta;
|
||||
private IConfigurationBuildState fBuildState;
|
||||
|
||||
private Map fToolToMultiStepMap = new HashMap();
|
||||
private BuildStep fOrderedMultiActions[];
|
||||
|
@ -235,14 +236,15 @@ public class BuildDescription implements IBuildDescription {
|
|||
IPath rcLocation = rc.getLocation();
|
||||
if(rcLocation == null){
|
||||
IPath fullPath = rc.getFullPath();
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject proj = root.getProject(fullPath.segment(0));
|
||||
rcLocation = proj.getLocation();
|
||||
if(rcLocation != null){
|
||||
rcLocation = rcLocation.append(fullPath.removeFirstSegments(1));
|
||||
} else {
|
||||
rcLocation = root.getLocation().append(fullPath);
|
||||
}
|
||||
rcLocation = calcLocationForFullPath(fullPath);
|
||||
// IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
// IProject proj = root.getProject(fullPath.segment(0));
|
||||
// rcLocation = proj.getLocation();
|
||||
// if(rcLocation != null){
|
||||
// rcLocation = rcLocation.append(fullPath.removeFirstSegments(1));
|
||||
// } else {
|
||||
// rcLocation = root.getLocation().append(fullPath);
|
||||
// }
|
||||
}
|
||||
return rcLocation;
|
||||
}
|
||||
|
@ -402,7 +404,7 @@ public class BuildDescription implements IBuildDescription {
|
|||
}
|
||||
|
||||
public BuildDescription(IConfiguration cfg){
|
||||
initBase(cfg, null, 0);
|
||||
initBase(cfg, null, null, 0);
|
||||
}
|
||||
|
||||
public void synchRebuildState() throws CoreException{
|
||||
|
@ -704,9 +706,10 @@ public class BuildDescription implements IBuildDescription {
|
|||
return (fFlags & flags) == flags;
|
||||
}
|
||||
|
||||
protected void initBase(IConfiguration cfg, IResourceDelta delta, int flags){
|
||||
protected void initBase(IConfiguration cfg, IConfigurationBuildState bs, IResourceDelta delta, int flags){
|
||||
fCfg = (Configuration)cfg;
|
||||
fDelta = delta;
|
||||
fBuildState = bs;
|
||||
fProject = cfg.getOwner().getProject();
|
||||
fInfo = ManagedBuildManager.getBuildInfo(fProject);
|
||||
fFlags = flags;
|
||||
|
@ -726,6 +729,9 @@ public class BuildDescription implements IBuildDescription {
|
|||
if(fCfg.needsFullRebuild())
|
||||
fInputStep.setRebuildState(true);
|
||||
|
||||
if(fBuildState != null && fBuildState.getState() == IRebuildState.NEED_REBUILD)
|
||||
fInputStep.setRebuildState(true);
|
||||
|
||||
initToolInfos();
|
||||
|
||||
initMultiSteps();
|
||||
|
@ -742,17 +748,63 @@ public class BuildDescription implements IBuildDescription {
|
|||
|
||||
visitor.setMode(true);
|
||||
if((checkFlags(BuildDescriptionManager.REMOVED)
|
||||
|| checkFlags(BuildDescriptionManager.REBUILD))
|
||||
&& fDelta != null)
|
||||
fDelta.accept(visitor);
|
||||
|| checkFlags(BuildDescriptionManager.REBUILD))){
|
||||
if(fDelta != null)
|
||||
fDelta.accept(visitor);
|
||||
if(fBuildState != null)
|
||||
processBuildState();
|
||||
}
|
||||
|
||||
completeLinking();
|
||||
synchRebuildState();
|
||||
//TODO: trim();
|
||||
}
|
||||
|
||||
protected void init(IConfiguration cfg, IResourceDelta delta, int flags) throws CoreException {
|
||||
initBase(cfg, delta, flags);
|
||||
protected void processBuildState(){
|
||||
IPath paths[] = fBuildState.getFullPathsForState(IRebuildState.NEED_REBUILD);
|
||||
processBuildState(IRebuildState.NEED_REBUILD, paths);
|
||||
|
||||
paths = fBuildState.getFullPathsForState(IRebuildState.REMOVED);
|
||||
processBuildState(IRebuildState.REMOVED, paths);
|
||||
}
|
||||
|
||||
protected void processBuildState(int state, IPath fullPaths[]){
|
||||
for(int i = 0; i < fullPaths.length; i++){
|
||||
processBuildState(state, fullPaths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
protected void processBuildState(int state, IPath fullPath){
|
||||
BuildResource bRc = (BuildResource)getBuildResourceForFullPath(fullPath);
|
||||
if(bRc == null)
|
||||
return;
|
||||
|
||||
if(bRc.getProducerIOType() != null
|
||||
&& bRc.getProducerIOType().getStep() == fInputStep){
|
||||
if(state == IRebuildState.REMOVED){
|
||||
if(checkFlags(BuildDescriptionManager.REMOVED)){
|
||||
bRc.setRemoved(true);
|
||||
}
|
||||
} else if (state == IRebuildState.NEED_REBUILD){
|
||||
if(checkFlags(BuildDescriptionManager.REBUILD)){
|
||||
bRc.setRebuildState(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(state == IRebuildState.NEED_REBUILD
|
||||
|| state == IRebuildState.REMOVED
|
||||
|| checkFlags(BuildDescriptionManager.REBUILD)){
|
||||
bRc.setRebuildState(true);
|
||||
IBuildIOType type = bRc.getProducerIOType();
|
||||
if(type != null){
|
||||
((BuildStep)type.getStep()).setRebuildState(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void init(IConfiguration cfg, IConfigurationBuildState bs, IResourceDelta delta, int flags) throws CoreException {
|
||||
initBase(cfg, bs, delta, flags);
|
||||
|
||||
initDescription();
|
||||
}
|
||||
|
@ -2086,6 +2138,23 @@ public class BuildDescription implements IBuildDescription {
|
|||
return getBuildResource(calcResourceLocation(resource));
|
||||
}
|
||||
|
||||
public IBuildResource getBuildResourceForFullPath(IPath fullPath){
|
||||
IPath location = calcLocationForFullPath(fullPath);
|
||||
return getBuildResource(location);
|
||||
}
|
||||
|
||||
protected IPath calcLocationForFullPath(IPath fullPath){
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IProject proj = root.getProject(fullPath.segment(0));
|
||||
IPath rcLocation = proj.getLocation();
|
||||
if(rcLocation != null){
|
||||
rcLocation = rcLocation.append(fullPath.removeFirstSegments(1));
|
||||
} else {
|
||||
rcLocation = root.getLocation().append(fullPath);
|
||||
}
|
||||
return rcLocation;
|
||||
}
|
||||
|
||||
private void initToolInfos(){
|
||||
fToolInfos = PathSettingsContainer.createRootContainer();
|
||||
|
||||
|
|
|
@ -0,0 +1,188 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||
import org.eclipse.cdt.core.settings.model.ICDescriptionDelta;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
||||
import org.eclipse.cdt.core.settings.model.util.ResourceChangeHandlerBase;
|
||||
import org.eclipse.cdt.core.settings.model.util.ResourceChangeHandlerBase.IResourceMoveHandler;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IResourceChangeEvent;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
public class BuildStateManager {
|
||||
private static final String PREFS_LOCATION = "buildState";
|
||||
|
||||
private static BuildStateManager fInstance;
|
||||
|
||||
private EventListener fListener;
|
||||
|
||||
private class ResourceMoveHandler implements IResourceMoveHandler {
|
||||
|
||||
public void done() {
|
||||
}
|
||||
|
||||
public void handleProjectClose(IProject project) {
|
||||
}
|
||||
|
||||
public boolean handleResourceMove(IResource fromRc, IResource toRc) {
|
||||
return doHandleResourceRemove(fromRc);
|
||||
}
|
||||
|
||||
public boolean handleResourceRemove(IResource rc) {
|
||||
return doHandleResourceRemove(rc);
|
||||
}
|
||||
|
||||
private boolean doHandleResourceRemove(IResource rc){
|
||||
switch(rc.getType()){
|
||||
case IResource.PROJECT:
|
||||
removeProjectInfo(rc.getProject());
|
||||
return false;
|
||||
case IResource.ROOT:
|
||||
return true;
|
||||
//TODO: handle files and folder [re]move
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private class EventListener extends ResourceChangeHandlerBase implements ICProjectDescriptionListener {
|
||||
|
||||
public void resourceChanged(IResourceChangeEvent event) {
|
||||
super.resourceChanged(event);
|
||||
//TODO: may handle resource changes as well
|
||||
}
|
||||
|
||||
public void handleEvent(CProjectDescriptionEvent event) {
|
||||
switch(event.getEventType()){
|
||||
case CProjectDescriptionEvent.APPLIED:
|
||||
case CProjectDescriptionEvent.LOADDED:
|
||||
ICDescriptionDelta delta = event.getProjectDelta();
|
||||
processAppliedDelta(event, delta);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void processAppliedDelta(CProjectDescriptionEvent event, ICDescriptionDelta delta){
|
||||
if(delta == null)
|
||||
return;
|
||||
|
||||
IProjectBuildState pbs = null;
|
||||
boolean apply = false;
|
||||
switch (delta.getDeltaKind()) {
|
||||
case ICDescriptionDelta.REMOVED:
|
||||
removeProjectInfo(event.getProject());
|
||||
break;
|
||||
case ICDescriptionDelta.CHANGED:
|
||||
ICDescriptionDelta[] children = delta.getChildren();
|
||||
for(int i = 0; i < children.length; i++){
|
||||
if(children[i].getDeltaKind() == ICDescriptionDelta.REMOVED){
|
||||
if(pbs == null){
|
||||
pbs = getProjectBuildState(event.getProject());
|
||||
String id = children[i].getSetting().getId();
|
||||
IConfigurationBuildState cbs = pbs.getConfigurationBuildState(id, false);
|
||||
if(cbs != null){
|
||||
apply = true;
|
||||
pbs.removeConfigurationBuildState(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(pbs != null && apply){
|
||||
setProjectBuildState(event.getProject(), pbs);
|
||||
}
|
||||
}
|
||||
|
||||
protected IResourceMoveHandler createResourceMoveHandler(
|
||||
IResourceChangeEvent event) {
|
||||
return new ResourceMoveHandler();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void removeProjectInfo(IProject project){
|
||||
File f = getPrefsDir(project);
|
||||
if(f.exists()){
|
||||
File[] children = f.listFiles();
|
||||
for(int i = 0; i < children.length; i++){
|
||||
children[i].delete();
|
||||
}
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private BuildStateManager(){
|
||||
}
|
||||
|
||||
public static BuildStateManager getInstance(){
|
||||
if(fInstance == null)
|
||||
fInstance = new BuildStateManager();
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public void startup(){
|
||||
if(fListener == null){
|
||||
fListener = new EventListener();
|
||||
CoreModel.getDefault().getProjectDescriptionManager().addCProjectDescriptionListener(fListener, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED);
|
||||
ResourcesPlugin.getWorkspace().addResourceChangeListener(fListener,
|
||||
IResourceChangeEvent.POST_CHANGE
|
||||
| IResourceChangeEvent.PRE_DELETE
|
||||
| IResourceChangeEvent.PRE_CLOSE);
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown(){
|
||||
if(fListener != null){
|
||||
ResourcesPlugin.getWorkspace().removeResourceChangeListener(fListener);
|
||||
CoreModel.getDefault().getProjectDescriptionManager().removeCProjectDescriptionListener(fListener);
|
||||
}
|
||||
}
|
||||
|
||||
public IProjectBuildState getProjectBuildState(IProject project){
|
||||
return new ProjectBuildState(project);
|
||||
}
|
||||
|
||||
public void setProjectBuildState(IProject project, IProjectBuildState state){
|
||||
((ProjectBuildState)state).serialize();
|
||||
}
|
||||
|
||||
private IPath getPrefsDirPath(){
|
||||
IPath path = ManagedBuilderCorePlugin.getDefault().getStateLocation();
|
||||
path = path.append(PREFS_LOCATION);
|
||||
return path;
|
||||
}
|
||||
|
||||
IPath getPrefsDirPath(IProject project){
|
||||
IPath path = getPrefsDirPath();
|
||||
path = path.append(project.getName());
|
||||
return path;
|
||||
}
|
||||
|
||||
private File getPrefsDir(IProject project){
|
||||
IPath path = getPrefsDirPath(project);
|
||||
File file = path.toFile();
|
||||
// if(!file.exists())
|
||||
// file.mkdirs();
|
||||
return file;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation and others.
|
||||
* Copyright (c) 2006, 2007 Intel 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
|
||||
|
@ -136,7 +136,7 @@ public class CommandBuilder implements IBuildModelBuilder {
|
|||
|
||||
}
|
||||
|
||||
public CommandBuilder(IBuildCommand cmd){
|
||||
public CommandBuilder(IBuildCommand cmd, IResourceRebuildStateContainer cr){
|
||||
fCmd = cmd;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,215 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
public class ConfigurationBuildState implements IConfigurationBuildState {
|
||||
private final static Integer REBUILD_STATE = new Integer(NEED_REBUILD);
|
||||
private final static Integer REMOVED_STATE = new Integer(REMOVED);
|
||||
private final static Integer NONE_STATE = new Integer(0);
|
||||
|
||||
private Map fStateToPathListMap;
|
||||
private Properties fPathToStateProps;
|
||||
private String fCfgId;
|
||||
private IProject fProject;
|
||||
private int fState;
|
||||
|
||||
ConfigurationBuildState(IProject project, String cfgId){
|
||||
fCfgId = cfgId;
|
||||
fProject = project;
|
||||
fState = NEED_REBUILD;
|
||||
}
|
||||
|
||||
void setProject(IProject project){
|
||||
fProject = project;
|
||||
}
|
||||
|
||||
public IPath[] getFullPathsForState(int state) {
|
||||
if(fStateToPathListMap == null)
|
||||
return new IPath[0];
|
||||
|
||||
Set set = (Set)fStateToPathListMap.get(new Integer(state));
|
||||
if(set == null)
|
||||
return new IPath[0];
|
||||
|
||||
return setToFullPaths(set);
|
||||
}
|
||||
|
||||
private IPath[] setToFullPaths(Set set){
|
||||
IPath paths[] = new IPath[set.size()];
|
||||
IPath path = fProject.getFullPath();
|
||||
int num = 0;
|
||||
for(Iterator iter = set.iterator(); iter.hasNext();){
|
||||
String projRel = (String)iter.next();
|
||||
paths[num++] = path.append(projRel);
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
|
||||
public int getStateForFullPath(IPath fullPath) {
|
||||
if(fPathToStateProps == null)
|
||||
return 0;
|
||||
String str = fullPathToString(fullPath);
|
||||
String v = fPathToStateProps.getProperty(str);
|
||||
if(v != null){
|
||||
Integer i = stateToInt(v);
|
||||
if(i != null)
|
||||
return i.intValue();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setStateForFullPath(IPath fullPath, int state) {
|
||||
String str = fullPathToString(fullPath);
|
||||
int cur = getStateForFullPath(fullPath);
|
||||
if(cur == state)
|
||||
return;
|
||||
|
||||
if(fPathToStateProps == null){
|
||||
fPathToStateProps = new Properties();
|
||||
fStateToPathListMap = new HashMap();
|
||||
}
|
||||
String strState = stateToString(new Integer(state));
|
||||
Integer iState = stateToInt(strState);
|
||||
if(iState == null)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
if(cur != 0){
|
||||
Set set = (Set)fStateToPathListMap.get(new Integer(cur));
|
||||
set.remove(str);
|
||||
if(set.size() == 0)
|
||||
fStateToPathListMap.remove(iState);
|
||||
}
|
||||
|
||||
if(state != 0){
|
||||
fPathToStateProps.setProperty(str, strState);
|
||||
Set set = (Set)fStateToPathListMap.get(iState);
|
||||
if(set == null){
|
||||
set = new HashSet();
|
||||
fStateToPathListMap.put(iState, set);
|
||||
}
|
||||
set.add(str);
|
||||
} else {
|
||||
fPathToStateProps.remove(str);
|
||||
}
|
||||
}
|
||||
|
||||
private String fullPathToString(IPath fullPath){
|
||||
return fullPath.removeFirstSegments(1).toString();
|
||||
}
|
||||
|
||||
public void load(InputStream iStream) throws IOException{
|
||||
Properties props = new Properties();
|
||||
props.load(iStream);
|
||||
load(props);
|
||||
}
|
||||
|
||||
private void load(Properties props){
|
||||
Map map = new HashMap();
|
||||
for(Iterator iter = props.entrySet().iterator(); iter.hasNext();){
|
||||
Map.Entry entry = (Map.Entry)iter.next();
|
||||
Integer i = stateToInt((String)entry.getValue());
|
||||
Set list = (Set)map.get(i);
|
||||
if(list == null){
|
||||
list = new HashSet();
|
||||
map.put(i, list);
|
||||
}
|
||||
list.add(entry.getKey());
|
||||
}
|
||||
|
||||
//TODO: trim lists
|
||||
if(map.size() != 0){
|
||||
fStateToPathListMap = map;
|
||||
fPathToStateProps = props;
|
||||
}
|
||||
fState = 0;
|
||||
}
|
||||
|
||||
public void store(OutputStream oStream) throws IOException{
|
||||
if(fPathToStateProps != null)
|
||||
fPathToStateProps.store(oStream, "");
|
||||
// Properties props = new Properties();
|
||||
// store(props);
|
||||
// props.store(oStream, "");
|
||||
}
|
||||
|
||||
// public void store(Properties props){
|
||||
// if(fStateToPathListMap == null)
|
||||
// return;
|
||||
//
|
||||
// for(Iterator iter = fStateToPathListMap.entrySet().iterator(); iter.hasNext();){
|
||||
// Map.Entry entry = (Map.Entry)iter.next();
|
||||
// String propValue = stateToString((Integer)entry.getKey());
|
||||
// List list = (List)entry.getValue();
|
||||
// for(int i = 0; i < list.size(); i++){
|
||||
// props.setProperty((String)list.get(i), propValue);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private Integer stateToInt(String state){
|
||||
try {
|
||||
Integer i = new Integer(state);
|
||||
if(i.equals(REBUILD_STATE))
|
||||
return REBUILD_STATE;
|
||||
if(i.equals(REMOVED_STATE))
|
||||
return REMOVED_STATE;
|
||||
if(i.equals(NONE_STATE))
|
||||
return NONE_STATE;
|
||||
} catch (NumberFormatException e){
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String stateToString(Integer state){
|
||||
return state.toString();
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
return fState;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
fState = state;
|
||||
clear();
|
||||
}
|
||||
|
||||
private void clear(){
|
||||
fPathToStateProps = null;
|
||||
fStateToPathListMap = null;
|
||||
}
|
||||
|
||||
public String getConfigurationId() {
|
||||
return fCfgId;
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
return fProject;
|
||||
}
|
||||
|
||||
public boolean exists(){
|
||||
return fState == 0;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation and others.
|
||||
* Copyright (c) 2006, 2007 Intel 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
|
||||
|
@ -33,8 +33,15 @@ public class DefaultBuildDescriptionFactory implements IBuildDescriptionFactory
|
|||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildDescriptionFactory#createBuildDescription(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.core.resources.IResourceDelta, int)
|
||||
*/
|
||||
public IBuildDescription createBuildDescription(IConfiguration cfg, IResourceDelta delta, int flags) throws CoreException {
|
||||
return createBuildDescription(cfg, null, delta, flags);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.builddescription.IBuildDescriptionFactory#createBuildDescription(org.eclipse.cdt.managedbuilder.core.IConfiguration, org.eclipse.core.resources.IResourceDelta, int)
|
||||
*/
|
||||
public IBuildDescription createBuildDescription(IConfiguration cfg, IConfigurationBuildState bs, IResourceDelta delta, int flags) throws CoreException {
|
||||
BuildDescription info = new BuildDescription();
|
||||
info.init(cfg, delta, flags);
|
||||
info.init(cfg, bs, delta, flags);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation and others.
|
||||
* Copyright (c) 2006, 2007 Intel 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
|
||||
|
@ -17,6 +17,7 @@ import java.util.Map;
|
|||
|
||||
import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager;
|
||||
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription;
|
||||
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildResource;
|
||||
import org.eclipse.cdt.managedbuilder.buildmodel.IBuildStep;
|
||||
import org.eclipse.cdt.managedbuilder.buildmodel.IStepVisitor;
|
||||
import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
|
||||
|
@ -50,6 +51,7 @@ public class DescriptionBuilder implements IBuildModelBuilder {
|
|||
private Map fStepToStepBuilderMap = new HashMap();
|
||||
private int fNumCommands = -1;
|
||||
private GenDirInfo fDir;
|
||||
private IResourceRebuildStateContainer fRebuildStateContainer;
|
||||
|
||||
private class BuildStepVisitor implements IStepVisitor{
|
||||
private OutputStream fOut;
|
||||
|
@ -111,19 +113,19 @@ public class DescriptionBuilder implements IBuildModelBuilder {
|
|||
|
||||
}
|
||||
|
||||
public DescriptionBuilder(IBuildDescription des){
|
||||
this(des, true);
|
||||
public DescriptionBuilder(IBuildDescription des, IResourceRebuildStateContainer rs){
|
||||
this(des, true, rs);
|
||||
}
|
||||
|
||||
public DescriptionBuilder(IBuildDescription des, boolean buildIncrementaly){
|
||||
this(des, buildIncrementaly, true);
|
||||
public DescriptionBuilder(IBuildDescription des, boolean buildIncrementaly, IResourceRebuildStateContainer rs){
|
||||
this(des, buildIncrementaly, true, rs);
|
||||
}
|
||||
|
||||
public DescriptionBuilder(IBuildDescription des, boolean buildIncrementaly, boolean resumeOnError){
|
||||
this(des, buildIncrementaly, resumeOnError, null);
|
||||
public DescriptionBuilder(IBuildDescription des, boolean buildIncrementaly, boolean resumeOnError, IResourceRebuildStateContainer rs){
|
||||
this(des, buildIncrementaly, resumeOnError, null, rs);
|
||||
}
|
||||
|
||||
public DescriptionBuilder(IBuildDescription des, boolean buildIncrementaly, boolean resumeOnErrs, IPath cwd){
|
||||
public DescriptionBuilder(IBuildDescription des, boolean buildIncrementaly, boolean resumeOnErrs, IPath cwd, IResourceRebuildStateContainer rs){
|
||||
fDes = des;
|
||||
fCWD = cwd;
|
||||
fBuildIncrementaly = buildIncrementaly;
|
||||
|
@ -132,6 +134,8 @@ public class DescriptionBuilder implements IBuildModelBuilder {
|
|||
|
||||
if(fCWD == null)
|
||||
fCWD = fDes.getDefaultBuildDirLocation();
|
||||
|
||||
fRebuildStateContainer = rs;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -140,6 +144,7 @@ public class DescriptionBuilder implements IBuildModelBuilder {
|
|||
public int build(OutputStream out, OutputStream err,
|
||||
IProgressMonitor monitor){
|
||||
|
||||
initRebuildStates();
|
||||
int num = getNumCommands();
|
||||
int status = STATUS_OK;
|
||||
|
||||
|
@ -167,6 +172,9 @@ public class DescriptionBuilder implements IBuildModelBuilder {
|
|||
|
||||
monitor.done();
|
||||
|
||||
if(status == STATUS_OK)
|
||||
clearRebuildStates();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -189,7 +197,7 @@ public class DescriptionBuilder implements IBuildModelBuilder {
|
|||
protected StepBuilder getStepBuilder(IBuildStep step){
|
||||
StepBuilder b = (StepBuilder)fStepToStepBuilderMap.get(step);
|
||||
if(b == null){
|
||||
b = new StepBuilder(step, fCWD, fResumeOnErrs, fDir);
|
||||
b = new StepBuilder(step, fCWD, fResumeOnErrs, fDir, fRebuildStateContainer);
|
||||
fStepToStepBuilderMap.put(step, b);
|
||||
}
|
||||
return b;
|
||||
|
@ -206,4 +214,41 @@ public class DescriptionBuilder implements IBuildModelBuilder {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initRebuildStates(){
|
||||
if(fRebuildStateContainer == null)
|
||||
return;
|
||||
|
||||
fRebuildStateContainer.setState(0);
|
||||
|
||||
IBuildResource[] rcs = fDes.getResources();
|
||||
putAll(fRebuildStateContainer, rcs, IRebuildState.NEED_REBUILD, true);
|
||||
}
|
||||
|
||||
private void clearRebuildStates(){
|
||||
if(fRebuildStateContainer == null)
|
||||
return;
|
||||
|
||||
fRebuildStateContainer.setState(0);
|
||||
|
||||
// IBuildResource[] rcs = fDes.getResources();
|
||||
// putAll(fRebuildStateContainer, rcs, IRebuildState.NEED_REBUILD, true);
|
||||
}
|
||||
|
||||
static void putAll(IResourceRebuildStateContainer cbs, IBuildResource[] rcs, int state, boolean rebuildRcOnly){
|
||||
for(int i = 0; i < rcs.length; i++){
|
||||
IBuildResource rc = rcs[i];
|
||||
if(rebuildRcOnly && !rc.needsRebuild())
|
||||
continue;
|
||||
|
||||
if(!rc.isProjectResource())
|
||||
continue;
|
||||
IPath fullPath = rc.getFullPath();
|
||||
if(fullPath == null)
|
||||
continue;
|
||||
|
||||
cbs.setStateForFullPath(fullPath, state);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
|
||||
public interface IConfigurationBuildState extends IResourceRebuildStateContainer {
|
||||
String getConfigurationId();
|
||||
|
||||
IProject getProject();
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
||||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
public interface IProjectBuildState extends IRebuildState {
|
||||
IConfigurationBuildState[] getConfigurationBuildStates();
|
||||
|
||||
IConfigurationBuildState getConfigurationBuildState(String id, boolean create);
|
||||
|
||||
void removeConfigurationBuildState(String id);
|
||||
|
||||
IProject getProject();
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
||||
|
||||
public interface IRebuildState {
|
||||
public static final int NEED_REBUILD = 1;
|
||||
public static final int REMOVED = 1 << 1;
|
||||
|
||||
int getState();
|
||||
|
||||
void setState(int state);
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
||||
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
public interface IResourceRebuildStateContainer extends IRebuildState {
|
||||
int getStateForFullPath(IPath fullPath);
|
||||
|
||||
IPath[] getFullPathsForState(int state);
|
||||
|
||||
void setStateForFullPath(IPath fullPath, int state);
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 Intel 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.managedbuilder.internal.buildmodel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
public class ProjectBuildState implements IProjectBuildState {
|
||||
private Properties fCfgIdToFileNameProps;
|
||||
private Map fCfgIdToStateMap = new HashMap();
|
||||
private IProject fProject;
|
||||
private boolean fIsMapInfoDirty;
|
||||
|
||||
public ProjectBuildState(IProject project){
|
||||
fProject = project;
|
||||
}
|
||||
|
||||
void setProject(IProject project){
|
||||
fProject = project;
|
||||
for(Iterator iter = fCfgIdToStateMap.values().iterator(); iter.hasNext();){
|
||||
ConfigurationBuildState cbs = (ConfigurationBuildState)iter.next();
|
||||
cbs.setProject(project);
|
||||
}
|
||||
}
|
||||
|
||||
public IConfigurationBuildState getConfigurationBuildState(String id, boolean create) {
|
||||
ConfigurationBuildState state = (ConfigurationBuildState)fCfgIdToStateMap.get(id);
|
||||
if(state == null){
|
||||
state = loadState(id, create);
|
||||
if(state.exists() || create)
|
||||
fCfgIdToStateMap.put(id, state);
|
||||
else
|
||||
state = null;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
private ConfigurationBuildState loadState(String id, boolean create){
|
||||
File file = getFileForCfg(id, create);
|
||||
ConfigurationBuildState bs = new ConfigurationBuildState(fProject, id);
|
||||
if(file != null && file.exists()){
|
||||
try {
|
||||
InputStream iStream = new FileInputStream(file);
|
||||
bs.load(iStream);
|
||||
iStream.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
} catch (IOException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
return bs;
|
||||
}
|
||||
|
||||
public IConfigurationBuildState[] getConfigurationBuildStates() {
|
||||
Properties props = getIdToNameProperties();
|
||||
List list = new ArrayList(props.size());
|
||||
for(Iterator iter = props.keySet().iterator(); iter.hasNext();){
|
||||
String id = (String)iter.next();
|
||||
IConfigurationBuildState state = getConfigurationBuildState(id, false);
|
||||
if(state != null)
|
||||
list.add(state);
|
||||
}
|
||||
return (ConfigurationBuildState[])list.toArray(new ConfigurationBuildState[list.size()]);
|
||||
}
|
||||
|
||||
public void removeConfigurationBuildState(String id) {
|
||||
ConfigurationBuildState cbs = (ConfigurationBuildState)getConfigurationBuildState(id, false);
|
||||
if(cbs != null){
|
||||
cbs.setState(IRebuildState.NEED_REBUILD);
|
||||
}
|
||||
}
|
||||
|
||||
public int getState() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setState(int state) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
private static final int OP_CREATE = 1;
|
||||
private static final int OP_REMOVE = 2;
|
||||
|
||||
private String getFileName(String id, int op){
|
||||
Properties props = getIdToNameProperties();
|
||||
String name = props.getProperty(id);
|
||||
if(name == null){
|
||||
if(op == OP_CREATE){
|
||||
name = new Integer(CDataUtil.genRandomNumber()).toString();
|
||||
props.setProperty(id, name);
|
||||
fIsMapInfoDirty = true;
|
||||
// saveMapFile();
|
||||
}
|
||||
} else if (op == OP_REMOVE){
|
||||
props.remove(id);
|
||||
fIsMapInfoDirty = true;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private File getFileForCfg(String id, boolean create){
|
||||
String name = getFileName(id, create ? OP_CREATE : 0);
|
||||
if(name == null)
|
||||
return null;
|
||||
|
||||
IPath path = BuildStateManager.getInstance().getPrefsDirPath(fProject);
|
||||
path = path.append(name);
|
||||
return path.toFile();
|
||||
}
|
||||
|
||||
private void saveMapFile(){
|
||||
if(fCfgIdToFileNameProps == null)
|
||||
return;
|
||||
|
||||
File file = getMapFile();
|
||||
File parent = file.getParentFile();
|
||||
if(!parent.exists())
|
||||
parent.mkdirs();
|
||||
|
||||
try {
|
||||
OutputStream oStream = new FileOutputStream(file);
|
||||
fCfgIdToFileNameProps.store(oStream, "");
|
||||
oStream.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
} catch (IOException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
private File getMapFile(){
|
||||
IPath path = BuildStateManager.getInstance().getPrefsDirPath(fProject);
|
||||
path = path.append(getProjFileName());
|
||||
File file = path.toFile();
|
||||
return file;
|
||||
}
|
||||
|
||||
private Properties getIdToNameProperties(){
|
||||
if(fCfgIdToFileNameProps == null){
|
||||
fCfgIdToFileNameProps = new Properties();
|
||||
File file = getMapFile();
|
||||
if(file.exists()){
|
||||
try {
|
||||
InputStream iStream = new FileInputStream(file);
|
||||
fCfgIdToFileNameProps.load(iStream);
|
||||
iStream.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
} catch (IOException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fCfgIdToFileNameProps;
|
||||
}
|
||||
|
||||
private String getProjFileName(){
|
||||
return fProject.getName();
|
||||
}
|
||||
|
||||
public IProject getProject() {
|
||||
return fProject;
|
||||
}
|
||||
|
||||
void serialize(){
|
||||
|
||||
for(Iterator iter = fCfgIdToStateMap.values().iterator(); iter.hasNext();){
|
||||
ConfigurationBuildState s = (ConfigurationBuildState)iter.next();
|
||||
String id = s.getConfigurationId();
|
||||
if(!s.exists()){
|
||||
File file = getFileForCfg(id, false);
|
||||
if(file != null && file.exists()){
|
||||
file.delete();
|
||||
getFileName(id, OP_REMOVE);
|
||||
}
|
||||
} else {
|
||||
File file = getFileForCfg(id, true);
|
||||
File parent = file.getParentFile();
|
||||
if(!parent.exists())
|
||||
parent.mkdirs();
|
||||
|
||||
try {
|
||||
FileOutputStream oStream = new FileOutputStream(file);
|
||||
s.store(oStream);
|
||||
oStream.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
} catch (IOException e) {
|
||||
ManagedBuilderCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(fIsMapInfoDirty)
|
||||
saveMapFile();
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006 Intel Corporation and others.
|
||||
* Copyright (c) 2006, 2007 Intel 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
|
||||
|
@ -43,16 +43,17 @@ public class StepBuilder implements IBuildModelBuilder {
|
|||
private boolean fResumeOnErrs;
|
||||
private int fNumCommands = -1;
|
||||
private CommandBuilder fCommandBuilders[];
|
||||
private IResourceRebuildStateContainer fRebuildStateContainer;
|
||||
|
||||
public StepBuilder(IBuildStep step){
|
||||
this(step, null);
|
||||
public StepBuilder(IBuildStep step, IResourceRebuildStateContainer rs){
|
||||
this(step, null, rs);
|
||||
}
|
||||
|
||||
public StepBuilder(IBuildStep step, IPath cwd){
|
||||
this(step, cwd, true, null);
|
||||
public StepBuilder(IBuildStep step, IPath cwd, IResourceRebuildStateContainer rs){
|
||||
this(step, cwd, true, null, rs);
|
||||
}
|
||||
|
||||
public StepBuilder(IBuildStep step, IPath cwd, boolean resumeOnErrs, GenDirInfo dirs){
|
||||
public StepBuilder(IBuildStep step, IPath cwd, boolean resumeOnErrs, GenDirInfo dirs, IResourceRebuildStateContainer rs){
|
||||
fStep = step;
|
||||
fCWD = cwd;
|
||||
fDirs = dirs;
|
||||
|
@ -63,6 +64,8 @@ public class StepBuilder implements IBuildModelBuilder {
|
|||
|
||||
if(fCWD == null)
|
||||
fCWD = fStep.getBuildDescription().getDefaultBuildDirLocation();
|
||||
|
||||
fRebuildStateContainer = rs;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -114,6 +117,7 @@ public class StepBuilder implements IBuildModelBuilder {
|
|||
}
|
||||
switch(status){
|
||||
case STATUS_OK:
|
||||
clearRebuildState();
|
||||
break;
|
||||
case STATUS_CANCELLED:
|
||||
case STATUS_ERROR_BUILD:
|
||||
|
@ -125,6 +129,16 @@ public class StepBuilder implements IBuildModelBuilder {
|
|||
return status;
|
||||
}
|
||||
|
||||
private void clearRebuildState(){
|
||||
if(fRebuildStateContainer == null)
|
||||
return;
|
||||
|
||||
IBuildResource[] rcs = fStep.getOutputResources();
|
||||
DescriptionBuilder.putAll(fRebuildStateContainer, rcs, 0, false);
|
||||
rcs = fStep.getInputResources();
|
||||
DescriptionBuilder.putAll(fRebuildStateContainer, rcs, 0, false);
|
||||
}
|
||||
|
||||
protected void refreshOutputs(IProgressMonitor monitor){
|
||||
if(fStep == fStep.getBuildDescription().getInputStep())
|
||||
return;
|
||||
|
@ -200,7 +214,7 @@ public class StepBuilder implements IBuildModelBuilder {
|
|||
else {
|
||||
fCommandBuilders = new CommandBuilder[cmds.length];
|
||||
for(int i = 0; i < cmds.length; i++){
|
||||
fCommandBuilders[i] = new CommandBuilder(cmds[i]);
|
||||
fCommandBuilders[i] = new CommandBuilder(cmds[i], fRebuildStateContainer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,8 +49,12 @@ import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
|||
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.BuildStateManager;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.DescriptionBuilder;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.IBuildModelBuilder;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.IConfigurationBuildState;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.IProjectBuildState;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.IRebuildState;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.ParallelBuilder;
|
||||
import org.eclipse.cdt.managedbuilder.internal.buildmodel.StepBuilder;
|
||||
import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
|
||||
|
@ -879,11 +883,14 @@ public class CommonBuilder extends ACBuilder {
|
|||
|
||||
boolean buildIncrementaly = delta != null;
|
||||
|
||||
IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, delta, flags);
|
||||
BuildStateManager bsMngr = BuildStateManager.getInstance();
|
||||
IProjectBuildState pBS = bsMngr.getProjectBuildState(currentProject);
|
||||
IConfigurationBuildState cBS = pBS.getConfigurationBuildState(cfg.getId(), true);
|
||||
IBuildDescription des = BuildDescriptionManager.createBuildDescription(cfg, cBS, delta, flags);
|
||||
|
||||
DescriptionBuilder dBuilder = null;
|
||||
if (!isParallel)
|
||||
dBuilder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr);
|
||||
dBuilder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr, cBS);
|
||||
|
||||
// Get a build console for the project
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
@ -982,6 +989,8 @@ public class CommonBuilder extends ACBuilder {
|
|||
.getResourceString(MARKERS));
|
||||
//TODO: addBuilderMarkers(epm);
|
||||
epm.reportProblems();
|
||||
|
||||
bsMngr.setProjectBuildState(currentProject, pBS);
|
||||
} else {
|
||||
buf = new StringBuffer();
|
||||
buf.append(ManagedMakeMessages.getFormattedString(NOTHING_BUILT, currentProject.getName()));
|
||||
|
@ -1169,7 +1178,7 @@ public class CommonBuilder extends ACBuilder {
|
|||
{
|
||||
IBuildStep step = (IBuildStep) stepIter.next();
|
||||
|
||||
StepBuilder stepBuilder = new StepBuilder(step);
|
||||
StepBuilder stepBuilder = new StepBuilder(step, null);
|
||||
|
||||
int status = stepBuilder.build(consoleOutStream, epmOutputStream, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2006 IBM Corporation and others.
|
||||
* Copyright (c) 2002, 2007 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
|
||||
|
@ -1216,7 +1216,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
|
||||
DescriptionBuilder builder = null;
|
||||
if (!isParallel)
|
||||
builder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr);
|
||||
builder = new DescriptionBuilder(des, buildIncrementaly, resumeOnErr, null);
|
||||
|
||||
// Get a build console for the project
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
@ -1480,7 +1480,7 @@ public class GeneratedMakefileBuilder extends ACBuilder {
|
|||
{
|
||||
IBuildStep step = (IBuildStep) stepIter.next();
|
||||
|
||||
StepBuilder stepBuilder = new StepBuilder(step);
|
||||
StepBuilder stepBuilder = new StepBuilder(step, null);
|
||||
|
||||
int status = stepBuilder.build(consoleOutStream, epmOutputStream, new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.core.settings.model;
|
|||
|
||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionDelta;
|
||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||
import org.eclipse.cdt.internal.core.settings.model.ICDescriptionDelta;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
||||
public final class CProjectDescriptionEvent {
|
||||
|
|
|
@ -8,9 +8,8 @@
|
|||
* Contributors:
|
||||
* Intel Corporation - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.settings.model;
|
||||
package org.eclipse.cdt.core.settings.model;
|
||||
|
||||
import org.eclipse.cdt.core.settings.model.ICSettingObject;
|
||||
|
||||
public interface ICDescriptionDelta {
|
||||
int REMOVED = 1;
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.settings.model;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.settings.model.ICDescriptionDelta;
|
||||
import org.eclipse.cdt.core.settings.model.ICSettingObject;
|
||||
|
||||
public class CProjectDescriptionDelta implements ICDescriptionDelta {
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.eclipse.cdt.core.model.ICProject;
|
|||
import org.eclipse.cdt.core.settings.model.CExternalSetting;
|
||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICDescriptionDelta;
|
||||
import org.eclipse.cdt.core.settings.model.ICFileDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICFolderDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICLanguageSetting;
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.CCorePlugin;
|
|||
import org.eclipse.cdt.core.settings.model.CExternalSetting;
|
||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICDescriptionDelta;
|
||||
import org.eclipse.cdt.core.settings.model.ICExternalSetting;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.eclipse.cdt.core.model.CModelException;
|
|||
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||
import org.eclipse.cdt.core.settings.model.ICDescriptionDelta;
|
||||
import org.eclipse.cdt.internal.core.model.CModelOperation;
|
||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.CompositeWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.ICDescriptorManager;
|
|||
import org.eclipse.cdt.core.ICDescriptorOperation;
|
||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICDescriptionDelta;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
||||
import org.eclipse.cdt.core.settings.model.ICSettingObject;
|
||||
|
@ -35,7 +36,6 @@ import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
|
|||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||
import org.eclipse.cdt.internal.core.settings.model.CStorage;
|
||||
import org.eclipse.cdt.internal.core.settings.model.ExceptionFactory;
|
||||
import org.eclipse.cdt.internal.core.settings.model.ICDescriptionDelta;
|
||||
import org.eclipse.cdt.internal.core.settings.model.IInternalCCfgInfo;
|
||||
import org.eclipse.cdt.internal.core.settings.model.InternalXmlStorageElement;
|
||||
import org.eclipse.cdt.internal.core.settings.model.PathEntryConfigurationDataProvider;
|
||||
|
|
Loading…
Add table
Reference in a new issue