From 3af85a03554609af06e8f182f59f97fbcbb469ec Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 10 Oct 2014 13:07:56 +0300 Subject: [PATCH] Better incpath logic in AndroidCxxCompiler 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 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/source/androidcxxcompiler.cpp b/source/androidcxxcompiler.cpp index bdcbad9..41f06ed 100644 --- a/source/androidcxxcompiler.cpp +++ b/source/androidcxxcompiler.cpp @@ -1,6 +1,9 @@ +#include +#include #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); + } } } -- 2.45.2