common/makefiles/JavaCompilation.gmk

changeset 458
c8d320b48626
parent 445
efd26e051e50
child 478
2ba6f4da4bf3
equal deleted inserted replaced
455:633f2378c904 458:c8d320b48626
92 $(if $5,$1_$(strip $5)) 92 $(if $5,$1_$(strip $5))
93 $(if $6,$1_$(strip $6)) 93 $(if $6,$1_$(strip $6))
94 $(if $7,$1_$(strip $7)) 94 $(if $7,$1_$(strip $7))
95 $(if $8,$1_$(strip $8)) 95 $(if $8,$1_$(strip $8))
96 $(if $9,$1_$(strip $9)) 96 $(if $9,$1_$(strip $9))
97 $(if $(10),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk))
97 98
98 ifeq ($$($1_MODE),MULTI_CORE_CONCURRENT) 99 ifeq ($$($1_MODE),MULTI_CORE_CONCURRENT)
99 ifneq (,$$($1_SERVER_DIR)) 100 ifneq (,$$($1_SERVER_DIR))
100 # A javac server has been requested. 101 # A javac server has been requested.
101 # The port file contains the tcp/ip on which the server listens 102 # The port file contains the tcp/ip on which the server listens
128 # JARMAIN:=Optional main class to add to manifest 129 # JARMAIN:=Optional main class to add to manifest
129 # JARINDEX := 130 # JARINDEX :=
130 # SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically 131 # SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically
131 # added to the archive. 132 # added to the archive.
132 # EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest. 133 # EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest.
134 # CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable
133 $(if $3,$1_$(strip $3)) 135 $(if $3,$1_$(strip $3))
134 $(if $4,$1_$(strip $4)) 136 $(if $4,$1_$(strip $4))
135 $(if $5,$1_$(strip $5)) 137 $(if $5,$1_$(strip $5))
136 $(if $6,$1_$(strip $6)) 138 $(if $6,$1_$(strip $6))
137 $(if $7,$1_$(strip $7)) 139 $(if $7,$1_$(strip $7))
141 $(if $(11),$1_$(strip $(11))) 143 $(if $(11),$1_$(strip $(11)))
142 $(if $(12),$1_$(strip $(12))) 144 $(if $(12),$1_$(strip $(12)))
143 $(if $(13),$1_$(strip $(13))) 145 $(if $(13),$1_$(strip $(13)))
144 $(if $(14),$1_$(strip $(14))) 146 $(if $(14),$1_$(strip $(14)))
145 $(if $(15),$1_$(strip $(15))) 147 $(if $(15),$1_$(strip $(15)))
148 $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk))
146 149
147 $1_JARMAIN:=$(strip $$($1_JARMAIN)) 150 $1_JARMAIN:=$(strip $$($1_JARMAIN))
148 $1_JARNAME:=$$(notdir $$($1_JAR)) 151 $1_JARNAME:=$$(notdir $$($1_JAR))
149 $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest 152 $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest
150 $1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess 153 $1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess
241 $1_TOUCH_API_FILES=$$(foreach src,$$($1_SRCS),\ 244 $1_TOUCH_API_FILES=$$(foreach src,$$($1_SRCS),\
242 ($(FIND) $$(src) -name _the.package.api -exec $(TOUCH) -r $$($1_JAR) \{\} \; ; true) && \ 245 ($(FIND) $$(src) -name _the.package.api -exec $(TOUCH) -r $$($1_JAR) \{\} \; ; true) && \
243 ($(FIND) $$(src) -name _the.package -exec $(TOUCH) -r $$($1_JAR) \{\} \; ; true) &&) 246 ($(FIND) $$(src) -name _the.package -exec $(TOUCH) -r $$($1_JAR) \{\} \; ; true) &&)
244 # Use a slightly shorter name for logging, but with enough path to identify this jar. 247 # Use a slightly shorter name for logging, but with enough path to identify this jar.
245 $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_JAR)) 248 $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_JAR))
249
250 ifneq (,$$($1_CHECK_COMPRESS_JAR))
251 $1_JAR_CREATE_OPTIONS := c0fm
252 ifeq ($(COMPRESS_JARS), true)
253 $1_JAR_CREATE_OPTIONS := cfm
254 endif
255 else
256 $1_JAR_CREATE_OPTIONS := cfm
257 endif
258
246 # Here is the rule that creates/updates the jar file. 259 # Here is the rule that creates/updates the jar file.
247 $$($1_JAR) : $2 $$($1_ALL_SRC) 260 $$($1_JAR) : $2 $$($1_ALL_SRC)
248 $(MKDIR) -p $$($1_BIN) 261 $(MKDIR) -p $$($1_BIN)
249 if [ -n "$$($1_MANIFEST)" ]; then \ 262 if [ -n "$$($1_MANIFEST)" ]; then \
250 $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \ 263 $(SED) -e "s#@@RELEASE@@#$(RELEASE)#" \
281 $$($1_JARINDEX) && \ 294 $$($1_JARINDEX) && \
282 $$($1_TOUCH_API_FILES) true && \ 295 $$($1_TOUCH_API_FILES) true && \
283 $$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.api.notify $(FIND_DELETE); true) &&) true ; \ 296 $$(foreach src,$$($1_SRCS),($(FIND) $$(src) -name _the.package.api.notify $(FIND_DELETE); true) &&) true ; \
284 fi ; \ 297 fi ; \
285 else \ 298 else \
286 $(ECHO) Creating $$($1_NAME) && $(JAR) cfm $$@ $$($1_MANIFEST_FILE) && \ 299 $(ECHO) Creating $$($1_NAME) && $(JAR) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) && \
287 $$($1_SCAPTURE_CONTENTS) \ 300 $$($1_SCAPTURE_CONTENTS) \
288 $$($1_SCAPTURE_METAINF) \ 301 $$($1_SCAPTURE_METAINF) \
289 $$($1_SUPDATE_CONTENTS) \ 302 $$($1_SUPDATE_CONTENTS) \
290 $$($1_JARINDEX) && \ 303 $$($1_JARINDEX) && \
291 $$($1_TOUCH_API_FILES) true && \ 304 $$($1_TOUCH_API_FILES) true && \
309 $(if $5,$1_$(strip $5)) 322 $(if $5,$1_$(strip $5))
310 $(if $6,$1_$(strip $6)) 323 $(if $6,$1_$(strip $6))
311 $(if $7,$1_$(strip $7)) 324 $(if $7,$1_$(strip $7))
312 $(if $8,$1_$(strip $8)) 325 $(if $8,$1_$(strip $8))
313 $(if $9,$1_$(strip $9)) 326 $(if $9,$1_$(strip $9))
327 $(if $(10),$(error Internal makefile error: Too many arguments to SetupZipArchive, please update JavaCompilation.gmk))
314 328
315 # Find all files in the source tree. 329 # Find all files in the source tree.
316 $1_SUFFIX_FILTER := $$(patsubst %,-o -name $(DQUOTE)*%$(DQUOTE),$$($1_SUFFIXES)) 330 $1_SUFFIX_FILTER := $$(patsubst %,-o -name $(DQUOTE)*%$(DQUOTE),$$($1_SUFFIXES))
317 $1_ALL_SRCS := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i -type f -a ! -name "_the.*" \( -name FALSE_DUMMY $$($1_SUFFIX_FILTER) \) )) 331 $1_ALL_SRCS := $$(foreach i,$$($1_SRC), $$(shell $(FIND) $$i -type f -a ! -name "_the.*" \( -name FALSE_DUMMY $$($1_SUFFIX_FILTER) \) ))
318 332
646 $(if $(10),$1_$(strip $(10))) 660 $(if $(10),$1_$(strip $(10)))
647 $(if $(11),$1_$(strip $(11))) 661 $(if $(11),$1_$(strip $(11)))
648 $(if $(12),$1_$(strip $(12))) 662 $(if $(12),$1_$(strip $(12)))
649 $(if $(13),$1_$(strip $(13))) 663 $(if $(13),$1_$(strip $(13)))
650 $(if $(14),$1_$(strip $(14))) 664 $(if $(14),$1_$(strip $(14)))
665 $(if $(15),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk))
651 666
652 # Extract the info from the java compiler setup. 667 # Extract the info from the java compiler setup.
653 $1_MODE := $$($$($1_SETUP)_MODE) 668 $1_MODE := $$($$($1_SETUP)_MODE)
654 ifneq (SINGLE_THREADED_BATCH,$$($1_MODE)) 669 ifneq (SINGLE_THREADED_BATCH,$$($1_MODE))
655 ifneq (MULTI_CORE_CONCURRENT,$$($1_MODE)) 670 ifneq (MULTI_CORE_CONCURRENT,$$($1_MODE))
685 # There can be only a single bin dir root, no need to foreach over the roots. 700 # There can be only a single bin dir root, no need to foreach over the roots.
686 $1_BINS := $$(shell $(FIND) $$($1_BIN) -name "*.class") 701 $1_BINS := $$(shell $(FIND) $$($1_BIN) -name "*.class")
687 702
688 # Now we have a list of all java files to compile: $$($1_SRCS) 703 # Now we have a list of all java files to compile: $$($1_SRCS)
689 # and we have a list of all existing class files: $$($1_BINS) 704 # and we have a list of all existing class files: $$($1_BINS)
705
706 # Create the corresponding smart javac wrapper command line.
707 $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix .*,$$(subst /,.,$$($1_EXCLUDES)))) \
708 $$(addprefix -i ,$$(addsuffix .*,$$(subst /,.,$$($1_INCLUDES)))) \
709 $$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES))) \
710 $$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) -src $$(subst $$(SPACE),$$(PATH_SEP),$$(strip $$($1_SRC)))
690 711
691 # Prepend the source/bin path to the filter expressions. 712 # Prepend the source/bin path to the filter expressions.
692 ifneq ($$($1_INCLUDES),) 713 ifneq ($$($1_INCLUDES),)
693 $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES)))) 714 $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES))))
694 $1_PKG_INCLUDES := $$(addprefix /,$$(addsuffix /%,$$($1_INCLUDES))) 715 $1_PKG_INCLUDES := $$(addprefix /,$$(addsuffix /%,$$($1_INCLUDES)))
797 $$($1_BIN)/_the.batch: $$($1_SRCS) $$($1_DEPENDS) 818 $$($1_BIN)/_the.batch: $$($1_SRCS) $$($1_DEPENDS)
798 $(MKDIR) -p $$(@D) 819 $(MKDIR) -p $$(@D)
799 $(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp 820 $(RM) $$($1_BIN)/_the.batch $$($1_BIN)/_the.batch.tmp
800 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp) 821 $$(call ListPathsSafely,$1_SRCS,\n, >> $$($1_BIN)/_the.batch.tmp)
801 $(ECHO) Compiling `$(WC) $$($1_BIN)/_the.batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files in batch $1 822 $(ECHO) Compiling `$(WC) $$($1_BIN)/_the.batch.tmp | $(TR) -s ' ' | $(CUT) -f 2 -d ' '` files in batch $1
823 ifeq ($$($1_NOSJAVAC),)
824 ifeq ($$(ENABLE_SJAVAC),yes)
825 mkdir -p $$($1_BIN)_sjavac
826 $$($1_JVM) $$(word 1,$$($1_JAVAC)) com.sun.tools.javac.smart.Main $$($1_SJAVAC_ARGS) -mfl $$($1_BIN)/_the.batch.tmp -d $$($1_BIN)_sjavac
827 endif
828 endif
802 ($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) -implicit:none -sourcepath "$$($1_SRCROOTSC)" -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.batch.tmp && \ 829 ($$($1_JVM) $$($1_JAVAC) $$($1_FLAGS) -implicit:none -sourcepath "$$($1_SRCROOTSC)" -d $$($1_BIN) $$($1_HEADERS_ARG) @$$($1_BIN)/_the.batch.tmp && \
803 $(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch) 830 $(MV) $$($1_BIN)/_the.batch.tmp $$($1_BIN)/_the.batch)
804 else 831 else
805 # Ok, we have a modern javac server running! 832 # Ok, we have a modern javac server running!
806 # Since a single Java file can generate zero to an infinity number of .class files 833 # Since a single Java file can generate zero to an infinity number of .class files
888 EXCLUDES:=$$($1_EXCLUDES),\ 915 EXCLUDES:=$$($1_EXCLUDES),\
889 EXCLUDE_FILES:=$$($1_EXCLUDE_FILES))) 916 EXCLUDE_FILES:=$$($1_EXCLUDE_FILES)))
890 endif 917 endif
891 918
892 endef 919 endef
893
894

mercurial