[Refactoring] Code cleanup and remove duplicate methods
authorj-h.choi <j-h.choi@samsung.com>
Thu, 18 Jan 2024 06:40:47 +0000 (15:40 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Mon, 19 Feb 2024 05:33:46 +0000 (14:33 +0900)
Change-Id: I6c65e5108b0110a51b5f9d60e34779d7d4f300ef

17 files changed:
NativeLauncher/CMakeLists.txt
NativeLauncher/hydra/hydra_main.cc
NativeLauncher/inc/multi_target_resolver.h
NativeLauncher/inc/r2r_checker.h
NativeLauncher/inc/utils.h
NativeLauncher/installer-plugin/dotnet_apptype_plugin.cc
NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc
NativeLauncher/launcher/exec/corerun.cc
NativeLauncher/launcher/lib/core_runtime.cc
NativeLauncher/tool/dotnettool.cc
NativeLauncher/tool/multi_target_resolver.cc
NativeLauncher/tool/ni_common.cc
NativeLauncher/tool/r2r_checker.cc
NativeLauncher/tool/tac_common.cc
NativeLauncher/tool/tac_installer.cc
NativeLauncher/util/plugin_manager.cc
NativeLauncher/util/utils.cc

index 350d373..d89bba3 100644 (file)
@@ -111,12 +111,14 @@ INCLUDE_DIRECTORIES(inc launcher util)
 
 SET(DOTNET_LAUNCHER_UTIL "dotnet_launcher_util")
 SET(${DOTNET_LAUNCHER_UTIL}_SOURCE_FILES
-    util/utils.cc
-    util/plugin_manager.cc
+    tool/r2r_checker.cc
     util/path_manager.cc
+    util/plugin_manager.cc
+    util/utils.cc
 )
 ADD_LIBRARY(${DOTNET_LAUNCHER_UTIL} SHARED ${${DOTNET_LAUNCHER_UTIL}_SOURCE_FILES})
 SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER_UTIL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB})
+TARGET_INCLUDE_DIRECTORIES(${DOTNET_LAUNCHER_UTIL} PRIVATE ${RUNTIME_DIR}/src/ ${RUNTIME_DIR}/src/pal ${RUNTIME_DIR}/src/pal/inc ${RUNTIME_DIR}/src/pal/inc/rt)
 TARGET_LINK_LIBRARIES(${DOTNET_LAUNCHER_UTIL} ${${PROJECT_NAME}_LDFLAGS} "-ldl" boost_filesystem boost_system)
 
 SET(DOTNET_LAUNCHER_CORE "dotnet_launcher_core")
