int main(int argc, char* argv[])
{
- DWORD flags = 0;
bool pkgMode = false;
bool dllMode = false;
bool rmPkgMode = false;
return -1;
}
- // Parse optional switches first.
- if (cmdOptionExists(argv, argv+argc, "--r2r")) {
- flags |= NI_FLAGS_ENABLER2R;
- }
- if (cmdOptionExists(argv, argv+argc, "--compatibility")) {
- flags |= NI_FLAGS_COMPATIBILITY;
- }
- if (cmdOptionExists(argv, argv+argc, "--instrument")) {
- flags |= NI_FLAGS_INSTRUMENT;
+ NIOption* opt = getNIOption();
+ if (opt == nullptr) {
+ _SERR("Fail to create option structure.");
+ return -1;
}
+
+ // Parse optional switches first.
if (cmdOptionExists(argv, argv+argc, "--verbose")) {
- flags |= NI_FLAGS_VERBOSE;
+ opt->flags |= NI_FLAGS_VERBOSE;
}
// The following commands are mutually exclusive.
help(argv[0]);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--system")) {
- createNIPlatform(flags);
+ createNIPlatform("", opt->flags);
return 0;
} else if (cmdOptionExists(argv, argv+argc, "--dll")) {
dllMode = true;
} else if (cmdOptionExists(argv, argv+argc, "--reset-pkg")) {
rmPkgMode = true;
} else if (cmdOptionExists(argv, argv+argc, "--regen-all-app")) {
- regenerateAppNI(flags);
+ regenerateAppNI(opt->flags);
return 0;
} else {
help(argv[0]);
if (args.size() < 1) {
if (pkgMode)
- fprintf(stderr, "Package name is missing.\n");
+ _SERR("Package name is missing.");
else if (dllMode)
- fprintf(stderr, "DLL path is missing.\n");
+ _SERR("DLL path is missing.");
help(argv[0]);
return -1;
}
if (pkgMode) {
for (const std::string pkg : args) {
// if there is AOTed dlls under package root, that is skiped.
- int ret = createNIUnderPkgRoot(pkg, flags);
+ int ret = createNIUnderPkgRoot(pkg, opt->flags);
if (ret == NI_ERROR_INVALID_PACKAGE) {
- fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
+ _SERR("Failed to get root path from [%s]", pkg.c_str());
return -1;
} else if (ret != NI_ERROR_NONE) {
- fprintf(stderr, "Failed to generate NI file [%s]\n", pkg.c_str());
+ _SERR("Failed to generate NI file [%s]", pkg.c_str());
return -1;
}
}
for (const std::string pkg : args) {
int ret = removeNIUnderPkgRoot(pkg);
if (ret == NI_ERROR_INVALID_PACKAGE) {
- fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
+ _SERR("Failed to get root path from [%s]", pkg.c_str());
return -1;
} else if (ret != NI_ERROR_NONE) {
- fprintf(stderr, "Failed to remove dlls for given package [%s]\n", pkg.c_str());
+ _SERR("Failed to remove dlls for given package [%s]", pkg.c_str());
return -1;
}
}
// donot return error code for generation failure.
// we have to run crossgen for all input dlls.
for (const std::string dll : args) {
- int ret = createNIDll(dll, flags);
+ int ret = createNIDll(dll, opt->flags);
if (ret == NI_ERROR_ALREADY_EXIST) {
// skip for already exist case
} else if (ret != NI_ERROR_NONE) {
- fprintf(stderr, "Failed to generate NI file [%s]\n", dll.c_str());
+ _SERR("Failed to generate NI file [%s]", dll.c_str());
}
}
}