--- old/make/common/JavaCompilation.gmk 2014-11-25 16:10:39.133488773 +0100 +++ new/make/common/JavaCompilation.gmk 2014-11-25 16:10:39.029488771 +0100 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2014, 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 @@ -42,17 +42,29 @@ $(error You must include MakeBase.gmk prior to including JavaCompilation.gmk) endif +# Java compilation needs SetupZipArchive if we're generating a source zip. +include ZipArchive.gmk + FALSE_FIND_PATTERN:=-name FILE_NAME_THAT_DOESNT_EXIST +# Setup make rules for defining a Java compiler, which is needed to compile +# Java code. This rule generates no output. +# +# Parameter 1 is the name of the compiler definition. This name needs to be +# passed to SetupJavaCompilation. This name is used as variable prefix. +# +# Remaining parameters are named arguments. These include: +# JVM:=The jvm used to run the javac/javah command +# JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out +# FLAGS:=Flags to be supplied to javac +# SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here +# SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above. define SetupJavaCompiler - # param 1 is for example GENERATE_OLD_BYTECODE or GENERATE_NEW_JDKBYTECODE - # This is the name of the compiler setup. - # param 2-9 are named args. - # JVM:=The jvm used to run the javac/javah command - # JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out - # FLAGS:=Flags to be supplied to javac - # SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here - # SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above. + $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk)) + $(call EvalDebugWrapper,$(strip $1),$(call SetupJavaCompilerInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))) +endef + +define SetupJavaCompilerInner $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) $(call LogSetupMacroEntry,SetupJavaCompiler($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk)) @@ -67,25 +79,32 @@ endif endef +# Setup make rules for creating a jar archive. +# +# 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. +# +# Remaining parameters are named arguments. These include: +# SRCS:=List of directories in where to find files to add to archive +# SUFFIXES:=File suffixes to include in jar +# INCLUDES:=List of directories/packages in SRCS that should be included +# EXCLUDES:=List of directories/packages in SRCS that should be excluded +# EXCLUDE_FILES:=List of files in SRCS that should be excluded +# EXTRA_FILES:=List of files in SRCS that should be included regardless of suffix match. +# JAR:=Jar file to create +# MANIFEST:=Optional manifest file template. +# JARMAIN:=Optional main class to add to manifest +# JARINDEX:=true means generate the index in the jar file. +# SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically +# added to the archive. +# EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest. +# CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable define SetupArchive - # param 1 is for example ARCHIVE_MYPACKAGE - # param 2 are the dependecies - # param 3,4,5,6,7,8,9 are named args. - # SRCS:=List of directories in where to find files to add to archive - # SUFFIXES:=File suffixes to include in jar - # INCLUDES:=List of directories/packages in SRCS that should be included - # EXCLUDES:=List of directories/packages in SRCS that should be excluded - # EXCLUDE_FILES:=List of files in SRCS that should be excluded - # EXTRA_FILES:=List of files in SRCS that should be included regardless of suffix match. - # JAR:=Jar file to create - # MANIFEST:=Optional manifest file template. - # JARMAIN:=Optional main class to add to manifest - # JARINDEX:=true means generate the index in the jar file. - # SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically - # added to the archive. - # EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest. - # CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable + $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk)) + $(call EvalDebugWrapper,$(strip $1),$(call SetupArchiveInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))) +endef +define SetupArchiveInner # NOTE: $2 is dependencies, not a named argument! $(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) $(call LogSetupMacroEntry,SetupArchive($1),,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) @@ -287,69 +306,6 @@ $1 += $$($1_JAR) endef -define SetupZipArchive - # param 1 is for example ZIP_MYSOURCE - # param 2,3,4,5,6,7,8,9 are named args. - # SRC,ZIP,INCLUDES,INCLUDE_FILES,EXCLUDES,EXCLUDE_FILES,SUFFIXES,EXTRA_DEPS - $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) - $(call LogSetupMacroEntry,SetupZipArchive($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) - $(if $(16),$(error Internal makefile error: Too many arguments to SetupZipArchive, please update JavaCompilation.gmk)) - - # To avoid running find over too large sets of files, which causes make to crash - # on some configurations (cygwin), use INCLUDES and INCLUDE_FILES to build a set - # of directories to run find in, if available. - ifneq ($$($1_INCLUDES)$$($1_INCLUDE_FILES),) - $1_FIND_LIST := $$(wildcard $$(foreach i,$$($1_SRC), \ - $$(addprefix $$i/,$$($1_INCLUDES) $$($1_INCLUDE_FILES)))) - else - $1_FIND_LIST := $$($1_SRC) - endif - - # Find all files in the source tree. - $1_ALL_SRCS := $$(call not-containing,_the.,$$(call CacheFind,$$($1_FIND_LIST))) - - # Filter on suffixes if set - ifneq ($$($1_SUFFIXES),) - $1_ALL_SRCS := $$(filter $$(addprefix %, $$($1_SUFFIXES)), $$($1_ALL_SRCS)) - endif - - ifneq ($$($1_INCLUDES),) - ifneq ($$($1_SUFFIXES),) - $1_ZIP_INCLUDES := $$(foreach s,$$($1_SUFFIXES), \ - $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$$s$(DQUOTE),$$($1_INCLUDES)))) - else - $1_ZIP_INCLUDES := $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_INCLUDES))) - endif - endif - ifneq ($$($1_INCLUDE_FILES),) - $1_ZIP_INCLUDES += $$(addprefix -i$(SPACE),$$($1_INCLUDE_FILES)) - endif - ifneq ($$($1_EXCLUDES),) - $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) - $1_ZIP_EXCLUDES := $$(addprefix -x$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_EXCLUDES))) - $1_ALL_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_SRCS)) - endif - - # Use a slightly shorter name for logging, but with enough path to identify this zip. - $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_ZIP)) - - # Now $1_ALL_SRCS should contain all sources that are going to be put into the zip. - # I.e. the zip -i and -x options should match the filtering done in the makefile. - # Explicitly excluded files can be given with absolute path. The patsubst solution - # isn't perfect but the likelyhood of an absolute path to match something in a src - # dir is very small. - # If zip has nothing to do, it returns 12 and would fail the build. Check for 12 - # and only fail if it's not. - $$($1_ZIP) : $$($1_ALL_SRCS) $$($1_EXTRA_DEPS) - $(MKDIR) -p $$(@D) - $(ECHO) Updating $$($1_NAME) - $$(foreach i,$$($1_SRC),(cd $$i && $(ZIP) -qru $$@ . $$($1_ZIP_INCLUDES) $$($1_ZIP_EXCLUDES) -x \*_the.\* $$(addprefix -x$(SPACE),$$(patsubst $$i/%,%,$$($1_EXCLUDE_FILES))) || test "$$$$?" = "12" )$$(NEWLINE)) true - $(TOUCH) $$@ - - # Add zip to target list - $1 += $$($1_ZIP) -endef - define add_file_to_copy # param 1 = BUILD_MYPACKAGE # parma 2 = The source file to copy. @@ -423,29 +379,39 @@ $1:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$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. +# +# Remaining parameters are named arguments. These include: +# SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC +# JVM:=path to ..bin/java +# ADD_JAVAC_FLAGS:=javac flags to append to the default ones. +# SRC:=one or more directories to search for sources +# BIN:=store classes here +# 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. +# JAVAC_SOURCE_PATH_OVERRIDE:=This forces an explicit -sourcepath to javac instead of the complete +# source roots from SRC. This is sometimes needed when compiling specific subsets of the source. +# HEADERS:=path to directory where all generated c-headers are written. +# DEPENDS:=Extra dependecy +# DISABLE_SJAVAC:=Explicitly disable the use of sjavac for this compilation unit. define SetupJavaCompilation - # param 1 is for example BUILD_MYPACKAGE - # param 2,3,4,5,6,7,8 are named args. - # SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC - # JVM:=path to ..bin/java - # ADD_JAVAC_FLAGS:=javac flags to append to the default ones. - # SRC:=one or more directories to search for sources - # BIN:=store classes here - # 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. - # JAVAC_SOURCE_PATH_OVERRIDE:=This forces an explicit -sourcepath to javac instead of the complete - # source roots from SRC. This is sometimes needed when compiling specific subsets of the source. - # HEADERS:=path to directory where all generated c-headers are written. - # DEPENDS:=Extra dependecy - # DISABLE_SJAVAC:=Explicitly disable the use of sjavac for this compilation unit. + $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk)) + $(call EvalDebugWrapper,$(strip $1),$(call SetupJavaCompilationInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))) +endef + +define SetupJavaCompilationInner $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) $(call LogSetupMacroEntry,SetupJavaCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk))