Renames and cleanup

This commit is contained in:
Alexander Karatarakis 2016-11-15 11:56:46 -08:00
parent 2b204e6739
commit b64b0cbc8a
3 changed files with 28 additions and 25 deletions

View File

@ -6,7 +6,7 @@
namespace vcpkg {namespace Dependencies
{
enum class install_plan_kind
enum class install_plan_type
{
BUILD_AND_INSTALL,
INSTALL,
@ -15,7 +15,7 @@ namespace vcpkg {namespace Dependencies
struct install_plan_action
{
install_plan_kind plan;
install_plan_type type;
std::unique_ptr<BinaryParagraph> bpgh;
std::unique_ptr<SourceParagraph> spgh;
};
@ -23,7 +23,7 @@ namespace vcpkg {namespace Dependencies
struct package_spec_with_install_plan
{
package_spec spec;
install_plan_action install_plan;
install_plan_action plan;
};
std::vector<package_spec_with_install_plan> create_install_plan(const vcpkg_paths& paths, const std::vector<package_spec>& specs, const StatusParagraphs& status_db);

View File

@ -13,9 +13,12 @@
namespace vcpkg
{
using Dependencies::package_spec_with_install_plan;
using Dependencies::install_plan_type;
static void create_binary_control_file(const vcpkg_paths& paths, const SourceParagraph& source_paragraph, const triplet& target_triplet)
{
auto bpgh = BinaryParagraph(source_paragraph, target_triplet);
const BinaryParagraph bpgh = BinaryParagraph(source_paragraph, target_triplet);
const fs::path binary_control_file = paths.packages / bpgh.dir() / "CONTROL";
std::ofstream(binary_control_file) << bpgh;
}
@ -23,7 +26,7 @@ namespace vcpkg
static void build_internal(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()");
auto&& target_triplet = spec.target_triplet();
const triplet& target_triplet = spec.target_triplet();
const fs::path ports_cmake_script_path = paths.ports_cmake;
const std::wstring command = Strings::wformat(LR"("%%VS140COMNTOOLS%%..\..\VC\vcvarsall.bat" %s && cmake -DCMD=BUILD -DPORT=%s -DTARGET_TRIPLET=%s "-DCURRENT_PORT_DIR=%s/." -P "%s")",
@ -70,7 +73,7 @@ namespace vcpkg
std::vector<package_spec> specs = Input::check_and_get_package_specs(args.command_arguments, default_target_triplet, example.c_str());
Input::check_triplets(specs, paths);
auto install_plan = Dependencies::create_install_plan(paths, specs, status_db);
std::vector<package_spec_with_install_plan> install_plan = Dependencies::create_install_plan(paths, specs, status_db);
Checks::check_exit(!install_plan.empty(), "Install plan cannot be empty");
std::string specs_string = to_string(install_plan[0].spec);
@ -82,27 +85,27 @@ namespace vcpkg
TrackProperty("installplan", specs_string);
Environment::ensure_utilities_on_path(paths);
for (const auto& action : install_plan)
for (const package_spec_with_install_plan& action : install_plan)
{
try
{
if (action.install_plan.plan == Dependencies::install_plan_kind::ALREADY_INSTALLED)
if (action.plan.type == install_plan_type::ALREADY_INSTALLED)
{
if (std::find(specs.begin(), specs.end(), action.spec) != specs.end())
{
System::println(System::color::success, "Package %s is already installed", action.spec);
}
}
else if (action.install_plan.plan == Dependencies::install_plan_kind::BUILD_AND_INSTALL)
else if (action.plan.type == install_plan_type::BUILD_AND_INSTALL)
{
build_internal(*action.install_plan.spgh, action.spec, paths, paths.port_dir(action.spec));
auto bpgh = try_load_cached_package(paths, action.spec).get_or_throw();
build_internal(*action.plan.spgh, action.spec, paths, paths.port_dir(action.spec));
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);
}
else if (action.install_plan.plan == Dependencies::install_plan_kind::INSTALL)
else if (action.plan.type == install_plan_type::INSTALL)
{
install_package(paths, *action.install_plan.bpgh, status_db);
install_package(paths, *action.plan.bpgh, status_db);
System::println(System::color::success, "Package %s is installed", action.spec);
}
else
@ -132,23 +135,23 @@ namespace vcpkg
Input::check_triplet(spec.target_triplet(), paths);
// Explicitly load and use the portfile's build dependencies when resolving the build command (instead of a cached package's dependencies).
auto maybe_spgh = try_load_port(paths, spec.name());
const expected<SourceParagraph> maybe_spgh = try_load_port(paths, spec.name());
Checks::check_exit(!maybe_spgh.error_code(), "Could not find package named %s: %s", spec, maybe_spgh.error_code().message());
auto& spgh = *maybe_spgh.get();
const SourceParagraph& spgh = *maybe_spgh.get();
auto first_level_deps = filter_dependencies(spgh.depends, spec.target_triplet());
const std::vector<std::string> first_level_deps = filter_dependencies(spgh.depends, spec.target_triplet());
std::vector<package_spec> first_level_deps_specs;
for (auto&& dep : first_level_deps)
for (const std::string& dep : first_level_deps)
{
first_level_deps_specs.push_back(package_spec::from_name_and_triplet(dep, spec.target_triplet()).get_or_throw());
}
std::vector<Dependencies::package_spec_with_install_plan> unmet_dependencies = Dependencies::create_install_plan(paths, first_level_deps_specs, status_db);
std::vector<package_spec_with_install_plan> unmet_dependencies = Dependencies::create_install_plan(paths, first_level_deps_specs, status_db);
unmet_dependencies.erase(
std::remove_if(unmet_dependencies.begin(), unmet_dependencies.end(), [](const Dependencies::package_spec_with_install_plan& p)
std::remove_if(unmet_dependencies.begin(), unmet_dependencies.end(), [](const package_spec_with_install_plan& p)
{
return p.install_plan.plan == Dependencies::install_plan_kind::ALREADY_INSTALLED;
return p.plan.type == install_plan_type::ALREADY_INSTALLED;
}),
unmet_dependencies.end());
@ -157,7 +160,7 @@ namespace vcpkg
System::println(System::color::error, "The build command requires all dependencies to be already installed.");
System::println("The following dependencies are missing:");
System::println("");
for (const auto& p : unmet_dependencies)
for (const package_spec_with_install_plan& p : unmet_dependencies)
{
System::println(" %s", to_string(p.spec));
}
@ -181,7 +184,7 @@ namespace vcpkg
Input::check_triplet(spec->target_triplet(), paths);
Environment::ensure_utilities_on_path(paths);
const fs::path port_dir = args.command_arguments.at(1);
auto maybe_spgh = try_load_port(port_dir);
const expected<SourceParagraph> maybe_spgh = try_load_port(port_dir);
if (auto spgh = maybe_spgh.get())
{
build_internal(*spgh, *spec, paths, port_dir);

View File

@ -44,7 +44,7 @@ namespace vcpkg { namespace Dependencies
auto it = status_db.find(spec);
if (it != status_db.end() && (*it)->want == want_t::install)
{
was_examined.emplace(spec, install_plan_action{install_plan_kind::ALREADY_INSTALLED, nullptr, nullptr});
was_examined.emplace(spec, install_plan_action{install_plan_type::ALREADY_INSTALLED, nullptr, nullptr});
continue;
}
@ -52,7 +52,7 @@ namespace vcpkg { namespace Dependencies
if (BinaryParagraph* bpgh = maybe_bpgh.get())
{
process_dependencies(bpgh->depends);
was_examined.emplace(spec, install_plan_action{install_plan_kind::INSTALL, std::make_unique<BinaryParagraph>(std::move(*bpgh)), nullptr});
was_examined.emplace(spec, install_plan_action{install_plan_type::INSTALL, std::make_unique<BinaryParagraph>(std::move(*bpgh)), nullptr});
continue;
}
@ -60,7 +60,7 @@ namespace vcpkg { namespace Dependencies
SourceParagraph* spgh = maybe_spgh.get();
Checks::check_exit(spgh != nullptr, "Cannot find package");
process_dependencies(filter_dependencies(spgh->depends, spec.target_triplet()));
was_examined.emplace(spec, install_plan_action{install_plan_kind::BUILD_AND_INSTALL, nullptr, std::make_unique<SourceParagraph>(std::move(*spgh))});
was_examined.emplace(spec, install_plan_action{install_plan_type::BUILD_AND_INSTALL, nullptr, std::make_unique<SourceParagraph>(std::move(*spgh))});
}
std::vector<package_spec_with_install_plan> ret;