示例#1
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;
  }
示例#2
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;
  }
 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) {
         }
       }
     }
   }
 }
示例#4
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;
  }
示例#5
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);
  }