Resolve sym links to probe paths on Unix
This commit is contained in:
parent
c055db7464
commit
45bee52522
6 changed files with 47 additions and 30 deletions
|
@ -78,7 +78,7 @@ bool parse_arguments(const int argc, const pal::char_t* argv[], arguments_t& arg
|
|||
args.app_argc = argc - 1;
|
||||
}
|
||||
|
||||
if(args.app_argc > 0)
|
||||
if (args.app_argc > 0)
|
||||
{
|
||||
auto depsfile_candidate = pal::string_t(args.app_argv[0]);
|
||||
|
||||
|
|
|
@ -96,7 +96,12 @@ void add_tpa_asset(
|
|||
}
|
||||
|
||||
trace::verbose(_X("Adding tpa entry: %s"), asset_path.c_str());
|
||||
output->append(asset_path);
|
||||
|
||||
// Workaround for CoreFX not being able to resolve sym links.
|
||||
pal::string_t real_asset_path = asset_path;
|
||||
pal::realpath(&real_asset_path);
|
||||
output->append(real_asset_path);
|
||||
|
||||
output->push_back(PATH_SEPARATOR);
|
||||
items->insert(asset_name);
|
||||
}
|
||||
|
@ -111,14 +116,14 @@ void add_mscorlib_to_tpa(const pal::string_t& clr_dir, std::set<pal::string_t>*
|
|||
pal::string_t mscorlib_ni_path = clr_dir + DIR_SEPARATOR + _X("mscorlib.ni.dll");
|
||||
if (pal::file_exists(mscorlib_ni_path))
|
||||
{
|
||||
add_tpa_asset(_X("mscorlib"), mscorlib_ni_path, items, output);
|
||||
add_tpa_asset(_X("mscorlib"), mscorlib_ni_path, items, output);
|
||||
return;
|
||||
}
|
||||
|
||||
pal::string_t mscorlib_path = clr_dir + DIR_SEPARATOR + _X("mscorlib.dll");
|
||||
if (pal::file_exists(mscorlib_path))
|
||||
{
|
||||
add_tpa_asset(_X("mscorlib"), mscorlib_ni_path, items, output);
|
||||
add_tpa_asset(_X("mscorlib"), mscorlib_ni_path, items, output);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -133,15 +138,21 @@ void add_unique_path(
|
|||
std::set<pal::string_t>* existing,
|
||||
pal::string_t* output)
|
||||
{
|
||||
if (existing->count(path))
|
||||
// Resolve sym links.
|
||||
pal::string_t real = path;
|
||||
pal::realpath(&real);
|
||||
|
||||
if (existing->count(real))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
trace::verbose(_X("Adding to %s path: %s"), type.c_str(), path.c_str());
|
||||
output->append(path);
|
||||
trace::verbose(_X("Adding to %s path: %s"), type.c_str(), real.c_str());
|
||||
|
||||
output->append(real);
|
||||
|
||||
output->push_back(PATH_SEPARATOR);
|
||||
existing->insert(path);
|
||||
existing->insert(real);
|
||||
}
|
||||
|
||||
} // end of anonymous namespace
|
||||
|
|
|
@ -196,6 +196,8 @@ int run(const arguments_t& args, const pal::string_t& clr_path)
|
|||
argv[i] = argv_strs[i].c_str();
|
||||
}
|
||||
|
||||
std::string managed_app = pal::to_stdstring(args.managed_application);
|
||||
|
||||
// Execute the application
|
||||
unsigned int exit_code = 1;
|
||||
hr = coreclr::execute_assembly(
|
||||
|
@ -203,7 +205,7 @@ int run(const arguments_t& args, const pal::string_t& clr_path)
|
|||
domain_id,
|
||||
argv.size(),
|
||||
argv.data(),
|
||||
pal::to_stdstring(args.managed_application).c_str(),
|
||||
managed_app.c_str(),
|
||||
&exit_code);
|
||||
if (!SUCCEEDED(hr))
|
||||
{
|
||||
|
@ -225,6 +227,8 @@ int run(const arguments_t& args, const pal::string_t& clr_path)
|
|||
|
||||
SHARED_API int corehost_main(const int argc, const pal::char_t* argv[])
|
||||
{
|
||||
trace::setup();
|
||||
|
||||
// Take care of arguments
|
||||
arguments_t args;
|
||||
if (!parse_arguments(argc, argv, args))
|
||||
|
@ -239,5 +243,6 @@ SHARED_API int corehost_main(const int argc, const pal::char_t* argv[])
|
|||
trace::error(_X("Could not resolve coreclr path"));
|
||||
return StatusCode::CoreClrResolveFailure;
|
||||
}
|
||||
pal::realpath(&clr_path);
|
||||
return run(args, clr_path);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,26 @@
|
|||
|
||||
static bool g_enabled = false;
|
||||
|
||||
//
|
||||
// Turn on tracing for the corehost based on "COREHOST_TRACE" env.
|
||||
//
|
||||
void trace::setup()
|
||||
{
|
||||
// Read trace environment variable
|
||||
pal::string_t trace_str;
|
||||
if (!pal::getenv(_X("COREHOST_TRACE"), &trace_str))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto trace_val = pal::xtoi(trace_str.c_str());
|
||||
if (trace_val > 0)
|
||||
{
|
||||
trace::enable();
|
||||
trace::info(_X("Tracing enabled"));
|
||||
}
|
||||
}
|
||||
|
||||
void trace::enable()
|
||||
{
|
||||
g_enabled = true;
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
namespace trace
|
||||
{
|
||||
void setup();
|
||||
void enable();
|
||||
bool is_enabled();
|
||||
void verbose(const pal::char_t* format, ...);
|
||||
|
|
|
@ -59,26 +59,6 @@ StatusCode load_host_lib(const pal::string_t& lib_dir, pal::dll_t* h_host, coreh
|
|||
: StatusCode::CoreHostEntryPointFailure;
|
||||
}
|
||||
|
||||
//
|
||||
// Turn on tracing for the corehost based on "COREHOST_TRACE" env.
|
||||
//
|
||||
void setup_tracing()
|
||||
{
|
||||
// Read trace environment variable
|
||||
pal::string_t trace_str;
|
||||
if (!pal::getenv(_X("COREHOST_TRACE"), &trace_str))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto trace_val = pal::xtoi(trace_str.c_str());
|
||||
if (trace_val > 0)
|
||||
{
|
||||
trace::enable();
|
||||
trace::info(_X("Tracing enabled"));
|
||||
}
|
||||
}
|
||||
|
||||
}; // end of anonymous namespace
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
@ -87,7 +67,7 @@ int __cdecl wmain(const int argc, const pal::char_t* argv[])
|
|||
int main(const int argc, const pal::char_t* argv[])
|
||||
#endif
|
||||
{
|
||||
setup_tracing();
|
||||
trace::setup();
|
||||
|
||||
pal::dll_t corehost;
|
||||
|
||||
|
|
Loading…
Reference in a new issue