From 89068dd405f68d06f0bf772b649fe043e7719d24 Mon Sep 17 00:00:00 2001 From: autoantwort <41973254+autoantwort@users.noreply.github.com> Date: Thu, 16 Jan 2025 09:48:37 +0100 Subject: [PATCH] Compiler detection: Cache compiler hash: Set compiler file hash cache variable (#1558) --- include/vcpkg/base/contractual-constants.h | 2 ++ include/vcpkg/installedpaths.h | 1 + src/vcpkg/commands.build.cpp | 2 ++ 3 files changed, 5 insertions(+) diff --git a/include/vcpkg/base/contractual-constants.h b/include/vcpkg/base/contractual-constants.h index fdb5c6cbba..0be218d064 100644 --- a/include/vcpkg/base/contractual-constants.h +++ b/include/vcpkg/base/contractual-constants.h @@ -339,6 +339,7 @@ namespace vcpkg inline constexpr StringLiteral FileBaselineDotJson = "baseline.json"; inline constexpr StringLiteral FileBin = "bin"; inline constexpr StringLiteral FileControl = "CONTROL"; + inline constexpr StringLiteral FileCompilerFileHashCacheDotJson = "compiler-file-hash-cache.json"; inline constexpr StringLiteral FileCopying = "COPYING"; inline constexpr StringLiteral FileCopyright = "copyright"; inline constexpr StringLiteral FileDebug = "debug"; @@ -377,6 +378,7 @@ namespace vcpkg inline constexpr StringLiteral CMakeVariableCMakeSystemName = "VCPKG_CMAKE_SYSTEM_NAME"; inline constexpr StringLiteral CMakeVariableCMakeSystemVersion = "VCPKG_CMAKE_SYSTEM_VERSION"; inline constexpr StringLiteral CMakeVariableCmd = "CMD"; + inline constexpr StringLiteral CMakeVariableCompilerCacheFile = "VCPKG_COMPILER_CACHE_FILE"; inline constexpr StringLiteral CMakeVariableConcurrency = "VCPKG_CONCURRENCY"; inline constexpr StringLiteral CMakeVariableCurrentBuildtreesDir = "CURRENT_BUILDTREES_DIR"; inline constexpr StringLiteral CMakeVariableCurrentPackagesDir = "CURRENT_PACKAGES_DIR"; diff --git a/include/vcpkg/installedpaths.h b/include/vcpkg/installedpaths.h index 08349eb24f..2dcb673362 100644 --- a/include/vcpkg/installedpaths.h +++ b/include/vcpkg/installedpaths.h @@ -21,6 +21,7 @@ namespace vcpkg Path vcpkg_dir_status_file() const { return vcpkg_dir() / FileStatus; } Path vcpkg_dir_info() const { return vcpkg_dir() / FileInfo; } Path vcpkg_dir_updates() const { return vcpkg_dir() / FileUpdates; } + Path compiler_hash_cache_file() const { return vcpkg_dir() / FileCompilerFileHashCacheDotJson; } Path lockfile_path() const { return vcpkg_dir() / FileVcpkgLock; } Path triplet_dir(Triplet t) const { return m_root / t.canonical_name(); } Path share_dir(const PackageSpec& p) const { return triplet_dir(p.triplet()) / FileShare / p.name(); } diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index e9e80f5686..745c6d0e13 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -695,7 +695,9 @@ namespace vcpkg paths.packages() / fmt::format("{}_{}", FileDetectCompiler, triplet.canonical_name())}, // The detect_compiler "port" doesn't depend on the host triplet, so always natively compile {CMakeVariableHostTriplet, triplet.canonical_name()}, + {CMakeVariableCompilerCacheFile, paths.installed().compiler_hash_cache_file()}, }; + get_generic_cmake_build_args(paths, triplet, toolset, cmake_args); auto cmd = vcpkg::make_cmake_cmd(paths, paths.ports_cmake, std::move(cmake_args));