Use relative symlink for NI files of pre-compiled app
authorj-h.choi <j-h.choi@samsung.com>
Mon, 30 Dec 2024 01:16:12 +0000 (10:16 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Tue, 14 Jan 2025 00:10:25 +0000 (09:10 +0900)
Change-Id: Icfde96d93ea5d342f36cc2070fc270b74f6c6ac7

NativeLauncher/installer-plugin/prefer_dotnet_aot_plugin.cc

index 75bb2f931e0ce81b274d7f8e7072a3ae69787644..3c1945b563e658672fc7b3072d2a3b33f9474444 100644 (file)
@@ -74,11 +74,31 @@ extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL(const char *pkgId, const char *app
 
        // if package contains native image, skip AOT.
        std::string rootPath = getRootPath(pkgId);
-       if (!rootPath.empty()) {
-               if (exist(concatPath(rootPath, concatPath("bin", APP_NI_SUB_DIR)))) {
-                       _INFO("Package already contains native images. Skip native image generation");
-                       doAOT = false;
+       std::string binPath = concatPath(rootPath, "bin");
+       std::string nativeImagePath = concatPath(binPath, APP_NI_SUB_DIR);
+       if (rootPath.empty()) {
+               _ERR("Failed to get root path from [%s]", pkgId);
+               return -1;
+       }
+
+       if (exist(nativeImagePath)) {
+               if (exist(concatPath(binPath, PRE_COMPILED_PACKAGE_FILE))) {
+                       _INFO("The %s is a Pre-Compiled package.", pkgId);
+                       try {
+                               for (auto& ni : bf::recursive_directory_iterator(nativeImagePath)) {
+                                       std::string niFile = ni.path().string();
+                                       if (isNativeImage(niFile)) {
+                                               std::string dllFile = changeExtension(niFile, ".ni.dll", ".dll");
+                                               bf::create_symlink(getFileName(niFile), dllFile);
+                                               copySmackAndOwnership(niFile, dllFile, true);
+                                       }
+                               }
+                       } catch (const bf::filesystem_error& error) {
+                               _ERR("Failed to recursive directory: %s", error.what());
+                       }
                }
+               _INFO("Package already contains native images. Skip native image generation");
+               doAOT = false;
        }
 
        if (doAOT) {