From ff222fac454449b2fc108bf5271e1823db54d3da Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Fri, 17 Feb 2017 14:55:37 -0800 Subject: [build_command] Extract function for calculations after Input processing --- toolsrc/src/commands_build.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'toolsrc/src/commands_build.cpp') diff --git a/toolsrc/src/commands_build.cpp b/toolsrc/src/commands_build.cpp index 38dd4cfe6..eaba531cb 100644 --- a/toolsrc/src/commands_build.cpp +++ b/toolsrc/src/commands_build.cpp @@ -112,13 +112,8 @@ namespace vcpkg::Commands::Build , spec.toString(), Info::version()); } - void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) + void perform_and_exit(const package_spec& spec, const fs::path& port_dir, const std::unordered_set& options, const vcpkg_paths& paths) { - static const std::string example = Commands::Help::create_example_string("build zlib:x64-windows"); - args.check_exact_arg_count(1, example); // Build only takes a single package and all dependencies must already be installed - const package_spec spec = Input::check_and_get_package_spec(args.command_arguments.at(0), default_target_triplet, example); - Input::check_triplet(spec.target_triplet(), paths); - const std::unordered_set options = args.check_and_get_optional_command_arguments({ OPTION_CHECKS_ONLY }); if (options.find(OPTION_CHECKS_ONLY) != options.end()) { const size_t error_count = PostBuildLint::perform_all_checks(spec, paths); @@ -129,8 +124,7 @@ namespace vcpkg::Commands::Build exit(EXIT_SUCCESS); } - // Explicitly load and use the portfile's build dependencies when resolving the build command (instead of a cached package's dependencies). - const expected maybe_spgh = try_load_port(paths, spec.name()); + const expected maybe_spgh = try_load_port(port_dir); Checks::check_exit(!maybe_spgh.error_code(), "Could not find package named %s: %s", spec, maybe_spgh.error_code().message()); const SourceParagraph& spgh = *maybe_spgh.get(); @@ -168,4 +162,14 @@ namespace vcpkg::Commands::Build exit(EXIT_SUCCESS); } + + void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet) + { + static const std::string example = Commands::Help::create_example_string("build zlib:x64-windows"); + args.check_exact_arg_count(1, example); // Build only takes a single package and all dependencies must already be installed + const package_spec spec = Input::check_and_get_package_spec(args.command_arguments.at(0), default_target_triplet, example); + Input::check_triplet(spec.target_triplet(), paths); + const std::unordered_set options = args.check_and_get_optional_command_arguments({ OPTION_CHECKS_ONLY }); + perform_and_exit(spec, paths.port_dir(spec), options, paths); + } } -- cgit v1.2.3