From 5fd5d5c2b7cf7d95eebf983067972ae2feb11bc0 Mon Sep 17 00:00:00 2001 From: dmn-star Date: Sat, 10 Feb 2024 11:45:16 +0100 Subject: [PATCH 1/5] Skip the emscripten cmake script execution. microsoft/vcpkg#12359 --- src/vcpkg/export.prefab.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vcpkg/export.prefab.cpp b/src/vcpkg/export.prefab.cpp index 8a08f72ecf..be003e7e78 100644 --- a/src/vcpkg/export.prefab.cpp +++ b/src/vcpkg/export.prefab.cpp @@ -281,8 +281,12 @@ namespace vcpkg::Prefab for (const auto& triplet_file : triplet_db.available_triplets) { - if (triplet_file.name.size() > 0) + if (!triplet_file.name.empty()) { + //The execution of emscripten cmake script causes the prefab export to fail. + //But here we don't need this execution at all so we skip it. + if (triplet_file.name == "wasm32-emscripten") continue; + Triplet triplet = Triplet::from_canonical_name(triplet_file.name); auto triplet_build_info = build_info_from_triplet(paths, provider, triplet); if (is_supported(*triplet_build_info)) From 5c4df5ebac7eceb5c3688898a8af2d4b982a0c25 Mon Sep 17 00:00:00 2001 From: dmn-star Date: Sat, 10 Feb 2024 12:16:39 +0100 Subject: [PATCH 2/5] Host-only ports (e.g. vcpkg_cmake) are not to be exported. microsoft/vcpkg#35538 --- include/vcpkg/export.prefab.h | 3 ++- src/vcpkg/commands.export.cpp | 2 +- src/vcpkg/export.prefab.cpp | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/vcpkg/export.prefab.h b/include/vcpkg/export.prefab.h index 1a7ea00092..ef1bfd56ae 100644 --- a/include/vcpkg/export.prefab.h +++ b/include/vcpkg/export.prefab.h @@ -88,7 +88,8 @@ namespace vcpkg::Prefab void do_export(const std::vector& export_plan, const VcpkgPaths& paths, const Options& prefab_options, - const Triplet& triplet); + const Triplet& triplet, + const Triplet& host_triplet); Optional find_ndk_version(StringView content); Optional to_version(StringView version); } diff --git a/src/vcpkg/commands.export.cpp b/src/vcpkg/commands.export.cpp index e44af7a404..43280d8852 100644 --- a/src/vcpkg/commands.export.cpp +++ b/src/vcpkg/commands.export.cpp @@ -702,7 +702,7 @@ namespace vcpkg if (opts.prefab) { - Prefab::do_export(export_plan, paths, opts.prefab_options, default_triplet); + Prefab::do_export(export_plan, paths, opts.prefab_options, default_triplet, host_triplet); } Checks::exit_success(VCPKG_LINE_INFO); diff --git a/src/vcpkg/export.prefab.cpp b/src/vcpkg/export.prefab.cpp index be003e7e78..2df7cb31ff 100644 --- a/src/vcpkg/export.prefab.cpp +++ b/src/vcpkg/export.prefab.cpp @@ -253,7 +253,8 @@ namespace vcpkg::Prefab void do_export(const std::vector& export_plan, const VcpkgPaths& paths, const Options& prefab_options, - const Triplet& default_triplet) + const Triplet& default_triplet, + const Triplet& host_triplet) { auto provider = CMakeVars::make_triplet_cmake_var_provider(paths); @@ -376,6 +377,10 @@ namespace vcpkg::Prefab for (const auto& action : export_plan) { + //cross-compiling + //Host-only ports (e.g. vcpkg_cmake) are not to be exported. + if(host_triplet == action.spec.triplet()) continue; + const std::string name = action.spec.name(); auto dependencies = action.dependencies(); From e74b1a7fb2a431c587e063db06b86434299e2f4f Mon Sep 17 00:00:00 2001 From: dmn-star Date: Sat, 10 Feb 2024 12:46:30 +0100 Subject: [PATCH 3/5] The port version is now ignored when looking for *.list files. microsoft/vcpkg#35538 --- src/vcpkg/export.prefab.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vcpkg/export.prefab.cpp b/src/vcpkg/export.prefab.cpp index 2df7cb31ff..252aaf549f 100644 --- a/src/vcpkg/export.prefab.cpp +++ b/src/vcpkg/export.prefab.cpp @@ -409,7 +409,10 @@ namespace vcpkg::Prefab const auto per_package_dir_path = paths.prefab / name; const auto& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO); - const std::string norm_version = binary_paragraph.version.to_string(); + + // The port version is not specified during installation (vcpkg install). Just ignore #version. + //jsoncpp_1.17#2_x64-android.list -> jsoncpp_1.17_x64-android.list + const std::string norm_version = binary_paragraph.version.text; version_map[name] = norm_version; @@ -518,7 +521,7 @@ namespace vcpkg::Prefab } Debug::print( - fmt::format("Found {} triplets:\n\t{}", triplets.size(), Strings::join("\n\t", triplet_names))); + fmt::format("Found {} triplets:\n\t{}\n", triplets.size(), Strings::join("\n\t", triplet_names))); for (const auto& triplet : triplets) { @@ -528,6 +531,8 @@ namespace vcpkg::Prefab if (!(fs.exists(listfile, IgnoreErrors{}))) { msg::println_error(msgCorruptedInstallTree); + msg::println_error(msgFileNotFound, msg::path = listfile); + Checks::exit_fail(VCPKG_LINE_INFO); } From 0efad5e344043b1a93a06500728ed4cf18095aef Mon Sep 17 00:00:00 2001 From: dmn-star Date: Sat, 10 Feb 2024 13:33:36 +0100 Subject: [PATCH 4/5] Reformat code and silence the clang-tidy. --- src/vcpkg/export.prefab.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/vcpkg/export.prefab.cpp b/src/vcpkg/export.prefab.cpp index 252aaf549f..63c7010cf5 100644 --- a/src/vcpkg/export.prefab.cpp +++ b/src/vcpkg/export.prefab.cpp @@ -66,7 +66,7 @@ namespace vcpkg::Prefab static std::string null_if_empty(const std::string& str) { std::string copy = str; - if (copy.size() == 0) + if (copy.empty()) { copy = "null"; } @@ -80,7 +80,7 @@ namespace vcpkg::Prefab static std::string null_if_empty_array(const std::string& str) { std::string copy = str; - if (copy.size() == 0) + if (copy.empty()) { copy = "null"; } @@ -230,7 +230,7 @@ namespace vcpkg::Prefab settings.environment = get_clean_environment(); const int exit_code = cmd_execute(cmd, settings).value_or_exit(VCPKG_LINE_INFO); - if (!(exit_code == 0)) + if (exit_code != 0) { msg::println_error(msgInstallingMavenFile, msg::path = aar); Checks::exit_fail(VCPKG_LINE_INFO); @@ -284,8 +284,8 @@ namespace vcpkg::Prefab { if (!triplet_file.name.empty()) { - //The execution of emscripten cmake script causes the prefab export to fail. - //But here we don't need this execution at all so we skip it. + // The execution of emscripten cmake script causes the prefab export to fail. + // But here we don't need this execution at all, so we skip it. if (triplet_file.name == "wasm32-emscripten") continue; Triplet triplet = Triplet::from_canonical_name(triplet_file.name); @@ -377,8 +377,8 @@ namespace vcpkg::Prefab for (const auto& action : export_plan) { - //cross-compiling - //Host-only ports (e.g. vcpkg_cmake) are not to be exported. + // cross-compiling + // Host-only ports (e.g. vcpkg_cmake) are not to be exported. if(host_triplet == action.spec.triplet()) continue; const std::string name = action.spec.name(); @@ -410,8 +410,8 @@ namespace vcpkg::Prefab const auto& binary_paragraph = action.core_paragraph().value_or_exit(VCPKG_LINE_INFO); - // The port version is not specified during installation (vcpkg install). Just ignore #version. - //jsoncpp_1.17#2_x64-android.list -> jsoncpp_1.17_x64-android.list + // The port version is not specified during installation (vcpkg install). Just ignore port version. + // jsoncpp_1.17#2_x64-android.list -> jsoncpp_1.17_x64-android.list const std::string norm_version = binary_paragraph.version.text; version_map[name] = norm_version; @@ -476,7 +476,7 @@ namespace vcpkg::Prefab std::vector pom_dependencies; - if (dependencies_minus_empty_packages.size() > 0) + if (!dependencies_minus_empty_packages.empty()) { pom_dependencies.emplace_back("\n"); } @@ -497,7 +497,7 @@ namespace vcpkg::Prefab pm.dependencies.push_back(it.name()); } - if (dependencies_minus_empty_packages.size() > 0) + if (!dependencies_minus_empty_packages.empty()) { pom_dependencies.emplace_back("\n"); } From 6cb950b607a3cf912381f24e2a996525edaf9abf Mon Sep 17 00:00:00 2001 From: dmn-star Date: Sat, 10 Feb 2024 13:56:41 +0100 Subject: [PATCH 5/5] Reformat the sources again. --- src/vcpkg/commands.export.cpp | 2 +- src/vcpkg/export.prefab.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vcpkg/commands.export.cpp b/src/vcpkg/commands.export.cpp index 43280d8852..2c685563e0 100644 --- a/src/vcpkg/commands.export.cpp +++ b/src/vcpkg/commands.export.cpp @@ -702,7 +702,7 @@ namespace vcpkg if (opts.prefab) { - Prefab::do_export(export_plan, paths, opts.prefab_options, default_triplet, host_triplet); + Prefab::do_export(export_plan, paths, opts.prefab_options, default_triplet, host_triplet); } Checks::exit_success(VCPKG_LINE_INFO); diff --git a/src/vcpkg/export.prefab.cpp b/src/vcpkg/export.prefab.cpp index 63c7010cf5..b358985dae 100644 --- a/src/vcpkg/export.prefab.cpp +++ b/src/vcpkg/export.prefab.cpp @@ -254,7 +254,7 @@ namespace vcpkg::Prefab const VcpkgPaths& paths, const Options& prefab_options, const Triplet& default_triplet, - const Triplet& host_triplet) + const Triplet& host_triplet) { auto provider = CMakeVars::make_triplet_cmake_var_provider(paths); @@ -379,7 +379,7 @@ namespace vcpkg::Prefab { // cross-compiling // Host-only ports (e.g. vcpkg_cmake) are not to be exported. - if(host_triplet == action.spec.triplet()) continue; + if (host_triplet == action.spec.triplet()) continue; const std::string name = action.spec.name(); auto dependencies = action.dependencies();