]> git.tdb.fi Git - builder.git/commitdiff
Make AndroidCompiler more robust about detecting the cxx-stl location
authorMikko Rasa <tdb@tdb.fi>
Fri, 1 Dec 2017 13:27:47 +0000 (15:27 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 1 Dec 2017 13:27:47 +0000 (15:27 +0200)
On recent NDK versions the toolchain reports its version as 4.9.x but the
cxx-stl directory is still 4.9.

source/androidcompiler.cpp

index 53f4de1947b11223138d38930be8180d506cc28f..3616cf450686ec5c1c10ad74592883d33f2ccb00 100644 (file)
@@ -41,7 +41,23 @@ void AndroidCompiler::do_prepare()
                catch(const runtime_error &)
                { }
 
-               FS::Path libstdcxx_path = ndk.get_root_dir()/"sources"/"cxx-stl"/"gnu-libstdc++"/version;
+               FS::Path libstdcxx_dir = ndk.get_root_dir()/"sources"/"cxx-stl"/"gnu-libstdc++";
+               FS::Path libstdcxx_path;
+               while(1)
+               {
+                       libstdcxx_path = libstdcxx_dir/version;
+                       if(FS::exists(libstdcxx_path))
+                               break;
+
+                       string::size_type dot = version.rfind('.');
+                       if(dot==string::npos)
+                       {
+                               problems.push_back("C++ standard library not found");
+                               return;
+                       }
+
+                       version = version.substr(0, dot);
+               }
 
                FS::Path public_dir = libstdcxx_path/"include";
                system_path.push_back(public_dir);