• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version="1.0" ?>
2
3<project name="libphonenumber-javascript" default="compile">
4  <property name="closure-compiler.dir"
5            value="${basedir}/../../closure-compiler" />
6  <property name="closure-compiler.jar"
7            value="${closure-compiler.dir}/bazel-bin/compiler_unshaded_deploy.jar" />
8  <property name="closure-library.dir"
9            value="${basedir}/../../closure-library" />
10  <property name="closure-linter.dir"
11            value="${basedir}/../../closure-linter" />
12  <property name="python-gflags.dir"
13            value="${basedir}/../../python-gflags" />
14
15  <macrodef name="closure-compile">
16    <attribute name="entrypoint" />
17    <attribute name="outputfile" />
18    <attribute name="compilationlevel" default="ADVANCED_OPTIMIZATIONS" />
19    <attribute name="outputwrapper" default="(function(){%output%})();" />
20    <element name="extraflags" optional="yes" />
21    <sequential>
22      <exec executable="java" failonerror="true" logError="true">
23        <arg value="-jar" />
24        <arg value="${closure-compiler.jar}" />
25        <arg line='--entry_point="@{entrypoint}"' />
26        <arg line='--js_output_file="@{outputfile}"' />
27        <arg line='--js="${closure-library.dir}/closure/goog/**.js"' />
28        <arg line='--js="${closure-library.dir}/third_party/closure/goog/**.js"' />
29        <arg line="--output_wrapper=@{outputwrapper}" />
30        <arg line="--compilation_level=@{compilationlevel}" />
31        <arg line="--warning_level=VERBOSE" />
32        <arg line="--jscomp_error=accessControls" />
33        <arg line="--jscomp_error=checkDebuggerStatement" />
34        <arg line="--jscomp_error=checkRegExp" />
35        <arg line="--jscomp_error=checkTypes" />
36        <arg line="--jscomp_error=checkVars" />
37        <arg line="--jscomp_error=const" />
38        <arg line="--jscomp_error=constantProperty" />
39        <arg line="--jscomp_error=duplicate" />
40        <arg line="--jscomp_error=duplicateMessage" />
41        <arg line="--jscomp_error=es5Strict" />
42        <arg line="--jscomp_error=externsValidation" />
43        <arg line="--jscomp_error=extraRequire" />
44        <arg line="--jscomp_error=globalThis" />
45        <arg line="--jscomp_error=invalidCasts" />
46        <arg line="--jscomp_error=misplacedTypeAnnotation" />
47        <arg line="--jscomp_error=missingProperties" />
48        <arg line="--jscomp_error=missingRequire" />
49        <arg line="--jscomp_error=nonStandardJsDocs" />
50        <arg line="--jscomp_error=strictModuleDepCheck" />
51        <arg line="--jscomp_error=suspiciousCode" />
52        <arg line="--jscomp_error=typeInvalidation" />
53        <arg line="--jscomp_error=undefinedNames" />
54        <arg line="--jscomp_error=undefinedVars" />
55        <arg line="--jscomp_error=unknownDefines" />
56        <arg line="--jscomp_error=uselessCode" />
57        <arg line="--jscomp_error=visibility" />
58        <extraflags />
59      </exec>
60    </sequential>
61  </macrodef>
62
63  <macrodef name="gjslint">
64    <attribute name="inputfile" />
65    <sequential>
66      <exec executable="python" failonerror="false" logError="true">
67        <env key="PYTHONPATH"
68             value="${closure-linter.dir}:${python-gflags.dir}"/>
69        <arg value="${closure-linter.dir}/closure_linter/gjslint.py" />
70        <arg line='--strict' />
71        <arg line='"@{inputfile}"' />
72      </exec>
73    </sequential>
74  </macrodef>
75
76  <condition property="os.iswindows">
77    <os family="windows" />
78  </condition>
79  <condition property="os.isunix">
80    <os family="unix" />
81  </condition>
82  <target name="nul" if="os.iswindows">
83    <property name="null.device" value="NUL" />
84  </target>
85  <target name="devnull" if="os.isunix">
86    <property name="null.device" value="/dev/null" />
87  </target>
88  <target name="setnulldevice" depends="nul,devnull" />
89
90  <target name="clean" description="deletes all generated files">
91    <delete file="i18n/phonenumbers/demo-compiled.js" />
92  </target>
93
94  <target name="compile-demo"
95          description="generates demo-compiled.js">
96    <closure-compile entrypoint="goog:i18n.phonenumbers.demo"
97                     outputfile="i18n/phonenumbers/demo-compiled.js">
98      <extraflags>
99        <arg line='--js="i18n/phonenumbers/**.js"' />
100        <arg line='--js="!i18n/phonenumbers/demo-compiled.js"' />
101        <arg line='--js="!i18n/phonenumbers/metadatafortesting.js"' />
102        <arg line='--js="!i18n/phonenumbers/metadatalite.js"' />
103        <arg line='--js="!i18n/phonenumbers/regioncodefortesting.js"' />
104      </extraflags>
105    </closure-compile>
106  </target>
107
108  <target name="compile-tests" depends="setnulldevice">
109    <closure-compile entrypoint="goog:i18n.phonenumbers.AsYouTypeFormatterTest"
110                     outputfile="${null.device}">
111      <extraflags>
112        <arg line='--js="i18n/phonenumbers/**.js"' />
113        <arg line='--js="!i18n/phonenumbers/demo-compiled.js"' />
114        <arg line='--js="!i18n/phonenumbers/metadata.js"' />
115        <arg line='--js="!i18n/phonenumbers/metadatalite.js"' />
116      </extraflags>
117    </closure-compile>
118    <closure-compile entrypoint="goog:i18n.phonenumbers.PhoneNumberUtilTest"
119                     outputfile="${null.device}">
120      <extraflags>
121        <arg line='--js="i18n/phonenumbers/**.js"' />
122        <arg line='--js="!i18n/phonenumbers/demo-compiled.js"' />
123        <arg line='--js="!i18n/phonenumbers/metadata.js"' />
124        <arg line='--js="!i18n/phonenumbers/metadatalite.js"' />
125      </extraflags>
126    </closure-compile>
127    <closure-compile entrypoint="goog:i18n.phonenumbers.ShortNumberInfoTest"
128                     outputfile="${null.device}">
129      <extraflags>
130        <arg line='--js="i18n/phonenumbers/**.js"' />
131        <arg line='--js="!i18n/phonenumbers/demo-compiled.js"' />
132        <arg line='--js="!i18n/phonenumbers/metadata.js"' />
133        <arg line='--js="!i18n/phonenumbers/metadatalite.js"' />
134      </extraflags>
135    </closure-compile>
136  </target>
137
138  <target name="compile" depends="compile-demo,compile-tests" />
139
140  <target name="lint" description="lints all javascript files">
141    <gjslint inputfile="i18n/phonenumbers/asyoutypeformatter*.js" />
142    <gjslint inputfile="i18n/phonenumbers/demo.js" />
143    <gjslint inputfile="i18n/phonenumbers/phonenumberutil*.js" />
144    <gjslint inputfile="i18n/phonenumbers/shortnumberinfo*.js" />
145  </target>
146
147</project>
148