mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 13:25:45 +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 {
|
try {
|
||||||
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
ManagedBuildManager.updateCoreSettings(project, cfgs);
|
ManagedBuildManager.updateCoreSettings(project, cfgs, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
CoreModel.run(runnable, null);
|
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{
|
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){
|
if(cfgs == null){
|
||||||
IManagedBuildInfo info = getBuildInfo(project);
|
IManagedBuildInfo info = getBuildInfo(project);
|
||||||
if(info != null && info.isValid() && info.getManagedProject() != null)
|
if(info != null && info.isValid() && info.getManagedProject() != null)
|
||||||
|
@ -1592,7 +1595,7 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(updated){
|
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.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
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.BuildException;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
|
||||||
import org.eclipse.cdt.managedbuilder.core.IOption;
|
import org.eclipse.cdt.managedbuilder.core.IOption;
|
||||||
|
@ -140,12 +141,19 @@ public class BuildSettingsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkApplyDescription(IProject project, ICProjectDescription des) throws CoreException{
|
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();
|
ICConfigurationDescription[] cfgs = des.getConfigurations();
|
||||||
for(int i = 0; i < cfgs.length; i++){
|
for(int i = 0; i < cfgs.length; i++){
|
||||||
if(!ManagedBuildManager.CFG_DATA_PROVIDER_ID.equals(cfgs[i].getBuildSystemId()))
|
if(!ManagedBuildManager.CFG_DATA_PROVIDER_ID.equals(cfgs[i].getBuildSystemId()))
|
||||||
des.removeConfiguration(cfgs[i]);
|
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,6 +15,8 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public interface ICProjectDescriptionManager {
|
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)}
|
* 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, 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
|
* returns the project description associated with this project
|
||||||
*
|
*
|
||||||
|
|
|
@ -191,6 +191,10 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty(){
|
||||||
|
return fRunnables.isEmpty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DesSerializationRunnable implements IWorkspaceRunnable {
|
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 {
|
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;
|
return;
|
||||||
|
|
||||||
if(((CProjectDescription)des).isLoadding()){
|
if(((CProjectDescription)des).isLoadding()){
|
||||||
|
@ -1165,30 +1181,8 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
CModelManager manager = CModelManager.getDefault();
|
CModelManager manager = CModelManager.getDefault();
|
||||||
ICProject cproject = manager.create(project);
|
ICProject cproject = manager.create(project);
|
||||||
|
|
||||||
SetCProjectDescriptionOperation op = new SetCProjectDescriptionOperation(cproject, (CProjectDescription)des);
|
SetCProjectDescriptionOperation op = new SetCProjectDescriptionOperation(cproject, (CProjectDescription)des, flags);
|
||||||
op.runOperation(monitor);
|
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{
|
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.model.ICProject;
|
||||||
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
import org.eclipse.cdt.core.settings.model.CProjectDescriptionEvent;
|
||||||
import org.eclipse.cdt.core.settings.model.ICDescriptionDelta;
|
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.model.CModelOperation;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.CompositeWorkspaceRunnable;
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.CompositeWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -26,16 +27,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
|
||||||
public class SetCProjectDescriptionOperation extends CModelOperation {
|
public class SetCProjectDescriptionOperation extends CModelOperation {
|
||||||
// private IProject fProject;
|
|
||||||
// private ICProject fCProject;
|
|
||||||
private CProjectDescription fSetDescription;
|
private CProjectDescription fSetDescription;
|
||||||
// private CProjectDescription fNewDescriptionCache;
|
private int fFlags;
|
||||||
// private ICProjectDescription fOldDescriptionCache;
|
|
||||||
|
|
||||||
|
SetCProjectDescriptionOperation(ICProject cProject, CProjectDescription description, int flags){
|
||||||
SetCProjectDescriptionOperation(ICProject cProject, CProjectDescription description){
|
|
||||||
super(cProject);
|
super(cProject);
|
||||||
// fCProject = cProject;
|
fFlags = flags;
|
||||||
fSetDescription = description;
|
fSetDescription = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +116,9 @@ public class SetCProjectDescriptionOperation extends CModelOperation {
|
||||||
mngr.notifyListeners(event);
|
mngr.notifyListeners(event);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if(!CProjectDescriptionManager.checkFlags(fFlags, ICProjectDescriptionManager.SET_NO_SERIALIZE))
|
||||||
runnable.add(mngr.createDesSerializationRunnable(fNewDescriptionCache));
|
runnable.add(mngr.createDesSerializationRunnable(fNewDescriptionCache));
|
||||||
|
if(!runnable.isEmpty())
|
||||||
mngr.runWspModification(runnable, new NullProgressMonitor());
|
mngr.runWspModification(runnable, new NullProgressMonitor());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
throw new CModelException(e);
|
throw new CModelException(e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue