return false;
}
-static int crossgen(const std::string& dllPath, const std::string& appPath, bool enableR2R, 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());
- return -1;
+ return NI_ERROR_NO_SUCH_FILE;
}
if (!isManagedAssembly(dllPath)) {
fprintf(stderr, "Input file is not a dll file : %s\n", dllPath.c_str());
- return -1;
+ return NI_ERROR_INVALID_PARAMETER;
}
if (niExist(dllPath)) {
fprintf(stderr, "Already ni file is exist for %s\n", dllPath.c_str());
- return -1;
+ return NI_ERROR_ALREADY_EXIST;
}
std::string absDllPath = absolutePath(dllPath);
std::string absNiPath = getNiFilePath(dllPath);
if (absNiPath.empty()) {
fprintf(stderr, "Fail to get ni file name\n");
- return -1;
+ return NI_ERROR_UNKNOWN;
}
if (isAppNI) {
pid_t pid = fork();
if (pid == -1)
- return -1;
+ return NI_ERROR_UNKNOWN;
if (pid > 0) {
int status;
// niEixst() return false for System.Private.Corelib.dll
if (isFileExist(absNiPath)) {
updateNiFileInfo(absDllPath, absNiPath);
- return 0;
+ return NI_ERROR_NONE;
} else {
fprintf(stderr, "Fail to create native image for %s\n", dllPath.c_str());
- return -1;
+ return NI_ERROR_NO_SUCH_FILE;
}
}
} else {
exit(0);
}
- return 0;
+ return NI_ERROR_NONE;
}
-static int getRootPath(std::string pkgId, std::string& rootPath)
+static ni_error_e getRootPath(std::string pkgId, std::string& rootPath)
{
int ret = 0;
char *path = 0;
if (pkgmgr_installer_info_get_target_uid(&uid) < 0) {
_ERR("Failed to get UID");
- return -1;
+ return NI_ERROR_UNKNOWN;
}
pkgmgrinfo_pkginfo_h handle;
if (uid == 0) {
ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgId.c_str(), &handle);
if (ret != PMINFO_R_OK)
- return -1;
+ return NI_ERROR_UNKNOWN;
} else {
ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgId.c_str(), uid, &handle);
if (ret != PMINFO_R_OK)
- return -1;
+ return NI_ERROR_UNKNOWN;
}
ret = pkgmgrinfo_pkginfo_get_root_path(handle, &path);
if (ret != PMINFO_R_OK) {
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return -1;
+ return NI_ERROR_UNKNOWN;
}
rootPath = path;
pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
- return 0;
+ return NI_ERROR_NONE;
}
-
+// callback function of "pkgmgrinfo_appinfo_metadata_filter_foreach"
static int appAotCb(pkgmgrinfo_appinfo_h handle, void *userData)
{
char *pkgId = NULL;
}
}
-int initNICommon(NiCommonOption* option)
+ni_error_e initNICommon(NiCommonOption* option)
{
#if defined(__arm__)
// get interval value
if (initializePluginManager("normal")) {
fprintf(stderr, "Fail to initialize plugin manager\n");
- return -1;
+ return NI_ERROR_UNKNOWN;
}
if (initializePathManager(option->runtimeDir, option->tizenFXDir, option->extraDirs)) {
fprintf(stderr, "Fail to initialize path manager\n");
- return -1;
+ return NI_ERROR_UNKNOWN;
}
__tpa = getTPA();
- return 0;
+ return NI_ERROR_NONE;
#else
fprintf(stderr, "crossgen supports arm architecture only. skip ni file generation\n");
- return -1;
+ return NI_ERROR_NOT_SUPPORTED;
#endif
}
createNiUnderDirs(platformDirs, 2, enableR2R);
}
-int createNiDll(const std::string& dllPath, bool enableR2R)
+ni_error_e createNiDll(const std::string& dllPath, bool enableR2R)
{
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;
+ }
+
return crossgen(dllPath, std::string(), enableR2R);
}
}
}
-int createNiUnderPkgRoot(const std::string& pkgName, bool enableR2R)
+ni_error_e createNiUnderPkgRoot(const std::string& pkgName, bool enableR2R)
{
std::string pkgRoot;
- if (getRootPath(pkgName, pkgRoot) < 0) {
+ if (getRootPath(pkgName, pkgRoot) != NI_ERROR_NONE) {
fprintf(stderr, "Failed to get root path from [%s]\n", pkgName.c_str());
- return -1;
+ return NI_ERROR_INVALID_PACKAGE;
}
std::string binDir = concatPath(pkgRoot, "bin");
createNiUnderDirs(paths, 2, enableR2R, true);
- return 0;
+ return NI_ERROR_NONE;
}
-int createNiDllUnderPkgRoot(const std::string& pkgName, const std::string& dllPath, bool enableR2R)
+ni_error_e createNiDllUnderPkgRoot(const std::string& pkgName, const std::string& dllPath, bool enableR2R)
{
std::string pkgRoot;
if (getRootPath(pkgName, pkgRoot) < 0) {
fprintf(stderr, "Failed to get root path from [%s]\n", pkgName.c_str());
- return -1;
+ return NI_ERROR_INVALID_PACKAGE;
}
std::string binDir = concatPath(pkgRoot, "bin");
scanFilesInDir(rootPaths[i], convert, -1);
}
-int removeNiUnderPkgRoot(const std::string& pkgName)
+ni_error_e removeNiUnderPkgRoot(const std::string& pkgName)
{
std::string pkgRoot;
if (getRootPath(pkgName, pkgRoot) < 0) {
fprintf(stderr, "Failed to get root path from [%s]\n", pkgName.c_str());
- return -1;
+ return NI_ERROR_INVALID_PACKAGE;
}
std::string binDir = concatPath(pkgRoot, "bin");
}
}
- return 0;
+ return NI_ERROR_NONE;
}
-int regenerateAppNI(bool enableR2R)
+ni_error_e regenerateAppNI(bool enableR2R)
{
int ret = 0;
pkgmgrinfo_appinfo_metadata_filter_h handle;
ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
if (ret != PMINFO_R_OK)
- return -1;
+ return NI_ERROR_UNKNOWN;
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 -1;
+ return NI_ERROR_UNKNOWN;
}
ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, appAotCb, &enableR2R);
if (ret != PMINFO_R_OK) {
fprintf(stderr, "Failed pkgmgrinfo_appinfo_metadata_filter_foreach\n");
pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
- return -1;
+ return NI_ERROR_UNKNOWN;
}
fprintf(stderr, "Success pkgmgrinfo_appinfo_metadata_filter_foreach\n");
pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
- return 0;
+ return NI_ERROR_NONE;
}