Add '--ni-ro-pkg' option to dotnettool
authorj-h.choi <j-h.choi@samsung.com>
Wed, 6 Jan 2021 00:51:56 +0000 (09:51 +0900)
committer조웅석/Common Platform Lab(SR)/Principal Engineer/삼성전자 <ws77.cho@samsung.com>
Thu, 7 Jan 2021 04:38:56 +0000 (13:38 +0900)
Change-Id: I0eea9ca9ef583374d9c8195360a6add733c7581d

NativeLauncher/tool/dotnettool.cc
NativeLauncher/tool/ni_common.cc

index 83f0b6a..2314a8f 100644 (file)
@@ -35,6 +35,7 @@ void DisplayUsage() {
                "       --ni-system               - Create NI under System DLLs\n"
                "       --ni-dll                  - Create NI for DLL\n"
                "       --ni-pkg                  - Create NI for package\n"
+               "       --ni-ro-pkg               - Create NI for read-only package\n"
                "       --ni-dir                  - Create NI for directory\n"
                "       --ni-reset-system         - Remove System NI files\n"
                "       --ni-reset-pkg            - Remove App NI files\n"
@@ -164,11 +165,36 @@ int main(int argc, char* argv[])
                }
                while (it != args.end()) {
                        std::string pkg = std::string(*it);
-                       // if there is AOTed dlls under package root, that is skiped.
-                       int ret = createNIUnderPkgRoot(pkg, flags);
-                       if (ret != NI_ERROR_NONE) {
-                               fprintf(stderr, "Failed to generate NI file [%s]\n", pkg.c_str());
-                               break;
+                       if (isReadOnlyApp(pkg)) {
+                               fprintf(stderr, "Skip to generate app NI. Try to create NI for read-only package [%s]\n# dotnettool --ni-ro-pkg %s\n", pkg.c_str(), pkg.c_str());
+                       } else {
+                               // if there is AOTed dlls under package root, that is skiped.
+                               int ret = createNIUnderPkgRoot(pkg, flags);
+                               if (ret != NI_ERROR_NONE) {
+                                       fprintf(stderr, "Failed to generate app NI [%s]\n", pkg.c_str());
+                                       break;
+                               }
+                       }
+                       it = args.erase(it);
+               }
+       }
+       //sh-3.2# dotnettool --ni-ro-pkg [pkgId] [pkgId] ...
+       else if (cmd == "--ni-ro-pkg") {
+               if (args.size() < 1) {
+                       fprintf(stderr, "Package name is missing\n");
+               }
+               flags |= NI_FLAGS_READONLY_APP;
+               while (it != args.end()) {
+                       std::string pkg = std::string(*it);
+                       if (isReadOnlyApp(pkg)) {
+                               // if there is AOTed dlls under package root, that is skiped.
+                               int ret = createNIUnderPkgRoot(pkg, flags);
+                               if (ret != NI_ERROR_NONE) {
+                                       fprintf(stderr, "Failed to generate read-only app NI [%s]\n", pkg.c_str());
+                                       break;
+                               }
+                       } else {
+                               fprintf(stderr, "Skip to generate app NI. Try to create NI for package [%s]\n# dotnettool --ni-pkg %s\n", pkg.c_str(), pkg.c_str());
                        }
                        it = args.erase(it);
                }
@@ -231,7 +257,7 @@ int main(int argc, char* argv[])
                int ret = regenerateAppNI(flags);
                if (ret != NI_ERROR_NONE) {
                        fprintf(stderr, "Failed to regenerate read-only app NI\n");
-               }               
+               }
        }
        //sh-3.2# dotnettool --tac-regen-all
        else if (cmd == "--tac-regen-all") {
index 1a8f894..c2d9c54 100644 (file)
@@ -432,13 +432,13 @@ static int appAotCb(pkgmgrinfo_appinfo_h handle, void *userData)
        // read-only and readonly flag set
        if (readOnlyApp && (*pFlags & NI_FLAGS_READONLY_APP)) {
                fprintf(stderr, "try to regenerate read-only pkg [%s]\n", pkgId);
-       } 
-       // not rad-only and readonly flag doesnot set
+       }
+       // not read-only and readonly flag does not set
        else if (!readOnlyApp && !(*pFlags & NI_FLAGS_READONLY_APP)) {
                if (removeNIUnderPkgRoot(pkgId) != NI_ERROR_NONE) {
                        fprintf(stderr, "Failed to remove previous dlls from [%s]\n", pkgId);
                        return -1;
-               }                       
+               }
        }
        // skip regeneration
        else {