From cdcd20852121d2155aff5601b0c78a84e9a7f2f3 Mon Sep 17 00:00:00 2001 From: Mikhail Sennikovsky Date: Thu, 29 Mar 2007 20:10:54 +0000 Subject: [PATCH] Fix to [Bug 174824] Specifying buildArtefactType not intuitive --- .../schema/buildDefinitions.exsd | 26 +++++++++ .../managedbuilder/core/IConfiguration.java | 6 ++ .../managedbuilder/core/IManagedProject.java | 1 + .../cdt/managedbuilder/core/IProjectType.java | 4 ++ .../buildproperties/BuildProperties.java | 27 +++++++-- .../buildproperties/BuildProperty.java | 10 ++-- .../internal/core/Configuration.java | 57 ++++++++++++++++--- .../internal/core/ManagedProject.java | 14 +++++ .../internal/core/ProjectType.java | 23 ++++++++ .../plugin.xml | 30 +++++----- 10 files changed, 166 insertions(+), 32 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd index fb3e0ced7e4..64c6e9c2e8b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd +++ b/build/org.eclipse.cdt.managedbuilder.core/schema/buildDefinitions.exsd @@ -150,6 +150,19 @@ property type-value pairs are specified in the type_id=value_id format. + + + + the attribute specified the Build Artefact Type. can contain the value id of the "org.eclipse.cdt.build.core.buildArtefactType" build property. Default values contributed with the build system are +"org.eclipse.cdt.build.core.buildArtefactType.exe" - represents executable, +"org.eclipse.cdt.build.core.buildArtefactType.staticLib" - represents static library, +"org.eclipse.cdt.build.core.buildArtefactType.sharedLib" - represents dynamic library +Custom values can be contributed via the "org.eclipse.cdt.managedbuilder.core.buildProperties" extension point. See the description of that extension point for more detail. + +Specifying this attribute is fully equivalent to specifying the "org.eclipse.cdt.build.core.buildArtefactType" via tne buildProperties attribute. The buildArtefactType attribute, the "buildArtefactType" attribute value takes precedence over the artefact type specified via the "buildProperties" attribute + + + @@ -299,6 +312,19 @@ property type-value pairs are specified in the type_id=value_id format. + + + + the attribute specified the Build Artefact Type. can contain the value id of the "org.eclipse.cdt.build.core.buildArtefactType" build property. Default values contributed with the build system are +"org.eclipse.cdt.build.core.buildArtefactType.exe" - represents executable, +"org.eclipse.cdt.build.core.buildArtefactType.staticLib" - represents static library, +"org.eclipse.cdt.build.core.buildArtefactType.sharedLib" - represents dynamic library +Custom values can be contributed via the "org.eclipse.cdt.managedbuilder.core.buildProperties" extension point. See the description of that extension point for more detail. + +Specifying this attribute is fully equivalent to specifying the "org.eclipse.cdt.build.core.buildArtefactType" via tne buildProperties attribute. The buildArtefactType attribute, the "buildArtefactType" attribute value takes precedence over the artefact type specified via the "buildProperties" attribute + + + diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java index 20181864ba4..701e0a3465a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IConfiguration.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.managedbuilder.core; import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; +import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue; import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier; import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier; import org.eclipse.core.resources.IFile; @@ -46,6 +47,7 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont public static final String DESCRIPTION = "description"; //$NON-NLS-1$ public static final String BUILD_PROPERTIES = "buildProperties"; //$NON-NLS-1$ + public static final String BUILD_ARTEFACT_TYPE = "buildArtefactType"; //$NON-NLS-1$ public static final String IS_SYSTEM = "isSystem"; //$NON-NLS-1$ @@ -620,4 +622,8 @@ public interface IConfiguration extends IBuildObject, IBuildObjectPropertiesCont boolean isBuilderCompatible(IBuilder builder); void changeBuilder(IBuilder newBuilder, String id, String name); + + IBuildPropertyValue getBuildArtefactType(); + + void setBuildArtefactType(String id) throws BuildException; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java index 0c1ff5912f8..7fb596d9c51 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java @@ -42,6 +42,7 @@ public interface IManagedProject extends IBuildObject, IBuildObjectPropertiesCon public static final String MANAGED_PROJECT_ELEMENT_NAME = "project"; //$NON-NLS-1$ public static final String PROJECTTYPE = "projectType"; //$NON-NLS-1$ public static final String BUILD_PROPERTIES = "buildProperties"; //$NON-NLS-1$ + public static final String BUILD_ARTEFACT_TYPE = "buildArtefactType"; //$NON-NLS-1$ /** diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java index c2f6a7d0f1c..441d8d718d2 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IProjectType.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.core; +import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue; import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier; import org.eclipse.cdt.managedbuilder.macros.IProjectBuildMacroSupplier; @@ -52,6 +53,7 @@ public interface IProjectType extends IBuildObject, IBuildObjectPropertiesContai public static final String PROJECT_ENVIRONMENT_SUPPLIER = "projectEnvironmentSupplier"; //$NON-NLS-1$ public static final String PROJECT_MACRO_SUPPLIER = "projectMacroSupplier"; //$NON-NLS-1$ public static final String BUILD_PROPERTIES = "buildProperties"; //$NON-NLS-1$ + public static final String BUILD_ARTEFACT_TYPE = "buildArtefactType"; //$NON-NLS-1$ /** @@ -191,4 +193,6 @@ public interface IProjectType extends IBuildObject, IBuildObjectPropertiesContai public boolean checkForMigrationSupport(); public String getNameAttribute(); + + public IBuildPropertyValue getBuildArtefactType(); } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperties.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperties.java index a68ee2df80f..a21353e56b1 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperties.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperties.java @@ -64,13 +64,28 @@ public class BuildProperties implements IBuildProperties { void addProperty(IBuildProperty property){ fPropertiesMap.put(property.getPropertyType().getId(), property); } - + public IBuildProperty setProperty(String propertyId, String propertyValue) throws CoreException { - IBuildProperty property = BuildPropertyManager.getInstance().createProperty(propertyId, propertyValue); - - addProperty(property); - - return property; + return setProperty(propertyId, propertyValue, false); + } + + public IBuildProperty setProperty(String propertyId, String propertyValue, boolean force) throws CoreException { + try { + IBuildProperty property = BuildPropertyManager.getInstance().createProperty(propertyId, propertyValue); + + addProperty(property); + + return property; + } catch (CoreException e){ + if(force){ + if(fInexistentProperties == null) + fInexistentProperties = new ArrayList(1); + + fInexistentProperties.add(BuildProperty.toString(propertyId, propertyValue)); + fInexistentProperties.trimToSize(); + } + throw e; + } } public IBuildProperty removeProperty(String id){ diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperty.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperty.java index 68715c6d0aa..338494b9f85 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperty.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/buildproperties/BuildProperty.java @@ -13,9 +13,6 @@ package org.eclipse.cdt.managedbuilder.internal.buildproperties; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildProperty; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyType; import org.eclipse.cdt.managedbuilder.buildproperties.IBuildPropertyValue; -import org.eclipse.cdt.managedbuilder.core.IInputType; -import org.eclipse.cdt.managedbuilder.core.IResourceInfo; -import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; @@ -74,9 +71,14 @@ public class BuildProperty implements IBuildProperty{ } public String toString(){ + return toString(fType.toString(), fValue.toString()); + } + + public static String toString(String type, String value){ StringBuffer buf = new StringBuffer(); - buf.append(fType.toString()).append(BuildPropertyManager.PROPERTY_VALUE_SEPARATOR).append(fValue.toString()); + buf.append(type).append(BuildPropertyManager.PROPERTY_VALUE_SEPARATOR).append(value); return buf.toString(); + } /* public Object clone() { diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index 2fcb78dae53..4d52f9e48a1 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -247,6 +247,19 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild String props = element.getAttribute(BUILD_PROPERTIES); if(props != null) buildProperties = new BuildObjectProperties(props, this, this); + + String artType = element.getAttribute(BUILD_ARTEFACT_TYPE); + if(artType != null){ + if(buildProperties == null) + buildProperties = new BuildObjectProperties(this, this); + + try { + buildProperties.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artType, true); + } catch (CoreException e) { + ManagedBuilderCorePlugin.log(e); + } + } + if(projectType != null && projectType.buildProperties != null){ if(buildProperties == null){ buildProperties = new BuildObjectProperties(projectType.buildProperties, this, this); @@ -765,6 +778,19 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild String props = element.getAttribute(BUILD_PROPERTIES); if(props != null) buildProperties = new BuildObjectProperties(props, this, this); + + String artType = element.getAttribute(BUILD_ARTEFACT_TYPE); + if(artType != null){ + if(buildProperties == null) + buildProperties = new BuildObjectProperties(this, this); + + try { + buildProperties.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artType, true); + } catch (CoreException e) { + ManagedBuilderCorePlugin.log(e); + } + } + if (element.getAttribute(IConfiguration.PARENT) != null) { // See if the parent belongs to the same project @@ -835,6 +861,12 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild if(buildProperties != null) element.setAttribute(BUILD_PROPERTIES, buildProperties.toString()); + IBuildProperty prop = buildProperties.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID); + if(prop != null){ + IBuildPropertyValue val = prop.getValue(); + element.setAttribute(BUILD_ARTEFACT_TYPE, val.getId()); + } + if (parent != null) element.setAttribute(IConfiguration.PARENT, parent.getId()); @@ -2843,11 +2875,22 @@ public class Configuration extends BuildObject implements IConfiguration, IBuild return isPreferenceConfig; } -// public boolean isPerFileDiscoveryCache(){ -// return isPerFileDiscoveryCache; -// } -// -// public void setPerFileDiscoveryCache(boolean perFile){ -// isPerFileDiscoveryCache = perFile; -// } + public IBuildPropertyValue getBuildArtefactType() { + IBuildObjectProperties props = findBuildProperties(); + if(props != null){ + IBuildProperty prop = props.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID); + if(prop != null) + return prop.getValue(); + } + return null; + } + + public void setBuildArtefactType(String id) throws BuildException { + IBuildObjectProperties props = getBuildProperties(); + try { + props.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, id); + } catch (CoreException e){ + throw new BuildException(e.getLocalizedMessage()); + } + } } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java index 3e9932d1697..6e16c2b509f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java @@ -32,8 +32,10 @@ import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; import org.eclipse.cdt.managedbuilder.core.IManagedProject; import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.utils.envvar.StorableEnvironment; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.PluginVersionIdentifier; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -194,6 +196,18 @@ public class ManagedProject extends BuildObject implements IManagedProject, IBui if(props != null && props.length() != 0) buildProperties = new BuildObjectProperties(props, this, this); + String artType = element.getAttribute(BUILD_ARTEFACT_TYPE); + if(artType != null){ + if(buildProperties == null) + buildProperties = new BuildObjectProperties(this, this); + + try { + buildProperties.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artType, true); + } catch (CoreException e) { + ManagedBuilderCorePlugin.log(e); + } + } + return true; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java index 2c2285d841d..f6c669c271f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ProjectType.java @@ -27,6 +27,7 @@ import org.eclipse.cdt.managedbuilder.core.IConfigurationNameProvider; import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement; import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin; import org.eclipse.cdt.managedbuilder.envvar.IProjectEnvironmentVariableSupplier; import org.eclipse.cdt.managedbuilder.macros.IProjectBuildMacroSupplier; import org.eclipse.core.runtime.CoreException; @@ -168,6 +169,18 @@ public class ProjectType extends BuildObject implements IProjectType, IBuildProp if(props != null) buildProperties = new BuildObjectProperties(props, this, this); + String artType = element.getAttribute(BUILD_ARTEFACT_TYPE); + if(artType != null){ + if(buildProperties == null) + buildProperties = new BuildObjectProperties(this, this); + + try { + buildProperties.setProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artType, true); + } catch (CoreException e) { + ManagedBuilderCorePlugin.log(e); + } + } + // Get the unused children, if any unusedChildren = element.getAttribute(UNUSED_CHILDREN); @@ -759,4 +772,14 @@ public class ProjectType extends BuildObject implements IProjectType, IBuildProp } return false; } + + public IBuildPropertyValue getBuildArtefactType() { + IBuildObjectProperties props = findBuildProperties(); + if(props != null){ + IBuildProperty prop = props.getProperty(ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID); + if(prop != null) + return prop.getValue(); + } + return null; + } } diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml index b5f8790ec44..51dd37b0f0a 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml @@ -1975,7 +1975,7 @@ @@ -2488,7 +2488,7 @@ @@ -2637,7 +2637,7 @@ @@ -2769,7 +2769,7 @@ @@ -3557,7 +3557,7 @@ @@ -3610,7 +3610,7 @@