diff options
Diffstat (limited to 'toolsrc')
| -rw-r--r-- | toolsrc/include/PostBuildLint.h | 2 | ||||
| -rw-r--r-- | toolsrc/include/vcpkg_Commands.h | 11 | ||||
| -rw-r--r-- | toolsrc/src/PostBuildLint.cpp | 8 | ||||
| -rw-r--r-- | toolsrc/src/commands_build.cpp | 27 | ||||
| -rw-r--r-- | toolsrc/src/commands_build_external.cpp | 7 | ||||
| -rw-r--r-- | toolsrc/src/commands_install.cpp | 6 |
6 files changed, 48 insertions, 13 deletions
diff --git a/toolsrc/include/PostBuildLint.h b/toolsrc/include/PostBuildLint.h index 215a237aa..73c8ec54b 100644 --- a/toolsrc/include/PostBuildLint.h +++ b/toolsrc/include/PostBuildLint.h @@ -4,5 +4,5 @@ namespace vcpkg::PostBuildLint { - void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths); + size_t perform_all_checks(const package_spec& spec, const vcpkg_paths& paths); } diff --git a/toolsrc/include/vcpkg_Commands.h b/toolsrc/include/vcpkg_Commands.h index 8d772b255..ef300ac12 100644 --- a/toolsrc/include/vcpkg_Commands.h +++ b/toolsrc/include/vcpkg_Commands.h @@ -11,7 +11,16 @@ namespace vcpkg::Commands namespace Build { - void build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir); + enum class BuildResult + { + BUILD_NOT_STARTED = 0, + SUCCESS, + CASCADED_DUE_TO_MISSING_DEPENDENCIES, + BUILD_FAILED, + POST_BUILD_CHECKS_FAILED, + }; + + BuildResult build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir); void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet); } diff --git a/toolsrc/src/PostBuildLint.cpp b/toolsrc/src/PostBuildLint.cpp index 23f1347cf..a5fd7aa52 100644 --- a/toolsrc/src/PostBuildLint.cpp +++ b/toolsrc/src/PostBuildLint.cpp @@ -619,6 +619,7 @@ namespace vcpkg::PostBuildLint left += static_cast<size_t>(right); } + static size_t perform_all_checks_and_return_error_count(const package_spec& spec, const vcpkg_paths& paths) { const fs::path dumpbin_exe = Environment::get_dumpbin_exe(paths); @@ -710,19 +711,18 @@ namespace vcpkg::PostBuildLint return error_count; } - void perform_all_checks(const package_spec& spec, const vcpkg_paths& paths) + size_t perform_all_checks(const package_spec& spec, const vcpkg_paths& paths) { System::println("-- Performing post-build validation"); - const size_t error_count = perform_all_checks_and_return_error_count(spec, paths); + System::println("-- Performing post-build validation done"); if (error_count != 0) { const fs::path portfile = paths.ports / spec.name() / "portfile.cmake"; System::println(System::color::error, "Found %u error(s). Please correct the portfile:\n %s", error_count, portfile.string()); - exit(EXIT_FAILURE); } - System::println("-- Performing post-build validation done"); + return error_count; } } diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp index c5a278450..a9c6469d7 100644 --- a/toolsrc/src/commands_build.cpp +++ b/toolsrc/src/commands_build.cpp @@ -9,6 +9,7 @@ #include "vcpkg_Environment.h" #include "metrics.h" #include "vcpkg_info.h" +#include "vcpkg_Enums.h" namespace vcpkg::Commands::Build { @@ -24,7 +25,7 @@ namespace vcpkg::Commands::Build std::ofstream(binary_control_file) << bpgh; } - void build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir) + BuildResult build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir) { Checks::check_exit(spec.name() == source_paragraph.name, "inconsistent arguments to build_internal()"); const triplet& target_triplet = spec.target_triplet(); @@ -58,15 +59,22 @@ namespace vcpkg::Commands::Build , spec.toString(), Info::version()); TrackProperty("error", "build failed"); TrackProperty("build_error", spec.toString()); - exit(EXIT_FAILURE); + return BuildResult::BUILD_FAILED; } - PostBuildLint::perform_all_checks(spec, paths); + const size_t error_count = PostBuildLint::perform_all_checks(spec, paths); + + if (error_count != 0) + { + return BuildResult::POST_BUILD_CHECKS_FAILED; + } create_binary_control_file(paths, source_paragraph, target_triplet); // const fs::path port_buildtrees_dir = paths.buildtrees / spec.name; // delete_directory(port_buildtrees_dir); + + return BuildResult::SUCCESS; } void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) @@ -86,7 +94,11 @@ namespace vcpkg::Commands::Build const std::unordered_set<std::string> options = args.check_and_get_optional_command_arguments({OPTION_CHECKS_ONLY}); if (options.find(OPTION_CHECKS_ONLY) != options.end()) { - PostBuildLint::perform_all_checks(spec, paths); + const size_t error_count = PostBuildLint::perform_all_checks(spec, paths); + if (error_count > 0) + { + exit(EXIT_FAILURE); + } exit(EXIT_SUCCESS); } @@ -125,7 +137,12 @@ namespace vcpkg::Commands::Build } Environment::ensure_utilities_on_path(paths); - build_package(spgh, spec, paths, paths.port_dir(spec)); + const BuildResult result = build_package(spgh, spec, paths, paths.port_dir(spec)); + if (result != BuildResult::SUCCESS) + { + exit(EXIT_FAILURE); + } + exit(EXIT_SUCCESS); } } diff --git a/toolsrc/src/commands_build_external.cpp b/toolsrc/src/commands_build_external.cpp index 5c3fa9857..8e9bf50fd 100644 --- a/toolsrc/src/commands_build_external.cpp +++ b/toolsrc/src/commands_build_external.cpp @@ -21,7 +21,12 @@ namespace vcpkg::Commands::BuildExternal const expected<SourceParagraph> maybe_spgh = try_load_port(port_dir); if (auto spgh = maybe_spgh.get()) { - Commands::Build::build_package(*spgh, *spec, paths, port_dir); + const Build::BuildResult result = Commands::Build::build_package(*spgh, *spec, paths, port_dir); + if (result !=Build::BuildResult::SUCCESS) + { + exit(EXIT_FAILURE); + } + exit(EXIT_SUCCESS); } } diff --git a/toolsrc/src/commands_install.cpp b/toolsrc/src/commands_install.cpp index 1f5a2234d..48da05e9c 100644 --- a/toolsrc/src/commands_install.cpp +++ b/toolsrc/src/commands_install.cpp @@ -214,7 +214,11 @@ namespace vcpkg::Commands::Install } else if (action.plan.plan_type == install_plan_type::BUILD_AND_INSTALL) { - Commands::Build::build_package(*action.plan.source_pgh, action.spec, paths, paths.port_dir(action.spec)); + const Build::BuildResult result = Commands::Build::build_package(*action.plan.source_pgh, action.spec, paths, paths.port_dir(action.spec)); + if (result != Build::BuildResult::SUCCESS) + { + exit(EXIT_FAILURE); + } const BinaryParagraph bpgh = try_load_cached_package(paths, action.spec).get_or_throw(); install_package(paths, bpgh, &status_db); System::println(System::color::success, "Package %s is installed", action.spec); |
