* limitations under the License.
*/
-#include "common.h"
+#include "ni_common.h"
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
-std::vector<const char*> getCmdArgs(char** begin, char** end)
+std::vector<std::string> getCmdArgs(char** begin, char** end)
{
- std::vector<const char*> list;
+ std::vector<std::string> list;
for (char** itr = begin+1; itr != end; itr++) {
if (strncmp(*itr, "--", 2) != 0)
list.push_back(*itr);
{
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"
+ " --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"
+ " --r2r - Use ready-to-run option (default: FNV)\n"
+ " (This option should be used with other options)\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"
- "%s --system\n"
- "Create native image for dll\n"
- "%s --dll /usr/bin/Tizen.Runtime.dll\n"
- "Create native image under the package's bin and lib directory\n"
- "%s --pkg org.tizen.FormsGallery\n\n";
- printf(helpDesc, argv0, argv0, argv0, argv0);
+ "1. Create native image for dlls and exes under platform directories\n"
+ " # %s --system\n"
+ "2. Create native image for dll\n"
+ " # %s --dll /usr/bin/Tizen.Runtime.dll\n"
+ "3. Create native image under the package's bin and lib directory\n"
+ " # %s --pkg org.tizen.FormsGallery\n"
+ "4. Regenerate native images for all installed .net packages with ready-to-run option\n"
+ " # %s --r2r --regen-all-app\n\n";
+ printf(helpDesc, argv0, argv0, argv0, argv0, argv0);
}
int main(int argc, char* argv[])
{
bool pkgMode = false;
bool dllMode = false;
+ bool dirMode = false;
+ bool rmPkgMode = false;
+ bool enableR2R = false;
+ bool pkgDllMode = false;
+
+ NiCommonOption option = {std::string(), std::string(), std::string()};
+ if (initNICommon(&option) < 0) {
+ fprintf(stderr, "Fail to initialize NI Common\n");
+ return -1;
+ }
+
+ if (cmdOptionExists(argv, argv+argc, "--r2r")) {
+ enableR2R = true;
+ }
if (cmdOptionExists(argv, argv+argc, "--help")) {
help(argv[0]);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--system")) {
- createNiPlatform();
+ createNiPlatform(enableR2R);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--dll")) {
dllMode = true;
} else if (cmdOptionExists(argv, argv+argc, "--pkg")) {
pkgMode = true;
+ } else if (cmdOptionExists(argv, argv+argc, "--dir")) {
+ dirMode = true;
+ } else if (cmdOptionExists(argv, argv+argc, "--reset-system")) {
+ removeNiPlatform();
+ return 0;
+ } else if (cmdOptionExists(argv, argv+argc, "--reset-pkg")) {
+ rmPkgMode = true;
+ } else if (cmdOptionExists(argv, argv+argc, "--regen-all-app")) {
+ regenerateAppNI(enableR2R);
+ return 0;
+ } else if (cmdOptionExists(argv, argv+argc, "--pkg-dll")) {
+ pkgDllMode = true;
} else {
help(argv[0]);
- return 1;
+ return 0;
}
- std::vector<const char*> args = getCmdArgs(argv, argv+argc);
+ std::vector<std::string> args = getCmdArgs(argv, argv+argc);
if (args.size() < 1) {
if (pkgMode)
}
if (pkgMode) {
- for (const char* pkg : args) {
- if (createNiUnderPkgRoot(pkg) != 0) {
- fprintf(stderr, "Failed to get root path from [%s]\n", pkg);
- return 1;
+ for (const std::string pkg : args) {
+ if (createNiUnderPkgRoot(pkg, enableR2R) != 0) {
+ fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
+ return -1;
+ }
+ }
+ } else if (pkgDllMode) {
+ if (createNiDllUnderPkgRoot(args[0], args[1], enableR2R) != 0) {
+ fprintf(stderr, "Failed to get root path from [%s]\n", args[0].c_str());
+ return -1;
+ }
+ } else if (rmPkgMode) {
+ for (const std::string pkg : args) {
+ if (removeNiUnderPkgRoot(pkg) != 0) {
+ fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
+ return -1;
}
}
} else if (dllMode) {
- for (const char* dll : args)
- createNiSelect(dll);
- } else {
- createNiUnderDirs(args.data(), args.size());
+ for (const std::string dll : args) {
+ if (createNiDll(dll, enableR2R) != 0) {
+ fprintf(stderr, "Failed to generate NI file [%s]\n", dll.c_str());
+ }
+ }
+ } else if (dirMode) {
+ createNiUnderDirs(args.data(), args.size(), enableR2R);
}
return 0;