return false;
}
+static int appAotCb(pkgmgrinfo_appinfo_h handle, void *userData)
+{
+ char *pkgId = NULL;
+ int ret = 0;
+
+ ret = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgId);
+ if (ret != PMINFO_R_OK) {
+ fprintf(stderr, "Failed to get pkgid\n");
+ return -1;
+ }
+
+ if (removeNiUnderPkgRoot(pkgId) != 0) {
+ fprintf(stderr, "Failed to remove previous dlls from [%s]\n", pkgId);
+ return -1;
+ }
+
+ if (createNiUnderPkgRoot(pkgId) != 0) {
+ fprintf(stderr, "Failed to get root path from [%s]\n", pkgId);
+ return -1;
+ } else {
+ fprintf(stderr, "Complete make application to native image\n");
+ }
+
+ return 0;
+}
+
static void createCoreLibNI()
{
std::string coreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll");
return 0;
}
+
+void removeNiUnderDirs(const std::string rootPaths[], int count)
+{
+ auto convert = [](const std::string& path, std::string name) {
+ std::string ni;
+ if (isNativeImage(path)) {
+ if (remove(path.c_str())) {
+ fprintf(stderr, "Failed to remove %s\n", path.c_str());
+ }
+ }
+ };
+
+ for (int i = 0; i < count; i++)
+ scanFilesInDir(rootPaths[i].c_str(), convert, -1);
+}
+
+int removeNiUnderPkgRoot(const std::string& pkgName)
+{
+ std::string pkgRoot;
+ if (getRootPath(pkgName.c_str(), pkgRoot) < 0)
+ return -1;
+
+ std::string binDir = concatPath(pkgRoot, "bin");
+ std::string libDir = concatPath(pkgRoot, "lib");
+ std::string paths[] = {binDir, libDir};
+
+ removeNiUnderDirs(paths, 2);
+
+ return 0;
+}
+
+int regenerateAppNI()
+{
+ int ret = 0;
+ pkgmgrinfo_appinfo_metadata_filter_h handle;
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_create(&handle);
+ if (ret != PMINFO_R_OK)
+ return -1;
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_add(handle, "http://tizen.org/metadata/prefer_dotnet_aot", "true");
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
+ return -1;
+ }
+
+ ret = pkgmgrinfo_appinfo_metadata_filter_foreach(handle, appAotCb, NULL);
+ if (ret != PMINFO_R_OK) {
+ fprintf(stderr, "Failed pkgmgrinfo_appinfo_metadata_filter_foreach\n");
+ pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
+ return -1;
+ }
+
+ fprintf(stderr, "Success pkgmgrinfo_appinfo_metadata_filter_foreach\n");
+
+ pkgmgrinfo_appinfo_metadata_filter_destroy(handle);
+ return 0;
+}
+