add nitool option to regenerate all app ni files 75/177175/1
authorCho Woong Suk <ws77.cho@samsung.com>
Thu, 26 Apr 2018 05:46:13 +0000 (14:46 +0900)
committerCho Woong Suk <ws77.cho@samsung.com>
Thu, 26 Apr 2018 05:46:13 +0000 (14:46 +0900)
Change-Id: I0fe1ec13358f790aa4dfac35c7760c9dbd38c2b7

NativeLauncher/installer-plugin/common.cc
NativeLauncher/installer-plugin/common.h
NativeLauncher/installer-plugin/nitool.cc

index eedb0bc..3ab426c 100644 (file)
@@ -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");
index 8914e4b..26fe0ee 100644 (file)
@@ -20,6 +20,7 @@
 #include <functional>
 
 typedef std::function<void (const char*)> 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);
index 9cd390c..989fb42 100644 (file)
@@ -41,13 +41,14 @@ static void help(const char *argv0)
 {
        const char* helpDesc =
                "Usage: %s [args] <root paths or pkg name>\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;