mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 06:18:13 +00:00
Improve install_paths handling for relative paths. (#4331)
Because install_paths is not presently validated, and it's resolved after the `SetWorkingDirForBazel` call, if a relative path is used with bazel then it would fail silently. This starts making the driver share install path errors, and starts changing how `//toolchain` launches `carbon`. Note the implementation is still brittle and will break with symlinks. That's something I plan to address as part of busyboxing.
This commit is contained in:
1 parent
edc6ed3d10
commit
c7057eff89
8 files changed
+78
-10
No files matched your search
@@ -19,15 +19,19 @@ auto main(int argc, char** argv) -> int {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Resolve paths before calling SetWorkingDirForBazel.
|
||||
std::string exe_path = Carbon::FindExecutablePath(argv[0]);
|
||||
const auto install_paths = Carbon::InstallPaths::MakeExeRelative(exe_path);
|
||||
if (install_paths.error()) {
|
||||
llvm::errs() << "error: " << *install_paths.error();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user