From d774d554c4c15b963215212b26a9ee5df3d705e8 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 4 Dec 2017 10:06:41 +0200 Subject: [PATCH] Recognize and use the common sysroot in newer Android NDKs --- source/androidcompiler.cpp | 7 +++++++ source/androidtools.cpp | 12 +++++++++++- source/androidtools.h | 2 ++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/source/androidcompiler.cpp b/source/androidcompiler.cpp index e45715e..cdd98af 100644 --- a/source/androidcompiler.cpp +++ b/source/androidcompiler.cpp @@ -25,6 +25,13 @@ AndroidCompiler::AndroidCompiler(Builder &b, const Architecture &a, const string if(ndk.get_platform_sysroot().empty()) problems.push_back("Android platform not found"); + else if(!ndk.get_common_sysroot().empty()) + { + build_info.sysroot = ndk.get_common_sysroot(); + /* The common sysroot has asm headers in arch directories and the + compiler doesn't pick them up automatically */ + build_info.incpath.push_back(ndk.get_common_sysroot()/"usr/include"/architecture->get_cross_prefix()); + } else build_info.sysroot = ndk.get_platform_sysroot(); diff --git a/source/androidtools.cpp b/source/androidtools.cpp index 22a893e..1512673 100644 --- a/source/androidtools.cpp +++ b/source/androidtools.cpp @@ -114,6 +114,16 @@ AndroidNdk::AndroidNdk(Builder &b, const Architecture &a): AndroidDevKit(b, "NDK"), architecture(a) { + if(!root.empty()) + { + FS::Path csr = root/"sysroot"; + if(FS::exists(csr)) + { + common_sysroot = csr; + builder.get_logger().log("tools", format("Android NDK common sysroot is %s", common_sysroot)); + } + } + find_toolchain_dir(); } @@ -196,7 +206,7 @@ void AndroidNdk::init_api_level(unsigned api) } platform_sysroot = platform_archs_dir/("arch-"+use_arch); - builder.get_logger().log("tools", format("Android NDK sysroot is %s", platform_sysroot.str())); + builder.get_logger().log("tools", format("Android NDK platform sysroot is %s", platform_sysroot)); } diff --git a/source/androidtools.h b/source/androidtools.h index 16f157d..c040794 100644 --- a/source/androidtools.h +++ b/source/androidtools.h @@ -50,6 +50,7 @@ class AndroidNdk: public AndroidDevKit private: const Architecture &architecture; Msp::FS::Path bin_dir; + Msp::FS::Path common_sysroot; Msp::FS::Path platform_sysroot; public: @@ -61,6 +62,7 @@ private: public: const Msp::FS::Path &get_bin_dir() const { return bin_dir; } + const Msp::FS::Path &get_common_sysroot() const { return common_sysroot; } const Msp::FS::Path &get_platform_sysroot() const { return platform_sysroot; } }; -- 2.43.0