Merge pull request #2083 from schellap/exec-deps
Resolve hostpolicy from deps file in exec mode
This commit is contained in:
commit
ab6db12866
7 changed files with 48 additions and 8 deletions
|
@ -97,6 +97,16 @@ void deps_json_t::reconcile_libraries_with_targets(
|
|||
entry.relative_path.c_str());
|
||||
}
|
||||
|
||||
if (i == deps_entry_t::asset_types::native &&
|
||||
entry.asset_name == LIBHOSTPOLICY_FILENAME)
|
||||
{
|
||||
m_hostpolicy_index = m_deps_entries[i].size() - 1;
|
||||
trace::verbose(_X("Found hostpolicy from deps %d [%s, %s, %s]"),
|
||||
m_hostpolicy_index,
|
||||
entry.library_name.c_str(),
|
||||
entry.library_version.c_str(),
|
||||
entry.relative_path.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
deps_json_t()
|
||||
: m_valid(false)
|
||||
, m_coreclr_index(-1)
|
||||
, m_hostpolicy_index(-1)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -51,12 +52,23 @@ public:
|
|||
return m_coreclr_index >= 0;
|
||||
}
|
||||
|
||||
bool has_hostpolicy_entry()
|
||||
{
|
||||
return m_hostpolicy_index >= 0;
|
||||
}
|
||||
|
||||
const deps_entry_t& get_coreclr_entry()
|
||||
{
|
||||
assert(has_coreclr_entry());
|
||||
return m_deps_entries[deps_entry_t::asset_types::native][m_coreclr_index];
|
||||
}
|
||||
|
||||
const deps_entry_t& get_hostpolicy_entry()
|
||||
{
|
||||
assert(has_hostpolicy_entry());
|
||||
return m_deps_entries[deps_entry_t::asset_types::native][m_hostpolicy_index];
|
||||
}
|
||||
|
||||
bool is_valid()
|
||||
{
|
||||
return m_valid;
|
||||
|
@ -90,6 +102,7 @@ private:
|
|||
std::unordered_map<pal::string_t, int> m_ni_entries;
|
||||
rid_fallback_graph_t m_rid_fallback_graph;
|
||||
int m_coreclr_index;
|
||||
int m_hostpolicy_index;
|
||||
bool m_valid;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ set(SOURCES
|
|||
../../common/trace.cpp
|
||||
../../common/utils.cpp
|
||||
../libhost.cpp
|
||||
../deps_format.cpp
|
||||
../deps_entry.cpp
|
||||
../runtime_config.cpp
|
||||
../json/casablanca/src/json/json.cpp
|
||||
../json/casablanca/src/json/json_parsing.cpp
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "runtime_config.h"
|
||||
#include "cpprest/json.h"
|
||||
#include "error_codes.h"
|
||||
#include "deps_format.h"
|
||||
|
||||
pal::string_t fx_muxer_t::resolve_fx_dir(const pal::string_t& muxer_dir, runtime_config_t* runtime)
|
||||
{
|
||||
|
@ -23,7 +24,7 @@ pal::string_t fx_muxer_t::resolve_fx_dir(const pal::string_t& muxer_dir, runtime
|
|||
fx_ver_t specified(-1, -1, -1);
|
||||
if (!fx_ver_t::parse(fx_ver, &specified, false))
|
||||
{
|
||||
trace::info(_X("The specified runtimeconfig.json version [%s] could not be parsed"), fx_ver.c_str());
|
||||
trace::error(_X("The specified runtimeconfig.json version [%s] could not be parsed"), fx_ver.c_str());
|
||||
return pal::string_t();
|
||||
}
|
||||
|
||||
|
@ -61,7 +62,7 @@ pal::string_t fx_muxer_t::resolve_fx_dir(const pal::string_t& muxer_dir, runtime
|
|||
}
|
||||
|
||||
trace::verbose(_X("Chose FX version [%s]"), fx_dir.c_str());
|
||||
return pal::directory_exists(fx_dir) ? fx_dir : pal::string_t();
|
||||
return fx_dir;
|
||||
}
|
||||
|
||||
pal::string_t fx_muxer_t::resolve_cli_version(const pal::string_t& global_json)
|
||||
|
@ -104,7 +105,7 @@ pal::string_t fx_muxer_t::resolve_cli_version(const pal::string_t& global_json)
|
|||
}
|
||||
catch (...)
|
||||
{
|
||||
trace::verbose(_X("A JSON parsing exception occurred"));
|
||||
trace::error(_X("A JSON parsing exception occurred"));
|
||||
}
|
||||
trace::verbose(_X("CLI version is [%s] in global json file [%s]"), retval.c_str(), global_json.c_str());
|
||||
return retval;
|
||||
|
@ -329,8 +330,20 @@ int fx_muxer_t::execute(const int argc, const pal::char_t* argv[])
|
|||
else
|
||||
{
|
||||
trace::verbose(_X("Executing as a standalone app as per config file [%s]"), config_file.c_str());
|
||||
corehost_init_t init(deps_file, probe_path, _X(""), host_mode_t::muxer, &config);
|
||||
pal::string_t impl_dir = get_directory(app_or_deps);
|
||||
if (!library_exists_in_dir(impl_dir, LIBHOSTPOLICY_NAME, nullptr) && !probe_path.empty() && !deps_file.empty())
|
||||
{
|
||||
deps_json_t deps_json(false, deps_file);
|
||||
pal::string_t candidate = impl_dir;
|
||||
if (!deps_json.has_hostpolicy_entry() ||
|
||||
!deps_json.get_hostpolicy_entry().to_full_path(probe_path, &candidate))
|
||||
{
|
||||
trace::error(_X("Policy library either not found in deps [%s] or not found in [%s]"), deps_file.c_str(), probe_path.c_str());
|
||||
return StatusCode::CoreHostLibMissingFailure;
|
||||
}
|
||||
impl_dir = get_directory(candidate);
|
||||
}
|
||||
corehost_init_t init(deps_file, probe_path, _X(""), host_mode_t::muxer, &config);
|
||||
return execute_app(impl_dir, &init, new_argv.size(), new_argv.data());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ int load_host_library(
|
|||
corehost_unload_fn* unload_fn)
|
||||
{
|
||||
pal::string_t host_path;
|
||||
if (!library_exists_in_dir(lib_dir, LIBHOST_NAME, &host_path))
|
||||
if (!library_exists_in_dir(lib_dir, LIBHOSTPOLICY_NAME, &host_path))
|
||||
{
|
||||
return StatusCode::CoreHostLibMissingFailure;
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ bool hostpolicy_exists_in_svc(pal::string_t* resolved_dir)
|
|||
append_path(&path, COREHOST_PACKAGE_NAME);
|
||||
append_path(&path, COREHOST_PACKAGE_VERSION);
|
||||
append_path(&path, COREHOST_PACKAGE_COREHOST_RELATIVE_DIR);
|
||||
if (library_exists_in_dir(path, LIBHOST_NAME))
|
||||
if (library_exists_in_dir(path, LIBHOSTPOLICY_NAME))
|
||||
{
|
||||
resolved_dir->assign(path);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#ifndef __LIBHOST_H__
|
||||
#define __LIBHOST_H__
|
||||
|
||||
#define LIBHOST_NAME MAKE_LIBNAME("hostpolicy")
|
||||
|
||||
enum host_mode_t
|
||||
{
|
||||
invalid = 0,
|
||||
|
|
|
@ -65,6 +65,10 @@
|
|||
#define LIBCORECLR_FILENAME (LIB_PREFIX _X("coreclr"))
|
||||
#define LIBCORECLR_NAME MAKE_LIBNAME("coreclr")
|
||||
|
||||
|
||||
#define LIBHOSTPOLICY_FILENAME (LIB_PREFIX _X("hostpolicy"))
|
||||
#define LIBHOSTPOLICY_NAME MAKE_LIBNAME("hostpolicy")
|
||||
|
||||
#if !defined(PATH_MAX) && !defined(_WIN32)
|
||||
#define PATH_MAX 4096
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue