From 2158324e388cdf7226410609d98bd9d95c0281c8 Mon Sep 17 00:00:00 2001 From: "j-h.choi" Date: Tue, 18 Feb 2020 15:38:36 +0900 Subject: [PATCH] Set the native library path with the RIDs value set in TizenFX Change-Id: I076c9966eb02552dec7e547933b64665577847d0 --- NativeLauncher/launcher/dotnet/dotnet_launcher.cc | 45 ++++++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc index eccee22..ec595ae 100644 --- a/NativeLauncher/launcher/dotnet/dotnet_launcher.cc +++ b/NativeLauncher/launcher/dotnet/dotnet_launcher.cc @@ -34,6 +34,7 @@ #include #include +#include #include #include "injection.h" @@ -57,33 +58,55 @@ namespace dotnetcore { #if defined (__aarch64__) #define ARCHITECTURE_IDENTIFIER "arm64" -const static std::vector RID_FALLBACK_GRAPH = - {"linux-arm64", "linux", "unix-arm64", "unix", "any", "base"}; #elif defined (__arm__) -#define ARCHITECTURE_IDENTIFIER "arm" -const static std::vector 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 RID_FALLBACK_GRAPH = - {"linux-x64", "linux", "unix-x64", "unix", "any", "base"}; #elif defined (__i386__) #define ARCHITECTURE_IDENTIFIER "x86" -const static std::vector 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 RID_FALLBACK_GRAPH; + std::vector RID_FALLBACK_TIZEN; + char* tizen_rid = vconf_get_str(__TIZEN_RID_VERSION_KEY); + if (tizen_rid) { + std::vector 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 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; -- 2.7.4