Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up members/signatures/visibility in deps_format/resolver #78572

Merged
merged 2 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 21 additions & 37 deletions src/native/corehost/hostpolicy/deps_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ pal::string_t deps_json_t::get_current_rid(const rid_fallback_graph_t& rid_fallb
return currentRid;
}

bool deps_json_t::perform_rid_fallback(rid_specific_assets_t* portable_assets, const rid_fallback_graph_t& rid_fallback_graph)
void deps_json_t::perform_rid_fallback(rid_specific_assets_t* portable_assets, const rid_fallback_graph_t& rid_fallback_graph)
{
pal::string_t host_rid = get_current_rid(rid_fallback_graph);

Expand Down Expand Up @@ -193,10 +193,9 @@ bool deps_json_t::perform_rid_fallback(rid_specific_assets_t* portable_assets, c
}
}
}
return true;
}

bool deps_json_t::process_runtime_targets(const json_parser_t::value_t& json, const pal::string_t& target_name, const rid_fallback_graph_t& rid_fallback_graph, rid_specific_assets_t* p_assets)
void deps_json_t::process_runtime_targets(const json_parser_t::value_t& json, const pal::string_t& target_name, const rid_fallback_graph_t& rid_fallback_graph, rid_specific_assets_t* p_assets)
{
rid_specific_assets_t& assets = *p_assets;
for (const auto& package : json[_X("targets")][target_name.c_str()].GetObject())
Expand Down Expand Up @@ -253,15 +252,10 @@ bool deps_json_t::process_runtime_targets(const json_parser_t::value_t& json, co
}
}

if (!perform_rid_fallback(&assets, rid_fallback_graph))
{
return false;
}

return true;
perform_rid_fallback(&assets, rid_fallback_graph);
}

bool deps_json_t::process_targets(const json_parser_t::value_t& json, const pal::string_t& target_name, deps_assets_t* p_assets)
void deps_json_t::process_targets(const json_parser_t::value_t& json, const pal::string_t& target_name, deps_assets_t* p_assets)
{
deps_assets_t& assets = *p_assets;
for (const auto& package : json[_X("targets")][target_name.c_str()].GetObject())
Expand Down Expand Up @@ -311,20 +305,12 @@ bool deps_json_t::process_targets(const json_parser_t::value_t& json, const pal:
}
}
}
return true;
}

