Skip to content

Commit 13b0afa

Browse files
committed
Use ndk metadata for default android platform
Instead of hardcoding default values per ndk version, it is better to read the ndk metadata to figure out the minimum version supported by the ndk.
1 parent 5dd7a5b commit 13b0afa

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

toolchain/android-toolchain-clang.xml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
<xml>
22

3-
<section unless="HXCPP_ANDROID_PLATFORM" >
4-
<set name="HXCPP_ANDROID_PLATFORM" value="16" />
5-
<set name="HXCPP_ANDROID_PLATFORM" value="19" if="NDKV24+" />
6-
<!-- 64 bit builds fail unless using platform 21 -->
7-
<set name="HXCPP_ANDROID_PLATFORM" value="21" if="NDKV26+||HXCPP_X86_64||HXCPP_ARM64" />
8-
</section>
9-
103
<!-- Set architecture -->
114
<section if="HXCPP_X86">
125
<set name="ARCH" value="-x86" />

tools/hxcpp/Setup.hx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,28 @@ class Setup
523523
if (defines.exists("PLATFORM_NUMBER")) {
524524
Log.warn("The PLATFORM_NUMBER define is deprecated. Please use the HXCPP_ANDROID_PLATFORM define instead.");
525525
defines.set("HXCPP_ANDROID_PLATFORM", Std.string(defines.get("PLATFORM_NUMBER")));
526+
} else {
527+
var platformsJson = root + "/meta/platforms.json";
528+
529+
var minPlatform:Null<Int> = try {
530+
haxe.Json.parse(sys.io.File.getContent(platformsJson)).min;
531+
} catch (e) {
532+
Log.warn("Unable to determine minimum supported Android platform: " + e.toString());
533+
null;
534+
};
535+
536+
if (minPlatform == null) {
537+
Log.warn("Defaulting to Android platform 21");
538+
minPlatform = 21;
539+
}
540+
541+
// only platform version 21 and above support 64 bit
542+
// https://developer.android.com/about/versions/lollipop#Perf
543+
if (minPlatform < 21 && (defines.exists('HXCPP_ARM64') || defines.exists('HXCPP_X86_64'))) {
544+
minPlatform = 21;
545+
}
546+
547+
defines.set("HXCPP_ANDROID_PLATFORM", Std.string(minPlatform));
526548
}
527549
}
528550
else {

0 commit comments

Comments
 (0)