-
Notifications
You must be signed in to change notification settings - Fork 5
/
build.xml
120 lines (101 loc) · 4.41 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
<?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"/>
<php returnProperty="metadata.version" expression="require 'METADATA-VERSION.php';" />
<property name="data.testCoreData" value="tests/core/data/"/>
<property name="data.coreData" value="src/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">
</target>
<target name="compile" description="Build all Data"
depends="cleanup-data,compile-test-data,build-phone-metadata,build-short-metadata,cs-fixer">
</target>
<target name="cleanup-test-data" description="Cleanup old built test data"
depends="delete-test-coredata"/>
<target name="cleanup-data" description="Cleanup built data"
depends="cleanup-test-data,delete-coredata"/>
<target name="delete-test-coredata">
<delete dir="${data.testCoreData}"/>
<mkdir dir="${data.testCoreData}"/>
</target>
<target name="delete-coredata">
<delete dir="src/data"/>
<mkdir dir="src/data"/>
</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-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="cs-fixer">
<exec executable="vendor/bin/php-cs-fixer" passthru="true">
<arg value="fix"/>
</exec>
</target>
</project>