parent
96c62d2d25
commit
103aaa4d8e
7 changed files with 66 additions and 3 deletions
|
@ -108,6 +108,8 @@ namespace pal
|
||||||
bool load_library(const char_t* path, dll_t& dll);
|
bool load_library(const char_t* path, dll_t& dll);
|
||||||
proc_t get_symbol(dll_t library, const char* name);
|
proc_t get_symbol(dll_t library, const char* name);
|
||||||
void unload_library(dll_t library);
|
void unload_library(dll_t library);
|
||||||
|
|
||||||
|
bool find_coreclr(pal::string_t& recv);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // PAL_H
|
#endif // PAL_H
|
||||||
|
|
|
@ -11,5 +11,6 @@ pal::string_t get_executable(const pal::string_t& filename);
|
||||||
pal::string_t get_directory(const pal::string_t& path);
|
pal::string_t get_directory(const pal::string_t& path);
|
||||||
pal::string_t get_filename(const pal::string_t& path);
|
pal::string_t get_filename(const pal::string_t& path);
|
||||||
void append_path(pal::string_t& path1, const pal::char_t* path2);
|
void append_path(pal::string_t& path1, const pal::char_t* path2);
|
||||||
|
bool coreclr_exists_in_dir(const pal::string_t& candidate);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -79,6 +79,14 @@ bool parse_arguments(const int argc, const pal::char_t* argv[], arguments_t& arg
|
||||||
append_path(home_str, _X("coreclr"));
|
append_path(home_str, _X("coreclr"));
|
||||||
args.clr_path.assign(home_str);
|
args.clr_path.assign(home_str);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Use platform-specific search algorithm
|
||||||
|
if (pal::find_coreclr(home_str))
|
||||||
|
{
|
||||||
|
args.clr_path.assign(home_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,14 +214,14 @@ int main(const int argc, const pal::char_t* argv[])
|
||||||
trace::info(_X("preparing to launch: %s"), app_name.c_str());
|
trace::info(_X("preparing to launch: %s"), app_name.c_str());
|
||||||
trace::info(_X("using app base: %s"), app_base.c_str());
|
trace::info(_X("using app base: %s"), app_base.c_str());
|
||||||
|
|
||||||
// Check for and load tpa file
|
// Check for and load deps file
|
||||||
pal::string_t tpafile_path;
|
pal::string_t tpafile_path;
|
||||||
get_tpafile_path(app_base, app_name, tpafile_path);
|
get_tpafile_path(app_base, app_name, tpafile_path);
|
||||||
trace::info(_X("checking for TPA File at: %s"), tpafile_path.c_str());
|
trace::info(_X("checking for .deps File at: %s"), tpafile_path.c_str());
|
||||||
tpafile tpa;
|
tpafile tpa;
|
||||||
if (!tpa.load(tpafile_path))
|
if (!tpa.load(tpafile_path))
|
||||||
{
|
{
|
||||||
trace::error(_X("invalid TPA file"));
|
trace::error(_X("invalid .deps file"));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return run(args, app_base, tpa);
|
return run(args, app_base, tpa);
|
||||||
|
|
|
@ -19,6 +19,32 @@
|
||||||
#define symlinkEntrypointExecutable "/proc/curproc/exe"
|
#define symlinkEntrypointExecutable "/proc/curproc/exe"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool coreclr_exists_in_dir(const pal::string_t& candidate)
|
||||||
|
{
|
||||||
|
pal::string_t test(candidate);
|
||||||
|
append_path(test, _X("runtime"));
|
||||||
|
append_path(test, LIBCORECLR_NAME);
|
||||||
|
return pal::file_exists(test);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pal::find_coreclr(pal::string_t& recv)
|
||||||
|
{
|
||||||
|
pal::string_t candidate;
|
||||||
|
pal::string_t test;
|
||||||
|
|
||||||
|
// Try %LocalAppData%\dotnet
|
||||||
|
if (pal::getenv(_X("LocalAppData"), candidate)) {
|
||||||
|
append_path(candidate, _X("dotnet"));
|
||||||
|
if (coreclr_exists_in_dir(candidate)) {
|
||||||
|
recv.assign(candidate);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Try somewhere in Program Files, see https://github.com/dotnet/cli/issues/249
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool pal::load_library(const char_t* path, dll_t& dll)
|
bool pal::load_library(const char_t* path, dll_t& dll)
|
||||||
{
|
{
|
||||||
dll = dlopen(path, RTLD_LAZY);
|
dll = dlopen(path, RTLD_LAZY);
|
||||||
|
|
|
@ -10,6 +10,24 @@
|
||||||
|
|
||||||
static std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> g_converter;
|
static std::wstring_convert<std::codecvt_utf8<wchar_t>, wchar_t> g_converter;
|
||||||
|
|
||||||
|
bool pal::find_coreclr(pal::string_t& recv)
|
||||||
|
{
|
||||||
|
pal::string_t candidate;
|
||||||
|
pal::string_t test;
|
||||||
|
|
||||||
|
// Try %LocalAppData%\dotnet
|
||||||
|
if (pal::getenv(_X("LocalAppData"), candidate)) {
|
||||||
|
append_path(candidate, _X("dotnet"));
|
||||||
|
if (coreclr_exists_in_dir(candidate)) {
|
||||||
|
recv.assign(candidate);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Try somewhere in Program Files, see https://github.com/dotnet/cli/issues/249
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool pal::load_library(const char_t* path, dll_t& dll)
|
bool pal::load_library(const char_t* path, dll_t& dll)
|
||||||
{
|
{
|
||||||
dll = ::LoadLibraryW(path);
|
dll = ::LoadLibraryW(path);
|
||||||
|
|
|
@ -3,6 +3,14 @@
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
bool coreclr_exists_in_dir(const pal::string_t& candidate)
|
||||||
|
{
|
||||||
|
pal::string_t test(candidate);
|
||||||
|
append_path(test, _X("runtime"));
|
||||||
|
append_path(test, LIBCORECLR_NAME);
|
||||||
|
return pal::file_exists(test);
|
||||||
|
}
|
||||||
|
|
||||||
bool ends_with(const pal::string_t& value, const pal::string_t& suffix)
|
bool ends_with(const pal::string_t& value, const pal::string_t& suffix)
|
||||||
{
|
{
|
||||||
return suffix.length() <= value.length() &&
|
return suffix.length() <= value.length() &&
|
||||||
|
|
Loading…
Add table
Reference in a new issue