How to run macro at OpenFl project before OpenFl parses assets?

Hello everybody,

I have a project with localization files kept in “.properties” format.
I have a macro which converts them to Json and applies ZLIB compression to the final json.

Project xml snippet:

<haxeflag name="--macro" value="macros.BuildMacro.compileLocales()"/>

<assets path="assets/locales/common.zjson" rename="locales/common" generate="false" preload="true"/>

The question is how to organize the compilation process to compile locales (run macro) before OpenFl detects that compiled .zjson files are not yet created?

Error:Could not find asset path "assets/locales/common.zjson"
Error: (Command exited with an error code) 1
Error:Compilation failed


Perhaps you could try writing a script using HXP to do this?

haxelib install hxp



import hxp.*;

class Script extends hxp.Script
	private var samples:Array<String>;

	public function new()

		if (command == "update" || command == "build" || command == "test")

		System.runCommand("", "openfl", [ command ].concat(commandArgs));


hxp path/to/script.hx test neko
hxp test neko (same directory)

I’m open to adding a change to the Lime command-line tools to execute an HXP script as part of the build if someone wanted to chat on Discord about implementing that