jdk

Форк
0
/
build.xml 
388 строк · 17.2 Кб
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
  ~ Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved.
4
  ~ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
  ~
6
  ~ This code is free software; you can redistribute it and/or modify it
7
  ~ under the terms of the GNU General Public License version 2 only, as
8
  ~ published by the Free Software Foundation.  Oracle designates this
9
  ~ particular file as subject to the "Classpath" exception as provided
10
  ~ by Oracle in the LICENSE file that accompanied this code.
11
  ~
12
  ~ This code is distributed in the hope that it will be useful, but WITHOUT
13
  ~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
  ~ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15
  ~ version 2 for more details (a copy is included in the LICENSE file that
16
  ~ accompanied this code).
17
  ~
18
  ~ You should have received a copy of the GNU General Public License version
19
  ~ 2 along with this work; if not, write to the Free Software Foundation,
20
  ~ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
  ~
22
  ~ Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23
  ~ or visit www.oracle.com if you need additional information or have any
24
  ~ questions.
25
  -->
26

27
<!--
28
 This is a convenience build file supporting development in the langtools
29
 repository. It can be run either standalone, or from IDEs. This build script
30
 is for a developer use only, it is not used to build the production version
31
 of javac or other langtools tools.
32

33
 External dependencies are specified via properties. These can be given
34
 on the command line, or by providing a local build.properties file.
35
 (They can also be edited into make/build.properties, although that is not
36
 recommended.)  At a minimum, langtools.jdk.home must be set to the installed
37
 location of the version of JDK used to build this repository. Additional
38
 properties may be required, depending on the targets that are built.
39
 For example, to run any of the jtreg tests you must set jtreg.home.
40

41
 The output of the build is as follows:
42

43
 build
44
   |-bin (scripts to invoke various tools, javac etc.)
45
   |-gensrc (generated sources - i.e. properties)
46
   |-modules (compiled classes in a modular layout)
47
   |-jtreg (test work/results)
48
   |-toolclasses (tools used for building - like the property compiler)
49

50
 This file is organized into sections as follows:
51
 - global property definitions
52
 - primary top level targets (cleaning, building)
53
 - utility definitions
54
 -->
55

56
<project name="langtools" default="build" basedir="../..">
57
    <!--
58
    **** Global property definitions.
59
    -->
60

61
    <!-- The following locations can be used to override default property values. -->
62

63
    <!-- Use this location for customizations specific to this instance of this workspace -->
64
    <property file="make/langtools/build.properties"/>
65

66
    <!-- Use this location for customizations common to all OpenJDK langtools workspaces -->
67
    <property file="${user.home}/.openjdk/${ant.project.name}-build.properties"/>
68

69
    <!-- Use this location for customizations common to all OpenJDK workspaces -->
70
    <property file="${user.home}/.openjdk/build.properties"/>
71

72
    <!-- Convenient shorthands for standard locations within the workspace. -->
73
    <property name="src.dir" location="src"/>
74
    <property name="test.dir" location="test"/>
75
    <property name="make.dir" location="make/langtools"/>
76
    <property name="make.idea.dir" location="make/ide/idea/langtools"/>
77
    <property name="make.conf.dir" location="${make.dir}/conf"/>
78
    <property name="make.tools.dir" location="${make.dir}/tools"/>
79
    <property name="build.dir" location="build/langtools"/>
80
    <property name="build.modules" location="${build.dir}/modules"/>
81
    <property name="build.gensrc" location="${build.dir}/gensrc"/>
82
    <property name="build.tools" location="${build.dir}/toolclasses"/>
83
    <property name="build.bin" location="${build.dir}/bin"/>
84
    <property name="build.jtreg" location="${build.dir}/jtreg"/>
85
    <property name="build.prevsrc" location="${build.dir}/prevsrc"/>
86

87
    <dirset id="src.module.dirset" dir="${src.dir}" includes="${module.names}"/>
88

89
    <pathconvert pathsep="," property="src.module.dirs" refid="src.module.dirset"/>
90

91
    <pathconvert property="xpatch.rest" pathsep=" --patch-module=" refid="src.module.dirset">
92
        <regexpmapper from="^.*(/|\\)([^/\\]*)$" to='\2="${build.modules}\1\2"' />
93
    </pathconvert>
94

95
    <pathconvert property="xpatch.noquotes.rest" pathsep=" --patch-module=" refid="src.module.dirset">
96
        <regexpmapper from="^([^/\\]*)(/|\\).*" to="\1=${build.modules}\2\1" />
97
    </pathconvert>
98

