forked from JetBrains/kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
270 lines (235 loc) · 10.3 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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<project name="Kotlin" default="dist">
<property name="output" value="${basedir}/dist"/>
<property name="kotlin-home" value="${output}/kotlinc"/>
<property name="build.number" value="snapshot"/>
<property name="output.name" value="kotlin-${build.number}"/>
<property name="idea.sdk" value="${basedir}/ideaSDK"/>
<import file="build-tools/build.xml" optional="false"/>
<path id="classpath">
<fileset dir="${idea.sdk}" includes="core/*.jar"/>
<fileset dir="${basedir}/lib" includes="*.jar"/>
<pathelement path="${output}/classes/runtime"/>
</path>
<path id="classpath.kotlin">
<path refid="classpath"/>
<pathelement path="${output}/classes/compiler"/>
</path>
<path id="sourcepath">
<dirset dir="${basedir}/compiler">
<include name="frontend/src"/>
<include name="frontend.java/src"/>
<include name="backend/src"/>
<include name="cli/src"/>
<include name="util/src"/>
<!--
<include name="jet.as.java.psi/src"/>
-->
</dirset>
</path>
<target name="init" depends="clean">
<mkdir dir="${kotlin-home}"/>
<mkdir dir="${kotlin-home}/lib"/>
<mkdir dir="${kotlin-home}/lib/alt"/>
</target>
<target name="compileRT" depends="init">
<mkdir dir="${output}/classes/runtime"/>
<javac destdir="${output}/classes/runtime" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false">
<src path="${basedir}/stdlib/src"/>
<classpath refid="classpath"/>
</javac>
</target>
<target name="compileStdlib" depends="jar">
<mkdir dir="${output}/classes/stdlib"/>
<java classname="org.jetbrains.jet.cli.KotlinCompiler" failonerror="true" fork="true">
<classpath>
<path refid="classpath"/>
<pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
<arg value="-src"/>
<arg value="${basedir}/stdlib/ktSrc"/>
<arg value="-output"/>
<arg value="${output}/classes/stdlib"/>
</java>
</target>
<target name="compileKunit" depends="jarRT">
<mkdir dir="${output}/classes/kunit"/>
<java classname="org.jetbrains.jet.cli.KotlinCompiler" failonerror="true" fork="true">
<classpath>
<path refid="classpath"/>
<pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
<arg value="-stdlib"/>
<arg value="${kotlin-home}/lib/kotlin-runtime.jar"/>
<arg value="-src"/>
<arg value="${basedir}/kunit/src/main/kotlin"/>
<arg value="-output"/>
<arg value="${output}/classes/kunit"/>
<arg value="-module"/>
<arg value="${basedir}/kunit/module.kt"/>
</java>
<jar destfile="${kotlin-home}/lib/kotlin-test.jar">
<fileset dir="${output}/classes/kunit"/>
</jar>
</target>
<target name="compileKdoc">
<mkdir dir="${output}/classes/kdoc"/>
<java classname="org.jetbrains.jet.cli.KotlinCompiler" failonerror="true" fork="true">
<classpath>
<path refid="classpath"/>
<pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
<arg value="-stdlib"/>
<arg value="${kotlin-home}/lib/kotlin-runtime.jar"/>
<arg value="-src"/>
<arg value="${basedir}/kdoc/src/main/kotlin"/>
<arg value="-output"/>
<arg value="${output}/classes/kdoc"/>
<arg value="-module"/>
<arg value="${basedir}/kdoc/module.kt"/>
</java>
<jar destfile="${kotlin-home}/lib/kotlin-doc.jar">
<fileset dir="${output}/classes/kdoc"/>
</jar>
</target>
<target name="docStdlib" depends="compileKdoc">
<mkdir dir="${output}/classes/stdlib"/>
<mkdir dir="${output}/apidoc/stdlib"/>
<java classname="org.jetbrains.jet.cli.KotlinCompiler" failonerror="true" fork="true">
<classpath>
<path refid="classpath"/>
<pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/>
<pathelement location="${output}/classes/kdoc"/>
<!--
lets use the local Ant build rather than the mvn build
<fileset dir="${basedir}/kdoc/target">
<include name="**/*.jar"/>
</fileset>
-->
<!-- TODO Dirty Hack until kdoc jar has stdlib inside it -->
<pathelement location="${output}/classes/stdlib"/>
</classpath>
<arg value="-src"/>
<arg value="${basedir}/stdlib/ktSrc"/>
<arg value="-output"/>
<arg value="${output}/classes/stdlib"/>
<arg value="-docOutput"/>
<arg value="${output}/apidoc/stdlib"/>
</java>
</target>
<target name="compileTestlib" depends="compileKunit">
<mkdir dir="${output}/classes/testlib"/>
<java classname="org.jetbrains.jet.cli.KotlinCompiler" failonerror="true" fork="true">
<classpath>
<path refid="classpath"/>
<pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
<arg value="-stdlib"/>
<arg value="${kotlin-home}/lib/kotlin-runtime.jar"/>
<arg value="-src"/>
<arg value="${basedir}/testlib/test"/>
<arg value="-output"/>
<arg value="${output}/classes/testlib"/>
<arg value="-module"/>
<arg value="${basedir}/testlib/module.kt"/>
</java>
</target>
<target name="generateStdlib" depends="compileTestlib" description="Generates the stdlib APIs for arrays and kotlin collections">
<java classname="kotlin.tools.namespace" failonerror="true" fork="true">
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-runtime.jar"/>
<pathelement location="${kotlin-home}/lib/kotlin-test.jar"/>
<pathelement location="${basedir}/testlib/lib/junit-4.9.jar"/>
<fileset dir="${basedir}/testlib/lib">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${output}/classes/testlib"/>
</classpath>
</java>
</target>
<target name="testlib" depends="compileTestlib">
<mkdir dir="${output}/test-reports"/>
<junit printsummary="yes" haltonfailure="true">
<classpath>
<pathelement location="${kotlin-home}/lib/kotlin-runtime.jar"/>
<pathelement location="${kotlin-home}/lib/kotlin-test.jar"/>
<pathelement location="${basedir}/testlib/lib/junit-4.9.jar"/>
<fileset dir="${basedir}/testlib/lib">
<include name="**/*.jar"/>
</fileset>
<pathelement path="${output}/classes/testlib"/>
</classpath>
<formatter type="plain"/>
<!--
<test name="my.test.TestCase" haltonfailure="no" outfile="result">
<formatter type="xml"/>
</test>
-->
<batchtest fork="yes" todir="${output}/test-reports" haltonerror="true">
<fileset dir="${output}/classes/testlib">
<include name="**/*Test.*"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="compileJDKHeaders" depends="jar">
<mkdir dir="${output}/classes/stdlib"/>
<java classname="org.jetbrains.jet.cli.KotlinCompiler" failonerror="true">
<classpath>
<path refid="classpath"/>
<pathelement location="${kotlin-home}/lib/kotlin-compiler.jar"/>
</classpath>
<arg value="-src"/>
<arg value="${basedir}/jdk-headers/src"/>
<arg value="-output"/>
<arg value="${output}/classes/jdk-headers"/>
<arg value="-stubs"/>
<arg value="-transformNamesToJava"/>
</java>
</target>
<target name="jarRT" depends="compile,copyKotlinJars,compileStdlib">
<jar destfile="${kotlin-home}/lib/kotlin-runtime.jar">
<fileset dir="${output}/classes/runtime"/>
<fileset dir="${output}/classes/stdlib"/>
</jar>
</target>
<target name="jarJDKHeaders" depends="compile,compileJDKHeaders">
<jar destfile="${kotlin-home}/lib/alt/kotlin-jdk-headers.jar">
<fileset dir="${output}/classes/jdk-headers"/>
</jar>
</target>
<target name="compile" depends="compileRT">
<mkdir dir="${output}/classes/compiler"/>
<javac destdir="${output}/classes/compiler" debug="true" debuglevel="lines,vars,source" includeAntRuntime="false">
<src refid="sourcepath"/>
<classpath refid="classpath"/>
</javac>
</target>
<target name="jar" depends="compile">
<jar destfile="${kotlin-home}/lib//kotlin-compiler.jar">
<fileset dir="${output}/classes/compiler"/>
<fileset dir="${basedir}/compiler/frontend/src" includes="jet/**"/>
</jar>
</target>
<target name="clean">
<delete dir="${output}"/>
</target>
<target name="copyKotlinJars">
<copy todir="${kotlin-home}/lib">
<fileset dir="${idea.sdk}/core" includes="*.jar"/>
<fileset dir="${basedir}/lib" includes="*.jar"/>
</copy>
</target>
<target name="dist" depends="init,jarRT,copyKotlinJars,jarJDKHeaders,jar,buildToolsJar,compileKunit,compileKdoc"/>
<target name="doc" depends="dist,docStdlib"/>
<target name="test" depends="dist,testlib" description="Creates the distribution and runs all the tests"/>
<target name="zip" depends="dist">
<echo file="${kotlin-home}/build.txt" message="${build.number}"/>
<zip destfile="${output}/${output.name}.zip">
<zipfileset prefix="kotlinc" dir="${kotlin-home}"/>
<zipfileset prefix="kotlinc" file="${output}/build.txt"/>
<zipfileset prefix="kotlinc/license" dir="${basedir}/license"/>
<zipfileset prefix="kotlinc/bin" filemode="755" dir="${basedir}/compiler/cli/bin"/>
<zipfileset prefix="kotlinc/examples" dir="${basedir}/examples/src"/>
</zip>
</target>
</project>