Merge pull request #2064 from schellap/app-local
RID specific and app local loads
This commit is contained in:
commit
a15988be14
3 changed files with 58 additions and 20 deletions
|
@ -6,6 +6,7 @@
|
|||
#include "deps_entry.h"
|
||||
#include "trace.h"
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Given a "base" directory, yield the relative path of this file in the package
|
||||
// layout.
|
||||
|
@ -18,7 +19,7 @@
|
|||
// Returns:
|
||||
// If the file exists in the path relative to the "base" directory.
|
||||
//
|
||||
bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) const
|
||||
bool deps_entry_t::to_rel_path(const pal::string_t& base, pal::string_t* str) const
|
||||
{
|
||||
pal::string_t& candidate = *str;
|
||||
|
||||
|
@ -40,23 +41,53 @@ bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) c
|
|||
|
||||
// Reserve space for the path below
|
||||
candidate.reserve(base.length() +
|
||||
library_name.length() +
|
||||
library_version.length() +
|
||||
pal_relative_path.length() + 3);
|
||||
|
||||
candidate.assign(base);
|
||||
append_path(&candidate, library_name.c_str());
|
||||
append_path(&candidate, library_version.c_str());
|
||||
append_path(&candidate, pal_relative_path.c_str());
|
||||
|
||||
bool exists = pal::file_exists(candidate);
|
||||
if (!exists)
|
||||
{
|
||||
trace::verbose(_X("Relative path query did not exist %s"), candidate.c_str());
|
||||
candidate.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
trace::verbose(_X("Relative path query exists %s"), candidate.c_str());
|
||||
}
|
||||
return exists;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Given a "base" directory, yield the relative path of this file in the package
|
||||
// layout.
|
||||
//
|
||||
// Parameters:
|
||||
// base - The base directory to look for the relative path of this entry
|
||||
// str - If the method returns true, contains the file path for this deps
|
||||
// entry relative to the "base" directory
|
||||
//
|
||||
// Returns:
|
||||
// If the file exists in the path relative to the "base" directory.
|
||||
//
|
||||
bool deps_entry_t::to_full_path(const pal::string_t& base, pal::string_t* str) const
|
||||
{
|
||||
str->clear();
|
||||
|
||||
// Base directory must be present to obtain full path
|
||||
if (base.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pal::string_t new_base = base;
|
||||
append_path(&new_base, library_name.c_str());
|
||||
append_path(&new_base, library_version.c_str());
|
||||
|
||||
return to_rel_path(new_base, str);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Given a "base" directory, yield the relative path of this file in the package
|
||||
// layout if the entry hash matches the hash file in the "base" directory
|
||||
|
|
|
@ -28,9 +28,12 @@ struct deps_entry_t
|
|||
bool is_serviceable;
|
||||
|
||||
// Given a "base" dir, yield the relative path in the package layout.
|
||||
bool to_rel_path(const pal::string_t& base, pal::string_t* str) const;
|
||||
|
||||
// Given a "base" dir, yield the relative path with package name, version in the package layout.
|
||||
bool to_full_path(const pal::string_t& root, pal::string_t* str) const;
|
||||
|
||||
// Given a "base" dir, yield the relative path in the package layout only if
|
||||
// Given a "base" dir, yield the relative path with package name, version in the package layout only if
|
||||
// the hash matches contents of the hash file.
|
||||
bool to_hash_matched_path(const pal::string_t& root, pal::string_t* str) const;
|
||||
};
|
||||
|
|
|
@ -286,6 +286,8 @@ void deps_resolver_t::resolve_tpa_list(
|
|||
|
||||
pal::string_t candidate;
|
||||
|
||||
trace::info(_X("Processing TPA for deps entry [%s, %s, %s]"), entry.library_name.c_str(), entry.library_version.c_str(), entry.relative_path.c_str());
|
||||
|
||||
// Is this a serviceable entry and is there an entry in the servicing index?
|
||||
if (entry.is_serviceable && entry.library_type == _X("Package") &&
|
||||
m_svc.find_redirection(entry.library_name, entry.library_version, entry.relative_path, &candidate))
|
||||
|
@ -302,16 +304,16 @@ void deps_resolver_t::resolve_tpa_list(
|
|||
{
|
||||
add_tpa_asset(entry.asset_name, candidate, &items, output);
|
||||
}
|
||||
// Is this entry present in the given dir?
|
||||
// The app is portable so the rid asset should be picked up from relative subpath.
|
||||
else if (is_portable && deps->try_ni(entry).to_rel_path(app_dir, &candidate))
|
||||
{
|
||||
add_tpa_asset(entry.asset_name, candidate, &items, output);
|
||||
}
|
||||
// The app is portable, but there could be a rid-less asset in the app base.
|
||||
else if (dir_assemblies.count(entry.asset_name))
|
||||
{
|
||||
add_tpa_asset(entry.asset_name, dir_assemblies.find(entry.asset_name)->second, &items, output);
|
||||
}
|
||||
// The app is portable so the asset should be picked up from relative subpath.
|
||||
else if (is_portable && deps->try_ni(entry).to_full_path(app_dir, &candidate))
|
||||
{
|
||||
add_tpa_asset(entry.asset_name, candidate, &items, output);
|
||||
}
|
||||
// Is this entry present in the package restore dir?
|
||||
else if (!package_dir.empty() && deps->try_ni(entry).to_full_path(package_dir, &candidate))
|
||||
{
|
||||
|
@ -323,10 +325,6 @@ void deps_resolver_t::resolve_tpa_list(
|
|||
std::for_each(deps_entries.begin(), deps_entries.end(), [&](const deps_entry_t& entry) {
|
||||
process_entry(m_portable, m_deps.get(), m_local_assemblies, entry);
|
||||
});
|
||||
const auto& fx_entries = m_portable ? m_fx_deps->get_entries(deps_entry_t::asset_types::runtime) : empty;
|
||||
std::for_each(fx_entries.begin(), fx_entries.end(), [&](const deps_entry_t& entry) {
|
||||
process_entry(false, m_fx_deps.get(), m_fx_assemblies, entry);
|
||||
});
|
||||
|
||||
// Finally, if the deps file wasn't present or has missing entries, then
|
||||
// add the app local assemblies to the TPA.
|
||||
|
@ -334,6 +332,12 @@ void deps_resolver_t::resolve_tpa_list(
|
|||
{
|
||||
add_tpa_asset(kv.first, kv.second, &items, output);
|
||||
}
|
||||
|
||||
const auto& fx_entries = m_portable ? m_fx_deps->get_entries(deps_entry_t::asset_types::runtime) : empty;
|
||||
std::for_each(fx_entries.begin(), fx_entries.end(), [&](const deps_entry_t& entry) {
|
||||
process_entry(false, m_fx_deps.get(), m_fx_assemblies, entry);
|
||||
});
|
||||
|
||||
for (const auto& kv : m_fx_assemblies)
|
||||
{
|
||||
add_tpa_asset(kv.first, kv.second, &items, output);
|
||||
|
@ -419,21 +423,21 @@ void deps_resolver_t::resolve_probe_dirs(
|
|||
std::for_each(fx_entries.begin(), fx_entries.end(), add_package_cache_entry);
|
||||
}
|
||||
|
||||
// App local path
|
||||
add_unique_path(asset_type, app_dir, &items, output);
|
||||
|
||||
// For portable path, the app relative directory must be used.
|
||||
if (m_portable)
|
||||
{
|
||||
std::for_each(entries.begin(), entries.end(), [&](const deps_entry_t& entry)
|
||||
{
|
||||
if (entry.asset_type == asset_type && entry.to_full_path(package_dir, &candidate))
|
||||
if (entry.asset_type == asset_type && entry.to_rel_path(app_dir, &candidate))
|
||||
{
|
||||
add_unique_path(asset_type, action(candidate), &items, output);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// App local path
|
||||
add_unique_path(asset_type, app_dir, &items, output);
|
||||
|
||||
// FX path if present
|
||||
if (!m_fx_dir.empty())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue