Exemplo n.º 1
0
 /* (non-Javadoc)
  * @see org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC#addSCOption(org.eclipse.cdt.make.internal.core.scannerconfig.util.KVStringPair)
  */
 @Override
 public void addSCOption(KVStringPair option) {
   if (project != null
       && (option.getKey().equals(SCDOptionsEnum.INCLUDE_FILE.toString())
           || option.getKey().equals(SCDOptionsEnum.INCLUDE.toString())
           || option.getKey().equals(SCDOptionsEnum.ISYSTEM.toString())
           || option.getKey().equals(SCDOptionsEnum.IMACROS_FILE.toString())
           || option.getKey().equals(SCDOptionsEnum.IQUOTE.toString()))) {
     String value = option.getValue();
     value = makeRelative(project, new Path(value)).toOSString();
     option = new KVStringPair(option.getKey(), value);
   }
   compilerCommand.add(option);
 }
  /**
   * @param genericLine
   * @param cppFileType
   * @return CCommandDSC compile command description
   */
  public CCommandDSC getNewCCommandDSC(
      String[] tokens, final int idxOfCompilerCommand, boolean cppFileType) {
    ArrayList dirafter = new ArrayList();
    ArrayList includes = new ArrayList();
    XLCCommandDSC command = new XLCCommandDSC(cppFileType, getProject());
    command.addSCOption(
        new KVStringPair(SCDOptionsEnum.COMMAND.toString(), tokens[idxOfCompilerCommand]));
    for (int i = idxOfCompilerCommand + 1; i < tokens.length; ++i) {
      String token = tokens[i];
      // Target specific options: see GccScannerInfoConsoleParser
      if (token.startsWith("-m")
          || //$NON-NLS-1$
          token.equals("-ansi")
          || //$NON-NLS-1$
          token.equals("-posix")
          || //$NON-NLS-1$
          token.equals("-pthread")
          || //$NON-NLS-1$
          token.startsWith("-O")
          || //$NON-NLS-1$
          token.equals("-fno-inline")
          || //$NON-NLS-1$
          token.startsWith("-finline")
          || //$NON-NLS-1$
          token.equals("-fno-exceptions")
          || //$NON-NLS-1$
          token.equals("-fexceptions")
          || //$NON-NLS-1$
          token.equals("-fshort-wchar")
          || //$NON-NLS-1$
          token.equals("-fshort-double")
          || //$NON-NLS-1$
          token.equals("-fno-signed-char")
          || //$NON-NLS-1$
          token.equals("-fsigned-char")
          || //$NON-NLS-1$
          token.startsWith("-fabi-version=") // $NON-NLS-1$
      ) {
        command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), token));
        continue;
      }
      for (int j = SCDOptionsEnum.MIN; j <= SCDOptionsEnum.MAX; ++j) {
        final SCDOptionsEnum optionKind = SCDOptionsEnum.getSCDOptionsEnum(j);
        if (token.startsWith(optionKind.toString())) {
          String option = token.substring(optionKind.toString().length()).trim();
          if (option.length() > 0) {
            // ex. -I/dir
          } else if (optionKind.equals(SCDOptionsEnum.IDASH)) {
            for (Iterator iter = includes.iterator(); iter.hasNext(); ) {
              option = (String) iter.next();
              KVStringPair pair = new KVStringPair(SCDOptionsEnum.IQUOTE.toString(), option);
              command.addSCOption(pair);
            }
            includes = new ArrayList();
            // -I- has no parameter
          } else {
            // ex. -I /dir
            // take a next token
            if (i + 1 < tokens.length && !tokens[i + 1].startsWith("-")) { // $NON-NLS-1$
              option = tokens[++i];
            } else break;
          }

          if (option.length() > 0
              && (optionKind.equals(SCDOptionsEnum.INCLUDE)
                  || optionKind.equals(SCDOptionsEnum.INCLUDE_FILE)
                  || optionKind.equals(SCDOptionsEnum.IMACROS_FILE)
                  || optionKind.equals(SCDOptionsEnum.IDIRAFTER)
                  || optionKind.equals(SCDOptionsEnum.ISYSTEM)
                  || optionKind.equals(SCDOptionsEnum.IQUOTE))) {
            option = (getAbsolutePath(option)).toString();
          }

          if (optionKind.equals(SCDOptionsEnum.IDIRAFTER)) {
            KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option);
            dirafter.add(pair);
          } else if (optionKind.equals(SCDOptionsEnum.INCLUDE)) {
            includes.add(option);
          } else { // add the pair
            if (optionKind.equals(SCDOptionsEnum.DEFINE)) {
              if (option.indexOf('=') == -1) {
                option += '=' + fDefaultMacroDefinitionValue;
              }
            }
            KVStringPair pair = new KVStringPair(optionKind.toString(), option);
            command.addSCOption(pair);
          }
          break;
        }
      }
    }
    String option;
    for (Iterator iter = includes.iterator(); iter.hasNext(); ) {
      option = (String) iter.next();
      KVStringPair pair = new KVStringPair(SCDOptionsEnum.INCLUDE.toString(), option);
      command.addSCOption(pair);
    }
    for (Iterator iter = dirafter.iterator(); iter.hasNext(); ) {
      command.addSCOption((KVStringPair) iter.next());
    }
    return command;
  }