@@ -192,11 +194,9 @@ TARGET_LINK_LIBRARIES(${TAC_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER
 SET(NI_COMMON "ni_common")
 SET(${NI_COMMON}_SOURCE_FILES
     tool/ni_common.cc
-    tool/r2r_checker.cc
 )
 ADD_LIBRARY(${NI_COMMON} SHARED ${${NI_COMMON}_SOURCE_FILES})
 SET_TARGET_PROPERTIES(${NI_COMMON} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB})
-TARGET_INCLUDE_DIRECTORIES(${NI_COMMON} PRIVATE ${RUNTIME_DIR}/src/ ${RUNTIME_DIR}/src/pal ${RUNTIME_DIR}/src/pal/inc ${RUNTIME_DIR}/src/pal/inc/rt)
 TARGET_LINK_LIBRARIES(${NI_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${TAC_COMMON})
 
 SET(PROFILE_COMMON "profile_common")
index b14f1ef..7ced0a3 100644 (file)
@@ -31,8 +31,8 @@
 #include "log.h"
 #include "launcher_env.h"
 
-const char* __coreclr_lib = "/usr/share/dotnet.tizen/netcoreapp/libcoreclr.so";
-const char* __dotnet_loader = "/usr/bin/dotnet-loader";
+static const char* __coreclr_lib = "/usr/share/dotnet.tizen/netcoreapp/libcoreclr.so";
+static const char* __dotnet_loader = "/usr/bin/dotnet-loader";
 
 typedef int (*coreclr_preload_assembly_ptr)(const char* assemblyPath);
 typedef int (*launcher_real_main_ptr)(int argc, char *argv[]);
index 380fcd0..9c57a77 100644 (file)
@@ -27,8 +27,7 @@ int resolvePlatformSpecificFiles(const std::string& appRootPath);
 
 /**
  * @brief resolve bin/runtimes directory if exist.
- * @return 0 if success, otherwise -1
  */
-int resolveAllApps();
+void resolveAllApps();
 
 #endif /* __MULTI_TAEGET_RESOLVER_H__ */
index 4694eff..ef10571 100644 (file)
 
 #include <string>
 
-bool isR2RImage(std::string fileName);
-unsigned int getSizeOfImage(std::string fileName);
+/**
+ * @brief check the file is r2r image or not.
+ * @param[in] file name
+ * @return return true when the file is r2r image.
+ */
+bool isR2RImage(const std::string& fileName);
+
+unsigned int getSizeOfImage(const std::string& fileName);
 
 #endif /* __R2R_CHECKER_H__ */
index 927b213..524264e 100644 (file)
@@ -165,13 +165,6 @@ bool isDirectory(const std::string& path);
 bool isManagedAssembly(const std::string& filePath);
 
 /**
- * @brief check the file is native image or not.
- * @param[in] file path
- * @return return true when the file is native image.
- */
-bool isNativeImage(const std::string& filePath);
-
-/**
  * @brief Resolve assembly files from directories and append their paths to the given list.
  * @remark If a native image exists for an assembly in the same directory, it will be used.
  *         If multiple assemblies of the same name exist, the first one will be used.
index 48e0ed3..0cff386 100644 (file)
@@ -30,7 +30,7 @@
 typedef struct _xmlDoc xmlDoc;
 typedef xmlDoc* xmlDocPtr;
 
-bool pluginInstalled = false;
+static bool pluginInstalled = false;
 
 extern "C" int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr doc, const char* pkgId)
 {
index 91928a7..840a40b 100644 (file)
@@ -30,8 +30,8 @@
 #endif
 #define LOG_TAG "DOTNET_INSTALLER_PLUGIN"
 
-bool aotPluginInstalled = false;
-bool aotPluginFinished = false;
+static bool aotPluginInstalled = false;
+static bool aotPluginFinished = false;
 
 extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *appId, GList *list)
 {
index 81fdb0c..820679b 100644 (file)
@@ -19,6 +19,7 @@
 #include "coreclr_host.h"
 #include "log.h"
 #include "utils.h"
+#include "r2r_checker.h"
 
 static const char* CLR_PATH = "/usr/share/dotnet.tizen/netcoreapp";
 static const char* TOOL_PATH = "/home/owner/share/.dotnet/tools";
@@ -102,7 +103,7 @@ int main(int argc, const char* argv[]) {
                        _SERR("Unknown option %s.", argv[0]);
                        DisplayUsage();
                        return -1;
-               } else if (isManagedAssembly(arg) || isNativeImage(arg)) {
+               } else if (isManagedAssembly(arg) || isR2RImage(arg)) {
                        if (!isFile(arg)) {
                                _SERR("The specified file does not exist.");
                                return -1;
index ba874aa..d0b0704 100644 (file)
@@ -97,8 +97,8 @@ static void setEnvFromFile()
 
 #define _unused(x) ((void)(x))
 
-struct sigaction sig_abrt_new;
-struct sigaction sig_abrt_old;
+static struct sigaction sig_abrt_new;
+static struct sigaction sig_abrt_old;
 
 static bool checkOnSigabrt = false;
 static bool checkOnTerminate = false;
index 628124c..eac0f2a 100644 (file)
@@ -401,10 +401,7 @@ int main(int argc, char* argv[])
        }
        //sh-3.2# dotnettool --resolve-all-app
        else if (cmd == "--resolve-all-app") {
-               int ret = resolveAllApps();
-               if (ret != 0) {
-                       _SERR("Failed to remove unused multi-targeting files");
-               }
+               resolveAllApps();
        }
        //sh-3.2# dotnettool --rm-app-profile [pkgId] [pkgId] ...
        else if (cmd == "--rm-app-profile") {
index 264dc6d..0f94ebb 100644 (file)
@@ -202,28 +202,29 @@ static int appResolveCb(pkgmgrinfo_appinfo_h handle, void *user_data)
        return 0;
 }
 
-int resolveAllApps()
+void resolveAllApps()
 {
        int ret = 0;
 
        pkgmgrinfo_appinfo_filter_h handle;
        ret = pkgmgrinfo_appinfo_filter_create(&handle);
        if (ret != PMINFO_R_OK) {
-               return -1;
+               _SERR("Failed to create pkgmgrinfo");
+               return;
        }
 
        ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_TYPE, "dotnet");
        if (ret != PMINFO_R_OK) {
                pkgmgrinfo_appinfo_filter_destroy(handle);
-               return -1;
+               _SERR("Failed to add pkgmgrinfo filter app type");
+               return;
        }
 
        ret = pkgmgrinfo_appinfo_filter_foreach_appinfo(handle, appResolveCb, NULL);
        if (ret != PMINFO_R_OK) {
                pkgmgrinfo_appinfo_filter_destroy(handle);
-               return -1;
+               _SERR("Failed to remove unused multi-targeting files");
+               return;
        }
        pkgmgrinfo_appinfo_filter_destroy(handle);
-
-       return 0;
 }
index bc0a466..08d9d6f 100644 (file)
@@ -230,8 +230,35 @@ static bool createDirsAndCopyOwnerShip(std::string& target_path, const std::stri
        return true;
 }
 
-static std::string getNIFilePath(const std::string& dllPath)
+static std::string getNIFilePath(const std::string& absDllPath, NIOption* opt)
 {
+       std::string dllPath = absDllPath;
+       if (opt->flags & NI_FLAGS_APPNI) {
+               std::string niDirPath;
+               std::string niTmpDirPath;
+               std::string prevPath;
+
+               prevPath = getBaseName(absDllPath);
+               niDirPath = concatPath(prevPath, APP_NI_SUB_DIR);
+               niTmpDirPath = concatPath(prevPath, APP_NI_SUB_TMP_DIR);
+
+               if (opt->flags & NI_FLAGS_APP_UNDER_RO_AREA) {
+                       niTmpDirPath = replaceAll(niTmpDirPath, getBaseName(__pm->getAppRootPath()), __READ_ONLY_APP_UPDATE_DIR);
+                       niDirPath = replaceAll(niDirPath, getBaseName(__pm->getAppRootPath()), __READ_ONLY_APP_UPDATE_DIR);
+                       _INFO("App is installed in RO area. Change NI path to RW area(%s).", niTmpDirPath.c_str());
+               }
+
+               if (!isDirectory(niDirPath)) {
+                       if (!createDirsAndCopyOwnerShip(niTmpDirPath, prevPath)) {
+                               niTmpDirPath = prevPath;
+                               _SERR("fail to create dir (%s)", niTmpDirPath.c_str());
+                       }
+                       dllPath = concatPath(niTmpDirPath, getFileName(absDllPath));
+               } else {
+                       dllPath = concatPath(niDirPath, getFileName(absDllPath));
+               }
+       }
+
        size_t index = dllPath.find_last_of(".");
        if (index == std::string::npos) {
                _SERR("File doesnot contain extension. fail to get NI file name");
@@ -247,33 +274,9 @@ static std::string getNIFilePath(const std::string& dllPath)
        return niPath;
 }
 
-static std::string getAppNIFilePath(const std::string& absDllPath, NIOption* opt)
+static bool checkNIExistence(const std::string& absDllPath, NIOption* opt)
 {
-       std::string niDirPath;
-       std::string prevPath;
-
-       prevPath = getBaseName(absDllPath);
-       niDirPath = concatPath(prevPath, APP_NI_SUB_TMP_DIR);
-
-       if (opt->flags & NI_FLAGS_APP_UNDER_RO_AREA) {
-               niDirPath = replaceAll(niDirPath, getBaseName(__pm->getAppRootPath()), __READ_ONLY_APP_UPDATE_DIR);
-               _SERR("App is installed in RO area. Change NI path to RW area(%s).", niDirPath.c_str());
-               _ERR("App is installed in RO area. Change NI path to RW area(%s).", niDirPath.c_str());
-       }
-
-       if (!isDirectory(niDirPath)) {
-               if (!createDirsAndCopyOwnerShip(niDirPath, prevPath)) {
-                       niDirPath = prevPath;
-                       _SERR("fail to create dir (%s)", niDirPath.c_str());
-               }
-       }
-
-       return getNIFilePath(concatPath(niDirPath, getFileName(absDllPath)));
-}
-
-static bool checkNIExistence(const std::string& absDllPath)
-{
-       std::string absNIPath = getNIFilePath(absDllPath);
+       std::string absNIPath = getNIFilePath(absDllPath, opt);
        if (absNIPath.empty()) {
                return false;
        }
@@ -291,25 +294,11 @@ static bool checkNIExistence(const std::string& absDllPath)
        return false;
 }
 
-static bool checkAppNIExistence(const std::string& absDllPath, NIOption* opt)
-{
-       std::string absNIPath = getAppNIFilePath(absDllPath, opt);
-       if (absNIPath.empty()) {
-               return false;
-       }
-
-       if (isFile(absNIPath)) {
-               return true;
-       }
-
-       return false;
-}
-
 static bool checkDllExistInDir(const std::string& path)
 {
        bool ret = false;
        auto func = [&ret](const std::string& f_path, const std::string& f_name) {
-               if (isManagedAssembly(f_name) || isNativeImage(f_name)) {
+               if (isManagedAssembly(f_name) || isR2RImage(f_name)) {
                        ret = true;
                }
        };
@@ -320,41 +309,18 @@ static bool checkDllExistInDir(const std::string& path)
 }
 
 /*
- * Get the list of managed files in the specific directory
- * Absolute paths of managed files are stored at the result list.
- * If native image already exist in the same directory, managed file is ignored.
- */
-static ni_error_e getTargetDllList(const std::string& path, std::vector<std::string>& fileList)
-{
-       if (!isDirectory(path)) {
-               return NI_ERROR_INVALID_PARAMETER;
-       }
-
-       auto func = [&fileList](const std::string& f_path, const std::string& f_name) {
-               if (isManagedAssembly(f_path) && !checkNIExistence(f_path)) {
-                       fileList.push_back(getAbsolutePath(f_path));
-               }
-       };
-
-       scanFilesInDirectory(path, func, 0);
-
-       return NI_ERROR_NONE;
-}
-
-/*
- * Get the list of managed files in the specific directory of Application
+ * Get the list of managed files in the specific directory (of Application)
  * Absolute paths of managed files are stored at the result list.
- * If native image already exist in the .native_image directory, managed file is ignored.
- *
+ * If native image already exist in the (same / .native_image) directory, managed file is ignored.
  */
-static ni_error_e getAppTargetDllList(const std::string& path, std::vector<std::string>& fileList, NIOption *opt)
+static ni_error_e getTargetDllList(const std::string& path, std::vector<std::string>& fileList, NIOption *opt)
 {
        if (!isDirectory(path)) {
                return NI_ERROR_INVALID_PARAMETER;
        }
 
        auto func = [&fileList, opt](const std::string& f_path, const std::string& f_name) {
-               if (isManagedAssembly(f_path) && !checkAppNIExistence(f_path, opt)) {
+               if (isManagedAssembly(f_path) && !checkNIExistence(f_path, opt)) {
                        fileList.push_back(getAbsolutePath(f_path));
                }
        };
@@ -482,7 +448,7 @@ static ni_error_e crossgen2PostAction(const std::string& dllPath, const std::str
 
        // if AppNI then move ni.dll file to .native_image and copy pdb to .native_image
        if (opt->flags & NI_FLAGS_APPNI) {
-               outFile = getAppNIFilePath(dllPath, opt);
+               outFile = getNIFilePath(dllPath, opt);
                makePdbSymlinkForNI(dllPath, outFile);
 
                if (opt->flags & NI_FLAGS_INPUT_BUBBLE && opt->flags & NI_FLAGS_NO_PIPELINE) {
@@ -581,11 +547,8 @@ static ni_error_e crossgen2NoPipeLine(const std::vector<std::string>& dllList, c
 {
        for (auto& dllPath : dllList) {
                std::string niPath;
-               if (opt->flags & NI_FLAGS_APPNI) {
-                       niPath = getAppNIFilePath(dllPath, opt);
-               } else {
-                       niPath = getNIFilePath(dllPath);
-               }
+               niPath = getNIFilePath(dllPath, opt);
+
 #ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
                uintptr_t baseAddr = 0;
                if (isTPADll(dllPath)) {
@@ -721,6 +684,8 @@ static void renameAppNITmpPath(NIOption* opt)
        if (isDirectory(niTmpPath)) {
                if (rename(niTmpPath.c_str(), niPath.c_str())) {
                        _SERR("Fail to rename from .native_image_tmp to .native_image");
+               } else {
+                       _SOUT("Success to rename from %s to %s", niTmpPath.c_str(), niPath.c_str());
                }
        }
 }
@@ -808,12 +773,7 @@ static ni_error_e doAOTList(std::vector<std::string>& dllList, const std::string
                if (opt->flags & NI_FLAGS_INPUT_BUBBLE) {
                        for (auto &dll : dllList) {
                                std::string tmpFile;
-                               std::string niFile;
-                               if (opt->flags & NI_FLAGS_APPNI) {
-                                       niFile = getAppNIFilePath(dll, opt);
-                               } else {
-                                       niFile = getNIFilePath(dll);
-                               }
+                               std::string niFile = getNIFilePath(dll, opt);
                                tmpFile = niFile + ".tmp";
 
                                if (exist(tmpFile)) {
@@ -837,16 +797,16 @@ static ni_error_e doAOTFile(const std::string& dllFile, const std::string& refPa
                return NI_ERROR_NO_SUCH_FILE;
        }
 
+       if (checkNIExistence(dllFile, opt)) {
+               _SERR("Native image file is already exist : %s", dllFile.c_str());
+               return NI_ERROR_ALREADY_EXIST;
+       }
+
        if (!isManagedAssembly(dllFile)) {
                _SERR("Failed. Input parameter is not managed dll (%s)\n", dllFile.c_str());
                return NI_ERROR_INVALID_PARAMETER;
        }
 
-       if (checkNIExistence(dllFile)) {
-               _SERR("Native image file is already exist : %s", dllFile.c_str());
-               return NI_ERROR_ALREADY_EXIST;
-       }
-
        std::vector<std::string> dllList;
        dllList.push_back(getAbsolutePath(dllFile));
        return doAOTList(dllList, refPaths, opt);
@@ -991,7 +951,7 @@ ni_error_e createNIUnderTAC(const std::string& targetPath, const std::string& re
 
        // get managed file list from targetPath
        std::vector<std::string> dllList;
-       ret = getTargetDllList(targetPath, dllList);
+       ret = getTargetDllList(targetPath, dllList, opt);
        if (ret != NI_ERROR_NONE) {
                return ret;
        }
@@ -1000,10 +960,10 @@ ni_error_e createNIUnderTAC(const std::string& targetPath, const std::string& re
        std::vector<std::string> niList;
 
        for (auto &dll : dllList) {
-               if (!checkNIExistence(dll)) {
+               if (!checkNIExistence(dll, opt)) {
                        needNIList.push_back(dll);
                }
-               niList.push_back(getNIFilePath(dll));
+               niList.push_back(getNIFilePath(dll, opt));
        }
 
        if (!needNIList.empty()) {
@@ -1063,13 +1023,8 @@ ni_error_e createNIUnderDirs(const std::string& rootPaths, NIOption* opt)
                        if (ret != NI_ERROR_NONE) {
                                return ret;
                        }
-               } else if (opt->flags & NI_FLAGS_APPNI) {
-                       ret = getAppTargetDllList(path, fileList, opt);
-                       if (ret != NI_ERROR_NONE) {
-                               return ret;
-                       }
                } else {
-                       ret = getTargetDllList(path, fileList);
+                       ret = getTargetDllList(path, fileList, opt);
                        if (ret != NI_ERROR_NONE) {
                                return ret;
                        }
@@ -1153,7 +1108,7 @@ void removeNIPlatform()
 void removeNIUnderDirs(const std::string& rootPaths)
 {
        auto convert = [](const std::string& path, const std::string& filename) {
-               if (isNativeImage(path)) {
+               if (isR2RImage(path)) {
                        std::string assemblyPath = changeExtension(path, ".ni.dll", ".dll");
                        if (exist(assemblyPath)) {
                                if (remove(path.c_str())) {
index bf8d2dc..06ef6e4 100644 (file)
@@ -110,7 +110,6 @@ static bool hasValidR2RHeader(void* pAddr)
 {
        IMAGE_NT_HEADERS* pNTHeaders = getNTHeaders(pAddr);
        if (!pNTHeaders) {
-               _SERR("Invalid NT Header");
                return false;
        }
 
@@ -141,12 +140,11 @@ static bool hasValidR2RHeader(void* pAddr)
        return false;
 }
 
-bool isR2RImage(std::string fileName)
+bool isR2RImage(const std::string& fileName)
 {
        int fd;
        struct stat sb;
        if ((fd = open(fileName.c_str(), O_RDONLY)) == -1) {
-               _SERR("File Not Found: %s", fileName.c_str());
                return false;
        }
 
@@ -157,7 +155,6 @@ bool isR2RImage(std::string fileName)
 
        void* pAddr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
        if (pAddr == MAP_FAILED) {
-               _SERR("Fail to Map File: %s", fileName.c_str());
                close(fd);
                return false;
        }
@@ -169,12 +166,11 @@ bool isR2RImage(std::string fileName)
        return ret;
 }
 
-unsigned int getSizeOfImage(std::string fileName)
+unsigned int getSizeOfImage(const std::string& fileName)
 {
        int fd;
        struct stat sb;
        if ((fd = open(fileName.c_str(), O_RDONLY)) == -1) {
-               _SERR("File Not Found: %s", fileName.c_str());
                return 0;
        }
 
@@ -185,14 +181,12 @@ unsigned int getSizeOfImage(std::string fileName)
 
        void* pAddr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
        if (pAddr == MAP_FAILED) {
-               _SERR("Fail to Map File: %s", fileName.c_str());
                close(fd);
                return 0;
        }
 
        IMAGE_NT_HEADERS* pNTHeaders = getNTHeaders(pAddr);
        if (!pNTHeaders) {
-               _SERR("Invalid NT Header");
                munmap(pAddr, sb.st_size);
                close(fd);
                return 0;
index 93462ec..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());
index c01a616..6bf9b57 100644 (file)
@@ -40,16 +40,16 @@ static const char* __DOTNET_DIR = __STR(DOTNET_DIR);
 #undef __STR
 #undef __XSTR
 
-std::vector<std::string> nugetPackagesAssembliesSha;
-std::vector<std::string> tacDB;
-std::vector<std::string> createDirectories;
-std::vector<std::string> createLibraries;
-std::vector<std::string> updateTac;
-tac_state tacState = TAC_STATE_NONE;
+static std::vector<std::string> nugetPackagesAssembliesSha;
+static std::vector<std::string> tacDB;
+static std::vector<std::string> createDirectories;
+static std::vector<std::string> createLibraries;
+static std::vector<std::string> updateTac;
+static tac_state tacState = TAC_STATE_NONE;
 static sqlite3 *tac_db = NULL;
 static sqlite3 *tlc_db = NULL;
-bool tacPluginInstalled = false;
-bool tacPluginFinished = false;
+static bool tacPluginInstalled = false;
+static bool tacPluginFinished = false;
 
 static void createSHA256Info(std::string sha256Info, std::string nugetPackage)
 {
index 4fcd787..472415d 100644 (file)
@@ -22,7 +22,7 @@
 
 static PluginFunc* __pluginFunc = NULL;
 static void* __pluginLib;
-bool initializedPluginManager = false;
+static bool initializedPluginManager = false;
 
 int initializePluginManager(const char* appType)
 {
index 9f34fb4..37ba52e 100644 (file)
@@ -43,6 +43,7 @@
 #include "log.h"
 #include "utils.h"
 #include "path_manager.h"
+#include "r2r_checker.h"
 
 static bool iCompare(const std::string& a, int aOffset, const std::string& b, int bOffset, int length)
 {
@@ -55,12 +56,7 @@ static bool iCompare(const std::string& a, int aOffset, const std::string& b, in
 
 bool isManagedAssembly(const std::string& fileName)
 {
-       return iCompare(fileName, fileName.size()-4, ".dll", 0, 4) && !isNativeImage(fileName);
-}
-
-bool isNativeImage(const std::string& fileName)
-{
-       return iCompare(fileName, fileName.size()-7, ".ni", 0, 3);
+       return iCompare(fileName, fileName.size()-4, ".dll", 0, 4) && !isR2RImage(fileName);
 }
 
 std::string concatPath(const std::string& path1, const std::string& path2)
@@ -82,7 +78,9 @@ void splitPath(const std::string& path, std::vector<std::string>& out)
        std::string token;
 
        while (std::getline(ss, token, ':')) {
-               out.push_back(token);
+               if (token != "") {
+                       out.push_back(token);
+               }
        }
 }
 
@@ -340,13 +338,13 @@ void addAssembliesFromDirectories(const std::vector<std::string>& directories, s
        std::unordered_map<std::string, std::string> assemPaths;
 
        auto reader = [&assems, &assemPaths](const std::string& path, const std::string& filename) {
-               if (isManagedAssembly(filename) || isNativeImage(filename)) {
+               if (isManagedAssembly(filename) || isR2RImage(filename)) {
                        std::string assem = getAssemblyNameFromPath(filename);
 
                        if (assemPaths.count(assem) == 0) {
                                assems.push_back(assem);
                                assemPaths[assem] = path;
-                       } else if (isManagedAssembly(assemPaths[assem]) && isNativeImage(filename)) {
+                       } else if (isManagedAssembly(assemPaths[assem]) && isR2RImage(filename)) {
                                // Update only if a native image is found in the same directory.
                                // For example, if we have two directories = { X, Y } where X contains A.dll and
                                // Y contains both A.dll and A.ni.dll, always A.dll in X will be used.