Haxe 构建过程中的令牌?
我正在使用 Haxe 制作一些用于 RTMP 视频流的简单 SWF。一切都运行良好,但我真正想做的是标记一些属性,以便使用特定于环境的属性 ALA Ant 来编译 SWF。
EG:
var host = "rtmp://localhost:1935/broadcasts";
变成:
var host = "@RTMP_ADDRESS@"
然后在编译期间,令牌被替换为环境特定值 - local.properties 包含:
RTMP_ADDRESS=rtmp://localhost:1935/broadcasts
我已经在文档和论坛帖子中浏览过,但不知道如何做到这一点,尽管我确信这是可能的。有人能指出我正确的方向吗?
注意:我考虑过使用 flashvars 并管理 Web 应用程序中的地址,但这似乎效率较低。如果这是处理此问题的更好方法,请解释原因。
I'm using Haxe to make a few simple SWFs for RTMP video streaming. Everything is working great, but what I'd really like to do is tokenize a few properties so that the SWFs are compiled with environment specific properties ALA Ant.
E.G:
var host = "rtmp://localhost:1935/broadcasts";
Becomes:
var host = "@RTMP_ADDRESS@"
And then during compile, the token is substituted with an environment specific value- local.properties contains:
RTMP_ADDRESS=rtmp://localhost:1935/broadcasts
I've poked around in documentation and on forum posts and can't see how to do this, though I'm sure it's possible. Can anyone point me in the right direction?
Note: I considered using flashvars and managing the address in the web application, but that seems less efficient. If that's the better way to handle this please explain why.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这听起来是使用 宏 的完美案例,它位于 haxe 的夜间构建中。
您可以在项目中创建一个配置文件(可能是 xml 格式),然后在宏函数的主体中加载该文件并提取字符串,最后将其作为表达式返回。
It sounds a perfect case to use macros, which is in the nightly build of haxe.
You can create a config file (maybe in xml format) inside your project, and in the body of your macro function you load the file and extract the String, finally return it as an expression.