Skip to content

Add support for HXCPP_ANDROID_PLATFORM define#1201

Merged
Simn merged 2 commits intoHaxeFoundation:masterfrom
tobil4sk:android-ndk-version-cleanup
Mar 29, 2025
Merged

Add support for HXCPP_ANDROID_PLATFORM define#1201
Simn merged 2 commits intoHaxeFoundation:masterfrom
tobil4sk:android-ndk-version-cleanup

Conversation

@tobil4sk
Copy link
Member

Originally, android min sdk version could be configured using PLATFORM=android-xx. This was used because it was a sub directory of the android ndk: 9e716f1. Hxcpp used to extract the version from this define:

hxcpp/tools/hxcpp/Setup.hx

Lines 547 to 552 in 75108a5

var platform = defines.get("PLATFORM");
var id = Std.parseInt( platform.substr("android-".length) );
if (id==0 || id==null)
Log.error('Badly formed android PLATFORM "$platform" - should be like android-123');
androidPlatform = id;
Log.info("", "\x1b[33;1mUsing Android NDK platform: " + defines.get("PLATFORM") + "\x1b[0m");

However, for modern ndks, PLATFORM is no longer used to resolve any directory and since #825 it is not parsed by hxcpp for ndk 20 or newer either.

This left people with no way to configure the min sdk version. To give a way of doing this again, PLATFORM_NUMBER was made configurable in #992. However, given that it does not have a very descriptive name this seems like it was an internal variable that should not have been exposed like this. It has also never been documented.

This PR allows setting the minimum sdk version using HXCPP_ANDROID_PLATFORM. This is a flag that was already used internally by hxcpp and has a much more descriptive name.

I have therefore also deprecated the PLATFORM_NUMBER define with a warning.

@tobil4sk
Copy link
Member Author

tobil4sk commented Mar 20, 2025

Actually, instead of hxcpp manually specifying which api version to use per ndk version, it should read the ndk's metadata to determine this, which avoids having to bump it every time and is closer to what it used to do with older ndks when it would read the platforms/ folder contents

This also deprecates the PLATFORM_NUMBER define.

Also removes notes about frameworks setting minSdkVersion as this was
outdated and confusing.
@tobil4sk tobil4sk force-pushed the android-ndk-version-cleanup branch from dcb6734 to 634c261 Compare March 26, 2025 21:06
@tobil4sk
Copy link
Member Author

tobil4sk commented Mar 26, 2025

The default HXCPP_ANDROID_PLATFORM value is now set based on the ndk metadata, which means it won't be necessary in future to have PRs like: #1134 (or the platform version bump in #992).

Later it may be a good idea if the branch for ndks older than 20 would be unified with this (in terms of the logic at least), because right now we use the maximum version there, but the minimum version for newer ndks. However, we need to use the minimum platform version that supports the given architecture.

@tobil4sk tobil4sk force-pushed the android-ndk-version-cleanup branch from 634c261 to e5670cb Compare March 26, 2025 21:18
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.
@tobil4sk tobil4sk force-pushed the android-ndk-version-cleanup branch from e5670cb to 13b0afa Compare March 26, 2025 21:20
@Simn Simn merged commit 1043cf2 into HaxeFoundation:master Mar 29, 2025
120 checks passed
@tobil4sk tobil4sk deleted the android-ndk-version-cleanup branch March 29, 2025 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants