From 13fd7ab03f3c3e9482a7b615ad9879df76bb1a65 Mon Sep 17 00:00:00 2001 From: data-queue <144965964+data-queue@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:59:49 -0800 Subject: [PATCH] Print path to compiler in output (#1328) * print compiler path * update messages.json * fix empty message * fix format * add tests and fix * update vcpkg to latest commit * fix * fix * Fix e2e test on Windows. * Change scripts SHA to not include https://github.com/microsoft/vcpkg/pull/36056 --------- Co-authored-by: Billy Robert O'Neal III --- .../end-to-end-tests-dir/build-test-ports.ps1 | 11 ++++++++++- include/vcpkg/base/message-data.inc.h | 1 + include/vcpkg/commands.build.h | 1 + locales/messages.json | 2 ++ src/vcpkg/commands.build.cpp | 10 ++++++++++ vcpkg-init/vcpkg-scripts-sha.txt | 2 +- 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/end-to-end-tests-dir/build-test-ports.ps1 b/azure-pipelines/end-to-end-tests-dir/build-test-ports.ps1 index 9f44fb33a..937f410cc 100644 --- a/azure-pipelines/end-to-end-tests-dir/build-test-ports.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/build-test-ports.ps1 @@ -2,8 +2,17 @@ $CurrentTest = "Build Test Ports" -Run-Vcpkg @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" install vcpkg-internal-e2e-test-port3 +$output = Run-VcpkgAndCaptureOutput @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports" install vcpkg-internal-e2e-test-port3 Throw-IfFailed +if ($output -match "Compiler found: ([^\r\n]+)") { + $detected = $matches[1] + if (-Not (Test-Path $detected)) { + throw "Did not print a valid compiler path (detected $detected)" + } +} else { + throw "Did not detect a compiler" +} + $output = Run-VcpkgAndCaptureOutput @commonArgs --overlay-ports="$PSScriptRoot/../e2e-ports/vcpkg-internal-e2e-test-port2" install vcpkg-internal-e2e-test-port2 Throw-IfFailed diff --git a/include/vcpkg/base/message-data.inc.h b/include/vcpkg/base/message-data.inc.h index 49f943961..1c1aee267 100644 --- a/include/vcpkg/base/message-data.inc.h +++ b/include/vcpkg/base/message-data.inc.h @@ -866,6 +866,7 @@ DECLARE_MESSAGE(CommandFailed, "{command_line}\n" "failed with the following results:") DECLARE_MESSAGE(CommunityTriplets, (), "", "Community Triplets:") +DECLARE_MESSAGE(CompilerPath, (msg::path), "", "Compiler found: {path}") DECLARE_MESSAGE(CompressFolderFailed, (msg::path), "", "Failed to compress folder \"{path}\":") DECLARE_MESSAGE(ComputingInstallPlan, (), "", "Computing installation plan...") DECLARE_MESSAGE(ConfigurationErrorRegistriesWithoutBaseline, diff --git a/include/vcpkg/commands.build.h b/include/vcpkg/commands.build.h index 59e9b8bb3..2f6ef690d 100644 --- a/include/vcpkg/commands.build.h +++ b/include/vcpkg/commands.build.h @@ -261,6 +261,7 @@ namespace vcpkg std::string id; std::string version; std::string hash; + std::string path; }; struct AbiInfo diff --git a/locales/messages.json b/locales/messages.json index 32cadcd6d..9459bbe44 100644 --- a/locales/messages.json +++ b/locales/messages.json @@ -511,6 +511,8 @@ "CommandFailed": "command:\n{command_line}\nfailed with the following results:", "_CommandFailed.comment": "An example of {command_line} is vcpkg install zlib.", "CommunityTriplets": "Community Triplets:", + "CompilerPath": "Compiler found: {path}", + "_CompilerPath.comment": "An example of {path} is /foo/bar.", "CompressFolderFailed": "Failed to compress folder \"{path}\":", "_CompressFolderFailed.comment": "An example of {path} is /foo/bar.", "ComputingInstallPlan": "Computing installation plan...", diff --git a/src/vcpkg/commands.build.cpp b/src/vcpkg/commands.build.cpp index 80e990410..19a43a52f 100644 --- a/src/vcpkg/commands.build.cpp +++ b/src/vcpkg/commands.build.cpp @@ -678,6 +678,12 @@ namespace vcpkg { compiler_info.id = s.substr(MarkerCompilerCxxId.size()).to_string(); } + static constexpr StringLiteral s_path_marker = "#COMPILER_CXX_PATH#"; + if (Strings::starts_with(s, s_path_marker)) + { + const auto compiler_cxx_path = s.substr(s_path_marker.size()); + compiler_info.path.assign(compiler_cxx_path.data(), compiler_cxx_path.size()); + } Debug::println(s); const auto old_buf_size = buf.size(); Strings::append(buf, s, '\n'); @@ -702,6 +708,10 @@ namespace vcpkg } Debug::println("Detected compiler hash for triplet ", triplet, ": ", compiler_info.hash); + if (!compiler_info.path.empty()) + { + msg::println(msgCompilerPath, msg::path = compiler_info.path); + } return compiler_info; } diff --git a/vcpkg-init/vcpkg-scripts-sha.txt b/vcpkg-init/vcpkg-scripts-sha.txt index cbd6e9f4b..de8abfd63 100644 --- a/vcpkg-init/vcpkg-scripts-sha.txt +++ b/vcpkg-init/vcpkg-scripts-sha.txt @@ -1 +1 @@ -66b4b34d99ab272fcf21f2bd12b616e371c6bb31 +002c5b065927a6142dd7858813f25a10947094d8