static std::string getNIFilePath(const std::string& absDllPath, NIOption* opt)
{
std::string dllPath = absDllPath;
+ std::string fileName = getFileName(absDllPath);
if (opt->flags & NI_FLAGS_APPNI) {
std::string niDirPath;
std::string niTmpDirPath;
niTmpDirPath = prevPath;
_SERR("fail to create dir (%s)", niTmpDirPath.c_str());
}
- dllPath = concatPath(niTmpDirPath, getFileName(absDllPath));
+ dllPath = concatPath(niTmpDirPath, fileName);
} else {
- dllPath = concatPath(niDirPath, getFileName(absDllPath));
+ dllPath = concatPath(niDirPath, fileName);
}
+ } else if (opt->flags & NI_FLAGS_RESOURCE_NI) {
+ std::string rpkDir = concatPath(__pm->getAppRootPath(), APP_NI_SUB_DIR);
+ dllPath = createDir(rpkDir) ? concatPath(rpkDir, fileName) : concatPath(__pm->getAppRootPath(), fileName);
}
size_t index = dllPath.find_last_of(".");
}
}
+ if (opt->flags & NI_FLAGS_RESOURCE_NI) {
+ moveFile(niPath, changeExtension(dllPath, ".dll", ".ni.dll"));
+ removeAll(concatPath(__pm->getAppRootPath(), APP_NI_SUB_DIR));
+ }
+
if (!(opt->flags & NI_FLAGS_INPUT_BUBBLE && opt->flags & NI_FLAGS_NO_PIPELINE)) {
_SOUT("Native image %s generated successfully.", outFile.c_str());
}
}
_SOUT("Complete make native image for pkg (%s)", pkgId);
- return NI_ERROR_NONE;
+ return NI_ERROR_NONE;
}
static bool isReadOnlyPkg(std::string pkgId)
return NI_ERROR_NONE;
}
-
ni_error_e createNIUnderDirs(const std::string& rootPaths, NIOption* opt)
{
ni_error_e ret = NI_ERROR_NONE;
_SERR("Failed to get root path from [%s]", pkgId.c_str());
return NI_ERROR_INVALID_PACKAGE;
}
+ __pm->setAppRootPath(rootPath);
char* extraDllPaths = pluginGetExtraDllPath();
if (extraDllPaths && extraDllPaths[0] != '\0') {
std::string targetDirs;
if (isRPK(pkgId)) {
- opt->flags &= ~NI_FLAGS_APPNI;
+ opt->flags &= ~NI_FLAGS_APPNI; // added to exclude logic of APP_NI
+ opt->flags |= NI_FLAGS_RESOURCE_NI; // added flag for RPK type
+ opt->flags |= NI_FLAGS_NO_PIPELINE; // added the flag to set the output path
+
std::string paths = getResourcePaths(rootPath);
if (paths.empty()) {
_SERR("Failed to get rpk paths from [%s]", pkgId.c_str());
}
targetDirs = paths;
} else {
- __pm->setAppRootPath(rootPath);
-
opt->flags |= NI_FLAGS_APPNI;
+ opt->flags &= ~NI_FLAGS_RESOURCE_NI; // added to exclude logic of RESOURCE_NI
if (isReadOnlyArea(rootPath)) {
opt->flags |= NI_FLAGS_APP_UNDER_RO_AREA;
if (isDirectory(path)) {
removeNIUnderDirs(path);
}
- }
+ }
} else {
__pm->setAppRootPath(rootPath);