Support for architecture-specific assemblies in a folder named runtimes (#276)
author최종헌/Common Platform Lab(SR)/Engineer/삼성전자 <j-h.choi@samsung.com>
Thu, 24 Sep 2020 07:53:02 +0000 (16:53 +0900)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Thu, 24 Sep 2020 07:53:02 +0000 (16:53 +0900)
Change-Id: I55399888f14f37e4c82c9ad2713918b05a0e87fb

NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
NativeLauncher/util/path_manager.cc

index dd35e47..6f93e44 100644 (file)
@@ -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;
                }
 
index 6094915..fbd2b3e 100644 (file)
@@ -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<std::string> 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<std::string> tfmList;
+       char* tizen_tfm = vconf_get_str(__TIZEN_TFM_SUPPORT_KEY);
+       if (tizen_tfm) {
+               splitPath(tizen_tfm, tfmList);
+               free(tizen_tfm);
+       }
+
+       std::vector<std::string> paths;
+       splitPath(replaceAll(getRidFallbackGraphDirs(appRoot), "/native", "/lib"), paths);
+
+       if (tfmList.empty() || paths.empty())
+               return candidate;
+
+       std::vector<std::string> 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;
 }