2
# Copyright (c) 2011, 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
ifndef _JAVA_COMPILATION_GMK
27
_JAVA_COMPILATION_GMK := 1
29
ifeq (,$(_MAKEBASE_GMK))
30
$(error You must include MakeBase.gmk prior to including JavaCompilation.gmk)
35
# Java compilation needs SetupJarArchive and/or SetupZipArchive, if we're
36
# generating a jar file or a source zip.
41
### Definitions for common release targets
44
# Create classes that can run on the bootjdk
45
TARGET_RELEASE_BOOTJDK := $(BOOT_JDK_SOURCETARGET)
47
# Create classes that can be used in (or be a part of) the new jdk we're building
48
TARGET_RELEASE_NEWJDK := -source $(JDK_SOURCE_TARGET_VERSION) -target $(JDK_SOURCE_TARGET_VERSION)
50
# Create classes that can be used in JDK 8, for legacy support
51
TARGET_RELEASE_JDK8 := --release 8
53
# Create classes for the new jdk, relying only on the modules of the new jdk
54
TARGET_RELEASE_NEWJDK_UPGRADED := $(TARGET_RELEASE_NEWJDK) \
55
--upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none
57
define add_file_to_copy
58
# param 1 = BUILD_MYPACKAGE
59
# parma 2 = The source file to copy.
61
# Remove the source prefix.
62
$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
63
# To allow for automatic overrides, do not create a rule for a target file that
65
ifneq ($$($1_COPY_$$($2_TARGET)), 1)
66
$1_COPY_$$($2_TARGET) := 1
67
# Now we can setup the dependency that will trigger the copying.
68
$$($1_BIN)$$($1_MODULE_SUBDIR)$$($2_TARGET) : $2
69
$$(call LogInfo, Copying $$(patsubst $$(OUTPUTDIR)/%,%, $$@))
73
# And do not forget this target
74
$1_ALL_COPY_TARGETS += $$($1_BIN)$$($1_MODULE_SUBDIR)$$($2_TARGET)
78
# This macro is used only for properties files that are to be
79
# copied over to the classes directory in cleaned form.
81
# An empty echo ensures that the input to sed always ends with a newline.
82
# Certain implementations (e.g. Solaris) will skip the last line without
85
# The sed expression does this:
86
# 1. Add a backslash before any :, = or ! that do not have a backslash already.
87
# 2. Apply the file unicode2x.sed which does a whole bunch of \u00XX to \xXX
89
# 3. Delete all lines starting with #.
90
# 4. Delete empty lines.
91
# 5. Append lines ending with \ with the next line.
92
# 6. Remove leading and trailing white space. Note that tabs must be explicit
93
# as sed on macosx does not understand '\t'.
94
# 7. Replace the first \= with just =.
95
# 8. Finally it's all sorted to create a stable output.
97
# It is assumed that = is the character used for separating names and values.
98
define add_file_to_clean
99
# param 1 = BUILD_MYPACKAGE
100
# parma 2 = The source file to copy and clean.
102
# Remove the source prefix.
103
$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
104
# Now we can setup the dependency that will trigger the copying.
105
# To allow for automatic overrides, do not create a rule for a target file that
107
ifneq ($$($1_CLEAN_$$($2_TARGET)), 1)
108
$1_CLEAN_$$($2_TARGET) := 1
109
$$($1_BIN)$$($1_MODULE_SUBDIR)$$($2_TARGET) : $2
110
$$(call LogInfo, Cleaning $$(patsubst $$(OUTPUTDIR)/%,%, $$@))
111
$$(call MakeTargetDir)
112
( $(CAT) $$< && $(ECHO) "" ) \
113
| $(SED) -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' \
114
-e 's/\([^\\]\)!/\1\\!/g' -e 's/^[ ]*#.*/#/g' \
115
| $(SED) -f "$$(TOPDIR)/make/common/support/unicode2x.sed" \
116
| $(SED) -e '/^#/d' -e '/^$$$$/d' \
117
-e :a -e '/\\$$$$/N; s/\\\n//; ta' \
118
-e 's/^[ ]*//;s/[ ]*$$$$//' \
123
# And do not forget this target
124
$1_ALL_COPY_CLEAN_TARGETS += $$($1_BIN)$$($1_MODULE_SUBDIR)$$($2_TARGET)
129
$2 := $$(subst $1,,$$($2))
132
# Setup make rules for compiling Java source code to class files and/or a
135
# Parameter 1 is the name of the rule. This name is used as variable prefix,
136
# and the targets generated are listed in a variable by that name.
138
# The target for public API digest is returned in $1_API_TARGET.
140
# Remaining parameters are named arguments. These include:
141
# SMALL_JAVA:=set to false to run javac as a "big" java app
142
# COMPILER:=bootjdk or interim, the latter is default
143
# TARGET_RELEASE:=javac flags to set the targeted jdk release (-source/-target or --release)
144
# Defaults to $(TARGET_RELEASE_NEWJDK).
145
# JAVAC_FLAGS:=javac flags to append to the default ones.
146
# JAVA_FLAGS:=flags to be appended to the java launching the compiler
147
# DISABLED_WARNINGS:=list of Xlint warnings that should be disabled
148
# SRC:=one or more directories to search for sources. The order of the source roots
149
# is significant. The first found file of a certain name has priority.
150
# BIN:=store classes here
151
# MODULE:=Name of module being compiled. If set, classes are put in BIN/MODULE.
152
# CLASSPATH:=a list of additional entries to set as classpath to javac
153
# INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages.
154
# EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages.
155
# COPY:=.prp means copy all prp files to the corresponding package in BIN.
156
# COPY_FILES:=myapp/foo/setting.txt means copy this file over to the package myapp/foo
157
# CLEAN:=.properties means copy and clean all properties file to the corresponding package in BIN.
158
# CLEAN_FILES:=myapp/foo/setting.txt means clean this file over to the package myapp/foo
159
# SRCZIP:=Create a src.zip based on the found sources and copied files.
160
# INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file!
161
# EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file!
162
# "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found.
163
# EXTRA_FILES:=List of extra source files to include in compilation. Can be used to
164
# specify files that need to be generated by other rules first.
165
# HEADERS:=path to directory where all generated c-headers are written.
166
# DEPENDS:=Extra dependency
167
# KEEP_DUPS:=Do not remove duplicate file names from different source roots.
168
# FAIL_NO_SRC:=Set to false to not fail the build if no source files are found,
170
# CREATE_API_DIGEST:=Set to true to use a javac plugin to generate a public API
171
# hash which can be used for down stream dependencies to only rebuild
172
# when the API changes.
173
# KEEP_ALL_TRANSLATIONS:=Set to true to skip translation filtering
174
SetupJavaCompilation = $(NamedParamsMacroTemplate)
175
define SetupJavaCompilationBody
179
$$(error Must specify BIN (in $1))
182
ifneq ($$($1_MODULE), )
183
$1_MODULE_SUBDIR := /$$($1_MODULE)
186
$1_SAFE_NAME := $$(strip $$(subst /,_, $1))
188
ifeq ($$($1_SMALL_JAVA), )
189
# If unspecified, default to true
190
$1_SMALL_JAVA := true
193
ifeq ($$($1_COMPILER), )
194
# If unspecified, default to interim compiler
195
$1_COMPILER := interim
198
ifeq ($$($1_COMPILER), bootjdk)
199
# Javac server is not available when using the bootjdk compiler.
200
$1_JAVAC_CMD := $$(JAVAC) -J$$(JAVA_FLAGS_TMPDIR)
202
ifeq ($$($1_SMALL_JAVA), true)
203
$1_FLAGS += $$(addprefix -J, $$(JAVA_FLAGS_SMALL))
205
ifeq ($$($1_JAVA_FLAGS), true)
206
$1_FLAGS += $$(addprefix -J, $$($1_JAVA_FLAGS))
209
ifeq ($$($1_TARGET_RELEASE), )
210
# If unspecified, default to the new jdk we're building
211
$1_TARGET_RELEASE := $$(TARGET_RELEASE_BOOTJDK)
213
else ifeq ($$($1_COMPILER), buildjdk)
214
$1_JAVAC_CMD := $$(BUILD_JAVAC) -J$$(JAVA_FLAGS_TMPDIR)
216
ifeq ($$($1_TARGET_RELEASE), )
217
# If unspecified, default to the new jdk we're building
218
$1_TARGET_RELEASE := $$(TARGET_RELEASE_NEWJDK)
220
else ifeq ($$($1_COMPILER), interim)
221
# Use java server if it is enabled, and the user does not want a specialized
223
ifeq ($$(ENABLE_JAVAC_SERVER)+$$($1_CLASSPATH), true+)
224
# Create a configuration file with the needed information for the javac
225
# server to function properly.
226
$1_JAVAC_SERVER_CONFIG := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$$($1_SAFE_NAME)-javacserver.conf
228
# Arguments needed to launch the javacserver client, as well as for the
229
# client to launch the server.
230
$1_JAVAC_SERVER_ARGS := $$(INTERIM_LANGTOOLS_ARGS) \
231
-cp $(BUILDTOOLS_OUTPUTDIR)/langtools_javacserver_classes
233
# The portfile contains the tcp/ip on which the server listens
234
# and the cookie necessary to talk to the server.
235
$1_JAVAC_PORT_FILE := $$(call FixPath, $$(JAVAC_SERVER_DIR)/server.port)
237
# The javacmd tells the client how to run java to launch the server.
238
$1_JAVAC_SERVER_JAVA_CMD := $$(call FixPath, $$(JAVA) $$($1_JAVA_FLAGS) \
239
$$($1_JAVAC_SERVER_ARGS))
241
$1_CONFIG_VARDEPS := $$($1_JAVAC_PORT_FILE) $$($1_JAVAC_SERVER_JAVA_CMD)
242
$1_CONFIG_VARDEPS_FILE := $$(call DependOnVariable, $1_CONFIG_VARDEPS, \
243
$$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1.config_vardeps)
245
# Write these values to a config file
246
$$($1_JAVAC_SERVER_CONFIG): $$($1_CONFIG_VARDEPS_FILE)
247
$(ECHO) portfile=$$($1_JAVAC_PORT_FILE) > $$@
248
$(ECHO) javacmd=$$($1_JAVAC_SERVER_JAVA_CMD) >> $$@
250
# Always use small java to launch client
251
$1_JAVAC_CMD := $$(JAVA_SMALL) $$($1_JAVA_FLAGS) $$($1_JAVAC_SERVER_ARGS) \
252
javacserver.Main --conf=$$($1_JAVAC_SERVER_CONFIG)
255
$1_JAVAC := $$(INTERIM_LANGTOOLS_ARGS) -m jdk.compiler.interim/com.sun.tools.javac.Main
257
ifeq ($$($1_SMALL_JAVA), true)
258
$1_JAVAC_CMD := $$(JAVA_SMALL) $$($1_JAVA_FLAGS) $$($1_JAVAC)
260
$1_JAVAC_CMD := $$(JAVA) $$($1_JAVA_FLAGS) $$($1_JAVAC)
264
ifeq ($$($1_TARGET_RELEASE), )
265
# If unspecified, default to the new jdk we're building
266
$1_TARGET_RELEASE := $$(TARGET_RELEASE_NEWJDK)
269
$$(error Invalid value for COMPILER in SetupJavaCompilation for $1: '$$($1_COMPILER)')
272
# Allow overriding on the command line
273
JAVA_WARNINGS_ARE_ERRORS ?= -Werror
275
# Tell javac to do exactly as told and no more
276
PARANOIA_FLAGS := -implicit:none -Xprefer:source -XDignore.symbol.file=true -encoding ascii
278
$1_FLAGS += -g -Xlint:all $$($1_TARGET_RELEASE) $$(PARANOIA_FLAGS) $$(JAVA_WARNINGS_ARE_ERRORS)
279
$1_FLAGS += $$($1_JAVAC_FLAGS)
281
ifneq ($$($1_DISABLED_WARNINGS), )
282
$1_FLAGS += -Xlint:$$(call CommaList, $$(addprefix -, $$($1_DISABLED_WARNINGS)))
285
ifneq ($$($1_CLASSPATH), )
286
$1_FLAGS += -cp $$(call PathList, $$($1_CLASSPATH))
289
# Make sure the dirs exist, or that one of the EXTRA_FILES, that may not
290
# exist yet, is in it.
291
$$(foreach d, $$($1_SRC), \
292
$$(if $$(wildcard $$d), , \
293
$$(if $$(filter $$d%, $$($1_EXTRA_FILES)), , \
294
$$(error SRC specified to SetupJavaCompilation $1 contains missing directory >$$d<) \
298
$$(call MakeDir,$$($1_BIN))
299
# Order src files according to the order of the src dirs. Correct ordering is
300
# needed for correct overriding between different source roots.
301
$1_ALL_SRC_RAW := $$(call FindFiles, $$($1_SRC))
302
$1_ALL_SRCS := $$($1_EXTRA_FILES) \
303
$$(foreach d, $$($1_SRC), $$(filter $$d%, $$($1_ALL_SRC_RAW)))
305
# Extract the java files.
306
$1_SRCS := $$(filter %.java, $$($1_ALL_SRCS))
308
# Translate include/exclude into patterns
309
ifneq ($$($1_EXCLUDE_FILES), )
310
$1_EXCLUDE_PATTERN := $$(addprefix %, $$($1_EXCLUDE_FILES))
312
ifneq ($$($1_INCLUDE_FILES), )
313
$1_INCLUDE_PATTERN := $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$($1_INCLUDE_FILES)))
315
ifneq ($$($1_EXCLUDES), )
316
$1_EXCLUDE_PATTERN += $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$(addsuffix /%, $$($1_EXCLUDES))))
318
ifneq ($$($1_INCLUDES), )
319
$1_INCLUDE_PATTERN += $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$(addsuffix /%, $$($1_INCLUDES))))
322
# Apply include/exclude patterns to java sources
323
ifneq ($$($1_EXCLUDE_PATTERN), )
324
$1_SRCS := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_SRCS))
326
ifneq ($$($1_INCLUDE_PATTERN), )
327
$1_SRCS := $$(filter $$($1_INCLUDE_PATTERN) $$($1_EXTRA_FILES), $$($1_SRCS))
330
ifneq ($$($1_KEEP_DUPS), true)
331
# Remove duplicate source files by keeping the first found of each duplicate.
332
# This allows for automatic overrides with custom or platform specific versions
333
# source files. Need to call DoubleDollar as we have java classes with '$' in
335
$1_SRCS := $$(strip $$(foreach s, $$($1_SRCS), \
336
$$(eval relative_src := $$(call remove-prefixes, $$($1_SRC), \
337
$$(call DoubleDollar, $$(s)))) \
338
$$(if $$($1_$$(relative_src)), \
340
$$(eval $1_$$(relative_src) := 1) $$(s))))
343
# Filter out any excluded translations
344
ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
345
$1_SRCS := $$(call FilterExcludedTranslations, $$($1_SRCS), .java)
348
ifeq ($$(strip $$($1_SRCS)), )
349
ifneq ($$($1_FAIL_NO_SRC), false)
350
$$(error No source files found for $1)
353
# All files below META-INF are always copied.
354
$1_ALL_COPIES := $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS))
355
# Find all files to be copied from source to bin.
356
ifneq (,$$($1_COPY)$$($1_COPY_FILES))
357
# Search for all files to be copied.
358
$1_ALL_COPIES += $$(filter $$(addprefix %,$$($1_COPY)),$$($1_ALL_SRCS))
359
# Copy these explicitly
360
$1_ALL_COPIES += $$($1_COPY_FILES)
362
# Copy must also respect filters.
363
ifneq (,$$($1_INCLUDE_PATTERN))
364
$1_ALL_COPIES := $$(filter $$($1_INCLUDE_PATTERN),$$($1_ALL_COPIES))
366
ifneq (,$$($1_EXCLUDE_PATTERN))
367
$1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_PATTERN),$$($1_ALL_COPIES))
369
# Filter out any excluded translations
370
ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
371
$1_ALL_COPIES := $$(call FilterExcludedTranslations, $$($1_ALL_COPIES), .properties)
373
ifneq (,$$($1_ALL_COPIES))
374
# Yep, there are files to be copied!
375
$1_ALL_COPY_TARGETS:=
376
$$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i)))
377
# Now we can depend on $$($1_ALL_COPY_TARGETS) to copy all files!
380
# Find all property files to be copied and cleaned from source to bin.
381
ifneq (,$$($1_CLEAN)$$($1_CLEAN_FILES))
382
# Search for all files to be copied.
383
$1_ALL_CLEANS := $$(filter $$(addprefix %,$$($1_CLEAN)),$$($1_ALL_SRCS))
384
# Clean these explicitly
385
$1_ALL_CLEANS += $$($1_CLEAN_FILES)
386
# Copy and clean must also respect filters.
387
ifneq (,$$($1_INCLUDE_PATTERN))
388
$1_ALL_CLEANS := $$(filter $$($1_INCLUDE_PATTERN),$$($1_ALL_CLEANS))
390
ifneq (,$$($1_EXCLUDE_PATTERN))
391
$1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_PATTERN),$$($1_ALL_CLEANS))
393
# Filter out any excluded translations
394
ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
395
$1_ALL_CLEANS := $$(call FilterExcludedTranslations, $$($1_ALL_CLEANS), .properties)
397
ifneq (,$$($1_ALL_CLEANS))
398
# Yep, there are files to be copied and cleaned!
399
$1_ALL_COPY_CLEAN_TARGETS:=
400
$$(foreach i,$$($1_ALL_CLEANS),$$(eval $$(call add_file_to_clean,$1,$$i)))
401
# Now we can depend on $$($1_ALL_COPY_CLEAN_TARGETS) to copy all files!
405
# Create a sed expression to remove the source roots and to replace / with .
406
# and remove .java at the end.
407
$1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g'
409
$1_COMPILE_TARGET := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch
410
$1_FILELIST := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch.filelist
411
$1_MODFILELIST := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch.modfiles
412
$1_MODFILELIST_FIXED := $$($1_MODFILELIST).fixed
414
$1_API_TARGET := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_pubapi
415
$1_API_INTERNAL := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_internalapi
417
# Put headers in a temp dir to filter out those that actually
418
# changed before copying them to the real header dir.
419
ifneq (,$$($1_HEADERS))
420
$1_HEADERS_ARG := -h $$($1_HEADERS).$1.tmp
422
$$($1_HEADERS)/_the.$1_headers: $$($1_COMPILE_TARGET)
423
$$(call MakeTargetDir)
424
if [ -d "$$($1_HEADERS).$1.tmp" ]; then \
425
for f in `$(CD) $$($1_HEADERS).$1.tmp && $(FIND) . -type f`; do \
426
if [ ! -f "$$($1_HEADERS)/$$$$f" ] \
427
|| [ "`$(DIFF) $$($1_HEADERS)/$$$$f $$($1_HEADERS).$1.tmp/$$$$f`" != "" ]; then \
428
$(MKDIR) -p `$(DIRNAME) $$($1_HEADERS)/$$$$f`; \
429
$(CP) -f $$($1_HEADERS).$1.tmp/$$$$f $$($1_HEADERS)/$$$$f; \
433
$(RM) -r $$($1_HEADERS).$1.tmp
436
$1_HEADER_TARGETS := $$($1_HEADERS)/_the.$1_headers
439
$1_VARDEPS := $$($1_JAVAC_CMD) $$($1_FLAGS) $$($1_BIN) \
440
$$($1_HEADERS_ARG) $$($1_EXCLUDES) $$($1_INCLUDES) \
441
$$($1_EXCLUDE_FILES) $$($1_INCLUDE_FILES)
442
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
443
$$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1.vardeps)
445
ifeq ($$($1_CREATE_API_DIGEST), true)
446
$1_API_DIGEST_FLAGS := \
447
-classpath $$(BUILDTOOLS_OUTPUTDIR)/depend \
448
-Xplugin:"depend $$($1_API_TARGET)" \
449
"-XDinternalAPIPath=$$($1_API_INTERNAL)" \
450
"-XDLOG_LEVEL=$(LOG_LEVEL)" \
453
$1_EXTRA_DEPS := $$(BUILDTOOLS_OUTPUTDIR)/depend/_the.COMPILE_DEPEND_batch
456
# Create a file with all sources, to pass to javac in an @file.
457
# $$($1_VARDEPS_FILE) is used as dependency to track changes in set of
459
$$($1_FILELIST): $$($1_SRCS) $$($1_VARDEPS_FILE)
460
$$(call MakeDir, $$(@D))
461
$$(call LogWarn, Compiling up to $$(words $$($1_SRCS)) files for $1)
462
$$(eval $$(call ListPathsSafely, $1_SRCS, $$($1_FILELIST)))
464
# Create a $$($1_MODFILELIST) file with significant modified dependencies
465
# (either sources files or the other mark dependencies).
466
# It is then sent using a side-channel
467
# to the custom Depend plugin. The Depend plugin will check the provided list
468
# of modified files, and if none of the Java source files is changed in a way
469
# observable from outside of the file, and the list of modified files does
470
# not include a non-Java source file, it will only compile the modified files.
471
# Otherwise, all module's sources will be compiled. If a non-Java file is included,
472
# it will be considered to be a significant change, and all module source will
474
$$($1_MODFILELIST): $$($1_SRCS) $$($1_DEPENDS) \
475
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG)
476
$$(eval $1_MODFILES := $$?)
477
$$(eval $$(call ListPathsSafely, $1_MODFILES, $$($1_MODFILELIST)))
479
# Convert the paths in the MODFILELIST file to Windows-style paths
480
# on Windows. This is needed because javac operates on Windows-style paths
481
# when running on Windows. On other platforms this just copies the MODFILELIST file.
482
$$($1_MODFILELIST_FIXED): $$($1_MODFILELIST)
483
$$(call FixPathFile, $$($1_MODFILELIST), $$($1_MODFILELIST_FIXED))
485
# Do the actual compilation
486
$$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_FILELIST) $$($1_DEPENDS) \
487
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG) \
488
$$($1_MODFILELIST_FIXED)
489
$$(call MakeDir, $$(@D))
490
$$(call ExecuteWithLog, $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$$($1_SAFE_NAME)_batch, \
491
$$($1_JAVAC_CMD) $$($1_FLAGS) \
492
$$($1_API_DIGEST_FLAGS) \
493
-XDmodifiedInputs=$$($1_MODFILELIST_FIXED) \
494
-d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_FILELIST)) && \
497
# Add all targets to main variable
498
$1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_COMPILE_TARGET) \
499
$$($1_HEADER_TARGETS)
501
# Check if a jar file was specified, then setup the rules for the jar.
503
# If no suffixes was explicitly set for this jar file.
504
# Use class and the cleaned/copied properties file suffixes as the default
505
# for the types of files to be put into the jar.
506
ifeq (,$$($1_SUFFIXES))
507
$1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY)
510
$$(eval $$(call SetupJarArchive, ARCHIVE_$1, \
511
DEPENDENCIES:=$$($1), \
512
SRCS:=$$($1_BIN)$$($1_MODULE_SUBDIR), \
513
SUFFIXES:=$$($1_SUFFIXES), \
514
EXCLUDE:=$$($1_EXCLUDES), \
515
INCLUDES:=$$($1_INCLUDES), \
516
EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS), \
518
JARMAIN:=$$($1_JARMAIN), \
519
MANIFEST:=$$($1_MANIFEST), \
520
EXTRA_MANIFEST_ATTR:=$$($1_EXTRA_MANIFEST_ATTR), \
521
JARINDEX:=$$($1_JARINDEX), \
522
HEADERS:=$$($1_HEADERS), \
525
# Add jar to target list
529
# Check if a srczip was specified, then setup the rules for the srczip.
530
ifneq (,$$($1_SRCZIP))
531
$$(eval $$(call SetupZipArchive, ZIP_ARCHIVE_$1, \
533
ZIP:=$$($1_SRCZIP), \
534
INCLUDES:=$$($1_INCLUDES), \
535
EXCLUDES:=$$($1_EXCLUDES), \
536
EXCLUDE_FILES:=$$($1_EXCLUDE_FILES)))
538
# Add zip to target list
541
endif # Source files found
544
# Use this macro to find the correct target to depend on when the original
545
# SetupJavaCompilation is declared in a different makefile, to avoid having
546
# to declare and evaluate it again.
547
# param 1 is for example BUILD_MYPACKAGE
548
# param 2 is the output directory (BIN)
549
SetupJavaCompilationCompileTarget = \
550
$(strip $2)/_the.$(strip $1)_batch
552
SetupJavaCompilationApiTarget = \
553
$(strip $2)/_the.$(strip $1)_pubapi
555
endif # _JAVA_COMPILATION_GMK