There are some cases to add dll and native library searching path through plugin API.
The adding dll searching path was already supported, but the adding native library searching part is missing, so this part is added.
The added searching path by plugin has the highest priority. (VD requirement)
Additionally, an environment for building simple libdotnet_plugin.so for testing was also added.
SET_TARGET_PROPERTIES(${DELETE_UNUSED_LIBRARY_PLUGIN} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB})
TARGET_LINK_LIBRARIES(${DELETE_UNUSED_LIBRARY_PLUGIN} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${MULTI_TARGET_RESOLVER})
+# Build for test plugin library (libdotnet-plugin.so)
+IF(DEFINED BUILD_DOTNET_PLUGIN)
+ SET(DOTNET_PLUGIN "dotnet_plugin")
+ SET(${DOTNET_PLUGIN}_SOURCE_FILES
+ dotnet-plugin/dotnet_plugin.cc
+ )
+ ADD_LIBRARY(${DOTNET_PLUGIN} SHARED ${${DOTNET_PLUGIN}_SOURCE_FILES})
+ SET_TARGET_PROPERTIES(${DOTNET_PLUGIN} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB})
+ TARGET_LINK_LIBRARIES(${DOTNET_PLUGIN} ${${PROJECT_NAME}_LDFLAGS})
+ENDIF(DEFINED BUILD_DOTNET_PLUGIN)
+
CONFIGURE_FILE(dotnet-launcher.pc.in dotnet-launcher.pc @ONLY)
INSTALL(TARGETS ${DOTNET_LAUNCHER_UTIL} DESTINATION ${LIBDIR})
INSTALL(FILES inc/tac_common.h DESTINATION ${INCLUDEDIR})
INSTALL(FILES ../dotnet-launcher.pc DESTINATION ${LIBDIR}/pkgconfig)
INSTALL(FILES dotnet-launcher.info DESTINATION /usr/share/parser-plugins)
+IF(DEFINED BUILD_DOTNET_PLUGIN)
+ INSTALL(TARGETS ${DOTNET_PLUGIN} DESTINATION ${NATIVE_LIB_DIR})
+ENDIF(DEFINED BUILD_DOTNET_PLUGIN)
+
--- /dev/null
+/*\r
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include <unistd.h>\r
+\r
+#include "dotnet_launcher_plugin.h"\r
+#include "log.h"\r
+\r
+void plugin_initialize(const char* appType)\r
+{\r
+ _SOUT("### plugin_initialize called");\r
+}\r
+\r
+void plugin_preload()\r
+{\r
+ _SOUT("### plugin_preload called");\r
+}\r
+\r
+void plugin_set_app_info(const char* appId, const char* managedAssemblyPath)\r
+{\r
+ _SOUT("### plugin_set_app_info called");\r
+}\r
+\r
+bool plugin_has_log_control()\r
+{\r
+ _SOUT("### plugin_has_log_control called");\r
+ return false;\r
+}\r
+\r
+void plugin_set_coreclr_info(void* hostHandle, unsigned int domainId, coreclr_create_delegate_ptr delegateFunc)\r
+{\r
+ _SOUT("### plugin_set_coreclr_info called");\r
+}\r
+\r
+char* plugin_get_dll_path()\r
+{\r
+ _SOUT("### plugin_get_dll_path called");\r
+ return "";\r
+}\r
+\r
+char* plugin_get_native_dll_searching_path()\r
+{\r
+ _SOUT("### plugin_get_native_dll_searching_path called");\r
+ return "";\r
+}\r
+\r
+char* plugin_get_tpa()\r
+{\r
+ _SOUT("### plugin_get_tpa called");\r
+ return "";\r
+}\r
+\r
+void plugin_before_execute()\r
+{\r
+ _SOUT("### plugin_before_execute called");\r
+}\r
+\r
+void plugin_finalize()\r
+{\r
+ _SOUT("### plugin_finalize called");\r
+}\r
+\r
*/
char* plugin_get_dll_path();
+ /**
+ * @brief return additional searching pathes to find native libraries.
+ * @return ":" seperated pathes
+ */
+ char* plugin_get_native_dll_searching_path();
+
/**
* @brief function will be called before invoking managed code
*/
#ifndef __LOG_H__
#define __LOG_H__
+#include <stdio.h>
#include <dlog.h>
#define LOGX(fmt, arg...) \
({ do { \
*/
void addPlatformAssembliesPaths(const std::string& paths, bool isHighPriority = false);
+ /**
+ * @brief Add native dll searching paths.
+ * @param[in] paths the paths to be added
+ * @param[in] isHighPriority if true, paths are added in front of the current list, otherwise added at the end of the list
+ */
+ void addNativeDllSearchingPaths(const std::string& paths, bool isHighPriority = false);
+
/**
* @brief Set application root path.
* All application related paths ("bin", "lib", ".tac_symlink", ".native_image") are generated based on it.
unsigned int domainId,
coreclr_create_delegate_ptr delegateFunc);
typedef char* (*plugin_get_dll_path_ptr)();
+typedef char* (*plugin_get_native_dll_searching_path_ptr)();
typedef char* (*plugin_get_tpa_ptr)();
typedef void (*plugin_before_execute_ptr)();
typedef void (*plugin_finalize_ptr)();
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_native_dll_searching_path_ptr get_native_dll_searching_path;
plugin_get_tpa_ptr get_tpa;
plugin_before_execute_ptr before_execute;
plugin_finalize_ptr finalize;
void pluginSetAppInfo(const char* appId, const char* managedAssemblyPath);
void pluginSetCoreclrInfo(void* hostHandle, unsigned int domainId, coreclr_create_delegate_ptr delegateFunc);
char* pluginGetDllPath();
+char* pluginGetNativeDllSearchingPath();
char* pluginGetTPA();
void pluginBeforeExecute();
void pluginFinalize();
return -1;
}
- char* pluginPath = pluginGetDllPath();
- if (pluginPath) {
- __pm->addPlatformAssembliesPaths(pluginPath);
+ char* pluginDllPaths = pluginGetDllPath();
+ if (pluginDllPaths && pluginDllPaths[0] != '\0') {
+ __pm->addPlatformAssembliesPaths(pluginDllPaths, true);
+ }
+
+ char* pluginNativePaths = pluginGetNativeDllSearchingPath();
+ if (pluginNativePaths && pluginNativePaths[0] != '\0') {
+ __pm->addNativeDllSearchingPaths(pluginNativePaths, true);
}
pluginHasLogControl();
std::string tpa;
char* pluginTPA = pluginGetTPA();
- if (pluginTPA) {
+ if (pluginTPA && pluginTPA[0] != '\0') {
tpa = std::string(pluginTPA);
} else {
addAssembliesFromDirectories(__pm->getPlatformAssembliesPaths(), tpa);
}
char* pluginDllPaths = pluginGetDllPath();
- if (pluginDllPaths) {
- __pm->addPlatformAssembliesPaths(pluginDllPaths);
+ if (pluginDllPaths && pluginDllPaths[0] != '\0') {
+ __pm->addPlatformAssembliesPaths(pluginDllPaths, true);
+ }
+
+ char* pluginNativePaths = pluginGetNativeDllSearchingPath();
+ if (pluginNativePaths && pluginNativePaths[0] != '\0') {
+ __pm->addNativeDllSearchingPaths(pluginNativePaths, true);
}
return NI_ERROR_NONE;
appTacPath = concatPath(appBinPath, TAC_SYMLINK_SUB_DIR);
appPaths = appRootPath + ":" + appBinPath + ":" + appLibPath + ":" + appTacPath;
appNIPaths = appNIBinPath + ":" + appNILibPath + ":"+ appTacPath;
- nativeDllSearchingPaths = runtimePath + ":" + __NATIVE_LIB_DIR + ":" + appBinPath + ":" + appLibPath + ":" + getExtraNativeLibDirs(appRootPath);
}
PathManager::PathManager() :
appNIRootPath = std::string("/proc/self/fd/") + std::to_string(niRootFD);
updateAppRelatedPath(appRootPath, appNIRootPath);
+ // Set native library searching path
+ nativeDllSearchingPaths = runtimePath + ":" + __NATIVE_LIB_DIR + ":" +
+ concatPath(appRootPath, "bin") + ":" + concatPath(appRootPath, "lib") + ":" +
+ getExtraNativeLibDirs(appRootPath);
+
_INFO("Path manager created successfully");
}
platformAssembliesPaths.insert(it, pathVec.begin(), pathVec.end());
}
+void PathManager::addNativeDllSearchingPaths(const std::string& paths, bool isHighPriority)
+{
+ if (isHighPriority) {
+ nativeDllSearchingPaths = paths + ":" + nativeDllSearchingPaths;
+ } else {
+ nativeDllSearchingPaths = nativeDllSearchingPaths + ":" + paths;
+ }
+}
+
void PathManager::setAppRootPath(const std::string& rootPath)
{
appRootPath = getAbsolutePath(rootPath);
__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_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");
__pluginFunc->finalize = (plugin_finalize_ptr)dlsym(__pluginLib, "plugin_finalize");
}
}
+char* pluginGetNativeDllSearchingPath()
+{
+ if (__pluginFunc && __pluginFunc->get_native_dll_searching_path) {
+ return __pluginFunc->get_native_dll_searching_path();
+ } else {
+ return NULL;
+ }
+}
+
char* pluginGetTPA()
{
if (__pluginFunc && __pluginFunc->get_tpa) {
%define _rw_update_scripts_dir /usr/share/upgrade/scripts
%define _rw_dotnet_update_script 715.dotnet_regen_app_ni.patch.sh
+%define _build_dotnet_plugin 0
+
%description
Launchpad plugin for launching dotnet apps
-DUNIQUE_DEFAULT_BASE_ADDR_SUPPORT="" \
-DSYSTEM_BASE_FILE=%{_system_base_addr_file} \
-DDEFAULT_BASE_ADDR_START=%{_default_base_addr_start} \
+%endif
+%if 0%{_build_dotnet_plugin}
+ -DBUILD_DOTNET_PLUGIN="" \
%endif
NativeLauncher
%{_ibc_data_dir}
%{_tizen_preload_dir}
%{_rw_update_scripts_dir}/%{_rw_dotnet_update_script}
+%if 0%{_build_dotnet_plugin}
+%{_native_lib_dir}/libdotnet_plugin.so
+%endif
%files devel
%manifest dotnet-launcher.manifest