mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-30 20:35:38 +02:00
Fix for [Bug 188211] .cproject written on every build, bad for Team
This commit is contained in:
parent
cada57636c
commit
29afb02f90
6 changed files with 47 additions and 39 deletions
|
@ -143,7 +143,7 @@ public class CfgDiscoveredPathManager implements IResourceChangeListener {
|
|||
try {
|
||||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
||||
public void run(IProgressMonitor monitor) throws CoreException {
|
||||
ManagedBuildManager.updateCoreSettings(project, cfgs);
|
||||
ManagedBuildManager.updateCoreSettings(project, cfgs, true);
|
||||
}
|
||||
};
|
||||
CoreModel.run(runnable, null);
|
||||
|
|
|
@ -1572,8 +1572,11 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateCoreSettings(IProject project, IConfiguration[] cfgs) throws CoreException{
|
||||
updateCoreSettings(project, cfgs, false);
|
||||
}
|
||||
|
||||
public static void updateCoreSettings(IProject project, IConfiguration[] cfgs, boolean avoidSerialization) throws CoreException{
|
||||
if(cfgs == null){
|
||||
IManagedBuildInfo info = getBuildInfo(project);
|
||||
if(info != null && info.isValid() && info.getManagedProject() != null)
|
||||
|
@ -1592,7 +1595,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
|||
}
|
||||
}
|
||||
if(updated){
|
||||
BuildSettingsUtil.checkApplyDescription(project, projDes);
|
||||
BuildSettingsUtil.checkApplyDescription(project, projDes, avoidSerialization);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
|||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||
import org.eclipse.cdt.managedbuilder.core.BuildException;
|
||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||
|
@ -138,14 +139,21 @@ public class BuildSettingsUtil {
|
|||
values.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void checkApplyDescription(IProject project, ICProjectDescription des) throws CoreException{
|
||||
checkApplyDescription(project, des, false);
|
||||
}
|
||||
|
||||
public static void checkApplyDescription(IProject project, ICProjectDescription des, boolean avoidSerialization) throws CoreException{
|
||||
ICConfigurationDescription[] cfgs = des.getConfigurations();
|
||||
for(int i = 0; i < cfgs.length; i++){
|
||||
if(!ManagedBuildManager.CFG_DATA_PROVIDER_ID.equals(cfgs[i].getBuildSystemId()))
|
||||
des.removeConfiguration(cfgs[i]);
|
||||
}
|
||||
|
||||
CoreModel.getDefault().setProjectDescription(project, des);
|
||||
int flags = 0;
|
||||
if(avoidSerialization)
|
||||
flags |= ICProjectDescriptionManager.SET_NO_SERIALIZE;
|
||||
CoreModel.getDefault().getProjectDescriptionManager().setProjectDescription(project, des, flags, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,9 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
|
||||
public interface ICProjectDescriptionManager {
|
||||
|
||||
public static final int SET_FORCE = 1;
|
||||
public static final int SET_NO_SERIALIZE = 1 << 1;
|
||||
|
||||
/**
|
||||
* this method is a full equivalent to {@link #createProjectDescription(IProject, boolean, false)}
|
||||
*
|
||||
|
@ -71,6 +73,8 @@ public interface ICProjectDescriptionManager {
|
|||
|
||||
void setProjectDescription(IProject project, ICProjectDescription des, boolean force, IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
void setProjectDescription(IProject project, ICProjectDescription des, int flags, IProgressMonitor monitor) throws CoreException;
|
||||
|
||||
/**
|
||||
* returns the project description associated with this project
|
||||
*
|
||||
|
|
|
@ -191,6 +191,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
monitor.done();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmpty(){
|
||||
return fRunnables.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
private class DesSerializationRunnable implements IWorkspaceRunnable {
|
||||
|
@ -1144,7 +1148,19 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
}
|
||||
|
||||
public void setProjectDescription(IProject project, ICProjectDescription des, boolean force, IProgressMonitor monitor) throws CoreException {
|
||||
if(!force && !des.isModified())
|
||||
int flags = 0;
|
||||
if(force)
|
||||
flags |= SET_FORCE;
|
||||
setProjectDescription(project, des, flags, monitor);
|
||||
}
|
||||
|
||||
static boolean checkFlags(int flags, int check){
|
||||
return (flags & check) == check;
|
||||
}
|
||||
|
||||
public void setProjectDescription(IProject project, ICProjectDescription des, int flags, IProgressMonitor monitor) throws CoreException {
|
||||
|
||||
if(!checkFlags(flags, SET_FORCE) && !des.isModified())
|
||||
return;
|
||||
|
||||
if(((CProjectDescription)des).isLoadding()){
|
||||
|
@ -1165,30 +1181,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
|||
CModelManager manager = CModelManager.getDefault();
|
||||
ICProject cproject = manager.create(project);
|
||||
|
||||
SetCProjectDescriptionOperation op = new SetCProjectDescriptionOperation(cproject, (CProjectDescription)des);
|
||||
SetCProjectDescriptionOperation op = new SetCProjectDescriptionOperation(cproject, (CProjectDescription)des, flags);
|
||||
op.runOperation(monitor);
|
||||
|
||||
|
||||
// CProjectDescription newDes = new CProjectDescription((CProjectDescription)des, true);
|
||||
|
||||
/*TODO: calculate delta, etc.
|
||||
ICProjectDescription previousDes = getProjecDescription(project, false);
|
||||
|
||||
if(des != previousDes){
|
||||
ICConfigurationDescription cfgDess[] = des.getConfigurations();
|
||||
}
|
||||
*/
|
||||
// ICProjectDescription oldDes = getProjectDescription(project, false);
|
||||
// setLoaddedDescription(newDes.getProject(), newDes);
|
||||
|
||||
// ICProjectDescriptionDelta delta = createDelta(newDes, oldDes);
|
||||
//TODO: notify listeners
|
||||
|
||||
// ICStorageElement element = newDes.getRootStorageElement();
|
||||
|
||||
// serialize(newDes.getProject(), STORAGE_FILE_NAME, element);
|
||||
|
||||
// serialize(newDes);
|
||||
}
|
||||
|
||||
IWorkspaceRunnable createDesSerializationRunnable(CProjectDescription des) throws CoreException{
|
||||
|
|
|
@ -16,6 +16,7 @@ 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.core.settings.model.ICProjectDescriptionManager;
|
||||
import org.eclipse.cdt.internal.core.model.CModelOperation;
|
||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.CompositeWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -26,16 +27,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
public class SetCProjectDescriptionOperation extends CModelOperation {
|
||||
// private IProject fProject;
|
||||
// private ICProject fCProject;
|
||||
private CProjectDescription fSetDescription;
|
||||
// private CProjectDescription fNewDescriptionCache;
|
||||
// private ICProjectDescription fOldDescriptionCache;
|
||||
|
||||
private int fFlags;
|
||||
|
||||
SetCProjectDescriptionOperation(ICProject cProject, CProjectDescription description){
|
||||
SetCProjectDescriptionOperation(ICProject cProject, CProjectDescription description, int flags){
|
||||
super(cProject);
|
||||
// fCProject = cProject;
|
||||
fFlags = flags;
|
||||
fSetDescription = description;
|
||||
}
|
||||
|
||||
|
@ -119,8 +116,10 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
|
|||
mngr.notifyListeners(event);
|
||||
|
||||
try {
|
||||
runnable.add(mngr.createDesSerializationRunnable(fNewDescriptionCache));
|
||||
mngr.runWspModification(runnable, new NullProgressMonitor());
|
||||
if(!CProjectDescriptionManager.checkFlags(fFlags, ICProjectDescriptionManager.SET_NO_SERIALIZE))
|
||||
runnable.add(mngr.createDesSerializationRunnable(fNewDescriptionCache));
|
||||
if(!runnable.isEmpty())
|
||||
mngr.runWspModification(runnable, new NullProgressMonitor());
|
||||
} catch (CoreException e) {
|
||||
throw new CModelException(e);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue