]> git.tdb.fi Git - builder.git/blobdiff - source/androidtools.cpp
Introduce a helper function in Architecture to pick the best matching name
[builder.git] / source / androidtools.cpp
index c0fe6d1557e5f3b9beb92f510d60e7e9b86eaf28..1042595fd9423802006136791e0ab9cf0587f40a 100644 (file)
@@ -75,14 +75,8 @@ void AndroidNdk::find_toolchain_dir()
 
        const Architecture &native_arch = builder.get_native_arch();
 
-       list<string> tc_archs = list_files(toolchains_dir/use_toolchain/"prebuilt");
-       string use_arch;
-       for(list<string>::const_iterator i=tc_archs.begin(); i!=tc_archs.end(); ++i)
-               if(native_arch.match_name(*i))
-               {
-                       use_arch = *i;
-                       break;
-               }
+       FS::Path tc_archs_dir = toolchains_dir/use_toolchain/"prebuilt";
+       string use_arch = native_arch.best_match(list_files(tc_archs_dir));
 
        if(use_arch.empty())
                throw runtime_error("No matching toolchain found");
@@ -111,14 +105,10 @@ void AndroidNdk::find_platform_dir()
        if(use_platform.empty())
                throw runtime_error("No applicable platforms found");
 
-       list<string> platform_archs = list_files(platforms_dir/use_platform);
-       string use_arch;
-       for(list<string>::const_iterator i=platform_archs.begin(); i!=platform_archs.end(); ++i)
-               if(!i->compare(0, 5, "arch-") && architecture.match_name(i->substr(5)))
-               {
-                       use_arch = *i;
-                       break;
-               }
+       list<string> platform_archs = list_filtered(platforms_dir/use_platform, "^arch-");
+       for(list<string>::iterator i=platform_archs.begin(); i!=platform_archs.end(); ++i)
+               i->erase(0, 5);
+       string use_arch = architecture.best_match(platform_archs);
 
        if(use_arch.empty())
                throw runtime_error("No matching platform found");