bool disableTacMode = false;
bool enableTacMode = false;
- bool doGenUniqueBaseSystem = true;
-
NiCommonOption option = {std::string(), std::string(), std::string()};
if (initNICommon(&option) != NI_ERROR_NONE) {
fprintf(stderr, "Fail to initialize NI Common\n");
help(argv[0]);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--ni-system")) {
- createNiPlatform(enableR2R, doGenUniqueBaseSystem);
+ createNiPlatform(enableR2R);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--ni-dll")) {
dllMode = true;
// donot return error code for generation failure.
// we have to run crossgen for all input dlls.
for (const std::string dll : args) {
- int ret = createNiDll(dll, enableR2R, doGenUniqueBaseSystem);
+ int ret = createNiDll(dll, enableR2R);
if (ret == NI_ERROR_ALREADY_EXIST) {
// skip for already exist case
} else if (ret != NI_ERROR_NONE) {
}
}
} else if (dirMode) {
- createNiUnderDirs(args.data(), args.size(), enableR2R, doGenUniqueBaseSystem);
+ createNiUnderDirs(args.data(), args.size(), enableR2R);
} else if (disableTacMode) {
for (const std::string pkg : args) {
int ret = disableTACPackage(pkg);
}
// Save base address of system ni image to file
-static void updateBaseAddrFile(const std::string &dllPath, uintptr_t baseAddr)
+static void updateBaseAddrFile(const std::string &absNiPath, uintptr_t baseAddr)
{
- std::string absNiPath = getNiFilePath(dllPath);
- if (absNiPath.empty()) {
- fprintf(stderr, "Failed to get ni file path for %s\n", dllPath.c_str());
- return;
- }
-
uintptr_t niSize = getFileSize(absNiPath);
if (niSize == 0) {
fprintf(stderr, "File %s doesn't exist\n", absNiPath.c_str());
#endif
// baseAddr should be checked in file before getting here
-static ni_error_e crossgen(const std::string& dllPath, const std::string& appPath, bool enableR2R, uintptr_t baseAddr = 0, bool isAppNI = false)
+static ni_error_e crossgen(const std::string& dllPath, const std::string& appPath, bool enableR2R, bool isAppNI = false)
{
if (!isFileExist(dllPath)) {
fprintf(stderr, "dll file is not exist : %s\n", dllPath.c_str());
absNiPath = getAppNIPath(absNiPath);
}
+#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
+ uintptr_t baseAddr = 0;
+
+ if (isTPADll(dllPath)) {
+ baseAddr = getNextBaseAddr();
+ }
+#endif
+
pid_t pid = fork();
if (pid == -1)
return NI_ERROR_UNKNOWN;
// niEixst() return false for System.Private.Corelib.dll
if (isFileExist(absNiPath)) {
updateAssemblyInfo(absDllPath, absNiPath);
+#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
+ if (baseAddr != 0) {
+ updateBaseAddrFile(absNiPath, baseAddr);
+ }
+#endif
return NI_ERROR_NONE;
} else {
fprintf(stderr, "Fail to create native image for %s\n", dllPath.c_str());
return 0;
}
-static void createCoreLibNI(bool enableR2R, bool doGenUniqueBaseSystem)
+static void createCoreLibNI(bool enableR2R)
{
std::string coreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll");
std::string niCoreLib = concatPath(getRuntimeDir(), "System.Private.CoreLib.ni.dll");
std::string coreLibBackup = concatPath(getRuntimeDir(), "System.Private.CoreLib.dll.Backup");
if (!isFileExist(coreLibBackup)) {
- uintptr_t baseAddr = 0;
-
-#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
- if (doGenUniqueBaseSystem) {
- baseAddr = getNextBaseAddr();
- }
-#endif
-
- if (!crossgen(coreLib, std::string(), enableR2R, baseAddr)) {
-#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
- if (doGenUniqueBaseSystem && baseAddr != 0) {
- updateBaseAddrFile(coreLib, baseAddr);
- }
-#endif
+ if (!crossgen(coreLib, std::string(), enableR2R)) {
if (rename(coreLib.c_str(), coreLibBackup.c_str())) {
fprintf(stderr, "Failed to rename System.Private.CoreLib.dll\n");
}
}
-void createNiPlatform(bool enableR2R, bool doGenUniqueBaseSystem)
+void createNiPlatform(bool enableR2R)
{
const std::string platformDirs[] = {getRuntimeDir(), getTizenFXDir()};
- createNiUnderDirs(platformDirs, 2, enableR2R, doGenUniqueBaseSystem);
+ createNiUnderDirs(platformDirs, 2, enableR2R);
}
-ni_error_e createNiDll(const std::string& dllPath, bool enableR2R, bool doGenUniqueBaseSystem)
+ni_error_e createNiDll(const std::string& dllPath, bool enableR2R)
{
- createCoreLibNI(enableR2R, doGenUniqueBaseSystem);
+ createCoreLibNI(enableR2R);
// System.Private.CoreLib.dll is generated in the createCoreLibNI function.
// Skip if input dll is System.Private.CoreLib.dll
if (dllPath.find("System.Private.CoreLib.dll") != std::string::npos) {
return NI_ERROR_NONE;
}
- uintptr_t baseAddr = 0;
-
-#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
- if (doGenUniqueBaseSystem && isTPADll(dllPath)) {
- baseAddr = getNextBaseAddr();
- }
-#endif
-
- ni_error_e status = crossgen(dllPath, std::string(), enableR2R, baseAddr);
-
-#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
- if (doGenUniqueBaseSystem && baseAddr != 0) {
- updateBaseAddrFile(dllPath, baseAddr);
- }
-#endif
+ ni_error_e status = crossgen(dllPath, std::string(), enableR2R);
return status;
}
-void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R, bool doGenUniqueBaseSystem, bool isAppNI)
+void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R, bool isAppNI)
{
- createCoreLibNI(enableR2R, doGenUniqueBaseSystem);
+ createCoreLibNI(enableR2R);
std::string appPaths;
for (int i = 0; i < count; i++) {
if (appPaths.back() == ':')
appPaths.pop_back();
- auto convert = [&appPaths, enableR2R, doGenUniqueBaseSystem, isAppNI](const std::string& path, const char* name) {
- uintptr_t baseAddr = 0;
-
-#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
- if (doGenUniqueBaseSystem && !isAppNI && isTPADll(path)) {
- baseAddr = getNextBaseAddr();
- }
-#endif
-
- if (!crossgen(path, appPaths.c_str(), enableR2R, baseAddr, isAppNI)) {
-#ifdef UNIQUE_DEFAULT_BASE_ADDR_SUPPORT
- if (doGenUniqueBaseSystem && !isAppNI && baseAddr != 0) {
- updateBaseAddrFile(path, baseAddr);
- }
-#endif
-
+ auto convert = [&appPaths, enableR2R, isAppNI](const std::string& path, const char* name) {
+ if (!crossgen(path, appPaths.c_str(), enableR2R, isAppNI)) {
waitInterval();
}
};
std::string tacDir = concatPath(binDir, TAC_SYMLINK_SUB_DIR);
std::string paths[] = {binDir, libDir, tacDir};
- createNiUnderDirs(paths, 3, enableR2R, false, true);
+ createNiUnderDirs(paths, 3, enableR2R, true);
return NI_ERROR_NONE;
}
std::string originPath = bf::read_symlink(dllPath).string();
std::string originNiPath = originPath.substr(0, originPath.rfind(".dll")) + ".ni.dll";
if (!bf::exists(originNiPath)) {
- if(createNiDll(originPath, false, false) != NI_ERROR_NONE) {
+ if(createNiDll(originPath, false) != NI_ERROR_NONE) {
fprintf(stderr, "Failed to create NI file [%s]\n", originPath.c_str());
return NI_ERROR_UNKNOWN;
}
}
return NI_ERROR_NONE;
} else {
- return crossgen(dllPath, paths, enableR2R, 0, true);
+ return crossgen(dllPath, paths, enableR2R, true);
}
}