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); }
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; }
/** * 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); } }
private boolean isToolLinker(ITool tool) { String linkerId = hasCCNature ? CPP_LINKER_ID : C_LINKER_ID; return tool.getSuperClass().getId().startsWith(linkerId); }
private boolean isToolCompiler(ITool tool) { String nature = hasCCNature ? CPP_COMPILER_ID : C_COMPILER_ID; return tool.getSuperClass().getId().startsWith(nature); }