driver_main.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include <cstdlib>
  5. #include "common/bazel_working_dir.h"
  6. #include "llvm/ADT/SmallVector.h"
  7. #include "llvm/ADT/StringRef.h"
  8. #include "llvm/Support/InitLLVM.h"
  9. #include "toolchain/driver/driver.h"
  10. auto main(int argc, char** argv) -> int {
  11. if (argc < 1) {
  12. return EXIT_FAILURE;
  13. }
  14. Carbon::SetWorkingDirForBazel();
  15. llvm::setBugReportMsg(
  16. "Please report issues to "
  17. "https://github.com/carbon-language/carbon-lang/issues and include the "
  18. "crash backtrace.\n");
  19. llvm::InitLLVM init_llvm(argc, argv);
  20. // Printing to stderr should flush stdout. This is most noticeable when stderr
  21. // is piped to stdout.
  22. llvm::errs().tie(&llvm::outs());
  23. llvm::SmallVector<llvm::StringRef, 16> args(argv + 1, argv + argc);
  24. Carbon::Driver driver;
  25. bool success = driver.RunFullCommand(args);
  26. return success ? EXIT_SUCCESS : EXIT_FAILURE;
  27. }