예제 #1
0
 public void reset() {
   // We just need to remove all Options
   ITool[] tools = getTools();
   // Send out the event to notify the options that they are about to be removed
   //		ManagedBuildManager.performValueHandlerEvent(this, IManagedOptionValueHandler.EVENT_CLOSE);
   // Remove the configurations
   for (int i = 0; i < tools.length; i++) {
     ITool tool = tools[i];
     IOption[] opts = tool.getOptions();
     for (int j = 0; j < opts.length; j++) {
       tool.removeOption(opts[j]);
     }
   }
   //		setExclude(false);
 }
  private Collection<String> getLinkerOptionValues(int linkerOption) {
    for (ITool tool : config.getToolChain().getTools()) {
      if (!isToolLinker(tool)) {
        continue;
      }

      for (IOption o : tool.getOptions()) {
        try {
          if (o.getValueType() != linkerOption) {
            continue;
          }
          return orderPreservingSet(
              linkerOption == IOption.LIBRARY_PATHS ? o.getLibraryPaths() : o.getLibraries());
        } catch (BuildException e) {
        }
      }
    }
    return Collections.emptySet();
  }
예제 #3
0
 /**
  * This method parses the string that is entered in the all build option field editor and stores
  * the options to the corresponding option fields.
  */
 public void parseAllOptions() {
   // Get the all build options string from all options field
   String alloptions = getToolSettingsPrefStore().getString(ToolSettingsPrefStore.ALL_OPTIONS_ID);
   // list that holds the options for the option type other than
   // boolean,string and enumerated
   List<String> optionsList = new ArrayList<String>();
   // additional options buffer
   StringBuffer addnOptions = new StringBuffer();
   // split all build options string
   Vector<String> optionsArr = getOptionVector(alloptions);
   for (String optionValue : optionsArr) {
     boolean optionValueExist = false;
     // get the options for this tool
     IOption[] options = fTool.getOptions();
     for (IOption opt : options) {
       // String name = opt.getId();
       // check whether the option value is "STRING" type
       for (String s : stringOptionsMap.values()) {
         if (s.indexOf(optionValue) != -1) optionValueExist = true;
       }
       // check whether the option value is "OBJECTS" type
       for (String s : userObjsMap.values()) {
         if (s.indexOf(optionValue) != -1) optionValueExist = true;
       }
       // if the value does not exist in string option or user objects
       // option
       if (!optionValueExist) {
         try {
           // check whether the option value is already exist
           // and also change the preference store based on
           // the option value
           switch (opt.getValueType()) {
             case IOption.BOOLEAN:
               String boolCommand;
               boolCommand = opt.getCommand();
               if (boolCommand != null && boolCommand.equals(optionValue)) {
                 setOption(opt, true);
                 optionValueExist = true;
               }
               boolCommand = opt.getCommandFalse();
               if (boolCommand != null && boolCommand.equals(optionValue)) {
                 setOption(opt, false);
                 optionValueExist = true;
               }
               break;
             case IOption.ENUMERATED:
               String enumeration = ""; // $NON-NLS-1$
               String[] enumValues = opt.getApplicableValues();
               for (int i = 0; i < enumValues.length; i++) {
                 if (opt.getEnumCommand(enumValues[i]).equals(optionValue)) {
                   enumeration = enumValues[i];
                   optionValueExist = true;
                 }
               }
               if (!enumeration.equals("")) // $NON-NLS-1$
               setOption(opt, enumeration);
               break;
             case IOption.STRING_LIST:
             case IOption.INCLUDE_PATH:
             case IOption.PREPROCESSOR_SYMBOLS:
             case IOption.LIBRARIES:
             case IOption.INCLUDE_FILES:
             case IOption.LIBRARY_PATHS:
             case IOption.LIBRARY_FILES:
             case IOption.MACRO_FILES:
             case IOption.UNDEF_INCLUDE_PATH:
             case IOption.UNDEF_PREPROCESSOR_SYMBOLS:
             case IOption.UNDEF_INCLUDE_FILES:
             case IOption.UNDEF_LIBRARY_PATHS:
             case IOption.UNDEF_LIBRARY_FILES:
             case IOption.UNDEF_MACRO_FILES:
               if (opt.getCommand() != null && optionValue.startsWith(opt.getCommand())) {
                 optionsList.add(optionValue);
                 optionValueExist = true;
               }
               break;
             default:
               break;
           }
         } catch (BuildException e) {
         }
       }
     }
     // If the parsed string does not match with any previous option
     // values then consider this option as a additional build option
     if (!optionValueExist) {
       addnOptions.append(optionValue + ITool.WHITE_SPACE);
     }
   }
   // check whether some of the "STRING" option value or "OBJECTS" type
   // option value removed
   // by the user from all build option field
   Set<String> set = stringOptionsMap.keySet();
   for (int i = 0; i < set.size(); i++) {
     Iterator<String> iterator = set.iterator();
     while (iterator.hasNext()) {
       Object key = iterator.next();
       String val = stringOptionsMap.get(key);
       if (alloptions.indexOf(val) == -1) {
         StringBuffer buf = new StringBuffer();
         String[] vals = val.split(WHITESPACE);
         for (int t = 0; t < vals.length; t++) {
           if (alloptions.indexOf(vals[t]) != -1) buf.append(vals[t] + ITool.WHITE_SPACE);
         }
         setOption(((IOption) key), buf.toString().trim());
       }
     }
   }
   // "OBJECTS" type
   Set<IOption> objSet = userObjsMap.keySet();
   for (int s = 0; s < objSet.size(); s++) {
     for (IOption op : objSet) {
       String val = userObjsMap.get(op);
       ArrayList<String> list = new ArrayList<String>();
       for (String v : parseString(val)) {
         if (alloptions.indexOf(v) != -1) list.add(v);
       }
       String listArr[] = new String[list.size()];
       list.toArray(listArr);
       setOption(op, listArr);
     }
   }
   // Now update the preference store with parsed options
   // Get the options for this tool
   IOption[] options = fTool.getOptions();
   for (int k = 0; k < options.length; ++k) {
     IOption opt = options[k];
     // String name = opt.getId();
     // String listStr = ""; //$NON-NLS-1$
     // String[] listVal = null;
     try {
       switch (opt.getValueType()) {
         case IOption.BOOLEAN:
           ArrayList<String> optsList = new ArrayList<String>(optionsArr);
           if (opt.getCommand() != null
               && opt.getCommand().length() > 0
               && !optsList.contains(opt.getCommand())) setOption(opt, false);
           if (opt.getCommandFalse() != null
               && opt.getCommandFalse().length() > 0
               && !optsList.contains(opt.getCommandFalse())) setOption(opt, true);
           break;
         case IOption.STRING:
           // TODO create a lst of valid default string options for the tool
           if (getDefaultOptionNames().contains(opt.getName())) {
             String newOptions = opt.getStringValue();
             if (addnOptions.length() > 0) {
               newOptions = newOptions + ITool.WHITE_SPACE + addnOptions.toString().trim();
             }
             setOption(opt, newOptions);
           }
           break;
         case IOption.STRING_LIST:
         case IOption.INCLUDE_PATH:
         case IOption.PREPROCESSOR_SYMBOLS:
         case IOption.LIBRARIES:
           ArrayList<String> newList = new ArrayList<String>();
           for (String s : optionsList) {
             if (opt.getCommand() != null && s.startsWith(opt.getCommand())) {
               newList.add(s.substring(opt.getCommand().length()));
             }
           }
           String[] strlist = new String[newList.size()];
           newList.toArray(strlist);
           newList.clear();
           setOption(opt, strlist);
           break;
         default:
           break;
       }
     } catch (BuildException e) {
     }
   }
 }