示例#1
0
  @Override
  protected boolean canRemove(ITool realTool) {
    IToolChain extTc = ManagedBuildManager.getExtensionToolChain(fSelectedToolChain);
    ITool[] tools = extTc.getTools();
    for (int i = 0; i < tools.length; i++) {
      if (realTool == ManagedBuildManager.getRealTool(tools[i])) return false;
    }

    return true;
  }
示例#2
0
  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);
  }
示例#3
0
  /**
   * This constructor is called to create a projectType defined by an extension point in a plugin
   * manifest file.
   */
  public ProjectType(IManagedConfigElement element, String managedBuildRevision) {
    // setup for resolving
    resolved = false;

    setManagedBuildRevision(managedBuildRevision);

    loadFromManifest(element);

    // Hook me up to the Managed Build Manager
    ManagedBuildManager.addExtensionProjectType(this);

    // Load the configuration children
    IManagedConfigElement[] configs =
        element.getChildren(IConfiguration.CONFIGURATION_ELEMENT_NAME);

    String[] usedConfigNames = new String[configs.length];
    IConfigurationNameProvider configurationNameProvder = getConfigurationNameProvider();

    if (configurationNameProvder != null) {
      // Tool Integrator provided 'ConfigurationNameProvider' class
      // to get configuration names dynamically based architecture, os, toolchain version etc.
      for (int n = 0; n < configs.length; ++n) {
        Configuration config = new Configuration(this, configs[n], managedBuildRevision);
        String newConfigName =
            configurationNameProvder.getNewConfigurationName(config, usedConfigNames);
        config.setName(newConfigName);
        usedConfigNames[n] = newConfigName;
      }
    } else {
      for (int n = 0; n < configs.length; ++n) {
        Configuration config = new Configuration(this, configs[n], managedBuildRevision);
      }
    }
  }
示例#4
0
  private IToolChain getDefaultToolChain() {
    IResourceInfo rcInfo = getResourceInfo();
    IToolChain defaultTc = null;
    if (rcInfo.getPath().segmentCount() == 0) {
      //			1.Per-project : change to the "default" tool-chain defined in the extension
      //			super-class of the project configuration. NOTE: the makefile project case might
      //			need a special handling in this case.

      IConfiguration cfg = rcInfo.getParent();
      IConfiguration extCfg = cfg.getParent();
      defaultTc = extCfg.getToolChain();
      if (defaultTc == null) {
        if (cfg.getToolChain() != null) {
          defaultTc = cfg.getToolChain().getSuperClass();
        }
      }
    } else {
      //			2.per-folder : change to the same tool-chain as the one used by the parent
      //			folder.
      IFolderInfo parentFo = ((ResourceInfo) rcInfo).getParentFolderInfo();
      IToolChain tc = parentFo.getToolChain();
      defaultTc = ManagedBuildManager.getExtensionToolChain(tc);
    }

    if (defaultTc != null && defaultTc.getId().equals(ConfigurationDataProvider.PREF_TC_ID))
      defaultTc = null;

    return defaultTc;
  }
示例#5
0
  /** Resolve the element IDs to interface references */
  public void resolveReferences() {
    if (!resolved) {
      resolved = true;
      // Resolve superClass
      if (superClassId != null && superClassId.length() > 0) {
        superClass = ManagedBuildManager.getExtensionProjectType(superClassId);
        if (superClass == null) {
          // Report error
          ManagedBuildManager.outputResolveError(
              "superClass", //$NON-NLS-1$
              superClassId,
              "projectType", //$NON-NLS-1$
              getId());
        }
      }

      // Add configurations from our superClass that are not overridden here
      if (superClass != null) {
        ((ProjectType) superClass).resolveReferences();
        IConfiguration[] superConfigs = superClass.getConfigurations();
        for (int i = 0; i < superConfigs.length; i++) {
          String superId = superConfigs[i].getId();

          check:
          {
            IConfiguration[] currentConfigs = getConfigurations();
            for (int j = 0; j < currentConfigs.length; j++) {
              IConfiguration config = currentConfigs[j];
              while (config.getParent() != null) {
                if (config.getParent().getId().equals(superId)) break check;
                config = config.getParent();
              }
            }
            addConfiguration((Configuration) superConfigs[i]);
          } // end check
        }
      }

      // Call resolve references on any children
      List<Configuration> configurationList = getConfigurationList();
      for (Configuration current : configurationList) {
        current.resolveReferences();
      }
    }
  }
  /** @see IncrementalProjectBuilder#build */
  @Override
  protected IProject[] build(
      int kind, @SuppressWarnings("rawtypes") Map args, IProgressMonitor monitor)
      throws CoreException {
    if (DEBUG_EVENTS) {
      @SuppressWarnings("unchecked")
      Map<String, String> argsMap = args;
      printEvent(kind, argsMap);
    }

    // If auto discovery is disabled, do nothing
    //		boolean autodiscoveryEnabled;
    //		boolean autodiscoveryEnabled2;
    //		IScannerConfigBuilderInfo2 buildInfo2 = null;
    //		IConfiguration cfg = ScannerConfigUtil.getActiveConfiguration(getProject());
    IManagedBuildInfo bInfo = ManagedBuildManager.getBuildInfo(getProject());
    if (bInfo != null) {
      IConfiguration cfgs[] = bInfo.getManagedProject().getConfigurations();
      if (cfgs.length != 0) {
        if (!needAllConfigBuild()) {
          ICProjectDescription des =
              CoreModel.getDefault().getProjectDescription(getProject(), false);
          IConfiguration cfg = null;
          if (des != null) {
            ICConfigurationDescription settingCfgDes = des.getDefaultSettingConfiguration();
            if (settingCfgDes != null) {
              for (int i = 0; i < cfgs.length; i++) {
                if (settingCfgDes.getId().equals(cfgs[i].getId())) {
                  cfg = cfgs[i];
                  break;
                }
              }
            }
          }
          if (cfg != null) {
            cfgs = new IConfiguration[] {cfg};
          } else {
            cfgs = new IConfiguration[0];
          }
        }
        int numWork = cfgs.length;
        if (numWork > 0) {
          monitor.beginTask(
              MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"),
              numWork); //$NON-NLS-1$
          for (int i = 0; i < cfgs.length; i++) {
            build(cfgs[i], 0, new SubProgressMonitor(monitor, 1));
          }
        }
      }

      CfgDiscoveredPathManager.getInstance().updateCoreSettings(getProject(), cfgs);
    }

    return getProject().getReferencedProjects();
  }
  private static Properties calcEnvironment(IConfiguration cfg) {
    Properties envProps = new Properties();
    ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
    IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
    IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
    for (int i = 0; i < vars.length; i++) {
      envProps.setProperty(vars[i].getName(), vars[i].getValue());
    }

    return envProps;
  }
