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