mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Move the core standard library to the installation. (#3995)
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.)
This commit is contained in:
@@ -32,7 +32,7 @@
|
||||
|
||||
namespace Carbon {
|
||||
|
||||
auto Driver::FindPreludeFiles(llvm::StringRef data_dir,
|
||||
auto Driver::FindPreludeFiles(llvm::StringRef core_package_dir,
|
||||
llvm::raw_ostream& error_stream)
|
||||
-> llvm::SmallVector<std::string> {
|
||||
llvm::SmallVector<std::string> result;
|
||||
@@ -40,16 +40,16 @@ auto Driver::FindPreludeFiles(llvm::StringRef data_dir,
|
||||
// Include <data>/core/prelude.carbon, which is the entry point into the
|
||||
// prelude.
|
||||
{
|
||||
llvm::SmallString<256> prelude_file(data_dir);
|
||||
llvm::SmallString<256> prelude_file(core_package_dir);
|
||||
llvm::sys::path::append(prelude_file, llvm::sys::path::Style::posix,
|
||||
"core/prelude.carbon");
|
||||
"prelude.carbon");
|
||||
result.push_back(prelude_file.str().str());
|
||||
}
|
||||
|
||||
// Glob for <data>/core/prelude/**/*.carbon and add all the files we find.
|
||||
llvm::SmallString<256> prelude_dir(data_dir);
|
||||
llvm::SmallString<256> prelude_dir(core_package_dir);
|
||||
llvm::sys::path::append(prelude_dir, llvm::sys::path::Style::posix,
|
||||
"core/prelude");
|
||||
"prelude");
|
||||
std::error_code ec;
|
||||
for (llvm::sys::fs::recursive_directory_iterator prelude_files_it(
|
||||
prelude_dir, ec, /*follow_symlinks=*/false);
|
||||
@@ -790,7 +790,8 @@ auto Driver::Compile(const CompileOptions& options,
|
||||
// package-specific search path based on the library name.
|
||||
bool want_prelude =
|
||||
options.prelude_import && options.phase >= CompileOptions::Phase::Check;
|
||||
auto prelude = want_prelude ? FindPreludeFiles(data_dir_, error_stream_)
|
||||
auto prelude = want_prelude ? FindPreludeFiles(installation_->core_package(),
|
||||
error_stream_)
|
||||
: llvm::SmallVector<std::string>{};
|
||||
if (want_prelude && prelude.empty()) {
|
||||
return {.success = false};
|
||||
|
||||
Reference in New Issue
Block a user