One thing I discovered recently is that Haxe, via hxcpp, by defaultĀ builds to a fairly old Android target platform. A consequence of this is that it uses software floating point emulation. But any Android device from ARM v7 on supports hardware floating point. Switching to this produces a dramatic speedup, assuming you’re ok with that requirement. To do so, use the HXCPP_ARMV7
option, something like so:
openfl build -DHXCPP_M64 -DHXCPP_ARMV7 android
The HXCPP_M64
flag is to build correctly on a 64bit machine; details here.
However, there’s apparently a bug somewhere in the hxcpp toolchain. Enabling the ARM v7 target adds a `-7` prefix to a variable denoting the target library extension (`.so`). Seemingly some part of the toolchain doesn’t use this extension variable, so you get a warning like this:
Error: Source path "export/android/obj/libApplicationMain.so" does not exist
NOTE that if you had previously built under the default architecture, the toolchain will blithely continue on using that old version and you’ll be left confused as to why none of your code updates are being applied. You have to delete that file or your Android build folder, typically export/android/
.
I haven’t looked into how to really fix this problem, but it seems to be enough for now to simply not add that extension prefix. In your haxelib folder, edit hxcpp/3,0,2/build-tool/android-toolchain.xml
and comment out this line:
<set name="ARCH" value ="-7" if="HXCPP_ARMV7" />
Everything should now build correctly and run speedier. Huzzah!