From 0ea36001b1278f1081145ec2f1e83b7c86809a88 Mon Sep 17 00:00:00 2001 From: Woongsuk Date: Thu, 17 Apr 2025 09:22:16 +0900 Subject: [PATCH] Move RPK check code The createNIUnderPkgRootWithPath() function can be called out-side. So, RPK checking code should be don in it. --- NativeLauncher/inc/ni_common.h | 2 +- NativeLauncher/tool/ni_common.cc | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/NativeLauncher/inc/ni_common.h b/NativeLauncher/inc/ni_common.h index e0f04bf..d387f8f 100644 --- a/NativeLauncher/inc/ni_common.h +++ b/NativeLauncher/inc/ni_common.h @@ -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 afterCreate; @@ -65,7 +66,6 @@ typedef struct NIOption{ std::vector mibcPath; int priority; std::string threadNum; - bool isRPK = false; } NIOption; /** diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index ca659ce..0568927 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -738,7 +738,9 @@ static void swapExtensionRpkFiles(std::vector& 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& 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 -- 2.34.1