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 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
|
#
# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
ifndef _JAVA_COMPILATION_GMK
_JAVA_COMPILATION_GMK := 1
ifeq (,$(_MAKEBASE_GMK))
$(error You must include MakeBase.gmk prior to including JavaCompilation.gmk)
endif
# Java compilation needs SetupJarArchive and/or SetupZipArchive, if we're
# generating a jar file or a source zip.
include JarArchive.gmk
include ZipArchive.gmk
###
### Definitions for common release targets
###
# Create classes that can run on the bootjdk
TARGET_RELEASE_BOOTJDK := $(BOOT_JDK_SOURCETARGET)
# Create classes that can be used in (or be a part of) the new jdk we're building
TARGET_RELEASE_NEWJDK := -source $(JDK_SOURCE_TARGET_VERSION) -target $(JDK_SOURCE_TARGET_VERSION)
# Create classes that can be used in JDK 8, for legacy support
TARGET_RELEASE_JDK8 := --release 8
# Create classes for the new jdk, relying only on the modules of the new jdk
TARGET_RELEASE_NEWJDK_UPGRADED := $(TARGET_RELEASE_NEWJDK) \
--upgrade-module-path $(JDK_OUTPUTDIR)/modules --system none
define add_file_to_copy
# param 1 = BUILD_MYPACKAGE
# parma 2 = The source file to copy.
$2_TARGET:=$2
# Remove the source prefix.
$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
# To allow for automatic overrides, do not create a rule for a target file that
# already has one
ifneq ($$($1_COPY_$$($2_TARGET)), 1)
$1_COPY_$$($2_TARGET) := 1
# Now we can setup the dependency that will trigger the copying.
$$($1_BIN)$$($1_MODULE_SUBDIR)$$($2_TARGET) : $2
$$(call LogInfo, Copying $$(patsubst $$(OUTPUTDIR)/%,%, $$@))
$$(install-file)
$(CHMOD) -f ug+w $$@
# And do not forget this target
$1_ALL_COPY_TARGETS += $$($1_BIN)$$($1_MODULE_SUBDIR)$$($2_TARGET)
endif
endef
# This macro is used only for properties files that are to be
# copied over to the classes directory in cleaned form.
#
# An empty echo ensures that the input to sed always ends with a newline.
# Certain implementations (e.g. Solaris) will skip the last line without
# it.
#
# The sed expression does this:
# 1. Add a backslash before any :, = or ! that do not have a backslash already.
# 2. Apply the file unicode2x.sed which does a whole bunch of \u00XX to \xXX
# conversions.
# 3. Delete all lines starting with #.
# 4. Delete empty lines.
# 5. Append lines ending with \ with the next line.
# 6. Remove leading and trailing white space. Note that tabs must be explicit
# as sed on macosx does not understand '\t'.
# 7. Replace the first \= with just =.
# 8. Finally it's all sorted to create a stable output.
#
# It is assumed that = is the character used for separating names and values.
define add_file_to_clean
# param 1 = BUILD_MYPACKAGE
# parma 2 = The source file to copy and clean.
$2_TARGET:=$2
# Remove the source prefix.
$$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
# Now we can setup the dependency that will trigger the copying.
# To allow for automatic overrides, do not create a rule for a target file that
# already has one
ifneq ($$($1_CLEAN_$$($2_TARGET)), 1)
$1_CLEAN_$$($2_TARGET) := 1
$$($1_BIN)$$($1_MODULE_SUBDIR)$$($2_TARGET) : $2
$$(call LogInfo, Cleaning $$(patsubst $$(OUTPUTDIR)/%,%, $$@))
$$(call MakeTargetDir)
( $(CAT) $$< && $(ECHO) "" ) \
| $(SED) -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' \
-e 's/\([^\\]\)!/\1\\!/g' -e 's/^[ ]*#.*/#/g' \
| $(SED) -f "$$(TOPDIR)/make/common/support/unicode2x.sed" \
| $(SED) -e '/^#/d' -e '/^$$$$/d' \
-e :a -e '/\\$$$$/N; s/\\\n//; ta' \
-e 's/^[ ]*//;s/[ ]*$$$$//' \
-e 's/\\=/=/' \
| $(SORT) > $$@
$(CHMOD) -f ug+w $$@
# And do not forget this target
$1_ALL_COPY_CLEAN_TARGETS += $$($1_BIN)$$($1_MODULE_SUBDIR)$$($2_TARGET)
endif
endef
define remove_string
$2 := $$(subst $1,,$$($2))
endef
# Setup make rules for compiling Java source code to class files and/or a
# resulting jar file.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
# The target for public API digest is returned in $1_API_TARGET.
#
# Remaining parameters are named arguments. These include:
# SMALL_JAVA:=set to false to run javac as a "big" java app
# COMPILER:=bootjdk or interim, the latter is default
# TARGET_RELEASE:=javac flags to set the targeted jdk release (-source/-target or --release)
# Defaults to $(TARGET_RELEASE_NEWJDK).
# JAVAC_FLAGS:=javac flags to append to the default ones.
# JAVA_FLAGS:=flags to be appended to the java launching the compiler
# DISABLED_WARNINGS:=list of Xlint warnings that should be disabled
# SRC:=one or more directories to search for sources. The order of the source roots
# is significant. The first found file of a certain name has priority.
# BIN:=store classes here
# MODULE:=Name of module being compiled. If set, classes are put in BIN/MODULE.
# CLASSPATH:=a list of additional entries to set as classpath to javac
# INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages.
# EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages.
# COPY:=.prp means copy all prp files to the corresponding package in BIN.
# COPY_FILES:=myapp/foo/setting.txt means copy this file over to the package myapp/foo
# CLEAN:=.properties means copy and clean all properties file to the corresponding package in BIN.
# CLEAN_FILES:=myapp/foo/setting.txt means clean this file over to the package myapp/foo
# SRCZIP:=Create a src.zip based on the found sources and copied files.
# INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file!
# EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file!
# "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found.
# EXTRA_FILES:=List of extra source files to include in compilation. Can be used to
# specify files that need to be generated by other rules first.
# HEADERS:=path to directory where all generated c-headers are written.
# DEPENDS:=Extra dependency
# KEEP_DUPS:=Do not remove duplicate file names from different source roots.
# FAIL_NO_SRC:=Set to false to not fail the build if no source files are found,
# default is true.
# CREATE_API_DIGEST:=Set to true to use a javac plugin to generate a public API
# hash which can be used for down stream dependencies to only rebuild
# when the API changes.
# KEEP_ALL_TRANSLATIONS:=Set to true to skip translation filtering
SetupJavaCompilation = $(NamedParamsMacroTemplate)
define SetupJavaCompilationBody
# Verify arguments
ifeq ($$($1_BIN),)
$$(error Must specify BIN (in $1))
endif
ifneq ($$($1_MODULE), )
$1_MODULE_SUBDIR := /$$($1_MODULE)
endif
$1_SAFE_NAME := $$(strip $$(subst /,_, $1))
ifeq ($$($1_SMALL_JAVA), )
# If unspecified, default to true
$1_SMALL_JAVA := true
endif
ifeq ($$($1_COMPILER), )
# If unspecified, default to interim compiler
$1_COMPILER := interim
endif
ifeq ($$($1_COMPILER), bootjdk)
# Javac server is not available when using the bootjdk compiler.
$1_JAVAC_CMD := $$(JAVAC)
ifeq ($$($1_SMALL_JAVA), true)
$1_FLAGS += $$(addprefix -J, $$(JAVA_FLAGS_SMALL))
endif
ifeq ($$($1_JAVA_FLAGS), true)
$1_FLAGS += $$(addprefix -J, $$($1_JAVA_FLAGS))
endif
ifeq ($$($1_TARGET_RELEASE), )
# If unspecified, default to the new jdk we're building
$1_TARGET_RELEASE := $$(TARGET_RELEASE_BOOTJDK)
endif
else ifeq ($$($1_COMPILER), buildjdk)
$1_JAVAC_CMD := $$(BUILD_JAVAC)
ifeq ($$($1_TARGET_RELEASE), )
# If unspecified, default to the new jdk we're building
$1_TARGET_RELEASE := $$(TARGET_RELEASE_NEWJDK)
endif
else ifeq ($$($1_COMPILER), interim)
# Use java server if it is enabled, and the user does not want a specialized
# class path.
ifeq ($$(ENABLE_JAVAC_SERVER)+$$($1_CLASSPATH), true+)
# Create a configuration file with the needed information for the javac
# server to function properly.
$1_JAVAC_SERVER_CONFIG := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$$($1_SAFE_NAME)-javacserver.conf
# Arguments needed to launch the javacserver client, as well as for the
# client to launch the server.
$1_JAVAC_SERVER_ARGS := $$(INTERIM_LANGTOOLS_ARGS) \
-cp $(BUILDTOOLS_OUTPUTDIR)/langtools_javacserver_classes
# The portfile contains the tcp/ip on which the server listens
# and the cookie necessary to talk to the server.
$1_JAVAC_PORT_FILE := $$(call FixPath, $$(JAVAC_SERVER_DIR)/server.port)
# The javacmd tells the client how to run java to launch the server.
$1_JAVAC_SERVER_JAVA_CMD := $$(call FixPath, $$(JAVA) $$($1_JAVA_FLAGS) \
$$($1_JAVAC_SERVER_ARGS))
$1_CONFIG_VARDEPS := $$($1_JAVAC_PORT_FILE) $$($1_JAVAC_SERVER_JAVA_CMD)
$1_CONFIG_VARDEPS_FILE := $$(call DependOnVariable, $1_CONFIG_VARDEPS, \
$$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1.config_vardeps)
# Write these values to a config file
$$($1_JAVAC_SERVER_CONFIG): $$($1_CONFIG_VARDEPS_FILE)
$(ECHO) portfile=$$($1_JAVAC_PORT_FILE) > $$@
$(ECHO) javacmd=$$($1_JAVAC_SERVER_JAVA_CMD) >> $$@
# Always use small java to launch client
$1_JAVAC_CMD := $$(JAVA_SMALL) $$($1_JAVA_FLAGS) $$($1_JAVAC_SERVER_ARGS) \
javacserver.Main --conf=$$($1_JAVAC_SERVER_CONFIG)
else
# No javac server
$1_JAVAC := $$(INTERIM_LANGTOOLS_ARGS) -m jdk.compiler.interim/com.sun.tools.javac.Main
ifeq ($$($1_SMALL_JAVA), true)
$1_JAVAC_CMD := $$(JAVA_SMALL) $$($1_JAVA_FLAGS) $$($1_JAVAC)
else
$1_JAVAC_CMD := $$(JAVA) $$($1_JAVA_FLAGS) $$($1_JAVAC)
endif
endif
ifeq ($$($1_TARGET_RELEASE), )
# If unspecified, default to the new jdk we're building
$1_TARGET_RELEASE := $$(TARGET_RELEASE_NEWJDK)
endif
else
$$(error Invalid value for COMPILER in SetupJavaCompilation for $1: '$$($1_COMPILER)')
endif
# Allow overriding on the command line
JAVA_WARNINGS_ARE_ERRORS ?= -Werror
# Tell javac to do exactly as told and no more
PARANOIA_FLAGS := -implicit:none -Xprefer:source -XDignore.symbol.file=true -encoding ascii
$1_FLAGS += -g -Xlint:all $$($1_TARGET_RELEASE) $$(PARANOIA_FLAGS) $$(JAVA_WARNINGS_ARE_ERRORS)
$1_FLAGS += $$($1_JAVAC_FLAGS)
ifneq ($$($1_DISABLED_WARNINGS), )
$1_FLAGS += -Xlint:$$(call CommaList, $$(addprefix -, $$($1_DISABLED_WARNINGS)))
endif
ifneq ($$($1_CLASSPATH), )
$1_FLAGS += -cp $$(call PathList, $$($1_CLASSPATH))
endif
# Make sure the dirs exist, or that one of the EXTRA_FILES, that may not
# exist yet, is in it.
$$(foreach d, $$($1_SRC), \
$$(if $$(wildcard $$d), , \
$$(if $$(filter $$d%, $$($1_EXTRA_FILES)), , \
$$(error SRC specified to SetupJavaCompilation $1 contains missing directory >$$d<) \
) \
) \
)
$$(call MakeDir,$$($1_BIN))
# Order src files according to the order of the src dirs. Correct ordering is
# needed for correct overriding between different source roots.
$1_ALL_SRC_RAW := $$(call FindFiles, $$($1_SRC))
$1_ALL_SRCS := $$($1_EXTRA_FILES) \
$$(foreach d, $$($1_SRC), $$(filter $$d%, $$($1_ALL_SRC_RAW)))
# Extract the java files.
$1_SRCS := $$(filter %.java, $$($1_ALL_SRCS))
# Translate include/exclude into patterns
ifneq ($$($1_EXCLUDE_FILES), )
$1_EXCLUDE_PATTERN := $$(addprefix %, $$($1_EXCLUDE_FILES))
endif
ifneq ($$($1_INCLUDE_FILES), )
$1_INCLUDE_PATTERN := $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$($1_INCLUDE_FILES)))
endif
ifneq ($$($1_EXCLUDES), )
$1_EXCLUDE_PATTERN += $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$(addsuffix /%, $$($1_EXCLUDES))))
endif
ifneq ($$($1_INCLUDES), )
$1_INCLUDE_PATTERN += $$(foreach i, $$($1_SRC), $$(addprefix $$i/, $$(addsuffix /%, $$($1_INCLUDES))))
endif
# Apply include/exclude patterns to java sources
ifneq ($$($1_EXCLUDE_PATTERN), )
$1_SRCS := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_SRCS))
endif
ifneq ($$($1_INCLUDE_PATTERN), )
$1_SRCS := $$(filter $$($1_INCLUDE_PATTERN) $$($1_EXTRA_FILES), $$($1_SRCS))
endif
ifneq ($$($1_KEEP_DUPS), true)
# Remove duplicate source files by keeping the first found of each duplicate.
# This allows for automatic overrides with custom or platform specific versions
# source files. Need to call DoubleDollar as we have java classes with '$' in
# their names.
$1_SRCS := $$(strip $$(foreach s, $$($1_SRCS), \
$$(eval relative_src := $$(call remove-prefixes, $$($1_SRC), \
$$(call DoubleDollar, $$(s)))) \
$$(if $$($1_$$(relative_src)), \
, \
$$(eval $1_$$(relative_src) := 1) $$(s))))
endif
# Filter out any excluded translations
ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
$1_SRCS := $$(call FilterExcludedTranslations, $$($1_SRCS), .java)
endif
ifeq ($$(strip $$($1_SRCS)), )
ifneq ($$($1_FAIL_NO_SRC), false)
$$(error No source files found for $1)
endif
else
# All files below META-INF are always copied.
$1_ALL_COPIES := $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS))
# Find all files to be copied from source to bin.
ifneq (,$$($1_COPY)$$($1_COPY_FILES))
# Search for all files to be copied.
$1_ALL_COPIES += $$(filter $$(addprefix %,$$($1_COPY)),$$($1_ALL_SRCS))
# Copy these explicitly
$1_ALL_COPIES += $$($1_COPY_FILES)
endif
# Copy must also respect filters.
ifneq (,$$($1_INCLUDE_PATTERN))
$1_ALL_COPIES := $$(filter $$($1_INCLUDE_PATTERN),$$($1_ALL_COPIES))
endif
ifneq (,$$($1_EXCLUDE_PATTERN))
$1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_PATTERN),$$($1_ALL_COPIES))
endif
# Filter out any excluded translations
ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
$1_ALL_COPIES := $$(call FilterExcludedTranslations, $$($1_ALL_COPIES), .properties)
endif
ifneq (,$$($1_ALL_COPIES))
# Yep, there are files to be copied!
$1_ALL_COPY_TARGETS:=
$$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i)))
# Now we can depend on $$($1_ALL_COPY_TARGETS) to copy all files!
endif
# Find all property files to be copied and cleaned from source to bin.
ifneq (,$$($1_CLEAN)$$($1_CLEAN_FILES))
# Search for all files to be copied.
$1_ALL_CLEANS := $$(filter $$(addprefix %,$$($1_CLEAN)),$$($1_ALL_SRCS))
# Clean these explicitly
$1_ALL_CLEANS += $$($1_CLEAN_FILES)
# Copy and clean must also respect filters.
ifneq (,$$($1_INCLUDE_PATTERN))
$1_ALL_CLEANS := $$(filter $$($1_INCLUDE_PATTERN),$$($1_ALL_CLEANS))
endif
ifneq (,$$($1_EXCLUDE_PATTERN))
$1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_PATTERN),$$($1_ALL_CLEANS))
endif
# Filter out any excluded translations
ifneq ($$($1_KEEP_ALL_TRANSLATIONS), true)
$1_ALL_CLEANS := $$(call FilterExcludedTranslations, $$($1_ALL_CLEANS), .properties)
endif
ifneq (,$$($1_ALL_CLEANS))
# Yep, there are files to be copied and cleaned!
$1_ALL_COPY_CLEAN_TARGETS:=
$$(foreach i,$$($1_ALL_CLEANS),$$(eval $$(call add_file_to_clean,$1,$$i)))
# Now we can depend on $$($1_ALL_COPY_CLEAN_TARGETS) to copy all files!
endif
endif
# Create a sed expression to remove the source roots and to replace / with .
# and remove .java at the end.
$1_REWRITE_INTO_CLASSES:=$$(foreach i,$$($1_SRC),-e 's|$$i/||g') -e 's|/|.|g' -e 's|.java$$$$||g'
$1_COMPILE_TARGET := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch
$1_FILELIST := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch.filelist
$1_MODFILELIST := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_batch.modfiles
$1_MODFILELIST_FIXED := $$($1_MODFILELIST).fixed
$1_API_TARGET := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_pubapi
$1_API_INTERNAL := $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1_internalapi
# Put headers in a temp dir to filter out those that actually
# changed before copying them to the real header dir.
ifneq (,$$($1_HEADERS))
$1_HEADERS_ARG := -h $$($1_HEADERS).$1.tmp
$$($1_HEADERS)/_the.$1_headers: $$($1_COMPILE_TARGET)
$$(call MakeTargetDir)
if [ -d "$$($1_HEADERS).$1.tmp" ]; then \
for f in `$(CD) $$($1_HEADERS).$1.tmp && $(FIND) . -type f`; do \
if [ ! -f "$$($1_HEADERS)/$$$$f" ] \
|| [ "`$(DIFF) $$($1_HEADERS)/$$$$f $$($1_HEADERS).$1.tmp/$$$$f`" != "" ]; then \
$(MKDIR) -p `$(DIRNAME) $$($1_HEADERS)/$$$$f`; \
$(CP) -f $$($1_HEADERS).$1.tmp/$$$$f $$($1_HEADERS)/$$$$f; \
fi; \
done; \
fi
$(RM) -r $$($1_HEADERS).$1.tmp
$(TOUCH) $$@
$1_HEADER_TARGETS := $$($1_HEADERS)/_the.$1_headers
endif
$1_VARDEPS := $$($1_JAVAC_CMD) $$($1_FLAGS) $$($1_BIN) \
$$($1_HEADERS_ARG) $$($1_EXCLUDES) $$($1_INCLUDES) \
$$($1_EXCLUDE_FILES) $$($1_INCLUDE_FILES)
$1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
$$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$1.vardeps)
ifeq ($$($1_CREATE_API_DIGEST), true)
$1_API_DIGEST_FLAGS := \
-classpath $$(BUILDTOOLS_OUTPUTDIR)/depend \
-Xplugin:"depend $$($1_API_TARGET)" \
"-XDinternalAPIPath=$$($1_API_INTERNAL)" \
"-XDLOG_LEVEL=$(LOG_LEVEL)" \
#
$1_EXTRA_DEPS := $$(BUILDTOOLS_OUTPUTDIR)/depend/_the.COMPILE_DEPEND_batch
endif
# Create a file with all sources, to pass to javac in an @file.
# $$($1_VARDEPS_FILE) is used as dependency to track changes in set of
# list of files.
$$($1_FILELIST): $$($1_SRCS) $$($1_VARDEPS_FILE)
$$(call MakeDir, $$(@D))
$$(call LogWarn, Compiling up to $$(words $$($1_SRCS)) files for $1)
$$(eval $$(call ListPathsSafely, $1_SRCS, $$($1_FILELIST)))
# Create a $$($1_MODFILELIST) file with significant modified dependencies
# (either sources files or the other mark dependencies).
# It is then sent using a side-channel
# to the custom Depend plugin. The Depend plugin will check the provided list
# of modified files, and if none of the Java source files is changed in a way
# observable from outside of the file, and the list of modified files does
# not include a non-Java source file, it will only compile the modified files.
# Otherwise, all module's sources will be compiled. If a non-Java file is included,
# it will be considered to be a significant change, and all module source will
# be recompiled
$$($1_MODFILELIST): $$($1_SRCS) $$($1_DEPENDS) \
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG)
$$(eval $1_MODFILES := $$?)
$$(eval $$(call ListPathsSafely, $1_MODFILES, $$($1_MODFILELIST)))
# Convert the paths in the MODFILELIST file to Windows-style paths
# on Windows. This is needed because javac operates on Windows-style paths
# when running on Windows. On other platforms this just copies the MODFILELIST file.
$$($1_MODFILELIST_FIXED): $$($1_MODFILELIST)
$$(call FixPathFile, $$($1_MODFILELIST), $$($1_MODFILELIST_FIXED))
# Do the actual compilation
$$($1_COMPILE_TARGET): $$($1_SRCS) $$($1_FILELIST) $$($1_DEPENDS) \
$$($1_VARDEPS_FILE) $$($1_EXTRA_DEPS) $$($1_JAVAC_SERVER_CONFIG) \
$$($1_MODFILELIST_FIXED)
$$(call MakeDir, $$(@D))
$$(call ExecuteWithLog, $$($1_BIN)$$($1_MODULE_SUBDIR)/_the.$$($1_SAFE_NAME)_batch, \
$$($1_JAVAC_CMD) $$($1_FLAGS) \
$$($1_API_DIGEST_FLAGS) \
-XDmodifiedInputs=$$($1_MODFILELIST_FIXED) \
-d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_FILELIST)) && \
$(TOUCH) $$@
# Add all targets to main variable
$1 := $$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS) $$($1_COMPILE_TARGET) \
$$($1_HEADER_TARGETS)
# Check if a jar file was specified, then setup the rules for the jar.
ifneq (,$$($1_JAR))
# If no suffixes was explicitly set for this jar file.
# Use class and the cleaned/copied properties file suffixes as the default
# for the types of files to be put into the jar.
ifeq (,$$($1_SUFFIXES))
$1_SUFFIXES:=.class $$($1_CLEAN) $$($1_COPY)
endif
$$(eval $$(call SetupJarArchive, ARCHIVE_$1, \
DEPENDENCIES:=$$($1), \
SRCS:=$$($1_BIN)$$($1_MODULE_SUBDIR), \
SUFFIXES:=$$($1_SUFFIXES), \
EXCLUDE:=$$($1_EXCLUDES), \
INCLUDES:=$$($1_INCLUDES), \
EXTRA_FILES:=$$($1_ALL_COPY_TARGETS) $$($1_ALL_COPY_CLEAN_TARGETS), \
JAR:=$$($1_JAR), \
JARMAIN:=$$($1_JARMAIN), \
MANIFEST:=$$($1_MANIFEST), \
EXTRA_MANIFEST_ATTR:=$$($1_EXTRA_MANIFEST_ATTR), \
JARINDEX:=$$($1_JARINDEX), \
HEADERS:=$$($1_HEADERS), \
))
# Add jar to target list
$1 += $$($1_JAR)
endif
# Check if a srczip was specified, then setup the rules for the srczip.
ifneq (,$$($1_SRCZIP))
$$(eval $$(call SetupZipArchive, ZIP_ARCHIVE_$1, \
SRC:=$$($1_SRC), \
ZIP:=$$($1_SRCZIP), \
INCLUDES:=$$($1_INCLUDES), \
EXCLUDES:=$$($1_EXCLUDES), \
EXCLUDE_FILES:=$$($1_EXCLUDE_FILES)))
# Add zip to target list
$1 += $$($1_SRCZIP)
endif
endif # Source files found
endef
# Use this macro to find the correct target to depend on when the original
# SetupJavaCompilation is declared in a different makefile, to avoid having
# to declare and evaluate it again.
# param 1 is for example BUILD_MYPACKAGE
# param 2 is the output directory (BIN)
SetupJavaCompilationCompileTarget = \
$(strip $2)/_the.$(strip $1)_batch
SetupJavaCompilationApiTarget = \
$(strip $2)/_the.$(strip $1)_pubapi
endif # _JAVA_COMPILATION_GMK
|