aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorFrancois Rivard <30326057+RoguePointer80@users.noreply.github.com>2020-09-27 21:18:27 -0400
committerGitHub <noreply@github.com>2020-09-27 18:18:27 -0700
commit741c8cbecde77f771f8c05f00f59a436a2b4213b (patch)
tree2c77fb7d283deb47a0ad612764d6dcc243f380b9 /toolsrc/src
parent64a281b865f31cf846c1e36d635361c2eaa985f4 (diff)
downloadvcpkg-741c8cbecde77f771f8c05f00f59a436a2b4213b.tar.gz
vcpkg-741c8cbecde77f771f8c05f00f59a436a2b4213b.zip
[vcpkg] Add compiler info to nuspec description (#13571)
* Add compiler info to nuspec description * Run clang-format on some files * Fix the unit tests * [vcpkg] Clarify NuGet description to note 'CXX compiler' * [vcpkg] Fix tests Co-authored-by: frivard <frivard@coveo.com> Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg-test/binarycaching.cpp14
-rw-r--r--toolsrc/src/vcpkg/binarycaching.cpp10
-rw-r--r--toolsrc/src/vcpkg/build.cpp70
-rw-r--r--toolsrc/src/vcpkg/vcpkgpaths.cpp5
4 files changed, 86 insertions, 13 deletions
diff --git a/toolsrc/src/vcpkg-test/binarycaching.cpp b/toolsrc/src/vcpkg-test/binarycaching.cpp
index 0b529f959..33f63e2ea 100644
--- a/toolsrc/src/vcpkg-test/binarycaching.cpp
+++ b/toolsrc/src/vcpkg-test/binarycaching.cpp
@@ -88,6 +88,11 @@ Build-Depends: bzip
ipa.abi_info.get()->package_abi = "packageabi";
std::string tripletabi("tripletabi");
ipa.abi_info.get()->triplet_abi = tripletabi;
+ Build::CompilerInfo compiler_info;
+ compiler_info.hash = "compilerhash";
+ compiler_info.id = "compilerid";
+ compiler_info.version = "compilerversion";
+ ipa.abi_info.get()->compiler_info = compiler_info;
NugetReference ref(ipa);
@@ -110,6 +115,9 @@ Build-Depends: bzip
a spiffy compression library wrapper
Version: 1.5
+Triplet: x64-windows
+CXX Compiler id: compilerid
+CXX Compiler version: compilerversion
Triplet/Compiler hash: tripletabi
Features: a, b
Dependencies:
@@ -139,6 +147,9 @@ Dependencies:
a spiffy compression library wrapper
Version: 1.5
+Triplet: x64-windows
+CXX Compiler id: compilerid
+CXX Compiler version: compilerversion
Triplet/Compiler hash: tripletabi
Features: a, b
Dependencies:
@@ -168,6 +179,9 @@ Dependencies:
a spiffy compression library wrapper
Version: 1.5
+Triplet: x64-windows
+CXX Compiler id: compilerid
+CXX Compiler version: compilerversion
Triplet/Compiler hash: tripletabi
Features: a, b
Dependencies:
diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp
index 130eab3ba..4563f575e 100644
--- a/toolsrc/src/vcpkg/binarycaching.cpp
+++ b/toolsrc/src/vcpkg/binarycaching.cpp
@@ -1016,13 +1016,21 @@ std::string vcpkg::generate_nuspec(const VcpkgPaths& paths,
auto& spec = action.spec;
auto& scf = *action.source_control_file_location.value_or_exit(VCPKG_LINE_INFO).source_control_file;
auto& version = scf.core_paragraph->version;
+ const auto& abi_info = action.abi_info.value_or_exit(VCPKG_LINE_INFO);
+ const auto& compiler_info = abi_info.compiler_info.value_or_exit(VCPKG_LINE_INFO);
std::string description =
Strings::concat("NOT FOR DIRECT USE. Automatically generated cache package.\n\n",
Strings::join("\n ", scf.core_paragraph->description),
"\n\nVersion: ",
version,
+ "\nTriplet: ",
+ spec.triplet().to_string(),
+ "\nCXX Compiler id: ",
+ compiler_info.id,
+ "\nCXX Compiler version: ",
+ compiler_info.version,
"\nTriplet/Compiler hash: ",
- action.abi_info.value_or_exit(VCPKG_LINE_INFO).triplet_abi.value_or_exit(VCPKG_LINE_INFO),
+ abi_info.triplet_abi.value_or_exit(VCPKG_LINE_INFO),
"\nFeatures:",
Strings::join(",", action.feature_list, [](const std::string& s) { return " " + s; }),
"\nDependencies:\n");
diff --git a/toolsrc/src/vcpkg/build.cpp b/toolsrc/src/vcpkg/build.cpp
index a0ff09327..6952b5c3b 100644
--- a/toolsrc/src/vcpkg/build.cpp
+++ b/toolsrc/src/vcpkg/build.cpp
@@ -347,7 +347,33 @@ namespace vcpkg::Build
}
#endif
- static std::string load_compiler_hash(const VcpkgPaths& paths, const AbiInfo& abi_info);
+ static CompilerInfo load_compiler_info(const VcpkgPaths& paths, const AbiInfo& abi_info);
+
+ const CompilerInfo& EnvCache::get_compiler_info(const VcpkgPaths& paths, const AbiInfo& abi_info)
+ {
+ const auto& fs = paths.get_filesystem();
+ Checks::check_exit(VCPKG_LINE_INFO, abi_info.pre_build_info != nullptr);
+ const fs::path triplet_file_path = paths.get_triplet_file_path(abi_info.pre_build_info->triplet);
+
+ auto tcfile = abi_info.pre_build_info->toolchain_file();
+ auto&& toolchain_hash = m_toolchain_cache.get_lazy(
+ tcfile, [&]() { return Hash::get_file_hash(VCPKG_LINE_INFO, fs, tcfile, Hash::Algorithm::Sha1); });
+
+ auto&& triplet_entry = m_triplet_cache.get_lazy(triplet_file_path, [&]() -> TripletMapEntry {
+ return TripletMapEntry{Hash::get_file_hash(VCPKG_LINE_INFO, fs, triplet_file_path, Hash::Algorithm::Sha1)};
+ });
+
+ return triplet_entry.compiler_info.get_lazy(toolchain_hash, [&]() -> CompilerInfo {
+ if (m_compiler_tracking)
+ {
+ return load_compiler_info(paths, abi_info);
+ }
+ else
+ {
+ return CompilerInfo{};
+ }
+ });
+ }
const std::string& EnvCache::get_triplet_info(const VcpkgPaths& paths, const AbiInfo& abi_info)
{
@@ -366,8 +392,17 @@ namespace vcpkg::Build
return triplet_entry.compiler_hashes.get_lazy(toolchain_hash, [&]() -> std::string {
if (m_compiler_tracking)
{
- auto compiler_hash = load_compiler_hash(paths, abi_info);
- return Strings::concat(triplet_entry.hash, '-', toolchain_hash, '-', compiler_hash);
+ auto& compiler_info = triplet_entry.compiler_info.get_lazy(toolchain_hash, [&]() -> CompilerInfo {
+ if (m_compiler_tracking)
+ {
+ return load_compiler_info(paths, abi_info);
+ }
+ else
+ {
+ return CompilerInfo{};
+ }
+ });
+ return Strings::concat(triplet_entry.hash, '-', toolchain_hash, '-', compiler_info.hash);
}
else
{
@@ -464,7 +499,7 @@ namespace vcpkg::Build
}
}
- static std::string load_compiler_hash(const VcpkgPaths& paths, const AbiInfo& abi_info)
+ static CompilerInfo load_compiler_info(const VcpkgPaths& paths, const AbiInfo& abi_info)
{
auto triplet = abi_info.pre_build_info->triplet;
System::print2("Detecting compiler hash for triplet ", triplet, "...\n");
@@ -499,14 +534,24 @@ namespace vcpkg::Build
auto stdoutlog = buildpath / ("stdout-" + triplet.canonical_name() + ".log");
std::ofstream out_file(stdoutlog.native().c_str(), std::ios::out | std::ios::binary | std::ios::trunc);
Checks::check_exit(VCPKG_LINE_INFO, out_file, "Failed to open '%s' for writing", fs::u8string(stdoutlog));
- std::string compiler_hash;
+ CompilerInfo compiler_info;
System::cmd_execute_and_stream_lines(
command,
[&](const std::string& s) {
- static const StringLiteral s_marker = "#COMPILER_HASH#";
- if (Strings::starts_with(s, s_marker))
+ static const StringLiteral s_hash_marker = "#COMPILER_HASH#";
+ if (Strings::starts_with(s, s_hash_marker))
+ {
+ compiler_info.hash = s.data() + s_hash_marker.size();
+ }
+ static const StringLiteral s_version_marker = "#COMPILER_CXX_VERSION#";
+ if (Strings::starts_with(s, s_version_marker))
+ {
+ compiler_info.version = s.data() + s_version_marker.size();
+ }
+ static const StringLiteral s_id_marker = "#COMPILER_CXX_ID#";
+ if (Strings::starts_with(s, s_id_marker))
{
- compiler_hash = s.data() + s_marker.size();
+ compiler_info.id = s.data() + s_id_marker.size();
}
Debug::print(s, '\n');
out_file.write(s.data(), s.size()).put('\n');
@@ -516,7 +561,7 @@ namespace vcpkg::Build
env);
out_file.close();
- if (compiler_hash.empty())
+ if (compiler_info.hash.empty())
{
Debug::print("Compiler information tracking can be disabled by passing --",
VcpkgCmdArguments::FEATURE_FLAGS_ARG,
@@ -525,11 +570,11 @@ namespace vcpkg::Build
"\n");
}
Checks::check_exit(VCPKG_LINE_INFO,
- !compiler_hash.empty(),
+ !compiler_info.hash.empty(),
"Error occurred while detecting compiler information. Pass `--debug` for more information.");
- Debug::print("Detecting compiler hash for triplet ", triplet, ": ", compiler_hash, "\n");
- return compiler_hash;
+ Debug::print("Detecting compiler hash for triplet ", triplet, ": ", compiler_info.hash, "\n");
+ return compiler_info;
}
static std::vector<System::CMakeVariable> get_cmake_build_args(const VcpkgPaths& paths,
@@ -957,6 +1002,7 @@ namespace vcpkg::Build
abi_info.pre_build_info = std::make_unique<PreBuildInfo>(
paths, action.spec.triplet(), var_provider.get_tag_vars(action.spec).value_or_exit(VCPKG_LINE_INFO));
abi_info.toolset = paths.get_toolset(*abi_info.pre_build_info);
+ abi_info.compiler_info = paths.get_compiler_info(abi_info);
abi_info.triplet_abi = paths.get_triplet_info(abi_info);
auto maybe_abi_tag_and_file = compute_abi_tag(paths, action, dependency_abis);
diff --git a/toolsrc/src/vcpkg/vcpkgpaths.cpp b/toolsrc/src/vcpkg/vcpkgpaths.cpp
index 60403edbd..b76ed19d9 100644
--- a/toolsrc/src/vcpkg/vcpkgpaths.cpp
+++ b/toolsrc/src/vcpkg/vcpkgpaths.cpp
@@ -555,6 +555,11 @@ If you wish to silence this error and use classic mode, you can:
return m_pimpl->m_env_cache.get_triplet_info(*this, abi_info);
}
+ const Build::CompilerInfo& VcpkgPaths::get_compiler_info(const Build::AbiInfo& abi_info) const
+ {
+ return m_pimpl->m_env_cache.get_compiler_info(*this, abi_info);
+ }
+
Files::Filesystem& VcpkgPaths::get_filesystem() const { return *m_pimpl->fs_ptr; }
void VcpkgPaths::track_feature_flag_metrics() const