示例#8
0
  private boolean 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 project type

            if (fromId.equals(getId()) && toId.equals(convertToId)) {
              // If it matches
              String mbsVersion = element.getAttribute("mbsVersion"); // $NON-NLS-1$
              Version currentMbsVersion = ManagedBuildManager.getBuildInfoVersion();

              // set the converter element based on the MbsVersion
              if (currentMbsVersion.compareTo(new Version(mbsVersion)) > 0) {
                previousMbsVersionConversionElement = element;
              } else {
                currentMbsVersionConversionElement = element;
              }
              return true;
            }
          }
        }
      }
    }

    // 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

    return false;
  }
示例#9
0
  /**
   * @param parentShell the parent shell
   * @param project the project to convert
   * @param title the title of the dialog
   */
  protected ConvertTargetDialog(Shell parentShell, IProject project, String title) {
    super(parentShell);
    this.title = title;
    setProject(project);

    IProjectType projectType = getProjectType();
    if (projectType != null) {
      conversionElements = ManagedBuildManager.getConversionElements(projectType);
    }
    for (IBuildObject tc : getProjectToolchains()) {
      Map<String, IConfigurationElement> converters = ManagedBuildManager.getConversionElements(tc);
      if (converters != null) {
        if (conversionElements == null) {
          conversionElements = converters;
        } else {
          conversionElements.putAll(converters);
        }
      }
    }

    setShellStyle(getShellStyle() | SWT.RESIZE);
  }
示例#10
0
  private IProjectType getProjectType() {
    IProjectType projectType = null;

    // Get the projectType from project.
    IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
    if (info != null) {
      IManagedProject managedProject = info.getManagedProject();
      if (managedProject != null) {
        projectType = managedProject.getProjectType();
      }
    }
    return projectType;
  }
示例#11
0
  public void setToolChain(IToolChain tc, boolean force) {
    if (tc == fSelectedToolChain && !force) return;

    applyToolChain((ToolChain) tc);

    fSelectedToolChain = (ToolChain) tc;
    IToolChain newReal = ManagedBuildManager.getRealToolChain(tc);
    if (newReal == fRealToolChain && !force) return;

    fRealToolChain = (ToolChain) newReal;

    //		setProjectTools(tc.getTools());
    //		applyToolChain(fSelectedToolChain);
    clearToolInfo(tc.getTools());
    fCurrentCompatibilityInfo = null;
  }
示例#12
0
  private List<IBuildObject> getProjectToolchains() {
    List<IBuildObject> projectToolchains = new ArrayList<>();

    // Get the projectType from project.
    IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
    if (info != null) {
      IConfiguration[] configs = info.getManagedProject().getConfigurations();
      for (IConfiguration config : configs) {
        IToolChain toolchain = config.getToolChain();
        if (toolchain != null) {
          projectToolchains.add(toolchain);
        }
      }
    }
    return projectToolchains;
  }
示例#13
0
  /**
   * This constructor is called to create a project type whose attributes and children will be added
   * by separate calls.
   *
   * @param superClass The superClass, if any
   * @param Id The id for the new project type
   * @param managedBuildRevision The name for the new project type
   */
  public ProjectType(ProjectType superClass, String Id, String name, String managedBuildRevision) {
    // setup for resolving
    resolved = false;

    this.superClass = superClass;
    if (this.superClass != null) {
      superClassId = this.superClass.getId();
    }
    setId(Id);
    setName(name);

    setManagedBuildRevision(managedBuildRevision);
    setVersion(getVersionFromId());

    // Hook me up to the Managed Build Manager
    ManagedBuildManager.addExtensionProjectType(this);
  }
示例#14
0
  public void testEnablement() {
    resetValueHandler();

    IProject project =
        ManagedBuildTestHelper.createProject("en", "cdt.managedbuild.target.enablement.exe");
    IFile aFile = ManagedBuildTestHelper.createFile(project, "a.c");
    IFile bFile = ManagedBuildTestHelper.createFile(project, "b.c");

    IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
    IConfiguration cfg = info.getManagedProject().getConfigurations()[0];
    assertFalse(fHandleValueCalled);

    doTestEnablement(cfg);

    doEnumAllValues(cfg);

    ManagedBuildTestHelper.removeProject("en");
  }
