Verify that the assembly is in the TPA list.
[platform/core/dotnet/launcher.git] / NativeLauncher / tool / ni_common.cc
index 5c29aa9..69c2dcf 100644 (file)
@@ -392,11 +392,11 @@ ni_error_e initNICommon(NiCommonOption* option)
        }
 
        if (initializePluginManager("normal")) {
-               fprintf(stderr, "Fail to initialize plugin manager\n");
+               fprintf(stderr, "Fail to initialize PluginManager\n");
                return NI_ERROR_UNKNOWN;
        }
        if (initializePathManager(option->runtimeDir, option->tizenFXDir, option->extraDirs)) {
-               fprintf(stderr, "Fail to initialize path manager\n");
+               fprintf(stderr, "Fail to initialize PathManager\n");
                return NI_ERROR_UNKNOWN;
        }
 
@@ -453,7 +453,24 @@ void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R,
        if (appPaths.back() == ':')
                appPaths.pop_back();
 
-       auto convert = [&appPaths, enableR2R, isAppNI](const std::string& path, const char* name) {
+       std::vector<std::string> tpaAssemblies;
+       splitPath(__tpa, tpaAssemblies);
+
+       auto convert = [&appPaths, enableR2R, isAppNI, tpaAssemblies](const std::string& path, const char* name) {
+               if (isAppNI) {
+                       std::string assembly = path.substr(path.rfind('/') + 1);
+                       bool isExist = false;
+                       for (auto& tpa : tpaAssemblies) {
+                               if (!strcmp(replaceAll(tpa, ".ni.dll", ".dll").c_str(), assembly.c_str())) {
+                                       isExist = true;
+                                       break;
+                               }
+                       }
+                       if (isExist) {
+                               fprintf(stderr, "%s present in the TPA list skips generation of NI file.\n", path.c_str());
+                               return;
+                       }
+               }
                if (!crossgen(path, appPaths.c_str(), enableR2R, isAppNI)) {
                        waitInterval();
                }
@@ -462,6 +479,8 @@ void createNiUnderDirs(const std::string rootPaths[], int count, bool enableR2R,
        for (int i = 0; i < count; i++) {
                scanFilesInDir(rootPaths[i], convert, 1);
        }
+
+       tpaAssemblies.clear();
 }
 
 ni_error_e createNiUnderPkgRoot(const std::string& pkgId, bool enableR2R)
@@ -514,7 +533,23 @@ ni_error_e createNiDllUnderPkgRoot(const std::string& pkgId, const std::string&
                }
                return NI_ERROR_NONE;
        } else {
-               return crossgen(dllPath, paths, enableR2R, true);
+               std::string assembly = dllPath.substr(dllPath.rfind('/') + 1);
+               std::vector<std::string> tpaAssemblies;
+               splitPath(__tpa, tpaAssemblies);
+               bool isExist = false;
+               for (auto& tpa : tpaAssemblies) {
+                       if (!strcmp(replaceAll(tpa, ".ni.dll", ".dll").c_str(), assembly.c_str())) {
+                               isExist = true;
+                               break;
+                       }
+               }
+               tpaAssemblies.clear();
+               if (isExist) {
+                       fprintf(stderr, "%s present in the TPA list skips generation of NI file.\n", dllPath.c_str());
+                       return NI_ERROR_NONE;
+               } else {
+                       return crossgen(dllPath, paths, enableR2R, true);
+               }
        }
 }