From fc5aef242abdc6c2942ae94a8f250f928192009b Mon Sep 17 00:00:00 2001 From: Cho Woong Suk Date: Thu, 26 Apr 2018 14:46:13 +0900 Subject: [PATCH] add nitool option to regenerate all app ni files Change-Id: I0fe1ec13358f790aa4dfac35c7760c9dbd38c2b7 --- NativeLauncher/installer-plugin/common.cc | 50 +++++++++++++++++++++++++++++++ NativeLauncher/installer-plugin/common.h | 1 + NativeLauncher/installer-plugin/nitool.cc | 18 ++++++----- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/NativeLauncher/installer-plugin/common.cc b/NativeLauncher/installer-plugin/common.cc index eedb0bc..3ab426c 100644 --- a/NativeLauncher/installer-plugin/common.cc +++ b/NativeLauncher/installer-plugin/common.cc @@ -233,6 +233,56 @@ static bool niExist(const std::string& path, std::string& ni) 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) { + _DBG("Failed to get pkgid"); + return -1; + } + + // When you create native image with pkgid, ni file is generated even though already ni file exist. + if (createNiUnderPkgRoot(pkgId) != 0) { + _ERR("Failed to get root path from [%s]", pkgId); + return -1; + } else { + _DBG("Complete make application to native image"); + } + + 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) { + _DBG("Failed pkgmgrinfo_appinfo_metadata_filter_foreach"); + pkgmgrinfo_appinfo_metadata_filter_destroy(handle); + return -1; + } + + _DBG("Success pkgmgrinfo_appinfo_metadata_filter_foreach"); + + pkgmgrinfo_appinfo_metadata_filter_destroy(handle); + return 0; +} + static void createCoreLibNI() { std::string coreLib = concatPath(__RUNTIME_DIR, "System.Private.CoreLib.dll"); diff --git a/NativeLauncher/installer-plugin/common.h b/NativeLauncher/installer-plugin/common.h index 8914e4b..26fe0ee 100644 --- a/NativeLauncher/installer-plugin/common.h +++ b/NativeLauncher/installer-plugin/common.h @@ -20,6 +20,7 @@ #include typedef std::function 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); diff --git a/NativeLauncher/installer-plugin/nitool.cc b/NativeLauncher/installer-plugin/nitool.cc index 9cd390c..989fb42 100644 --- a/NativeLauncher/installer-plugin/nitool.cc +++ b/NativeLauncher/installer-plugin/nitool.cc @@ -41,13 +41,14 @@ static void help(const char *argv0) { const char* helpDesc = "Usage: %s [args] \n" - " --help - Display this screen\n" - " --system - Create NI under System DLLs\n" - " --dll - Create NI for DLL\n" - " --pkg - Create NI for package\n" - " --dir - Create NI for directory\n" - " --reset-system - Remove System NI files\n" - " --reset-pkg - Remove App NI files\n" + " --help - Display this screen\n" + " --system - Create NI under System DLLs\n" + " --dll - Create NI for DLL\n" + " --pkg - Create NI for package\n" + " --dir - Create NI for directory\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" "\n" "Example:\n" "Create native image for dlls and exes under platform directories\n" @@ -83,6 +84,9 @@ int main(int argc, char* argv[]) return 0; } else if (cmdOptionExists(argv, argv+argc, "--reset-pkg")) { rmPkgMode = true; + } else if (cmdOptionExists(argv, argv+argc, "--regen-all-app")) { + regenerateAppNI(); + return 0; } else { help(argv[0]); return 1; -- 2.7.4