2011-04-15 71 views
1

我最近跟着this great guide将颠覆版本整合到我的C++/c#visual studio项目中生成的exe/dll文件中。现在,我可以轻松地右键单击一个exe文件来查找哪个版本用于构建二进制文件(请参阅下图)。我喜欢这个功能。Flash/Flex:将subversion版本集成到exe/swf文件中?

在建立空气/独立应用程序时,这是否可以在flash/flex中执行相同的操作?我想标记exe文件和dll。

Details with svn revision information http://www.zachburlingame.com/wp-content/uploads/2011/03/c_svn_autoversion_version_info.png


更新与解决方案:

虽然这里提供的基于ANT的解决方案并不像一个在SVN信息被燃烧成的.exe/.dll顺利文件(在我看来),它解决了我的问题,现在在我们的制作中实施。 我的设置基于凯文和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> 
+0

这可能无法直接执行......但您可以使用AIR中默认集成的这种超酷自动触发功能http://gregsramblings.com/2008/08/16/adding-auto-update-features-to-your应用程序在3简单步骤/ – Neeraj 2011-04-15 11:27:50

+0

Incase你觉得这是正确的事情。请让我把它作为答案并标记为正确。 – Neeraj 2011-04-15 11:28:11

+0

谢谢你的回复Neeraj。虽然这确实是一个很好的功能,但它与我当前的配置不匹配,并且在我的设置中实现不会很容易。我感谢您的评论,稍后我会深入研究它,但它并不直接帮助我。如果你把它变成答案,我会给你一个投票:) – 2011-04-15 11:36:02

回答

1

我们用下面的方法(和它的相当类似凯文的答案,但我可以肯定,它的工作原理):

从我的build.xml代码片段:这使用两个jar文件(svnkit和svntask),而不是svn.exe(所以它运行跨平台) - 这些罐子也通过svn检入,所以你不能失去它们或misinstall 。

<!-- SVN revision stuff --> 
<typedef resource="com/googlecode/svntask/svntask.xml"> 
    <classpath> 
     <fileset dir="${basedir}/util"> 
      <include name="svnkit.jar"/> 
      <include name="svntask.jar"/> 
     </fileset> 
    </classpath> 
</typedef> 

<target name="revision"> 
    <svn><info path="${basedir}" revisionProperty="revision" /></svn> 
    <echo>${revision}</echo> 
</target> 
<!-- /SVN revision stuff --> 

现在我们有一个属性的修改,我们包括在mxmlc的任务作为条件编译变量:

 <mxmlc file="${src.dir}/@{appfile}[email protected]{ext}" 
      output="@{output}/@{appfile}.swf" 
      debug="@{debug}" 
      target-player="${version_major}" 
      optimize="true" 
      locale="" 
      use-network="true" 
     > 
      <define name="compile::REVISION" value="'${revision}'"/> 
      [... rest snipped] 
     </mxmlc> 

然后你可以使用该变量在AS:

var version:String = "1.0."+compile::REVISION; 

对于在Flash Builder中工作的代码,您必须将以下行添加到其他编译器参数中:

-define+=compile::REVISION,'dev' 

这样你的开发代码就会有修订版'dev',表明它不一定是从代码的提交版本构建的。

+0

坦率地说,非常感谢您的答复。经过一些调整后,我使用的是基于SubWCrev的解决方案,但在其他方面与您的相似(发布在我的问题中)。谢谢! – 2011-06-13 12:19:55

4

实际上,我是希望这样做我自己,所以我想通我会调查它。我使用ANT和mxmlc来完成我的构建。这里是一个ANT片段,我发现here以获得修订版本号:。

<target name="find_revision" description="Sets property 'revision.number' to the head svn revision"> 
     <property name="revision" value="HEAD"/> 

     <!-- find out revision number of HEAD, need svn.exe installed on local machine --> 
    <exec executable="svn" outputproperty="revision.number"> 
     <arg line="info -r ${revision}"/> 
     <redirector> 
      <outputfilterchain> 
       <linecontainsregexp> 
       <regexp pattern='^Revision' /> 
       </linecontainsregexp> 
       <tokenfilter> 
       <replaceregex pattern='[\D]+([\d]+)' replace="\1" /> 
       </tokenfilter> 
      </outputfilterchain> 
     </redirector> 
    </exec> 
</target> 

在找到修订号后,可以在编译时将该变量作为全局常量传递。这是通过mxmlc parameter完成的。

define=NAMESPACE::variable,value 

该变量可以在AS3中检索并以任何您想要的方式使用。有关详细信息,请参见using conditional compilatio

我还没有找到通过编程方式设置AIR应用程序描述符的方法,因此您可能必须在编译之前通过ANT编辑/创建XML描述符文件。

让我知道如果这个方法对你的作品,所以我可以用它自己= d

+0

你不能使用'get HEAD revnum',因为它可能不匹配您正在构建的代码版本(例如,如果某人在您之后进行了检查)。使用SubWCRev来获得您正在构建的工作副本的更新。 – gbjbaanb 2011-04-15 12:49:34

+0

凯文,非常感谢你的回答。随着frankhermes的增加下面,它或多或少是一个完整的解决方案。不幸的是,我不能接受多于一个的答案,但至少你得到了我的投票。再次感谢ypour的智慧! – 2011-06-13 12:17:32

相关问题