< prev index next >

make/common/JavaCompilation.gmk

Print this page


   1 #
   2 # Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   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.
  10 #
  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).
  16 #
  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.
  20 #
  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


  25 
  26 # This makefile is much simpler now that it can use the smart javac wrapper
  27 # for dependency tracking between java packages and incremental compiles.
  28 # It could be even more simple if we added support for incremental jar updates
  29 # directly from the smart javac wrapper.
  30 
  31 # Cleaning/copying properties here is not a good solution. The properties
  32 # should be cleaned/copied by a annotation processor in sjavac.
  33 
  34 # When you read this source. Remember that $(sort ...) has the side effect
  35 # of removing duplicates. It is actually this side effect that is
  36 # desired whenever sort is used below!
  37 
  38 ifndef _JAVA_COMPILATION_GMK
  39 _JAVA_COMPILATION_GMK := 1
  40 
  41 ifeq (,$(_MAKEBASE_GMK))
  42   $(error You must include MakeBase.gmk prior to including JavaCompilation.gmk)
  43 endif
  44 



  45 FALSE_FIND_PATTERN:=-name FILE_NAME_THAT_DOESNT_EXIST
  46 












  47 define SetupJavaCompiler
  48   # param 1 is for example GENERATE_OLD_BYTECODE or GENERATE_NEW_JDKBYTECODE
  49   # This is the name of the compiler setup.
  50   # param 2-9 are named args.
  51   #   JVM:=The jvm used to run the javac/javah command
  52   #   JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out
  53   #   FLAGS:=Flags to be supplied to javac
  54   #   SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here
  55   #   SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above.
  56   $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
  57   $(call LogSetupMacroEntry,SetupJavaCompiler($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
  58   $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk))
  59 
  60   # The port file contains the tcp/ip on which the server listens
  61   # and the cookie necessary to talk to the server.
  62   $1_SJAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port
  63   # You can use a different JVM to run the background javac server.
  64   ifeq ($$($1_SERVER_JVM),)
  65     # It defaults to the same JVM that is used to start the javac command.
  66     $1_SERVER_JVM:=$$($1_JVM)
  67   endif
  68 endef
  69 




















  70 define SetupArchive
  71   # param 1 is for example ARCHIVE_MYPACKAGE
  72   # param 2 are the dependecies
  73   # param 3,4,5,6,7,8,9 are named args.
  74   #   SRCS:=List of directories in where to find files to add to archive
  75   #   SUFFIXES:=File suffixes to include in jar
  76   #   INCLUDES:=List of directories/packages in SRCS that should be included
  77   #   EXCLUDES:=List of directories/packages in SRCS that should be excluded
  78   #   EXCLUDE_FILES:=List of files in SRCS that should be excluded
  79   #   EXTRA_FILES:=List of files in SRCS that should be included regardless of suffix match.
  80   #   JAR:=Jar file to create
  81   #   MANIFEST:=Optional manifest file template.
  82   #   JARMAIN:=Optional main class to add to manifest
  83   #   JARINDEX:=true means generate the index in the jar file.
  84   #   SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically
  85   #       added to the archive.
  86   #   EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest.
  87   #   CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable
  88 

  89   # NOTE: $2 is dependencies, not a named argument!
  90   $(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
  91   $(call LogSetupMacroEntry,SetupArchive($1),<dependencies>,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
  92   $(if $(findstring $(LOG_LEVEL),trace), $(info *[2] <dependencies> = $(strip $2)))
  93   $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk))
  94 
  95   $1_JARMAIN:=$(strip $$($1_JARMAIN))
  96   $1_JARNAME:=$$(notdir $$($1_JAR))
  97   $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest
  98   $1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess
  99   $1_DELETES_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletes
 100   $1_BIN:=$$(dir $$($1_JAR))
 101 
 102   ifeq (,$$($1_SUFFIXES))
 103     # No suffix was set, default to classes.
 104     $1_SUFFIXES:=.class
 105   endif
 106   # Convert suffixes to a find expression
 107   $1_FIND_PATTERNS:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_SUFFIXES))
 108   # On windows, a lot of includes/excludes risk making the command line too long, so


 270           $(RM) $$($1_DELETES_FILE) $$(NEWLINE) \
 271           $$($1_CAPTURE_DELETES) \
 272           $(CAT) $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) $$(NEWLINE) \
 273           if [ -s $$($1_DELETESS_FILE) ]; then \
 274             $(ECHO) "  deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \
 275             $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \
 276           fi $$(NEWLINE) \
 277           $$($1_UPDATE_CONTENTS) true $$(NEWLINE) \
 278           $$($1_JARINDEX) && true \
 279         , \
 280           $(ECHO) Creating $$($1_NAME) && $(JAR) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) $$(NEWLINE) \
 281           $$($1_SCAPTURE_CONTENTS) \
 282           $$($1_SCAPTURE_METAINF) \
 283           $$($1_SUPDATE_CONTENTS) \
 284           $$($1_JARINDEX) && true )
 285 
 286   # Add jar to target list
 287   $1 += $$($1_JAR)
 288 endef
 289 
 290 define SetupZipArchive
 291   # param 1 is for example ZIP_MYSOURCE
 292   # param 2,3,4,5,6,7,8,9 are named args.
 293   #   SRC,ZIP,INCLUDES,INCLUDE_FILES,EXCLUDES,EXCLUDE_FILES,SUFFIXES,EXTRA_DEPS
 294   $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
 295   $(call LogSetupMacroEntry,SetupZipArchive($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
 296   $(if $(16),$(error Internal makefile error: Too many arguments to SetupZipArchive, please update JavaCompilation.gmk))
 297 
 298   # To avoid running find over too large sets of files, which causes make to crash
 299   # on some configurations (cygwin), use INCLUDES and INCLUDE_FILES to build a set
 300   # of directories to run find in, if available.
 301   ifneq ($$($1_INCLUDES)$$($1_INCLUDE_FILES),)
 302     $1_FIND_LIST := $$(wildcard $$(foreach i,$$($1_SRC), \
 303         $$(addprefix $$i/,$$($1_INCLUDES) $$($1_INCLUDE_FILES))))
 304   else
 305     $1_FIND_LIST := $$($1_SRC)
 306   endif
 307 
 308   # Find all files in the source tree.
 309   $1_ALL_SRCS := $$(call not-containing,_the.,$$(call CacheFind,$$($1_FIND_LIST)))
 310 
 311   # Filter on suffixes if set
 312   ifneq ($$($1_SUFFIXES),)
 313     $1_ALL_SRCS := $$(filter $$(addprefix %, $$($1_SUFFIXES)), $$($1_ALL_SRCS))
 314   endif
 315 
 316   ifneq ($$($1_INCLUDES),)
 317     ifneq ($$($1_SUFFIXES),)
 318       $1_ZIP_INCLUDES := $$(foreach s,$$($1_SUFFIXES), \
 319           $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$$s$(DQUOTE),$$($1_INCLUDES))))
 320     else
 321       $1_ZIP_INCLUDES := $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_INCLUDES)))
 322     endif
 323   endif
 324   ifneq ($$($1_INCLUDE_FILES),)
 325     $1_ZIP_INCLUDES += $$(addprefix -i$(SPACE),$$($1_INCLUDE_FILES))
 326   endif
 327   ifneq ($$($1_EXCLUDES),)
 328     $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
 329     $1_ZIP_EXCLUDES := $$(addprefix -x$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_EXCLUDES)))
 330     $1_ALL_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_SRCS))
 331   endif
 332 
 333   # Use a slightly shorter name for logging, but with enough path to identify this zip.
 334   $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_ZIP))
 335 
 336   # Now $1_ALL_SRCS should contain all sources that are going to be put into the zip.
 337   # I.e. the zip -i and -x options should match the filtering done in the makefile.
 338   # Explicitly excluded files can be given with absolute path. The patsubst solution
 339   # isn't perfect but the likelyhood of an absolute path to match something in a src
 340   # dir is very small.
 341   # If zip has nothing to do, it returns 12 and would fail the build. Check for 12
 342   # and only fail if it's not.
 343   $$($1_ZIP) : $$($1_ALL_SRCS) $$($1_EXTRA_DEPS)
 344         $(MKDIR) -p $$(@D)
 345         $(ECHO) Updating $$($1_NAME)
 346         $$(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
 347         $(TOUCH) $$@
 348 
 349   # Add zip to target list
 350   $1 += $$($1_ZIP)
 351 endef
 352 
 353 define add_file_to_copy
 354   # param 1 = BUILD_MYPACKAGE
 355   # parma 2 = The source file to copy.
 356   $2_TARGET:=$2
 357   # Remove the source prefix.
 358   $$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
 359   # To allow for automatic overrides, do not create a rule for a target file that
 360   # already has one
 361   ifeq ($$(findstring $$($2_TARGET), $$($1_COPY_LIST)), )
 362     $1_COPY_LIST += $$($2_TARGET)
 363     # Now we can setup the depency that will trigger the copying.
 364     $$($1_BIN)$$($2_TARGET) : $2
 365         $(MKDIR) -p $$(@D)
 366         $(CP) $$< $$@
 367         $(CHMOD) -f ug+w $$@
 368 
 369     # And do not forget this target
 370     $1_ALL_COPY_TARGETS += $$($1_BIN)$$($2_TARGET)
 371   endif
 372 endef


 406             | $(SED) -f "$(SRC_ROOT)/make/common/support/unicode2x.sed" \
 407             | $(SED) -e '/^#/d' -e '/^$$$$/d' \
 408                 -e :a -e '/\\$$$$/N; s/\\\n//; ta' \
 409                 -e 's/^[        ]*//;s/[        ]*$$$$//' \
 410                 -e 's/\\=/=/' \
 411             | $(SORT) > $$@
 412         $(CHMOD) -f ug+w $$@
 413 
 414   # And do not forget this target
 415   $1_ALL_COPY_CLEAN_TARGETS += $$($1_BIN)$$($2_TARGET)
 416 endef
 417 
 418 define remove_string
 419   $2 := $$(subst $1,,$$($2))
 420 endef
 421 
 422 define replace_space_with_pathsep
 423   $1:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$2)))
 424 endef
 425 



























 426 define SetupJavaCompilation
 427   # param 1 is for example BUILD_MYPACKAGE
 428   # param 2,3,4,5,6,7,8 are named args.
 429   #   SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC
 430   #   JVM:=path to ..bin/java
 431   #   ADD_JAVAC_FLAGS:=javac flags to append to the default ones.
 432   #   SRC:=one or more directories to search for sources
 433   #   BIN:=store classes here
 434   #   INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages.
 435   #   EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages.
 436   #   COPY:=.prp means copy all prp files to the corresponding package in BIN.
 437   #   COPY_FILES:=myapp/foo/setting.txt means copy this file over to the package myapp/foo
 438   #   CLEAN:=.properties means copy and clean all properties file to the corresponding package in BIN.
 439   #   CLEAN_FILES:=myapp/foo/setting.txt means clean this file over to the package myapp/foo
 440   #   SRCZIP:=Create a src.zip based on the found sources and copied files.
 441   #   INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file!
 442   #   EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file!
 443   #       "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found.
 444   #   JAVAC_SOURCE_PATH_OVERRIDE:=This forces an explicit -sourcepath to javac instead of the complete
 445   #       source roots from SRC. This is sometimes needed when compiling specific subsets of the source.
 446   #   HEADERS:=path to directory where all generated c-headers are written.
 447   #   DEPENDS:=Extra dependecy
 448   #   DISABLE_SJAVAC:=Explicitly disable the use of sjavac for this compilation unit.
 449   $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
 450   $(call LogSetupMacroEntry,SetupJavaCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
 451   $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk))
 452 
 453   # Extract the info from the java compiler setup.
 454   $1_JVM := $$($$($1_SETUP)_JVM)
 455   $1_JAVAC := $$($$($1_SETUP)_JAVAC)
 456   $1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS)
 457   ifeq ($$($1_JAVAC),)
 458     $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP))
 459   endif
 460   $1_SJAVAC_PORTFILE := $$($$($1_SETUP)_SJAVAC_PORTFILE)
 461   $1_SERVER_JVM := $$($$($1_SETUP)_SERVER_JVM)
 462 
 463   # Handle addons and overrides.
 464   $1_SRC:=$$(call ADD_SRCS,$$($1_SRC))
 465   # Make sure the dirs exist.
 466   $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory $$d)))
 467   $$(eval $$(call MakeDir,$$($1_BIN)))
 468   # Add all source roots to the find cache since we are likely going to run find 


   1 #
   2 # Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   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.
  10 #
  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).
  16 #
  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.
  20 #
  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


  25 
  26 # This makefile is much simpler now that it can use the smart javac wrapper
  27 # for dependency tracking between java packages and incremental compiles.
  28 # It could be even more simple if we added support for incremental jar updates
  29 # directly from the smart javac wrapper.
  30 
  31 # Cleaning/copying properties here is not a good solution. The properties
  32 # should be cleaned/copied by a annotation processor in sjavac.
  33 
  34 # When you read this source. Remember that $(sort ...) has the side effect
  35 # of removing duplicates. It is actually this side effect that is
  36 # desired whenever sort is used below!
  37 
  38 ifndef _JAVA_COMPILATION_GMK
  39 _JAVA_COMPILATION_GMK := 1
  40 
  41 ifeq (,$(_MAKEBASE_GMK))
  42   $(error You must include MakeBase.gmk prior to including JavaCompilation.gmk)
  43 endif
  44 
  45 # Java compilation needs SetupZipArchive if we're generating a source zip.
  46 include ZipArchive.gmk
  47 
  48 FALSE_FIND_PATTERN:=-name FILE_NAME_THAT_DOESNT_EXIST
  49 
  50 # Setup make rules for defining a Java compiler, which is needed to compile
  51 # Java code. This rule generates no output.
  52 #
  53 # Parameter 1 is the name of the compiler definition. This name needs to be
  54 # passed to SetupJavaCompilation. This name is used as variable prefix.
  55 #
  56 # Remaining parameters are named arguments. These include:
  57 #   JVM:=The jvm used to run the javac/javah command
  58 #   JAVAC:=The javac jar and bootstrap classpath changes, or just bin/javac if JVM is left out
  59 #   FLAGS:=Flags to be supplied to javac
  60 #   SERVER_DIR:=Use a javac server (-XDserver) and store the server related files here
  61 #   SERVER_JVM:=Use this JVM for the server. Defaults to the JVM above.
  62 define SetupJavaCompiler
  63   $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk))
  64   $(call EvalDebugWrapper,$(strip $1),$(call SetupJavaCompilerInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)))
  65 endef
  66 
  67 define SetupJavaCompilerInner



  68   $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
  69   $(call LogSetupMacroEntry,SetupJavaCompiler($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
  70   $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompiler, please update JavaCompilation.gmk))
  71 
  72   # The port file contains the tcp/ip on which the server listens
  73   # and the cookie necessary to talk to the server.
  74   $1_SJAVAC_PORTFILE:=$$($1_SERVER_DIR)/server.port
  75   # You can use a different JVM to run the background javac server.
  76   ifeq ($$($1_SERVER_JVM),)
  77     # It defaults to the same JVM that is used to start the javac command.
  78     $1_SERVER_JVM:=$$($1_JVM)
  79   endif
  80 endef
  81 
  82 # Setup make rules for creating a jar archive.
  83 #
  84 # Parameter 1 is the name of the rule. This name is used as variable prefix,
  85 # and the targets generated are listed in a variable by that name.
  86 #
  87 # Remaining parameters are named arguments. These include:
  88 #   SRCS:=List of directories in where to find files to add to archive
  89 #   SUFFIXES:=File suffixes to include in jar
  90 #   INCLUDES:=List of directories/packages in SRCS that should be included
  91 #   EXCLUDES:=List of directories/packages in SRCS that should be excluded
  92 #   EXCLUDE_FILES:=List of files in SRCS that should be excluded
  93 #   EXTRA_FILES:=List of files in SRCS that should be included regardless of suffix match.
  94 #   JAR:=Jar file to create
  95 #   MANIFEST:=Optional manifest file template.
  96 #   JARMAIN:=Optional main class to add to manifest
  97 #   JARINDEX:=true means generate the index in the jar file.
  98 #   SKIP_METAINF:=Set to prevent contents of an META-INF directory to be automatically
  99 #       added to the archive.
 100 #   EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest.
 101 #   CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable
 102 define SetupArchive
 103   $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk))
 104   $(call EvalDebugWrapper,$(strip $1),$(call SetupArchiveInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)))
 105 endef














 106 
 107 define SetupArchiveInner
 108   # NOTE: $2 is dependencies, not a named argument!
 109   $(foreach i,3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
 110   $(call LogSetupMacroEntry,SetupArchive($1),<dependencies>,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
 111   $(if $(findstring $(LOG_LEVEL),trace), $(info *[2] <dependencies> = $(strip $2)))
 112   $(if $(16),$(error Internal makefile error: Too many arguments to SetupArchive, please update JavaCompilation.gmk))
 113 
 114   $1_JARMAIN:=$(strip $$($1_JARMAIN))
 115   $1_JARNAME:=$$(notdir $$($1_JAR))
 116   $1_MANIFEST_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_manifest
 117   $1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess
 118   $1_DELETES_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletes
 119   $1_BIN:=$$(dir $$($1_JAR))
 120 
 121   ifeq (,$$($1_SUFFIXES))
 122     # No suffix was set, default to classes.
 123     $1_SUFFIXES:=.class
 124   endif
 125   # Convert suffixes to a find expression
 126   $1_FIND_PATTERNS:=$(FALSE_FIND_PATTERN) $$(patsubst %,$(SPACE)-o$(SPACE)-name$(SPACE)$(DQUOTE)*%$(DQUOTE),$$($1_SUFFIXES))
 127   # On windows, a lot of includes/excludes risk making the command line too long, so


 289           $(RM) $$($1_DELETES_FILE) $$(NEWLINE) \
 290           $$($1_CAPTURE_DELETES) \
 291           $(CAT) $$($1_DELETES_FILE) > $$($1_DELETESS_FILE) $$(NEWLINE) \
 292           if [ -s $$($1_DELETESS_FILE) ]; then \
 293             $(ECHO) "  deleting" `$(WC) -l $$($1_DELETESS_FILE) | $(AWK) '{ print $$$$1 }'` files && \
 294             $(ZIP) -q -d $$@ `$(CAT) $$($1_DELETESS_FILE)` ; \
 295           fi $$(NEWLINE) \
 296           $$($1_UPDATE_CONTENTS) true $$(NEWLINE) \
 297           $$($1_JARINDEX) && true \
 298         , \
 299           $(ECHO) Creating $$($1_NAME) && $(JAR) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) $$(NEWLINE) \
 300           $$($1_SCAPTURE_CONTENTS) \
 301           $$($1_SCAPTURE_METAINF) \
 302           $$($1_SUPDATE_CONTENTS) \
 303           $$($1_JARINDEX) && true )
 304 
 305   # Add jar to target list
 306   $1 += $$($1_JAR)
 307 endef
 308 































































 309 define add_file_to_copy
 310   # param 1 = BUILD_MYPACKAGE
 311   # parma 2 = The source file to copy.
 312   $2_TARGET:=$2
 313   # Remove the source prefix.
 314   $$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET)))
 315   # To allow for automatic overrides, do not create a rule for a target file that
 316   # already has one
 317   ifeq ($$(findstring $$($2_TARGET), $$($1_COPY_LIST)), )
 318     $1_COPY_LIST += $$($2_TARGET)
 319     # Now we can setup the depency that will trigger the copying.
 320     $$($1_BIN)$$($2_TARGET) : $2
 321         $(MKDIR) -p $$(@D)
 322         $(CP) $$< $$@
 323         $(CHMOD) -f ug+w $$@
 324 
 325     # And do not forget this target
 326     $1_ALL_COPY_TARGETS += $$($1_BIN)$$($2_TARGET)
 327   endif
 328 endef


 362             | $(SED) -f "$(SRC_ROOT)/make/common/support/unicode2x.sed" \
 363             | $(SED) -e '/^#/d' -e '/^$$$$/d' \
 364                 -e :a -e '/\\$$$$/N; s/\\\n//; ta' \
 365                 -e 's/^[        ]*//;s/[        ]*$$$$//' \
 366                 -e 's/\\=/=/' \
 367             | $(SORT) > $$@
 368         $(CHMOD) -f ug+w $$@
 369 
 370   # And do not forget this target
 371   $1_ALL_COPY_CLEAN_TARGETS += $$($1_BIN)$$($2_TARGET)
 372 endef
 373 
 374 define remove_string
 375   $2 := $$(subst $1,,$$($2))
 376 endef
 377 
 378 define replace_space_with_pathsep
 379   $1:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$2)))
 380 endef
 381 
 382 # Setup make rules for compiling Java source code to class files and/or a
 383 # resulting jar file.
 384 #
 385 # Parameter 1 is the name of the rule. This name is used as variable prefix,
 386 # and the targets generated are listed in a variable by that name.
 387 #
 388 # Remaining parameters are named arguments. These include:
 389 #   SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC
 390 #   JVM:=path to ..bin/java
 391 #   ADD_JAVAC_FLAGS:=javac flags to append to the default ones.
 392 #   SRC:=one or more directories to search for sources
 393 #   BIN:=store classes here
 394 #   INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages.
 395 #   EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages.
 396 #   COPY:=.prp means copy all prp files to the corresponding package in BIN.
 397 #   COPY_FILES:=myapp/foo/setting.txt means copy this file over to the package myapp/foo
 398 #   CLEAN:=.properties means copy and clean all properties file to the corresponding package in BIN.
 399 #   CLEAN_FILES:=myapp/foo/setting.txt means clean this file over to the package myapp/foo
 400 #   SRCZIP:=Create a src.zip based on the found sources and copied files.
 401 #   INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file!
 402 #   EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file!
 403 #       "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found.
 404 #   JAVAC_SOURCE_PATH_OVERRIDE:=This forces an explicit -sourcepath to javac instead of the complete
 405 #       source roots from SRC. This is sometimes needed when compiling specific subsets of the source.
 406 #   HEADERS:=path to directory where all generated c-headers are written.
 407 #   DEPENDS:=Extra dependecy
 408 #   DISABLE_SJAVAC:=Explicitly disable the use of sjavac for this compilation unit.
 409 define SetupJavaCompilation
 410   $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk))
 411   $(call EvalDebugWrapper,$(strip $1),$(call SetupJavaCompilationInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)))
 412 endef
 413 
 414 define SetupJavaCompilationInner

















 415   $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE))
 416   $(call LogSetupMacroEntry,SetupJavaCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))
 417   $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk))
 418 
 419   # Extract the info from the java compiler setup.
 420   $1_JVM := $$($$($1_SETUP)_JVM)
 421   $1_JAVAC := $$($$($1_SETUP)_JAVAC)
 422   $1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS)
 423   ifeq ($$($1_JAVAC),)
 424     $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP))
 425   endif
 426   $1_SJAVAC_PORTFILE := $$($$($1_SETUP)_SJAVAC_PORTFILE)
 427   $1_SERVER_JVM := $$($$($1_SETUP)_SERVER_JVM)
 428 
 429   # Handle addons and overrides.
 430   $1_SRC:=$$(call ADD_SRCS,$$($1_SRC))
 431   # Make sure the dirs exist.
 432   $$(foreach d,$$($1_SRC), $$(if $$(wildcard $$d),,$$(error SRC specified to SetupJavaCompilation $1 contains missing directory $$d)))
 433   $$(eval $$(call MakeDir,$$($1_BIN)))
 434   # Add all source roots to the find cache since we are likely going to run find 


< prev index next >