X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=NativeLauncher%2Flauncher%2Flib%2Fcore_runtime.cc;h=ba874aabfe212c89614996224e01cf8acc0477be;hb=546f3a3947b7e7c205a4799156bcd41bc5ae3c2e;hp=5f1be89cfe28738c050c6cb9a411acfbcf41e283;hpb=841a169fddd9c86764e081fbe2c9e56eab583785;p=platform%2Fcore%2Fdotnet%2Flauncher.git diff --git a/NativeLauncher/launcher/lib/core_runtime.cc b/NativeLauncher/launcher/lib/core_runtime.cc index 5f1be89..ba874aa 100644 --- a/NativeLauncher/launcher/lib/core_runtime.cc +++ b/NativeLauncher/launcher/lib/core_runtime.cc @@ -33,10 +33,11 @@ #include #include #include +#include -#include #include #include +#include #include @@ -142,55 +143,36 @@ static void registerSigHandler() } } -static bool storage_cb(int id, storage_type_e type, storage_state_e state, const char *path, void *user_data) -{ - int* tmp = (int*)user_data; - if (type == STORAGE_TYPE_INTERNAL) - { - *tmp = id; - return false; - } - - return true; -} - -static void setSpecialFolder(storage_directory_e type, const char* key) -{ - int error; - char* path = NULL; - static int __storageId = -1; - - if (__storageId < 0) { - error = storage_foreach_device_supported(storage_cb, &__storageId); - if (error != STORAGE_ERROR_NONE) { - return; - } - } - - error = storage_get_directory(__storageId, type, &path); - if (error == STORAGE_ERROR_NONE && path != NULL) { - setenv(key, const_cast(path), 1); - free(path); - } -} - static void initEnvForSpecialFolder() { + const char* path = NULL; if (getenv("XDG_PICTURES_DIR") == NULL) { - setSpecialFolder(STORAGE_DIRECTORY_IMAGES, "XDG_PICTURES_DIR"); + path = tzplatform_getenv(TZ_USER_IMAGES); + if (path) { + setenv("XDG_PICTURES_DIR", path, 1); + } } if (getenv("XDG_MUSIC_DIR") == NULL) { - setSpecialFolder(STORAGE_DIRECTORY_MUSIC, "XDG_MUSIC_DIR"); + path = tzplatform_getenv(TZ_USER_MUSIC); + if (path) { + setenv("XDG_MUSIC_DIR", path, 1); + } } if (getenv("XDG_VIDEOS_DIR") == NULL) { - setSpecialFolder(STORAGE_DIRECTORY_VIDEOS, "XDG_VIDEOS_DIR"); + path = tzplatform_getenv(TZ_USER_VIDEOS); + if (path) { + setenv("XDG_VIDEOS_DIR", path, 1); + } } } static void setLang() { + //To reduce search overhead of libicuuc.so.xx + setenv("CLR_ICU_VERSION_OVERRIDE", "build", 1); + char* lang = vconf_get_str(VCONFKEY_LANGSET); if (!lang) { _ERR("Fail to get language from vconf"); @@ -317,9 +299,6 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) return -1; } - // Intiailize ecore first (signal handlers, etc.) before runtime init. - ecore_init(); - // set language environment to support ICU setLang(); @@ -354,10 +333,10 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) // See https://github.com/dotnet/coreclr/issues/6698 // // libunwind use following methods to unwind stack frame. - // UNW_ARM_METHOD_ALL 0xFF - // UNW_ARM_METHOD_DWARF 0x01 - // UNW_ARM_METHOD_FRAME 0x02 - // UNW_ARM_METHOD_EXIDX 0x04 + // UNW_ARM_METHOD_ALL 0xFF + // UNW_ARM_METHOD_DWARF 0x01 + // UNW_ARM_METHOD_FRAME 0x02 + // UNW_ARM_METHOD_EXIDX 0x04 putenv(const_cast("UNW_ARM_UNWIND_METHOD=6")); #endif // __arm__ @@ -375,6 +354,9 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) // Disable config cache to set environment after coreclr_initialize() putenv(const_cast("COMPlus_DisableConfigCache=1")); + // Set environment variable for System.Environment.SpecialFolder + initEnvForSpecialFolder(); + // read string from external file and set them to environment value. setEnvFromFile(); @@ -400,8 +382,6 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) __pm->setExtraDllPaths(pluginExtraDllPaths); } - pluginHasLogControl(); - std::string libCoreclr(concatPath(__pm->getRuntimePath(), "libcoreclr.so")); __coreclrLib = dlopen(libCoreclr.c_str(), RTLD_NOW | RTLD_LOCAL); @@ -429,12 +409,6 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) _INFO("libcoreclr dlopen and dlsym success"); - // Set environment for System.Environment.SpecialFolder - // Below function creates dbus connection by callging storage API. - // If dbus connection is created bofere fork(), forked process cannot use dbus. - // To avoid gdbus blocking issue, below function should be called after fork() - initEnvForSpecialFolder(); - std::string tpa; char* pluginTPA = pluginGetTPA(); if (pluginTPA && pluginTPA[0] != '\0') { @@ -448,6 +422,11 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) return -1; } + // VD has their own signal handler. + if (!pluginHasLogControl()) { + registerSigHandler(); + } + int st = createDelegate(__hostHandle, __domainId, "Tizen.Runtime", "Tizen.Runtime.Environment", "SetEnvironmentVariable", (void**)&setEnvironmentVariable); if (st < 0 || setEnvironmentVariable == nullptr) { _ERR("Create delegate for Tizen.Runtime.dll -> Tizen.Runtime.Environment -> SetEnvironmentVariable failed (0x%08x)", st); @@ -467,7 +446,6 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) } if (launchMode == LaunchMode::loader) { - // preload libraries and manage dlls for optimizing startup time preload(); @@ -496,7 +474,7 @@ void CoreRuntime::finalize() checkOnTerminate = true; // workaround : to prevent crash while process terminate on profiling mode, - // kill process immediately. + // kill process immediately. // see https://github.com/dotnet/coreclr/issues/26687 if (__isProfileMode) { _INFO("shutdown process immediately."); @@ -545,11 +523,6 @@ int CoreRuntime::launch(const char* appId, const char* root, const char* path, i return -1; } - // VD has their own signal handler. - if (!pluginHasLogControl()) { - registerSigHandler(); - } - pluginSetAppInfo(appId, path); // temporal root path is overrided to real application root path