Пример #1
0
/// Create a dependency file for `-d` option.
///
/// This functionality is really only for the benefit of the build system.
/// It is similar to GCC's `-M*` family of options.
static int createDependencyFile(const TGParser &Parser, const char *argv0) {
  if (OutputFilename == "-")
    return reportError(argv0, "the option -d must be used together with -o\n");

  std::error_code EC;
  ToolOutputFile DepOut(DependFilename, EC, sys::fs::F_Text);
  if (EC)
    return reportError(argv0, "error opening " + DependFilename + ":" +
                                  EC.message() + "\n");
  DepOut.os() << OutputFilename << ":";
  for (const auto &Dep : Parser.getDependencies()) {
    DepOut.os() << ' ' << Dep.first;
  }
  DepOut.os() << "\n";
  DepOut.keep();
  return 0;
}
Пример #2
0
/// \brief Create a dependency file for `-d` option.
///
/// This functionality is really only for the benefit of the build system.
/// It is similar to GCC's `-M*` family of options.
static int createDependencyFile(const TGParser &Parser, const char *argv0) {
  if (OutputFilename == "-") {
    errs() << argv0 << ": the option -d must be used together with -o\n";
    return 1;
  }
  std::string Error;
  tool_output_file DepOut(DependFilename.c_str(), Error);
  if (!Error.empty()) {
    errs() << argv0 << ": error opening " << DependFilename
      << ":" << Error << "\n";
    return 1;
  }
  DepOut.os() << OutputFilename << ":";
  const std::vector<std::string> &Dependencies = Parser.getDependencies();
  for (std::vector<std::string>::const_iterator I = Dependencies.begin(),
                                                E = Dependencies.end();
       I != E; ++I) {
    DepOut.os() << " " << (*I);
  }
  DepOut.os() << "\n";
  DepOut.keep();
  return 0;
}