}
}
-static std::string getNIFilePath(const std::string& dllPath)
-{
- size_t index = dllPath.find_last_of(".");
- if (index == std::string::npos) {
- _SERR("File doesnot contain extension. fail to get NI file name");
- return "";
- }
- std::string fName = dllPath.substr(0, index);
- std::string fExt = dllPath.substr(index, dllPath.length());
-
- // crossgen generate file with lower case extension only
- std::transform(fExt.begin(), fExt.end(), fExt.begin(), ::tolower);
- std::string niPath = fName + ".ni" + fExt;
-
- return niPath;
-}
-
/**
* @brief create the directory including parents directory, and
* copy ownership and smack labels to the created directory.
return true;
}
+static std::string getNIFilePath(const std::string& dllPath)
+{
+ size_t index = dllPath.find_last_of(".");
+ if (index == std::string::npos) {
+ _SERR("File doesnot contain extension. fail to get NI file name");
+ return "";
+ }
+ std::string fName = dllPath.substr(0, index);
+ std::string fExt = dllPath.substr(index, dllPath.length());
+
+ // crossgen generate file with lower case extension only
+ std::transform(fExt.begin(), fExt.end(), fExt.begin(), ::tolower);
+ std::string niPath = fName + ".ni" + fExt;
+
+ return niPath;
+}
+
static std::string getAppNIFilePath(const std::string& absDllPath, NIOption* opt)
{
std::string niDirPath;
return false;
}
+static bool checkAppNIExistence(const std::string& absDllPath, NIOption* opt)
+{
+ std::string absNIPath = getAppNIFilePath(absDllPath, opt);
+ if (absNIPath.empty()) {
+ return false;
+ }
+
+ if (isFile(absNIPath)) {
+ return true;
+ }
+
+ return false;
+}
+
static bool checkDllExistInDir(const std::string& path)
{
bool ret = false;
return NI_ERROR_NONE;
}
+/*
+ * Get the list of managed files in the specific directory of Application
+ * Absolute paths of managed files are stored at the result list.
+ * If native image already exist in the .native_image directory, managed file is ignored.
+ *
+ */
+static ni_error_e getAppTargetDllList(const std::string& path, std::vector<std::string>& fileList, NIOption *opt)
+{
+ if (!isDirectory(path)) {
+ return NI_ERROR_INVALID_PARAMETER;
+ }
+
+ auto func = [&fileList, opt](const std::string& f_path, const std::string& f_name) {
+ if (isManagedAssembly(f_path) && !checkAppNIExistence(f_path, opt)) {
+ fileList.push_back(getAbsolutePath(f_path));
+ }
+ };
+
+ scanFilesInDirectory(path, func, 0);
+
+ return NI_ERROR_NONE;
+}
+
static void makeArgs(std::vector<const char*>& args, const std::vector<std::string>& refPaths, NIOption* opt)
{
args.push_back(CORERUN_CMD.c_str());
if (ret != NI_ERROR_NONE) {
return ret;
}
+ } else if (opt->flags & NI_FLAGS_APPNI) {
+ ret = getAppTargetDllList(path, fileList, opt);
+ if (ret != NI_ERROR_NONE) {
+ return ret;
+ }
} else {
ret = getTargetDllList(path, fileList);
if (ret != NI_ERROR_NONE) {