]> git.tdb.fi Git - builder.git/blob - source/androidcxxcompiler.cpp
Better incpath logic in AndroidCxxCompiler
[builder.git] / source / androidcxxcompiler.cpp
1 #include <msp/fs/dir.h>
2 #include <msp/strings/format.h>
3 #include "androidcxxcompiler.h"
4 #include "androidtools.h"
5 #include "architecture.h"
6 #include "builder.h"
7
8 using namespace std;
9 using namespace Msp;
10
11 AndroidCxxCompiler::AndroidCxxCompiler(Builder &b, const Architecture &a, const AndroidNdk &n):
12         GnuCxxCompiler(b, a, n.get_platform_sysroot()),
13         ndk(n)
14 {
15         set_command((ndk.get_bin_dir()/command).str());
16         build_info.incpath.insert(build_info.incpath.end(), system_path.begin(), system_path.end());
17         build_info.libs.push_back("gnustl_static");
18 }
19
20 void AndroidCxxCompiler::do_prepare()
21 {
22         GnuCxxCompiler::do_prepare();
23         if(executable)
24         {
25                 FS::Path libstdcxx_path = ndk.get_root_dir()/"sources"/"cxx-stl"/"gnu-libstdc++"/version;
26
27                 FS::Path public_dir = libstdcxx_path/"include";
28                 system_path.push_back(public_dir);
29                 build_info.incpath.push_back(public_dir);
30
31                 FS::Path arch_path = libstdcxx_path/"libs";
32                 builder.get_logger().log("files", format("Traversing %s", arch_path.str()));
33                 string arch_dir = architecture->best_match(list_files(arch_path));
34                 if(!arch_dir.empty())
35                 {
36                         build_info.incpath.push_back(libstdcxx_path/"libs"/arch_dir/"include");
37                         build_info.libpath.push_back(libstdcxx_path/"libs"/arch_dir);
38                 }
39         }
40 }