forked from Kitteh6660/Corruption-of-Champions-Mod
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
155 lines (129 loc) · 6.23 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<project name="Corruption of Champions Build Script" default="testAndRelease">
<!-- Create a environment variable FLEX_HOME that points to the flex SDK -->
<property environment="env" />
<property name="FLEX_HOME" location="${env.FLEX_HOME}" />
<property name="main.src.dir" value="${basedir}/classes"/>
<property name="test.src.dir" value="${basedir}/test"/>
<property name="lib.dir" value="${basedir}/lib/bin"/>
<property name="build.dir" value="${basedir}/target"/>
<property name="report.dir" value="${build.dir}/report"/>
<property name="test.file" value="${build.dir}/CoC-test.swf"/>
<!-- Setup Flex and FlexUnit ant tasks -->
<!-- You can set this directly so mxmlc will work correctly, or set FLEX_HOME as an environment variable and use as below -->
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<taskdef resource="flexUnitTasks.tasks">
<classpath>
<fileset dir="${lib.dir}/flexunit">
<include name="flexUnitTasks*.jar" />
</fileset>
</classpath>
</taskdef>
<!-- delete and create the DEPLOY dir again -->
<target name="init">
<delete dir="${build.dir}" />
<mkdir dir="${build.dir}" />
<mkdir dir="${report.dir}" />
</target>
<macrodef name="build-game-binary">
<attribute name="debug-flag"/>
<attribute name="release-flag"/>
<attribute name="binary-name"/>
<sequential>
<!-- build the game binary -->
<mxmlc file="${main.src.dir}/classes/CoC.as" output="${build.dir}/@{binary-name}" static-rsls="true">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${main.src.dir}/"/>
<compiler.debug>@{debug-flag}</compiler.debug>
<library-path dir="${lib.dir}" includes="*.swc" append="true"/>
<define name="CONFIG::release" value="@{release-flag}"/>
<define name="CONFIG::debug" value="@{debug-flag}"/>
<define name="CONFIG::AIR" value="false"/>
<define name="CONFIG::STANDALONE" value="true"/>
</mxmlc>
</sequential>
</macrodef>
<target name="release" depends="init" description="Build with release flags">
<build-game-binary debug-flag="false" release-flag="true" binary-name="CoC-release.swf"></build-game-binary>
</target>
<target name="debug" depends="init" description="Build with debug flags">
<build-game-binary debug-flag="true" release-flag="false" binary-name="CoC-debug.swf"></build-game-binary>
</target>
<macrodef name="build-unit-tests">
<attribute name="debug-flag"/>
<attribute name="release-flag"/>
<attribute name="test-runner" default="${test.src.dir}/TestRunner.mxml"/>
<sequential>
<!-- build the unit test binary -->
<mxmlc file="@{test-runner}" output="${test.file}" static-rsls="true">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${main.src.dir}/"/>
<source-path path-element="${test.src.dir}"/>
<compiler.debug>true</compiler.debug>
<library-path dir="${lib.dir}" includes="*.swc" append="true"/>
<library-path dir="${lib.dir}/flexunit" includes="*.swc" append="true"/>
<define name="CONFIG::release" value="@{release-flag}"/>
<define name="CONFIG::debug" value="@{debug-flag}"/>
<define name="CONFIG::AIR" value="false"/>
<define name="CONFIG::STANDALONE" value="true"/>
</mxmlc>
</sequential>
</macrodef>
<target name="test-build-debug" depends="init" description="Build the swf with test libraries and the debug flag">
<build-unit-tests debug-flag="true" release-flag="false">
</build-unit-tests>
</target>
<target name="test-build-release" depends="init" description="Build the swf with test libraries and without the debug flag">
<build-unit-tests debug-flag="false" release-flag="true">
</build-unit-tests>
</target>
<target name="all" depends="init,release,debug,test" description="Build all swf versions">
</target>
<target name="testAndRelease" depends="init,test,release" description="Run tests and build release">
</target>
<target name="test" depends="test-debug" description="Run the unit tests and create a HTML report">
</target>
<target name="test-single" depends="init" description="Run a single unit test or suit and create a HTML report. Specify the FQN of the class with -Dtestclass=">
<property name="single-runner" value="${test.src.dir}/SingleRunner.mxml"/>
<!-- Copy the original test target for all tests... -->
<copy file="${test.src.dir}/TestRunner.mxml" tofile="${single-runner}" overwrite="true"/>
<!-- And rewrite the import and class to run to the target test or suite -->
<replace file="${single-runner}" token="AllTestsSuite" value="${testclass}"/>
<build-unit-tests debug-flag="true" release-flag="false" test-runner="${single-runner}">
</build-unit-tests>
<run-unit-tests></run-unit-tests>
</target>
<macrodef name="run-unit-tests">
<sequential>
<!-- Execute FlexUnit tests and publish reports -->
<flexunit
workingDir="${build.dir}"
toDir="${report.dir}"
haltonfailure="false"
failureproperty="flexunit.failure"
verbose="true"
swf="${test.file}"
localTrusted="true">
<source dir="${main.src.dir}/" />
<library dir="${lib.dir}" />
</flexunit>
<!-- Generate readable JUnit-style reports -->
<junitreport todir="${report.dir}">
<fileset dir="${report.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${report.dir}/html" />
</junitreport>
<!-- Fail the build while still generating a report -->
<!-- From http://blog.yoz.sk/2012/04/quick-tip-flexunit-and-junitreport-and-haltonfailure/-->
<fail if="flexunit.failure" message="Unit test(s) failed. See reports!"/>
</sequential>
</macrodef>
<target name="test-debug" depends="test-build-debug" description="Run the unit tests and create a HTML report">
<run-unit-tests></run-unit-tests>
</target>
<target name="test-release" depends="test-build-release" description="Run the unit tests and create a HTML report">
<run-unit-tests></run-unit-tests>
</target>
</project>