DISCLAIMER: the code (not the README) is AI generated using the Haxe compiler's ocaml HXB parser as reference.
We are using it as a frontend for hx2go. It should however be applicable for other projects that want a faster way to get Haxe's typed AST (not limited to eval/interp), while keeping all code in Haxe, such as other Haxe targets.
- Haxe nightly
5.0.0-preview.1+957b2c7or newer
haxelib git hxb-parser github.com/go2hx/hxb-parserThe sample code to implement a custom target, can be found at ./targetSample. Do note this is a lose generic reference implementation to how we implement hx2go, it's meant to be likewise used as a reference implementation and adapted for your own target's needs.
After you cd into the target sample you can run:
haxe build.hxmlThis will run a new custom target haxe2 (made purely for demonstration purposes)
Look in ./targetSample/source/Context.hx for the majority of the code. The target gets setup with Haxe's custom target hook, by calling --custom-target haxe2=output in the build.hxml which looks for a file found at any source path that adheres to: [target]/Init.hx. Inside it defines a public static function init() using both Compiler.setPlatformConfiguration and Compiler.setHxbWriterConfiguration.