summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaltasar Belyavsky2012-02-09 10:18:56 (EST)
committer Andrew Gvozdev2012-02-12 09:02:24 (EST)
commit6b66aef60bc1a3ee2f5fa862ed63f48721b1c15f (patch)
treeca21d2f6fab5298a6e9c78e20fdbaf8bd0ed3a10
parent088185204c04f304896540521a423111ae2afc36 (diff)
downloadorg.eclipse.cdt-6b66aef60bc1a3ee2f5fa862ed63f48721b1c15f.zip
org.eclipse.cdt-6b66aef60bc1a3ee2f5fa862ed63f48721b1c15f.tar.gz
org.eclipse.cdt-6b66aef60bc1a3ee2f5fa862ed63f48721b1c15f.tar.bz2
bug 340219: Project metadata files are saved unnecessarily, patch to
address .project file modifications
-rw-r--r--build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java32
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java97
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildBuildData.java22
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java44
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CBuildData.java20
5 files changed, 103 insertions, 112 deletions
diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
index 10bbd64..52e7f70 100644
--- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
+++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/BuildInfoFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * Copyright (c) 2000, 2012 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
+ * Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
*******************************************************************************/
package org.eclipse.cdt.make.internal.core;
@@ -18,6 +19,10 @@ import java.util.Map.Entry;
import java.util.StringTokenizer;
import org.eclipse.cdt.core.ErrorParserManager;
+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.extension.CBuildData;
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
import org.eclipse.cdt.make.core.IMakeCommonBuildInfo;
import org.eclipse.cdt.make.core.MakeCorePlugin;
@@ -493,12 +498,27 @@ public class BuildInfoFactory {
BuildInfoProject(IProject project, String builderID) throws CoreException {
this.project = project;
this.builderID = builderID;
- ICommand builder;
- builder = MakeProjectNature.getBuildSpec(project.getDescription(), builderID);
- if (builder == null) {
- throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
- MakeMessages.getString("BuildInfoFactory.Missing_Builder") + builderID, null)); //$NON-NLS-1$
+
+ ICommand builder = null;
+
+ // first, give the build-system a chance to return the build-command overlayed with data managed by it
+ ICProjectDescription cProjectDescription = CoreModel.getDefault().getProjectDescription(project, false);
+ if(cProjectDescription != null) {
+ ICConfigurationDescription cConfigDescription = cProjectDescription.getActiveConfiguration();
+ CBuildData buildData = cConfigDescription.getConfigurationData().getBuildData();
+ if(buildData != null) {
+ builder = buildData.getBuildSpecCommand();
+ }
}
+
+ if(builder == null) {
+ builder = MakeProjectNature.getBuildSpec(project.getDescription(), builderID);
+ if (builder == null) {
+ throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1,
+ MakeMessages.getString("BuildInfoFactory.Missing_Builder") + builderID, null)); //$NON-NLS-1$
+ }
+ }
+
Map<String, String> builderArgs = builder.getArguments();
args = builderArgs;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
index 31f262e..bd0fd00 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/BuilderFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * Copyright (c) 2007, 2012 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Intel Corporation - Initial API and implementation
+ * Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.core;
@@ -25,7 +26,6 @@ import org.eclipse.cdt.managedbuilder.core.IManagedProject;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
@@ -59,7 +59,6 @@ public class BuilderFactory {
static final String CONTENTS_BUILDER = PREFIX + ".builder"; //$NON-NLS-1$
static final String CONTENTS_BUILDER_CUSTOMIZATION = PREFIX + ".builderCustomization"; //$NON-NLS-1$
static final String CONTENTS_CONFIGURATION_IDS = PREFIX + ".configurationIds"; //$NON-NLS-1$
- static final String CONTENTS_ACTIVE_CFG_SETTINGS = PREFIX + ".activeConfigSettings"; //$NON-NLS-1$
// static final String IDS = PREFIX + ".ids"; //$NON-NLS-1$
static final String CONFIGURATION_IDS = PREFIX + ".configurationIds"; //$NON-NLS-1$
@@ -225,19 +224,6 @@ public class BuilderFactory {
return el.toStringMap();
}
- private static Map<String, String> builderBuildArgsMap(IBuilder builder){
- MapStorageElement el = new BuildArgsStorageElement("", null); //$NON-NLS-1$
- ((Builder)builder).serializeRawData(el);
-
- Boolean d = Boolean.valueOf(builder.isDefaultBuildCmd());
- el.setAttribute(BuilderFactory.USE_DEFAULT_BUILD_CMD, d.toString());
-
- Map<String, String> map = el.toStringMap();
- map.put(CONTENTS, CONTENTS_ACTIVE_CFG_SETTINGS);
-
- return map;
- }
-
public static IBuilder createCustomBuilder(IConfiguration cfg, String builderId) throws CoreException{
IBuilder builder = cfg.getBuilder();
if(!builderId.equals(builder.getId())){
@@ -293,6 +279,31 @@ public class BuilderFactory {
// return createBuilder(cfg, args);
}
+ /**
+ * Creates a new build-command containing data dynamically obtained from the Builder.
+ */
+ public static ICommand createCommandFromBuilder(IBuilder builder) throws CoreException {
+ IProject project = builder.getParent().getParent().getOwner().getProject();
+ ICommand command = getBuildSpec(project.getDescription(), CommonBuilder.BUILDER_ID);
+ if(command == null)
+ return null;
+
+ MapStorageElement el = new BuildArgsStorageElement("", null); //$NON-NLS-1$
+ ((Builder)builder).serializeRawData(el);
+
+ // always set to false - the raw data will always explicitly contain the build-command
+ el.setAttribute(BuilderFactory.USE_DEFAULT_BUILD_CMD, Boolean.FALSE.toString());
+
+ command.setArguments(el.toStringMap());
+
+ command.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, builder.isAutoBuildEnable());
+ command.setBuilding(IncrementalProjectBuilder.FULL_BUILD, builder.isFullBuildEnabled());
+ command.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, builder.isIncrementalBuildEnabled());
+ command.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, builder.isCleanBuildEnabled());
+
+ return command;
+ }
+
public static ICommand getBuildSpec(IProjectDescription description, String builderID) {
ICommand[] commands = description.getBuildSpec();
for (int i = 0; i < commands.length; ++i) {
@@ -350,6 +361,7 @@ public class BuilderFactory {
IConfiguration cfg = info.getDefaultConfiguration();
IBuilder builder = cfg.getEditableBuilder();
builders = new IBuilder[]{builder};
+
} else {
String type = args.get(CONTENTS);
if(type == null || CONTENTS_BUILDER_CUSTOMIZATION.equals(type)){
@@ -361,12 +373,6 @@ public class BuilderFactory {
builder = createBuilder(cfg, args, true);
}
builders = new IBuilder[]{builder};
- } else if (CONTENTS_ACTIVE_CFG_SETTINGS.equals(type)) {
- IConfiguration cfg = info.getDefaultConfiguration();
-
- IBuilder builder = cfg.getEditableBuilder();
-
- builders = new IBuilder[]{builder};
} else if (CONTENTS_BUILDER.equals(type)){
IConfiguration cfgs[] = configsFromMap(args, info);
@@ -379,6 +385,7 @@ public class BuilderFactory {
}
builders = list.toArray(new IBuilder[list.size()]);
}
+
} else if (CONTENTS_CONFIGURATION_IDS.equals(type)){
IConfiguration cfgs[] = configsFromMap(args, info);
if(cfgs.length != 0){
@@ -388,6 +395,17 @@ public class BuilderFactory {
}
builders = list.toArray(new IBuilder[list.size()]);
}
+
+ } else if ("org.eclipse.cdt.make.core.activeConfigSettings".equals(type)) { //$NON-NLS-1$
+ /* NOTE: Here, only for backwards-compatibility support, since bug 340219 was fixed.
+ * Existing projects will still be going through this execution path, but new
+ * projects will no longer store the active-configuration's builder-arguments in the
+ * build-command, and will be going through the "args == null" condition above.
+ */
+ IConfiguration cfg = info.getDefaultConfiguration();
+ IBuilder builder = cfg.getEditableBuilder();
+ builders = new IBuilder[]{builder};
+
} /*else if (CONTENTS_BUILDER_CUSTOMIZATION.equals(type)){
String idsString = (String)args.get(CONFIGURATION_IDS);
if(idsString != null){
@@ -415,39 +433,4 @@ public class BuilderFactory {
return EMPTY_BUILDERS_ARRAY;
}
- public static int applyBuilder(IProjectDescription eDes, IBuilder builder){
- return applyBuilder(eDes, CommonBuilder.BUILDER_ID, builder);
- }
-
- public static final int CMD_UNDEFINED = -1;
- public static final int NO_CHANGES = 0;
- public static final int CMD_CHANGED = 1;
-
- public static int applyBuilder(IProjectDescription eDes, String eBuilderId, IBuilder builder){
- ICommand cmd = ManagedCProjectNature.getBuildSpec(eDes, eBuilderId);
- if(cmd == null)
- return CMD_UNDEFINED;
-
- if(applyBuilder(cmd, builder)){
- ManagedCProjectNature.setBuildSpec(eDes, cmd);
- return CMD_CHANGED;
- }
- return NO_CHANGES;
- }
-
- public static boolean applyBuilder(ICommand cmd, IBuilder builder) {
- Map<String, String> oldMap = cmd.getArguments();
- Map<String, String> map = builderBuildArgsMap(builder);
-
- if(oldMap.equals(map))
- return false;
-
- cmd.setArguments(map);
-
- cmd.setBuilding(IncrementalProjectBuilder.AUTO_BUILD, builder.isAutoBuildEnable());
- cmd.setBuilding(IncrementalProjectBuilder.FULL_BUILD, builder.isFullBuildEnabled());
- cmd.setBuilding(IncrementalProjectBuilder.INCREMENTAL_BUILD, builder.isIncrementalBuildEnabled());
- cmd.setBuilding(IncrementalProjectBuilder.CLEAN_BUILD, builder.isCleanBuildEnabled());
- return true;
- }
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildBuildData.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildBuildData.java
index 9f539b6..d4f94ad 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildBuildData.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/BuildBuildData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Intel Corporation and others.
+ * Copyright (c) 2007, 2012 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Intel Corporation - Initial API and implementation
+ * Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.dataprovider;
@@ -14,8 +15,12 @@ import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
import org.eclipse.cdt.core.settings.model.ICOutputEntry;
import org.eclipse.cdt.core.settings.model.extension.CBuildData;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
+import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@@ -32,7 +37,7 @@ public class BuildBuildData extends CBuildData {
public IPath getBuilderCWD() {
return new Path(fBuilder.getBuildPath());//ManagedBuildManager.getBuildLocation(fCfg, fBuilder);
}
-
+
// private IPath createAbsolutePathFromWorkspacePath(IPath path){
// IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
// String locationString = mngr.generateVariableExpression("workspace_loc", path.toString()); //$NON-NLS-1$
@@ -90,7 +95,18 @@ public class BuildBuildData extends CBuildData {
// return fEnvContibutor;
return new BuildEnvironmentContributor(this);
}
-
+
+ @Override
+ public ICommand getBuildSpecCommand() {
+ try {
+ return BuilderFactory.createCommandFromBuilder(this.fBuilder);
+ }
+ catch(CoreException cx) {
+ ManagedBuilderCorePlugin.log(cx);
+ return null;
+ }
+ }
+
public IBuilder getBuilder(){
return fBuilder;
}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
index 2e57720..82a1c9c 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/dataprovider/ConfigurationDataProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Intel Corporation and others.
+ * Copyright (c) 2007, 2012 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Intel Corporation - Initial API and implementation
+ * Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
*******************************************************************************/
package org.eclipse.cdt.managedbuilder.internal.dataprovider;
@@ -29,7 +30,6 @@ import org.eclipse.cdt.core.settings.model.IModificationContext;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
import org.eclipse.cdt.core.settings.model.extension.CConfigurationDataProvider;
import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IFolderInfo;
import org.eclipse.cdt.managedbuilder.core.IInputType;
@@ -43,7 +43,6 @@ import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
-import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ISettingsChangeListener;
import org.eclipse.cdt.managedbuilder.internal.core.InputType;
@@ -54,7 +53,6 @@ import org.eclipse.cdt.managedbuilder.internal.core.SettingsChangeEvent;
import org.eclipse.cdt.managedbuilder.internal.core.Tool;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.QualifiedName;
@@ -83,28 +81,6 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
}
}
- private static class DesApplyRunnable implements IWorkspaceRunnable {
- IBuilder fBuilder;
- IProject fProject;
-
- DesApplyRunnable(IProject project, IBuilder builder){
- fProject = project;
- fBuilder = builder;
- }
-
- @Override
- public void run(IProgressMonitor monitor) throws CoreException {
- try {
- IProjectDescription eDes = fProject.getDescription();
- if(BuilderFactory.applyBuilder(eDes, fBuilder) == BuilderFactory.CMD_CHANGED) {
- fProject.setDescription(eDes, monitor);
- }
- } catch (Exception e){
- ManagedBuilderCorePlugin.log(e);
- }
- }
-
- }
static BuildConfigurationData writeConfiguration(ICConfigurationDescription cfgDescription,
BuildConfigurationData base) throws CoreException {
BuildConfigurationData appliedCfg = base;
@@ -178,22 +154,6 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
setPersistedFlag(cfgDescription);
cacheNaturesIdsUsedOnCache(cfgDescription);
-
- if(cfgDescription.isActive()){
- IConfiguration cfg = appliedCfg.getConfiguration();
- IBuilder builder = cfg.getEditableBuilder();
- IProject project = context.getProject();
- IProjectDescription eDes = context.getEclipseProjectDescription();
- switch(BuilderFactory.applyBuilder(eDes, builder)){
- case BuilderFactory.CMD_UNDEFINED:
- IWorkspaceRunnable applyR = new DesApplyRunnable(project, builder);
- context.addWorkspaceRunnable(applyR);
- break;
- case BuilderFactory.CMD_CHANGED:
- context.setEclipseProjectDescription(eDes);
- break;
- }
- }
}
return appliedCfg;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CBuildData.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CBuildData.java
index 4d42f17..d1f67b3 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CBuildData.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/extension/CBuildData.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2008 Intel Corporation and others.
+ * Copyright (c) 2007, 2012 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
@@ -7,12 +7,14 @@
*
* Contributors:
* Intel Corporation - Initial API and implementation
+ * Baltasar Belyavsky (Texas Instruments) - bug 340219: Project metadata files are saved unnecessarily
*******************************************************************************/
package org.eclipse.cdt.core.settings.model.extension;
import org.eclipse.cdt.core.envvar.IEnvironmentContributor;
import org.eclipse.cdt.core.settings.model.ICOutputEntry;
import org.eclipse.cdt.core.settings.model.ICSettingBase;
+import org.eclipse.core.resources.ICommand;
import org.eclipse.core.runtime.IPath;
public abstract class CBuildData extends CDataObject {
@@ -26,12 +28,22 @@ public abstract class CBuildData extends CDataObject {
public abstract void setBuilderCWD(IPath path);
public abstract ICOutputEntry[] getOutputDirectories();
-
+
public abstract void setOutputDirectories(ICOutputEntry[] entries);
-
+
public abstract String[] getErrorParserIDs();
public abstract void setErrorParserIDs(String[] ids);
-
+
public abstract IEnvironmentContributor getBuildEnvironmentContributor();
+
+ /**
+ * Override to return the build-command overlayed with data (eg. builder-arguments) managed by the build-system.
+ *
+ * @since 5.4
+ */
+ public ICommand getBuildSpecCommand() {
+ return null;
+ }
+
}