mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 22:02:45 +01:00
This removes the `data_dir` from the driver favoring the installation abstraction for the both locating the prelude and linking utilities. With this, an installed toolchain should also be able to compile and link Carbon successfully, and the build of the examples should exercise this path almost exactly. (The only difference is using the driver `cc_binary` directly rather than relying on the symlink from inside the install tree.)
35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#include <cstdlib>
|
|
|
|
#include "common/bazel_working_dir.h"
|
|
#include "common/exe_path.h"
|
|
#include "common/init_llvm.h"
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "toolchain/driver/driver.h"
|
|
#include "toolchain/install/install_paths.h"
|
|
|
|
auto main(int argc, char** argv) -> int {
|
|
Carbon::InitLLVM init_llvm(argc, argv);
|
|
|
|
if (argc < 1) {
|
|
return EXIT_FAILURE;
|
|
}
|
|
|
|
std::string exe_path = Carbon::FindExecutablePath(argv[0]);
|
|
|
|
Carbon::SetWorkingDirForBazel();
|
|
|
|
llvm::SmallVector<llvm::StringRef> args(argv + 1, argv + argc);
|
|
auto fs = llvm::vfs::getRealFileSystem();
|
|
|
|
const auto install_paths = Carbon::InstallPaths::MakeExeRelative(exe_path);
|
|
|
|
Carbon::Driver driver(*fs, &install_paths, llvm::outs(), llvm::errs());
|
|
bool success = driver.RunCommand(args).success;
|
|
return success ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
}
|