Flash/Flex:将 subversion 修订版集成到 exe/swf 文件中?
我最近关注了 这个很棒的指南,将 subversion 修订版集成到我的 c++/c# Visual Studio 项目生成的 exe/dll 文件中。现在,我可以轻松地右键单击 exe 文件来查找用于构建二进制文件的版本(参见下图)。我喜欢这个功能。
在构建空气/独立应用程序时,是否可以在 flash/flex 中执行相同的操作?我想标记 exe 文件和 dll。
(来源:zachburlingame.com)
更新解决方案:
虽然这里提供的基于 ANT 的解决方案不如将 svn 信息烧录到 .exe/.dll 文件中的解决方案那么顺利(在我看来),它解决了我的问题,现在已在我们的作品中实施。 我的设置基于 Kevin 和 Frankhermes 的答案,但使用 SubMCRev.exe 而不是 svn.exe 或 jar 文件。
在我们的实现中,我们在启动时将 svn 修订转储到日志文件中。下面 SVN 目标的输出如下所示:
Built with SVN Revision: 1.0.0.1181 (local modifications found)
SVN 目标:
<target name="SVN Revision">
<exec executable="subWCRev.exe" outputproperty="revision">
<arg value="${basedir}\\.." />
<redirector>
<outputfilterchain>
<linecontainsregexp>
<regexp pattern='^([Last]|[Local])' />
</linecontainsregexp>
<tokenfilter>
<replaceregex pattern='[\D]+([\d]+)' replace="Built with SVN Revision: 1.0.0.\1" />
<replaceregex pattern='Local modifications found' replace=" (local modifications found)" />
</tokenfilter>
<striplinebreaks />
</outputfilterchain>
</redirector>
</exec>
</target>
编译目标:
<target name="compile" depends="init, SVN Revision">
<mxmlc file="..." output="...">
<define name="compile::REVISION" value="'${revision}'" />
....
</mxmlc>
</target>
I recently I followed this great guide to integrate the subversion revision into exe/dll files generated from my c++/c# visual studio projects. Now I can easily right-click on an exe-file to find which revision was used to build the binary (see image below). I love this feature.
Is this possible to do the same in flash/flex when building air/stand-alone applications? I would like to tag both exe file and dlls.
(source: zachburlingame.com)
Update with solution:
Although the ANT-based solutions provided here aren't as smooth as the one where the svn info is burnt into .exe/.dll files (in my opinion), it has solved my problem and is now implemented in our productions.
My setup is based both on Kevin's and frankhermes's answeres but uses SubMCRev.exe instead of svn.exe or jar files.
In our implementation we dump the svn revision to the logfile at startup. The output from the SVN target below looks like this:
Built with SVN Revision: 1.0.0.1181 (local modifications found)
SVN target:
<target name="SVN Revision">
<exec executable="subWCRev.exe" outputproperty="revision">
<arg value="${basedir}\\.." />
<redirector>
<outputfilterchain>
<linecontainsregexp>
<regexp pattern='^([Last]|[Local])' />
</linecontainsregexp>
<tokenfilter>
<replaceregex pattern='[\D]+([\d]+)' replace="Built with SVN Revision: 1.0.0.\1" />
<replaceregex pattern='Local modifications found' replace=" (local modifications found)" />
</tokenfilter>
<striplinebreaks />
</outputfilterchain>
</redirector>
</exec>
</target>
Compile target:
<target name="compile" depends="init, SVN Revision">
<mxmlc file="..." output="...">
<define name="compile::REVISION" value="'${revision}'" />
....
</mxmlc>
</target>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我实际上想自己做这件事,所以我想我应该调查一下。我使用 ANT 和 mxmlc 来进行构建。这是我在此处找到的 ANT 片段获取修订号:.
通过找到修订号,可以在编译时将该变量作为全局常量传递。这是通过 mxmlc 参数 完成的:。
该变量可以在 AS3 中检索并以您想要的任何方式使用。有关详细信息,请参阅使用条件编译。
我还没有找到以编程方式设置 AIR 应用程序描述符的方法,因此您可能必须在编译之前通过 ANT 编辑/创建 XML 描述符文件。
让我知道这个方法是否适合你,这样我就可以自己使用=D
I was actually looking to do this myself, so I figured I'd investigate it. I use ANT and mxmlc to do my builds. Here is an ANT snippet I found here to get the revision number:.
With the revision number found one could pass the variable as a global constant at compilation time. This is accomplished via the mxmlc parameter:.
This variable can be retrieved in AS3 and used in whatever way you want. See using conditional compilation for details.
I haven't found a way to set an AIR Application's descriptors programmatically yet, so you might have to edit/create your XML descriptor file via ANT before compilation.
Let me know if this method works for you so I can use it myself =D
我们使用以下方法(它与 Kevin 的答案非常相似,但我可以确认它有效):
来自我的 build.xml 的片段:这使用两个 jar 文件(svnkit 和 svntask)而不是 svn.exe (因此它跨-platform) - 这些 jar 也通过 svn 签入,因此您不会丢失它们或错误安装。
现在,我们对属性进行了修订,将其作为条件编译器变量包含在 mxmlc 任务中:
然后您可以在 AS 中使用该变量:
为了使代码也能在 Flash Builder 中工作,您必须将以下行添加到您的附加编译器参数:
这样您的开发代码将具有修订版“dev”,表明它不一定是从代码的提交版本构建的。
We use the following method (and it's pretty similar to Kevin's answer but I can confirm that it works):
a snippet from my build.xml: this uses two jar files (svnkit and svntask) instead of svn.exe (so it runs cross-platform) - these jars are checked in via svn too so you can't lose them or misinstall.
Now we have the revision in a property that we include in the mxmlc task as a conditional compiler variable:
Then you can use that variable in AS:
For the code to work in Flash Builder too, you'd have to add the following line to your additional compiler arguments:
That way your development code will have the revision 'dev', indicating that it was not necessarily built from a committed version of the code.