From d85e169c054c0702ec6cd2deedff58eaf49dcfab Mon Sep 17 00:00:00 2001 From: Alexander Karatarakis Date: Mon, 7 Nov 2016 17:05:32 -0800 Subject: [Dependencies] Make function static --- toolsrc/include/vcpkg_Dependencies.h | 1 - toolsrc/src/vcpkg_Dependencies.cpp | 48 ++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/toolsrc/include/vcpkg_Dependencies.h b/toolsrc/include/vcpkg_Dependencies.h index d8d331f9c..d8709e0bb 100644 --- a/toolsrc/include/vcpkg_Dependencies.h +++ b/toolsrc/include/vcpkg_Dependencies.h @@ -11,6 +11,5 @@ namespace vcpkg {namespace Dependencies std::unordered_set find_unmet_dependencies(const vcpkg_paths& paths, const std::vector& specs, const StatusParagraphs& status_db); - std::vector get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db); std::vector get_unmet_package_build_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db); }} diff --git a/toolsrc/src/vcpkg_Dependencies.cpp b/toolsrc/src/vcpkg_Dependencies.cpp index 2e79a2499..953bd9925 100644 --- a/toolsrc/src/vcpkg_Dependencies.cpp +++ b/toolsrc/src/vcpkg_Dependencies.cpp @@ -12,6 +12,29 @@ namespace vcpkg { namespace Dependencies { + // TODO: Refactoring between this function and install_package + static std::vector get_single_level_unmet_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db) + { + const fs::path packages_dir_control_file_path = paths.package_dir(spec) / "CONTROL"; + + auto control_contents_maybe = Files::get_contents(packages_dir_control_file_path); + if (auto control_contents = control_contents_maybe.get()) + { + std::vector> pghs; + try + { + pghs = Paragraphs::parse_paragraphs(*control_contents); + } + catch (std::runtime_error) + { + } + Checks::check_exit(pghs.size() == 1, "Invalid control file at %s", packages_dir_control_file_path.string()); + return BinaryParagraph(pghs[0]).depends; + } + + return get_unmet_package_build_dependencies(paths, spec, status_db); + } + static Graphs::Graph build_dependency_graph(const vcpkg_paths& paths, const std::vector& specs, const StatusParagraphs& status_db) { std::vector examine_stack(specs); @@ -29,7 +52,7 @@ namespace vcpkg { namespace Dependencies continue; } - std::vector dependencies_as_string = get_unmet_package_dependencies(paths, spec, status_db); + std::vector dependencies_as_string = get_single_level_unmet_dependencies(paths, spec, status_db); for (const std::string& dep_as_string : dependencies_as_string) { @@ -64,29 +87,6 @@ namespace vcpkg { namespace Dependencies return Maps::extract_key_set(dependency_graph.adjacency_list()); } - // TODO: Refactoring between this function and install_package - std::vector get_unmet_package_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db) - { - const fs::path packages_dir_control_file_path = paths.package_dir(spec) / "CONTROL"; - - auto control_contents_maybe = Files::get_contents(packages_dir_control_file_path); - if (auto control_contents = control_contents_maybe.get()) - { - std::vector> pghs; - try - { - pghs = Paragraphs::parse_paragraphs(*control_contents); - } - catch (std::runtime_error) - { - } - Checks::check_exit(pghs.size() == 1, "Invalid control file at %s", packages_dir_control_file_path.string()); - return BinaryParagraph(pghs[0]).depends; - } - - return get_unmet_package_build_dependencies(paths, spec, status_db); - } - std::vector get_unmet_package_build_dependencies(const vcpkg_paths& paths, const package_spec& spec, const StatusParagraphs& status_db) { const fs::path ports_dir_control_file_path = paths.port_dir(spec) / "CONTROL"; -- cgit v1.2.3