99
    <property name="xpatch.cmd" value="--patch-module=${xpatch.rest}"/>
100
    <property name="xpatch.noquotes.cmd" value="--patch-module=${xpatch.noquotes.rest}"/>
101

102
    <!-- java.marker is set to a marker file to check for within a Java install dir.
103
         The best file to check for across Linux/Windows/MacOS is one of the
104
         executables; regrettably, that is OS-specific. -->
105
    <condition property="java.marker" value="bin/java">
106
        <os family="unix"/>
107
    </condition>
108
    <condition property="java.marker" value="bin/java.exe">
109
        <os family="windows"/>
110
    </condition>
111

112
    <!-- Standard property values, if not overridden by earlier settings. -->
113
    <property file="${make.dir}/build.properties"/>
114

115
    <condition property="langtools.jdk.home" value="${jdk.home}">
116
        <isset property="jdk.home" />
117
    </condition>
118

119
    <!-- launcher.java is used in the launcher scripts provided to run
120
        the tools' jar files.  If it has not already been set, then
121
        default it to use ${langtools.jdk.home}, if available, otherwise
122
        quietly default to simply use "java". -->
123
    <condition property="launcher.java"
124
        value="${langtools.jdk.home}/bin/java" else="java">
125
        <isset property="langtools.jdk.home"/>
126
    </condition>
127

128
    <!--
129
        **** Check targets
130
    -->
131

132
    <target name="-def-check">
133
      <macrodef name="check">
134
          <attribute name="name"/>
135
          <attribute name="property"/>
136
          <attribute name="marker" default=""/>
137
            <sequential>
138
                <fail message="Cannot locate @{name}: please set @{property} to its location">
139
                    <condition>
140
                        <not>
141
                            <isset property="@{property}"/>
142
                        </not>
143
                    </condition>
144
                </fail>
145
                <fail message="@{name} is not installed in ${@{property}}">
146
                    <condition>
147
                        <and>
148
                            <not>
149
                                <equals arg1="@{marker}" arg2=""/>
150
                            </not>
151
                            <not>
152
                                <available file="${@{property}}/@{marker}"/>
153
                            </not>
154
                        </and>
155
                    </condition>
156
                </fail>
157
            </sequential>
158
        </macrodef>
159
    </target>
160

161
    <target name="-check-langtools.jdk.home" depends="-def-check">
162
        <check name="target java" property="langtools.jdk.home" marker="${java.marker}"/>
163
    </target>
164

165
    <target name="-check-jtreg.home" depends="-def-check">
166
        <check name="jtreg" property="jtreg.home" marker="lib/jtreg.jar"/>
167
    </target>
168

169
    <!--
170
        **** Primary targets
171
    -->
172

173
    <target name="clean" description="Delete all generated files">
174
        <delete dir="${build.dir}"/>
175
    </target>
176

177
    <target name="build" depends="build-all-tools"/>
178

179
    <target name="-prepare-build" depends="-check-langtools.jdk.home">
180
        <mkdir dir="${build.modules}"/>
181
        <mkdir dir="${build.tools}"/>
182
        <mkdir dir="${build.gensrc}"/>
183
        <mkdir dir="${build.bin}"/>
184
        <mkdir dir="${build.prevsrc}"/>
185
    </target>
186

187
    <target name="generate-sources-internal">
188
        <basename property="module.name" file="${basedir}"/>
189
        <mkdir dir="${build.gensrc}/${module.name}"/>
190
        <pparse destdir="${build.gensrc}/${module.name}" includes="${langtools.resource.includes}">
191
            <src path="./share/classes"/>
192
        </pparse>
193
        <pcompile destdir="${build.gensrc}/${module.name}" includes="**/*.properties">
194
            <src path="./share/classes"/>
195
        </pcompile>
196
    </target>
197

198
    <target name="generate-sources"  depends="-prepare-build,-def-pparse,-def-pcompile">
199
        <subant inheritall="true" target="generate-sources-internal" genericantfile="${make.dir}/build.xml">
200
              <dirset refid="src.module.dirset"/>
201
        </subant>
202
    </target>
203

204
    <target name="build-all-classes" depends="generate-sources">
205
        <pathconvert property="xpatch.src.rest" pathsep=" --patch-module=" refid="src.module.dirset">
206
            <regexpmapper from="^.*(/|\\)([^/\\]*)$" to="\2=${src.dir}\1\2/share/classes${path.separator}${build.gensrc}\1\2" />
207
        </pathconvert>
208
        <property name="xpatch.src.cmd" value="--patch-module=${xpatch.src.rest}"/>
