Modify to find high priority RID values according to folder name order
authorj-h.choi <j-h.choi@samsung.com>
Tue, 27 May 2025 02:57:51 +0000 (11:57 +0900)
committer조웅석/MDE Lab(SR)/삼성전자 <ws77.cho@samsung.com>
Wed, 28 May 2025 08:11:51 +0000 (17:11 +0900)
Change-Id: Ib9b7d61b6039d6668099b726f12c13578a61fd05

NativeLauncher/tool/multi_target_resolver.cc

index af9527f213504bf7ca00e017308b63153b0caf98..13800fd688a1fef67d89b69f33c58ebacb471d03 100644 (file)
@@ -152,14 +152,18 @@ int resolvePlatformSpecificFiles(const std::string& rootPath)
 
        // found best matched rid and tfm directory and copy all files to bin directory
        std::vector<std::string> ridFallbackGraph = getRidFallbackGraph();
+       int bestMatch = ridFallbackGraph.size();
        try {
                for (auto& rid : bf::recursive_directory_iterator(runtimesPath)) {
                        std::string ridPath = rid.path().string();
+                       int ridCnt = 0;
                        if (bf::is_directory(ridPath) && strstr(ridPath.c_str(), ARCHITECTURE_IDENTIFIER) != NULL) {
                                for (auto& ridFG : ridFallbackGraph) {
+                                       ridCnt++;
                                        if (!strcmp(getFileName(ridPath).c_str(), ridFG.c_str())) {
                                                std::string nativePath = concatPath(ridPath, "native");
-                                               if (isDirectory(nativePath)) {
+                                               if (isDirectory(nativePath) && bestMatch >= ridCnt) {
+                                                       bestMatch = ridCnt;
                                                        _INFO("Found best matched rid (%s)", ridFG.c_str());
                                                        // copy all files from bin/runtimes/${rid}/native to appBintPath if exist
                                                        if (!moveAllFilesTo(nativePath, appBinPath)) {
@@ -173,7 +177,8 @@ int resolvePlatformSpecificFiles(const std::string& rootPath)
                                                std::vector<std::string> tfmFallbackGraph = getTfmFallbackGraph();
                                                for (auto& tfmFG : tfmFallbackGraph) {
                                                        std::string tfmPath = concatPath(libPath, tfmFG);
-                                                       if (isDirectory(tfmPath)) {
+                                                       if (isDirectory(tfmPath) && bestMatch >= ridCnt) {
+                                                               bestMatch = ridCnt;
                                                                _INFO("Found best matched tfm (%s)", tfmFG .c_str());
                                                                // copy all files from bin/runtimes/${rid}/lib/${tfm} to appBintPath if exist
                                                                if (!moveAllFilesTo(tfmPath, appBinPath)) {