private void doEnumAllValues(IBuildObject cfgBo) { ITool thisTool = getTool(cfgBo, "enablement.this.child_1.2.3"); ITool otherTool = getTool(cfgBo, "enablement.other"); IBuildObject thisCfg = thisTool.getParent(); IBuildObject otherCfg = otherTool.getParent(); for (int i = 0; i < thisStrings.length; i++) { String strVal = thisStrings[i]; setOption(cfgBo, thisTool, "this.string", strVal); doTestEnablement(cfgBo); } /* for(int i = 0; i < thisEnumIds.length; i++){ String strVal = thisEnumIds[i]; setOption(cfgBo, thisTool, "this.enum", strVal); doTestEnablement(cfgBo); } */ setOption(cfgBo, thisTool, "this.boolean", false); doTestEnablement(cfgBo); setOption(cfgBo, thisTool, "this.boolean", true); doTestEnablement(cfgBo); }
/** This method assumes that file has only one tool. */ private IOption getOptionForFile(IFileInfo rcInfo, String optionId) { ITool[] tools = null; tools = rcInfo.getTools(); assertNotNull(tools); assertEquals(1, tools.length); ITool tool = tools[0]; assertNotNull(tool); IOption option = tool.getOptionBySuperClassId(optionId); return option; }
@Override public CLanguageData[] getCLanguageDatas() { ITool tools[] = getTools /*ToInvoke*/(); List<CLanguageData> list = new ArrayList<CLanguageData>(); for (ITool tool : tools) { CLanguageData datas[] = tool.getCLanguageDatas(); for (int j = 0; j < datas.length; j++) { list.add(datas[j]); } } return list.toArray(new BuildLanguageData[list.size()]); }
/* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IResourceConfiguration#setDirty(boolean) */ @Override public void setDirty(boolean isDirty) { if (isExtensionResourceConfig) return; super.setDirty(isDirty); // Propagate "false" to the children if (!isDirty) { for (ITool toolChild : getToolList()) { toolChild.setDirty(false); } } }
/* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IResourceConfiguration#isDirty() */ @Override public boolean isDirty() { // This shouldn't be called for an extension tool-chain if (isExtensionResourceConfig) return false; // If I need saving, just say yes if (super.isDirty()) return true; // Otherwise see if any tools need saving for (ITool toolChild : getToolList()) { if (toolChild.isDirty()) return true; } return false; }
public void reset() { // We just need to remove all Options ITool[] tools = getTools(); // Send out the event to notify the options that they are about to be removed // ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE); // Remove the configurations for (int i = 0; i < tools.length; i++) { ITool tool = tools[i]; IOption[] opts = tool.getOptions(); for (int j = 0; j < opts.length; j++) { tool.removeOption(opts[j]); } } // setExclude(false); }
@Override void applyToolsInternal(ITool[] resultingTools, ToolListModificationInfo info) { List<ITool> list = getToolList(); Map<String, ITool> map = getToolMap(); list.clear(); map.clear(); list.addAll(Arrays.asList(resultingTools)); for (int i = 0; i < resultingTools.length; i++) { ITool tool = resultingTools[i]; map.put(tool.getId(), tool); } setRebuildState(true); }
public String getLinkerFlags() { for (ITool t : config.getToolChain().getTools()) { if (!isToolLinker(t)) { continue; } try { Set<String> flags = orderPreservingSet( t.getOptionBySuperClassId("gnu.cpp.link.option.other").getStringListValue()); if (!flags.isEmpty()) return String.format("-Xlinker %s", StringUtil.join(flags, " -Xlinker ")); } catch (BuildException e) { } } return EMPTY_STRING; }
/* * (non-Javadoc) * * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors() */ @Override protected void createFieldEditors() { // Load up the preference store super.createFieldEditors(); // Add a string editor to edit the tool command Composite parent = getFieldEditorParent(); FontMetrics fm = AbstractCPropertyTab.getFontMetrics(parent); commandStringField = new StringFieldEditor(fTool.getId(), Messages.BuildToolSettingsPage_tool_command, parent); commandStringField.setEmptyStringAllowed(false); GridData gd = ((GridData) commandStringField.getTextControl(parent).getLayoutData()); gd.grabExcessHorizontalSpace = true; gd.minimumWidth = Dialog.convertWidthInCharsToPixels(fm, 3); addField(commandStringField); // Add a field editor that displays overall build options Composite par = getFieldEditorParent(); allOptionFieldEditor = new MultiLineTextFieldEditor(ToolSettingsPrefStore.ALL_OPTIONS_ID, ALL_OPTIONS, par); allOptionFieldEditor.getTextControl(par).setEditable(false); // gd = ((GridData)allOptionFieldEditor.getTextControl().getLayoutData()); gd.grabExcessHorizontalSpace = true; gd.minimumWidth = Dialog.convertWidthInCharsToPixels(fm, 20); addField(allOptionFieldEditor); addField(createLabelEditor(getFieldEditorParent(), WHITESPACE)); addField( createLabelEditor( getFieldEditorParent(), Messages.BuildToolSettingsPage_tool_advancedSettings)); // Add a string editor to edit the tool command line pattern parent = getFieldEditorParent(); commandLinePatternField = new StringFieldEditor( fTool.getId() + ToolSettingsPrefStore.COMMAND_LINE_SUFFIX, Messages.BuildToolSettingsPage_tool_commandLinePattern, parent); gd = ((GridData) commandLinePatternField.getTextControl(parent).getLayoutData()); gd.grabExcessHorizontalSpace = true; gd.widthHint = Dialog.convertWidthInCharsToPixels(fm, 30); gd.minimumWidth = Dialog.convertWidthInCharsToPixels(fm, 20); addField(commandLinePatternField); }
private Collection<String> getLinkerOptionValues(int linkerOption) { for (ITool tool : config.getToolChain().getTools()) { if (!isToolLinker(tool)) { continue; } for (IOption o : tool.getOptions()) { try { if (o.getValueType() != linkerOption) { continue; } return orderPreservingSet( linkerOption == IOption.LIBRARY_PATHS ? o.getLibraryPaths() : o.getLibraries()); } catch (BuildException e) { } } } return Collections.emptySet(); }
public IToolChain getBaseToolChain() { ITool tools[] = getToolsToInvoke(); ITool baseTool = null; for (int i = 0; i < tools.length; i++) { ITool tool = tools[i]; ITool superTool = tool.getSuperClass(); if (superTool != null) { baseTool = superTool; if (!superTool.isExtensionElement()) { break; } } } IToolChain baseTc = null; if (baseTool != null) { IBuildObject parent = baseTool.getParent(); if (parent instanceof IToolChain) { baseTc = (IToolChain) parent; } else if (parent instanceof ResourceConfiguration) { baseTc = ((ResourceConfiguration) parent).getBaseToolChain(); } } return baseTc; }
public ResourceConfiguration(ResourceConfiguration baseInfo, IPath path, String id, String name) { super(baseInfo, path, id, name); isExtensionResourceConfig = false; setResourceData(new BuildFileData(this)); setManagedBuildRevision(baseInfo.getManagedBuildRevision()); // Copy the remaining attributes toolsToInvoke = baseInfo.toolsToInvoke; rcbsApplicability = new Integer(KIND_DISABLE_RCBS_TOOL); // Clone the resource configuration's tool children if (baseInfo.toolList != null) { for (ITool toolChild : baseInfo.getToolList()) { ITool superTool = toolChild.getSuperClass(); String baseId = superTool != null ? superTool.getId() : toolChild.getId(); String subId = ManagedBuildManager.calculateChildId(baseId, null); String subName = toolChild.getName(); Tool newTool = new Tool(this, superTool, subId, subName, (Tool) toolChild); addTool(newTool); } } setDirty(true); setRebuildState(true); }
@Override public void propertyChange(PropertyChangeEvent event) { // allow superclass to handle as well super.propertyChange(event); if (fInfo instanceof MultiResourceInfo) { MultiResourceInfo mri = (MultiResourceInfo) fInfo; if (event.getSource() == commandStringField) { mri.setToolsCommand(fTool, commandStringField.getStringValue()); updateFields(); } else if (event.getSource() == commandLinePatternField) { mri.setCommandLinePattern(fTool, commandLinePatternField.getStringValue()); } } else { if (event.getSource() == commandStringField) { fTool.setToolCommand(commandStringField.getStringValue()); updateFields(); } else if (event.getSource() == commandLinePatternField) { fTool.setCommandLinePattern(commandLinePatternField.getStringValue()); } } }
private ITool getTool(IBuildObject cfgBo, String id) { IResourceConfiguration rcCfg = null; IConfiguration cfg = null; ITool tool = null; if (cfgBo instanceof IResourceConfiguration) { rcCfg = (IResourceConfiguration) cfgBo; cfg = rcCfg.getParent(); ITool tools[] = rcCfg.getTools(); for (int i = 0; i < tools.length; i++) { for (ITool tmp = tools[i]; tmp != null; tmp = tmp.getSuperClass()) { if (tmp.getId().equals(id)) { tool = tools[i]; break; } } } } else if (cfgBo instanceof IConfiguration) { cfg = (IConfiguration) cfgBo; tool = cfg.getToolsBySuperClassId(id)[0]; } else fail("wrong argument"); return tool; }
private void syncNameField(ICConfigurationDescription cfgd) { IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd); String id = cfgd.getId(); if (icfg != null) { IToolChain toolchain = icfg.getToolChain(); ITool[] tools = toolchain.getTools(); for (int j = 0; j < tools.length; ++j) { ITool tool = tools[j]; if (tool.getName().equals("configure")) { // $NON-NLS-1$ IOption option = tool.getOptionBySuperClassId( "org.eclipse.linuxtools.cdt.autotools.core.option.configure.name"); // $NON-NLS-1$ IHoldsOptions h = tool; try { IOption optionToSet = h.getOptionToSet(option, false); optionToSet.setValue(id); } catch (BuildException e) { } } } } }
public ResourceConfiguration( FolderInfo folderInfo, ITool baseTool, String id, String resourceName, IPath path) { super(folderInfo, path, id, resourceName); // setParentFolder(folderInfo); // setParentFolderId(folderInfo.getId()); isExtensionResourceConfig = folderInfo.isExtensionElement(); if (!isExtensionResourceConfig) setResourceData(new BuildFileData(this)); if (folderInfo.getParent() != null) setManagedBuildRevision(folderInfo.getParent().getManagedBuildRevision()); setDirty(false); toolsToInvoke = EMPTY_STRING; rcbsApplicability = new Integer(KIND_DISABLE_RCBS_TOOL); // Get file extension. String extString = path.getFileExtension(); if (baseTool != null) { if (baseTool.getParentResourceInfo() != folderInfo) baseTool = null; } // Add the resource specific tools to this resource. ITool tools[] = folderInfo.getFilteredTools(); String subId = new String(); for (int i = 0; i < tools.length; i++) { if (tools[i].buildsFileType(extString)) { baseTool = tools[i]; break; } } if (baseTool != null) { subId = ManagedBuildManager.calculateChildId(baseTool.getId(), null); createTool(baseTool, subId, baseTool.getName(), false); setRebuildState(true); } }
/** * This method parses the string that is entered in the all build option field editor and stores * the options to the corresponding option fields. */ public void parseAllOptions() { // Get the all build options string from all options field String alloptions = getToolSettingsPrefStore().getString(ToolSettingsPrefStore.ALL_OPTIONS_ID); // list that holds the options for the option type other than // boolean,string and enumerated List<String> optionsList = new ArrayList<String>(); // additional options buffer StringBuffer addnOptions = new StringBuffer(); // split all build options string Vector<String> optionsArr = getOptionVector(alloptions); for (String optionValue : optionsArr) { boolean optionValueExist = false; // get the options for this tool IOption[] options = fTool.getOptions(); for (IOption opt : options) { // String name = opt.getId(); // check whether the option value is "STRING" type for (String s : stringOptionsMap.values()) { if (s.indexOf(optionValue) != -1) optionValueExist = true; } // check whether the option value is "OBJECTS" type for (String s : userObjsMap.values()) { if (s.indexOf(optionValue) != -1) optionValueExist = true; } // if the value does not exist in string option or user objects // option if (!optionValueExist) { try { // check whether the option value is already exist // and also change the preference store based on // the option value switch (opt.getValueType()) { case IOption.BOOLEAN: String boolCommand; boolCommand = opt.getCommand(); if (boolCommand != null && boolCommand.equals(optionValue)) { setOption(opt, true); optionValueExist = true; } boolCommand = opt.getCommandFalse(); if (boolCommand != null && boolCommand.equals(optionValue)) { setOption(opt, false); optionValueExist = true; } break; case IOption.ENUMERATED: String enumeration = ""; // $NON-NLS-1$ String[] enumValues = opt.getApplicableValues(); for (int i = 0; i < enumValues.length; i++) { if (opt.getEnumCommand(enumValues[i]).equals(optionValue)) { enumeration = enumValues[i]; optionValueExist = true; } } if (!enumeration.equals("")) // $NON-NLS-1$ setOption(opt, enumeration); break; case IOption.STRING_LIST: case IOption.INCLUDE_PATH: case IOption.PREPROCESSOR_SYMBOLS: case IOption.LIBRARIES: case IOption.INCLUDE_FILES: case IOption.LIBRARY_PATHS: case IOption.LIBRARY_FILES: case IOption.MACRO_FILES: case IOption.UNDEF_INCLUDE_PATH: case IOption.UNDEF_PREPROCESSOR_SYMBOLS: case IOption.UNDEF_INCLUDE_FILES: case IOption.UNDEF_LIBRARY_PATHS: case IOption.UNDEF_LIBRARY_FILES: case IOption.UNDEF_MACRO_FILES: if (opt.getCommand() != null && optionValue.startsWith(opt.getCommand())) { optionsList.add(optionValue); optionValueExist = true; } break; default: break; } } catch (BuildException e) { } } } // If the parsed string does not match with any previous option // values then consider this option as a additional build option if (!optionValueExist) { addnOptions.append(optionValue + ITool.WHITE_SPACE); } } // check whether some of the "STRING" option value or "OBJECTS" type // option value removed // by the user from all build option field Set<String> set = stringOptionsMap.keySet(); for (int i = 0; i < set.size(); i++) { Iterator<String> iterator = set.iterator(); while (iterator.hasNext()) { Object key = iterator.next(); String val = stringOptionsMap.get(key); if (alloptions.indexOf(val) == -1) { StringBuffer buf = new StringBuffer(); String[] vals = val.split(WHITESPACE); for (int t = 0; t < vals.length; t++) { if (alloptions.indexOf(vals[t]) != -1) buf.append(vals[t] + ITool.WHITE_SPACE); } setOption(((IOption) key), buf.toString().trim()); } } } // "OBJECTS" type Set<IOption> objSet = userObjsMap.keySet(); for (int s = 0; s < objSet.size(); s++) { for (IOption op : objSet) { String val = userObjsMap.get(op); ArrayList<String> list = new ArrayList<String>(); for (String v : parseString(val)) { if (alloptions.indexOf(v) != -1) list.add(v); } String listArr[] = new String[list.size()]; list.toArray(listArr); setOption(op, listArr); } } // Now update the preference store with parsed options // Get the options for this tool IOption[] options = fTool.getOptions(); for (int k = 0; k < options.length; ++k) { IOption opt = options[k]; // String name = opt.getId(); // String listStr = ""; //$NON-NLS-1$ // String[] listVal = null; try { switch (opt.getValueType()) { case IOption.BOOLEAN: ArrayList<String> optsList = new ArrayList<String>(optionsArr); if (opt.getCommand() != null && opt.getCommand().length() > 0 && !optsList.contains(opt.getCommand())) setOption(opt, false); if (opt.getCommandFalse() != null && opt.getCommandFalse().length() > 0 && !optsList.contains(opt.getCommandFalse())) setOption(opt, true); break; case IOption.STRING: // TODO create a lst of valid default string options for the tool if (getDefaultOptionNames().contains(opt.getName())) { String newOptions = opt.getStringValue(); if (addnOptions.length() > 0) { newOptions = newOptions + ITool.WHITE_SPACE + addnOptions.toString().trim(); } setOption(opt, newOptions); } break; case IOption.STRING_LIST: case IOption.INCLUDE_PATH: case IOption.PREPROCESSOR_SYMBOLS: case IOption.LIBRARIES: ArrayList<String> newList = new ArrayList<String>(); for (String s : optionsList) { if (opt.getCommand() != null && s.startsWith(opt.getCommand())) { newList.add(s.substring(opt.getCommand().length())); } } String[] strlist = new String[newList.size()]; newList.toArray(strlist); newList.clear(); setOption(opt, strlist); break; default: break; } } catch (BuildException e) { } } }
public String getCompilerName() { for (ITool tool : config.getToolChain().getTools()) { if (isToolCompiler(tool)) return tool.getToolCommand(); } return EMPTY_STRING; }
private String getCompilerFlags(String compiler) throws BuildException { for (ITool tool : config.getToolChain().getTools()) { if (tool.getId().startsWith(compiler)) return tool.getToolCommandFlagsString(null, null); } return EMPTY_STRING; }
/* (non-Javadoc) * @see org.eclipse.cdt.managedbuilder.core.IResourceConfiguration#setToolCommand(org.eclipse.cdt.managedbuilder.core.ITool, java.lang.String) */ @Override public void setToolCommand(ITool tool, String command) { // TODO: Do we need to verify that the tool is part of the configuration? tool.setToolCommand(command); }
private boolean isToolCompiler(ITool tool) { String nature = hasCCNature ? CPP_COMPILER_ID : C_COMPILER_ID; return tool.getSuperClass().getId().startsWith(nature); }
private boolean isToolLinker(ITool tool) { String linkerId = hasCCNature ? CPP_LINKER_ID : C_LINKER_ID; return tool.getSuperClass().getId().startsWith(linkerId); }
private void doTestEnablement(IBuildObject cfg) { ITool tool = getTool(cfg, "enablement.this.child_1.2.3"); ITool otherTool = getTool(cfg, "enablement.other"); ITool tool2 = getTool(cfg, "enablement.this.child.2_1.2.3"); // IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); IOption thisBoolean = tool.getOptionBySuperClassId("this.boolean"); IOption thisString = tool.getOptionBySuperClassId("this.string"); IOption thisEnum = tool.getOptionBySuperClassId("this.enum"); IOption otherString = otherTool.getOptionBySuperClassId("other.string"); IOption otherBoolean = otherTool.getOptionBySuperClassId("other.boolean"); try { IOption option = tool.getOptionBySuperClassId("enablement.command.c1"); assertEquals(option.getCommand(), "c1"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.command.c2"); assertEquals(option.getCommand(), "c2"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.commandFalse.c1"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "c1"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.commandFalse.c2"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "c2"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.command.c1.commandFalse.cF1"); assertEquals(option.getCommand(), "c1"); assertEquals(option.getCommandFalse(), "cF1"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.command.cmd.commandFalse.cmdF"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.command.c1.commandFalse.cmdF"); assertEquals(option.getCommand(), "c1"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.command.cmd.commandFalse.cF1"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cF1"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.ui.en"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cF1"); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.ui.vis"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cF1"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.cmd.us"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.cmdUs.or.uiVis"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cF1"); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.uiEn.or.uiVis"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cF1"); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.all"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cF1"); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.all.ac.vh"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cF1"); setEnablement(false, false, false); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); setEnablement(false, true, false); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); setEnablement(false, false, true); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); setEnablement(true, false, false); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); setEnablement(false, false, false); option = tool.getOptionBySuperClassId("enablement.all.cF1.ac.vh"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cF1"); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); setEnablement(true, false, true); option = tool.getOptionBySuperClassId("enablement.all.cF.cmdF"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.all.cF.cF1"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cF1"); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("this.boolean"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkOpt.all.Q.this.boolean.True"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertEquals( thisBoolean.getBooleanValue() == true, option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertEquals( thisBoolean.getBooleanValue() == true, option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertEquals( thisBoolean.getBooleanValue() == true, option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkOpt.all.Q.this.boolean.False"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertEquals( thisBoolean.getBooleanValue() == false, option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertEquals( thisBoolean.getBooleanValue() == false, option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertEquals( thisBoolean.getBooleanValue() == false, option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkOpt.all.Q.this.string.Q.empty"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertEquals( thisString.getStringValue().equals(""), option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertEquals( thisString.getStringValue().equals(""), option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertEquals( thisString.getStringValue().equals(""), option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkOpt.all.Q.this.string.Q.test a b c"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertEquals( thisString.getStringValue().equals("test a b c"), option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertEquals( thisString.getStringValue().equals("test a b c"), option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertEquals( thisString.getStringValue().equals("test a b c"), option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId( "enablement.checkOpt.all.Q.this.enum.Q.testgnu.enablement.c.optimization.level.optimize"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); String id = thisEnum.getEnumeratedId(thisEnum.getStringValue()); if (id == null) id = ""; assertEquals( id.equals("testgnu.enablement.c.optimization.level.optimize"), option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertEquals( id.equals("testgnu.enablement.c.optimization.level.optimize"), option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertEquals( id.equals("testgnu.enablement.c.optimization.level.optimize"), option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkOpt.all.Q.this.Q.true"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertEquals( option.getBooleanValue() == true, option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertEquals( option.getBooleanValue() == true, option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertEquals( option.getBooleanValue() == true, option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId( "enablement.checkOpt.all.Q.this.string.Q.start ${ParentVersion} stop"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertEquals( thisString.getStringValue().equals("start 1.2.3 stop"), option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertEquals( thisString.getStringValue().equals("start 1.2.3 stop"), option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertEquals( thisString.getStringValue().equals("start 1.2.3 stop"), option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkOpt.all.Q.this.string.Q.other.string"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertEquals( thisString.getStringValue().equals(otherString.getStringValue()), option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertEquals( thisString.getStringValue().equals(otherString.getStringValue()), option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertEquals( thisString.getStringValue().equals(otherString.getStringValue()), option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkOpt.all.Q.this.string.Q.other.string"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertEquals( thisString.getStringValue().equals(otherString.getStringValue()), option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertEquals( thisString.getStringValue().equals(otherString.getStringValue()), option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertEquals( thisString.getStringValue().equals(otherString.getStringValue()), option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkString"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkString.2"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkString.3"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkFalse.false"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkNot.false"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkOr.true"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkAnd.false"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertFalse(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool.getOptionBySuperClassId("enablement.checkHolder.true.1.false.2"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertTrue(option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionVisible(cfg, tool, option)); assertTrue(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool, option)); option = tool2.getOptionBySuperClassId("enablement.checkHolder.true.1.false.2"); assertEquals(option.getCommand(), "cmd"); assertEquals(option.getCommandFalse(), "cmdF"); assertFalse( option.getApplicabilityCalculator().isOptionUsedInCommandLine(cfg, tool2, option)); assertFalse(option.getApplicabilityCalculator().isOptionVisible(cfg, tool2, option)); assertFalse(option.getApplicabilityCalculator().isOptionEnabled(cfg, tool2, option)); } catch (BuildException e) { fail(e.getLocalizedMessage()); } }
/** * Create a new resource configuration based on one already defined. * * @param cfg The <code>IConfiguration</code> the resource configuration will be added to. * @param cloneConfig The <code>ResourceConfiguration</code> to copy the settings from. * @param id A unique ID for the new resource configuration. */ public ResourceConfiguration( IConfiguration cfg, ResourceConfiguration cloneConfig, String id, Map<IPath, Map<String, String>> superClassIdMap, boolean cloneChildren) { super(cfg, cloneConfig, id); isExtensionResourceConfig = cfg.isExtensionElement(); if (!cloneConfig.isExtensionResourceConfig) cloneChildren = true; if (!isExtensionResourceConfig) setResourceData(new BuildFileData(this)); setManagedBuildRevision(cloneConfig.getManagedBuildRevision()); // Copy the remaining attributes if (cloneConfig.toolsToInvoke != null) { toolsToInvoke = new String(cloneConfig.toolsToInvoke); } if (cloneConfig.rcbsApplicability != null) { rcbsApplicability = new Integer(cloneConfig.rcbsApplicability.intValue()); } boolean copyIds = cloneChildren && id.equals(cloneConfig.id); // Clone the resource configuration's tool children if (cloneConfig.toolList != null) { for (ITool toolChild : cloneConfig.getToolList()) { String subId = null; String subName; Map<String, String> curIdMap = superClassIdMap.get(cloneConfig.getPath()); ITool extTool = ManagedBuildManager.getExtensionTool(toolChild); if (curIdMap != null) { if (extTool != null) { subId = curIdMap.get(extTool.getId()); } } subName = toolChild.getName(); if (subId == null) { if (extTool != null) { subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(extTool.getId(), null); // subName = toolChild.getSuperClass().getName(); } else { subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(toolChild.getId(), null); // subName = toolChild.getName(); } } // The superclass for the cloned tool is not the same as the one from the tool being // cloned. // The superclasses reside in different configurations. ITool toolSuperClass = null; String superId = null; // Search for the tool in this configuration that has the same grand-superClass as the // tool being cloned ITool otherSuperTool = toolChild.getSuperClass(); if (otherSuperTool != null) { if (otherSuperTool.isExtensionElement()) { toolSuperClass = otherSuperTool; } else { IResourceInfo otherRcInfo = otherSuperTool.getParentResourceInfo(); IResourceInfo thisRcInfo = cfg.getResourceInfo(otherRcInfo.getPath(), true); ITool otherExtTool = ManagedBuildManager.getExtensionTool(otherSuperTool); if (otherExtTool != null) { if (thisRcInfo != null) { ITool tools[] = thisRcInfo.getTools(); for (int i = 0; i < tools.length; i++) { ITool thisExtTool = ManagedBuildManager.getExtensionTool(tools[i]); if (otherExtTool.equals(thisExtTool)) { toolSuperClass = tools[i]; superId = toolSuperClass.getId(); break; } } } else { superId = copyIds ? otherSuperTool.getId() : ManagedBuildManager.calculateChildId(otherExtTool.getId(), null); Map<String, String> idMap = superClassIdMap.get(otherRcInfo.getPath()); if (idMap == null) { idMap = new HashMap<String, String>(); superClassIdMap.put(otherRcInfo.getPath(), idMap); } idMap.put(otherExtTool.getId(), superId); } } } } // IToolChain tCh = cloneConfig.getBaseToolChain(); // if(tCh != null){ // if(!tCh.isExtensionElement()){ // IFolderInfo fo = tCh.getParentFolderInfo(); // IPath path = fo.getPath(); // IResourceInfo baseFo = cfg.getResourceInfo(path, false); // if(baseFo instanceof IFileInfo) // baseFo = cfg.getResourceInfo(path.removeLastSegments(1), false); // tCh = ((IFolderInfo)baseFo).getToolChain(); // // } // ITool[] tools = tCh.getTools(); // for (int i=0; i<tools.length; i++) { // ITool configTool = tools[i]; // if (toolChild.getSuperClass() != null // && configTool.getSuperClass() == toolChild.getSuperClass().getSuperClass()) // { // toolSuperClass = configTool; // break; // } // } // } else { // //TODO: // } Tool newTool = null; if (toolSuperClass != null) newTool = new Tool(this, toolSuperClass, subId, subName, (Tool) toolChild); else newTool = new Tool(this, superId, subId, subName, (Tool) toolChild); addTool(newTool); } } if (copyIds) { isDirty = cloneConfig.isDirty; needsRebuild = cloneConfig.needsRebuild; } else { setDirty(true); setRebuildState(true); } }
public boolean isOutputTypeEnabled(ITool tool, IOutputType type) { return evaluate( tool.getParentResourceInfo(), tool, null, OptionEnablementExpression.FLAG_CMD_USAGE); }