From 8a89c356d766ad80392bdfb8364d7ee82f203c1a Mon Sep 17 00:00:00 2001 From: "j-h.choi" Date: Wed, 6 Jan 2021 09:51:56 +0900 Subject: [PATCH] Add '--ni-ro-pkg' option to dotnettool Change-Id: I0eea9ca9ef583374d9c8195360a6add733c7581d --- NativeLauncher/tool/dotnettool.cc | 38 ++++++++++++++++++++++++++++++++------ NativeLauncher/tool/ni_common.cc | 6 +++--- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/NativeLauncher/tool/dotnettool.cc b/NativeLauncher/tool/dotnettool.cc index 83f0b6a..2314a8f 100644 --- a/NativeLauncher/tool/dotnettool.cc +++ b/NativeLauncher/tool/dotnettool.cc @@ -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") { diff --git a/NativeLauncher/tool/ni_common.cc b/NativeLauncher/tool/ni_common.cc index 1a8f894..c2d9c54 100644 --- a/NativeLauncher/tool/ni_common.cc +++ b/NativeLauncher/tool/ni_common.cc @@ -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 { -- 2.7.4