From 8863a014d0ede56d090d3c459996e61359f6bc26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=B5=9C=EC=A2=85=ED=97=8C/Common=20Platform=20Lab=28SR=29?= =?utf8?q?/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Thu, 24 Sep 2020 16:53:02 +0900 Subject: [PATCH] Support for architecture-specific assemblies in a folder named runtimes (#276) Change-Id: I55399888f14f37e4c82c9ad2713918b05a0e87fb --- .../installer-plugin/prefer_dotnet_aot_plugin.cc | 2 +- NativeLauncher/util/path_manager.cc | 48 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc index dd35e47..6f93e44 100644 --- a/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc +++ b/NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc @@ -63,7 +63,7 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app } if (createNIUnderPkgRoot(pkgId, 0) != NI_ERROR_NONE) { - _ERR("Failed to get root path from [%s]", pkgId); + _ERR("Failed to generate application to native image [%s]", pkgId); return -1; } diff --git a/NativeLauncher/util/path_manager.cc b/NativeLauncher/util/path_manager.cc index 6094915..fbd2b3e 100644 --- a/NativeLauncher/util/path_manager.cc +++ b/NativeLauncher/util/path_manager.cc @@ -31,6 +31,7 @@ static const char* __TIZEN_API_PATH_KEY = "db/dotnet/tizen_api_path"; static const char* __TIZEN_RID_VERSION_KEY = "db/dotnet/tizen_rid_version"; +static const char* __TIZEN_TFM_SUPPORT_KEY = "db/dotnet/tizen_tfm_support"; #define __XSTR(x) #x #define __STR(x) __XSTR(x) @@ -46,7 +47,7 @@ static const char* __NATIVE_LIB_DIR = __STR(NATIVE_LIB_DIR); // 3. OS(tizen, linux, unix) + Architecture // 4. OS(tizen, linux, unix) // 5. any, base -static std::string getExtraNativeLibDirs(const std::string& appRoot) +static std::string getRidFallbackGraphDirs(const std::string& appRoot) { std::vector RID_FALLBACK_GRAPH; char* tizen_rid = vconf_get_str(__TIZEN_RID_VERSION_KEY); @@ -77,6 +78,15 @@ static std::string getExtraNativeLibDirs(const std::string& appRoot) candidate += concatPath(appRoot, "bin/runtimes/" + RID_FALLBACK_GRAPH[i] + "/native"); } + return candidate; +} + +// 1. /appRoot/runtimes/{Platform}-{Architecture}/native/xxxxx.so +// 2. /appRoot/lib/{Architecture}/xxxxx.so +static std::string getExtraNativeLibDirs(const std::string& appRoot) +{ + std::string candidate = getRidFallbackGraphDirs(appRoot); + candidate = candidate + ":" + concatPath(appRoot, "lib/" ARCHITECTURE_IDENTIFIER); if (!strncmp(ARCHITECTURE_IDENTIFIER, "arm64", 5)) { candidate = candidate + ":" + concatPath(appRoot, "lib/aarch64"); @@ -87,13 +97,47 @@ static std::string getExtraNativeLibDirs(const std::string& appRoot) return candidate; } +// 1. /appRoot/runtimes/{Platform}-{Architecture}/lib/{TFMs}/xxxxx.dll +static std::string getExtraTfmDirs(const std::string& appRoot) +{ + std::string candidate; + std::vector tfmList; + char* tizen_tfm = vconf_get_str(__TIZEN_TFM_SUPPORT_KEY); + if (tizen_tfm) { + splitPath(tizen_tfm, tfmList); + free(tizen_tfm); + } + + std::vector paths; + splitPath(replaceAll(getRidFallbackGraphDirs(appRoot), "/native", "/lib"), paths); + + if (tfmList.empty() || paths.empty()) + return candidate; + + std::vector tfmDirectoryList; + for (unsigned int i = 0; i < paths.size(); i++) { + for (unsigned int j = 0; j < tfmList.size(); j++) { + tfmDirectoryList.push_back(concatPath(paths[i], tfmList[j])); + } + } + + for (unsigned int i = 0; i < tfmDirectoryList.size(); i++) { + if (!candidate.empty()) { + candidate += ":"; + } + candidate += tfmDirectoryList[i]; + } + + return candidate; +} + void PathManager::updateAppRelatedPath(const std::string& appRootPath) { std::string appBinPath = concatPath(appRootPath, "bin"); std::string appLibPath = concatPath(appRootPath, "lib"); appTacPath = concatPath(appBinPath, TAC_SYMLINK_SUB_DIR); - appPaths = appRootPath + ":" + appBinPath + ":" + appLibPath + ":" + appTacPath; + appPaths = appRootPath + ":" + appBinPath + ":" + appLibPath + ":" + appTacPath + ":" + getExtraTfmDirs(appRootPath); appNIPaths = concatPath(appBinPath, APP_NI_SUB_DIR) + ":" + concatPath(appLibPath, APP_NI_SUB_DIR) + ":"+ appTacPath; nativeDllSearchingPaths = runtimePath + ":" + __NATIVE_LIB_DIR + ":" + getExtraNativeLibDirs(appRootPath) + ":" + appBinPath + ":" + appLibPath; } -- 2.7.4