}
}
-static void crossgen(const char* dllPath, const char* appPath)
+static void crossgen(const char* dllPath, const char* appPath, bool enableR2R)
{
//pid_t parent = getpid();
pid_t pid = fork();
std::vector<const char*> argv = {
__CROSSGEN_PATH,
"/Trusted_Platform_Assemblies", tpa.c_str(),
- "/JITPath", __JIT_PATH,
- "/FragileNonVersionable"
+ "/JITPath", __JIT_PATH
};
+
+ if (!enableR2R) {
+ fprintf(stderr, "FNV mode enabled!!!\n");
+ argv.push_back("/FragileNonVersionable");
+ } else {
+ fprintf(stderr, "R2R mode enabled!!!\n");
+ }
+
if (appPath != nullptr) {
argv.push_back("/App_Paths");
argv.push_back(appPath);
}
// When you create native image with pkgid, ni file is generated even though already ni file exist.
- if (createNiUnderPkgRoot(pkgId) != 0) {
+ // Regenerate ni files with R2R mode forcibiliy. (there is no way to now which option is used)
+ if (createNiUnderPkgRoot(pkgId, true) != 0) {
_ERR("Failed to get root path from [%s]", pkgId);
return -1;
} else {
return 0;
}
-static void createCoreLibNI()
+static void createCoreLibNI(bool enableR2R)
{
std::string coreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll");
std::string niCoreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.ni.dll");
std::string coreLibBackup = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll.Backup");
if (!niExist(coreLib, niCoreLib)) {
- crossgen(coreLib.c_str(), nullptr);
+ crossgen(coreLib.c_str(), nullptr, enableR2R);
if (!fileNotExist(niCoreLib)) {
// change owner and groups for generated ni file.
struct stat info;
void removeNiPlatform()
{
std::string coreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll");
- std::string niCoreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.ni.dll");
std::string coreLibBackup = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll.Backup");
if (fileNotExist(coreLibBackup)) {
removeNiUnderDirs(platformDirs, 3);
}
-void createNiPlatform()
+void createNiPlatform(bool enableR2R)
{
- createCoreLibNI();
+ createCoreLibNI(enableR2R);
const char* platformDirs[] = {__RUNTIME_DIR, __DEVICE_API_DIR, "/usr/bin"};
createNiUnderDirs(platformDirs, 3, [](const char* ni) {
smack_(ni, "_");
- }, false);
+ }, enableR2R);
}
-void createNiSelect(const char* dllPath)
+void createNiSelect(const char* dllPath, bool enableR2R)
{
- createCoreLibNI();
+ createCoreLibNI(enableR2R);
std::string niPath;
if (!fileNotExist(dllPath)) {
if (!niExist(dllPath, niPath)) {
- crossgen(dllPath, nullptr);
+ crossgen(dllPath, nullptr, enableR2R);
if (niExist(dllPath, niPath)) {
// change owner and groups for generated ni file.
struct stat info;
}
}
-void createNiUnderDirs(const char* rootPaths[], int count, const char* ignores[], int igcount, afterCreate cb, bool update)
+void createNiUnderDirs(const char* rootPaths[], int count, const char* ignores[], int igcount, afterCreate cb, bool update, bool enableR2R)
{
std::string appPaths;
for (int i = 0; i < count; i++) {
if (appPaths.back() == ':')
appPaths.pop_back();
- auto convert = [&appPaths, ignores, igcount, &cb, update](const char* path, const char* name) {
+ auto convert = [&appPaths, ignores, igcount, &cb, update, enableR2R](const char* path, const char* name) {
for (int i = 0; i < igcount; i++) {
if (strcmp(path, ignores[i]) == 0)
return;
return;
}
}
- crossgen(path, appPaths.c_str());
+ crossgen(path, appPaths.c_str(), enableR2R);
if (niExist(path, niPath)) {
// change owner and groups for generated ni file.
struct stat info;
for (int i = 0; i < count; i++)
scanFilesInDir(rootPaths[i], convert, 1);
}
-void createNiUnderDirs(const char* rootPaths[], int count, afterCreate cb, bool update)
+void createNiUnderDirs(const char* rootPaths[], int count, afterCreate cb, bool update, bool enableR2R)
{
- createNiUnderDirs(rootPaths, count, nullptr, 0, cb, update);
+ createNiUnderDirs(rootPaths, count, nullptr, 0, cb, update, enableR2R);
}
-void createNiUnderDirs(const char* rootPaths[], int count, bool update)
+void createNiUnderDirs(const char* rootPaths[], int count, bool update, bool enableR2R)
{
- createNiUnderDirs(rootPaths, count, nullptr, update);
+ createNiUnderDirs(rootPaths, count, nullptr, update, enableR2R);
}
int removeNiUnderPkgRoot(const char* pkgName)
}
-int createNiUnderPkgRoot(const char* pkgName)
+int createNiUnderPkgRoot(const char* pkgName, bool enableR2R)
{
std::string pkgRoot;
if (getRootPath(pkgName, pkgRoot) < 0)
_INFO("sleep %d usec", interval);
usleep(interval);
}
- }, true);
+ }, true, enableR2R);
return 0;
}
typedef std::function<void (const char*)> afterCreate;
int regenerateAppNI();
-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);
+void createNiUnderDirs(const char* rootPaths[], int count, const char* ignores[], int igcount, afterCreate cb, bool update, bool enableR2R);
+void createNiUnderDirs(const char* rootPaths[], int count, afterCreate cb, bool update, bool enableR2R);
+void createNiUnderDirs(const char* rootPaths[], int count, bool update, bool enableR2R);
+int createNiUnderPkgRoot(const char* pkgName, bool enableR2R);
+void createNiPlatform(bool enableR2R);
+void createNiSelect(const char* dllPath, bool enableR2R);
void removeNiPlatform();
int removeNiUnderPkgRoot(const char* pkgName);
" --dll - Create NI for DLL\n"
" --pkg - Create NI for package\n"
" --dir - Create NI for directory\n"
+ " --r2r - Use ready-to-run option (default: FNV)\n"
" --reset-system - Remove System NI files\n"
" --reset-pkg - Remove App NI files\n"
" --regen-all-app - Re-generate All App NI files\n"
bool dllMode = false;
bool dirMode = false;
bool rmPkgMode = false;
+ bool enableR2R = false;
+
+ if (cmdOptionExists(argv, argv+argc, "--r2r")) {
+ enableR2R = true;
+ }
if (cmdOptionExists(argv, argv+argc, "--help")) {
help(argv[0]);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--system")) {
- createNiPlatform();
+ createNiPlatform(enableR2R);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--dll")) {
dllMode = true;
if (pkgMode) {
for (const char* pkg : args) {
- if (createNiUnderPkgRoot(pkg) != 0) {
+ if (createNiUnderPkgRoot(pkg, enableR2R) != 0) {
fprintf(stderr, "Failed to get root path from [%s]\n", pkg);
return 1;
}
}
} else if (dllMode) {
for (const char* dll : args)
- createNiSelect(dll);
+ createNiSelect(dll, enableR2R);
} else if (dirMode) {
- createNiUnderDirs(args.data(), args.size(), false);
+ createNiUnderDirs(args.data(), args.size(), false, enableR2R);
}
return 0;