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 "common/exe_path.h"
  7. #include "common/init_llvm.h"
  8. #include "llvm/ADT/SmallVector.h"
  9. #include "llvm/ADT/StringRef.h"
  10. #include "toolchain/driver/driver.h"
  11. #include "toolchain/install/install_paths.h"
  12. auto main(int argc, char** argv) -> int {
  13. Carbon::InitLLVM init_llvm(argc, argv);
  14. if (argc < 1) {
  15. return EXIT_FAILURE;
  16. }
  17. std::string exe_path = Carbon::FindExecutablePath(argv[0]);
  18. Carbon::SetWorkingDirForBazel();
  19. llvm::SmallVector<llvm::StringRef> args(argv + 1, argv + argc);
  20. auto fs = llvm::vfs::getRealFileSystem();
  21. const auto install_paths = Carbon::InstallPaths::MakeExeRelative(exe_path);
  22. Carbon::Driver driver(*fs, &install_paths, llvm::outs(), llvm::errs());
  23. bool success = driver.RunCommand(args).success;
  24. return success ? EXIT_SUCCESS : EXIT_FAILURE;
  25. }