From cd27d59419ae2bb5947583b0b3dca8bd06ff2975 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 4 Dec 2017 10:15:24 +0200 Subject: [PATCH] Use $sdk_root/ndk-bundle as default path for Android NDK It's now available for download through the SDK manager, which installs it in this location. --- source/androidtools.cpp | 17 +++++++++++++---- source/androidtools.h | 7 ++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/source/androidtools.cpp b/source/androidtools.cpp index 1512673..eeb6edf 100644 --- a/source/androidtools.cpp +++ b/source/androidtools.cpp @@ -32,12 +32,14 @@ unsigned parse_version(const std::string &version_str) } -AndroidDevKit::AndroidDevKit(Builder &b, const string &type): +AndroidDevKit::AndroidDevKit(Builder &b, const string &type, const FS::Path &default_path): builder(b) { string var = format("ANDROID_%s_ROOT", type); if(const char *value = getenv(var.c_str())) root = value; + else if(!default_path.empty() && FS::exists(default_path)) + root = default_path; else { builder.get_logger().log("problems", format("Android %s not found", type)); @@ -110,8 +112,8 @@ void AndroidSdk::init_api_level(unsigned api) } -AndroidNdk::AndroidNdk(Builder &b, const Architecture &a): - AndroidDevKit(b, "NDK"), +AndroidNdk::AndroidNdk(Builder &b, const Architecture &a, const AndroidSdk &sdk): + AndroidDevKit(b, "NDK", create_default_path(sdk)), architecture(a) { if(!root.empty()) @@ -127,6 +129,13 @@ AndroidNdk::AndroidNdk(Builder &b, const Architecture &a): find_toolchain_dir(); } +FS::Path AndroidNdk::create_default_path(const AndroidSdk &sdk) +{ + if(sdk.get_root_dir().empty()) + return FS::Path(); + return sdk.get_root_dir()/"ndk-bundle"; +} + void AndroidNdk::find_toolchain_dir() { if(root.empty()) @@ -212,7 +221,7 @@ void AndroidNdk::init_api_level(unsigned api) AndroidTools::AndroidTools(Builder &builder, const Architecture &arch): sdk(builder), - ndk(builder, arch) + ndk(builder, arch, sdk) { const set &sdk_api_levels = sdk.get_supported_api_levels(); const set &ndk_api_levels = ndk.get_supported_api_levels(); diff --git a/source/androidtools.h b/source/androidtools.h index c040794..dfa8a11 100644 --- a/source/androidtools.h +++ b/source/androidtools.h @@ -15,7 +15,7 @@ protected: Msp::FS::Path root; std::set supported_api_levels; - AndroidDevKit(Builder &, const std::string &); + AndroidDevKit(Builder &, const std::string &, const Msp::FS::Path & = Msp::FS::Path()); ~AndroidDevKit() { } public: @@ -54,9 +54,10 @@ private: Msp::FS::Path platform_sysroot; public: - AndroidNdk(Builder &, const Architecture &); - + AndroidNdk(Builder &, const Architecture &, const AndroidSdk &); private: + static Msp::FS::Path create_default_path(const AndroidSdk &); + void find_toolchain_dir(); virtual void init_api_level(unsigned); -- 2.45.2