createNiUnderDirs(platformDirs, 3, [](const char* ni) {
smack_(ni, "_");
- });
+ }, false);
}
void createNiSelect(const char* dllPath)
}
smack_(niPath.c_str(), "_");
}
- }
- else
+ } else {
printf("Already [%s] file is exist\n", niPath.c_str());
+ }
+ } else {
+ printf("Failed to find dll : %s", dllPath);
}
}
-void createNiUnderDirs(const char* rootPaths[], int count, const char* ignores[], int igcount, afterCreate cb)
+void createNiUnderDirs(const char* rootPaths[], int count, const char* ignores[], int igcount, afterCreate cb, bool update)
{
std::string appPaths;
for (int i = 0; i < count; i++) {
if (appPaths.back() == ':')
appPaths.pop_back();
- auto convert = [&appPaths, ignores, igcount, &cb](const char* path, const char* name) {
+ auto convert = [&appPaths, ignores, igcount, &cb, update](const char* path, const char* name) {
for (int i = 0; i < igcount; i++) {
if (strcmp(path, ignores[i]) == 0)
return;
}
- std::string ni;
- if (isManagedAssembly(path) && !isNativeImage(path) && !niExist(path, ni)) {
+ std::string niPath;
+ if (isManagedAssembly(path) && !isNativeImage(path)) {
+ if (niExist(path, niPath)) {
+ if (update && !niPath.empty()) {
+ _INFO("override [%s] file", niPath.c_str());
+ } else {
+ _INFO("Already [%s] file is exist", niPath.c_str());
+ return;
+ }
+ }
crossgen(path, appPaths.c_str());
- if (niExist(path, ni)) {
+ if (niExist(path, niPath)) {
// change owner and groups for generated ni file.
struct stat info;
if (!stat(path, &info)) {
- if (chown(ni.c_str(), info.st_uid, info.st_gid) == -1)
+ if (chown(niPath.c_str(), info.st_uid, info.st_gid) == -1)
_ERR("Failed to change owner and group name");
}
if (cb != nullptr)
- cb(ni.c_str());
+ cb(niPath.c_str());
+ } else {
+ _INFO("Failed to create native image for %s", path);
}
}
};
for (int i = 0; i < count; i++)
- scanFilesInDir(rootPaths[i], convert, -1);
+ scanFilesInDir(rootPaths[i], convert, 1);
}
-void createNiUnderDirs(const char* rootPaths[], int count, afterCreate cb)
+void createNiUnderDirs(const char* rootPaths[], int count, afterCreate cb, bool update)
{
- createNiUnderDirs(rootPaths, count, nullptr, 0, cb);
+ createNiUnderDirs(rootPaths, count, nullptr, 0, cb, update);
}
-void createNiUnderDirs(const char* rootPaths[], int count)
+void createNiUnderDirs(const char* rootPaths[], int count, bool update)
{
- createNiUnderDirs(rootPaths, count, nullptr);
+ createNiUnderDirs(rootPaths, count, nullptr, update);
}
int removeNiUnderPkgRoot(const char* pkgName)
_INFO("sleep %d usec", interval);
usleep(interval);
}
- });
+ }, true);
return 0;
}
#include <functional>
typedef std::function<void (const char*)> afterCreate;
-void createNiUnderDirs(const char* rootPaths[], int count, const char* ignores[], int igcount, afterCreate cb);
-void createNiUnderDirs(const char* rootPaths[], int count, afterCreate cb);
-void createNiUnderDirs(const char* rootPaths[], int count);
+void createNiUnderDirs(const char* rootPaths[], int count, const char* ignores[], int igcount, afterCreate cb, bool update);
+void createNiUnderDirs(const char* rootPaths[], int count, afterCreate cb, bool update);
+void createNiUnderDirs(const char* rootPaths[], int count, bool update);
int createNiUnderPkgRoot(const char* pkgName);
void createNiPlatform();
void createNiSelect(const char* dllPath);
" --system - Create NI under System DLLs\n"
" --dll - Create NI for DLL\n"
" --pkg - Create NI for package\n"
+ " --dir - Create NI for directory\n"
" --reset-system - Remove System NI files\n"
" --reset-pkg - Remove App NI files\n"
"\n"
{
bool pkgMode = false;
bool dllMode = false;
+ bool dirMode = false;
bool rmPkgMode = false;
if (cmdOptionExists(argv, argv+argc, "--help")) {
dllMode = true;
} else if (cmdOptionExists(argv, argv+argc, "--pkg")) {
pkgMode = true;
+ } else if (cmdOptionExists(argv, argv+argc, "--dir")) {
+ dirMode = true;
} else if (cmdOptionExists(argv, argv+argc, "--reset-system")) {
removeNiPlatform();
return 0;
} else if (dllMode) {
for (const char* dll : args)
createNiSelect(dll);
- } else {
- createNiUnderDirs(args.data(), args.size());
+ } else if (dirMode) {
+ createNiUnderDirs(args.data(), args.size(), false);
}
return 0;