2
# Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation. Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
26
# This must be the first rule
33
include JavaCompilation.gmk
36
################################################################################
37
# Generate interim versions of the module-info.java files for the interim
38
# langtools modules. Each interim module has ".interim" added as suffix to the
39
# original module name.
41
INTERIM_MODULEINFO_PATTERN := \
42
$(foreach m, $(INTERIM_LANGTOOLS_BASE_MODULES), -e 's/$m\([,; ]\)/$m.interim\1/g')
44
$(BUILDTOOLS_OUTPUTDIR)/gensrc/%.interim/module-info.java: \
45
$(TOPDIR)/src/%/share/classes/module-info.java
46
$(call LogInfo, Generating module-info.java for $*.interim)
47
$(call MakeDir, $(@D))
48
$(SED) $(INTERIM_MODULEINFO_PATTERN) $< > $@
50
TARGETS += $(patsubst %, $(BUILDTOOLS_OUTPUTDIR)/gensrc/%/module-info.java, \
51
$(INTERIM_LANGTOOLS_MODULES))
53
################################################################################
54
# Generate interim versions of the ToolProvider.java files for the interim
55
# langtools modules, which will allow to load javac from the interim
58
INTERIM_TOOL_PROVIDER_PATTERN := \
59
$(foreach m, $(INTERIM_LANGTOOLS_BASE_MODULES), -e 's/"$m"/"$m.interim"/g')
61
$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java: \
62
$(TOPDIR)/src/java.compiler/share/classes/javax/tools/ToolProvider.java
63
$(call LogInfo, Generating ToolProvider.java for java.compiler.interim)
64
$(call MakeDir, $(@D))
65
$(SED) $(INTERIM_TOOL_PROVIDER_PATTERN) $< > $@
67
java.compiler.interim_EXTRA_FILES := \
68
$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java
70
TARGETS += $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.compiler.interim/javax/tools/ToolProvider.java
72
################################################################################
73
# Use the up-to-date PreviewFeature.java and NoPreview.java from the current
74
# sources, instead of the versions from the boot JDK, as javac may be referring
75
# to constants from the up-to-date versions.
77
$(eval $(call SetupCopyFiles, COPY_PREVIEW_FEATURES, \
78
FILES := $(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/PreviewFeature.java \
79
$(TOPDIR)/src/java.base/share/classes/jdk/internal/javac/NoPreview.java, \
80
DEST := $(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim/jdk/internal/javac/, \
83
TARGETS += $(COPY_PREVIEW_FEATURES)
85
################################################################################
86
# Setup the rules to build interim langtools, which is compiled by the boot
87
# javac and can be run on the boot jdk. This will be used to compile the rest of
88
# the product. Each module is compiled separately because a multi module setup
89
# would require the source files to be copied into directories named after the
90
# actual interim modules.
92
# Param 1 - Name of module to compile
93
define SetupInterimModule
94
$$(eval $$(call SetupJavaCompilation, BUILD_$1.interim, \
95
COMPILER := bootjdk, \
96
TARGET_RELEASE := $$(TARGET_RELEASE_BOOTJDK), \
97
SRC := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim \
98
$$(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$1) \
99
$(TOPDIR)/src/$1/share/classes, \
100
EXCLUDES := sun javax/tools/snippet-files, \
101
EXCLUDE_FILES := $(TOPDIR)/src/$1/share/classes/module-info.java \
102
$(TOPDIR)/src/$1/share/classes/javax/tools/ToolProvider.java \
103
$(TOPDIR)/src/$1/share/classes/com/sun/tools/javac/launcher/Main.java \
104
$(TOPDIR)/src/$1/share/classes/com/sun/tools/javac/launcher/MemoryContext.java \
105
$(TOPDIR)/src/$1/share/classes/com/sun/tools/javac/launcher/MemoryModuleFinder.java \
106
$(TOPDIR)/src/$1/share/classes/com/sun/tools/javac/launcher/SourceLauncher.java \
108
EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java \
109
$($1.interim_EXTRA_FILES), \
110
COPY := .gif .png .xml .css .svg .js .js.template .txt .woff .woff2 javax.tools.JavaCompilerTool, \
111
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
112
DISABLED_WARNINGS := module options, \
114
--module-path $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules \
115
$$(INTERIM_LANGTOOLS_ADD_EXPORTS) \
116
--patch-module java.base=$(BUILDTOOLS_OUTPUTDIR)/gensrc/java.base.interim \
117
--add-exports java.base/jdk.internal.javac=java.compiler.interim \
118
--add-exports java.base/jdk.internal.javac=jdk.compiler.interim \
119
--add-exports jdk.internal.opt/jdk.internal.opt=jdk.compiler.interim \
120
--add-exports jdk.internal.opt/jdk.internal.opt=jdk.javadoc.interim, \
123
$1_DEPS_INTERIM := $$(addsuffix .interim, $$(filter \
124
$$(INTERIM_LANGTOOLS_BASE_MODULES), $$(call FindTransitiveDepsForModule, $1)))
126
$$(BUILD_$1.interim): $$(foreach d, $$($1_DEPS_INTERIM), $$(BUILD_$$d)) $(COPY_PREVIEW_FEATURES)
128
TARGETS += $$(BUILD_$1.interim)
131
$(foreach m, $(INTERIM_LANGTOOLS_BASE_MODULES), \
132
$(eval $(call SetupInterimModule,$m)) \
135
################################################################################
136
# Setup the compilation of the javac server build tool. Technically, this is not
137
# really "interim" langtools, but just like it, it is needed henceforth for all
138
# java compilation using the interim compiler.
139
$(eval $(call SetupJavaCompilation, BUILD_JAVAC_SERVER, \
140
COMPILER := bootjdk, \
141
TARGET_RELEASE := $(TARGET_RELEASE_BOOTJDK), \
142
SRC := $(TOPDIR)/make/langtools/tools, \
143
INCLUDES := javacserver, \
144
BIN := $(BUILDTOOLS_OUTPUTDIR)/langtools_javacserver_classes, \
147
TARGETS += $(BUILD_JAVAC_SERVER)
149
################################################################################