Merge pull request #2898 from schellap/master

Prefer servicing for native dll search order
This commit is contained in:
Senthil 2016-05-05 09:55:14 -07:00
commit d9d8bb2f03
3 changed files with 33 additions and 8 deletions

View file

@ -49,7 +49,9 @@ void add_unique_path(
deps_entry_t::asset_types asset_type,
const pal::string_t& path,
std::unordered_set<pal::string_t>* existing,
pal::string_t* output)
pal::string_t* serviced,
pal::string_t* non_serviced,
const pal::string_t& svc_dir)
{
// Resolve sym links.
pal::string_t real = path;
@ -62,9 +64,18 @@ void add_unique_path(
trace::verbose(_X("Adding to %s path: %s"), deps_entry_t::s_known_asset_types[asset_type], real.c_str());
output->append(real);
if (starts_with(real, svc_dir, false))
{
serviced->append(real);
serviced->push_back(PATH_SEPARATOR);
}
else
{
non_serviced->append(real);
non_serviced->push_back(PATH_SEPARATOR);
}
output->push_back(PATH_SEPARATOR);
existing->insert(real);
}
@ -502,6 +513,9 @@ void deps_resolver_t::resolve_probe_dirs(
};
std::function<pal::string_t(const pal::string_t&)>& action = is_resources ? resources : native;
std::unordered_set<pal::string_t> items;
pal::string_t core_servicing = m_core_servicing;
pal::realpath(&core_servicing);
pal::string_t non_serviced;
std::vector<deps_entry_t> empty(0);
const auto& entries = m_deps->get_entries(asset_type);
@ -536,7 +550,7 @@ void deps_resolver_t::resolve_probe_dirs(
m_api_set_paths.insert(result_dir);
}
add_unique_path(asset_type, result_dir, &items, output);
add_unique_path(asset_type, result_dir, &items, output, &non_serviced, core_servicing);
}
};
std::for_each(entries.begin(), entries.end(), add_package_cache_entry);
@ -551,7 +565,7 @@ void deps_resolver_t::resolve_probe_dirs(
{
if (entry.is_rid_specific && entry.asset_type == asset_type && entry.to_rel_path(m_app_dir, &candidate))
{
add_unique_path(asset_type, action(candidate), &items, output);
add_unique_path(asset_type, action(candidate), &items, output, &non_serviced, core_servicing);
}
// App called out an explicit API set dependency.
@ -566,7 +580,7 @@ void deps_resolver_t::resolve_probe_dirs(
track_api_sets = m_api_set_paths.empty();
// App local path
add_unique_path(asset_type, m_app_dir, &items, output);
add_unique_path(asset_type, m_app_dir, &items, output, &non_serviced, core_servicing);
// If API sets is not found (i.e., empty) in the probe paths above:
// 1. For standalone app, do nothing as all are sxs.
@ -581,11 +595,13 @@ void deps_resolver_t::resolve_probe_dirs(
{
m_api_set_paths.insert(m_fx_dir);
}
add_unique_path(asset_type, m_fx_dir, &items, output);
add_unique_path(asset_type, m_fx_dir, &items, output, &non_serviced, core_servicing);
}
// CLR path
add_unique_path(asset_type, clr_dir, &items, output);
add_unique_path(asset_type, clr_dir, &items, output, &non_serviced, core_servicing);
output->append(non_serviced);
}

View file

@ -31,6 +31,7 @@ public:
, m_portable(init.is_portable)
, m_deps(nullptr)
, m_fx_deps(nullptr)
, m_core_servicing(args.core_servicing)
{
m_deps_file = args.deps_path;
if (m_portable)
@ -150,6 +151,9 @@ private:
pal::string_t m_package_cache;
// Servicing root, could be empty on platforms that don't support or when errors occur.
pal::string_t m_core_servicing;
// Special entry for api-sets
std::unordered_set<pal::string_t> m_api_set_paths;

View file

@ -37,6 +37,11 @@ bool ends_with(const pal::string_t& value, const pal::string_t& suffix, bool mat
bool starts_with(const pal::string_t& value, const pal::string_t& prefix, bool match_case)
{
if (prefix.empty())
{
// Cannot start with an empty string.
return false;
}
auto cmp = match_case ? pal::strncmp : pal::strncasecmp;
return (value.size() >= prefix.size()) &&
cmp(value.c_str(), prefix.c_str(), prefix.size()) == 0;