Modified to add 'NI_FLAGS_APPNI' flag and appPaths when the app generates ni
authorj-h.choi <j-h.choi@samsung.com>
Thu, 6 Feb 2020 03:58:39 +0000 (12:58 +0900)
committer이형주/Common Platform Lab(SR)/Staff Engineer/삼성전자 <leee.lee@samsung.com>
Fri, 7 Feb 2020 09:40:30 +0000 (18:40 +0900)
NativeLauncher/launcher/dotnet/dotnet_launcher.cc
NativeLauncher/tool/ni_common.cc

index 9a828f3..eccee22 100644 (file)
@@ -397,8 +397,9 @@ int CoreRuntime::initialize(bool standalone)
 
        _INFO("libcoreclr dlopen and dlsym success");
 
-       if (!standalone)
+       if (!standalone) {
                pluginPreload();
+       }
 
        // Set environment for System.Environment.SpecialFolder
        // Below function creates dbus connection by callging storage API.
@@ -431,8 +432,7 @@ int CoreRuntime::initialize(bool standalone)
 
        __initialized = true;
 
-       if (!standalone)
-       {
+       if (!standalone) {
                preloadTypes();         // Preload common managed code
        }
 
index 2326722..bd72dc2 100644 (file)
@@ -452,9 +452,7 @@ ni_error_e createNiDll(const std::string& dllPath, DWORD flags)
                return NI_ERROR_NONE;
        }
 
-       ni_error_e status = crossgen(dllPath, std::string(), flags);
-
-       return status;
+       return crossgen(dllPath, std::string(), flags);
 }
 
 void createNiUnderTAC(std::vector<std::string> nugets, DWORD flags)
@@ -488,8 +486,10 @@ ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags)
        }
 
        std::string binDir = concatPath(pkgRoot, "bin");
+       std::string libDir = concatPath(pkgRoot, "lib");
        std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR);
        std::string binNIDir = concatPath(binDir, APP_NI_SUB_DIR);
+       std::string paths = binDir + ":" + libDir + ":" + tacDir;
        if (bf::exists(tacDir)) {
                try {
                        for (auto& symlinkAssembly : bf::recursive_directory_iterator(tacDir)) {
@@ -499,7 +499,8 @@ ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags)
                                                std::string originPath = bf::read_symlink(symPath).string();
                                                std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
                                                if (!bf::exists(originNiPath)) {
-                                                       if(createNiDll(originPath, flags) != NI_ERROR_NONE) {
+                                                       flags |= NI_FLAGS_APPNI;
+                                                       if(crossgen(originPath, paths, flags) != NI_ERROR_NONE) {
                                                                fprintf(stderr, "Failed to create NI file [%s]\n", originPath.c_str());
                                                                return NI_ERROR_UNKNOWN;
                                                        }
@@ -510,10 +511,9 @@ ni_error_e createTACPkgRoot(const std::string& pkgId, DWORD flags)
                                                        fprintf(stderr, "%s symbolic link file generated successfully.\n", symNIPath.c_str());
                                                        copySmackAndOwnership(tacDir.c_str(), symNIPath.c_str(), true);
 
-                                                       std::string NIFileName = symNIPath.substr(symNIPath.rfind('/') + 1);
-                                                       if (!removeFile(concatPath(binNIDir, NIFileName))) {
-                                                               fprintf(stderr, "Failed to remove of %s\n", concatPath(binNIDir, NIFileName).c_str());
-                                                               return NI_ERROR_UNKNOWN;
+                                                       std::string niFileName = symNIPath.substr(symNIPath.rfind('/') + 1);
+                                                       if (!removeFile(concatPath(binNIDir, niFileName))) {
+                                                               fprintf(stderr, "Failed to remove of %s\n", concatPath(binNIDir, niFileName).c_str());
                                                        }
                                                }
                                        }
@@ -593,6 +593,7 @@ ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string&
        std::string binDir = concatPath(pkgRoot, "bin");
        std::string libDir = concatPath(pkgRoot, "lib");
        std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR);
+       std::string binNIDir = concatPath(binDir, APP_NI_SUB_DIR);
        std::string paths = binDir + ":" + libDir + ":" + tacDir;
 
        if (bf::is_symlink(dllPath)) {
@@ -601,7 +602,8 @@ ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string&
                                std::string originPath = bf::read_symlink(dllPath).string();
                                std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
                                if (!bf::exists(originNiPath)) {
-                                       if(createNiDll(originPath, flags) != NI_ERROR_NONE) {
+                                       flags |= NI_FLAGS_APPNI;
+                                       if(crossgen(originPath, paths, flags) != NI_ERROR_NONE) {
                                                fprintf(stderr, "Failed to create NI file [%s]\n", originPath.c_str());
                                                return NI_ERROR_UNKNOWN;
                                        }
@@ -612,6 +614,10 @@ ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string&
                                        fprintf(stderr, "%s symbolic link file generated successfully.\n", setNiPath.c_str());
                                        copySmackAndOwnership(tacDir.c_str(), setNiPath.c_str(), true);
                                }
+                               std::string niFileName = setNiPath.substr(setNiPath.rfind('/') + 1);
+                               if (!removeFile(concatPath(binNIDir, niFileName))) {
+                                       fprintf(stderr, "Failed to remove of %s\n", concatPath(binNIDir, niFileName).c_str());
+                               }
                        }
                }
                return NI_ERROR_NONE;