// 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)) {
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)) {