Makefile revision 35cfb08c588ba0af98ad0845ced6a9eeeeca4054
1# Put some miscellaneous rules here 2 3# Pick a reasonable string to use to identify files. 4ifneq "" "$(filter eng.%,$(BUILD_NUMBER))" 5 # BUILD_NUMBER has a timestamp in it, which means that 6 # it will change every time. Pick a stable value. 7 FILE_NAME_TAG := eng.$(USER) 8else 9 FILE_NAME_TAG := $(BUILD_NUMBER) 10endif 11 12# ----------------------------------------------------------------- 13# Define rules to copy PRODUCT_COPY_FILES defined by the product. 14# PRODUCT_COPY_FILES contains words like <source file>:<dest file>. 15# <dest file> is relative to $(PRODUCT_OUT), so it should look like, 16# e.g., "system/etc/file.xml". 17$(foreach cf,$(PRODUCT_COPY_FILES), \ 18 $(eval _w := $(subst :,$(space),$(cf))) \ 19 $(eval _src := $(word 1,$(_w))) \ 20 $(eval _dest := $(subst //,/,$(PRODUCT_OUT)/$(word 2,$(_w)))) \ 21 $(eval $(call copy-one-file,$(_src),$(_dest))) \ 22 $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_dest)) \ 23 ) 24 25# ----------------------------------------------------------------- 26# docs/index.html 27gen := $(OUT_DOCS)/index.html 28ALL_DOCS += $(gen) 29$(gen): frameworks/base/docs/docs-redirect-index.html 30 @mkdir -p $(dir $@) 31 @cp -f $< $@ 32 33# ----------------------------------------------------------------- 34# default.prop 35INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop 36ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET) 37ADDITIONAL_DEFAULT_PROPERTIES := \ 38 $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) 39 40$(INSTALLED_DEFAULT_PROP_TARGET): 41 @echo Target buildinfo: $@ 42 @mkdir -p $(dir $@) 43 $(hide) echo "#" > $@; \ 44 echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \ 45 echo "#" >> $@; 46 $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \ 47 echo "$(line)" >> $@;) 48 49# ----------------------------------------------------------------- 50# build.prop 51INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop 52ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET) 53ADDITIONAL_BUILD_PROPERTIES := \ 54 $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES)) 55 56# A list of arbitrary tags describing the build configuration. 57# Force ":=" so we can use += 58BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS) 59ifeq ($(TARGET_BUILD_TYPE),debug) 60 BUILD_VERSION_TAGS += debug 61endif 62# Apps are always signed with test keys, and may be re-signed in a post-build 63# step. If that happens, the "test-keys" tag will be removed by that step. 64BUILD_VERSION_TAGS += test-keys 65ifndef INCLUDE_TEST_OTA_KEYS 66 BUILD_VERSION_TAGS += ota-rel-keys 67endif 68BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS))) 69 70# A human-readable string that descibes this build in detail. 71build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER) $(BUILD_VERSION_TAGS) 72$(INSTALLED_BUILD_PROP_TARGET): PRIVATE_BUILD_DESC := $(build_desc) 73 74# The string used to uniquely identify this build; used by the OTA server. 75ifeq (,$(strip $(BUILD_FINGERPRINT))) 76 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE)/$(TARGET_BOOTLOADER_BOARD_NAME):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 77endif 78ifneq ($(words $(BUILD_FINGERPRINT)),1) 79 $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)") 80endif 81 82# Selects the first locale in the list given as the argument, 83# and splits it into language and region, which each may be 84# empty. 85define default-locale 86$(subst _, , $(firstword $(1))) 87endef 88 89# Selects the first locale in the list given as the argument 90# and returns the language (or the region) 91define default-locale-language 92$(word 2, 2, $(call default-locale, $(1))) 93endef 94define default-locale-region 95$(word 3, 3, $(call default-locale, $(1))) 96endef 97 98BUILDINFO_SH := build/tools/buildinfo.sh 99$(INSTALLED_BUILD_PROP_TARGET): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) 100 @echo Target buildinfo: $@ 101 @mkdir -p $(dir $@) 102 $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \ 103 TARGET_DEVICE="$(TARGET_DEVICE)" \ 104 PRODUCT_NAME="$(TARGET_PRODUCT)" \ 105 PRODUCT_BRAND="$(PRODUCT_BRAND)" \ 106 PRODUCT_DEFAULT_LANGUAGE="$(call default-locale-language,$(PRODUCT_LOCALES))" \ 107 PRODUCT_DEFAULT_REGION="$(call default-locale-region,$(PRODUCT_LOCALES))" \ 108 PRODUCT_MODEL="$(PRODUCT_MODEL)" \ 109 PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \ 110 PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \ 111 BUILD_ID="$(BUILD_ID)" \ 112 BUILD_NUMBER="$(BUILD_NUMBER)" \ 113 PLATFORM_VERSION="$(PLATFORM_VERSION)" \ 114 PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \ 115 BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \ 116 TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \ 117 BUILD_FINGERPRINT="$(BUILD_FINGERPRINT)" \ 118 TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \ 119 bash $(BUILDINFO_SH) > $@ 120 $(hide) if [ -f $(TARGET_DEVICE_DIR)/system.prop ]; then \ 121 cat $(TARGET_DEVICE_DIR)/system.prop >> $@; \ 122 fi 123 $(if $(ADDITIONAL_BUILD_PROPERTIES), \ 124 $(hide) echo >> $@; \ 125 echo "#" >> $@; \ 126 echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \ 127 echo "#" >> $@; ) 128 $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \ 129 echo "$(line)" >> $@;) 130 131build_desc := 132 133# ----------------------------------------------------------------- 134# sdk-build.prop 135# 136# There are certain things in build.prop that we don't want to 137# ship with the sdk; remove them. 138 139# This must be a list of entire property keys followed by 140# "=" characters, without any internal spaces. 141sdk_build_prop_remove := \ 142 ro.build.user= \ 143 ro.build.host= \ 144 ro.product.brand= \ 145 ro.product.manufacturer= \ 146 ro.product.device= 147# TODO: Remove this soon-to-be obsolete property 148sdk_build_prop_remove += ro.build.product= 149INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop 150$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) 151 @echo SDK buildinfo: $@ 152 @mkdir -p $(dir $@) 153 $(hide) grep -v "$(subst $(space),\|,$(strip \ 154 $(sdk_build_prop_remove)))" $< > $@.tmp 155 $(hide) for x in $(sdk_build_prop_remove); do \ 156 echo "$$x"generic >> $@.tmp; done 157 $(hide) mv $@.tmp $@ 158 159# ----------------------------------------------------------------- 160# package stats 161PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt 162PACKAGES_TO_STAT := \ 163 $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \ 164 $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES)))) 165$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT) 166 @echo Package stats: $@ 167 @mkdir -p $(dir $@) 168 $(hide) rm -f $@ 169 $(hide) build/tools/dump-package-stats $^ > $@ 170 171.PHONY: package-stats 172package-stats: $(PACKAGE_STATS_FILE) 173 174# ----------------------------------------------------------------- 175# Cert-to-package mapping. Used by the post-build signing tools. 176name := $(TARGET_PRODUCT) 177ifeq ($(TARGET_BUILD_TYPE),debug) 178 name := $(name)_debug 179endif 180name := $(name)-apkcerts-$(FILE_NAME_TAG) 181intermediates := \ 182 $(call intermediates-dir-for,PACKAGING,apkcerts) 183APKCERTS_FILE := $(intermediates)/$(name).txt 184# Depending on the built packages isn't exactly right, 185# but it should guarantee that the apkcerts file is rebuilt 186# if any packages change which certs they're signed with. 187all_built_packages := $(foreach p,$(PACKAGES),$(ALL_MODULES.$(p).BUILT)) 188$(APKCERTS_FILE): $(all_built_packages) 189 @echo APK certs list: $@ 190 @mkdir -p $(dir $@) 191 @rm -f $@ 192 $(hide) $(foreach p,$(PACKAGES),\ 193 echo 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \ 194 private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@;) 195 196.PHONY: apkcerts-list 197apkcerts-list: $(APKCERTS_FILE) 198 199# ----------------------------------------------------------------- 200# installed file list 201INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt 202$(INSTALLED_FILES_FILE): $(ALL_DEFAULT_INSTALLED_MODULES) 203 @echo Installed file list: $@ 204 @mkdir -p $(dir $@) 205 @rm -f $@ 206 $(hide) (cd $(PRODUCT_OUT) && \ 207 find system data -type f -printf 'name="%p" size=%s\n') | \ 208 sort > $@ 209 210.PHONY: installed-file-list 211installed-file-list: $(INSTALLED_FILES_FILE) 212 213# ----------------------------------------------------------------- 214# module info file 215ifdef CREATE_MODULE_INFO_FILE 216 MODULE_INFO_FILE := $(PRODUCT_OUT)/module-info.txt 217 $(info Generating $(MODULE_INFO_FILE)...) 218 $(shell rm -f $(MODULE_INFO_FILE)) 219 $(foreach m,$(ALL_MODULES), \ 220 $(shell echo "NAME=\"$(m)\"" \ 221 "PATH=\"$(strip $(ALL_MODULES.$(m).PATH))\"" \ 222 "TAGS=\"$(strip $(filter-out _%,$(ALL_MODULES.$(m).TAGS)))\"" \ 223 "BUILT=\"$(strip $(ALL_MODULES.$(m).BUILT))\"" \ 224 "INSTALLED=\"$(strip $(ALL_MODULES.$(m).INSTALLED))\"" >> $(MODULE_INFO_FILE))) 225endif 226 227# Rules that need to be present for the simulator, even 228# if they don't do anything. 229.PHONY: systemimage 230systemimage: 231 232ifneq ($(TARGET_SIMULATOR),true) 233 234# ################################################################# 235# Targets for boot/OS images 236# ################################################################# 237 238# ----------------------------------------------------------------- 239# the ramdisk 240INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \ 241 $(ALL_PREBUILT) \ 242 $(ALL_COPIED_HEADERS) \ 243 $(ALL_GENERATED_SOURCES) \ 244 $(ALL_DEFAULT_INSTALLED_MODULES)) 245 246INSTALLED_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img 247$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) 248 $(call pretty,"Target ram disk: $@") 249 $(hide) $(MKBOOTFS) $(TARGET_ROOT_OUT) | gzip > $@ 250 251 252ifneq ($(strip $(TARGET_NO_KERNEL)),true) 253 254# ----------------------------------------------------------------- 255# the boot image, which is a collection of other images. 256INTERNAL_BOOTIMAGE_ARGS := \ 257 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 258 --kernel $(INSTALLED_KERNEL_TARGET) \ 259 --ramdisk $(INSTALLED_RAMDISK_TARGET) 260 261INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS)) 262 263BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE)) 264ifdef BOARD_KERNEL_CMDLINE 265 INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 266endif 267 268INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img 269 270ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true) 271tmp_dir_for_image := $(call intermediates-dir-for,EXECUTABLES,boot_img)/bootimg 272INTERNAL_BOOTIMAGE_ARGS += --tmpdir $(tmp_dir_for_image) 273INTERNAL_BOOTIMAGE_ARGS += --genext2fs $(MKEXT2IMG) 274$(INSTALLED_BOOTIMAGE_TARGET): $(MKEXT2IMG) $(INTERNAL_BOOTIMAGE_FILES) 275 $(call pretty,"Target boot image: $@") 276 $(hide) $(MKEXT2BOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@ 277 278else # TARGET_BOOTIMAGE_USE_EXT2 != true 279 280$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) 281 $(call pretty,"Target boot image: $@") 282 $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) --output $@ 283 $(hide) $(call assert-max-file-size,$@,$(BOARD_BOOTIMAGE_MAX_SIZE)) 284endif # TARGET_BOOTIMAGE_USE_EXT2 285 286else # TARGET_NO_KERNEL 287# HACK: The top-level targets depend on the bootimage. Not all targets 288# can produce a bootimage, though, and emulator targets need the ramdisk 289# instead. Fake it out by calling the ramdisk the bootimage. 290# TODO: make the emulator use bootimages, and make mkbootimg accept 291# kernel-less inputs. 292INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET) 293endif 294 295# ----------------------------------------------------------------- 296# NOTICE files 297# 298# This needs to be before the systemimage rules, because it adds to 299# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files 300# go into the systemimage. 301 302.PHONY: notice_files 303 304# Create the rule to combine the files into text and html forms 305# $(1) - Plain text output file 306# $(2) - HTML output file 307# $(3) - File title 308# $(4) - Directory to use. Notice files are all $(4)/src. Other 309# directories in there will be used for scratch 310# $(5) - Dependencies for the output files 311# 312# The algorithm here is that we go collect a hash for each of the notice 313# files and write the names of the files that match that hash. Then 314# to generate the real files, we go print out all of the files and their 315# hashes. 316# 317# These rules are fairly complex, so they depend on this makefile so if 318# it changes, they'll run again. 319# 320# TODO: We could clean this up so that we just record the locations of the 321# original notice files instead of making rules to copy them somwehere. 322# Then we could traverse that without quite as much bash drama. 323define combine-notice-files 324$(1) $(2): PRIVATE_MESSAGE := $(3) 325$(1) $(2) $(4)/hash-timestamp: PRIVATE_DIR := $(4) 326$(4)/hash-timestamp: $(5) $(BUILD_SYSTEM)/Makefile 327 @echo Finding NOTICE files: $$@ 328 $$(hide) rm -rf $$@ $$(PRIVATE_DIR)/hash 329 $$(hide) mkdir -p $$(PRIVATE_DIR)/hash 330 $$(hide) for file in $$$$(find $$(PRIVATE_DIR)/src -type f); do \ 331 hash=$$$$($(MD5SUM) $$$$file | sed -e "s/ .*//"); \ 332 hashfile=$$(PRIVATE_DIR)/hash/$$$$hash; \ 333 echo $$$$file >> $$$$hashfile; \ 334 done 335 $$(hide) touch $$@ 336$(1): $(4)/hash-timestamp 337 @echo Combining NOTICE files: $$@ 338 $$(hide) mkdir -p $$(dir $$@) 339 $$(hide) echo $$(PRIVATE_MESSAGE) > $$@ 340 $$(hide) find $$(PRIVATE_DIR)/hash -type f | xargs cat | sort | \ 341 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> $$@ 342 $$(hide) echo >> $$@ 343 $$(hide) echo >> $$@ 344 $$(hide) echo >> $$@ 345 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \ 346 echo "============================================================"\ 347 >> $$@; \ 348 echo "Notices for file(s):" >> $$@; \ 349 cat $$$$hashfile | sort | \ 350 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1:" >> \ 351 $$@; \ 352 echo "------------------------------------------------------------"\ 353 >> $$@; \ 354 echo >> $$@; \ 355 orig=$$$$(head -n 1 $$$$hashfile); \ 356 cat $$$$orig >> $$@; \ 357 echo >> $$@; \ 358 echo >> $$@; \ 359 echo >> $$@; \ 360 done 361$(2): $(4)/hash-timestamp 362 @echo Combining NOTICE files: $$@ 363 $$(hide) mkdir -p $$(dir $$@) 364 $$(hide) echo "<html><head>" > $$@ 365 $$(hide) echo "<style type=\"text/css\">" >> $$@ 366 $$(hide) echo "body { padding: 0; font-family: sans-serif; }" >> $$@ 367 $$(hide) echo ".same-license { background-color: #eeeeee; border-top: 20px solid white; padding: 10px; }" >> $$@ 368 $$(hide) echo ".label { font-weight: bold; }" >> $$@ 369 $$(hide) echo ".file-list { margin-left: 1em; font-color: blue; }" >> $$@ 370 $$(hide) echo "</style>" >> $$@ 371 $$(hide) echo "</head><body topmargin=\"0\" leftmargin=\"0\" rightmargin=\"0\" bottommargin=\"0\">" >> $$@ 372 $$(hide) echo "<table cellpading=\"0\" cellspacing=\"0\" border=\"0\">" \ 373 >> $$@ 374 $$(hide) for hashfile in $$$$(find $$(PRIVATE_DIR)/hash -type f); do \ 375 cat $$$$hashfile | sort | \ 376 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: <a name=\"\1\"></a>:" >> \ 377 $$@; \ 378 echo "<tr><td class=\"same-license\">" >> $$@; \ 379 echo "<div class=\"label\">Notices for file(s):</div>" >> $$@; \ 380 echo "<div class=\"file-list\">" >> $$@; \ 381 cat $$$$hashfile | sort | \ 382 sed -e "s:$$(PRIVATE_DIR)/src\(.*\)\.txt: \1<br/>:" >> $$@; \ 383 echo "</div><!-- file-list -->" >> $$@; \ 384 echo >> $$@; \ 385 orig=$$$$(head -n 1 $$$$hashfile); \ 386 echo "<pre class=\"license-text\">" >> $$@; \ 387 cat $$$$orig | sed -e "s/\&/\&/g" | sed -e "s/</\</g" \ 388 | sed -e "s/>/\>/g" >> $$@; \ 389 echo "</pre><!-- license-text -->" >> $$@; \ 390 echo "</td></tr><!-- same-license -->" >> $$@; \ 391 echo >> $$@; \ 392 echo >> $$@; \ 393 echo >> $$@; \ 394 done 395 $$(hide) echo "</table>" >> $$@ 396 $$(hide) echo "</body></html>" >> $$@ 397notice_files: $(1) $(2) 398endef 399 400# TODO These intermediate NOTICE.txt/NOTICE.html files should go into 401# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from 402# the src subdirectory. 403 404target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt 405target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html 406target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz 407tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt 408tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html 409 410kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt 411 412$(eval $(call combine-notice-files, \ 413 $(target_notice_file_txt), \ 414 $(target_notice_file_html), \ 415 "Notices for files contained in the filesystem images in this directory:", \ 416 $(TARGET_OUT_NOTICE_FILES), \ 417 $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file))) 418 419$(eval $(call combine-notice-files, \ 420 $(tools_notice_file_txt), \ 421 $(tools_notice_file_html), \ 422 "Notices for files contained in the tools directory:", \ 423 $(HOST_OUT_NOTICE_FILES), \ 424 $(ALL_DEFAULT_INSTALLED_MODULES))) 425 426# Install the html file at /system/etc/NOTICE.html.gz. 427# This is not ideal, but this is very late in the game, after a lot of 428# the module processing has already been done -- in fact, we used the 429# fact that all that has been done to get the list of modules that we 430# need notice files for. 431$(target_notice_file_html_gz): $(target_notice_file_html) 432 gzip -c $< > $@ 433installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz 434$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP) 435 $(copy-file-to-target) 436ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz) 437 438# The kernel isn't really a module, so to get its module file in there, we 439# make the target NOTICE files depend on this particular file too, which will 440# then be in the right directory for the find in combine-notice-files to work. 441$(kernel_notice_file): \ 442 prebuilt/$(TARGET_PREBUILT_TAG)/kernel/LINUX_KERNEL_COPYING \ 443 | $(ACP) 444 @echo Copying: $@ 445 $(hide) mkdir -p $(dir $@) 446 $(hide) $(ACP) $< $@ 447 448 449# ################################################################# 450# Targets for user images 451# ################################################################# 452 453ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 454include external/genext2fs/Config.mk 455INTERNAL_MKUSERFS := $(MKEXT2IMG) 456else 457INTERNAL_MKUSERFS := $(MKYAFFS2) 458endif 459 460# ----------------------------------------------------------------- 461# system yaffs image 462# 463# First, the "unoptimized" image, which contains .apk/.jar files 464# that contain regular, unoptimized/unverified .dex entries. 465# 466systemimage_unopt_intermediates := \ 467 $(call intermediates-dir-for,PACKAGING,systemimage_unopt) 468BUILT_SYSTEMIMAGE_UNOPT := $(systemimage_unopt_intermediates)/system.img 469 470INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \ 471 $(ALL_PREBUILT) \ 472 $(ALL_COPIED_HEADERS) \ 473 $(ALL_GENERATED_SOURCES) \ 474 $(ALL_DEFAULT_INSTALLED_MODULES)) 475 476ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 477## generate an ext2 image 478# $(1): output file 479define build-systemimage-target 480 @echo "Target system fs image: $(1)" 481 $(call build-userimage-ext2-target,$(TARGET_OUT),$(1),system,) 482endef 483 484else # TARGET_USERIMAGES_USE_EXT2 != true 485 486## generate a yaffs2 image 487# $(1): output file 488define build-systemimage-target 489 @echo "Target system fs image: $(1)" 490 @mkdir -p $(dir $(1)) 491 $(hide) $(MKYAFFS2) -f $(TARGET_OUT) $(1) 492endef 493endif # TARGET_USERIMAGES_USE_EXT2 494 495$(BUILT_SYSTEMIMAGE_UNOPT): $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_MKUSERFS) 496 $(call build-systemimage-target,$@) 497 498# The installed image, which may be optimized or unoptimized. 499# 500INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img 501 502ifdef WITH_DEXPREOPT 503 ifndef DISABLE_DEXPREOPT 504 with_dexpreopt := true 505 endif 506endif 507ifdef with_dexpreopt 508 # This file will set BUILT_SYSTEMIMAGE and SYSTEMIMAGE_SOURCE_DIR 509 include build/tools/dexpreopt/Config.mk 510else 511 BUILT_SYSTEMIMAGE := $(BUILT_SYSTEMIMAGE_UNOPT) 512 SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT) 513endif 514 515$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) | $(ACP) 516 @echo "Install system fs image: $@" 517 $(copy-file-to-target) 518 $(hide) $(call assert-max-file-size,$@,$(BOARD_SYSTEMIMAGE_MAX_SIZE)) 519 520systemimage: $(INSTALLED_SYSTEMIMAGE) 521 522.PHONY: systemimage-nodeps snod 523systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \ 524 | $(INTERNAL_MKUSERFS) 525 @echo "make $@: ignoring dependencies" 526 $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE)) 527 $(hide) $(call assert-max-file-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_MAX_SIZE)) 528 529####### 530## system tarball 531define build-systemtarball-target 532 $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)") 533 $(MKTARBALL) $(FS_GET_STATS) \ 534 $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \ 535 $(INSTALLED_SYSTEMTARBALL_TARGET) 536endef 537 538system_tar := $(PRODUCT_OUT)/system.tar 539INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).bz2 540$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar) 541$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES) 542 $(build-systemtarball-target) 543 544.PHONY: systemtarball-nodeps 545systemtarball-nodeps: $(FS_GET_STATS) \ 546 $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS)) 547 $(build-systemtarball-target) 548 549.PHONY: stnod 550stnod: systemtarball-nodeps 551 552 553# ----------------------------------------------------------------- 554# data partition image 555INTERNAL_USERDATAIMAGE_FILES := \ 556 $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) 557 558ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) 559## Generate an ext2 image 560define build-userdataimage-target 561 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)") 562 $(call build-userimage-ext2-target,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET),userdata,) 563 $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE)) 564endef 565 566else # TARGET_USERIMAGES_USE_EXT2 != true 567 568## Generate a yaffs2 image 569define build-userdataimage-target 570 $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)") 571 $(hide) $(MKYAFFS2) -f $(TARGET_OUT_DATA) $(INSTALLED_USERDATAIMAGE_TARGET) 572 $(hide) $(call assert-max-file-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_MAX_SIZE)) 573endef 574endif # TARGET_USERIMAGES_USE_EXT2 575 576INSTALLED_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img 577$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_MKUSERFS) \ 578 $(INTERNAL_USERDATAIMAGE_FILES) 579 $(build-userdataimage-target) 580 581.PHONY: userdataimage-nodeps 582userdataimage-nodeps: $(INTERNAL_MKUSERFS) 583 $(build-userdataimage-target) 584 585####### 586## data partition tarball 587define build-userdatatarball-target 588 $(call pretty,"Target userdata fs tarball: " \ 589 "$(INSTALLED_USERDATATARBALL_TARGET)") 590 $(MKTARBALL) $(FS_GET_STATS) \ 591 $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \ 592 $(INSTALLED_USERDATATARBALL_TARGET) 593endef 594 595userdata_tar := $(PRODUCT_OUT)/userdata.tar 596INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2 597$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar) 598$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES) 599 $(build-userdatatarball-target) 600 601.PHONY: userdatatarball-nodeps 602userdatatarball-nodeps: $(FS_GET_STATS) 603 $(build-userdatatarball-target) 604 605 606# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 607ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 608 609# ----------------------------------------------------------------- 610# Recovery image 611INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img 612 613recovery_initrc := $(call include-path-for, recovery)/etc/init.rc 614recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system 615recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img 616recovery_build_prop := $(INSTALLED_BUILD_PROP_TARGET) 617recovery_binary := $(call intermediates-dir-for,EXECUTABLES,recovery)/recovery 618recovery_resources := $(call include-path-for, recovery)/res 619 620INTERNAL_RECOVERYIMAGE_ARGS := \ 621 $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ 622 --kernel $(recovery_kernel) \ 623 --ramdisk $(recovery_ramdisk) 624 625# Assumes this has already been stripped 626ifdef BOARD_KERNEL_CMDLINE 627 INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" 628endif 629 630$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) \ 631 $(INSTALLED_RAMDISK_TARGET) \ 632 $(INSTALLED_BOOTIMAGE_TARGET) \ 633 $(recovery_binary) \ 634 $(recovery_initrc) $(recovery_kernel) \ 635 $(INSTALLED_2NDBOOTLOADER_TARGET) \ 636 $(recovery_build_prop) 637 @echo ----- Making recovery image ------ 638 rm -rf $(TARGET_RECOVERY_OUT) 639 mkdir -p $(TARGET_RECOVERY_OUT) 640 mkdir -p $(TARGET_RECOVERY_ROOT_OUT) 641 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc 642 mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/tmp 643 echo Copying baseline ramdisk... 644 cp -R $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) 645 echo Modifying ramdisk contents... 646 cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/ 647 cp -f $(recovery_binary) $(TARGET_RECOVERY_ROOT_OUT)/sbin/ 648 cp -rf $(recovery_resources) $(TARGET_RECOVERY_ROOT_OUT)/ 649 cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \ 650 > $(TARGET_RECOVERY_ROOT_OUT)/default.prop 651 $(MKBOOTFS) $(TARGET_RECOVERY_ROOT_OUT) | gzip > $(recovery_ramdisk) 652 $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) --output $@ 653 @echo ----- Made recovery image -------- $@ 654 $(hide) $(call assert-max-file-size,$@,$(BOARD_RECOVERYIMAGE_MAX_SIZE)) 655 656else 657INSTALLED_RECOVERYIMAGE_TARGET := 658endif 659 660.PHONY: recoveryimage 661recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) 662 663# ----------------------------------------------------------------- 664# bring in the installer image generation defines if necessary 665ifeq ($(TARGET_USE_DISKINSTALLER),true) 666include bootable/diskinstaller/config.mk 667endif 668 669# ----------------------------------------------------------------- 670# OTA update package 671name := $(TARGET_PRODUCT) 672ifeq ($(TARGET_BUILD_TYPE),debug) 673 name := $(name)_debug 674endif 675name := $(name)-ota-$(FILE_NAME_TAG) 676 677INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 678INTERNAL_OTA_INTERMEDIATES_DIR := $(call intermediates-dir-for,PACKAGING,ota) 679 680# If neither TARGET_NO_KERNEL nor TARGET_NO_RECOVERY are true 681ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) 682INTERNAL_OTA_RECOVERYIMAGE_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/system/recovery.img 683else 684INTERNAL_OTA_RECOVERYIMAGE_TARGET := 685endif 686INTERNAL_OTA_SCRIPT_TARGET := $(INTERNAL_OTA_INTERMEDIATES_DIR)/META-INF/com/google/android/update-script 687 688# Sign OTA packages with the test key by default. 689# Actual product deliverables will be re-signed by hand. 690private_key := $(SRC_TARGET_DIR)/product/security/testkey.pk8 691certificate := $(SRC_TARGET_DIR)/product/security/testkey.x509.pem 692$(INTERNAL_OTA_PACKAGE_TARGET): $(private_key) $(certificate) $(SIGNAPK_JAR) 693$(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_PRIVATE_KEY := $(private_key) 694$(INTERNAL_OTA_PACKAGE_TARGET): PRIVATE_CERTIFICATE := $(certificate) 695 696# Depending on INSTALLED_SYSTEMIMAGE guarantees that SYSTEMIMAGE_SOURCE_DIR 697# is up-to-date. We use jar instead of zip so that we can use the -C 698# switch to avoid cd-ing all over the place. 699# TODO: Make our own jar-creation tool to avoid all these shenanigans. 700$(INTERNAL_OTA_PACKAGE_TARGET): \ 701 $(INTERNAL_OTA_SCRIPT_TARGET) \ 702 $(INTERNAL_OTA_RECOVERYIMAGE_TARGET) \ 703 $(INSTALLED_BOOTIMAGE_TARGET) \ 704 $(INSTALLED_RADIOIMAGE_TARGET) \ 705 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 706 $(INSTALLED_SYSTEMIMAGE) 707 @echo "Package OTA: $@" 708 $(hide) rm -rf $@ 709 $(hide) jar cf $@ \ 710 $(foreach item, \ 711 $(INSTALLED_BOOTIMAGE_TARGET) \ 712 $(INSTALLED_RADIOIMAGE_TARGET) \ 713 $(INSTALLED_ANDROID_INFO_TXT_TARGET), \ 714 -C $(dir $(item)) $(notdir $(item))) \ 715 -C $(INTERNAL_OTA_INTERMEDIATES_DIR) . 716 $(hide) find $(SYSTEMIMAGE_SOURCE_DIR) -type f -print | \ 717 sed 's|^$(dir $(SYSTEMIMAGE_SOURCE_DIR))|-C & |' | \ 718 xargs jar uf $@ 719 $(hide) if jar tf $@ | egrep '.{65}' >&2; then \ 720 echo "Path too long (>64 chars) for OTA update" >&2; \ 721 exit 1; \ 722 fi 723 $(sign-package) 724 725$(INTERNAL_OTA_SCRIPT_TARGET): \ 726 $(HOST_OUT_EXECUTABLES)/make-update-script \ 727 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 728 $(INSTALLED_SYSTEMIMAGE) 729 @mkdir -p $(dir $@) 730 @rm -rf $@ 731 @echo "Update script: $@" 732 $(hide) TARGET_DEVICE=$(TARGET_DEVICE) \ 733 $< $(SYSTEMIMAGE_SOURCE_DIR) \ 734 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 735 > $@ 736 737ifneq (,$(INTERNAL_OTA_RECOVERYIMAGE_TARGET)) 738# This copy is so recovery.img can be in /system within the OTA package. 739# That way it gets installed into the system image, which in turn installs it. 740$(INTERNAL_OTA_RECOVERYIMAGE_TARGET): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ACP) 741 @mkdir -p $(dir $@) 742 $(hide) $(ACP) $< $@ 743endif 744 745.PHONY: otapackage 746otapackage: $(INTERNAL_OTA_PACKAGE_TARGET) 747 748# Keys authorized to sign OTA packages this build will accept. 749ifeq ($(INCLUDE_TEST_OTA_KEYS),true) 750 OTA_PUBLIC_KEYS := \ 751 $(sort $(SRC_TARGET_DIR)/product/security/testkey.x509.pem $(OTA_PUBLIC_KEYS)) 752endif 753 754ifeq ($(OTA_PUBLIC_KEYS),) 755 $(error No OTA_PUBLIC_KEYS defined) 756endif 757 758# Build a keystore with the authorized keys in it. 759# java/android/android/server/checkin/UpdateVerifier.java uses this. 760ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip 761$(TARGET_OUT_ETC)/security/otacerts.zip: $(OTA_PUBLIC_KEYS) 762 $(hide) rm -f $@ 763 $(hide) mkdir -p $(dir $@) 764 zip -qj $@ $(OTA_PUBLIC_KEYS) 765 766# The device does not support JKS. 767# $(hide) for f in $(OTA_PUBLIC_KEYS); do \ 768# echo "keytool: $@ <= $$f" && \ 769# keytool -keystore $@ -storepass $(notdir $@) -noprompt \ 770# -import -file $$f -alias $(notdir $$f) || exit 1; \ 771# done 772 773ifdef RECOVERY_INSTALL_OTA_KEYS_INC 774# Generate a C-includable file containing the keys. 775# RECOVERY_INSTALL_OTA_KEYS_INC is defined by recovery/Android.mk. 776# *** THIS IS A TOTAL HACK; EXECUTABLES MUST NOT CHANGE BETWEEN DIFFERENT 777# PRODUCTS/BUILD TYPES. *** 778# TODO: make recovery read the keys from an external file. 779DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar 780$(RECOVERY_INSTALL_OTA_KEYS_INC): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS) 781$(RECOVERY_INSTALL_OTA_KEYS_INC): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) 782 @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS)" 783 @rm -rf $@ 784 @mkdir -p $(dir $@) 785 $(hide) java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) > $@ 786endif 787 788# ----------------------------------------------------------------- 789# A zip of the directories that map to the target filesystem. 790# This zip can be used to create an OTA package or filesystem image 791# as a post-build step. 792# 793name := $(TARGET_PRODUCT) 794ifeq ($(TARGET_BUILD_TYPE),debug) 795 name := $(name)_debug 796endif 797name := $(name)-target_files-$(FILE_NAME_TAG) 798 799intermediates := $(call intermediates-dir-for,PACKAGING,target_files) 800BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip 801$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates) 802$(BUILT_TARGET_FILES_PACKAGE): \ 803 zip_root := $(intermediates)/$(name) 804 805# $(1): Directory to copy 806# $(2): Location to copy it to 807# The "ls -A" is to prevent "acp s/* d" from failing if s is empty. 808define package_files-copy-root 809 if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \ 810 mkdir -p $(2) && \ 811 $(ACP) -rd $(strip $(1))/* $(2); \ 812 fi 813endef 814 815built_ota_tools := \ 816 $(call intermediates-dir-for,EXECUTABLES,applypatch)/applypatch \ 817 $(call intermediates-dir-for,EXECUTABLES,check_prereq)/check_prereq 818$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools) 819 820# Depending on the various images guarantees that the underlying 821# directories are up-to-date. 822$(BUILT_TARGET_FILES_PACKAGE): \ 823 $(INTERNAL_OTA_SCRIPT_TARGET) \ 824 $(INSTALLED_BOOTIMAGE_TARGET) \ 825 $(INSTALLED_RADIOIMAGE_TARGET) \ 826 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 827 $(BUILT_SYSTEMIMAGE) \ 828 $(INSTALLED_USERDATAIMAGE_TARGET) \ 829 $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ 830 $(INTERNAL_OTA_SCRIPT_TARGET) \ 831 $(built_ota_tools) \ 832 $(APKCERTS_FILE) \ 833 | $(ACP) 834 @echo "Package target files: $@" 835 $(hide) rm -rf $@ $(zip_root) 836 $(hide) mkdir -p $(dir $@) $(zip_root) 837 @# Components of the recovery image 838 $(hide) mkdir -p $(zip_root)/RECOVERY 839 $(hide) $(call package_files-copy-root, \ 840 $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/RECOVERY/RAMDISK) 841ifdef INSTALLED_KERNEL_TARGET 842 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/RECOVERY/kernel 843endif 844ifdef INSTALLED_2NDBOOTLOADER_TARGET 845 $(hide) $(ACP) \ 846 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/RECOVERY/second 847endif 848ifdef BOARD_KERNEL_CMDLINE 849 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/RECOVERY/cmdline 850endif 851 @# Components of the boot image 852 $(hide) mkdir -p $(zip_root)/BOOT 853 $(hide) $(call package_files-copy-root, \ 854 $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK) 855ifdef INSTALLED_KERNEL_TARGET 856 $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel 857endif 858ifdef INSTALLED_2NDBOOTLOADER_TARGET 859 $(hide) $(ACP) \ 860 $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second 861endif 862ifdef BOARD_KERNEL_CMDLINE 863 $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline 864endif 865ifdef INSTALLED_RADIOIMAGE_TARGET 866 @# The radio image 867 $(hide) mkdir -p $(zip_root)/RADIO 868 $(hide) $(ACP) $(INSTALLED_RADIOIMAGE_TARGET) $(zip_root)/RADIO/image 869endif 870 @# Contents of the system image 871 $(hide) $(call package_files-copy-root, \ 872 $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM) 873 @# Contents of the data image 874 $(hide) $(call package_files-copy-root, \ 875 $(TARGET_OUT_DATA),$(zip_root)/DATA) 876 @# Extra contents of the OTA package 877 $(hide) mkdir -p $(zip_root)/OTA/bin 878 $(hide) $(call package_files-copy-root, \ 879 $(INTERNAL_OTA_INTERMEDIATES_DIR),$(zip_root)/OTA) 880 $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/ 881 $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/ 882 @# Files that don't end up in any images, but are necessary to 883 @# build them. 884 $(hide) mkdir -p $(zip_root)/META 885 $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt 886 @# Zip everything up, preserving symlinks 887 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .) 888 889target-files-package: $(BUILT_TARGET_FILES_PACKAGE) 890 891# ----------------------------------------------------------------- 892# A zip of the tests that are built when running "make tests". 893# This is very similar to BUILT_TARGET_FILES_PACKAGE, but we 894# only grab SYSTEM and DATA, and it's called "*-tests-*.zip". 895# 896name := $(TARGET_PRODUCT) 897ifeq ($(TARGET_BUILD_TYPE),debug) 898 name := $(name)_debug 899endif 900name := $(name)-tests-$(FILE_NAME_TAG) 901 902intermediates := $(call intermediates-dir-for,PACKAGING,tests_zip) 903BUILT_TESTS_ZIP_PACKAGE := $(intermediates)/$(name).zip 904$(BUILT_TESTS_ZIP_PACKAGE): intermediates := $(intermediates) 905$(BUILT_TESTS_ZIP_PACKAGE): zip_root := $(intermediates)/$(name) 906 907# Depending on the images guarantees that the underlying 908# directories are up-to-date. 909$(BUILT_TESTS_ZIP_PACKAGE): \ 910 $(BUILT_SYSTEMIMAGE) \ 911 $(INSTALLED_USERDATAIMAGE_TARGET) \ 912 | $(ACP) 913 @echo "Package test files: $@" 914 $(hide) rm -rf $@ $(zip_root) 915 $(hide) mkdir -p $(dir $@) $(zip_root) 916 @# Some parts of the system image 917 $(hide) $(call package_files-copy-root, \ 918 $(SYSTEMIMAGE_SOURCE_DIR)/xbin,$(zip_root)/SYSTEM/xbin) 919 $(hide) $(call package_files-copy-root, \ 920 $(SYSTEMIMAGE_SOURCE_DIR)/lib,$(zip_root)/SYSTEM/lib) 921 $(hide) $(call package_files-copy-root, \ 922 $(SYSTEMIMAGE_SOURCE_DIR)/framework, \ 923 $(zip_root)/SYSTEM/framework) 924 $(hide) $(ACP) $(SYSTEMIMAGE_SOURCE_DIR)/build.prop $(zip_root)/SYSTEM 925 @# Contents of the data image 926 $(hide) $(call package_files-copy-root, \ 927 $(TARGET_OUT_DATA),$(zip_root)/DATA) 928 $(hide) (cd $(zip_root) && zip -qry ../$(notdir $@) .) 929 930tests-zip-package: $(BUILT_TESTS_ZIP_PACKAGE) 931 932# ----------------------------------------------------------------- 933# A zip of the symbols directory. Keep the full paths to make it 934# more obvious where these files came from. 935# 936name := $(TARGET_PRODUCT) 937ifeq ($(TARGET_BUILD_TYPE),debug) 938 name := $(name)_debug 939endif 940name := $(name)-symbols-$(FILE_NAME_TAG) 941 942SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip 943$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET) 944 @echo "Package symbols: $@" 945 $(hide) rm -rf $@ 946 $(hide) mkdir -p $(dir $@) 947 $(hide) zip -qr $@ $(TARGET_OUT_UNSTRIPPED) 948 949# ----------------------------------------------------------------- 950# A zip of the Android Apps. Not keeping full path so that we don't 951# include product names when distributing 952# 953name := $(TARGET_PRODUCT) 954ifeq ($(TARGET_BUILD_TYPE),debug) 955 name := $(name)_debug 956endif 957name := $(name)-apps-$(FILE_NAME_TAG) 958 959APPS_ZIP := $(PRODUCT_OUT)/$(name).zip 960$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE) 961 @echo "Package apps: $@" 962 $(hide) rm -rf $@ 963 $(hide) mkdir -p $(dir $@) 964 $(hide) zip -qj $@ $(TARGET_OUT_APPS)/* 965 966endif # TARGET_SIMULATOR != true 967 968# ----------------------------------------------------------------- 969# dalvik something 970.PHONY: dalvikfiles 971dalvikfiles: $(INTERNAL_DALVIK_MODULES) 972 973# ----------------------------------------------------------------- 974# The update package 975 976INTERNAL_UPDATE_PACKAGE_FILES += \ 977 $(INSTALLED_BOOTIMAGE_TARGET) \ 978 $(INSTALLED_RECOVERYIMAGE_TARGET) \ 979 $(INSTALLED_SYSTEMIMAGE) \ 980 $(INSTALLED_USERDATAIMAGE_TARGET) \ 981 $(INSTALLED_ANDROID_INFO_TXT_TARGET) 982 983ifneq ($(strip $(INTERNAL_UPDATE_PACKAGE_FILES)),) 984 985name := $(TARGET_PRODUCT) 986ifeq ($(TARGET_BUILD_TYPE),debug) 987 name := $(name)_debug 988endif 989name := $(name)-img-$(FILE_NAME_TAG) 990 991INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 992 993$(INTERNAL_UPDATE_PACKAGE_TARGET): $(INTERNAL_UPDATE_PACKAGE_FILES) 994 @echo "Package: $@" 995 $(hide) zip -qj $@ $(INTERNAL_UPDATE_PACKAGE_FILES) 996 997else 998INTERNAL_UPDATE_PACKAGE_TARGET := 999endif 1000 1001# ----------------------------------------------------------------- 1002# The emulator package 1003 1004ifneq ($(TARGET_SIMULATOR),true) 1005 1006INTERNAL_EMULATOR_PACKAGE_FILES += \ 1007 $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \ 1008 prebuilt/android-arm/kernel/kernel-qemu \ 1009 $(INSTALLED_RAMDISK_TARGET) \ 1010 $(INSTALLED_SYSTEMIMAGE) \ 1011 $(INSTALLED_USERDATAIMAGE_TARGET) 1012 1013name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG) 1014 1015INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip 1016 1017$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES) 1018 @echo "Package: $@" 1019 $(hide) zip -qj $@ $(INTERNAL_EMULATOR_PACKAGE_FILES) 1020 1021endif 1022 1023# ----------------------------------------------------------------- 1024# The pdk package (Platform Development Kit) 1025 1026ifneq (,$(filter pdk,$(MAKECMDGOALS))) 1027 include development/pdk/Pdk.mk 1028endif 1029 1030# ----------------------------------------------------------------- 1031# The SDK 1032 1033ifneq ($(TARGET_SIMULATOR),true) 1034 1035# The SDK includes host-specific components, so it belongs under HOST_OUT. 1036sdk_dir := $(HOST_OUT)/sdk 1037 1038# Build a name that looks like: 1039# 1040# linux-x86 --> android-sdk_12345_linux-x86 1041# darwin-x86 --> android-sdk_12345_mac-x86 1042# windows-x86 --> android-sdk_12345_windows 1043# 1044sdk_name := android-sdk_$(FILE_NAME_TAG) 1045ifeq ($(HOST_OS),darwin) 1046 sdk_host_os := mac 1047else 1048 sdk_host_os := $(HOST_OS) 1049endif 1050ifneq ($(HOST_OS),windows) 1051 sdk_host_os := $(sdk_host_os)-$(HOST_ARCH) 1052endif 1053sdk_name := $(sdk_name)_$(sdk_host_os) 1054 1055sdk_dep_file := $(sdk_dir)/sdk_deps.mk 1056 1057ATREE_FILES := 1058-include $(sdk_dep_file) 1059 1060# if we don't have a real list, then use "everything" 1061ifeq ($(strip $(ATREE_FILES)),) 1062ATREE_FILES := \ 1063 $(ALL_PREBUILT) \ 1064 $(ALL_COPIED_HEADERS) \ 1065 $(ALL_GENERATED_SOURCES) \ 1066 $(ALL_DEFAULT_INSTALLED_MODULES) \ 1067 $(INSTALLED_RAMDISK_TARGET) \ 1068 $(ALL_DOCS) \ 1069 $(ALL_SDK_FILES) 1070endif 1071 1072atree_dir := development/build 1073 1074sdk_atree_files := \ 1075 $(atree_dir)/sdk.exclude.atree \ 1076 $(atree_dir)/sdk.atree \ 1077 $(atree_dir)/sdk-$(HOST_OS)-$(HOST_ARCH).atree 1078 1079deps := \ 1080 $(target_notice_file_txt) \ 1081 $(tools_notice_file_txt) \ 1082 $(OUT_DOCS)/offline-sdk-timestamp \ 1083 $(INTERNAL_UPDATE_PACKAGE_TARGET) \ 1084 $(INSTALLED_SDK_BUILD_PROP_TARGET) \ 1085 $(ATREE_FILES) \ 1086 $(atree_dir)/sdk.atree \ 1087 $(HOST_OUT_EXECUTABLES)/atree \ 1088 $(HOST_OUT_EXECUTABLES)/line_endings 1089 1090INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip 1091$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name) 1092$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name) 1093$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file) 1094$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files) 1095 1096# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built. 1097# 1098#SDK_GNU_ERROR := true 1099 1100$(INTERNAL_SDK_TARGET): $(deps) 1101 @echo "Package SDK: $@" 1102 $(hide) rm -rf $(PRIVATE_DIR) $@ 1103 $(hide) for f in $(target_gnu_MODULES); do \ 1104 if [ -f $$f ]; then \ 1105 echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \ 1106 including GNU target $$f >&2; \ 1107 FAIL=$(SDK_GNU_ERROR); \ 1108 fi; \ 1109 done; \ 1110 if [ $$FAIL ]; then exit 1; fi 1111 $(hide) ( \ 1112 $(HOST_OUT_EXECUTABLES)/atree \ 1113 $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \ 1114 -m $(PRIVATE_DEP_FILE) \ 1115 -I . \ 1116 -I $(PRODUCT_OUT) \ 1117 -I $(HOST_OUT) \ 1118 -I $(TARGET_COMMON_OUT_ROOT) \ 1119 -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \ 1120 -o $(PRIVATE_DIR) && \ 1121 cp -f $(target_notice_file_txt) \ 1122 $(PRIVATE_DIR)/platforms/android-$(PLATFORM_VERSION)/images/NOTICE.txt && \ 1123 cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/tools/NOTICE.txt && \ 1124 HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \ 1125 development/tools/scripts/sdk_clean.sh $(PRIVATE_DIR) && \ 1126 chmod -R ug+rwX $(PRIVATE_DIR) && \ 1127 cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME) \ 1128 ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 ) 1129 1130endif # !simulator 1131 1132# ----------------------------------------------------------------- 1133# Findbugs 1134INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml 1135INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html 1136$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES) 1137 @echo UnionBugs: $@ 1138 $(hide) prebuilt/common/findbugs/bin/unionBugs $(ALL_FINDBUGS_FILES) \ 1139 > $@ 1140$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET) 1141 @echo ConvertXmlToText: $@ 1142 $(hide) prebuilt/common/findbugs/bin/convertXmlToText -html:fancy.xsl \ 1143 $(INTERNAL_FINDBUGS_XML_TARGET) > $@ 1144 1145# ----------------------------------------------------------------- 1146# Findbugs 1147 1148# ----------------------------------------------------------------- 1149# These are some additional build tasks that need to be run. 1150include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk)) 1151