Macro --include is recursively including packages not appropriate for build target

只愿长相守 提交于 2019-12-11 05:15:04

问题


I'm building a game using the HaxeFlixel lib. In one part of my code I'm dynamically resolving classes via Type.resolveClass(). In order to avoid having to reference every potential class individually, I tried to use --macro include() by adding this to my project.xml:

<haxeflag name="--macro" value="include('my.pack')" />

This worked fine when compiling against the Flash target, but when I try to compile against neko I get:

C:\HaxeToolkit\haxe\lib\flixel/3,0,4/flixel/FlxG.hx:3: characters 7-34 : You can not access the flash package while targeting neko (for flash.display.DisplayObject)
C:\HaxeToolkit\haxe\lib\flixel/3,0,4/flixel/FlxSprite.hx:3: characters 7-18 :     referenced here
source/objects/enemies/Bat.hx:3: characters 7-23 :     referenced here
--macro:1: character 0 :     referenced here

It looks like the include macro is recursively including everything that my classes imported, including stuff that isn't appropriate for the neko target. Is there a way around this problem?


回答1:


OpenFL requires --macro allowPackage("flash") to work, which suppress the You can not access the flash package... error.

It looks like include is called before allowPackage, so you may manually call allowPackage before include:

<haxeflag name="--macro" value="allowPackage('flash')" />
<haxeflag name="--macro" value="include('my.pack')" />


来源:https://stackoverflow.com/questions/21391833/macro-include-is-recursively-including-packages-not-appropriate-for-build-targ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!