Merge branch 'tizen' of https://github.sec.samsung.net/j-h-choi/dotnet-launcher into...
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / nitool.cc
index 16b6693..9647369 100644 (file)
@@ -70,7 +70,7 @@ int main(int argc, char* argv[])
        bool pkgDllMode = false;
 
        NiCommonOption option = {std::string(), std::string(), std::string()};
-       if (initNICommon(&option) < 0) {
+       if (initNICommon(&option) != NI_ERROR_NONE) {
                fprintf(stderr, "Fail to initialize NI Common\n");
                return -1;
        }
@@ -119,26 +119,47 @@ int main(int argc, char* argv[])
 
        if (pkgMode) {
                for (const std::string pkg : args) {
-                       if (createNiUnderPkgRoot(pkg, enableR2R) != 0) {
+                       // if there is AOTed dlls under package root, that is skiped.
+                       int ret = createNiUnderPkgRoot(pkg, enableR2R);
+                       if (ret == NI_ERROR_INVALID_PACKAGE) {
                                fprintf(stderr, "Failed to get root path from [%s]\n", pkg.c_str());
                                return -1;
+                       } else if (ret != NI_ERROR_NONE) {
+                               fprintf(stderr, "Failed to generate NI file [%s]\n", args[1].c_str());
+                               return -1;
                        }
                }
        } else if (pkgDllMode) {
-               if (createNiDllUnderPkgRoot(args[0], args[1], enableR2R) != 0) {
+               int ret = createNiDllUnderPkgRoot(args[0], args[1], enableR2R);
+               if (ret == NI_ERROR_INVALID_PACKAGE) {
                        fprintf(stderr, "Failed to get root path from [%s]\n", args[0].c_str());
                        return -1;
+               } else if (ret == NI_ERROR_ALREADY_EXIST) {
+                       // skip for already exist case
+                       return -1;
+               } else if (ret != NI_ERROR_NONE) {
+                       fprintf(stderr, "Failed to generate NI file [%s]\n", args[1].c_str());
+                       return -1;
                }
        } else if (rmPkgMode) {
                for (const std::string pkg : args) {
-                       if (removeNiUnderPkgRoot(pkg) != 0) {
+                       int ret = removeNiUnderPkgRoot(pkg);
+                       if (ret == NI_ERROR_INVALID_PACKAGE) {
                                fprintf(stderr, "Failed to get root path from [%s]\n", 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());
+                               return -1;
                        }
                }
        } else if (dllMode) {
+               // donot return error code for generation failure.
+               // we have to run crossgen for all input dlls.
                for (const std::string dll : args) {
-                       if (createNiDll(dll, enableR2R) != 0) {
+                       int ret = createNiDll(dll, enableR2R);
+                       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());
                        }
                }