]> git.tdb.fi Git - builder.git/commitdiff
Better incpath logic in AndroidCxxCompiler
authorMikko Rasa <tdb@tdb.fi>
Fri, 10 Oct 2014 10:07:56 +0000 (13:07 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 10 Oct 2014 13:00:12 +0000 (16:00 +0300)
Don't expose the private directory through system_path, since programs
are not suppose to #include those files directly.  Also use architecture
to determine which subdir to pick.

source/androidcxxcompiler.cpp

index bdcbad92b79eced428660b90073abfe514cfc88b..41f06ed4fe823f51ed9242c24487a05f2eeaf3d0 100644 (file)
@@ -1,6 +1,9 @@
+#include <msp/fs/dir.h>
+#include <msp/strings/format.h>
 #include "androidcxxcompiler.h"
 #include "androidtools.h"
 #include "architecture.h"
+#include "builder.h"
 
 using namespace std;
 using namespace Msp;
@@ -21,20 +24,17 @@ void AndroidCxxCompiler::do_prepare()
        {
                FS::Path libstdcxx_path = ndk.get_root_dir()/"sources"/"cxx-stl"/"gnu-libstdc++"/version;
 
-               /* TODO Match against architecture.  Armeabi-v7a is problematic.
-               Architecture currently has no provisions for ABI, and the gcc -march
-               flag for ARMv7-A contains a dash. */
-               string subdir;
-               if(architecture->get_type()=="pc")
-                       subdir = "x86";
-               else if(architecture->get_type()=="arm")
-                       subdir = "armeabi-v7a";
+               FS::Path public_dir = libstdcxx_path/"include";
+               system_path.push_back(public_dir);
+               build_info.incpath.push_back(public_dir);
 
-               SearchPath incpath;
-               incpath.push_back(libstdcxx_path/"include");
-               incpath.push_back(libstdcxx_path/"libs"/subdir/"include");
-               system_path.insert(system_path.end(), incpath.begin(), incpath.end());
-               build_info.incpath.insert(build_info.incpath.end(), incpath.begin(), incpath.end());
-               build_info.libpath.push_back(libstdcxx_path/"libs"/subdir);
+               FS::Path arch_path = libstdcxx_path/"libs";
+               builder.get_logger().log("files", format("Traversing %s", arch_path.str()));
+               string arch_dir = architecture->best_match(list_files(arch_path));
+               if(!arch_dir.empty())
+               {
+                       build_info.incpath.push_back(libstdcxx_path/"libs"/arch_dir/"include");
+                       build_info.libpath.push_back(libstdcxx_path/"libs"/arch_dir);
+               }
        }
 }