From fe49959e3e6df3c13c09ba28cfabab1e330cb995 Mon Sep 17 00:00:00 2001 From: "j-h.choi" Date: Tue, 31 Oct 2023 07:11:43 +0900 Subject: [PATCH] Create vconf related to .NET as a file in RO location --- NativeLauncher/inc/launcher_env.h | 1 + NativeLauncher/tool/multi_target_resolver.cc | 91 +++++++++++++++++++--------- NativeLauncher/util/path_manager.cc | 10 +-- 3 files changed, 69 insertions(+), 33 deletions(-) diff --git a/NativeLauncher/inc/launcher_env.h b/NativeLauncher/inc/launcher_env.h index 31de2a5..f32405a 100644 --- a/NativeLauncher/inc/launcher_env.h +++ b/NativeLauncher/inc/launcher_env.h @@ -19,6 +19,7 @@ #define PLUGIN_PATH "/usr/share/dotnet.tizen/lib/libdotnet_plugin.so" #define ENV_FILE_PATH "/usr/share/dotnet.tizen/lib/coreclr_env.list" +#define DOTNET_RESOLVING_INFO_PATH "/usr/share/dotnet.tizen/lib/dotnet_resolving.info" #define AOT_METADATA_KEY "http://tizen.org/metadata/prefer_dotnet_aot" #define TAC_METADATA_KEY "http://tizen.org/metadata/prefer_nuget_cache" #define METADATA_VALUE_TRUE "true" diff --git a/NativeLauncher/tool/multi_target_resolver.cc b/NativeLauncher/tool/multi_target_resolver.cc index 839f6a0..38416a6 100644 --- a/NativeLauncher/tool/multi_target_resolver.cc +++ b/NativeLauncher/tool/multi_target_resolver.cc @@ -50,23 +50,47 @@ static int convertStrVersionToInt(const std::string& version) return ret; } +// Guided by Appfw, vconf daemon does not run at mic stage. +// So vconf_get_* api does not work normally. +// Therefore, it provides a second chance to read the file when vconf_get_* is null. +// /usr/share/dotnet.tizen/lib/dotnet_resolving.info +static std::string getDotnetResolvingInfo(const char* key) +{ + std::ifstream ifs(DOTNET_RESOLVING_INFO_PATH); + std::string line; + while (std::getline(ifs, line)) { + if (!strcmp(line.substr(0, line.find(" ")).c_str(), key)) { + ifs.close(); + return line.substr(line.rfind(" ") + 1); + } + } + _ERR("Faield to get vconf. %s is null", key); + return ""; +} + static std::vector getRidFallbackGraph() { + std::string tizen_rid_version; + char* tizen_rid_version_value = vconf_get_str(__TIZEN_RID_VERSION_KEY); + if (!tizen_rid_version_value) { + _INFO("Faield to get vconf. So, Read the dotnet_resolving.info file"); + tizen_rid_version = getDotnetResolvingInfo(__TIZEN_RID_VERSION_KEY); + } else { + tizen_rid_version = std::string(tizen_rid_version_value); + free(tizen_rid_version_value); + } + + std::vector rid_version; std::vector RID_FALLBACK_GRAPH; - char* tizen_rid_version = vconf_get_str(__TIZEN_RID_VERSION_KEY); - if (tizen_rid_version) { - std::vector rid_version; - splitPath(tizen_rid_version, rid_version); - std::reverse(std::begin(rid_version), std::end(rid_version)); - for (auto& ridVersion : rid_version) { - //.NET 6.0 is supported from Tizen 6.5.0 - if (convertStrVersionToInt(ridVersion) >= 650) { - platform_version_list.push_back(ridVersion.substr(0, ridVersion.rfind('.'))); - } - RID_FALLBACK_GRAPH.push_back(std::string("tizen." + ridVersion + "-" + ARCHITECTURE_IDENTIFIER)); - RID_FALLBACK_GRAPH.push_back(std::string("tizen." + ridVersion)); + splitPath(tizen_rid_version, rid_version); + std::reverse(std::begin(rid_version), std::end(rid_version)); + for (auto& ridVersion : rid_version) { + //.NET 6.0 is supported from Tizen 6.5.0 + if (convertStrVersionToInt(ridVersion) >= 650) { + platform_version_list.push_back(ridVersion.substr(0, ridVersion.rfind('.'))); } - free(tizen_rid_version); + RID_FALLBACK_GRAPH.push_back(std::string("tizen." + ridVersion + "-" + ARCHITECTURE_IDENTIFIER)); + RID_FALLBACK_GRAPH.push_back(std::string("tizen." + ridVersion)); } std::vector RID_FALLBACK_OS = {"tizen", "linux", "unix"}; @@ -82,26 +106,37 @@ static std::vector getRidFallbackGraph() static std::vector getTfmFallbackGraph() { + std::string dotnet_runtime_version; + char* dotnet_runtime_version_value = vconf_get_str(__DOTNET_RUNTIME_VERSION_KEY); + if (!dotnet_runtime_version_value) { + _INFO("Faield to get vconf. So, Read the dotnet_resolving.info file"); + dotnet_runtime_version = getDotnetResolvingInfo(__DOTNET_RUNTIME_VERSION_KEY); + } else { + dotnet_runtime_version = std::string(dotnet_runtime_version_value); + free(dotnet_runtime_version_value); + } + std::vector tfm_list; - char* dotnet_runtime_version = vconf_get_str(__DOTNET_RUNTIME_VERSION_KEY); - if (dotnet_runtime_version) { - std::vector dotnet_version; - splitPath(dotnet_runtime_version, dotnet_version); - for (auto& dotnetVersion : dotnet_version) { - for (auto& platformVersion : platform_version_list) { - tfm_list.push_back(std::string("net" + dotnetVersion + "-tizen" + platformVersion)); - } - tfm_list.push_back(std::string("net" + dotnetVersion + "-tizen")); - tfm_list.push_back(std::string("net" + dotnetVersion)); + std::vector dotnet_version; + splitPath(dotnet_runtime_version, dotnet_version); + for (auto& dotnetVersion : dotnet_version) { + for (auto& platformVersion : platform_version_list) { + tfm_list.push_back(std::string("net" + dotnetVersion + "-tizen" + platformVersion)); } - free(dotnet_runtime_version); + tfm_list.push_back(std::string("net" + dotnetVersion + "-tizen")); + tfm_list.push_back(std::string("net" + dotnetVersion)); } - char* tizen_tfm = vconf_get_str(__TIZEN_TFM_SUPPORT_KEY); - if (tizen_tfm) { - splitPath(tizen_tfm, tfm_list); - free(tizen_tfm); + std::string tizen_tfm; + char* tizen_tfm_value = vconf_get_str(__TIZEN_TFM_SUPPORT_KEY); + if (!tizen_tfm_value) { + _INFO("Faield to get vconf. So, Read the dotnet_resolving.info file"); + tizen_tfm = getDotnetResolvingInfo(__TIZEN_TFM_SUPPORT_KEY); + } else { + tizen_tfm = std::string(tizen_tfm_value); + free(tizen_tfm_value); } + splitPath(tizen_tfm, tfm_list); tfm_list.push_back("net5.0"); std::vector netcoreapp_version = {"3.1", "3.0", "2.2", "2.1", "2.0", "1.1", "1.0"}; diff --git a/NativeLauncher/util/path_manager.cc b/NativeLauncher/util/path_manager.cc index a91cad6..2eac3b7 100644 --- a/NativeLauncher/util/path_manager.cc +++ b/NativeLauncher/util/path_manager.cc @@ -81,11 +81,11 @@ PathManager::PathManager() : platformAssembliesPaths.push_back(runtimePath); // set tizenfx path - char* tmp = vconf_get_str(__TIZEN_API_PATH_KEY); - if (tmp) { - tizenfxPath = std::string(tmp); - _DBG("Device API Directory is set by vconf : %s", tmp); - free(tmp); + char* tizenfx_path = vconf_get_str(__TIZEN_API_PATH_KEY); + if (tizenfx_path) { + tizenfxPath = std::string(tizenfx_path); + _DBG("Device API Directory is set by vconf : %s", tizenfx_path); + free(tizenfx_path); } else { tizenfxPath = getAbsolutePath(__DEVICE_API_DIR); } -- 2.7.4