宏--include递归地包含不适用于构建目标的软件包 [英] Macro --include is recursively including packages not appropriate for build target
问题描述
我正在使用HaxeFlixel库构建游戏.在我的代码的一部分中,我通过Type.resolveClass()
动态地解析类.为了避免单独引用每个潜在的类,我尝试通过将--macro include()
添加到我的project.xml
中来使用它:
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')" />
当针对Flash目标进行编译时,此方法工作正常,但是当我尝试针对neko进行编译时,我得到了:
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
似乎include宏递归地包含了我的类导入的所有内容,包括不适合neko目标的内容.有办法解决这个问题吗?
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?
推荐答案
OpenFL要求--macro allowPackage("flash")
起作用,从而抑制了You can not access the flash package...
错误.
OpenFL requires --macro allowPackage("flash")
to work, which suppress the You can not access the flash package...
error.
看起来include
在allowPackage
之前被调用,因此您可以在include
之前手动调用allowPackage
:
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')" />
这篇关于宏--include递归地包含不适用于构建目标的软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!