diff options
| author | ras0219 <robertallenschumacher@gmail.com> | 2020-06-22 14:14:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-22 14:14:36 -0700 |
| commit | aef838536ea3a08e3c1030ead553ca6456cc7fe3 (patch) | |
| tree | 37f6b5437b0cbb2b5a3111a8fee391b9f0994297 /toolsrc/include | |
| parent | 2bf1f30debfac3f55c887855d82abd008f786a1a (diff) | |
| download | vcpkg-aef838536ea3a08e3c1030ead553ca6456cc7fe3.tar.gz vcpkg-aef838536ea3a08e3c1030ead553ca6456cc7fe3.zip | |
[vcpkg] Track compiler information in ABI (#11654)
* [vcpkg] Refactor out abi_tags_from_pre_build_info()
* [vcpkg] Track Windows toolchain file in triplet hash
* [vcpkg] Improve error messages when constructing PreBuildInfo
* [vcpkg] Extract InstallPlanAction::BuildAbiInfo
* [vcpkg] Extract Build::EnvCache and private-impl VcpkgPaths
* [vcpkg] Enable compiler hash detection when binarycaching is enabled
* [vcpkg] Downgrade warning about missing ABI keys
When binarycaching is not enabled, this warning is spurious and provides no user value.
* [vcpkg] Cleanup
* [vcpkg] Refactor compiler tracking into triplet abi computation
Move several static global caches into VcpkgPaths/EnvCache.
Add feature flag 'compilertracking' to enable the new feature.
* [vcpkg] Refactor out PreBuildInfo::using_vcvars()
Move VcpkgTripletVar into build.cpp because it is not used outside that file.
* [vcpkg] Address some code analysis warnings
Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/include')
| -rw-r--r-- | toolsrc/include/vcpkg/base/expected.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/pragmas.h | 6 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/base/util.h | 5 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/binarycaching.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/build.h | 94 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/dependencies.h | 5 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/export.prefab.h | 4 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgcmdarguments.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg/vcpkgpaths.h | 32 |
9 files changed, 88 insertions, 64 deletions
diff --git a/toolsrc/include/vcpkg/base/expected.h b/toolsrc/include/vcpkg/base/expected.h index 88b09fdb2..ff60149ac 100644 --- a/toolsrc/include/vcpkg/base/expected.h +++ b/toolsrc/include/vcpkg/base/expected.h @@ -10,7 +10,7 @@ namespace vcpkg template<class Err> struct ErrorHolder { - ErrorHolder() : m_is_error(false) {} + ErrorHolder() : m_is_error(false), m_err{} {} template<class U> ErrorHolder(U&& err) : m_is_error(true), m_err(std::forward<U>(err)) { diff --git a/toolsrc/include/vcpkg/base/pragmas.h b/toolsrc/include/vcpkg/base/pragmas.h index 97d01955e..73f14c4b2 100644 --- a/toolsrc/include/vcpkg/base/pragmas.h +++ b/toolsrc/include/vcpkg/base/pragmas.h @@ -19,8 +19,10 @@ #include <sal.h> #endif -#ifndef _Analysis_assume_ -#define _Analysis_assume_(...) +#if defined(_MSC_VER) +#define ASSUME(expr) __assume(expr) +#else +#define ASSUME(expr) #endif #ifdef _MSC_VER diff --git a/toolsrc/include/vcpkg/base/util.h b/toolsrc/include/vcpkg/base/util.h index 849781b95..89f2c51d6 100644 --- a/toolsrc/include/vcpkg/base/util.h +++ b/toolsrc/include/vcpkg/base/util.h @@ -22,6 +22,11 @@ namespace vcpkg::Util { augend->insert(augend->end(), addend.begin(), addend.end()); } + template<class Vec, class Key> + bool contains(const Vec& container, const Key& item) + { + return std::find(container.begin(), container.end(), item) != container.end(); + } } namespace Sets diff --git a/toolsrc/include/vcpkg/binarycaching.h b/toolsrc/include/vcpkg/binarycaching.h index 69e3287d6..88f529c22 100644 --- a/toolsrc/include/vcpkg/binarycaching.h +++ b/toolsrc/include/vcpkg/binarycaching.h @@ -36,6 +36,8 @@ namespace vcpkg bool purge_tombstones) = 0;
};
+ IBinaryProvider& null_binary_provider();
+
ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs(const VcpkgPaths& paths,
View<std::string> args);
ExpectedS<std::unique_ptr<IBinaryProvider>> create_binary_provider_from_configs_pure(const std::string& env_string,
diff --git a/toolsrc/include/vcpkg/build.h b/toolsrc/include/vcpkg/build.h index 864317fb9..68cfd7d23 100644 --- a/toolsrc/include/vcpkg/build.h +++ b/toolsrc/include/vcpkg/build.h @@ -10,6 +10,7 @@ #include <vcpkg/base/cstringview.h> #include <vcpkg/base/files.h> #include <vcpkg/base/optional.h> +#include <vcpkg/base/system.process.h> #include <array> #include <map> @@ -27,6 +28,11 @@ namespace vcpkg::Dependencies struct ActionPlan; } +namespace vcpkg::System +{ + struct Environment; +} + namespace vcpkg::Build { namespace Command @@ -34,7 +40,6 @@ namespace vcpkg::Build void perform_and_exit_ex(const FullPackageSpec& full_spec, const SourceControlFileLocation& scfl, const PortFileProvider::PathsPortFileProvider& provider, - const bool binary_caching_enabled, IBinaryProvider& binaryprovider, const VcpkgPaths& paths); @@ -90,12 +95,6 @@ namespace vcpkg::Build }; const std::string& to_string(DownloadTool tool); - enum class BinaryCaching - { - NO = 0, - YES - }; - enum class FailOnTombstone { NO = 0, @@ -117,7 +116,6 @@ namespace vcpkg::Build CleanPackages clean_packages; CleanDownloads clean_downloads; DownloadTool download_tool; - BinaryCaching binary_caching; FailOnTombstone fail_on_tombstone; PurgeDecompressFailure purge_decompress_failure; }; @@ -149,14 +147,14 @@ namespace vcpkg::Build /// <summary> /// Settings from the triplet file which impact the build environment and post-build checks /// </summary> - struct PreBuildInfo + struct PreBuildInfo : Util::ResourceBase { PreBuildInfo(const VcpkgPaths& paths, Triplet triplet, const std::unordered_map<std::string, std::string>& cmakevars); - bool load_vcvars_env; - std::string triplet_abi_tag; + Triplet triplet; + bool load_vcvars_env = false; std::string target_architecture; std::string cmake_system_name; std::string cmake_system_version; @@ -165,38 +163,16 @@ namespace vcpkg::Build Optional<std::string> external_toolchain_file; Optional<ConfigurationType> build_type; Optional<std::string> public_abi_override; - Optional<const SourceControlFileLocation&> port; std::vector<std::string> passthrough_env_vars; - }; - std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset); + fs::path toolchain_file() const; + bool using_vcvars() const; - enum class VcpkgTripletVar - { - TARGET_ARCHITECTURE = 0, - CMAKE_SYSTEM_NAME, - CMAKE_SYSTEM_VERSION, - PLATFORM_TOOLSET, - VISUAL_STUDIO_PATH, - CHAINLOAD_TOOLCHAIN_FILE, - BUILD_TYPE, - ENV_PASSTHROUGH, - PUBLIC_ABI_OVERRIDE, - LOAD_VCVARS_ENV, + private: + const VcpkgPaths& m_paths; }; - const std::unordered_map<std::string, VcpkgTripletVar> VCPKG_OPTIONS = { - {"VCPKG_TARGET_ARCHITECTURE", VcpkgTripletVar::TARGET_ARCHITECTURE}, - {"VCPKG_CMAKE_SYSTEM_NAME", VcpkgTripletVar::CMAKE_SYSTEM_NAME}, - {"VCPKG_CMAKE_SYSTEM_VERSION", VcpkgTripletVar::CMAKE_SYSTEM_VERSION}, - {"VCPKG_PLATFORM_TOOLSET", VcpkgTripletVar::PLATFORM_TOOLSET}, - {"VCPKG_VISUAL_STUDIO_PATH", VcpkgTripletVar::VISUAL_STUDIO_PATH}, - {"VCPKG_CHAINLOAD_TOOLCHAIN_FILE", VcpkgTripletVar::CHAINLOAD_TOOLCHAIN_FILE}, - {"VCPKG_BUILD_TYPE", VcpkgTripletVar::BUILD_TYPE}, - {"VCPKG_ENV_PASSTHROUGH", VcpkgTripletVar::ENV_PASSTHROUGH}, - {"VCPKG_PUBLIC_ABI_OVERRIDE", VcpkgTripletVar::PUBLIC_ABI_OVERRIDE}, - {"VCPKG_LOAD_VCVARS_ENV", VcpkgTripletVar::LOAD_VCVARS_ENV}, - }; + std::string make_build_env_cmd(const PreBuildInfo& pre_build_info, const Toolset& toolset); struct ExtendedBuildResult { @@ -238,8 +214,7 @@ namespace vcpkg::Build BuildPolicy::ALLOW_OBSOLETE_MSVCRT, BuildPolicy::ALLOW_RESTRICTED_HEADERS, BuildPolicy::SKIP_DUMPBIN_CHECKS, - BuildPolicy::SKIP_ARCHITECTURE_CHECK - }; + BuildPolicy::SKIP_ARCHITECTURE_CHECK}; const std::string& to_string(BuildPolicy policy); CStringView to_cmake_variable(BuildPolicy policy); @@ -300,12 +275,45 @@ namespace vcpkg::Build fs::path tag_file; }; + struct AbiInfo + { + std::unique_ptr<PreBuildInfo> pre_build_info; + const Toolset* toolset; + std::string package_abi; + Optional<fs::path> abi_tag_file; + }; + void compute_all_abis(const VcpkgPaths& paths, Dependencies::ActionPlan& action_plan, const CMakeVars::CMakeVarProvider& var_provider, const StatusParagraphs& status_db); - Optional<AbiTagAndFile> compute_abi_tag(const VcpkgPaths& paths, - const Dependencies::InstallPlanAction& config, - Span<const AbiEntry> dependency_abis); + struct EnvCache + { + explicit EnvCache(bool compiler_tracking) : m_compiler_tracking(compiler_tracking) {} + + const System::Environment& get_action_env(const VcpkgPaths& paths, const AbiInfo& abi_info); + const std::string& get_triplet_info(const VcpkgPaths& paths, const AbiInfo& abi_info); + + private: + struct TripletMapEntry + { + std::string hash; + Cache<std::string, std::string> compiler_hashes; + }; + Cache<fs::path, TripletMapEntry> m_triplet_cache; + Cache<fs::path, std::string> m_toolchain_cache; + +#if defined(_WIN32) + struct EnvMapEntry + { + std::unordered_map<std::string, std::string> env_map; + Cache<std::string, System::Environment> cmd_cache; + }; + + Cache<std::vector<std::string>, EnvMapEntry> envs; +#endif + + bool m_compiler_tracking; + }; } diff --git a/toolsrc/include/vcpkg/dependencies.h b/toolsrc/include/vcpkg/dependencies.h index d2eca4408..7b1696dc3 100644 --- a/toolsrc/include/vcpkg/dependencies.h +++ b/toolsrc/include/vcpkg/dependencies.h @@ -55,6 +55,7 @@ namespace vcpkg::Dependencies std::string displayname() const; const std::string& public_abi() const; + const Build::PreBuildInfo& pre_build_info(LineInfo linfo) const; PackageSpec spec; @@ -69,9 +70,7 @@ namespace vcpkg::Dependencies std::vector<PackageSpec> package_dependencies; std::vector<std::string> feature_list; - Optional<std::unique_ptr<Build::PreBuildInfo>> pre_build_info; - Optional<std::string> package_abi; - Optional<fs::path> abi_tag_file; + Optional<Build::AbiInfo> abi_info; }; enum class RemovePlanType diff --git a/toolsrc/include/vcpkg/export.prefab.h b/toolsrc/include/vcpkg/export.prefab.h index 56a5ba371..cf9f940f9 100644 --- a/toolsrc/include/vcpkg/export.prefab.h +++ b/toolsrc/include/vcpkg/export.prefab.h @@ -18,8 +18,8 @@ namespace vcpkg::Export::Prefab Optional<std::string> maybe_version; Optional<std::string> maybe_min_sdk; Optional<std::string> maybe_target_sdk; - bool enable_maven; - bool enable_debug; + bool enable_maven = false; + bool enable_debug = false; }; struct NdkVersion { diff --git a/toolsrc/include/vcpkg/vcpkgcmdarguments.h b/toolsrc/include/vcpkg/vcpkgcmdarguments.h index e4ed0471b..378aa9703 100644 --- a/toolsrc/include/vcpkg/vcpkgcmdarguments.h +++ b/toolsrc/include/vcpkg/vcpkgcmdarguments.h @@ -130,7 +130,9 @@ namespace vcpkg // feature flags Optional<bool> feature_packages = nullopt; Optional<bool> binary_caching = nullopt; + Optional<bool> compiler_tracking = nullopt; bool binary_caching_enabled() const { return binary_caching.value_or(false); } + bool compiler_tracking_enabled() const { return compiler_tracking.value_or(false); } std::string command; std::vector<std::string> command_arguments; diff --git a/toolsrc/include/vcpkg/vcpkgpaths.h b/toolsrc/include/vcpkg/vcpkgpaths.h index 38a9d4e4d..c4c420820 100644 --- a/toolsrc/include/vcpkg/vcpkgpaths.h +++ b/toolsrc/include/vcpkg/vcpkgpaths.h @@ -6,9 +6,10 @@ #include <vcpkg/vcpkgcmdarguments.h> #include <vcpkg/base/cache.h> -#include <vcpkg/base/expected.h> #include <vcpkg/base/files.h> #include <vcpkg/base/lazy.h> +#include <vcpkg/base/optional.h> +#include <vcpkg/base/util.h> namespace vcpkg { @@ -46,9 +47,20 @@ namespace vcpkg namespace Build { struct PreBuildInfo; + struct AbiInfo; } - struct VcpkgPaths + namespace System + { + struct Environment; + } + + namespace details + { + struct VcpkgPathsImpl; + } + + struct VcpkgPaths : Util::MoveOnlyBase { struct TripletFile { @@ -59,6 +71,7 @@ namespace vcpkg }; VcpkgPaths(Files::Filesystem& filesystem, const VcpkgCmdArguments& args); + ~VcpkgPaths() noexcept; fs::path package_dir(const PackageSpec& spec) const; fs::path build_info_file_path(const PackageSpec& spec) const; @@ -105,17 +118,10 @@ namespace vcpkg Files::Filesystem& get_filesystem() const; - private: - Lazy<std::vector<TripletFile>> available_triplets; - Lazy<std::vector<Toolset>> toolsets; - Lazy<std::vector<Toolset>> toolsets_vs2013; - - fs::path default_vs_path; - std::vector<fs::path> triplets_dirs; + const System::Environment& get_action_env(const Build::AbiInfo& abi_info) const; + const std::string& get_triplet_info(const Build::AbiInfo& abi_info) const; - Files::Filesystem* fsPtr; - - mutable std::unique_ptr<ToolCache> m_tool_cache; - mutable vcpkg::Cache<Triplet, fs::path> m_triplets_cache; + private: + std::unique_ptr<details::VcpkgPathsImpl> m_pimpl; }; } |
