From 88a49a484feb210e7adaa3ea971d3b45e312259f Mon Sep 17 00:00:00 2001 From: Mihai Alexandru <77043862+MAJigsaw77@users.noreply.github.com> Date: Sat, 17 Aug 2024 00:41:20 +0300 Subject: [PATCH] Define `PLATFORM` and `PLATFORM_NUMBER` based on the minimum `Android` SDK Version. --- tools/platforms/AndroidPlatform.hx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tools/platforms/AndroidPlatform.hx b/tools/platforms/AndroidPlatform.hx index 4d4caaaf12..165f2c0990 100644 --- a/tools/platforms/AndroidPlatform.hx +++ b/tools/platforms/AndroidPlatform.hx @@ -161,8 +161,9 @@ class AndroidPlatform extends PlatformTarget for (architecture in architectures) { - var haxeParams = [hxml, "-D", "android", "-D", "PLATFORM=android-21"]; - var cppParams = ["-Dandroid", "-DPLATFORM=android-21"]; + var minimumSDKVersion = project.config.getInt("android.minimum-sdk-version", 21); + var haxeParams = [hxml, "-D", "android", "-D", "PLATFORM=android-" + minimumSDKVersion, "-D", "PLATFORM_NUMBER=" + minimumSDKVersion]; + var cppParams = ["-Dandroid", "-DPLATFORM=android-" + minimumSDKVersion, "-DPLATFORM_NUMBER=" + minimumSDKVersion]; var path = sourceSet + "/jniLibs/armeabi"; var suffix = ".so"; @@ -363,21 +364,22 @@ class AndroidPlatform extends PlatformTarget public override function rebuild():Void { - var armv5 = (/*command == "rebuild" ||*/ - ArrayTools.containsValue(project.architectures, Architecture.ARMV5) - || ArrayTools.containsValue(project.architectures, Architecture.ARMV6)); + var armv5 = ArrayTools.containsValue(project.architectures, Architecture.ARMV5) + || ArrayTools.containsValue(project.architectures, Architecture.ARMV6); var armv7 = (command == "rebuild" || ArrayTools.containsValue(project.architectures, Architecture.ARMV7)); var arm64 = (command == "rebuild" || ArrayTools.containsValue(project.architectures, Architecture.ARM64)); var x86 = (command == "rebuild" || ArrayTools.containsValue(project.architectures, Architecture.X86)); - var x64 = (/*command == "rebuild" ||*/ ArrayTools.containsValue(project.architectures, Architecture.X64)); + var x64 = ArrayTools.containsValue(project.architectures, Architecture.X64); var commands = []; - if (armv5) commands.push(["-Dandroid", "-DPLATFORM=android-21"]); - if (armv7) commands.push(["-Dandroid", "-DHXCPP_ARMV7", "-DPLATFORM=android-21"]); - if (arm64) commands.push(["-Dandroid", "-DHXCPP_ARM64", "-DPLATFORM=android-21"]); - if (x86) commands.push(["-Dandroid", "-DHXCPP_X86", "-DPLATFORM=android-21"]); - if (x64) commands.push(["-Dandroid", "-DHXCPP_X86_64", "-DPLATFORM=android-21"]); + var minimumSDKVersion = project.config.getInt("android.minimum-sdk-version", 21); + + if (armv5) commands.push(["-Dandroid", "-DPLATFORM=android-" + minimumSDKVersion, "-DPLATFORM_NUMBER=" + minimumSDKVersion]); + if (armv7) commands.push(["-Dandroid", "-DHXCPP_ARMV7", "-DPLATFORM=android-" + minimumSDKVersion, "-DPLATFORM_NUMBER=" + minimumSDKVersion]); + if (arm64) commands.push(["-Dandroid", "-DHXCPP_ARM64", "-DPLATFORM=android-" + minimumSDKVersion, "-DPLATFORM_NUMBER=" + minimumSDKVersion]); + if (x86) commands.push(["-Dandroid", "-DHXCPP_X86", "-DPLATFORM=android-" + minimumSDKVersion, "-DPLATFORM_NUMBER=" + minimumSDKVersion]); + if (x64) commands.push(["-Dandroid", "-DHXCPP_X86_64", "-DPLATFORM=android-" + minimumSDKVersion, "-DPLATFORM_NUMBER=" + minimumSDKVersion]); CPPHelper.rebuild(project, commands); }