fix macro not running without explicit import

This commit is contained in:
2026-08-06 01:26:10 +02:00
parent 34f56e93df
commit ce9f71470f
3 changed files with 6 additions and 1 deletions

View File

@@ -25,4 +25,5 @@
--macro keep("Main")
--macro keep("Assets")
--macro keep("AssetMacro")
--macro macros.AssetMacro.includeAssets()
# --macro macros.MacroLoader.run()

View File

@@ -1,7 +1,6 @@
package;
import openfl.display.Sprite;
import Assets; // Forces @:build(macros.AssetMacro.build()) to run.
class Main extends Sprite {
public function new() {

View File

@@ -16,6 +16,11 @@ class AssetMacro {
// Track all assets processed
private static var assetMap:Map<String, Array<{id:String, path:String, size:Int, type:String}>> = new Map();
/** Force Assets to be typed, which invokes its @:build macro. */
public static function includeAssets():Void {
Context.getType("Assets");
}
/**
* Entry point for the macro - called during compilation
*/