示例#15
0
  /* (non-Javadoc)
   * Loads the resource configuration information from the ManagedConfigElement
   * specified in the argument.
   *
   * @param element Contains the resource configuration information
   */
  protected void loadFromManifest(IManagedConfigElement element) {
    ManagedBuildManager.putConfigElement(this, element);

    // toolsToInvoke
    toolsToInvoke =
        SafeStringInterner.safeIntern(element.getAttribute(IResourceConfiguration.TOOLS_TO_INVOKE));

    // rcbsApplicability
    String rcbsApplicabilityStr = element.getAttribute(IResourceConfiguration.RCBS_APPLICABILITY);
    if (rcbsApplicabilityStr == null || rcbsApplicabilityStr.equals(DISABLE_RCBS_TOOL)) {
      rcbsApplicability = new Integer(KIND_DISABLE_RCBS_TOOL);
    } else if (rcbsApplicabilityStr.equals(APPLY_RCBS_TOOL_BEFORE)) {
      rcbsApplicability = new Integer(KIND_APPLY_RCBS_TOOL_BEFORE);
    } else if (rcbsApplicabilityStr.equals(APPLY_RCBS_TOOL_AFTER)) {
      rcbsApplicability = new Integer(KIND_APPLY_RCBS_TOOL_AFTER);
    } else if (rcbsApplicabilityStr.equals(APPLY_RCBS_TOOL_AS_OVERRIDE)) {
      rcbsApplicability = new Integer(KIND_APPLY_RCBS_TOOL_AS_OVERRIDE);
    }
  }
  /** @since 1.2 */
  public synchronized Map<String, IAutotoolsOption> getAutotoolsCfgOptions(
      IProject project, String cfgId) throws CoreException {

    // Verify project is valid Autotools project
    if (project == null || !project.hasNature(AutotoolsNewProjectNature.AUTOTOOLS_NATURE_ID)) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              AutotoolsPlugin.PLUGIN_ID,
              ConfigureMessages.getString(INVALID_AUTOTOOLS_PROJECT)));
    }

    // Verify configuration id is valid
    ICConfigurationDescription cfgd =
        CoreModel.getDefault().getProjectDescription(project).getConfigurationById(cfgId);
    IConfiguration icfg = ManagedBuildManager.getConfigurationForDescription(cfgd);
    if (icfg == null) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              AutotoolsPlugin.PLUGIN_ID,
              ConfigureMessages.getString(INVALID_AUTOTOOLS_CONFIG_ID)));
    }

    IAConfiguration cfg = getConfiguration(project, cfgId);
    HashMap<String, IAutotoolsOption> options = new HashMap<>();

    // Get set of configuration options and convert to set of IAutotoolOptions
    Map<String, IConfigureOption> cfgOptions = cfg.getOptions();
    IAConfiguration dummyCfg = createDefaultConfiguration(createDummyId());
    for (Iterator<Entry<String, IConfigureOption>> i = cfgOptions.entrySet().iterator();
        i.hasNext(); ) {
      Map.Entry<String, IConfigureOption> entry = i.next();
      String name = entry.getKey();
      IAutotoolsOption configOption =
          new AutotoolsOption(entry.getValue().copy((AutotoolsConfiguration) dummyCfg));
      options.put(name, configOption);
    }

    return options;
  }
 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) {
         }
       }
     }
   }
 }
示例#18
0
  @Override
  protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
      handleConverterSelection();
      IConvertManagedBuildObject convertBuildObject = null;
      try {
        convertBuildObject =
            (IConvertManagedBuildObject)
                getSelectedConversionElement().createExecutableExtension("class"); // $NON-NLS-1$
      } catch (CoreException e) {
        ManagedBuilderUIPlugin.log(e);
      }
      if (convertBuildObject != null) {
        String fromId = getSelectedConversionElement().getAttribute("fromId"); // $NON-NLS-1$
        String toId = getSelectedConversionElement().getAttribute("toId"); // $NON-NLS-1$

        IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(getProject());
        if (info != null) {
          IManagedProject managedProject = info.getManagedProject();
          if (managedProject != null) {
            if (convertBuildObject.convert(managedProject, fromId, toId, true) == null) {
              setConversionSuccessful(false);
            } else {
              setConversionSuccessful(true);
            }
          } else {
            setConversionSuccessful(false);
          }
        } else {
          setConversionSuccessful(false);
        }
      } else {
        setConversionSuccessful(false);
      }
    }
    super.buttonPressed(buttonId);
  }
示例#19
0
  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);
    }
  }
示例#20
0
  /**
   * This constructor is called to create a resource configuration defined by an extension point in
   * a plugin manifest file, or returned by a dynamic element provider
   *
   * @param parent The IConfiguration parent of this resource configuration
   * @param element The resource configuration definition from the manifest file or a dynamic
   *     element provider
   */
  public ResourceConfiguration(
      IConfiguration parent, IManagedConfigElement element, String managedBuildRevision) {
    super(parent, element, true);
    isExtensionResourceConfig = true;

    // setup for resolving
    resolved = false;

    setManagedBuildRevision(managedBuildRevision);
    loadFromManifest(element);

    // Hook me up to the Managed Build Manager
    ManagedBuildManager.addExtensionResourceConfiguration(this);

    // Load the tool children
    IManagedConfigElement[] tools = element.getChildren(ITool.TOOL_ELEMENT_NAME);
    for (int n = 0; n < tools.length; ++n) {
      Tool toolChild = new Tool(this, tools[n], getManagedBuildRevision());
      getToolList().add(toolChild);
      getToolMap().put(toolChild.getId(), toolChild);
    }

    setDirty(false);
  }
