328 329 # And do not forget this target 330 $1_ALL_COPY_TARGETS += $$($1_BIN)$$($2_TARGET) 331 endef 332 333 334 # This macro is used only for properties files that are to be 335 # copied over to the classes directory in cleaned form: 336 # Previously this was inconsistently done in different repositories. 337 # This is the new clean standard. Though it is to be superseded by 338 # a standard annotation processor from with sjavac. 339 define add_file_to_copy_and_clean 340 # param 1 = BUILD_MYPACKAGE 341 # parma 2 = The source file to copy and clean. 342 $2_TARGET:=$2 343 # Remove the source prefix. 344 $$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET))) 345 # Now we can setup the depency that will trigger the copying. 346 $$($1_BIN)$$($2_TARGET) : $2 347 $(MKDIR) -p $$(@D) 348 $(CAT) $$< | $(SED) -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \ 349 | $(SED) -f "$(SRC_ROOT)/make/common/support/unicode2x.sed" \ 350 | $(SED) -e '/^#/d' -e '/^$$$$/d' \ 351 -e :a -e '/\\$$$$/N; s/\\\n//; ta' \ 352 -e 's/^[ \t]*//;s/[ \t]*$$$$//' \ 353 -e 's/\\=/=/' | LANG=C $(SORT) > $$@ 354 $(CHMOD) -f ug+w $$@ 355 356 # And do not forget this target 357 $1_ALL_COPY_CLEAN_TARGETS += $$($1_BIN)$$($2_TARGET) 358 endef 359 360 define remove_string 361 $2 := $$(subst $1,,$$($2)) 362 endef 363 364 define replace_space_with_pathsep 365 $1:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$2))) 366 endef 367 368 define SetupJavaCompilation 369 # param 1 is for example BUILD_MYPACKAGE 370 # param 2,3,4,5,6,7,8 are named args. 371 # SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC 372 # JVM:=path to ..bin/java 373 # ADD_JAVAC_FLAGS:=javac flags to append to the default ones. 374 # SRC:=one or more directories to search for sources 375 # BIN:=store classes here 376 # INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages. 377 # EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages. 378 # COPY:=.prp means copy all prp files to the corresponding package in BIN. 379 # CLEAN:=.properties means copy and clean all properties file to the corresponding package in BIN. 380 # COPY_FILES:=myapp/foo/setting.txt means copy this file over to the package myapp/foo 381 # SRCZIP:=Create a src.zip based on the found sources and copied files. 382 # INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file! 383 # EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file! 384 # "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found. 385 # JAVAC_SOURCE_PATH_OVERRIDE:=This forces an explicit -sourcepath to javac instead of the complete 386 # source roots from SRC. This is sometimes needed when compiling specific subsets of the source. 387 # HEADERS:=path to directory where all generated c-headers are written. 388 # DEPENDS:=Extra dependecy 389 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) 390 $(call LogSetupMacroEntry,SetupJavaCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) 391 $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk)) 392 393 # Extract the info from the java compiler setup. 394 $1_JVM := $$($$($1_SETUP)_JVM) 395 $1_JAVAC := $$($$($1_SETUP)_JAVAC) 396 $1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS) 397 ifeq ($$($1_JAVAC),) 398 $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP)) 399 endif 400 $1_SJAVAC_PORTFILE := $$($$($1_SETUP)_SJAVAC_PORTFILE) 420 # Now we have a list of all java files to compile: $$($1_SRCS) 421 422 # Create the corresponding smart javac wrapper command line. 423 $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix .*,$$(subst /,.,$$($1_EXCLUDES)))) \ 424 $$(addprefix -i ,$$(addsuffix .*,$$(subst /,.,$$($1_INCLUDES)))) \ 425 $$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES))) \ 426 $$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) \ 427 -src "$$(subst $$(SPACE),$$(PATH_SEP),$$(strip $$($1_SRC)))" 428 429 # Prepend the source/bin path to the filter expressions. 430 ifneq ($$($1_INCLUDES),) 431 $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES)))) 432 $1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS)) 433 endif 434 ifneq ($$($1_EXCLUDES),) 435 $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) 436 $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS)) 437 endif 438 439 # Find all files to be copied from source to bin. 440 ifneq (,$$($1_COPY)) 441 # Search for all files to be copied. 442 $1_ALL_COPIES := $$(filter $$(addprefix %,$$($1_COPY)),$$($1_ALL_SRCS)) 443 # Copy these explicitly 444 $1_ALL_COPIES += $$($1_COPY_FILES) 445 # Copy must also respect filters. 446 ifneq (,$$($1_INCLUDES)) 447 $1_ALL_COPIES := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_COPIES)) 448 endif 449 ifneq (,$$($1_EXCLUDES)) 450 $1_ALL_COPIES := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_COPIES)) 451 endif 452 ifneq (,$$($1_EXCLUDE_FILES)) 453 $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_COPIES)) 454 endif 455 # All files below META-INF are always copied. 456 $1_ALL_COPIES += $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS)) 457 ifneq (,$$($1_ALL_COPIES)) 458 # Yep, there are files to be copied! 459 $1_ALL_COPY_TARGETS:= 460 $$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i))) 461 # Now we can depend on $$($1_ALL_COPY_TARGETS) to copy all files! 462 endif 463 endif 464 465 # Find all property files to be copied and cleaned from source to bin. 466 ifneq (,$$($1_CLEAN)) 467 # Search for all files to be copied. 468 $1_ALL_CLEANS := $$(filter $$(addprefix %,$$($1_CLEAN)),$$($1_ALL_SRCS)) 469 # Copy and clean must also respect filters. 470 ifneq (,$$($1_INCLUDES)) 471 $1_ALL_CLEANS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_CLEANS)) 472 endif 473 ifneq (,$$($1_EXCLUDES)) 474 $1_ALL_CLEANS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_CLEANS)) 475 endif 476 ifneq (,$$($1_EXCLUDE_FILES)) 477 $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_CLEANS)) 478 endif 479 ifneq (,$$($1_ALL_CLEANS)) 480 # Yep, there are files to be copied and cleaned! 481 $1_ALL_COPY_CLEAN_TARGETS:= 482 $$(foreach i,$$($1_ALL_CLEANS),$$(eval $$(call add_file_to_copy_and_clean,$1,$$i))) 483 # Now we can depend on $$($1_ALL_COPY_CLEAN_TARGETS) to copy all files! 484 endif 485 endif 486 487 # Prep the source paths. 488 ifneq ($$($1_JAVAC_SOURCE_PATH_OVERRIDE),) | 328 329 # And do not forget this target 330 $1_ALL_COPY_TARGETS += $$($1_BIN)$$($2_TARGET) 331 endef 332 333 334 # This macro is used only for properties files that are to be 335 # copied over to the classes directory in cleaned form: 336 # Previously this was inconsistently done in different repositories. 337 # This is the new clean standard. Though it is to be superseded by 338 # a standard annotation processor from with sjavac. 339 define add_file_to_copy_and_clean 340 # param 1 = BUILD_MYPACKAGE 341 # parma 2 = The source file to copy and clean. 342 $2_TARGET:=$2 343 # Remove the source prefix. 344 $$(foreach i,$$($1_SRC),$$(eval $$(call remove_string,$$i,$2_TARGET))) 345 # Now we can setup the depency that will trigger the copying. 346 $$($1_BIN)$$($2_TARGET) : $2 347 $(MKDIR) -p $$(@D) 348 $(CAT) $$< | $(SED) -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' \ 349 -e 's/\([^\\]\)!/\1\\!/g' -e 's/#.*/#/g' \ 350 | $(SED) -f "$(SRC_ROOT)/make/common/support/unicode2x.sed" \ 351 | $(SED) -e '/^#/d' -e '/^$$$$/d' \ 352 -e :a -e '/\\$$$$/N; s/\\\n//; ta' \ 353 -e 's/^[ \t]*//;s/[ \t]*$$$$//' \ 354 -e 's/\\=/=/' | LANG=C $(SORT) > $$@ 355 $(CHMOD) -f ug+w $$@ 356 357 # And do not forget this target 358 $1_ALL_COPY_CLEAN_TARGETS += $$($1_BIN)$$($2_TARGET) 359 endef 360 361 define remove_string 362 $2 := $$(subst $1,,$$($2)) 363 endef 364 365 define replace_space_with_pathsep 366 $1:=$(subst $(SPACE),$(PATH_SEP),$(strip $(patsubst %,%,$2))) 367 endef 368 369 define SetupJavaCompilation 370 # param 1 is for example BUILD_MYPACKAGE 371 # param 2,3,4,5,6,7,8 are named args. 372 # SETUP:=must point to a previously setup java compiler, for example: SETUP:=BOOTJAVAC 373 # JVM:=path to ..bin/java 374 # ADD_JAVAC_FLAGS:=javac flags to append to the default ones. 375 # SRC:=one or more directories to search for sources 376 # BIN:=store classes here 377 # INCLUDES:=myapp.foo means will only compile java files in myapp.foo or any of its sub-packages. 378 # EXCLUDES:=myapp.foo means will do not compile java files in myapp.foo or any of its sub-packages. 379 # COPY:=.prp means copy all prp files to the corresponding package in BIN. 380 # COPY_FILES:=myapp/foo/setting.txt means copy this file over to the package myapp/foo 381 # CLEAN:=.properties means copy and clean all properties file to the corresponding package in BIN. 382 # CLEAN_FILES:=myapp/foo/setting.txt means clean this file over to the package myapp/foo 383 # SRCZIP:=Create a src.zip based on the found sources and copied files. 384 # INCLUDE_FILES:="com/sun/SolarisFoobar.java" means only compile this file! 385 # EXCLUDE_FILES:="com/sun/SolarisFoobar.java" means do not compile this particular file! 386 # "SolarisFoobar.java" means do not compile SolarisFoobar, wherever it is found. 387 # JAVAC_SOURCE_PATH_OVERRIDE:=This forces an explicit -sourcepath to javac instead of the complete 388 # source roots from SRC. This is sometimes needed when compiling specific subsets of the source. 389 # HEADERS:=path to directory where all generated c-headers are written. 390 # DEPENDS:=Extra dependecy 391 $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $($i),$1_$(strip $($i)))$(NEWLINE)) 392 $(call LogSetupMacroEntry,SetupJavaCompilation($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) 393 $(if $(16),$(error Internal makefile error: Too many arguments to SetupJavaCompilation, please update JavaCompilation.gmk)) 394 395 # Extract the info from the java compiler setup. 396 $1_JVM := $$($$($1_SETUP)_JVM) 397 $1_JAVAC := $$($$($1_SETUP)_JAVAC) 398 $1_FLAGS := $$($$($1_SETUP)_FLAGS) $(JAVAC_FLAGS) $$($1_ADD_JAVAC_FLAGS) 399 ifeq ($$($1_JAVAC),) 400 $$(error The Java compilation $1 refers to a non-existant java compiler setup $$($1_SETUP)) 401 endif 402 $1_SJAVAC_PORTFILE := $$($$($1_SETUP)_SJAVAC_PORTFILE) 422 # Now we have a list of all java files to compile: $$($1_SRCS) 423 424 # Create the corresponding smart javac wrapper command line. 425 $1_SJAVAC_ARGS:=$$(addprefix -x ,$$(addsuffix .*,$$(subst /,.,$$($1_EXCLUDES)))) \ 426 $$(addprefix -i ,$$(addsuffix .*,$$(subst /,.,$$($1_INCLUDES)))) \ 427 $$(addprefix -xf *,$$(strip $$($1_EXCLUDE_FILES))) \ 428 $$(addprefix -if *,$$(strip $$($1_INCLUDE_FILES))) \ 429 -src "$$(subst $$(SPACE),$$(PATH_SEP),$$(strip $$($1_SRC)))" 430 431 # Prepend the source/bin path to the filter expressions. 432 ifneq ($$($1_INCLUDES),) 433 $1_SRC_INCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_INCLUDES)))) 434 $1_SRCS := $$(filter $$($1_SRC_INCLUDES),$$($1_SRCS)) 435 endif 436 ifneq ($$($1_EXCLUDES),) 437 $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES)))) 438 $1_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_SRCS)) 439 endif 440 441 # Find all files to be copied from source to bin. 442 ifneq (,$$($1_COPY)$$($1_COPY_FILES)) 443 # Search for all files to be copied. 444 $1_ALL_COPIES := $$(filter $$(addprefix %,$$($1_COPY)),$$($1_ALL_SRCS)) 445 # Copy these explicitly 446 $1_ALL_COPIES += $$($1_COPY_FILES) 447 # Copy must also respect filters. 448 ifneq (,$$($1_INCLUDES)) 449 $1_ALL_COPIES := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_COPIES)) 450 endif 451 ifneq (,$$($1_EXCLUDES)) 452 $1_ALL_COPIES := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_COPIES)) 453 endif 454 ifneq (,$$($1_EXCLUDE_FILES)) 455 $1_ALL_COPIES := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_COPIES)) 456 endif 457 endif 458 # All files below META-INF are always copied. 459 $1_ALL_COPIES += $$(filter $$(addsuffix /META-INF%,$$($1_SRC)),$$($1_ALL_SRCS)) 460 ifneq (,$$($1_ALL_COPIES)) 461 # Yep, there are files to be copied! 462 $1_ALL_COPY_TARGETS:= 463 $$(foreach i,$$($1_ALL_COPIES),$$(eval $$(call add_file_to_copy,$1,$$i))) 464 # Now we can depend on $$($1_ALL_COPY_TARGETS) to copy all files! 465 endif 466 467 # Find all property files to be copied and cleaned from source to bin. 468 ifneq (,$$($1_CLEAN)$$($1_CLEAN_FILES)) 469 # Search for all files to be copied. 470 $1_ALL_CLEANS := $$(filter $$(addprefix %,$$($1_CLEAN)),$$($1_ALL_SRCS)) 471 # Clean these explicitly 472 $1_ALL_CLEANS += $$($1_CLEAN_FILES) 473 # Copy and clean must also respect filters. 474 ifneq (,$$($1_INCLUDES)) 475 $1_ALL_CLEANS := $$(filter $$($1_SRC_INCLUDES),$$($1_ALL_CLEANS)) 476 endif 477 ifneq (,$$($1_EXCLUDES)) 478 $1_ALL_CLEANS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_CLEANS)) 479 endif 480 ifneq (,$$($1_EXCLUDE_FILES)) 481 $1_ALL_CLEANS := $$(filter-out $$($1_EXCLUDE_FILES_PATTERN),$$($1_ALL_CLEANS)) 482 endif 483 ifneq (,$$($1_ALL_CLEANS)) 484 # Yep, there are files to be copied and cleaned! 485 $1_ALL_COPY_CLEAN_TARGETS:= 486 $$(foreach i,$$($1_ALL_CLEANS),$$(eval $$(call add_file_to_copy_and_clean,$1,$$i))) 487 # Now we can depend on $$($1_ALL_COPY_CLEAN_TARGETS) to copy all files! 488 endif 489 endif 490 491 # Prep the source paths. 492 ifneq ($$($1_JAVAC_SOURCE_PATH_OVERRIDE),) |