209
        <pathconvert pathsep="," property="gensrc.module.dirs">
210
            <dirset dir="${build.gensrc}" includes="${module.names}"/>
211
        </pathconvert>
212
        <multirootfileset id="source.fileset" basedirs="${src.module.dirs},${gensrc.module.dirs}">
213
            <include name="**/*.java"/>
214
            <different targetdir="${build.prevsrc}" ignoreFileTimes="true"/>
215
        </multirootfileset>
216
        <pathconvert pathsep=" " property="source.files" refid="source.fileset"/>
217
        <echo file="${build.dir}/sources.txt">${source.files}</echo>
218
        <exec executable="${langtools.jdk.home}/bin/javac" failonerror="true">
219
            <arg value="-d" />
220
            <arg value="${build.modules}" />
221
            <arg line="${javac.opts}" />
222
            <arg line="${xpatch.src.cmd}" />
223
            <arg line="--module-source-path ." />
224
            <arg line="@${build.dir}/sources.txt" />
225
        </exec>
226
        <delete file="${build.dir}/sources.txt"/>
227
        <delete>
228
            <fileset dir="${build.modules}" includes="**/module-info.class"/>
229
        </delete>
230
        <!-- workaround for incremental compilation -->
231
        <copy todir="${build.prevsrc}" >
232
            <multirootfileset refid="source.fileset"/>
233
        </copy>
234
    </target>
235

236
    <target name="build-all-tools" depends="build-all-classes, -def-build-tool">
237
        <build-tool name="javac"/>
238
        <build-tool name="javadoc"/>
239
        <build-tool name="javap"/>
240
        <build-tool name="jdeps"/>
241
        <build-tool name="jshell"/>
242
    </target>
243

244
    <target name="jtreg" depends="build-all-tools,-def-jtreg">
245
        <jtreg-tool name="all" tests="${jtreg.tests}"/>
246
    </target>
247

248
    <!--
249
    **** IDE support
250
    -->
251

252
    <target name="idea" depends="-check-langtools.jdk.home">
253
        <mkdir dir=".idea"/>
254
        <copy todir=".idea" >
255
            <fileset dir="${make.idea.dir}/template">
256
               <exclude name="**/src/**"/>
257
               <exclude name="**/utils/**"/>
258
            </fileset>
259
        </copy>
260
        <condition property="idea.jtreg.home" value="${jtreg.home}" else = "[jtreg.home]">
261
            <isset property="jtreg.home"/>
262
        </condition>
263
        <condition property="idea.target.jdk" value="${langtools.jdk.home}" else = "$JDKPath$">
264
            <isset property="langtools.jdk.home"/>
265
        </condition>
266
        <replace file=".idea/ant.xml" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
267
        <replace dir=".idea/runConfigurations" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
268
        <replace dir=".idea/runConfigurations" token="@XPATCH@" value="${xpatch.cmd}"/>
269
        <replace file=".idea/misc.xml" token="@IDEA_JTREG_HOME@" value="${idea.jtreg.home}"/>
270
        <replace file=".idea/misc.xml" token="@IDEA_TARGET_JDK@" value="${idea.target.jdk}"/>
271
        <replace file=".idea/misc.xml" token="@XPATCH@" value="${xpatch.cmd}"/>
272
        <mkdir dir=".idea/classes"/>
273
        <javac source="${javac.build.source}"
274
               target="${javac.build.target}"
275
               srcdir="${make.idea.dir}/template/src"
276
               destdir=".idea/classes"/>
277
    </target>
278

279
    <!--
280
        **** Utility definitions
281
    -->
282

283
    <target name="-def-pparse">
284
        <copy todir="${build.tools}/propertiesparser" >
285
            <fileset dir="${make.tools.dir}/propertiesparser" includes="**/resources/**"/>
286
        </copy>
287
        <javac source="${javac.build.source}"
288
               target="${javac.build.target}"
289
               srcdir="${make.tools.dir}"
290
               includes="propertiesparser/* anttasks/PropertiesParser* anttasks/PathFileSet*"
291
               destdir="${build.tools}"
292
               classpath="${ant.core.lib}"
293
               bootclasspath="${langtools.jdk.home}/jre/lib/rt.jar"
294
               includeantruntime="false">
295
            <compilerarg line="${javac.build.opts} -XDstringConcat=inline"/>
296
        </javac>
297
        <taskdef name="pparse"
298
                 classname="anttasks.PropertiesParserTask"
299
                 classpath="${build.tools}"/>
300
    </target>
301

302
     <target name="-def-pcompile">
303
        <javac
