[Refactoring] Code cleanup and remove duplicate methods
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / tac_common.cc
index 71623b3..94ff439 100644 (file)
@@ -23,6 +23,7 @@
 #include "utils.h"
 #include "tac_common.h"
 #include "db_manager.h"
+#include "r2r_checker.h"
 
 #ifdef  LOG_TAG
 #undef  LOG_TAG
@@ -38,8 +39,8 @@ static const char* __READ_ONLY_APP_UPDATE_DIR = __STR(READ_ONLY_APP_UPDATE_DIR);
 
 static sqlite3 *tac_db = NULL;
 static sqlite3 *tlc_db = NULL;
-std::vector<std::string> restore_nuget;
-std::vector<std::string> restore_library;
+static std::vector<std::string> restore_nuget;
+static std::vector<std::string> restore_library;
 
 static void cleanupDirectory()
 {
@@ -223,7 +224,7 @@ tac_error_e disableTACPackage(const std::string& pkgId)
                                std::string fileName = symlinkAssembly.path().filename().string();
                                if (isSymlinkFile(symPath)) {
                                        std::string originPath = bf::read_symlink(symPath).string();
-                                       if (!isNativeImage(symPath)) {
+                                       if (!isR2RImage(symPath)) {
                                                std::string dllPath = concatPath(binDir, fileName);
                                                if (!copyFile(originPath, dllPath)) {
                                                        _SERR("Failed to copy of %s", dllPath.c_str());
@@ -371,19 +372,6 @@ std::vector<std::string> depsJsonParser(const std::string& rootPath, const std::
                                }
                                const Json::Value runtimeTargetName = root["runtimeTarget"]["name"];
                                const Json::Value nugetPackages = root["targets"][runtimeTargetName.asString().c_str()];
-                               std::vector<std::string> appDependencies;
-                               for (auto& nuget : nugetPackages.getMemberNames()) {
-                                       if (strstr(nuget.c_str(), (execName.substr(0, execName.find(".Tizen."))).c_str()) != NULL ||
-                                               strstr(nuget.c_str(), (execName.substr(0, execName.find(".dll"))).c_str()) != NULL) {
-                                               const Json::Value assemblies = nugetPackages[nuget.c_str()]["runtime"];
-                                               if (assemblies != Json::nullValue) {
-                                                       const Json::Value dependencies = nugetPackages[nuget.c_str()]["dependencies"];
-                                                       for (auto& dependency : dependencies.getMemberNames()) {
-                                                               appDependencies.push_back(dependency);
-                                                       }
-                                               }
-                                       }
-                               }
                                for (auto& nuget : nugetPackages.getMemberNames()) {
                                        //Skip the nuget package related to Tizen
                                        if (strstr(nuget.c_str(), TIZEN_DOTNET_NUGET) == NULL &&
@@ -392,36 +380,15 @@ std::vector<std::string> depsJsonParser(const std::string& rootPath, const std::
                                                strstr(nuget.c_str(), (execName.substr(0, execName.find(".dll"))).c_str()) == NULL) {
                                                const Json::Value assemblies = nugetPackages[nuget.c_str()]["runtime"];
                                                if (assemblies != Json::nullValue) {
-                                                       const Json::Value dependencies = nugetPackages[nuget.c_str()]["dependencies"];
-                                                       bool hasDependency = false;
-                                                       for (auto& dependency : dependencies.getMemberNames()) {
-                                                               //Skip the nugget package that is dependent on another nuget package
-                                                               if (strstr(dependency.c_str(), TIZEN_DOTNET_NUGET) == NULL &&
-                                                                       strstr(dependency.c_str(), NET_STANDARD_LIBRARY_NUGET) == NULL) {
-                                                                       hasDependency = true;
-                                                                       for (auto& ad : appDependencies) {
-                                                                               if (!strcmp(ad.c_str(), dependency.c_str())) {
-                                                                                       hasDependency = true;
-                                                                                       break;
-                                                                               } else {
-                                                                                       hasDependency = false;
-                                                                               }
-                                                                       }
-                                                                       if (hasDependency) break;
-                                                               }
-                                                       }
-                                                       if (!hasDependency) {
-                                                               // handle assembly even though that is included in the TPA.
-                                                               for (auto& assembly : assemblies.getMemberNames()) {
-                                                                       std::string assemblyName = assembly.substr(assembly.rfind('/') + 1);
-                                                                       parserData.push_back(nuget + ":" + assemblyName);
-                                                                       _INFO("Nuget : [%s] / Assembly : [%s]", nuget.c_str(), assemblyName.c_str());
-                                                               }
+                                                       // handle assembly even though that is included in the TPA.
+                                                       for (auto& assembly : assemblies.getMemberNames()) {
+                                                               std::string assemblyName = assembly.substr(assembly.rfind('/') + 1);
+                                                               parserData.push_back(nuget + ":" + assemblyName);
+                                                               _INFO("Nuget : [%s] / Assembly : [%s]", nuget.c_str(), assemblyName.c_str());
                                                        }
                                                }
                                        }
                                }
-                               appDependencies.clear();
                                ifs.close();
                        }
                }