Set the native library path with the RIDs value set in TizenFX accepted/tizen/unified/20200315.214822 submit/tizen/20200312.235329
authorj-h.choi <j-h.choi@samsung.com>
Tue, 18 Feb 2020 06:38:36 +0000 (15:38 +0900)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Thu, 12 Mar 2020 00:39:38 +0000 (09:39 +0900)
Change-Id: I076c9966eb02552dec7e547933b64665577847d0

NativeLauncher/launcher/dotnet/dotnet_launcher.cc

index eccee22..ec595ae 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/limits.h>
 
 #include <storage.h>
+#include <vconf.h>
 #include <app_common.h>
 
 #include "injection.h"
@@ -57,33 +58,55 @@ namespace dotnetcore {
 
 #if defined (__aarch64__)
 #define ARCHITECTURE_IDENTIFIER "arm64"
-const static std::vector<std::string> RID_FALLBACK_GRAPH =
-       {"linux-arm64", "linux", "unix-arm64", "unix", "any", "base"};
 
 #elif defined (__arm__)
-#define ARCHITECTURE_IDENTIFIER "arm"
-const static std::vector<std::string> RID_FALLBACK_GRAPH =
-       {"tizen.6.0.0-armel", "tizen.6.0.0", "tizen.5.5.0-armel", "tizen.5.5.0", "tizen.5.0.0-armel", "tizen.5.0.0", "tizen.4.0.0-armel", "tizen.4.0.0", "tizen-armel", "tizen", "linux-armel", "linux", "unix-armel", "unix", "any", "base"};
+#define ARCHITECTURE_IDENTIFIER "armel"
 
 #elif defined (__x86_64__)
 #define ARCHITECTURE_IDENTIFIER "x64"
-const static std::vector<std::string> RID_FALLBACK_GRAPH =
-       {"linux-x64", "linux", "unix-x64", "unix", "any", "base"};
 
 #elif defined (__i386__)
 #define ARCHITECTURE_IDENTIFIER "x86"
-const static std::vector<std::string> RID_FALLBACK_GRAPH =
-       {"tizen.6.0.0-x86", "tizen.6.0.0", "tizen.5.5.0-x86", "tizen.5.5.0", "tizen.5.0.0-x86", "tizen.5.0.0", "tizen.4.0.0-x86", "tizen.4.0.0", "tizen-x86", "tizen", "linux-x86", "linux", "unix-x86", "unix", "any", "base"};
 
 #else
 #error "Unknown target"
 #endif
 
+static const char* __TIZEN_RID_VERSION_KEY = "db/dotnet/tizen_rid_version";
+
+// The sequence of RID_FALLBACK graphs must be:
+// 1. Tizen + Version + Architecture
+// 2. Tizen + Version
+// 3. OS(tizen, linux, unix) + Architecture
+// 4. OS(tizen, linux, unix)
+// 5. any, base
 static std::string getExtraNativeLibDirs(const std::string& appRoot)
 {
+       std::vector<std::string> RID_FALLBACK_GRAPH;
+       std::vector<std::string> RID_FALLBACK_TIZEN;
+       char* tizen_rid = vconf_get_str(__TIZEN_RID_VERSION_KEY);
+       if (tizen_rid) {
+               std::vector<std::string> version;
+               splitPath(tizen_rid, version);
+               std::reverse(std::begin(version), std::end(version));
+               for (unsigned int i = 0; i < version.size(); i++) {
+                       RID_FALLBACK_TIZEN.push_back(std::string("tizen." + version[i] + "-" + ARCHITECTURE_IDENTIFIER));
+                       RID_FALLBACK_TIZEN.push_back(std::string("tizen." + version[i]));
+               }
+               free(tizen_rid);
+       }
+
+       std::vector<std::string> RID_FALLBACK_OS = {"tizen", "linux", "unix"};
+       for (unsigned int i = 0; i < RID_FALLBACK_OS.size(); i++) {
+               RID_FALLBACK_GRAPH.push_back(std::string(RID_FALLBACK_OS[i] + "-" +  ARCHITECTURE_IDENTIFIER));
+               RID_FALLBACK_GRAPH.push_back(std::string(RID_FALLBACK_OS[i]));
+       }
+       RID_FALLBACK_GRAPH.push_back("any");
+       RID_FALLBACK_GRAPH.push_back("base");
+
        std::string candidate;
        for (unsigned int i = 0; i < RID_FALLBACK_GRAPH.size(); i++) {
-               if(!candidate.empty()) {
+               if (!candidate.empty()) {
                        candidate += ":";
                }
                candidate += concatPath(appRoot, "bin/runtimes/" + RID_FALLBACK_GRAPH[i] + "/native");
@@ -92,6 +115,8 @@ static std::string getExtraNativeLibDirs(const std::string& appRoot)
        candidate = candidate + ":" + concatPath(appRoot, "lib/" ARCHITECTURE_IDENTIFIER);
        if (!strncmp(ARCHITECTURE_IDENTIFIER, "arm64", 5)) {
                candidate = candidate + ":" + concatPath(appRoot, "lib/aarch64");
+       } else if (!strncmp(ARCHITECTURE_IDENTIFIER, "armel", 5)) {
+               candidate = candidate + ":" + concatPath(appRoot, "lib/arm");
        }
 
        return candidate;