mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Move the :install_paths library to //toolchain/base (#6457)
Previously this was kept in `//toolchain/install` so it would be near to the code that actually defines the installation layout. However, that creates somewhat unfortunate dependency cycles between `//toolchain/install` and other directories. Exacerbating this, a subsequent PR is likely to add dependencies on it from `//toolchain/base` itself that suggests that is the correct layering. This PR just moves the code mechanically with as few other edits as possible.
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
// 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 "toolchain/base/install_paths_test_helpers.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "testing/base/global_exe_path.h"
|
||||
|
||||
namespace Carbon::Testing {
|
||||
|
||||
// Prepares the VFS with prelude files from the real filesystem. Primarily for
|
||||
// tests.
|
||||
auto AddPreludeFilesToVfs(
|
||||
const InstallPaths& install_paths,
|
||||
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>& vfs) -> void {
|
||||
// Load the prelude into the test VFS.
|
||||
auto real_fs = llvm::vfs::getRealFileSystem();
|
||||
auto prelude = install_paths.ReadPreludeManifest();
|
||||
CARBON_CHECK(prelude.ok(), "{0}", prelude.error());
|
||||
|
||||
for (const auto& path : *prelude) {
|
||||
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> file =
|
||||
real_fs->getBufferForFile(path);
|
||||
CARBON_CHECK(file, "Error getting file: {0}", file.getError().message());
|
||||
bool added = vfs->addFile(path, /*ModificationTime=*/0, std::move(*file));
|
||||
CARBON_CHECK(added, "Duplicate file: {0}", path);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Carbon::Testing
|
||||
Reference in New Issue
Block a user