build-external now calls code from build after input processing

This commit is contained in:
Alexander Karatarakis 2017-02-17 15:09:15 -08:00
parent ff222fac45
commit b4304c9c99

View File

@ -3,7 +3,6 @@
#include "vcpkg_System.h"
#include "vcpkg_Environment.h"
#include "vcpkg_Input.h"
#include "vcpkglib.h"
namespace vcpkg::Commands::BuildExternal
{
@ -11,32 +10,11 @@ namespace vcpkg::Commands::BuildExternal
{
static const std::string example = Commands::Help::create_example_string(R"(build_external zlib2 C:\path\to\dir\with\controlfile\)");
args.check_exact_arg_count(2, example);
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<std::string> options = args.check_and_get_optional_command_arguments({});
StatusParagraphs status_db = database_load_check(paths);
expected<package_spec> maybe_current_spec = package_spec::from_string(args.command_arguments[0], default_target_triplet);
if (auto spec = maybe_current_spec.get())
{
Input::check_triplet(spec->target_triplet(), paths);
Environment::ensure_utilities_on_path(paths);
const fs::path port_dir = args.command_arguments.at(1);
const expected<SourceParagraph> maybe_spgh = try_load_port(port_dir);
if (auto spgh = maybe_spgh.get())
{
const Build::BuildResult result = Commands::Build::build_package(*spgh, *spec, paths, port_dir, status_db);
if (result != Build::BuildResult::SUCCEEDED)
{
System::println(System::color::error, Build::create_error_message(result, *spec));
System::println(Build::create_user_troubleshooting_message(*spec));
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
}
}
System::println(System::color::error, "Error: %s: %s", maybe_current_spec.error_code().message(), args.command_arguments[0]);
Commands::Help::print_example(Strings::format("%s zlib:x64-windows", args.command));
exit(EXIT_FAILURE);
const fs::path port_dir = args.command_arguments.at(1);
Build::perform_and_exit(spec, port_dir, options, paths);
}
}