X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fandroidcompiler.cpp;h=e45715e5a7313068ff66663406473f1e52608565;hb=f41742cb2b21241634c123561b71ee1667cb1ff4;hp=490c198196c9764af402a91235b782d258eb12af;hpb=a4f02f02d4682c7f504e46ff2ce8f93035fd36dd;p=builder.git diff --git a/source/androidcompiler.cpp b/source/androidcompiler.cpp index 490c198..e45715e 100644 --- a/source/androidcompiler.cpp +++ b/source/androidcompiler.cpp @@ -1,19 +1,33 @@ #include #include +#include #include +#include #include "androidcompiler.h" #include "androidtools.h" #include "builder.h" +#include "externaltask.h" +#include "filetarget.h" using namespace std; using namespace Msp; AndroidCompiler::AndroidCompiler(Builder &b, const Architecture &a, const string &t, const AndroidNdk &n): - GnuCompiler(b, a, t, n.get_platform_sysroot()), + GnuCompiler(b, a, t), ndk(n) { - set_command((ndk.get_bin_dir()/command).str()); - build_info.incpath.insert(build_info.incpath.end(), system_path.begin(), system_path.end()); + if(ndk.get_root_dir().empty()) + problems.push_back("Android NDK not found"); + else if(ndk.get_bin_dir().empty()) + problems.push_back("Android NDK toolchain not found"); + else + set_command((ndk.get_bin_dir()/command).str()); + + if(ndk.get_platform_sysroot().empty()) + problems.push_back("Android platform not found"); + else + build_info.sysroot = ndk.get_platform_sysroot(); + if(tag=="CXX") build_info.libs.push_back("gnustl_static"); } @@ -23,7 +37,37 @@ void AndroidCompiler::do_prepare() GnuCompiler::do_prepare(); if(executable && tag=="CXX") { - FS::Path libstdcxx_path = ndk.get_root_dir()/"sources"/"cxx-stl"/"gnu-libstdc++"/version; + ExternalTask::Arguments argv; + argv.push_back(executable->get_path().str()); + argv.push_back("-dumpversion"); + + builder.get_logger().log("auxcommands", format("Running %s", join(argv.begin(), argv.end()))); + string version; + try + { + version = strip(ExternalTask::run_and_capture_output(argv)); + builder.get_logger().log("tools", format("%s version is %s", FS::basename(executable->get_path()), version)); + } + catch(const runtime_error &) + { } + + 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);