diff options
Diffstat (limited to 'NativeLauncher/src/dotnet/dotnet_launcher.cc')
-rw-r--r-- | NativeLauncher/src/dotnet/dotnet_launcher.cc | 162 |
1 files changed, 51 insertions, 111 deletions
diff --git a/NativeLauncher/src/dotnet/dotnet_launcher.cc b/NativeLauncher/src/dotnet/dotnet_launcher.cc index 4942710..62738a3 100644 --- a/NativeLauncher/src/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/src/dotnet/dotnet_launcher.cc @@ -3,7 +3,6 @@ #include <string> #include <fstream> -#include <thread> #include <vector> #include "utils.h" @@ -15,43 +14,12 @@ namespace tizen { namespace runtime { namespace dotnetcore { - -void CoreRuntime::SetStandaloneExe(const char* exePath, int argc, char* argv[]) -{ - if (exePath == nullptr) - { - _ERR("executable path is null"); - return; - } - - if (FileNotExist(exePath)) - { - _ERR("File not exist : %s", exePath); - return; - } - - isLaunched = true; - LaunchParam.path = exePath; - LaunchParam.argc = argc; - LaunchParam.argv = argv; - - const char *_deviceapi_directory = getenv("DeviceAPIDirectory"); - const char *_runtime_directory = getenv("RuntimeDirectory"); - const char *_launcher_assembly = getenv("LauncherAssembly"); - if (_deviceapi_directory != nullptr) - DeviceAPIDirectory = _deviceapi_directory; - if (_runtime_directory != nullptr) - RuntimeDirectory = _runtime_directory; - if (_launcher_assembly != nullptr) - LauncherAssembly = _launcher_assembly; -} - CoreRuntime::CoreRuntime() : coreclrLib(nullptr), hostHandle(nullptr), domainId(-1), + PreparedFunction(nullptr), LaunchFunction(nullptr), - isLaunched(false), InitializeClr(nullptr), ExecuteAssembly(nullptr), Shutdown(nullptr), @@ -66,8 +34,8 @@ CoreRuntime::CoreRuntime() : #ifdef RUNTIME_DIR RuntimeDirectory = __STR(RUNTIME_DIR); #endif -#ifdef LAUNCHER_ASSEMBLY_PATH - LauncherAssembly = __STR(LAUNCHER_ASSEMBLY_PATH); +#ifdef CORECLR_LAUNCHER_ASSEMBLY_PATH + LauncherAssembly = __STR(CORECLR_LAUNCHER_ASSEMBLY_PATH); #endif #undef __STR @@ -81,9 +49,22 @@ CoreRuntime::~CoreRuntime() Dispose(); } -int CoreRuntime::Initialize() +int CoreRuntime::Initialize(bool standalone) { + if (standalone) + { + const char *_deviceapi_directory = getenv("DeviceAPIDirectory"); + const char *_runtime_directory = getenv("RuntimeDirectory"); + const char *_launcher_assembly = getenv("LauncherAssembly"); + if (_deviceapi_directory != nullptr) + DeviceAPIDirectory = _deviceapi_directory; + if (_runtime_directory != nullptr) + RuntimeDirectory = _runtime_directory; + if (_launcher_assembly != nullptr) + LauncherAssembly = _launcher_assembly; + } + if (DeviceAPIDirectory.empty()) { _ERR("Empty Device API Directory"); @@ -190,7 +171,7 @@ int CoreRuntime::RunManagedLauncher() "UseLatestBehaviorWhenTFMNotSpecified" }; -// _DBG("trusted platform assemblies : %s", propertyValues[0]); + _DBG("trusted platform assemblies : %s", propertyValues[0]); _DBG("app_path : %s", propertyValues[1]); _DBG("app_ni_path : %s", propertyValues[2]); _DBG("native dll search path : %s", propertyValues[3]); @@ -224,40 +205,34 @@ int CoreRuntime::RunManagedLauncher() _DBG("Initialize core clr success"); - void *launchFunctionDelegate; + void *preparedFunctionDelegate; st = CreateDelegate(hostHandle, domainId, - "Tizen.Runtime", - "Tizen.Runtime.AssemblyManager", - "Launch", &launchFunctionDelegate); + "Tizen.Runtime.Coreclr", + "Tizen.Runtime.Coreclr.AssemblyManager", + "Prepared", &preparedFunctionDelegate); if (st < 0) { - _ERR("Create delegate for Launch managed function is fail! (0x%08x)", st); + _ERR("Create delegate for Launch prepared function is fail (0x%08x)", st); return 1; } - LaunchFunction = reinterpret_cast<LaunchFunctionPtr>(launchFunctionDelegate); + PreparedFunction = reinterpret_cast<PreparedFunctionPtr>(preparedFunctionDelegate); - if (isLaunched) + if(PreparedFunction != nullptr) { - bool success = LaunchFunction(LaunchParam.path.c_str(), - LaunchParam.argc, LaunchParam.argv); - if (!success) - { - _ERR("Failed to Launching"); - } + PreparedFunction(); } - /* - unsigned int exitCode; - const char* argv[] = {LauncherAssembly.c_str()}; - st = ExecuteAssembly(hostHandle, domainId, - 1, argv, LauncherAssembly.c_str(), &exitCode); - _DBG("after execute coreclr"); + void *launchFunctionDelegate; + st = CreateDelegate(hostHandle, domainId, + "Tizen.Runtime.Coreclr", + "Tizen.Runtime.Coreclr.AssemblyManager", + "Launch", &launchFunctionDelegate); if (st < 0) { - _ERR("execute core clr fail! (0x%08x / %d)", st, exitCode); + _ERR("Create delegate for Launch managed function is fail! (0x%08x)", st); return 1; } - */ + LaunchFunction = reinterpret_cast<LaunchFunctionPtr>(launchFunctionDelegate); return 0; } @@ -282,67 +257,32 @@ void CoreRuntime::Dispose() _DBG("Dotnet runtime disposed"); } -int CoreRuntime::Launch(const char* path, int argc, char* argv[]) +int CoreRuntime::Launch(const char* root, const char* path, int argc, char* argv[]) { - if (LaunchFunction != nullptr) + if (path == nullptr) { - LaunchFunction(path, argc, argv); + _ERR("executable path is null"); + return 1; } - else + + if (FileNotExist(path)) { - LaunchParam.path = path; - LaunchParam.argc = argc; - LaunchParam.argv = argv; + _ERR("File not exist : %s", path); + return 1; } - isLaunched = true; - return 0; -} - -} // namespace dotnetcore -} // namespace runtime -} // namespace tizen - -static std::string StandaloneOption("--standalone"); - -#include "base64.h" - -int main(int argc, char *argv[]) -{ - int i; - bool standalone = false; - const char* standalonePath = nullptr; - - for (i=1; i<argc; i++) + bool success = false; + if (LaunchFunction != nullptr) { - if (StandaloneOption.compare(argv[i]) == 0) - { - standalone = true; - } - else + success = LaunchFunction(root, path, argc, argv); + if (!success) { - if (standalonePath == nullptr) - standalonePath = argv[i]; + _ERR("Failed to launch Application %s", path); } } - - tizen::runtime::dotnetcore::CoreRuntime runtime; - if (standalone) - { - runtime.SetStandaloneExe(standalonePath, argc, argv); - } - else - { - tizen::runtime::Launchpad.LoaderMain(&runtime, argc, argv); - } - - runtime.Initialize(); - runtime.RunManagedLauncher(); - - if (!standalone) - { - tizen::runtime::Launchpad.WaitUtilLaunched(); - } - - return 0; + return success ? 0 : 1; } + +} // namespace dotnetcore +} // namespace runtime +} // namespace tizen |