Add ant-based build system
authorAndy Allan <gravitystorm@gmail.com>
Wed, 3 Nov 2010 16:44:21 +0000 (16:44 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Wed, 3 Nov 2010 16:44:21 +0000 (16:44 +0000)
README.txt
build.properties.template [new file with mode: 0644]
build.xml [new file with mode: 0644]
lib/flexTasks.jar [new file with mode: 0644]
potlatch2.mxml
version.as.template [new file with mode: 0644]

index b597174..2eb5c8e 100644 (file)
@@ -14,6 +14,7 @@ Many icons used in halcyon/potlatch2 are based on the awesome CC0-licensed SJJB
 * AS3 docs - http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
 * Flash debug player - http://www.adobe.com/support/flashplayer/downloads.html
 * Basically you might as well just sell your soul to Adobe
+* Ant
 
 ***Do not use FlexSDK <= 3.3 or > 4***. There are compatibility errors with version 4, and 3.3
 and earlier have this bug: http://bugs.adobe.com/jira/browse/SDK-16705 which is a major issue for the
@@ -28,11 +29,17 @@ for development and testing.
 
 Compiling Potlatch 2:
 
-The following command will compile potlatch2 in optimized configuration
+Before you start, copy the properties template file, and edit the FLEX_HOME variable
+  cp build.properties.template build.properties
+
+The following command will compile potlatch2 in debug configuration
 The result is put at resources/potlatch2.swf
 
-* mxmlc potlatch2.mxml
+* ant
+
+The following command will compile potlatch2 in release configuration
 
+* ant release
 
 Compiling Halcyon as standalone viewer:
 
diff --git a/build.properties.template b/build.properties.template
new file mode 100644 (file)
index 0000000..b42f38e
--- /dev/null
@@ -0,0 +1,10 @@
+# change this to your Flex SDK directory path
+# e.g. FLEX_HOME=/home/andy/bin/flex/
+# e.g. FLEX_HOME=C:/Program Files/Adobe/Flex Builder 3/sdks/3.5.0
+FLEX_HOME=/path/to/your/flex/sdk
+
+# this points to your project's src directory
+# {$basedir} is a default variable that can be used in any Ant script
+# SRC_DIR =${basedir}/src
+# points to the project's libs directory
+# LIBS_DIR =${basedir}/lib
diff --git a/build.xml b/build.xml
new file mode 100644 (file)
index 0000000..f821671
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,52 @@
+<project name="Potlatch2 ├╝ber compile system" default="debug">
+
+  <!-- load previously defined configuration properties file -->
+  <property file="build.properties" />
+
+  <!-- flexTasks comes with flex, but apparently it's good practice to put in the libs folder -->
+  <taskdef resource="flexTasks.tasks" classpath="${basedir}/lib/flexTasks.jar"/>
+
+  <!-- if you are running git-svn, you need to run "git tag -a 0.4 0ac0de" where 0ac0de corresponds to the commitid of
+      potlatch2 v0.4 . You need to do this for each point release while we're still in SVN.
+      If you don't, then expect "git describe" to fail miserably.
+      Produces a build number of the form 0.4-1-g9692243 which means 1 commit later than 0.4, latest commit was 9692243 -->
+  <available file=".git" type="dir" property="git.present"/>
+  <target name="git-buildnumber" description="Store output from git-describe in ${buildnumber}" if="git.present">
+    <exec outputproperty="build_number" executable="git" dir="${basedir}">
+      <arg value="describe" />
+    </exec>
+  </target>
+
+  <!-- if you are running svn ("I pity the fool", etc) then svnversion will give the svn revision number, and the
+       build number will be of the form 24041 -->
+  <available file=".svn" type="dir" property="svn.present"/>
+  <target name="svn-buildnumber" description="Store output from svnversion in ${buildnumber}" if="svn.present">
+    <exec outputproperty="build_number" executable="svnversion" dir="${basedir}" />
+  </target>
+
+  <!-- delete and create the DEPLOY dir again -->
+  <target name="init" depends="git-buildnumber,svn-buildnumber">
+    <echo>Build Number ${build_number}</echo>
+    <copy file="version.as.template" tofile="version.as" overwrite="true" />
+    <replace file="version.as" token="@@@buildnumber@@@" value="${build_number}" />
+  </target>
+
+  <!-- Build and output potlatch2.swf in debug mode -->
+  <target name="debug" depends="init">
+    <mxmlc file="potlatch2.mxml">
+      <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
+      <load-config filename="debug-config.xml"/>
+      <source-path path-element="${FLEX_HOME}/frameworks"/>
+      <compiler.debug>true</compiler.debug>
+    </mxmlc>
+  </target>
+
+  <!-- Build and output potlatch2.swf in release mode -->
+  <target name="release" depends="init">
+    <mxmlc file="potlatch2.mxml">
+      <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
+      <source-path path-element="${FLEX_HOME}/frameworks"/>
+      <compiler.debug>false</compiler.debug>
+    </mxmlc>
+  </target>
+</project>
\ No newline at end of file
diff --git a/lib/flexTasks.jar b/lib/flexTasks.jar
new file mode 100644 (file)
index 0000000..b753057
Binary files /dev/null and b/lib/flexTasks.jar differ
index 79735e5..22475c8 100755 (executable)
 
                private var savecount:uint=0;
                private var loadcount:uint=0;
-               
-               public var version:String="(Foxbase) Alpha";                    // mxml won't read it if it's a const. Go figure
+
+        include "version.as";
 
                private function initApp():void {
 
diff --git a/version.as.template b/version.as.template
new file mode 100644 (file)
index 0000000..eb9c15a
--- /dev/null
@@ -0,0 +1,6 @@
+// This template file is copied to version.as, and variables are substituted,
+// during ant builds. I expect the version to become a variable (read from git tags)
+// at some point in the future.
+
+public var build_number:String="@@@buildnumber@@@";
+public var version:String="0.4";