File:  [mozdev] / popomungo / build.xml
Revision 1.47: download - view: text, annotated - select for diffs - revision graph
Tue Mar 22 18:42:11 2011 UTC (8 years, 8 months ago) by rautava
Branches: MAIN
CVS tags: v2_6_3a1, v2_6_3, HEAD
2.6.3 alpha 1

<?xml version="1.0"?>

<!--
    build.xml
    Copyright (C) 2007-2011 Tommi Rautava
    
    This file is part of Popomungo.

    Popomungo is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    Popomungo is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->

<project name="popomungo" default="build-dev-src">
	<description>Enhancements for Popmundo online game</description>

	<property file="${basedir}/release.properties" />

	<property name="babelzilla.dir" value="${basedir}/babelzilla" />
	<property name="build.dir" value="${basedir}/build" />
	<property name="cert.dir" value="${basedir}/cert" />
	<property name="dist.dir" value="${basedir}/dist" />
	<property name="downloads.dir" value="${basedir}/downloads" />
	<property name="src.dir" value="${basedir}/src" />
	<property name="www.dir" value="${basedir}/www" />
	
	<property name="releaseIni.file" value="${www.dir}/release.ini"/>
	<property name="buildNumber.file" value="${basedir}/.buildNumbers/build.number.${extension.version}"/>
	
	
	<condition property="isWindows">
		<os family="windows"/>
	</condition>
	
	
	<fileset id="src.root.files" dir="${src.dir}"> 
		<include name="chrome.manifest"/>
		<include name="defaults/**"/> 
		<include name="license.*"/> 
		<include name="gpl.txt"/> 
		<exclude name="**/.cvsignore"/>
	</fileset>
	
	
	<target name="build-babelzilla" depends="clean,init,set-version-dev,copy-src-to-build,xpi-babelzilla">
		<tstamp prefix="stop">
			<format property="build.tstamp" timezone="GMT+0" pattern="yyyy-MM-dd HH:mm z"/>
		</tstamp>
		<echo message="${extension.versionNumber.forThisBuild} ready ${stop.build.tstamp}" />
	</target>
	
	
	<target name="build-dev-src" depends="clean,init,set-version-dev,copy-src-to-build,unpack-babelzilla-replaced-bundle">
		<tstamp prefix="stop">
			<format property="build.tstamp" timezone="GMT+0" pattern="yyyy-MM-dd HH:mm z"/>
		</tstamp>
		<echo message="${extension.versionNumber.forThisBuild} ready ${stop.build.tstamp}" />
	</target>
	
	
	<target name="build-dev-all" depends="clean,init,set-version-dev,copy-src-to-build,xpi-dev,xpi-babelzilla,install-to-firefox">
		<tstamp prefix="stop">
			<format property="build.tstamp" timezone="GMT+0" pattern="yyyy-MM-dd HH:mm z"/>
		</tstamp>
		<echo message="${extension.versionNumber.forThisBuild} ready ${stop.build.tstamp}" />
	</target>
	
	
	<target name="checksum">
		<checksum file="${downloads.dir}/${extension.published.xpi}" 
			algorithm="${extension.checksum.algorithm}" 
			property="extension.checksum.value"/>
	</target>
	

	<target name="clean">
		<delete includeemptydirs="true">
			<fileset dir="${build.dir}" includes="**/*" excludes=".cvsignore" />
		</delete>
	</target>

	
	<target name="clean-dist">
		<delete includeemptydirs="true">
			<fileset dir="${dist.dir}" includes="**/*" excludes=".cvsignore" />
		</delete>
	</target>
	
	
	<target name="copy-src-to-build" depends="init">
		<copy todir="${build.dir}/src/chrome" overwrite="true">
			<fileset dir="${src.dir}" 
				includes="content/**,skin/**" 
				excludes="**/.cvsignore"/>
		</copy>
		
		<copy todir="${build.dir}/src" overwrite="true">
			<fileset refid="src.root.files"/>
		</copy>

		<replace file="${build.dir}/src/chrome.manifest">
			<replacefilter token="jar:" value="" />
			<replacefilter token="${ant.project.name}.jar!/" value="" />
		</replace>

		<copy todir="${build.dir}/src" file="${src.dir}/install.rdf" overwrite="true"/>

		<!-- Patch install.rdf -->
		<replace file="${build.dir}/src/install.rdf" propertyFile="${basedir}/release.properties">
			<replacefilter token="@id@" value="${extension.id}" />
			<replacefilter token="@version@" value="${extension.versionNumber.forThisBuild}" />
			<replacefilter token="@updateURL@" value="${extension.updateURL}" />
			<replacefilter token="@homepageURL@" property="extension.homepageURL" />
			<replacefilter token="@firefoxMinVersion@" property="extension.firefox.minVersion" />
			<replacefilter token="@firefoxMaxVersion@" property="extension.firefox.maxVersion" />
			<replacefilter token="@seamonkeyMinVersion@" property="extension.seamonkey.minVersion" />
			<replacefilter token="@seamonkeyMaxVersion@" property="extension.seamonkey.maxVersion" />
		</replace>
	</target>
	
	
	<target name="copy-src-to-xpi-build" depends="init,copy-src-to-build">
		<mkdir dir="${build.dir}/xpi" />
		<mkdir dir="${build.dir}/xpi/chrome" />

		<copy todir="${build.dir}/xpi" overwrite="true">
			<fileset refid="src.root.files"/>
		</copy>
	
		<copy todir="${build.dir}/xpi" file="${build.dir}/src/install.rdf" overwrite="true"/>
	</target>
	

	<target name="dist" depends="clean,set-version-dist,xpi-babelzilla,xpi,xpi-amo">
		<copy file="${dist.dir}/${extension.xpi}" todir="${downloads.dir}" overwrite="true"/>
		
		<checksum 
			file="${downloads.dir}/${extension.xpi}" 
			algorithm="${extension.checksum.algorithm}" 
			property="extension.downloads.xpi.checksum"/>
		
		<tstamp prefix="stop">
			<format property="build.tstamp" timezone="GMT+0" pattern="yyyy-MM-dd HH:mm z"/>
		</tstamp>
		
		<echo message="${extension.versionNumber.forThisBuild} is ready ${stop.build.tstamp}" />
		<echo message="${extension.checksum.algorithm} checsum is ${extension.downloads.xpi.checksum}" />
	</target>
	
	
	<target name="init" depends="init-build">
		<echo level="info" message="Version ${extension.version}-${extension.subVersion} Build ${build.number} started ${build.tstamp}"/>

		<mkdir dir="${build.dir}/src" />
		<mkdir dir="${build.dir}/src/chrome" />
	</target>
	
	
	<target name="init-amo" depends="init">
		<mkdir dir="${build.dir}/amo" />
	</target>
	

	<target name="init-babelzilla" depends="init">
		<mkdir dir="${build.dir}/babelzilla" />
		<mkdir dir="${build.dir}/babelzilla/chrome" />
	</target>
	

	<target name="init-build">
		<tstamp>
			<format property="build.tstamp" timezone="GMT+0" pattern="yyyy-MM-dd HH:mm z"/>
		</tstamp>
		
		<!-- Make the build number file writable. -->
		<exec executable="attrib" dir="${basedir}" osfamily="windows">
			<arg value="-r"/>
			<arg file="${buildNumber.file}"/>
		</exec>

		<buildnumber file="${buildNumber.file}"/>
	</target>

	
	<target name="install-to-firefox" if="isWindows">
		<property file="${build.dir}/build.latest"/>
		<exec executable="c:/program files/mozilla firefox/firefox.exe">
			<arg value="file:///${dist.dir}/${extension.xpi}"/>
		</exec>
	</target>

	
	<target name="jar" depends="copy-src-to-xpi-build,unpack-babelzilla-replaced-bundle">
		<delete file="${build.dir}/xpi/chrome/${ant.project.name}.jar"/>
		
		<zip destfile="${build.dir}/xpi/chrome/${ant.project.name}.jar">
			<zipfileset dir="${build.dir}/src/chrome" includes="**/*" excludes="**/amo.properties"/>
		</zip>
	</target>
	
	
	<target name="publish" depends="update.rdf,release.ini">
		<copy file="${build.dir}/update.rdf" todir="${www.dir}" overwrite="true"/>
	</target>
	
	
	<!-- Create release.ini file which is read by www/local.conf -->
	<target name="release.ini" depends="set-pub-xpi-name,checksum">
		<exec executable="attrib" dir="${basedir}" osfamily="windows">
			<arg value="-r"/>
			<arg file="${releaseIni.file}"/>
		</exec>

		<concat destfile="${releaseIni.file}">
			<string value="[release]&#0010;" />
			<string value="version = &quot;${extension.publishedVersion}&quot;&#0010;" />
			<string value="xpi = &quot;${extension.published.xpi}&quot;&#0010;" />
			<string value="checksum = &quot;${extension.checksum.algorithm}:${extension.checksum.value}&quot;&#0010;" />
		</concat>
	</target>
	
	
	<!-- Repack an existing xpi file as AMO release. -->
	<target name="repack-published-for-amo" depends="init-amo,set-pub-xpi-name">
		<property name="repack.dir" value="${build.dir}/amo.${DSTAMP}.${TSTAMP}"/>

		<mkdir dir="${repack.dir}"/>

		<unzip src="${downloads.dir}/${extension.published.xpi}" dest="${repack.dir}"/>

		<!-- Comment out updateURL as AMO does not allow it. -->
		<replace file="${repack.dir}/install.rdf">
			<replacefilter token="&lt;em:updateURL&gt;" value="&lt;!-- &lt;em:updateURL&gt;"/>
			<replacefilter token="&lt;/em:updateURL&gt;" value="&lt;/em:updateURL&gt; --&gt;"/>
		</replace>

		<mkdir dir="${dist.dir}/amo" />

		<delete file="${dist.dir}/amo/${extension.published.xpi}"/>
		
		<zip destfile="${dist.dir}/amo/${extension.published.xpi}">
			<zipfileset dir="${repack.dir}" includes="*/**"/>
		</zip>
		
		<delete dir="${repack.dir}"/>
	</target>
	
	
	<target name="set-pub-xpi-name">
		<property name="extension.published.xpi" value="${ant.project.name}-${extension.publishedVersion}${extension.appsPostfix}.xpi"/>
	</target>

	
	<target name="set-version">
		<property name="extension.versionNumber" value="${extension.version}${extension.subVersion}"/>
	</target>		

	
	<target name="set-version-dev" depends="set-version">
		<property name="extension.versionNumber.plusBuild" value="${extension.versionNumber}.0pre${build.number}"/>
		<property name="extension.versionNumber.forThisBuild" value="${extension.versionNumber.plusBuild}"/>
		<concat destfile="${build.dir}/build.latest">
			<string value="extension.versionNumber.latest=${extension.versionNumber.forThisBuild}"/>
		</concat>
	</target>
	
	
	<target name="set-version-dist" depends="set-version">
		<property name="extension.versionNumber.forThisBuild" value="${extension.versionNumber}"/>
		<concat destfile="${build.dir}/build.latest">
			<string value="extension.versionNumber.latest=${extension.versionNumber.forThisBuild}"/>
		</concat>
	</target>
	
	
	<target name="set-xpi-name">
		<property name="extension.xpi" value="${ant.project.name}-${extension.versionNumber.forThisBuild}${extension.appsPostfix}.xpi"/>
		<concat destfile="${build.dir}/build.latest" append="true">
			<string value="extension.xpi.latest=${extension.xpi}"/>
		</concat>
	</target>
	
	
	<target name="sign" depends="jar">
		<exec executable="signtool">
			<arg value="-d"/>
			<arg path="${cert.dir}"/>
			<arg value="-k"/>
			<arg value="Popomungo"/>
			<arg path="${build.dir}/xpi"/>
		</exec>
	</target>
	
	
	<target name="sign-dev" depends="copy-src-to-build">
		<exec executable="signtool">
			<arg value="-d"/>
			<arg path="${cert.dir}"/>
			<arg value="-k"/>
			<arg value="Popomungo"/>
			<arg path="${build.dir}/src"/>
		</exec>
	</target>
	
	
	<target name="update.rdf" depends="set-pub-xpi-name,checksum">
		<copy file="${src.dir}/update.rdf" todir="${build.dir}" overwrite="true"/>
		
		<replace file="${build.dir}/update.rdf" propertyFile="${basedir}/release.properties">
			<replacefilter token="@id@" value="${extension.id}" />
			<replacefilter token="@version@" value="${extension.publishedVersion}" />
			<replacefilter token="@updateLink@" value="${extension.downloadsDirURL}${extension.published.xpi}" />
			<replacefilter token="@firefoxMinVersion@" property="extension.firefox.minVersion" />
			<replacefilter token="@firefoxMaxVersion@" property="extension.firefox.maxVersion" />
			<replacefilter token="@checksum@" value="${extension.checksum.algorithm}:${extension.checksum.value}" />
		</replace>
	</target>
	
	
	<target name="unpack-babelzilla-replaced-bundle" depends="init">
		<mkdir dir="${build.dir}/all_locales_replaced" />
		
		<property name="babelzilla-replaced-bundle-tar-gz" value="${extension.babelzillaFilenamePrefix}_all_locales_replaced.tar.gz"/>
		
		<!-- Unpack the string bundle. -->
		<untar src="${basedir}/babelzilla/${babelzilla-replaced-bundle-tar-gz}" dest="${build.dir}/all_locales_replaced/locale"
			compression="gzip" overwrite="true"/>
		
		<!-- Move all files except .properties to .xpi build directory. -->
		<!-- Also, exclude the default locale (en-US) -->
		<move todir="${build.dir}/src/chrome" overwrite="true">
			<fileset dir="${build.dir}/all_locales_replaced" 
				includes="*/**" 
				excludes="**/*.properties,**/en-US/**,**/contents.rdf"/>
		</move>
		
		<!-- Copy the files of the default locale to the .xpi build directory, but exclude .properties. -->
		<copy todir="${build.dir}/src/chrome" overwrite="true">
			<fileset dir="${src.dir}" 
				includes="locale/**" 
				excludes="**/.cvsignore,locale/**/*.properties"/>
		</copy>
		
		<!-- Encode .properties files of the default locale
		<!   and store the results to the .xpi build directory. -->
		<native2ascii src="${src.dir}" dest="${build.dir}/src/chrome" encoding="UTF-8">
			<include name="locale/**/*.properties"/>
		</native2ascii>
		
		<!-- Encode .properties from the bundle -->
		<native2ascii src="${build.dir}/all_locales_replaced" dest="${build.dir}/src/chrome" encoding="UTF-8">
			<include name="locale/**/*.properties"/>
			<exclude name="locale/en-US/**"/>
		</native2ascii>
	</target>
	
	
	<target name="unpack-babelzilla-blank-bundle" depends="init-babelzilla">
		<mkdir dir="${build.dir}/all_locales_blank" />
		
		<property name="babelzilla-blank-bundle-tar-gz" value="${extension.babelzillaFilenamePrefix}_all_locales_skipped.tar.gz"/>
		
		<!-- Unpack the string bundle. -->
		<untar src="${basedir}/babelzilla/${babelzilla-blank-bundle-tar-gz}" dest="${build.dir}/all_locales_blank/locale"
			compression="gzip" overwrite="true"/>
		
		<!-- Move all files except .properties to .xpi build directory. -->
		<!-- Also, exclude the default locale (en-US) -->
		<move todir="${build.dir}/babelzilla/chrome" overwrite="true">
			<fileset dir="${build.dir}/all_locales_blank" 
				includes="*/**" 
				excludes="**/*.properties,**/en-US/**,**/contents.rdf"/>
		</move>
		
		<!-- Copy the files of the default locale to the .xpi build directory, but exclude .properties. -->
		<copy todir="${build.dir}/babelzilla/chrome" overwrite="true">
			<fileset dir="${src.dir}" 
				includes="locale/**" 
				excludes="**/.cvsignore,locale/**/*.properties"/>
		</copy>
		
		<!-- Encode .properties files of the default locale
		<!   and store the results to the .xpi build directory. -->
		<native2ascii src="${src.dir}" dest="${build.dir}/babelzilla/chrome" encoding="UTF-8">
			<include name="locale/**/*.properties"/>
		</native2ascii>
		
		<!-- Encode .properties from the bundle -->
		<native2ascii src="${build.dir}/all_locales_blank" dest="${build.dir}/babelzilla/chrome" encoding="UTF-8">
			<include name="locale/**/*.properties"/>
			<exclude name="locale/en-US/**"/>
		</native2ascii>
		
		<!-- Remove strings equal to ones on en-US locale. -->
		<!--
		<exec executable="perl" dir="${build.dir}/babelzilla/chrome/locale/">
			<arg file="${basedir}/test/fix_for_babelzilla.pl"/>
		</exec>
		-->
	</target>
	
	
	<target name="xpi" depends="set-xpi-name,unpack-babelzilla-replaced-bundle,jar">
		<delete file="${dist.dir}/${extension.xpi}"/>

		<zip destfile="${dist.dir}/${extension.xpi}">
			<zipfileset dir="${build.dir}/xpi" includes="*/**" />
		</zip>
	</target>

	
	<target name="xpi-amo" depends="init-amo,set-xpi-name,unpack-babelzilla-replaced-bundle,jar">
		<mkdir dir="${build.dir}/amo" />

		<copy file="${build.dir}/xpi/install.rdf" todir="${build.dir}/amo" overwrite="true"/>
		
		<!-- Comment out updateURL as AMO does not allow it. -->
		<replace file="${build.dir}/amo/install.rdf">
			<replacefilter token="&lt;em:updateURL&gt;" value="&lt;!-- &lt;em:updateURL&gt;"/>
			<replacefilter token="&lt;/em:updateURL&gt;" value="&lt;/em:updateURL&gt; --&gt;"/>
		</replace>
		
		<mkdir dir="${dist.dir}/amo" />
		
		<delete file="${dist.dir}/amo/${extension.xpi}" />

		<zip destfile="${dist.dir}/amo/${extension.xpi}">
			<zipfileset dir="${build.dir}/xpi" includes="*/**" excludes="install.rdf"/>
			<zipfileset dir="${build.dir}/amo" includes="install.rdf" />
		</zip>
	</target>


	<!-- Make a special .xpi for Babelzilla:
	<!   - Untranslated strings are blank.
	<!   - Leave the contents unpacked (in other words, do not pack the content and the locale files into a jar file). -->
	<target name="xpi-babelzilla" depends="set-xpi-name,copy-src-to-build,unpack-babelzilla-blank-bundle,jar">
		<mkdir dir="${dist.dir}/babelzilla" />
		
		<delete file="${dist.dir}/babelzilla/${extension.xpi}" />

		<zip destfile="${dist.dir}/babelzilla/${extension.xpi}" filesonly="true">
			<zipfileset dir="${build.dir}/src" includes="META-INF/zigbert.rsa"/>
			<zipfileset dir="${build.dir}/src" includes="*/**" excludes="META-INF/zigbert.rsa,chrome/locale/**"/>
			<zipfileset dir="${build.dir}/babelzilla" includes="*/**"/>
		</zip>
	</target>


	<target name="xpi-dev" depends="set-xpi-name,copy-src-to-build,unpack-babelzilla-replaced-bundle">
		<delete file="${dist.dir}/${extension.xpi}"/>
		
		<zip destfile="${dist.dir}/${extension.xpi}" filesonly="true">
			<zipfileset dir="${build.dir}/src" includes="META-INF/zigbert.rsa"/>
			<zipfileset dir="${build.dir}/src" includes="*/**" excludes="META-INF/zigbert.rsa"/>
		</zip>
	</target>
	
</project>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>