-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbuild.xml
206 lines (176 loc) · 9.31 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<?xml version="1.0" encoding="utf-8" ?>
<project name="NDS3" default="make_distribution" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<!-- This is an ant build file" -->
<!-- Initialize the version number -->
<target name="version" description="Initialize the build number">
<property environment="env"/>
<property name="fileVersion" value="${env.BUILD_BRANCH}_build_${env.BUILD_VERSION}"/>
<property name="fullVersionReadable" value="${env.BUILD_BRANCH} build ${env.BUILD_VERSION}"/>
<property name="productName" value="NDS3 ${fullVersionReadable}"/>
</target>
<!-- Create the directory for the final build -->
<target name="create_build_dir" depends="version" description="Create the directory for the final build">
<property name="artifacts" value="./artifacts" />
<delete dir="${artifacts}" failonerror="false" />
<mkdir dir="${artifacts}" />
<property name="build_dir_tests" value="./build_tests_reports" />
<delete dir="${build_dir_tests}" failonerror="false" />
<mkdir dir="${build_dir_tests}" />
<copy todir="${build_dir_tests}">
<fileset dir=".">
<include name="src/**/*.cpp" />
<include name="include/**/*.h" />
<include name="CMake/**/CMakeLists.txt" />
</fileset>
<fileset dir=".">
<include name="tests/src/**/*.cpp" />
<include name="tests/include/**/*.h" />
<include name="tests/CMake/**/CMakeLists.txt" />
<include name="tests/CMake/**/CMakeLists.txt.in" />
</fileset>
<fileset dir=".">
<include name="doc/**/*.h" />
<include name="doc/**/*.cpp" />
<include name="doc/**/Makefile" />
<include name="doc/**/*.md" />
<include name="doc/**/*.dox" />
<include name="doc/**/DoxyfileHTML" />
<include name="doc/**/DoxyfilePDF" />
<include name="doc/**/DoxyfilePDFH" />
<include name="doc/**/*.xml" />
<include name="doc/api/documentation.html" />
</fileset>
</copy>
<property name="build_dir" value="./build" />
<delete dir="${build_dir}" failonerror="false" />
<mkdir dir="${build_dir}" />
<copy todir="${build_dir}">
<fileset dir=".">
<include name="Makefile" />
<include name="readme.md" />
<include name="src/**/*.cpp" />
<include name="include/**/*.h" />
<include name="CMake/**/CMakeLists.txt" />
</fileset>
</copy>
</target>
<!-- Replace the version number and license info -->
<target name="replace_version" depends="create_build_dir">
<!-- Replace version for tests and reports -->
<replace file="${build_dir_tests}/doc/api/DoxyfileHTML" token="1.0.0" value='"${fullVersionReadable}"'/>
<replace file="${build_dir_tests}/doc/api/DoxyfilePDF" token="1.0.0" value='"${fullVersionReadable}"'/>
<replace file="${build_dir_tests}/doc/api/DoxyfilePDFH" token="1.0.0" value='"${fullVersionReadable}"'/>
<replace file="${build_dir_tests}/CMake/CMakeLists.txt" token="1.0.0" value='"${fullVersionReadable}"'/>
<replace dir="${build_dir_tests}" includes="*.rc,*.h,*.cpp" token="1.0.0" value="${fullVersionReadable}" />
<replace dir="${build_dir_tests}" includes="*.rc,*.h,*.cpp" token=""1.0.0"" value=""${fullVersionReadable}"" />
<replace dir="${build_dir_tests}" includes="*.rc,*.h,*.cpp" token="L"1.0.0"" value="L"${fullVersionReadable}"" />
<loadfile property="license" srcFile="license.txt" />
<replace dir="${build_dir_tests}" token="$license$" value="${license}" />
</target>
<!-- Build the library -->
<target name="build_library" depends="replace_version" description="Build the NDS3 library">
<exec executable="cmake" failonerror="true" dir="${build_dir_tests}/CMake">
<arg value="--verbose"/>
<arg value="-DCMAKE_BUILD_TYPE=Debug" />
<arg path="${build_dir_tests}/CMake"/>
</exec>
<exec executable="make" failonerror="true" dir="${build_dir_tests}/CMake" />
</target>
<!-- Build the test cases -->
<target name="build_test_cases" depends="replace_version, build_library" description="Build the NDS3 test cases">
<exec executable="cmake" failonerror="true" dir="${build_dir_tests}/tests/CMake">
<arg value="--verbose"/>
<arg path="${build_dir_tests}/tests/CMake"/>
<arg value="-DCMAKE_BUILD_TYPE=Debug" />
<arg value="-DADDITIONAL_INCLUDE=../../include" />
<arg value="-DLIBRARY_LOCATION=../../CMake" />
</exec>
<exec executable="make" failonerror="true" dir="${build_dir_tests}/tests/CMake" />
</target>
<target name="clear_coverage" depends="build_test_cases" if="coverage.set" description="Initializes the coverage data">
<exec executable="lcov" dir="${build_dir_tests}/CMake" resolveexecutable="true" failonerror="true">
<arg value="--zerocounters" />
<arg value="--directory" />
<arg path="${build_dir_tests}/CMake" />
</exec>
<exec executable="lcov" dir="${build_dir_tests}/CMake" resolveexecutable="true" failonerror="true">
<arg value="--capture" />
<arg value="--initial" />
<arg value="--directory" />
<arg path="${build_dir_tests}/CMake" />
<arg value="--output-file" />
<arg path="${build_dir_tests}/CMake/test.info" />
</exec>
</target>
<!-- Run the test cases -->
<target name="run_test_cases" depends="build_test_cases, clear_coverage" description="Run the test cases">
<exec executable="${build_dir_tests}/tests/CMake/nds3tests" dir="${build_dir_tests}/tests/CMake" resolveexecutable="true" failonerror="true" />
</target>
<target name="collect_coverage" depends="run_test_cases" if="coverage.set" description="Collect the coverage data">
<exec executable="lcov" dir="${build_dir_tests}/CMake" resolveexecutable="true" failonerror="true">
<arg value="--capture" />
<arg value="--no-checksum" />
<arg value="--directory" />
<arg path="${build_dir_tests}/CMake" />
<arg value="--output-file" />
<arg path="${build_dir_tests}/CMake/test.info" />
</exec>
<exec executable="genhtml" dir="${build_dir_tests}/CMake" resolveexecutable="true" failonerror="true">
<arg value="--output-directory" />
<arg path="${build_dir_tests}/CMake/coverage" />
<arg path="${build_dir_tests}/CMake/test.info" />
</exec>
</target>
<!-- Build the HTML documentation -->
<target name="HTML" depends="run_test_cases" description="Build the HTML documents">
<exec dir="${build_dir_tests}/doc/api" executable="doxygen" failonerror="true">
<arg value="DoxyfileHTML"/>
</exec>
<replace dir="${build_dir_tests}/doc/api/html" token="Related Pages" value="User manual"/>
<replace dir="${build_dir_tests}/doc/api/html" token="Main Page" value="Introduction"/>
<replace dir="${build_dir_tests}/doc/api/html" token="Related&#160;Pages" value="User&#160;manual"/>
<replace dir="${build_dir_tests}/doc/api/html" token="Main&#160;Page" value="Introduction"/>
</target>
<!-- Build the hyperlinked PDF documentation -->
<target name="PDFH" depends="run_test_cases" description="Build the PDFH documents">
<exec dir="${build_dir_tests}/doc/api" executable="doxygen" failonerror="true">
<arg value="DoxyfilePDFH"/>
</exec>
<exec dir="${build_dir_tests}/doc/api/hlatex" executable="make" failonerror="true" />
</target>
<!-- Build the printable PDF documentation -->
<target name="PDF" depends="run_test_cases" description="Build the PDF documents">
<exec dir="${build_dir_tests}/doc/api" executable="doxygen" failonerror="true">
<arg value="DoxyfilePDF"/>
</exec>
<exec dir="${build_dir_tests}/doc/api/latex" executable="make" failonerror="true" />
</target>
<!-- Copy the coverage report to the artifacts -->
<target name="artifacts_coverage" if="coverage.set" depends="collect_coverage">
<mkdir dir="${artifacts}/coverage_report" />
<copy todir="${artifacts}/coverage_report">
<fileset dir="${build_dir_tests}/CMake/coverage" />
</copy>
</target>
<!-- Copy the documentation to the artifacts -->
<target name="artifacts_documentation" depends="HTML, PDFH, PDF" >
<mkdir dir="${artifacts}/documentation/html" />
<copy todir="${artifacts}/documentation/html">
<fileset dir="${build_dir_tests}/doc/api/html" />
</copy>
<copy todir="${artifacts}/documentation">
<fileset file="${build_dir_tests}/doc/api/documentation.html" />
</copy>
<copy tofile="${artifacts}/documentation/nds3_hyperlinked.pdf" file="${build_dir_tests}/doc/api/hlatex/refman.pdf" />
<copy tofile="${artifacts}/documentation/nds3_print.pdf" file="${build_dir_tests}/doc/api/latex/refman.pdf" />
</target>
<!-- Copy the source to the artifacts -->
<target name="artifacts_source" depends="run_test_cases">
<mkdir dir="${artifacts}/sources" />
<copy todir="${artifacts}/sources">
<fileset dir="${build_dir}" />
</copy>
</target>
<target name="make_distribution" depends="artifacts_coverage, artifacts_documentation, artifacts_source">
</target>
</project>