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:
Chandler Carruth
2025-12-03 17:14:34 +00:00
committed by GitHub
parent 4ddff65e8e
commit 5d0d443c98
31 changed files with 108 additions and 108 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ filegroup(
)
# A list of prelude inputs.
# This is consumed by //toolchain/install:install_paths.
# This is consumed by //toolchain/base:install_paths.
manifest(
name = "prelude_manifest.txt",
srcs = [":prelude_files"],
+1 -1
View File
@@ -82,8 +82,8 @@ cc_test(
":source_gen_lib",
"//common:all_llvm_targets",
"//common:set",
"//toolchain/base:install_paths_test_helpers",
"//toolchain/driver",
"//toolchain/install:install_paths_test_helpers",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
+1 -1
View File
@@ -11,8 +11,8 @@
#include "common/set.h"
#include "testing/base/global_exe_path.h"
#include "toolchain/base/install_paths_test_helpers.h"
#include "toolchain/driver/driver.h"
#include "toolchain/install/install_paths_test_helpers.h"
namespace Carbon::Testing {
namespace {
+1 -1
View File
@@ -11,7 +11,7 @@ cc_library(
visibility = ["//visibility:public"],
deps = [
"//common:check",
"//toolchain/install:install_paths",
"//toolchain/base:install_paths",
"@llvm-project//clang:basic",
"@llvm-project//clang:codegen",
"@llvm-project//clang:frontend",
+1 -1
View File
@@ -31,7 +31,7 @@
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/Timer.h"
#include "llvm/Support/raw_ostream.h"
#include "toolchain/install/install_paths.h"
#include "toolchain/base/install_paths.h"
namespace Carbon {
+1 -1
View File
@@ -8,7 +8,7 @@
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "toolchain/install/install_paths.h"
#include "toolchain/base/install_paths.h"
namespace Carbon {
+61 -1
View File
@@ -2,7 +2,7 @@
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
load("//bazel/cc_rules:defs.bzl", "cc_library", "cc_test")
load("//bazel/cc_rules:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("llvm_tools.bzl", "LLVM_MAIN_TOOLS", "generate_llvm_tools_def")
load("runtime_sources.bzl", "generate_runtime_sources_cc_library")
@@ -90,6 +90,66 @@ cc_library(
],
)
# A library for computing install paths for the toolchain. Note that this
# library does *not* include the data itself, as that would form a dependency
# cycle. Each part of the toolchain should add the narrow data file groups to
# their data dependencies, and then use this library to locate them.
cc_library(
name = "install_paths",
srcs = ["install_paths.cpp"],
hdrs = ["install_paths.h"],
deps = [
":llvm_tools",
"//common:check",
"//common:error",
"//common:filesystem",
"@bazel_tools//tools/cpp/runfiles",
"@llvm-project//clang:basic",
"@llvm-project//llvm:Support",
],
)
cc_binary(
name = "test_binary",
testonly = 1,
srcs = ["test_binary.cpp"],
data = ["//toolchain/install:install_data"],
)
cc_test(
name = "install_paths_test",
size = "small",
srcs = ["install_paths_test.cpp"],
data = [
":test_binary",
"//toolchain/install:install_data",
],
deps = [
":install_paths",
"//common:check",
"//common:error_test_helpers",
"//common:filesystem",
"//common:ostream",
"//testing/base:global_exe_path",
"//testing/base:gtest_main",
"@bazel_tools//tools/cpp/runfiles",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "install_paths_test_helpers",
testonly = 1,
srcs = ["install_paths_test_helpers.cpp"],
hdrs = ["install_paths_test_helpers.h"],
deps = [
":install_paths",
"//testing/base:global_exe_path",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "kind_switch",
hdrs = ["kind_switch.h"],
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/install/install_paths.h"
#include "toolchain/base/install_paths.h"
#include <filesystem>
#include <memory>
@@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_INSTALL_INSTALL_PATHS_H_
#define CARBON_TOOLCHAIN_INSTALL_INSTALL_PATHS_H_
#ifndef CARBON_TOOLCHAIN_BASE_INSTALL_PATHS_H_
#define CARBON_TOOLCHAIN_BASE_INSTALL_PATHS_H_
#include <filesystem>
@@ -183,4 +183,4 @@ class InstallPaths {
} // namespace Carbon
#endif // CARBON_TOOLCHAIN_INSTALL_INSTALL_PATHS_H_
#endif // CARBON_TOOLCHAIN_BASE_INSTALL_PATHS_H_
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/install/install_paths.h"
#include "toolchain/base/install_paths.h"
#include <gmock/gmock.h>
#include <gtest/gtest.h>
@@ -121,7 +121,7 @@ TEST_F(InstallPathsTest, TestRunfiles) {
TEST_F(InstallPathsTest, BinaryRunfiles) {
std::filesystem::path test_binary_path =
test_runfiles_->Rlocation("carbon/toolchain/install/test_binary");
test_runfiles_->Rlocation("carbon/toolchain/base/test_binary");
ASSERT_THAT(Filesystem::Cwd().Access(test_binary_path,
Filesystem::AccessCheckFlags::Execute),
IsSuccess(Eq(true)))
@@ -2,7 +2,7 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/install/install_paths_test_helpers.h"
#include "toolchain/base/install_paths_test_helpers.h"
#include <memory>
#include <utility>
@@ -2,11 +2,11 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_INSTALL_INSTALL_PATHS_TEST_HELPERS_H_
#define CARBON_TOOLCHAIN_INSTALL_INSTALL_PATHS_TEST_HELPERS_H_
#ifndef CARBON_TOOLCHAIN_BASE_INSTALL_PATHS_TEST_HELPERS_H_
#define CARBON_TOOLCHAIN_BASE_INSTALL_PATHS_TEST_HELPERS_H_
#include "llvm/Support/VirtualFileSystem.h"
#include "toolchain/install/install_paths.h"
#include "toolchain/base/install_paths.h"
namespace Carbon::Testing {
@@ -17,4 +17,4 @@ auto AddPreludeFilesToVfs(
} // namespace Carbon::Testing
#endif // CARBON_TOOLCHAIN_INSTALL_INSTALL_PATHS_TEST_HELPERS_H_
#endif // CARBON_TOOLCHAIN_BASE_INSTALL_PATHS_TEST_HELPERS_H_
+11 -11
View File
@@ -38,9 +38,9 @@ cc_library(
"//common:ostream",
"//common:vlog",
"//third_party/llvm:clang_cc1",
"//toolchain/base:install_paths",
"//toolchain/base:kind_switch",
"//toolchain/base:runtime_sources",
"//toolchain/install:install_paths",
"@llvm-project//clang:basic",
"@llvm-project//clang:clang-driver",
"@llvm-project//clang:codegen",
@@ -72,7 +72,7 @@ cc_test(
"//testing/base:file_helpers",
"//testing/base:global_exe_path",
"//testing/base:gtest_main",
"//toolchain/install:install_paths",
"//toolchain/base:install_paths",
"@googletest//:gtest",
"@llvm-project//llvm:Object",
"@llvm-project//llvm:Support",
@@ -97,8 +97,8 @@ cc_test(
"//testing/base:file_helpers",
"//testing/base:global_exe_path",
"//testing/base:gtest_main",
"//toolchain/base:install_paths",
"//toolchain/base:llvm_tools",
"//toolchain/install:install_paths",
"@googletest//:gtest",
"@llvm-project//llvm:Object",
"@llvm-project//llvm:Support",
@@ -116,7 +116,7 @@ cc_binary(
"//testing/base:benchmark_main",
"//testing/base:global_exe_path",
"//testing/base:source_gen_lib",
"//toolchain/install:install_paths_test_helpers",
"//toolchain/base:install_paths_test_helpers",
"//toolchain/testing:compile_helper",
"@google_benchmark//:benchmark",
"@llvm-project//llvm:Support",
@@ -181,6 +181,7 @@ cc_library(
"//common:version",
"//common:vlog",
"//toolchain/base:clang_invocation",
"//toolchain/base:install_paths",
"//toolchain/base:llvm_tools",
"//toolchain/base:shared_value_stores",
"//toolchain/base:timings",
@@ -189,7 +190,6 @@ cc_library(
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:sorting_diagnostic_consumer",
"//toolchain/format",
"//toolchain/install:install_paths",
"//toolchain/language_server",
"//toolchain/lex",
"//toolchain/lower",
@@ -218,8 +218,8 @@ cc_test(
"//testing/base:file_helpers",
"//testing/base:global_exe_path",
"//testing/base:gtest_main",
"//toolchain/base:install_paths",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/install:install_paths",
"//toolchain/lex:tokenized_buffer_test_helpers",
"//toolchain/testing:yaml_test_helpers",
"@googletest//:gtest",
@@ -238,7 +238,7 @@ cc_fuzz_test(
"//common:exe_path",
"//common:raw_string_ostream",
"//testing/fuzzing:libfuzzer_header",
"//toolchain/install:install_paths",
"//toolchain/base:install_paths",
"@llvm-project//llvm:Support",
],
)
@@ -251,7 +251,7 @@ cc_library(
":tool_runner_base",
"//common:ostream",
"//common:vlog",
"//toolchain/install:install_paths",
"//toolchain/base:install_paths",
"@llvm-project//lld:Common",
"@llvm-project//lld:ELF",
"@llvm-project//lld:MachO",
@@ -289,8 +289,8 @@ cc_library(
":tool_runner_base",
"//common:ostream",
"//common:vlog",
"//toolchain/base:install_paths",
"//toolchain/base:llvm_tools",
"//toolchain/install:install_paths",
"@llvm-project//lld:Common",
"@llvm-project//lld:ELF",
"@llvm-project//lld:MachO",
@@ -326,7 +326,7 @@ cc_library(
"//common:ostream",
"//common:version",
"//common:vlog",
"//toolchain/install:install_paths",
"//toolchain/base:install_paths",
"@llvm-project//llvm:Support",
],
)
@@ -363,7 +363,7 @@ cc_library(
deps = [
"//common:ostream",
"//common:vlog",
"//toolchain/install:install_paths",
"//toolchain/base:install_paths",
"@llvm-project//llvm:Support",
],
)
+1 -1
View File
@@ -50,10 +50,10 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "third_party/llvm/clang_cc1.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/driver/clang_runtimes.h"
#include "toolchain/driver/runtimes_cache.h"
#include "toolchain/driver/tool_runner_base.h"
#include "toolchain/install/install_paths.h"
// Defined in:
// https://github.com/llvm/llvm-project/blob/main/clang/tools/driver/driver.cpp
+1 -1
View File
@@ -17,9 +17,9 @@
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/Triple.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/driver/runtimes_cache.h"
#include "toolchain/driver/tool_runner_base.h"
#include "toolchain/install/install_paths.h"
namespace Carbon {
+1 -1
View File
@@ -22,8 +22,8 @@
#include "testing/base/capture_std_streams.h"
#include "testing/base/file_helpers.h"
#include "testing/base/global_exe_path.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/driver/runtimes_cache.h"
#include "toolchain/install/install_paths.h"
namespace Carbon {
namespace {
+1 -1
View File
@@ -23,9 +23,9 @@
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/Triple.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/driver/clang_runner.h"
#include "toolchain/driver/runtimes_cache.h"
#include "toolchain/install/install_paths.h"
namespace Carbon {
+1 -1
View File
@@ -24,11 +24,11 @@
#include "llvm/TargetParser/Triple.h"
#include "testing/base/capture_std_streams.h"
#include "testing/base/global_exe_path.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/base/llvm_tools.h"
#include "toolchain/driver/clang_runner.h"
#include "toolchain/driver/llvm_runner.h"
#include "toolchain/driver/runtimes_cache.h"
#include "toolchain/install/install_paths.h"
namespace Carbon {
namespace {
+1 -1
View File
@@ -9,8 +9,8 @@
#include "testing/base/global_exe_path.h"
#include "testing/base/source_gen.h"
#include "toolchain/base/install_paths_test_helpers.h"
#include "toolchain/driver/driver.h"
#include "toolchain/install/install_paths_test_helpers.h"
#include "toolchain/testing/compile_helper.h"
namespace Carbon::Testing {
+1 -1
View File
@@ -12,9 +12,9 @@
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/driver/runtimes_cache.h"
#include "toolchain/install/install_paths.h"
namespace Carbon {
+1 -1
View File
@@ -11,8 +11,8 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/raw_ostream.h"
#include "testing/fuzzing/libfuzzer.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/driver/driver.h"
#include "toolchain/install/install_paths.h"
namespace Carbon::Testing {
+1 -1
View File
@@ -8,8 +8,8 @@
#include "common/command_line.h"
#include "common/ostream.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/driver/driver_env.h"
#include "toolchain/install/install_paths.h"
namespace Carbon {
+1 -1
View File
@@ -9,8 +9,8 @@
#include "lld/Common/Driver.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/driver/tool_runner_base.h"
#include "toolchain/install/install_paths.h"
namespace Carbon {
+1 -1
View File
@@ -15,7 +15,7 @@
#include "common/ostream.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "toolchain/install/install_paths.h"
#include "toolchain/base/install_paths.h"
namespace Carbon {
+1 -1
View File
@@ -10,7 +10,7 @@
#include "common/ostream.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "toolchain/install/install_paths.h"
#include "toolchain/base/install_paths.h"
namespace Carbon {
+2 -62
View File
@@ -22,66 +22,6 @@ package(default_visibility = ["//visibility:public"])
# This populates a synthetic Carbon toolchain installation under the
# `prefix_root` directory. For details on its layout, see `install_dirs` below.
# A library for computing install paths for the toolchain. Note that this
# library does *not* include the data itself, as that would form a dependency
# cycle. Each part of the toolchain should add the narrow data file groups to
# their data dependencies, and then use this library to locate them.
cc_library(
name = "install_paths",
srcs = ["install_paths.cpp"],
hdrs = ["install_paths.h"],
deps = [
"//common:check",
"//common:error",
"//common:filesystem",
"//toolchain/base:llvm_tools",
"@bazel_tools//tools/cpp/runfiles",
"@llvm-project//clang:basic",
"@llvm-project//llvm:Support",
],
)
cc_binary(
name = "test_binary",
testonly = 1,
srcs = ["test_binary.cpp"],
data = [":install_data"],
)
cc_test(
name = "install_paths_test",
size = "small",
srcs = ["install_paths_test.cpp"],
data = [
":install_data",
":test_binary",
],
deps = [
":install_paths",
"//common:check",
"//common:error_test_helpers",
"//common:filesystem",
"//common:ostream",
"//testing/base:global_exe_path",
"//testing/base:gtest_main",
"@bazel_tools//tools/cpp/runfiles",
"@googletest//:gtest",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "install_paths_test_helpers",
testonly = 1,
srcs = ["install_paths_test_helpers.cpp"],
hdrs = ["install_paths_test_helpers.h"],
deps = [
":install_paths",
"//testing/base:global_exe_path",
"@llvm-project//llvm:Support",
],
)
cc_library(
name = "busybox_info",
srcs = ["busybox_info.cpp"],
@@ -115,13 +55,13 @@ cc_binary(
srcs = ["busybox_main.cpp"],
deps = [
":busybox_info",
":install_paths",
"//common:all_llvm_targets",
"//common:bazel_working_dir",
"//common:error",
"//common:exe_path",
"//common:init_llvm",
"//common:version_stamp",
"//toolchain/base:install_paths",
"//toolchain/base:llvm_tools_def",
"//toolchain/driver",
"@llvm-project//llvm:Support",
@@ -450,7 +390,6 @@ cc_binary(
name = "make-installation-digest",
srcs = ["make_installation_digest.cpp"],
deps = [
":install_paths",
"//common:bazel_working_dir",
"//common:error",
"//common:exe_path",
@@ -458,6 +397,7 @@ cc_binary(
"//common:init_llvm",
"//common:map",
"//common:vlog",
"//toolchain/base:install_paths",
"@llvm-project//llvm:Support",
],
)
+1 -1
View File
@@ -13,9 +13,9 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/LLVMDriver.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/driver/driver.h"
#include "toolchain/install/busybox_info.h"
#include "toolchain/install/install_paths.h"
namespace Carbon {
+2 -2
View File
@@ -21,8 +21,8 @@ cc_library(
":outgoing_messages",
"//common:ostream",
"//common:raw_string_ostream",
"//toolchain/base:install_paths",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/install:install_paths",
"@llvm-project//clang-tools-extra/clangd:ClangDaemon",
],
)
@@ -36,11 +36,11 @@ cc_library(
"//common:map",
"//common:raw_string_ostream",
"//toolchain/base:clang_invocation",
"//toolchain/base:install_paths",
"//toolchain/base:shared_value_stores",
"//toolchain/check",
"//toolchain/diagnostics:diagnostic_emitter",
"//toolchain/diagnostics:file_diagnostics",
"//toolchain/install:install_paths",
"//toolchain/lex",
"//toolchain/lex:tokenized_buffer",
"//toolchain/parse",
+1 -1
View File
@@ -10,11 +10,11 @@
#include "clang-tools-extra/clangd/LSPBinder.h"
#include "common/map.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/diagnostics/file_diagnostics.h"
#include "toolchain/install/install_paths.h"
#include "toolchain/lex/tokenized_buffer.h"
#include "toolchain/parse/tree_and_subtrees.h"
#include "toolchain/sem_ir/file.h"
+1 -1
View File
@@ -6,8 +6,8 @@
#define CARBON_TOOLCHAIN_LANGUAGE_SERVER_LANGUAGE_SERVER_H_
#include "common/ostream.h"
#include "toolchain/base/install_paths.h"
#include "toolchain/diagnostics/diagnostic_consumer.h"
#include "toolchain/install/install_paths.h"
namespace Carbon::LanguageServer {