ProjectType
the configuration will be added to.
- * @param parentConfig The IConfiguration
that is the parent configuration of this configuration
- * @param id A unique ID for the new configuration.
- */
- public Configuration(ProjectType projectType, IConfiguration parentConfig, String id) {
- setId(id);
- this.projectType = projectType;
- isExtensionConfig = true;
-
- // setup for resolving
- resolved = false;
-
- if (parentConfig != null) {
- name = parentConfig.getName();
- // If this contructor is called to clone an existing
- // configuration, the parent of the parent should be stored.
- // As of 2.1, there is still one single level of inheritence to
- // worry about
- parent = parentConfig.getParent() == null ? parentConfig : parentConfig.getParent();
- }
-
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionConfiguration(this);
-
- // Hook me up to the ProjectType
- if (projectType != null) {
- projectType.addConfiguration(this);
- // set managedBuildRevision
- setManagedBuildRevision(projectType.getManagedBuildRevision());
- }
- }
-
- /**
- * Create a new extension configuration and fill in the attributes and childen later.
- *
- * @param projectType The ProjectType
the configuration will be added to.
- * @param parentConfig The IConfiguration
that is the parent configuration of this configuration
- * @param id A unique ID for the new configuration.
- * @param name A name for the new configuration.
- */
- public Configuration(ProjectType projectType, IConfiguration parentConfig, String id, String name) {
- setId(id);
- setName(name);
- this.projectType = projectType;
- parent = parentConfig;
- isExtensionConfig = true;
-
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionConfiguration(this);
-
- // Hook me up to the ProjectType
- if (projectType != null) {
- projectType.addConfiguration(this);
- setManagedBuildRevision(projectType.getManagedBuildRevision());
- }
- }
-
- /**
- * Create a Configuration
based on the specification stored in the
- * project file (.cdtbuild).
- *
- * @param managedProject The ManagedProject
the configuration will be added to.
- * @param element The XML element that contains the configuration settings.
- *
- */
- public Configuration(ManagedProject managedProject, Element element, String managedBuildRevision) {
- this.managedProject = managedProject;
- isExtensionConfig = false;
-
- setManagedBuildRevision(managedBuildRevision);
-
- // Initialize from the XML attributes
- loadFromProject(element);
-
- // Hook me up
- managedProject.addConfiguration(this);
-
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
- toolChain = new ToolChain(this, (Element)configElement, managedBuildRevision);
- }else if (configElement.getNodeName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
- ResourceConfiguration resConfig = new ResourceConfiguration(this, (Element)configElement, managedBuildRevision);
- addResourceConfiguration(resConfig);
- }
- }
- }
-
- /**
- * Create a new project, non-extension, configuration based on one already defined.
- *
- * @param managedProject The ManagedProject
the configuration will be added to.
- * @param cloneConfig The IConfiguration
to copy the settings from.
- * @param id A unique ID for the new configuration.
- * @param cloneChildren If true
, the configuration's tools are cloned
- */
- public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary) {
- setId(id);
- setName(cloneConfig.getName());
- this.description = cloneConfig.getDescription();
- this.managedProject = managedProject;
- isExtensionConfig = false;
- this.isTemporary = temporary;
-
- // set managedBuildRevision
- setManagedBuildRevision(cloneConfig.getManagedBuildRevision());
-
- // If this contructor is called to clone an existing
- // configuration, the parent of the cloning config should be stored.
- parent = cloneConfig.getParent() == null ? cloneConfig : cloneConfig.getParent();
-
- // Copy the remaining attributes
- projectType = cloneConfig.projectType;
- if (cloneConfig.artifactName != null) {
- artifactName = new String(cloneConfig.artifactName);
- }
- if (cloneConfig.cleanCommand != null) {
- cleanCommand = new String(cloneConfig.cleanCommand);
- }
- if (cloneConfig.artifactExtension != null) {
- artifactExtension = new String(cloneConfig.artifactExtension);
- }
- if (cloneConfig.errorParserIds != null) {
- errorParserIds = new String(cloneConfig.errorParserIds);
- }
- if (cloneConfig.prebuildStep != null) {
- prebuildStep = new String(cloneConfig.prebuildStep);
- }
- if (cloneConfig.postbuildStep != null) {
- postbuildStep = new String(cloneConfig.postbuildStep);
- }
- if (cloneConfig.preannouncebuildStep != null) {
- preannouncebuildStep = new String(cloneConfig.preannouncebuildStep);
- }
- if (cloneConfig.postannouncebuildStep != null) {
- postannouncebuildStep = new String(cloneConfig.postannouncebuildStep);
- }
-
- // Clone the configuration's children
- // Tool Chain
- String subId;
- String subName;
- if (cloneConfig.parent != null) {
- subId = ManagedBuildManager.calculateChildId(
- cloneConfig.parent.getToolChain().getId(),
- null);
- subName = cloneConfig.parent.getToolChain().getName();
-
- } else {
- subId = ManagedBuildManager.calculateChildId(
- cloneConfig.getToolChain().getId(),
- null);
- subName = cloneConfig.getToolChain().getName();
- }
-
- if (cloneChildren) {
- toolChain = new ToolChain(this, subId, subName, (ToolChain)cloneConfig.getToolChain());
-
- //copy expand build macros setting
- BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
- macroProvider.expandMacrosInBuildfile(this,
- macroProvider.areMacrosExpandedInBuildfile(cloneConfig));
-
- //copy user-defined build macros
- UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
- userMacros.setMacros(
- userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig),
- BuildMacroProvider.CONTEXT_CONFIGURATION,
- this);
-
- //copy user-defined environment
- UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
- userEnv.setVariables(
- userEnv.getVariables(cloneConfig), this);
-
- } else {
- // Add a tool-chain element that specifies as its superClass the
- // tool-chain that is the child of the configuration.
- ToolChain superChain = (ToolChain)cloneConfig.getToolChain();
- subId = ManagedBuildManager.calculateChildId(
- superChain.getId(),
- null);
- IToolChain newChain = createToolChain(superChain, subId, superChain.getName(), false);
-
- // For each option/option category child of the tool-chain that is
- // the child of the selected configuration element, create an option/
- // option category child of the cloned configuration's tool-chain element
- // that specifies the original tool element as its superClass.
- newChain.createOptions(superChain);
-
- // For each tool element child of the tool-chain that is the child of
- // the selected configuration element, create a tool element child of
- // the cloned configuration's tool-chain element that specifies the
- // original tool element as its superClass.
- ITool[] tools = superChain.getTools();
- for (int i=0; iProjectType
the configuration will be added to.
+ * @param parentConfig The IConfiguration
that is the parent configuration of this configuration
+ * @param id A unique ID for the new configuration.
+ */
+ public Configuration(ProjectType projectType, IConfiguration parentConfig, String id) {
+ setId(id);
+ this.projectType = projectType;
+ isExtensionConfig = true;
+
+ // setup for resolving
+ resolved = false;
+
+ if (parentConfig != null) {
+ name = parentConfig.getName();
+ // If this contructor is called to clone an existing
+ // configuration, the parent of the parent should be stored.
+ // As of 2.1, there is still one single level of inheritence to
+ // worry about
+ parent = parentConfig.getParent() == null ? parentConfig : parentConfig.getParent();
+ }
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionConfiguration(this);
+
+ // Hook me up to the ProjectType
+ if (projectType != null) {
+ projectType.addConfiguration(this);
+ // set managedBuildRevision
+ setManagedBuildRevision(projectType.getManagedBuildRevision());
+ }
+ }
+
+ /**
+ * Create a new extension configuration and fill in the attributes and childen later.
+ *
+ * @param projectType The ProjectType
the configuration will be added to.
+ * @param parentConfig The IConfiguration
that is the parent configuration of this configuration
+ * @param id A unique ID for the new configuration.
+ * @param name A name for the new configuration.
+ */
+ public Configuration(ProjectType projectType, IConfiguration parentConfig, String id, String name) {
+ setId(id);
+ setName(name);
+ this.projectType = projectType;
+ parent = parentConfig;
+ isExtensionConfig = true;
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionConfiguration(this);
+
+ // Hook me up to the ProjectType
+ if (projectType != null) {
+ projectType.addConfiguration(this);
+ setManagedBuildRevision(projectType.getManagedBuildRevision());
+ }
+ }
+
+ /**
+ * Create a Configuration
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param managedProject The ManagedProject
the configuration will be added to.
+ * @param element The XML element that contains the configuration settings.
+ *
+ */
+ public Configuration(ManagedProject managedProject, Element element, String managedBuildRevision) {
+ this.managedProject = managedProject;
+ isExtensionConfig = false;
+
+ setManagedBuildRevision(managedBuildRevision);
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // Hook me up
+ managedProject.addConfiguration(this);
+
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(IToolChain.TOOL_CHAIN_ELEMENT_NAME)) {
+ toolChain = new ToolChain(this, (Element)configElement, managedBuildRevision);
+ }else if (configElement.getNodeName().equals(IResourceConfiguration.RESOURCE_CONFIGURATION_ELEMENT_NAME)) {
+ ResourceConfiguration resConfig = new ResourceConfiguration(this, (Element)configElement, managedBuildRevision);
+ addResourceConfiguration(resConfig);
+ }
+ }
+ }
+
+ /**
+ * Create a new project, non-extension, configuration based on one already defined.
+ *
+ * @param managedProject The ManagedProject
the configuration will be added to.
+ * @param cloneConfig The IConfiguration
to copy the settings from.
+ * @param id A unique ID for the new configuration.
+ * @param cloneChildren If true
, the configuration's tools are cloned
+ */
+ public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneChildren, boolean temporary) {
+ setId(id);
+ setName(cloneConfig.getName());
+ this.description = cloneConfig.getDescription();
+ this.managedProject = managedProject;
+ isExtensionConfig = false;
+ this.isTemporary = temporary;
+
+ // set managedBuildRevision
+ setManagedBuildRevision(cloneConfig.getManagedBuildRevision());
+
+ // If this contructor is called to clone an existing
+ // configuration, the parent of the cloning config should be stored.
+ parent = cloneConfig.getParent() == null ? cloneConfig : cloneConfig.getParent();
+
+ // Copy the remaining attributes
+ projectType = cloneConfig.projectType;
+ if (cloneConfig.artifactName != null) {
+ artifactName = new String(cloneConfig.artifactName);
+ }
+ if (cloneConfig.cleanCommand != null) {
+ cleanCommand = new String(cloneConfig.cleanCommand);
+ }
+ if (cloneConfig.artifactExtension != null) {
+ artifactExtension = new String(cloneConfig.artifactExtension);
+ }
+ if (cloneConfig.errorParserIds != null) {
+ errorParserIds = new String(cloneConfig.errorParserIds);
+ }
+ if (cloneConfig.prebuildStep != null) {
+ prebuildStep = new String(cloneConfig.prebuildStep);
+ }
+ if (cloneConfig.postbuildStep != null) {
+ postbuildStep = new String(cloneConfig.postbuildStep);
+ }
+ if (cloneConfig.preannouncebuildStep != null) {
+ preannouncebuildStep = new String(cloneConfig.preannouncebuildStep);
+ }
+ if (cloneConfig.postannouncebuildStep != null) {
+ postannouncebuildStep = new String(cloneConfig.postannouncebuildStep);
+ }
+
+ // Clone the configuration's children
+ // Tool Chain
+ String subId;
+ String subName;
+ if (cloneConfig.parent != null) {
+ subId = ManagedBuildManager.calculateChildId(
+ cloneConfig.parent.getToolChain().getId(),
+ null);
+ subName = cloneConfig.parent.getToolChain().getName();
+
+ } else {
+ subId = ManagedBuildManager.calculateChildId(
+ cloneConfig.getToolChain().getId(),
+ null);
+ subName = cloneConfig.getToolChain().getName();
+ }
+
+ if (cloneChildren) {
+ toolChain = new ToolChain(this, subId, subName, (ToolChain)cloneConfig.getToolChain());
+
+ //copy expand build macros setting
+ BuildMacroProvider macroProvider = (BuildMacroProvider)ManagedBuildManager.getBuildMacroProvider();
+ macroProvider.expandMacrosInBuildfile(this,
+ macroProvider.areMacrosExpandedInBuildfile(cloneConfig));
+
+ //copy user-defined build macros
+ UserDefinedMacroSupplier userMacros = BuildMacroProvider.fUserDefinedMacroSupplier;
+ userMacros.setMacros(
+ userMacros.getMacros(BuildMacroProvider.CONTEXT_CONFIGURATION,cloneConfig),
+ BuildMacroProvider.CONTEXT_CONFIGURATION,
+ this);
+
+ //copy user-defined environment
+ UserDefinedEnvironmentSupplier userEnv = EnvironmentVariableProvider.fUserSupplier;
+ userEnv.setVariables(
+ userEnv.getVariables(cloneConfig), this);
+
+ } else {
+ // Add a tool-chain element that specifies as its superClass the
+ // tool-chain that is the child of the configuration.
+ ToolChain superChain = (ToolChain)cloneConfig.getToolChain();
+ subId = ManagedBuildManager.calculateChildId(
+ superChain.getId(),
+ null);
+ IToolChain newChain = createToolChain(superChain, subId, superChain.getName(), false);
+
+ // For each option/option category child of the tool-chain that is
+ // the child of the selected configuration element, create an option/
+ // option category child of the cloned configuration's tool-chain element
+ // that specifies the original tool element as its superClass.
+ newChain.createOptions(superChain);
+
+ // For each tool element child of the tool-chain that is the child of
+ // the selected configuration element, create a tool element child of
+ // the cloned configuration's tool-chain element that specifies the
+ // original tool element as its superClass.
+ ITool[] tools = superChain.getTools();
+ for (int i=0; isuperClass
must be shared with the
- * derived class. This requires to wrap this member by access functions
- * in the derived class or frequent casts, because the type of superClass
- * in HoldsOptions
must be IHoldOptions
. Further
- * note that the member resolved
must inherit the value of its
- * derived class. This achieved through the constructor.
- *
- * @since 3.0
- */
-public class HoldsOptions extends BuildObject implements IHoldsOptions {
-
- private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
-
- // Members that are to be shared with the derived class
- protected IHoldsOptions superClass;
- // Members that must have the same values on creation as the derived class
- private boolean resolved;
- // Parent and children
- private Vector categoryIds;
- private Map categoryMap;
- private List childOptionCategories;
- private Vector optionList;
- private Map optionMap;
- // Miscellaneous
- private boolean isDirty = false;
-
- /*
- * C O N S T R U C T O R S
- */
-
- private HoldsOptions() {
- // prevent accidental construction of class without setting up
- // resolved
- }
-
- protected HoldsOptions(boolean resolved) {
- this.resolved = resolved;
- }
-
- /**
- * Copies children of HoldsOptions
. Helper function for
- * derived constructors.
- *
- * @param source The children of the source will be cloned and added
- * to the class itself.
- */
- protected void copyChildren(HoldsOptions source) {
-
- // Note: This function ignores OptionCategories since they should not be
- // found on an non-extension tools
- if (source.optionList != null) {
- Iterator iter = source.getOptionList().listIterator();
- while (iter.hasNext()) {
- Option option = (Option) iter.next();
- int nnn = ManagedBuildManager.getRandomNumber();
- String subId;
- String subName;
- if (option.getSuperClass() != null) {
- subId = option.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
- subName = option.getSuperClass().getName();
- } else {
- subId = option.getId() + "." + nnn; //$NON-NLS-1$
- subName = option.getName();
- }
- Option newOption = new Option(this, subId, subName, option);
- addOption(newOption);
- }
- }
- }
-
- /*
- * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
- */
-
- /**
- * Load child element from XML element if it is of the correct type
- *
- * @param element which is loaded as child only iff it is of the correct type
- * @return true when a child has been loaded, false otherwise
- */
- protected boolean loadChild(Node element) {
- if (element.getNodeName().equals(ITool.OPTION)) {
- Option option = new Option(this, (Element)element);
- addOption(option);
- return true;
- } else if (element.getNodeName().equals(ITool.OPTION_CAT)) {
- new OptionCategory(this, (Element)element);
- return true;
- }
- return false;
- }
-
- /**
- * Load child element from configuration element if it is of the correct type
- *
- * @param element which is loaded as child only iff it is of the correct type
- * @return true when a child has been loaded, false otherwise
- */
- protected boolean loadChild(IManagedConfigElement element) {
- if (element.getName().equals(ITool.OPTION)) {
- Option option = new Option(this, element);
- addOption(option);
- return true;
- } else if (element.getName().equals(ITool.OPTION_CAT)) {
- new OptionCategory(this, element);
- return true;
- }
- return false;
- }
-
- /**
- * Persist the tool to the project file. Intended to be called by derived
- * class only, thus do not handle exceptions.
- *
- * @param doc
- * @param element
- * @throws BuildException
- */
- protected void serialize(Document doc, Element element) throws BuildException {
-
- Iterator iter;
-
- if (childOptionCategories != null) {
- iter = childOptionCategories.listIterator();
- while (iter.hasNext()) {
- OptionCategory optCat = (OptionCategory)iter.next();
- Element optCatElement = doc.createElement(OPTION);
- element.appendChild(optCatElement);
- optCat.serialize(doc, optCatElement);
- }
- }
-
- List optionElements = getOptionList();
- iter = optionElements.listIterator();
- while (iter.hasNext()) {
- Option option = (Option) iter.next();
- Element optionElement = doc.createElement(OPTION);
- element.appendChild(optionElement);
- option.serialize(doc, optionElement);
- }
-}
-
- /*
- * M E T H O D S M O V E D F R O M I T O O L I N 3 . 0
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOption(IOption, String, String, boolean)
- */
- public IOption createOption(IOption superClass, String Id, String name, boolean isExtensionElement) {
- Option option = new Option(this, superClass, Id, name, isExtensionElement);
- addOption(option);
- if(!isExtensionElement)
- setDirty(true);
- return option;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOptions(IHoldsOptions)
- */
- public void createOptions(IHoldsOptions superClass) {
- Iterator iter = ((HoldsOptions)superClass).getOptionList().listIterator();
- while (iter.hasNext()) {
- Option optionChild = (Option) iter.next();
- int nnn = ManagedBuildManager.getRandomNumber();
- String subId = optionChild.getId() + "." + nnn; //$NON-NLS-1$
- createOption(optionChild, subId, optionChild.getName(), false);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#removeOption(IOption)
- */
- public void removeOption(IOption option) {
- getOptionList().remove(option);
- getOptionMap().remove(option.getId());
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptions()
- */
- public IOption[] getOptions() {
- IOption[] options = null;
- // Merge our options with our superclass' options.
- if (superClass != null) {
- options = superClass.getOptions();
- }
- // Our options take precedence.
- Vector ourOpts = getOptionList();
- if (options != null) {
- for (int i = 0; i < ourOpts.size(); i++) {
- int j = options.length;
- IOption ourOpt = (IOption)ourOpts.get(i);
- if (ourOpt.getSuperClass() != null) {
- String matchId = ourOpt.getSuperClass().getId();
- search:
- for (j = 0; j < options.length; j++) {
- IOption superHolderOption = options[j];
- if (((Option)superHolderOption).wasOptRef()) {
- superHolderOption = superHolderOption.getSuperClass();
- }
- while (superHolderOption != null) {
- if (matchId.equals(superHolderOption.getId())) {
- options[j] = ourOpt;
- break search;
- }
- superHolderOption = superHolderOption.getSuperClass();
- }
- }
- }
- // No Match? Add it.
- if (j == options.length) {
- IOption[] newOptions = new IOption[options.length + 1];
- for (int k = 0; k < options.length; k++) {
- newOptions[k] = options[k];
- }
- newOptions[j] = ourOpt;
- options = newOptions;
- }
- }
- } else {
- options = (IOption[])ourOpts.toArray(new IOption[ourOpts.size()]);
- }
- // Check for any invalid options.
- int numInvalidOptions = 0;
- int i;
- for (i=0; i < options.length; i++) {
- if (options[i].isValid() == false) {
- numInvalidOptions++;
- }
- }
- // Take invalid options out of the array, if there are any
- if (numInvalidOptions > 0) {
- int j = 0;
- IOption[] newOptions = new IOption[options.length - numInvalidOptions];
- for (i=0; i < options.length; i++) {
- if (options[i].isValid() == true) {
- newOptions[j] = options[i];
- j++;
- }
- }
- options = newOptions;
- }
- return options;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOption(java.lang.String)
- */
- public IOption getOption(String id) {
- return getOptionById(id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionById(java.lang.String)
- */
- public IOption getOptionById(String id) {
- IOption opt = (IOption)getOptionMap().get(id);
- if (opt == null) {
- if (superClass != null) {
- return superClass.getOptionById(id);
- }
- }
- if (opt == null) return null;
- return opt.isValid() ? opt : null;
- }
-
- /* (non-Javadoc)
- * org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionBySuperClassId(java.lang.String)
- */
- public IOption getOptionBySuperClassId(String optionId) {
- if (optionId == null) return null;
-
- // Look for an option with this ID, or an option with a superclass with this id
- IOption[] options = getOptions();
- for (int i = 0; i < options.length; i++) {
- IOption targetOption = options[i];
- IOption option = targetOption;
- do {
- if (optionId.equals(option.getId())) {
- return targetOption.isValid() ? targetOption : null;
- }
- option = option.getSuperClass();
- } while (option != null);
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getChildCategories()
- */
- public IOptionCategory[] getChildCategories() {
- IOptionCategory[] superCats = EMPTY_CATEGORIES;
- IOptionCategory[] ourCats = EMPTY_CATEGORIES;
- // Merge our option categories with our superclass' option categories.
- // Note that these are two disjoint sets of categories because
- // categories do not use derivation AND object Id's are unique. Thus
- // they are merely sequentially added.
- if (superClass != null) {
- superCats = superClass.getChildCategories();
- }
- if ( childOptionCategories != null ) {
- ourCats = (IOptionCategory[])childOptionCategories.toArray(new IOptionCategory[childOptionCategories.size()]);
- }
- // Add the two arrays together;
- if (superCats.length > 0 || ourCats.length > 0) {
- IOptionCategory[] allCats = new IOptionCategory[superCats.length + ourCats.length];
- int j;
- for (j=0; j < superCats.length; j++)
- allCats[j] = superCats[j];
- for (j=0; j < ourCats.length; j++)
- allCats[j+superCats.length] = ourCats[j];
- return allCats;
- }
- // Nothing found, return EMPTY_CATEGORIES
- return EMPTY_CATEGORIES;
- }
-
- /*
- * M E T H O D S M O V E D F R O M T O O L I N 3 . 0
- */
-
- /* (non-Javadoc)
- * Memory-safe way to access the vector of category IDs
- */
- private Vector getCategoryIds() {
- if (categoryIds == null) {
- categoryIds = new Vector();
- }
- return categoryIds;
- }
-
- /**
- * @param category
- */
- public void addChildCategory(IOptionCategory category) {
- if (childOptionCategories == null)
- childOptionCategories = new ArrayList();
- childOptionCategories.add(category);
- }
-
- /**
- * @param option
- */
- public void addOption(Option option) {
- getOptionList().add(option);
- getOptionMap().put(option.getId(), option);
- }
- /* (non-Javadoc)
- * Memeory-safe way to access the map of category IDs to categories
- */
- private Map getCategoryMap() {
- if (categoryMap == null) {
- categoryMap = new HashMap();
- }
- return categoryMap;
- }
-
- /* (non-Javadoc)
- * Memory-safe way to access the list of options
- */
- private Vector getOptionList() {
- if (optionList == null) {
- optionList = new Vector();
- }
- return optionList;
- }
-
- /* (non-Javadoc)
- * Memory-safe way to access the list of IDs to options
- */
- private Map getOptionMap() {
- if (optionMap == null) {
- optionMap = new HashMap();
- }
- return optionMap;
- }
-
- /* (non-Javadoc)
- * org.eclipse.cdt.managedbuilder.core.IHoldsOptions#addOptionCategory()
- */
- public void addOptionCategory(IOptionCategory category) {
- // To preserve the order of the categories, record the ids in the order they are read
- getCategoryIds().add(category.getId());
- // Map the categories by ID for resolution later
- getCategoryMap().put(category.getId(), category);
- }
-
- /* (non-Javadoc)
- * org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionCategory()
- */
- public IOptionCategory getOptionCategory(String id) {
- IOptionCategory cat = (IOptionCategory)getCategoryMap().get(id);
- if (cat == null && superClass != null) {
- // Look up the holders superclasses to find the category
- return superClass.getOptionCategory(id);
- }
- return cat;
- }
-
- /*
- * O B J E C T S T A T E M A I N T E N A N C E
- */
-
- /* (non-Javadoc)
- * Implements isDirty() for children of HoldsOptions. Intended to be
- * called by derived class.
- */
- protected boolean isDirty() {
- // If I need saving, just say yes
- if (isDirty) return true;
-
- // Otherwise see if any options need saving
- List optionElements = getOptionList();
- Iterator iter = optionElements.listIterator();
- while (iter.hasNext()) {
- Option option = (Option) iter.next();
- if (option.isDirty()) return true;
- }
-
- return isDirty;
- }
-
- /* (non-Javadoc)
- * Implements setDirty() for children of HoldsOptions. Intended to be
- * called by derived class.
- */
- protected void setDirty(boolean isDirty) {
- this.isDirty = isDirty;
- // Propagate "false" to the children
- if (!isDirty) {
- List optionElements = getOptionList();
- Iterator iter = optionElements.listIterator();
- while (iter.hasNext()) {
- Option option = (Option) iter.next();
- if(!option.isExtensionElement())
- option.setDirty(false);
- }
- }
- }
-
- /* (non-Javadoc)
- * Resolve the element IDs to interface references. Intended to be
- * called by derived class.
- */
- protected void resolveReferences() {
- if (!resolved) {
- resolved = true;
- // Call resolveReferences on our children
- Iterator optionIter = getOptionList().iterator();
- while (optionIter.hasNext()) {
- Option current = (Option)optionIter.next();
- current.resolveReferences();
- }
- // Somewhat wasteful, but use the vector to retrieve the categories in proper order
- Iterator catIter = getCategoryIds().iterator();
- while (catIter.hasNext()) {
- String id = (String)catIter.next();
- IOptionCategory current = (IOptionCategory)getCategoryMap().get(id);
- if (current instanceof Tool) {
- ((Tool)current).resolveReferences();
- } else if (current instanceof ToolChain) {
- ((ToolChain)current).resolveReferences();
- } else if (current instanceof OptionCategory) {
- ((OptionCategory)current).resolveReferences();
- }
- }
- }
- }
-
- public IOption getOptionToSet(IOption option, boolean adjustExtension) throws BuildException{
- IOption setOption = null;
- if(option.getOptionHolder() != this)
- option = getOptionBySuperClassId(option.getId());
-
- if(adjustExtension){
- for(; option != null && !option.isExtensionElement(); option=option.getSuperClass()){}
-
- if(option != null){
- IHoldsOptions holder = option.getOptionHolder();
- if(holder == this)
- setOption = option;
- else {
- IOption newSuperClass = option;
- if (((Option)option).wasOptRef()) {
- newSuperClass = option.getSuperClass();
- }
- // Create a new extension Option element
- String subId;
- String version = ManagedBuildManager.getVersionFromIdAndVersion(newSuperClass.getId());
- String baseId = ManagedBuildManager.getIdFromIdAndVersion(newSuperClass.getId());
- if ( version != null) {
- subId = baseId + ".adjusted." + new Integer(ManagedBuildManager.getRandomNumber()) + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- subId = baseId + ".adjusted." + new Integer(ManagedBuildManager.getRandomNumber()); //$NON-NLS-1$
- }
- setOption = createOption(newSuperClass, subId, null, true);
- ((Option)setOption).setAdjusted(true);
- setOption.setValueType(option.getValueType());
- }
- }
- } else {
- if(option.getOptionHolder() == this && !option.isExtensionElement()){
- setOption = option;
- } else {
- IOption newSuperClass = option;
- for(;
- newSuperClass != null && !newSuperClass.isExtensionElement();
- newSuperClass = newSuperClass.getSuperClass()){}
-
- if (((Option)newSuperClass).wasOptRef()) {
- newSuperClass = newSuperClass.getSuperClass();
- }
-
- if(((Option)newSuperClass).isAdjustedExtension()){
- newSuperClass = newSuperClass.getSuperClass();
- }
- // Create an Option element for the managed build project file (.CDTBUILD)
- String subId;
- subId = ManagedBuildManager.calculateChildId(newSuperClass.getId(), null);
- setOption = createOption(newSuperClass, subId, null, false);
- setOption.setValueType(option.getValueType());
- }
- }
- return setOption;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2005 Symbian Ltd 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:
+ * Symbian Ltd - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * Implements the functionality that is needed to hold options and option
+ * categories. In CDT 3.0, the functionality has been moved from ITool and
+ * Tool to this class.
+ *
+ * This class is intended to be used as base class for all MBS grammar
+ * elements that can hold Options and Option Categories. These are currently
+ * Tool and ToolChain.
+ *
+ * Note that the member superClass
must be shared with the
+ * derived class. This requires to wrap this member by access functions
+ * in the derived class or frequent casts, because the type of superClass
+ * in HoldsOptions
must be IHoldOptions
. Further
+ * note that the member resolved
must inherit the value of its
+ * derived class. This achieved through the constructor.
+ *
+ * @since 3.0
+ */
+public class HoldsOptions extends BuildObject implements IHoldsOptions {
+
+ private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
+
+ // Members that are to be shared with the derived class
+ protected IHoldsOptions superClass;
+ // Members that must have the same values on creation as the derived class
+ private boolean resolved;
+ // Parent and children
+ private Vector categoryIds;
+ private Map categoryMap;
+ private List childOptionCategories;
+ private Vector optionList;
+ private Map optionMap;
+ // Miscellaneous
+ private boolean isDirty = false;
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ private HoldsOptions() {
+ // prevent accidental construction of class without setting up
+ // resolved
+ }
+
+ protected HoldsOptions(boolean resolved) {
+ this.resolved = resolved;
+ }
+
+ /**
+ * Copies children of HoldsOptions
. Helper function for
+ * derived constructors.
+ *
+ * @param source The children of the source will be cloned and added
+ * to the class itself.
+ */
+ protected void copyChildren(HoldsOptions source) {
+
+ // Note: This function ignores OptionCategories since they should not be
+ // found on an non-extension tools
+ if (source.optionList != null) {
+ Iterator iter = source.getOptionList().listIterator();
+ while (iter.hasNext()) {
+ Option option = (Option) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (option.getSuperClass() != null) {
+ subId = option.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = option.getSuperClass().getName();
+ } else {
+ subId = option.getId() + "." + nnn; //$NON-NLS-1$
+ subName = option.getName();
+ }
+ Option newOption = new Option(this, subId, subName, option);
+ addOption(newOption);
+ }
+ }
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /**
+ * Load child element from XML element if it is of the correct type
+ *
+ * @param element which is loaded as child only iff it is of the correct type
+ * @return true when a child has been loaded, false otherwise
+ */
+ protected boolean loadChild(Node element) {
+ if (element.getNodeName().equals(ITool.OPTION)) {
+ Option option = new Option(this, (Element)element);
+ addOption(option);
+ return true;
+ } else if (element.getNodeName().equals(ITool.OPTION_CAT)) {
+ new OptionCategory(this, (Element)element);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Load child element from configuration element if it is of the correct type
+ *
+ * @param element which is loaded as child only iff it is of the correct type
+ * @return true when a child has been loaded, false otherwise
+ */
+ protected boolean loadChild(IManagedConfigElement element) {
+ if (element.getName().equals(ITool.OPTION)) {
+ Option option = new Option(this, element);
+ addOption(option);
+ return true;
+ } else if (element.getName().equals(ITool.OPTION_CAT)) {
+ new OptionCategory(this, element);
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Persist the tool to the project file. Intended to be called by derived
+ * class only, thus do not handle exceptions.
+ *
+ * @param doc
+ * @param element
+ * @throws BuildException
+ */
+ protected void serialize(Document doc, Element element) throws BuildException {
+
+ Iterator iter;
+
+ if (childOptionCategories != null) {
+ iter = childOptionCategories.listIterator();
+ while (iter.hasNext()) {
+ OptionCategory optCat = (OptionCategory)iter.next();
+ Element optCatElement = doc.createElement(OPTION);
+ element.appendChild(optCatElement);
+ optCat.serialize(doc, optCatElement);
+ }
+ }
+
+ List optionElements = getOptionList();
+ iter = optionElements.listIterator();
+ while (iter.hasNext()) {
+ Option option = (Option) iter.next();
+ Element optionElement = doc.createElement(OPTION);
+ element.appendChild(optionElement);
+ option.serialize(doc, optionElement);
+ }
+}
+
+ /*
+ * M E T H O D S M O V E D F R O M I T O O L I N 3 . 0
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOption(IOption, String, String, boolean)
+ */
+ public IOption createOption(IOption superClass, String Id, String name, boolean isExtensionElement) {
+ Option option = new Option(this, superClass, Id, name, isExtensionElement);
+ addOption(option);
+ if(!isExtensionElement)
+ setDirty(true);
+ return option;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOptions(IHoldsOptions)
+ */
+ public void createOptions(IHoldsOptions superClass) {
+ Iterator iter = ((HoldsOptions)superClass).getOptionList().listIterator();
+ while (iter.hasNext()) {
+ Option optionChild = (Option) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId = optionChild.getId() + "." + nnn; //$NON-NLS-1$
+ createOption(optionChild, subId, optionChild.getName(), false);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#removeOption(IOption)
+ */
+ public void removeOption(IOption option) {
+ getOptionList().remove(option);
+ getOptionMap().remove(option.getId());
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptions()
+ */
+ public IOption[] getOptions() {
+ IOption[] options = null;
+ // Merge our options with our superclass' options.
+ if (superClass != null) {
+ options = superClass.getOptions();
+ }
+ // Our options take precedence.
+ Vector ourOpts = getOptionList();
+ if (options != null) {
+ for (int i = 0; i < ourOpts.size(); i++) {
+ int j = options.length;
+ IOption ourOpt = (IOption)ourOpts.get(i);
+ if (ourOpt.getSuperClass() != null) {
+ String matchId = ourOpt.getSuperClass().getId();
+ search:
+ for (j = 0; j < options.length; j++) {
+ IOption superHolderOption = options[j];
+ if (((Option)superHolderOption).wasOptRef()) {
+ superHolderOption = superHolderOption.getSuperClass();
+ }
+ while (superHolderOption != null) {
+ if (matchId.equals(superHolderOption.getId())) {
+ options[j] = ourOpt;
+ break search;
+ }
+ superHolderOption = superHolderOption.getSuperClass();
+ }
+ }
+ }
+ // No Match? Add it.
+ if (j == options.length) {
+ IOption[] newOptions = new IOption[options.length + 1];
+ for (int k = 0; k < options.length; k++) {
+ newOptions[k] = options[k];
+ }
+ newOptions[j] = ourOpt;
+ options = newOptions;
+ }
+ }
+ } else {
+ options = (IOption[])ourOpts.toArray(new IOption[ourOpts.size()]);
+ }
+ // Check for any invalid options.
+ int numInvalidOptions = 0;
+ int i;
+ for (i=0; i < options.length; i++) {
+ if (options[i].isValid() == false) {
+ numInvalidOptions++;
+ }
+ }
+ // Take invalid options out of the array, if there are any
+ if (numInvalidOptions > 0) {
+ int j = 0;
+ IOption[] newOptions = new IOption[options.length - numInvalidOptions];
+ for (i=0; i < options.length; i++) {
+ if (options[i].isValid() == true) {
+ newOptions[j] = options[i];
+ j++;
+ }
+ }
+ options = newOptions;
+ }
+ return options;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOption(java.lang.String)
+ */
+ public IOption getOption(String id) {
+ return getOptionById(id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionById(java.lang.String)
+ */
+ public IOption getOptionById(String id) {
+ IOption opt = (IOption)getOptionMap().get(id);
+ if (opt == null) {
+ if (superClass != null) {
+ return superClass.getOptionById(id);
+ }
+ }
+ if (opt == null) return null;
+ return opt.isValid() ? opt : null;
+ }
+
+ /* (non-Javadoc)
+ * org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionBySuperClassId(java.lang.String)
+ */
+ public IOption getOptionBySuperClassId(String optionId) {
+ if (optionId == null) return null;
+
+ // Look for an option with this ID, or an option with a superclass with this id
+ IOption[] options = getOptions();
+ for (int i = 0; i < options.length; i++) {
+ IOption targetOption = options[i];
+ IOption option = targetOption;
+ do {
+ if (optionId.equals(option.getId())) {
+ return targetOption.isValid() ? targetOption : null;
+ }
+ option = option.getSuperClass();
+ } while (option != null);
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getChildCategories()
+ */
+ public IOptionCategory[] getChildCategories() {
+ IOptionCategory[] superCats = EMPTY_CATEGORIES;
+ IOptionCategory[] ourCats = EMPTY_CATEGORIES;
+ // Merge our option categories with our superclass' option categories.
+ // Note that these are two disjoint sets of categories because
+ // categories do not use derivation AND object Id's are unique. Thus
+ // they are merely sequentially added.
+ if (superClass != null) {
+ superCats = superClass.getChildCategories();
+ }
+ if ( childOptionCategories != null ) {
+ ourCats = (IOptionCategory[])childOptionCategories.toArray(new IOptionCategory[childOptionCategories.size()]);
+ }
+ // Add the two arrays together;
+ if (superCats.length > 0 || ourCats.length > 0) {
+ IOptionCategory[] allCats = new IOptionCategory[superCats.length + ourCats.length];
+ int j;
+ for (j=0; j < superCats.length; j++)
+ allCats[j] = superCats[j];
+ for (j=0; j < ourCats.length; j++)
+ allCats[j+superCats.length] = ourCats[j];
+ return allCats;
+ }
+ // Nothing found, return EMPTY_CATEGORIES
+ return EMPTY_CATEGORIES;
+ }
+
+ /*
+ * M E T H O D S M O V E D F R O M T O O L I N 3 . 0
+ */
+
+ /* (non-Javadoc)
+ * Memory-safe way to access the vector of category IDs
+ */
+ private Vector getCategoryIds() {
+ if (categoryIds == null) {
+ categoryIds = new Vector();
+ }
+ return categoryIds;
+ }
+
+ /**
+ * @param category
+ */
+ public void addChildCategory(IOptionCategory category) {
+ if (childOptionCategories == null)
+ childOptionCategories = new ArrayList();
+ childOptionCategories.add(category);
+ }
+
+ /**
+ * @param option
+ */
+ public void addOption(Option option) {
+ getOptionList().add(option);
+ getOptionMap().put(option.getId(), option);
+ }
+ /* (non-Javadoc)
+ * Memeory-safe way to access the map of category IDs to categories
+ */
+ private Map getCategoryMap() {
+ if (categoryMap == null) {
+ categoryMap = new HashMap();
+ }
+ return categoryMap;
+ }
+
+ /* (non-Javadoc)
+ * Memory-safe way to access the list of options
+ */
+ private Vector getOptionList() {
+ if (optionList == null) {
+ optionList = new Vector();
+ }
+ return optionList;
+ }
+
+ /* (non-Javadoc)
+ * Memory-safe way to access the list of IDs to options
+ */
+ private Map getOptionMap() {
+ if (optionMap == null) {
+ optionMap = new HashMap();
+ }
+ return optionMap;
+ }
+
+ /* (non-Javadoc)
+ * org.eclipse.cdt.managedbuilder.core.IHoldsOptions#addOptionCategory()
+ */
+ public void addOptionCategory(IOptionCategory category) {
+ // To preserve the order of the categories, record the ids in the order they are read
+ getCategoryIds().add(category.getId());
+ // Map the categories by ID for resolution later
+ getCategoryMap().put(category.getId(), category);
+ }
+
+ /* (non-Javadoc)
+ * org.eclipse.cdt.managedbuilder.core.IHoldsOptions#getOptionCategory()
+ */
+ public IOptionCategory getOptionCategory(String id) {
+ IOptionCategory cat = (IOptionCategory)getCategoryMap().get(id);
+ if (cat == null && superClass != null) {
+ // Look up the holders superclasses to find the category
+ return superClass.getOptionCategory(id);
+ }
+ return cat;
+ }
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * Implements isDirty() for children of HoldsOptions. Intended to be
+ * called by derived class.
+ */
+ protected boolean isDirty() {
+ // If I need saving, just say yes
+ if (isDirty) return true;
+
+ // Otherwise see if any options need saving
+ List optionElements = getOptionList();
+ Iterator iter = optionElements.listIterator();
+ while (iter.hasNext()) {
+ Option option = (Option) iter.next();
+ if (option.isDirty()) return true;
+ }
+
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * Implements setDirty() for children of HoldsOptions. Intended to be
+ * called by derived class.
+ */
+ protected void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ // Propagate "false" to the children
+ if (!isDirty) {
+ List optionElements = getOptionList();
+ Iterator iter = optionElements.listIterator();
+ while (iter.hasNext()) {
+ Option option = (Option) iter.next();
+ if(!option.isExtensionElement())
+ option.setDirty(false);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Resolve the element IDs to interface references. Intended to be
+ * called by derived class.
+ */
+ protected void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ // Call resolveReferences on our children
+ Iterator optionIter = getOptionList().iterator();
+ while (optionIter.hasNext()) {
+ Option current = (Option)optionIter.next();
+ current.resolveReferences();
+ }
+ // Somewhat wasteful, but use the vector to retrieve the categories in proper order
+ Iterator catIter = getCategoryIds().iterator();
+ while (catIter.hasNext()) {
+ String id = (String)catIter.next();
+ IOptionCategory current = (IOptionCategory)getCategoryMap().get(id);
+ if (current instanceof Tool) {
+ ((Tool)current).resolveReferences();
+ } else if (current instanceof ToolChain) {
+ ((ToolChain)current).resolveReferences();
+ } else if (current instanceof OptionCategory) {
+ ((OptionCategory)current).resolveReferences();
+ }
+ }
+ }
+ }
+
+ public IOption getOptionToSet(IOption option, boolean adjustExtension) throws BuildException{
+ IOption setOption = null;
+ if(option.getOptionHolder() != this)
+ option = getOptionBySuperClassId(option.getId());
+
+ if(adjustExtension){
+ for(; option != null && !option.isExtensionElement(); option=option.getSuperClass()){}
+
+ if(option != null){
+ IHoldsOptions holder = option.getOptionHolder();
+ if(holder == this)
+ setOption = option;
+ else {
+ IOption newSuperClass = option;
+ if (((Option)option).wasOptRef()) {
+ newSuperClass = option.getSuperClass();
+ }
+ // Create a new extension Option element
+ String subId;
+ String version = ManagedBuildManager.getVersionFromIdAndVersion(newSuperClass.getId());
+ String baseId = ManagedBuildManager.getIdFromIdAndVersion(newSuperClass.getId());
+ if ( version != null) {
+ subId = baseId + ".adjusted." + new Integer(ManagedBuildManager.getRandomNumber()) + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ subId = baseId + ".adjusted." + new Integer(ManagedBuildManager.getRandomNumber()); //$NON-NLS-1$
+ }
+ setOption = createOption(newSuperClass, subId, null, true);
+ ((Option)setOption).setAdjusted(true);
+ setOption.setValueType(option.getValueType());
+ }
+ }
+ } else {
+ if(option.getOptionHolder() == this && !option.isExtensionElement()){
+ setOption = option;
+ } else {
+ IOption newSuperClass = option;
+ for(;
+ newSuperClass != null && !newSuperClass.isExtensionElement();
+ newSuperClass = newSuperClass.getSuperClass()){}
+
+ if (((Option)newSuperClass).wasOptRef()) {
+ newSuperClass = newSuperClass.getSuperClass();
+ }
+
+ if(((Option)newSuperClass).isAdjustedExtension()){
+ newSuperClass = newSuperClass.getSuperClass();
+ }
+ // Create an Option element for the managed build project file (.CDTBUILD)
+ String subId;
+ subId = ManagedBuildManager.calculateChildId(newSuperClass.getId(), null);
+ setOption = createOption(newSuperClass, subId, null, false);
+ setOption.setValueType(option.getValueType());
+ }
+ }
+ return setOption;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
index 6380d298951..f828fa58e4a 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/InputType.java
@@ -1,1221 +1,1221 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 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.core;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.content.*;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IInputOrder;
-import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class InputType extends BuildObject implements IInputType {
-
- private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
- private static final String EMPTY_STRING = new String();
-
- // Superclass
- private IInputType superClass;
- private String superClassId;
- // Parent and children
- private ITool parent;
- private Vector inputOrderList;
- private Vector additionalInputList;
- // Managed Build model attributes
- private String sourceContentTypeId;
- private IContentType sourceContentType;
- private List inputExtensions;
- private String dependencyContentTypeId;
- private IContentType dependencyContentType;
- private List dependencyExtensions;
- private String optionId;
- private String assignToOptionId;
- private String buildVariable;
- private Boolean multipleOfType;
- private Boolean primaryInput;
- private IConfigurationElement dependencyGeneratorElement = null;
- private IManagedDependencyGeneratorType dependencyGenerator = null;
- // Miscellaneous
- private boolean isExtensionInputType = false;
- private boolean isDirty = false;
- private boolean resolved = true;
-
- /*
- * C O N S T R U C T O R S
- */
-
- /**
- * This constructor is called to create an InputType defined by an extension point in
- * a plugin manifest file, or returned by a dynamic element provider
- *
- * @param parent The ITool parent of this InputType
- * @param element The InputType definition from the manifest file or a dynamic element
- * provider
- */
- public InputType(ITool parent, IManagedConfigElement element) {
- this.parent = parent;
- isExtensionInputType = true;
-
- // setup for resolving
- resolved = false;
-
- loadFromManifest(element);
-
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionInputType(this);
-
- // Load Children
- IManagedConfigElement[] iElements = element.getChildren();
- for (int l = 0; l < iElements.length; ++l) {
- IManagedConfigElement iElement = iElements[l];
- if (iElement.getName().equals(IInputOrder.INPUT_ORDER_ELEMENT_NAME)) {
- InputOrder inputOrder = new InputOrder(this, iElement);
- getInputOrderList().add(inputOrder);
- } else if (iElement.getName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
- AdditionalInput addlInput = new AdditionalInput(this, iElement);
- getAdditionalInputList().add(addlInput);
- }
- }
- }
-
- /**
- * This constructor is called to create an InputType whose attributes and children will be
- * added by separate calls.
- *
- * @param Tool The parent of the an InputType
- * @param InputType The superClass, if any
- * @param String The id for the new InputType
- * @param String The name for the new InputType
- * @param boolean Indicates whether this is an extension element or a managed project element
- */
- public InputType(Tool parent, IInputType superClass, String Id, String name, boolean isExtensionElement) {
- this.parent = parent;
- this.superClass = superClass;
- if (this.superClass != null) {
- superClassId = this.superClass.getId();
- }
- setId(Id);
- setName(name);
-
- isExtensionInputType = isExtensionElement;
- if (isExtensionElement) {
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionInputType(this);
- } else {
- setDirty(true);
- }
- }
-
- /**
- * Create an InputType
based on the specification stored in the
- * project file (.cdtbuild).
- *
- * @param parent The ITool
the InputType will be added to.
- * @param element The XML element that contains the InputType settings.
- *
- */
- public InputType(ITool parent, Element element) {
- this.parent = parent;
- isExtensionInputType = false;
-
- // Initialize from the XML attributes
- loadFromProject(element);
-
- // Load children
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(IInputOrder.INPUT_ORDER_ELEMENT_NAME)) {
- InputOrder inputOrder = new InputOrder(this, (Element)configElement);
- getInputOrderList().add(inputOrder);
- } else if (configElement.getNodeName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
- AdditionalInput addlInput = new AdditionalInput(this, (Element)configElement);
- getAdditionalInputList().add(addlInput);
- }
- }
- }
-
- /**
- * Create an InputType
based upon an existing InputType.
- *
- * @param parent The ITool
the InputType will be added to.
- * @param Id The identifier of the new InputType
- * @param name The name of the new InputType
- * @param inputType The existing InputType to clone.
- */
- public InputType(ITool parent, String Id, String name, InputType inputType) {
- this.parent = parent;
- superClass = inputType.superClass;
- if (superClass != null) {
- if (inputType.superClassId != null) {
- superClassId = new String(inputType.superClassId);
- }
- }
- setId(Id);
- setName(name);
-
- isExtensionInputType = false;
-
- // Copy the remaining attributes
-
- if (inputType.sourceContentTypeId != null) {
- sourceContentTypeId = new String(inputType.sourceContentTypeId);
- }
- sourceContentType = inputType.sourceContentType;
- if (inputType.inputExtensions != null) {
- inputExtensions = new ArrayList(inputType.inputExtensions);
- }
- if (inputType.dependencyContentTypeId != null) {
- dependencyContentTypeId = new String(inputType.dependencyContentTypeId);
- }
- dependencyContentType = inputType.dependencyContentType;
- if (inputType.dependencyExtensions != null) {
- dependencyExtensions = new ArrayList(inputType.dependencyExtensions);
- }
- if (inputType.optionId != null) {
- optionId = new String(inputType.optionId);
- }
- if (inputType.assignToOptionId != null) {
- assignToOptionId = new String(inputType.assignToOptionId);
- }
- if (inputType.buildVariable != null) {
- buildVariable = new String(inputType.buildVariable);
- }
- if (inputType.multipleOfType != null) {
- multipleOfType = new Boolean(inputType.multipleOfType.booleanValue());
- }
- if (inputType.primaryInput != null) {
- primaryInput = new Boolean(inputType.primaryInput.booleanValue());
- }
- dependencyGeneratorElement = inputType.dependencyGeneratorElement;
- dependencyGenerator = inputType.dependencyGenerator;
-
- // Clone the children
- if (inputType.inputOrderList != null) {
- Iterator iter = inputType.getInputOrderList().listIterator();
- while (iter.hasNext()) {
- InputOrder inputOrder = (InputOrder) iter.next();
- InputOrder newInputOrder = new InputOrder(this, inputOrder);
- getInputOrderList().add(newInputOrder);
- }
- }
- if (inputType.additionalInputList != null) {
- Iterator iter = inputType.getAdditionalInputList().listIterator();
- while (iter.hasNext()) {
- AdditionalInput additionalInput = (AdditionalInput) iter.next();
- AdditionalInput newAdditionalInput = new AdditionalInput(this, additionalInput);
- getAdditionalInputList().add(newAdditionalInput);
- }
- }
-
- setDirty(true);
- }
-
- /*
- * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
- */
-
- /* (non-Javadoc)
- * Loads the InputType information from the ManagedConfigElement specified in the
- * argument.
- *
- * @param element Contains the InputType information
- */
- protected void loadFromManifest(IManagedConfigElement element) {
- ManagedBuildManager.putConfigElement(this, element);
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // Get the name
- setName(element.getAttribute(IBuildObject.NAME));
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
-
- // sourceContentType
- sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
-
- // Get the supported input file extensions
- String inputs = element.getAttribute(ITool.SOURCES);
- if (inputs != null) {
- StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
- }
- }
-
- // dependencyContentType
- dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
-
- // Get the dependency (header file) extensions
- String headers = element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS);
- if (headers != null) {
- StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getDependencyExtensionsList().add(tokenizer.nextElement());
- }
- }
-
- // option
- optionId = element.getAttribute(IInputType.OPTION);
-
- // assignToOption
- assignToOptionId = element.getAttribute(IInputType.ASSIGN_TO_OPTION);
-
- // multipleOfType
- String isMOT = element.getAttribute(IInputType.MULTIPLE_OF_TYPE);
- if (isMOT != null){
- multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
- }
-
- // primaryInput
- String isPI = element.getAttribute(IInputType.PRIMARY_INPUT);
- if (isPI != null){
- primaryInput = new Boolean("true".equals(isPI)); //$NON-NLS-1$
- }
-
- // buildVariable
- buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
-
- // Store the configuration element IFF there is a dependency generator defined
- String depGenerator = element.getAttribute(ITool.DEP_CALC_ID);
- if (depGenerator != null && element instanceof DefaultManagedConfigElement) {
- dependencyGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- }
- }
-
- /* (non-Javadoc)
- * Initialize the InputType information from the XML element
- * specified in the argument
- *
- * @param element An XML element containing the InputType information
- */
- protected boolean loadFromProject(Element element) {
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // name
- if (element.hasAttribute(IBuildObject.NAME)) {
- setName(element.getAttribute(IBuildObject.NAME));
- }
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
- if (superClassId != null && superClassId.length() > 0) {
- superClass = ManagedBuildManager.getExtensionInputType(superClassId);
- if (superClass == null) {
- // TODO: Report error
- }
- }
-
- // sourceContentType
- IContentTypeManager manager = Platform.getContentTypeManager();
- if (element.hasAttribute(IInputType.SOURCE_CONTENT_TYPE)) {
- sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
- if (sourceContentTypeId != null && sourceContentTypeId.length() > 0) {
- sourceContentType = manager.getContentType(sourceContentTypeId);
- }
- }
-
- // sources
- if (element.hasAttribute(IInputType.SOURCES)) {
- String inputs = element.getAttribute(ITool.SOURCES);
- if (inputs != null) {
- StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
- }
- }
- }
-
- // dependencyContentType
- if (element.hasAttribute(IInputType.DEPENDENCY_CONTENT_TYPE)) {
- dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
- if (dependencyContentTypeId != null && dependencyContentTypeId.length() > 0) {
- dependencyContentType = manager.getContentType(dependencyContentTypeId);
- }
- }
-
- // dependencyExtensions
- // Get the dependency (header file) extensions
- if (element.hasAttribute(IInputType.DEPENDENCY_EXTENSIONS)) {
- String headers = element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS);
- if (headers != null) {
- StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getDependencyExtensionsList().add(tokenizer.nextElement());
- }
- }
- }
-
- // option
- if (element.hasAttribute(IInputType.OPTION)) {
- optionId = element.getAttribute(IInputType.OPTION);
- }
-
- // assignToOption
- if (element.hasAttribute(IInputType.ASSIGN_TO_OPTION)) {
- assignToOptionId = element.getAttribute(IInputType.ASSIGN_TO_OPTION);
- }
-
- // multipleOfType
- if (element.hasAttribute(IInputType.MULTIPLE_OF_TYPE)) {
- String isMOT = element.getAttribute(IInputType.MULTIPLE_OF_TYPE);
- if (isMOT != null){
- multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
- }
- }
-
- // primaryInput
- if (element.hasAttribute(IInputType.PRIMARY_INPUT)) {
- String isPI = element.getAttribute(IInputType.PRIMARY_INPUT);
- if (isPI != null){
- primaryInput = new Boolean("true".equals(isPI)); //$NON-NLS-1$
- }
- }
-
- // buildVariable
- if (element.hasAttribute(IInputType.BUILD_VARIABLE)) {
- buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
- }
-
- // Note: dependency generator cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (element.hasAttribute(ITool.DEP_CALC_ID)) {
- // TODO: Issue warning?
- }
-
- return true;
- }
-
- /**
- * Persist the InputType to the project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- if (superClass != null)
- element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
-
- element.setAttribute(IBuildObject.ID, id);
-
- if (name != null) {
- element.setAttribute(IBuildObject.NAME, name);
- }
-
- // sourceContentType
- if (sourceContentTypeId != null) {
- element.setAttribute(IInputType.SOURCE_CONTENT_TYPE, sourceContentTypeId);
- }
-
- // input file extensions
- if (getInputExtensionsList().size() > 0) {
- String inputs;
- List list = getInputExtensionsList();
- Iterator iter = list.listIterator();
- inputs = (String)iter.next();
- while (iter.hasNext()) {
- inputs += DEFAULT_SEPARATOR;
- inputs += iter.next();
- }
- element.setAttribute(IInputType.SOURCES, inputs);
- }
-
- // dependencyContentType
- if (dependencyContentTypeId != null) {
- element.setAttribute(IInputType.DEPENDENCY_CONTENT_TYPE, dependencyContentTypeId);
- }
-
- // dependency (header file) extensions
- if (getDependencyExtensionsList().size() > 0) {
- String headers;
- List list = getDependencyExtensionsList();
- Iterator iter = list.listIterator();
- headers = (String)iter.next();
- while (iter.hasNext()) {
- headers += DEFAULT_SEPARATOR;
- headers += iter.next();
- }
- element.setAttribute(IInputType.DEPENDENCY_EXTENSIONS, headers);
- }
-
- if (optionId != null) {
- element.setAttribute(IInputType.OPTION, optionId);
- }
-
- if (assignToOptionId != null) {
- element.setAttribute(IInputType.ASSIGN_TO_OPTION, assignToOptionId);
- }
-
- if (multipleOfType != null) {
- element.setAttribute(IInputType.MULTIPLE_OF_TYPE, multipleOfType.toString());
- }
-
- if (primaryInput != null) {
- element.setAttribute(IInputType.PRIMARY_INPUT, primaryInput.toString());
- }
-
- if (buildVariable != null) {
- element.setAttribute(IInputType.BUILD_VARIABLE, buildVariable);
- }
-
- // Note: dependency generator cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (dependencyGeneratorElement != null) {
- // TODO: issue warning?
- }
-
- // Serialize my children
- List childElements = getInputOrderList();
- Iterator iter = childElements.listIterator();
- while (iter.hasNext()) {
- InputOrder io = (InputOrder) iter.next();
- Element ioElement = doc.createElement(InputOrder.INPUT_ORDER_ELEMENT_NAME);
- element.appendChild(ioElement);
- io.serialize(doc, ioElement);
- }
- childElements = getAdditionalInputList();
- iter = childElements.listIterator();
- while (iter.hasNext()) {
- AdditionalInput ai = (AdditionalInput) iter.next();
- Element aiElement = doc.createElement(AdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME);
- element.appendChild(aiElement);
- ai.serialize(doc, aiElement);
- }
-
- // I am clean now
- isDirty = false;
- }
-
- /*
- * P A R E N T A N D C H I L D H A N D L I N G
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getParent()
- */
- public ITool getParent() {
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#createInputOrder()
- */
- public IInputOrder createInputOrder(String path) {
- InputOrder inputOrder = new InputOrder(this, false);
- inputOrder.setPath(path);
- getInputOrderList().add(inputOrder);
- setDirty(true);
- return inputOrder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getInputOrders()
- */
- public IInputOrder[] getInputOrders() {
- IInputOrder[] orders;
- Vector ours = getInputOrderList();
- orders = (IInputOrder[])ours.toArray(new IInputOrder[ours.size()]);
- return orders;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getInputOrder()
- */
- public IInputOrder getInputOrder(String path) {
- // TODO Convert both paths to absolute?
- List orders = getInputOrderList();
- Iterator iter = orders.listIterator();
- while (iter.hasNext()) {
- InputOrder io = (InputOrder) iter.next();
- if (path.compareToIgnoreCase(io.getPath()) != 0) {
- return io;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#removeInputOrder()
- */
- public void removeInputOrder(String path) {
- IInputOrder order = getInputOrder(path);
- if (order != null) removeInputOrder(order);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#removeInputOrder()
- */
- public void removeInputOrder(IInputOrder element) {
- getInputOrderList().remove(element);
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#createAdditionalInput()
- */
- public IAdditionalInput createAdditionalInput(String paths) {
- AdditionalInput addlInput = new AdditionalInput(this, false);
- addlInput.setPaths(paths);
- getAdditionalInputList().add(addlInput);
- setDirty(true);
- return addlInput;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalInputs()
- */
- public IAdditionalInput[] getAdditionalInputs() {
- IAdditionalInput[] inputs;
- Vector ours = getAdditionalInputList();
- inputs = (IAdditionalInput[])ours.toArray(new IAdditionalInput[ours.size()]);
- return inputs;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalInput()
- */
- public IAdditionalInput getAdditionalInput(String paths) {
- // TODO Convert both paths to absolute?
- // Must match all strings
- String[] inputTokens = paths.split(";"); //$NON-NLS-1$
- List inputs = getInputOrderList();
- Iterator iter = inputs.listIterator();
- while (iter.hasNext()) {
- AdditionalInput ai = (AdditionalInput) iter.next();
- boolean match = false;
- String[] tokens = ai.getPaths();
- if (tokens.length == inputTokens.length) {
- match = true;
- for (int i = 0; i < tokens.length; i++) {
- if (tokens[i].compareToIgnoreCase(inputTokens[i]) != 0) {
- match = false;
- break;
- }
- }
- }
- if (match) return ai;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#removeAdditionalInput()
- */
- public void removeAdditionalInput(String path) {
- IAdditionalInput input = getAdditionalInput(path);
- if (input != null) removeAdditionalInput(input);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#removeAdditionalInput()
- */
- public void removeAdditionalInput(IAdditionalInput element) {
- getAdditionalInputList().remove(element);
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalDependencies()
- */
- public IPath[] getAdditionalDependencies() {
- List deps = new ArrayList();
- Iterator typeIter = getAdditionalInputList().iterator();
- while (typeIter.hasNext()) {
- AdditionalInput current = (AdditionalInput)typeIter.next();
- int kind = current.getKind();
- if (kind == IAdditionalInput.KIND_ADDITIONAL_DEPENDENCY ||
- kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
- String[] paths = current.getPaths();
- if (paths != null) {
- for (int i = 0; i < paths.length; i++) {
- if (paths[i].length() > 0) {
- deps.add(Path.fromOSString(paths[i]));
- }
- }
- }
- }
- }
- return (IPath[])deps.toArray(new IPath[deps.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalResources()
- */
- public IPath[] getAdditionalResources() {
- List ins = new ArrayList();
- Iterator typeIter = getAdditionalInputList().iterator();
- while (typeIter.hasNext()) {
- AdditionalInput current = (AdditionalInput)typeIter.next();
- int kind = current.getKind();
- if (kind == IAdditionalInput.KIND_ADDITIONAL_INPUT ||
- kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
- String[] paths = current.getPaths();
- if (paths != null) {
- for (int i = 0; i < paths.length; i++) {
- if (paths[i].length() > 0) {
- ins.add(Path.fromOSString(paths[i]));
- }
- }
- }
- }
- }
- return (IPath[])ins.toArray(new IPath[ins.size()]);
- }
-
- /* (non-Javadoc)
- * Memory-safe way to access the list of input orders
- */
- private Vector getInputOrderList() {
- if (inputOrderList == null) {
- inputOrderList = new Vector();
- }
- return inputOrderList;
- }
-
- /* (non-Javadoc)
- * Memory-safe way to access the list of input orders
- */
- private Vector getAdditionalInputList() {
- if (additionalInputList == null) {
- additionalInputList = new Vector();
- }
- return additionalInputList;
- }
-
-
- /*
- * M O D E L A T T R I B U T E A C C E S S O R S
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IInputType#getSuperClass()
- */
- public IInputType getSuperClass() {
- return superClass;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getName()
- */
- public String getName() {
- return (name == null && superClass != null) ? superClass.getName() : name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getBuildVariable()
- */
- public String getBuildVariable() {
- if (buildVariable == null) {
- // If I have a superClass, ask it
- if (superClass != null) {
- return superClass.getBuildVariable();
- } else {
- return EMPTY_STRING;
- }
- }
- return buildVariable;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setBuildVariable()
- */
- public void setBuildVariable(String variableName) {
- if (variableName == null && buildVariable == null) return;
- if (buildVariable == null || variableName == null || !(variableName.equals(buildVariable))) {
- buildVariable = variableName;
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyContentType()
- */
- public IContentType getDependencyContentType() {
- if (dependencyContentType == null) {
- if (superClass != null) {
- return superClass.getDependencyContentType();
- } else {
- return null;
- }
- }
- return dependencyContentType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyContentType()
- */
- public void setDependencyContentType(IContentType type) {
- if (dependencyContentType != type) {
- dependencyContentType = type;
- if (dependencyContentType != null) {
- dependencyContentTypeId = dependencyContentType.getId();
- } else {
- dependencyContentTypeId = null;
- }
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyExtensionsAttribute()
- */
- public String[] getDependencyExtensionsAttribute() {
- if (dependencyExtensions == null || dependencyExtensions.size() == 0) {
- // If I have a superClass, ask it
- if (superClass != null) {
- return superClass.getDependencyExtensionsAttribute();
- } else {
- if (dependencyExtensions == null) {
- dependencyExtensions = new ArrayList();
- }
- }
- }
- return (String[])dependencyExtensions.toArray(new String[dependencyExtensions.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyExtensionsAttribute()
- */
- public void setDependencyExtensionsAttribute(String extensions) {
- getDependencyExtensionsList().clear();
- if (extensions != null) {
- StringTokenizer tokenizer = new StringTokenizer(extensions, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getDependencyExtensionsList().add(tokenizer.nextElement());
- }
- }
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyExtensions()
- */
- public String[] getDependencyExtensions(ITool tool) {
- // Use content type if specified and registered with Eclipse
- IContentType type = getDependencyContentType();
- if (type != null) {
- String[] exts = ((Tool)tool).getContentTypeFileSpecs(type);
- // TODO: This is a temporary hack until we decide how to specify the langauge (C vs. C++)
- // of a .h file. If the content type is the CDT-defined C/C++ content type, then
- // add "h" to the list if it is not already there.
- if (type.getId().compareTo("org.eclipse.cdt.core.cxxHeader") == 0) { // $NON-NLS-1$
- boolean h_found = false;
- for (int i=0; iInputType
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The ITool
the InputType will be added to.
+ * @param element The XML element that contains the InputType settings.
+ *
+ */
+ public InputType(ITool parent, Element element) {
+ this.parent = parent;
+ isExtensionInputType = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // Load children
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(IInputOrder.INPUT_ORDER_ELEMENT_NAME)) {
+ InputOrder inputOrder = new InputOrder(this, (Element)configElement);
+ getInputOrderList().add(inputOrder);
+ } else if (configElement.getNodeName().equals(IAdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME)) {
+ AdditionalInput addlInput = new AdditionalInput(this, (Element)configElement);
+ getAdditionalInputList().add(addlInput);
+ }
+ }
+ }
+
+ /**
+ * Create an InputType
based upon an existing InputType.
+ *
+ * @param parent The ITool
the InputType will be added to.
+ * @param Id The identifier of the new InputType
+ * @param name The name of the new InputType
+ * @param inputType The existing InputType to clone.
+ */
+ public InputType(ITool parent, String Id, String name, InputType inputType) {
+ this.parent = parent;
+ superClass = inputType.superClass;
+ if (superClass != null) {
+ if (inputType.superClassId != null) {
+ superClassId = new String(inputType.superClassId);
+ }
+ }
+ setId(Id);
+ setName(name);
+
+ isExtensionInputType = false;
+
+ // Copy the remaining attributes
+
+ if (inputType.sourceContentTypeId != null) {
+ sourceContentTypeId = new String(inputType.sourceContentTypeId);
+ }
+ sourceContentType = inputType.sourceContentType;
+ if (inputType.inputExtensions != null) {
+ inputExtensions = new ArrayList(inputType.inputExtensions);
+ }
+ if (inputType.dependencyContentTypeId != null) {
+ dependencyContentTypeId = new String(inputType.dependencyContentTypeId);
+ }
+ dependencyContentType = inputType.dependencyContentType;
+ if (inputType.dependencyExtensions != null) {
+ dependencyExtensions = new ArrayList(inputType.dependencyExtensions);
+ }
+ if (inputType.optionId != null) {
+ optionId = new String(inputType.optionId);
+ }
+ if (inputType.assignToOptionId != null) {
+ assignToOptionId = new String(inputType.assignToOptionId);
+ }
+ if (inputType.buildVariable != null) {
+ buildVariable = new String(inputType.buildVariable);
+ }
+ if (inputType.multipleOfType != null) {
+ multipleOfType = new Boolean(inputType.multipleOfType.booleanValue());
+ }
+ if (inputType.primaryInput != null) {
+ primaryInput = new Boolean(inputType.primaryInput.booleanValue());
+ }
+ dependencyGeneratorElement = inputType.dependencyGeneratorElement;
+ dependencyGenerator = inputType.dependencyGenerator;
+
+ // Clone the children
+ if (inputType.inputOrderList != null) {
+ Iterator iter = inputType.getInputOrderList().listIterator();
+ while (iter.hasNext()) {
+ InputOrder inputOrder = (InputOrder) iter.next();
+ InputOrder newInputOrder = new InputOrder(this, inputOrder);
+ getInputOrderList().add(newInputOrder);
+ }
+ }
+ if (inputType.additionalInputList != null) {
+ Iterator iter = inputType.getAdditionalInputList().listIterator();
+ while (iter.hasNext()) {
+ AdditionalInput additionalInput = (AdditionalInput) iter.next();
+ AdditionalInput newAdditionalInput = new AdditionalInput(this, additionalInput);
+ getAdditionalInputList().add(newAdditionalInput);
+ }
+ }
+
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Loads the InputType information from the ManagedConfigElement specified in the
+ * argument.
+ *
+ * @param element Contains the InputType information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // Get the name
+ setName(element.getAttribute(IBuildObject.NAME));
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // sourceContentType
+ sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
+
+ // Get the supported input file extensions
+ String inputs = element.getAttribute(ITool.SOURCES);
+ if (inputs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+
+ // dependencyContentType
+ dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
+
+ // Get the dependency (header file) extensions
+ String headers = element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS);
+ if (headers != null) {
+ StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getDependencyExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+
+ // option
+ optionId = element.getAttribute(IInputType.OPTION);
+
+ // assignToOption
+ assignToOptionId = element.getAttribute(IInputType.ASSIGN_TO_OPTION);
+
+ // multipleOfType
+ String isMOT = element.getAttribute(IInputType.MULTIPLE_OF_TYPE);
+ if (isMOT != null){
+ multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
+ }
+
+ // primaryInput
+ String isPI = element.getAttribute(IInputType.PRIMARY_INPUT);
+ if (isPI != null){
+ primaryInput = new Boolean("true".equals(isPI)); //$NON-NLS-1$
+ }
+
+ // buildVariable
+ buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
+
+ // Store the configuration element IFF there is a dependency generator defined
+ String depGenerator = element.getAttribute(ITool.DEP_CALC_ID);
+ if (depGenerator != null && element instanceof DefaultManagedConfigElement) {
+ dependencyGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+ }
+
+ /* (non-Javadoc)
+ * Initialize the InputType information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the InputType information
+ */
+ protected boolean loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionInputType(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // sourceContentType
+ IContentTypeManager manager = Platform.getContentTypeManager();
+ if (element.hasAttribute(IInputType.SOURCE_CONTENT_TYPE)) {
+ sourceContentTypeId = element.getAttribute(IInputType.SOURCE_CONTENT_TYPE);
+ if (sourceContentTypeId != null && sourceContentTypeId.length() > 0) {
+ sourceContentType = manager.getContentType(sourceContentTypeId);
+ }
+ }
+
+ // sources
+ if (element.hasAttribute(IInputType.SOURCES)) {
+ String inputs = element.getAttribute(ITool.SOURCES);
+ if (inputs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ }
+
+ // dependencyContentType
+ if (element.hasAttribute(IInputType.DEPENDENCY_CONTENT_TYPE)) {
+ dependencyContentTypeId = element.getAttribute(IInputType.DEPENDENCY_CONTENT_TYPE);
+ if (dependencyContentTypeId != null && dependencyContentTypeId.length() > 0) {
+ dependencyContentType = manager.getContentType(dependencyContentTypeId);
+ }
+ }
+
+ // dependencyExtensions
+ // Get the dependency (header file) extensions
+ if (element.hasAttribute(IInputType.DEPENDENCY_EXTENSIONS)) {
+ String headers = element.getAttribute(IInputType.DEPENDENCY_EXTENSIONS);
+ if (headers != null) {
+ StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getDependencyExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ }
+
+ // option
+ if (element.hasAttribute(IInputType.OPTION)) {
+ optionId = element.getAttribute(IInputType.OPTION);
+ }
+
+ // assignToOption
+ if (element.hasAttribute(IInputType.ASSIGN_TO_OPTION)) {
+ assignToOptionId = element.getAttribute(IInputType.ASSIGN_TO_OPTION);
+ }
+
+ // multipleOfType
+ if (element.hasAttribute(IInputType.MULTIPLE_OF_TYPE)) {
+ String isMOT = element.getAttribute(IInputType.MULTIPLE_OF_TYPE);
+ if (isMOT != null){
+ multipleOfType = new Boolean("true".equals(isMOT)); //$NON-NLS-1$
+ }
+ }
+
+ // primaryInput
+ if (element.hasAttribute(IInputType.PRIMARY_INPUT)) {
+ String isPI = element.getAttribute(IInputType.PRIMARY_INPUT);
+ if (isPI != null){
+ primaryInput = new Boolean("true".equals(isPI)); //$NON-NLS-1$
+ }
+ }
+
+ // buildVariable
+ if (element.hasAttribute(IInputType.BUILD_VARIABLE)) {
+ buildVariable = element.getAttribute(IInputType.BUILD_VARIABLE);
+ }
+
+ // Note: dependency generator cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (element.hasAttribute(ITool.DEP_CALC_ID)) {
+ // TODO: Issue warning?
+ }
+
+ return true;
+ }
+
+ /**
+ * Persist the InputType to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ if (superClass != null)
+ element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
+
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ // sourceContentType
+ if (sourceContentTypeId != null) {
+ element.setAttribute(IInputType.SOURCE_CONTENT_TYPE, sourceContentTypeId);
+ }
+
+ // input file extensions
+ if (getInputExtensionsList().size() > 0) {
+ String inputs;
+ List list = getInputExtensionsList();
+ Iterator iter = list.listIterator();
+ inputs = (String)iter.next();
+ while (iter.hasNext()) {
+ inputs += DEFAULT_SEPARATOR;
+ inputs += iter.next();
+ }
+ element.setAttribute(IInputType.SOURCES, inputs);
+ }
+
+ // dependencyContentType
+ if (dependencyContentTypeId != null) {
+ element.setAttribute(IInputType.DEPENDENCY_CONTENT_TYPE, dependencyContentTypeId);
+ }
+
+ // dependency (header file) extensions
+ if (getDependencyExtensionsList().size() > 0) {
+ String headers;
+ List list = getDependencyExtensionsList();
+ Iterator iter = list.listIterator();
+ headers = (String)iter.next();
+ while (iter.hasNext()) {
+ headers += DEFAULT_SEPARATOR;
+ headers += iter.next();
+ }
+ element.setAttribute(IInputType.DEPENDENCY_EXTENSIONS, headers);
+ }
+
+ if (optionId != null) {
+ element.setAttribute(IInputType.OPTION, optionId);
+ }
+
+ if (assignToOptionId != null) {
+ element.setAttribute(IInputType.ASSIGN_TO_OPTION, assignToOptionId);
+ }
+
+ if (multipleOfType != null) {
+ element.setAttribute(IInputType.MULTIPLE_OF_TYPE, multipleOfType.toString());
+ }
+
+ if (primaryInput != null) {
+ element.setAttribute(IInputType.PRIMARY_INPUT, primaryInput.toString());
+ }
+
+ if (buildVariable != null) {
+ element.setAttribute(IInputType.BUILD_VARIABLE, buildVariable);
+ }
+
+ // Note: dependency generator cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (dependencyGeneratorElement != null) {
+ // TODO: issue warning?
+ }
+
+ // Serialize my children
+ List childElements = getInputOrderList();
+ Iterator iter = childElements.listIterator();
+ while (iter.hasNext()) {
+ InputOrder io = (InputOrder) iter.next();
+ Element ioElement = doc.createElement(InputOrder.INPUT_ORDER_ELEMENT_NAME);
+ element.appendChild(ioElement);
+ io.serialize(doc, ioElement);
+ }
+ childElements = getAdditionalInputList();
+ iter = childElements.listIterator();
+ while (iter.hasNext()) {
+ AdditionalInput ai = (AdditionalInput) iter.next();
+ Element aiElement = doc.createElement(AdditionalInput.ADDITIONAL_INPUT_ELEMENT_NAME);
+ element.appendChild(aiElement);
+ ai.serialize(doc, aiElement);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getParent()
+ */
+ public ITool getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#createInputOrder()
+ */
+ public IInputOrder createInputOrder(String path) {
+ InputOrder inputOrder = new InputOrder(this, false);
+ inputOrder.setPath(path);
+ getInputOrderList().add(inputOrder);
+ setDirty(true);
+ return inputOrder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getInputOrders()
+ */
+ public IInputOrder[] getInputOrders() {
+ IInputOrder[] orders;
+ Vector ours = getInputOrderList();
+ orders = (IInputOrder[])ours.toArray(new IInputOrder[ours.size()]);
+ return orders;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getInputOrder()
+ */
+ public IInputOrder getInputOrder(String path) {
+ // TODO Convert both paths to absolute?
+ List orders = getInputOrderList();
+ Iterator iter = orders.listIterator();
+ while (iter.hasNext()) {
+ InputOrder io = (InputOrder) iter.next();
+ if (path.compareToIgnoreCase(io.getPath()) != 0) {
+ return io;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#removeInputOrder()
+ */
+ public void removeInputOrder(String path) {
+ IInputOrder order = getInputOrder(path);
+ if (order != null) removeInputOrder(order);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#removeInputOrder()
+ */
+ public void removeInputOrder(IInputOrder element) {
+ getInputOrderList().remove(element);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#createAdditionalInput()
+ */
+ public IAdditionalInput createAdditionalInput(String paths) {
+ AdditionalInput addlInput = new AdditionalInput(this, false);
+ addlInput.setPaths(paths);
+ getAdditionalInputList().add(addlInput);
+ setDirty(true);
+ return addlInput;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalInputs()
+ */
+ public IAdditionalInput[] getAdditionalInputs() {
+ IAdditionalInput[] inputs;
+ Vector ours = getAdditionalInputList();
+ inputs = (IAdditionalInput[])ours.toArray(new IAdditionalInput[ours.size()]);
+ return inputs;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalInput()
+ */
+ public IAdditionalInput getAdditionalInput(String paths) {
+ // TODO Convert both paths to absolute?
+ // Must match all strings
+ String[] inputTokens = paths.split(";"); //$NON-NLS-1$
+ List inputs = getInputOrderList();
+ Iterator iter = inputs.listIterator();
+ while (iter.hasNext()) {
+ AdditionalInput ai = (AdditionalInput) iter.next();
+ boolean match = false;
+ String[] tokens = ai.getPaths();
+ if (tokens.length == inputTokens.length) {
+ match = true;
+ for (int i = 0; i < tokens.length; i++) {
+ if (tokens[i].compareToIgnoreCase(inputTokens[i]) != 0) {
+ match = false;
+ break;
+ }
+ }
+ }
+ if (match) return ai;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#removeAdditionalInput()
+ */
+ public void removeAdditionalInput(String path) {
+ IAdditionalInput input = getAdditionalInput(path);
+ if (input != null) removeAdditionalInput(input);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#removeAdditionalInput()
+ */
+ public void removeAdditionalInput(IAdditionalInput element) {
+ getAdditionalInputList().remove(element);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalDependencies()
+ */
+ public IPath[] getAdditionalDependencies() {
+ List deps = new ArrayList();
+ Iterator typeIter = getAdditionalInputList().iterator();
+ while (typeIter.hasNext()) {
+ AdditionalInput current = (AdditionalInput)typeIter.next();
+ int kind = current.getKind();
+ if (kind == IAdditionalInput.KIND_ADDITIONAL_DEPENDENCY ||
+ kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
+ String[] paths = current.getPaths();
+ if (paths != null) {
+ for (int i = 0; i < paths.length; i++) {
+ if (paths[i].length() > 0) {
+ deps.add(Path.fromOSString(paths[i]));
+ }
+ }
+ }
+ }
+ }
+ return (IPath[])deps.toArray(new IPath[deps.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getAdditionalResources()
+ */
+ public IPath[] getAdditionalResources() {
+ List ins = new ArrayList();
+ Iterator typeIter = getAdditionalInputList().iterator();
+ while (typeIter.hasNext()) {
+ AdditionalInput current = (AdditionalInput)typeIter.next();
+ int kind = current.getKind();
+ if (kind == IAdditionalInput.KIND_ADDITIONAL_INPUT ||
+ kind == IAdditionalInput.KIND_ADDITIONAL_INPUT_DEPENDENCY) {
+ String[] paths = current.getPaths();
+ if (paths != null) {
+ for (int i = 0; i < paths.length; i++) {
+ if (paths[i].length() > 0) {
+ ins.add(Path.fromOSString(paths[i]));
+ }
+ }
+ }
+ }
+ }
+ return (IPath[])ins.toArray(new IPath[ins.size()]);
+ }
+
+ /* (non-Javadoc)
+ * Memory-safe way to access the list of input orders
+ */
+ private Vector getInputOrderList() {
+ if (inputOrderList == null) {
+ inputOrderList = new Vector();
+ }
+ return inputOrderList;
+ }
+
+ /* (non-Javadoc)
+ * Memory-safe way to access the list of input orders
+ */
+ private Vector getAdditionalInputList() {
+ if (additionalInputList == null) {
+ additionalInputList = new Vector();
+ }
+ return additionalInputList;
+ }
+
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IInputType#getSuperClass()
+ */
+ public IInputType getSuperClass() {
+ return superClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getName()
+ */
+ public String getName() {
+ return (name == null && superClass != null) ? superClass.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getBuildVariable()
+ */
+ public String getBuildVariable() {
+ if (buildVariable == null) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getBuildVariable();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return buildVariable;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setBuildVariable()
+ */
+ public void setBuildVariable(String variableName) {
+ if (variableName == null && buildVariable == null) return;
+ if (buildVariable == null || variableName == null || !(variableName.equals(buildVariable))) {
+ buildVariable = variableName;
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyContentType()
+ */
+ public IContentType getDependencyContentType() {
+ if (dependencyContentType == null) {
+ if (superClass != null) {
+ return superClass.getDependencyContentType();
+ } else {
+ return null;
+ }
+ }
+ return dependencyContentType;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyContentType()
+ */
+ public void setDependencyContentType(IContentType type) {
+ if (dependencyContentType != type) {
+ dependencyContentType = type;
+ if (dependencyContentType != null) {
+ dependencyContentTypeId = dependencyContentType.getId();
+ } else {
+ dependencyContentTypeId = null;
+ }
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyExtensionsAttribute()
+ */
+ public String[] getDependencyExtensionsAttribute() {
+ if (dependencyExtensions == null || dependencyExtensions.size() == 0) {
+ // If I have a superClass, ask it
+ if (superClass != null) {
+ return superClass.getDependencyExtensionsAttribute();
+ } else {
+ if (dependencyExtensions == null) {
+ dependencyExtensions = new ArrayList();
+ }
+ }
+ }
+ return (String[])dependencyExtensions.toArray(new String[dependencyExtensions.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#setDependencyExtensionsAttribute()
+ */
+ public void setDependencyExtensionsAttribute(String extensions) {
+ getDependencyExtensionsList().clear();
+ if (extensions != null) {
+ StringTokenizer tokenizer = new StringTokenizer(extensions, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getDependencyExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IInputType#getDependencyExtensions()
+ */
+ public String[] getDependencyExtensions(ITool tool) {
+ // Use content type if specified and registered with Eclipse
+ IContentType type = getDependencyContentType();
+ if (type != null) {
+ String[] exts = ((Tool)tool).getContentTypeFileSpecs(type);
+ // TODO: This is a temporary hack until we decide how to specify the langauge (C vs. C++)
+ // of a .h file. If the content type is the CDT-defined C/C++ content type, then
+ // add "h" to the list if it is not already there.
+ if (type.getId().compareTo("org.eclipse.cdt.core.cxxHeader") == 0) { // $NON-NLS-1$
+ boolean h_found = false;
+ for (int i=0; iIResource
specified
- * in the argument.
- *
- * @param resource
- */
- public void updateOwner(IResource resource) {
- // Check to see if the owner is the same as the argument
- if (resource != null) {
- if (!owner.equals(resource)) {
- owner = resource;
- // Do the same for the managed project
- managedProject.updateOwner(resource);
- // And finally update the cModelElement
- cProject = CoreModel.getDefault().create(owner.getProject());
-
- // Save everything
- setDirty(true);
- setRebuildState(true);
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getSelectedConfiguration()
- */
- public IConfiguration getSelectedConfiguration() {
- return selectedConfig;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public void setSelectedConfiguration(IConfiguration config) {
- selectedConfig = config;
- }
-
- /*
- * Note: "Target" routines are only currently applicable when loading a CDT 2.0
- * or earlier managed build project file (.cdtbuild)
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
- */
- public void addTarget(ITarget target) {
- getTargetMap().put(target.getId(), target);
- getTargets().add(target);
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#removeTarget(java.lang.String)
- */
- public void removeTarget(String id) {
- getTargets().remove(getTarget(id));
- getTargetMap().remove(id);
- setDirty(true);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public ITarget getTarget(String id) {
- return (ITarget) getTargetMap().get(id);
- }
-
- /* (non-Javadoc)
- * Safe accessor.
- *
- * @return Returns the map of IDs to ITargets.
- */
- private Map getTargetMap() {
- if (targetMap == null) {
- targetMap = new HashMap();
- }
- return targetMap;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
- */
- public List getTargets() {
- if (targetList == null) {
- targetList = new ArrayList();
- }
- return targetList;
- }
-
- /**
- *
- * @return
- */
- private String getCWD() {
- String cwd = ""; //$NON-NLS-1$
- IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", getDefaultConfiguration(), false, true); //$NON-NLS-1$
- if (cwdvar != null) { cwd = cwdvar.getValue().replace('\\','/'); } //$NON-NLS-1$ //$NON-NLS-2$
- return cwd;
- }
-
- /**
- */
- private List processPath(List list, String path, int context, Object obj) {
- final String EMPTY = ""; //$NON-NLS-1$
- if (path != null) {
- if (context != 0) {
- try {
- String paths[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValue(path, EMPTY, " ", context, obj); //$NON-NLS-1$
- if (paths != null) {
- for(int i = 0; i < paths.length; i++){
- list.add(checkPath(paths[i]));
- }
- }
- } catch (BuildMacroException e) {
- }
- } else {
- list.add(checkPath(path));
- }
- }
- return list;
- }
-
- private String checkPath(String p){
- final String QUOTE = "\""; //$NON-NLS-1$
- final String EMPTY = ""; //$NON-NLS-1$
-
- if(p == null)
- return EMPTY;
-
- if (p.length()> 1 && p.startsWith(QUOTE) && p.endsWith(QUOTE)) {
- p = p.substring(1, p.length()-1);
- }
-
- if ( ".".equals(p) ) { //$NON-NLS-1$
- String cwd = getCWD();
- if (cwd.length()>0) { p = cwd; }
- }
- if (!(new Path(p)).isAbsolute()) {
- String cwd = getCWD();
- if (cwd.length()>0) { p = cwd + "/" + p; } //$NON-NLS-1$
- }
- return p;
-
- }
-
- /**
- * Obtain all possible Managed build values
- * @return
- */
- public IPathEntry[] getManagedBuildValues() {
- List entries = new ArrayList();
- int i=0;
- IPathEntry[] a = getManagedBuildValues(IPathEntry.CDT_INCLUDE);
- if (a != null) { for (i=0; iIResource
specified
+ * in the argument.
+ *
+ * @param resource
+ */
+ public void updateOwner(IResource resource) {
+ // Check to see if the owner is the same as the argument
+ if (resource != null) {
+ if (!owner.equals(resource)) {
+ owner = resource;
+ // Do the same for the managed project
+ managedProject.updateOwner(resource);
+ // And finally update the cModelElement
+ cProject = CoreModel.getDefault().create(owner.getProject());
+
+ // Save everything
+ setDirty(true);
+ setRebuildState(true);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getSelectedConfiguration()
+ */
+ public IConfiguration getSelectedConfiguration() {
+ return selectedConfig;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#setSelectedConfiguration(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public void setSelectedConfiguration(IConfiguration config) {
+ selectedConfig = config;
+ }
+
+ /*
+ * Note: "Target" routines are only currently applicable when loading a CDT 2.0
+ * or earlier managed build project file (.cdtbuild)
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#addTarget(org.eclipse.cdt.core.build.managed.ITarget)
+ */
+ public void addTarget(ITarget target) {
+ getTargetMap().put(target.getId(), target);
+ getTargets().add(target);
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo#removeTarget(java.lang.String)
+ */
+ public void removeTarget(String id) {
+ getTargets().remove(getTarget(id));
+ getTargetMap().remove(id);
+ setDirty(true);
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTarget(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public ITarget getTarget(String id) {
+ return (ITarget) getTargetMap().get(id);
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor.
+ *
+ * @return Returns the map of IDs to ITargets.
+ */
+ private Map getTargetMap() {
+ if (targetMap == null) {
+ targetMap = new HashMap();
+ }
+ return targetMap;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IManagedBuildInfo#getTargets(org.eclipse.cdt.core.build.managed.IConfiguration)
+ */
+ public List getTargets() {
+ if (targetList == null) {
+ targetList = new ArrayList();
+ }
+ return targetList;
+ }
+
+ /**
+ *
+ * @return
+ */
+ private String getCWD() {
+ String cwd = ""; //$NON-NLS-1$
+ IBuildEnvironmentVariable cwdvar = ManagedBuildManager.getEnvironmentVariableProvider().getVariable("CWD", getDefaultConfiguration(), false, true); //$NON-NLS-1$
+ if (cwdvar != null) { cwd = cwdvar.getValue().replace('\\','/'); } //$NON-NLS-1$ //$NON-NLS-2$
+ return cwd;
+ }
+
+ /**
+ */
+ private List processPath(List list, String path, int context, Object obj) {
+ final String EMPTY = ""; //$NON-NLS-1$
+ if (path != null) {
+ if (context != 0) {
+ try {
+ String paths[] = ManagedBuildManager.getBuildMacroProvider().resolveStringListValue(path, EMPTY, " ", context, obj); //$NON-NLS-1$
+ if (paths != null) {
+ for(int i = 0; i < paths.length; i++){
+ list.add(checkPath(paths[i]));
+ }
+ }
+ } catch (BuildMacroException e) {
+ }
+ } else {
+ list.add(checkPath(path));
+ }
+ }
+ return list;
+ }
+
+ private String checkPath(String p){
+ final String QUOTE = "\""; //$NON-NLS-1$
+ final String EMPTY = ""; //$NON-NLS-1$
+
+ if(p == null)
+ return EMPTY;
+
+ if (p.length()> 1 && p.startsWith(QUOTE) && p.endsWith(QUOTE)) {
+ p = p.substring(1, p.length()-1);
+ }
+
+ if ( ".".equals(p) ) { //$NON-NLS-1$
+ String cwd = getCWD();
+ if (cwd.length()>0) { p = cwd; }
+ }
+ if (!(new Path(p)).isAbsolute()) {
+ String cwd = getCWD();
+ if (cwd.length()>0) { p = cwd + "/" + p; } //$NON-NLS-1$
+ }
+ return p;
+
+ }
+
+ /**
+ * Obtain all possible Managed build values
+ * @return
+ */
+ public IPathEntry[] getManagedBuildValues() {
+ List entries = new ArrayList();
+ int i=0;
+ IPathEntry[] a = getManagedBuildValues(IPathEntry.CDT_INCLUDE);
+ if (a != null) { for (i=0; inull
if
- * defined at the top level
- * @param element The option definition from the manifest file or a dynamic element
- * provider
- */
- public Option(IHoldsOptions parent, IManagedConfigElement element) {
- this.holder = parent;
- isExtensionOption = true;
-
- // setup for resolving
- resolved = false;
-
- loadFromManifest(element);
-
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionOption(this);
- }
-
- /**
- * This constructor is called to create an Option whose attributes and children will be
- * added by separate calls.
- *
- * @param IHoldsOptions The parent of the option, if any
- * @param Option The superClass, if any
- * @param String The id for the new option
- * @param String The name for the new option
- * @param boolean Indicates whether this is an extension element or a managed project element
- */
- public Option(IHoldsOptions parent, IOption superClass, String Id, String name, boolean isExtensionElement) {
- this.holder = parent;
- this.superClass = superClass;
- if (this.superClass != null) {
- superClassId = this.superClass.getId();
- }
- setId(Id);
- setName(name);
- isExtensionOption = isExtensionElement;
- if (isExtensionElement) {
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionOption(this);
- } else {
- setDirty(true);
- }
- }
-
- /**
- * Create an Option
based on the specification stored in the
- * project file (.cdtbuild).
- *
- * @param parent The IHoldsOptions
the option will be added to.
- * @param element The XML element that contains the option settings.
- */
- public Option(IHoldsOptions parent, Element element) {
- this.holder = parent;
- isExtensionOption = false;
-
- // Initialize from the XML attributes
- loadFromProject(element);
- }
-
- /**
- * Create an Option
based upon an existing option.
- *
- * @param parent The IHoldsOptions
the option will be added to.
- * @param Id New ID for the option.
- * @param name New name for the option.
- * @param option The existing option to clone, except for the above fields.
- */
- public Option(IHoldsOptions parent, String Id, String name, Option option){
- this.holder = parent;
- superClass = option.superClass;
- if (superClass != null) {
- superClassId = option.superClass.getId();
- }
- setId(Id);
- setName(name);
- isExtensionOption = false;
-
- // Copy the remaining attributes
- if (option.unusedChildren != null) {
- unusedChildren = new String(option.unusedChildren);
- }
- if (option.isAbstract != null) {
- isAbstract = new Boolean(option.isAbstract.booleanValue());
- }
- if (option.command != null) {
- command = new String(option.command);
- }
- if (option.commandFalse != null) {
- commandFalse = new String(option.commandFalse);
- }
- if (option.tip != null) {
- tip = new String(option.tip);
- }
- if (option.categoryId != null) {
- categoryId = new String(option.categoryId);
- }
- if (option.builtIns != null) {
- builtIns = new ArrayList(option.builtIns);
- }
- if (option.browseType != null) {
- browseType = new Integer(option.browseType.intValue());
- }
- if (option.resourceFilter != null) {
- resourceFilter = new Integer(option.resourceFilter.intValue());
- }
- if (option.enumList != null) {
- enumList = new ArrayList(option.enumList);
- enumCommands = new HashMap(option.enumCommands);
- enumNames = new HashMap(option.enumNames);
- }
-
- if (option.valueType != null) {
- valueType = new Integer(option.valueType.intValue());
- }
- Integer vType = null;
- try {
- vType = new Integer(option.getValueType());
- if (vType != null) {
- switch (vType.intValue()) {
- case BOOLEAN:
- if (option.value != null) {
- value = new Boolean(((Boolean)option.value).booleanValue());
- }
- if (option.defaultValue != null) {
- defaultValue = new Boolean(((Boolean)option.defaultValue).booleanValue());
- }
- break;
- case STRING:
- case ENUMERATED:
- if (option.value != null) {
- value = new String((String)option.value);
- }
- if (option.defaultValue != null) {
- defaultValue = new String((String)option.defaultValue);
- }
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- if (option.value != null) {
- value = new ArrayList((ArrayList)option.value);
- }
- if (option.defaultValue != null) {
- defaultValue = new ArrayList((ArrayList)option.defaultValue);
- }
- break;
- }
- }
- } catch (BuildException be) {
- // TODO: should we ignore this??
- }
-
- category = option.category;
- applicabilityCalculatorElement = option.applicabilityCalculatorElement;
- applicabilityCalculator = option.applicabilityCalculator;
-
- booleanExpressionCalculator = option.booleanExpressionCalculator;
-
- if (option.valueHandlerElement != null) {
- valueHandlerElement = option.valueHandlerElement;
- valueHandler = option.valueHandler;
- }
- if (option.valueHandlerExtraArgument != null) {
- valueHandlerExtraArgument = new String(option.valueHandlerExtraArgument);
- }
-
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /*
- * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
- */
-
- /* (non-Javadoc)
- * Loads the option information from the ManagedConfigElement specified in the
- * argument.
- *
- * @param element Contains the option information
- */
- protected void loadFromManifest(IManagedConfigElement element) {
- ManagedBuildManager.putConfigElement(this, element);
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // Get the name
- setName(element.getAttribute(IBuildObject.NAME));
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
-
- // Get the unused children, if any
- unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
-
- // isAbstract
- String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
- if (isAbs != null){
- isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
- }
-
- // Get the command defined for the option
- command = element.getAttribute(COMMAND);
-
- // Get the command defined for a Boolean option when the value is False
- commandFalse = element.getAttribute(COMMAND_FALSE);
-
- // Get the tooltip for the option
- tip = element.getAttribute(TOOL_TIP);
-
- // Options hold different types of values
- String valueTypeStr = element.getAttribute(VALUE_TYPE);
- if (valueTypeStr != null) {
- valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
- }
-
- // Note: The value and defaultValue attributes are loaded in the resolveReferences routine.
- // This is because we need to have the value-type, and this may be defined in a
- // superClass that is not yet loaded.
-
- // Determine if there needs to be a browse button
- String browseTypeStr = element.getAttribute(BROWSE_TYPE);
- if (browseTypeStr == null) {
- // Set to null, to indicate no browse type specification
- // This will allow any superclasses to be searched for the
- // browse type specification, and thus inherited, if found,
- // which they should be
- browseType = null;
- } else if (browseTypeStr.equals(NONE)) {
- browseType = new Integer(BROWSE_NONE);
- } else if (browseTypeStr.equals(FILE)) {
- browseType = new Integer(BROWSE_FILE);
- } else if (browseTypeStr.equals(DIR)) {
- browseType = new Integer(BROWSE_DIR);
- }
-
- categoryId = element.getAttribute(CATEGORY);
-
- // Get the resourceFilter attribute
- String resFilterStr = element.getAttribute(RESOURCE_FILTER);
- if (resFilterStr == null) {
- // Set to null, to indicate no resource filter specification
- // This will allow any superclasses to be searched for the
- // resource filter specification, and thus inherited, if found,
- // which they should be
- resourceFilter = null;
- } else if (resFilterStr.equals(ALL)) {
- resourceFilter = new Integer(FILTER_ALL);
- } else if (resFilterStr.equals(FILE)) {
- resourceFilter = new Integer(FILTER_FILE);
- } else if (resFilterStr.equals(PROJECT)) {
- resourceFilter = new Integer(FILTER_PROJECT);
- }
-
- //get enablements
- IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
- if(enablements.length > 0)
- booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
-
- // get the applicability calculator, if any
- String applicabilityCalculatorStr = element.getAttribute(APPLICABILITY_CALCULATOR);
- if (applicabilityCalculatorStr != null && element instanceof DefaultManagedConfigElement) {
- applicabilityCalculatorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- } else {
- applicabilityCalculator = booleanExpressionCalculator;
- }
-
- // valueHandler
- // Store the configuration element IFF there is a value handler defined
- String valueHandler = element.getAttribute(VALUE_HANDLER);
- if (valueHandler != null && element instanceof DefaultManagedConfigElement) {
- valueHandlerElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- }
- // valueHandlerExtraArgument
- valueHandlerExtraArgument = element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT);
- }
-
- /* (non-Javadoc)
- * Initialize the option information from the XML element
- * specified in the argument
- *
- * @param element An XML element containing the option information
- */
- protected void loadFromProject(Element element) {
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // name
- if (element.hasAttribute(IBuildObject.NAME)) {
- setName(element.getAttribute(IBuildObject.NAME));
- }
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
- if (superClassId != null && superClassId.length() > 0) {
- superClass = ManagedBuildManager.getExtensionOption(superClassId);
- if (superClass == null) {
- // TODO: Report error
- }
- }
-
- // Get the unused children, if any
- if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
- unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
- }
-
- // isAbstract
- if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
- String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
- if (isAbs != null){
- isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
- }
- }
-
- // Get the command defined for the option
- if (element.hasAttribute(COMMAND)) {
- command = element.getAttribute(COMMAND);
- }
-
- // Get the command defined for a Boolean option when the value is False
- if (element.hasAttribute(COMMAND_FALSE)) {
- commandFalse = element.getAttribute(COMMAND_FALSE);
- }
-
- // Get the tooltip for the option
- if (element.hasAttribute(TOOL_TIP)) {
- tip = element.getAttribute(TOOL_TIP);
- }
-
- // Options hold different types of values
- if (element.hasAttribute(VALUE_TYPE)) {
- String valueTypeStr = element.getAttribute(VALUE_TYPE);
- valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
- }
-
- // Now get the actual value based upon value-type
- try {
- int valType = getValueType();
- switch (valType) {
- case BOOLEAN:
- // Convert the string to a boolean
- if (element.hasAttribute(VALUE)) {
- value = new Boolean(element.getAttribute(VALUE));
- }
- if (element.hasAttribute(DEFAULT_VALUE)) {
- defaultValue = new Boolean(element.getAttribute(DEFAULT_VALUE));
- }
- break;
- case STRING:
- // Just get the value out of the option directly
- if (element.hasAttribute(VALUE)) {
- value = element.getAttribute(VALUE);
- }
- if (element.hasAttribute(DEFAULT_VALUE)) {
- defaultValue = element.getAttribute(DEFAULT_VALUE);
- }
- break;
- case ENUMERATED:
- if (element.hasAttribute(VALUE)) {
- value = element.getAttribute(VALUE);
- }
- if (element.hasAttribute(DEFAULT_VALUE)) {
- defaultValue = element.getAttribute(DEFAULT_VALUE);
- }
-
- // Do we have enumeratedOptionValue children? If so, load them
- // to define the valid values and the default value.
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configNode = configElements.item(i);
- if (configNode.getNodeName().equals(ENUM_VALUE)) {
- Element configElement = (Element)configNode;
- String optId = configElement.getAttribute(ID);
- if (i == 0) {
- enumList = new ArrayList();
- if (defaultValue == null) {
- defaultValue = optId; // Default value to be overridden is default is specified
- }
- }
- enumList.add(optId);
- if (configElement.hasAttribute(COMMAND)) {
- getEnumCommandMap().put(optId, configElement.getAttribute(COMMAND));
- } else {
- getEnumCommandMap().put(optId, EMPTY_STRING);
- }
- getEnumNameMap().put(optId, configElement.getAttribute(NAME));
- if (configElement.hasAttribute(IS_DEFAULT)) {
- Boolean isDefault = new Boolean(configElement.getAttribute(IS_DEFAULT));
- if (isDefault.booleanValue()) {
- defaultValue = optId;
- }
- }
- }
- }
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- // Note: These string-list options do not load either the "value" or
- // "defaultValue" attributes. Instead, the ListOptionValue children
- // are loaded in the value field.
- List valueList = null;
- configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- if (i == 0) {
- valueList = new ArrayList();
- builtIns = new ArrayList();
- }
- Node configNode = configElements.item(i);
- if (configNode.getNodeName().equals(LIST_VALUE)) {
- Element valueElement = (Element)configNode;
- Boolean isBuiltIn;
- if (valueElement.hasAttribute(IS_DEFAULT)) {
- isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
- } else {
- isBuiltIn = new Boolean(false);
- }
- if (isBuiltIn.booleanValue()) {
- builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- else {
- valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- }
- }
- value = valueList;
- break;
- default :
- break;
- }
- } catch (BuildException e) {
- // TODO: report error
- }
-
- // Determine if there needs to be a browse button
- if (element.hasAttribute(BROWSE_TYPE)) {
- String browseTypeStr = element.getAttribute(BROWSE_TYPE);
-
- if (browseTypeStr == null) {
- // Set to null, to indicate no browse type specification
- // This will allow any superclasses to be searched for the
- // browse type specification, and thus inherited, if found,
- // which they should be
- browseType = null;
- } else if (browseTypeStr.equals(NONE)) {
- browseType = new Integer(BROWSE_NONE);
- } else if (browseTypeStr.equals(FILE)) {
- browseType = new Integer(BROWSE_FILE);
- } else if (browseTypeStr.equals(DIR)) {
- browseType = new Integer(BROWSE_DIR);
- }
- }
-
- if (element.hasAttribute(CATEGORY)) {
- categoryId = element.getAttribute(CATEGORY);
- if (categoryId != null) {
- category = holder.getOptionCategory(categoryId);
- }
- }
-
- // Get the resourceFilter attribute
- if (element.hasAttribute(RESOURCE_FILTER)) {
- String resFilterStr = element.getAttribute(RESOURCE_FILTER);
- if (resFilterStr == null) {
- // Set to null, to indicate no resource filter specification
- // This will allow any superclasses to be searched for the
- // resource filter specification, and thus inherited, if found,
- // which they should be
- resourceFilter = null;
- } else if (resFilterStr.equals(ALL)) {
- resourceFilter = new Integer(FILTER_ALL);
- } else if (resFilterStr.equals(FILE)) {
- resourceFilter = new Integer(FILTER_FILE);
- } else if (resFilterStr.equals(PROJECT)) {
- resourceFilter = new Integer(FILTER_PROJECT);
- }
- }
-
- // Note: valueHandlerElement and VALUE_HANDLER are not restored,
- // as they are not saved. See note in serialize().
-
- // valueHandlerExtraArgument
- if (element.hasAttribute(VALUE_HANDLER_EXTRA_ARGUMENT)) {
- valueHandlerExtraArgument = element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT);
- }
- }
-
- private int ValueTypeStrToInt(String valueTypeStr) {
- if (valueTypeStr == null) return -1;
- if (valueTypeStr.equals(TYPE_STRING))
- return STRING;
- else if (valueTypeStr.equals(TYPE_STR_LIST))
- return STRING_LIST;
- else if (valueTypeStr.equals(TYPE_BOOL))
- return BOOLEAN;
- else if (valueTypeStr.equals(TYPE_ENUM))
- return ENUMERATED;
- else if (valueTypeStr.equals(TYPE_INC_PATH))
- return INCLUDE_PATH;
- else if (valueTypeStr.equals(TYPE_LIB))
- return LIBRARIES;
- else if (valueTypeStr.equals(TYPE_USER_OBJS))
- return OBJECTS;
- else if (valueTypeStr.equals(TYPE_DEFINED_SYMBOLS))
- return PREPROCESSOR_SYMBOLS;
- else {
- // TODO: This was the CDT 2.0 default - should we keep it?
- return PREPROCESSOR_SYMBOLS;
- }
- }
-
- /**
- * Persist the option to the project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) throws BuildException {
- if (superClass != null)
- element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
-
- element.setAttribute(IBuildObject.ID, id);
-
- if (name != null) {
- element.setAttribute(IBuildObject.NAME, name);
- }
-
- if (unusedChildren != null) {
- element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
- }
-
- if (isAbstract != null) {
- element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
- }
-
- if (command != null) {
- element.setAttribute(COMMAND, command);
- }
-
- if (commandFalse != null) {
- element.setAttribute(COMMAND_FALSE, commandFalse);
- }
-
- if (tip != null) {
- element.setAttribute(TOOL_TIP, tip);
- }
-
- /*
- * Note: We store value & value-type as a pair, so we know what type of value we are
- * dealing with when we read it back in.
- * This is also true of defaultValue.
- */
- boolean storeValueType = false;
-
- // value
- if (value != null) {
- storeValueType = true;
- switch (getValueType()) {
- case BOOLEAN:
- element.setAttribute(VALUE, ((Boolean)value).toString());
- break;
- case STRING:
- case ENUMERATED:
- element.setAttribute(VALUE, (String)value);
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- if (value != null) {
- ArrayList stringList = (ArrayList)value;
- ListIterator iter = stringList.listIterator();
- while (iter.hasNext()) {
- Element valueElement = doc.createElement(LIST_VALUE);
- valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
- valueElement.setAttribute(LIST_ITEM_BUILTIN, "false"); //$NON-NLS-1$
- element.appendChild(valueElement);
- }
- }
- // Serialize the built-ins that have been overridden
- if (builtIns != null) {
- ListIterator iter = builtIns.listIterator();
- while (iter.hasNext()) {
- Element valueElement = doc.createElement(LIST_VALUE);
- valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
- valueElement.setAttribute(LIST_ITEM_BUILTIN, "true"); //$NON-NLS-1$
- element.appendChild(valueElement);
- }
- }
- break;
- }
- }
-
- // defaultValue
- if (defaultValue != null) {
- storeValueType = true;
- switch (getValueType()) {
- case BOOLEAN:
- element.setAttribute(DEFAULT_VALUE, ((Boolean)defaultValue).toString());
- break;
- case STRING:
- case ENUMERATED:
- element.setAttribute(DEFAULT_VALUE, (String)defaultValue);
- break;
- default:
- break;
- }
- }
-
- if (storeValueType) {
- String str;
- switch (getValueType()) {
- case BOOLEAN:
- str = TYPE_BOOL;
- break;
- case STRING:
- str = TYPE_STRING;
- break;
- case ENUMERATED:
- str = TYPE_ENUM;
- break;
- case STRING_LIST:
- str = TYPE_STR_LIST;
- break;
- case INCLUDE_PATH:
- str = TYPE_INC_PATH;
- break;
- case LIBRARIES:
- str = TYPE_LIB;
- break;
- case OBJECTS:
- str = TYPE_USER_OBJS;
- break;
- case PREPROCESSOR_SYMBOLS:
- str = TYPE_DEFINED_SYMBOLS;
- break;
- default:
- // TODO; is this a problem...
- str = EMPTY_STRING;
- break;
- }
- element.setAttribute(VALUE_TYPE, str);
- }
-
- // browse type
- if (browseType != null) {
- String str;
- switch (getBrowseType()) {
- case BROWSE_NONE:
- str = NONE;
- break;
- case BROWSE_FILE:
- str = FILE;
- break;
- case BROWSE_DIR:
- str = DIR;
- break;
- default:
- str = EMPTY_STRING;
- break;
- }
- element.setAttribute(BROWSE_TYPE, str);
- }
-
- if (categoryId != null) {
- element.setAttribute(CATEGORY, categoryId);
- }
-
- // resource filter
- if (resourceFilter != null) {
- String str;
- switch (getResourceFilter()) {
- case FILTER_ALL:
- str = ALL;
- break;
- case FILTER_FILE:
- str = FILE;
- break;
- case FILTER_PROJECT:
- str = PROJECT;
- break;
- default:
- str = EMPTY_STRING;
- break;
- }
- element.setAttribute(RESOURCE_FILTER, str);
- }
-
- // Note: applicability calculator cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (applicabilityCalculatorElement != null) {
- // TODO: issue warning?
- }
-
- // Note: a value handler cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (valueHandlerElement != null) {
- // TODO: Issue warning? Stuck with behavior of this elsewhere in
- // CDT, e.g. the implementation of Tool
- }
- if (valueHandlerExtraArgument != null) {
- element.setAttribute(VALUE_HANDLER_EXTRA_ARGUMENT, valueHandlerExtraArgument);
- }
-
- // I am clean now
- isDirty = false;
- }
-
- /*
- * P A R E N T A N D C H I L D H A N D L I N G
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getParent()
- */
- public IBuildObject getParent() {
- return holder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getOptionHolder()
- */
- public IHoldsOptions getOptionHolder() {
- // Do not take superclasses into account
- return holder;
- }
-
- /*
- * M O D E L A T T R I B U T E A C C E S S O R S
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getSuperClass()
- */
- public IOption getSuperClass() {
- return superClass;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getName()
- */
- public String getName() {
- return (name == null && superClass != null) ? superClass.getName() : name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicableValues()
- */
- public String[] getApplicableValues() {
- // Does this option instance have the list of values?
- if (enumList == null) {
- if (superClass != null) {
- return superClass.getApplicableValues();
- } else {
- return EMPTY_STRING_ARRAY;
- }
- }
- // Get all of the enumerated names from the option
- if (enumList.size() == 0) {
- return EMPTY_STRING_ARRAY;
- } else {
- // Return the elements in the order they are specified in the manifest
- String[] enumNames = new String[enumList.size()];
- for (int index = 0; index < enumList.size(); ++ index) {
- enumNames[index] = (String) getEnumNameMap().get(enumList.get(index));
- }
- return enumNames;
- }
- }
-
- public boolean getBooleanValue() {
- return ((Boolean)getValue()).booleanValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getBrowseType()
- */
- public int getBrowseType() {
- if (browseType == null) {
- if (superClass != null) {
- return superClass.getBrowseType();
- } else {
- return BROWSE_NONE;
- }
- }
- return browseType.intValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getResourceFilter()
- */
- public int getResourceFilter() {
- if (resourceFilter == null) {
- if (superClass != null) {
- return superClass.getResourceFilter();
- } else {
- return FILTER_ALL;
- }
- }
- return resourceFilter.intValue();
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculatorElement()
- */
- public IConfigurationElement getApplicabilityCalculatorElement() {
-/* if (applicabilityCalculatorElement == null) {
- if (superClass != null) {
- return ((Option)superClass).getApplicabilityCalculatorElement();
- }
- }
-*/
- return applicabilityCalculatorElement;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculator()
- */
- public IOptionApplicability getApplicabilityCalculator() {
- if (applicabilityCalculator == null) {
- if (applicabilityCalculatorElement != null) {
- try {
- if (applicabilityCalculatorElement.getAttribute(APPLICABILITY_CALCULATOR) != null)
- applicabilityCalculator = (IOptionApplicability) applicabilityCalculatorElement
- .createExecutableExtension(APPLICABILITY_CALCULATOR);
- } catch (CoreException e) {
- }
- }
- else if(superClass != null)
- applicabilityCalculator = superClass.getApplicabilityCalculator();
- }
-
- return applicabilityCalculator;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getBuiltIns()
- */
- public String[] getBuiltIns() {
- // Return the list of built-ins as an array
- if (builtIns == null) {
- if (superClass != null) {
- return superClass.getBuiltIns();
- } else {
- return EMPTY_STRING_ARRAY;
- }
- }
- return (String[])builtIns.toArray(new String[builtIns.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getCategory()
- */
- public IOptionCategory getCategory() {
- if (category == null) {
- if (superClass != null) {
- return superClass.getCategory();
- } else {
- if (getOptionHolder() instanceof ITool) {
- return ((ITool)getOptionHolder()).getTopOptionCategory();
- } else {
- return null;
- }
- }
- }
- return category;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getCommand()
- */
- public String getCommand() {
- if (command == null) {
- if (superClass != null) {
- return superClass.getCommand();
- } else {
- return EMPTY_STRING;
- }
- }
- return command;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getCommandFalse()
- */
- public String getCommandFalse() {
- if (commandFalse == null) {
- if (superClass != null) {
- return superClass.getCommandFalse();
- } else {
- return EMPTY_STRING;
- }
- }
- return commandFalse;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getToolTip()
- */
- public String getToolTip() {
- if (tip == null) {
- if (superClass != null) {
- return superClass.getToolTip();
- } else {
- return EMPTY_STRING;
- }
- }
- return tip;
- }
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefinedSymbols()
- */
- public String[] getDefinedSymbols() throws BuildException {
- if (getValueType() != PREPROCESSOR_SYMBOLS) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumCommand(java.lang.String)
- */
- public String getEnumCommand(String id) throws BuildException {
- // Sanity
- if (id == null) return EMPTY_STRING;
-
- // Does this option instance have the list of values?
- if (enumList == null) {
- if (superClass != null) {
- return superClass.getEnumCommand(id);
- } else {
- return EMPTY_STRING;
- }
- }
- if (getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
-
- // First check for the command in ID->command map
- String cmd = (String) getEnumCommandMap().get(id);
- if (cmd == null) {
- // This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
- // name of the enumeration. Search for the ID that maps to the name and use that to find the
- // command.
- ListIterator iter = enumList.listIterator();
- while (iter.hasNext()) {
- String realID = (String) iter.next();
- String name = (String) getEnumNameMap().get(realID);
- if (id.equals(name)) {
- cmd = (String) getEnumCommandMap().get(realID);
- break;
- }
- }
- }
- return cmd == null ? EMPTY_STRING : cmd;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumName(java.lang.String)
- */
- public String getEnumName(String id) throws BuildException {
- // Sanity
- if (id == null) return EMPTY_STRING;
-
- // Does this option instance have the list of values?
- if (enumList == null) {
- if (superClass != null) {
- return superClass.getEnumName(id);
- } else {
- return EMPTY_STRING;
- }
- }
- if (getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
-
- // First check for the command in ID->name map
- String name = (String) getEnumNameMap().get(id);
- if (name == null) {
- // This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
- // name of the enumeration.
- name = id;
- }
- return name;
- }
-
- /* (non-Javadoc)
- * A memory-safe accessor to the map of enumerated option value IDs to the commands
- * that a tool understands.
- *
- * @return a Map of enumerated option value IDs to actual commands that are passed
- * to a tool on the command line.
- */
- private Map getEnumCommandMap() {
- if (enumCommands == null) {
- enumCommands = new HashMap();
- }
- return enumCommands;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumeratedId(java.lang.String)
- */
- public String getEnumeratedId(String name) throws BuildException {
- if (name == null) return null;
-
- // Does this option instance have the list of values?
- if (enumList == null) {
- if (superClass != null) {
- return superClass.getEnumeratedId(name);
- } else {
- return EMPTY_STRING;
- }
- }
- if (getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
-
- Set idSet = getEnumNameMap().keySet();
- Iterator iter = idSet.iterator();
- while (iter.hasNext()) {
- String id = (String) iter.next();
- String enumName = (String) getEnumNameMap().get(id);
- if (name.equals(enumName)) {
- return id;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- *
- * @return a Map of enumerated option value IDs to the selection displayed to the user.
- */
- private Map getEnumNameMap() {
- if (enumNames == null) {
- enumNames = new HashMap();
- }
- return enumNames;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getIncludePaths()
- */
- public String[] getIncludePaths() throws BuildException {
- if (getValueType() != INCLUDE_PATH) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getLibraries()
- */
- public String[] getLibraries() throws BuildException {
- if (getValueType() != LIBRARIES) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefaultEnumValue()
- */
- public String getSelectedEnum() throws BuildException {
- if (getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- return getStringValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getStringListValue()
- */
- public String[] getStringListValue() throws BuildException {
- if (getValueType() != STRING_LIST) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getStringValue()
- */
- public String getStringValue() throws BuildException {
- if (getValueType() != STRING && getValueType() != ENUMERATED) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- return getValue() == null ? EMPTY_STRING : (String)getValue();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getUserObjects()
- */
- public String[] getUserObjects() throws BuildException {
- if (getValueType() != OBJECTS) {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- // This is the right puppy, so return its list value
- ArrayList v = (ArrayList)getValue();
- if (v == null) {
- return EMPTY_STRING_ARRAY;
- } else {
- v.trimToSize();
- return (String[]) v.toArray(new String[v.size()]);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueType()
- */
- public int getValueType() throws BuildException {
- if (valueType == null) {
- if (superClass != null) {
- return superClass.getValueType();
- } else {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$;
- }
- }
- return valueType.intValue();
- }
-
- /* (non-Javadoc)
- * Gets the value, applying appropriate defaults if necessary.
- */
- public Object getValue() {
- /*
- * In order to determine the current value of an option, perform the following steps until a value is found:
- * 1. Examine the value attribute of the option.
- * 2. Examine the value attribute of the option’s superClass recursively.
- * 3. Examine the dynamicDefaultValue attribute of the option and invoke it if specified. (not yet implemented)
- * 4. Examine the defaultValue attribute of the option.
- * 5. Examine the dynamicDefaultValue attribute of the option’s superClass and invoke it if specified. (not yet implemented)
- * 6. Examine the defaultValue attribute of the option’s superClass.
- * 7. Go to step 5 recursively until no more super classes.
- * 8. Use the default value for the option type.
- */
-
- Object val = getRawValue();
- if (val == null) {
- val = getDefaultValue();
- if (val == null) {
- int valType;
- try {
- valType = getValueType();
- } catch (BuildException e) {
- return EMPTY_STRING;
- }
- switch (valType) {
- case BOOLEAN:
- val = new Boolean(false);
- break;
- case STRING:
- val = EMPTY_STRING;
- break;
- case ENUMERATED:
- // TODO: Can we default to the first enumerated id?
- val = EMPTY_STRING;
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- val = new ArrayList();
- break;
- default:
- val = EMPTY_STRING;
- break;
- }
- }
- }
- return val;
- }
-
- /* (non-Javadoc)
- * Gets the raw value, applying appropriate defauls if necessary.
- */
- public Object getRawValue() {
- if (value == null) {
- if (superClass != null) {
- Option mySuperClass = (Option)superClass;
- return mySuperClass.getRawValue();
- }
- }
- return value;
- }
-
- /* (non-Javadoc)
- * Gets the raw default value.
- */
- public Object getDefaultValue() {
- // Note: string-list options do not have a default value
- if (defaultValue == null) {
- if (superClass != null) {
- return superClass.getDefaultValue();
- }
- }
- return defaultValue;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(Object)
- */
- public void setDefaultValue(Object v) {
- defaultValue = v;
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
- */
- public void setCategory(IOptionCategory category) {
- if (this.category != category) {
- this.category = category;
- if (category != null) {
- categoryId = category.getId();
- } else {
- categoryId = null;
- }
- if(!isExtensionElement())
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setCommand(String)
- */
- public void setCommand(String cmd) {
- if (cmd == null && command == null) return;
- if (cmd == null || command == null || !cmd.equals(command)) {
- command = cmd;
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setCommandFalse(String)
- */
- public void setCommandFalse(String cmd) {
- if (cmd == null && commandFalse == null) return;
- if (cmd == null || commandFalse == null || !cmd.equals(commandFalse)) {
- commandFalse = cmd;
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setToolTip(String)
- */
- public void setToolTip(String tooltip) {
- if (tooltip == null && tip == null) return;
- if (tooltip == null || tip == null || !tooltip.equals(tip)) {
- tip = tooltip;
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int)
- */
- public void setResourceFilter(int filter) {
- if (resourceFilter == null || !(filter == resourceFilter.intValue())) {
- resourceFilter = new Integer(filter);
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setBrowseType(int)
- */
- public void setBrowseType(int type) {
- if (browseType == null || !(type == browseType.intValue())) {
- browseType = new Integer(type);
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(boolean)
- */
- public void setValue(boolean value) throws BuildException {
- if (/*!isExtensionElement() && */getValueType() == BOOLEAN){
- this.value = new Boolean(value);
- } else {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- if(!isExtensionElement())
- setDirty(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String)
- */
- public void setValue(String value) throws BuildException {
- // Note that we can still set the human-readable value here
- if (/*!isExtensionElement() && */(getValueType() == STRING || getValueType() == ENUMERATED)) {
- this.value = value;
- } else {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- if(!isExtensionElement())
- setDirty(true);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String [])
- */
- public void setValue(String [] value) throws BuildException {
- if (/*!isExtensionElement() && */
- (getValueType() == STRING_LIST
- || getValueType() == INCLUDE_PATH
- || getValueType() == PREPROCESSOR_SYMBOLS
- || getValueType() == LIBRARIES
- || getValueType() == OBJECTS)) {
- // Just replace what the option reference is holding onto
- if(value == null)
- this.value = null;
- else
- this.value = new ArrayList(Arrays.asList(value));
- }
- else {
- throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
- }
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(Object)
- */
- public void setValue(Object v) {
- value = v;
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValueType()
- */
- public void setValueType(int type) {
- // TODO: Verify that this is a valid type
- if (valueType == null || valueType.intValue() != type) {
- valueType = new Integer(type);
- if(!isExtensionElement())
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueHandlerElement()
- */
- public IConfigurationElement getValueHandlerElement() {
- if (valueHandlerElement == null) {
- if (superClass != null) {
- return ((Option)superClass).getValueHandlerElement();
- }
- }
- return valueHandlerElement;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValueHandlerElement(IConfigurationElement)
- */
- public void setValueHandlerElement(IConfigurationElement element) {
- valueHandlerElement = element;
- if(!isExtensionElement())
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueHandler()
- */
- public IManagedOptionValueHandler getValueHandler() {
- if (valueHandler != null) {
- return valueHandler;
- }
- IConfigurationElement element = getValueHandlerElement();
- if (element != null) {
- try {
- if (element.getAttribute(VALUE_HANDLER) != null) {
- valueHandler = (IManagedOptionValueHandler) element.createExecutableExtension(VALUE_HANDLER);
- return valueHandler;
- }
- } catch (CoreException e) {
- ManagedBuildManager.OptionValueHandlerError(element.getAttribute(VALUE_HANDLER), getId());
- // Assign the default handler to avoid further error messages
- valueHandler = ManagedOptionValueHandler.getManagedOptionValueHandler();
- return valueHandler;
- }
- }
- // If no handler is provided, then use the default handler
- return ManagedOptionValueHandler.getManagedOptionValueHandler();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueHandlerExtraArgument())
- */
- public String getValueHandlerExtraArgument() {
- if (valueHandlerExtraArgument == null) {
- if (superClass != null) {
- return superClass.getValueHandlerExtraArgument();
- } else {
- return EMPTY_STRING;
- }
- }
- return valueHandlerExtraArgument;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#setValueHandlerExtraArgument(String))
- */
- public void setValueHandlerExtraArgument(String extraArgument) {
- if (extraArgument == null && valueHandlerExtraArgument == null) return;
- if (extraArgument == null ||
- valueHandlerExtraArgument == null ||
- !extraArgument.equals(valueHandlerExtraArgument)) {
- valueHandlerExtraArgument = extraArgument;
- if(!isExtensionElement())
- isDirty = true;
- }
- }
-
-
- /*
- * O B J E C T S T A T E M A I N T E N A N C E
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#isExtensionElement()
- */
- public boolean isExtensionElement() {
- return isExtensionOption;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#overridesOnlyValue()
- * Deprecated since 3.0.1
- */
- public boolean overridesOnlyValue() {
- if (superClass != null &&
- unusedChildren == null &&
- browseType == null &&
- (builtIns == null || builtIns.size() == 0) &&
- category == null &&
- categoryId == null &&
- command == null &&
- commandFalse == null &&
- tip == null &&
- enumList == null &&
- enumCommands == null &&
- enumNames == null &&
- defaultValue == null) {
- return true;
- } else {
- return false;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#isDirty()
- */
- public boolean isDirty() {
- // This shouldn't be called for an extension option
- if (isExtensionOption) return false;
- return isDirty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- this.isDirty = isDirty;
- }
-
- public void resolveReferences() {
-
- if (!resolved) {
- resolved = true;
- // Resolve superClass
- if (superClassId != null && superClassId.length() > 0) {
- superClass = ManagedBuildManager.getExtensionOption(superClassId);
- if (superClass == null) {
- // Report error
- ManagedBuildManager.OutputResolveError(
- "superClass", //$NON-NLS-1$
- superClassId,
- "option", //$NON-NLS-1$
- getId());
- } else {
- // All of our superclasses must be resolved in order to call
- // getValueType below.
- ((Option)superClass).resolveReferences();
- }
- }
- if (categoryId != null) {
- category = holder.getOptionCategory(categoryId);
- if (category == null) {
- // Report error
- ManagedBuildManager.OutputResolveError(
- "category", //$NON-NLS-1$
- categoryId,
- "option", //$NON-NLS-1$
- getId());
- }
- }
- // Process the value and default value attributes. This is delayed until now
- // because we may not know the valueType until after we have resolved the superClass above
- // Now get the actual value
- try {
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- switch (getValueType()) {
- case BOOLEAN:
- // Convert the string to a boolean
- String val = element.getAttribute(VALUE);
- if (val != null) {
- value = new Boolean(val);
- }
- val = element.getAttribute(DEFAULT_VALUE);
- if (val != null) {
- defaultValue = new Boolean(val);
- }
- break;
- case STRING:
- // Just get the value out of the option directly
- value = element.getAttribute(VALUE);
- defaultValue = element.getAttribute(DEFAULT_VALUE);
- break;
- case ENUMERATED:
- value = element.getAttribute(VALUE);
- defaultValue = element.getAttribute(DEFAULT_VALUE);
-
- // Do we have enumeratedOptionValue children? If so, load them
- // to define the valid values and the default value.
- IManagedConfigElement[] enumElements = element.getChildren(ENUM_VALUE);
- for (int i = 0; i < enumElements.length; ++i) {
- String optId = enumElements[i].getAttribute(ID);
- if (i == 0) {
- enumList = new ArrayList();
- if (defaultValue == null) {
- defaultValue = optId; // Default value to be overridden if default is specified
- }
- }
- enumList.add(optId);
- getEnumCommandMap().put(optId, enumElements[i].getAttribute(COMMAND));
- getEnumNameMap().put(optId, enumElements[i].getAttribute(NAME));
- Boolean isDefault = new Boolean(enumElements[i].getAttribute(IS_DEFAULT));
- if (isDefault.booleanValue()) {
- defaultValue = optId;
- }
- }
- break;
- case STRING_LIST:
- case INCLUDE_PATH:
- case PREPROCESSOR_SYMBOLS:
- case LIBRARIES:
- case OBJECTS:
- // Note: These string-list options do not load either the "value" or
- // "defaultValue" attributes. Instead, the ListOptionValue children
- // are loaded in the value field.
- List valueList = null;
- IManagedConfigElement[] valueElements = element.getChildren(LIST_VALUE);
- for (int i = 0; i < valueElements.length; ++i) {
- if (i == 0) {
- valueList = new ArrayList();
- builtIns = new ArrayList();
- }
- IManagedConfigElement valueElement = valueElements[i];
- Boolean isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
- if (isBuiltIn.booleanValue()) {
- builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- else {
- valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
- }
- }
- value = valueList;
- break;
- default :
- break;
- }
- } catch (BuildException e) {
- // TODO: report error
- }
- }
- }
-
- /**
- * @return Returns the managedBuildRevision.
- */
- public String getManagedBuildRevision() {
- if ( managedBuildRevision == null) {
- if ( getParent() != null) {
- return getParent().getManagedBuildRevision();
- }
- }
- return managedBuildRevision;
- }
-
- /* (non-Javadoc)
- * For now implement this method just as a utility to make code
- * within the Option class cleaner.
- * TODO: In future we may want to move this to IOption
- */
- protected boolean isAbstract() {
- if (isAbstract != null) {
- return isAbstract.booleanValue();
- } else {
- return false; // Note: no inheritance from superClass
- }
- }
-
- /**
- * Verifies whether the option is valid and handles
- * any errors for the option. The following errors
- * can occur:
- * (a) Options that are children of a ToolChain must
- * ALWAYS have a category
- * (b) Options that are children of a ToolChain must
- * NEVER have a resourceFilter of "file".
- * If an error occurs, the option is set to being invalid.
- *
- * @pre All references have been resolved.
- */
- private void verify() {
- if (verified) return;
- verified = true;
- // Ignore elements that are superclasses
- if ( getOptionHolder() instanceof IToolChain && isAbstract() == false ) {
- // Check for error (a)
- if (getCategory() == null) {
- ManagedBuildManager.OptionValidError(ManagedBuildManager.ERROR_CATEGORY, getId());
- // Object becomes invalid
- isValid = false;
- }
- // Check for error (b). Not specifying an attribute is OK.
- // Do not use getResourceFilter as it does not allow
- // differentiating between "all" and no attribute specified.
- if ( resourceFilter != null )
- {
- switch (getResourceFilter()) {
- case Option.FILTER_FILE:
- // TODO: Cannot differentiate between "all" and attribute not
- // specified. Thus do not produce an error. We can argue that "all"
- // means all valid resource configurations.
- ManagedBuildManager.OptionValidError(ManagedBuildManager.ERROR_FILTER, getId());
- // Object becomes invalid
- isValid = false;
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IOption#isValid()
- */
- public boolean isValid() {
- // We use a lazy scheme to check whether the option is valid.
- // Note that by default an option is valid. verify() is only called if
- // the option has been resolved. This gets us around having to deal with
- // ordering problems during a resolve, or introducing another global
- // stage to verify the configuration after a resolve.
- // The trade-off is that errors in the MBS grammar may not be
- // detected on load, but only when a particular grammar element
- // is used, say in the GUI.
- if (verified == false && resolved == true) {
- verify();
- }
- return isValid;
- }
-
- /**
- * @return Returns true if this Option was created from an MBS 2.0 model
- * OptionReference element.
- */
- public boolean wasOptRef() {
- return wasOptRef;
- }
-
- public void setWasOptRef(boolean was) {
- wasOptRef = was;
- }
-
- /**
- * @return Returns the version.
- */
- public PluginVersionIdentifier getVersion() {
- if ( version == null) {
- if ( getParent() != null) {
- return getParent().getVersion();
- }
- }
- return version;
- }
-
- public void setVersion(PluginVersionIdentifier version) {
- // Do nothing
- }
-
- public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
- return booleanExpressionCalculator;
- }
-
- public boolean isAdjustedExtension(){
- return isUdjusted;
- }
-
- public void setAdjusted(boolean adjusted) {
- isUdjusted = adjusted;
- }
-
- public void setSuperClass(IOption superClass) {
- if ( this.superClass != superClass ) {
- this.superClass = superClass;
- if ( this.superClass == null) {
- superClassId = null;
- } else {
- superClassId = this.superClass.getId();
- }
-
- if(!isExtensionElement())
- setDirty(true);
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ * ARM Ltd. - basic tooltip support
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedOptionValueHandler;
+import org.eclipse.cdt.managedbuilder.internal.enablement.OptionEnablementExpression;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class Option extends BuildObject implements IOption {
+ // Static default return values
+ private static final String EMPTY_STRING = new String();
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ // Superclass
+ private IOption superClass;
+ private String superClassId;
+ // Parent and children
+ private IHoldsOptions holder;
+ // Managed Build model attributes
+ private String unusedChildren;
+ private Integer browseType;
+ private List builtIns;
+ private IOptionCategory category;
+ private String categoryId;
+ private String command;
+ private String commandFalse;
+ private String tip;
+ private List enumList;
+ private Map enumCommands;
+ private Map enumNames;
+ private Object value;
+ private Object defaultValue;
+ private Integer valueType;
+ private Boolean isAbstract;
+ private Integer resourceFilter;
+ private IConfigurationElement valueHandlerElement = null;
+ private IManagedOptionValueHandler valueHandler = null;
+ private String valueHandlerExtraArgument;
+ private IConfigurationElement applicabilityCalculatorElement = null;
+ private IOptionApplicability applicabilityCalculator = null;
+ private BooleanExpressionApplicabilityCalculator booleanExpressionCalculator = null;
+ // Miscellaneous
+ private boolean isExtensionOption = false;
+ private boolean isDirty = false;
+ private boolean resolved = true;
+ private boolean verified = false;
+ private boolean isValid = true; /** False for options which are invalid. getOption()
+ * routines will ignore invalid options. */
+ private boolean wasOptRef = false; /** True for options which are created because of an
+ * MBS 2.0 model OptionReference element
+ */
+ private boolean isUdjusted = false;
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /**
+ * This constructor is called to create an option defined by an extension point in
+ * a plugin manifest file, or returned by a dynamic element provider
+ *
+ * @param parent The IHoldsOptions parent of this option, or null
if
+ * defined at the top level
+ * @param element The option definition from the manifest file or a dynamic element
+ * provider
+ */
+ public Option(IHoldsOptions parent, IManagedConfigElement element) {
+ this.holder = parent;
+ isExtensionOption = true;
+
+ // setup for resolving
+ resolved = false;
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionOption(this);
+ }
+
+ /**
+ * This constructor is called to create an Option whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param IHoldsOptions The parent of the option, if any
+ * @param Option The superClass, if any
+ * @param String The id for the new option
+ * @param String The name for the new option
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+ public Option(IHoldsOptions parent, IOption superClass, String Id, String name, boolean isExtensionElement) {
+ this.holder = parent;
+ this.superClass = superClass;
+ if (this.superClass != null) {
+ superClassId = this.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionOption = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionOption(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Create an Option
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The IHoldsOptions
the option will be added to.
+ * @param element The XML element that contains the option settings.
+ */
+ public Option(IHoldsOptions parent, Element element) {
+ this.holder = parent;
+ isExtensionOption = false;
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+ }
+
+ /**
+ * Create an Option
based upon an existing option.
+ *
+ * @param parent The IHoldsOptions
the option will be added to.
+ * @param Id New ID for the option.
+ * @param name New name for the option.
+ * @param option The existing option to clone, except for the above fields.
+ */
+ public Option(IHoldsOptions parent, String Id, String name, Option option){
+ this.holder = parent;
+ superClass = option.superClass;
+ if (superClass != null) {
+ superClassId = option.superClass.getId();
+ }
+ setId(Id);
+ setName(name);
+ isExtensionOption = false;
+
+ // Copy the remaining attributes
+ if (option.unusedChildren != null) {
+ unusedChildren = new String(option.unusedChildren);
+ }
+ if (option.isAbstract != null) {
+ isAbstract = new Boolean(option.isAbstract.booleanValue());
+ }
+ if (option.command != null) {
+ command = new String(option.command);
+ }
+ if (option.commandFalse != null) {
+ commandFalse = new String(option.commandFalse);
+ }
+ if (option.tip != null) {
+ tip = new String(option.tip);
+ }
+ if (option.categoryId != null) {
+ categoryId = new String(option.categoryId);
+ }
+ if (option.builtIns != null) {
+ builtIns = new ArrayList(option.builtIns);
+ }
+ if (option.browseType != null) {
+ browseType = new Integer(option.browseType.intValue());
+ }
+ if (option.resourceFilter != null) {
+ resourceFilter = new Integer(option.resourceFilter.intValue());
+ }
+ if (option.enumList != null) {
+ enumList = new ArrayList(option.enumList);
+ enumCommands = new HashMap(option.enumCommands);
+ enumNames = new HashMap(option.enumNames);
+ }
+
+ if (option.valueType != null) {
+ valueType = new Integer(option.valueType.intValue());
+ }
+ Integer vType = null;
+ try {
+ vType = new Integer(option.getValueType());
+ if (vType != null) {
+ switch (vType.intValue()) {
+ case BOOLEAN:
+ if (option.value != null) {
+ value = new Boolean(((Boolean)option.value).booleanValue());
+ }
+ if (option.defaultValue != null) {
+ defaultValue = new Boolean(((Boolean)option.defaultValue).booleanValue());
+ }
+ break;
+ case STRING:
+ case ENUMERATED:
+ if (option.value != null) {
+ value = new String((String)option.value);
+ }
+ if (option.defaultValue != null) {
+ defaultValue = new String((String)option.defaultValue);
+ }
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ if (option.value != null) {
+ value = new ArrayList((ArrayList)option.value);
+ }
+ if (option.defaultValue != null) {
+ defaultValue = new ArrayList((ArrayList)option.defaultValue);
+ }
+ break;
+ }
+ }
+ } catch (BuildException be) {
+ // TODO: should we ignore this??
+ }
+
+ category = option.category;
+ applicabilityCalculatorElement = option.applicabilityCalculatorElement;
+ applicabilityCalculator = option.applicabilityCalculator;
+
+ booleanExpressionCalculator = option.booleanExpressionCalculator;
+
+ if (option.valueHandlerElement != null) {
+ valueHandlerElement = option.valueHandlerElement;
+ valueHandler = option.valueHandler;
+ }
+ if (option.valueHandlerExtraArgument != null) {
+ valueHandlerExtraArgument = new String(option.valueHandlerExtraArgument);
+ }
+
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Loads the option information from the ManagedConfigElement specified in the
+ * argument.
+ *
+ * @param element Contains the option information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // Get the name
+ setName(element.getAttribute(IBuildObject.NAME));
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+
+ // Get the command defined for the option
+ command = element.getAttribute(COMMAND);
+
+ // Get the command defined for a Boolean option when the value is False
+ commandFalse = element.getAttribute(COMMAND_FALSE);
+
+ // Get the tooltip for the option
+ tip = element.getAttribute(TOOL_TIP);
+
+ // Options hold different types of values
+ String valueTypeStr = element.getAttribute(VALUE_TYPE);
+ if (valueTypeStr != null) {
+ valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
+ }
+
+ // Note: The value and defaultValue attributes are loaded in the resolveReferences routine.
+ // This is because we need to have the value-type, and this may be defined in a
+ // superClass that is not yet loaded.
+
+ // Determine if there needs to be a browse button
+ String browseTypeStr = element.getAttribute(BROWSE_TYPE);
+ if (browseTypeStr == null) {
+ // Set to null, to indicate no browse type specification
+ // This will allow any superclasses to be searched for the
+ // browse type specification, and thus inherited, if found,
+ // which they should be
+ browseType = null;
+ } else if (browseTypeStr.equals(NONE)) {
+ browseType = new Integer(BROWSE_NONE);
+ } else if (browseTypeStr.equals(FILE)) {
+ browseType = new Integer(BROWSE_FILE);
+ } else if (browseTypeStr.equals(DIR)) {
+ browseType = new Integer(BROWSE_DIR);
+ }
+
+ categoryId = element.getAttribute(CATEGORY);
+
+ // Get the resourceFilter attribute
+ String resFilterStr = element.getAttribute(RESOURCE_FILTER);
+ if (resFilterStr == null) {
+ // Set to null, to indicate no resource filter specification
+ // This will allow any superclasses to be searched for the
+ // resource filter specification, and thus inherited, if found,
+ // which they should be
+ resourceFilter = null;
+ } else if (resFilterStr.equals(ALL)) {
+ resourceFilter = new Integer(FILTER_ALL);
+ } else if (resFilterStr.equals(FILE)) {
+ resourceFilter = new Integer(FILTER_FILE);
+ } else if (resFilterStr.equals(PROJECT)) {
+ resourceFilter = new Integer(FILTER_PROJECT);
+ }
+
+ //get enablements
+ IManagedConfigElement enablements[] = element.getChildren(OptionEnablementExpression.NAME);
+ if(enablements.length > 0)
+ booleanExpressionCalculator = new BooleanExpressionApplicabilityCalculator(enablements);
+
+ // get the applicability calculator, if any
+ String applicabilityCalculatorStr = element.getAttribute(APPLICABILITY_CALCULATOR);
+ if (applicabilityCalculatorStr != null && element instanceof DefaultManagedConfigElement) {
+ applicabilityCalculatorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ } else {
+ applicabilityCalculator = booleanExpressionCalculator;
+ }
+
+ // valueHandler
+ // Store the configuration element IFF there is a value handler defined
+ String valueHandler = element.getAttribute(VALUE_HANDLER);
+ if (valueHandler != null && element instanceof DefaultManagedConfigElement) {
+ valueHandlerElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+ // valueHandlerExtraArgument
+ valueHandlerExtraArgument = element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT);
+ }
+
+ /* (non-Javadoc)
+ * Initialize the option information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the option information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionOption(superClassId);
+ if (superClass == null) {
+ // TODO: Report error
+ }
+ }
+
+ // Get the unused children, if any
+ if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+ }
+
+ // isAbstract
+ if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+ }
+
+ // Get the command defined for the option
+ if (element.hasAttribute(COMMAND)) {
+ command = element.getAttribute(COMMAND);
+ }
+
+ // Get the command defined for a Boolean option when the value is False
+ if (element.hasAttribute(COMMAND_FALSE)) {
+ commandFalse = element.getAttribute(COMMAND_FALSE);
+ }
+
+ // Get the tooltip for the option
+ if (element.hasAttribute(TOOL_TIP)) {
+ tip = element.getAttribute(TOOL_TIP);
+ }
+
+ // Options hold different types of values
+ if (element.hasAttribute(VALUE_TYPE)) {
+ String valueTypeStr = element.getAttribute(VALUE_TYPE);
+ valueType = new Integer(ValueTypeStrToInt(valueTypeStr));
+ }
+
+ // Now get the actual value based upon value-type
+ try {
+ int valType = getValueType();
+ switch (valType) {
+ case BOOLEAN:
+ // Convert the string to a boolean
+ if (element.hasAttribute(VALUE)) {
+ value = new Boolean(element.getAttribute(VALUE));
+ }
+ if (element.hasAttribute(DEFAULT_VALUE)) {
+ defaultValue = new Boolean(element.getAttribute(DEFAULT_VALUE));
+ }
+ break;
+ case STRING:
+ // Just get the value out of the option directly
+ if (element.hasAttribute(VALUE)) {
+ value = element.getAttribute(VALUE);
+ }
+ if (element.hasAttribute(DEFAULT_VALUE)) {
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+ }
+ break;
+ case ENUMERATED:
+ if (element.hasAttribute(VALUE)) {
+ value = element.getAttribute(VALUE);
+ }
+ if (element.hasAttribute(DEFAULT_VALUE)) {
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+ }
+
+ // Do we have enumeratedOptionValue children? If so, load them
+ // to define the valid values and the default value.
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configNode = configElements.item(i);
+ if (configNode.getNodeName().equals(ENUM_VALUE)) {
+ Element configElement = (Element)configNode;
+ String optId = configElement.getAttribute(ID);
+ if (i == 0) {
+ enumList = new ArrayList();
+ if (defaultValue == null) {
+ defaultValue = optId; // Default value to be overridden is default is specified
+ }
+ }
+ enumList.add(optId);
+ if (configElement.hasAttribute(COMMAND)) {
+ getEnumCommandMap().put(optId, configElement.getAttribute(COMMAND));
+ } else {
+ getEnumCommandMap().put(optId, EMPTY_STRING);
+ }
+ getEnumNameMap().put(optId, configElement.getAttribute(NAME));
+ if (configElement.hasAttribute(IS_DEFAULT)) {
+ Boolean isDefault = new Boolean(configElement.getAttribute(IS_DEFAULT));
+ if (isDefault.booleanValue()) {
+ defaultValue = optId;
+ }
+ }
+ }
+ }
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ // Note: These string-list options do not load either the "value" or
+ // "defaultValue" attributes. Instead, the ListOptionValue children
+ // are loaded in the value field.
+ List valueList = null;
+ configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ if (i == 0) {
+ valueList = new ArrayList();
+ builtIns = new ArrayList();
+ }
+ Node configNode = configElements.item(i);
+ if (configNode.getNodeName().equals(LIST_VALUE)) {
+ Element valueElement = (Element)configNode;
+ Boolean isBuiltIn;
+ if (valueElement.hasAttribute(IS_DEFAULT)) {
+ isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
+ } else {
+ isBuiltIn = new Boolean(false);
+ }
+ if (isBuiltIn.booleanValue()) {
+ builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ else {
+ valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ }
+ }
+ value = valueList;
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {
+ // TODO: report error
+ }
+
+ // Determine if there needs to be a browse button
+ if (element.hasAttribute(BROWSE_TYPE)) {
+ String browseTypeStr = element.getAttribute(BROWSE_TYPE);
+
+ if (browseTypeStr == null) {
+ // Set to null, to indicate no browse type specification
+ // This will allow any superclasses to be searched for the
+ // browse type specification, and thus inherited, if found,
+ // which they should be
+ browseType = null;
+ } else if (browseTypeStr.equals(NONE)) {
+ browseType = new Integer(BROWSE_NONE);
+ } else if (browseTypeStr.equals(FILE)) {
+ browseType = new Integer(BROWSE_FILE);
+ } else if (browseTypeStr.equals(DIR)) {
+ browseType = new Integer(BROWSE_DIR);
+ }
+ }
+
+ if (element.hasAttribute(CATEGORY)) {
+ categoryId = element.getAttribute(CATEGORY);
+ if (categoryId != null) {
+ category = holder.getOptionCategory(categoryId);
+ }
+ }
+
+ // Get the resourceFilter attribute
+ if (element.hasAttribute(RESOURCE_FILTER)) {
+ String resFilterStr = element.getAttribute(RESOURCE_FILTER);
+ if (resFilterStr == null) {
+ // Set to null, to indicate no resource filter specification
+ // This will allow any superclasses to be searched for the
+ // resource filter specification, and thus inherited, if found,
+ // which they should be
+ resourceFilter = null;
+ } else if (resFilterStr.equals(ALL)) {
+ resourceFilter = new Integer(FILTER_ALL);
+ } else if (resFilterStr.equals(FILE)) {
+ resourceFilter = new Integer(FILTER_FILE);
+ } else if (resFilterStr.equals(PROJECT)) {
+ resourceFilter = new Integer(FILTER_PROJECT);
+ }
+ }
+
+ // Note: valueHandlerElement and VALUE_HANDLER are not restored,
+ // as they are not saved. See note in serialize().
+
+ // valueHandlerExtraArgument
+ if (element.hasAttribute(VALUE_HANDLER_EXTRA_ARGUMENT)) {
+ valueHandlerExtraArgument = element.getAttribute(VALUE_HANDLER_EXTRA_ARGUMENT);
+ }
+ }
+
+ private int ValueTypeStrToInt(String valueTypeStr) {
+ if (valueTypeStr == null) return -1;
+ if (valueTypeStr.equals(TYPE_STRING))
+ return STRING;
+ else if (valueTypeStr.equals(TYPE_STR_LIST))
+ return STRING_LIST;
+ else if (valueTypeStr.equals(TYPE_BOOL))
+ return BOOLEAN;
+ else if (valueTypeStr.equals(TYPE_ENUM))
+ return ENUMERATED;
+ else if (valueTypeStr.equals(TYPE_INC_PATH))
+ return INCLUDE_PATH;
+ else if (valueTypeStr.equals(TYPE_LIB))
+ return LIBRARIES;
+ else if (valueTypeStr.equals(TYPE_USER_OBJS))
+ return OBJECTS;
+ else if (valueTypeStr.equals(TYPE_DEFINED_SYMBOLS))
+ return PREPROCESSOR_SYMBOLS;
+ else {
+ // TODO: This was the CDT 2.0 default - should we keep it?
+ return PREPROCESSOR_SYMBOLS;
+ }
+ }
+
+ /**
+ * Persist the option to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) throws BuildException {
+ if (superClass != null)
+ element.setAttribute(IProjectType.SUPERCLASS, superClass.getId());
+
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (unusedChildren != null) {
+ element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
+ }
+
+ if (isAbstract != null) {
+ element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
+ }
+
+ if (command != null) {
+ element.setAttribute(COMMAND, command);
+ }
+
+ if (commandFalse != null) {
+ element.setAttribute(COMMAND_FALSE, commandFalse);
+ }
+
+ if (tip != null) {
+ element.setAttribute(TOOL_TIP, tip);
+ }
+
+ /*
+ * Note: We store value & value-type as a pair, so we know what type of value we are
+ * dealing with when we read it back in.
+ * This is also true of defaultValue.
+ */
+ boolean storeValueType = false;
+
+ // value
+ if (value != null) {
+ storeValueType = true;
+ switch (getValueType()) {
+ case BOOLEAN:
+ element.setAttribute(VALUE, ((Boolean)value).toString());
+ break;
+ case STRING:
+ case ENUMERATED:
+ element.setAttribute(VALUE, (String)value);
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ if (value != null) {
+ ArrayList stringList = (ArrayList)value;
+ ListIterator iter = stringList.listIterator();
+ while (iter.hasNext()) {
+ Element valueElement = doc.createElement(LIST_VALUE);
+ valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
+ valueElement.setAttribute(LIST_ITEM_BUILTIN, "false"); //$NON-NLS-1$
+ element.appendChild(valueElement);
+ }
+ }
+ // Serialize the built-ins that have been overridden
+ if (builtIns != null) {
+ ListIterator iter = builtIns.listIterator();
+ while (iter.hasNext()) {
+ Element valueElement = doc.createElement(LIST_VALUE);
+ valueElement.setAttribute(LIST_ITEM_VALUE, (String)iter.next());
+ valueElement.setAttribute(LIST_ITEM_BUILTIN, "true"); //$NON-NLS-1$
+ element.appendChild(valueElement);
+ }
+ }
+ break;
+ }
+ }
+
+ // defaultValue
+ if (defaultValue != null) {
+ storeValueType = true;
+ switch (getValueType()) {
+ case BOOLEAN:
+ element.setAttribute(DEFAULT_VALUE, ((Boolean)defaultValue).toString());
+ break;
+ case STRING:
+ case ENUMERATED:
+ element.setAttribute(DEFAULT_VALUE, (String)defaultValue);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (storeValueType) {
+ String str;
+ switch (getValueType()) {
+ case BOOLEAN:
+ str = TYPE_BOOL;
+ break;
+ case STRING:
+ str = TYPE_STRING;
+ break;
+ case ENUMERATED:
+ str = TYPE_ENUM;
+ break;
+ case STRING_LIST:
+ str = TYPE_STR_LIST;
+ break;
+ case INCLUDE_PATH:
+ str = TYPE_INC_PATH;
+ break;
+ case LIBRARIES:
+ str = TYPE_LIB;
+ break;
+ case OBJECTS:
+ str = TYPE_USER_OBJS;
+ break;
+ case PREPROCESSOR_SYMBOLS:
+ str = TYPE_DEFINED_SYMBOLS;
+ break;
+ default:
+ // TODO; is this a problem...
+ str = EMPTY_STRING;
+ break;
+ }
+ element.setAttribute(VALUE_TYPE, str);
+ }
+
+ // browse type
+ if (browseType != null) {
+ String str;
+ switch (getBrowseType()) {
+ case BROWSE_NONE:
+ str = NONE;
+ break;
+ case BROWSE_FILE:
+ str = FILE;
+ break;
+ case BROWSE_DIR:
+ str = DIR;
+ break;
+ default:
+ str = EMPTY_STRING;
+ break;
+ }
+ element.setAttribute(BROWSE_TYPE, str);
+ }
+
+ if (categoryId != null) {
+ element.setAttribute(CATEGORY, categoryId);
+ }
+
+ // resource filter
+ if (resourceFilter != null) {
+ String str;
+ switch (getResourceFilter()) {
+ case FILTER_ALL:
+ str = ALL;
+ break;
+ case FILTER_FILE:
+ str = FILE;
+ break;
+ case FILTER_PROJECT:
+ str = PROJECT;
+ break;
+ default:
+ str = EMPTY_STRING;
+ break;
+ }
+ element.setAttribute(RESOURCE_FILTER, str);
+ }
+
+ // Note: applicability calculator cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (applicabilityCalculatorElement != null) {
+ // TODO: issue warning?
+ }
+
+ // Note: a value handler cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (valueHandlerElement != null) {
+ // TODO: Issue warning? Stuck with behavior of this elsewhere in
+ // CDT, e.g. the implementation of Tool
+ }
+ if (valueHandlerExtraArgument != null) {
+ element.setAttribute(VALUE_HANDLER_EXTRA_ARGUMENT, valueHandlerExtraArgument);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getParent()
+ */
+ public IBuildObject getParent() {
+ return holder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getOptionHolder()
+ */
+ public IHoldsOptions getOptionHolder() {
+ // Do not take superclasses into account
+ return holder;
+ }
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getSuperClass()
+ */
+ public IOption getSuperClass() {
+ return superClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getName()
+ */
+ public String getName() {
+ return (name == null && superClass != null) ? superClass.getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicableValues()
+ */
+ public String[] getApplicableValues() {
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getApplicableValues();
+ } else {
+ return EMPTY_STRING_ARRAY;
+ }
+ }
+ // Get all of the enumerated names from the option
+ if (enumList.size() == 0) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ // Return the elements in the order they are specified in the manifest
+ String[] enumNames = new String[enumList.size()];
+ for (int index = 0; index < enumList.size(); ++ index) {
+ enumNames[index] = (String) getEnumNameMap().get(enumList.get(index));
+ }
+ return enumNames;
+ }
+ }
+
+ public boolean getBooleanValue() {
+ return ((Boolean)getValue()).booleanValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getBrowseType()
+ */
+ public int getBrowseType() {
+ if (browseType == null) {
+ if (superClass != null) {
+ return superClass.getBrowseType();
+ } else {
+ return BROWSE_NONE;
+ }
+ }
+ return browseType.intValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getResourceFilter()
+ */
+ public int getResourceFilter() {
+ if (resourceFilter == null) {
+ if (superClass != null) {
+ return superClass.getResourceFilter();
+ } else {
+ return FILTER_ALL;
+ }
+ }
+ return resourceFilter.intValue();
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculatorElement()
+ */
+ public IConfigurationElement getApplicabilityCalculatorElement() {
+/* if (applicabilityCalculatorElement == null) {
+ if (superClass != null) {
+ return ((Option)superClass).getApplicabilityCalculatorElement();
+ }
+ }
+*/
+ return applicabilityCalculatorElement;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getApplicabilityCalculator()
+ */
+ public IOptionApplicability getApplicabilityCalculator() {
+ if (applicabilityCalculator == null) {
+ if (applicabilityCalculatorElement != null) {
+ try {
+ if (applicabilityCalculatorElement.getAttribute(APPLICABILITY_CALCULATOR) != null)
+ applicabilityCalculator = (IOptionApplicability) applicabilityCalculatorElement
+ .createExecutableExtension(APPLICABILITY_CALCULATOR);
+ } catch (CoreException e) {
+ }
+ }
+ else if(superClass != null)
+ applicabilityCalculator = superClass.getApplicabilityCalculator();
+ }
+
+ return applicabilityCalculator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getBuiltIns()
+ */
+ public String[] getBuiltIns() {
+ // Return the list of built-ins as an array
+ if (builtIns == null) {
+ if (superClass != null) {
+ return superClass.getBuiltIns();
+ } else {
+ return EMPTY_STRING_ARRAY;
+ }
+ }
+ return (String[])builtIns.toArray(new String[builtIns.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getCategory()
+ */
+ public IOptionCategory getCategory() {
+ if (category == null) {
+ if (superClass != null) {
+ return superClass.getCategory();
+ } else {
+ if (getOptionHolder() instanceof ITool) {
+ return ((ITool)getOptionHolder()).getTopOptionCategory();
+ } else {
+ return null;
+ }
+ }
+ }
+ return category;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getCommand()
+ */
+ public String getCommand() {
+ if (command == null) {
+ if (superClass != null) {
+ return superClass.getCommand();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getCommandFalse()
+ */
+ public String getCommandFalse() {
+ if (commandFalse == null) {
+ if (superClass != null) {
+ return superClass.getCommandFalse();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return commandFalse;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getToolTip()
+ */
+ public String getToolTip() {
+ if (tip == null) {
+ if (superClass != null) {
+ return superClass.getToolTip();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return tip;
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefinedSymbols()
+ */
+ public String[] getDefinedSymbols() throws BuildException {
+ if (getValueType() != PREPROCESSOR_SYMBOLS) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumCommand(java.lang.String)
+ */
+ public String getEnumCommand(String id) throws BuildException {
+ // Sanity
+ if (id == null) return EMPTY_STRING;
+
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getEnumCommand(id);
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+
+ // First check for the command in ID->command map
+ String cmd = (String) getEnumCommandMap().get(id);
+ if (cmd == null) {
+ // This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
+ // name of the enumeration. Search for the ID that maps to the name and use that to find the
+ // command.
+ ListIterator iter = enumList.listIterator();
+ while (iter.hasNext()) {
+ String realID = (String) iter.next();
+ String name = (String) getEnumNameMap().get(realID);
+ if (id.equals(name)) {
+ cmd = (String) getEnumCommandMap().get(realID);
+ break;
+ }
+ }
+ }
+ return cmd == null ? EMPTY_STRING : cmd;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumName(java.lang.String)
+ */
+ public String getEnumName(String id) throws BuildException {
+ // Sanity
+ if (id == null) return EMPTY_STRING;
+
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getEnumName(id);
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+
+ // First check for the command in ID->name map
+ String name = (String) getEnumNameMap().get(id);
+ if (name == null) {
+ // This may be a 1.2 project or plugin manifest. If so, the argument is the human readable
+ // name of the enumeration.
+ name = id;
+ }
+ return name;
+ }
+
+ /* (non-Javadoc)
+ * A memory-safe accessor to the map of enumerated option value IDs to the commands
+ * that a tool understands.
+ *
+ * @return a Map of enumerated option value IDs to actual commands that are passed
+ * to a tool on the command line.
+ */
+ private Map getEnumCommandMap() {
+ if (enumCommands == null) {
+ enumCommands = new HashMap();
+ }
+ return enumCommands;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getEnumeratedId(java.lang.String)
+ */
+ public String getEnumeratedId(String name) throws BuildException {
+ if (name == null) return null;
+
+ // Does this option instance have the list of values?
+ if (enumList == null) {
+ if (superClass != null) {
+ return superClass.getEnumeratedId(name);
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+
+ Set idSet = getEnumNameMap().keySet();
+ Iterator iter = idSet.iterator();
+ while (iter.hasNext()) {
+ String id = (String) iter.next();
+ String enumName = (String) getEnumNameMap().get(id);
+ if (name.equals(enumName)) {
+ return id;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ *
+ * @return a Map of enumerated option value IDs to the selection displayed to the user.
+ */
+ private Map getEnumNameMap() {
+ if (enumNames == null) {
+ enumNames = new HashMap();
+ }
+ return enumNames;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getIncludePaths()
+ */
+ public String[] getIncludePaths() throws BuildException {
+ if (getValueType() != INCLUDE_PATH) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getLibraries()
+ */
+ public String[] getLibraries() throws BuildException {
+ if (getValueType() != LIBRARIES) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getDefaultEnumValue()
+ */
+ public String getSelectedEnum() throws BuildException {
+ if (getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ return getStringValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getStringListValue()
+ */
+ public String[] getStringListValue() throws BuildException {
+ if (getValueType() != STRING_LIST) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getStringValue()
+ */
+ public String getStringValue() throws BuildException {
+ if (getValueType() != STRING && getValueType() != ENUMERATED) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ return getValue() == null ? EMPTY_STRING : (String)getValue();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getUserObjects()
+ */
+ public String[] getUserObjects() throws BuildException {
+ if (getValueType() != OBJECTS) {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ // This is the right puppy, so return its list value
+ ArrayList v = (ArrayList)getValue();
+ if (v == null) {
+ return EMPTY_STRING_ARRAY;
+ } else {
+ v.trimToSize();
+ return (String[]) v.toArray(new String[v.size()]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueType()
+ */
+ public int getValueType() throws BuildException {
+ if (valueType == null) {
+ if (superClass != null) {
+ return superClass.getValueType();
+ } else {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$;
+ }
+ }
+ return valueType.intValue();
+ }
+
+ /* (non-Javadoc)
+ * Gets the value, applying appropriate defaults if necessary.
+ */
+ public Object getValue() {
+ /*
+ * In order to determine the current value of an option, perform the following steps until a value is found:
+ * 1. Examine the value attribute of the option.
+ * 2. Examine the value attribute of the option�s superClass recursively.
+ * 3. Examine the dynamicDefaultValue attribute of the option and invoke it if specified. (not yet implemented)
+ * 4. Examine the defaultValue attribute of the option.
+ * 5. Examine the dynamicDefaultValue attribute of the option�s superClass and invoke it if specified. (not yet implemented)
+ * 6. Examine the defaultValue attribute of the option�s superClass.
+ * 7. Go to step 5 recursively until no more super classes.
+ * 8. Use the default value for the option type.
+ */
+
+ Object val = getRawValue();
+ if (val == null) {
+ val = getDefaultValue();
+ if (val == null) {
+ int valType;
+ try {
+ valType = getValueType();
+ } catch (BuildException e) {
+ return EMPTY_STRING;
+ }
+ switch (valType) {
+ case BOOLEAN:
+ val = new Boolean(false);
+ break;
+ case STRING:
+ val = EMPTY_STRING;
+ break;
+ case ENUMERATED:
+ // TODO: Can we default to the first enumerated id?
+ val = EMPTY_STRING;
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ val = new ArrayList();
+ break;
+ default:
+ val = EMPTY_STRING;
+ break;
+ }
+ }
+ }
+ return val;
+ }
+
+ /* (non-Javadoc)
+ * Gets the raw value, applying appropriate defauls if necessary.
+ */
+ public Object getRawValue() {
+ if (value == null) {
+ if (superClass != null) {
+ Option mySuperClass = (Option)superClass;
+ return mySuperClass.getRawValue();
+ }
+ }
+ return value;
+ }
+
+ /* (non-Javadoc)
+ * Gets the raw default value.
+ */
+ public Object getDefaultValue() {
+ // Note: string-list options do not have a default value
+ if (defaultValue == null) {
+ if (superClass != null) {
+ return superClass.getDefaultValue();
+ }
+ }
+ return defaultValue;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(Object)
+ */
+ public void setDefaultValue(Object v) {
+ defaultValue = v;
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setCategory(org.eclipse.cdt.managedbuilder.core.IOptionCategory)
+ */
+ public void setCategory(IOptionCategory category) {
+ if (this.category != category) {
+ this.category = category;
+ if (category != null) {
+ categoryId = category.getId();
+ } else {
+ categoryId = null;
+ }
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setCommand(String)
+ */
+ public void setCommand(String cmd) {
+ if (cmd == null && command == null) return;
+ if (cmd == null || command == null || !cmd.equals(command)) {
+ command = cmd;
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setCommandFalse(String)
+ */
+ public void setCommandFalse(String cmd) {
+ if (cmd == null && commandFalse == null) return;
+ if (cmd == null || commandFalse == null || !cmd.equals(commandFalse)) {
+ commandFalse = cmd;
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setToolTip(String)
+ */
+ public void setToolTip(String tooltip) {
+ if (tooltip == null && tip == null) return;
+ if (tooltip == null || tip == null || !tooltip.equals(tip)) {
+ tip = tooltip;
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setResourceFilter(int)
+ */
+ public void setResourceFilter(int filter) {
+ if (resourceFilter == null || !(filter == resourceFilter.intValue())) {
+ resourceFilter = new Integer(filter);
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setBrowseType(int)
+ */
+ public void setBrowseType(int type) {
+ if (browseType == null || !(type == browseType.intValue())) {
+ browseType = new Integer(type);
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(boolean)
+ */
+ public void setValue(boolean value) throws BuildException {
+ if (/*!isExtensionElement() && */getValueType() == BOOLEAN){
+ this.value = new Boolean(value);
+ } else {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String)
+ */
+ public void setValue(String value) throws BuildException {
+ // Note that we can still set the human-readable value here
+ if (/*!isExtensionElement() && */(getValueType() == STRING || getValueType() == ENUMERATED)) {
+ this.value = value;
+ } else {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(String [])
+ */
+ public void setValue(String [] value) throws BuildException {
+ if (/*!isExtensionElement() && */
+ (getValueType() == STRING_LIST
+ || getValueType() == INCLUDE_PATH
+ || getValueType() == PREPROCESSOR_SYMBOLS
+ || getValueType() == LIBRARIES
+ || getValueType() == OBJECTS)) {
+ // Just replace what the option reference is holding onto
+ if(value == null)
+ this.value = null;
+ else
+ this.value = new ArrayList(Arrays.asList(value));
+ }
+ else {
+ throw new BuildException(ManagedMakeMessages.getResourceString("Option.error.bad_value_type")); //$NON-NLS-1$
+ }
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValue(Object)
+ */
+ public void setValue(Object v) {
+ value = v;
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValueType()
+ */
+ public void setValueType(int type) {
+ // TODO: Verify that this is a valid type
+ if (valueType == null || valueType.intValue() != type) {
+ valueType = new Integer(type);
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueHandlerElement()
+ */
+ public IConfigurationElement getValueHandlerElement() {
+ if (valueHandlerElement == null) {
+ if (superClass != null) {
+ return ((Option)superClass).getValueHandlerElement();
+ }
+ }
+ return valueHandlerElement;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValueHandlerElement(IConfigurationElement)
+ */
+ public void setValueHandlerElement(IConfigurationElement element) {
+ valueHandlerElement = element;
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueHandler()
+ */
+ public IManagedOptionValueHandler getValueHandler() {
+ if (valueHandler != null) {
+ return valueHandler;
+ }
+ IConfigurationElement element = getValueHandlerElement();
+ if (element != null) {
+ try {
+ if (element.getAttribute(VALUE_HANDLER) != null) {
+ valueHandler = (IManagedOptionValueHandler) element.createExecutableExtension(VALUE_HANDLER);
+ return valueHandler;
+ }
+ } catch (CoreException e) {
+ ManagedBuildManager.OptionValueHandlerError(element.getAttribute(VALUE_HANDLER), getId());
+ // Assign the default handler to avoid further error messages
+ valueHandler = ManagedOptionValueHandler.getManagedOptionValueHandler();
+ return valueHandler;
+ }
+ }
+ // If no handler is provided, then use the default handler
+ return ManagedOptionValueHandler.getManagedOptionValueHandler();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#getValueHandlerExtraArgument())
+ */
+ public String getValueHandlerExtraArgument() {
+ if (valueHandlerExtraArgument == null) {
+ if (superClass != null) {
+ return superClass.getValueHandlerExtraArgument();
+ } else {
+ return EMPTY_STRING;
+ }
+ }
+ return valueHandlerExtraArgument;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#setValueHandlerExtraArgument(String))
+ */
+ public void setValueHandlerExtraArgument(String extraArgument) {
+ if (extraArgument == null && valueHandlerExtraArgument == null) return;
+ if (extraArgument == null ||
+ valueHandlerExtraArgument == null ||
+ !extraArgument.equals(valueHandlerExtraArgument)) {
+ valueHandlerExtraArgument = extraArgument;
+ if(!isExtensionElement())
+ isDirty = true;
+ }
+ }
+
+
+ /*
+ * O B J E C T S T A T E M A I N T E N A N C E
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return isExtensionOption;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#overridesOnlyValue()
+ * Deprecated since 3.0.1
+ */
+ public boolean overridesOnlyValue() {
+ if (superClass != null &&
+ unusedChildren == null &&
+ browseType == null &&
+ (builtIns == null || builtIns.size() == 0) &&
+ category == null &&
+ categoryId == null &&
+ command == null &&
+ commandFalse == null &&
+ tip == null &&
+ enumList == null &&
+ enumCommands == null &&
+ enumNames == null &&
+ defaultValue == null) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#isDirty()
+ */
+ public boolean isDirty() {
+ // This shouldn't be called for an extension option
+ if (isExtensionOption) return false;
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ this.isDirty = isDirty;
+ }
+
+ public void resolveReferences() {
+
+ if (!resolved) {
+ resolved = true;
+ // Resolve superClass
+ if (superClassId != null && superClassId.length() > 0) {
+ superClass = ManagedBuildManager.getExtensionOption(superClassId);
+ if (superClass == null) {
+ // Report error
+ ManagedBuildManager.OutputResolveError(
+ "superClass", //$NON-NLS-1$
+ superClassId,
+ "option", //$NON-NLS-1$
+ getId());
+ } else {
+ // All of our superclasses must be resolved in order to call
+ // getValueType below.
+ ((Option)superClass).resolveReferences();
+ }
+ }
+ if (categoryId != null) {
+ category = holder.getOptionCategory(categoryId);
+ if (category == null) {
+ // Report error
+ ManagedBuildManager.OutputResolveError(
+ "category", //$NON-NLS-1$
+ categoryId,
+ "option", //$NON-NLS-1$
+ getId());
+ }
+ }
+ // Process the value and default value attributes. This is delayed until now
+ // because we may not know the valueType until after we have resolved the superClass above
+ // Now get the actual value
+ try {
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
+ switch (getValueType()) {
+ case BOOLEAN:
+ // Convert the string to a boolean
+ String val = element.getAttribute(VALUE);
+ if (val != null) {
+ value = new Boolean(val);
+ }
+ val = element.getAttribute(DEFAULT_VALUE);
+ if (val != null) {
+ defaultValue = new Boolean(val);
+ }
+ break;
+ case STRING:
+ // Just get the value out of the option directly
+ value = element.getAttribute(VALUE);
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+ break;
+ case ENUMERATED:
+ value = element.getAttribute(VALUE);
+ defaultValue = element.getAttribute(DEFAULT_VALUE);
+
+ // Do we have enumeratedOptionValue children? If so, load them
+ // to define the valid values and the default value.
+ IManagedConfigElement[] enumElements = element.getChildren(ENUM_VALUE);
+ for (int i = 0; i < enumElements.length; ++i) {
+ String optId = enumElements[i].getAttribute(ID);
+ if (i == 0) {
+ enumList = new ArrayList();
+ if (defaultValue == null) {
+ defaultValue = optId; // Default value to be overridden if default is specified
+ }
+ }
+ enumList.add(optId);
+ getEnumCommandMap().put(optId, enumElements[i].getAttribute(COMMAND));
+ getEnumNameMap().put(optId, enumElements[i].getAttribute(NAME));
+ Boolean isDefault = new Boolean(enumElements[i].getAttribute(IS_DEFAULT));
+ if (isDefault.booleanValue()) {
+ defaultValue = optId;
+ }
+ }
+ break;
+ case STRING_LIST:
+ case INCLUDE_PATH:
+ case PREPROCESSOR_SYMBOLS:
+ case LIBRARIES:
+ case OBJECTS:
+ // Note: These string-list options do not load either the "value" or
+ // "defaultValue" attributes. Instead, the ListOptionValue children
+ // are loaded in the value field.
+ List valueList = null;
+ IManagedConfigElement[] valueElements = element.getChildren(LIST_VALUE);
+ for (int i = 0; i < valueElements.length; ++i) {
+ if (i == 0) {
+ valueList = new ArrayList();
+ builtIns = new ArrayList();
+ }
+ IManagedConfigElement valueElement = valueElements[i];
+ Boolean isBuiltIn = new Boolean(valueElement.getAttribute(LIST_ITEM_BUILTIN));
+ if (isBuiltIn.booleanValue()) {
+ builtIns.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ else {
+ valueList.add(valueElement.getAttribute(LIST_ITEM_VALUE));
+ }
+ }
+ value = valueList;
+ break;
+ default :
+ break;
+ }
+ } catch (BuildException e) {
+ // TODO: report error
+ }
+ }
+ }
+
+ /**
+ * @return Returns the managedBuildRevision.
+ */
+ public String getManagedBuildRevision() {
+ if ( managedBuildRevision == null) {
+ if ( getParent() != null) {
+ return getParent().getManagedBuildRevision();
+ }
+ }
+ return managedBuildRevision;
+ }
+
+ /* (non-Javadoc)
+ * For now implement this method just as a utility to make code
+ * within the Option class cleaner.
+ * TODO: In future we may want to move this to IOption
+ */
+ protected boolean isAbstract() {
+ if (isAbstract != null) {
+ return isAbstract.booleanValue();
+ } else {
+ return false; // Note: no inheritance from superClass
+ }
+ }
+
+ /**
+ * Verifies whether the option is valid and handles
+ * any errors for the option. The following errors
+ * can occur:
+ * (a) Options that are children of a ToolChain must
+ * ALWAYS have a category
+ * (b) Options that are children of a ToolChain must
+ * NEVER have a resourceFilter of "file".
+ * If an error occurs, the option is set to being invalid.
+ *
+ * @pre All references have been resolved.
+ */
+ private void verify() {
+ if (verified) return;
+ verified = true;
+ // Ignore elements that are superclasses
+ if ( getOptionHolder() instanceof IToolChain && isAbstract() == false ) {
+ // Check for error (a)
+ if (getCategory() == null) {
+ ManagedBuildManager.OptionValidError(ManagedBuildManager.ERROR_CATEGORY, getId());
+ // Object becomes invalid
+ isValid = false;
+ }
+ // Check for error (b). Not specifying an attribute is OK.
+ // Do not use getResourceFilter as it does not allow
+ // differentiating between "all" and no attribute specified.
+ if ( resourceFilter != null )
+ {
+ switch (getResourceFilter()) {
+ case Option.FILTER_FILE:
+ // TODO: Cannot differentiate between "all" and attribute not
+ // specified. Thus do not produce an error. We can argue that "all"
+ // means all valid resource configurations.
+ ManagedBuildManager.OptionValidError(ManagedBuildManager.ERROR_FILTER, getId());
+ // Object becomes invalid
+ isValid = false;
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IOption#isValid()
+ */
+ public boolean isValid() {
+ // We use a lazy scheme to check whether the option is valid.
+ // Note that by default an option is valid. verify() is only called if
+ // the option has been resolved. This gets us around having to deal with
+ // ordering problems during a resolve, or introducing another global
+ // stage to verify the configuration after a resolve.
+ // The trade-off is that errors in the MBS grammar may not be
+ // detected on load, but only when a particular grammar element
+ // is used, say in the GUI.
+ if (verified == false && resolved == true) {
+ verify();
+ }
+ return isValid;
+ }
+
+ /**
+ * @return Returns true if this Option was created from an MBS 2.0 model
+ * OptionReference element.
+ */
+ public boolean wasOptRef() {
+ return wasOptRef;
+ }
+
+ public void setWasOptRef(boolean was) {
+ wasOptRef = was;
+ }
+
+ /**
+ * @return Returns the version.
+ */
+ public PluginVersionIdentifier getVersion() {
+ if ( version == null) {
+ if ( getParent() != null) {
+ return getParent().getVersion();
+ }
+ }
+ return version;
+ }
+
+ public void setVersion(PluginVersionIdentifier version) {
+ // Do nothing
+ }
+
+ public BooleanExpressionApplicabilityCalculator getBooleanExpressionCalculator(){
+ return booleanExpressionCalculator;
+ }
+
+ public boolean isAdjustedExtension(){
+ return isUdjusted;
+ }
+
+ public void setAdjusted(boolean adjusted) {
+ isUdjusted = adjusted;
+ }
+
+ public void setSuperClass(IOption superClass) {
+ if ( this.superClass != superClass ) {
+ this.superClass = superClass;
+ if ( this.superClass == null) {
+ superClassId = null;
+ } else {
+ superClassId = this.superClass.getId();
+ }
+
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
index f3fc0fc7815..03173c51c76 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties
@@ -1,111 +1,111 @@
-###############################################################################
-# Copyright (c) 2002, 2006 Rational Software 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:
-# IBM Rational Software - Initial API and implementation
-###############################################################################
-
-# Generated makefile builder messages
-ManagedMakeBuilder.message.starting = Starting the build for project {0}
-ManagedMakeBuilder.message.rebuild.makefiles = Regenerating makefiles for project {0}
-ManagedMakeBuilder.message.update.makefiles = Updating makefiles for project {0}
-ManagedMakeBuilder.message.incremental = Updating makefiles for project {0}
-ManagedMakeBuilder.message.updating = Updating project files...
-ManagedMakeBuilder.message.make = Calling {0} for project {1}
-ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
-ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
-ManagedMakeBuilder.message.creating.markers = Generating markers...
-ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} ****
-ManagedMakeBuilder.message.no.build = Nothing to build for {0}
-ManagedMakeBuilder.message.error = Build error
-ManagedMakeBuilder.message.error.refresh = Error refreshing project
-ManagedMakeBuilder.message.finished = Build complete for project {0}
-ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
-ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
-ManagedMakeBuilder.type.clean = Clean-only build
-ManagedMakeBuider.type.incremental = Build
-ManagedMakeBuilder.warning.unsupported.configuration=**** WARNING: The "{0}" Configuration may not build ****\n**** because it uses the "{1}" ****\n**** tool-chain that is unsupported on this system. ****\n\n**** Attempting to build... ****
-
-# Option exception messages
-Option.error.bad_value_type=Bad value for type
-
-# Managed build manager exception messages
-ManagedBuildManager.error.owner_not_null=addTarget: owner not null
-ManagedBuildManager.error.null_owner=addTarget: null owner
-ManagedBuildManager.error.owner_not_project=addTarget: owner not project
-ManagedBuildManager.error.manifest_load_failed_title=Managed Build System Version Error
-ManagedBuildManager.error.manifest.version.error=The version number defined in the plugin manifest file\n{0}\nis greater than the version of the Managed Build System.\nThe definitions in the manifest file will not be loaded.
-ManagedBuildManager.error.manifest.header=Managed Build system manifest file error:
-ManagedBuildManager.error.manifest.resolving=Unable to resolve the {0} identifier {1} in the {2} {3}.
-ManagedBuildManager.error.manifest.duplicate=Duplicate identifier {1} for element type {0}.
-ManagedBuildManager.error.manifest.icon=Could not load icon "{0}".
-ManagedBuildManager.error.manifest.option.category=Option {0} uses a null category that is invalid in its context. The option was ignored.
-ManagedBuildManager.error.manifest.option.filter=Option {0} uses an unsupported resourceFilter attribute value. The option was ignored.
-ManagedBuildManager.error.manifest.option.valuehandler=Could not load value handler {0} in option {1}.
-ManagedBuildManager.error.open_failed_title=Managed Make Project File Error
-ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error:\n\n{0}\n\nManaged Make functionality will not be available for this project.
-ManagedBuildManager.error.write_failed_title=Managed Make Project File Write Error
-ManagedBuildManager.error.write_failed=The Managed Make project file could not be written because of the following error:\n\n{0}\n
-ManagedBuildManager.error.read_only=File {0} is read-only.
-ManagedBuildManager.error.project.version.error=The version number of the project {0} is greater than the Managed Build System version number.
-ManagedBuildManager.error.id.nomatch=Error loading Managed Make project information for project {0}. The tool definitions used to create the project are not available.
-ManagedBuildManager.error.project.file.missing=The Managed Make project file for project {0} is missing.
-# Makefile Generator Messages
-MakefileGenerator.message.start.file=Building file:
-MakefileGenerator.message.finish.file=Finished building:
-MakefileGenerator.message.start.build=Building target:
-MakefileGenerator.message.finish.build=Finished building target:
-MakefileGenerator.message.start.dependency=Regenerating dependency file:
-MakefileGenerator.message.no.target=No tool found that can build the extension specified with the build arrtifact name
-MakefileGenerator.message.adding.source.folder=Adding folder {0} to sources
-MakefileGenerator.message.gen.source.makefile=Generating makefile for source folder {0}
-MakefileGenerator.message.calc.delta=Calculating the delta for project {0}
-MakefileGenerator.message.finding.sources=Finding source files in project {0}
-MakefileGenerator.comment.module.list = Every subdirectory with source files must be described here
-MakefileGenerator.comment.module.variables = Add inputs and outputs from these tool invocations to the build variables
-MakefileGenerator.comment.source.list = All of the sources participating in the build are defined here
-MakefileGenerator.comment.build.rule = Each subdirectory must supply rules for building sources it contributes
-MakefileGenerator.comment.build.toprules = Tool invocations
-MakefileGenerator.comment.build.alltarget = All Target
-MakefileGenerator.comment.build.mainbuildtarget = Main-build Target
-MakefileGenerator.comment.build.toptargets = Other Targets
-MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory
-MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list:
-MakefileGenerator.comment.autodeps=Automatically-generated dependency list:
-MakefileGenerator.comment.header=Automatically-generated file. Do not edit!
-MakefileGenerator.error.spaces=Cannot generate makefile for folder with spaces in name
-MakefileGenerator.warning.no.source=Nothing to build for project {0}
-MakefileGenerator.error.no.nameprovider=A nameProvider or outputNames must be specified with multipleType == true
-
-ManagedBuildInfo.message.job.init = Initializing path container for {0}
-ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0}
-
-# Default GNU Makefile Generator messages
-GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency file {0}
-
-# Tool strings
-Tool.default.announcement=Invoking:
-#Environment loader messages
-StorableEnvironmentLoader.storeOutputStream.wrong.arguments=Wrong arguments
-
-#User Defined Macro Supplier
-UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist macros: Wrong arguments
-
-# BuildMacroStatus messages
-BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
-BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
-BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect
-BuildMacroStatus.status.macro.not.string=Macro {0} is not of String type
-BuildMacroStatus.status.macro.not.stringlist=Macro {0} is not of String-list type
-BuildMacroStatus.status.error=Error occured
-BuildMacroStatus.value.undefined=
-
-#ResourceChangeHandler messages
-ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
-
-#ManagedBuilderCorePlugin messages
+###############################################################################
+# Copyright (c) 2002, 2006 Rational Software 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:
+# IBM Rational Software - Initial API and implementation
+###############################################################################
+
+# Generated makefile builder messages
+ManagedMakeBuilder.message.starting = Starting the build for project {0}
+ManagedMakeBuilder.message.rebuild.makefiles = Regenerating makefiles for project {0}
+ManagedMakeBuilder.message.update.makefiles = Updating makefiles for project {0}
+ManagedMakeBuilder.message.incremental = Updating makefiles for project {0}
+ManagedMakeBuilder.message.updating = Updating project files...
+ManagedMakeBuilder.message.make = Calling {0} for project {1}
+ManagedMakeBuilder.message.regen.deps = Regenerating dependency files for {0}
+ManagedMakeBuilder.message.updating.deps = Updating dependency files for {0}
+ManagedMakeBuilder.message.creating.markers = Generating markers...
+ManagedMakeBuilder.message.console.header = **** {0} of configuration {1} for project {2} ****
+ManagedMakeBuilder.message.no.build = Nothing to build for {0}
+ManagedMakeBuilder.message.error = Build error
+ManagedMakeBuilder.message.error.refresh = Error refreshing project
+ManagedMakeBuilder.message.finished = Build complete for project {0}
+ManagedMakeBuilder.message.clean.deleting.output=Removing build artifacts from {0}
+ManagedMakeBuilder.message.clean.build.clean=Trying a make clean in {0}
+ManagedMakeBuilder.type.clean = Clean-only build
+ManagedMakeBuider.type.incremental = Build
+ManagedMakeBuilder.warning.unsupported.configuration=**** WARNING: The "{0}" Configuration may not build ****\n**** because it uses the "{1}" ****\n**** tool-chain that is unsupported on this system. ****\n\n**** Attempting to build... ****
+
+# Option exception messages
+Option.error.bad_value_type=Bad value for type
+
+# Managed build manager exception messages
+ManagedBuildManager.error.owner_not_null=addTarget: owner not null
+ManagedBuildManager.error.null_owner=addTarget: null owner
+ManagedBuildManager.error.owner_not_project=addTarget: owner not project
+ManagedBuildManager.error.manifest_load_failed_title=Managed Build System Version Error
+ManagedBuildManager.error.manifest.version.error=The version number defined in the plugin manifest file\n{0}\nis greater than the version of the Managed Build System.\nThe definitions in the manifest file will not be loaded.
+ManagedBuildManager.error.manifest.header=Managed Build system manifest file error:
+ManagedBuildManager.error.manifest.resolving=Unable to resolve the {0} identifier {1} in the {2} {3}.
+ManagedBuildManager.error.manifest.duplicate=Duplicate identifier {1} for element type {0}.
+ManagedBuildManager.error.manifest.icon=Could not load icon "{0}".
+ManagedBuildManager.error.manifest.option.category=Option {0} uses a null category that is invalid in its context. The option was ignored.
+ManagedBuildManager.error.manifest.option.filter=Option {0} uses an unsupported resourceFilter attribute value. The option was ignored.
+ManagedBuildManager.error.manifest.option.valuehandler=Could not load value handler {0} in option {1}.
+ManagedBuildManager.error.open_failed_title=Managed Make Project File Error
+ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error:\n\n{0}\n\nManaged Make functionality will not be available for this project.
+ManagedBuildManager.error.write_failed_title=Managed Make Project File Write Error
+ManagedBuildManager.error.write_failed=The Managed Make project file could not be written because of the following error:\n\n{0}\n
+ManagedBuildManager.error.read_only=File {0} is read-only.
+ManagedBuildManager.error.project.version.error=The version number of the project {0} is greater than the Managed Build System version number.
+ManagedBuildManager.error.id.nomatch=Error loading Managed Make project information for project {0}. The tool definitions used to create the project are not available.
+ManagedBuildManager.error.project.file.missing=The Managed Make project file for project {0} is missing.
+# Makefile Generator Messages
+MakefileGenerator.message.start.file=Building file:
+MakefileGenerator.message.finish.file=Finished building:
+MakefileGenerator.message.start.build=Building target:
+MakefileGenerator.message.finish.build=Finished building target:
+MakefileGenerator.message.start.dependency=Regenerating dependency file:
+MakefileGenerator.message.no.target=No tool found that can build the extension specified with the build arrtifact name
+MakefileGenerator.message.adding.source.folder=Adding folder {0} to sources
+MakefileGenerator.message.gen.source.makefile=Generating makefile for source folder {0}
+MakefileGenerator.message.calc.delta=Calculating the delta for project {0}
+MakefileGenerator.message.finding.sources=Finding source files in project {0}
+MakefileGenerator.comment.module.list = Every subdirectory with source files must be described here
+MakefileGenerator.comment.module.variables = Add inputs and outputs from these tool invocations to the build variables
+MakefileGenerator.comment.source.list = All of the sources participating in the build are defined here
+MakefileGenerator.comment.build.rule = Each subdirectory must supply rules for building sources it contributes
+MakefileGenerator.comment.build.toprules = Tool invocations
+MakefileGenerator.comment.build.alltarget = All Target
+MakefileGenerator.comment.build.mainbuildtarget = Main-build Target
+MakefileGenerator.comment.build.toptargets = Other Targets
+MakefileGenerator.comment.module.make.includes = Include the makefiles for each source subdirectory
+MakefileGenerator.comment.module.dep.includes = Include automatically-generated dependency list:
+MakefileGenerator.comment.autodeps=Automatically-generated dependency list:
+MakefileGenerator.comment.header=Automatically-generated file. Do not edit!
+MakefileGenerator.error.spaces=Cannot generate makefile for folder with spaces in name
+MakefileGenerator.warning.no.source=Nothing to build for project {0}
+MakefileGenerator.error.no.nameprovider=A nameProvider or outputNames must be specified with multipleType == true
+
+ManagedBuildInfo.message.job.init = Initializing path container for {0}
+ManagedBuildInfo.message.init.ok = Initializing path container succeeded for {0}
+
+# Default GNU Makefile Generator messages
+GnuMakefileGenerator.message.postproc.dep.file=Verifying contents of dependency file {0}
+
+# Tool strings
+Tool.default.announcement=Invoking:
+#Environment loader messages
+StorableEnvironmentLoader.storeOutputStream.wrong.arguments=Wrong arguments
+
+#User Defined Macro Supplier
+UserDefinedMacroSupplier.storeOutputStream.wrong.arguments=Failed to persist macros: Wrong arguments
+
+# BuildMacroStatus messages
+BuildMacroStatus.status.macro.undefined=Macro {0} is undefined
+BuildMacroStatus.status.reference.eachother=Macros {0} and {1} reference each other
+BuildMacroStatus.status.reference.incorrect=Macro {0} reference is incorrect
+BuildMacroStatus.status.macro.not.string=Macro {0} is not of String type
+BuildMacroStatus.status.macro.not.stringlist=Macro {0} is not of String-list type
+BuildMacroStatus.status.error=Error occured
+BuildMacroStatus.value.undefined=
+
+#ResourceChangeHandler messages
+ResourceChangeHandler.buildInfoSerializationJob=Build Info Serialization
+
+#ManagedBuilderCorePlugin messages
ManagedBuilderCorePlugin.resourceChangeHandlingInitializationJob=Initializing Resource Change Handling
\ No newline at end of file
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
index 136104c5753..a9749482531 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ResourceChangeHandler.java
@@ -1,458 +1,458 @@
-/*******************************************************************************
- * Copyright (c) 2005 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.core;
-
-import java.util.HashMap;
-import java.util.HashSet;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IResourceRuleFactory;
-import org.eclipse.core.resources.ISaveContext;
-import org.eclipse.core.resources.ISaveParticipant;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.core.runtime.jobs.MultiRule;
-
-public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant {
-
- private class ResourceConfigurationChecker implements IResourceDeltaVisitor{
- private IResourceDelta fRootDelta;
- private HashMap fBuildFileGeneratorMap = new HashMap();
- private HashSet fValidatedFilesSet = new HashSet();
- private HashSet fModifiedProjects = new HashSet();
-
- public ResourceConfigurationChecker(IResourceDelta rootDelta){
- fRootDelta = rootDelta;
- }
-
- public IProject[] getModifiedProjects(){
- return (IProject[])fModifiedProjects.toArray(new IProject[fModifiedProjects.size()]);
- }
-
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource dResource = delta.getResource();
- int rcType = dResource.getType();
-
- if(rcType == IResource.PROJECT || rcType == IResource.FOLDER){
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IProject project = null;
- IResource rcToCheck = null;
- switch (delta.getKind()) {
- case IResourceDelta.REMOVED :
- if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) {
- sendClose((IProject)dResource);
- break;
- }
- case IResourceDelta.CHANGED :
- if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
- IPath path = delta.getMovedToPath();
- if(path != null){
- project = root.findMember(path.segment(0)).getProject();
- if(project != null && rcType == IResource.FOLDER)
- rcToCheck = root.getFolder(substituteProject(dResource.getFullPath(),project.getName()));
- }
- break;
- }
- default:
- project = dResource.getProject();
- if(rcType == IResource.FOLDER)
- rcToCheck = dResource;
- break;
- }
-
- if(project != null) {
- IManagedBuilderMakefileGenerator makeGen = getInitializedGenerator(project);
- if(makeGen != null){
- if(rcToCheck == null || !makeGen.isGeneratedResource(rcToCheck))
- return true;
- }
- }
- return false;
- } else if (rcType == IResource.FILE && !dResource.isDerived()) {
- int flags = delta.getFlags();
- switch (delta.getKind()) {
- case IResourceDelta.REMOVED :
- if ((flags & IResourceDelta.MOVED_TO) == 0) {
- handleDeleteFile(dResource.getFullPath());
- break;
- }
- case IResourceDelta.ADDED :
- case IResourceDelta.CHANGED :
- if ((flags & IResourceDelta.MOVED_TO) != 0) {
- IPath path = delta.getMovedToPath();
- if (path != null) {
- handleRenamedFile(
- dResource.getFullPath(),
- path);
- }
- } else if ((flags & IResourceDelta.MOVED_FROM) != 0) {
- IPath path = delta.getMovedFromPath();
- if (path != null) {
- handleRenamedFile(
- path,
- dResource.getFullPath());
- }
- }
- break;
-
- default:
- break;
- }
- return false;
- }
- return true; // visit the children
- }
-
- private IPath substituteProject(IPath path, String projectName){
- return new Path(projectName).makeAbsolute().append(path.removeFirstSegments(1));
- }
-
- private void handleRenamedFile(IPath fromPath, IPath toPath){
- if(!fValidatedFilesSet.add(fromPath))
- return;
-
- IProject fromProject = findModifiedProject(fromPath.segment(0));
- if(fromProject == null)
- return;
- IManagedBuilderMakefileGenerator fromMakeGen = getInitializedGenerator(fromProject);
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- if(fromMakeGen == null || fromMakeGen.isGeneratedResource(root.getFile(substituteProject(fromPath,fromProject.getName()))))
- return;
-
- IManagedBuildInfo fromInfo = fromProject != null ?
- ManagedBuildManager.getBuildInfo(fromProject) :
- null;
-
- IProject toProject = root.findMember(toPath.uptoSegment(1)).getProject();
- IManagedBuildInfo toInfo = toProject != null ?
- ManagedBuildManager.getBuildInfo(toProject) :
- null;
- IManagedBuilderMakefileGenerator toMakeGen = toProject != null ?
- getInitializedGenerator(toProject) :
- null;
- if(toMakeGen != null && toMakeGen.isGeneratedResource(root.getFile(toPath)))
- toInfo = null;
-
- if(fromInfo == toInfo){
- //the resource was moved whithing the project scope
- if(updateResourceConfigurations(fromInfo,fromPath,toPath) && toProject != null)
- fModifiedProjects.add(toProject);
- } else {
- if(fromInfo != null && toInfo != null){
- //TODO: this is the case when the resource
- //is moved from one managed project to another
- //should we handle this?
- //e.g. add resource configurations to the destination project?
- }
- if(fromInfo != null && removeResourceConfigurations(fromInfo,fromPath) && fromProject != null)
- fModifiedProjects.add(fromProject);
- }
- }
-
- private void handleDeleteFile(IPath path){
- IProject project = findModifiedProject(path.segment(0));
- if(project != null){
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
- if(info != null
- && removeResourceConfigurations(info,path))
- fModifiedProjects.add(project);
- }
- }
-
- //finds the project geven the initial project name
- //That is:
- // if the project of a given name was renamed returns the renamed project
- // if the project of a given name was removed returns null
- // if the project of a given name was neither renamed or removed
- // returns the project of that name or null if the project does not exist
- //
- private IProject findModifiedProject(final String oldProjectName){
- IResourceDelta projectDelta = fRootDelta.findMember(new Path(oldProjectName));
- boolean replaced = false;
- if(projectDelta != null) {
- switch(projectDelta.getKind()){
- case IResourceDelta.REMOVED :
- if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) == 0) {
- return null;
- }
- case IResourceDelta.CHANGED :
- if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
- IPath path = projectDelta.getMovedToPath();
- if(path != null)
- return ResourcesPlugin.getWorkspace().getRoot().findMember(path).getProject();
- }
- break;
- }
- }
-
- final IProject project[] = new IProject[1];
- try {
- fRootDelta.accept(new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource dResource = delta.getResource();
- int rcType = dResource.getType();
- if(rcType == IResource.ROOT) {
- return true;
- } else if(rcType == IResource.PROJECT){
- switch(delta.getKind()){
- case IResourceDelta.ADDED :
- case IResourceDelta.CHANGED :
- if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
- IPath path = delta.getMovedFromPath();
- if (path != null && path.segment(0).equals(oldProjectName)) {
- project[0] = dResource.getProject();
- }
- }
- break;
- default:
- break;
- }
- }
- return false;
- }
- });
- } catch (CoreException e) {
- }
-
- if(project[0] == null && !replaced)
- project[0] = ResourcesPlugin.getWorkspace().getRoot().findMember(oldProjectName).getProject();
- return project[0];
- }
-
- private IManagedBuilderMakefileGenerator getInitializedGenerator(IProject project){
- IManagedBuilderMakefileGenerator makeGen = (IManagedBuilderMakefileGenerator)fBuildFileGeneratorMap.get(project);
- if (makeGen == null) {
- try {
- if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
- // Determine if we can access the build info before actually trying
- // If not, don't try, to avoid putting up a dialog box warning the user
- if (!ManagedBuildManager.canGetBuildInfo(project)) return null;
-
- IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
- if (buildInfo != null){
- IConfiguration defaultCfg = buildInfo.getDefaultConfiguration();
- if (defaultCfg != null) {
- makeGen = ManagedBuildManager.getBuildfileGenerator(defaultCfg);
- makeGen.initialize(project,buildInfo,new NullProgressMonitor());
- fBuildFileGeneratorMap.put(project,makeGen);
- }
- }
- }
- } catch (CoreException e){
- return null;
- }
- }
- return makeGen;
- }
- }
-
- public void sendClose(IProject project){
- IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
- if(info != null){
- IManagedProject managedProj = info.getManagedProject();
- if (managedProj != null) {
- IConfiguration cfgs[] = managedProj.getConfigurations();
-
- for(int i = 0; i < cfgs.length; i++)
- ManagedBuildManager.performValueHandlerEvent(cfgs[i], IManagedOptionValueHandler.EVENT_CLOSE, true);
- }
- }
- }
-
- /*
- * I R e s o u r c e C h a n g e L i s t e n e r
- */
-
- /* (non-Javadoc)
- *
- * Handle the renaming and deletion of project resources
- * This is necessary in order to update ResourceConfigurations and AdditionalInputs
- *
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- if (event.getSource() instanceof IWorkspace) {
-
- switch (event.getType()) {
- case IResourceChangeEvent.PRE_CLOSE:
- IResource proj = event.getResource();
- if(proj instanceof IProject)
- sendClose((IProject)proj);
- break;
- case IResourceChangeEvent.POST_CHANGE :
- case IResourceChangeEvent.POST_BUILD :
- case IResourceChangeEvent.PRE_DELETE :
- IResourceDelta resDelta = event.getDelta();
- if (resDelta == null) {
- break;
- }
- try {
- ResourceConfigurationChecker rcChecker = new ResourceConfigurationChecker(resDelta);
- resDelta.accept(rcChecker);
-
- //saving info for the modified projects
- initInfoSerialization(rcChecker.getModifiedProjects());
-
- } catch (CoreException e) {
- CCorePlugin.log(e);
- }
- break;
- default :
- break;
- }
- }
- }
-
- private void initInfoSerialization(final IProject projects[]){
- if(projects.length == 0)
- return;
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- IResourceRuleFactory ruleFactory = workspace.getRuleFactory();
- ISchedulingRule buildInfoSaveRule;
- if(projects.length == 1){
- buildInfoSaveRule = ruleFactory.modifyRule(projects[0]);
- } else {
- ISchedulingRule rules[] = new ISchedulingRule[projects.length];
- for(int i = 0; i < rules.length; i++)
- rules[i] = ruleFactory.modifyRule(projects[i]);
- buildInfoSaveRule = MultiRule.combine(rules);
- }
-
- Job savingJob = new Job(ManagedMakeMessages.getResourceString("ResourceChangeHandler.buildInfoSerializationJob")){ //$NON-NLS-1$
- protected IStatus run(IProgressMonitor monitor) {
- for(int i = 0; i < projects.length; i++){
- ManagedBuildManager.saveBuildInfo(projects[i],true);
- }
- return new Status(
- IStatus.OK,
- ManagedBuilderCorePlugin.getUniqueIdentifier(),
- IStatus.OK,
- new String(),
- null);
- }
- };
- savingJob.setRule(buildInfoSaveRule);
-
- savingJob.schedule();
- }
-
- private boolean updateResourceConfigurations(IManagedBuildInfo info, IPath oldPath, IPath newPath){
- boolean changed = false;
- if(!oldPath.equals(newPath)){
- IManagedProject mngProj = info.getManagedProject();
- if(mngProj != null){
- IConfiguration configs[] = mngProj.getConfigurations();
- if(configs != null && configs.length > 0){
- for(int i = 0; i < configs.length; i++){
- if(updateResourceConfiguration(configs[i],oldPath,newPath))
- changed = true;
- }
- }
- }
- }
- return changed;
- }
-
- private boolean removeResourceConfigurations(IManagedBuildInfo info, IPath path){
- boolean changed = false;
- IManagedProject mngProj = info.getManagedProject();
- if(mngProj != null){
- IConfiguration configs[] = mngProj.getConfigurations();
- if(configs != null && configs.length > 0){
- for(int i = 0; i < configs.length; i++){
- if(removeResourceConfiguration(configs[i],path))
- changed = true;
- }
- }
- }
- return changed;
- }
-
- private boolean updateResourceConfiguration(IConfiguration config, IPath oldPath, IPath newPath){
- IResourceConfiguration rcCfg = config.getResourceConfiguration(oldPath.toString());
- if(rcCfg != null && !oldPath.equals(newPath)){
- config.removeResourceConfiguration(rcCfg);
- rcCfg.setResourcePath(newPath.toString());
- ((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg);
- config.setRebuildState(true);
- return true;
- }
- return false;
- }
-
- private boolean removeResourceConfiguration(IConfiguration config, IPath path){
- IResourceConfiguration rcCfg = config.getResourceConfiguration(path.toString());
- if(rcCfg != null){
- config.removeResourceConfiguration(rcCfg);
- config.setRebuildState(true);
- return true;
- }
- return false;
- }
-
- /*
- * I S a v e P a r t i c i p a n t
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
- */
- public void saving(ISaveContext context) throws CoreException {
- // No state to be saved by the plug-in, but request a
- // resource delta to be used on next activation.
- context.needDelta();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext)
- */
- public void doneSaving(ISaveContext context) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext)
- */
- public void prepareToSave(ISaveContext context) throws CoreException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext)
- */
- public void rollback(ISaveContext context) {
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2005 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.core;
+
+import java.util.HashMap;
+import java.util.HashSet;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IResourceRuleFactory;
+import org.eclipse.core.resources.ISaveContext;
+import org.eclipse.core.resources.ISaveParticipant;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.core.runtime.jobs.MultiRule;
+
+public class ResourceChangeHandler implements IResourceChangeListener, ISaveParticipant {
+
+ private class ResourceConfigurationChecker implements IResourceDeltaVisitor{
+ private IResourceDelta fRootDelta;
+ private HashMap fBuildFileGeneratorMap = new HashMap();
+ private HashSet fValidatedFilesSet = new HashSet();
+ private HashSet fModifiedProjects = new HashSet();
+
+ public ResourceConfigurationChecker(IResourceDelta rootDelta){
+ fRootDelta = rootDelta;
+ }
+
+ public IProject[] getModifiedProjects(){
+ return (IProject[])fModifiedProjects.toArray(new IProject[fModifiedProjects.size()]);
+ }
+
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ IResource dResource = delta.getResource();
+ int rcType = dResource.getType();
+
+ if(rcType == IResource.PROJECT || rcType == IResource.FOLDER){
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = null;
+ IResource rcToCheck = null;
+ switch (delta.getKind()) {
+ case IResourceDelta.REMOVED :
+ if ((delta.getFlags() & IResourceDelta.MOVED_TO) == 0 && rcType == IResource.PROJECT) {
+ sendClose((IProject)dResource);
+ break;
+ }
+ case IResourceDelta.CHANGED :
+ if ((delta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
+ IPath path = delta.getMovedToPath();
+ if(path != null){
+ project = root.findMember(path.segment(0)).getProject();
+ if(project != null && rcType == IResource.FOLDER)
+ rcToCheck = root.getFolder(substituteProject(dResource.getFullPath(),project.getName()));
+ }
+ break;
+ }
+ default:
+ project = dResource.getProject();
+ if(rcType == IResource.FOLDER)
+ rcToCheck = dResource;
+ break;
+ }
+
+ if(project != null) {
+ IManagedBuilderMakefileGenerator makeGen = getInitializedGenerator(project);
+ if(makeGen != null){
+ if(rcToCheck == null || !makeGen.isGeneratedResource(rcToCheck))
+ return true;
+ }
+ }
+ return false;
+ } else if (rcType == IResource.FILE && !dResource.isDerived()) {
+ int flags = delta.getFlags();
+ switch (delta.getKind()) {
+ case IResourceDelta.REMOVED :
+ if ((flags & IResourceDelta.MOVED_TO) == 0) {
+ handleDeleteFile(dResource.getFullPath());
+ break;
+ }
+ case IResourceDelta.ADDED :
+ case IResourceDelta.CHANGED :
+ if ((flags & IResourceDelta.MOVED_TO) != 0) {
+ IPath path = delta.getMovedToPath();
+ if (path != null) {
+ handleRenamedFile(
+ dResource.getFullPath(),
+ path);
+ }
+ } else if ((flags & IResourceDelta.MOVED_FROM) != 0) {
+ IPath path = delta.getMovedFromPath();
+ if (path != null) {
+ handleRenamedFile(
+ path,
+ dResource.getFullPath());
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+ return false;
+ }
+ return true; // visit the children
+ }
+
+ private IPath substituteProject(IPath path, String projectName){
+ return new Path(projectName).makeAbsolute().append(path.removeFirstSegments(1));
+ }
+
+ private void handleRenamedFile(IPath fromPath, IPath toPath){
+ if(!fValidatedFilesSet.add(fromPath))
+ return;
+
+ IProject fromProject = findModifiedProject(fromPath.segment(0));
+ if(fromProject == null)
+ return;
+ IManagedBuilderMakefileGenerator fromMakeGen = getInitializedGenerator(fromProject);
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ if(fromMakeGen == null || fromMakeGen.isGeneratedResource(root.getFile(substituteProject(fromPath,fromProject.getName()))))
+ return;
+
+ IManagedBuildInfo fromInfo = fromProject != null ?
+ ManagedBuildManager.getBuildInfo(fromProject) :
+ null;
+
+ IProject toProject = root.findMember(toPath.uptoSegment(1)).getProject();
+ IManagedBuildInfo toInfo = toProject != null ?
+ ManagedBuildManager.getBuildInfo(toProject) :
+ null;
+ IManagedBuilderMakefileGenerator toMakeGen = toProject != null ?
+ getInitializedGenerator(toProject) :
+ null;
+ if(toMakeGen != null && toMakeGen.isGeneratedResource(root.getFile(toPath)))
+ toInfo = null;
+
+ if(fromInfo == toInfo){
+ //the resource was moved whithing the project scope
+ if(updateResourceConfigurations(fromInfo,fromPath,toPath) && toProject != null)
+ fModifiedProjects.add(toProject);
+ } else {
+ if(fromInfo != null && toInfo != null){
+ //TODO: this is the case when the resource
+ //is moved from one managed project to another
+ //should we handle this?
+ //e.g. add resource configurations to the destination project?
+ }
+ if(fromInfo != null && removeResourceConfigurations(fromInfo,fromPath) && fromProject != null)
+ fModifiedProjects.add(fromProject);
+ }
+ }
+
+ private void handleDeleteFile(IPath path){
+ IProject project = findModifiedProject(path.segment(0));
+ if(project != null){
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
+ if(info != null
+ && removeResourceConfigurations(info,path))
+ fModifiedProjects.add(project);
+ }
+ }
+
+ //finds the project geven the initial project name
+ //That is:
+ // if the project of a given name was renamed returns the renamed project
+ // if the project of a given name was removed returns null
+ // if the project of a given name was neither renamed or removed
+ // returns the project of that name or null if the project does not exist
+ //
+ private IProject findModifiedProject(final String oldProjectName){
+ IResourceDelta projectDelta = fRootDelta.findMember(new Path(oldProjectName));
+ boolean replaced = false;
+ if(projectDelta != null) {
+ switch(projectDelta.getKind()){
+ case IResourceDelta.REMOVED :
+ if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) == 0) {
+ return null;
+ }
+ case IResourceDelta.CHANGED :
+ if ((projectDelta.getFlags() & IResourceDelta.MOVED_TO) != 0) {
+ IPath path = projectDelta.getMovedToPath();
+ if(path != null)
+ return ResourcesPlugin.getWorkspace().getRoot().findMember(path).getProject();
+ }
+ break;
+ }
+ }
+
+ final IProject project[] = new IProject[1];
+ try {
+ fRootDelta.accept(new IResourceDeltaVisitor() {
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ IResource dResource = delta.getResource();
+ int rcType = dResource.getType();
+ if(rcType == IResource.ROOT) {
+ return true;
+ } else if(rcType == IResource.PROJECT){
+ switch(delta.getKind()){
+ case IResourceDelta.ADDED :
+ case IResourceDelta.CHANGED :
+ if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
+ IPath path = delta.getMovedFromPath();
+ if (path != null && path.segment(0).equals(oldProjectName)) {
+ project[0] = dResource.getProject();
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ return false;
+ }
+ });
+ } catch (CoreException e) {
+ }
+
+ if(project[0] == null && !replaced)
+ project[0] = ResourcesPlugin.getWorkspace().getRoot().findMember(oldProjectName).getProject();
+ return project[0];
+ }
+
+ private IManagedBuilderMakefileGenerator getInitializedGenerator(IProject project){
+ IManagedBuilderMakefileGenerator makeGen = (IManagedBuilderMakefileGenerator)fBuildFileGeneratorMap.get(project);
+ if (makeGen == null) {
+ try {
+ if (project.hasNature(ManagedCProjectNature.MNG_NATURE_ID)) {
+ // Determine if we can access the build info before actually trying
+ // If not, don't try, to avoid putting up a dialog box warning the user
+ if (!ManagedBuildManager.canGetBuildInfo(project)) return null;
+
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
+ if (buildInfo != null){
+ IConfiguration defaultCfg = buildInfo.getDefaultConfiguration();
+ if (defaultCfg != null) {
+ makeGen = ManagedBuildManager.getBuildfileGenerator(defaultCfg);
+ makeGen.initialize(project,buildInfo,new NullProgressMonitor());
+ fBuildFileGeneratorMap.put(project,makeGen);
+ }
+ }
+ }
+ } catch (CoreException e){
+ return null;
+ }
+ }
+ return makeGen;
+ }
+ }
+
+ public void sendClose(IProject project){
+ IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project,false);
+ if(info != null){
+ IManagedProject managedProj = info.getManagedProject();
+ if (managedProj != null) {
+ IConfiguration cfgs[] = managedProj.getConfigurations();
+
+ for(int i = 0; i < cfgs.length; i++)
+ ManagedBuildManager.performValueHandlerEvent(cfgs[i], IManagedOptionValueHandler.EVENT_CLOSE, true);
+ }
+ }
+ }
+
+ /*
+ * I R e s o u r c e C h a n g e L i s t e n e r
+ */
+
+ /* (non-Javadoc)
+ *
+ * Handle the renaming and deletion of project resources
+ * This is necessary in order to update ResourceConfigurations and AdditionalInputs
+ *
+ * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+ */
+ public void resourceChanged(IResourceChangeEvent event) {
+ if (event.getSource() instanceof IWorkspace) {
+
+ switch (event.getType()) {
+ case IResourceChangeEvent.PRE_CLOSE:
+ IResource proj = event.getResource();
+ if(proj instanceof IProject)
+ sendClose((IProject)proj);
+ break;
+ case IResourceChangeEvent.POST_CHANGE :
+ case IResourceChangeEvent.POST_BUILD :
+ case IResourceChangeEvent.PRE_DELETE :
+ IResourceDelta resDelta = event.getDelta();
+ if (resDelta == null) {
+ break;
+ }
+ try {
+ ResourceConfigurationChecker rcChecker = new ResourceConfigurationChecker(resDelta);
+ resDelta.accept(rcChecker);
+
+ //saving info for the modified projects
+ initInfoSerialization(rcChecker.getModifiedProjects());
+
+ } catch (CoreException e) {
+ CCorePlugin.log(e);
+ }
+ break;
+ default :
+ break;
+ }
+ }
+ }
+
+ private void initInfoSerialization(final IProject projects[]){
+ if(projects.length == 0)
+ return;
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IResourceRuleFactory ruleFactory = workspace.getRuleFactory();
+ ISchedulingRule buildInfoSaveRule;
+ if(projects.length == 1){
+ buildInfoSaveRule = ruleFactory.modifyRule(projects[0]);
+ } else {
+ ISchedulingRule rules[] = new ISchedulingRule[projects.length];
+ for(int i = 0; i < rules.length; i++)
+ rules[i] = ruleFactory.modifyRule(projects[i]);
+ buildInfoSaveRule = MultiRule.combine(rules);
+ }
+
+ Job savingJob = new Job(ManagedMakeMessages.getResourceString("ResourceChangeHandler.buildInfoSerializationJob")){ //$NON-NLS-1$
+ protected IStatus run(IProgressMonitor monitor) {
+ for(int i = 0; i < projects.length; i++){
+ ManagedBuildManager.saveBuildInfo(projects[i],true);
+ }
+ return new Status(
+ IStatus.OK,
+ ManagedBuilderCorePlugin.getUniqueIdentifier(),
+ IStatus.OK,
+ new String(),
+ null);
+ }
+ };
+ savingJob.setRule(buildInfoSaveRule);
+
+ savingJob.schedule();
+ }
+
+ private boolean updateResourceConfigurations(IManagedBuildInfo info, IPath oldPath, IPath newPath){
+ boolean changed = false;
+ if(!oldPath.equals(newPath)){
+ IManagedProject mngProj = info.getManagedProject();
+ if(mngProj != null){
+ IConfiguration configs[] = mngProj.getConfigurations();
+ if(configs != null && configs.length > 0){
+ for(int i = 0; i < configs.length; i++){
+ if(updateResourceConfiguration(configs[i],oldPath,newPath))
+ changed = true;
+ }
+ }
+ }
+ }
+ return changed;
+ }
+
+ private boolean removeResourceConfigurations(IManagedBuildInfo info, IPath path){
+ boolean changed = false;
+ IManagedProject mngProj = info.getManagedProject();
+ if(mngProj != null){
+ IConfiguration configs[] = mngProj.getConfigurations();
+ if(configs != null && configs.length > 0){
+ for(int i = 0; i < configs.length; i++){
+ if(removeResourceConfiguration(configs[i],path))
+ changed = true;
+ }
+ }
+ }
+ return changed;
+ }
+
+ private boolean updateResourceConfiguration(IConfiguration config, IPath oldPath, IPath newPath){
+ IResourceConfiguration rcCfg = config.getResourceConfiguration(oldPath.toString());
+ if(rcCfg != null && !oldPath.equals(newPath)){
+ config.removeResourceConfiguration(rcCfg);
+ rcCfg.setResourcePath(newPath.toString());
+ ((Configuration)config).addResourceConfiguration((ResourceConfiguration)rcCfg);
+ config.setRebuildState(true);
+ return true;
+ }
+ return false;
+ }
+
+ private boolean removeResourceConfiguration(IConfiguration config, IPath path){
+ IResourceConfiguration rcCfg = config.getResourceConfiguration(path.toString());
+ if(rcCfg != null){
+ config.removeResourceConfiguration(rcCfg);
+ config.setRebuildState(true);
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * I S a v e P a r t i c i p a n t
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.ISaveParticipant#saving(org.eclipse.core.resources.ISaveContext)
+ */
+ public void saving(ISaveContext context) throws CoreException {
+ // No state to be saved by the plug-in, but request a
+ // resource delta to be used on next activation.
+ context.needDelta();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.ISaveParticipant#doneSaving(org.eclipse.core.resources.ISaveContext)
+ */
+ public void doneSaving(ISaveContext context) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.ISaveParticipant#prepareToSave(org.eclipse.core.resources.ISaveContext)
+ */
+ public void prepareToSave(ISaveContext context) throws CoreException {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.ISaveParticipant#rollback(org.eclipse.core.resources.ISaveContext)
+ */
+ public void rollback(ISaveContext context) {
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
index d2b9737e946..3df55d55276 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Target.java
@@ -1,1180 +1,1180 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2005 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.core;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.managedbuilder.core.IBuilder;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.ITarget;
-import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.IToolReference;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class Target extends BuildObject implements ITarget {
- private static final String EMPTY_STRING = new String();
- private static final IConfigurationV2[] emptyConfigs = new IConfigurationV2[0];
- private String artifactName;
- private String binaryParserId;
- private String cleanCommand;
- private List configList;
- private Map configMap;
- private String defaultExtension;
- private Map depCalculatorsMap;
- private String errorParserIds;
- private String extension;
- private boolean isAbstract = false;
- private boolean isDirty = false;
- private boolean isTest = false;
- private String makeArguments;
- private String makeCommand;
- private IResource owner;
- private ITarget parent;
- private boolean resolved = true;
- private List targetArchList;
- private List targetOSList;
- private List toolList;
- private Map toolMap;
- private List toolReferences;
- private ProjectType createdProjectType;
- private String scannerInfoCollectorId;
-
- /**
- * This constructor is called to create a target defined by an extension point in
- * a plugin manifest file.
- *
- * @param element
- * @param managedBuildRevision the fileVersion of Managed Build System
- */
- public Target(IManagedConfigElement element, String managedBuildRevision) {
- // setup for resolving
- ManagedBuildManager.putConfigElement(this, element);
- resolved = false;
-
- // id
- setId(element.getAttribute(ID));
-
- // managedBuildRevision
- setManagedBuildRevision(managedBuildRevision);
-
- // hook me up
- ManagedBuildManager.addExtensionTarget(this);
-
- // Get the target name
- setName(element.getAttribute(NAME));
-
- // Get the name of the build artifact associated with target (usually
- // in the plugin specification).
- artifactName = element.getAttribute(ARTIFACT_NAME);
-
- // Get the ID of the binary parser
- binaryParserId = element.getAttribute(BINARY_PARSER);
-
- // Get the semicolon separated list of IDs of the error parsers
- errorParserIds = element.getAttribute(ERROR_PARSERS);
-
- // Get the default extension
- defaultExtension = element.getAttribute(DEFAULT_EXTENSION);
-
- // isAbstract
- isAbstract = ("true".equals(element.getAttribute(IS_ABSTRACT))); //$NON-NLS-1$
-
- // Is this a test target
- isTest = ("true".equals(element.getAttribute(IS_TEST))); //$NON-NLS-1$
-
- // Get the clean command
- cleanCommand = element.getAttribute(CLEAN_COMMAND);
-
- // Get the make command
- makeCommand = element.getAttribute(MAKE_COMMAND);
-
- // Get the make arguments
- makeArguments = element.getAttribute(MAKE_ARGS);
-
- // Get scannerInfoCollectorId
- scannerInfoCollectorId = element.getAttribute(SCANNER_INFO_COLLECTOR_ID);
-
- // Get the comma-separated list of valid OS
- String os = element.getAttribute(OS_LIST);
- if (os != null) {
- targetOSList = new ArrayList();
- String[] osTokens = os.split(","); //$NON-NLS-1$
- for (int i = 0; i < osTokens.length; ++i) {
- targetOSList.add(osTokens[i].trim());
- }
- }
-
- // Get the comma-separated list of valid Architectures
- String arch = element.getAttribute(ARCH_LIST);
- if (arch != null) {
- targetArchList = new ArrayList();
- String[] archTokens = arch.split(","); //$NON-NLS-1$
- for (int j = 0; j < archTokens.length; ++j) {
- targetArchList.add(archTokens[j].trim());
- }
- }
-
- // Load any tool references we might have
- IManagedConfigElement[] toolRefs = element.getChildren(IConfigurationV2.TOOLREF_ELEMENT_NAME);
- for (int k = 0; k < toolRefs.length; ++k) {
- new ToolReference(this, toolRefs[k]);
- }
- // Then load any tools defined for the target
- IManagedConfigElement[] tools = element.getChildren(ITool.TOOL_ELEMENT_NAME);
- for (int m = 0; m < tools.length; ++m) {
- ITool newTool = new Tool(this, tools[m], managedBuildRevision);
- // Add this tool to the target, as this is not done in the constructor
- this.addTool(newTool);
- }
- // Then load the configurations which may have tool references
- IManagedConfigElement[] configs = element.getChildren(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
- for (int n = 0; n < configs.length; ++n) {
- new ConfigurationV2(this, configs[n]);
- }
- }
-
- /* (non-Javadoc)
- * Set the resource that owns the target.
- *
- * @param owner
- */
- protected Target(IResource owner) {
- this.owner = owner;
- }
-
- /**
- * Create a copy of the target specified in the argument,
- * that is owned by the owned by the specified resource.
- *
- * @param owner
- * @param parent
- */
- public Target(IResource owner, ITarget parent) {
- // Make the owner of the target the project resource
- this(owner);
-
- // Copy the parent's identity
- this.parent = parent;
- int id = ManagedBuildManager.getRandomNumber();
- setId(owner.getName() + "." + parent.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
- setName(parent.getName());
-
- setManagedBuildRevision(parent.getManagedBuildRevision());
-
- setArtifactName(parent.getArtifactName());
- this.binaryParserId = parent.getBinaryParserId();
- this.errorParserIds = parent.getErrorParserIds();
- this.defaultExtension = parent.getArtifactExtension();
- this.isTest = parent.isTestTarget();
- this.cleanCommand = parent.getCleanCommand();
- this.scannerInfoCollectorId = ((Target)parent).scannerInfoCollectorId;
-
- // Hook me up
- IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
- buildInfo.addTarget(this);
- }
-
- /**
- * Create target from project file.
- *
- * @param buildInfo
- * @param element
- */
- public Target(ManagedBuildInfo buildInfo, Element element) {
- this(buildInfo.getOwner());
-
- // id
- setId(element.getAttribute(ID));
-
- // hook me up
- buildInfo.addTarget(this);
-
- // name
- setName(element.getAttribute(NAME));
-
- // Get the name of the build artifact associated with target (should
- // contain what the user entered in the UI).
- artifactName = element.getAttribute(ARTIFACT_NAME);
-
- // Get the overridden extension
- if (element.hasAttribute(EXTENSION)) {
- extension = element.getAttribute(EXTENSION);
- }
-
- // parent
- String parentId = element.getAttribute(PARENT);
- if (parentId != null)
- parent = ManagedBuildManager.getTarget(null, parentId);
-
- // isAbstract
- if ("true".equals(element.getAttribute(IS_ABSTRACT))) //$NON-NLS-1$
- isAbstract = true;
-
- // Is this a test target
- isTest = ("true".equals(element.getAttribute(IS_TEST))); //$NON-NLS-1$
-
- // Get the clean command
- if (element.hasAttribute(CLEAN_COMMAND)) {
- cleanCommand = element.getAttribute(CLEAN_COMMAND);
- }
-
- // Get the semicolon separated list of IDs of the error parsers
- if (element.hasAttribute(ERROR_PARSERS)) {
- errorParserIds = element.getAttribute(ERROR_PARSERS);
- }
-
- // Get the make command and arguments
- if (element.hasAttribute(MAKE_COMMAND)) {
- makeCommand = element.getAttribute(MAKE_COMMAND);
- }
- if(element.hasAttribute(MAKE_ARGS)) {
- makeArguments = element.getAttribute(MAKE_ARGS);
- }
-
- Node child = element.getFirstChild();
- while (child != null) {
- if (child.getNodeName().equals(IConfigurationV2.CONFIGURATION_ELEMENT_NAME)) {
- new ConfigurationV2(this, (Element)child);
- }
- child = child.getNextSibling();
- }
- }
-
- /**
- * @param configuration
- */
- public void addConfiguration(IConfigurationV2 configuration) {
- getConfigurationList().add(configuration);
- getConfigurationMap().put(configuration.getId(), configuration);
- }
-
- /**
- * Adds a tool specification to the receiver. This tool is defined
- * only for the receiver, and cannot be shared by other targets.
- *
- * @param tool
- */
- public void addTool(ITool tool) {
- getToolList().add(tool);
- getToolMap().put(tool.getId(), tool);
- }
-
- /**
- * Adds a tool reference to the receiver.
- *
- * @param toolRef
- */
- public void addToolReference(ToolReference toolRef) {
- getLocalToolReferences().add(toolRef);
- }
-
-
- /* (non-Javadoc)
- * Tail-recursion method that creates a lits of tools and tool reference
- * walking the receiver's parent hierarchy.
- *
- * @param toolArray
- */
- private void addToolsToArray(Vector toolArray) {
- if (parent != null) {
- ((Target)parent).addToolsToArray(toolArray);
- }
-
- // Add the tools from out own list
- toolArray.addAll(getToolList());
-
- // Add local tool references
- toolArray.addAll(getLocalToolReferences());
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration(org.eclipse.cdt.core.build.managed.IConfigurationV2)
- */
- public IConfigurationV2 createConfiguration(IConfigurationV2 parent, String id) {
- isDirty = true;
- return new ConfigurationV2(this, parent, id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration()
- */
- public IConfigurationV2 createConfiguration(String id) {
- return new ConfigurationV2(this, id);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getArtifactExtension()
- */
- public String getArtifactExtension() {
- // Has the user changed the extension for this target
- if (extension != null) {
- return extension;
- }
- // If not, then go through the default extension lookup
- if (defaultExtension == null) {
- // Ask my parent first
- if (parent != null) {
- return parent.getArtifactExtension();
- } else {
- return EMPTY_STRING;
- }
- } else {
- return defaultExtension;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getArtifactName()
- */
- public String getArtifactName() {
- if (artifactName == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getArtifactName();
- } else {
- // I'm it and this is not good!
- return EMPTY_STRING;
- }
- } else {
- return artifactName;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getBinaryParserId()
- */
- public String getBinaryParserId() {
- if (binaryParserId == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getBinaryParserId();
- } else {
- // I'm it and this is not good!
- return EMPTY_STRING;
- }
- }
- return binaryParserId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getCleanCommand()
- */
- public String getCleanCommand() {
- // Return the command used to remove files
- if (cleanCommand == null) {
- if (parent != null) {
- return parent.getCleanCommand();
- } else {
- // User forgot to specify it. Guess based on OS.
- if (Platform.getOS().equals(Platform.OS_WIN32)) {
- return new String("del"); //$NON-NLS-1$
- } else {
- return new String("rm"); //$NON-NLS-1$
- }
- }
- } else {
- // This was spec'd in the manifest
- return cleanCommand;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getConfiguration()
- */
- public IConfigurationV2 getConfiguration(String id) {
- return (IConfigurationV2)getConfigurationMap().get(id);
- }
-
- /* (non-Javadoc)
- * Safe accessor for the list of configurations.
- *
- * @return List containing the configurations
- */
- private List getConfigurationList() {
- if (configList == null) {
- configList = new ArrayList();
- }
- return configList;
- }
-
- /* (non-Javadoc)
- * Safe accessor for the map of configuration ids to configurations
- *
- * @return
- */
- private Map getConfigurationMap() {
- if (configMap == null) {
- configMap = new HashMap();
- }
- return configMap;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getConfigurations()
- */
- public IConfigurationV2[] getConfigurations() {
- return (IConfigurationV2[])getConfigurationList().toArray(new IConfigurationV2[getConfigurationList().size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getDefaultExtension()
- */
- public String getDefaultExtension() {
- return defaultExtension == null ? EMPTY_STRING : defaultExtension;
- }
-
- private Map getDepCalcMap() {
- if (depCalculatorsMap == null) {
- depCalculatorsMap = new HashMap();
- }
- return depCalculatorsMap;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserIds()
- */
- public String getErrorParserIds() {
- if (errorParserIds == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getErrorParserIds();
- }
- }
- return errorParserIds;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserList()
- */
- public String[] getErrorParserList() {
- String parserIDs = getErrorParserIds();
- String[] errorParsers = null;
- if (parserIDs != null) {
- // Check for an empty string
- if (parserIDs.length() == 0) {
- errorParsers = new String[0];
- } else {
- StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
- List list = new ArrayList(tok.countTokens());
- while (tok.hasMoreElements()) {
- list.add(tok.nextToken());
- }
- String[] strArr = {""}; //$NON-NLS-1$
- errorParsers = (String[]) list.toArray(strArr);
- }
- } else {
- // If no error parsers are specified by the target, the default is
- // all error parsers
- errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
- }
- return errorParsers;
- }
-
- /* (non-javadoc)
- * A safe accesor method. It answers the tool reference list in the
- * receiver.
- *
- * @return List
- */
- protected List getLocalToolReferences() {
- if (toolReferences == null) {
- toolReferences = new ArrayList();
- }
- return toolReferences;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getMakeArguments()
- */
- public String getMakeArguments() {
- if (makeArguments == null) {
- // See if it is defined in my parent
- if (parent != null) {
- return parent.getMakeArguments();
- } else {
- // No parent and no user setting
- return new String(""); //$NON-NLS-1$
- }
- }
- return makeArguments;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#getMakeCommand()
- */
- public String getMakeCommand() {
- // Return the name of the make utility
- if (makeCommand == null) {
- // If I have a parent, ask it
- if (parent != null) {
- return parent.getMakeCommand();
- } else {
- // The user has forgotten to specify a command in the plugin manifest
- return new String("make"); //$NON-NLS-1$
- }
- } else {
- return makeCommand;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName()
- */
- public String getName() {
- // If I am unnamed, see if I can inherit one from my parent
- if (name == null) {
- if (parent != null) {
- return parent.getName();
- } else {
- return new String(""); //$NON-NLS-1$
- }
- } else {
- return name;
- }
- }
-
- /* (non-javadoc)
- *
- * @param tool
- * @return List
- */
- protected List getOptionReferences(ITool tool) {
- List references = new ArrayList();
-
- // Get all the option references I add for this tool
- ToolReference toolRef = getToolReference(tool);
- if (toolRef != null) {
- references.addAll(toolRef.getOptionReferenceList());
- }
-
- // See if there is anything that my parents add that I don't
- if (parent != null) {
- List temp = ((Target)parent).getOptionReferences(tool);
- Iterator iter = temp.listIterator();
- while (iter.hasNext()) {
- OptionReference ref = (OptionReference) iter.next();
- if (!references.contains(ref)) {
- references.add(ref);
- }
- }
- }
-
- return references;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getOwner()
- */
- public IResource getOwner() {
- return owner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getParent()
- */
- public ITarget getParent() {
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetArchList()
- */
- public String[] getTargetArchList() {
- if (targetArchList == null) {
- // Ask parent for its list
- if (parent != null) {
- return parent.getTargetArchList();
- } else {
- // I have no parent and no defined list
- return new String[] {"all"}; //$NON-NLS-1$
- }
- }
- return (String[]) targetArchList.toArray(new String[targetArchList.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetOSList()
- */
- public String[] getTargetOSList() {
- if (targetOSList == null) {
- // Ask parent for its list
- if (parent != null) {
- return parent.getTargetOSList();
- } else {
- // I have no parent and no defined filter list
- return new String[] {"all"}; //$NON-NLS-1$
- }
- }
- return (String[]) targetOSList.toArray(new String[targetOSList.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTool(java.lang.String)
- */
- public ITool getTool(String id) {
- ITool result = null;
-
- // See if receiver has it in list
- result = (ITool) getToolMap().get(id);
-
- // If not, check if parent has it
- if (result == null && parent != null) {
- result = ((Target)parent).getTool(id);
- }
-
- // If not defined in parents, check if defined at all
- if (result == null) {
- result = ManagedBuildManager.getExtensionTool(id);
- }
-
- return result;
- }
-
- /* (non-Javadoc)
- * A safe accessor method for the list of tools maintained by the
- * target
- *
- */
- private List getToolList() {
- if (toolList == null) {
- toolList = new ArrayList();
- }
- return toolList;
- }
-
- /* (non-Javadoc)
- * A safe accessor for the tool map
- *
- */
- private Map getToolMap() {
- if (toolMap == null) {
- toolMap = new HashMap();
- }
- return toolMap;
- }
-
- /* (non-Javadoc)
- * Returns the reference for a given tool or null
if one is not
- * found.
- *
- * @param tool
- * @return ToolReference
- */
- private ToolReference getToolReference(ITool tool) {
- // See if the receiver has a reference to the tool
- ToolReference ref = null;
- if (tool == null) return ref;
- Iterator iter = getLocalToolReferences().listIterator();
- while (iter.hasNext()) {
- ToolReference temp = (ToolReference)iter.next();
- if (temp.references(tool)) {
- ref = temp;
- break;
- }
- }
- return ref;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTools()
- */
- public ITool[] getTools() {
- Vector toolArray = new Vector();
- addToolsToArray(toolArray);
- return (ITool[]) toolArray.toArray(new ITool[toolArray.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#hasMakeCommandOverride()
- */
- public boolean hasOverridenMakeCommand() {
- // We answer true if the make command or the flags are different
- return ((makeCommand != null && !makeCommand.equals(parent.getMakeCommand()))
- || (makeArguments != null && !makeArguments.equals(parent.getMakeArguments())));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#isAbstract()
- */
- public boolean isAbstract() {
- return isAbstract;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#isDirty()
- */
- public boolean isDirty() {
- // If I need saving, just say yes
- if (isDirty) {
- return true;
- }
-
- // Iterate over the configurations and ask them if they need saving
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- if (((IConfigurationV2)iter.next()).isDirty()) {
- return true;
- }
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#isTestTarget()
- */
- public boolean isTestTarget() {
- return isTest;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#needsRebuild()
- */
- public boolean needsRebuild(){
- // Iterate over the configurations and ask them if they need saving
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- if (((IConfigurationV2)iter.next()).needsRebuild()) {
- return true;
- }
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#removeConfiguration(java.lang.String)
- */
- public void removeConfiguration(String id) {
- // Remove the specified configuration from the list and map
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- IConfigurationV2 config = (IConfigurationV2)iter.next();
- if (config.getId().equals(id)) {
- getConfigurationList().remove(config);
- getConfigurationMap().remove(id);
- isDirty = true;
- break;
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#resetMakeCommand()
- */
- public void resetMakeCommand() {
- // Flag target as dirty if the reset actually changes something
- if (makeCommand != null) {
- setDirty(true);
- }
- makeCommand = null;
- makeArguments = null;
- }
-
- /**
- *
- */
- public void resolveReferences() {
- if (!resolved) {
- resolved = true;
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- // parent
- String parentId = element.getAttribute(PARENT);
- if (parentId != null) {
- parent = ManagedBuildManager.getTarget(null, parentId);
- // should resolve before calling methods on it
- ((Target)parent).resolveReferences();
- // copy over the parents configs
- IConfigurationV2[] parentConfigs = parent.getConfigurations();
- for (int i = 0; i < parentConfigs.length; ++i)
- addConfiguration(parentConfigs[i]);
- }
-
- // call resolve references on any children
- Iterator toolIter = getToolList().iterator();
- while (toolIter.hasNext()) {
- Tool current = (Tool)toolIter.next();
- current.resolveReferences();
- }
- Iterator refIter = getLocalToolReferences().iterator();
- while (refIter.hasNext()) {
- ToolReference current = (ToolReference)refIter.next();
- current.resolveReferences();
- }
- Iterator configIter = getConfigurationList().iterator();
- while (configIter.hasNext()) {
- ConfigurationV2 current = (ConfigurationV2)configIter.next();
- current.resolveReferences();
- }
- }
- }
-
- /**
- * Persist receiver to project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- element.setAttribute(ID, getId());
- element.setAttribute(NAME, getName());
- if (parent != null)
- element.setAttribute(PARENT, parent.getId());
- element.setAttribute(IS_ABSTRACT, isAbstract ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
- element.setAttribute(ARTIFACT_NAME, getArtifactName());
- if (extension != null) {
- element.setAttribute(EXTENSION, extension);
- }
- element.setAttribute(IS_TEST, isTest ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (makeCommand != null) {
- element.setAttribute(MAKE_COMMAND, makeCommand);
- } else {
- // Make sure we use the default
- }
-
- if (makeArguments != null) {
- element.setAttribute(MAKE_ARGS, makeArguments);
- }
- if (errorParserIds != null) {
- element.setAttribute(ERROR_PARSERS, errorParserIds);
- }
-
- // Serialize the configuration settings
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- ConfigurationV2 config = (ConfigurationV2) iter.next();
- Element configElement = doc.createElement(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
- element.appendChild(configElement);
- config.serialize(doc, configElement);
- }
-
- // I am clean now
- isDirty = false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setArtifactExtension(java.lang.String)
- */
- public void setArtifactExtension(String extension) {
- if (extension != null) {
- this.extension = extension;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITarget#setArtifactName(java.lang.String)
- */
- public void setArtifactName(String name) {
- if (name != null) {
- artifactName = name;
- setRebuildState(true);
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- // Override the dirty flag here
- this.isDirty = isDirty;
- // and in the configurations
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- IConfigurationV2 config = (IConfigurationV2)iter.next();
- config.setDirty(isDirty);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setErrorParserIds()
- */
- public void setErrorParserIds(String ids) {
- if (ids == null) return;
- String currentIds = getErrorParserIds();
- if (currentIds == null || !(currentIds.equals(ids))) {
- errorParserIds = ids;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeArguments(java.lang.String)
- */
- public void setMakeArguments(String makeArgs) {
- if (makeArgs != null && !getMakeArguments().equals(makeArgs)) {
- makeArguments = makeArgs;
- setRebuildState(true);
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeCommand(java.lang.String)
- */
- public void setMakeCommand(String command) {
- if (command != null && !getMakeCommand().equals(command)) {
- makeCommand = command;
- setRebuildState(true);
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#setRebuildState(boolean)
- */
- public void setRebuildState(boolean rebuild) {
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- ((IConfigurationV2)iter.next()).setRebuildState(rebuild);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#updateOwner(org.eclipse.core.resources.IResource)
- */
- public void updateOwner(IResource resource) {
- if (!resource.equals(owner)) {
- // Set the owner correctly
- owner = resource;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#convertToProjectType()
- */
- public void convertToProjectType(String managedBuildRevision) {
- // Create a ProjectType + Configuration + Toolchain + Builder + TargetPlatform
- // from the Target
-
- // The "parent" needs to have been converted already.
- // Do it now if necessary.
- ProjectType parentProj = null;
- if (parent != null) {
- parentProj = parent.getCreatedProjectType();
- if (parentProj == null) {
- parent.convertToProjectType(managedBuildRevision);
- parentProj = parent.getCreatedProjectType();
- }
- }
- ProjectType projectType = new ProjectType(parentProj, getId(), getName(), managedBuildRevision);
- createdProjectType = projectType;
- // Set the project type attributes
- projectType.setIsAbstract(isAbstract);
- projectType.setIsTest(isTest);
- // Add children
- // Add configurations (Configuration -> ToolChain -> Builder -> TargetPlatform)
- Iterator iter = getConfigurationList().listIterator();
- while (iter.hasNext()) {
- IConfigurationV2 configV2 = (IConfigurationV2)iter.next();
- if (configV2.getCreatedConfig() != null) continue;
- // The new config's superClass needs to be the
- // Configuration created from the ConfigurationV2 parent...
- IConfiguration configSuperClass = null;
- IConfigurationV2 parentV2 = configV2.getParent();
- if (parentV2 != null) {
- configSuperClass = parentV2.getCreatedConfig();
- }
- String id = configV2.getId();
- String name = configV2.getName();
- IConfiguration config = projectType.createConfiguration(configSuperClass, id, name);
- configV2.setCreatedConfig(config);
- // Set the configuration attributes
- config.setArtifactName(getArtifactName());
- config.setArtifactExtension(getArtifactExtension());
- config.setCleanCommand(getCleanCommand());
- config.setErrorParserIds(getErrorParserIds());
- // Create the Tool-chain
- String subId;
- String subName;
- subId = id + ".toolchain"; //$NON-NLS-1$
- subName = name + ".toolchain"; //$NON-NLS-1$
- IToolChain toolChain = config.createToolChain(null, subId, subName, true);
- // Set the tool chain attributes
- toolChain.setIsAbstract(isAbstract);
- toolChain.setOSList(getTargetOSList());
- toolChain.setArchList(getTargetArchList());
- // In target element had a scannerInfoCollector element here which
- // is now replaced with scanner config discovery profile id.
- // Using the default per project profile for managed make
- if(scannerInfoCollectorId != null && scannerInfoCollectorId.equals("org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector")) //$NON-NLS-1$
- toolChain.setScannerConfigDiscoveryProfileId(ManagedBuildCPathEntryContainer.MM_PP_DISCOVERY_PROFILE_ID);
- // Create the Builder
- subId = id + ".builder"; //$NON-NLS-1$
- subName = name + ".builder"; //$NON-NLS-1$
- IBuilder builder = toolChain.createBuilder(null, subId, subName, true);
- // Set the builder attributes
- builder.setIsAbstract(isAbstract);
- builder.setCommand(getMakeCommand());
- builder.setArguments(getMakeArguments());
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- if (element instanceof DefaultManagedConfigElement) {
- ((Builder)builder).setBuildFileGeneratorElement(((DefaultManagedConfigElement)element).getConfigurationElement());
- }
- // Create the TargetPlatform
- subId = id + ".targetplatform"; //$NON-NLS-1$
- subName = name + ".targetplatform"; //$NON-NLS-1$
- ITargetPlatform targetPlatform = toolChain.createTargetPlatform(null, subId, subName, true);
- // Set the target platform attributes
- targetPlatform.setIsAbstract(isAbstract);
- targetPlatform.setOSList(getTargetOSList());
- targetPlatform.setArchList(getTargetArchList());
- targetPlatform.setBinaryParserList(new String[]{getBinaryParserId()}); // Older projects will always have only one binary parser set.
-
- // Handle ConfigurationV2 children (ToolReference)
- // The tools references fetched here are strictly local to the configuration,
- // so additional work is required to fetch the tool references from the target
- IToolReference[] configToolRefs = configV2.getToolReferences();
- // Add the "local" tool references (they are direct children of the target and
- // its parent targets)
- Vector targetToolRefs = new Vector();
- addTargetToolReferences(targetToolRefs);
- IToolReference[] toolRefs;
- if (targetToolRefs.size() > 0) {
- toolRefs = new IToolReference[targetToolRefs.size() + configToolRefs.length];
- int i;
- for (i = 0; i < configToolRefs.length; ++i) {
- toolRefs[i] = configToolRefs[i];
- }
- Iterator localToolRefIter = targetToolRefs.iterator();
- while (localToolRefIter.hasNext()) {
- toolRefs[i++] = (IToolReference)localToolRefIter.next();
- }
- } else {
- toolRefs = configToolRefs;
- }
- for (int i = 0; i < toolRefs.length; ++i) {
- IToolReference toolRef = toolRefs[i];
- subId = id + "." + toolRef.getId(); //$NON-NLS-1$
- // The ToolReference's Tool becomes the newTool's SuperClass
- ITool newTool = toolChain.createTool(toolRef.getTool(), subId, toolRef.getName(), true);
- // Set the tool attributes
- newTool.setToolCommand(toolRef.getRawToolCommand());
- newTool.setOutputPrefix(toolRef.getRawOutputPrefix());
- newTool.setOutputFlag(toolRef.getRawOutputFlag());
- newTool.setOutputsAttribute(toolRef.getRawOutputExtensions());
- // Handle ToolReference children (OptionReference)
- Iterator optRefIter = toolRef.getOptionReferenceList().listIterator();
- while (optRefIter.hasNext()) {
- OptionReference optRef = (OptionReference)optRefIter.next();
- subId = id + "." + optRef.getId(); //$NON-NLS-1$
- IOption newOption = newTool.createOption(optRef.getOption(), subId, optRef.getName(), true);
- // Set the option attributes
- newOption.setValue(optRef.getValue());
- newOption.setValueType(optRef.getValueType());
- ((Option)newOption).setWasOptRef(true);
- }
- }
-
- // Process the tools in the configuration, adding them to the toolchain
- // Tools for a configuration are stored in the enclosing target, so getting
- // the tools for the configuration ultimately gets them from the enclosing target
- ITool[] configTools = configV2.getTools();
- for (int i = 0; i < configTools.length; ++i) {
- ITool tool = configTools[i];
- // If tool references encountered, they have already been processed, above,
- // so ignore them now
- if (!(tool instanceof ToolReference)) {
- // See if the toolchain already has a tool with a SuperClass that has an id
- // equal to the tool that we are considering adding to the toolchain; if so,
- // don't add it
- // This case arises when we have added a tool to the toolchain because
- // we processed a ToolReference (above) that references this tool
- // The original tool referenced in the ToolReference becomes the SuperClass
- // of the tool that is created because of the ToolReference
- boolean found = false;
- ITool[] tools = toolChain.getTools();
- ITool currentTool;
- ITool supercurrentTool;
- for (int j = 0; j < tools.length; ++j) {
- currentTool = tools[j];
- supercurrentTool = currentTool.getSuperClass();
- if (supercurrentTool != null) {
- if (supercurrentTool.getId() == tool.getId()) {
- found = true;
- // If this tool was already added to the toolchain because of a
- // ToolReference, then we disconnent this redundant
- // tool from the target by setting the parent to null
- ((Tool)tool).setToolParent(null);
- break;
- }
- }
- }
-
- if (!found)
- // This tool is not in the toolchain yet, so add it to the toolchain
- ((ToolChain)toolChain).addTool((Tool)tool);
-
- }
- }
- // Normalize the outputextensions list by adding an empty string for each tool
- // which did not have an explicit output file extension specified
- ((ToolChain)toolChain).normalizeOutputExtensions();
- }
- }
-
- /*
- * A target element may contain toolReference elements. These get applied to all of the configurations
- * of the target. The method adds the list of this target's local tool references to the passed in vector.
- */
- public void addTargetToolReferences(Vector toolRefs) {
- toolRefs.addAll(getLocalToolReferences());
- if (parent != null) {
- Target targetParent = (Target)parent;
- targetParent.addTargetToolReferences(toolRefs);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITarget#getCreatedProjectType()
- */
- public ProjectType getCreatedProjectType() {
- return createdProjectType;
- }
-
- /**
- * @return Returns the version.
- */
- public PluginVersionIdentifier getVersion() {
- if ( version == null) {
- if ( getParent() != null) {
- return getParent().getVersion();
- }
- }
- return version;
- }
-
- public void setVersion(PluginVersionIdentifier version) {
- // Do nothing
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2003, 2005 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.eclipse.cdt.core.CCorePlugin;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.ITarget;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.IToolReference;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.internal.scannerconfig.ManagedBuildCPathEntryContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class Target extends BuildObject implements ITarget {
+ private static final String EMPTY_STRING = new String();
+ private static final IConfigurationV2[] emptyConfigs = new IConfigurationV2[0];
+ private String artifactName;
+ private String binaryParserId;
+ private String cleanCommand;
+ private List configList;
+ private Map configMap;
+ private String defaultExtension;
+ private Map depCalculatorsMap;
+ private String errorParserIds;
+ private String extension;
+ private boolean isAbstract = false;
+ private boolean isDirty = false;
+ private boolean isTest = false;
+ private String makeArguments;
+ private String makeCommand;
+ private IResource owner;
+ private ITarget parent;
+ private boolean resolved = true;
+ private List targetArchList;
+ private List targetOSList;
+ private List toolList;
+ private Map toolMap;
+ private List toolReferences;
+ private ProjectType createdProjectType;
+ private String scannerInfoCollectorId;
+
+ /**
+ * This constructor is called to create a target defined by an extension point in
+ * a plugin manifest file.
+ *
+ * @param element
+ * @param managedBuildRevision the fileVersion of Managed Build System
+ */
+ public Target(IManagedConfigElement element, String managedBuildRevision) {
+ // setup for resolving
+ ManagedBuildManager.putConfigElement(this, element);
+ resolved = false;
+
+ // id
+ setId(element.getAttribute(ID));
+
+ // managedBuildRevision
+ setManagedBuildRevision(managedBuildRevision);
+
+ // hook me up
+ ManagedBuildManager.addExtensionTarget(this);
+
+ // Get the target name
+ setName(element.getAttribute(NAME));
+
+ // Get the name of the build artifact associated with target (usually
+ // in the plugin specification).
+ artifactName = element.getAttribute(ARTIFACT_NAME);
+
+ // Get the ID of the binary parser
+ binaryParserId = element.getAttribute(BINARY_PARSER);
+
+ // Get the semicolon separated list of IDs of the error parsers
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+
+ // Get the default extension
+ defaultExtension = element.getAttribute(DEFAULT_EXTENSION);
+
+ // isAbstract
+ isAbstract = ("true".equals(element.getAttribute(IS_ABSTRACT))); //$NON-NLS-1$
+
+ // Is this a test target
+ isTest = ("true".equals(element.getAttribute(IS_TEST))); //$NON-NLS-1$
+
+ // Get the clean command
+ cleanCommand = element.getAttribute(CLEAN_COMMAND);
+
+ // Get the make command
+ makeCommand = element.getAttribute(MAKE_COMMAND);
+
+ // Get the make arguments
+ makeArguments = element.getAttribute(MAKE_ARGS);
+
+ // Get scannerInfoCollectorId
+ scannerInfoCollectorId = element.getAttribute(SCANNER_INFO_COLLECTOR_ID);
+
+ // Get the comma-separated list of valid OS
+ String os = element.getAttribute(OS_LIST);
+ if (os != null) {
+ targetOSList = new ArrayList();
+ String[] osTokens = os.split(","); //$NON-NLS-1$
+ for (int i = 0; i < osTokens.length; ++i) {
+ targetOSList.add(osTokens[i].trim());
+ }
+ }
+
+ // Get the comma-separated list of valid Architectures
+ String arch = element.getAttribute(ARCH_LIST);
+ if (arch != null) {
+ targetArchList = new ArrayList();
+ String[] archTokens = arch.split(","); //$NON-NLS-1$
+ for (int j = 0; j < archTokens.length; ++j) {
+ targetArchList.add(archTokens[j].trim());
+ }
+ }
+
+ // Load any tool references we might have
+ IManagedConfigElement[] toolRefs = element.getChildren(IConfigurationV2.TOOLREF_ELEMENT_NAME);
+ for (int k = 0; k < toolRefs.length; ++k) {
+ new ToolReference(this, toolRefs[k]);
+ }
+ // Then load any tools defined for the target
+ IManagedConfigElement[] tools = element.getChildren(ITool.TOOL_ELEMENT_NAME);
+ for (int m = 0; m < tools.length; ++m) {
+ ITool newTool = new Tool(this, tools[m], managedBuildRevision);
+ // Add this tool to the target, as this is not done in the constructor
+ this.addTool(newTool);
+ }
+ // Then load the configurations which may have tool references
+ IManagedConfigElement[] configs = element.getChildren(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
+ for (int n = 0; n < configs.length; ++n) {
+ new ConfigurationV2(this, configs[n]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * Set the resource that owns the target.
+ *
+ * @param owner
+ */
+ protected Target(IResource owner) {
+ this.owner = owner;
+ }
+
+ /**
+ * Create a copy of the target specified in the argument,
+ * that is owned by the owned by the specified resource.
+ *
+ * @param owner
+ * @param parent
+ */
+ public Target(IResource owner, ITarget parent) {
+ // Make the owner of the target the project resource
+ this(owner);
+
+ // Copy the parent's identity
+ this.parent = parent;
+ int id = ManagedBuildManager.getRandomNumber();
+ setId(owner.getName() + "." + parent.getId() + "." + id); //$NON-NLS-1$ //$NON-NLS-2$
+ setName(parent.getName());
+
+ setManagedBuildRevision(parent.getManagedBuildRevision());
+
+ setArtifactName(parent.getArtifactName());
+ this.binaryParserId = parent.getBinaryParserId();
+ this.errorParserIds = parent.getErrorParserIds();
+ this.defaultExtension = parent.getArtifactExtension();
+ this.isTest = parent.isTestTarget();
+ this.cleanCommand = parent.getCleanCommand();
+ this.scannerInfoCollectorId = ((Target)parent).scannerInfoCollectorId;
+
+ // Hook me up
+ IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(owner);
+ buildInfo.addTarget(this);
+ }
+
+ /**
+ * Create target from project file.
+ *
+ * @param buildInfo
+ * @param element
+ */
+ public Target(ManagedBuildInfo buildInfo, Element element) {
+ this(buildInfo.getOwner());
+
+ // id
+ setId(element.getAttribute(ID));
+
+ // hook me up
+ buildInfo.addTarget(this);
+
+ // name
+ setName(element.getAttribute(NAME));
+
+ // Get the name of the build artifact associated with target (should
+ // contain what the user entered in the UI).
+ artifactName = element.getAttribute(ARTIFACT_NAME);
+
+ // Get the overridden extension
+ if (element.hasAttribute(EXTENSION)) {
+ extension = element.getAttribute(EXTENSION);
+ }
+
+ // parent
+ String parentId = element.getAttribute(PARENT);
+ if (parentId != null)
+ parent = ManagedBuildManager.getTarget(null, parentId);
+
+ // isAbstract
+ if ("true".equals(element.getAttribute(IS_ABSTRACT))) //$NON-NLS-1$
+ isAbstract = true;
+
+ // Is this a test target
+ isTest = ("true".equals(element.getAttribute(IS_TEST))); //$NON-NLS-1$
+
+ // Get the clean command
+ if (element.hasAttribute(CLEAN_COMMAND)) {
+ cleanCommand = element.getAttribute(CLEAN_COMMAND);
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ if (element.hasAttribute(ERROR_PARSERS)) {
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+ }
+
+ // Get the make command and arguments
+ if (element.hasAttribute(MAKE_COMMAND)) {
+ makeCommand = element.getAttribute(MAKE_COMMAND);
+ }
+ if(element.hasAttribute(MAKE_ARGS)) {
+ makeArguments = element.getAttribute(MAKE_ARGS);
+ }
+
+ Node child = element.getFirstChild();
+ while (child != null) {
+ if (child.getNodeName().equals(IConfigurationV2.CONFIGURATION_ELEMENT_NAME)) {
+ new ConfigurationV2(this, (Element)child);
+ }
+ child = child.getNextSibling();
+ }
+ }
+
+ /**
+ * @param configuration
+ */
+ public void addConfiguration(IConfigurationV2 configuration) {
+ getConfigurationList().add(configuration);
+ getConfigurationMap().put(configuration.getId(), configuration);
+ }
+
+ /**
+ * Adds a tool specification to the receiver. This tool is defined
+ * only for the receiver, and cannot be shared by other targets.
+ *
+ * @param tool
+ */
+ public void addTool(ITool tool) {
+ getToolList().add(tool);
+ getToolMap().put(tool.getId(), tool);
+ }
+
+ /**
+ * Adds a tool reference to the receiver.
+ *
+ * @param toolRef
+ */
+ public void addToolReference(ToolReference toolRef) {
+ getLocalToolReferences().add(toolRef);
+ }
+
+
+ /* (non-Javadoc)
+ * Tail-recursion method that creates a lits of tools and tool reference
+ * walking the receiver's parent hierarchy.
+ *
+ * @param toolArray
+ */
+ private void addToolsToArray(Vector toolArray) {
+ if (parent != null) {
+ ((Target)parent).addToolsToArray(toolArray);
+ }
+
+ // Add the tools from out own list
+ toolArray.addAll(getToolList());
+
+ // Add local tool references
+ toolArray.addAll(getLocalToolReferences());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration(org.eclipse.cdt.core.build.managed.IConfigurationV2)
+ */
+ public IConfigurationV2 createConfiguration(IConfigurationV2 parent, String id) {
+ isDirty = true;
+ return new ConfigurationV2(this, parent, id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#createConfiguration()
+ */
+ public IConfigurationV2 createConfiguration(String id) {
+ return new ConfigurationV2(this, id);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getArtifactExtension()
+ */
+ public String getArtifactExtension() {
+ // Has the user changed the extension for this target
+ if (extension != null) {
+ return extension;
+ }
+ // If not, then go through the default extension lookup
+ if (defaultExtension == null) {
+ // Ask my parent first
+ if (parent != null) {
+ return parent.getArtifactExtension();
+ } else {
+ return EMPTY_STRING;
+ }
+ } else {
+ return defaultExtension;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getArtifactName()
+ */
+ public String getArtifactName() {
+ if (artifactName == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getArtifactName();
+ } else {
+ // I'm it and this is not good!
+ return EMPTY_STRING;
+ }
+ } else {
+ return artifactName;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getBinaryParserId()
+ */
+ public String getBinaryParserId() {
+ if (binaryParserId == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getBinaryParserId();
+ } else {
+ // I'm it and this is not good!
+ return EMPTY_STRING;
+ }
+ }
+ return binaryParserId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getCleanCommand()
+ */
+ public String getCleanCommand() {
+ // Return the command used to remove files
+ if (cleanCommand == null) {
+ if (parent != null) {
+ return parent.getCleanCommand();
+ } else {
+ // User forgot to specify it. Guess based on OS.
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ return new String("del"); //$NON-NLS-1$
+ } else {
+ return new String("rm"); //$NON-NLS-1$
+ }
+ }
+ } else {
+ // This was spec'd in the manifest
+ return cleanCommand;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getConfiguration()
+ */
+ public IConfigurationV2 getConfiguration(String id) {
+ return (IConfigurationV2)getConfigurationMap().get(id);
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the list of configurations.
+ *
+ * @return List containing the configurations
+ */
+ private List getConfigurationList() {
+ if (configList == null) {
+ configList = new ArrayList();
+ }
+ return configList;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of configuration ids to configurations
+ *
+ * @return
+ */
+ private Map getConfigurationMap() {
+ if (configMap == null) {
+ configMap = new HashMap();
+ }
+ return configMap;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getConfigurations()
+ */
+ public IConfigurationV2[] getConfigurations() {
+ return (IConfigurationV2[])getConfigurationList().toArray(new IConfigurationV2[getConfigurationList().size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getDefaultExtension()
+ */
+ public String getDefaultExtension() {
+ return defaultExtension == null ? EMPTY_STRING : defaultExtension;
+ }
+
+ private Map getDepCalcMap() {
+ if (depCalculatorsMap == null) {
+ depCalculatorsMap = new HashMap();
+ }
+ return depCalculatorsMap;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ if (errorParserIds == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getErrorParserIds();
+ }
+ }
+ return errorParserIds;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getErrorParserList()
+ */
+ public String[] getErrorParserList() {
+ String parserIDs = getErrorParserIds();
+ String[] errorParsers = null;
+ if (parserIDs != null) {
+ // Check for an empty string
+ if (parserIDs.length() == 0) {
+ errorParsers = new String[0];
+ } else {
+ StringTokenizer tok = new StringTokenizer(parserIDs, ";"); //$NON-NLS-1$
+ List list = new ArrayList(tok.countTokens());
+ while (tok.hasMoreElements()) {
+ list.add(tok.nextToken());
+ }
+ String[] strArr = {""}; //$NON-NLS-1$
+ errorParsers = (String[]) list.toArray(strArr);
+ }
+ } else {
+ // If no error parsers are specified by the target, the default is
+ // all error parsers
+ errorParsers = CCorePlugin.getDefault().getAllErrorParsersIDs();
+ }
+ return errorParsers;
+ }
+
+ /* (non-javadoc)
+ * A safe accesor method. It answers the tool reference list in the
+ * receiver.
+ *
+ * @return List
+ */
+ protected List getLocalToolReferences() {
+ if (toolReferences == null) {
+ toolReferences = new ArrayList();
+ }
+ return toolReferences;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getMakeArguments()
+ */
+ public String getMakeArguments() {
+ if (makeArguments == null) {
+ // See if it is defined in my parent
+ if (parent != null) {
+ return parent.getMakeArguments();
+ } else {
+ // No parent and no user setting
+ return new String(""); //$NON-NLS-1$
+ }
+ }
+ return makeArguments;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#getMakeCommand()
+ */
+ public String getMakeCommand() {
+ // Return the name of the make utility
+ if (makeCommand == null) {
+ // If I have a parent, ask it
+ if (parent != null) {
+ return parent.getMakeCommand();
+ } else {
+ // The user has forgotten to specify a command in the plugin manifest
+ return new String("make"); //$NON-NLS-1$
+ }
+ } else {
+ return makeCommand;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getName()
+ */
+ public String getName() {
+ // If I am unnamed, see if I can inherit one from my parent
+ if (name == null) {
+ if (parent != null) {
+ return parent.getName();
+ } else {
+ return new String(""); //$NON-NLS-1$
+ }
+ } else {
+ return name;
+ }
+ }
+
+ /* (non-javadoc)
+ *
+ * @param tool
+ * @return List
+ */
+ protected List getOptionReferences(ITool tool) {
+ List references = new ArrayList();
+
+ // Get all the option references I add for this tool
+ ToolReference toolRef = getToolReference(tool);
+ if (toolRef != null) {
+ references.addAll(toolRef.getOptionReferenceList());
+ }
+
+ // See if there is anything that my parents add that I don't
+ if (parent != null) {
+ List temp = ((Target)parent).getOptionReferences(tool);
+ Iterator iter = temp.listIterator();
+ while (iter.hasNext()) {
+ OptionReference ref = (OptionReference) iter.next();
+ if (!references.contains(ref)) {
+ references.add(ref);
+ }
+ }
+ }
+
+ return references;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getOwner()
+ */
+ public IResource getOwner() {
+ return owner;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getParent()
+ */
+ public ITarget getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetArchList()
+ */
+ public String[] getTargetArchList() {
+ if (targetArchList == null) {
+ // Ask parent for its list
+ if (parent != null) {
+ return parent.getTargetArchList();
+ } else {
+ // I have no parent and no defined list
+ return new String[] {"all"}; //$NON-NLS-1$
+ }
+ }
+ return (String[]) targetArchList.toArray(new String[targetArchList.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTargetOSList()
+ */
+ public String[] getTargetOSList() {
+ if (targetOSList == null) {
+ // Ask parent for its list
+ if (parent != null) {
+ return parent.getTargetOSList();
+ } else {
+ // I have no parent and no defined filter list
+ return new String[] {"all"}; //$NON-NLS-1$
+ }
+ }
+ return (String[]) targetOSList.toArray(new String[targetOSList.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTool(java.lang.String)
+ */
+ public ITool getTool(String id) {
+ ITool result = null;
+
+ // See if receiver has it in list
+ result = (ITool) getToolMap().get(id);
+
+ // If not, check if parent has it
+ if (result == null && parent != null) {
+ result = ((Target)parent).getTool(id);
+ }
+
+ // If not defined in parents, check if defined at all
+ if (result == null) {
+ result = ManagedBuildManager.getExtensionTool(id);
+ }
+
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * A safe accessor method for the list of tools maintained by the
+ * target
+ *
+ */
+ private List getToolList() {
+ if (toolList == null) {
+ toolList = new ArrayList();
+ }
+ return toolList;
+ }
+
+ /* (non-Javadoc)
+ * A safe accessor for the tool map
+ *
+ */
+ private Map getToolMap() {
+ if (toolMap == null) {
+ toolMap = new HashMap();
+ }
+ return toolMap;
+ }
+
+ /* (non-Javadoc)
+ * Returns the reference for a given tool or null
if one is not
+ * found.
+ *
+ * @param tool
+ * @return ToolReference
+ */
+ private ToolReference getToolReference(ITool tool) {
+ // See if the receiver has a reference to the tool
+ ToolReference ref = null;
+ if (tool == null) return ref;
+ Iterator iter = getLocalToolReferences().listIterator();
+ while (iter.hasNext()) {
+ ToolReference temp = (ToolReference)iter.next();
+ if (temp.references(tool)) {
+ ref = temp;
+ break;
+ }
+ }
+ return ref;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getTools()
+ */
+ public ITool[] getTools() {
+ Vector toolArray = new Vector();
+ addToolsToArray(toolArray);
+ return (ITool[]) toolArray.toArray(new ITool[toolArray.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#hasMakeCommandOverride()
+ */
+ public boolean hasOverridenMakeCommand() {
+ // We answer true if the make command or the flags are different
+ return ((makeCommand != null && !makeCommand.equals(parent.getMakeCommand()))
+ || (makeArguments != null && !makeArguments.equals(parent.getMakeArguments())));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#isAbstract()
+ */
+ public boolean isAbstract() {
+ return isAbstract;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#isDirty()
+ */
+ public boolean isDirty() {
+ // If I need saving, just say yes
+ if (isDirty) {
+ return true;
+ }
+
+ // Iterate over the configurations and ask them if they need saving
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ if (((IConfigurationV2)iter.next()).isDirty()) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#isTestTarget()
+ */
+ public boolean isTestTarget() {
+ return isTest;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#needsRebuild()
+ */
+ public boolean needsRebuild(){
+ // Iterate over the configurations and ask them if they need saving
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ if (((IConfigurationV2)iter.next()).needsRebuild()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#removeConfiguration(java.lang.String)
+ */
+ public void removeConfiguration(String id) {
+ // Remove the specified configuration from the list and map
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ IConfigurationV2 config = (IConfigurationV2)iter.next();
+ if (config.getId().equals(id)) {
+ getConfigurationList().remove(config);
+ getConfigurationMap().remove(id);
+ isDirty = true;
+ break;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#resetMakeCommand()
+ */
+ public void resetMakeCommand() {
+ // Flag target as dirty if the reset actually changes something
+ if (makeCommand != null) {
+ setDirty(true);
+ }
+ makeCommand = null;
+ makeArguments = null;
+ }
+
+ /**
+ *
+ */
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
+ // parent
+ String parentId = element.getAttribute(PARENT);
+ if (parentId != null) {
+ parent = ManagedBuildManager.getTarget(null, parentId);
+ // should resolve before calling methods on it
+ ((Target)parent).resolveReferences();
+ // copy over the parents configs
+ IConfigurationV2[] parentConfigs = parent.getConfigurations();
+ for (int i = 0; i < parentConfigs.length; ++i)
+ addConfiguration(parentConfigs[i]);
+ }
+
+ // call resolve references on any children
+ Iterator toolIter = getToolList().iterator();
+ while (toolIter.hasNext()) {
+ Tool current = (Tool)toolIter.next();
+ current.resolveReferences();
+ }
+ Iterator refIter = getLocalToolReferences().iterator();
+ while (refIter.hasNext()) {
+ ToolReference current = (ToolReference)refIter.next();
+ current.resolveReferences();
+ }
+ Iterator configIter = getConfigurationList().iterator();
+ while (configIter.hasNext()) {
+ ConfigurationV2 current = (ConfigurationV2)configIter.next();
+ current.resolveReferences();
+ }
+ }
+ }
+
+ /**
+ * Persist receiver to project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ element.setAttribute(ID, getId());
+ element.setAttribute(NAME, getName());
+ if (parent != null)
+ element.setAttribute(PARENT, parent.getId());
+ element.setAttribute(IS_ABSTRACT, isAbstract ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ element.setAttribute(ARTIFACT_NAME, getArtifactName());
+ if (extension != null) {
+ element.setAttribute(EXTENSION, extension);
+ }
+ element.setAttribute(IS_TEST, isTest ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ if (makeCommand != null) {
+ element.setAttribute(MAKE_COMMAND, makeCommand);
+ } else {
+ // Make sure we use the default
+ }
+
+ if (makeArguments != null) {
+ element.setAttribute(MAKE_ARGS, makeArguments);
+ }
+ if (errorParserIds != null) {
+ element.setAttribute(ERROR_PARSERS, errorParserIds);
+ }
+
+ // Serialize the configuration settings
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ ConfigurationV2 config = (ConfigurationV2) iter.next();
+ Element configElement = doc.createElement(IConfigurationV2.CONFIGURATION_ELEMENT_NAME);
+ element.appendChild(configElement);
+ config.serialize(doc, configElement);
+ }
+
+ // I am clean now
+ isDirty = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setArtifactExtension(java.lang.String)
+ */
+ public void setArtifactExtension(String extension) {
+ if (extension != null) {
+ this.extension = extension;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITarget#setArtifactName(java.lang.String)
+ */
+ public void setArtifactName(String name) {
+ if (name != null) {
+ artifactName = name;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ // Override the dirty flag here
+ this.isDirty = isDirty;
+ // and in the configurations
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ IConfigurationV2 config = (IConfigurationV2)iter.next();
+ config.setDirty(isDirty);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setErrorParserIds()
+ */
+ public void setErrorParserIds(String ids) {
+ if (ids == null) return;
+ String currentIds = getErrorParserIds();
+ if (currentIds == null || !(currentIds.equals(ids))) {
+ errorParserIds = ids;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeArguments(java.lang.String)
+ */
+ public void setMakeArguments(String makeArgs) {
+ if (makeArgs != null && !getMakeArguments().equals(makeArgs)) {
+ makeArguments = makeArgs;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setMakeCommand(java.lang.String)
+ */
+ public void setMakeCommand(String command) {
+ if (command != null && !getMakeCommand().equals(command)) {
+ makeCommand = command;
+ setRebuildState(true);
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#setRebuildState(boolean)
+ */
+ public void setRebuildState(boolean rebuild) {
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ ((IConfigurationV2)iter.next()).setRebuildState(rebuild);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#updateOwner(org.eclipse.core.resources.IResource)
+ */
+ public void updateOwner(IResource resource) {
+ if (!resource.equals(owner)) {
+ // Set the owner correctly
+ owner = resource;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#convertToProjectType()
+ */
+ public void convertToProjectType(String managedBuildRevision) {
+ // Create a ProjectType + Configuration + Toolchain + Builder + TargetPlatform
+ // from the Target
+
+ // The "parent" needs to have been converted already.
+ // Do it now if necessary.
+ ProjectType parentProj = null;
+ if (parent != null) {
+ parentProj = parent.getCreatedProjectType();
+ if (parentProj == null) {
+ parent.convertToProjectType(managedBuildRevision);
+ parentProj = parent.getCreatedProjectType();
+ }
+ }
+ ProjectType projectType = new ProjectType(parentProj, getId(), getName(), managedBuildRevision);
+ createdProjectType = projectType;
+ // Set the project type attributes
+ projectType.setIsAbstract(isAbstract);
+ projectType.setIsTest(isTest);
+ // Add children
+ // Add configurations (Configuration -> ToolChain -> Builder -> TargetPlatform)
+ Iterator iter = getConfigurationList().listIterator();
+ while (iter.hasNext()) {
+ IConfigurationV2 configV2 = (IConfigurationV2)iter.next();
+ if (configV2.getCreatedConfig() != null) continue;
+ // The new config's superClass needs to be the
+ // Configuration created from the ConfigurationV2 parent...
+ IConfiguration configSuperClass = null;
+ IConfigurationV2 parentV2 = configV2.getParent();
+ if (parentV2 != null) {
+ configSuperClass = parentV2.getCreatedConfig();
+ }
+ String id = configV2.getId();
+ String name = configV2.getName();
+ IConfiguration config = projectType.createConfiguration(configSuperClass, id, name);
+ configV2.setCreatedConfig(config);
+ // Set the configuration attributes
+ config.setArtifactName(getArtifactName());
+ config.setArtifactExtension(getArtifactExtension());
+ config.setCleanCommand(getCleanCommand());
+ config.setErrorParserIds(getErrorParserIds());
+ // Create the Tool-chain
+ String subId;
+ String subName;
+ subId = id + ".toolchain"; //$NON-NLS-1$
+ subName = name + ".toolchain"; //$NON-NLS-1$
+ IToolChain toolChain = config.createToolChain(null, subId, subName, true);
+ // Set the tool chain attributes
+ toolChain.setIsAbstract(isAbstract);
+ toolChain.setOSList(getTargetOSList());
+ toolChain.setArchList(getTargetArchList());
+ // In target element had a scannerInfoCollector element here which
+ // is now replaced with scanner config discovery profile id.
+ // Using the default per project profile for managed make
+ if(scannerInfoCollectorId != null && scannerInfoCollectorId.equals("org.eclipse.cdt.managedbuilder.internal.scannerconfig.DefaultGCCScannerInfoCollector")) //$NON-NLS-1$
+ toolChain.setScannerConfigDiscoveryProfileId(ManagedBuildCPathEntryContainer.MM_PP_DISCOVERY_PROFILE_ID);
+ // Create the Builder
+ subId = id + ".builder"; //$NON-NLS-1$
+ subName = name + ".builder"; //$NON-NLS-1$
+ IBuilder builder = toolChain.createBuilder(null, subId, subName, true);
+ // Set the builder attributes
+ builder.setIsAbstract(isAbstract);
+ builder.setCommand(getMakeCommand());
+ builder.setArguments(getMakeArguments());
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
+ if (element instanceof DefaultManagedConfigElement) {
+ ((Builder)builder).setBuildFileGeneratorElement(((DefaultManagedConfigElement)element).getConfigurationElement());
+ }
+ // Create the TargetPlatform
+ subId = id + ".targetplatform"; //$NON-NLS-1$
+ subName = name + ".targetplatform"; //$NON-NLS-1$
+ ITargetPlatform targetPlatform = toolChain.createTargetPlatform(null, subId, subName, true);
+ // Set the target platform attributes
+ targetPlatform.setIsAbstract(isAbstract);
+ targetPlatform.setOSList(getTargetOSList());
+ targetPlatform.setArchList(getTargetArchList());
+ targetPlatform.setBinaryParserList(new String[]{getBinaryParserId()}); // Older projects will always have only one binary parser set.
+
+ // Handle ConfigurationV2 children (ToolReference)
+ // The tools references fetched here are strictly local to the configuration,
+ // so additional work is required to fetch the tool references from the target
+ IToolReference[] configToolRefs = configV2.getToolReferences();
+ // Add the "local" tool references (they are direct children of the target and
+ // its parent targets)
+ Vector targetToolRefs = new Vector();
+ addTargetToolReferences(targetToolRefs);
+ IToolReference[] toolRefs;
+ if (targetToolRefs.size() > 0) {
+ toolRefs = new IToolReference[targetToolRefs.size() + configToolRefs.length];
+ int i;
+ for (i = 0; i < configToolRefs.length; ++i) {
+ toolRefs[i] = configToolRefs[i];
+ }
+ Iterator localToolRefIter = targetToolRefs.iterator();
+ while (localToolRefIter.hasNext()) {
+ toolRefs[i++] = (IToolReference)localToolRefIter.next();
+ }
+ } else {
+ toolRefs = configToolRefs;
+ }
+ for (int i = 0; i < toolRefs.length; ++i) {
+ IToolReference toolRef = toolRefs[i];
+ subId = id + "." + toolRef.getId(); //$NON-NLS-1$
+ // The ToolReference's Tool becomes the newTool's SuperClass
+ ITool newTool = toolChain.createTool(toolRef.getTool(), subId, toolRef.getName(), true);
+ // Set the tool attributes
+ newTool.setToolCommand(toolRef.getRawToolCommand());
+ newTool.setOutputPrefix(toolRef.getRawOutputPrefix());
+ newTool.setOutputFlag(toolRef.getRawOutputFlag());
+ newTool.setOutputsAttribute(toolRef.getRawOutputExtensions());
+ // Handle ToolReference children (OptionReference)
+ Iterator optRefIter = toolRef.getOptionReferenceList().listIterator();
+ while (optRefIter.hasNext()) {
+ OptionReference optRef = (OptionReference)optRefIter.next();
+ subId = id + "." + optRef.getId(); //$NON-NLS-1$
+ IOption newOption = newTool.createOption(optRef.getOption(), subId, optRef.getName(), true);
+ // Set the option attributes
+ newOption.setValue(optRef.getValue());
+ newOption.setValueType(optRef.getValueType());
+ ((Option)newOption).setWasOptRef(true);
+ }
+ }
+
+ // Process the tools in the configuration, adding them to the toolchain
+ // Tools for a configuration are stored in the enclosing target, so getting
+ // the tools for the configuration ultimately gets them from the enclosing target
+ ITool[] configTools = configV2.getTools();
+ for (int i = 0; i < configTools.length; ++i) {
+ ITool tool = configTools[i];
+ // If tool references encountered, they have already been processed, above,
+ // so ignore them now
+ if (!(tool instanceof ToolReference)) {
+ // See if the toolchain already has a tool with a SuperClass that has an id
+ // equal to the tool that we are considering adding to the toolchain; if so,
+ // don't add it
+ // This case arises when we have added a tool to the toolchain because
+ // we processed a ToolReference (above) that references this tool
+ // The original tool referenced in the ToolReference becomes the SuperClass
+ // of the tool that is created because of the ToolReference
+ boolean found = false;
+ ITool[] tools = toolChain.getTools();
+ ITool currentTool;
+ ITool supercurrentTool;
+ for (int j = 0; j < tools.length; ++j) {
+ currentTool = tools[j];
+ supercurrentTool = currentTool.getSuperClass();
+ if (supercurrentTool != null) {
+ if (supercurrentTool.getId() == tool.getId()) {
+ found = true;
+ // If this tool was already added to the toolchain because of a
+ // ToolReference, then we disconnent this redundant
+ // tool from the target by setting the parent to null
+ ((Tool)tool).setToolParent(null);
+ break;
+ }
+ }
+ }
+
+ if (!found)
+ // This tool is not in the toolchain yet, so add it to the toolchain
+ ((ToolChain)toolChain).addTool((Tool)tool);
+
+ }
+ }
+ // Normalize the outputextensions list by adding an empty string for each tool
+ // which did not have an explicit output file extension specified
+ ((ToolChain)toolChain).normalizeOutputExtensions();
+ }
+ }
+
+ /*
+ * A target element may contain toolReference elements. These get applied to all of the configurations
+ * of the target. The method adds the list of this target's local tool references to the passed in vector.
+ */
+ public void addTargetToolReferences(Vector toolRefs) {
+ toolRefs.addAll(getLocalToolReferences());
+ if (parent != null) {
+ Target targetParent = (Target)parent;
+ targetParent.addTargetToolReferences(toolRefs);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITarget#getCreatedProjectType()
+ */
+ public ProjectType getCreatedProjectType() {
+ return createdProjectType;
+ }
+
+ /**
+ * @return Returns the version.
+ */
+ public PluginVersionIdentifier getVersion() {
+ if ( version == null) {
+ if ( getParent() != null) {
+ return getParent().getVersion();
+ }
+ }
+ return version;
+ }
+
+ public void setVersion(PluginVersionIdentifier version) {
+ // Do nothing
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
index c2b0c270a4d..36c8dc24405 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Tool.java
@@ -1,2825 +1,2825 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.core;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
-import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
-import org.eclipse.cdt.managedbuilder.core.IManagedProject;
-import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IOutputType;
-import org.eclipse.cdt.managedbuilder.core.IProjectType;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.macros.BuildfileMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
-import org.eclipse.cdt.managedbuilder.internal.macros.IMacroSubstitutor;
-import org.eclipse.cdt.managedbuilder.internal.macros.MacroResolver;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ProjectScope;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeSettings;
-import org.eclipse.core.runtime.preferences.IScopeContext;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Represents a tool that can be invoked during a build.
- * Note that this class implements IOptionCategory to represent the top
- * category.
- */
-public class Tool extends HoldsOptions implements ITool, IOptionCategory {
-
- public static final String DEFAULT_PATTERN = "${COMMAND} ${FLAGS} ${OUTPUT_FLAG}${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}"; //$NON-NLS-1$
- public static final String DEFAULT_CBS_PATTERN = "${COMMAND}"; //$NON-NLS-1$
-
- private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
- //private static final IOptionCategory[] EMPTY_CATEGORIES = new IOptionCategory[0];
- //private static final IOption[] EMPTY_OPTIONS = new IOption[0];
- private static final String EMPTY_STRING = new String();
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
- private static final String DEFAULT_ANNOUNCEMENT_PREFIX = "Tool.default.announcement"; //$NON-NLS-1$
- private static final String WHITESPACE = " "; //$NON-NLS-1$
-
- private static final boolean resolvedDefault = true;
-
- // Superclass
- // Note that superClass itself is defined in the base and that the methods
- // getSuperClass() and setSuperClassInternal(), defined in Tool must be used to
- // access it. This avoids widespread casts from IHoldsOptions to ITool.
- private String superClassId;
- // Parent and children
- private IBuildObject parent;
- private Vector inputTypeList;
- private Map inputTypeMap;
- private Vector outputTypeList;
- private Map outputTypeMap;
- private List envVarBuildPathList;
- // Managed Build model attributes
- private String unusedChildren;
- private Boolean isAbstract;
- private String command;
- private List inputExtensions;
- private List interfaceExtensions;
- private Integer natureFilter;
- private String outputExtensions;
- private String outputFlag;
- private String outputPrefix;
- private String errorParserIds;
- private String commandLinePattern;
- private String versionsSupported;
- private String convertToId;
- private Boolean advancedInputCategory;
- private Boolean customBuildStep;
- private String announcement;
- private IConfigurationElement commandLineGeneratorElement = null;
- private IManagedCommandLineGenerator commandLineGenerator = null;
- private IConfigurationElement dependencyGeneratorElement = null;
- private IManagedDependencyGeneratorType dependencyGenerator = null;
- private URL iconPathURL;
- // Miscellaneous
- private boolean isExtensionTool = false;
- private boolean isDirty = false;
- private boolean resolved = resolvedDefault;
- private IConfigurationElement previousMbsVersionConversionElement = null;
- private IConfigurationElement currentMbsVersionConversionElement = null;
-
- /*
- * C O N S T R U C T O R S
- */
-
- /**
- * Constructor to create a tool based on an element from the plugin
- * manifest.
- *
- * @param element The element containing the information about the tool.
- * @param managedBuildRevision the fileVersion of Managed Build System
- */
- public Tool(IManagedConfigElement element, String managedBuildRevision) {
- // setup for resolving
- super(false);
- resolved = false;
-
- isExtensionTool = true;
-
- // Set the managedBuildRevision
- setManagedBuildRevision(managedBuildRevision);
-
- loadFromManifest(element);
-
- // hook me up
- ManagedBuildManager.addExtensionTool(this);
-
- // set up the category map
- addOptionCategory(this);
-
- // Load children
- IManagedConfigElement[] toolElements = element.getChildren();
- for (int l = 0; l < toolElements.length; ++l) {
- IManagedConfigElement toolElement = toolElements[l];
- if (loadChild(toolElement)) {
- // do nothing
- } else if (toolElement.getName().equals(ITool.INPUT_TYPE)) {
- InputType inputType = new InputType(this, toolElement);
- addInputType(inputType);
- } else if (toolElement.getName().equals(ITool.OUTPUT_TYPE)) {
- OutputType outputType = new OutputType(this, toolElement);
- addOutputType(outputType);
- } else if (toolElement.getName().equals(IEnvVarBuildPath.BUILD_PATH_ELEMENT_NAME)){
- addEnvVarBuildPath(new EnvVarBuildPath(this,toolElement));
- }
- }
- }
-
- /**
- * Constructor to create a new tool for a tool-chain based on the information
- * defined in the plugin.xml manifest.
- *
- * @param parent The parent of this tool. This can be a ToolChain or a
- * ResourceConfiguration.
- * @param element The element containing the information about the tool.
- * @param managedBuildRevision the fileVersion of Managed Build System
- */
- public Tool(IBuildObject parent, IManagedConfigElement element, String managedBuildRevision) {
- this(element, managedBuildRevision);
- this.parent = parent;
- }
-
- /**
- * This constructor is called to create a Tool whose attributes and children will be
- * added by separate calls.
- *
- * @param ToolChain The parent of the tool, if any
- * @param Tool The superClass, if any
- * @param String The id for the new tool
- * @param String The name for the new tool
- * @param boolean Indicates whether this is an extension element or a managed project element
- */
- public Tool(ToolChain parent, ITool superClass, String Id, String name, boolean isExtensionElement) {
- super(resolvedDefault);
- this.parent = parent;
- setSuperClassInternal(superClass);
- setManagedBuildRevision(parent.getManagedBuildRevision());
- if (getSuperClass() != null) {
- superClassId = getSuperClass().getId();
- }
-
- setId(Id);
- setName(name);
- setVersion(getVersionFromId());
-
- isExtensionTool = isExtensionElement;
- if (isExtensionElement) {
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionTool(this);
- } else {
- setDirty(true);
- }
- }
-
- /**
- * This constructor is called to create a Tool whose attributes and children will be
- * added by separate calls.
- *
- * @param ResourceConfiguration, The parent of the tool, if any
- * @param Tool The superClass, if any
- * @param String The id for the new tool
- * @param String The name for the new tool
- * @param boolean Indicates whether this is an extension element or a managed project element
- */
-
- public Tool(ResourceConfiguration parent, ITool superClass, String Id, String name, boolean isExtensionElement) {
- super(resolvedDefault);
- this.parent = parent;
- setSuperClassInternal( superClass );
- setManagedBuildRevision(parent.getManagedBuildRevision());
- if (getSuperClass() != null) {
- superClassId = getSuperClass().getId();
- }
- setId(Id);
- setName(name);
- setVersion(getVersionFromId());
-
- isExtensionTool = isExtensionElement;
- if (isExtensionElement) {
- // Hook me up to the Managed Build Manager
- ManagedBuildManager.addExtensionTool(this);
- } else {
- setDirty(true);
- }
- }
-
- /**
- * Create a Tool
based on the specification stored in the
- * project file (.cdtbuild).
- *
- * @param parent The IToolChain
or IResourceConfiguration
- * the tool will be added to.
- * @param element The XML element that contains the tool settings.
- * @param managedBuildRevision the fileVersion of Managed Build System
- */
- public Tool(IBuildObject parent, Element element, String managedBuildRevision) {
- super(resolvedDefault);
- this.parent = parent;
- isExtensionTool = false;
-
- // Set the managedBuildRevsion
- setManagedBuildRevision(managedBuildRevision);
-
- // Initialize from the XML attributes
- loadFromProject(element);
-
- // set up the category map
- addOptionCategory(this);
-
- // Load children
- NodeList toolElements = element.getChildNodes();
- for (int i = 0; i < toolElements.getLength(); ++i) {
- Node toolElement = toolElements.item(i);
- if (loadChild(toolElement)) {
- // do nothing
- } else if (toolElement.getNodeName().equals(ITool.INPUT_TYPE)) {
- InputType inputType = new InputType(this, (Element)toolElement);
- addInputType(inputType);
- } else if (toolElement.getNodeName().equals(ITool.OUTPUT_TYPE)) {
- OutputType outputType = new OutputType(this, (Element)toolElement);
- addOutputType(outputType);
- }
- }
- }
-
- /**
- * Create a Tool
based upon an existing tool.
- *
- * @param parent The IToolChain
or IResourceConfiguration
- * the tool will be added to.
- * @param tool The existing tool to clone.
- */
- public Tool(IBuildObject parent, ITool toolSuperClass, String Id, String name, Tool tool){
- super(resolvedDefault);
- this.parent = parent;
- if (toolSuperClass != null) {
- setSuperClassInternal( toolSuperClass );
- } else {
- setSuperClassInternal( tool.getSuperClass() );
- }
- if (getSuperClass() != null) {
- superClassId = getSuperClass().getId();
- }
- setId(Id);
- setName(name);
-
- // Set the managedBuildRevision & the version
- setManagedBuildRevision(tool.getManagedBuildRevision());
- setVersion(getVersionFromId());
-
- isExtensionTool = false;
-
- // Copy the remaining attributes
- if(tool.versionsSupported != null) {
- versionsSupported = new String(tool.versionsSupported);
- }
- if(tool.convertToId != null) {
- convertToId = new String(tool.convertToId);
- }
- if (tool.unusedChildren != null) {
- unusedChildren = new String(tool.unusedChildren);
- }
- if (tool.errorParserIds != null) {
- errorParserIds = new String(tool.errorParserIds);
- }
- if (tool.isAbstract != null) {
- isAbstract = new Boolean(tool.isAbstract.booleanValue());
- }
- if (tool.command != null) {
- command = new String(tool.command);
- }
- if (tool.commandLinePattern != null) {
- commandLinePattern = new String(tool.commandLinePattern);
- }
- if (tool.inputExtensions != null) {
- inputExtensions = new ArrayList(tool.inputExtensions);
- }
- if (tool.interfaceExtensions != null) {
- interfaceExtensions = new ArrayList(tool.interfaceExtensions);
- }
- if (tool.natureFilter != null) {
- natureFilter = new Integer(tool.natureFilter.intValue());
- }
- if (tool.outputExtensions != null) {
- outputExtensions = new String(tool.outputExtensions);
- }
- if (tool.outputFlag != null) {
- outputFlag = new String(tool.outputFlag);
- }
- if (tool.outputPrefix != null) {
- outputPrefix = new String(tool.outputPrefix);
- }
- if (tool.advancedInputCategory != null) {
- advancedInputCategory = new Boolean(tool.advancedInputCategory.booleanValue());
- }
- if (tool.customBuildStep != null) {
- customBuildStep = new Boolean(tool.customBuildStep.booleanValue());
- }
- if (tool.announcement != null) {
- announcement = new String(tool.announcement);
- }
-
- commandLineGeneratorElement = tool.commandLineGeneratorElement;
- commandLineGenerator = tool.commandLineGenerator;
- dependencyGeneratorElement = tool.dependencyGeneratorElement;
- dependencyGenerator = tool.dependencyGenerator;
-
- if(tool.envVarBuildPathList != null)
- envVarBuildPathList = new ArrayList(tool.envVarBuildPathList);
-
- // Clone the children in superclass
- super.copyChildren(tool);
- // Clone the children
- if (tool.inputTypeList != null) {
- Iterator iter = tool.getInputTypeList().listIterator();
- while (iter.hasNext()) {
- InputType inputType = (InputType) iter.next();
- int nnn = ManagedBuildManager.getRandomNumber();
- String subId;
- String subName;
- if (inputType.getSuperClass() != null) {
- subId = inputType.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
- subName = inputType.getSuperClass().getName();
- } else {
- subId = inputType.getId() + "." + nnn; //$NON-NLS-1$
- subName = inputType.getName();
- }
- InputType newInputType = new InputType(this, subId, subName, inputType);
- addInputType(newInputType);
- }
- }
- if (tool.outputTypeList != null) {
- Iterator iter = tool.getOutputTypeList().listIterator();
- while (iter.hasNext()) {
- OutputType outputType = (OutputType) iter.next();
- int nnn = ManagedBuildManager.getRandomNumber();
- String subId;
- String subName;
- if (outputType.getSuperClass() != null) {
- subId = outputType.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
- subName = outputType.getSuperClass().getName();
- } else {
- subId = outputType.getId() + "." + nnn; //$NON-NLS-1$
- subName = outputType.getName();
- }
- OutputType newOutputType = new OutputType(this, subId, subName, outputType);
- addOutputType(newOutputType);
- }
- }
-
- // icon
- if ( tool.iconPathURL != null ) {
- iconPathURL = tool.iconPathURL;
- }
-
- setDirty(true);
- }
-
- /*
- * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
- */
-
- /* (non-Javadoc)
- * Load the tool information from the XML element specified in the
- * argument
- * @param element An XML element containing the tool information
- */
- protected void loadFromManifest(IManagedConfigElement element) {
- // setup for resolving
- ManagedBuildManager.putConfigElement(this, element);
-
- // id
- setId(element.getAttribute(ITool.ID));
-
- // name
- setName(element.getAttribute(ITool.NAME));
-
- // version
- setVersion(getVersionFromId());
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
-
- // Get the unused children, if any
- unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
-
- // Get the 'versionsSupported' attribute
- versionsSupported =element.getAttribute(VERSIONS_SUPPORTED);
-
- // Get the 'convertToId' attribute
- convertToId = element.getAttribute(CONVERT_TO_ID);
-
- // isAbstract
- String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
- if (isAbs != null){
- isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
- }
-
- // Get the semicolon separated list of IDs of the error parsers
- errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
-
- // Get the nature filter
- String nature = element.getAttribute(NATURE);
- if (nature != null) {
- if ("both".equals(nature)) { //$NON-NLS-1$
- natureFilter = new Integer(FILTER_BOTH);
- } else if ("cnature".equals(nature)) { //$NON-NLS-1$
- natureFilter = new Integer(FILTER_C);
- } else if ("ccnature".equals(nature)) { //$NON-NLS-1$
- natureFilter = new Integer(FILTER_CC);
- } else {
- natureFilter = new Integer(FILTER_BOTH);
- }
- }
-
- // Get the supported input file extensions
- String inputs = element.getAttribute(ITool.SOURCES);
- if (inputs != null) {
- StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
- }
- }
-
- // Get the interface (header file) extensions
- String headers = element.getAttribute(INTERFACE_EXTS);
- if (headers != null) {
- StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInterfaceExtensionsList().add(tokenizer.nextElement());
- }
- }
-
- // Get the output extension
- outputExtensions = element.getAttribute(ITool.OUTPUTS);
-
- // Get the tool invocation command
- command = element.getAttribute(ITool.COMMAND);
-
- // Get the flag to control output
- outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
-
- // Get the output prefix
- outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
-
- // Get command line pattern
- commandLinePattern = element.getAttribute( ITool.COMMAND_LINE_PATTERN );
-
- // Get advancedInputCategory
- String advInput = element.getAttribute(ITool.ADVANCED_INPUT_CATEGORY);
- if (advInput != null){
- advancedInputCategory = new Boolean("true".equals(advInput)); //$NON-NLS-1$
- }
-
- // Get customBuildStep
- String cbs = element.getAttribute(ITool.CUSTOM_BUILD_STEP);
- if (cbs != null){
- customBuildStep = new Boolean("true".equals(cbs)); //$NON-NLS-1$
- }
-
- // Get the announcement text
- announcement = element.getAttribute(ITool.ANNOUNCEMENT);
-
- // Store the configuration element IFF there is a command line generator defined
- String commandLineGenerator = element.getAttribute(COMMAND_LINE_GENERATOR);
- if (commandLineGenerator != null && element instanceof DefaultManagedConfigElement) {
- commandLineGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- }
-
- // Store the configuration element IFF there is a dependency generator defined
- String depGenerator = element.getAttribute(DEP_CALC_ID);
- if (depGenerator != null && element instanceof DefaultManagedConfigElement) {
- dependencyGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- }
-
- // icon
- if ( element.getAttribute(IOptionCategory.ICON) != null && element instanceof DefaultManagedConfigElement)
- {
- String icon = element.getAttribute(IOptionCategory.ICON);
- iconPathURL = ManagedBuildManager.getURLInBuildDefinitions( (DefaultManagedConfigElement)element, new Path(icon) );
- }
- }
-
- /* (non-Javadoc)
- * Initialize the tool information from the XML element
- * specified in the argument
- *
- * @param element An XML element containing the tool information
- */
- protected void loadFromProject(Element element) {
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // name
- if (element.hasAttribute(IBuildObject.NAME)) {
- setName(element.getAttribute(IBuildObject.NAME));
- }
-
- // version
- setVersion(getVersionFromId());
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
- if (superClassId != null && superClassId.length() > 0) {
- if( getParent() instanceof IResourceConfiguration ) {
- IResourceConfiguration resConfig = (IResourceConfiguration) getParent();
- setSuperClassInternal( resConfig.getParent().getTool(superClassId) );
- } else {
- setSuperClassInternal( ManagedBuildManager.getExtensionTool(superClassId) );
- }
-
- // Check for migration support
- checkForMigrationSupport();
-
- }
-
- // Get the unused children, if any
- if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
- unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
- }
-
- // isAbstract
- if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
- String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
- if (isAbs != null){
- isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
- }
- }
-
- // Get the 'versionSupported' attribute
- if (element.hasAttribute(VERSIONS_SUPPORTED)) {
- versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
- }
-
- // Get the 'convertToId' id
- if (element.hasAttribute(CONVERT_TO_ID)) {
- convertToId = element.getAttribute(CONVERT_TO_ID);
- }
-
- // Get the semicolon separated list of IDs of the error parsers
- if (element.hasAttribute(IToolChain.ERROR_PARSERS)) {
- errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
- }
-
- // Get the nature filter
- if (element.hasAttribute(NATURE)) {
- String nature = element.getAttribute(NATURE);
- if (nature != null) {
- if ("both".equals(nature)) { //$NON-NLS-1$
- natureFilter = new Integer(FILTER_BOTH);
- } else if ("cnature".equals(nature)) { //$NON-NLS-1$
- natureFilter = new Integer(FILTER_C);
- } else if ("ccnature".equals(nature)) { //$NON-NLS-1$
- natureFilter = new Integer(FILTER_CC);
- } else {
- natureFilter = new Integer(FILTER_BOTH);
- }
- }
- }
-
- // Get the supported input file extension
- if (element.hasAttribute(ITool.SOURCES)) {
- String inputs = element.getAttribute(ITool.SOURCES);
- if (inputs != null) {
- StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInputExtensionsList().add(tokenizer.nextElement());
- }
- }
- }
-
- // Get the interface (header file) extensions
- if (element.hasAttribute(INTERFACE_EXTS)) {
- String headers = element.getAttribute(INTERFACE_EXTS);
- if (headers != null) {
- StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
- while (tokenizer.hasMoreElements()) {
- getInterfaceExtensionsList().add(tokenizer.nextElement());
- }
- }
- }
-
- // Get the output extension
- if (element.hasAttribute(ITool.OUTPUTS)) {
- outputExtensions = element.getAttribute(ITool.OUTPUTS);
- }
-
- // Get the tool invocation command
- if (element.hasAttribute(ITool.COMMAND)) {
- command = element.getAttribute(ITool.COMMAND);
- }
-
- // Get the flag to control output
- if (element.hasAttribute(ITool.OUTPUT_FLAG)) {
- outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
- }
-
- // Get the output prefix
- if (element.hasAttribute(ITool.OUTPUT_PREFIX)) {
- outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
- }
-
- // Get command line pattern
- if( element.hasAttribute( ITool.COMMAND_LINE_PATTERN ) ) {
- commandLinePattern = element.getAttribute( ITool.COMMAND_LINE_PATTERN );
- }
-
- // advancedInputCategory
- if (element.hasAttribute(ITool.ADVANCED_INPUT_CATEGORY)) {
- String advInput = element.getAttribute(ITool.ADVANCED_INPUT_CATEGORY);
- if (advInput != null){
- advancedInputCategory = new Boolean("true".equals(advInput)); //$NON-NLS-1$
- }
- }
-
- // customBuildStep
- if (element.hasAttribute(ITool.CUSTOM_BUILD_STEP)) {
- String cbs = element.getAttribute(ITool.CUSTOM_BUILD_STEP);
- if (cbs != null){
- customBuildStep = new Boolean("true".equals(cbs)); //$NON-NLS-1$
- }
- }
-
- // Get the announcement text
- if (element.hasAttribute(ITool.ANNOUNCEMENT)) {
- announcement = element.getAttribute(ITool.ANNOUNCEMENT);
- }
-
- // icon - was saved as URL in string form
- if (element.hasAttribute(IOptionCategory.ICON)) {
- String iconPath = element.getAttribute(IOptionCategory.ICON);
- try {
- iconPathURL = new URL(iconPath);
- } catch (MalformedURLException e) {
- // Print a warning
- ManagedBuildManager.OutputIconError(iconPath);
- iconPathURL = null;
- }
- }
- }
-
- /**
- * Persist the tool to the project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- try {
- if (getSuperClass() != null)
- element.setAttribute(IProjectType.SUPERCLASS, getSuperClass().getId());
-
- // id
- element.setAttribute(IBuildObject.ID, id);
-
- // name
- if (name != null) {
- element.setAttribute(IBuildObject.NAME, name);
- }
-
- // unused children
- if (unusedChildren != null) {
- element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
- }
-
- // isAbstract
- if (isAbstract != null) {
- element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
- }
-
- // versionsSupported
- if (versionsSupported != null) {
- element.setAttribute(VERSIONS_SUPPORTED, versionsSupported);
- }
-
- // convertToId
- if (convertToId != null) {
- element.setAttribute(CONVERT_TO_ID, convertToId);
- }
-
- // error parsers
- if (errorParserIds != null) {
- element.setAttribute(IToolChain.ERROR_PARSERS, errorParserIds);
- }
-
- // nature filter
- if (natureFilter != null) {
- String nature;
- if (natureFilter.intValue() == FILTER_C) {
- nature = "cnature"; //$NON-NLS-1$
- } else if (natureFilter.intValue() == FILTER_CC) {
- nature = "ccnature"; //$NON-NLS-1$
- } else {
- nature = "both"; //$NON-NLS-1$
- }
- element.setAttribute(NATURE, nature);
- }
-
- // input file extensions
- if (getInputExtensionsList().size() > 0) {
- String inputs;
- List list = getInputExtensionsList();
- Iterator iter = list.listIterator();
- inputs = (String)iter.next();
- while (iter.hasNext()) {
- inputs += DEFAULT_SEPARATOR;
- inputs += iter.next();
- }
- element.setAttribute(ITool.SOURCES, inputs);
- }
-
- // interface (header file) extensions
- if (getInterfaceExtensionsList().size() > 0) {
- String headers;
- List list = getInterfaceExtensionsList();
- Iterator iter = list.listIterator();
- headers = (String)iter.next();
- while (iter.hasNext()) {
- headers += DEFAULT_SEPARATOR;
- headers += iter.next();
- }
- element.setAttribute(INTERFACE_EXTS, headers);
- }
-
- // output extension
- if (outputExtensions != null) {
- element.setAttribute(ITool.OUTPUTS, outputExtensions);
- }
-
- // command
- if (command != null) {
- element.setAttribute(ITool.COMMAND, command);
- }
-
- // flag to control output
- if (outputFlag != null) {
- element.setAttribute(ITool.OUTPUT_FLAG, outputFlag);
- }
-
- // output prefix
- if (outputPrefix != null) {
- element.setAttribute(ITool.OUTPUT_PREFIX, outputPrefix);
- }
-
- // command line pattern
- if (commandLinePattern != null) {
- element.setAttribute(ITool.COMMAND_LINE_PATTERN, commandLinePattern);
- }
-
- // advancedInputCategory
- if (advancedInputCategory != null) {
- element.setAttribute(ITool.ADVANCED_INPUT_CATEGORY, advancedInputCategory.toString());
- }
-
- // customBuildStep
- if (customBuildStep != null) {
- element.setAttribute(ITool.CUSTOM_BUILD_STEP, customBuildStep.toString());
- }
-
- // announcement text
- if (announcement != null) {
- element.setAttribute(ITool.ANNOUNCEMENT, announcement);
- }
-
- // Serialize elements from my super class
- super.serialize(doc, element);
-
- // Serialize my children
- Iterator iter;
- List typeElements = getInputTypeList();
- iter = typeElements.listIterator();
- while (iter.hasNext()) {
- InputType type = (InputType) iter.next();
- Element typeElement = doc.createElement(INPUT_TYPE);
- element.appendChild(typeElement);
- type.serialize(doc, typeElement);
- }
- typeElements = getOutputTypeList();
- iter = typeElements.listIterator();
- while (iter.hasNext()) {
- OutputType type = (OutputType) iter.next();
- Element typeElement = doc.createElement(OUTPUT_TYPE);
- element.appendChild(typeElement);
- type.serialize(doc, typeElement);
- }
-
- // Note: command line generator cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (commandLineGeneratorElement != null) {
- // TODO: issue warning?
- }
-
- // Note: dependency generator cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (dependencyGeneratorElement != null) {
- // TODO: issue warning?
- }
-
- if (iconPathURL != null) {
- // Save as URL in string form
- element.setAttribute(IOptionCategory.ICON, iconPathURL.toString());
- }
-
- // I am clean now
- isDirty = false;
- } catch (Exception e) {
- // TODO: issue an error message
- }
- }
-
- /*
- * P A R E N T A N D C H I L D H A N D L I N G
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getParent()
- */
- public IBuildObject getParent() {
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#setParent(IBuildObject)
- */
- public void setToolParent(IBuildObject newParent) {
- this.parent = newParent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getTopOptionCategory()
- */
- public IOptionCategory getTopOptionCategory() {
- return this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#createInputType(IInputType, String, String, boolean)
- */
- public IInputType createInputType(IInputType superClass, String Id, String name, boolean isExtensionElement) {
- InputType type = new InputType(this, superClass, Id, name, isExtensionElement);
- addInputType(type);
- setDirty(true);
- return type;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#removeInputType(IInputType)
- */
- public void removeInputType(IInputType type) {
- getInputTypeList().remove(type);
- getInputTypeMap().remove(type.getId());
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getInputTypes()
- */
- public IInputType[] getInputTypes() {
- IInputType[] types = null;
- // Merge our input types with our superclass' input types.
- if (getSuperClass() != null) {
- types = getSuperClass().getInputTypes();
- }
- // Our options take precedence.
- Vector ourTypes = getInputTypeList();
- if (types != null) {
- for (int i = 0; i < ourTypes.size(); i++) {
- IInputType ourType = (IInputType)ourTypes.get(i);
- int j;
- for (j = 0; j < types.length; j++) {
- if (ourType.getSuperClass() != null &&
- ourType.getSuperClass().getId().equals(types[j].getId())) {
- types[j] = ourType;
- break;
- }
- }
- // No Match? Add it.
- if (j == types.length) {
- IInputType[] newTypes = new IInputType[types.length + 1];
- for (int k = 0; k < types.length; k++) {
- newTypes[k] = types[k];
- }
- newTypes[j] = ourType;
- types = newTypes;
- }
- }
- } else {
- types = (IInputType[])ourTypes.toArray(new IInputType[ourTypes.size()]);
- }
- return types;
- }
-
- private boolean hasInputTypes() {
- Vector ourTypes = getInputTypeList();
- if (ourTypes.size() > 0) return true;
- return false;
- }
-
- public IInputType getInputTypeById(String id) {
- IInputType type = (IInputType)getInputTypeMap().get(id);
- if (type == null) {
- if (getSuperClass() != null) {
- return getSuperClass().getInputTypeById(id);
- }
- }
- return type;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#createOutputType(IOutputType, String, String, boolean)
- */
- public IOutputType createOutputType(IOutputType superClass, String Id, String name, boolean isExtensionElement) {
- OutputType type = new OutputType(this, superClass, Id, name, isExtensionElement);
- addOutputType(type);
- setDirty(true);
- return type;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#removeOutputType(IOutputType)
- */
- public void removeOutputType(IOutputType type) {
- getOutputTypeList().remove(type);
- getOutputTypeMap().remove(type.getId());
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputTypes()
- */
- public IOutputType[] getOutputTypes() {
- IOutputType[] types = null;
- // Merge our output types with our superclass' output types.
- if (getSuperClass() != null) {
- types = getSuperClass().getOutputTypes();
- }
- // Our options take precedence.
- Vector ourTypes = getOutputTypeList();
- if (types != null) {
- for (int i = 0; i < ourTypes.size(); i++) {
- IOutputType ourType = (IOutputType)ourTypes.get(i);
- int j;
- for (j = 0; j < types.length; j++) {
- if (ourType.getSuperClass() != null &&
- ourType.getSuperClass().getId().equals(types[j].getId())) {
- types[j] = ourType;
- break;
- }
- }
- // No Match? Add it.
- if (j == types.length) {
- IOutputType[] newTypes = new IOutputType[types.length + 1];
- for (int k = 0; k < types.length; k++) {
- newTypes[k] = types[k];
- }
- newTypes[j] = ourType;
- types = newTypes;
- }
- }
- } else {
- types = (IOutputType[])ourTypes.toArray(new IOutputType[ourTypes.size()]);
- }
- return types;
- }
-
- private boolean hasOutputTypes() {
- Vector ourTypes = getOutputTypeList();
- if (ourTypes.size() > 0) return true;
- return false;
- }
-
- public IOutputType getPrimaryOutputType() {
- IOutputType type = null;
- IOutputType[] types = getOutputTypes();
- if (types != null && types.length > 0) {
- for (int i=0; iIToolChain
or IResourceConfiguration
+ * the tool will be added to.
+ * @param element The XML element that contains the tool settings.
+ * @param managedBuildRevision the fileVersion of Managed Build System
+ */
+ public Tool(IBuildObject parent, Element element, String managedBuildRevision) {
+ super(resolvedDefault);
+ this.parent = parent;
+ isExtensionTool = false;
+
+ // Set the managedBuildRevsion
+ setManagedBuildRevision(managedBuildRevision);
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // set up the category map
+ addOptionCategory(this);
+
+ // Load children
+ NodeList toolElements = element.getChildNodes();
+ for (int i = 0; i < toolElements.getLength(); ++i) {
+ Node toolElement = toolElements.item(i);
+ if (loadChild(toolElement)) {
+ // do nothing
+ } else if (toolElement.getNodeName().equals(ITool.INPUT_TYPE)) {
+ InputType inputType = new InputType(this, (Element)toolElement);
+ addInputType(inputType);
+ } else if (toolElement.getNodeName().equals(ITool.OUTPUT_TYPE)) {
+ OutputType outputType = new OutputType(this, (Element)toolElement);
+ addOutputType(outputType);
+ }
+ }
+ }
+
+ /**
+ * Create a Tool
based upon an existing tool.
+ *
+ * @param parent The IToolChain
or IResourceConfiguration
+ * the tool will be added to.
+ * @param tool The existing tool to clone.
+ */
+ public Tool(IBuildObject parent, ITool toolSuperClass, String Id, String name, Tool tool){
+ super(resolvedDefault);
+ this.parent = parent;
+ if (toolSuperClass != null) {
+ setSuperClassInternal( toolSuperClass );
+ } else {
+ setSuperClassInternal( tool.getSuperClass() );
+ }
+ if (getSuperClass() != null) {
+ superClassId = getSuperClass().getId();
+ }
+ setId(Id);
+ setName(name);
+
+ // Set the managedBuildRevision & the version
+ setManagedBuildRevision(tool.getManagedBuildRevision());
+ setVersion(getVersionFromId());
+
+ isExtensionTool = false;
+
+ // Copy the remaining attributes
+ if(tool.versionsSupported != null) {
+ versionsSupported = new String(tool.versionsSupported);
+ }
+ if(tool.convertToId != null) {
+ convertToId = new String(tool.convertToId);
+ }
+ if (tool.unusedChildren != null) {
+ unusedChildren = new String(tool.unusedChildren);
+ }
+ if (tool.errorParserIds != null) {
+ errorParserIds = new String(tool.errorParserIds);
+ }
+ if (tool.isAbstract != null) {
+ isAbstract = new Boolean(tool.isAbstract.booleanValue());
+ }
+ if (tool.command != null) {
+ command = new String(tool.command);
+ }
+ if (tool.commandLinePattern != null) {
+ commandLinePattern = new String(tool.commandLinePattern);
+ }
+ if (tool.inputExtensions != null) {
+ inputExtensions = new ArrayList(tool.inputExtensions);
+ }
+ if (tool.interfaceExtensions != null) {
+ interfaceExtensions = new ArrayList(tool.interfaceExtensions);
+ }
+ if (tool.natureFilter != null) {
+ natureFilter = new Integer(tool.natureFilter.intValue());
+ }
+ if (tool.outputExtensions != null) {
+ outputExtensions = new String(tool.outputExtensions);
+ }
+ if (tool.outputFlag != null) {
+ outputFlag = new String(tool.outputFlag);
+ }
+ if (tool.outputPrefix != null) {
+ outputPrefix = new String(tool.outputPrefix);
+ }
+ if (tool.advancedInputCategory != null) {
+ advancedInputCategory = new Boolean(tool.advancedInputCategory.booleanValue());
+ }
+ if (tool.customBuildStep != null) {
+ customBuildStep = new Boolean(tool.customBuildStep.booleanValue());
+ }
+ if (tool.announcement != null) {
+ announcement = new String(tool.announcement);
+ }
+
+ commandLineGeneratorElement = tool.commandLineGeneratorElement;
+ commandLineGenerator = tool.commandLineGenerator;
+ dependencyGeneratorElement = tool.dependencyGeneratorElement;
+ dependencyGenerator = tool.dependencyGenerator;
+
+ if(tool.envVarBuildPathList != null)
+ envVarBuildPathList = new ArrayList(tool.envVarBuildPathList);
+
+ // Clone the children in superclass
+ super.copyChildren(tool);
+ // Clone the children
+ if (tool.inputTypeList != null) {
+ Iterator iter = tool.getInputTypeList().listIterator();
+ while (iter.hasNext()) {
+ InputType inputType = (InputType) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (inputType.getSuperClass() != null) {
+ subId = inputType.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = inputType.getSuperClass().getName();
+ } else {
+ subId = inputType.getId() + "." + nnn; //$NON-NLS-1$
+ subName = inputType.getName();
+ }
+ InputType newInputType = new InputType(this, subId, subName, inputType);
+ addInputType(newInputType);
+ }
+ }
+ if (tool.outputTypeList != null) {
+ Iterator iter = tool.getOutputTypeList().listIterator();
+ while (iter.hasNext()) {
+ OutputType outputType = (OutputType) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (outputType.getSuperClass() != null) {
+ subId = outputType.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = outputType.getSuperClass().getName();
+ } else {
+ subId = outputType.getId() + "." + nnn; //$NON-NLS-1$
+ subName = outputType.getName();
+ }
+ OutputType newOutputType = new OutputType(this, subId, subName, outputType);
+ addOutputType(newOutputType);
+ }
+ }
+
+ // icon
+ if ( tool.iconPathURL != null ) {
+ iconPathURL = tool.iconPathURL;
+ }
+
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Load the tool information from the XML element specified in the
+ * argument
+ * @param element An XML element containing the tool information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ // setup for resolving
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(ITool.ID));
+
+ // name
+ setName(element.getAttribute(ITool.NAME));
+
+ // version
+ setVersion(getVersionFromId());
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+
+ // Get the 'versionsSupported' attribute
+ versionsSupported =element.getAttribute(VERSIONS_SUPPORTED);
+
+ // Get the 'convertToId' attribute
+ convertToId = element.getAttribute(CONVERT_TO_ID);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
+
+ // Get the nature filter
+ String nature = element.getAttribute(NATURE);
+ if (nature != null) {
+ if ("both".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_BOTH);
+ } else if ("cnature".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_C);
+ } else if ("ccnature".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_CC);
+ } else {
+ natureFilter = new Integer(FILTER_BOTH);
+ }
+ }
+
+ // Get the supported input file extensions
+ String inputs = element.getAttribute(ITool.SOURCES);
+ if (inputs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+
+ // Get the interface (header file) extensions
+ String headers = element.getAttribute(INTERFACE_EXTS);
+ if (headers != null) {
+ StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInterfaceExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+
+ // Get the output extension
+ outputExtensions = element.getAttribute(ITool.OUTPUTS);
+
+ // Get the tool invocation command
+ command = element.getAttribute(ITool.COMMAND);
+
+ // Get the flag to control output
+ outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
+
+ // Get the output prefix
+ outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
+
+ // Get command line pattern
+ commandLinePattern = element.getAttribute( ITool.COMMAND_LINE_PATTERN );
+
+ // Get advancedInputCategory
+ String advInput = element.getAttribute(ITool.ADVANCED_INPUT_CATEGORY);
+ if (advInput != null){
+ advancedInputCategory = new Boolean("true".equals(advInput)); //$NON-NLS-1$
+ }
+
+ // Get customBuildStep
+ String cbs = element.getAttribute(ITool.CUSTOM_BUILD_STEP);
+ if (cbs != null){
+ customBuildStep = new Boolean("true".equals(cbs)); //$NON-NLS-1$
+ }
+
+ // Get the announcement text
+ announcement = element.getAttribute(ITool.ANNOUNCEMENT);
+
+ // Store the configuration element IFF there is a command line generator defined
+ String commandLineGenerator = element.getAttribute(COMMAND_LINE_GENERATOR);
+ if (commandLineGenerator != null && element instanceof DefaultManagedConfigElement) {
+ commandLineGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+
+ // Store the configuration element IFF there is a dependency generator defined
+ String depGenerator = element.getAttribute(DEP_CALC_ID);
+ if (depGenerator != null && element instanceof DefaultManagedConfigElement) {
+ dependencyGeneratorElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+
+ // icon
+ if ( element.getAttribute(IOptionCategory.ICON) != null && element instanceof DefaultManagedConfigElement)
+ {
+ String icon = element.getAttribute(IOptionCategory.ICON);
+ iconPathURL = ManagedBuildManager.getURLInBuildDefinitions( (DefaultManagedConfigElement)element, new Path(icon) );
+ }
+ }
+
+ /* (non-Javadoc)
+ * Initialize the tool information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the tool information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // version
+ setVersion(getVersionFromId());
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ if( getParent() instanceof IResourceConfiguration ) {
+ IResourceConfiguration resConfig = (IResourceConfiguration) getParent();
+ setSuperClassInternal( resConfig.getParent().getTool(superClassId) );
+ } else {
+ setSuperClassInternal( ManagedBuildManager.getExtensionTool(superClassId) );
+ }
+
+ // Check for migration support
+ checkForMigrationSupport();
+
+ }
+
+ // Get the unused children, if any
+ if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+ }
+
+ // isAbstract
+ if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+ }
+
+ // Get the 'versionSupported' attribute
+ if (element.hasAttribute(VERSIONS_SUPPORTED)) {
+ versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
+ }
+
+ // Get the 'convertToId' id
+ if (element.hasAttribute(CONVERT_TO_ID)) {
+ convertToId = element.getAttribute(CONVERT_TO_ID);
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ if (element.hasAttribute(IToolChain.ERROR_PARSERS)) {
+ errorParserIds = element.getAttribute(IToolChain.ERROR_PARSERS);
+ }
+
+ // Get the nature filter
+ if (element.hasAttribute(NATURE)) {
+ String nature = element.getAttribute(NATURE);
+ if (nature != null) {
+ if ("both".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_BOTH);
+ } else if ("cnature".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_C);
+ } else if ("ccnature".equals(nature)) { //$NON-NLS-1$
+ natureFilter = new Integer(FILTER_CC);
+ } else {
+ natureFilter = new Integer(FILTER_BOTH);
+ }
+ }
+ }
+
+ // Get the supported input file extension
+ if (element.hasAttribute(ITool.SOURCES)) {
+ String inputs = element.getAttribute(ITool.SOURCES);
+ if (inputs != null) {
+ StringTokenizer tokenizer = new StringTokenizer(inputs, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInputExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ }
+
+ // Get the interface (header file) extensions
+ if (element.hasAttribute(INTERFACE_EXTS)) {
+ String headers = element.getAttribute(INTERFACE_EXTS);
+ if (headers != null) {
+ StringTokenizer tokenizer = new StringTokenizer(headers, DEFAULT_SEPARATOR);
+ while (tokenizer.hasMoreElements()) {
+ getInterfaceExtensionsList().add(tokenizer.nextElement());
+ }
+ }
+ }
+
+ // Get the output extension
+ if (element.hasAttribute(ITool.OUTPUTS)) {
+ outputExtensions = element.getAttribute(ITool.OUTPUTS);
+ }
+
+ // Get the tool invocation command
+ if (element.hasAttribute(ITool.COMMAND)) {
+ command = element.getAttribute(ITool.COMMAND);
+ }
+
+ // Get the flag to control output
+ if (element.hasAttribute(ITool.OUTPUT_FLAG)) {
+ outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
+ }
+
+ // Get the output prefix
+ if (element.hasAttribute(ITool.OUTPUT_PREFIX)) {
+ outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
+ }
+
+ // Get command line pattern
+ if( element.hasAttribute( ITool.COMMAND_LINE_PATTERN ) ) {
+ commandLinePattern = element.getAttribute( ITool.COMMAND_LINE_PATTERN );
+ }
+
+ // advancedInputCategory
+ if (element.hasAttribute(ITool.ADVANCED_INPUT_CATEGORY)) {
+ String advInput = element.getAttribute(ITool.ADVANCED_INPUT_CATEGORY);
+ if (advInput != null){
+ advancedInputCategory = new Boolean("true".equals(advInput)); //$NON-NLS-1$
+ }
+ }
+
+ // customBuildStep
+ if (element.hasAttribute(ITool.CUSTOM_BUILD_STEP)) {
+ String cbs = element.getAttribute(ITool.CUSTOM_BUILD_STEP);
+ if (cbs != null){
+ customBuildStep = new Boolean("true".equals(cbs)); //$NON-NLS-1$
+ }
+ }
+
+ // Get the announcement text
+ if (element.hasAttribute(ITool.ANNOUNCEMENT)) {
+ announcement = element.getAttribute(ITool.ANNOUNCEMENT);
+ }
+
+ // icon - was saved as URL in string form
+ if (element.hasAttribute(IOptionCategory.ICON)) {
+ String iconPath = element.getAttribute(IOptionCategory.ICON);
+ try {
+ iconPathURL = new URL(iconPath);
+ } catch (MalformedURLException e) {
+ // Print a warning
+ ManagedBuildManager.OutputIconError(iconPath);
+ iconPathURL = null;
+ }
+ }
+ }
+
+ /**
+ * Persist the tool to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ try {
+ if (getSuperClass() != null)
+ element.setAttribute(IProjectType.SUPERCLASS, getSuperClass().getId());
+
+ // id
+ element.setAttribute(IBuildObject.ID, id);
+
+ // name
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ // unused children
+ if (unusedChildren != null) {
+ element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
+ }
+
+ // isAbstract
+ if (isAbstract != null) {
+ element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
+ }
+
+ // versionsSupported
+ if (versionsSupported != null) {
+ element.setAttribute(VERSIONS_SUPPORTED, versionsSupported);
+ }
+
+ // convertToId
+ if (convertToId != null) {
+ element.setAttribute(CONVERT_TO_ID, convertToId);
+ }
+
+ // error parsers
+ if (errorParserIds != null) {
+ element.setAttribute(IToolChain.ERROR_PARSERS, errorParserIds);
+ }
+
+ // nature filter
+ if (natureFilter != null) {
+ String nature;
+ if (natureFilter.intValue() == FILTER_C) {
+ nature = "cnature"; //$NON-NLS-1$
+ } else if (natureFilter.intValue() == FILTER_CC) {
+ nature = "ccnature"; //$NON-NLS-1$
+ } else {
+ nature = "both"; //$NON-NLS-1$
+ }
+ element.setAttribute(NATURE, nature);
+ }
+
+ // input file extensions
+ if (getInputExtensionsList().size() > 0) {
+ String inputs;
+ List list = getInputExtensionsList();
+ Iterator iter = list.listIterator();
+ inputs = (String)iter.next();
+ while (iter.hasNext()) {
+ inputs += DEFAULT_SEPARATOR;
+ inputs += iter.next();
+ }
+ element.setAttribute(ITool.SOURCES, inputs);
+ }
+
+ // interface (header file) extensions
+ if (getInterfaceExtensionsList().size() > 0) {
+ String headers;
+ List list = getInterfaceExtensionsList();
+ Iterator iter = list.listIterator();
+ headers = (String)iter.next();
+ while (iter.hasNext()) {
+ headers += DEFAULT_SEPARATOR;
+ headers += iter.next();
+ }
+ element.setAttribute(INTERFACE_EXTS, headers);
+ }
+
+ // output extension
+ if (outputExtensions != null) {
+ element.setAttribute(ITool.OUTPUTS, outputExtensions);
+ }
+
+ // command
+ if (command != null) {
+ element.setAttribute(ITool.COMMAND, command);
+ }
+
+ // flag to control output
+ if (outputFlag != null) {
+ element.setAttribute(ITool.OUTPUT_FLAG, outputFlag);
+ }
+
+ // output prefix
+ if (outputPrefix != null) {
+ element.setAttribute(ITool.OUTPUT_PREFIX, outputPrefix);
+ }
+
+ // command line pattern
+ if (commandLinePattern != null) {
+ element.setAttribute(ITool.COMMAND_LINE_PATTERN, commandLinePattern);
+ }
+
+ // advancedInputCategory
+ if (advancedInputCategory != null) {
+ element.setAttribute(ITool.ADVANCED_INPUT_CATEGORY, advancedInputCategory.toString());
+ }
+
+ // customBuildStep
+ if (customBuildStep != null) {
+ element.setAttribute(ITool.CUSTOM_BUILD_STEP, customBuildStep.toString());
+ }
+
+ // announcement text
+ if (announcement != null) {
+ element.setAttribute(ITool.ANNOUNCEMENT, announcement);
+ }
+
+ // Serialize elements from my super class
+ super.serialize(doc, element);
+
+ // Serialize my children
+ Iterator iter;
+ List typeElements = getInputTypeList();
+ iter = typeElements.listIterator();
+ while (iter.hasNext()) {
+ InputType type = (InputType) iter.next();
+ Element typeElement = doc.createElement(INPUT_TYPE);
+ element.appendChild(typeElement);
+ type.serialize(doc, typeElement);
+ }
+ typeElements = getOutputTypeList();
+ iter = typeElements.listIterator();
+ while (iter.hasNext()) {
+ OutputType type = (OutputType) iter.next();
+ Element typeElement = doc.createElement(OUTPUT_TYPE);
+ element.appendChild(typeElement);
+ type.serialize(doc, typeElement);
+ }
+
+ // Note: command line generator cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (commandLineGeneratorElement != null) {
+ // TODO: issue warning?
+ }
+
+ // Note: dependency generator cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (dependencyGeneratorElement != null) {
+ // TODO: issue warning?
+ }
+
+ if (iconPathURL != null) {
+ // Save as URL in string form
+ element.setAttribute(IOptionCategory.ICON, iconPathURL.toString());
+ }
+
+ // I am clean now
+ isDirty = false;
+ } catch (Exception e) {
+ // TODO: issue an error message
+ }
+ }
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getParent()
+ */
+ public IBuildObject getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setParent(IBuildObject)
+ */
+ public void setToolParent(IBuildObject newParent) {
+ this.parent = newParent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getTopOptionCategory()
+ */
+ public IOptionCategory getTopOptionCategory() {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#createInputType(IInputType, String, String, boolean)
+ */
+ public IInputType createInputType(IInputType superClass, String Id, String name, boolean isExtensionElement) {
+ InputType type = new InputType(this, superClass, Id, name, isExtensionElement);
+ addInputType(type);
+ setDirty(true);
+ return type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#removeInputType(IInputType)
+ */
+ public void removeInputType(IInputType type) {
+ getInputTypeList().remove(type);
+ getInputTypeMap().remove(type.getId());
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getInputTypes()
+ */
+ public IInputType[] getInputTypes() {
+ IInputType[] types = null;
+ // Merge our input types with our superclass' input types.
+ if (getSuperClass() != null) {
+ types = getSuperClass().getInputTypes();
+ }
+ // Our options take precedence.
+ Vector ourTypes = getInputTypeList();
+ if (types != null) {
+ for (int i = 0; i < ourTypes.size(); i++) {
+ IInputType ourType = (IInputType)ourTypes.get(i);
+ int j;
+ for (j = 0; j < types.length; j++) {
+ if (ourType.getSuperClass() != null &&
+ ourType.getSuperClass().getId().equals(types[j].getId())) {
+ types[j] = ourType;
+ break;
+ }
+ }
+ // No Match? Add it.
+ if (j == types.length) {
+ IInputType[] newTypes = new IInputType[types.length + 1];
+ for (int k = 0; k < types.length; k++) {
+ newTypes[k] = types[k];
+ }
+ newTypes[j] = ourType;
+ types = newTypes;
+ }
+ }
+ } else {
+ types = (IInputType[])ourTypes.toArray(new IInputType[ourTypes.size()]);
+ }
+ return types;
+ }
+
+ private boolean hasInputTypes() {
+ Vector ourTypes = getInputTypeList();
+ if (ourTypes.size() > 0) return true;
+ return false;
+ }
+
+ public IInputType getInputTypeById(String id) {
+ IInputType type = (IInputType)getInputTypeMap().get(id);
+ if (type == null) {
+ if (getSuperClass() != null) {
+ return getSuperClass().getInputTypeById(id);
+ }
+ }
+ return type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#createOutputType(IOutputType, String, String, boolean)
+ */
+ public IOutputType createOutputType(IOutputType superClass, String Id, String name, boolean isExtensionElement) {
+ OutputType type = new OutputType(this, superClass, Id, name, isExtensionElement);
+ addOutputType(type);
+ setDirty(true);
+ return type;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#removeOutputType(IOutputType)
+ */
+ public void removeOutputType(IOutputType type) {
+ getOutputTypeList().remove(type);
+ getOutputTypeMap().remove(type.getId());
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputTypes()
+ */
+ public IOutputType[] getOutputTypes() {
+ IOutputType[] types = null;
+ // Merge our output types with our superclass' output types.
+ if (getSuperClass() != null) {
+ types = getSuperClass().getOutputTypes();
+ }
+ // Our options take precedence.
+ Vector ourTypes = getOutputTypeList();
+ if (types != null) {
+ for (int i = 0; i < ourTypes.size(); i++) {
+ IOutputType ourType = (IOutputType)ourTypes.get(i);
+ int j;
+ for (j = 0; j < types.length; j++) {
+ if (ourType.getSuperClass() != null &&
+ ourType.getSuperClass().getId().equals(types[j].getId())) {
+ types[j] = ourType;
+ break;
+ }
+ }
+ // No Match? Add it.
+ if (j == types.length) {
+ IOutputType[] newTypes = new IOutputType[types.length + 1];
+ for (int k = 0; k < types.length; k++) {
+ newTypes[k] = types[k];
+ }
+ newTypes[j] = ourType;
+ types = newTypes;
+ }
+ }
+ } else {
+ types = (IOutputType[])ourTypes.toArray(new IOutputType[ourTypes.size()]);
+ }
+ return types;
+ }
+
+ private boolean hasOutputTypes() {
+ Vector ourTypes = getOutputTypeList();
+ if (ourTypes.size() > 0) return true;
+ return false;
+ }
+
+ public IOutputType getPrimaryOutputType() {
+ IOutputType type = null;
+ IOutputType[] types = getOutputTypes();
+ if (types != null && types.length > 0) {
+ for (int i=0; iToolChain
based on the specification stored in the
- * project file (.cdtbuild).
- *
- * @param parent The IConfiguration
the tool-chain will be added to.
- * @param element The XML element that contains the tool-chain settings.
- * @param managedBuildRevision the fileVersion of Managed Build System
- */
- public ToolChain(IConfiguration parent, Element element, String managedBuildRevision) {
- super(resolvedDefault);
- this.parent = parent;
- isExtensionToolChain = false;
-
- // Set the managedBuildRevision
- setManagedBuildRevision(managedBuildRevision);
-
- // Initialize from the XML attributes
- loadFromProject(element);
-
- // Load children
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (loadChild(configElement)) {
- // do nothing
- } else if (configElement.getNodeName().equals(ITool.TOOL_ELEMENT_NAME)) {
- Tool tool = new Tool(this, (Element)configElement, managedBuildRevision);
- addTool(tool);
- }else if (configElement.getNodeName().equals(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME)) {
- if (targetPlatform != null) {
- // TODO: report error
- }
- targetPlatform = new TargetPlatform(this, (Element)configElement, managedBuildRevision);
- }else if (configElement.getNodeName().equals(IBuilder.BUILDER_ELEMENT_NAME)) {
- if (builder != null) {
- // TODO: report error
- }
- builder = new Builder(this, (Element)configElement, managedBuildRevision);
- }else if (configElement.getNodeName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
- //load user-defined macros
- userDefinedMacros = new StorableMacros((Element)configElement);
-
- }
- }
- }
-
- /**
- * Create a ToolChain
based upon an existing tool chain.
- *
- * @param parent The IConfiguration
the tool-chain will be added to.
- * @param toolChain The existing tool-chain to clone.
- */
- public ToolChain(IConfiguration parent, String Id, String name, ToolChain toolChain) {
- super(resolvedDefault);
- this.parent = parent;
- setSuperClassInternal(toolChain.getSuperClass());
- if (getSuperClass() != null) {
- if (toolChain.superClassId != null) {
- superClassId = new String(toolChain.superClassId);
- }
- }
- setId(Id);
- setName(name);
-
- // Set the managedBuildRevision and the version
- setManagedBuildRevision(toolChain.getManagedBuildRevision());
- setVersion(getVersionFromId());
-
- isExtensionToolChain = false;
-
- // Copy the remaining attributes
- if(toolChain.versionsSupported != null) {
- versionsSupported = new String(toolChain.versionsSupported);
- }
- if(toolChain.convertToId != null) {
- convertToId = new String(toolChain.convertToId);
- }
-
- if (toolChain.unusedChildren != null) {
- unusedChildren = new String(toolChain.unusedChildren);
- }
- if (toolChain.errorParserIds != null) {
- errorParserIds = new String(toolChain.errorParserIds);
- }
- if (toolChain.osList != null) {
- osList = new ArrayList(toolChain.osList);
- }
- if (toolChain.archList != null) {
- archList = new ArrayList(toolChain.archList);
- }
- if (toolChain.targetToolIds != null) {
- targetToolIds = new String(toolChain.targetToolIds);
- }
- if (toolChain.secondaryOutputIds != null) {
- secondaryOutputIds = new String(toolChain.secondaryOutputIds);
- }
- if (toolChain.isAbstract != null) {
- isAbstract = new Boolean(toolChain.isAbstract.booleanValue());
- }
- if (toolChain.scannerConfigDiscoveryProfileId != null) {
- scannerConfigDiscoveryProfileId = new String(toolChain.scannerConfigDiscoveryProfileId);
- }
- managedIsToolChainSupportedElement = toolChain.managedIsToolChainSupportedElement;
- managedIsToolChainSupported = toolChain.managedIsToolChainSupported;
-
- environmentVariableSupplierElement = toolChain.environmentVariableSupplierElement;
- environmentVariableSupplier = toolChain.environmentVariableSupplier;
-
- buildMacroSupplierElement = toolChain.buildMacroSupplierElement;
- buildMacroSupplier = toolChain.buildMacroSupplier;
-
- // Clone the children in superclass
- super.copyChildren(toolChain);
- // Clone the children
- if (toolChain.builder != null) {
- String subId;
- String subName;
-
- if (toolChain.builder.getSuperClass() != null) {
- subId = ManagedBuildManager.calculateChildId(
- toolChain.builder.getSuperClass().getId(),
- null);
- subName = toolChain.builder.getSuperClass().getName();
- } else {
- subId = ManagedBuildManager.calculateChildId(
- toolChain.builder.getId(),
- null);
- subName = toolChain.builder.getName();
- }
-
- builder = new Builder(this, subId, subName, toolChain.builder);
- }
- if (toolChain.targetPlatform != null) {
- int nnn = ManagedBuildManager.getRandomNumber();
- String subId;
- String subName;
- if (toolChain.targetPlatform.getSuperClass() != null) {
- subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
- subName = toolChain.targetPlatform.getSuperClass().getName();
- } else {
- subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$
- subName = toolChain.targetPlatform.getName();
- }
- targetPlatform = new TargetPlatform(this, subId, subName, toolChain.targetPlatform);
- }
- if (toolChain.toolList != null) {
- Iterator iter = toolChain.getToolList().listIterator();
- while (iter.hasNext()) {
- Tool toolChild = (Tool) iter.next();
- int nnn = ManagedBuildManager.getRandomNumber();
- String subId;
- String tmpId;
- String subName;
- String version;
-
- if (toolChild.getSuperClass() != null) {
- tmpId = toolChild.getSuperClass().getId();
- subName = toolChild.getSuperClass().getName();
- } else {
- tmpId = toolChild.getId();
- subName = toolChild.getName();
- }
- version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
- if ( version != null) { // If the 'tmpId' contains version information
- subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- subId = tmpId + "." + nnn; //$NON-NLS-1$
- }
-
- Tool newTool = new Tool(this, null, subId, subName, toolChild);
- addTool(newTool);
- }
- }
-
- setDirty(true);
- }
-
- /*
- * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
- */
-
- /* (non-Javadoc)
- * Loads the tool-chain information from the ManagedConfigElement specified in the
- * argument.
- *
- * @param element Contains the tool-chain information
- */
- protected void loadFromManifest(IManagedConfigElement element) {
- ManagedBuildManager.putConfigElement(this, element);
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // Get the name
- setName(element.getAttribute(IBuildObject.NAME));
-
- // version
- setVersion(getVersionFromId());
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
-
- // Get the unused children, if any
- unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
-
- // isAbstract
- String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
- if (isAbs != null){
- isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
- }
-
- // Get the semicolon separated list of IDs of the error parsers
- errorParserIds = element.getAttribute(ERROR_PARSERS);
-
- // Get the semicolon separated list of IDs of the secondary outputs
- secondaryOutputIds = element.getAttribute(SECONDARY_OUTPUTS);
-
- // Get the target tool id
- targetToolIds = element.getAttribute(TARGET_TOOL);
-
- // Get the scanner config discovery profile id
- scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
-
- // Get the 'versionsSupported' attribute
- versionsSupported =element.getAttribute(VERSIONS_SUPPORTED);
-
- // Get the 'convertToId' attribute
- convertToId = element.getAttribute(CONVERT_TO_ID);
-
- // Get the comma-separated list of valid OS
- String os = element.getAttribute(OS_LIST);
- if (os != null) {
- osList = new ArrayList();
- String[] osTokens = os.split(","); //$NON-NLS-1$
- for (int i = 0; i < osTokens.length; ++i) {
- osList.add(osTokens[i].trim());
- }
- }
-
- // Get the comma-separated list of valid Architectures
- String arch = element.getAttribute(ARCH_LIST);
- if (arch != null) {
- archList = new ArrayList();
- String[] archTokens = arch.split(","); //$NON-NLS-1$
- for (int j = 0; j < archTokens.length; ++j) {
- archList.add(archTokens[j].trim());
- }
- }
-
- // Get the isToolchainSupported configuration element
- String managedIsToolChainSupported = element.getAttribute(IS_TOOL_CHAIN_SUPPORTED);
- if (managedIsToolChainSupported != null && element instanceof DefaultManagedConfigElement) {
- managedIsToolChainSupportedElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- }
-
- // Get the environmentVariableSupplier configuration element
- String environmentVariableSupplier = element.getAttribute(CONFIGURATION_ENVIRONMENT_SUPPLIER);
- if(environmentVariableSupplier != null && element instanceof DefaultManagedConfigElement){
- environmentVariableSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- }
-
- // Get the configurationMacroSupplier configuration element
- String buildMacroSupplier = element.getAttribute(CONFIGURATION_MACRO_SUPPLIER);
- if(buildMacroSupplier != null && element instanceof DefaultManagedConfigElement){
- buildMacroSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
- }
-
- }
-
-
- /* (non-Javadoc)
- * Initialize the tool-chain information from the XML element
- * specified in the argument
- *
- * @param element An XML element containing the tool-chain information
- */
- protected void loadFromProject(Element element) {
-
- // id
- setId(element.getAttribute(IBuildObject.ID));
-
- // name
- if (element.hasAttribute(IBuildObject.NAME)) {
- setName(element.getAttribute(IBuildObject.NAME));
- }
-
- // version
- setVersion(getVersionFromId());
-
- // superClass
- superClassId = element.getAttribute(IProjectType.SUPERCLASS);
- if (superClassId != null && superClassId.length() > 0) {
- setSuperClassInternal( ManagedBuildManager.getExtensionToolChain(superClassId) );
- // Check for migration support
- checkForMigrationSupport();
- }
-
- // Get the unused children, if any
- if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
- unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
- }
-
- // isAbstract
- if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
- String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
- if (isAbs != null){
- isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
- }
- }
-
- // Get the semicolon separated list of IDs of the error parsers
- if (element.hasAttribute(ERROR_PARSERS)) {
- errorParserIds = element.getAttribute(ERROR_PARSERS);
- }
-
- // Get the semicolon separated list of IDs of the secondary outputs
- if (element.hasAttribute(SECONDARY_OUTPUTS)) {
- secondaryOutputIds = element.getAttribute(SECONDARY_OUTPUTS);
- }
-
- // Get the target tool id
- if (element.hasAttribute(TARGET_TOOL)) {
- targetToolIds = element.getAttribute(TARGET_TOOL);
- }
-
- // Get the scanner config discovery profile id
- if (element.hasAttribute(SCANNER_CONFIG_PROFILE_ID)) {
- scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
- }
-
- // Get the 'versionSupported' attribute
- if (element.hasAttribute(VERSIONS_SUPPORTED)) {
- versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
- }
-
- // Get the 'convertToId' id
- if (element.hasAttribute(CONVERT_TO_ID)) {
- convertToId = element.getAttribute(CONVERT_TO_ID);
- }
-
- // Get the comma-separated list of valid OS
- if (element.hasAttribute(OS_LIST)) {
- String os = element.getAttribute(OS_LIST);
- if (os != null) {
- osList = new ArrayList();
- String[] osTokens = os.split(","); //$NON-NLS-1$
- for (int i = 0; i < osTokens.length; ++i) {
- osList.add(osTokens[i].trim());
- }
- }
- }
-
- // Get the comma-separated list of valid Architectures
- if (element.hasAttribute(ARCH_LIST)) {
- String arch = element.getAttribute(ARCH_LIST);
- if (arch != null) {
- archList = new ArrayList();
- String[] archTokens = arch.split(","); //$NON-NLS-1$
- for (int j = 0; j < archTokens.length; ++j) {
- archList.add(archTokens[j].trim());
- }
- }
- }
- }
-
- /**
- * Persist the tool-chain to the project file.
- *
- * @param doc
- * @param element
- */
- public void serialize(Document doc, Element element) {
- try {
- if (getSuperClass() != null)
- element.setAttribute(IProjectType.SUPERCLASS, getSuperClass().getId());
-
- element.setAttribute(IBuildObject.ID, id);
-
- if (name != null) {
- element.setAttribute(IBuildObject.NAME, name);
- }
-
- if (unusedChildren != null) {
- element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
- }
-
- if (isAbstract != null) {
- element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
- }
-
- if (errorParserIds != null) {
- element.setAttribute(ERROR_PARSERS, errorParserIds);
- }
-
- if (secondaryOutputIds != null) {
- element.setAttribute(SECONDARY_OUTPUTS, secondaryOutputIds);
- }
-
- if (targetToolIds != null) {
- element.setAttribute(TARGET_TOOL, targetToolIds);
- }
-
- if (scannerConfigDiscoveryProfileId != null) {
- element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
- }
-
- // versionsSupported
- if (versionsSupported != null) {
- element.setAttribute(VERSIONS_SUPPORTED, versionsSupported);
- }
-
- // convertToId
- if (convertToId != null) {
- element.setAttribute(CONVERT_TO_ID, convertToId);
- }
-
- if (osList != null) {
- Iterator osIter = osList.listIterator();
- String listValue = EMPTY_STRING;
- while (osIter.hasNext()) {
- String current = (String) osIter.next();
- listValue += current;
- if ((osIter.hasNext())) {
- listValue += ","; //$NON-NLS-1$
- }
- }
- element.setAttribute(OS_LIST, listValue);
- }
-
- if (archList != null) {
- Iterator archIter = archList.listIterator();
- String listValue = EMPTY_STRING;
- while (archIter.hasNext()) {
- String current = (String) archIter.next();
- listValue += current;
- if ((archIter.hasNext())) {
- listValue += ","; //$NON-NLS-1$
- }
- }
- element.setAttribute(ARCH_LIST, listValue);
- }
-
- // Serialize elements from my super class
- super.serialize(doc, element);
-
- // Serialize my children
- if (targetPlatform != null) {
- Element targetPlatformElement = doc.createElement(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
- element.appendChild(targetPlatformElement);
- targetPlatform.serialize(doc, targetPlatformElement);
- }
- if (builder != null) {
- Element builderElement = doc.createElement(IBuilder.BUILDER_ELEMENT_NAME);
- element.appendChild(builderElement);
- builder.serialize(doc, builderElement);
- }
- List toolElements = getToolList();
- Iterator iter = toolElements.listIterator();
- while (iter.hasNext()) {
- Tool tool = (Tool) iter.next();
- Element toolElement = doc.createElement(ITool.TOOL_ELEMENT_NAME);
- element.appendChild(toolElement);
- tool.serialize(doc, toolElement);
- }
-
- // Note: isToolChainSupported cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if (managedIsToolChainSupportedElement != null) {
- // TODO: issue warning?
- }
-
- // Note: environmentVariableSupplier cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if(environmentVariableSupplierElement != null) {
- // TODO: issue warning?
- }
-
- // Note: buildMacroSupplier cannot be specified in a project file because
- // an IConfigurationElement is needed to load it!
- if(buildMacroSupplierElement != null) {
- // TODO: issue warning?
- }
-
- //serialize user-defined macros
- if(userDefinedMacros != null){
- Element macrosElement = doc.createElement(StorableMacros.MACROS_ELEMENT_NAME);
- element.appendChild(macrosElement);
- userDefinedMacros.serialize(doc,macrosElement);
- }
-
- if(userDefinedEnvironment != null)
- EnvironmentVariableProvider.fUserSupplier.storeEnvironment(getParent(),true);
-
- // I am clean now
- isDirty = false;
- } catch (Exception e) {
- // TODO: issue an error message
- }
-}
-
- /*
- * P A R E N T A N D C H I L D H A N D L I N G
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#getConfiguration()
- */
- public IConfiguration getParent() {
- return parent;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#createTargetPlatform(ITargetPlatform, String, String, boolean)
- */
- public ITargetPlatform createTargetPlatform(ITargetPlatform superClass, String id, String name, boolean isExtensionElement) {
- targetPlatform = new TargetPlatform(this, superClass, id, name, isExtensionElement);
- setDirty(true);
- return (ITargetPlatform)targetPlatform;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#getTargetPlatform()
- */
- public ITargetPlatform getTargetPlatform() {
- if (targetPlatform == null) {
- if (getSuperClass() != null) {
- return getSuperClass().getTargetPlatform();
- }
- }
- return (ITargetPlatform)targetPlatform;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalTargetPlatform()
- */
- public void removeLocalTargetPlatform() {
- if (targetPlatform == null) return;
- targetPlatform = null;
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#createBuilder(IBuilder, String, String, boolean)
- */
- public IBuilder createBuilder(IBuilder superClass, String id, String name, boolean isExtensionElement) {
- builder = new Builder(this, superClass, id, name, isExtensionElement);
- setDirty(true);
- return (IBuilder)builder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#getBuilder()
- */
- public IBuilder getBuilder() {
- if (builder == null) {
- if (getSuperClass() != null) {
- return getSuperClass().getBuilder();
- }
- }
- return (IBuilder)builder;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalBuilder()
- */
- public void removeLocalBuilder() {
- if (builder == null) return;
- builder = null;
- setDirty(true);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#createTool(ITool, String, String, boolean)
- */
- public ITool createTool(ITool superClass, String id, String name, boolean isExtensionElement) {
- Tool tool = new Tool(this, superClass, id, name, isExtensionElement);
- addTool(tool);
- setDirty(true);
- return (ITool)tool;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#getTools()
- */
- public ITool[] getTools() {
- ITool[] tools = null;
- // Merge our tools with our superclass' tools
- if (getSuperClass() != null) {
- tools = getSuperClass().getTools();
- }
- // Our tools take precedence
- if (tools != null) {
- Iterator iter = getToolList().listIterator();
- while (iter.hasNext()) {
- Tool tool = (Tool)iter.next();
- int j;
- for (j = 0; j < tools.length; j++) {
- if (tool.getSuperClass() != null // Remove assumption that ALL tools must have superclasses
- && tool.getSuperClass().getId().equals(tools[j].getId())) {
- tools[j] = tool;
- break;
- }
- }
- // No Match? Insert it (may be re-ordered)
- if (j == tools.length) {
- ITool[] newTools = new ITool[tools.length + 1];
- for (int k = 0; k < tools.length; k++) {
- newTools[k] = tools[k];
- }
- newTools[j] = tool;
- tools = newTools;
- }
- }
- } else {
- tools = new ITool[getToolList().size()];
- Iterator iter = getToolList().listIterator();
- int i = 0;
- while (iter.hasNext()) {
- Tool tool = (Tool)iter.next();
- tools[i++] = (ITool)tool;
- }
- }
- return tools;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTool(java.lang.String)
- */
- public ITool getTool(String id) {
- Tool tool = (Tool)getToolMap().get(id);
- return (ITool)tool;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getToolsBySuperClassId(java.lang.String)
- */
- public ITool[] getToolsBySuperClassId(String id) {
- List retTools = new ArrayList();
- if (id != null) {
- // Look for a tool with this ID, or the tool(s) with a superclass with this id
- ITool[] tools = getTools();
- for (int i = 0; i < tools.length; i++) {
- ITool targetTool = tools[i];
- ITool tool = targetTool;
- do {
- if (id.equals(tool.getId())) {
- retTools.add(targetTool);
- break;
- }
- tool = tool.getSuperClass();
- } while (tool != null);
- }
- }
- return (ITool[])retTools.toArray( new ITool[retTools.size()]);
- }
-
- /* (non-Javadoc)
- * Safe accessor for the list of tools.
- *
- * @return List containing the tools
- */
- public List getToolList() {
- if (toolList == null) {
- toolList = new ArrayList();
- }
- return toolList;
- }
-
- /* (non-Javadoc)
- * Safe accessor for the map of tool ids to tools
- *
- * @return
- */
- private Map getToolMap() {
- if (toolMap == null) {
- toolMap = new HashMap();
- }
- return toolMap;
- }
-
- /* (non-Javadoc)
- * Adds the Tool to the Tool-chain list and map
- *
- * @param Tool
- */
- public void addTool(Tool tool) {
- getToolList().add(tool);
- getToolMap().put(tool.getId(), tool);
- }
-
- /*
- * M O D E L A T T R I B U T E A C C E S S O R S
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSuperClass()
- */
- public IToolChain getSuperClass() {
- return (IToolChain)superClass;
- }
-
- /* (non-Javadoc)
- * Access function to set the superclass element that is defined in
- * the base class.
- */
- private void setSuperClassInternal(IToolChain superClass) {
- this.superClass = superClass;
- }
-
- public void setSuperClass(IToolChain superClass) {
- if ( this.superClass != superClass ) {
- this.superClass = superClass;
- if ( this.superClass == null) {
- superClassId = null;
- } else {
- superClassId = this.superClass.getId();
- }
-
- if(!isExtensionElement())
- setDirty(true);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#getName()
- */
- public String getName() {
- return (name == null && getSuperClass() != null) ? getSuperClass().getName() : name;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#isAbstract()
- */
- public boolean isAbstract() {
- if (isAbstract != null) {
- return isAbstract.booleanValue();
- } else {
- return false; // Note: no inheritance from superClass
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IToolChain#getUnusedChildren()
- */
- public String getUnusedChildren() {
- if (unusedChildren != null) {
- return unusedChildren;
- } else
- return EMPTY_STRING; // Note: no inheritance from superClass
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds()
- */
- public String getErrorParserIds() {
- String ids = errorParserIds;
- if (ids == null) {
- // If I have a superClass, ask it
- if (getSuperClass() != null) {
- ids = getSuperClass().getErrorParserIds();
- }
- }
- if (ids == null) {
- // Collect the error parsers from my children
- ids = builder.getErrorParserIds();
- ITool[] tools = getTools();
- for (int i = 0; i < tools.length; i++) {
- ITool tool = tools[i];
- String toolIds = tool.getErrorParserIds();
- if (toolIds != null && toolIds.length() > 0) {
- if (ids != null) {
- ids += ";"; //$NON-NLS-1$
- ids += toolIds;
- } else {
- ids = toolIds;
- }
- }
- }
- }
- return ids;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSecondaryOutputs()
- */
- public IOutputType[] getSecondaryOutputs() {
- IOutputType[] types = null;
- String ids = secondaryOutputIds;
- if (ids == null) {
- if (getSuperClass() != null) {
- return getSuperClass().getSecondaryOutputs();
- }
- else {
- return new IOutputType[0];
- }
- }
- StringTokenizer tok = new StringTokenizer(ids, ";"); //$NON-NLS-1$
- types = new IOutputType[tok.countTokens()];
- ITool[] tools = getTools();
- int i = 0;
- while (tok.hasMoreElements()) {
- String id = tok.nextToken();
- for (int j=0; jnull
if none.
- *
- * @return IConfigurationElement
- */
- public IConfigurationElement getEnvironmentVariableSupplierElement(){
- if (environmentVariableSupplierElement == null) {
- if (getSuperClass() != null && getSuperClass() instanceof ToolChain) {
- return ((ToolChain)getSuperClass()).getEnvironmentVariableSupplierElement();
- }
- }
- return environmentVariableSupplierElement;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getEnvironmentVariableSupplier()
- */
- public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
- if (environmentVariableSupplier != null) {
- return environmentVariableSupplier;
- }
- IConfigurationElement element = getEnvironmentVariableSupplierElement();
- if (element != null) {
- try {
- if (element.getAttribute(CONFIGURATION_ENVIRONMENT_SUPPLIER) != null) {
- environmentVariableSupplier = (IConfigurationEnvironmentVariableSupplier) element.createExecutableExtension(CONFIGURATION_ENVIRONMENT_SUPPLIER);
- return environmentVariableSupplier;
- }
- } catch (CoreException e) {}
- }
- return null;
- }
-
- /*
- * this method is called by the UserDefinedMacroSupplier to obtain user-defined
- * macros available for this tool-chain
- */
- public StorableMacros getUserDefinedMacros(){
- if(isExtensionToolChain)
- return null;
-
- if(userDefinedMacros == null)
- userDefinedMacros = new StorableMacros();
- return userDefinedMacros;
- }
-
- public StorableEnvironment getUserDefinedEnvironment(){
- if(isExtensionToolChain)
- return null;
-
- return userDefinedEnvironment;
- }
-
- public void setUserDefinedEnvironment(StorableEnvironment env){
- if(!isExtensionToolChain)
- userDefinedEnvironment = env;
- }
-
-
- /**
- * Returns the plugin.xml element of the configurationMacroSupplier extension or null
if none.
- *
- * @return IConfigurationElement
- */
- public IConfigurationElement getBuildMacroSupplierElement(){
- if (buildMacroSupplierElement == null) {
- if (superClass != null && superClass instanceof ToolChain) {
- return ((ToolChain)superClass).getBuildMacroSupplierElement();
- }
- }
- return buildMacroSupplierElement;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getBuildMacroSupplier()
- */
- public IConfigurationBuildMacroSupplier getBuildMacroSupplier(){
- if (buildMacroSupplier != null) {
- return buildMacroSupplier;
- }
- IConfigurationElement element = getBuildMacroSupplierElement();
- if (element != null) {
- try {
- if (element.getAttribute(CONFIGURATION_MACRO_SUPPLIER) != null) {
- buildMacroSupplier = (IConfigurationBuildMacroSupplier) element.createExecutableExtension(CONFIGURATION_MACRO_SUPPLIER);
- return buildMacroSupplier;
- }
- } catch (CoreException e) {}
- }
- return null;
- }
-
- /*
- * This function checks for migration support for the toolchain, while
- * loading. If migration support is needed, looks for the available
- * converters and adds them to the list.
- */
-
- public void checkForMigrationSupport() {
-
- boolean isExists = false;
-
- if (getSuperClass() == null) {
- // If 'getSuperClass()' is null, then there is no toolchain available in
- // plugin manifest file with the 'id' & version.
- // Look for the 'versionsSupported' attribute
- String high = (String) ManagedBuildManager
- .getExtensionToolChainMap().lastKey();
-
- SortedMap subMap = null;
- if (superClassId.compareTo(high) <= 0) {
- subMap = ManagedBuildManager.getExtensionToolChainMap().subMap(
- superClassId, high + "\0"); //$NON-NLS-1$
- } else {
- // It means there are no entries in the map for the given id.
- // make the project is invalid
- IConfiguration parentConfig = getParent();
- IManagedProject managedProject = parentConfig.getManagedProject();
- if (managedProject != null) {
- managedProject.setValid(false);
- }
- return;
- }
-
- // for each element in the 'subMap',
- // check the 'versionsSupported' attribute whether the given
- // toolChain version is supported
-
- String baseId = ManagedBuildManager.getIdFromIdAndVersion(superClassId);
- String version = getVersionFromId().toString();
-
- IToolChain[] toolChainElements = (IToolChain[]) subMap.values().toArray();
-
- for (int i = 0; i < toolChainElements.length; i++) {
- IToolChain toolChainElement = toolChainElements[i];
-
- if (ManagedBuildManager.getIdFromIdAndVersion(
- toolChainElement.getId()).compareTo(baseId) > 0)
- break;
-
- // First check if both base ids are equal
- if (ManagedBuildManager.getIdFromIdAndVersion(
- toolChainElement.getId()).equals(baseId)) {
-
- // Check if 'versionsSupported' attribute is available'
- String versionsSupported = toolChainElement.getVersionsSupported();
-
- if ((versionsSupported != null)
- && (!versionsSupported.equals(""))) { //$NON-NLS-1$
- String[] tmpVersions = versionsSupported.split(","); //$NON-NLS-1$
-
- for (int j = 0; j < tmpVersions.length; j++) {
- if (new PluginVersionIdentifier(version).equals(new PluginVersionIdentifier(tmpVersions[j]))) {
- // version is supported.
- // Do the automatic conversion without
- // prompting the user.
- // Get the supported version
- String supportedVersion = ManagedBuildManager.getVersionFromIdAndVersion(
- toolChainElement.getId());
- setId(ManagedBuildManager.getIdFromIdAndVersion(getId())
- + "_" + supportedVersion); //$NON-NLS-1$
-
- // If control comes here means that 'superClass' is null
- // So, set the superClass to this toolChain element
- setSuperClassInternal(toolChainElement);
- superClassId = getSuperClass().getId();
- isExists = true;
- break;
- }
- }
- if(isExists)
- break; // break the outer for loop if 'isExists' is true
- }
- }
- }
- }
-
- if (getSuperClass() != null) {
- // If 'getSuperClass()' is not null, look for 'convertToId' attribute in plugin
- // manifest file for this toolchain.
- String convertToId = getSuperClass().getConvertToId();
- if ((convertToId == null) || (convertToId.equals(""))) { //$NON-NLS-1$
- // It means there is no 'convertToId' attribute available and
- // the version is still actively
- // supported by the tool integrator. So do nothing, just return
- return;
- } else {
- // In case the 'convertToId' attribute is available,
- // it means that Tool integrator currently does not support this
- // version of toolchain.
- // Look for the converters available for this toolchain version.
-
- getConverter(convertToId);
- }
-
- } else {
- // make the project is invalid
- //
- IConfiguration parentConfig = getParent();
- IManagedProject managedProject = parentConfig.getManagedProject();
- if (managedProject != null) {
- managedProject.setValid(false);
- }
- }
- return;
- }
-
- private void getConverter(String convertToId) {
-
- String fromId = null;
- String toId = null;
-
- // Get the Converter Extension Point
- IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
- .getExtensionPoint("org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$
- "projectConverter"); //$NON-NLS-1$
- if (extensionPoint != null) {
- // Get the extensions
- IExtension[] extensions = extensionPoint.getExtensions();
- for (int i = 0; i < extensions.length; i++) {
- // Get the configuration elements of each extension
- IConfigurationElement[] configElements = extensions[i]
- .getConfigurationElements();
- for (int j = 0; j < configElements.length; j++) {
-
- IConfigurationElement element = configElements[j];
-
- if (element.getName().equals("converter")) { //$NON-NLS-1$
-
- fromId = element.getAttribute("fromId"); //$NON-NLS-1$
- toId = element.getAttribute("toId"); //$NON-NLS-1$
- // Check whether the current converter can be used for
- // the selected toolchain
-
- if (fromId.equals(getSuperClass().getId())
- && toId.equals(convertToId)) {
- // If it matches
- String mbsVersion = element
- .getAttribute("mbsVersion"); //$NON-NLS-1$
- PluginVersionIdentifier currentMbsVersion = ManagedBuildManager
- .getBuildInfoVersion();
-
- // set the converter element based on the MbsVersion
- if (currentMbsVersion
- .isGreaterThan(new PluginVersionIdentifier(
- mbsVersion))) {
- previousMbsVersionConversionElement = element;
- } else {
- currentMbsVersionConversionElement = element;
- }
- return;
- }
- }
- }
- }
- }
-
- // If control comes here, it means 'Tool Integrator' specified
- // 'convertToId' attribute in toolchain definition file, but
- // has not provided any converter.
- // So, make the project is invalid
-
- IConfiguration parentConfig = getParent();
- IManagedProject managedProject = parentConfig.getManagedProject();
- if (managedProject != null) {
- managedProject.setValid(false);
- }
- }
-
-
- public IConfigurationElement getPreviousMbsVersionConversionElement() {
- return previousMbsVersionConversionElement;
- }
-
- public IConfigurationElement getCurrentMbsVersionConversionElement() {
- return currentMbsVersionConversionElement;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
- */
- public void updateManagedBuildRevision(String revision){
- super.updateManagedBuildRevision(revision);
-
- for(Iterator iter = getToolList().iterator(); iter.hasNext();){
- ((Tool)iter.next()).updateManagedBuildRevision(revision);
- }
-
- if(builder != null)
- builder.updateManagedBuildRevision(revision);
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2005 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.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.StringTokenizer;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IBuilder;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IManagedIsToolChainSupported;
+import org.eclipse.cdt.managedbuilder.core.IManagedProject;
+import org.eclipse.cdt.managedbuilder.core.IOutputType;
+import org.eclipse.cdt.managedbuilder.core.IProjectType;
+import org.eclipse.cdt.managedbuilder.core.ITargetPlatform;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.envvar.IConfigurationEnvironmentVariableSupplier;
+import org.eclipse.cdt.managedbuilder.internal.envvar.EnvironmentVariableProvider;
+import org.eclipse.cdt.managedbuilder.internal.envvar.StorableEnvironment;
+import org.eclipse.cdt.managedbuilder.internal.macros.StorableMacros;
+import org.eclipse.cdt.managedbuilder.macros.IConfigurationBuildMacroSupplier;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ToolChain extends HoldsOptions implements IToolChain {
+
+ private static final String EMPTY_STRING = new String();
+
+ private static final boolean resolvedDefault = true;
+
+ // Superclass
+ // Note that superClass itself is defined in the base and that the methods
+ // getSuperClass() and setSuperClassInternal(), defined in ToolChain must be used
+ // to access it. This avoids widespread casts from IHoldsOptions to IToolChain.
+ private String superClassId;
+ // Parent and children
+ private IConfiguration parent;
+ private List toolList;
+ private Map toolMap;
+ private TargetPlatform targetPlatform;
+ private Builder builder;
+ // Managed Build model attributes
+ private String unusedChildren;
+ private String errorParserIds;
+ private List osList;
+ private List archList;
+ private String targetToolIds;
+ private String secondaryOutputIds;
+ private Boolean isAbstract;
+ private String scannerConfigDiscoveryProfileId;
+ private String versionsSupported;
+ private String convertToId;
+ private IConfigurationElement managedIsToolChainSupportedElement = null;
+ private IManagedIsToolChainSupported managedIsToolChainSupported = null;
+ private IConfigurationElement environmentVariableSupplierElement = null;
+ private IConfigurationEnvironmentVariableSupplier environmentVariableSupplier = null;
+ private IConfigurationElement buildMacroSupplierElement = null;
+ private IConfigurationBuildMacroSupplier buildMacroSupplier = null;
+
+ // Miscellaneous
+ private boolean isExtensionToolChain = false;
+ private boolean isDirty = false;
+ private boolean resolved = resolvedDefault;
+ //holds the user-defined macros
+ private StorableMacros userDefinedMacros;
+ //holds user-defined macros
+ private StorableEnvironment userDefinedEnvironment;
+
+ private IConfigurationElement previousMbsVersionConversionElement = null;
+ private IConfigurationElement currentMbsVersionConversionElement = null;
+
+ /*
+ * C O N S T R U C T O R S
+ */
+
+ /**
+ * This constructor is called to create a tool-chain defined by an extension point in
+ * a plugin manifest file, or returned by a dynamic element provider
+ *
+ * @param parent The IConfiguration parent of this tool-chain, or null
if
+ * defined at the top level
+ * @param element The tool-chain definition from the manifest file or a dynamic element
+ * provider
+ * @param managedBuildRevision the fileVersion of Managed Build System
+ */
+ public ToolChain(IConfiguration parent, IManagedConfigElement element, String managedBuildRevision) {
+ // setup for resolving
+ super(false);
+ resolved = false;
+
+ this.parent = parent;
+ isExtensionToolChain = true;
+
+ // Set the managedBuildRevision
+ setManagedBuildRevision(managedBuildRevision);
+
+ loadFromManifest(element);
+
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionToolChain(this);
+
+ // Load the TargetPlatform child
+ IManagedConfigElement[] targetPlatforms =
+ element.getChildren(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
+ if (targetPlatforms.length < 1 || targetPlatforms.length > 1) {
+ // TODO: Report error
+ }
+ if (targetPlatforms.length > 0) {
+ targetPlatform = new TargetPlatform(this, targetPlatforms[0], managedBuildRevision);
+ }
+
+ // Load the Builder child
+ IManagedConfigElement[] builders =
+ element.getChildren(IBuilder.BUILDER_ELEMENT_NAME);
+ if (builders.length < 1 || builders.length > 1) {
+ // TODO: Report error
+ }
+ if (builders.length > 0) {
+ builder = new Builder(this, builders[0], managedBuildRevision);
+ }
+
+ // Load children
+ IManagedConfigElement[] toolChainElements = element.getChildren();
+ for (int l = 0; l < toolChainElements.length; ++l) {
+ IManagedConfigElement toolChainElement = toolChainElements[l];
+ if (loadChild(toolChainElement)) {
+ // do nothing
+ } else if (toolChainElement.getName().equals(ITool.TOOL_ELEMENT_NAME)) {
+ Tool toolChild = new Tool(this, toolChainElement, managedBuildRevision);
+ addTool(toolChild);
+ }
+ }
+ }
+
+ /**
+ * This constructor is called to create a ToolChain whose attributes and children will be
+ * added by separate calls.
+ *
+ * @param Configuration The parent of the tool chain, if any
+ * @param ToolChain The superClass, if any
+ * @param String The id for the new tool chain
+ * @param String The name for the new tool chain
+ * @param boolean Indicates whether this is an extension element or a managed project element
+ */
+ public ToolChain(Configuration parent, IToolChain superClass, String Id, String name, boolean isExtensionElement) {
+ super(resolvedDefault);
+ this.parent = parent;
+ setSuperClassInternal(superClass);
+ setManagedBuildRevision(parent.getManagedBuildRevision());
+
+ if (getSuperClass() != null) {
+ superClassId = getSuperClass().getId();
+ }
+ setId(Id);
+ setName(name);
+ setVersion(getVersionFromId());
+
+ isExtensionToolChain = isExtensionElement;
+ if (isExtensionElement) {
+ // Hook me up to the Managed Build Manager
+ ManagedBuildManager.addExtensionToolChain(this);
+ } else {
+ setDirty(true);
+ }
+ }
+
+ /**
+ * Create a ToolChain
based on the specification stored in the
+ * project file (.cdtbuild).
+ *
+ * @param parent The IConfiguration
the tool-chain will be added to.
+ * @param element The XML element that contains the tool-chain settings.
+ * @param managedBuildRevision the fileVersion of Managed Build System
+ */
+ public ToolChain(IConfiguration parent, Element element, String managedBuildRevision) {
+ super(resolvedDefault);
+ this.parent = parent;
+ isExtensionToolChain = false;
+
+ // Set the managedBuildRevision
+ setManagedBuildRevision(managedBuildRevision);
+
+ // Initialize from the XML attributes
+ loadFromProject(element);
+
+ // Load children
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (loadChild(configElement)) {
+ // do nothing
+ } else if (configElement.getNodeName().equals(ITool.TOOL_ELEMENT_NAME)) {
+ Tool tool = new Tool(this, (Element)configElement, managedBuildRevision);
+ addTool(tool);
+ }else if (configElement.getNodeName().equals(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME)) {
+ if (targetPlatform != null) {
+ // TODO: report error
+ }
+ targetPlatform = new TargetPlatform(this, (Element)configElement, managedBuildRevision);
+ }else if (configElement.getNodeName().equals(IBuilder.BUILDER_ELEMENT_NAME)) {
+ if (builder != null) {
+ // TODO: report error
+ }
+ builder = new Builder(this, (Element)configElement, managedBuildRevision);
+ }else if (configElement.getNodeName().equals(StorableMacros.MACROS_ELEMENT_NAME)) {
+ //load user-defined macros
+ userDefinedMacros = new StorableMacros((Element)configElement);
+
+ }
+ }
+ }
+
+ /**
+ * Create a ToolChain
based upon an existing tool chain.
+ *
+ * @param parent The IConfiguration
the tool-chain will be added to.
+ * @param toolChain The existing tool-chain to clone.
+ */
+ public ToolChain(IConfiguration parent, String Id, String name, ToolChain toolChain) {
+ super(resolvedDefault);
+ this.parent = parent;
+ setSuperClassInternal(toolChain.getSuperClass());
+ if (getSuperClass() != null) {
+ if (toolChain.superClassId != null) {
+ superClassId = new String(toolChain.superClassId);
+ }
+ }
+ setId(Id);
+ setName(name);
+
+ // Set the managedBuildRevision and the version
+ setManagedBuildRevision(toolChain.getManagedBuildRevision());
+ setVersion(getVersionFromId());
+
+ isExtensionToolChain = false;
+
+ // Copy the remaining attributes
+ if(toolChain.versionsSupported != null) {
+ versionsSupported = new String(toolChain.versionsSupported);
+ }
+ if(toolChain.convertToId != null) {
+ convertToId = new String(toolChain.convertToId);
+ }
+
+ if (toolChain.unusedChildren != null) {
+ unusedChildren = new String(toolChain.unusedChildren);
+ }
+ if (toolChain.errorParserIds != null) {
+ errorParserIds = new String(toolChain.errorParserIds);
+ }
+ if (toolChain.osList != null) {
+ osList = new ArrayList(toolChain.osList);
+ }
+ if (toolChain.archList != null) {
+ archList = new ArrayList(toolChain.archList);
+ }
+ if (toolChain.targetToolIds != null) {
+ targetToolIds = new String(toolChain.targetToolIds);
+ }
+ if (toolChain.secondaryOutputIds != null) {
+ secondaryOutputIds = new String(toolChain.secondaryOutputIds);
+ }
+ if (toolChain.isAbstract != null) {
+ isAbstract = new Boolean(toolChain.isAbstract.booleanValue());
+ }
+ if (toolChain.scannerConfigDiscoveryProfileId != null) {
+ scannerConfigDiscoveryProfileId = new String(toolChain.scannerConfigDiscoveryProfileId);
+ }
+ managedIsToolChainSupportedElement = toolChain.managedIsToolChainSupportedElement;
+ managedIsToolChainSupported = toolChain.managedIsToolChainSupported;
+
+ environmentVariableSupplierElement = toolChain.environmentVariableSupplierElement;
+ environmentVariableSupplier = toolChain.environmentVariableSupplier;
+
+ buildMacroSupplierElement = toolChain.buildMacroSupplierElement;
+ buildMacroSupplier = toolChain.buildMacroSupplier;
+
+ // Clone the children in superclass
+ super.copyChildren(toolChain);
+ // Clone the children
+ if (toolChain.builder != null) {
+ String subId;
+ String subName;
+
+ if (toolChain.builder.getSuperClass() != null) {
+ subId = ManagedBuildManager.calculateChildId(
+ toolChain.builder.getSuperClass().getId(),
+ null);
+ subName = toolChain.builder.getSuperClass().getName();
+ } else {
+ subId = ManagedBuildManager.calculateChildId(
+ toolChain.builder.getId(),
+ null);
+ subName = toolChain.builder.getName();
+ }
+
+ builder = new Builder(this, subId, subName, toolChain.builder);
+ }
+ if (toolChain.targetPlatform != null) {
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String subName;
+ if (toolChain.targetPlatform.getSuperClass() != null) {
+ subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChain.targetPlatform.getSuperClass().getName();
+ } else {
+ subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$
+ subName = toolChain.targetPlatform.getName();
+ }
+ targetPlatform = new TargetPlatform(this, subId, subName, toolChain.targetPlatform);
+ }
+ if (toolChain.toolList != null) {
+ Iterator iter = toolChain.getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool toolChild = (Tool) iter.next();
+ int nnn = ManagedBuildManager.getRandomNumber();
+ String subId;
+ String tmpId;
+ String subName;
+ String version;
+
+ if (toolChild.getSuperClass() != null) {
+ tmpId = toolChild.getSuperClass().getId();
+ subName = toolChild.getSuperClass().getName();
+ } else {
+ tmpId = toolChild.getId();
+ subName = toolChild.getName();
+ }
+ version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
+ if ( version != null) { // If the 'tmpId' contains version information
+ subId = ManagedBuildManager.getIdFromIdAndVersion(tmpId) + "." + nnn + "_" + version; //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ subId = tmpId + "." + nnn; //$NON-NLS-1$
+ }
+
+ Tool newTool = new Tool(this, null, subId, subName, toolChild);
+ addTool(newTool);
+ }
+ }
+
+ setDirty(true);
+ }
+
+ /*
+ * E L E M E N T A T T R I B U T E R E A D E R S A N D W R I T E R S
+ */
+
+ /* (non-Javadoc)
+ * Loads the tool-chain information from the ManagedConfigElement specified in the
+ * argument.
+ *
+ * @param element Contains the tool-chain information
+ */
+ protected void loadFromManifest(IManagedConfigElement element) {
+ ManagedBuildManager.putConfigElement(this, element);
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // Get the name
+ setName(element.getAttribute(IBuildObject.NAME));
+
+ // version
+ setVersion(getVersionFromId());
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+
+ // Get the unused children, if any
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+
+ // isAbstract
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+
+ // Get the semicolon separated list of IDs of the secondary outputs
+ secondaryOutputIds = element.getAttribute(SECONDARY_OUTPUTS);
+
+ // Get the target tool id
+ targetToolIds = element.getAttribute(TARGET_TOOL);
+
+ // Get the scanner config discovery profile id
+ scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
+
+ // Get the 'versionsSupported' attribute
+ versionsSupported =element.getAttribute(VERSIONS_SUPPORTED);
+
+ // Get the 'convertToId' attribute
+ convertToId = element.getAttribute(CONVERT_TO_ID);
+
+ // Get the comma-separated list of valid OS
+ String os = element.getAttribute(OS_LIST);
+ if (os != null) {
+ osList = new ArrayList();
+ String[] osTokens = os.split(","); //$NON-NLS-1$
+ for (int i = 0; i < osTokens.length; ++i) {
+ osList.add(osTokens[i].trim());
+ }
+ }
+
+ // Get the comma-separated list of valid Architectures
+ String arch = element.getAttribute(ARCH_LIST);
+ if (arch != null) {
+ archList = new ArrayList();
+ String[] archTokens = arch.split(","); //$NON-NLS-1$
+ for (int j = 0; j < archTokens.length; ++j) {
+ archList.add(archTokens[j].trim());
+ }
+ }
+
+ // Get the isToolchainSupported configuration element
+ String managedIsToolChainSupported = element.getAttribute(IS_TOOL_CHAIN_SUPPORTED);
+ if (managedIsToolChainSupported != null && element instanceof DefaultManagedConfigElement) {
+ managedIsToolChainSupportedElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+
+ // Get the environmentVariableSupplier configuration element
+ String environmentVariableSupplier = element.getAttribute(CONFIGURATION_ENVIRONMENT_SUPPLIER);
+ if(environmentVariableSupplier != null && element instanceof DefaultManagedConfigElement){
+ environmentVariableSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+
+ // Get the configurationMacroSupplier configuration element
+ String buildMacroSupplier = element.getAttribute(CONFIGURATION_MACRO_SUPPLIER);
+ if(buildMacroSupplier != null && element instanceof DefaultManagedConfigElement){
+ buildMacroSupplierElement = ((DefaultManagedConfigElement)element).getConfigurationElement();
+ }
+
+ }
+
+
+ /* (non-Javadoc)
+ * Initialize the tool-chain information from the XML element
+ * specified in the argument
+ *
+ * @param element An XML element containing the tool-chain information
+ */
+ protected void loadFromProject(Element element) {
+
+ // id
+ setId(element.getAttribute(IBuildObject.ID));
+
+ // name
+ if (element.hasAttribute(IBuildObject.NAME)) {
+ setName(element.getAttribute(IBuildObject.NAME));
+ }
+
+ // version
+ setVersion(getVersionFromId());
+
+ // superClass
+ superClassId = element.getAttribute(IProjectType.SUPERCLASS);
+ if (superClassId != null && superClassId.length() > 0) {
+ setSuperClassInternal( ManagedBuildManager.getExtensionToolChain(superClassId) );
+ // Check for migration support
+ checkForMigrationSupport();
+ }
+
+ // Get the unused children, if any
+ if (element.hasAttribute(IProjectType.UNUSED_CHILDREN)) {
+ unusedChildren = element.getAttribute(IProjectType.UNUSED_CHILDREN);
+ }
+
+ // isAbstract
+ if (element.hasAttribute(IProjectType.IS_ABSTRACT)) {
+ String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
+ if (isAbs != null){
+ isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
+ }
+ }
+
+ // Get the semicolon separated list of IDs of the error parsers
+ if (element.hasAttribute(ERROR_PARSERS)) {
+ errorParserIds = element.getAttribute(ERROR_PARSERS);
+ }
+
+ // Get the semicolon separated list of IDs of the secondary outputs
+ if (element.hasAttribute(SECONDARY_OUTPUTS)) {
+ secondaryOutputIds = element.getAttribute(SECONDARY_OUTPUTS);
+ }
+
+ // Get the target tool id
+ if (element.hasAttribute(TARGET_TOOL)) {
+ targetToolIds = element.getAttribute(TARGET_TOOL);
+ }
+
+ // Get the scanner config discovery profile id
+ if (element.hasAttribute(SCANNER_CONFIG_PROFILE_ID)) {
+ scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
+ }
+
+ // Get the 'versionSupported' attribute
+ if (element.hasAttribute(VERSIONS_SUPPORTED)) {
+ versionsSupported = element.getAttribute(VERSIONS_SUPPORTED);
+ }
+
+ // Get the 'convertToId' id
+ if (element.hasAttribute(CONVERT_TO_ID)) {
+ convertToId = element.getAttribute(CONVERT_TO_ID);
+ }
+
+ // Get the comma-separated list of valid OS
+ if (element.hasAttribute(OS_LIST)) {
+ String os = element.getAttribute(OS_LIST);
+ if (os != null) {
+ osList = new ArrayList();
+ String[] osTokens = os.split(","); //$NON-NLS-1$
+ for (int i = 0; i < osTokens.length; ++i) {
+ osList.add(osTokens[i].trim());
+ }
+ }
+ }
+
+ // Get the comma-separated list of valid Architectures
+ if (element.hasAttribute(ARCH_LIST)) {
+ String arch = element.getAttribute(ARCH_LIST);
+ if (arch != null) {
+ archList = new ArrayList();
+ String[] archTokens = arch.split(","); //$NON-NLS-1$
+ for (int j = 0; j < archTokens.length; ++j) {
+ archList.add(archTokens[j].trim());
+ }
+ }
+ }
+ }
+
+ /**
+ * Persist the tool-chain to the project file.
+ *
+ * @param doc
+ * @param element
+ */
+ public void serialize(Document doc, Element element) {
+ try {
+ if (getSuperClass() != null)
+ element.setAttribute(IProjectType.SUPERCLASS, getSuperClass().getId());
+
+ element.setAttribute(IBuildObject.ID, id);
+
+ if (name != null) {
+ element.setAttribute(IBuildObject.NAME, name);
+ }
+
+ if (unusedChildren != null) {
+ element.setAttribute(IProjectType.UNUSED_CHILDREN, unusedChildren);
+ }
+
+ if (isAbstract != null) {
+ element.setAttribute(IProjectType.IS_ABSTRACT, isAbstract.toString());
+ }
+
+ if (errorParserIds != null) {
+ element.setAttribute(ERROR_PARSERS, errorParserIds);
+ }
+
+ if (secondaryOutputIds != null) {
+ element.setAttribute(SECONDARY_OUTPUTS, secondaryOutputIds);
+ }
+
+ if (targetToolIds != null) {
+ element.setAttribute(TARGET_TOOL, targetToolIds);
+ }
+
+ if (scannerConfigDiscoveryProfileId != null) {
+ element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
+ }
+
+ // versionsSupported
+ if (versionsSupported != null) {
+ element.setAttribute(VERSIONS_SUPPORTED, versionsSupported);
+ }
+
+ // convertToId
+ if (convertToId != null) {
+ element.setAttribute(CONVERT_TO_ID, convertToId);
+ }
+
+ if (osList != null) {
+ Iterator osIter = osList.listIterator();
+ String listValue = EMPTY_STRING;
+ while (osIter.hasNext()) {
+ String current = (String) osIter.next();
+ listValue += current;
+ if ((osIter.hasNext())) {
+ listValue += ","; //$NON-NLS-1$
+ }
+ }
+ element.setAttribute(OS_LIST, listValue);
+ }
+
+ if (archList != null) {
+ Iterator archIter = archList.listIterator();
+ String listValue = EMPTY_STRING;
+ while (archIter.hasNext()) {
+ String current = (String) archIter.next();
+ listValue += current;
+ if ((archIter.hasNext())) {
+ listValue += ","; //$NON-NLS-1$
+ }
+ }
+ element.setAttribute(ARCH_LIST, listValue);
+ }
+
+ // Serialize elements from my super class
+ super.serialize(doc, element);
+
+ // Serialize my children
+ if (targetPlatform != null) {
+ Element targetPlatformElement = doc.createElement(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
+ element.appendChild(targetPlatformElement);
+ targetPlatform.serialize(doc, targetPlatformElement);
+ }
+ if (builder != null) {
+ Element builderElement = doc.createElement(IBuilder.BUILDER_ELEMENT_NAME);
+ element.appendChild(builderElement);
+ builder.serialize(doc, builderElement);
+ }
+ List toolElements = getToolList();
+ Iterator iter = toolElements.listIterator();
+ while (iter.hasNext()) {
+ Tool tool = (Tool) iter.next();
+ Element toolElement = doc.createElement(ITool.TOOL_ELEMENT_NAME);
+ element.appendChild(toolElement);
+ tool.serialize(doc, toolElement);
+ }
+
+ // Note: isToolChainSupported cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if (managedIsToolChainSupportedElement != null) {
+ // TODO: issue warning?
+ }
+
+ // Note: environmentVariableSupplier cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if(environmentVariableSupplierElement != null) {
+ // TODO: issue warning?
+ }
+
+ // Note: buildMacroSupplier cannot be specified in a project file because
+ // an IConfigurationElement is needed to load it!
+ if(buildMacroSupplierElement != null) {
+ // TODO: issue warning?
+ }
+
+ //serialize user-defined macros
+ if(userDefinedMacros != null){
+ Element macrosElement = doc.createElement(StorableMacros.MACROS_ELEMENT_NAME);
+ element.appendChild(macrosElement);
+ userDefinedMacros.serialize(doc,macrosElement);
+ }
+
+ if(userDefinedEnvironment != null)
+ EnvironmentVariableProvider.fUserSupplier.storeEnvironment(getParent(),true);
+
+ // I am clean now
+ isDirty = false;
+ } catch (Exception e) {
+ // TODO: issue an error message
+ }
+}
+
+ /*
+ * P A R E N T A N D C H I L D H A N D L I N G
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getConfiguration()
+ */
+ public IConfiguration getParent() {
+ return parent;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#createTargetPlatform(ITargetPlatform, String, String, boolean)
+ */
+ public ITargetPlatform createTargetPlatform(ITargetPlatform superClass, String id, String name, boolean isExtensionElement) {
+ targetPlatform = new TargetPlatform(this, superClass, id, name, isExtensionElement);
+ setDirty(true);
+ return (ITargetPlatform)targetPlatform;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getTargetPlatform()
+ */
+ public ITargetPlatform getTargetPlatform() {
+ if (targetPlatform == null) {
+ if (getSuperClass() != null) {
+ return getSuperClass().getTargetPlatform();
+ }
+ }
+ return (ITargetPlatform)targetPlatform;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalTargetPlatform()
+ */
+ public void removeLocalTargetPlatform() {
+ if (targetPlatform == null) return;
+ targetPlatform = null;
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#createBuilder(IBuilder, String, String, boolean)
+ */
+ public IBuilder createBuilder(IBuilder superClass, String id, String name, boolean isExtensionElement) {
+ builder = new Builder(this, superClass, id, name, isExtensionElement);
+ setDirty(true);
+ return (IBuilder)builder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getBuilder()
+ */
+ public IBuilder getBuilder() {
+ if (builder == null) {
+ if (getSuperClass() != null) {
+ return getSuperClass().getBuilder();
+ }
+ }
+ return (IBuilder)builder;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalBuilder()
+ */
+ public void removeLocalBuilder() {
+ if (builder == null) return;
+ builder = null;
+ setDirty(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#createTool(ITool, String, String, boolean)
+ */
+ public ITool createTool(ITool superClass, String id, String name, boolean isExtensionElement) {
+ Tool tool = new Tool(this, superClass, id, name, isExtensionElement);
+ addTool(tool);
+ setDirty(true);
+ return (ITool)tool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getTools()
+ */
+ public ITool[] getTools() {
+ ITool[] tools = null;
+ // Merge our tools with our superclass' tools
+ if (getSuperClass() != null) {
+ tools = getSuperClass().getTools();
+ }
+ // Our tools take precedence
+ if (tools != null) {
+ Iterator iter = getToolList().listIterator();
+ while (iter.hasNext()) {
+ Tool tool = (Tool)iter.next();
+ int j;
+ for (j = 0; j < tools.length; j++) {
+ if (tool.getSuperClass() != null // Remove assumption that ALL tools must have superclasses
+ && tool.getSuperClass().getId().equals(tools[j].getId())) {
+ tools[j] = tool;
+ break;
+ }
+ }
+ // No Match? Insert it (may be re-ordered)
+ if (j == tools.length) {
+ ITool[] newTools = new ITool[tools.length + 1];
+ for (int k = 0; k < tools.length; k++) {
+ newTools[k] = tools[k];
+ }
+ newTools[j] = tool;
+ tools = newTools;
+ }
+ }
+ } else {
+ tools = new ITool[getToolList().size()];
+ Iterator iter = getToolList().listIterator();
+ int i = 0;
+ while (iter.hasNext()) {
+ Tool tool = (Tool)iter.next();
+ tools[i++] = (ITool)tool;
+ }
+ }
+ return tools;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTool(java.lang.String)
+ */
+ public ITool getTool(String id) {
+ Tool tool = (Tool)getToolMap().get(id);
+ return (ITool)tool;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getToolsBySuperClassId(java.lang.String)
+ */
+ public ITool[] getToolsBySuperClassId(String id) {
+ List retTools = new ArrayList();
+ if (id != null) {
+ // Look for a tool with this ID, or the tool(s) with a superclass with this id
+ ITool[] tools = getTools();
+ for (int i = 0; i < tools.length; i++) {
+ ITool targetTool = tools[i];
+ ITool tool = targetTool;
+ do {
+ if (id.equals(tool.getId())) {
+ retTools.add(targetTool);
+ break;
+ }
+ tool = tool.getSuperClass();
+ } while (tool != null);
+ }
+ }
+ return (ITool[])retTools.toArray( new ITool[retTools.size()]);
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the list of tools.
+ *
+ * @return List containing the tools
+ */
+ public List getToolList() {
+ if (toolList == null) {
+ toolList = new ArrayList();
+ }
+ return toolList;
+ }
+
+ /* (non-Javadoc)
+ * Safe accessor for the map of tool ids to tools
+ *
+ * @return
+ */
+ private Map getToolMap() {
+ if (toolMap == null) {
+ toolMap = new HashMap();
+ }
+ return toolMap;
+ }
+
+ /* (non-Javadoc)
+ * Adds the Tool to the Tool-chain list and map
+ *
+ * @param Tool
+ */
+ public void addTool(Tool tool) {
+ getToolList().add(tool);
+ getToolMap().put(tool.getId(), tool);
+ }
+
+ /*
+ * M O D E L A T T R I B U T E A C C E S S O R S
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSuperClass()
+ */
+ public IToolChain getSuperClass() {
+ return (IToolChain)superClass;
+ }
+
+ /* (non-Javadoc)
+ * Access function to set the superclass element that is defined in
+ * the base class.
+ */
+ private void setSuperClassInternal(IToolChain superClass) {
+ this.superClass = superClass;
+ }
+
+ public void setSuperClass(IToolChain superClass) {
+ if ( this.superClass != superClass ) {
+ this.superClass = superClass;
+ if ( this.superClass == null) {
+ superClassId = null;
+ } else {
+ superClassId = this.superClass.getId();
+ }
+
+ if(!isExtensionElement())
+ setDirty(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getName()
+ */
+ public String getName() {
+ return (name == null && getSuperClass() != null) ? getSuperClass().getName() : name;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#isAbstract()
+ */
+ public boolean isAbstract() {
+ if (isAbstract != null) {
+ return isAbstract.booleanValue();
+ } else {
+ return false; // Note: no inheritance from superClass
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IToolChain#getUnusedChildren()
+ */
+ public String getUnusedChildren() {
+ if (unusedChildren != null) {
+ return unusedChildren;
+ } else
+ return EMPTY_STRING; // Note: no inheritance from superClass
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ String ids = errorParserIds;
+ if (ids == null) {
+ // If I have a superClass, ask it
+ if (getSuperClass() != null) {
+ ids = getSuperClass().getErrorParserIds();
+ }
+ }
+ if (ids == null) {
+ // Collect the error parsers from my children
+ ids = builder.getErrorParserIds();
+ ITool[] tools = getTools();
+ for (int i = 0; i < tools.length; i++) {
+ ITool tool = tools[i];
+ String toolIds = tool.getErrorParserIds();
+ if (toolIds != null && toolIds.length() > 0) {
+ if (ids != null) {
+ ids += ";"; //$NON-NLS-1$
+ ids += toolIds;
+ } else {
+ ids = toolIds;
+ }
+ }
+ }
+ }
+ return ids;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSecondaryOutputs()
+ */
+ public IOutputType[] getSecondaryOutputs() {
+ IOutputType[] types = null;
+ String ids = secondaryOutputIds;
+ if (ids == null) {
+ if (getSuperClass() != null) {
+ return getSuperClass().getSecondaryOutputs();
+ }
+ else {
+ return new IOutputType[0];
+ }
+ }
+ StringTokenizer tok = new StringTokenizer(ids, ";"); //$NON-NLS-1$
+ types = new IOutputType[tok.countTokens()];
+ ITool[] tools = getTools();
+ int i = 0;
+ while (tok.hasMoreElements()) {
+ String id = tok.nextToken();
+ for (int j=0; jnull
if none.
+ *
+ * @return IConfigurationElement
+ */
+ public IConfigurationElement getEnvironmentVariableSupplierElement(){
+ if (environmentVariableSupplierElement == null) {
+ if (getSuperClass() != null && getSuperClass() instanceof ToolChain) {
+ return ((ToolChain)getSuperClass()).getEnvironmentVariableSupplierElement();
+ }
+ }
+ return environmentVariableSupplierElement;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getEnvironmentVariableSupplier()
+ */
+ public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
+ if (environmentVariableSupplier != null) {
+ return environmentVariableSupplier;
+ }
+ IConfigurationElement element = getEnvironmentVariableSupplierElement();
+ if (element != null) {
+ try {
+ if (element.getAttribute(CONFIGURATION_ENVIRONMENT_SUPPLIER) != null) {
+ environmentVariableSupplier = (IConfigurationEnvironmentVariableSupplier) element.createExecutableExtension(CONFIGURATION_ENVIRONMENT_SUPPLIER);
+ return environmentVariableSupplier;
+ }
+ } catch (CoreException e) {}
+ }
+ return null;
+ }
+
+ /*
+ * this method is called by the UserDefinedMacroSupplier to obtain user-defined
+ * macros available for this tool-chain
+ */
+ public StorableMacros getUserDefinedMacros(){
+ if(isExtensionToolChain)
+ return null;
+
+ if(userDefinedMacros == null)
+ userDefinedMacros = new StorableMacros();
+ return userDefinedMacros;
+ }
+
+ public StorableEnvironment getUserDefinedEnvironment(){
+ if(isExtensionToolChain)
+ return null;
+
+ return userDefinedEnvironment;
+ }
+
+ public void setUserDefinedEnvironment(StorableEnvironment env){
+ if(!isExtensionToolChain)
+ userDefinedEnvironment = env;
+ }
+
+
+ /**
+ * Returns the plugin.xml element of the configurationMacroSupplier extension or null
if none.
+ *
+ * @return IConfigurationElement
+ */
+ public IConfigurationElement getBuildMacroSupplierElement(){
+ if (buildMacroSupplierElement == null) {
+ if (superClass != null && superClass instanceof ToolChain) {
+ return ((ToolChain)superClass).getBuildMacroSupplierElement();
+ }
+ }
+ return buildMacroSupplierElement;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolChain#getBuildMacroSupplier()
+ */
+ public IConfigurationBuildMacroSupplier getBuildMacroSupplier(){
+ if (buildMacroSupplier != null) {
+ return buildMacroSupplier;
+ }
+ IConfigurationElement element = getBuildMacroSupplierElement();
+ if (element != null) {
+ try {
+ if (element.getAttribute(CONFIGURATION_MACRO_SUPPLIER) != null) {
+ buildMacroSupplier = (IConfigurationBuildMacroSupplier) element.createExecutableExtension(CONFIGURATION_MACRO_SUPPLIER);
+ return buildMacroSupplier;
+ }
+ } catch (CoreException e) {}
+ }
+ return null;
+ }
+
+ /*
+ * This function checks for migration support for the toolchain, while
+ * loading. If migration support is needed, looks for the available
+ * converters and adds them to the list.
+ */
+
+ public void checkForMigrationSupport() {
+
+ boolean isExists = false;
+
+ if (getSuperClass() == null) {
+ // If 'getSuperClass()' is null, then there is no toolchain available in
+ // plugin manifest file with the 'id' & version.
+ // Look for the 'versionsSupported' attribute
+ String high = (String) ManagedBuildManager
+ .getExtensionToolChainMap().lastKey();
+
+ SortedMap subMap = null;
+ if (superClassId.compareTo(high) <= 0) {
+ subMap = ManagedBuildManager.getExtensionToolChainMap().subMap(
+ superClassId, high + "\0"); //$NON-NLS-1$
+ } else {
+ // It means there are no entries in the map for the given id.
+ // make the project is invalid
+ IConfiguration parentConfig = getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ return;
+ }
+
+ // for each element in the 'subMap',
+ // check the 'versionsSupported' attribute whether the given
+ // toolChain version is supported
+
+ String baseId = ManagedBuildManager.getIdFromIdAndVersion(superClassId);
+ String version = getVersionFromId().toString();
+
+ IToolChain[] toolChainElements = (IToolChain[]) subMap.values().toArray();
+
+ for (int i = 0; i < toolChainElements.length; i++) {
+ IToolChain toolChainElement = toolChainElements[i];
+
+ if (ManagedBuildManager.getIdFromIdAndVersion(
+ toolChainElement.getId()).compareTo(baseId) > 0)
+ break;
+
+ // First check if both base ids are equal
+ if (ManagedBuildManager.getIdFromIdAndVersion(
+ toolChainElement.getId()).equals(baseId)) {
+
+ // Check if 'versionsSupported' attribute is available'
+ String versionsSupported = toolChainElement.getVersionsSupported();
+
+ if ((versionsSupported != null)
+ && (!versionsSupported.equals(""))) { //$NON-NLS-1$
+ String[] tmpVersions = versionsSupported.split(","); //$NON-NLS-1$
+
+ for (int j = 0; j < tmpVersions.length; j++) {
+ if (new PluginVersionIdentifier(version).equals(new PluginVersionIdentifier(tmpVersions[j]))) {
+ // version is supported.
+ // Do the automatic conversion without
+ // prompting the user.
+ // Get the supported version
+ String supportedVersion = ManagedBuildManager.getVersionFromIdAndVersion(
+ toolChainElement.getId());
+ setId(ManagedBuildManager.getIdFromIdAndVersion(getId())
+ + "_" + supportedVersion); //$NON-NLS-1$
+
+ // If control comes here means that 'superClass' is null
+ // So, set the superClass to this toolChain element
+ setSuperClassInternal(toolChainElement);
+ superClassId = getSuperClass().getId();
+ isExists = true;
+ break;
+ }
+ }
+ if(isExists)
+ break; // break the outer for loop if 'isExists' is true
+ }
+ }
+ }
+ }
+
+ if (getSuperClass() != null) {
+ // If 'getSuperClass()' is not null, look for 'convertToId' attribute in plugin
+ // manifest file for this toolchain.
+ String convertToId = getSuperClass().getConvertToId();
+ if ((convertToId == null) || (convertToId.equals(""))) { //$NON-NLS-1$
+ // It means there is no 'convertToId' attribute available and
+ // the version is still actively
+ // supported by the tool integrator. So do nothing, just return
+ return;
+ } else {
+ // In case the 'convertToId' attribute is available,
+ // it means that Tool integrator currently does not support this
+ // version of toolchain.
+ // Look for the converters available for this toolchain version.
+
+ getConverter(convertToId);
+ }
+
+ } else {
+ // make the project is invalid
+ //
+ IConfiguration parentConfig = getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ }
+ return;
+ }
+
+ private void getConverter(String convertToId) {
+
+ String fromId = null;
+ String toId = null;
+
+ // Get the Converter Extension Point
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
+ .getExtensionPoint("org.eclipse.cdt.managedbuilder.core", //$NON-NLS-1$
+ "projectConverter"); //$NON-NLS-1$
+ if (extensionPoint != null) {
+ // Get the extensions
+ IExtension[] extensions = extensionPoint.getExtensions();
+ for (int i = 0; i < extensions.length; i++) {
+ // Get the configuration elements of each extension
+ IConfigurationElement[] configElements = extensions[i]
+ .getConfigurationElements();
+ for (int j = 0; j < configElements.length; j++) {
+
+ IConfigurationElement element = configElements[j];
+
+ if (element.getName().equals("converter")) { //$NON-NLS-1$
+
+ fromId = element.getAttribute("fromId"); //$NON-NLS-1$
+ toId = element.getAttribute("toId"); //$NON-NLS-1$
+ // Check whether the current converter can be used for
+ // the selected toolchain
+
+ if (fromId.equals(getSuperClass().getId())
+ && toId.equals(convertToId)) {
+ // If it matches
+ String mbsVersion = element
+ .getAttribute("mbsVersion"); //$NON-NLS-1$
+ PluginVersionIdentifier currentMbsVersion = ManagedBuildManager
+ .getBuildInfoVersion();
+
+ // set the converter element based on the MbsVersion
+ if (currentMbsVersion
+ .isGreaterThan(new PluginVersionIdentifier(
+ mbsVersion))) {
+ previousMbsVersionConversionElement = element;
+ } else {
+ currentMbsVersionConversionElement = element;
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ // If control comes here, it means 'Tool Integrator' specified
+ // 'convertToId' attribute in toolchain definition file, but
+ // has not provided any converter.
+ // So, make the project is invalid
+
+ IConfiguration parentConfig = getParent();
+ IManagedProject managedProject = parentConfig.getManagedProject();
+ if (managedProject != null) {
+ managedProject.setValid(false);
+ }
+ }
+
+
+ public IConfigurationElement getPreviousMbsVersionConversionElement() {
+ return previousMbsVersionConversionElement;
+ }
+
+ public IConfigurationElement getCurrentMbsVersionConversionElement() {
+ return currentMbsVersionConversionElement;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
+ */
+ public void updateManagedBuildRevision(String revision){
+ super.updateManagedBuildRevision(revision);
+
+ for(Iterator iter = getToolList().iterator(); iter.hasNext();){
+ ((Tool)iter.next()).updateManagedBuildRevision(revision);
+ }
+
+ if(builder != null)
+ builder.updateManagedBuildRevision(revision);
+ }
+
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
index 34feff3a9cd..cb150d7e7d8 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ToolReference.java
@@ -1,1254 +1,1254 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.internal.core;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
-import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
-import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
-import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
-import org.eclipse.cdt.managedbuilder.core.IOutputType;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IToolChain;
-import org.eclipse.cdt.managedbuilder.core.IToolReference;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.PluginVersionIdentifier;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class ToolReference implements IToolReference {
- private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
-
- private String command;
- private boolean isDirty = false;
- private List optionReferences;
- private IBuildObject owner;
- private String outputExtensions;
- private String outputFlag;
- private String outputPrefix;
- protected ITool parent;
- private boolean resolved = true;
- private String versionsSupported;
- private String convertToId;
-
- /**
- * Create a new tool reference based on information contained in
- * a project file.
- *
- * @param owner The ConfigurationV2
the receiver will be added to.
- * @param element The element defined in the project file containing build information
- * for the receiver.
- */
- public ToolReference(BuildObject owner, Element element) {
- this.owner = owner;
-
- if (owner instanceof ConfigurationV2) {
- if (parent == null) {
- Target parentTarget = (Target) ((ConfigurationV2)owner).getTarget();
- try {
- parent = ((Target)parentTarget.getParent()).getTool(element.getAttribute(ID));
- } catch (NullPointerException e) {
- parent = null;
- }
- }
- ((ConfigurationV2)owner).addToolReference(this);
- } else if (owner instanceof Target) {
- if (parent == null) {
- try {
- parent = ((Target)((Target)owner).getParent()).getTool(element.getAttribute(ID));
- } catch (NullPointerException e) {
- parent = null;
- }
- }
- ((Target)owner).addToolReference(this);
- }
-
- // Get the overridden tool command (if any)
- if (element.hasAttribute(ITool.COMMAND)) {
- command = element.getAttribute(ITool.COMMAND);
- }
-
- // Get the overridden output prefix (if any)
- if (element.hasAttribute(ITool.OUTPUT_PREFIX)) {
- outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
- }
-
- // Get the output extensions the reference produces
- if (element.hasAttribute(ITool.OUTPUTS)) {
- outputExtensions = element.getAttribute(ITool.OUTPUTS);
- }
- // Get the flag to control output
- if (element.hasAttribute(ITool.OUTPUT_FLAG))
- outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
-
- NodeList configElements = element.getChildNodes();
- for (int i = 0; i < configElements.getLength(); ++i) {
- Node configElement = configElements.item(i);
- if (configElement.getNodeName().equals(ITool.OPTION_REF)) {
- new OptionReference(this, (Element)configElement);
- }
- }
- }
-
- /**
- * Created tool reference from an extension defined in a plugin manifest.
- *
- * @param owner The BuildObject
the receiver will be added to.
- * @param element The element containing build information for the reference.
- */
- public ToolReference(BuildObject owner, IManagedConfigElement element) {
- // setup for resolving
- ManagedBuildManager.putConfigElement(this, element);
- resolved = false;
-
- this.owner = owner;
-
- // hook me up
- if (owner instanceof ConfigurationV2) {
- ((ConfigurationV2)owner).addToolReference(this);
- } else if (owner instanceof Target) {
- ((Target)owner).addToolReference(this);
- }
-
- // Get the overridden tool command (if any)
- command = element.getAttribute(ITool.COMMAND);
-
- // Get the overridden output prefix, if any
- outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
-
- // Get the overridden output extensions (if any)
- String output = element.getAttribute(ITool.OUTPUTS);
- if (output != null) {
- outputExtensions = output;
- }
-
- // Get the flag to control output
- outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
-
- IManagedConfigElement[] toolElements = element.getChildren();
- for (int m = 0; m < toolElements.length; ++m) {
- IManagedConfigElement toolElement = toolElements[m];
- if (toolElement.getName().equals(ITool.OPTION_REF)) {
- new OptionReference(this, toolElement);
- }
- }
- }
-
- /**
- * Created a tool reference on the fly based on an existing tool or tool reference.
- *
- * @param owner The BuildObject
the receiver will be added to.
- * @param tool The ITool
tool the reference will be based on.
- */
- public ToolReference(BuildObject owner, ITool tool) {
- this.owner = owner;
- if (tool instanceof ToolReference) {
- parent = ((ToolReference)tool).getTool();
- } else {
- parent = tool;
- }
- command = tool.getToolCommand();
- outputFlag = tool.getOutputFlag();
- outputPrefix = tool.getOutputPrefix();
- String[] extensions = tool.getOutputsAttribute();
- outputExtensions = new String();
- if (extensions != null) {
- for (int index = 0; index < extensions.length; ++index) {
- if (extensions[index] == null) continue;
- outputExtensions += extensions[index];
- if (index < extensions.length - 1) {
- outputExtensions += DEFAULT_SEPARATOR;
- }
- }
- }
-
- // Create a copy of the option references of the parent in the receiver
- if (tool instanceof ToolReference) {
- List parentRefs = ((ToolReference)tool).getOptionReferenceList();
- Iterator iter = parentRefs.iterator();
- while (iter.hasNext()) {
- IOption parent = (IOption)iter.next();
- OptionReference clone = createOptionReference(parent);
- try {
- switch (parent.getValueType()) {
- case IOption.BOOLEAN:
- clone.setValue(parent.getBooleanValue());
- break;
- case IOption.STRING:
- clone.setValue(parent.getStringValue());
- case IOption.ENUMERATED:
- clone.setValue(parent.getSelectedEnum());
- break;
- default:
- clone.setValue(parent.getStringListValue());
- break;
- }
- } catch (BuildException e) {
- // Likely a mismatch between the value and option type
- continue;
- }
- }
- }
-
- if (owner instanceof ConfigurationV2) {
- ((ConfigurationV2)owner).addToolReference(this);
- } else if (owner instanceof Target) {
- ((Target)owner).addToolReference(this);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#references(org.eclipse.cdt.managedbuilder.core.ITool)
- */
- public boolean references(ITool target) {
- if (equals(target)) {
- // we are the target
- return true;
- } else if (parent == null) {
- // basic sanity before proceeding
- return false;
- } else if (parent instanceof IToolReference) {
- // check the reference we are overriding
- return ((IToolReference)parent).references(target);
- } else if (target instanceof IToolReference) {
- return parent.equals(((IToolReference)target).getTool());
- } else {
- // the real reference
- return parent.equals(target);
- }
- }
-
- public void resolveReferences() {
- if (!resolved) {
- resolved = true;
- IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
- // resolve my parent
- if (owner instanceof ConfigurationV2) {
- Target target = (Target) ((ConfigurationV2)owner).getTarget();
- parent = target.getTool(element.getAttribute(ID));
- } else if (owner instanceof Target) {
- parent = ((Target)owner).getTool(element.getAttribute(ID));
- }
- // recursively resolve my parent
- if (parent instanceof Tool) {
- ((Tool)parent).resolveReferences();
- } else if (parent instanceof ToolReference) {
- ((ToolReference)parent).resolveReferences();
- }
-
- Iterator it = getOptionReferenceList().iterator();
- while (it.hasNext()) {
- OptionReference optRef = (OptionReference)it.next();
- optRef.resolveReferences();
- }
- }
- }
-
- /**
- * Adds the option reference specified in the argument to the receiver.
- *
- * @param optionRef
- */
- public void addOptionReference(OptionReference optionRef) {
- getOptionReferenceList().add(optionRef);
- isDirty = true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#buildsFileType(java.lang.String)
- */
- public boolean buildsFileType(String extension) {
- if (parent == null) {
- // bad reference
- return false;
- }
- return parent.buildsFileType(extension);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#buildsFileType(java.lang.String)
- */
- public boolean isInputFileType(String extension) {
- if (parent == null) {
- // bad reference
- return false;
- }
- return parent.isInputFileType(extension);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#createOptionReference(org.eclipse.cdt.managedbuilder.core.IOption)
- */
- public OptionReference createOptionReference(IOption option) {
- // Check if the option reference already exists
- OptionReference ref = getOptionReference(option);
- // It is possible that the search will return an option reference
- // that is supplied by another element of the build model, not the caller.
- // For example, if the search is starated by a configuration and the target
- // the caller belongs to has an option reference for the option, it
- // will be returned. While this is correct behaviour for a search, the
- // caller will need to create a clone for itself, so make sure the tool
- // reference of the search result is owned by the caller
- if (ref == null || !ref.getToolReference().owner.equals(this.owner)) {
- ref = new OptionReference(this, option);
- }
- return ref;
- }
-
- /* (non-Javadoc)
- * @return
- */
- protected List getAllOptionRefs() {
- // First get all the option references this tool reference contains
- if (owner instanceof ConfigurationV2) {
- return ((ConfigurationV2)owner).getOptionReferences(parent);
- } else if (owner instanceof Target) {
- return ((Target)owner).getOptionReferences(parent);
- } else {
- // this shouldn't happen
- return null;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getId()
- */
- public String getId() {
- if (parent == null) {
- // bad reference
- return new String();
- }
- return parent.getId();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getBaseId()
- */
- public String getBaseId() {
- if (parent == null) {
- // bad reference
- return new String();
- }
- return parent.getBaseId();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getInputExtensions()
- */
- public List getInputExtensions() {
- String[] exts = getPrimaryInputExtensions();
- List extList = new ArrayList();
- for (int i=0; inull
- *
- * @param option
- * @return OptionReference
- */
- private OptionReference getOptionReference(IOption option) {
- // Get all the option references for this option
- Iterator iter = getAllOptionRefs().listIterator();
- while (iter.hasNext()) {
- OptionReference optionRef = (OptionReference) iter.next();
- if (optionRef.references(option))
- return optionRef;
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- *
- * @param id
- * @return
- */
- /*
- private OptionReference getOptionReference(String id) {
- Iterator it = getOptionReferenceList().iterator();
- while (it.hasNext()) {
- OptionReference current = (OptionReference)it.next();
- if (current.getId().equals(id)) {
- return current;
- }
- }
- return null;
- }
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getOptionReferenceList()
- */
- public List getOptionReferenceList() {
- if (optionReferences == null) {
- optionReferences = new ArrayList();
- }
- return optionReferences;
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getOptions()
- */
- public IOption[] getOptions() {
- IOption[] options = parent.getOptions();
-
- // Replace with our references
- for (int i = 0; i < options.length; ++i) {
- OptionReference ref = getOptionReference(options[i]);
- if (ref != null)
- options[i] = ref;
- }
-
- return options;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputExtensions()
- */
- public String[] getOutputExtensions() {
- if (outputExtensions == null){
- if (parent != null) {
- return parent.getOutputsAttribute();
- } else {
- return new String[0];
- }
- }
- return outputExtensions.split(DEFAULT_SEPARATOR);
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputExtension(java.lang.String)
- */
- public String getOutputExtension(String inputExtension) {
- if (parent == null) {
- // bad reference
- return new String();
- }
- return parent.getOutputExtension(inputExtension);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputFlag()
- */
- public String getOutputFlag() {
- if (outputFlag == null) {
- if (parent != null) {
- return parent.getOutputFlag();
- } else {
- // We never should be here
- return new String();
- }
- }
- return outputFlag;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputPrefix()
- */
- public String getOutputPrefix() {
- if (outputPrefix == null) {
- if (parent != null) {
- return parent.getOutputPrefix();
- }
- return new String(); // bad reference
- }
- return outputPrefix;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#isDirty()
- */
- public boolean isDirty() {
- return isDirty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#isHeaderFile(java.lang.String)
- */
- public boolean isHeaderFile(String ext) {
- if (parent == null) {
- // bad reference
- return false;
- }
- return parent.isHeaderFile(ext);
- }
-
- /**
- * Answers true
if the owner of the receiver matches
- * the argument.
- *
- * @param config
- * @return
- */
- public boolean ownedByConfiguration(IConfigurationV2 config) {
- if (owner instanceof ConfigurationV2) {
- return ((IConfigurationV2)owner).equals(config);
- }
- return false;
- }
-
- /**
- * Persist receiver to project file.
- *
- * @param doc The persistent store for the reference information.
- * @param element The root element in the store the receiver must use
- * to persist settings.
- */
- public void serialize(Document doc, Element element) {
- if (parent == null) return; // This is a bad reference
- element.setAttribute(ITool.ID, parent.getId());
-
- // Output the command
- if (command != null) {
- element.setAttribute(ITool.COMMAND, getToolCommand());
- }
-
- // Save output prefix
- if (outputPrefix != null) {
- element.setAttribute(ITool.OUTPUT_PREFIX, getOutputPrefix());
- }
-
- // Save the output flag
- if (outputFlag != null) {
- element.setAttribute(ITool.OUTPUT_FLAG, getOutputFlag());
- }
-
- // Save the outputs
- if (outputExtensions != null) {
- element.setAttribute(ITool.OUTPUTS, outputExtensions);
- }
-
- // Output the option references
- Iterator iter = getOptionReferenceList().listIterator();
- while (iter.hasNext()) {
- OptionReference optionRef = (OptionReference) iter.next();
- Element optionRefElement = doc.createElement(ITool.OPTION_REF);
- element.appendChild(optionRefElement);
- optionRef.serialize(doc, optionRefElement);
- }
-
- // Set the reference to clean
- isDirty = false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#setDirty(boolean)
- */
- public void setDirty(boolean isDirty) {
- // Override the local flag
- this.isDirty = isDirty;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#setToolCommand(java.lang.String)
- */
- public boolean setToolCommand(String cmd) {
- if (cmd != null && !cmd.equals(command)) {
- command = cmd;
- isDirty = true;
- return true;
- } else {
- return false;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputFlag(java.lang.String)
- */
- public void setOutputFlag(String flag) {
- if (flag == null) return;
- if (outputFlag == null || !(flag.equals(outputFlag))) {
- outputFlag = flag;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputPrefix(java.lang.String)
- */
- public void setOutputPrefix(String prefix) {
- if (prefix == null) return;
- if (outputPrefix == null || !(prefix.equals(outputPrefix))) {
- outputPrefix = prefix;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputExtensions(java.lang.String)
- */
- public void setOutputExtensions(String ext) {
- if (ext == null) return;
- if (outputExtensions == null || !(ext.equals(outputExtensions))) {
- outputExtensions = ext;
- isDirty = true;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#setParent(IBuildObject)
- */
- public void setToolParent(IBuildObject newParent) {
- if (parent == null) {
- // bad reference
- return;
- }
- // Set the parent in the parent of this ToolRefernce, the tool
- ((Tool)parent).setToolParent(newParent);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getParent()
- */
- public IBuildObject getParent() {
- return owner;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLinePattern()
- */
- public String getCommandLinePattern() {
- if( parent == null ) return new String();
- return parent.getCommandLinePattern();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLineGenerator()
- */
- public IManagedCommandLineGenerator getCommandLineGenerator() {
- if( parent == null ) return null;
- return parent.getCommandLineGenerator();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getDependencyGenerator()
- */
- public IManagedDependencyGenerator getDependencyGenerator() {
- if( parent == null ) return null;
- return parent.getDependencyGenerator();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getCommandFlags()
- */
- public String[] getCommandFlags() throws BuildException {
- if( parent == null ) return null;
- return parent.getToolCommandFlags(null, null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getToolCommandFlags(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
- */
- public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation) throws BuildException{
- return getCommandFlags();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getToolCommandFlagsString(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
- */
- public String getToolCommandFlagsString(IPath inputFileLocation, IPath outputFileLocation) throws BuildException{
- return getToolFlags();
-
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- String answer = new String();
- if (parent != null) {
- answer += "Reference to " + parent.getName(); //$NON-NLS-1$
- }
-
- if (answer.length() > 0) {
- return answer;
- } else {
- return super.toString();
- }
- }
-
- /*
- * The following methods are here in order to implement the new ITool methods.
- * They should never be called.
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getSuperClass()
- */
- public ITool getSuperClass() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#isAbstract()
- */
- public boolean isAbstract() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getUnusedChildren()
- */
- public String getUnusedChildren() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getErrorParserList()
- */
- public String[] getErrorParserList() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getErrorParserIds()
- */
- public String getErrorParserIds() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#setErrorParserIds()
- */
- public void setErrorParserIds(String ids) {
- }
-
- public List getInterfaceExtensions() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#isExtensionElement()
- */
- public boolean isExtensionElement() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#createOption()
- */
- public IOption createOption(IOption superClass, String Id, String name, boolean b) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOptions()
- */
- public void createOptions(IHoldsOptions options) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#removeOption()
- */
- public void removeOption(IOption o) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
- */
- public IOptionCategory[] getChildCategories() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#setIsAbstract(boolean)
- */
- public void setIsAbstract(boolean b) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLinePattern()
- */
- public void setCommandLinePattern(String pattern) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#setCommandLineGenerator(IConfigurationElement)
- */
- public void setCommandLineGeneratorElement(IConfigurationElement element) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLineGenerator()
- */
- public IConfigurationElement getDependencyGeneratorElement() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#setCommandLineGenerator(IConfigurationElement)
- */
- public void setDependencyGeneratorElement(IConfigurationElement element) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLineGeneratorElement()
- */
- public IConfigurationElement getCommandLineGeneratorElement() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getAdvancedInputCategory()
- */
- public boolean getAdvancedInputCategory() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#setAdvancedInputCategory()
- */
- public void setAdvancedInputCategory(boolean display) {
- }
-
- public IInputType createInputType(IInputType superClass, String Id, String name, boolean isExtensionElement) {
- return null;
- }
-
- public IOutputType createOutputType(IOutputType superClass, String Id, String name, boolean isExtensionElement) {
- return null;
- }
-
- public String getAnnouncement() {
- return null;
- }
-
- public IInputType getInputTypeById(String id) {
- return null;
- }
-
- public IInputType[] getInputTypes() {
- return null;
- }
-
- public IOutputType getOutputTypeById(String id) {
- return null;
- }
-
- public IOutputType[] getOutputTypes() {
- return null;
- }
-
- public void removeInputType(IInputType type) {
- }
-
- public void removeOutputType(IOutputType type) {
- }
-
- public void setAnnouncement(String announcement) {
- }
-
- public String getDefaultInputExtension() {
- return null;
- }
-
- public String[] getAllInputExtensions() {
- return null;
- }
-
- public String[] getPrimaryInputExtensions() {
- return null;
- }
-
- public IInputType getInputType(String inputExtension) {
- return null;
- }
-
- public String[] getOutputsAttribute() {
- return null;
- }
-
- public IOutputType getOutputType(String outputExtension) {
- return null;
- }
-
- public void setOutputsAttribute(String extensions) {
- }
-
- public String[] getAllOutputExtensions() {
- return null;
- }
-
- public String[] getAllDependencyExtensions() {
- return null;
- }
-
- public IInputType getPrimaryInputType() {
- return null;
- }
-
- public IOutputType getPrimaryOutputType() {
- return null;
- }
-
- public IPath[] getAdditionalDependencies() {
- return null;
- }
-
- public IPath[] getAdditionalResources() {
- return null;
- }
-
- public IConfigurationElement getDependencyGeneratorElementForExtension(String sourceExt) {
- return null;
- }
-
- public IManagedDependencyGeneratorType getDependencyGeneratorForExtension(String sourceExt) {
- return null;
- }
-
- public boolean getCustomBuildStep() {
- return false;
- }
-
- public void setCustomBuildStep(boolean customBuildStep) {
- }
-
- public IOption getOptionBySuperClassId(String id) {
- return null;
- }
-
- public IOptionCategory getOptionCategory(String id) {
- // return null as class is deprecated
- return null;
- }
-
- public void addOptionCategory(IOptionCategory category) {
- }
-
- /*
- * The following methods are added to allow the converter from ToolReference -> Tool
- * to retrieve the actual value of attributes. These routines do not go to the
- * referenced Tool for a value if the ToolReference does not have a value.
- */
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawOutputExtensions()
- */
- public String getRawOutputExtensions() {
- return outputExtensions;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawOutputFlag()
- */
- public String getRawOutputFlag() {
- return outputFlag;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawOutputPrefix()
- */
- public String getRawOutputPrefix() {
- return outputPrefix;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawToolCommand()
- */
- public String getRawToolCommand() {
- return command;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getConvertToId()
- */
- public String getConvertToId() {
- if (convertToId == null) {
- // If I have a superClass, ask it
- if (parent != null) {
- return parent.getConvertToId();
- } else {
- return new String();
- }
- }
- return convertToId;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#setConvertToId(String)
- */
- public void setConvertToId(String convertToId) {
- if (convertToId == null && this.convertToId == null) return;
- if (convertToId == null || this.convertToId == null || !convertToId.equals(this.convertToId)) {
- this.convertToId = convertToId;
- setDirty(true);
- }
- return;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#getVersionsSupported()
- */
- public String getVersionsSupported() {
- if (versionsSupported == null) {
- // If I have a superClass, ask it
- if (parent != null) {
- return parent.getVersionsSupported();
- } else {
- return new String();
- }
- }
- return versionsSupported;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.core.ITool#setVersionsSupported(String)
- */
- public void setVersionsSupported(String versionsSupported) {
- if (versionsSupported == null && this.versionsSupported == null) return;
- if (versionsSupported == null || this.versionsSupported == null || !versionsSupported.equals(this.versionsSupported)) {
- this.versionsSupported = versionsSupported;
- setDirty(true);
- }
- return;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.build.managed.ITool#getEnvVarBuildPaths()
- */
- public IEnvVarBuildPath[] getEnvVarBuildPaths(){
- return null;
- }
-
- public PluginVersionIdentifier getVersion() {
- return null;
- }
-
- public void setVersion(PluginVersionIdentifier version) {
- // TODO Auto-generated method stub
- }
-
- public String getManagedBuildRevision() {
- return null;
- }
-
- public IOption getOptionToSet(IOption option, boolean adjustExtension){
- return null;
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2003, 2006 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.internal.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.managedbuilder.core.BuildException;
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IConfigurationV2;
+import org.eclipse.cdt.managedbuilder.core.IHoldsOptions;
+import org.eclipse.cdt.managedbuilder.core.IInputType;
+import org.eclipse.cdt.managedbuilder.core.IEnvVarBuildPath;
+import org.eclipse.cdt.managedbuilder.core.IOptionApplicability;
+import org.eclipse.cdt.managedbuilder.core.IManagedConfigElement;
+import org.eclipse.cdt.managedbuilder.core.IOption;
+import org.eclipse.cdt.managedbuilder.core.IOptionCategory;
+import org.eclipse.cdt.managedbuilder.core.IOutputType;
+import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.cdt.managedbuilder.core.IToolChain;
+import org.eclipse.cdt.managedbuilder.core.IToolReference;
+import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
+import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
+import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.PluginVersionIdentifier;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class ToolReference implements IToolReference {
+ private static final String DEFAULT_SEPARATOR = ","; //$NON-NLS-1$
+
+ private String command;
+ private boolean isDirty = false;
+ private List optionReferences;
+ private IBuildObject owner;
+ private String outputExtensions;
+ private String outputFlag;
+ private String outputPrefix;
+ protected ITool parent;
+ private boolean resolved = true;
+ private String versionsSupported;
+ private String convertToId;
+
+ /**
+ * Create a new tool reference based on information contained in
+ * a project file.
+ *
+ * @param owner The ConfigurationV2
the receiver will be added to.
+ * @param element The element defined in the project file containing build information
+ * for the receiver.
+ */
+ public ToolReference(BuildObject owner, Element element) {
+ this.owner = owner;
+
+ if (owner instanceof ConfigurationV2) {
+ if (parent == null) {
+ Target parentTarget = (Target) ((ConfigurationV2)owner).getTarget();
+ try {
+ parent = ((Target)parentTarget.getParent()).getTool(element.getAttribute(ID));
+ } catch (NullPointerException e) {
+ parent = null;
+ }
+ }
+ ((ConfigurationV2)owner).addToolReference(this);
+ } else if (owner instanceof Target) {
+ if (parent == null) {
+ try {
+ parent = ((Target)((Target)owner).getParent()).getTool(element.getAttribute(ID));
+ } catch (NullPointerException e) {
+ parent = null;
+ }
+ }
+ ((Target)owner).addToolReference(this);
+ }
+
+ // Get the overridden tool command (if any)
+ if (element.hasAttribute(ITool.COMMAND)) {
+ command = element.getAttribute(ITool.COMMAND);
+ }
+
+ // Get the overridden output prefix (if any)
+ if (element.hasAttribute(ITool.OUTPUT_PREFIX)) {
+ outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
+ }
+
+ // Get the output extensions the reference produces
+ if (element.hasAttribute(ITool.OUTPUTS)) {
+ outputExtensions = element.getAttribute(ITool.OUTPUTS);
+ }
+ // Get the flag to control output
+ if (element.hasAttribute(ITool.OUTPUT_FLAG))
+ outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
+
+ NodeList configElements = element.getChildNodes();
+ for (int i = 0; i < configElements.getLength(); ++i) {
+ Node configElement = configElements.item(i);
+ if (configElement.getNodeName().equals(ITool.OPTION_REF)) {
+ new OptionReference(this, (Element)configElement);
+ }
+ }
+ }
+
+ /**
+ * Created tool reference from an extension defined in a plugin manifest.
+ *
+ * @param owner The BuildObject
the receiver will be added to.
+ * @param element The element containing build information for the reference.
+ */
+ public ToolReference(BuildObject owner, IManagedConfigElement element) {
+ // setup for resolving
+ ManagedBuildManager.putConfigElement(this, element);
+ resolved = false;
+
+ this.owner = owner;
+
+ // hook me up
+ if (owner instanceof ConfigurationV2) {
+ ((ConfigurationV2)owner).addToolReference(this);
+ } else if (owner instanceof Target) {
+ ((Target)owner).addToolReference(this);
+ }
+
+ // Get the overridden tool command (if any)
+ command = element.getAttribute(ITool.COMMAND);
+
+ // Get the overridden output prefix, if any
+ outputPrefix = element.getAttribute(ITool.OUTPUT_PREFIX);
+
+ // Get the overridden output extensions (if any)
+ String output = element.getAttribute(ITool.OUTPUTS);
+ if (output != null) {
+ outputExtensions = output;
+ }
+
+ // Get the flag to control output
+ outputFlag = element.getAttribute(ITool.OUTPUT_FLAG);
+
+ IManagedConfigElement[] toolElements = element.getChildren();
+ for (int m = 0; m < toolElements.length; ++m) {
+ IManagedConfigElement toolElement = toolElements[m];
+ if (toolElement.getName().equals(ITool.OPTION_REF)) {
+ new OptionReference(this, toolElement);
+ }
+ }
+ }
+
+ /**
+ * Created a tool reference on the fly based on an existing tool or tool reference.
+ *
+ * @param owner The BuildObject
the receiver will be added to.
+ * @param tool The ITool
tool the reference will be based on.
+ */
+ public ToolReference(BuildObject owner, ITool tool) {
+ this.owner = owner;
+ if (tool instanceof ToolReference) {
+ parent = ((ToolReference)tool).getTool();
+ } else {
+ parent = tool;
+ }
+ command = tool.getToolCommand();
+ outputFlag = tool.getOutputFlag();
+ outputPrefix = tool.getOutputPrefix();
+ String[] extensions = tool.getOutputsAttribute();
+ outputExtensions = new String();
+ if (extensions != null) {
+ for (int index = 0; index < extensions.length; ++index) {
+ if (extensions[index] == null) continue;
+ outputExtensions += extensions[index];
+ if (index < extensions.length - 1) {
+ outputExtensions += DEFAULT_SEPARATOR;
+ }
+ }
+ }
+
+ // Create a copy of the option references of the parent in the receiver
+ if (tool instanceof ToolReference) {
+ List parentRefs = ((ToolReference)tool).getOptionReferenceList();
+ Iterator iter = parentRefs.iterator();
+ while (iter.hasNext()) {
+ IOption parent = (IOption)iter.next();
+ OptionReference clone = createOptionReference(parent);
+ try {
+ switch (parent.getValueType()) {
+ case IOption.BOOLEAN:
+ clone.setValue(parent.getBooleanValue());
+ break;
+ case IOption.STRING:
+ clone.setValue(parent.getStringValue());
+ case IOption.ENUMERATED:
+ clone.setValue(parent.getSelectedEnum());
+ break;
+ default:
+ clone.setValue(parent.getStringListValue());
+ break;
+ }
+ } catch (BuildException e) {
+ // Likely a mismatch between the value and option type
+ continue;
+ }
+ }
+ }
+
+ if (owner instanceof ConfigurationV2) {
+ ((ConfigurationV2)owner).addToolReference(this);
+ } else if (owner instanceof Target) {
+ ((Target)owner).addToolReference(this);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#references(org.eclipse.cdt.managedbuilder.core.ITool)
+ */
+ public boolean references(ITool target) {
+ if (equals(target)) {
+ // we are the target
+ return true;
+ } else if (parent == null) {
+ // basic sanity before proceeding
+ return false;
+ } else if (parent instanceof IToolReference) {
+ // check the reference we are overriding
+ return ((IToolReference)parent).references(target);
+ } else if (target instanceof IToolReference) {
+ return parent.equals(((IToolReference)target).getTool());
+ } else {
+ // the real reference
+ return parent.equals(target);
+ }
+ }
+
+ public void resolveReferences() {
+ if (!resolved) {
+ resolved = true;
+ IManagedConfigElement element = ManagedBuildManager.getConfigElement(this);
+ // resolve my parent
+ if (owner instanceof ConfigurationV2) {
+ Target target = (Target) ((ConfigurationV2)owner).getTarget();
+ parent = target.getTool(element.getAttribute(ID));
+ } else if (owner instanceof Target) {
+ parent = ((Target)owner).getTool(element.getAttribute(ID));
+ }
+ // recursively resolve my parent
+ if (parent instanceof Tool) {
+ ((Tool)parent).resolveReferences();
+ } else if (parent instanceof ToolReference) {
+ ((ToolReference)parent).resolveReferences();
+ }
+
+ Iterator it = getOptionReferenceList().iterator();
+ while (it.hasNext()) {
+ OptionReference optRef = (OptionReference)it.next();
+ optRef.resolveReferences();
+ }
+ }
+ }
+
+ /**
+ * Adds the option reference specified in the argument to the receiver.
+ *
+ * @param optionRef
+ */
+ public void addOptionReference(OptionReference optionRef) {
+ getOptionReferenceList().add(optionRef);
+ isDirty = true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#buildsFileType(java.lang.String)
+ */
+ public boolean buildsFileType(String extension) {
+ if (parent == null) {
+ // bad reference
+ return false;
+ }
+ return parent.buildsFileType(extension);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#buildsFileType(java.lang.String)
+ */
+ public boolean isInputFileType(String extension) {
+ if (parent == null) {
+ // bad reference
+ return false;
+ }
+ return parent.isInputFileType(extension);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#createOptionReference(org.eclipse.cdt.managedbuilder.core.IOption)
+ */
+ public OptionReference createOptionReference(IOption option) {
+ // Check if the option reference already exists
+ OptionReference ref = getOptionReference(option);
+ // It is possible that the search will return an option reference
+ // that is supplied by another element of the build model, not the caller.
+ // For example, if the search is starated by a configuration and the target
+ // the caller belongs to has an option reference for the option, it
+ // will be returned. While this is correct behaviour for a search, the
+ // caller will need to create a clone for itself, so make sure the tool
+ // reference of the search result is owned by the caller
+ if (ref == null || !ref.getToolReference().owner.equals(this.owner)) {
+ ref = new OptionReference(this, option);
+ }
+ return ref;
+ }
+
+ /* (non-Javadoc)
+ * @return
+ */
+ protected List getAllOptionRefs() {
+ // First get all the option references this tool reference contains
+ if (owner instanceof ConfigurationV2) {
+ return ((ConfigurationV2)owner).getOptionReferences(parent);
+ } else if (owner instanceof Target) {
+ return ((Target)owner).getOptionReferences(parent);
+ } else {
+ // this shouldn't happen
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getId()
+ */
+ public String getId() {
+ if (parent == null) {
+ // bad reference
+ return new String();
+ }
+ return parent.getId();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IBuildObject#getBaseId()
+ */
+ public String getBaseId() {
+ if (parent == null) {
+ // bad reference
+ return new String();
+ }
+ return parent.getBaseId();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getInputExtensions()
+ */
+ public List getInputExtensions() {
+ String[] exts = getPrimaryInputExtensions();
+ List extList = new ArrayList();
+ for (int i=0; inull
+ *
+ * @param option
+ * @return OptionReference
+ */
+ private OptionReference getOptionReference(IOption option) {
+ // Get all the option references for this option
+ Iterator iter = getAllOptionRefs().listIterator();
+ while (iter.hasNext()) {
+ OptionReference optionRef = (OptionReference) iter.next();
+ if (optionRef.references(option))
+ return optionRef;
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ *
+ * @param id
+ * @return
+ */
+ /*
+ private OptionReference getOptionReference(String id) {
+ Iterator it = getOptionReferenceList().iterator();
+ while (it.hasNext()) {
+ OptionReference current = (OptionReference)it.next();
+ if (current.getId().equals(id)) {
+ return current;
+ }
+ }
+ return null;
+ }
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getOptionReferenceList()
+ */
+ public List getOptionReferenceList() {
+ if (optionReferences == null) {
+ optionReferences = new ArrayList();
+ }
+ return optionReferences;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getOptions()
+ */
+ public IOption[] getOptions() {
+ IOption[] options = parent.getOptions();
+
+ // Replace with our references
+ for (int i = 0; i < options.length; ++i) {
+ OptionReference ref = getOptionReference(options[i]);
+ if (ref != null)
+ options[i] = ref;
+ }
+
+ return options;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputExtensions()
+ */
+ public String[] getOutputExtensions() {
+ if (outputExtensions == null){
+ if (parent != null) {
+ return parent.getOutputsAttribute();
+ } else {
+ return new String[0];
+ }
+ }
+ return outputExtensions.split(DEFAULT_SEPARATOR);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputExtension(java.lang.String)
+ */
+ public String getOutputExtension(String inputExtension) {
+ if (parent == null) {
+ // bad reference
+ return new String();
+ }
+ return parent.getOutputExtension(inputExtension);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputFlag()
+ */
+ public String getOutputFlag() {
+ if (outputFlag == null) {
+ if (parent != null) {
+ return parent.getOutputFlag();
+ } else {
+ // We never should be here
+ return new String();
+ }
+ }
+ return outputFlag;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getOutputPrefix()
+ */
+ public String getOutputPrefix() {
+ if (outputPrefix == null) {
+ if (parent != null) {
+ return parent.getOutputPrefix();
+ }
+ return new String(); // bad reference
+ }
+ return outputPrefix;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#isDirty()
+ */
+ public boolean isDirty() {
+ return isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#isHeaderFile(java.lang.String)
+ */
+ public boolean isHeaderFile(String ext) {
+ if (parent == null) {
+ // bad reference
+ return false;
+ }
+ return parent.isHeaderFile(ext);
+ }
+
+ /**
+ * Answers true
if the owner of the receiver matches
+ * the argument.
+ *
+ * @param config
+ * @return
+ */
+ public boolean ownedByConfiguration(IConfigurationV2 config) {
+ if (owner instanceof ConfigurationV2) {
+ return ((IConfigurationV2)owner).equals(config);
+ }
+ return false;
+ }
+
+ /**
+ * Persist receiver to project file.
+ *
+ * @param doc The persistent store for the reference information.
+ * @param element The root element in the store the receiver must use
+ * to persist settings.
+ */
+ public void serialize(Document doc, Element element) {
+ if (parent == null) return; // This is a bad reference
+ element.setAttribute(ITool.ID, parent.getId());
+
+ // Output the command
+ if (command != null) {
+ element.setAttribute(ITool.COMMAND, getToolCommand());
+ }
+
+ // Save output prefix
+ if (outputPrefix != null) {
+ element.setAttribute(ITool.OUTPUT_PREFIX, getOutputPrefix());
+ }
+
+ // Save the output flag
+ if (outputFlag != null) {
+ element.setAttribute(ITool.OUTPUT_FLAG, getOutputFlag());
+ }
+
+ // Save the outputs
+ if (outputExtensions != null) {
+ element.setAttribute(ITool.OUTPUTS, outputExtensions);
+ }
+
+ // Output the option references
+ Iterator iter = getOptionReferenceList().listIterator();
+ while (iter.hasNext()) {
+ OptionReference optionRef = (OptionReference) iter.next();
+ Element optionRefElement = doc.createElement(ITool.OPTION_REF);
+ element.appendChild(optionRefElement);
+ optionRef.serialize(doc, optionRefElement);
+ }
+
+ // Set the reference to clean
+ isDirty = false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#setDirty(boolean)
+ */
+ public void setDirty(boolean isDirty) {
+ // Override the local flag
+ this.isDirty = isDirty;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#setToolCommand(java.lang.String)
+ */
+ public boolean setToolCommand(String cmd) {
+ if (cmd != null && !cmd.equals(command)) {
+ command = cmd;
+ isDirty = true;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputFlag(java.lang.String)
+ */
+ public void setOutputFlag(String flag) {
+ if (flag == null) return;
+ if (outputFlag == null || !(flag.equals(outputFlag))) {
+ outputFlag = flag;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputPrefix(java.lang.String)
+ */
+ public void setOutputPrefix(String prefix) {
+ if (prefix == null) return;
+ if (outputPrefix == null || !(prefix.equals(outputPrefix))) {
+ outputPrefix = prefix;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setOutputExtensions(java.lang.String)
+ */
+ public void setOutputExtensions(String ext) {
+ if (ext == null) return;
+ if (outputExtensions == null || !(ext.equals(outputExtensions))) {
+ outputExtensions = ext;
+ isDirty = true;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setParent(IBuildObject)
+ */
+ public void setToolParent(IBuildObject newParent) {
+ if (parent == null) {
+ // bad reference
+ return;
+ }
+ // Set the parent in the parent of this ToolRefernce, the tool
+ ((Tool)parent).setToolParent(newParent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getParent()
+ */
+ public IBuildObject getParent() {
+ return owner;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLinePattern()
+ */
+ public String getCommandLinePattern() {
+ if( parent == null ) return new String();
+ return parent.getCommandLinePattern();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLineGenerator()
+ */
+ public IManagedCommandLineGenerator getCommandLineGenerator() {
+ if( parent == null ) return null;
+ return parent.getCommandLineGenerator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getDependencyGenerator()
+ */
+ public IManagedDependencyGenerator getDependencyGenerator() {
+ if( parent == null ) return null;
+ return parent.getDependencyGenerator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandFlags()
+ */
+ public String[] getCommandFlags() throws BuildException {
+ if( parent == null ) return null;
+ return parent.getToolCommandFlags(null, null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getToolCommandFlags(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
+ */
+ public String[] getToolCommandFlags(IPath inputFileLocation, IPath outputFileLocation) throws BuildException{
+ return getCommandFlags();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getToolCommandFlagsString(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath)
+ */
+ public String getToolCommandFlagsString(IPath inputFileLocation, IPath outputFileLocation) throws BuildException{
+ return getToolFlags();
+
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ String answer = new String();
+ if (parent != null) {
+ answer += "Reference to " + parent.getName(); //$NON-NLS-1$
+ }
+
+ if (answer.length() > 0) {
+ return answer;
+ } else {
+ return super.toString();
+ }
+ }
+
+ /*
+ * The following methods are here in order to implement the new ITool methods.
+ * They should never be called.
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getSuperClass()
+ */
+ public ITool getSuperClass() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#isAbstract()
+ */
+ public boolean isAbstract() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getUnusedChildren()
+ */
+ public String getUnusedChildren() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getErrorParserList()
+ */
+ public String[] getErrorParserList() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getErrorParserIds()
+ */
+ public String getErrorParserIds() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setErrorParserIds()
+ */
+ public void setErrorParserIds(String ids) {
+ }
+
+ public List getInterfaceExtensions() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#isExtensionElement()
+ */
+ public boolean isExtensionElement() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#createOption()
+ */
+ public IOption createOption(IOption superClass, String Id, String name, boolean b) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IHoldsOptions#createOptions()
+ */
+ public void createOptions(IHoldsOptions options) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#removeOption()
+ */
+ public void removeOption(IOption o) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.IOptionCategory#getChildCategories()
+ */
+ public IOptionCategory[] getChildCategories() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setIsAbstract(boolean)
+ */
+ public void setIsAbstract(boolean b) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLinePattern()
+ */
+ public void setCommandLinePattern(String pattern) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#setCommandLineGenerator(IConfigurationElement)
+ */
+ public void setCommandLineGeneratorElement(IConfigurationElement element) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLineGenerator()
+ */
+ public IConfigurationElement getDependencyGeneratorElement() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#setCommandLineGenerator(IConfigurationElement)
+ */
+ public void setDependencyGeneratorElement(IConfigurationElement element) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getCommandLineGeneratorElement()
+ */
+ public IConfigurationElement getCommandLineGeneratorElement() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getAdvancedInputCategory()
+ */
+ public boolean getAdvancedInputCategory() {
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#setAdvancedInputCategory()
+ */
+ public void setAdvancedInputCategory(boolean display) {
+ }
+
+ public IInputType createInputType(IInputType superClass, String Id, String name, boolean isExtensionElement) {
+ return null;
+ }
+
+ public IOutputType createOutputType(IOutputType superClass, String Id, String name, boolean isExtensionElement) {
+ return null;
+ }
+
+ public String getAnnouncement() {
+ return null;
+ }
+
+ public IInputType getInputTypeById(String id) {
+ return null;
+ }
+
+ public IInputType[] getInputTypes() {
+ return null;
+ }
+
+ public IOutputType getOutputTypeById(String id) {
+ return null;
+ }
+
+ public IOutputType[] getOutputTypes() {
+ return null;
+ }
+
+ public void removeInputType(IInputType type) {
+ }
+
+ public void removeOutputType(IOutputType type) {
+ }
+
+ public void setAnnouncement(String announcement) {
+ }
+
+ public String getDefaultInputExtension() {
+ return null;
+ }
+
+ public String[] getAllInputExtensions() {
+ return null;
+ }
+
+ public String[] getPrimaryInputExtensions() {
+ return null;
+ }
+
+ public IInputType getInputType(String inputExtension) {
+ return null;
+ }
+
+ public String[] getOutputsAttribute() {
+ return null;
+ }
+
+ public IOutputType getOutputType(String outputExtension) {
+ return null;
+ }
+
+ public void setOutputsAttribute(String extensions) {
+ }
+
+ public String[] getAllOutputExtensions() {
+ return null;
+ }
+
+ public String[] getAllDependencyExtensions() {
+ return null;
+ }
+
+ public IInputType getPrimaryInputType() {
+ return null;
+ }
+
+ public IOutputType getPrimaryOutputType() {
+ return null;
+ }
+
+ public IPath[] getAdditionalDependencies() {
+ return null;
+ }
+
+ public IPath[] getAdditionalResources() {
+ return null;
+ }
+
+ public IConfigurationElement getDependencyGeneratorElementForExtension(String sourceExt) {
+ return null;
+ }
+
+ public IManagedDependencyGeneratorType getDependencyGeneratorForExtension(String sourceExt) {
+ return null;
+ }
+
+ public boolean getCustomBuildStep() {
+ return false;
+ }
+
+ public void setCustomBuildStep(boolean customBuildStep) {
+ }
+
+ public IOption getOptionBySuperClassId(String id) {
+ return null;
+ }
+
+ public IOptionCategory getOptionCategory(String id) {
+ // return null as class is deprecated
+ return null;
+ }
+
+ public void addOptionCategory(IOptionCategory category) {
+ }
+
+ /*
+ * The following methods are added to allow the converter from ToolReference -> Tool
+ * to retrieve the actual value of attributes. These routines do not go to the
+ * referenced Tool for a value if the ToolReference does not have a value.
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawOutputExtensions()
+ */
+ public String getRawOutputExtensions() {
+ return outputExtensions;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawOutputFlag()
+ */
+ public String getRawOutputFlag() {
+ return outputFlag;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawOutputPrefix()
+ */
+ public String getRawOutputPrefix() {
+ return outputPrefix;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.IToolReference#getRawToolCommand()
+ */
+ public String getRawToolCommand() {
+ return command;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getConvertToId()
+ */
+ public String getConvertToId() {
+ if (convertToId == null) {
+ // If I have a superClass, ask it
+ if (parent != null) {
+ return parent.getConvertToId();
+ } else {
+ return new String();
+ }
+ }
+ return convertToId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setConvertToId(String)
+ */
+ public void setConvertToId(String convertToId) {
+ if (convertToId == null && this.convertToId == null) return;
+ if (convertToId == null || this.convertToId == null || !convertToId.equals(this.convertToId)) {
+ this.convertToId = convertToId;
+ setDirty(true);
+ }
+ return;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#getVersionsSupported()
+ */
+ public String getVersionsSupported() {
+ if (versionsSupported == null) {
+ // If I have a superClass, ask it
+ if (parent != null) {
+ return parent.getVersionsSupported();
+ } else {
+ return new String();
+ }
+ }
+ return versionsSupported;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.core.ITool#setVersionsSupported(String)
+ */
+ public void setVersionsSupported(String versionsSupported) {
+ if (versionsSupported == null && this.versionsSupported == null) return;
+ if (versionsSupported == null || this.versionsSupported == null || !versionsSupported.equals(this.versionsSupported)) {
+ this.versionsSupported = versionsSupported;
+ setDirty(true);
+ }
+ return;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.build.managed.ITool#getEnvVarBuildPaths()
+ */
+ public IEnvVarBuildPath[] getEnvVarBuildPaths(){
+ return null;
+ }
+
+ public PluginVersionIdentifier getVersion() {
+ return null;
+ }
+
+ public void setVersion(PluginVersionIdentifier version) {
+ // TODO Auto-generated method stub
+ }
+
+ public String getManagedBuildRevision() {
+ return null;
+ }
+
+ public IOption getOptionToSet(IOption option, boolean adjustExtension){
+ return null;
+ }
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCalculator.java
index 71775b26b28..842ebd2bf03 100755
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCalculator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCalculator.java
@@ -1,79 +1,79 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.makegen;
-
-import org.eclipse.core.runtime.IPath;
-
-/**
- * @since 3.1
- *
- * A Tool dependency calculator may implement this interface or
- * IManagedDependencyCommands or IManagedDependencyPreBuild.
- * An object implementing the interface is returned from a call to
- * IManagedDependencyGenerator2.getDependencySourceInfo.
- *
- * Discussion of Dependency Calculation:
- *
- * There are two major, and multiple minor, modes of dependency calculation
- * supported by the MBS. The major modes are:
- *
- * 1. The build file generator invokes tool integrator provided methods
- * that calculate all dependencies using whatever method the tool
- * integrator wants. The build file generator then adds the dependencies
- * to the build file using the appropriate build file syntax.
- * This type of dependency calculator implements the
- * IManagedDependencyCalculator interface defined in this module.
- *
- * One minor mode of this mode is to use a dependency calculator provided
- * by a language integration (e.g. C, C++ or Fortran) that uses the
- * language's parsing support to return information regarding source file
- * dependencies. An example of this is using the C/C++ Indexer to
- * compute dependencies.
- *
- * 2. The build file generator and the tool-chain cooperate in creating and
- * using separate "dependency" files. In this case, dependency calculation
- * is done at "build time", rather than at "build file generation time" as
- * in mode #1. This currently supports the GNU concept of using .d files
- * in GNU make. See the IManagedDependencyCommands and
- * IManagedDependencyPreBuild interfaces for more information.
- *
- */
-
-public interface IManagedDependencyCalculator extends IManagedDependencyInfo {
-
- /**
- * Returns the list of source file specific dependencies.
- *
- * The paths can be either relative to the project directory, or absolute
- * in the file system.
- *
- * @return IPath[]
- */
- public IPath[] getDependencies();
-
- /**
- * Returns the list of source file specific additional targets that the
- * source file creates. Most source files will return null. An example
- * of where additional targets should be returned is for a Fortran 90
- * source file that creates one or more Fortran Modules.
- *
- * Note that these output files that are dependencies to other invocations
- * of the same tool can be specified here, or as another output type
- * of the tool. If the output file can be used as the input of a different
- * tool, then use the output type mechanism.
- *
- * The paths can be either relative to the top build directory, or absolute
- * in the file system.
- *
- * @return IPath[]
- */
- public IPath[] getAdditionalTargets();
-}
+/*******************************************************************************
+ * Copyright (c) 2006 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.makegen;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @since 3.1
+ *
+ * A Tool dependency calculator may implement this interface or
+ * IManagedDependencyCommands or IManagedDependencyPreBuild.
+ * An object implementing the interface is returned from a call to
+ * IManagedDependencyGenerator2.getDependencySourceInfo.
+ *
+ * Discussion of Dependency Calculation:
+ *
+ * There are two major, and multiple minor, modes of dependency calculation
+ * supported by the MBS. The major modes are:
+ *
+ * 1. The build file generator invokes tool integrator provided methods
+ * that calculate all dependencies using whatever method the tool
+ * integrator wants. The build file generator then adds the dependencies
+ * to the build file using the appropriate build file syntax.
+ * This type of dependency calculator implements the
+ * IManagedDependencyCalculator interface defined in this module.
+ *
+ * One minor mode of this mode is to use a dependency calculator provided
+ * by a language integration (e.g. C, C++ or Fortran) that uses the
+ * language's parsing support to return information regarding source file
+ * dependencies. An example of this is using the C/C++ Indexer to
+ * compute dependencies.
+ *
+ * 2. The build file generator and the tool-chain cooperate in creating and
+ * using separate "dependency" files. In this case, dependency calculation
+ * is done at "build time", rather than at "build file generation time" as
+ * in mode #1. This currently supports the GNU concept of using .d files
+ * in GNU make. See the IManagedDependencyCommands and
+ * IManagedDependencyPreBuild interfaces for more information.
+ *
+ */
+
+public interface IManagedDependencyCalculator extends IManagedDependencyInfo {
+
+ /**
+ * Returns the list of source file specific dependencies.
+ *
+ * The paths can be either relative to the project directory, or absolute
+ * in the file system.
+ *
+ * @return IPath[]
+ */
+ public IPath[] getDependencies();
+
+ /**
+ * Returns the list of source file specific additional targets that the
+ * source file creates. Most source files will return null. An example
+ * of where additional targets should be returned is for a Fortran 90
+ * source file that creates one or more Fortran Modules.
+ *
+ * Note that these output files that are dependencies to other invocations
+ * of the same tool can be specified here, or as another output type
+ * of the tool. If the output file can be used as the input of a different
+ * tool, then use the output type mechanism.
+ *
+ * The paths can be either relative to the top build directory, or absolute
+ * in the file system.
+ *
+ * @return IPath[]
+ */
+ public IPath[] getAdditionalTargets();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCommands.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCommands.java
index 3e451e6a5eb..077e712fe6e 100755
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCommands.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyCommands.java
@@ -1,168 +1,168 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.makegen;
-
-import org.eclipse.core.runtime.IPath;
-
-/**
- * @since 3.1
- *
- * A Tool dependency calculator may implement this interface or
- * IManagedDependencyCalculator or IManagedDependencyPreBuild.
- * An object implementing the interface is returned from a call to
- * IManagedDependencyGenerator2.getDependencySourceInfo.
- *
- * Discussion of Dependency Calculation:
- *
- * There are two major, and multiple minor, modes of dependency calculation
- * supported by the MBS. The major modes are:
- *
- * 1. The build file generator invokes tool integrator provided methods
- * that calculate all dependencies using whatever method the tool
- * integrator wants. The build file generator then adds the dependencies
- * to the build file using the appropriate build file syntax.
- * See the IManagedDependencyCalculator interface for more information.
- *
- * 2. The build file generator and the tool-chain cooperate in creating and
- * using separate "dependency" files. The build file generator calls
- * the dependency calculator to get the dependency file names and to get
- * commands that need to be added to the build file. In this case,
- * dependency calculation is done at "build time", rather than at
- * "build file generation time" as in mode #1. This currently
- * supports the GNU concept of using .d files in GNU make.
- *
- * There are multiple ways that these separate dependency files can
- * be created by the tool-chain and used by the builder.
- *
- * a. In some cases (e.g., Fortran 90 using modules) the dependency files
- * must be created/updated prior to invoking the build of the project
- * artifact (e.g., an application). In this case, the dependency
- * generation step must occur separately before the main build.
- * See the IManagedDependencyPreBuild interface for more information.
- *
- * b. In other cases (e.g., C/C++) the dependency files can be created as
- * a side effect of the main build. This implies that the up to date
- * dependency files are not required for the current build, but for
- * the next build. C/C++ builds can be treated in this manner as is
- * described in the following link:
- * http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
- *
- * Use the IManagedDependencyCommands interface defined in this file
- * for this mode.
- *
- * Two sub-scenarios of this mode are to:
- *
- * Create dependency files in the same invocation of the tool that
- * creates the tool's build artifact - by adding additional options
- * to the tool invocation command line.
- *
- * Create dependency files in a separate invocation of the tool, or
- * by the invocation of another tool.
- *
- * MBS can also help in the generation of the dependency files. Prior to
- * CDT 3.1, MBS and gcc cooperated in generating dependency files using the
- * following steps:
- *
- * 1. Gcc is invoked to perform the compilation that generates the object
- * file.
- *
- * 2. An "echo" command creates the .d file, adding the name of the .d
- * file to the beginning of the newly created .d file. Note that this
- * causes problems with some implementations of "echo" that don't
- * work exactly the way that we want (e.g., it doesn't support the -n
- * switch).
-
- * 3. Gcc is invoked again with the appropriate additional command line
- * options to append its dependency file information to the .d file
- * that was created by "echo".
- *
- * 4. Steps 1 - 3 are invoked in the make file. Step 4 occurs after the
- * make invocation has finished. In step 4, MBS code post-processes
- * the .d files to add a dummy dependency for each header file, for
- * the reason explained in the link above.
- *
- * This mode is no longer used by the default gcc implementation, but can
- * still be used by selecting the DefaultGCCDependencyCalculator.
- *
- *
- * Note for GNU make: these separate dependency files are "include"d by
- * a main makefile. Therefore, if the dependency files are required to
- * be up to date before the main build begins, they must be updated by
- * a separate invocation of make. Also, the configuration "clean" step
- * must be invoked by a separate invocation of make. This is so that
- * we can exclude the dependency files for a "make clean" invocation
- * using syntax like:
- *
- * ifneq ($(MAKECMDGOALS), clean)
- * -include $(DEPS)
- * endif
- *
- * Otherwise, because GNU make attempts to re-make make files, we
- * can end up with out of date or missing dependency files being
- * re-generated and then immediately "clean"ed.
- */
-
-public interface IManagedDependencyCommands extends IManagedDependencyInfo {
-
- /**
- * Returns the list of generated dependency files.
- *
- * The paths can be either relative to the top build directory, or absolute
- * in the file system.
- *
- * @return IPath[]
- */
- public IPath[] getDependencyFiles();
-
- /**
- * Returns the command lines to be invoked before the normal tool invocation
- * to calculate dependencies.
- *
- * @return String[] This can be null or an empty array if no dependency
- * generation command needs to be invoked before the normal
- * tool invocation.
- */
- public String[] getPreToolDependencyCommands();
-
- /**
- * Returns the command line options to be used to calculate dependencies.
- * The options are added to the normal tool invocation.
- *
- * @return String[] This can be null or an empty array if no additional
- * arguments need to be added to the tool invocation.
- * SHOULD THIS RETURN AN IOption[]?
- */
- public String[] getDependencyCommandOptions();
- // IMPLEMENTATION NOTE: This should be called from addRuleFromSource for both resconfig & non-resconfig
-
- /**
- * Returns the command lines to be invoked after the normal tool invocation
- * to calculate dependencies.
- *
- * @return String[] This can be null or an empty array if no dependency
- * generation commands needs to be invoked after the normal
- * tool invocation
- */
- public String[] getPostToolDependencyCommands();
-
- /**
- * Returns true if the command lines and/or options returned by this interface
- * are not specific to the particular source file, but are only specific to,
- * at most, the configuration and tool. If the build context is a resource
- * configuration, this method should return false if any of the command lines
- * and/or options are different than if the build context were the parent
- * configuration. This can be used by the build file generator in helping
- * to determine if a "pattern" (generic) rule can be used.
- *
- * @return boolean
- */
- public boolean areCommandsGeneric();
-}
+/*******************************************************************************
+ * Copyright (c) 2006 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.makegen;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @since 3.1
+ *
+ * A Tool dependency calculator may implement this interface or
+ * IManagedDependencyCalculator or IManagedDependencyPreBuild.
+ * An object implementing the interface is returned from a call to
+ * IManagedDependencyGenerator2.getDependencySourceInfo.
+ *
+ * Discussion of Dependency Calculation:
+ *
+ * There are two major, and multiple minor, modes of dependency calculation
+ * supported by the MBS. The major modes are:
+ *
+ * 1. The build file generator invokes tool integrator provided methods
+ * that calculate all dependencies using whatever method the tool
+ * integrator wants. The build file generator then adds the dependencies
+ * to the build file using the appropriate build file syntax.
+ * See the IManagedDependencyCalculator interface for more information.
+ *
+ * 2. The build file generator and the tool-chain cooperate in creating and
+ * using separate "dependency" files. The build file generator calls
+ * the dependency calculator to get the dependency file names and to get
+ * commands that need to be added to the build file. In this case,
+ * dependency calculation is done at "build time", rather than at
+ * "build file generation time" as in mode #1. This currently
+ * supports the GNU concept of using .d files in GNU make.
+ *
+ * There are multiple ways that these separate dependency files can
+ * be created by the tool-chain and used by the builder.
+ *
+ * a. In some cases (e.g., Fortran 90 using modules) the dependency files
+ * must be created/updated prior to invoking the build of the project
+ * artifact (e.g., an application). In this case, the dependency
+ * generation step must occur separately before the main build.
+ * See the IManagedDependencyPreBuild interface for more information.
+ *
+ * b. In other cases (e.g., C/C++) the dependency files can be created as
+ * a side effect of the main build. This implies that the up to date
+ * dependency files are not required for the current build, but for
+ * the next build. C/C++ builds can be treated in this manner as is
+ * described in the following link:
+ * http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
+ *
+ * Use the IManagedDependencyCommands interface defined in this file
+ * for this mode.
+ *
+ * Two sub-scenarios of this mode are to:
+ *
+ * Create dependency files in the same invocation of the tool that
+ * creates the tool's build artifact - by adding additional options
+ * to the tool invocation command line.
+ *
+ * Create dependency files in a separate invocation of the tool, or
+ * by the invocation of another tool.
+ *
+ * MBS can also help in the generation of the dependency files. Prior to
+ * CDT 3.1, MBS and gcc cooperated in generating dependency files using the
+ * following steps:
+ *
+ * 1. Gcc is invoked to perform the compilation that generates the object
+ * file.
+ *
+ * 2. An "echo" command creates the .d file, adding the name of the .d
+ * file to the beginning of the newly created .d file. Note that this
+ * causes problems with some implementations of "echo" that don't
+ * work exactly the way that we want (e.g., it doesn't support the -n
+ * switch).
+
+ * 3. Gcc is invoked again with the appropriate additional command line
+ * options to append its dependency file information to the .d file
+ * that was created by "echo".
+ *
+ * 4. Steps 1 - 3 are invoked in the make file. Step 4 occurs after the
+ * make invocation has finished. In step 4, MBS code post-processes
+ * the .d files to add a dummy dependency for each header file, for
+ * the reason explained in the link above.
+ *
+ * This mode is no longer used by the default gcc implementation, but can
+ * still be used by selecting the DefaultGCCDependencyCalculator.
+ *
+ *
+ * Note for GNU make: these separate dependency files are "include"d by
+ * a main makefile. Therefore, if the dependency files are required to
+ * be up to date before the main build begins, they must be updated by
+ * a separate invocation of make. Also, the configuration "clean" step
+ * must be invoked by a separate invocation of make. This is so that
+ * we can exclude the dependency files for a "make clean" invocation
+ * using syntax like:
+ *
+ * ifneq ($(MAKECMDGOALS), clean)
+ * -include $(DEPS)
+ * endif
+ *
+ * Otherwise, because GNU make attempts to re-make make files, we
+ * can end up with out of date or missing dependency files being
+ * re-generated and then immediately "clean"ed.
+ */
+
+public interface IManagedDependencyCommands extends IManagedDependencyInfo {
+
+ /**
+ * Returns the list of generated dependency files.
+ *
+ * The paths can be either relative to the top build directory, or absolute
+ * in the file system.
+ *
+ * @return IPath[]
+ */
+ public IPath[] getDependencyFiles();
+
+ /**
+ * Returns the command lines to be invoked before the normal tool invocation
+ * to calculate dependencies.
+ *
+ * @return String[] This can be null or an empty array if no dependency
+ * generation command needs to be invoked before the normal
+ * tool invocation.
+ */
+ public String[] getPreToolDependencyCommands();
+
+ /**
+ * Returns the command line options to be used to calculate dependencies.
+ * The options are added to the normal tool invocation.
+ *
+ * @return String[] This can be null or an empty array if no additional
+ * arguments need to be added to the tool invocation.
+ * SHOULD THIS RETURN AN IOption[]?
+ */
+ public String[] getDependencyCommandOptions();
+ // IMPLEMENTATION NOTE: This should be called from addRuleFromSource for both resconfig & non-resconfig
+
+ /**
+ * Returns the command lines to be invoked after the normal tool invocation
+ * to calculate dependencies.
+ *
+ * @return String[] This can be null or an empty array if no dependency
+ * generation commands needs to be invoked after the normal
+ * tool invocation
+ */
+ public String[] getPostToolDependencyCommands();
+
+ /**
+ * Returns true if the command lines and/or options returned by this interface
+ * are not specific to the particular source file, but are only specific to,
+ * at most, the configuration and tool. If the build context is a resource
+ * configuration, this method should return false if any of the command lines
+ * and/or options are different than if the build context were the parent
+ * configuration. This can be used by the build file generator in helping
+ * to determine if a "pattern" (generic) rule can be used.
+ *
+ * @return boolean
+ */
+ public boolean areCommandsGeneric();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java
index 5511d473dfe..f3870e8e606 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator.java
@@ -1,27 +1,27 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.makegen;
-
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-
-/**
- * @since 2.0
- * @deprecated 3.1
- *
- * Use IManagedDependencyGenerator2 instead.
-*/
-public interface IManagedDependencyGenerator extends IManagedDependencyGeneratorType {
-
- public IResource[] findDependencies(IResource resource, IProject project);
- public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
-}
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.makegen;
+
+import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+
+/**
+ * @since 2.0
+ * @deprecated 3.1
+ *
+ * Use IManagedDependencyGenerator2 instead.
+*/
+public interface IManagedDependencyGenerator extends IManagedDependencyGeneratorType {
+
+ public IResource[] findDependencies(IResource resource, IProject project);
+ public String getDependencyCommand(IResource resource, IManagedBuildInfo info);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator2.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator2.java
index 3d16344053c..1e28c6046cf 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator2.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGenerator2.java
@@ -1,114 +1,114 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation of IManagedDependencyGenerator
- * Intel - Initial API and implementation of IManagedDependencyGenerator2
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.makegen;
-
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-
-/**
- * @since 3.1
- *
- * A Tool dependency calculator must implement this interface. This interface
- * replaces IManagedDependencyGenerator which is deprecated.
- *
- * Discussion of Dependency Calculation:
- *
- * There are two major, and multiple minor, modes of dependency calculation
- * supported by the MBS. The major modes are:
- *
- * 1. The build file generator invokes tool integrator provided methods
- * that calculate all dependencies using whatever method the tool
- * integrator wants. The build file generator then adds the dependencies
- * to the build file using the appropriate build file syntax.
- * This is a TYPE_CUSTOM dependency calculator as defined below.
- * See the IManagedDependencyCalculator interface for more information.
- *
- * 2. The build file generator and the tool-chain cooperate in creating and
- * using separate "dependency" files. In this case, dependency calculation
- * is done at "build time", rather than at "build file generation time" as
- * in mode #1. This currently supports the GNU concept of using .d files
- * in GNU make.
- * This is either a TYPE_BUILD_COMMANDS dependency calculator or a
- * TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
- * See the IManagedDependencyCommands and IManagedDependencyPreBuild
- * interfaces for more information.
- *
- */
-
-public interface IManagedDependencyGenerator2 extends IManagedDependencyGeneratorType {
-
- /**
- * Returns an instance of IManagedDependencyInfo for this source file.
- * IManagedDependencyCalculator, IManagedDependencyCommands
- * and IManagedDependencyPreBuild are all derived from
- * IManagedDependencyInfo, and any one of the three can be returned.
- * This is called when getCalculatorType returns TYPE_BUILD_COMMANDS,
- * TYPE_CUSTOM or TYPE_PREBUILD_COMMANDS.
- *
- * @param source The source file for which dependencies should be calculated
- * The IPath can be either relative to the project directory, or absolute in the file system.
- * @param buildContext The IConfiguration or IResourceConfiguration that
- * contains the context in which the source file will be built
- * @param tool The tool associated with the source file
- * @param topBuildDirectory The top build directory of the configuration. This is
- * the working directory for the tool. This IPath is relative to the project directory.
- * @return IManagedDependencyInfo
- */
- public IManagedDependencyInfo getDependencySourceInfo(
- IPath source,
- IBuildObject buildContext,
- ITool tool,
- IPath topBuildDirectory);
-
- /**
- * Returns the file extension used by dependency files created
- * by this dependency generator.
- * This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
- * TYPE_PREBUILD_COMMANDS.
- *
- * @param buildContext The IConfiguration that contains the context of the build
- * @param tool The tool associated with the dependency generator.
- *
- * @return String
- */
- public String getDependencyFileExtension(
- IConfiguration buildContext,
- ITool tool);
-
- /**
- * Called to allow the dependency calculator to post-process dependency files.
- * This method is called after the build has completed for at least every
- * dependency file that has changed, and possibly for those that have not
- * changed as well. It may also be called with dependency files created by
- * another tool. This method should be able to recognize dependency files
- * that don't belong to it, or that it has already post-processed.
- * This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
- * TYPE_PREBUILD_COMMANDS.
- *
- * @param dependencyFile The dependency file
- * The IPath can be either relative to the top build directory, or absolute in the file system.
- * @param buildContext The IConfiguration that contains the context of the build
- * @param tool The tool associated with the dependency generator. Note that this is
- * not necessarily the tool that created the dependency file
- * @param topBuildDirectory The top build directory of the project. This is
- * the working directory for the tool.
- *
- * @return boolean True if the method modified the dependency (e.g., .d) file
- */
- public boolean postProcessDependencyFile(
- IPath dependencyFile,
- IConfiguration buildContext,
- ITool tool,
- IPath topBuildDirectory);
-}
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation of IManagedDependencyGenerator
+ * Intel - Initial API and implementation of IManagedDependencyGenerator2
+ *******************************************************************************/
+package org.eclipse.cdt.managedbuilder.makegen;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.IConfiguration;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+
+/**
+ * @since 3.1
+ *
+ * A Tool dependency calculator must implement this interface. This interface
+ * replaces IManagedDependencyGenerator which is deprecated.
+ *
+ * Discussion of Dependency Calculation:
+ *
+ * There are two major, and multiple minor, modes of dependency calculation
+ * supported by the MBS. The major modes are:
+ *
+ * 1. The build file generator invokes tool integrator provided methods
+ * that calculate all dependencies using whatever method the tool
+ * integrator wants. The build file generator then adds the dependencies
+ * to the build file using the appropriate build file syntax.
+ * This is a TYPE_CUSTOM dependency calculator as defined below.
+ * See the IManagedDependencyCalculator interface for more information.
+ *
+ * 2. The build file generator and the tool-chain cooperate in creating and
+ * using separate "dependency" files. In this case, dependency calculation
+ * is done at "build time", rather than at "build file generation time" as
+ * in mode #1. This currently supports the GNU concept of using .d files
+ * in GNU make.
+ * This is either a TYPE_BUILD_COMMANDS dependency calculator or a
+ * TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
+ * See the IManagedDependencyCommands and IManagedDependencyPreBuild
+ * interfaces for more information.
+ *
+ */
+
+public interface IManagedDependencyGenerator2 extends IManagedDependencyGeneratorType {
+
+ /**
+ * Returns an instance of IManagedDependencyInfo for this source file.
+ * IManagedDependencyCalculator, IManagedDependencyCommands
+ * and IManagedDependencyPreBuild are all derived from
+ * IManagedDependencyInfo, and any one of the three can be returned.
+ * This is called when getCalculatorType returns TYPE_BUILD_COMMANDS,
+ * TYPE_CUSTOM or TYPE_PREBUILD_COMMANDS.
+ *
+ * @param source The source file for which dependencies should be calculated
+ * The IPath can be either relative to the project directory, or absolute in the file system.
+ * @param buildContext The IConfiguration or IResourceConfiguration that
+ * contains the context in which the source file will be built
+ * @param tool The tool associated with the source file
+ * @param topBuildDirectory The top build directory of the configuration. This is
+ * the working directory for the tool. This IPath is relative to the project directory.
+ * @return IManagedDependencyInfo
+ */
+ public IManagedDependencyInfo getDependencySourceInfo(
+ IPath source,
+ IBuildObject buildContext,
+ ITool tool,
+ IPath topBuildDirectory);
+
+ /**
+ * Returns the file extension used by dependency files created
+ * by this dependency generator.
+ * This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
+ * TYPE_PREBUILD_COMMANDS.
+ *
+ * @param buildContext The IConfiguration that contains the context of the build
+ * @param tool The tool associated with the dependency generator.
+ *
+ * @return String
+ */
+ public String getDependencyFileExtension(
+ IConfiguration buildContext,
+ ITool tool);
+
+ /**
+ * Called to allow the dependency calculator to post-process dependency files.
+ * This method is called after the build has completed for at least every
+ * dependency file that has changed, and possibly for those that have not
+ * changed as well. It may also be called with dependency files created by
+ * another tool. This method should be able to recognize dependency files
+ * that don't belong to it, or that it has already post-processed.
+ * This is called when getCalculatorType returns TYPE_BUILD_COMMANDS or
+ * TYPE_PREBUILD_COMMANDS.
+ *
+ * @param dependencyFile The dependency file
+ * The IPath can be either relative to the top build directory, or absolute in the file system.
+ * @param buildContext The IConfiguration that contains the context of the build
+ * @param tool The tool associated with the dependency generator. Note that this is
+ * not necessarily the tool that created the dependency file
+ * @param topBuildDirectory The top build directory of the project. This is
+ * the working directory for the tool.
+ *
+ * @return boolean True if the method modified the dependency (e.g., .d) file
+ */
+ public boolean postProcessDependencyFile(
+ IPath dependencyFile,
+ IConfiguration buildContext,
+ ITool tool,
+ IPath topBuildDirectory);
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGeneratorType.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGeneratorType.java
index bca6f078f11..a510e4fb424 100755
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGeneratorType.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyGeneratorType.java
@@ -1,87 +1,87 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.makegen;
-
-/**
- * @since 3.1
- *
- * IManagedDependencyGenerator (deprecated) and IManagedDependencyGenerator2
- * extend this interface.
- *
- * Discussion of Dependency Calculation:
- *
- * There are two major, and multiple minor, modes of dependency calculation
- * supported by the MBS. The major modes are:
- *
- * 1. The build file generator invokes tool integrator provided methods
- * that calculate all dependencies using whatever method the tool
- * integrator wants. The build file generator then adds the dependencies
- * to the build file using the appropriate build file syntax.
- * This is a TYPE_CUSTOM dependency calculator as defined below.
- * See the IManagedDependencyCalculator interface for more information.
- *
- * 2. The build file generator and the tool-chain cooperate in creating and
- * using separate "dependency" files. In this case, dependency calculation
- * is done at "build time", rather than at "build file generation time" as
- * in mode #1. This currently supports the GNU concept of using .d files
- * in GNU make.
- * This is either a TYPE_BUILD_COMMANDS dependency calculator or a
- * TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
- * See the IManagedDependencyCommands and IManagedDependencyPreBuild
- * interfaces for more information.
- *
- */
-
-public interface IManagedDependencyGeneratorType {
- /**
- * Constants returned by getCalculatorType
- */
- public int TYPE_NODEPS = 0; // Deprecated - use TYPE_NODEPENDENCIES
- public int TYPE_COMMAND = 1; // Deprecated - use TYPE_BUILD_COMMANDS
- public int TYPE_INDEXER = 2; // Deprecated - use TYPE_CUSTOM
- public int TYPE_EXTERNAL = 3; // Deprecated - use TYPE_CUSTOM
- public int TYPE_OLD_TYPE_LIMIT = 3;
-
- // Use these types
- public int TYPE_NODEPENDENCIES = 4;
- public int TYPE_BUILD_COMMANDS = 5;
- public int TYPE_PREBUILD_COMMANDS = 6;
- public int TYPE_CUSTOM = 7;
-
- /**
- * Returns the type of dependency generator that is implemented.
- *
- * TYPE_NODEPENDENCIES indicates that no dependency generator is
- * supplied or needed.
- * TYPE_CUSTOM indicates that a custom, "build file generation time"
- * dependency calculator is implemented. Note that the dependency
- * calculator will be called when the makefile is generated, and
- * for every source file that is built by this tool in the build
- * file, not just for those that have changed since the last build
- * file generation.
- * TYPE_BUILD_COMMANDS indicates that command lines or options will
- * be returned to be used to calculate dependencies. These
- * commands/options are added to the build file to perform dependency
- * calculation at "build time". This currently supports
- * compilers/tools that generate .d files either as a
- * side-effect of tool invocation, or as a separate step that is
- * invoked immediately before or after the tool invocation.
- * TYPE_PREBUILD_COMMANDS indicates that a separate build step is
- * invoked, prior to the the normal build steps, to update the
- * dependency information. These commands are added to the build
- * file to perform dependency calculation at "build time". Note
- * that this step will be invoked every time a build is done in
- * order to determine if dependency files need to be re-generated.
- *
- * @return int
- */
- public int getCalculatorType();
-}
+/*******************************************************************************
+ * Copyright (c) 2006 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.makegen;
+
+/**
+ * @since 3.1
+ *
+ * IManagedDependencyGenerator (deprecated) and IManagedDependencyGenerator2
+ * extend this interface.
+ *
+ * Discussion of Dependency Calculation:
+ *
+ * There are two major, and multiple minor, modes of dependency calculation
+ * supported by the MBS. The major modes are:
+ *
+ * 1. The build file generator invokes tool integrator provided methods
+ * that calculate all dependencies using whatever method the tool
+ * integrator wants. The build file generator then adds the dependencies
+ * to the build file using the appropriate build file syntax.
+ * This is a TYPE_CUSTOM dependency calculator as defined below.
+ * See the IManagedDependencyCalculator interface for more information.
+ *
+ * 2. The build file generator and the tool-chain cooperate in creating and
+ * using separate "dependency" files. In this case, dependency calculation
+ * is done at "build time", rather than at "build file generation time" as
+ * in mode #1. This currently supports the GNU concept of using .d files
+ * in GNU make.
+ * This is either a TYPE_BUILD_COMMANDS dependency calculator or a
+ * TYPE_PREBUILD_COMMANDS dependency calculator as defined below.
+ * See the IManagedDependencyCommands and IManagedDependencyPreBuild
+ * interfaces for more information.
+ *
+ */
+
+public interface IManagedDependencyGeneratorType {
+ /**
+ * Constants returned by getCalculatorType
+ */
+ public int TYPE_NODEPS = 0; // Deprecated - use TYPE_NODEPENDENCIES
+ public int TYPE_COMMAND = 1; // Deprecated - use TYPE_BUILD_COMMANDS
+ public int TYPE_INDEXER = 2; // Deprecated - use TYPE_CUSTOM
+ public int TYPE_EXTERNAL = 3; // Deprecated - use TYPE_CUSTOM
+ public int TYPE_OLD_TYPE_LIMIT = 3;
+
+ // Use these types
+ public int TYPE_NODEPENDENCIES = 4;
+ public int TYPE_BUILD_COMMANDS = 5;
+ public int TYPE_PREBUILD_COMMANDS = 6;
+ public int TYPE_CUSTOM = 7;
+
+ /**
+ * Returns the type of dependency generator that is implemented.
+ *
+ * TYPE_NODEPENDENCIES indicates that no dependency generator is
+ * supplied or needed.
+ * TYPE_CUSTOM indicates that a custom, "build file generation time"
+ * dependency calculator is implemented. Note that the dependency
+ * calculator will be called when the makefile is generated, and
+ * for every source file that is built by this tool in the build
+ * file, not just for those that have changed since the last build
+ * file generation.
+ * TYPE_BUILD_COMMANDS indicates that command lines or options will
+ * be returned to be used to calculate dependencies. These
+ * commands/options are added to the build file to perform dependency
+ * calculation at "build time". This currently supports
+ * compilers/tools that generate .d files either as a
+ * side-effect of tool invocation, or as a separate step that is
+ * invoked immediately before or after the tool invocation.
+ * TYPE_PREBUILD_COMMANDS indicates that a separate build step is
+ * invoked, prior to the the normal build steps, to update the
+ * dependency information. These commands are added to the build
+ * file to perform dependency calculation at "build time". Note
+ * that this step will be invoked every time a build is done in
+ * order to determine if dependency files need to be re-generated.
+ *
+ * @return int
+ */
+ public int getCalculatorType();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyInfo.java
index 849bbd774c2..cd73d580c09 100755
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyInfo.java
@@ -1,35 +1,35 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.makegen;
-
-import org.eclipse.cdt.managedbuilder.core.IBuildObject;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.core.runtime.IPath;
-
-/**
- * @since 3.1
- *
- * This interface is the base interface for IManagedDependencyCalculator,
- * IManagedDependencyCommands and IManagedDependencyPreBuild. See these
- * interfaces and IManagedDependencyGenerator2 for more information on
- * writing a dependency calculator.
- *
- * The methods below simply return the arguments passed to the
- * IManagedDependencyGenerator2.getDependency*Info call that created the
- * IManagedDependencyInfo instance.
- *
- */
-public interface IManagedDependencyInfo {
- public IPath getSource();
- public IBuildObject getBuildContext();
- public ITool getTool();
- public IPath getTopBuildDirectory();
-}
+/*******************************************************************************
+ * Copyright (c) 2006 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.makegen;
+
+import org.eclipse.cdt.managedbuilder.core.IBuildObject;
+import org.eclipse.cdt.managedbuilder.core.ITool;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @since 3.1
+ *
+ * This interface is the base interface for IManagedDependencyCalculator,
+ * IManagedDependencyCommands and IManagedDependencyPreBuild. See these
+ * interfaces and IManagedDependencyGenerator2 for more information on
+ * writing a dependency calculator.
+ *
+ * The methods below simply return the arguments passed to the
+ * IManagedDependencyGenerator2.getDependency*Info call that created the
+ * IManagedDependencyInfo instance.
+ *
+ */
+public interface IManagedDependencyInfo {
+ public IPath getSource();
+ public IBuildObject getBuildContext();
+ public ITool getTool();
+ public IPath getTopBuildDirectory();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java
index 83ef41a83da..d43a686646a 100755
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/IManagedDependencyPreBuild.java
@@ -1,136 +1,136 @@
-/*******************************************************************************
- * Copyright (c) 2006 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.makegen;
-
-import org.eclipse.core.runtime.IPath;
-
-/**
- * @since 3.1
- *
- * A Tool dependency calculator may implement this interface or
- * IManagedDependencyCalculator or IManagedDependencyCommands.
- * An object implementing the interface is returned from a call to
- * IManagedDependencyGenerator2.getDependencySourceInfo.
- *
- * Discussion of Dependency Calculation:
- *
- * There are two major, and multiple minor, modes of dependency calculation
- * supported by the MBS. The major modes are:
- *
- * 1. The build file generator invokes tool integrator provided methods
- * that calculate all dependencies using whatever method the tool
- * integrator wants. The build file generator then adds the dependencies
- * to the build file using the appropriate build file syntax.
- * See the IManagedDependencyCalculator interface for more information.
- *
- * 2. The build file generator and the tool-chain cooperate in creating and
- * using separate "dependency" files. The build file generator calls
- * the dependency calculator to get the dependency file names and to get
- * commands that need to be added to the build file. In this case,
- * dependency calculation is done at "build time", rather than at
- * "build file generation time" as in mode #1. This currently
- * supports the GNU concept of using .d files in GNU make.
- *
- * There are multiple ways that these separate dependency files can
- * be created by the tool-chain and used by the builder.
- *
- * a. In some cases (e.g., Fortran 90 using modules) the dependency files
- * must be created/updated prior to invoking the build of the project
- * artifact (e.g., an application). In this case, the dependency
- * generation step must occur separately before the main build.
- * Use the IManagedDependencyPreBuild interface defined in this file
- * for this mode.
- *
- * b. In other cases (e.g., C/C++) the dependency files can be created as
- * a side effect of the main build. This implies that the up to date
- * dependency files are not required for the current build, but for
- * the next build. C/C++ builds can be treated in this manner as is
- * described in the following link:
- * http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
- *
- * See the IManagedDependencyCommands interface for more information.
- *
- *
- * Note for GNU make: these separate dependency files are "include"d by
- * a main makefile. Make performs special processing on make files:
- *
- * "To this end, after reading in all makefiles, make will consider
- * each as a goal target and attempt to update it. If a makefile has a
- * rule which says how to update it (found either in that very
- * makefile or in another one)..., it will be updated if necessary.
- * After all makefiles have been checked, if any have actually been
- * changed, make starts with a clean slate and reads all the makefiles
- * over again."
- *
- * We can use this to ensure that the dependency files are up to date
- * by adding rules to the make file for generating the dependency files.
- * These rules are returned by the call to getDependencyCommands.
- * However, this has a significant problem when we don’t want to build
- * the build target, but only want to “clean” the configuration,
- * for example. If we invoke make just to clean the configuration,
- * make will still update the dependency files if necessary, thereby
- * re-generating the dependency files only to immediately delete them.
- * The workaround suggested by the make documentation is to check for
- * an invocation using the “clean” target, and to not include the
- * dependency files it that case. For example,
- *
- * ifneq ($(MAKECMDGOALS),clean)
- * include $(DEPS)
- * endif
- *
- * The restriction with this is that it only works if “clean” is the only
- * target specified on the make command line. Therefore, the build
- * "clean" step must be invoked separately.
- */
-
-public interface IManagedDependencyPreBuild extends IManagedDependencyInfo {
-
- /**
- * Returns the list of generated dependency files.
- *
- * The paths can be either relative to the top build directory, or absolute
- * in the file system.
- *
- * @return IPath[]
- */
- public IPath[] getDependencyFiles();
-
- /**
- * Returns the name to be used in the build file to identify the separate
- * build step. Note that this name should be unique to the tool since
- * multiple tools in a tool-chain may be using this method of
- * dependency calculation.
- *
- * @return String
- */
- public String getBuildStepName();
-
- /**
- * Returns the command line(s) to be invoked in the separate
- * dependencies pre-build step.
- *
- * @return String[]
- */
- public String[] getDependencyCommands();
-
- /**
- * Returns true if the command lines returned by this interface
- * are not specific to the particular source file, but are only specific to,
- * at most, the configuration and tool. If the build context is a resource
- * configuration, this method should return false if any of the command lines
- * are different than if the build context were the parent configuration.
- * This can be used by the build file generator in helping to determine if
- * a "pattern" (generic) rule can be used.
- *
- * @return boolean
- */
- public boolean areCommandsGeneric();
-}
+/*******************************************************************************
+ * Copyright (c) 2006 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.makegen;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * @since 3.1
+ *
+ * A Tool dependency calculator may implement this interface or
+ * IManagedDependencyCalculator or IManagedDependencyCommands.
+ * An object implementing the interface is returned from a call to
+ * IManagedDependencyGenerator2.getDependencySourceInfo.
+ *
+ * Discussion of Dependency Calculation:
+ *
+ * There are two major, and multiple minor, modes of dependency calculation
+ * supported by the MBS. The major modes are:
+ *
+ * 1. The build file generator invokes tool integrator provided methods
+ * that calculate all dependencies using whatever method the tool
+ * integrator wants. The build file generator then adds the dependencies
+ * to the build file using the appropriate build file syntax.
+ * See the IManagedDependencyCalculator interface for more information.
+ *
+ * 2. The build file generator and the tool-chain cooperate in creating and
+ * using separate "dependency" files. The build file generator calls
+ * the dependency calculator to get the dependency file names and to get
+ * commands that need to be added to the build file. In this case,
+ * dependency calculation is done at "build time", rather than at
+ * "build file generation time" as in mode #1. This currently
+ * supports the GNU concept of using .d files in GNU make.
+ *
+ * There are multiple ways that these separate dependency files can
+ * be created by the tool-chain and used by the builder.
+ *
+ * a. In some cases (e.g., Fortran 90 using modules) the dependency files
+ * must be created/updated prior to invoking the build of the project
+ * artifact (e.g., an application). In this case, the dependency
+ * generation step must occur separately before the main build.
+ * Use the IManagedDependencyPreBuild interface defined in this file
+ * for this mode.
+ *
+ * b. In other cases (e.g., C/C++) the dependency files can be created as
+ * a side effect of the main build. This implies that the up to date
+ * dependency files are not required for the current build, but for
+ * the next build. C/C++ builds can be treated in this manner as is
+ * described in the following link:
+ * http://sourceware.org/automake/automake.html#Dependency-Tracking-Evolution
+ *
+ * See the IManagedDependencyCommands interface for more information.
+ *
+ *
+ * Note for GNU make: these separate dependency files are "include"d by
+ * a main makefile. Make performs special processing on make files:
+ *
+ * "To this end, after reading in all makefiles, make will consider
+ * each as a goal target and attempt to update it. If a makefile has a
+ * rule which says how to update it (found either in that very
+ * makefile or in another one)..., it will be updated if necessary.
+ * After all makefiles have been checked, if any have actually been
+ * changed, make starts with a clean slate and reads all the makefiles
+ * over again."
+ *
+ * We can use this to ensure that the dependency files are up to date
+ * by adding rules to the make file for generating the dependency files.
+ * These rules are returned by the call to getDependencyCommands.
+ * However, this has a significant problem when we don�t want to build
+ * the build target, but only want to �clean� the configuration,
+ * for example. If we invoke make just to clean the configuration,
+ * make will still update the dependency files if necessary, thereby
+ * re-generating the dependency files only to immediately delete them.
+ * The workaround suggested by the make documentation is to check for
+ * an invocation using the �clean� target, and to not include the
+ * dependency files it that case. For example,
+ *
+ * ifneq ($(MAKECMDGOALS),clean)
+ * include $(DEPS)
+ * endif
+ *
+ * The restriction with this is that it only works if �clean� is the only
+ * target specified on the make command line. Therefore, the build
+ * "clean" step must be invoked separately.
+ */
+
+public interface IManagedDependencyPreBuild extends IManagedDependencyInfo {
+
+ /**
+ * Returns the list of generated dependency files.
+ *
+ * The paths can be either relative to the top build directory, or absolute
+ * in the file system.
+ *
+ * @return IPath[]
+ */
+ public IPath[] getDependencyFiles();
+
+ /**
+ * Returns the name to be used in the build file to identify the separate
+ * build step. Note that this name should be unique to the tool since
+ * multiple tools in a tool-chain may be using this method of
+ * dependency calculation.
+ *
+ * @return String
+ */
+ public String getBuildStepName();
+
+ /**
+ * Returns the command line(s) to be invoked in the separate
+ * dependencies pre-build step.
+ *
+ * @return String[]
+ */
+ public String[] getDependencyCommands();
+
+ /**
+ * Returns true if the command lines returned by this interface
+ * are not specific to the particular source file, but are only specific to,
+ * at most, the configuration and tool. If the build context is a resource
+ * configuration, this method should return false if any of the command lines
+ * are different than if the build context were the parent configuration.
+ * This can be used by the build file generator in helping to determine if
+ * a "pattern" (generic) rule can be used.
+ *
+ * @return boolean
+ */
+ public boolean areCommandsGeneric();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java
index 900502650da..8fa330cf536 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/DefaultGCCDependencyCalculator.java
@@ -1,300 +1,300 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- *******************************************************************************/
-package org.eclipse.cdt.managedbuilder.makegen.gnu;
-
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
-import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineGenerator;
-import org.eclipse.cdt.managedbuilder.core.IManagedCommandLineInfo;
-import org.eclipse.cdt.managedbuilder.core.IResourceConfiguration;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.internal.macros.FileContextData;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * @since 2.0
- */
-public class DefaultGCCDependencyCalculator implements IManagedDependencyGenerator {
-
- private static final String EMPTY_STRING = new String();
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
- public final String WHITESPACE = " "; //$NON-NLS-1$
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#findDependencies(org.eclipse.core.resources.IResource)
- */
- public IResource[] findDependencies(IResource resource, IProject project) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getCalculatorType()
- */
- public int getCalculatorType() {
- return TYPE_COMMAND;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderDependencyCalculator#getDependencyCommand()
- */
- public String getDependencyCommand(IResource resource, IManagedBuildInfo info) {
- /*
- * For a given input,
- * The actual dependencies are recalculated as a result of the build step
- * itself. We are relying on make to do the right things when confronted
- * with a dependency on a moved header file. That said, make will treat
- * the missing header file in a dependency rule as a target it has to build
- * unless told otherwise. These dummy targets are added to the makefile
- * to avoid a missing target error.
- */
- public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
- private GnuMakefileGenerator generator;
- private IManagedBuildInfo info;
-
- /**
- * The constructor
- */
- public ResourceDeltaVisitor(GnuMakefileGenerator generator, IManagedBuildInfo info) {
- this.generator = generator;
- this.info = info;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
- // Should the visitor keep iterating in current directory
- boolean keepLooking = false;
- IResource resource = delta.getResource();
-
- // What kind of resource change has occurred
- if (resource.getType() == IResource.FILE) {
- String ext = resource.getFileExtension();
- switch (delta.getKind()) {
- case IResourceDelta.ADDED:
- if (!generator.isGeneratedResource(resource)) {
- // This is a source file so just add its container
- if (info.buildsFileType(ext)) {
- generator.appendModifiedSubdirectory(resource);
- }
- }
- break;
- case IResourceDelta.REMOVED:
- // we get this notification if a resource is moved too
- if (!generator.isGeneratedResource(resource)) {
- // This is a source file so just add its container
- if (info.buildsFileType(ext)) {
- generator.appendDeletedFile(resource);
- generator.appendModifiedSubdirectory(resource);
- }
- }
- break;
- default:
- keepLooking = true;
- break;
- }
- }
- if (resource.getType() == IResource.FOLDER) {
- // I only care about delete event
- switch (delta.getKind()) {
- case IResourceDelta.REMOVED:
- if (!generator.isGeneratedResource(resource)) {
- generator.appendDeletedSubdirectory((IContainer)resource);
- }
- default:
- break;
- }
- }
- if (resource.getType() == IResource.PROJECT) {
- // If there is a zero-length delta, something the project depends on has changed so just call make
- IResourceDelta[] children = delta.getAffectedChildren();
- if (children != null && children.length > 0) {
- keepLooking = true;
- }
- } else {
- // If the resource is part of the generated directory structure don't recurse
- if (!generator.isGeneratedResource(resource)) {
- keepLooking = true;
- }
- }
-
- return keepLooking;
- }
- }
-
-
-
- /**
- * This class is used to recursively walk the project and determine which
- * modules contribute buildable source files.
- */
- protected class ResourceProxyVisitor implements IResourceProxyVisitor {
- private GnuMakefileGenerator generator;
- private IManagedBuildInfo info;
-
- /**
- * Constructs a new resource proxy visitor to quickly visit project
- * resources.
- */
- public ResourceProxyVisitor(GnuMakefileGenerator generator, IManagedBuildInfo info) {
- this.generator = generator;
- this.info = info;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IResourceProxyVisitor#visit(org.eclipse.core.resources.IResourceProxy)
- */
- public boolean visit(IResourceProxy proxy) throws CoreException {
- // No point in proceeding, is there
- if (generator == null) {
- return false;
- }
-
- // Is this a resource we should even consider
- if (proxy.getType() == IResource.FILE) {
- // If this resource has a Resource Configuration and is not excluded or
- // if it has a file extension that one of the tools builds, add the sudirectory to the list
- IResource resource = proxy.requestResource();
- boolean willBuild = false;
- IResourceConfiguration resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
- if (resConfig != null) willBuild = true;
- if (!willBuild) {
- String ext = resource.getFileExtension();
- if (info.buildsFileType(ext) &&
- // If this file resource is a generated resource, then it is uninteresting
- !generator.isGeneratedResource(resource)) {
- willBuild = true;
- }
- }
- if (willBuild) {
- if ((resConfig == null) || (!(resConfig.isExcluded()))) {
- generator.appendBuildSubdirectory(resource);
- }
- }
- return false;
- }
-
- // Recurse into subdirectories
- return true;
- }
-
- }
-
- // String constants for makefile contents and messages
- private static final String COMMENT = "MakefileGenerator.comment"; //$NON-NLS-1$
- //private static final String AUTO_DEP = COMMENT + ".autodeps"; //$NON-NLS-1$
- //private static final String MESSAGE = "ManagedMakeBuilder.message"; //$NON-NLS-1$
- //private static final String BUILD_ERROR = MESSAGE + ".error"; //$NON-NLS-1$
-
- //private static final String DEP_INCL = COMMENT + ".module.dep.includes"; //$NON-NLS-1$
- private static final String HEADER = COMMENT + ".header"; //$NON-NLS-1$
-
- protected static final String MESSAGE_FINISH_BUILD = ManagedMakeMessages.getResourceString("MakefileGenerator.message.finish.build"); //$NON-NLS-1$
- protected static final String MESSAGE_FINISH_FILE = ManagedMakeMessages.getResourceString("MakefileGenerator.message.finish.file"); //$NON-NLS-1$
- protected static final String MESSAGE_START_BUILD = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.build"); //$NON-NLS-1$
- protected static final String MESSAGE_START_FILE = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.file"); //$NON-NLS-1$
- protected static final String MESSAGE_START_DEPENDENCY = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.dependency"); //$NON-NLS-1$
- protected static final String MESSAGE_NO_TARGET_TOOL = ManagedMakeMessages.getResourceString("MakefileGenerator.message.no.target"); //$NON-NLS-1$
- //private static final String MOD_INCL = COMMENT + ".module.make.includes"; //$NON-NLS-1$
- private static final String MOD_LIST = COMMENT + ".module.list"; //$NON-NLS-1$
- private static final String MOD_VARS = COMMENT + ".module.variables"; //$NON-NLS-1$
- private static final String MOD_RULES = COMMENT + ".build.rule"; //$NON-NLS-1$
- private static final String BUILD_TOP = COMMENT + ".build.toprules"; //$NON-NLS-1$
- private static final String ALL_TARGET = COMMENT + ".build.alltarget"; //$NON-NLS-1$
- private static final String MAINBUILD_TARGET = COMMENT + ".build.mainbuildtarget"; //$NON-NLS-1$
- private static final String BUILD_TARGETS = COMMENT + ".build.toptargets"; //$NON-NLS-1$
- private static final String SRC_LISTS = COMMENT + ".source.list"; //$NON-NLS-1$
-
- private static final String EMPTY_STRING = new String();
- private static final String[] EMPTY_STRING_ARRAY = new String[0];
-
- private static final String OBJS_MACRO = "OBJS"; //$NON-NLS-1$
- private static final String MACRO_ADDITION_ADDPREFIX_HEADER = "${addprefix "; //$NON-NLS-1$
- private static final String MACRO_ADDITION_ADDPREFIX_SUFFIX = "," + WHITESPACE + LINEBREAK; //$NON-NLS-1$
- private static final String MACRO_ADDITION_PREFIX_SUFFIX = "+=" + WHITESPACE + LINEBREAK; //$NON-NLS-1$
- private static final String PREBUILD = "pre-build"; //$NON-NLS-1$
- private static final String MAINBUILD = "main-build"; //$NON-NLS-1$
- private static final String POSTBUILD = "post-build"; //$NON-NLS-1$
- private static final String SECONDARY_OUTPUTS = "secondary-outputs"; //$NON-NLS-1$
-
- // Enumerations
- public static final int
- PROJECT_RELATIVE = 1,
- PROJECT_SUBDIR_RELATIVE = 2,
- ABSOLUTE = 3;
-
- // Local variables needed by generator
- private String buildTargetName;
- private String buildTargetExt;
- private IConfiguration config;
- private ITool[] buildTools;
- private boolean[] buildToolsUsed;
- private ManagedBuildGnuToolInfo[] gnuToolInfos;
- private Vector deletedFileList;
- private Vector deletedDirList;
- private IManagedBuildInfo info;
- private Vector invalidDirList;
- private Vector modifiedList;
- private IProgressMonitor monitor;
- private IProject project;
- private IResource[] projectResources;
- private Vector ruleList;
- private Vector depLineList; // String's of additional dependency lines
- private Vector depRuleList; // String's of rules for generating dependency files
- private Vector subdirList;
- private IPath topBuildDir; // Build directory - relative to the workspace
- private Set outputExtensionsSet;
- // Maps of macro names (String) to values (List)
- private HashMap buildSrcVars = new HashMap(); // Map of source file build variable names
- // to a List of source file Path's
- private HashMap buildOutVars = new HashMap(); // Map of output file build variable names
- // to a List of output file Path's
- private HashMap buildDepVars = new HashMap(); // Map of dependency file build variable names
- // to a List of GnuDependencyGroupInfo objects
- private LinkedHashMap topBuildOutVars = new LinkedHashMap();
- // Dependency file variables
- private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute
-
-
- public GnuMakefileGenerator() {
- super();
- }
-
-
- /*************************************************************************
- * IManagedBuilderMakefileGenerator M E T H O D S
- ************************************************************************/
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#initialize()
- *
- * @param project
- * @param info
- * @param monitor
- */
- public void initialize(IProject project, IManagedBuildInfo info, IProgressMonitor monitor) {
- // Save the project so we can get path and member information
- this.project = project;
- try {
- projectResources = project.members();
- } catch (CoreException e) {
- projectResources = null;
- }
- // Save the monitor reference for reporting back to the user
- this.monitor = monitor;
- // Get the build info for the project
- this.info = info;
- // Get the name of the build target
- buildTargetName = info.getBuildArtifactName();
- // Get its extension
- buildTargetExt = info.getBuildArtifactExtension();
-
- try{
- //try to resolve the build macros in the target extension
- buildTargetExt = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
- buildTargetExt,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_CONFIGURATION,
- info.getDefaultConfiguration());
- } catch (BuildMacroException e){
- }
-
- try{
- //try to resolve the build macros in the target name
- String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
- buildTargetName,
- "", //$NON-NLS-1$
- " ", //$NON-NLS-1$
- IBuildMacroProvider.CONTEXT_CONFIGURATION,
- info.getDefaultConfiguration());
- if((resolved = resolved.trim()).length() > 0)
- buildTargetName = resolved;
- } catch (BuildMacroException e){
- }
-
-
- if (buildTargetExt == null) {
- buildTargetExt = new String();
- }
- // Cache the build tools
- config = info.getDefaultConfiguration();
- buildTools = config.getFilteredTools();
- buildToolsUsed = new boolean[buildTools.length];
- for (int i=0; i
+ * The actual dependencies are recalculated as a result of the build step
+ * itself. We are relying on make to do the right things when confronted
+ * with a dependency on a moved header file. That said, make will treat
+ * the missing header file in a dependency rule as a target it has to build
+ * unless told otherwise. These dummy targets are added to the makefile
+ * to avoid a missing target error.
+ */
+ public class ResourceDeltaVisitor implements IResourceDeltaVisitor {
+ private GnuMakefileGenerator generator;
+ private IManagedBuildInfo info;
+
+ /**
+ * The constructor
+ */
+ public ResourceDeltaVisitor(GnuMakefileGenerator generator, IManagedBuildInfo info) {
+ this.generator = generator;
+ this.info = info;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
+ */
+ public boolean visit(IResourceDelta delta) throws CoreException {
+ // Should the visitor keep iterating in current directory
+ boolean keepLooking = false;
+ IResource resource = delta.getResource();
+
+ // What kind of resource change has occurred
+ if (resource.getType() == IResource.FILE) {
+ String ext = resource.getFileExtension();
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ if (!generator.isGeneratedResource(resource)) {
+ // This is a source file so just add its container
+ if (info.buildsFileType(ext)) {
+ generator.appendModifiedSubdirectory(resource);
+ }
+ }
+ break;
+ case IResourceDelta.REMOVED:
+ // we get this notification if a resource is moved too
+ if (!generator.isGeneratedResource(resource)) {
+ // This is a source file so just add its container
+ if (info.buildsFileType(ext)) {
+ generator.appendDeletedFile(resource);
+ generator.appendModifiedSubdirectory(resource);
+ }
+ }
+ break;
+ default:
+ keepLooking = true;
+ break;
+ }
+ }
+ if (resource.getType() == IResource.FOLDER) {
+ // I only care about delete event
+ switch (delta.getKind()) {
+ case IResourceDelta.REMOVED:
+ if (!generator.isGeneratedResource(resource)) {
+ generator.appendDeletedSubdirectory((IContainer)resource);
+ }
+ default:
+ break;
+ }
+ }
+ if (resource.getType() == IResource.PROJECT) {
+ // If there is a zero-length delta, something the project depends on has changed so just call make
+ IResourceDelta[] children = delta.getAffectedChildren();
+ if (children != null && children.length > 0) {
+ keepLooking = true;
+ }
+ } else {
+ // If the resource is part of the generated directory structure don't recurse
+ if (!generator.isGeneratedResource(resource)) {
+ keepLooking = true;
+ }
+ }
+
+ return keepLooking;
+ }
+ }
+
+
+
+ /**
+ * This class is used to recursively walk the project and determine which
+ * modules contribute buildable source files.
+ */
+ protected class ResourceProxyVisitor implements IResourceProxyVisitor {
+ private GnuMakefileGenerator generator;
+ private IManagedBuildInfo info;
+
+ /**
+ * Constructs a new resource proxy visitor to quickly visit project
+ * resources.
+ */
+ public ResourceProxyVisitor(GnuMakefileGenerator generator, IManagedBuildInfo info) {
+ this.generator = generator;
+ this.info = info;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.resources.IResourceProxyVisitor#visit(org.eclipse.core.resources.IResourceProxy)
+ */
+ public boolean visit(IResourceProxy proxy) throws CoreException {
+ // No point in proceeding, is there
+ if (generator == null) {
+ return false;
+ }
+
+ // Is this a resource we should even consider
+ if (proxy.getType() == IResource.FILE) {
+ // If this resource has a Resource Configuration and is not excluded or
+ // if it has a file extension that one of the tools builds, add the sudirectory to the list
+ IResource resource = proxy.requestResource();
+ boolean willBuild = false;
+ IResourceConfiguration resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
+ if (resConfig != null) willBuild = true;
+ if (!willBuild) {
+ String ext = resource.getFileExtension();
+ if (info.buildsFileType(ext) &&
+ // If this file resource is a generated resource, then it is uninteresting
+ !generator.isGeneratedResource(resource)) {
+ willBuild = true;
+ }
+ }
+ if (willBuild) {
+ if ((resConfig == null) || (!(resConfig.isExcluded()))) {
+ generator.appendBuildSubdirectory(resource);
+ }
+ }
+ return false;
+ }
+
+ // Recurse into subdirectories
+ return true;
+ }
+
+ }
+
+ // String constants for makefile contents and messages
+ private static final String COMMENT = "MakefileGenerator.comment"; //$NON-NLS-1$
+ //private static final String AUTO_DEP = COMMENT + ".autodeps"; //$NON-NLS-1$
+ //private static final String MESSAGE = "ManagedMakeBuilder.message"; //$NON-NLS-1$
+ //private static final String BUILD_ERROR = MESSAGE + ".error"; //$NON-NLS-1$
+
+ //private static final String DEP_INCL = COMMENT + ".module.dep.includes"; //$NON-NLS-1$
+ private static final String HEADER = COMMENT + ".header"; //$NON-NLS-1$
+
+ protected static final String MESSAGE_FINISH_BUILD = ManagedMakeMessages.getResourceString("MakefileGenerator.message.finish.build"); //$NON-NLS-1$
+ protected static final String MESSAGE_FINISH_FILE = ManagedMakeMessages.getResourceString("MakefileGenerator.message.finish.file"); //$NON-NLS-1$
+ protected static final String MESSAGE_START_BUILD = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.build"); //$NON-NLS-1$
+ protected static final String MESSAGE_START_FILE = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.file"); //$NON-NLS-1$
+ protected static final String MESSAGE_START_DEPENDENCY = ManagedMakeMessages.getResourceString("MakefileGenerator.message.start.dependency"); //$NON-NLS-1$
+ protected static final String MESSAGE_NO_TARGET_TOOL = ManagedMakeMessages.getResourceString("MakefileGenerator.message.no.target"); //$NON-NLS-1$
+ //private static final String MOD_INCL = COMMENT + ".module.make.includes"; //$NON-NLS-1$
+ private static final String MOD_LIST = COMMENT + ".module.list"; //$NON-NLS-1$
+ private static final String MOD_VARS = COMMENT + ".module.variables"; //$NON-NLS-1$
+ private static final String MOD_RULES = COMMENT + ".build.rule"; //$NON-NLS-1$
+ private static final String BUILD_TOP = COMMENT + ".build.toprules"; //$NON-NLS-1$
+ private static final String ALL_TARGET = COMMENT + ".build.alltarget"; //$NON-NLS-1$
+ private static final String MAINBUILD_TARGET = COMMENT + ".build.mainbuildtarget"; //$NON-NLS-1$
+ private static final String BUILD_TARGETS = COMMENT + ".build.toptargets"; //$NON-NLS-1$
+ private static final String SRC_LISTS = COMMENT + ".source.list"; //$NON-NLS-1$
+
+ private static final String EMPTY_STRING = new String();
+ private static final String[] EMPTY_STRING_ARRAY = new String[0];
+
+ private static final String OBJS_MACRO = "OBJS"; //$NON-NLS-1$
+ private static final String MACRO_ADDITION_ADDPREFIX_HEADER = "${addprefix "; //$NON-NLS-1$
+ private static final String MACRO_ADDITION_ADDPREFIX_SUFFIX = "," + WHITESPACE + LINEBREAK; //$NON-NLS-1$
+ private static final String MACRO_ADDITION_PREFIX_SUFFIX = "+=" + WHITESPACE + LINEBREAK; //$NON-NLS-1$
+ private static final String PREBUILD = "pre-build"; //$NON-NLS-1$
+ private static final String MAINBUILD = "main-build"; //$NON-NLS-1$
+ private static final String POSTBUILD = "post-build"; //$NON-NLS-1$
+ private static final String SECONDARY_OUTPUTS = "secondary-outputs"; //$NON-NLS-1$
+
+ // Enumerations
+ public static final int
+ PROJECT_RELATIVE = 1,
+ PROJECT_SUBDIR_RELATIVE = 2,
+ ABSOLUTE = 3;
+
+ // Local variables needed by generator
+ private String buildTargetName;
+ private String buildTargetExt;
+ private IConfiguration config;
+ private ITool[] buildTools;
+ private boolean[] buildToolsUsed;
+ private ManagedBuildGnuToolInfo[] gnuToolInfos;
+ private Vector deletedFileList;
+ private Vector deletedDirList;
+ private IManagedBuildInfo info;
+ private Vector invalidDirList;
+ private Vector modifiedList;
+ private IProgressMonitor monitor;
+ private IProject project;
+ private IResource[] projectResources;
+ private Vector ruleList;
+ private Vector depLineList; // String's of additional dependency lines
+ private Vector depRuleList; // String's of rules for generating dependency files
+ private Vector subdirList;
+ private IPath topBuildDir; // Build directory - relative to the workspace
+ private Set outputExtensionsSet;
+ // Maps of macro names (String) to values (List)
+ private HashMap buildSrcVars = new HashMap(); // Map of source file build variable names
+ // to a List of source file Path's
+ private HashMap buildOutVars = new HashMap(); // Map of output file build variable names
+ // to a List of output file Path's
+ private HashMap buildDepVars = new HashMap(); // Map of dependency file build variable names
+ // to a List of GnuDependencyGroupInfo objects
+ private LinkedHashMap topBuildOutVars = new LinkedHashMap();
+ // Dependency file variables
+ private Vector dependencyMakefiles; // IPath's - relative to the top build directory or absolute
+
+
+ public GnuMakefileGenerator() {
+ super();
+ }
+
+
+ /*************************************************************************
+ * IManagedBuilderMakefileGenerator M E T H O D S
+ ************************************************************************/
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator#initialize()
+ *
+ * @param project
+ * @param info
+ * @param monitor
+ */
+ public void initialize(IProject project, IManagedBuildInfo info, IProgressMonitor monitor) {
+ // Save the project so we can get path and member information
+ this.project = project;
+ try {
+ projectResources = project.members();
+ } catch (CoreException e) {
+ projectResources = null;
+ }
+ // Save the monitor reference for reporting back to the user
+ this.monitor = monitor;
+ // Get the build info for the project
+ this.info = info;
+ // Get the name of the build target
+ buildTargetName = info.getBuildArtifactName();
+ // Get its extension
+ buildTargetExt = info.getBuildArtifactExtension();
+
+ try{
+ //try to resolve the build macros in the target extension
+ buildTargetExt = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ buildTargetExt,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ info.getDefaultConfiguration());
+ } catch (BuildMacroException e){
+ }
+
+ try{
+ //try to resolve the build macros in the target name
+ String resolved = ManagedBuildManager.getBuildMacroProvider().resolveValueToMakefileFormat(
+ buildTargetName,
+ "", //$NON-NLS-1$
+ " ", //$NON-NLS-1$
+ IBuildMacroProvider.CONTEXT_CONFIGURATION,
+ info.getDefaultConfiguration());
+ if((resolved = resolved.trim()).length() > 0)
+ buildTargetName = resolved;
+ } catch (BuildMacroException e){
+ }
+
+
+ if (buildTargetExt == null) {
+ buildTargetExt = new String();
+ }
+ // Cache the build tools
+ config = info.getDefaultConfiguration();
+ buildTools = config.getFilteredTools();
+ buildToolsUsed = new boolean[buildTools.length];
+ for (int i=0; inull
- * @param targetName If this is the "targetTool", the target file extension, else null
- * @param outputVarsAdditionsList list to add needed build output variables to
- * @param managedProjectOutputs Other projects in the workspace that this project depends upon
- * @param bPostBuildStep Emit post-build step invocation
- */
- protected boolean addRuleForTool(ITool tool, StringBuffer buffer, boolean bTargetTool, String targetName, String targetExt,
- List outputVarsAdditionsList, Vector managedProjectOutputs, boolean bEmitPostBuildStepCall) {
-
- // Get the tool's inputs and outputs
- Vector inputs = new Vector();
- Vector dependencies = new Vector();
- Vector outputs = new Vector();
- Vector enumeratedPrimaryOutputs = new Vector();
- Vector enumeratedSecondaryOutputs = new Vector();
- Vector outputVariables = new Vector();
- Vector additionalTargets = new Vector();
- String outputPrefix = EMPTY_STRING;
-
- if (!getToolInputsOutputs(tool, inputs, dependencies, outputs,
- enumeratedPrimaryOutputs, enumeratedSecondaryOutputs,
- outputVariables, additionalTargets, bTargetTool, managedProjectOutputs)) {
- return false;
- }
-
- // If we have no primary output, make all of the secondary outputs the primary output
- if (enumeratedPrimaryOutputs.size() == 0) {
- enumeratedPrimaryOutputs = enumeratedSecondaryOutputs;
- enumeratedSecondaryOutputs.clear();
- }
-
- // Add the output variables for this tool to our list
- outputVarsAdditionsList.addAll(outputVariables);
-
- // Create the build rule
- String buildRule = EMPTY_STRING;
- String outflag = tool.getOutputFlag();
-
- String primaryOutputs = EMPTY_STRING;
- boolean first = true;
- for (int i=0; iStringBuffer
containing makefile text for all of the sources
- * contributed by a container (project directory/subdirectory) to the fragement makefile
- *
- * @param module project resource directory/subdirectory
- * @return StringBuffer generated text for the fragement makefile
- */
- protected StringBuffer addSources(IContainer module) throws CoreException {
- // Calculate the new directory relative to the build output
- IPath moduleRelativePath = module.getProjectRelativePath();
- String relativePath = moduleRelativePath.toString();
- relativePath += relativePath.length() == 0 ? "" : SEPARATOR; //$NON-NLS-1$
-
- // For build macros in the configuration, create a map which will map them
- // to a string which holds its list of sources.
- LinkedHashMap buildVarToRuleStringMap = new LinkedHashMap();
-
- // Add statements that add the source files in this folder,
- // and generated source files, and generated dependency files
- // to the build macros
- Iterator iterator = buildSrcVars.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry)iterator.next();
- String macroName = (String)entry.getKey();
- addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, null, false);
- }
- iterator = buildOutVars.entrySet().iterator();
- while (iterator.hasNext()) {
- Map.Entry entry = (Map.Entry)iterator.next();
- String macroName = (String)entry.getKey();
- addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "./" + relativePath, false); //$NON-NLS-1$
- }
-
- // String buffers
- StringBuffer buffer = new StringBuffer(); // Return buffer
- StringBuffer ruleBuffer = new StringBuffer(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MOD_RULES) + NEWLINE);
-
- // Visit the resources in this folder and add each one to a sources macro, and generate a build rule, if appropriate
- IResource[] resources = module.members();
-
- IResourceConfiguration resConfig;
- IFolder folder = project.getFolder(info.getConfigurationName());
-
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if (resource.getType() == IResource.FILE) {
- // Check whether this resource is excluded from build
- resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
- if( (resConfig != null) && (resConfig.isExcluded()) )
- continue;
- addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer,
- folder, relativePath, resource, resource.getLocation(), resConfig, null, false);
- }
- }
-
- // Write out the macro addition entries to the buffer
- buffer.append(writeAdditionMacros(buildVarToRuleStringMap));
- return buffer.append(ruleBuffer + NEWLINE);
- }
-
- /* (non-Javadoc
- * Adds the entries for a particular source file to the fragment makefile
- *
- * @param buildVarToRuleStringMap map of build variable names to the list of files assigned to the variable
- * @param ruleBuffer buffer to add generated nmakefile text to
- * @param folder the top level build output directory
- * @param relativePath build output directory relative path of the current output directory
- * @param resource the source file for this invocation of the tool - this may be null for a generated output
- * @param sourceLocation the full path of the source
- * @param resConfig the IResourceConfiguration associated with this file or null
- * @param varName the build variable to add this invocation's outputs to
- * if null
, use the file extension to find the name
- * @param generatedSource if true
, this file was generated by another tool in the tool-chain
- */
- protected void addFragmentMakefileEntriesForSource (LinkedHashMap buildVarToRuleStringMap, StringBuffer ruleBuffer,
- IFolder folder, String relativePath, IResource resource, IPath sourceLocation, IResourceConfiguration resConfig,
- String varName, boolean generatedSource) {
-
- // Determine which tool, if any, builds files with this extension
- String ext = sourceLocation.getFileExtension();
- ITool tool = null;
-
- // Use the tool from the resource configuration if there is one
- if (resConfig != null) {
- ITool[] tools = resConfig.getToolsToInvoke();
- if (tools != null && tools.length > 0) {
- tool = tools[0];
- }
- }
- for (int j=0; jnull
, use the file extension to find the name
- * @param relativePath build output directory relative path of the current output directory
- * @param sourceLocation the full path of the source
- * @param generatedSource if true
, this file was generated by another tool in the tool-chain
- */
- protected void addToBuildVar (LinkedHashMap buildVarToRuleStringMap, String ext,
- String varName, String relativePath, IPath sourceLocation, boolean generatedSource) {
- List varList = null;
- if (varName == null) {
- // Get the proper source build variable based upon the extension
- varName = getSourceMacroName(ext).toString();
- varList = (List)buildSrcVars.get(varName);
- } else {
- varList = (List)buildOutVars.get(varName);
- }
- // Add the resource to the list of all resources associated with a variable.
- // Do not allow duplicates - there is no reason to and it can be 'bad' -
- // e.g., having the same object in the OBJS list can cause duplicate symbol errors from the linker
- if ((varList != null) && !(varList.contains(sourceLocation))) {
- // Since we don't know how these files will be used, we store them using a "location"
- // path rather than a relative path
- varList.add(sourceLocation);
- if (!buildVarToRuleStringMap.containsKey(varName)) {
- // TODO - is this an error?
- } else {
- // Add the resource name to the makefile line that adds resources to the build variable
- addMacroAdditionFile(buildVarToRuleStringMap, varName, relativePath, sourceLocation, generatedSource);
- }
- }
- }
-
- /* (non-Javadoc)
- * Create a rule for this source file. We create a pattern rule if possible.
- *
- * This is an example of a pattern rule:
- *
- * true
if the resource is a generated output
- * @param generatedDepFile build directory relative paths of the dependency files generated by the rule
- * @param enumeratedOutputs vector of the filenames that are the output of this rule
- */
- protected void addRuleForSource(String relativePath, StringBuffer buffer, IResource resource,
- IPath sourceLocation, IResourceConfiguration resConfig,
- boolean generatedSource, Vector generatedDepFiles, Vector enumeratedOutputs) {
-
- String fileName = sourceLocation.removeFileExtension().lastSegment();
- String inputExtension = sourceLocation.getFileExtension();
- String outputExtension = info.getOutputExtension(inputExtension);
-
- ITool tool = null;
- if( resConfig != null) {
- ITool[] tools = resConfig.getToolsToInvoke();
- if (tools != null && tools.length > 0) {
- tool = tools[0];
- }
- }
- if (tool == null) {
- tool = info.getToolFromInputExtension(inputExtension);
- }
-
- // Get the dependency generator information for this tool and file extension
- IManagedDependencyGenerator oldDepGen = null; // This interface is deprecated but still supported
- IManagedDependencyGenerator2 depGen = null; // This is the recommended interface
- IManagedDependencyInfo depInfo = null;
- IManagedDependencyCommands depCommands = null;
- IManagedDependencyPreBuild depPreBuild = null;
- IPath[] depFiles = null;
- boolean doDepGen = false;
- {
- IManagedDependencyGeneratorType t = tool.getDependencyGeneratorForExtension(inputExtension);
- if (t != null) {
- int calcType = t.getCalculatorType();
- if (calcType <= IManagedDependencyGeneratorType.TYPE_OLD_TYPE_LIMIT) {
- oldDepGen = (IManagedDependencyGenerator)t;
- doDepGen = (calcType == IManagedDependencyGeneratorType.TYPE_COMMAND);
- if (doDepGen) {
- IPath depFile = Path.fromOSString(relativePath + fileName + DOT + DEP_EXT);
- getDependencyMakefiles().add(depFile);
- generatedDepFiles.add(depFile);
- }
- } else {
- depGen = (IManagedDependencyGenerator2)t;
- doDepGen = (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS);
- IBuildObject buildContext = (resConfig != null) ? (IBuildObject)resConfig : (IBuildObject)config;
- depInfo = depGen.getDependencySourceInfo(resource.getProjectRelativePath(), buildContext, tool, getBuildWorkingDir());
- if (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS) {
- depCommands = (IManagedDependencyCommands)depInfo;
- depFiles = depCommands.getDependencyFiles();
- } else if (calcType == IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS) {
- depPreBuild = (IManagedDependencyPreBuild)depInfo;
- depFiles = depPreBuild.getDependencyFiles();
- }
- if (depFiles != null) {
- for (int i=0; iIPath
s for this invocation of the tool with the specified source file
- /*
- * The priorities for determining the names of the outputs of a tool are:
- * 1. If the tool is the build target and primary output, use artifact name & extension -
- * This case does not apply here...
- * 2. If an option is specified, use the value of the option
- * 3. If a nameProvider is specified, call it
- * 4. If outputNames is specified, use it
- * 5. Use the name pattern to generate a transformation macro
- * so that the source names can be transformed into the target names
- * using the built-in string substitution functions of make
.
- *
- * @param tool
- * @param relativePath build output directory relative path of the current output directory
- * @param resource
- * @param ruleOutputs Vector of rule IPaths that are relative to the build directory
- * @param enumeratedPrimaryOutputs Vector of IPaths of primary outputs
- * that are relative to the build directory
- * @param enumeratedSecondaryOutputs Vector of IPaths of secondary outputs
- * that are relative to the build directory
- */
- protected void calculateOutputsForSource(ITool tool, String relativePath, IResource resource,
- IPath sourceLocation, Vector ruleOutputs, Vector enumeratedPrimaryOutputs, Vector enumeratedSecondaryOutputs) {
- String inExt = sourceLocation.getFileExtension();
- String outExt = tool.getOutputExtension(inExt);
-
- IOutputType[] outTypes = tool.getOutputTypes();
- if (outTypes != null && outTypes.length > 0) {
- for (int i=0; imake
.
- if (multOfType) {
- // This case is not handled - a nameProvider or outputNames must be specified
- // TODO - report error
- } else {
- String namePattern = type.getNamePattern();
- IPath namePatternPath = null;
- if (namePattern == null || namePattern.length() == 0) {
- namePattern = relativePath + outputPrefix + IManagedBuilderMakefileGenerator.WILDCARD;
- if (outExt != null && outExt.length() > 0) {
- namePattern += DOT + outExt;
- }
- namePatternPath = Path.fromOSString(namePattern);
- }
- else {
- if (outputPrefix.length() > 0) {
- namePattern = outputPrefix + namePattern;
- }
- namePatternPath = Path.fromOSString(namePattern);
- // If only a file name is specified, add the relative path of this output directory
- if (namePatternPath.segmentCount() == 1) {
- namePatternPath = Path.fromOSString(relativePath + namePatternPath.toString());
- }
- }
-
- if (primaryOutput) {
- ruleOutputs.add(0, namePatternPath);
- enumeratedPrimaryOutputs.add(0, resolvePercent(namePatternPath, sourceLocation));
- } else {
- ruleOutputs.add(namePatternPath);
- enumeratedSecondaryOutputs.add(resolvePercent(namePatternPath, sourceLocation));
- }
- }
- }
- }
- } else {
- // For support of pre-CDT 3.0 integrations.
- // NOTE WELL: This only supports the case of a single "target tool"
- // that consumes exactly all of the object files, $OBJS, produced
- // by other tools in the build and produces a single output.
- // In this case, the output file name is the input file name with
- // the output extension.
-
- //if (!ignorePrimary) {
- String outPrefix = tool.getOutputPrefix();
- IPath outPath = Path.fromOSString(relativePath + outPrefix + WILDCARD);
- outPath = outPath.addFileExtension(outExt);
- ruleOutputs.add(0, outPath);
- enumeratedPrimaryOutputs.add(0, resolvePercent(outPath, sourceLocation));
- //}
- }
- }
-
- /* (non-Javadoc)
- * If the path contains a %, returns the path resolved using the resource name
- *
- */
- protected IPath resolvePercent(IPath outPath, IPath sourceLocation) {
- // Get the input file name
- String fileName = sourceLocation.removeFileExtension().lastSegment();
- // Replace the % with the file name
- String outName = outPath.toOSString().replaceAll("%", fileName); //$NON-NLS-1$
- return Path.fromOSString(outName);
- }
-
- /* (non-Javadoc)
- * Returns the dependency IPath
s for this invocation of the tool with the specified source file
- *
- * @param depGen the dependency calculator
- * @param tool tool used to build the source file
- * @param relativePath build output directory relative path of the current output directory
- * @param resource source file to scan for dependencies
- * @return Vector of IPaths that are relative to the build directory
- */
- protected IPath[] oldCalculateDependenciesForSource(IManagedDependencyGenerator depGen, ITool tool, String relativePath, IResource resource) {
- Vector deps = new Vector();
- int type = depGen.getCalculatorType();
-
- switch (type) {
-
- case IManagedDependencyGeneratorType.TYPE_INDEXER:
- case IManagedDependencyGeneratorType.TYPE_EXTERNAL:
- IResource[] res = depGen.findDependencies(resource, project);
- if (res != null) {
- for (int i=0; inull
+ * @param targetName If this is the "targetTool", the target file extension, else null
+ * @param outputVarsAdditionsList list to add needed build output variables to
+ * @param managedProjectOutputs Other projects in the workspace that this project depends upon
+ * @param bPostBuildStep Emit post-build step invocation
+ */
+ protected boolean addRuleForTool(ITool tool, StringBuffer buffer, boolean bTargetTool, String targetName, String targetExt,
+ List outputVarsAdditionsList, Vector managedProjectOutputs, boolean bEmitPostBuildStepCall) {
+
+ // Get the tool's inputs and outputs
+ Vector inputs = new Vector();
+ Vector dependencies = new Vector();
+ Vector outputs = new Vector();
+ Vector enumeratedPrimaryOutputs = new Vector();
+ Vector enumeratedSecondaryOutputs = new Vector();
+ Vector outputVariables = new Vector();
+ Vector additionalTargets = new Vector();
+ String outputPrefix = EMPTY_STRING;
+
+ if (!getToolInputsOutputs(tool, inputs, dependencies, outputs,
+ enumeratedPrimaryOutputs, enumeratedSecondaryOutputs,
+ outputVariables, additionalTargets, bTargetTool, managedProjectOutputs)) {
+ return false;
+ }
+
+ // If we have no primary output, make all of the secondary outputs the primary output
+ if (enumeratedPrimaryOutputs.size() == 0) {
+ enumeratedPrimaryOutputs = enumeratedSecondaryOutputs;
+ enumeratedSecondaryOutputs.clear();
+ }
+
+ // Add the output variables for this tool to our list
+ outputVarsAdditionsList.addAll(outputVariables);
+
+ // Create the build rule
+ String buildRule = EMPTY_STRING;
+ String outflag = tool.getOutputFlag();
+
+ String primaryOutputs = EMPTY_STRING;
+ boolean first = true;
+ for (int i=0; iStringBuffer
containing makefile text for all of the sources
+ * contributed by a container (project directory/subdirectory) to the fragement makefile
+ *
+ * @param module project resource directory/subdirectory
+ * @return StringBuffer generated text for the fragement makefile
+ */
+ protected StringBuffer addSources(IContainer module) throws CoreException {
+ // Calculate the new directory relative to the build output
+ IPath moduleRelativePath = module.getProjectRelativePath();
+ String relativePath = moduleRelativePath.toString();
+ relativePath += relativePath.length() == 0 ? "" : SEPARATOR; //$NON-NLS-1$
+
+ // For build macros in the configuration, create a map which will map them
+ // to a string which holds its list of sources.
+ LinkedHashMap buildVarToRuleStringMap = new LinkedHashMap();
+
+ // Add statements that add the source files in this folder,
+ // and generated source files, and generated dependency files
+ // to the build macros
+ Iterator iterator = buildSrcVars.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = (Map.Entry)iterator.next();
+ String macroName = (String)entry.getKey();
+ addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, null, false);
+ }
+ iterator = buildOutVars.entrySet().iterator();
+ while (iterator.hasNext()) {
+ Map.Entry entry = (Map.Entry)iterator.next();
+ String macroName = (String)entry.getKey();
+ addMacroAdditionPrefix(buildVarToRuleStringMap, macroName, "./" + relativePath, false); //$NON-NLS-1$
+ }
+
+ // String buffers
+ StringBuffer buffer = new StringBuffer(); // Return buffer
+ StringBuffer ruleBuffer = new StringBuffer(COMMENT_SYMBOL + WHITESPACE + ManagedMakeMessages.getResourceString(MOD_RULES) + NEWLINE);
+
+ // Visit the resources in this folder and add each one to a sources macro, and generate a build rule, if appropriate
+ IResource[] resources = module.members();
+
+ IResourceConfiguration resConfig;
+ IFolder folder = project.getFolder(info.getConfigurationName());
+
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (resource.getType() == IResource.FILE) {
+ // Check whether this resource is excluded from build
+ resConfig = config.getResourceConfiguration(resource.getFullPath().toString());
+ if( (resConfig != null) && (resConfig.isExcluded()) )
+ continue;
+ addFragmentMakefileEntriesForSource(buildVarToRuleStringMap, ruleBuffer,
+ folder, relativePath, resource, resource.getLocation(), resConfig, null, false);
+ }
+ }
+
+ // Write out the macro addition entries to the buffer
+ buffer.append(writeAdditionMacros(buildVarToRuleStringMap));
+ return buffer.append(ruleBuffer + NEWLINE);
+ }
+
+ /* (non-Javadoc
+ * Adds the entries for a particular source file to the fragment makefile
+ *
+ * @param buildVarToRuleStringMap map of build variable names to the list of files assigned to the variable
+ * @param ruleBuffer buffer to add generated nmakefile text to
+ * @param folder the top level build output directory
+ * @param relativePath build output directory relative path of the current output directory
+ * @param resource the source file for this invocation of the tool - this may be null for a generated output
+ * @param sourceLocation the full path of the source
+ * @param resConfig the IResourceConfiguration associated with this file or null
+ * @param varName the build variable to add this invocation's outputs to
+ * if null
, use the file extension to find the name
+ * @param generatedSource if true
, this file was generated by another tool in the tool-chain
+ */
+ protected void addFragmentMakefileEntriesForSource (LinkedHashMap buildVarToRuleStringMap, StringBuffer ruleBuffer,
+ IFolder folder, String relativePath, IResource resource, IPath sourceLocation, IResourceConfiguration resConfig,
+ String varName, boolean generatedSource) {
+
+ // Determine which tool, if any, builds files with this extension
+ String ext = sourceLocation.getFileExtension();
+ ITool tool = null;
+
+ // Use the tool from the resource configuration if there is one
+ if (resConfig != null) {
+ ITool[] tools = resConfig.getToolsToInvoke();
+ if (tools != null && tools.length > 0) {
+ tool = tools[0];
+ }
+ }
+ for (int j=0; jnull
, use the file extension to find the name
+ * @param relativePath build output directory relative path of the current output directory
+ * @param sourceLocation the full path of the source
+ * @param generatedSource if true
, this file was generated by another tool in the tool-chain
+ */
+ protected void addToBuildVar (LinkedHashMap buildVarToRuleStringMap, String ext,
+ String varName, String relativePath, IPath sourceLocation, boolean generatedSource) {
+ List varList = null;
+ if (varName == null) {
+ // Get the proper source build variable based upon the extension
+ varName = getSourceMacroName(ext).toString();
+ varList = (List)buildSrcVars.get(varName);
+ } else {
+ varList = (List)buildOutVars.get(varName);
+ }
+ // Add the resource to the list of all resources associated with a variable.
+ // Do not allow duplicates - there is no reason to and it can be 'bad' -
+ // e.g., having the same object in the OBJS list can cause duplicate symbol errors from the linker
+ if ((varList != null) && !(varList.contains(sourceLocation))) {
+ // Since we don't know how these files will be used, we store them using a "location"
+ // path rather than a relative path
+ varList.add(sourceLocation);
+ if (!buildVarToRuleStringMap.containsKey(varName)) {
+ // TODO - is this an error?
+ } else {
+ // Add the resource name to the makefile line that adds resources to the build variable
+ addMacroAdditionFile(buildVarToRuleStringMap, varName, relativePath, sourceLocation, generatedSource);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * Create a rule for this source file. We create a pattern rule if possible.
+ *
+ * This is an example of a pattern rule:
+ *
+ * true
if the resource is a generated output
+ * @param generatedDepFile build directory relative paths of the dependency files generated by the rule
+ * @param enumeratedOutputs vector of the filenames that are the output of this rule
+ */
+ protected void addRuleForSource(String relativePath, StringBuffer buffer, IResource resource,
+ IPath sourceLocation, IResourceConfiguration resConfig,
+ boolean generatedSource, Vector generatedDepFiles, Vector enumeratedOutputs) {
+
+ String fileName = sourceLocation.removeFileExtension().lastSegment();
+ String inputExtension = sourceLocation.getFileExtension();
+ String outputExtension = info.getOutputExtension(inputExtension);
+
+ ITool tool = null;
+ if( resConfig != null) {
+ ITool[] tools = resConfig.getToolsToInvoke();
+ if (tools != null && tools.length > 0) {
+ tool = tools[0];
+ }
+ }
+ if (tool == null) {
+ tool = info.getToolFromInputExtension(inputExtension);
+ }
+
+ // Get the dependency generator information for this tool and file extension
+ IManagedDependencyGenerator oldDepGen = null; // This interface is deprecated but still supported
+ IManagedDependencyGenerator2 depGen = null; // This is the recommended interface
+ IManagedDependencyInfo depInfo = null;
+ IManagedDependencyCommands depCommands = null;
+ IManagedDependencyPreBuild depPreBuild = null;
+ IPath[] depFiles = null;
+ boolean doDepGen = false;
+ {
+ IManagedDependencyGeneratorType t = tool.getDependencyGeneratorForExtension(inputExtension);
+ if (t != null) {
+ int calcType = t.getCalculatorType();
+ if (calcType <= IManagedDependencyGeneratorType.TYPE_OLD_TYPE_LIMIT) {
+ oldDepGen = (IManagedDependencyGenerator)t;
+ doDepGen = (calcType == IManagedDependencyGeneratorType.TYPE_COMMAND);
+ if (doDepGen) {
+ IPath depFile = Path.fromOSString(relativePath + fileName + DOT + DEP_EXT);
+ getDependencyMakefiles().add(depFile);
+ generatedDepFiles.add(depFile);
+ }
+ } else {
+ depGen = (IManagedDependencyGenerator2)t;
+ doDepGen = (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS);
+ IBuildObject buildContext = (resConfig != null) ? (IBuildObject)resConfig : (IBuildObject)config;
+ depInfo = depGen.getDependencySourceInfo(resource.getProjectRelativePath(), buildContext, tool, getBuildWorkingDir());
+ if (calcType == IManagedDependencyGeneratorType.TYPE_BUILD_COMMANDS) {
+ depCommands = (IManagedDependencyCommands)depInfo;
+ depFiles = depCommands.getDependencyFiles();
+ } else if (calcType == IManagedDependencyGeneratorType.TYPE_PREBUILD_COMMANDS) {
+ depPreBuild = (IManagedDependencyPreBuild)depInfo;
+ depFiles = depPreBuild.getDependencyFiles();
+ }
+ if (depFiles != null) {
+ for (int i=0; iIPath
s for this invocation of the tool with the specified source file
+ /*
+ * The priorities for determining the names of the outputs of a tool are:
+ * 1. If the tool is the build target and primary output, use artifact name & extension -
+ * This case does not apply here...
+ * 2. If an option is specified, use the value of the option
+ * 3. If a nameProvider is specified, call it
+ * 4. If outputNames is specified, use it
+ * 5. Use the name pattern to generate a transformation macro
+ * so that the source names can be transformed into the target names
+ * using the built-in string substitution functions of make
.
+ *
+ * @param tool
+ * @param relativePath build output directory relative path of the current output directory
+ * @param resource
+ * @param ruleOutputs Vector of rule IPaths that are relative to the build directory
+ * @param enumeratedPrimaryOutputs Vector of IPaths of primary outputs
+ * that are relative to the build directory
+ * @param enumeratedSecondaryOutputs Vector of IPaths of secondary outputs
+ * that are relative to the build directory
+ */
+ protected void calculateOutputsForSource(ITool tool, String relativePath, IResource resource,
+ IPath sourceLocation, Vector ruleOutputs, Vector enumeratedPrimaryOutputs, Vector enumeratedSecondaryOutputs) {
+ String inExt = sourceLocation.getFileExtension();
+ String outExt = tool.getOutputExtension(inExt);
+
+ IOutputType[] outTypes = tool.getOutputTypes();
+ if (outTypes != null && outTypes.length > 0) {
+ for (int i=0; imake
.
+ if (multOfType) {
+ // This case is not handled - a nameProvider or outputNames must be specified
+ // TODO - report error
+ } else {
+ String namePattern = type.getNamePattern();
+ IPath namePatternPath = null;
+ if (namePattern == null || namePattern.length() == 0) {
+ namePattern = relativePath + outputPrefix + IManagedBuilderMakefileGenerator.WILDCARD;
+ if (outExt != null && outExt.length() > 0) {
+ namePattern += DOT + outExt;
+ }
+ namePatternPath = Path.fromOSString(namePattern);
+ }
+ else {
+ if (outputPrefix.length() > 0) {
+ namePattern = outputPrefix + namePattern;
+ }
+ namePatternPath = Path.fromOSString(namePattern);
+ // If only a file name is specified, add the relative path of this output directory
+ if (namePatternPath.segmentCount() == 1) {
+ namePatternPath = Path.fromOSString(relativePath + namePatternPath.toString());
+ }
+ }
+
+ if (primaryOutput) {
+ ruleOutputs.add(0, namePatternPath);
+ enumeratedPrimaryOutputs.add(0, resolvePercent(namePatternPath, sourceLocation));
+ } else {
+ ruleOutputs.add(namePatternPath);
+ enumeratedSecondaryOutputs.add(resolvePercent(namePatternPath, sourceLocation));
+ }
+ }
+ }
+ }
+ } else {
+ // For support of pre-CDT 3.0 integrations.
+ // NOTE WELL: This only supports the case of a single "target tool"
+ // that consumes exactly all of the object files, $OBJS, produced
+ // by other tools in the build and produces a single output.
+ // In this case, the output file name is the input file name with
+ // the output extension.
+
+ //if (!ignorePrimary) {
+ String outPrefix = tool.getOutputPrefix();
+ IPath outPath = Path.fromOSString(relativePath + outPrefix + WILDCARD);
+ outPath = outPath.addFileExtension(outExt);
+ ruleOutputs.add(0, outPath);
+ enumeratedPrimaryOutputs.add(0, resolvePercent(outPath, sourceLocation));
+ //}
+ }
+ }
+
+ /* (non-Javadoc)
+ * If the path contains a %, returns the path resolved using the resource name
+ *
+ */
+ protected IPath resolvePercent(IPath outPath, IPath sourceLocation) {
+ // Get the input file name
+ String fileName = sourceLocation.removeFileExtension().lastSegment();
+ // Replace the % with the file name
+ String outName = outPath.toOSString().replaceAll("%", fileName); //$NON-NLS-1$
+ return Path.fromOSString(outName);
+ }
+
+ /* (non-Javadoc)
+ * Returns the dependency IPath
s for this invocation of the tool with the specified source file
+ *
+ * @param depGen the dependency calculator
+ * @param tool tool used to build the source file
+ * @param relativePath build output directory relative path of the current output directory
+ * @param resource source file to scan for dependencies
+ * @return Vector of IPaths that are relative to the build directory
+ */
+ protected IPath[] oldCalculateDependenciesForSource(IManagedDependencyGenerator depGen, ITool tool, String relativePath, IResource resource) {
+ Vector deps = new Vector();
+ int type = depGen.getCalculatorType();
+
+ switch (type) {
+
+ case IManagedDependencyGeneratorType.TYPE_INDEXER:
+ case IManagedDependencyGeneratorType.TYPE_EXTERNAL:
+ IResource[] res = depGen.findDependencies(resource, project);
+ if (res != null) {
+ for (int i=0; itrue
if the tool's inputs have been calculated,
- * else false
.
- *
- * @return boolean
- */
- public boolean areInputsCalculated();
-
- /**
- * Returns the tool's inputs in command line format. This will use
- * variables rather than actual file names as appropriate.
- *
- * @return Vector
- */
- public Vector getCommandInputs();
-
- /**
- * Returns the raw list of tool's input file names.
- *
- * @return Vector
- */
- public Vector getEnumeratedInputs();
-
- /**
- * Returns true
if the tool's outputs have been calculated,
- * else false
.
- *
- * @return boolean
- */
- public boolean areOutputsCalculated();
-
- /**
- * Returns the tool's outputs in command line format. This will use
- * variables rather than actual file names as appropriate.
- *
- * @return Vector
- */
- public Vector getCommandOutputs();
-
- /**
- * Returns the raw list of tool's primary output file names.
- *
- * @return Vector
- */
- public Vector getEnumeratedPrimaryOutputs();
-
- /**
- * Returns the raw list of tool's secondary output file names.
- *
- * @return Vector
- */
- public Vector getEnumeratedSecondaryOutputs();
-
- /**
- * Returns the raw list of tool's output variable names.
- *
- * @return Vector
- */
- public Vector getOutputVariables();
-
- /**
- * Returns true
if the tool's dependencies have been calculated,
- * else false
.
- *
- * @return boolean
- */
- public boolean areDependenciesCalculated();
-
- /**
- * Returns the tool's dependencies in command line format. This will use
- * variables rather than actual file names as appropriate.
- * Dependencies are top build directory relative.
- *
- * @return Vector
- */
- public Vector getCommandDependencies();
-
- /**
- * Returns the tool's additional targets as determined by the
- * dependency calculator.
- * Additional targets are top build directory relative
- *
- * @return Vector
- */
- public Vector getAdditionalTargets();
-
- /**
- * Returns the raw list of tool's input dependencies.
- *
- * @return Vector
- */
- //public Vector getEnumeratedDependencies();
-
- /**
- * Returns true
if this is the target tool
- * else false
.
- *
- * @return boolean
- */
- public boolean isTargetTool();
-}
+/*******************************************************************************
+ * Copyright (c) 2005, 2006 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.makegen.gnu;
+
+import java.util.Vector;
+
+/**
+ * This interface returns information about a Tool's inputs
+ * and outputs while a Gnu makefile is being generated.
+ */
+public interface IManagedBuildGnuToolInfo {
+ public final String DOT = "."; //$NON-NLS-1$
+
+ /**
+ * Returns true
if the tool's inputs have been calculated,
+ * else false
.
+ *
+ * @return boolean
+ */
+ public boolean areInputsCalculated();
+
+ /**
+ * Returns the tool's inputs in command line format. This will use
+ * variables rather than actual file names as appropriate.
+ *
+ * @return Vector
+ */
+ public Vector getCommandInputs();
+
+ /**
+ * Returns the raw list of tool's input file names.
+ *
+ * @return Vector
+ */
+ public Vector getEnumeratedInputs();
+
+ /**
+ * Returns true
if the tool's outputs have been calculated,
+ * else false
.
+ *
+ * @return boolean
+ */
+ public boolean areOutputsCalculated();
+
+ /**
+ * Returns the tool's outputs in command line format. This will use
+ * variables rather than actual file names as appropriate.
+ *
+ * @return Vector
+ */
+ public Vector getCommandOutputs();
+
+ /**
+ * Returns the raw list of tool's primary output file names.
+ *
+ * @return Vector
+ */
+ public Vector getEnumeratedPrimaryOutputs();
+
+ /**
+ * Returns the raw list of tool's secondary output file names.
+ *
+ * @return Vector
+ */
+ public Vector getEnumeratedSecondaryOutputs();
+
+ /**
+ * Returns the raw list of tool's output variable names.
+ *
+ * @return Vector
+ */
+ public Vector getOutputVariables();
+
+ /**
+ * Returns true
if the tool's dependencies have been calculated,
+ * else false
.
+ *
+ * @return boolean
+ */
+ public boolean areDependenciesCalculated();
+
+ /**
+ * Returns the tool's dependencies in command line format. This will use
+ * variables rather than actual file names as appropriate.
+ * Dependencies are top build directory relative.
+ *
+ * @return Vector
+ */
+ public Vector getCommandDependencies();
+
+ /**
+ * Returns the tool's additional targets as determined by the
+ * dependency calculator.
+ * Additional targets are top build directory relative
+ *
+ * @return Vector
+ */
+ public Vector getAdditionalTargets();
+
+ /**
+ * Returns the raw list of tool's input dependencies.
+ *
+ * @return Vector
+ */
+ //public Vector getEnumeratedDependencies();
+
+ /**
+ * Returns true
if this is the target tool
+ * else false
.
+ *
+ * @return boolean
+ */
+ public boolean isTargetTool();
+}
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java
index ca0d780621a..c12413dbe59 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/makegen/gnu/ManagedBuildGnuToolInfo.java
@@ -1,996 +1,996 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 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.makegen.gnu;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.Vector;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.HashSet;
-
-import org.eclipse.cdt.managedbuilder.core.IAdditionalInput;
-import org.eclipse.cdt.managedbuilder.core.IConfiguration;
-import org.eclipse.cdt.managedbuilder.core.IInputType;
-import org.eclipse.cdt.managedbuilder.core.IOutputType;
-import org.eclipse.cdt.managedbuilder.core.ITool;
-import org.eclipse.cdt.managedbuilder.core.IOption;
-import org.eclipse.cdt.managedbuilder.core.IManagedOutputNameProvider;
-import org.eclipse.cdt.managedbuilder.core.BuildException;
-import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
-import org.eclipse.cdt.managedbuilder.macros.BuildMacroException;
-import org.eclipse.cdt.managedbuilder.macros.IBuildMacroProvider;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedBuilderMakefileGenerator;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator2;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGeneratorType;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyGenerator;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyCalculator;
-import org.eclipse.cdt.managedbuilder.makegen.IManagedDependencyInfo;
-import org.eclipse.cdt.managedbuilder.internal.core.ManagedMakeMessages;
-import org.eclipse.cdt.managedbuilder.internal.core.Tool;
-import org.eclipse.cdt.managedbuilder.internal.macros.OptionContextData;
-import org.eclipse.cdt.managedbuilder.makegen.gnu.GnuMakefileGenerator;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * This class represents information about a Tool's inputs
- * and outputs while a Gnu makefile is being generated.
- */
-public class ManagedBuildGnuToolInfo implements IManagedBuildGnuToolInfo {
-
- /*
- * Members
- */
- private IProject project;
- private Tool tool;
- private boolean bIsTargetTool;
- private String targetName;
- private String targetExt;
- private boolean inputsCalculated = false;
- private boolean outputsCalculated = false;
- private boolean outputVariablesCalculated = false;
- private boolean dependenciesCalculated = false;
- private Vector commandInputs = new Vector();
- private Vector enumeratedInputs = new Vector();
- private Vector commandOutputs = new Vector();
- private Vector enumeratedPrimaryOutputs = new Vector();
- private Vector enumeratedSecondaryOutputs = new Vector();
- private Vector outputVariables = new Vector();
- private Vector commandDependencies = new Vector();
- private Vector additionalTargets = new Vector();
- //private Vector enumeratedDependencies = new Vector();
- // Map of macro names (String) to values (List)
-
- /*
- * Constructor
- */
- public ManagedBuildGnuToolInfo(IProject project, ITool tool, boolean targetTool, String name, String ext) {
- this.project = project;
- this.tool = (Tool)tool;
- bIsTargetTool = targetTool;
- if (bIsTargetTool) {
- targetName = name;
- targetExt = ext;
- }
- }
-
- /*
- * IManagedBuildGnuToolInfo Methods
- */
- public boolean areInputsCalculated() {
- return inputsCalculated;
- }
-
- // Command inputs are top build directory relative
- public Vector getCommandInputs() {
- return commandInputs;
- }
-
- // Enumerated inputs are project relative
- public Vector getEnumeratedInputs() {
- return enumeratedInputs;
- }
-
- public boolean areOutputsCalculated() {
- return outputsCalculated;
- }
-
- // Command outputs are top build directory relative
- public Vector getCommandOutputs() {
- return commandOutputs;
- }
-
- public Vector getEnumeratedPrimaryOutputs() {
- return enumeratedPrimaryOutputs;
- }
-
- public Vector getEnumeratedSecondaryOutputs() {
- return enumeratedSecondaryOutputs;
- }
-
- public Vector getOutputVariables() {
- return outputVariables;
- }
-
- public boolean areOutputVariablesCalculated() {
- return outputVariablesCalculated;
- }
-
- public boolean areDependenciesCalculated() {
- return dependenciesCalculated;
- }
-
- // Command dependencies are top build directory relative
- public Vector getCommandDependencies() {
- return commandDependencies;
- }
-
- // Additional targets are top build directory relative
- public Vector getAdditionalTargets() {
- return additionalTargets;
- }
-
- //public Vector getEnumeratedDependencies() {
- // return enumeratedDependencies;
- //}
-
- public boolean isTargetTool() {
- return bIsTargetTool;
- }
-
- /*
- * Other Methods
- */
-
- public boolean calculateInputs(GnuMakefileGenerator makeGen, IConfiguration config, IResource[] projResources, boolean lastChance) {
- // Get the inputs for this tool invocation
- // Note that command inputs that are also dependencies are also added to the command dependencies list
-
- /* The priorities for determining the names of the inputs of a tool are:
- * 1. If an option is specified, use the value of the option.
- * 2. If a build variable is specified, use the files that have been added to the build variable as
- * the output(s) of other build steps.
- * 3. Use the file extensions and the resources in the project
- */
- boolean done = true;
- Vector myCommandInputs = new Vector(); // Inputs for the tool command line
- Vector myCommandDependencies = new Vector(); // Dependencies for the make rule
- Vector myEnumeratedInputs = new Vector(); // Complete list of individual inputs
-
- IInputType[] inTypes = tool.getInputTypes();
- if (inTypes != null && inTypes.length > 0) {
- for (int i=0; imake
.
- *
- * NOTE: If an option is not specified and this is not the primary output type, the outputs
- * from the type are not added to the command line
- */
- public boolean calculateOutputs(GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions, boolean lastChance) {
-
- boolean done = true;
- Vector myCommandOutputs = new Vector();
- Vector myEnumeratedPrimaryOutputs = new Vector();
- Vector myEnumeratedSecondaryOutputs = new Vector();
- HashMap myOutputMacros = new HashMap();
- // The next two fields are used together
- Vector myBuildVars = new Vector();
- Vector myBuildVarsValues = new Vector();
-
- // Get the outputs for this tool invocation
- IOutputType[] outTypes = tool.getOutputTypes();
- if (outTypes != null && outTypes.length > 0) {
- for (int i=0; imake
.
+ *
+ * NOTE: If an option is not specified and this is not the primary output type, the outputs
+ * from the type are not added to the command line
+ */
+ public boolean calculateOutputs(GnuMakefileGenerator makeGen, IConfiguration config, HashSet handledInputExtensions, boolean lastChance) {
+
+ boolean done = true;
+ Vector myCommandOutputs = new Vector();
+ Vector myEnumeratedPrimaryOutputs = new Vector();
+ Vector myEnumeratedSecondaryOutputs = new Vector();
+ HashMap myOutputMacros = new HashMap();
+ // The next two fields are used together
+ Vector myBuildVars = new Vector();
+ Vector myBuildVarsValues = new Vector();
+
+ // Get the outputs for this tool invocation
+ IOutputType[] outTypes = tool.getOutputTypes();
+ if (outTypes != null && outTypes.length > 0) {
+ for (int i=0; i