コード例 #1
0
  /** 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;
  }
コード例 #2
0
  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;
  }
コード例 #3
0
 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
  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());
    }
  }