304
               source="${javac.build.source}"
305
               target="${javac.build.target}"
306
               srcdir="${make.tools.dir}"
307
               includes="compileproperties/* anttasks/CompileProperties* anttasks/PathFileSet*"
308
               destdir="${build.dir}/toolclasses/"
309
               classpath="${ant.core.lib}"
310
               includeantruntime="false">
311
            <compilerarg line="${javac.build.opts} -XDstringConcat=inline"/>
312
        </javac>
313
        <taskdef name="pcompile"
314
                 classname="anttasks.CompilePropertiesTask"
315
                 classpath="${build.tools}"/>
316
    </target>
317

318
    <target name="-def-build-tool">
319
        <macrodef name="build-tool">
320
            <attribute name="name"/>
321
            <attribute name="compilation.kind" default=""/>
322
            <attribute name="bin.dir" default="${build.bin}"/>
323
            <attribute name="java" default="${launcher.java}"/>
324
            <attribute name="main.class" default="${tool.@{name}.main.class}"/>
325
            <attribute name="xpatch" default="${xpatch.cmd}"/>
326
            <sequential>
327
                <mkdir dir="@{bin.dir}"/>
328
                <copy file="${make.dir}/launcher.sh-template" tofile="@{bin.dir}/@{name}">
329
                    <filterset begintoken="#" endtoken="#">
330
                        <filter token="PROGRAM" value="@{main.class}"/>
331
                        <filter token="TARGET_JAVA" value="@{java}"/>
332
                        <filter token="PS" value="${path.separator}"/>
333
                        <filter token="XPATCH" value="${xpatch.cmd}"/>
334
                    </filterset>
335
                </copy>
336
                <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
337
            </sequential>
338
        </macrodef>
339
    </target>
340

341
    <target name="-def-jtreg" unless="jtreg.defined" depends="-check-jtreg.home,-check-langtools.jdk.home">
342
        <taskdef name="jtreg" classname="com.sun.javatest.regtest.Main$$Ant">
343
            <classpath>
344
                <pathelement location="${jtreg.home}/lib/jtreg.jar"/>
345
                <pathelement location="${jtreg.home}/lib/javatest.jar"/>
346
            </classpath>
347
        </taskdef>
348
        <macrodef name="jtreg-tool">
349
            <attribute name="name"/>
350
            <attribute name="tests"/>
351
            <attribute name="jdk" default="${langtools.jdk.home}"/>
352
            <attribute name="agentvm" default="true"/>
353
            <attribute name="verbose" default="${default.jtreg.verbose}"/>
354
            <attribute name="options" default="${other.jtreg.options}"/>
355
            <attribute name="ignore" default="-keywords:!ignore -exclude:${test.dir}/ProblemList.txt"/>
356
            <attribute name="jpda.jvmargs" default=""/>
357
            <attribute name="extra.jvmargs" default=""/>
358
            <attribute name="build.modules" default="${build.modules}"/>
359
            <sequential>
360
                <property name="coverage.options" value=""/>              <!-- default -->
361
                <property name="coverage.classpath" value=""/>            <!-- default -->
362
                <property name="default.jtreg.verbose" value="summary"/>  <!-- default -->
363
                <property name="other.jtreg.options" value=""/>           <!-- default -->
364
                <property name="jtreg.classfiles.to.modules" value="@{agentvm}"/>
365
                <jtreg
366
                    dir="${test.dir}"
367
                    workDir="${build.jtreg}/@{name}/work"
368
                    reportDir="${build.jtreg}/@{name}/report"
369
                    jdk="@{jdk}"
370
                    agentvm="@{agentvm}" verbose="@{verbose}"
371
                    failonerror="false" resultproperty="jtreg.@{name}.result"
372
                    vmoptions="${coverage.options} @{extra.jvmargs} ${xpatch.noquotes.cmd}">
373
                    <arg value="-debug:@{jpda.jvmargs}"/>
374
                    <arg line="@{ignore}"/>
375
                    <arg line="@{options}"/>
376
                    <arg line="@{tests}"/>
377
                </jtreg>
378
                <!-- the next two properties are for convenience, when only
379
                     a single instance of jtreg will be invoked. -->
380
                <condition property="jtreg.passed">
381
                    <equals arg1="${jtreg.@{name}.result}" arg2="0"/>
382
                </condition>
383
                <property name="jtreg.report" value="${build.jtreg}/@{name}/report"/>
384
            </sequential>
385
        </macrodef>
386
        <property name="jtreg.defined" value="true"/>
387
    </target>
388
</project>
389

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.