bool deps_json_t::load_framework_dependent(const pal::string_t& deps_path, const json_parser_t::value_t& json, const pal::string_t& target_name, const rid_fallback_graph_t& rid_fallback_graph)
void deps_json_t::load_framework_dependent(const pal::string_t& deps_path, const json_parser_t::value_t& json, const pal::string_t& target_name, const rid_fallback_graph_t& rid_fallback_graph)
{
if (!process_runtime_targets(json, target_name, rid_fallback_graph, &m_rid_assets))
{
return false;
}

if (!process_targets(json, target_name, &m_assets))
{
return false;
}
process_runtime_targets(json, target_name, rid_fallback_graph, &m_rid_assets);
process_targets(json, target_name, &m_assets);

auto package_exists = [&](const pal::string_t& package) -> bool {
return m_rid_assets.libs.count(package) || m_assets.libs.count(package);
Expand Down Expand Up @@ -357,16 +343,11 @@ bool deps_json_t::load_framework_dependent(const pal::string_t& deps_path, const
};

reconcile_libraries_with_targets(deps_path, json, package_exists, get_relpaths);

return true;
}

bool deps_json_t::load_self_contained(const pal::string_t& deps_path, const json_parser_t::value_t& json, const pal::string_t& target_name)
void deps_json_t::load_self_contained(const pal::string_t& deps_path, const json_parser_t::value_t& json, const pal::string_t& target_name)
{
if (!process_targets(json, target_name, &m_assets))
{
return false;
}
process_targets(json, target_name, &m_assets);

auto package_exists = [&](const pal::string_t& package) -> bool {
return m_assets.libs.count(package);
Expand Down Expand Up @@ -408,7 +389,6 @@ bool deps_json_t::load_self_contained(const pal::string_t& deps_path, const json
}
trace::verbose(_X("}"));
}
return true;
}

bool deps_json_t::has_package(const pal::string_t& name, const pal::string_t& ver) const
Expand Down Expand Up @@ -438,7 +418,7 @@ bool deps_json_t::has_package(const pal::string_t& name, const pal::string_t& ve
// Load the deps file and parse its "entry" lines which contain the "fields" of
// the entry. Populate an array of these entries.
//
bool deps_json_t::load(bool is_framework_dependent, const pal::string_t& deps_path, const rid_fallback_graph_t& rid_fallback_graph)
void deps_json_t::load(bool is_framework_dependent, const pal::string_t& deps_path, const rid_fallback_graph_t& rid_fallback_graph)
{
m_deps_file = deps_path;
m_file_exists = bundle::info_t::config_t::probe(deps_path) || pal::realpath(&m_deps_file, true);
Expand All @@ -448,14 +428,14 @@ bool deps_json_t::load(bool is_framework_dependent, const pal::string_t& deps_pa
{
// If file doesn't exist, then assume parsed.
trace::verbose(_X("Could not locate the dependencies manifest file [%s]. Some libraries may fail to resolve."), deps_path.c_str());
return true;
m_valid = true;
return;
}

if (!json.parse_file(m_deps_file))
{
return false;
}
return;

m_valid = true;
const auto& runtime_target = json.document()[_X("runtimeTarget")];
const pal::string_t& name = runtime_target.IsString() ?
runtime_target.GetString() :
Expand All @@ -464,7 +444,11 @@ bool deps_json_t::load(bool is_framework_dependent, const pal::string_t& deps_pa
trace::verbose(_X("Loading deps file... %s as framework dependent=[%d]"), deps_path.c_str(), is_framework_dependent);

if (is_framework_dependent)
return load_framework_dependent(deps_path, json.document(), name, rid_fallback_graph);

return load_self_contained(deps_path, json.document(), name);
{
load_framework_dependent(deps_path, json.document(), name, rid_fallback_graph);
}
else
{
load_self_contained(deps_path, json.document(), name);
}
}
14 changes: 7 additions & 7 deletions src/native/corehost/hostpolicy/deps_format.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class deps_json_t
: m_file_exists(false)
, m_valid(false)
{
m_valid = load(is_framework_dependent, deps_path, graph == nullptr ? m_rid_fallback_graph : *graph);
load(is_framework_dependent, deps_path, graph == nullptr ? m_rid_fallback_graph : *graph);
}

const std::vector<deps_entry_t>& get_entries(deps_entry_t::asset_types type) const
Expand Down Expand Up @@ -62,11 +62,11 @@ class deps_json_t
}

private:
bool load_self_contained(const pal::string_t& deps_path, const json_parser_t::value_t& json, const pal::string_t& target_name);
bool load_framework_dependent(const pal::string_t& deps_path, const json_parser_t::value_t& json, const pal::string_t& target_name, const rid_fallback_graph_t& rid_fallback_graph);
bool load(bool is_framework_dependent, const pal::string_t& deps_path, const rid_fallback_graph_t& rid_fallback_graph);
bool process_runtime_targets(const json_parser_t::value_t& json, const pal::string_t& target_name, const rid_fallback_graph_t& rid_fallback_graph, rid_specific_assets_t* p_assets);
bool process_targets(const json_parser_t::value_t& json, const pal::string_t& target_name, deps_assets_t* p_assets);
void load_self_contained(const pal::string_t& deps_path, const json_parser_t::value_t& json, const pal::string_t& target_name);
void load_framework_dependent(const pal::string_t& deps_path, const json_parser_t::value_t& json, const pal::string_t& target_name, const rid_fallback_graph_t& rid_fallback_graph);
void load(bool is_framework_dependent, const pal::string_t& deps_path, const rid_fallback_graph_t& rid_fallback_graph);
void process_runtime_targets(const json_parser_t::value_t& json, const pal::string_t& target_name, const rid_fallback_graph_t& rid_fallback_graph, rid_specific_assets_t* p_assets);
void process_targets(const json_parser_t::value_t& json, const pal::string_t& target_name, deps_assets_t* p_assets);

void reconcile_libraries_with_targets(
const pal::string_t& deps_path,
Expand All @@ -75,7 +75,7 @@ class deps_json_t
const std::function<const vec_asset_t&(const pal::string_t&, size_t, bool*)>& get_assets_fn);

pal::string_t get_current_rid(const rid_fallback_graph_t& rid_fallback_graph);
bool perform_rid_fallback(rid_specific_assets_t* portable_assets, const rid_fallback_graph_t& rid_fallback_graph);
void perform_rid_fallback(rid_specific_assets_t* portable_assets, const rid_fallback_graph_t& rid_fallback_graph);

std::vector<deps_entry_t> m_deps_entries[deps_entry_t::asset_types::count];

Expand Down
Loading