}
}
-static std::string getNiFileName(const std::string& dllPath)
+static void updateNiFileInfo(const std::string& dllPath, const std::string& niPath)
+{
+ char* label = NULL;
+
+ // change smack label
+ if (smack_getlabel(dllPath.c_str(), &label, SMACK_LABEL_ACCESS) == 0) {
+ if (smack_setlabel(niPath.c_str(), label, SMACK_LABEL_ACCESS) < 0) {
+ fprintf(stderr, "Fail to set smack label\n");
+ }
+ free(label);
+ }
+
+ // change owner and groups for generated ni file.
+ struct stat info;
+ if (!stat(dllPath.c_str(), &info)) {
+ if (chown(niPath.c_str(), info.st_uid, info.st_gid) == -1)
+ fprintf(stderr, "Failed to change owner and group name\n");
+ }
+}
+
+static std::string getNiFilePath(const std::string& dllPath)
{
size_t index = dllPath.find_last_of(".");
if (index == std::string::npos) {
return niPath;
}
+static std::string getAppNIPath(const std::string& niPath)
+{
+ size_t index = niPath.find_last_of("/");
+ if (index == std::string::npos) {
+ fprintf(stderr, "dllPath doesnot contains path info\n");
+ return "";
+ }
+
+ std::string prevPath = niPath.substr(0, index);
+ std::string fileName = niPath.substr(index, niPath.length());
+ std::string niDirPath = prevPath + APP_NI_SUB_DIR;
+
+ if (!isFileExist(niDirPath)) {
+ if (mkdir(niDirPath.c_str(), 0755) == 0) {
+ updateNiFileInfo(prevPath, niDirPath);
+ } else {
+ fprintf(stderr, "Fail to create app ni directory (%s)\n", niDirPath.c_str());
+ }
+ }
+
+ return niDirPath + fileName;
+}
+
static bool niExist(const std::string& path)
{
- std::string f = getNiFileName(path);
+ std::string f = getNiFilePath(path);
if (f.empty()) {
return false;
}
return false;
}
-static void updateNiFileInfo(const std::string& dllPath, const std::string& niPath)
-{
- char* label = NULL;
-
- // change smack label
- if (smack_getlabel(dllPath.c_str(), &label, SMACK_LABEL_ACCESS) == 0) {
- if (smack_setlabel(niPath.c_str(), label, SMACK_LABEL_ACCESS) < 0) {
- fprintf(stderr, "Fail to set smack label\n");
- }
- free(label);
- }
-
- // change owner and groups for generated ni file.
- struct stat info;
- if (!stat(dllPath.c_str(), &info)) {
- if (chown(niPath.c_str(), info.st_uid, info.st_gid) == -1)
- fprintf(stderr, "Failed to change owner and group name\n");
- }
-}
-
-static ni_error_e crossgen(const std::string& dllPath, const std::string& appPath, bool enableR2R)
+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());
}
std::string absDllPath = absolutePath(dllPath);
- std::string absNiPath = getNiFileName(dllPath);
+ std::string absNiPath = getNiFilePath(dllPath);
if (absNiPath.empty()) {
fprintf(stderr, "Fail to get ni file name\n");
return NI_ERROR_UNKNOWN;
}
+ if (isAppNI) {
+ absNiPath = getAppNIPath(absNiPath);
+ }
+
pid_t pid = fork();
if (pid == -1)
return NI_ERROR_UNKNOWN;
return crossgen(dllPath, std::string(), enableR2R);
}
-void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R)
+void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R, bool isAppNI)
{
createCoreLibNI(enableR2R);
if (appPaths.back() == ':')
appPaths.pop_back();
- auto convert = [&appPaths, enableR2R](const std::string& path, const char* name) {
- if (!crossgen(path, appPaths.c_str(), enableR2R)) {
+ auto convert = [&appPaths, enableR2R, isAppNI](const std::string& path, const char* name) {
+ if (!crossgen(path, appPaths.c_str(), enableR2R, isAppNI)) {
waitInterval();
}
};
std::string libDir = concatPath(pkgRoot, "lib");
std::string paths[] = {binDir, libDir};
- createNiUnderDirs(paths, 2, enableR2R);
+ createNiUnderDirs(paths, 2, enableR2R, true);
return NI_ERROR_NONE;
}
std::string libDir = concatPath(pkgRoot, "lib");
std::string paths = binDir + ":" + libDir;
- return crossgen(dllPath, paths, enableR2R);
+ return crossgen(dllPath, paths, enableR2R, true);
}
void removeNiPlatform()
removeNiUnderDirs(paths, 2);
+ std::string binNIDir = binDir + APP_NI_SUB_DIR;
+ if (isFileExist(binNIDir)) {
+ if (rmdir(binNIDir.c_str()) != 0) {
+ fprintf(stderr, "Failed to remove app ni dir [%s]\n", binNIDir.c_str());
+ }
+ }
+
+ std::string libNIDir = libDir + APP_NI_SUB_DIR;
+ if (isFileExist(libNIDir)) {
+ if (rmdir(libNIDir.c_str()) != 0) {
+ fprintf(stderr, "Failed to remove app ni dir [%s]\n", libNIDir.c_str());
+ }
+ }
+
return NI_ERROR_NONE;
}
if (ret != PMINFO_R_OK)
return NI_ERROR_UNKNOWN;
- ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, "http://tizen.org/metadata/prefer_dotnet_aot", "true");
+ ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, AOT_METADATA_KEY, AOT_METADATA_VALUE);
if (ret != PMINFO_R_OK) {
pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
return NI_ERROR_UNKNOWN;