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..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); + 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 8a08f72ecf..b358985dae 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); @@ -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); @@ -281,8 +282,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)) @@ -372,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(); @@ -400,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 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; @@ -464,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"); } @@ -485,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"); } @@ -509,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) { @@ -519,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); }