示例#21
0
  public void testEnablement_Bug250686() throws Exception {
    final String testName = getName();
    IProject project = ManagedBuildTestHelper.createProject(testName, PROJECT_TYPE);
    assertNotNull(project);

    IFolder folder = ManagedBuildTestHelper.createFolder(project, "Folder");
    assertNotNull(folder);

    IFile file = ManagedBuildTestHelper.createFile(project, "Folder/file.c");
    assertNotNull(file);

    ICProjectDescription prjDescription = CoreModel.getDefault().getProjectDescription(project);
    prjDescription.getConfigurationByName(CFG_NAME);

    IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project);
    IConfiguration cfg = info.getManagedProject().getConfigurations()[0];
    assertNotNull(cfg);
    assertEquals(CFG_NAME, cfg.getName());

    {
      // Round 1. Test root folder option
      IFolderInfo rootFolderInfo = cfg.getRootFolderInfo();
      assertNotNull(rootFolderInfo);

      IOption option = getOptionForFolder(rootFolderInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_ENABLEMENT, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 1. Test subfolder option
      IResourceInfo folderInfo = cfg.getResourceInfo(folder.getFullPath(), false);
      assertNotNull(folderInfo);
      assertTrue(folderInfo instanceof IFolderInfo);

      IOption option = getOptionForFolder((IFolderInfo) folderInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_ENABLEMENT, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 1. Test file option
      IResourceInfo fileInfo = cfg.getResourceInfo(file.getFullPath(), false);
      assertNotNull(fileInfo);
      assertTrue(fileInfo instanceof IFolderInfo);

      // Option is taken from root folder here
      IOption option = getOptionForFolder((IFolderInfo) fileInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_ENABLEMENT, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 2. Override the value of the option for the root folder
      IFolderInfo rootFolderInfo = cfg.getRootFolderInfo();
      ITool[] tools = rootFolderInfo.getToolsBySuperClassId(TOOL_ID);
      assertEquals(1, tools.length);
      IOption option = getOptionForFolder(rootFolderInfo, TOOL_ID, OPTION_ID);
      rootFolderInfo.setOption(tools[0], option, OPTION_VALUE_ROOT);
    }

    {
      // Round 2. Test root folder option
      IFolderInfo rootFolderInfo = cfg.getRootFolderInfo();
      assertNotNull(rootFolderInfo);

      IOption option = getOptionForFolder(rootFolderInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_ROOT, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 2. Test subfolder option
      IResourceInfo folderInfo = cfg.getResourceInfo(folder.getFullPath(), false);
      assertNotNull(folderInfo);
      assertTrue(folderInfo instanceof IFolderInfo);

      IOption option = getOptionForFolder((IFolderInfo) folderInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_ROOT, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 2. Test file option
      IResourceInfo fileInfo = cfg.getResourceInfo(file.getFullPath(), false);
      assertNotNull(fileInfo);
      assertTrue(fileInfo instanceof IFolderInfo);

      // Option is taken from root folder here
      IOption option = getOptionForFolder((IFolderInfo) fileInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_ROOT, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 3. Override the value of the option for the subfolder
      IFolderInfo folderInfo = cfg.createFolderInfo(folder.getFullPath());
      assertNotNull(folderInfo);

      ITool[] tools = folderInfo.getToolsBySuperClassId(TOOL_ID);
      assertEquals(1, tools.length);

      IOption option = getOptionForFolder(folderInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_ROOT, option.getValue());
      assertFalse(option.isExtensionElement());

      folderInfo.setOption(tools[0], option, OPTION_VALUE_FOLDER);
    }

    {
      // Round 3. Test root folder option
      IFolderInfo rootFolderInfo = cfg.getRootFolderInfo();
      assertNotNull(rootFolderInfo);

      IOption option = getOptionForFolder(rootFolderInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_ROOT, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 3. Test subfolder option
      IResourceInfo folderInfo = cfg.getResourceInfo(folder.getFullPath(), false);
      assertNotNull(folderInfo);
      assertTrue(folderInfo instanceof IFolderInfo);

      IOption option = getOptionForFolder((IFolderInfo) folderInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_FOLDER, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 3. Test file option
      IResourceInfo fileInfo = cfg.getResourceInfo(file.getFullPath(), false);
      assertNotNull(fileInfo);
      assertTrue(fileInfo instanceof IFolderInfo);

      // Option is taken from parent folder here
      IOption option = getOptionForFolder((IFolderInfo) fileInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_FOLDER, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 4. Override the value of the option for the file
      IFileInfo fileInfo = cfg.createFileInfo(file.getFullPath());
      assertNotNull(fileInfo);

      ITool[] tools = fileInfo.getTools();
      assertEquals(1, tools.length);
      ITool tool = tools[0];
      assertNotNull(tool);

      IOption option = getOptionForFile(fileInfo, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_FOLDER, option.getValue());
      assertFalse(option.isExtensionElement());

      fileInfo.setOption(tool, option, OPTION_VALUE_FILE);
    }

    {
      // Round 4. Test root folder option
      IFolderInfo rootFolderInfo = cfg.getRootFolderInfo();
      assertNotNull(rootFolderInfo);

      IOption option = getOptionForFolder(rootFolderInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_ROOT, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 4. Test subfolder option
      IResourceInfo folderInfo = cfg.getResourceInfo(folder.getFullPath(), false);
      assertNotNull(folderInfo);
      assertTrue(folderInfo instanceof IFolderInfo);

      IOption option = getOptionForFolder((IFolderInfo) folderInfo, TOOL_ID, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_FOLDER, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    {
      // Round 4. Test file option
      IResourceInfo fileInfo = cfg.getResourceInfo(file.getFullPath(), false);
      assertNotNull(fileInfo);
      assertTrue(fileInfo instanceof IFileInfo);

      IOption option = getOptionForFile((IFileInfo) fileInfo, OPTION_ID);
      assertNotNull(option);
      assertEquals(OPTION_VALUE_FILE, option.getValue());
      assertFalse(option.isExtensionElement());
    }

    ManagedBuildTestHelper.removeProject(testName);
  }
示例#22
0
 private IToolChain[] getAllSysToolChains() {
   if (fAllSysToolChains == null) fAllSysToolChains = ManagedBuildManager.getRealToolChains();
   return fAllSysToolChains;
 }
示例#23
0
 public FolderInfoModification(FolderInfo foInfo) {
   super(foInfo, foInfo.getTools());
   fSelectedToolChain = (ToolChain) foInfo.getToolChain();
   fRealToolChain = (ToolChain) ManagedBuildManager.getRealToolChain(fSelectedToolChain);
 }
示例#24
0
  private void applyToolChain(ToolChain newNonRealTc) {
    ToolChain newRealTc = (ToolChain) ManagedBuildManager.getRealToolChain(newNonRealTc);

    ToolChainApplicabilityPaths tcApplicability = getToolChainApplicabilityPaths();
    PerTypeMapStorage<? extends IRealBuildObjectAssociation, Set<IPath>> storage =
        getCompleteObjectStore();

    @SuppressWarnings("unchecked")
    Map<ToolChain, Set<IPath>> tcMap =
        (Map<ToolChain, Set<IPath>>)
            storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false);
    @SuppressWarnings("unchecked")
    Map<Tool, Set<IPath>> toolMap =
        (Map<Tool, Set<IPath>>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false);

    TcModificationUtil.removePaths(tcMap, fRealToolChain, tcApplicability.fFolderInfoPaths);
    TcModificationUtil.addPaths(tcMap, newRealTc, tcApplicability.fFolderInfoPaths);
    Tool[] newTools = (Tool[]) newNonRealTc.getTools();

    for (int i = 0; i < newTools.length; i++) {
      newTools[i] = (Tool) ManagedBuildManager.getRealTool(newTools[i]);
    }

    Set<Entry<Tool, Set<IPath>>> entrySet = tcApplicability.fToolPathMap.entrySet();
    for (Iterator<Entry<Tool, Set<IPath>>> iter = entrySet.iterator(); iter.hasNext(); ) {
      Map.Entry<Tool, Set<IPath>> entry = iter.next();
      Tool tool = entry.getKey();
      Set<IPath> pathSet = entry.getValue();

      TcModificationUtil.removePaths(toolMap, tool, pathSet);
    }

    for (int i = 0; i < newTools.length; i++) {
      TcModificationUtil.addPaths(toolMap, newTools[i], tcApplicability.fFolderInfoPaths);
    }

    if (tcApplicability.fFileInfoPaths.size() != 0) {
      FolderInfo foInfo = (FolderInfo) getResourceInfo();
      IManagedProject mProj = foInfo.getParent().getManagedProject();
      IProject project = mProj.getOwner().getProject();
      Tool[] filtered = (Tool[]) foInfo.filterTools(newTools, mProj);
      if (filtered.length != 0) {
        for (IPath p : tcApplicability.fFileInfoPaths) {
          boolean found = false;
          String ext = p.getFileExtension();
          if (ext == null) ext = ""; // $NON-NLS-1$
          for (int i = 0; i < filtered.length; i++) {
            if (filtered[i].buildsFileType(ext, project)) {
              TcModificationUtil.addPath(toolMap, filtered[i], p);
              found = true;
              break;
            }
          }

          if (!found) {
            if (DbgTcmUtil.DEBUG) {
              DbgTcmUtil.println("no tools found for path " + p); // $NON-NLS-1$
            }
          }
        }

      } else if (DbgTcmUtil.DEBUG) {
        DbgTcmUtil.println("no filtered tools"); // $NON-NLS-1$
      }
    }
  }
示例#25
0
  @Override
  public void process(
      TemplateCore template, ProcessArgument[] args, String processId, IProgressMonitor monitor)
      throws ProcessFailureException {
    String projectName = args[0].getSimpleValue();
    String prefix = args[1].getSimpleValue();
    String path = args[2].getSimpleValue();

    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    if (!project.exists()) return;

    IManagedBuildInfo buildInfo = ManagedBuildManager.getBuildInfo(project);
    if (buildInfo == null) return;

    IConfiguration[] configs = buildInfo.getManagedProject().getConfigurations();
    for (IConfiguration config : configs) {
      IToolChain toolchain = config.getToolChain();
      IOption option =
          toolchain.getOptionBySuperClassId("cdt.managedbuild.option.gnu.cross.prefix");
      ManagedBuildManager.setOption(config, toolchain, option, prefix);
      option = toolchain.getOptionBySuperClassId("cdt.managedbuild.option.gnu.cross.path");
      ManagedBuildManager.setOption(config, toolchain, option, path);

      ICfgScannerConfigBuilderInfo2Set cbi =
          CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(config);
      Map<CfgInfoContext, IScannerConfigBuilderInfo2> map = cbi.getInfoMap();
      for (CfgInfoContext cfgInfoContext : map.keySet()) {
        IScannerConfigBuilderInfo2 bi = map.get(cfgInfoContext);
        String providerId = "specsFile";
        String runCommand = bi.getProviderRunCommand(providerId);
        bi.setProviderRunCommand(providerId, prefix + runCommand);
        try {
          bi.save();
        } catch (CoreException e) {
          throw new ProcessFailureException(e);
        }

        // Clear the path info that was captured at project creation time
        // TODO we need an API to do this to avoid the discouraged access warnings.

        DiscoveredPathInfo pathInfo = new DiscoveredPathInfo(project);
        InfoContext infoContext = cfgInfoContext.toInfoContext();

        // 1. Remove scanner info from .metadata/.plugins/org.eclipse.cdt.make.core/Project.sc
        DiscoveredScannerInfoStore dsiStore = DiscoveredScannerInfoStore.getInstance();
        try {
          dsiStore.saveDiscoveredScannerInfoToState(project, infoContext, pathInfo);
        } catch (CoreException e) {
          e.printStackTrace();
        }

        // 2. Remove scanner info from CfgDiscoveredPathManager cache and from the Tool
        CfgDiscoveredPathManager cdpManager = CfgDiscoveredPathManager.getInstance();
        cdpManager.removeDiscoveredInfo(project, cfgInfoContext);

        // 3. Remove scanner info from SI collector
        IScannerConfigBuilderInfo2 buildInfo2 = map.get(cfgInfoContext);
        if (buildInfo2 != null) {
          ScannerConfigProfileManager scpManager = ScannerConfigProfileManager.getInstance();
          String selectedProfileId = buildInfo2.getSelectedProfileId();
          SCProfileInstance profileInstance =
              scpManager.getSCProfileInstance(project, infoContext, selectedProfileId);

          IScannerInfoCollector collector = profileInstance.getScannerInfoCollector();
          if (collector instanceof IScannerInfoCollectorCleaner) {
            ((IScannerInfoCollectorCleaner) collector).deleteAll(project);
          }
          buildInfo2 = null;
        }
      }
    }

    ManagedBuildManager.saveBuildInfo(project, true);
  }
示例#26
0
  /**
   * Test getting and updating configuration options for an Autotools Project. The top-level
   * contains autogen.sh which will build configure, but not run it.
   *
   * @throws Exception
   */
  public void testGetAndUpdateConfigureOptions() throws Exception {
    Path p = new Path("zip/project2.zip");
    ProjectTools.addSourceContainerWithImport(testProject, "src", p, null);
    assertTrue(testProject.hasNature(ManagedCProjectNature.MNG_NATURE_ID));
    ProjectTools.setConfigDir(testProject, "src");
    ProjectTools.markExecutable(testProject, "src/autogen.sh");
    assertTrue(ProjectTools.build());
    ICConfigurationDescription cfgDes =
        CoreModel.getDefault().getProjectDescription(testProject).getActiveConfiguration();
    IConfiguration cfg = ManagedBuildManager.getConfigurationForDescription(cfgDes);
    assertTrue(cfg.getName().equals("Build (GNU)"));
    Map<String, IAutotoolsOption> opts =
        AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
    IAutotoolsOption configdir = opts.get(AutotoolsOptionConstants.OPT_CONFIGDIR);
    assertEquals(configdir.getType(), IAutotoolsOption.INTERNAL);
    assertTrue(configdir.getValue().equals("src"));
    assertTrue(configdir.canUpdate());
    // Verify we cannot update any of the categories or flags
    IAutotoolsOption k = opts.get(AutotoolsOptionConstants.CATEGORY_DIRECTORIES);
    assertFalse(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.CATEGORY);

    k = opts.get(AutotoolsOptionConstants.CATEGORY_FEATURES);
    assertFalse(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.CATEGORY);

    k = opts.get(AutotoolsOptionConstants.CATEGORY_FILENAMES);
    assertFalse(k.canUpdate());

    k = opts.get(AutotoolsOptionConstants.CATEGORY_GENERAL);
    assertEquals(k.getType(), IAutotoolsOption.CATEGORY);
    assertFalse(k.canUpdate());

    k = opts.get(AutotoolsOptionConstants.CATEGORY_OPTIONS);
    assertEquals(k.getType(), IAutotoolsOption.CATEGORY);
    assertFalse(k.canUpdate());

    k = opts.get(AutotoolsOptionConstants.CATEGORY_PLATFORM);
    assertFalse(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.CATEGORY);

    k = opts.get(AutotoolsOptionConstants.FLAG_CFLAGS);
    assertFalse(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.FLAG);

    // Tools are ok to update
    k = opts.get(AutotoolsOptionConstants.TOOL_AUTOGEN);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.TOOL);
    assertEquals(k.getValue(), "autogen.sh"); // $NON-NLS-1$
    k.setValue("autogen2.sh"); // $NON-NLS-1$

    k = opts.get(AutotoolsOptionConstants.TOOL_CONFIGURE);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.TOOL);
    assertEquals(k.getValue(), "configure"); // $NON-NLS-1$
    k.setValue("config"); // $NON-NLS-1$

    // Flag values are ok to update
    k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.FLAGVALUE);
    assertEquals(k.getValue(), "false"); // $NON-NLS-1$
    k.setValue("true");

    k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GCOV);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.FLAGVALUE);
    assertEquals(k.getValue(), "false"); // $NON-NLS-1$
    k.setValue("true");

    k = opts.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.FLAGVALUE);
    assertEquals(k.getValue(), "false"); // $NON-NLS-1$
    k.setValue("true");

    // Check other options
    k = opts.get(AutotoolsOptionConstants.OPT_AUTOGENOPTS);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.MULTIARG);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("some opts");

    k = opts.get(AutotoolsOptionConstants.OPT_BINDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/bin");

    k = opts.get(AutotoolsOptionConstants.OPT_BUILD);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("linux");

    k = opts.get(AutotoolsOptionConstants.OPT_CACHE_FILE);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("config.status");

    k = opts.get(AutotoolsOptionConstants.OPT_DATADIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/data");

    k = opts.get(AutotoolsOptionConstants.OPT_ENABLE_MAINTAINER_MODE);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.BIN);
    assertEquals(k.getValue(), "false"); // $NON-NLS-1$
    k.setValue("true");

    k = opts.get(AutotoolsOptionConstants.OPT_EXEC_PREFIX);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/exec");

    k = opts.get(AutotoolsOptionConstants.OPT_HELP);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.BIN);
    assertEquals(k.getValue(), "false"); // $NON-NLS-1$
    k.setValue("true");

    k = opts.get(AutotoolsOptionConstants.OPT_HOST);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("linux");

    k = opts.get(AutotoolsOptionConstants.OPT_INCLUDEDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/include");

    k = opts.get(AutotoolsOptionConstants.OPT_INFODIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/info");

    k = opts.get(AutotoolsOptionConstants.OPT_LIBDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/lib");

    k = opts.get(AutotoolsOptionConstants.OPT_LIBEXECDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/libexec");

    k = opts.get(AutotoolsOptionConstants.OPT_LOCALSTATEDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/localstate");

    k = opts.get(AutotoolsOptionConstants.OPT_MANDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/man");

    k = opts.get(AutotoolsOptionConstants.OPT_NO_CREATE);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.BIN);
    assertEquals(k.getValue(), "false"); // $NON-NLS-1$
    k.setValue("true");

    k = opts.get(AutotoolsOptionConstants.OPT_OLDINCLUDEDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/oldinclude");

    k = opts.get(AutotoolsOptionConstants.OPT_PREFIX);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("prefix");

    k = opts.get(AutotoolsOptionConstants.OPT_PROGRAM_PREFIX);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("program_prefix");

    k = opts.get(AutotoolsOptionConstants.OPT_PROGRAM_SUFFIX);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("program_suffix");

    k = opts.get(AutotoolsOptionConstants.OPT_PROGRAM_TRANSFORM_NAME);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("program_transform_name");

    k = opts.get(AutotoolsOptionConstants.OPT_QUIET);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.BIN);
    assertEquals(k.getValue(), "false"); // $NON-NLS-1$
    k.setValue("true");

    k = opts.get(AutotoolsOptionConstants.OPT_SBINDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/sbin");

    k = opts.get(AutotoolsOptionConstants.OPT_SHAREDSTATEDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/sharedstate");

    k = opts.get(AutotoolsOptionConstants.OPT_SRCDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("src");

    k = opts.get(AutotoolsOptionConstants.OPT_SYSCONFDIR);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("/usr/sysconf");

    k = opts.get(AutotoolsOptionConstants.OPT_TARGET);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.STRING);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("target");

    k = opts.get(AutotoolsOptionConstants.OPT_USER);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.MULTIARG);
    assertEquals(k.getValue(), ""); // $NON-NLS-1$
    k.setValue("user opts");

    k = opts.get(AutotoolsOptionConstants.OPT_VERSION);
    assertTrue(k.canUpdate());
    assertEquals(k.getType(), IAutotoolsOption.BIN);
    assertEquals(k.getValue(), "false"); // $NON-NLS-1$
    k.setValue("true");

    // Verify last option changed has changed in our copy, but not
    // in the actual options
    assertEquals(k.getValue(), "true");
    Map<String, IAutotoolsOption> opts2 =
        AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());
    IAutotoolsOption k2 = opts2.get(AutotoolsOptionConstants.OPT_VERSION);
    assertEquals(k2.getValue(), "false");

    // Now update the options we changed
    AutotoolsPlugin.getDefault().updateAutotoolCfgOptions(testProject, cfg.getId(), opts);
    opts2 = AutotoolsPlugin.getDefault().getAutotoolCfgOptions(testProject, cfg.getId());

    // Verify new option values
    k = opts2.get(AutotoolsOptionConstants.TOOL_AUTOGEN);
    assertEquals(k.getValue(), "autogen2.sh"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.TOOL_CONFIGURE);
    assertEquals(k.getValue(), "config"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_CFLAGS_DEBUG);
    assertEquals(k.getValue(), "true"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_CFLAGS_GCOV);
    assertEquals(k.getValue(), "true"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_CFLAGS_GPROF);
    assertEquals(k.getValue(), "true"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_AUTOGENOPTS);
    assertEquals(k.getValue(), "some opts"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_BINDIR);
    assertEquals(k.getValue(), "/usr/bin"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_BUILD);
    assertEquals(k.getValue(), "linux"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_CACHE_FILE);
    assertEquals(k.getValue(), "config.status"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_DATADIR);
    assertEquals(k.getValue(), "/usr/data"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_ENABLE_MAINTAINER_MODE);
    assertEquals(k.getValue(), "true"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_EXEC_PREFIX);
    assertEquals(k.getValue(), "/usr/exec"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_HELP);
    assertEquals(k.getValue(), "true"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_HOST);
    assertEquals(k.getValue(), "linux"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_INCLUDEDIR);
    assertEquals(k.getValue(), "/usr/include"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_INFODIR);
    assertEquals(k.getValue(), "/usr/info"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_LIBDIR);
    assertEquals(k.getValue(), "/usr/lib"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_LIBEXECDIR);
    assertEquals(k.getValue(), "/usr/libexec"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_LOCALSTATEDIR);
    assertEquals(k.getValue(), "/usr/localstate"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_MANDIR);
    assertEquals(k.getValue(), "/usr/man"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_NO_CREATE);
    assertEquals(k.getValue(), "true"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_OLDINCLUDEDIR);
    assertEquals(k.getValue(), "/usr/oldinclude"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_PREFIX);
    assertEquals(k.getValue(), "prefix"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_PROGRAM_PREFIX);
    assertEquals(k.getValue(), "program_prefix"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_PROGRAM_SUFFIX);
    assertEquals(k.getValue(), "program_suffix"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_PROGRAM_TRANSFORM_NAME);
    assertEquals(k.getValue(), "program_transform_name"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_QUIET);
    assertEquals(k.getValue(), "true"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_SBINDIR);
    assertEquals(k.getValue(), "/usr/sbin"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_SHAREDSTATEDIR);
    assertEquals(k.getValue(), "/usr/sharedstate"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_SRCDIR);
    assertEquals(k.getValue(), "src"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_SYSCONFDIR);
    assertEquals(k.getValue(), "/usr/sysconf"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_TARGET);
    assertEquals(k.getValue(), "target"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_USER);
    assertEquals(k.getValue(), "user opts"); // $NON-NLS-1$

    k = opts2.get(AutotoolsOptionConstants.OPT_VERSION);
    assertEquals(k.getValue(), "true"); // $NON-NLS-1$

    // Verify one updated option in the .autotools file for the project
    try {
      IPath fileLocation = testProject.getLocation().append(".autotools"); // $NON-NLS-1$
      File dirFile = fileLocation.toFile();
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      assertTrue(dirFile.exists());
      Document d = db.parse(dirFile);
      Element e = d.getDocumentElement();
      // Get the stored configuration data
      NodeList cfgs = e.getElementsByTagName("configuration"); // $NON-NLS-1$
      for (int x = 0; x < cfgs.getLength(); ++x) {
        Node n = cfgs.item(x);
        NodeList l = n.getChildNodes();
        for (int y = 0; y < l.getLength(); ++y) {
          Node child = l.item(y);
          if (child.getNodeName().equals("option")) { // $NON-NLS-1$
            NamedNodeMap optionAttrs = child.getAttributes();
            Node id = optionAttrs.getNamedItem("id"); // $NON-NLS-1$
            Node value = optionAttrs.getNamedItem("value"); // $NON-NLS-1$
            // Verify the bindir option is updated
            if (id.equals(AutotoolsOptionConstants.OPT_BINDIR))
              assertEquals(value, "/usr/bin"); // $NON-NLS-1$
          }
        }
      }
    } catch (ParserConfigurationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (SAXException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 private IConfiguration getDefaultConfig() {
   return ManagedBuildManager.getBuildInfo(project).getDefaultConfiguration();
 }
示例#28
0
  /**
   * 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);
    }
  }
示例#29
0
  /**
   * Load the project-type information from the XML element specified in the argument
   *
   * @param element An XML element containing the project type information
   */
  protected void loadFromManifest(IManagedConfigElement element) {
    ManagedBuildManager.putConfigElement(this, element);

    // id
    setId(SafeStringInterner.safeIntern(element.getAttribute(ID)));

    // Get the name
    setName(SafeStringInterner.safeIntern(element.getAttribute(NAME)));

    // version
    setVersion(getVersionFromId());

    // superClass
    superClassId = SafeStringInterner.safeIntern(element.getAttribute(SUPERCLASS));

    String props = SafeStringInterner.safeIntern(element.getAttribute(BUILD_PROPERTIES));
    if (props != null) buildProperties = new BuildObjectProperties(props, this, this);

    String artType = SafeStringInterner.safeIntern(element.getAttribute(BUILD_ARTEFACT_TYPE));
    if (artType != null) {
      if (buildProperties == null) buildProperties = new BuildObjectProperties(this, this);

      try {
        buildProperties.setProperty(
            ManagedBuildManager.BUILD_ARTEFACT_TYPE_PROPERTY_ID, artType, true);
      } catch (CoreException e) {
        ManagedBuilderCorePlugin.log(e);
      }
    }

    // Get the unused children, if any
    unusedChildren = SafeStringInterner.safeIntern(element.getAttribute(UNUSED_CHILDREN));

    // isAbstract
    String isAbs = element.getAttribute(IS_ABSTRACT);
    if (isAbs != null) {
      isAbstract = Boolean.parseBoolean(isAbs);
    }

    // Is this a test project type
    String isTestStr = element.getAttribute(IS_TEST);
    if (isTestStr != null) {
      isTest = Boolean.parseBoolean(isTestStr);
    }

    // Store the configuration element IFF there is a configuration name provider defined
    if (element.getAttribute(CONFIGURATION_NAME_PROVIDER) != null
        && element instanceof DefaultManagedConfigElement) {
      configurationNameProviderElement =
          ((DefaultManagedConfigElement) element).getConfigurationElement();
    }

    // Get the environmentVariableSupplier configuration element
    String environmentVariableSupplier = element.getAttribute(PROJECT_ENVIRONMENT_SUPPLIER);
    if (environmentVariableSupplier != null && element instanceof DefaultManagedConfigElement) {
      environmentVariableSupplierElement =
          ((DefaultManagedConfigElement) element).getConfigurationElement();
    }

    // Get the buildMacroSupplier configuration element
    String buildMacroSupplier = element.getAttribute(PROJECT_MACRO_SUPPLIER);
    if (buildMacroSupplier != null && element instanceof DefaultManagedConfigElement) {
      buildMacroSupplierElement = ((DefaultManagedConfigElement) element).getConfigurationElement();
    }

    // Get the 'convertToId' attribute if it is available
    convertToId = SafeStringInterner.safeIntern(element.getAttribute(CONVERT_TO_ID));
  }