-
Notifications
You must be signed in to change notification settings - Fork 463
/
build.xml
223 lines (187 loc) · 8.4 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
<?xml version="1.0" encoding="UTF-8"?>
<project name="libphonenumber-for-php" default="test">
<property name="build.script" value="build/build.php"/>
<property name="git.url" value="https://github.com/google/libphonenumber.git"/>
<property name="git.path" value="libphonenumber-data-dir"/>
<loadfile property="metadata.version" file="METADATA-VERSION.txt">
<filterchain>
<striplinecomments>
<comment value="#" />
</striplinecomments>
<striplinebreaks />
</filterchain>
</loadfile>
<property name="data.testCoreData" value="tests/core/data/"/>
<property name="data.testPrefixMapperData" value="tests/prefixmapper/data/"/>
<property name="data.testCarrierData" value="tests/carrier/data/"/>
<property name="data.testTimezoneData" value="tests/timezone/data/"/>
<property name="data.coreData" value="src/data/"/>
<property name="data.carrierData" value="src/carrier/data/"/>
<property name="data.geocodingData" value="src/geocoding/data/"/>
<property name="data.timezoneData" value="src/timezone/data/"/>
<target name="test" description="Run unit tests" depends="compile-test-data">
<exec passthru="true" command="phpunit"/>
</target>
<target name="compile-test-data" description="Build Test Data"
depends="cleanup-test-data,build-test-metadata,build-geo-test-data,build-carrier-test-data,build-timezones-test-data">
</target>
<target name="compile" description="Build all Data"
depends="cleanup-data,compile-test-data,build-phone-metadata,build-short-metadata,build-alternate-metadata,build-carrier-data,build-timezones-data,build-geo-data">
</target>
<target name="cleanup-test-data" description="Cleanup old built test data"
depends="delete-test-carrierdata,delete-test-prefixmapper,delete-test-coredata,delete-test-timezone"/>
<target name="cleanup-data" description="Cleanup built data"
depends="cleanup-test-data,delete-coredata,delete-carrierdata,delete-geocoding,delete-timezone"/>
<target name="delete-test-coredata">
<delete dir="${data.testCoreData}"/>
<mkdir dir="${data.testCoreData}"/>
</target>
<target name="delete-test-carrierdata">
<delete dir="${data.testCarrierData}"/>
<mkdir dir="${data.testCarrierData}"/>
</target>
<target name="delete-test-prefixmapper">
<delete dir="${data.testPrefixMapperData}"/>
<mkdir dir="${data.testPrefixMapperData}"/>
</target>
<target name="delete-test-timezone">
<delete dir="${data.testTimezoneData}"/>
<mkdir dir="${data.testTimezoneData}"/>
</target>
<target name="delete-coredata">
<delete dir="src/data"/>
<mkdir dir="src/data"/>
</target>
<target name="delete-carrierdata">
<delete dir="${data.carrierData}"/>
<mkdir dir="${data.carrierData}"/>
</target>
<target name="delete-geocoding">
<delete dir="${data.geocodingData}"/>
<mkdir dir="${data.geocodingData}"/>
</target>
<target name="delete-timezone">
<delete dir="${data.timezoneData}"/>
<mkdir dir="${data.timezoneData}"/>
</target>
<target name="git-pull">
<available file="${git.path}" type="dir" property="git.path.exists" />
<if>
<or>
<not>
<isset property="git.path.exists" />
</not>
<isfalse value="${git.path.exists}"/>
</or>
<then>
<echo>Cloning repository</echo>
<gitclone
branch="master"
repository="${git.url}"
targetPath="${git.path}"/>
</then>
</if>
<gitfetch repository="${git.path}" all="true"/>
<echo message="Pulling Git project @ ${metadata.version}"/>
<gitcheckout
repository="${git.path}"
branchname="${metadata.version}" quiet="false" force="true" />
<foreach param="filename" absparam="absfilename" target="apply-data-patch">
<fileset dir="build/data-patches">
<include name="*.patch" />
</fileset>
</foreach>
</target>
<target name="apply-data-patch">
<echo>Applying patch ${filename}</echo>
<resolvepath propertyName="fullpath" file="${absfilename}"/>
<patch patchfile="${fullpath}" dir="${git.path}/" strip="1" haltonfailure="true" />
</target>
<target name="build-test-metadata" description="Build test Phone Metadata" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="BuildMetadataPHPFromXML"/>
<arg value="${git.path}/resources/PhoneNumberMetadataForTesting.xml"/>
<arg value="${data.testCoreData}"/>
<arg value="PhoneNumberMetadataForTesting"/>
<arg value="CountryCodeToRegionCodeMapForTesting"/>
<arg value="src/"/>
<arg value="false"/>
</exec>
</target>
<target name="build-geo-test-data" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="GeneratePhonePrefixData"/>
<arg value="${git.path}/resources/test/geocoding/"/>
<arg value="${data.testPrefixMapperData}"/>
</exec>
</target>
<target name="build-carrier-test-data" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="GeneratePhonePrefixData"/>
<arg value="${git.path}/resources/test/carrier/"/>
<arg value="${data.testCarrierData}"/>
</exec>
</target>
<target name="build-phone-metadata" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="BuildMetadataPHPFromXML"/>
<arg value="${git.path}/resources/PhoneNumberMetadata.xml"/>
<arg value="${data.coreData}"/>
<arg value="PhoneNumberMetadata"/>
<arg value="CountryCodeToRegionCodeMap"/>
<arg value="src/"/>
<arg value="false"/>
</exec>
</target>
<target name="build-short-metadata" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="BuildMetadataPHPFromXML"/>
<arg value="${git.path}/resources/ShortNumberMetadata.xml"/>
<arg value="${data.coreData}"/>
<arg value="ShortNumberMetadata"/>
<arg value="ShortNumbersRegionCodeSet"/>
<arg value="src/"/>
<arg value="false"/>
</exec>
</target>
<target name="build-alternate-metadata" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="BuildMetadataPHPFromXML"/>
<arg value="${git.path}/resources/PhoneNumberAlternateFormats.xml"/>
<arg value="${data.coreData}"/>
<arg value="PhoneNumberAlternateFormats"/>
<arg value="AlternateFormatsCountryCodeSet"/>
<arg value="src/"/>
<arg value="false"/>
</exec>
</target>
<target name="build-carrier-data" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="GeneratePhonePrefixData"/>
<arg value="${git.path}/resources/carrier/"/>
<arg value="${data.carrierData}"/>
</exec>
</target>
<target name="build-geo-data" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="GeneratePhonePrefixData"/>
<arg line="--expandCountries"/>
<arg value="${git.path}/resources/geocoding/"/>
<arg value="${data.geocodingData}"/>
</exec>
</target>
<target name="build-timezones-data" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="GenerateTimeZonesMapData"/>
<arg value="${git.path}/resources/timezones/map_data.txt"/>
<arg value="${data.timezoneData}"/>
</exec>
</target>
<target name="build-timezones-test-data" depends="git-pull">
<exec executable="${build.script}" passthru="true">
<arg value="GenerateTimeZonesMapData"/>
<arg value="${git.path}/resources/test/timezones/map_data.txt"/>
<arg value="${data.testTimezoneData}"/>
</exec>
</target>
</project>