forked from PRTSToken/PRTSToken
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
237 lines (208 loc) · 7.54 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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!--
Build file for Protos Token Smart Contract.
Author: Mikhail Vladimirov <[email protected]>
-->
<project name="protos-token-smart-contract"
default="build">
<property file="build.properties" />
<!-- Source directories -->
<property name="source.dir" location="src" />
<property name="sol.source.dir" location="${source.dir}/sol" />
<property name="js.source.dir" location="${source.dir}/js" />
<property name="test.source.dir" location="src-test" />
<property name="sol.test.source.dir" location="${test.source.dir}/sol" />
<property name="js.test.source.dir" location="${test.source.dir}/js" />
<property name="common.js.test.source.dir"
location="${test.source.dir}/common-js" />
<!-- Docs directories -->
<property name="docs.dir" location="xdocs" />
<!-- Target directories -->
<property name="target.dir" location="target" />
<property name="solc.target.dir" location="${target.dir}/solc" />
<property name="js.deploy.target.dir" location="${target.dir}/deploy-js" />
<property name="solc.test.target.dir" location="${target.dir}/test-solc" />
<property name="js.solc.test.target.dir"
location="${target.dir}/test-solc-js" />
<!-- Geth data directories -->
<property name="data.dir" location="data" />
<!-- Name of the main contract -->
<property name="contract.name" value="ProtosToken" />
<!-- Targets -->
<target name="build" description="Build smart contract">
<mkdir dir="${solc.target.dir}" />
<pathconvert pathsep="' '" property="sources">
<map from="${basedir}" to="." />
<fileset dir="${sol.source.dir}">
<include name="*.sol" />
</fileset>
</pathconvert>
<exec executable="${solc}"
dir="${basedir}"
failonerror="true">
<arg value="--optimize" />
<arg value="--output-dir" />
<arg file="${solc.target.dir}" />
<arg value="--overwrite" />
<arg value="--bin" />
<arg value="--abi" />
<arg value="--userdoc" />
<arg value="--devdoc" />
<arg value="--metadata" />
<arg line="'${sources}'" />
</exec>
</target>
<target name="build-test" description="Build smart contract tests">
<mkdir dir="${solc.test.target.dir}" />
<pathconvert pathsep="' '" property="sources">
<map from="${basedir}" to="." />
<fileset dir="${sol.source.dir}">
<include name="*.sol" />
</fileset>
</pathconvert>
<pathconvert pathsep="' '" property="test.sources">
<map from="${basedir}" to="." />
<fileset dir="${sol.test.source.dir}">
<include name="*.sol" />
</fileset>
</pathconvert>
<exec executable="${solc}"
dir="${basedir}"
failonerror="true">
<arg value="--optimize" />
<arg value="--output-dir" />
<arg file="${solc.test.target.dir}" />
<arg value="--overwrite" />
<arg value="--bin" />
<arg value="--abi" />
<arg line="'${sources}'" />
<arg line="'${test.sources}'" />
</exec>
</target>
<target name="build-test-js" depends="build-test">
<mkdir dir="${js.solc.test.target.dir}" />
<copy toDir="${js.solc.test.target.dir}">
<fileset dir="${solc.test.target.dir}">
<include name="*.bin" />
</fileset>
<mapper type="glob" from="*.bin" to="*.bin.js" />
<filterchain>
<prefixlines prefix="var _ = '0x" />
<suffixlines suffix="';" />
</filterchain>
</copy>
<copy toDir="${js.solc.test.target.dir}">
<fileset dir="${solc.test.target.dir}">
<include name="*.abi" />
</fileset>
<mapper type="glob" from="*.abi" to="*.abi.js" />
<filterchain>
<striplinebreaks />
<prefixlines prefix="var _ = " />
<suffixlines suffix=";" />
</filterchain>
</copy>
</target>
<target name="build-deploy"
depends="build"
description="Build deploy scripts">
<mkdir dir="${js.deploy.target.dir}" />
<loadfile property="bin"
srcFile="${solc.target.dir}/${contract.name}.bin" />
<loadfile property="abi"
srcFile="${solc.target.dir}/${contract.name}.abi" />
<copy todir="${js.deploy.target.dir}">
<fileset dir="${js.source.dir}">
<include name="**/*Deploy.js" />
</fileset>
<filterchain>
<replacetokens>
<token key="BIN" value="${bin}"/>
<token key="ABI" value="${abi}"/>
</replacetokens>
</filterchain>
</copy>
</target>
<target name="package"
depends="build,build-deploy"
description="Package smart contract">
<tstamp>
<format property="version" pattern="yyyy-MM-dd" />
</tstamp>
<zip destfile="${ant.project.name}-${version}.zip" encoding="UTF-8">
<zipfileset dir="${sol.source.dir}"
prefix="${ant.project.name}-${version}/sol">
<include name="**/*.sol" />
</zipfileset>
<zipfileset dir="${solc.target.dir}"
prefix="${ant.project.name}-${version}/bin">
<include name="${contract.name}.bin" />
</zipfileset>
<zipfileset dir="${solc.target.dir}"
prefix="${ant.project.name}-${version}/abi">
<include name="${contract.name}.abi" />
</zipfileset>
<zipfileset dir="${docs.dir}" prefix="${ant.project.name}-${version}" />
<zipfileset dir="${solc.target.dir}"
prefix="${ant.project.name}-${version}/doc">
<include name="${contract.name}.docuser" />
</zipfileset>
<zipfileset dir="${solc.target.dir}"
prefix="${ant.project.name}-${version}/doc">
<include name="${contract.name}.docdev" />
</zipfileset>
<zipfileset dir="${solc.target.dir}"
prefix="${ant.project.name}-${version}">
<include name="${contract.name}_meta.json" />
</zipfileset>
<zipfileset dir="${js.deploy.target.dir}"
prefix="${ant.project.name}-${version}">
<include name="**/*.js" />
</zipfileset>
</zip>
</target>
<target name="deploy"
depends="build-deploy"
description="Deploy smart contract">
<pathconvert pathsep="' '" property="deploy.scripts">
<fileset dir="${js.deploy.target.dir}">
<include name="**/*.js" />
</fileset>
</pathconvert>
<exec executable="${geth}">
<arg line="${geth.deploy.args}" />
<arg value="js" />
<arg line="'${deploy.scripts}'" />
</exec>
</target>
<target name="test" depends="build-test-js" description="Test smart contract">
<mkdir dir="${data.dir}" />
<pathconvert pathsep="' '" property="tests">
<fileset dir="${js.test.source.dir}">
<include name="*Test.js" />
</fileset>
</pathconvert>
<exec executable="${geth}">
<arg value="--dev" />
<arg value="--datadir" />
<arg file="${data.dir}" />
<arg line="${geth.test.args}" />
<arg value="--verbosity" />
<arg value="0" />
<arg value="js" />
<arg file="${common.js.test.source.dir}/TestCommons.js" />
<arg line="'${tests}'" />
<arg file="${common.js.test.source.dir}/TestRunner.js" />
<redirector outputproperty="output" alwayslog="true" />
</exec>
<condition property="success">
<contains string="${output}" substring="SUCCESS" />
</condition>
<fail unless="success" />
</target>
<target name="clean" description="Delete generated files">
<delete dir="${target.dir}" />
</target>
<target name="clean-data" description="Delete geth data dir">
<delete dir="${data.dir}" />
</target>
</project>