From: 조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 Date: Wed, 5 Jan 2022 04:32:46 +0000 (+0900) Subject: Add plugin API for setting extra dll path (#353) X-Git-Tag: submit/tizen/20220110.045001~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f1f56dfa11d2c5636ce5916c2806873031e4495;p=platform%2Fcore%2Fdotnet%2Flauncher.git Add plugin API for setting extra dll path (#353) There is a requirement to add a searching path for a specific app. For this requirement, a new plugin API is added to get the extra searching path. --- diff --git a/NativeLauncher/dotnet-plugin/dotnet_plugin.cc b/NativeLauncher/dotnet-plugin/dotnet_plugin.cc index 539d5ae..d101f2a 100644 --- a/NativeLauncher/dotnet-plugin/dotnet_plugin.cc +++ b/NativeLauncher/dotnet-plugin/dotnet_plugin.cc @@ -51,6 +51,12 @@ char* plugin_get_dll_path() return ""; } +char* plugin_get_extra_dll_path() +{ + _SOUT("### plugin_get_extra_dll_path called"); + return "/tmp"; +} + char* plugin_get_native_dll_searching_path() { _SOUT("### plugin_get_native_dll_searching_path called"); diff --git a/NativeLauncher/inc/dotnet_launcher_plugin.h b/NativeLauncher/inc/dotnet_launcher_plugin.h index 517bbb1..9385485 100644 --- a/NativeLauncher/inc/dotnet_launcher_plugin.h +++ b/NativeLauncher/inc/dotnet_launcher_plugin.h @@ -63,6 +63,12 @@ extern "C" */ char* plugin_get_dll_path(); + /** + * @brief return additional pathes to find app assembly. + * @return ":" seperated pathes + */ + char* plugin_get_extra_dll_path(); + /** * @brief return additional searching pathes to find native libraries. * @return ":" seperated pathes diff --git a/NativeLauncher/inc/path_manager.h b/NativeLauncher/inc/path_manager.h index fb24637..b3bc88e 100644 --- a/NativeLauncher/inc/path_manager.h +++ b/NativeLauncher/inc/path_manager.h @@ -132,6 +132,12 @@ public: */ const std::string& getAppNIPaths(); + /** + * @brief Set addtional dll searching path for App. + * @param[in] paths path + */ + void setExtraDllPaths(const char* paths); + /** * @brief Get the list of directories where the native libraries of this application exist * @return the list(":" seperated) of paths the loader should probe when looking for native libraries @@ -159,6 +165,7 @@ private: std::string appNIPaths; std::string nativeDllSearchingPaths; std::string appTacPath; + std::string extraDllPaths; int rootFD; int niRootFD; }; diff --git a/NativeLauncher/inc/plugin_manager.h b/NativeLauncher/inc/plugin_manager.h index 15c495e..13d5281 100644 --- a/NativeLauncher/inc/plugin_manager.h +++ b/NativeLauncher/inc/plugin_manager.h @@ -30,6 +30,7 @@ typedef void (*plugin_set_coreclr_info_ptr)( unsigned int domainId, coreclr_create_delegate_ptr delegateFunc); typedef char* (*plugin_get_dll_path_ptr)(); +typedef char* (*plugin_get_extra_dll_path_ptr)(); typedef char* (*plugin_get_native_dll_searching_path_ptr)(); typedef char* (*plugin_get_tpa_ptr)(); typedef void (*plugin_before_execute_ptr)(); @@ -42,6 +43,7 @@ typedef struct PluginFunc { plugin_set_app_info_ptr set_app_info; plugin_set_coreclr_info_ptr set_coreclr_info; plugin_get_dll_path_ptr get_dll_path; + plugin_get_extra_dll_path_ptr get_extra_dll_path; plugin_get_native_dll_searching_path_ptr get_native_dll_searching_path; plugin_get_tpa_ptr get_tpa; plugin_before_execute_ptr before_execute; @@ -54,6 +56,7 @@ bool pluginHasLogControl(); void pluginSetAppInfo(const char* appId, const char* managedAssemblyPath); void pluginSetCoreclrInfo(void* hostHandle, unsigned int domainId, coreclr_create_delegate_ptr delegateFunc); char* pluginGetDllPath(); +char* pluginGetExtraDllPath(); char* pluginGetNativeDllSearchingPath(); char* pluginGetTPA(); void pluginBeforeExecute(); diff --git a/NativeLauncher/launcher/lib/core_runtime.cc b/NativeLauncher/launcher/lib/core_runtime.cc index eafb586..c7e1577 100644 --- a/NativeLauncher/launcher/lib/core_runtime.cc +++ b/NativeLauncher/launcher/lib/core_runtime.cc @@ -396,6 +396,11 @@ int CoreRuntime::initialize(const char* appType, LaunchMode launchMode) __pm->addNativeDllSearchingPaths(pluginNativePaths, true); } + char* pluginExtraDllPaths = pluginGetExtraDllPath(); + if (pluginExtraDllPaths && pluginExtraDllPaths[0] != '\0') { + __pm->setExtraDllPaths(pluginExtraDllPaths); + } + pluginHasLogControl(); std::string libCoreclr(concatPath(__pm->getRuntimePath(), "libcoreclr.so")); diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index ed24af3..7abedcd 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -789,6 +789,11 @@ ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt) __pm->setAppRootPath(rootPath); + char* extraDllPaths = pluginGetExtraDllPath(); + if (extraDllPaths && extraDllPaths[0] != '\0') { + __pm->setExtraDllPaths(extraDllPaths); + } + opt->flags |= NI_FLAGS_APPNI; if (isReadOnlyArea(rootPath)) { diff --git a/NativeLauncher/util/path_manager.cc b/NativeLauncher/util/path_manager.cc index 6ecd556..664da52 100644 --- a/NativeLauncher/util/path_manager.cc +++ b/NativeLauncher/util/path_manager.cc @@ -64,7 +64,12 @@ void PathManager::updateAppRelatedPath(const std::string& appRootPath, const std appTacPath = concatPath(appBinPath, TAC_SYMLINK_SUB_DIR); appPaths = appRootPath + ":" + appBinPath + ":" + appLibPath + ":" + appTacPath; - appNIPaths = appNIBinPath + ":" + appNILibPath + ":"+ appTacPath; + appNIPaths = appNIBinPath + ":" + appNILibPath + ":" + appTacPath; + + if (!extraDllPaths.empty()) { + appPaths = appPaths + ":" + extraDllPaths; + appNIPaths = appNIPaths + ":" + extraDllPaths; + } } PathManager::PathManager() : @@ -180,6 +185,16 @@ void PathManager::setAppRootPath(const std::string& rootPath) updateAppRelatedPath(appRootPath, appNIRootPath); } +// paths: ":" separated muliple path. +void PathManager::setExtraDllPaths(const char* paths) +{ + extraDllPaths = std::string(paths); + if (!extraDllPaths.empty()) { + appPaths = appPaths + ":" + extraDllPaths; + appNIPaths = appNIPaths + ":" + extraDllPaths; + } +} + const std::string& PathManager::getRuntimePath() { return runtimePath; diff --git a/NativeLauncher/util/plugin_manager.cc b/NativeLauncher/util/plugin_manager.cc index 957d522..0e38f4e 100644 --- a/NativeLauncher/util/plugin_manager.cc +++ b/NativeLauncher/util/plugin_manager.cc @@ -47,6 +47,7 @@ int initializePluginManager(const char* appType) __pluginFunc->set_app_info = (plugin_set_app_info_ptr)dlsym(__pluginLib, "plugin_set_app_info"); __pluginFunc->set_coreclr_info = (plugin_set_coreclr_info_ptr)dlsym(__pluginLib, "plugin_set_coreclr_info"); __pluginFunc->get_dll_path = (plugin_get_dll_path_ptr)dlsym(__pluginLib, "plugin_get_dll_path"); + __pluginFunc->get_extra_dll_path = (plugin_get_extra_dll_path_ptr)dlsym(__pluginLib, "plugin_get_extra_dll_path"); __pluginFunc->get_native_dll_searching_path = (plugin_get_native_dll_searching_path_ptr)dlsym(__pluginLib, "plugin_get_native_dll_searching_path"); __pluginFunc->get_tpa = (plugin_get_tpa_ptr)dlsym(__pluginLib, "plugin_get_tpa"); __pluginFunc->before_execute = (plugin_before_execute_ptr)dlsym(__pluginLib, "plugin_before_execute"); @@ -122,6 +123,15 @@ char* pluginGetDllPath() } } +char* pluginGetExtraDllPath() +{ + if (__pluginFunc && __pluginFunc->get_extra_dll_path) { + return __pluginFunc->get_extra_dll_path(); + } else { + return NULL; + } +} + char* pluginGetNativeDllSearchingPath() { if (__pluginFunc && __pluginFunc->get_native_dll_searching_path) {