コード例 #1
0
  @Override
  public IExtendedScannerInfo getDefaultScannerInfo(
      IBuildConfiguration buildConfig,
      IExtendedScannerInfo baseScannerInfo,
      ILanguage language,
      URI buildDirectoryURI) {
    try {
      String[] commands = getCompileCommands(language);
      if (commands == null || commands.length == 0) {
        // no default commands
        return null;
      }

      Path buildDirectory = Paths.get(buildDirectoryURI);

      // Pick the first one
      Path command = Paths.get(commands[0]);
      List<String> commandLine = new ArrayList<>();
      if (command.isAbsolute()) {
        commandLine.add(command.toString());
      } else {
        commandLine.add(getCommandPath(command).toString());
      }

      if (baseScannerInfo != null && baseScannerInfo.getIncludePaths() != null) {
        for (String includePath : baseScannerInfo.getIncludePaths()) {
          commandLine.add("-I" + includePath); // $NON-NLS-1$
        }
      }

      addDiscoveryOptions(commandLine);

      // output to stdout
      commandLine.add("-o"); // $NON-NLS-1$
      commandLine.add("-"); // $NON-NLS-1$

      // Source is an empty tmp file
      String extension;
      if (GPPLanguage.ID.equals(language.getId())) {
        extension = ".cpp";
      } else if (GCCLanguage.ID.equals(language.getId())) {
        extension = ".c";
      } else {
        // In theory we shouldn't get here
        return null;
      }

      Path tmpFile = Files.createTempFile(buildDirectory, ".sc", extension); // $NON-NLS-1$
      commandLine.add(tmpFile.toString());

      return getScannerInfo(buildConfig, commandLine, buildDirectory, tmpFile);
    } catch (IOException e) {
      Activator.log(e);
      return null;
    }
  }
コード例 #2
0
 @Override
 public String[] getCompileCommands(ILanguage language) {
   if (GPPLanguage.ID.equals(language.getId())) {
     return new String[] {
       prefix + "g++", prefix + "clang++", prefix + "c++"
     }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   } else if (GCCLanguage.ID.equals(language.getId())) {
     return new String[] {
       prefix + "gcc", prefix + "clang", prefix + "cc"
     }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
   } else {
     return new String[0];
   }
 }