Пример #1
0
 public static void build(IConfiguration cfg, int flags, IProgressMonitor monitor) {
   if (cfg != null) {
     //			IScannerConfigBuilderInfo buildInfo =
     // MakeCorePlugin.createScannerConfigBuildInfo(getProject(), BUILDER_ID);
     //			autodiscoveryEnabled = buildInfo.isAutoDiscoveryEnabled();
     //
     //            if (autodiscoveryEnabled) {
     //                monitor.beginTask("ScannerConfigBuilder.Invoking_Builder", 100);
     // //$NON-NLS-1$
     //
     // monitor.subTask(MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder") +
     // //$NON-NLS-1$
     //                        getProject().getName());
     //                ScannerInfoCollector.getInstance().updateScannerConfiguration(getProject(),
     // new SubProgressMonitor(monitor, 100));
     //            }
     ICfgScannerConfigBuilderInfo2Set info =
         CfgScannerConfigProfileManager.getCfgScannerConfigBuildInfo(cfg);
     IProject project = cfg.getOwner().getProject();
     Map<CfgInfoContext, IScannerConfigBuilderInfo2> infoMap = info.getInfoMap();
     int num = infoMap.size();
     if (num != 0) {
       Properties envProps = calcEnvironment(cfg);
       monitor.beginTask(
           MakeMessages.getString("ScannerConfigBuilder.Invoking_Builder"), num); // $NON-NLS-1$
       for (Entry<CfgInfoContext, IScannerConfigBuilderInfo2> entry : infoMap.entrySet()) {
         try {
           CfgInfoContext c = entry.getKey();
           IScannerConfigBuilderInfo2 buildInfo2 = entry.getValue();
           build(
               c,
               buildInfo2,
               (flags & (~PERFORM_CORE_UPDATE)),
               envProps,
               new SubProgressMonitor(monitor, 1));
         } catch (CoreException e) {
           // builder not installed or disabled
           //			autodiscoveryEnabled = false;
           //										autodiscoveryEnabled2 = false;
           ManagedBuilderCorePlugin.log(e);
         }
       }
     }
     if ((flags & PERFORM_CORE_UPDATE) != 0)
       CfgDiscoveredPathManager.getInstance()
           .updateCoreSettings(project, new IConfiguration[] {cfg});
   }
 }
Пример #2
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);
  }