Move RPK check code accepted/tizen/unified/20250428.091730 accepted/tizen/unified/x/20250429.081917
authorWoongsuk <ws77.cho@samsung.com>
Thu, 17 Apr 2025 00:22:16 +0000 (09:22 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Thu, 17 Apr 2025 04:15:19 +0000 (13:15 +0900)
The createNIUnderPkgRootWithPath() function can be called out-side.
So, RPK checking code should be don in it.

NativeLauncher/inc/ni_common.h
NativeLauncher/tool/ni_common.cc

index e0f04bfd5c7121140a657ef5d2645b88bc566aaa..d387f8f44644da93d17758c79e6182a96ac0232c 100644 (file)
@@ -42,6 +42,7 @@
 #define NI_FLAGS_RM_ORIGIN_AFTER_NI     0x0800
 #define NI_FLAGS_SET_PRIORITY           0x1000
 #define NI_FLAGS_PARALLELISM            0x2000
+#define NI_FLAGS_RPK                    0x4000
 
 typedef std::function<void (std::string)> afterCreate;
 
@@ -65,7 +66,6 @@ typedef struct NIOption{
        std::vector<std::string> mibcPath;
        int priority;
        std::string threadNum;
-       bool isRPK = false;
 } NIOption;
 
 /**
index ca659ceaa9fe92d891cc0640af645fbf5c069cf0..056892729586ac2326eb1362d58357cb5cd1f8d1 100644 (file)
@@ -738,7 +738,9 @@ static void swapExtensionRpkFiles(std::vector<std::string>& paths, NIOption* opt
        }
 
        for (auto& dll : dllList) {
-               rename(dll.c_str(), changeExtension(dll, ".dll", ".dll.backup").c_str());
+               if (rename(dll.c_str(), changeExtension(dll, ".dll", ".dll.backup").c_str())) {
+                       _SERR("Failed to rename from %s to backup file", dll.c_str());
+               }
        }
        for (auto& ni : niList) {
                std::string dll = changeExtension(ni, ".ni.dll", ".dll");
@@ -862,7 +864,7 @@ static ni_error_e doAOTList(std::vector<std::string>& dllList, const std::string
                renameAppNITmpPath(opt);
        }
 
-       if (opt->isRPK) {
+       if (opt->flags & NI_FLAGS_RPK) {
                swapExtensionRpkFiles(paths, opt);
        }
 
@@ -1130,7 +1132,6 @@ ni_error_e createNIUnderPkgRoot(const std::string& pkgId, NIOption* opt)
                _SERR("Failed to get root path from [%s]", pkgId.c_str());
                return NI_ERROR_INVALID_PACKAGE;
        }
-       opt->isRPK = isRPK(pkgId);
 
        return createNIUnderPkgRootWithPath(rootPath, opt);
 }
@@ -1156,8 +1157,15 @@ ni_error_e createNIUnderPkgRootWithPath(const std::string& rootPath, NIOption* o
                splitPath(extraDllPaths, opt->extraRefPath);
        }
 
+       std::string pkgId = getPkgId(rootPath);
+       if (!pkgId.empty()) {
+               if (isRPK(pkgId)) {
+                       opt->flags |= NI_FLAGS_RPK;
+               }
+       }
+
        std::string targetDirs;
-       if (opt->isRPK) {
+       if (opt->flags & NI_FLAGS_RPK) {
                opt->flags &= ~NI_FLAGS_APPNI; // added to exclude logic of APP_NI
                opt->flags |= NI_FLAGS_NO_PIPELINE; // added the flag to set the output path