Create vconf related to .NET as a file in RO location accepted/tizen/8.0/unified/20231103.040910
authorj-h.choi <j-h.choi@samsung.com>
Mon, 30 Oct 2023 22:11:43 +0000 (07:11 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Tue, 31 Oct 2023 03:17:06 +0000 (12:17 +0900)
NativeLauncher/inc/launcher_env.h
NativeLauncher/tool/multi_target_resolver.cc
NativeLauncher/util/path_manager.cc

index 31de2a5..f32405a 100644 (file)
@@ -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"
index 839f6a0..38416a6 100644 (file)
@@ -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<std::string> 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<std::string> rid_version;
        std::vector<std::string> RID_FALLBACK_GRAPH;
-       char* tizen_rid_version = vconf_get_str(__TIZEN_RID_VERSION_KEY);
-       if (tizen_rid_version) {
-               std::vector<std::string> 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<std::string> RID_FALLBACK_OS = {"tizen", "linux", "unix"};
@@ -82,26 +106,37 @@ static std::vector<std::string> getRidFallbackGraph()
 
 static std::vector<std::string> 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<std::string> tfm_list;
-       char* dotnet_runtime_version = vconf_get_str(__DOTNET_RUNTIME_VERSION_KEY);
-       if (dotnet_runtime_version) {
-               std::vector<std::string> 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<std::string> 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<std::string> netcoreapp_version = {"3.1", "3.0", "2.2", "2.1", "2.0", "1.1", "1.0"};
index a91cad6..2eac3b7 100644 (file)
@@ -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);
        }