diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..f1f4a529f1b494b0990f04411fc458a9b1f85b5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.pyc +*.swp +blueprint/ +kati/ +soong/ diff --git a/CleanSpec.mk b/CleanSpec.mk new file mode 100644 index 0000000000000000000000000000000000000000..a97c71a49e02ef529e9ce288adad78f337ce00e9 --- /dev/null +++ b/CleanSpec.mk @@ -0,0 +1,383 @@ +# Copyright (C) 2007 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# If you don't need to do a full clean build but would like to touch +# a file or delete some intermediate files, add a clean step to the end +# of the list. These steps will only be run once, if they haven't been +# run before. +# +# E.g.: +# $(call add-clean-step, touch -c external/sqlite/sqlite3.h) +# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) +# +# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with +# files that are missing or have been moved. +# +# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. +# Use $(OUT_DIR) to refer to the "out" directory. +# +# If you need to re-do something that's already mentioned, just copy +# the command and add it to the bottom of the list. E.g., if a change +# that you made last week required touching a file and a change you +# made today requires touching the same file, just copy the old +# touch step and add it to the end of the list. +# +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ + +# For example: +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) +#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) +#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) + +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libmediaplayerservice_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libmedia_jni_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_omx_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/android-info.txt) +$(call add-clean-step, find $(PRODUCT_OUT) -name "*.apk" | xargs rm) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/*/LINKED) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so) +$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/iself) +$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/lsd) +$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/apriori) +$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/isprelinked) +$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/soslim) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/YouTube*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_omx_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/librtp_jni_intermediates) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/android-info.txt) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/JAVA_LIBRARIES/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libbcinfo_intermediates) + +# ICS MR2!!!!!!!!!!!! +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libbcinfo_intermediates) + +# WAIT, I MEAN JELLY BEAN!!!!!!!!!!!! +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Changing where ro.carrier value is instantiated for system/build.prop +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Now we switched to build against Mac OS X SDK 10.6 +$(call add-clean-step, rm -rf $(OUT_DIR)/host/darwin-x86/obj) + +$(call add-clean-step, rm -f $(OUT_DIR)/versions_checked.mk) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o) + +# JB MR2!!!!!!! AND *NO*, THIS WILL NOT BE K-WHATEVER. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Start of "K" development! +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# GCC 4.7 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o) + +# Wait, back to some JB development! +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# And on to KLP... +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# KLP now based off API 18. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# Clean up around the /system/app -> /system/priv-app migration +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) + +# Clean up old location of generated Java files from aidl +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src) + +# Clean up ApplicationsProvider which is being removed. +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/ApplicationsProvider_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/ApplicationsProvider.apk) + +# Clean up Moto OMA DM client which isn't ready yet. +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.plugin.dev_intermediates) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.plugin.diagmon_intermediates) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.pluginhelper_intermediates) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.plugin_intermediates) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.service.api_intermediates) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/DMService_intermediates) +$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/SprintDM_intermediates) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/DMService.apk) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/SprintDM.apk) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/omadm) + +# GCC 4.8 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o) + +# KLP I mean KitKat now API 19. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# 4.4.1 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# 4.4.2 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# "L" and beyond. +# Make libart the default runtime +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Rename persist.sys.dalvik.vm.lib to allow new default +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# KKWT development +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# L development +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# L development +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# Add ro.product.cpu.abilist{32,64} to build.prop. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Unset TARGET_PREFER_32_BIT_APPS for 64 bit targets. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Adding dalvik.vm.dex2oat-flags to eng builds +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Unset TARGET_PREFER_32_BIT_APPS for 64 bit targets. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Switching the x86 emulator over to a 64 bit primary zygote. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) + +# Rename persist.sys.dalvik.vm.lib.1 to allow new default +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Switching PRODUCT_RUNTIMES default for some devices +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Switching to 32-bit-by-default host multilib build +$(call add-clean-step, rm -rf $(HOST_OUT_INTERMEDIATES)) + +# KKWT has become API 20 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# ims-common.jar added to BOOTCLASSPATH +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/ETC/init.environ.rc_intermediates) + +# Change ro.zygote for core_64_bit.mk from zygote32_64 to zygote64_32 +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) + +# Adding dalvik.vm.dex2oat-Xms, dalvik.vm.dex2oat-Xmx +# dalvik.vm.image-dex2oat-Xms, and dalvik.vm.image-dex2oat-Xmx +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system) + +# Switch host builds to Clang by default +$(call add-clean-step, rm -rf $(OUT_DIR)/host) + +# Adding dalvik.vm.dex2oat-filter +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) + +# API 21? +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# API 21! +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# API 22! +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# Move to libc++ as the default STL. +$(call add-clean-step, rm -rf $(OUT_DIR)) + +# dex2oat instruction-set changes +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) + +# Make GNU++11 the default standard version. This requires a cleanspec because +# char16_t/char32_t will be real types now instead of typedefs, which means +# an ABI change since the names will mangle differently. +$(call add-clean-step, rm -rf $(OUT_DIR)) + +# 5.1! +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# Remove ro.product.locale.language/country and add ro.product.locale +# instead. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# On to MNC +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# Adding dalvik.vm.usejit +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) + +# Rename dalvik.vm.usejit to debug.dalvik.vm.usejit +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) + +# Revert rename dalvik.vm.usejit to debug.dalvik.vm.usejit +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) + +# Change from interpret-only to verify-at-runtime. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop) + +# New York, New York! +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# 23 is becoming alive!!! +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) + +# Change PLATFORM_VERSION from NYC to N +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*) + +# $(PRODUCT_OUT)/recovery/root/sdcard goes from symlink to folder. +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/sdcard) + +# Add BOARD_USES_SYSTEM_OTHER_ODEX +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*) +$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/*) + +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ diff --git a/builds.spec b/builds.spec new file mode 100644 index 0000000000000000000000000000000000000000..b0f45d60addde3c4cc78f348b27c0c59618d660d --- /dev/null +++ b/builds.spec @@ -0,0 +1,10 @@ +Name: build +Version: android7.1.r13 +Release: 1 +Summary: platform frameworks build module +License: APL +URL: https://gitee.com/src-openeuler/platform_build + + +%description +This is my first RPM package, which does nothing. diff --git a/buildspec.mk.default b/buildspec.mk.default new file mode 100644 index 0000000000000000000000000000000000000000..d14208e09994a1a7619d08a4c3ca0e78d4fd6e11 --- /dev/null +++ b/buildspec.mk.default @@ -0,0 +1,111 @@ +# +# Copyright (C) 2007 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +###################################################################### +# This is a do-nothing template file. To use it, copy it to a file +# named "buildspec.mk" in the root directory, and uncomment or change +# the variables necessary for your desired configuration. The file +# "buildspec.mk" should never be checked in to source control. +###################################################################### + +# Choose a product to build for. Look in the products directory for ones +# that work. +ifndef TARGET_PRODUCT +#TARGET_PRODUCT:=generic +endif + +# Choose a variant to build. If you don't pick one, the default is eng. +# User is what we ship. Userdebug is that, with a few flags turned on +# for debugging. Eng has lots of extra tools for development. +ifndef TARGET_BUILD_VARIANT +#TARGET_BUILD_VARIANT:=user +#TARGET_BUILD_VARIANT:=userdebug +#TARGET_BUILD_VARIANT:=eng +endif + +# Choose additional targets to always install, even when building +# minimal targets like "make droid". This takes simple target names +# like "Browser" or "MyApp", the names used by LOCAL_MODULE or +# LOCAL_PACKAGE_NAME. Modules listed here will always be installed in +# /system, even if they'd usually go in /data. +ifndef CUSTOM_MODULES +#CUSTOM_MODULES:= +endif + +# Set this to debug or release if you care. Otherwise, it defaults to release. +ifndef TARGET_BUILD_TYPE +#TARGET_BUILD_TYPE:=release +endif + +# Uncomment this if you want the host tools built in debug mode. Otherwise +# it defaults to release. +ifndef HOST_BUILD_TYPE +#HOST_BUILD_TYPE:=debug +endif + +# Turn on debugging for selected modules. If DEBUG_MODULE_ is set +# to a non-empty value, the appropriate HOST_/TARGET_CUSTOM_DEBUG_CFLAGS +# will be added to LOCAL_CFLAGS when building the module. +#DEBUG_MODULE_ModuleName:=true + +# Specify an alternative tool chain prefix if needed. +#TARGET_TOOLS_PREFIX:= + +# Specify the extra CFLAGS to use when building a module whose +# DEBUG_MODULE_ variable is set. Host and device flags are handled +# separately. +#HOST_CUSTOM_DEBUG_CFLAGS:= +#TARGET_CUSTOM_DEBUG_CFLAGS:= + +# Choose additional locales, like "en_US" or "it_IT", to add to any +# built product. Any locales that appear in CUSTOM_LOCALES but not in +# the locale list for the selected product will be added to the end +# of PRODUCT_LOCALES. +ifndef CUSTOM_LOCALES +#CUSTOM_LOCALES:= +endif + +# If you have a special place to put your ouput files, set this, otherwise +# it goes to /out +#OUT_DIR:=/tmp/stuff + +# If you want to always set certain system properties, add them to this list. +# E.g., "ADDITIONAL_BUILD_PROPERTIES += ro.prop1=5 prop2=value" +# This mechanism does not currently support values containing spaces. +#ADDITIONAL_BUILD_PROPERTIES += + +# If you want to reduce the system.img size by several meg, and are willing to +# lose access to CJK (and other) character sets, define NO_FALLBACK_FONT:=true +ifndef NO_FALLBACK_FONT +#NO_FALLBACK_FONT:=true +endif + +# OVERRIDE_RUNTIMES allows you to locally override PRODUCT_RUNTIMES. +# +# To only build ART, use "runtime_libart_default" +# To use Dalvik but also include ART, use "runtime_libdvm_default runtime_libart" +# To use ART but also include Dalvik, use "runtime_libart_default runtime_libdvm" +ifndef OVERRIDE_RUNTIMES +#OVERRIDE_RUNTIMES:=runtime_libart_default +#OVERRIDE_RUNTIMES:=runtime_libdvm_default runtime_libart +#OVERRIDE_RUNTIMES:=runtime_libart_default runtime_libdvm +endif + +# when the build system changes such that this file must be updated, this +# variable will be changed. After you have modified this file with the new +# changes (see buildspec.mk.default), update this to the new value from +# buildspec.mk.default. +BUILD_ENV_SEQUENCE_NUMBER := 10 diff --git a/core/LINUX_KERNEL_COPYING b/core/LINUX_KERNEL_COPYING new file mode 100644 index 0000000000000000000000000000000000000000..ca442d313d86dc67e0a2e5d584b465bd382cbf5c --- /dev/null +++ b/core/LINUX_KERNEL_COPYING @@ -0,0 +1,356 @@ + + NOTE! This copyright does *not* cover user programs that use kernel + services by normal system calls - this is merely considered normal use + of the kernel, and does *not* fall under the heading of "derived work". + Also note that the GPL below is copyrighted by the Free Software + Foundation, but the instance of code that it refers to (the Linux + kernel) is copyrighted by me and others who actually wrote it. + + Also note that the only valid version of the GPL as far as the kernel + is concerned is _this_ particular version of the license (ie v2, not + v2.2 or v3.x or whatever), unless explicitly otherwise stated. + + Linus Torvalds + +---------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/core/Makefile b/core/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..5badde5587efa10f6848d29119d5371ccc257feb --- /dev/null +++ b/core/Makefile @@ -0,0 +1,2262 @@ +# Put some miscellaneous rules here + +# HACK: clear LOCAL_PATH from including last build target before calling +# intermedites-dir-for +LOCAL_PATH := $(BUILD_SYSTEM) + +# Pick a reasonable string to use to identify files. +ifneq "" "$(filter eng.%,$(BUILD_NUMBER))" + # BUILD_NUMBER has a timestamp in it, which means that + # it will change every time. Pick a stable value. + FILE_NAME_TAG := eng.$(USER) +else + FILE_NAME_TAG := $(BUILD_NUMBER) +endif + +# ----------------------------------------------------------------- +# Define rules to copy PRODUCT_COPY_FILES defined by the product. +# PRODUCT_COPY_FILES contains words like :[:]. +# is relative to $(PRODUCT_OUT), so it should look like, +# e.g., "system/etc/file.xml". +# The filter part means "only eval the copy-one-file rule if this +# src:dest pair is the first one to match the same dest" +#$(1): the src:dest pair +define check-product-copy-files +$(if $(filter %.apk, $(call word-colon, 2, $(1))),$(error \ + Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!)) +endef +# filter out the duplicate : pairs. +unique_product_copy_files_pairs := +$(foreach cf,$(PRODUCT_COPY_FILES), \ + $(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\ + $(eval unique_product_copy_files_pairs += $(cf)))) +unique_product_copy_files_destinations := +$(foreach cf,$(unique_product_copy_files_pairs), \ + $(eval _src := $(call word-colon,1,$(cf))) \ + $(eval _dest := $(call word-colon,2,$(cf))) \ + $(call check-product-copy-files,$(cf)) \ + $(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \ + $(info PRODUCT_COPY_FILES $(cf) ignored.), \ + $(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \ + $(if $(filter %.xml,$(_dest)),\ + $(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\ + $(eval $(call copy-one-file,$(_src),$(_fulldest)))) \ + $(eval ALL_DEFAULT_INSTALLED_MODULES += $(_fulldest)) \ + $(eval unique_product_copy_files_destinations += $(_dest)))) +unique_product_copy_files_pairs := +unique_product_copy_files_destinations := + +# ----------------------------------------------------------------- +# Define rules to copy headers defined in copy_headers.mk +# If more than one makefile declared a header, print a warning, +# then copy the last one defined. This matches the previous make +# behavior. +$(foreach dest,$(ALL_COPIED_HEADERS), \ + $(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \ + $(eval _src := $(word $(words $(_srcs)),$(_srcs))) \ + $(if $(call streq,$(_src),$(_srcs)),, \ + $(warning Duplicate header copy: $(dest)) \ + $(warning Defined in: $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \ + $(eval $(call copy-one-header,$(_src),$(dest)))) +all_copied_headers: $(ALL_COPIED_HEADERS) + +# ----------------------------------------------------------------- +# docs/index.html +ifeq (,$(TARGET_BUILD_APPS)) +gen := $(OUT_DOCS)/index.html +ALL_DOCS += $(gen) +$(gen): frameworks/base/docs/docs-redirect-index.html + @mkdir -p $(dir $@) + @cp -f $< $@ +endif + +# ----------------------------------------------------------------- +# default.prop +INSTALLED_DEFAULT_PROP_TARGET := $(TARGET_ROOT_OUT)/default.prop +ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_DEFAULT_PROP_TARGET) +ADDITIONAL_DEFAULT_PROPERTIES := \ + $(call collapse-pairs, $(ADDITIONAL_DEFAULT_PROPERTIES)) +ADDITIONAL_DEFAULT_PROPERTIES += \ + $(call collapse-pairs, $(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)) +ADDITIONAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \ + $(ADDITIONAL_DEFAULT_PROPERTIES),=) + +intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop + +$(INSTALLED_DEFAULT_PROP_TARGET): $(intermediate_system_build_prop) + @echo Target buildinfo: $@ + @mkdir -p $(dir $@) + $(hide) echo "#" > $@; \ + echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> $@; \ + echo "#" >> $@; + $(hide) $(foreach line,$(ADDITIONAL_DEFAULT_PROPERTIES), \ + echo "$(line)" >> $@;) + $(hide) echo "#" >> $@; \ + echo "# BOOTIMAGE_BUILD_PROPERTIES" >> $@; \ + echo "#" >> $@; + $(hide) echo ro.bootimage.build.date=`$(DATE_FROM_FILE)`>>$@ + $(hide) echo ro.bootimage.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@ + $(hide) echo ro.bootimage.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@ + $(hide) build/tools/post_process_props.py $@ + +# ----------------------------------------------------------------- +# build.prop +INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop +ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET) +ADDITIONAL_BUILD_PROPERTIES := \ + $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES)) +ADDITIONAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \ + $(ADDITIONAL_BUILD_PROPERTIES),=) + +# A list of arbitrary tags describing the build configuration. +# Force ":=" so we can use += +BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS) +ifeq ($(TARGET_BUILD_TYPE),debug) + BUILD_VERSION_TAGS += debug +endif +# The "test-keys" tag marks builds signed with the old test keys, +# which are available in the SDK. "dev-keys" marks builds signed with +# non-default dev keys (usually private keys from a vendor directory). +# Both of these tags will be removed and replaced with "release-keys" +# when the target-files is signed in a post-build step. +ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey) +BUILD_KEYS := test-keys +else +BUILD_KEYS := dev-keys +endif +BUILD_VERSION_TAGS += $(BUILD_KEYS) +BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS))) + +# A human-readable string that descibes this build in detail. +build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS) +$(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc) + +# The string used to uniquely identify the combined build and product; used by the OTA server. +ifeq (,$(strip $(BUILD_FINGERPRINT))) + ifneq ($(filter eng.%,$(BUILD_NUMBER)),) + # Trim down BUILD_FINGERPRINT: the default BUILD_NUMBER makes it easily exceed + # the Android system property length limit (PROPERTY_VALUE_MAX=92). + BF_BUILD_NUMBER := $(shell echo $${USER:0:6})$(shell $(DATE) +%m%d%H%M) + else + BF_BUILD_NUMBER := $(BUILD_NUMBER) + endif + BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BF_BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) +endif +ifneq ($(words $(BUILD_FINGERPRINT)),1) + $(error BUILD_FINGERPRINT cannot contain spaces: "$(BUILD_FINGERPRINT)") +endif + +$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) > $(PRODUCT_OUT)/build_fingerprint.txt) +BUILD_FINGERPRINT_FROM_FILE := $$(cat $(PRODUCT_OUT)/build_fingerprint.txt) + +# The string used to uniquely identify the system build; used by the OTA server. +# This purposefully excludes any product-specific variables. +ifeq (,$(strip $(BUILD_THUMBPRINT))) + BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) +endif +ifneq ($(words $(BUILD_THUMBPRINT)),1) + $(error BUILD_THUMBPRINT cannot contain spaces: "$(BUILD_THUMBPRINT)") +endif + +KNOWN_OEM_THUMBPRINT_PROPERTIES := \ + ro.product.brand \ + ro.product.name \ + ro.product.device +OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\ + $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES)) + +# Display parameters shown under Settings -> About Phone +ifeq ($(TARGET_BUILD_VARIANT),user) + # User builds should show: + # release build number or branch.buld_number non-release builds + + # Dev. branches should have DISPLAY_BUILD_NUMBER set + ifeq "true" "$(DISPLAY_BUILD_NUMBER)" + BUILD_DISPLAY_ID := $(BUILD_ID).$(BUILD_NUMBER_FROM_FILE) $(BUILD_KEYS) + else + BUILD_DISPLAY_ID := $(BUILD_ID) $(BUILD_KEYS) + endif +else + # Non-user builds should show detailed build information + BUILD_DISPLAY_ID := $(build_desc) +endif + +# Accepts a whitespace separated list of product locales such as +# (en_US en_AU en_GB...) and returns the first locale in the list with +# underscores replaced with hyphens. In the example above, this will +# return "en-US". +define get-default-product-locale +$(strip $(subst _,-, $(firstword $(1)))) +endef + +BUILDINFO_SH := build/tools/buildinfo.sh + +# TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test harness to distinguish builds. +TARGET_BUILD_FLAVOR := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) +ifdef SANITIZE_TARGET +TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan +endif + +ifdef TARGET_SYSTEM_PROP +system_prop_file := $(TARGET_SYSTEM_PROP) +else +system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop) +endif +$(intermediate_system_build_prop): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) $(INSTALLED_ANDROID_INFO_TXT_TARGET) + @echo Target buildinfo: $@ + @mkdir -p $(dir $@) + $(hide) echo > $@ +ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES),) + $(hide) echo "#" >> $@; \ + echo "# PRODUCT_OEM_PROPERTIES" >> $@; \ + echo "#" >> $@; + $(hide) $(foreach prop,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OEM_PROPERTIES), \ + echo "import /oem/oem.prop $(prop)" >> $@;) +endif + $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \ + TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \ + TARGET_DEVICE="$(TARGET_DEVICE)" \ + PRODUCT_NAME="$(TARGET_PRODUCT)" \ + PRODUCT_BRAND="$(PRODUCT_BRAND)" \ + PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \ + PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \ + PRODUCT_MODEL="$(PRODUCT_MODEL)" \ + PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \ + PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \ + BUILD_ID="$(BUILD_ID)" \ + BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \ + DATE="$(DATE_FROM_FILE)" \ + BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \ + BOARD_BUILD_SYSTEM_ROOT_IMAGE="$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)" \ + AB_OTA_UPDATER="$(AB_OTA_UPDATER)" \ + PLATFORM_VERSION="$(PLATFORM_VERSION)" \ + PLATFORM_SECURITY_PATCH="$(PLATFORM_SECURITY_PATCH)" \ + PLATFORM_BASE_OS="$(PLATFORM_BASE_OS)" \ + PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \ + PLATFORM_PREVIEW_SDK_VERSION="$(PLATFORM_PREVIEW_SDK_VERSION)" \ + PLATFORM_VERSION_CODENAME="$(PLATFORM_VERSION_CODENAME)" \ + PLATFORM_VERSION_ALL_CODENAMES="$(PLATFORM_VERSION_ALL_CODENAMES)" \ + BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \ + TARGET_BOOTLOADER_BOARD_NAME="$(TARGET_BOOTLOADER_BOARD_NAME)" \ + BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \ + $(if $(OEM_THUMBPRINT_PROPERTIES),BUILD_THUMBPRINT="$(BUILD_THUMBPRINT)") \ + TARGET_BOARD_PLATFORM="$(TARGET_BOARD_PLATFORM)" \ + TARGET_CPU_ABI_LIST="$(TARGET_CPU_ABI_LIST)" \ + TARGET_CPU_ABI_LIST_32_BIT="$(TARGET_CPU_ABI_LIST_32_BIT)" \ + TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \ + TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \ + TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \ + TARGET_AAPT_CHARACTERISTICS="$(TARGET_AAPT_CHARACTERISTICS)" \ + bash $(BUILDINFO_SH) >> $@ + $(hide) $(foreach file,$(system_prop_file), \ + if [ -f "$(file)" ]; then \ + echo "#" >> $@; \ + echo Target buildinfo from: "$(file)"; \ + echo "# from $(file)" >> $@; \ + echo "#" >> $@; \ + cat $(file) >> $@; \ + fi;) + $(if $(ADDITIONAL_BUILD_PROPERTIES), \ + $(hide) echo >> $@; \ + echo "#" >> $@; \ + echo "# ADDITIONAL_BUILD_PROPERTIES" >> $@; \ + echo "#" >> $@; ) + $(hide) $(foreach line,$(ADDITIONAL_BUILD_PROPERTIES), \ + echo "$(line)" >> $@;) + $(hide) cat $(INSTALLED_ANDROID_INFO_TXT_TARGET) | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' >> $@ + $(hide) build/tools/post_process_props.py $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_PROPERTY_BLACKLIST) + +build_desc := + +ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY))) +INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img +else +INSTALLED_RECOVERYIMAGE_TARGET := +endif + +$(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop) $(INSTALLED_RECOVERYIMAGE_TARGET) + @echo "Target build info: $@" + $(hide) cat $(intermediate_system_build_prop) > $@ +ifdef INSTALLED_RECOVERYIMAGE_TARGET + $(hide) echo ro.expect.recovery_id=`cat $(RECOVERYIMAGE_ID_FILE)` >> $@ +endif + +# ----------------------------------------------------------------- +# vendor build.prop +# +# For verifying that the vendor build is what we thing it is +ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE +INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop +ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET) +$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) + @echo Target vendor buildinfo: $@ + @mkdir -p $(dir $@) + $(hide) echo > $@ + $(hide) echo ro.vendor.build.date=`$(DATE_FROM_FILE)`>>$@ + $(hide) echo ro.vendor.build.date.utc=`$(DATE_FROM_FILE) +%s`>>$@ + $(hide) echo ro.vendor.build.fingerprint="$(BUILD_FINGERPRINT_FROM_FILE)">>$@ +endif + +# ---------------------------------------------------------------- + +# ----------------------------------------------------------------- +# sdk-build.prop +# +# There are certain things in build.prop that we don't want to +# ship with the sdk; remove them. + +# This must be a list of entire property keys followed by +# "=" characters, without any internal spaces. +sdk_build_prop_remove := \ + ro.build.user= \ + ro.build.host= \ + ro.product.brand= \ + ro.product.manufacturer= \ + ro.product.device= +# TODO: Remove this soon-to-be obsolete property +sdk_build_prop_remove += ro.build.product= +INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop +$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET) + @echo SDK buildinfo: $@ + @mkdir -p $(dir $@) + $(hide) grep -v "$(subst $(space),\|,$(strip \ + $(sdk_build_prop_remove)))" $< > $@.tmp + $(hide) for x in $(sdk_build_prop_remove); do \ + echo "$$x"generic >> $@.tmp; done + $(hide) mv $@.tmp $@ + +# ----------------------------------------------------------------- +# package stats +PACKAGE_STATS_FILE := $(PRODUCT_OUT)/package-stats.txt +PACKAGES_TO_STAT := \ + $(sort $(filter $(TARGET_OUT)/% $(TARGET_OUT_DATA)/%, \ + $(filter %.jar %.apk, $(ALL_DEFAULT_INSTALLED_MODULES)))) +$(PACKAGE_STATS_FILE): $(PACKAGES_TO_STAT) + @echo Package stats: $@ + @mkdir -p $(dir $@) + $(hide) rm -f $@ +ifeq ($(PACKAGES_TO_STAT),) +# Create empty package stats file if target builds no jar(s) or apk(s). + $(hide) touch $@ +else + $(hide) build/tools/dump-package-stats $^ > $@ +endif + +.PHONY: package-stats +package-stats: $(PACKAGE_STATS_FILE) + +# ----------------------------------------------------------------- +# Cert-to-package mapping. Used by the post-build signing tools. +# Use a macro to add newline to each echo command +define _apkcerts_echo_with_newline +$(hide) echo $(1) + +endef + +name := $(TARGET_PRODUCT) +ifeq ($(TARGET_BUILD_TYPE),debug) + name := $(name)_debug +endif +name := $(name)-apkcerts-$(FILE_NAME_TAG) +intermediates := \ + $(call intermediates-dir-for,PACKAGING,apkcerts) +APKCERTS_FILE := $(intermediates)/$(name).txt +# We don't need to really build all the modules. +# TODO: rebuild APKCERTS_FILE if any app change its cert. +$(APKCERTS_FILE): + @echo APK certs list: $@ + @mkdir -p $(dir $@) + @rm -f $@ + $(foreach p,$(PACKAGES),\ + $(if $(PACKAGES.$(p).EXTERNAL_KEY),\ + $(call _apkcerts_echo_with_newline,\ + 'name="$(p).apk" certificate="EXTERNAL" \ + private_key=""' >> $@),\ + $(call _apkcerts_echo_with_newline,\ + 'name="$(p).apk" certificate="$(PACKAGES.$(p).CERTIFICATE)" \ + private_key="$(PACKAGES.$(p).PRIVATE_KEY)"' >> $@))) + # In case value of PACKAGES is empty. + $(hide) touch $@ + +.PHONY: apkcerts-list +apkcerts-list: $(APKCERTS_FILE) + +ifneq (,$(TARGET_BUILD_APPS)) + $(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt) +endif + +# ----------------------------------------------------------------- + +# The dev key is used to sign this package, and as the key required +# for future OTA packages installed by this system. Actual product +# deliverables will be re-signed by hand. We expect this file to +# exist with the suffixes ".x509.pem" and ".pk8". +DEFAULT_KEY_CERT_PAIR := $(DEFAULT_SYSTEM_DEV_CERTIFICATE) + + +# Rules that need to be present for the all targets, even +# if they don't do anything. +.PHONY: systemimage +systemimage: + +# ----------------------------------------------------------------- + +.PHONY: event-log-tags + +# Produce an event logs tag file for everything we know about, in order +# to properly allocate numbers. Then produce a file that's filtered +# for what's going to be installed. + +all_event_log_tags_file := $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt + +event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags + +# Include tags from all packages that we know about +all_event_log_tags_src := \ + $(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS))) + +# PDK builds will already have a full list of tags that needs to get merged +# in with the ones from source +pdk_fusion_log_tags_file := $(patsubst $(PRODUCT_OUT)/%,$(_pdk_fusion_intermediates)/%,$(filter $(event_log_tags_file),$(ALL_PDK_FUSION_FILES))) + +$(all_event_log_tags_file): PRIVATE_SRC_FILES := $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) +$(all_event_log_tags_file): $(all_event_log_tags_src) $(pdk_fusion_log_tags_file) + $(hide) mkdir -p $(dir $@) + $(hide) build/tools/merge-event-log-tags.py -o $@ $(PRIVATE_SRC_FILES) + +# Include tags from all packages included in this product, plus all +# tags that are part of the system (ie, not in a vendor/ or device/ +# directory). +event_log_tags_src := \ + $(sort $(foreach m,\ + $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES) \ + $(call module-names-for-tag-list,user), \ + $(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \ + $(filter-out vendor/% device/% out/%,$(all_event_log_tags_src))) + +$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src) $(pdk_fusion_log_tags_file) +$(event_log_tags_file): PRIVATE_MERGED_FILE := $(all_event_log_tags_file) +$(event_log_tags_file): $(event_log_tags_src) $(all_event_log_tags_file) $(pdk_fusion_log_tags_file) + $(hide) mkdir -p $(dir $@) + $(hide) build/tools/merge-event-log-tags.py -o $@ -m $(PRIVATE_MERGED_FILE) $(PRIVATE_SRC_FILES) + +event-log-tags: $(event_log_tags_file) + +ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file) + + +# ################################################################# +# Targets for boot/OS images +# ################################################################# +ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true) + INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader + ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true) + INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader + else + INSTALLED_2NDBOOTLOADER_TARGET := + endif +else + INSTALLED_BOOTLOADER_MODULE := + INSTALLED_2NDBOOTLOADER_TARGET := +endif # TARGET_NO_BOOTLOADER +ifneq ($(strip $(TARGET_NO_KERNEL)),true) + INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel +else + INSTALLED_KERNEL_TARGET := +endif + +# ----------------------------------------------------------------- +# the ramdisk +INTERNAL_RAMDISK_FILES := $(filter $(TARGET_ROOT_OUT)/%, \ + $(ALL_PREBUILT) \ + $(ALL_GENERATED_SOURCES) \ + $(ALL_DEFAULT_INSTALLED_MODULES)) + +BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img + +# We just build this directly to the install location. +INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET) +$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_RAMDISK_FILES) | $(MINIGZIP) + $(call pretty,"Target ram disk: $@") + $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $@ + +.PHONY: ramdisk-nodeps +ramdisk-nodeps: $(MKBOOTFS) | $(MINIGZIP) + @echo "make $@: ignoring dependencies" + $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_ROOT_OUT) | $(MINIGZIP) > $(INSTALLED_RAMDISK_TARGET) + +ifneq ($(strip $(TARGET_NO_KERNEL)),true) + +# ----------------------------------------------------------------- +# the boot image, which is a collection of other images. +INTERNAL_BOOTIMAGE_ARGS := \ + $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ + --kernel $(INSTALLED_KERNEL_TARGET) + +ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) +INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET) +endif + +INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS)) + +BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE)) +ifdef BOARD_KERNEL_BASE + INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) +endif + +BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE)) +ifdef BOARD_KERNEL_PAGESIZE + INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE) +endif + +ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),true) +ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) +VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem -text \ + | grep keyid | sed 's/://g' | tr -d '[:space:]' | tr '[:upper:]' '[:lower:]' | sed 's/keyid//g'` +endif +endif + +BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID)) +ifdef BOARD_KERNEL_CMDLINE +INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" +endif + +INTERNAL_MKBOOTIMG_VERSION_ARGS := \ + --os_version $(PLATFORM_VERSION) \ + --os_patch_level $(PLATFORM_SECURITY_PATCH) + +INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img + +# BOARD_USES_RECOVERY_AS_BOOT = true must have BOARD_BUILD_SYSTEM_ROOT_IMAGE = true. +ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) +ifneq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) + $(error BOARD_BUILD_SYSTEM_ROOT_IMAGE must be enabled for BOARD_USES_RECOVERY_AS_BOOT.) +endif +endif + +# We build recovery as boot image if BOARD_USES_RECOVERY_AS_BOOT is true. +ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true) +ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true) +$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore) +else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) # TARGET_BOOTIMAGE_USE_EXT2 != true + +$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(BOOT_SIGNER) + $(call pretty,"Target boot image: $@") + $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@ + $(BOOT_SIGNER) /boot $@ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $@ + $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) + +.PHONY: bootimage-nodeps +bootimage-nodeps: $(MKBOOTIMG) $(BOOT_SIGNER) + @echo "make $@: ignoring dependencies" + $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET) + $(BOOT_SIGNER) /boot $(INSTALLED_BOOTIMAGE_TARGET) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(INSTALLED_BOOTIMAGE_TARGET) + $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE)) + +else ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)) # PRODUCT_SUPPORTS_BOOT_SIGNER != true + +$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) $(VBOOT_SIGNER) + $(call pretty,"Target boot image: $@") + $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@.unsigned + $(VBOOT_SIGNER) $(FUTILITY) $@.unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $@.keyblock $@ + $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) + +.PHONY: bootimage-nodeps +bootimage-nodeps: $(MKBOOTIMG) $(VBOOT_SIGNER) + @echo "make $@: ignoring dependencies" + $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET).unsigned + $(VBOOT_SIGNER) $(FUTILITY) $(INSTALLED_BOOTIMAGE_TARGET).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(INSTALLED_BOOTIMAGE_TARGET).keyblock $(INSTALLED_BOOTIMAGE_TARGET) + $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE)) + +else # PRODUCT_SUPPORTS_VBOOT != true + +$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES) + $(call pretty,"Target boot image: $@") + $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $@ + $(hide) $(call assert-max-image-size,$@,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) + +.PHONY: bootimage-nodeps +bootimage-nodeps: $(MKBOOTIMG) + @echo "make $@: ignoring dependencies" + $(hide) $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(INSTALLED_BOOTIMAGE_TARGET) + $(hide) $(call assert-max-image-size,$(INSTALLED_BOOTIMAGE_TARGET),$(BOARD_BOOTIMAGE_PARTITION_SIZE)) + +endif # TARGET_BOOTIMAGE_USE_EXT2 +endif # BOARD_USES_RECOVERY_AS_BOOT + +else # TARGET_NO_KERNEL +# HACK: The top-level targets depend on the bootimage. Not all targets +# can produce a bootimage, though, and emulator targets need the ramdisk +# instead. Fake it out by calling the ramdisk the bootimage. +# TODO: make the emulator use bootimages, and make mkbootimg accept +# kernel-less inputs. +INSTALLED_BOOTIMAGE_TARGET := $(INSTALLED_RAMDISK_TARGET) +endif + +# ----------------------------------------------------------------- +# NOTICE files +# +# We are required to publish the licenses for all code under BSD, GPL and +# Apache licenses (and possibly other more exotic ones as well). We err on the +# side of caution, so the licenses for other third-party code are included here +# too. +# +# This needs to be before the systemimage rules, because it adds to +# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files +# go into the systemimage. + +.PHONY: notice_files + +# Create the rule to combine the files into text and html forms +# $(1) - Plain text output file +# $(2) - HTML output file +# $(3) - File title +# $(4) - Directory to use. Notice files are all $(4)/src. Other +# directories in there will be used for scratch +# $(5) - Dependencies for the output files +# +# The algorithm here is that we go collect a hash for each of the notice +# files and write the names of the files that match that hash. Then +# to generate the real files, we go print out all of the files and their +# hashes. +# +# These rules are fairly complex, so they depend on this makefile so if +# it changes, they'll run again. +# +# TODO: We could clean this up so that we just record the locations of the +# original notice files instead of making rules to copy them somwehere. +# Then we could traverse that without quite as much bash drama. +define combine-notice-files +$(1) $(2): PRIVATE_MESSAGE := $(3) +$(1) $(2): PRIVATE_DIR := $(4) +$(1) : $(2) +$(2) : $(5) $(BUILD_SYSTEM)/Makefile build/tools/generate-notice-files.py + build/tools/generate-notice-files.py $(1) $(2) $$(PRIVATE_MESSAGE) $$(PRIVATE_DIR)/src +notice_files: $(1) $(2) +endef + +# TODO These intermediate NOTICE.txt/NOTICE.html files should go into +# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from +# the src subdirectory. + +target_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE.txt +target_notice_file_html := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html +target_notice_file_html_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.html.gz +tools_notice_file_txt := $(HOST_OUT_INTERMEDIATES)/NOTICE.txt +tools_notice_file_html := $(HOST_OUT_INTERMEDIATES)/NOTICE.html + +ifndef TARGET_BUILD_APPS +kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt +pdk_fusion_notice_files := $(filter $(TARGET_OUT_NOTICE_FILES)/%, $(ALL_PDK_FUSION_FILES)) + +$(eval $(call combine-notice-files, \ + $(target_notice_file_txt), \ + $(target_notice_file_html), \ + "Notices for files contained in the filesystem images in this directory:", \ + $(TARGET_OUT_NOTICE_FILES), \ + $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file) $(pdk_fusion_notice_files))) + +$(eval $(call combine-notice-files, \ + $(tools_notice_file_txt), \ + $(tools_notice_file_html), \ + "Notices for files contained in the tools directory:", \ + $(HOST_OUT_NOTICE_FILES), \ + $(ALL_DEFAULT_INSTALLED_MODULES))) + +# Install the html file at /system/etc/NOTICE.html.gz. +# This is not ideal, but this is very late in the game, after a lot of +# the module processing has already been done -- in fact, we used the +# fact that all that has been done to get the list of modules that we +# need notice files for. +$(target_notice_file_html_gz): $(target_notice_file_html) | $(MINIGZIP) + $(hide) $(MINIGZIP) -9 < $< > $@ +installed_notice_html_gz := $(TARGET_OUT)/etc/NOTICE.html.gz +$(installed_notice_html_gz): $(target_notice_file_html_gz) | $(ACP) + $(copy-file-to-target) + +# if we've been run my mm, mmm, etc, don't reinstall this every time +ifeq ($(ONE_SHOT_MAKEFILE),) +ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_gz) +endif +endif # TARGET_BUILD_APPS + +# The kernel isn't really a module, so to get its module file in there, we +# make the target NOTICE files depend on this particular file too, which will +# then be in the right directory for the find in combine-notice-files to work. +$(kernel_notice_file): \ + $(BUILD_SYSTEM)/LINUX_KERNEL_COPYING \ + | $(ACP) + @echo Copying: $@ + $(hide) mkdir -p $(dir $@) + $(hide) $(ACP) $< $@ + + +# ----------------------------------------------------------------- +# Build a keystore with the authorized keys in it, used to verify the +# authenticity of downloaded OTA packages. +# +# This rule adds to ALL_DEFAULT_INSTALLED_MODULES, so it needs to come +# before the rules that use that variable to build the image. +ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/security/otacerts.zip +$(TARGET_OUT_ETC)/security/otacerts.zip: KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) +$(TARGET_OUT_ETC)/security/otacerts.zip: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) | $(ZIPTIME) + $(hide) rm -f $@ + $(hide) mkdir -p $(dir $@) + $(hide) zip -qjX $@ $< + $(remove-timestamps-from-package) + +# Carry the public key for update_engine if it's a non-Brillo target that +# uses the AB updater. We use the same key as otacerts but in RSA public key +# format. +ifeq ($(AB_OTA_UPDATER),true) +ifeq ($(BRILLO),) +ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem +$(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem: $(addsuffix .x509.pem,$(DEFAULT_KEY_CERT_PAIR)) + $(hide) rm -f $@ + $(hide) mkdir -p $(dir $@) + $(hide) openssl x509 -pubkey -noout -in $< > $@ + +ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem +$(TARGET_RECOVERY_ROOT_OUT)/etc/update_engine/update-payload-key.pub.pem: $(TARGET_OUT_ETC)/update_engine/update-payload-key.pub.pem + $(hide) cp -f $< $@ +endif +endif + +.PHONY: otacerts +otacerts: $(TARGET_OUT_ETC)/security/otacerts.zip + + +# ################################################################# +# Targets for user images +# ################################################################# + +INTERNAL_USERIMAGES_EXT_VARIANT := +ifeq ($(TARGET_USERIMAGES_USE_EXT2),true) +INTERNAL_USERIMAGES_USE_EXT := true +INTERNAL_USERIMAGES_EXT_VARIANT := ext2 +else +ifeq ($(TARGET_USERIMAGES_USE_EXT3),true) +INTERNAL_USERIMAGES_USE_EXT := true +INTERNAL_USERIMAGES_EXT_VARIANT := ext3 +else +ifeq ($(TARGET_USERIMAGES_USE_EXT4),true) +INTERNAL_USERIMAGES_USE_EXT := true +INTERNAL_USERIMAGES_EXT_VARIANT := ext4 +endif +endif +endif + +# These options tell the recovery updater/installer how to mount the partitions writebale. +# =[|]... +# fstype_opts := [,]... +# opt := [=] +# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10 +DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc + +ifneq (true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)) + INTERNAL_USERIMAGES_SPARSE_EXT_FLAG := -s +endif + +ifeq ($(INTERNAL_USERIMAGES_USE_EXT),true) +INTERNAL_USERIMAGES_DEPS := $(SIMG2IMG) +INTERNAL_USERIMAGES_DEPS += $(MKEXTUSERIMG) $(MAKE_EXT4FS) $(E2FSCK) +ifeq ($(TARGET_USERIMAGES_USE_F2FS),true) +INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG) $(MAKE_F2FS) +endif +endif + +ifneq (true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED)) + INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG := -s +endif +ifneq ($(filter $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),squashfs),) +INTERNAL_USERIMAGES_DEPS += $(MAKE_SQUASHFS) $(MKSQUASHFSUSERIMG) $(IMG2SIMG) +endif + +INTERNAL_USERIMAGES_BINARY_PATHS := $(sort $(dir $(INTERNAL_USERIMAGES_DEPS))) + +ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)) +INTERNAL_USERIMAGES_DEPS += $(BUILD_VERITY_TREE) $(APPEND2SIMG) $(VERITY_SIGNER) +ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC)) +INTERNAL_USERIMAGES_DEPS += $(FEC) +endif +endif + +SELINUX_FC := $(TARGET_ROOT_OUT)/file_contexts.bin +INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC) + +INTERNAL_USERIMAGES_DEPS += $(BLK_ALLOC_TO_BASE_FS) + +# $(1): the path of the output dictionary file +# $(2): additional "key=value" pairs to append to the dictionary file. +define generate-userimage-prop-dictionary +$(if $(INTERNAL_USERIMAGES_EXT_VARIANT),$(hide) echo "fs_type=$(INTERNAL_USERIMAGES_EXT_VARIANT)" >> $(1)) +$(if $(BOARD_SYSTEMIMAGE_PARTITION_SIZE),$(hide) echo "system_size=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)" >> $(1)) +$(if $(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "system_fs_type=$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) +$(if $(BOARD_SYSTEMIMAGE_JOURNAL_SIZE),$(hide) echo "system_journal_size=$(BOARD_SYSTEMIMAGE_JOURNAL_SIZE)" >> $(1)) +$(if $(BOARD_HAS_EXT4_RESERVED_BLOCKS),$(hide) echo "has_ext4_reserved_blocks=$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" >> $(1)) +$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "system_squashfs_compressor=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR)" >> $(1)) +$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "system_squashfs_compressor_opt=$(BOARD_SYSTEMIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1)) +$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "system_squashfs_block_size=$(BOARD_SYSTEMIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1)) +$(if $(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "system_squashfs_disable_4k_align=$(BOARD_SYSTEMIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),$(hide) echo "system_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)" >> $(1)) +$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) +$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1)) +$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) +$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1)) +$(if $(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "vendor_fs_type=$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE)" >> $(1)) +$(if $(BOARD_VENDORIMAGE_PARTITION_SIZE),$(hide) echo "vendor_size=$(BOARD_VENDORIMAGE_PARTITION_SIZE)" >> $(1)) +$(if $(BOARD_VENDORIMAGE_JOURNAL_SIZE),$(hide) echo "vendor_journal_size=$(BOARD_VENDORIMAGE_JOURNAL_SIZE)" >> $(1)) +$(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "vendor_squashfs_compressor=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR)" >> $(1)) +$(if $(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "vendor_squashfs_compressor_opt=$(BOARD_VENDORIMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(1)) +$(if $(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "vendor_squashfs_block_size=$(BOARD_VENDORIMAGE_SQUASHFS_BLOCK_SIZE)" >> $(1)) +$(if $(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "vendor_squashfs_disable_4k_align=$(BOARD_VENDORIMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),$(hide) echo "vendor_base_fs_file=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH)" >> $(1)) +$(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1)) +$(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1)) +$(if $(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG),$(hide) echo "extfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_EXT_FLAG)" >> $(1)) +$(if $(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG),$(hide) echo "squashfs_sparse_flag=$(INTERNAL_USERIMAGES_SPARSE_SQUASHFS_FLAG)" >> $(1)) +$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(1) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER),$(hide) echo "boot_signer=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY),$(hide) echo "verity_signer_cmd=$(notdir $(VERITY_SIGNER))" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC),$(hide) echo "verity_fec=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VERITY_FEC)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_key=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_subkey=$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "futility=$(FUTILITY)" >> $(1)) +$(if $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT),$(hide) echo "vboot_signer_cmd=$(VBOOT_SIGNER)" >> $(1)) +$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\ + $(hide) echo "recovery_as_boot=true" >> $(1)) +$(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)),\ + $(hide) echo "system_root_image=true" >> $(1);\ + echo "ramdisk_dir=$(TARGET_ROOT_OUT)" >> $(1)) +$(if $(2),$(hide) $(foreach kv,$(2),echo "$(kv)" >> $(1);)) +endef + +# ----------------------------------------------------------------- +# Recovery image + +# Recovery image exists if we are building recovery, or building recovery as boot. +ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))) + +INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \ + $(ALL_DEFAULT_INSTALLED_MODULES)) + +recovery_initrc := $(call include-path-for, recovery)/etc/init.rc +recovery_sepolicy := $(call intermediates-dir-for,ETC,sepolicy.recovery)/sepolicy.recovery +recovery_kernel := $(INSTALLED_KERNEL_TARGET) # same as a non-recovery system +recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img +recovery_build_prop := $(intermediate_system_build_prop) +recovery_resources_common := $(call include-path-for, recovery)/res + +# Set recovery_density to the density bucket of the device. +recovery_density := unknown +ifneq (,$(PRODUCT_AAPT_PREF_CONFIG)) +# If PRODUCT_AAPT_PREF_CONFIG includes a dpi bucket, then use that value. +recovery_density := $(filter %dpi,$(PRODUCT_AAPT_PREF_CONFIG)) +else +# Otherwise, use the default medium density. +recovery_densities := mdpi +endif + +ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density))) +recovery_resources_common := $(recovery_resources_common)-$(recovery_density) +else +recovery_resources_common := $(recovery_resources_common)-xhdpi +endif + +# Select the 18x32 font on high-density devices (xhdpi and up); and +# the 12x22 font on other devices. Note that the font selected here +# can be overridden for a particular device by putting a font.png in +# its private recovery resources. + +ifneq (,$(filter xxxhdpi 560dpi xxhdpi 400dpi xhdpi,$(recovery_density))) +recovery_font := $(call include-path-for, recovery)/fonts/18x32.png +else +recovery_font := $(call include-path-for, recovery)/fonts/12x22.png +endif + +ifndef TARGET_PRIVATE_RES_DIRS +TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res) +endif +recovery_resource_deps := $(shell find $(recovery_resources_common) \ + $(TARGET_PRIVATE_RES_DIRS) -type f) +ifdef TARGET_RECOVERY_FSTAB +recovery_fstab := $(TARGET_RECOVERY_FSTAB) +else +recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab)) +endif +ifdef TARGET_RECOVERY_WIPE +recovery_wipe := $(TARGET_RECOVERY_WIPE) +else +recovery_wipe := +endif + +# Prior to A/B update, we used to have: +# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img. +# recovery-resource.dat is needed only if we carry a patch of the boot and +# recovery images and invoke install-recovery.sh on the first boot post an +# OTA update. +# +# We no longer need that if one of the following conditions holds: +# a) We carry a full copy of the recovery image +# (BOARD_USES_FULL_RECOVERY_IMAGE = true); +# b) We build a single image that contains boot and recovery both +# (BOARD_USES_RECOVERY_AS_BOOT = true). + +ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT))) +# Named '.dat' so we don't attempt to use imgdiff for patching it. +RECOVERY_RESOURCE_ZIP := $(TARGET_OUT)/etc/recovery-resource.dat +else +RECOVERY_RESOURCE_ZIP := +endif + +ifeq ($(TARGET_PRIVATE_RES_DIRS),) + $(info No private recovery resources for TARGET_DEVICE $(TARGET_DEVICE)) +endif + +ifeq ($(recovery_fstab),) + $(info No recovery.fstab for TARGET_DEVICE $(TARGET_DEVICE)) +endif + +INTERNAL_RECOVERYIMAGE_ARGS := \ + $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET)) \ + --kernel $(recovery_kernel) \ + --ramdisk $(recovery_ramdisk) + +# Assumes this has already been stripped +ifdef BOARD_KERNEL_CMDLINE + INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)" +endif +ifdef BOARD_KERNEL_BASE + INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE) +endif +BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE)) +ifdef BOARD_KERNEL_PAGESIZE + INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE) +endif + +# Keys authorized to sign OTA packages this build will accept. The +# build always uses dev-keys for this; release packaging tools will +# substitute other keys for this one. +OTA_PUBLIC_KEYS := $(DEFAULT_SYSTEM_DEV_CERTIFICATE).x509.pem + +# Generate a file containing the keys that will be read by the +# recovery binary. +RECOVERY_INSTALL_OTA_KEYS := \ + $(call intermediates-dir-for,PACKAGING,ota_keys)/keys +DUMPKEY_JAR := $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar +$(RECOVERY_INSTALL_OTA_KEYS): PRIVATE_OTA_PUBLIC_KEYS := $(OTA_PUBLIC_KEYS) +$(RECOVERY_INSTALL_OTA_KEYS): extra_keys := $(patsubst %,%.x509.pem,$(PRODUCT_EXTRA_RECOVERY_KEYS)) +$(RECOVERY_INSTALL_OTA_KEYS): $(OTA_PUBLIC_KEYS) $(DUMPKEY_JAR) $(extra_keys) + @echo "DumpPublicKey: $@ <= $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys)" + @rm -rf $@ + @mkdir -p $(dir $@) + java -jar $(DUMPKEY_JAR) $(PRIVATE_OTA_PUBLIC_KEYS) $(extra_keys) > $@ + +RECOVERYIMAGE_ID_FILE := $(PRODUCT_OUT)/recovery.id +# $(1): output file +define build-recoveryimage-target + @echo ----- Making recovery image ------ + $(hide) mkdir -p $(TARGET_RECOVERY_OUT) + $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/etc $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp + @echo Copying baseline ramdisk... + $(hide) rsync -a --exclude=etc --exclude=sdcard $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT) # "cp -Rf" fails to overwrite broken symlinks on Mac. + @echo Modifying ramdisk contents... + $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/init*.rc + $(hide) cp -f $(recovery_initrc) $(TARGET_RECOVERY_ROOT_OUT)/ + $(hide) rm -f $(TARGET_RECOVERY_ROOT_OUT)/sepolicy + $(hide) cp -f $(recovery_sepolicy) $(TARGET_RECOVERY_ROOT_OUT)/sepolicy + $(hide) cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ || true # Ignore error when the src file doesn't exist. + $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res + $(hide) rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/* + $(hide) cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res + $(hide) cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png + $(hide) $(foreach item,$(TARGET_PRIVATE_RES_DIRS), \ + cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline)) + $(hide) $(foreach item,$(recovery_fstab), \ + cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.fstab) + $(if $(strip $(recovery_wipe)), \ + $(hide) cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/etc/recovery.wipe) + $(hide) cp $(RECOVERY_INSTALL_OTA_KEYS) $(TARGET_RECOVERY_ROOT_OUT)/res/keys + $(hide) cat $(INSTALLED_DEFAULT_PROP_TARGET) $(recovery_build_prop) \ + > $(TARGET_RECOVERY_ROOT_OUT)/default.prop + $(BOARD_RECOVERY_IMAGE_PREPARE) + $(if $(filter true,$(BOARD_BUILD_SYSTEM_ROOT_IMAGE)), \ + $(hide) mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/system_root; \ + rm -rf $(TARGET_RECOVERY_ROOT_OUT)/system; \ + ln -sf /system_root/system $(TARGET_RECOVERY_ROOT_OUT)/system) # Mount the system_root_image to /system_root and symlink /system. + $(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(MINIGZIP) > $(recovery_ramdisk) + $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \ + $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1).unsigned, \ + $(hide) $(MKBOOTIMG) $(INTERNAL_RECOVERYIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1) --id > $(RECOVERYIMAGE_ID_FILE)) + $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)),\ + $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\ + $(BOOT_SIGNER) /boot $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1),\ + $(BOOT_SIGNER) /recovery $(1) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).pk8 $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY).x509.pem $(1)\ + )\ + ) + $(if $(filter true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)), \ + $(VBOOT_SIGNER) $(FUTILITY) $(1).unsigned $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbpubk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_KEY).vbprivk $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VBOOT_SIGNING_SUBKEY).vbprivk $(1).keyblock $(1)) + $(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \ + $(hide) $(call assert-max-image-size,$(1),$(BOARD_BOOTIMAGE_PARTITION_SIZE)), \ + $(hide) $(call assert-max-image-size,$(1),$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))) + @echo ----- Made recovery image: $(1) -------- +endef + +ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) +ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_BOOT_SIGNER)) +$(INSTALLED_BOOTIMAGE_TARGET) : $(BOOT_SIGNER) +endif +ifeq (true,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SUPPORTS_VBOOT)) +$(INSTALLED_BOOTIMAGE_TARGET) : $(VBOOT_SIGNER) +endif +$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \ + $(INSTALLED_RAMDISK_TARGET) \ + $(INTERNAL_RECOVERYIMAGE_FILES) \ + $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \ + $(INSTALLED_2NDBOOTLOADER_TARGET) \ + $(recovery_build_prop) $(recovery_resource_deps) \ + $(recovery_fstab) \ + $(RECOVERY_INSTALL_OTA_KEYS) + $(call pretty,"Target boot image from recovery: $@") + $(call build-recoveryimage-target, $@) +endif + +$(INSTALLED_RECOVERYIMAGE_TARGET): $(MKBOOTFS) $(MKBOOTIMG) $(MINIGZIP) \ + $(INSTALLED_RAMDISK_TARGET) \ + $(INSTALLED_BOOTIMAGE_TARGET) \ + $(INTERNAL_RECOVERYIMAGE_FILES) \ + $(recovery_initrc) $(recovery_sepolicy) $(recovery_kernel) \ + $(INSTALLED_2NDBOOTLOADER_TARGET) \ + $(recovery_build_prop) $(recovery_resource_deps) \ + $(recovery_fstab) \ + $(RECOVERY_INSTALL_OTA_KEYS) + $(call build-recoveryimage-target, $@) + +ifdef RECOVERY_RESOURCE_ZIP +$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME) + $(hide) mkdir -p $(dir $@) + $(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@ + $(remove-timestamps-from-package) +endif + +.PHONY: recoveryimage-nodeps +recoveryimage-nodeps: + @echo "make $@: ignoring dependencies" + $(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET)) + +else # INSTALLED_RECOVERYIMAGE_TARGET not defined +RECOVERY_RESOURCE_ZIP := +endif + +.PHONY: recoveryimage +recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP) + +ifeq ($(BOARD_NAND_PAGE_SIZE),) +BOARD_NAND_PAGE_SIZE := 2048 +endif + +ifeq ($(BOARD_NAND_SPARE_SIZE),) +BOARD_NAND_SPARE_SIZE := 64 +endif + +# ----------------------------------------------------------------- +# system image +# +# Remove overridden packages from $(ALL_PDK_FUSION_FILES) +PDK_FUSION_SYSIMG_FILES := \ + $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk), \ + $(ALL_PDK_FUSION_FILES)) + +INTERNAL_SYSTEMIMAGE_FILES := $(filter $(TARGET_OUT)/%, \ + $(ALL_PREBUILT) \ + $(ALL_GENERATED_SOURCES) \ + $(ALL_DEFAULT_INSTALLED_MODULES) \ + $(PDK_FUSION_SYSIMG_FILES) \ + $(RECOVERY_RESOURCE_ZIP)) + + +FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS) +# ----------------------------------------------------------------- +# installed file list +# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on. +# We put installed-files.txt ahead of image itself in the dependency graph +# so that we can get the size stat even if the build fails due to too large +# system image. +INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt +$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) + @echo Installed file list: $@ + @mkdir -p $(dir $@) + @rm -f $@ + $(hide) build/tools/fileslist.py $(TARGET_OUT) > $@ + +.PHONY: installed-file-list +installed-file-list: $(INSTALLED_FILES_FILE) + +$(call dist-for-goals, sdk win_sdk sdk_addon, $(INSTALLED_FILES_FILE)) + +systemimage_intermediates := \ + $(call intermediates-dir-for,PACKAGING,systemimage) +BUILT_SYSTEMIMAGE := $(systemimage_intermediates)/system.img + +# Create symlink /system/vendor to /vendor if necessary. +ifdef BOARD_USES_VENDORIMAGE +define create-system-vendor-symlink +$(hide) if [ -d $(TARGET_OUT)/vendor ] && [ ! -h $(TARGET_OUT)/vendor ]; then \ + echo 'Non-symlink $(TARGET_OUT)/vendor detected!' 1>&2; \ + echo 'You cannot install files to $(TARGET_OUT)/vendor while building a separate vendor.img!' 1>&2; \ + exit 1; \ +fi +$(hide) ln -sf /vendor $(TARGET_OUT)/vendor +endef +else +define create-system-vendor-symlink +endef +endif + +# $(1): output file +define build-systemimage-target + @echo "Target system fs image: $(1)" + $(call create-system-vendor-symlink) + @mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt + $(call generate-userimage-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt, \ + skip_fsck=true) + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + ./build/tools/releasetools/build_image.py \ + $(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \ + || ( echo "Out of space? the tree size of $(TARGET_OUT) is (MB): " 1>&2 ;\ + du -sm $(TARGET_OUT) 1>&2;\ + if [ "$(INTERNAL_USERIMAGES_EXT_VARIANT)" == "ext4" ]; then \ + maxsize=$(BOARD_SYSTEMIMAGE_PARTITION_SIZE); \ + if [ "$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" == "true" ]; then \ + maxsize=$$((maxsize - 4096 * 4096)); \ + fi; \ + echo "The max is $$(( maxsize / 1048576 )) MB." 1>&2 ;\ + else \ + echo "The max is $$(( $(BOARD_SYSTEMIMAGE_PARTITION_SIZE) / 1048576 )) MB." 1>&2 ;\ + fi; \ + mkdir -p $(DIST_DIR); cp $(INSTALLED_FILES_FILE) $(DIST_DIR)/installed-files-rescued.txt; \ + exit 1 ) +endef + +$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) + $(call build-systemimage-target,$@) + +INSTALLED_SYSTEMIMAGE := $(PRODUCT_OUT)/system.img +SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT) + +# The system partition needs room for the recovery image as well. We +# now store the recovery image as a binary patch using the boot image +# as the source (since they are very similar). Generate the patch so +# we can see how big it's going to be, and include that in the system +# image size check calculation. +ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),) +ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true) +intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch) +RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p +$(RECOVERY_FROM_BOOT_PATCH): $(INSTALLED_RECOVERYIMAGE_TARGET) \ + $(INSTALLED_BOOTIMAGE_TARGET) \ + $(HOST_OUT_EXECUTABLES)/imgdiff \ + $(HOST_OUT_EXECUTABLES)/bsdiff + @echo "Construct recovery from boot" + mkdir -p $(dir $@) + PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(HOST_OUT_EXECUTABLES)/imgdiff $(INSTALLED_BOOTIMAGE_TARGET) $(INSTALLED_RECOVERYIMAGE_TARGET) $@ +else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true +RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET) +endif +endif + + +$(INSTALLED_SYSTEMIMAGE): $(BUILT_SYSTEMIMAGE) $(RECOVERY_FROM_BOOT_PATCH) | $(ACP) + @echo "Install system fs image: $@" + $(copy-file-to-target) + $(hide) $(call assert-max-image-size,$@ $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)) + +systemimage: $(INSTALLED_SYSTEMIMAGE) + +.PHONY: systemimage-nodeps snod +systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \ + | $(INTERNAL_USERIMAGES_DEPS) + @echo "make $@: ignoring dependencies" + $(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE)) + $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)) + +ifneq (,$(filter systemimage-nodeps snod, $(MAKECMDGOALS))) +ifeq (true,$(WITH_DEXPREOPT)) +$(warning Warning: with dexpreopt enabled, you may need a full rebuild.) +endif +endif + +####### +## system tarball +define build-systemtarball-target + $(call pretty,"Target system fs tarball: $(INSTALLED_SYSTEMTARBALL_TARGET)") + $(call create-system-vendor-symlink) + $(MKTARBALL) $(FS_GET_STATS) \ + $(PRODUCT_OUT) system $(PRIVATE_SYSTEM_TAR) \ + $(INSTALLED_SYSTEMTARBALL_TARGET) $(TARGET_OUT) +endef + +ifndef SYSTEM_TARBALL_FORMAT + SYSTEM_TARBALL_FORMAT := bz2 +endif + +system_tar := $(PRODUCT_OUT)/system.tar +INSTALLED_SYSTEMTARBALL_TARGET := $(system_tar).$(SYSTEM_TARBALL_FORMAT) +$(INSTALLED_SYSTEMTARBALL_TARGET): PRIVATE_SYSTEM_TAR := $(system_tar) +$(INSTALLED_SYSTEMTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_SYSTEMIMAGE_FILES) + $(build-systemtarball-target) + +.PHONY: systemtarball-nodeps +systemtarball-nodeps: $(FS_GET_STATS) \ + $(filter-out systemtarball-nodeps stnod,$(MAKECMDGOALS)) + $(build-systemtarball-target) + +.PHONY: stnod +stnod: systemtarball-nodeps + +# ----------------------------------------------------------------- +## platform.zip: system, plus other files to be used in PDK fusion build, +## in a zip file +## +## PDK_PLATFORM_ZIP_PRODUCT_BINARIES is used to store specified files to platform.zip. +## The variable will be typically set from BoardConfig.mk. +## Files under out dir will be rejected to prevent possible conflicts with other rules. +pdk_odex_javalibs := $(strip $(foreach m,$(DEXPREOPT.MODULES.JAVA_LIBRARIES),\ + $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m)))) +pdk_odex_apps := $(strip $(foreach m,$(DEXPREOPT.MODULES.APPS),\ + $(if $(filter $(DEXPREOPT.$(m).INSTALLED),$(ALL_DEFAULT_INSTALLED_MODULES)),$(m)))) +pdk_classes_dex := $(strip \ + $(foreach m,$(pdk_odex_javalibs),$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar) \ + $(foreach m,$(pdk_odex_apps),$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)) + +pdk_odex_config_mk := $(PRODUCT_OUT)/pdk_dexpreopt_config.mk +$(pdk_odex_config_mk): PRIVATE_JAVA_LIBRARIES := $(pdk_odex_javalibs) +$(pdk_odex_config_mk): PRIVATE_APPS := $(pdk_odex_apps) +$(pdk_odex_config_mk) : + @echo "PDK odex config makefile: $@" + $(hide) mkdir -p $(dir $@) + $(hide) echo "# Auto-generated. Do not modify." > $@ + $(hide) echo "PDK.DEXPREOPT.JAVA_LIBRARIES:=$(PRIVATE_JAVA_LIBRARIES)" >> $@ + $(hide) echo "PDK.DEXPREOPT.APPS:=$(PRIVATE_APPS)" >> $@ + $(foreach m,$(PRIVATE_JAVA_LIBRARIES),\ + $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,JAVA_LIBRARIES,$(m),,COMMON)/javalib.jar)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\ + ) + $(foreach m,$(PRIVATE_APPS),\ + $(hide) echo "PDK.DEXPREOPT.$(m).SRC:=$(patsubst $(OUT_DIR)/%,%,$(call intermediates-dir-for,APPS,$(m))/package.dex.apk)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT:=$(DEXPREOPT.$(m).DEX_PREOPT)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).MULTILIB:=$(DEXPREOPT.$(m).MULTILIB)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).DEX_PREOPT_FLAGS:=$(DEXPREOPT.$(m).DEX_PREOPT_FLAGS)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).PRIVILEGED_MODULE:=$(DEXPREOPT.$(m).PRIVILEGED_MODULE)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).PROPRIETARY_MODULE:=$(DEXPREOPT.$(m).PROPRIETARY_MODULE)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).TARGET_ARCH:=$(DEXPREOPT.$(m).TARGET_ARCH)" >> $@$(newline)\ + $(hide) echo "PDK.DEXPREOPT.$(m).STRIPPED_SRC:=$(patsubst $(PRODUCT_OUT)/%,%,$(DEXPREOPT.$(m).INSTALLED_STRIPPED))" >> $@$(newline)\ + ) + +PDK_PLATFORM_ZIP_PRODUCT_BINARIES := $(filter-out $(OUT_DIR)/%,$(PDK_PLATFORM_ZIP_PRODUCT_BINARIES)) +INSTALLED_PLATFORM_ZIP := $(PRODUCT_OUT)/platform.zip + +$(INSTALLED_PLATFORM_ZIP): PRIVATE_DEX_FILES := $(pdk_classes_dex) +$(INSTALLED_PLATFORM_ZIP): PRIVATE_ODEX_CONFIG := $(pdk_odex_config_mk) +$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_SYSTEMIMAGE_FILES) $(pdk_odex_config_mk) + $(call pretty,"Platform zip package: $(INSTALLED_PLATFORM_ZIP)") + $(hide) rm -f $@ + $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \ + $(TARGET_COPY_OUT_SYSTEM) \ + $(patsubst $(PRODUCT_OUT)/%, %, $(TARGET_OUT_NOTICE_FILES)) \ + $(addprefix symbols/,$(PDK_SYMBOL_FILES_LIST)) +ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE + $(hide) cd $(dir $@) && zip -qryX $(notdir $@) \ + $(TARGET_COPY_OUT_VENDOR) +endif +ifneq ($(PDK_PLATFORM_JAVA_ZIP_CONTENTS),) + $(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@) $(PDK_PLATFORM_JAVA_ZIP_CONTENTS) +endif +ifneq ($(PDK_PLATFORM_ZIP_PRODUCT_BINARIES),) + $(hide) zip -qryX $@ $(PDK_PLATFORM_ZIP_PRODUCT_BINARIES) +endif + @# Add dex-preopt files and config. + $(if $(PRIVATE_DEX_FILES),$(hide) cd $(OUT_DIR) && zip -qryX $(patsubst $(OUT_DIR)/%,%,$@ $(PRIVATE_DEX_FILES))) + $(hide) zip -qryXj $@ $(PRIVATE_ODEX_CONFIG) + +.PHONY: platform +platform: $(INSTALLED_PLATFORM_ZIP) + +.PHONY: platform-java +platform-java: platform + +# Dist the platform.zip +ifneq (,$(filter platform platform-java, $(MAKECMDGOALS))) +$(call dist-for-goals, platform platform-java, $(INSTALLED_PLATFORM_ZIP)) +endif + +# ----------------------------------------------------------------- +## boot tarball +define build-boottarball-target + $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)" + $(hide) mkdir -p $(PRODUCT_OUT)/boot + $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/. + $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline + $(hide) $(MKTARBALL) $(FS_GET_STATS) \ + $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \ + $(INSTALLED_BOOTTARBALL_TARGET) $(TARGET_OUT) +endef + +ifndef BOOT_TARBALL_FORMAT + BOOT_TARBALL_FORMAT := bz2 +endif + +boot_tar := $(PRODUCT_OUT)/boot.tar +INSTALLED_BOOTTARBALL_TARGET := $(boot_tar).$(BOOT_TARBALL_FORMAT) +$(INSTALLED_BOOTTARBALL_TARGET): PRIVATE_BOOT_TAR := $(boot_tar) +$(INSTALLED_BOOTTARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_BOOTIMAGE_FILES) + $(build-boottarball-target) + +.PHONY: boottarball-nodeps btnod +boottarball-nodeps btnod: $(FS_GET_STATS) \ + $(filter-out boottarball-nodeps btnod,$(MAKECMDGOALS)) + $(build-boottarball-target) + + +# ----------------------------------------------------------------- +# data partition image +INTERNAL_USERDATAIMAGE_FILES := \ + $(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) + +# Don't build userdata.img if it's extfs but no partition size +skip_userdata.img := +ifdef INTERNAL_USERIMAGES_EXT_VARIANT +ifndef BOARD_USERDATAIMAGE_PARTITION_SIZE +skip_userdata.img := true +endif +endif + +ifneq ($(skip_userdata.img),true) +userdataimage_intermediates := \ + $(call intermediates-dir-for,PACKAGING,userdata) +BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img + +define build-userdataimage-target + $(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)") + @mkdir -p $(TARGET_OUT_DATA) + @mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt + $(call generate-userimage-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt, skip_fsck=true) + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + ./build/tools/releasetools/build_image.py \ + $(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt $(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT) + $(hide) $(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE)) +endef + +# We just build this directly to the install location. +INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET) +$(INSTALLED_USERDATAIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) \ + $(INTERNAL_USERDATAIMAGE_FILES) + $(build-userdataimage-target) + +.PHONY: userdataimage-nodeps +userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) + $(build-userdataimage-target) + +endif # not skip_userdata.img +skip_userdata.img := + +####### +## data partition tarball +define build-userdatatarball-target + $(call pretty,"Target userdata fs tarball: " \ + "$(INSTALLED_USERDATATARBALL_TARGET)") + $(MKTARBALL) $(FS_GET_STATS) \ + $(PRODUCT_OUT) data $(PRIVATE_USERDATA_TAR) \ + $(INSTALLED_USERDATATARBALL_TARGET) $(TARGET_OUT) +endef + +userdata_tar := $(PRODUCT_OUT)/userdata.tar +INSTALLED_USERDATATARBALL_TARGET := $(userdata_tar).bz2 +$(INSTALLED_USERDATATARBALL_TARGET): PRIVATE_USERDATA_TAR := $(userdata_tar) +$(INSTALLED_USERDATATARBALL_TARGET): $(FS_GET_STATS) $(INTERNAL_USERDATAIMAGE_FILES) + $(build-userdatatarball-target) + +$(call dist-for-goals,userdatatarball,$(INSTALLED_USERDATATARBALL_TARGET)) + +.PHONY: userdatatarball-nodeps +userdatatarball-nodeps: $(FS_GET_STATS) + $(build-userdatatarball-target) + + +# ----------------------------------------------------------------- +# cache partition image +ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE +INTERNAL_CACHEIMAGE_FILES := \ + $(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES)) + +cacheimage_intermediates := \ + $(call intermediates-dir-for,PACKAGING,cache) +BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img + +define build-cacheimage-target + $(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)") + @mkdir -p $(TARGET_OUT_CACHE) + @mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt + $(call generate-userimage-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt, skip_fsck=true) + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + ./build/tools/releasetools/build_image.py \ + $(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt $(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT) + $(hide) $(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE)) +endef + +# We just build this directly to the install location. +INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET) +$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) + $(build-cacheimage-target) + +.PHONY: cacheimage-nodeps +cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) + $(build-cacheimage-target) + +else # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE +# we need to ignore the broken cache link when doing the rsync +IGNORE_CACHE_LINK := --exclude=cache +endif # BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE + + +# ----------------------------------------------------------------- +# system_other partition image +ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true) +BOARD_USES_SYSTEM_OTHER := true + +# Marker file to identify that odex files are installed +INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker +ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER) +$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER): + $(hide) touch $@ +endif + +ifdef BOARD_USES_SYSTEM_OTHER +INTERNAL_SYSTEMOTHERIMAGE_FILES := \ + $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\ + $(ALL_DEFAULT_INSTALLED_MODULES)\ + $(ALL_PDK_FUSION_FILES)) + +INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt +$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) + @echo Installed file list: $@ + @mkdir -p $(dir $@) + @rm -f $@ + $(hide) build/tools/fileslist.py $(TARGET_OUT_SYSTEM_OTHER) > $@ + +systemotherimage_intermediates := \ + $(call intermediates-dir-for,PACKAGING,system_other) +BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img + +# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image. +define build-systemotherimage-target + $(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)") + @mkdir -p $(TARGET_OUT_SYSTEM_OTHER) + @mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt + $(call generate-userimage-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt, skip_fsck=true) + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + ./build/tools/releasetools/build_image.py \ + $(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT) + $(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE)) +endef + +# We just build this directly to the install location. +INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET) +$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER) + $(build-systemotherimage-target) + +.PHONY: systemotherimage-nodeps +systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) + $(build-systemotherimage-target) + +endif # BOARD_USES_SYSTEM_OTHER + + +# ----------------------------------------------------------------- +# vendor partition image +ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE +INTERNAL_VENDORIMAGE_FILES := \ + $(filter $(TARGET_OUT_VENDOR)/%,\ + $(ALL_DEFAULT_INSTALLED_MODULES)\ + $(ALL_PDK_FUSION_FILES)) + +# platform.zip depends on $(INTERNAL_VENDORIMAGE_FILES). +$(INSTALLED_PLATFORM_ZIP) : $(INTERNAL_VENDORIMAGE_FILES) + +INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt +$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) + @echo Installed file list: $@ + @mkdir -p $(dir $@) + @rm -f $@ + $(hide) build/tools/fileslist.py $(TARGET_OUT_VENDOR) > $@ + +vendorimage_intermediates := \ + $(call intermediates-dir-for,PACKAGING,vendor) +BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img + +define build-vendorimage-target + $(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)") + @mkdir -p $(TARGET_OUT_VENDOR) + @mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt + $(call generate-userimage-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt, skip_fsck=true) + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \ + ./build/tools/releasetools/build_image.py \ + $(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt $(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT) + $(hide) $(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_VENDORIMAGE_PARTITION_SIZE)) +endef + +# We just build this directly to the install location. +INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET) +$(INSTALLED_VENDORIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR) + $(build-vendorimage-target) + +.PHONY: vendorimage-nodeps +vendorimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) + $(build-vendorimage-target) + +else ifdef BOARD_PREBUILT_VENDORIMAGE +INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img +$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET))) +endif + +# ----------------------------------------------------------------- +# bring in the installer image generation defines if necessary +ifeq ($(TARGET_USE_DISKINSTALLER),true) +include bootable/diskinstaller/config.mk +endif + +# ----------------------------------------------------------------- +# host tools needed to build dist and OTA packages + +build_ota_package := true +ifeq ($(TARGET_SKIP_OTA_PACKAGE),true) +build_ota_package := false +endif +ifeq ($(BUILD_OS),darwin) +build_ota_package := false +endif +ifneq ($(strip $(SANITIZE_TARGET)),) +build_ota_package := false +endif +ifeq ($(TARGET_PRODUCT),sdk) +build_ota_package := false +endif +ifneq ($(filter generic%,$(TARGET_DEVICE)),) +build_ota_package := false +endif +ifeq ($(TARGET_NO_KERNEL),true) +build_ota_package := false +endif +ifeq ($(recovery_fstab),) +build_ota_package := false +endif +ifeq ($(TARGET_BUILD_PDK),true) +build_ota_package := false +endif + +ifeq ($(build_ota_package),true) +OTATOOLS := $(HOST_OUT_EXECUTABLES)/minigzip \ + $(HOST_OUT_EXECUTABLES)/aapt \ + $(HOST_OUT_EXECUTABLES)/mkbootfs \ + $(HOST_OUT_EXECUTABLES)/mkbootimg \ + $(HOST_OUT_EXECUTABLES)/fs_config \ + $(HOST_OUT_EXECUTABLES)/zipalign \ + $(HOST_OUT_EXECUTABLES)/bsdiff \ + $(HOST_OUT_EXECUTABLES)/imgdiff \ + $(HOST_OUT_JAVA_LIBRARIES)/dumpkey.jar \ + $(HOST_OUT_JAVA_LIBRARIES)/signapk.jar \ + $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar \ + $(HOST_OUT_EXECUTABLES)/mkuserimg.sh \ + $(HOST_OUT_EXECUTABLES)/make_ext4fs \ + $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh \ + $(HOST_OUT_EXECUTABLES)/mksquashfs \ + $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh \ + $(HOST_OUT_EXECUTABLES)/make_f2fs \ + $(HOST_OUT_EXECUTABLES)/simg2img \ + $(HOST_OUT_EXECUTABLES)/e2fsck \ + $(HOST_OUT_EXECUTABLES)/build_verity_tree \ + $(HOST_OUT_EXECUTABLES)/verity_signer \ + $(HOST_OUT_EXECUTABLES)/append2simg \ + $(HOST_OUT_EXECUTABLES)/img2simg \ + $(HOST_OUT_EXECUTABLES)/boot_signer \ + $(HOST_OUT_EXECUTABLES)/fec \ + $(HOST_OUT_EXECUTABLES)/brillo_update_payload \ + $(HOST_OUT_EXECUTABLES)/lib/shflags/shflags \ + $(HOST_OUT_EXECUTABLES)/delta_generator \ + $(BLK_ALLOC_TO_BASE_FS) + +# Shared libraries. +OTATOOLS += \ + $(HOST_LIBRARY_PATH)/libc++$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/liblog$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libcutils$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libselinux$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libcrypto-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libdivsufsort$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libdivsufsort64$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libext2fs-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libext2_blkid-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libext2_com_err-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libext2_e2p-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libext2_profile-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libext2_quota-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libext2_uuid-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libconscrypt_openjdk_jni$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libbrillo$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libbrillo-stream$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libbrillo-http$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libchrome$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libcurl-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libevent-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libprotobuf-cpp-lite$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libssl-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libz-host$(HOST_SHLIB_SUFFIX) \ + $(HOST_LIBRARY_PATH)/libbase$(HOST_SHLIB_SUFFIX) + +.PHONY: otatools +otatools: $(OTATOOLS) + +BUILT_OTATOOLS_PACKAGE := $(PRODUCT_OUT)/otatools.zip +$(BUILT_OTATOOLS_PACKAGE): zip_root := $(call intermediates-dir-for,PACKAGING,otatools)/otatools + +$(BUILT_OTATOOLS_PACKAGE): $(OTATOOLS) | $(ACP) + @echo "Package OTA tools: $@" + $(hide) rm -rf $@ $(zip_root) + $(hide) mkdir -p $(dir $@) $(zip_root)/bin $(zip_root)/framework $(zip_root)/releasetools $(zip_root)/system/extras/verity + $(call copy-files-with-structure,$(OTATOOLS),$(HOST_OUT)/,$(zip_root)) + $(hide) $(ACP) $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar $(zip_root)/framework/ + $(hide) $(ACP) -p system/extras/verity/build_verity_metadata.py $(zip_root)/system/extras/verity/ + $(hide) $(ACP) -r -d -p build/tools/releasetools/* $(zip_root)/releasetools + $(hide) rm -rf $@ $(zip_root)/releasetools/*.pyc + $(hide) (cd $(zip_root) && zip -qryX $(abspath $@) *) + $(hide) zip -qryX $(abspath $@) build/target/product/security/ + $(hide) find device vendor -name \*.pk8 -o -name verifiedboot\* -o -name \*.x509.pem -o -name oem\*.prop | xargs zip -qryX $(abspath $@)>/dev/null || true + +.PHONY: otatools-package +otatools-package: $(BUILT_OTATOOLS_PACKAGE) + +endif # build_ota_package + +# ----------------------------------------------------------------- +# A zip of the directories that map to the target filesystem. +# This zip can be used to create an OTA package or filesystem image +# as a post-build step. +# +name := $(TARGET_PRODUCT) +ifeq ($(TARGET_BUILD_TYPE),debug) + name := $(name)_debug +endif +name := $(name)-target_files-$(FILE_NAME_TAG) + +intermediates := $(call intermediates-dir-for,PACKAGING,target_files) +BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip +$(BUILT_TARGET_FILES_PACKAGE): intermediates := $(intermediates) +$(BUILT_TARGET_FILES_PACKAGE): \ + zip_root := $(intermediates)/$(name) + +# $(1): Directory to copy +# $(2): Location to copy it to +# The "ls -A" is to prevent "acp s/* d" from failing if s is empty. +define package_files-copy-root + if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \ + mkdir -p $(2) && \ + $(ACP) -rd $(strip $(1))/* $(2); \ + fi +endef + +built_ota_tools := + +# We can't build static executables when SANITIZE_TARGET=address +ifeq ($(strip $(SANITIZE_TARGET)),) +built_ota_tools += \ + $(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater +endif + +$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_OTA_TOOLS := $(built_ota_tools) + +$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_API_VERSION := $(RECOVERY_API_VERSION) +$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_FSTAB_VERSION := $(RECOVERY_FSTAB_VERSION) + +ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),) +# default to common dir for device vendor +$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_DEVICE_DIR)/../common +else +$(BUILT_TARGET_FILES_PACKAGE): tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS) +endif + +# Build OTA tools if not using the AB Updater. +ifneq ($(AB_OTA_UPDATER),true) +$(BUILT_TARGET_FILES_PACKAGE): $(built_ota_tools) +endif + +# If we are using recovery as boot, output recovery files to BOOT/. +ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true) +$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := BOOT +else +$(BUILT_TARGET_FILES_PACKAGE): PRIVATE_RECOVERY_OUT := RECOVERY +endif + +# Depending on the various images guarantees that the underlying +# directories are up-to-date. +$(BUILT_TARGET_FILES_PACKAGE): \ + $(INSTALLED_BOOTIMAGE_TARGET) \ + $(INSTALLED_RADIOIMAGE_TARGET) \ + $(INSTALLED_RECOVERYIMAGE_TARGET) \ + $(INSTALLED_SYSTEMIMAGE) \ + $(INSTALLED_USERDATAIMAGE_TARGET) \ + $(INSTALLED_CACHEIMAGE_TARGET) \ + $(INSTALLED_VENDORIMAGE_TARGET) \ + $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) \ + $(INSTALLED_ANDROID_INFO_TXT_TARGET) \ + $(SELINUX_FC) \ + $(APKCERTS_FILE) \ + $(HOST_OUT_EXECUTABLES)/fs_config \ + | $(ACP) + @echo "Package target files: $@" + $(hide) rm -rf $@ $(zip_root) + $(hide) mkdir -p $(dir $@) $(zip_root) +ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))) + @# Components of the recovery image + $(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT) + $(hide) $(call package_files-copy-root, \ + $(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK) +ifdef INSTALLED_KERNEL_TARGET + $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel +endif +ifdef INSTALLED_2NDBOOTLOADER_TARGET + $(hide) $(ACP) \ + $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second +endif +ifdef BOARD_KERNEL_CMDLINE + $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline +endif +ifdef BOARD_KERNEL_BASE + $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base +endif +ifdef BOARD_KERNEL_PAGESIZE + $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize +endif +endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true + @# Components of the boot image + $(hide) mkdir -p $(zip_root)/BOOT +ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) + $(hide) mkdir -p $(zip_root)/ROOT + $(hide) $(call package_files-copy-root, \ + $(TARGET_ROOT_OUT),$(zip_root)/ROOT) +else + $(hide) $(call package_files-copy-root, \ + $(TARGET_ROOT_OUT),$(zip_root)/BOOT/RAMDISK) +endif + @# If we are using recovery as boot, this is already done when processing recovery. +ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true) +ifdef INSTALLED_KERNEL_TARGET + $(hide) $(ACP) $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/kernel +endif +ifdef INSTALLED_2NDBOOTLOADER_TARGET + $(hide) $(ACP) \ + $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second +endif +ifdef BOARD_KERNEL_CMDLINE + $(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline +endif +ifdef BOARD_KERNEL_BASE + $(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base +endif +ifdef BOARD_KERNEL_PAGESIZE + $(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize +endif +endif # BOARD_USES_RECOVERY_AS_BOOT + $(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\ + mkdir -p $(zip_root)/RADIO; \ + $(ACP) $(t) $(zip_root)/RADIO/$(notdir $(t));) + @# Contents of the system image + $(hide) $(call package_files-copy-root, \ + $(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM) + @# Contents of the data image + $(hide) $(call package_files-copy-root, \ + $(TARGET_OUT_DATA),$(zip_root)/DATA) +ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE + @# Contents of the vendor image + $(hide) $(call package_files-copy-root, \ + $(TARGET_OUT_VENDOR),$(zip_root)/VENDOR) +endif +ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET + @# Contents of the system_other image + $(hide) $(call package_files-copy-root, \ + $(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER) +endif + @# Extra contents of the OTA package + $(hide) mkdir -p $(zip_root)/OTA + $(hide) $(ACP) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/ +ifneq ($(AB_OTA_UPDATER),true) +ifneq ($(built_ota_tools),) + $(hide) mkdir -p $(zip_root)/OTA/bin + $(hide) $(ACP) $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/ +endif +endif + @# Files that do not end up in any images, but are necessary to + @# build them. + $(hide) mkdir -p $(zip_root)/META + $(hide) $(ACP) $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt + $(hide) if test -e $(tool_extensions)/releasetools.py; then $(ACP) $(tool_extensions)/releasetools.py $(zip_root)/META/; fi + $(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt + $(hide) $(ACP) $(SELINUX_FC) $(zip_root)/META/file_contexts.bin + $(hide) echo "recovery_api_version=$(PRIVATE_RECOVERY_API_VERSION)" > $(zip_root)/META/misc_info.txt + $(hide) echo "fstab_version=$(PRIVATE_RECOVERY_FSTAB_VERSION)" >> $(zip_root)/META/misc_info.txt +ifdef BOARD_FLASH_BLOCK_SIZE + $(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $(zip_root)/META/misc_info.txt +endif +ifdef BOARD_BOOTIMAGE_PARTITION_SIZE + $(hide) echo "boot_size=$(BOARD_BOOTIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt +endif +ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),) + $(hide) echo "recovery_as_boot=$(BOARD_USES_RECOVERY_AS_BOOT)" >> $(zip_root)/META/misc_info.txt +endif +ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),) + $(hide) echo "no_recovery=true" >> $(zip_root)/META/misc_info.txt +endif +ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE + $(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $(zip_root)/META/misc_info.txt +endif +ifdef BOARD_HAS_EXT4_RESERVED_BLOCKS + $(hide) echo "has_ext4_reserved_blocks=$(BOARD_HAS_EXT4_RESERVED_BLOCKS)" >> $(zip_root)/META/misc_info.txt +endif +ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS + @# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used. + $(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt +else + $(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $(zip_root)/META/misc_info.txt +endif + $(hide) echo "tool_extensions=$(tool_extensions)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $(zip_root)/META/misc_info.txt +ifdef PRODUCT_EXTRA_RECOVERY_KEYS + $(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $(zip_root)/META/misc_info.txt +endif + $(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $(zip_root)/META/misc_info.txt + $(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $(zip_root)/META/misc_info.txt + $(hide) echo "use_set_metadata=1" >> $(zip_root)/META/misc_info.txt + $(hide) echo "multistage_support=1" >> $(zip_root)/META/misc_info.txt + $(hide) echo "update_rename_support=1" >> $(zip_root)/META/misc_info.txt + $(hide) echo "blockimgdiff_versions=1,2,3,4" >> $(zip_root)/META/misc_info.txt +ifneq ($(OEM_THUMBPRINT_PROPERTIES),) + # OTA scripts are only interested in fingerprint related properties + $(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $(zip_root)/META/misc_info.txt +endif +ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH),) + $(hide) $(ACP) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH) \ + $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_BASE_FS_PATH)) +endif +ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH),) + $(hide) $(ACP) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH) \ + $(zip_root)/META/$(notdir $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_BASE_FS_PATH)) +endif +ifneq ($(strip $(SANITIZE_TARGET)),) + # We need to create userdata.img with real data because the instrumented libraries are in userdata.img. + $(hide) echo "userdata_img_with_data=true" >> $(zip_root)/META/misc_info.txt +endif +ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true) + $(hide) echo "full_recovery_image=true" >> $(zip_root)/META/misc_info.txt +endif + $(call generate-userimage-prop-dictionary, $(zip_root)/META/misc_info.txt) +ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),) + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ + ./build/tools/releasetools/make_recovery_patch $(zip_root) $(zip_root) +endif +ifeq ($(AB_OTA_UPDATER),true) + @# When using the A/B updater, include the updater config files in the zip. + $(hide) $(ACP) $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt + $(hide) for part in $(AB_OTA_PARTITIONS); do \ + echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \ + done + $(hide) for conf in $(AB_OTA_POSTINSTALL_CONFIG); do \ + echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \ + done + @# Include the build type in META/misc_info.txt so the server can easily differentiate production builds. + $(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $(zip_root)/META/misc_info.txt + $(hide) echo "ab_update=true" >> $(zip_root)/META/misc_info.txt +ifdef OSRELEASED_DIRECTORY + $(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt + $(hide) $(ACP) $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt +endif +endif +ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true) + @# If breakpad symbols have been generated, add them to the zip. + $(hide) $(ACP) -r $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD +endif +ifdef BOARD_PREBUILT_VENDORIMAGE + $(hide) mkdir -p $(zip_root)/IMAGES + $(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/ +endif + @# Zip everything up, preserving symlinks and placing META/ files first to + @# help early validation of the .zip file while uploading it. + $(hide) (cd $(zip_root) && \ + zip -qryX ../$(notdir $@) ./META && \ + zip -qryXu ../$(notdir $@) .) + @# Run fs_config on all the system, vendor, boot ramdisk, + @# and recovery ramdisk files in the zip, and save the output + $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM/" } /^SYSTEM\// {print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/filesystem_config.txt + $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="VENDOR/" } /^VENDOR\// {print "vendor/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/vendor_filesystem_config.txt +ifeq ($(BOARD_BUILD_SYSTEM_ROOT_IMAGE),true) + $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="ROOT/" } /^ROOT\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/root_filesystem_config.txt +endif + $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="BOOT/RAMDISK/" } /^BOOT\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/boot_filesystem_config.txt +ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),) + $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="RECOVERY/RAMDISK/" } /^RECOVERY\/RAMDISK\// {print $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/recovery_filesystem_config.txt +endif +ifdef INSTALLED_SYSTEMOTHERIMAGE_TARGET + $(hide) zipinfo -1 $@ | awk 'BEGIN { FS="SYSTEM_OTHER/" } /^SYSTEM_OTHER\// { print "system/" $$2}' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -S $(SELINUX_FC) > $(zip_root)/META/system_other_filesystem_config.txt +endif + $(hide) (cd $(zip_root) && zip -qX ../$(notdir $@) META/*filesystem_config.txt) + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ + ./build/tools/releasetools/add_img_to_target_files -a -v -p $(HOST_OUT) $@ + +.PHONY: target-files-package +target-files-package: $(BUILT_TARGET_FILES_PACKAGE) + +ifneq ($(filter $(MAKECMDGOALS),target-files-package),) +$(call dist-for-goals, target-files-package, $(BUILT_TARGET_FILES_PACKAGE)) +endif + +ifeq ($(build_ota_package),true) +# ----------------------------------------------------------------- +# OTA update package + +name := $(TARGET_PRODUCT) +ifeq ($(TARGET_BUILD_TYPE),debug) + name := $(name)_debug +endif +name := $(name)-ota-$(FILE_NAME_TAG) + +INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip + +$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR) + +$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) + @echo "Package OTA: $@" + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ + ./build/tools/releasetools/ota_from_target_files -v \ + --block \ + -p $(HOST_OUT) \ + -k $(KEY_CERT_PAIR) \ + $(if $(OEM_OTA_CONFIG), -o $(OEM_OTA_CONFIG)) \ + $(BUILT_TARGET_FILES_PACKAGE) $@ + +.PHONY: otapackage +otapackage: $(INTERNAL_OTA_PACKAGE_TARGET) + +endif # build_ota_package + +# ----------------------------------------------------------------- +# The update package + +name := $(TARGET_PRODUCT) +ifeq ($(TARGET_BUILD_TYPE),debug) + name := $(name)_debug +endif +name := $(name)-img-$(FILE_NAME_TAG) + +INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip + +$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) + @echo "Package: $@" + $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH MKBOOTIMG=$(MKBOOTIMG) \ + ./build/tools/releasetools/img_from_target_files -v \ + -p $(HOST_OUT) \ + $(BUILT_TARGET_FILES_PACKAGE) $@ + +.PHONY: updatepackage +updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET) + +# ----------------------------------------------------------------- +# A zip of the symbols directory. Keep the full paths to make it +# more obvious where these files came from. +# +name := $(TARGET_PRODUCT) +ifeq ($(TARGET_BUILD_TYPE),debug) + name := $(name)_debug +endif +name := $(name)-symbols-$(FILE_NAME_TAG) + +SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name).zip +# For apps_only build we'll establish the dependency later in build/core/main.mk. +ifndef TARGET_BUILD_APPS +$(SYMBOLS_ZIP): $(INSTALLED_SYSTEMIMAGE) $(INSTALLED_BOOTIMAGE_TARGET) +endif +$(SYMBOLS_ZIP): + @echo "Package symbols: $@" + $(hide) rm -rf $@ + $(hide) mkdir -p $(dir $@) $(TARGET_OUT_UNSTRIPPED) + $(hide) zip -qrX $@ $(TARGET_OUT_UNSTRIPPED) + +# ----------------------------------------------------------------- +# A zip of the Android Apps. Not keeping full path so that we don't +# include product names when distributing +# +name := $(TARGET_PRODUCT) +ifeq ($(TARGET_BUILD_TYPE),debug) + name := $(name)_debug +endif +name := $(name)-apps-$(FILE_NAME_TAG) + +APPS_ZIP := $(PRODUCT_OUT)/$(name).zip +$(APPS_ZIP): $(INSTALLED_SYSTEMIMAGE) + @echo "Package apps: $@" + $(hide) rm -rf $@ + $(hide) mkdir -p $(dir $@) + $(hide) apps_to_zip=`find $(TARGET_OUT_APPS) $(TARGET_OUT_APPS_PRIVILEGED) -mindepth 2 -maxdepth 3 -name "*.apk"`; \ + if [ -z "$$apps_to_zip" ]; then \ + echo "No apps to zip up. Generating empty apps archive." ; \ + a=$$(mktemp /tmp/XXXXXXX) && touch $$a && zip $@ $$a && zip -d $@ $$a; \ + else \ + zip -qjX $@ $$apps_to_zip; \ + fi + +#------------------------------------------------------------------ +# A zip of emma code coverage meta files. Generated for fully emma +# instrumented build. +# +ifeq (true,$(EMMA_INSTRUMENT)) +EMMA_META_ZIP := $(PRODUCT_OUT)/emma_meta.zip +# the dependency will be set up later in build/core/main.mk. +$(EMMA_META_ZIP) : + @echo "Collecting Emma coverage meta files." + $(hide) find $(TARGET_COMMON_OUT_ROOT) $(HOST_COMMON_OUT_ROOT) -name "coverage.em" | \ + zip -@ -qX $@ + +endif # EMMA_INSTRUMENT=true + +#------------------------------------------------------------------ +# A zip of Proguard obfuscation dictionary files. +# Only for apps_only build. +# +ifdef TARGET_BUILD_APPS +PROGUARD_DICT_ZIP := $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-$(FILE_NAME_TAG).zip +# the dependency will be set up later in build/core/main.mk. +$(PROGUARD_DICT_ZIP) : + @echo "Packaging Proguard obfuscation dictionary files." + $(hide) dict_files=`find $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS -name proguard_dictionary -o -name jack_dictionary`; \ + if [ -n "$$dict_files" ]; then \ + unobfuscated_jars=$${dict_files//proguard_dictionary/classes.jar}; \ + zip -qX $@ $$dict_files $$unobfuscated_jars; \ + else \ + touch $(dir $@)/zipdummy; \ + (cd $(dir $@) && zip -q $(notdir $@) zipdummy); \ + zip -qd $@ zipdummy; \ + rm $(dir $@)/zipdummy; \ + fi + +endif # TARGET_BUILD_APPS + +# ----------------------------------------------------------------- +# dalvik something +.PHONY: dalvikfiles +dalvikfiles: $(INTERNAL_DALVIK_MODULES) + +# ----------------------------------------------------------------- +# The emulator package +ifeq ($(BUILD_EMULATOR),true) +INTERNAL_EMULATOR_PACKAGE_FILES += \ + $(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \ + prebuilts/qemu-kernel/$(TARGET_ARCH)/kernel-qemu \ + $(INSTALLED_RAMDISK_TARGET) \ + $(INSTALLED_SYSTEMIMAGE) \ + $(INSTALLED_USERDATAIMAGE_TARGET) + +name := $(TARGET_PRODUCT)-emulator-$(FILE_NAME_TAG) + +INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip + +$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES) + @echo "Package: $@" + $(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES) + +endif +# ----------------------------------------------------------------- +# Old PDK stuffs, retired +# The pdk package (Platform Development Kit) + +#ifneq (,$(filter pdk,$(MAKECMDGOALS))) +# include development/pdk/Pdk.mk +#endif + + +# ----------------------------------------------------------------- +# The SDK + +# The SDK includes host-specific components, so it belongs under HOST_OUT. +sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT) + +# Build a name that looks like: +# +# linux-x86 --> android-sdk_12345_linux-x86 +# darwin-x86 --> android-sdk_12345_mac-x86 +# windows-x86 --> android-sdk_12345_windows +# +sdk_name := android-sdk_$(FILE_NAME_TAG) +ifeq ($(HOST_OS),darwin) + INTERNAL_SDK_HOST_OS_NAME := mac +else + INTERNAL_SDK_HOST_OS_NAME := $(HOST_OS) +endif +ifneq ($(HOST_OS),windows) + INTERNAL_SDK_HOST_OS_NAME := $(INTERNAL_SDK_HOST_OS_NAME)-$(SDK_HOST_ARCH) +endif +sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME) + +sdk_dep_file := $(sdk_dir)/sdk_deps.mk + +ATREE_FILES := +-include $(sdk_dep_file) + +# if we don't have a real list, then use "everything" +ifeq ($(strip $(ATREE_FILES)),) +ATREE_FILES := \ + $(ALL_PREBUILT) \ + $(ALL_DEFAULT_INSTALLED_MODULES) \ + $(INSTALLED_RAMDISK_TARGET) \ + $(ALL_DOCS) \ + $(ALL_SDK_FILES) +endif + +atree_dir := development/build + + +sdk_atree_files := \ + $(atree_dir)/sdk.exclude.atree \ + $(atree_dir)/sdk-$(HOST_OS)-$(SDK_HOST_ARCH).atree + +# development/build/sdk-android-.atree is used to differentiate +# between architecture models (e.g. ARMv5TE versus ARMv7) when copying +# files like the kernel image. We use TARGET_CPU_ABI because we don't +# have a better way to distinguish between CPU models. +ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree))) + sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree +endif + +ifneq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES),) +sdk_atree_files += $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ATREE_FILES) +else +sdk_atree_files += $(atree_dir)/sdk.atree +endif + +include $(BUILD_SYSTEM)/sdk_font.mk + +deps := \ + $(target_notice_file_txt) \ + $(tools_notice_file_txt) \ + $(OUT_DOCS)/offline-sdk-timestamp \ + $(SYMBOLS_ZIP) \ + $(INSTALLED_SYSTEMIMAGE) \ + $(INSTALLED_USERDATAIMAGE_TARGET) \ + $(INSTALLED_RAMDISK_TARGET) \ + $(INSTALLED_SDK_BUILD_PROP_TARGET) \ + $(INSTALLED_BUILD_PROP_TARGET) \ + $(ATREE_FILES) \ + $(sdk_atree_files) \ + $(HOST_OUT_EXECUTABLES)/atree \ + $(HOST_OUT_EXECUTABLES)/line_endings \ + $(SDK_FONT_DEPS) + +INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip +$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name) +$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name) +$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file) +$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files) + +# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built. +# +#SDK_GNU_ERROR := true + +$(INTERNAL_SDK_TARGET): $(deps) + @echo "Package SDK: $@" + $(hide) rm -rf $(PRIVATE_DIR) $@ + $(hide) for f in $(target_gnu_MODULES); do \ + if [ -f $$f ]; then \ + echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \ + including GNU target $$f >&2; \ + FAIL=$(SDK_GNU_ERROR); \ + fi; \ + done; \ + if [ $$FAIL ]; then exit 1; fi + $(hide) echo $(notdir $(SDK_FONT_DEPS)) | tr " " "\n" > $(SDK_FONT_TEMP)/fontsInSdk.txt + $(hide) ( \ + ATREE_STRIP="strip -x" \ + $(HOST_OUT_EXECUTABLES)/atree \ + $(addprefix -f ,$(PRIVATE_INPUT_FILES)) \ + -m $(PRIVATE_DEP_FILE) \ + -I . \ + -I $(PRODUCT_OUT) \ + -I $(HOST_OUT) \ + -I $(TARGET_COMMON_OUT_ROOT) \ + -v "PLATFORM_NAME=android-$(PLATFORM_VERSION)" \ + -v "OUT_DIR=$(OUT_DIR)" \ + -v "HOST_OUT=$(HOST_OUT)" \ + -v "TARGET_ARCH=$(TARGET_ARCH)" \ + -v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \ + -v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \ + -v "FONT_OUT=$(SDK_FONT_TEMP)" \ + -v "JACK_SDKTOOL_VERSION=$(JACK_SDKTOOL_VERSION)" \ + -o $(PRIVATE_DIR) && \ + cp -f $(target_notice_file_txt) \ + $(PRIVATE_DIR)/system-images/android-$(PLATFORM_VERSION)/$(TARGET_CPU_ABI)/NOTICE.txt && \ + cp -f $(tools_notice_file_txt) $(PRIVATE_DIR)/platform-tools/NOTICE.txt && \ + HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \ + development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \ + chmod -R ug+rwX $(PRIVATE_DIR) && \ + cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \ + ) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 ) + + +# Is a Windows SDK requested? If so, we need some definitions from here +# in order to find the Linux SDK used to create the Windows one. +MAIN_SDK_NAME := $(sdk_name) +MAIN_SDK_DIR := $(sdk_dir) +MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET) +ifneq ($(filter win_sdk winsdk-tools,$(MAKECMDGOALS)),) +include $(TOPDIR)development/build/tools/windows_sdk.mk +endif + +# ----------------------------------------------------------------- +# Findbugs +INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml +INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html +$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES) + @echo UnionBugs: $@ + $(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \ + > $@ +$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET) + @echo ConvertXmlToText: $@ + $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \ + $(INTERNAL_FINDBUGS_XML_TARGET) > $@ + +# ----------------------------------------------------------------- +# Findbugs + +# ----------------------------------------------------------------- +# These are some additional build tasks that need to be run. +ifneq ($(dont_bother),true) +include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk)) +-include $(sort $(wildcard vendor/*/build/tasks/*.mk)) +-include $(sort $(wildcard device/*/build/tasks/*.mk)) +-include $(sort $(wildcard product/*/build/tasks/*.mk)) +# Also the project-specific tasks +-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk)) +-include $(sort $(wildcard device/*/*/build/tasks/*.mk)) +-include $(sort $(wildcard product/*/*/build/tasks/*.mk)) +endif + +include $(BUILD_SYSTEM)/product-graph.mk + +# ----------------------------------------------------------------- +# Create SDK repository packages. Must be done after tasks/* since +# we need the addon rules defined. +ifneq ($(sdk_repo_goal),) +include $(TOPDIR)development/build/tools/sdk_repo.mk +endif diff --git a/core/aapt2.mk b/core/aapt2.mk new file mode 100644 index 0000000000000000000000000000000000000000..ccc45357632a19ebdab028f40238635667c1b7a1 --- /dev/null +++ b/core/aapt2.mk @@ -0,0 +1,89 @@ +###################################### +# Compile resource with AAPT2 +# Input variables: +# full_android_manifest, +# my_res_resources, my_overlay_resources, +# my_compiled_res_base_dir, my_res_package, +# R_file_stamp, proguard_options_file +# my_generated_res_dirs: Resources generated during the build process and we have to compile them in a single run of aapt2. +# my_generated_res_dirs_deps: the dependency to use for my_generated_res_dirs. +# +# Output variables: +# my_res_resources_flat, my_overlay_resources_flat, +# my_generated_resources_flata +# +###################################### + + +# Compile all the resource files. +my_res_resources_flat := \ + $(foreach r, $(my_res_resources),\ + $(eval o := $(call aapt2-compiled-resource-out-file,$(r),$(my_compiled_res_base_dir)))\ + $(eval $(call aapt2-compile-one-resource-file-rule,$(r),$(o)))\ + $(o)) + +my_overlay_resources_flat := \ + $(foreach r, $(my_overlay_resources),\ + $(eval o := $(call aapt2-compiled-resource-out-file,$(r),$(my_compiled_res_base_dir)))\ + $(eval $(call aapt2-compile-one-resource-file-rule,$(r),$(o)))\ + $(o)) + +my_generated_resources_flata := +# Compile generated resources +ifneq ($(my_generated_res_dirs),) +my_generated_resources_flata := $(my_compiled_res_base_dir)/gen_res.flata +$(my_generated_resources_flata): PRIVATE_SOURCE_RES_DIRS := $(my_generated_res_dirs) +$(my_generated_resources_flata) : $(my_generated_res_dirs_deps) + @echo "AAPT2 compile $@ <- $(PRIVATE_SOURCE_RES_DIRS)" + $(call aapt2-compile-resource-dirs) + +my_generated_resources_flata += $(my_generated_resources_flata) +endif + +$(my_res_resources_flat) $(my_overlay_resources_flat) $(my_generated_resources_flata): \ + PRIVATE_AAPT2_CFLAGS := $(PRODUCT_AAPT2_CFLAGS) + +my_static_library_resources := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES)),\ + $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk) +my_shared_library_resources := $(foreach l, $(LOCAL_SHARED_ANDROID_LIBRARIES),\ + $(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk) + +ifneq ($(my_static_library_resources),) +$(my_res_package): PRIVATE_AAPT_FLAGS += --auto-add-overlay +endif + +$(my_res_package): PRIVATE_RES_FLAT := $(my_res_resources_flat) +$(my_res_package): PRIVATE_OVERLAY_FLAT := $(my_static_library_resources) $(my_generated_resources_flata) $(my_overlay_resources_flat) +$(my_res_package): PRIVATE_SHARED_ANDROID_LIBRARIES := $(my_shared_library_resources) +$(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file) +$(my_res_package) : $(full_android_manifest) $(my_static_library_resources) $(my_shared_library_resources) +$(my_res_package) : $(my_res_resources_flat) $(my_overlay_resources_flat) \ + $(my_generated_resources_flata) $(my_static_library_resources) \ + $(AAPT2) + @echo "AAPT2 link $@" + $(call aapt2-link) + +ifdef R_file_stamp +$(R_file_stamp) : $(my_res_package) | $(ACP) + @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)" + @rm -rf $@ && mkdir -p $(dir $@) + $(call find-generated-R.java) +endif + +ifdef proguard_options_file +$(proguard_options_file) : $(my_res_package) +endif + +resource_export_package := +ifdef LOCAL_EXPORT_PACKAGE_RESOURCES +# Put this module's resources into a PRODUCT-agnositc package that +# other packages can use to build their own PRODUCT-agnostic R.java (etc.) +# files. +resource_export_package := $(intermediates.COMMON)/package-export.apk +$(R_file_stamp) : $(resource_export_package) + +$(resource_export_package) : $(my_res_package) | $(ACP) + @echo "target Export Resources: $(PRIVATE_MODULE) $(@)" + $(copy-file-to-new-target) + +endif diff --git a/core/android_manifest.mk b/core/android_manifest.mk new file mode 100644 index 0000000000000000000000000000000000000000..0093e02087f88c4f400a2da0009cd72b2b6321d7 --- /dev/null +++ b/core/android_manifest.mk @@ -0,0 +1,43 @@ +# Handle AndroidManifest.xmls +# Input: LOCAL_MANIFEST_FILE, LOCAL_FULL_MANIFEST_FILE, LOCAL_FULL_LIBS_MANIFEST_FILES +# Output: full_android_manifest + +ifeq ($(strip $(LOCAL_MANIFEST_FILE)),) + LOCAL_MANIFEST_FILE := AndroidManifest.xml +endif +ifdef LOCAL_FULL_MANIFEST_FILE + full_android_manifest := $(LOCAL_FULL_MANIFEST_FILE) +else + full_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE) +endif + +my_full_libs_manifest_files := $(LOCAL_FULL_LIBS_MANIFEST_FILES) +my_full_libs_manifest_deps := $(LOCAL_FULL_LIBS_MANIFEST_FILES) + +# Set up dependency on aar libraries +LOCAL_STATIC_JAVA_AAR_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)) +ifdef LOCAL_STATIC_JAVA_AAR_LIBRARIES +my_full_libs_manifest_deps += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ + $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/classes.jar) +my_full_libs_manifest_files += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ + $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/AndroidManifest.xml) + +# With aapt2, we'll link in the built resource from the AAR. +ifndef LOCAL_USE_AAPT2 +LOCAL_RESOURCE_DIR += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES),\ + $(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/aar/res) +endif # LOCAL_USE_AAPT2 +endif # LOCAL_STATIC_JAVA_AAR_LIBRARIES + +# Set up rules to merge library manifest files +ifdef my_full_libs_manifest_files +main_android_manifest := $(full_android_manifest) +full_android_manifest := $(intermediates.COMMON)/AndroidManifest.xml +$(full_android_manifest): PRIVATE_LIBS_MANIFESTS := $(my_full_libs_manifest_files) +$(full_android_manifest) : $(main_android_manifest) $(my_full_libs_manifest_deps) + @echo "Merge android manifest files: $@ <-- $< $(PRIVATE_LIBS_MANIFESTS)" + @mkdir -p $(dir $@) + $(hide) $(ANDROID_MANIFEST_MERGER) --main $< --libs $(PRIVATE_LIBS_MANIFESTS) \ + --out $@ + +endif diff --git a/core/apicheck_msg_current.txt b/core/apicheck_msg_current.txt new file mode 100644 index 0000000000000000000000000000000000000000..440e7f8862e81b2d32ed3357d7b3161914544d78 --- /dev/null +++ b/core/apicheck_msg_current.txt @@ -0,0 +1,17 @@ + +****************************** +You have tried to change the API from what has been previously approved. + +To make these errors go away, you have two choices: + 1) You can add "@hide" javadoc comments to the methods, etc. listed in the + errors above. + + 2) You can update current.txt by executing the following command: + make update-api + + To submit the revised current.txt to the main Android repository, + you will need approval. +****************************** + + + diff --git a/core/apicheck_msg_last.txt b/core/apicheck_msg_last.txt new file mode 100644 index 0000000000000000000000000000000000000000..2993157b165d79e11f1b3526bdf20e71339b3db2 --- /dev/null +++ b/core/apicheck_msg_last.txt @@ -0,0 +1,7 @@ + +****************************** +You have tried to change the API from what has been previously released in +an SDK. Please fix the errors listed above. +****************************** + + diff --git a/core/base_rules.mk b/core/base_rules.mk new file mode 100644 index 0000000000000000000000000000000000000000..6722af4f27ad1eae869694db53efdbef7d1ab475 --- /dev/null +++ b/core/base_rules.mk @@ -0,0 +1,523 @@ +# +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Users can define base-rules-hook in their buildspec.mk to perform +# arbitrary operations as each module is included. +ifdef base-rules-hook +$(if $(base-rules-hook),) +endif + +########################################################### +## Common instructions for a generic module. +########################################################### + +LOCAL_MODULE := $(strip $(LOCAL_MODULE)) +ifeq ($(LOCAL_MODULE),) + $(error $(LOCAL_PATH): LOCAL_MODULE is not defined) +endif + +LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE)) +ifdef LOCAL_IS_HOST_MODULE + ifneq ($(LOCAL_IS_HOST_MODULE),true) + $(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)") + endif + ifeq ($(LOCAL_HOST_PREFIX),) + my_prefix := HOST_ + else + my_prefix := $(LOCAL_HOST_PREFIX) + endif + my_host := host- +else + my_prefix := TARGET_ + my_host := +endif + +ifeq ($(my_prefix),HOST_CROSS_) + my_host_cross := true +else + my_host_cross := +endif + +my_module_tags := $(LOCAL_MODULE_TAGS) +ifeq ($(my_host_cross),true) + my_module_tags := +endif + +ifdef BUILDING_WITH_NINJA +# Ninja has an implicit dependency on the command being run, and kati will +# regenerate the ninja manifest if any read makefile changes, so there is no +# need to have dependencies on makefiles. +# This won't catch all the cases where LOCAL_ADDITIONAL_DEPENDENCIES contains +# a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't include +# base_rules.mk, but it will fix the most common ones. +LOCAL_ADDITIONAL_DEPENDENCIES := $(filter-out %.mk,$(LOCAL_ADDITIONAL_DEPENDENCIES)) +endif + +########################################################### +## Validate and define fallbacks for input LOCAL_* variables. +########################################################### + +## Dump a .csv file of all modules and their tags +#ifneq ($(tag-list-first-time),false) +#$(shell rm -f tag-list.csv) +#tag-list-first-time := false +#endif +#$(shell echo $(lastword $(filter-out config/% out/%,$(MAKEFILE_LIST))),$(LOCAL_MODULE),$(strip $(LOCAL_MODULE_CLASS)),$(subst $(space),$(comma),$(sort $(my_module_tags))) >> tag-list.csv) + +LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE)) +my_module_tags := $(sort $(my_module_tags)) +ifeq (,$(my_module_tags)) + my_module_tags := optional +endif + +# User tags are not allowed anymore. Fail early because it will not be installed +# like it used to be. +ifneq ($(filter $(my_module_tags),user),) + $(warning *** Module name: $(LOCAL_MODULE)) + $(warning *** Makefile location: $(LOCAL_MODULE_MAKEFILE)) + $(warning * ) + $(warning * Module is attempting to use the 'user' tag. This) + $(warning * used to cause the module to be installed automatically.) + $(warning * Now, the module must be listed in the PRODUCT_PACKAGES) + $(warning * section of a product makefile to have it installed.) + $(warning * ) + $(error user tag detected on module.) +endif + +# Only the tags mentioned in this test are expected to be set by module +# makefiles. Anything else is either a typo or a source of unexpected +# behaviors. +ifneq ($(filter-out debug eng tests optional samples,$(my_module_tags)),) +$(warning unusual tags $(my_module_tags) on $(LOCAL_MODULE) at $(LOCAL_PATH)) +endif + +# Add implicit tags. +# +# If the local directory or one of its parents contains a MODULE_LICENSE_GPL +# file, tag the module as "gnu". Search for "*_GPL*", "*_LGPL*" and "*_MPL*" +# so that we can also find files like MODULE_LICENSE_GPL_AND_AFL +# +license_files := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*) +gpl_license_file := $(call find-parent-file,$(LOCAL_PATH),MODULE_LICENSE*_GPL* MODULE_LICENSE*_MPL* MODULE_LICENSE*_LGPL*) +ifneq ($(gpl_license_file),) + my_module_tags += gnu + ALL_GPL_MODULE_LICENSE_FILES := $(sort $(ALL_GPL_MODULE_LICENSE_FILES) $(gpl_license_file)) +endif + +LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS)) +ifneq ($(words $(LOCAL_MODULE_CLASS)),1) + $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)") +endif + +my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32) + +ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) +my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix))) +ifdef my_multilib_module_path +my_module_path := $(my_multilib_module_path) +else +my_module_path := $(strip $(LOCAL_MODULE_PATH)) +endif +my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH)) +ifeq ($(my_module_path),) + ifdef LOCAL_IS_HOST_MODULE + partition_tag := + else + ifeq (true,$(LOCAL_PROPRIETARY_MODULE)) + partition_tag := _VENDOR + else ifeq (true,$(LOCAL_OEM_MODULE)) + partition_tag := _OEM + else ifeq (true,$(LOCAL_ODM_MODULE)) + partition_tag := _ODM + else + # The definition of should-install-to-system will be different depending + # on which goal (e.g., sdk or just droid) is being built. + partition_tag := $(if $(call should-install-to-system,$(my_module_tags)),,_DATA) + endif + endif + install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS) + ifeq (true,$(LOCAL_PRIVILEGED_MODULE)) + install_path_var := $(install_path_var)_PRIVILEGED + endif + + my_module_path := $($(install_path_var)) + ifeq ($(strip $(my_module_path)),) + $(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)") + endif +endif +ifneq ($(my_module_relative_path),) + my_module_path := $(my_module_path)/$(my_module_relative_path) +endif +endif # not LOCAL_UNINSTALLABLE_MODULE + +ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),) + $(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles) +endif + +my_register_name := $(LOCAL_MODULE) +ifeq ($(my_host_cross),true) + my_register_name := host_cross_$(LOCAL_MODULE) +endif +ifdef LOCAL_2ND_ARCH_VAR_PREFIX +ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX +my_register_name := $(my_register_name)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX) +endif +endif +# Make sure that this IS_HOST/CLASS/MODULE combination is unique. +module_id := MODULE.$(if \ + $(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name) +ifdef $(module_id) +$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id))) +endif +$(module_id) := $(LOCAL_PATH) + +intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross)) +intermediates.COMMON := $(call local-intermediates-dir,COMMON) +generated_sources_dir := $(call local-generated-sources-dir) + +########################################################### +# Pick a name for the intermediate and final targets +########################################################### +include $(BUILD_SYSTEM)/configure_module_stem.mk + +# OVERRIDE_BUILT_MODULE_PATH is only allowed to be used by the +# internal SHARED_LIBRARIES build files. +OVERRIDE_BUILT_MODULE_PATH := $(strip $(OVERRIDE_BUILT_MODULE_PATH)) +ifdef OVERRIDE_BUILT_MODULE_PATH + ifneq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES) + $(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH) + endif + built_module_path := $(OVERRIDE_BUILT_MODULE_PATH) +else + built_module_path := $(intermediates) +endif +LOCAL_BUILT_MODULE := $(built_module_path)/$(my_built_module_stem) + +ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) + # Apk and its attachments reside in its own subdir. + ifeq ($(LOCAL_MODULE_CLASS),APPS) + # framework-res.apk doesn't like the additional layer. + ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true) + my_module_path := $(my_module_path)/$(LOCAL_MODULE) + endif + endif + LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem) +endif + +# Assemble the list of targets to create PRIVATE_ variables for. +LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE) + +########################################################### +## Create .toc files from shared objects to reduce unnecessary rebuild +# .toc files have the list of external dynamic symbols without their addresses. +# As .KATI_RESTAT is specified to .toc files and commit-change-for-toc is used, +# dependent binaries of a .toc file will be rebuilt only when the content of +# the .toc file is changed. +########################################################### +ifndef LOCAL_IS_HOST_MODULE +# Disable .toc optimization for host modules: we may run the host binaries during the build process +# and the libraries' implementation matters. +ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES) +LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc +$(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE) + $(call $(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)transform-shared-lib-to-toc,$<,$@.tmp) + $(call commit-change-for-toc,$@) + +# Kati adds restat=1 to ninja. GNU make does nothing for this. +.KATI_RESTAT: $(LOCAL_BUILT_MODULE).toc +# Build .toc file when using mm, mma, or make $(my_register_name) +$(my_register_name): $(LOCAL_BUILT_MODULE).toc +endif +endif + +########################################################### +## logtags: Add .logtags files to global list +########################################################### + +logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) + +ifneq ($(strip $(logtags_sources)),) +event_log_tags := $(addprefix $(LOCAL_PATH)/,$(logtags_sources)) +else +event_log_tags := +endif + +########################################################### +## make clean- targets +########################################################### +cleantarget := clean-$(my_register_name) +$(cleantarget) : PRIVATE_MODULE := $(my_register_name) +$(cleantarget) : PRIVATE_CLEAN_FILES := \ + $(LOCAL_BUILT_MODULE) \ + $(LOCAL_INSTALLED_MODULE) \ + $(intermediates) +$(cleantarget):: + @echo "Clean: $(PRIVATE_MODULE)" + $(hide) rm -rf $(PRIVATE_CLEAN_FILES) + +########################################################### +## Common definitions for module. +########################################################### +$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH) +$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE) +$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host) +$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix) + +$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates) +$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX) + +# Tell the module and all of its sub-modules who it is. +$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name) + +# Provide a short-hand for building this module. +# We name both BUILT and INSTALLED in case +# LOCAL_UNINSTALLABLE_MODULE is set. +.PHONY: $(my_register_name) +$(my_register_name): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE) + +# Set up phony targets that covers all modules under the given paths. +# This allows us to build everything in given paths by running mmma/mma. +my_path_components := $(subst /,$(space),$(LOCAL_PATH)) +my_path_prefix := MODULES-IN +$(foreach c, $(my_path_components),\ + $(eval my_path_prefix := $(my_path_prefix)-$(c))\ + $(eval .PHONY : $(my_path_prefix))\ + $(eval $(my_path_prefix) : $(my_register_name))) + +########################################################### +## Module installation rule +########################################################### + +# Some hosts do not have ACP; override the LOCAL version if that's the case. +ifneq ($(strip $(HOST_ACP_UNAVAILABLE)),) + LOCAL_ACP_UNAVAILABLE := $(strip $(HOST_ACP_UNAVAILABLE)) +endif + +ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) + # Define a copy rule to install the module. + # acp and libraries that it uses can't use acp for + # installation; hence, LOCAL_ACP_UNAVAILABLE. +$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD) +ifneq ($(LOCAL_ACP_UNAVAILABLE),true) +$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) | $(ACP) + @echo "Install: $@" + $(copy-file-to-new-target) + $(PRIVATE_POST_INSTALL_CMD) +else +$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE) + @echo "Install: $@" + $(copy-file-to-target-with-cp) +endif + +# Rule to install the module's companion init.rc. +my_init_rc := $(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) +my_init_rc_src := +my_init_rc_installed := +ifndef my_init_rc +my_init_rc := $(LOCAL_INIT_RC) +# Make sure we don't define the rule twice in multilib module. +LOCAL_INIT_RC := +endif +ifdef my_init_rc +my_init_rc_src := $(LOCAL_PATH)/$(my_init_rc) +my_init_rc_installed := $(TARGET_OUT$(partition_tag)_ETC)/init/$(notdir $(my_init_rc_src)) +$(my_init_rc_installed) : $(my_init_rc_src) | $(ACP) + @echo "Install: $@" + $(copy-file-to-new-target) + +$(my_register_name) : $(my_init_rc_installed) +endif # my_init_rc +endif # !LOCAL_UNINSTALLABLE_MODULE + +########################################################### +## CHECK_BUILD goals +########################################################### +my_checked_module := +# If nobody has defined a more specific module for the +# checked modules, use LOCAL_BUILT_MODULE. +ifdef LOCAL_CHECKED_MODULE + my_checked_module := $(LOCAL_CHECKED_MODULE) +else + my_checked_module := $(LOCAL_BUILT_MODULE) +endif + +# If they request that this module not be checked, then don't. +# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT +# GOOD REASON WILL HAVE IT REMOVED. +ifdef LOCAL_DONT_CHECK_MODULE + my_checked_module := +endif +# Don't check build target module defined for the 2nd arch +ifndef LOCAL_IS_HOST_MODULE +ifdef LOCAL_2ND_ARCH_VAR_PREFIX + my_checked_module := +endif +endif + +########################################################### +## Compatibiliy suite files. +########################################################### +ifdef LOCAL_COMPATIBILITY_SUITE +ifneq ($(words $(LOCAL_COMPATIBILITY_SUITE)),1) +$(error $(LOCAL_PATH):$(LOCAL_MODULE) LOCAL_COMPATIBILITY_SUITE can be only one name) +endif + +# The module itself. +my_compat_dist := \ + $(LOCAL_BUILT_MODULE):$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(my_installed_module_stem) + +# Make sure we only add the files once for multilib modules. +ifndef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files +$(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files := true + +# LOCAL_COMPATIBILITY_SUPPORT_FILES is a list of [:]. +my_compat_dist += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES),\ + $(eval p := $(subst :,$(space),$(f)))\ + $(eval s := $(word 1,$(p)))\ + $(eval d := $(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(or $(word 2,$(p)),$(notdir $(word 1,$(p)))))\ + $(s):$(d)) + +ifneq (,$(wildcard $(LOCAL_PATH)/AndroidTest.xml)) +my_compat_dist += \ + $(LOCAL_PATH)/AndroidTest.xml:$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE).config +endif + +ifneq (,$(wildcard $(LOCAL_PATH)/DynamicConfig.xml)) +my_compat_dist += \ + $(LOCAL_PATH)/DynamicConfig.xml:$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE).dynamic +endif +endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files + +my_compat_files := $(call copy-many-files, $(my_compat_dist)) + +COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES := \ + $(COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES) \ + $(my_compat_files) + +# Copy over the compatibility files when user runs mm/mmm. +$(my_register_name) : $(my_compat_files) +endif # LOCAL_COMPATIBILITY_SUITE + +########################################################### +## Register with ALL_MODULES +########################################################### + +ALL_MODULES += $(my_register_name) + +# Don't use += on subvars, or else they'll end up being +# recursively expanded. +ALL_MODULES.$(my_register_name).CLASS := \ + $(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS) +ALL_MODULES.$(my_register_name).PATH := \ + $(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH) +ALL_MODULES.$(my_register_name).TAGS := \ + $(ALL_MODULES.$(my_register_name).TAGS) $(my_module_tags) +ALL_MODULES.$(my_register_name).CHECKED := \ + $(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module) +ALL_MODULES.$(my_register_name).BUILT := \ + $(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE) +ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE)) +ALL_MODULES.$(my_register_name).INSTALLED := \ + $(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \ + $(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed)) +ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \ + $(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \ + $(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE) \ + $(addprefix $(my_init_rc_src):,$(my_init_rc_installed))) +endif +ifdef LOCAL_PICKUP_FILES +# Files or directories ready to pick up by the build system +# when $(LOCAL_BUILT_MODULE) is done. +ALL_MODULES.$(my_register_name).PICKUP_FILES := \ + $(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES) +endif +my_required_modules := $(LOCAL_REQUIRED_MODULES) \ + $(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) +ifdef LOCAL_IS_HOST_MODULE +my_required_modules += $(LOCAL_REQUIRED_MODULES_$($(my_prefix)OS)) +endif +ALL_MODULES.$(my_register_name).REQUIRED := \ + $(strip $(ALL_MODULES.$(my_register_name).REQUIRED) $(my_required_modules)) +ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \ + $(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags) +ALL_MODULES.$(my_register_name).MAKEFILE := \ + $(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE) +ifdef LOCAL_MODULE_OWNER +ALL_MODULES.$(my_register_name).OWNER := \ + $(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER)) +endif +ifdef LOCAL_2ND_ARCH_VAR_PREFIX +ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true +endif +ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross) + +INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name) + +########################################################## +# Track module-level dependencies. +# Use $(LOCAL_MODULE) instead of $(my_register_name) to ignore module's bitness. +ALL_DEPS.MODULES := $(sort $(ALL_DEPS.MODULES) $(LOCAL_MODULE)) +ALL_DEPS.$(LOCAL_MODULE).ALL_DEPS := $(sort \ + $(ALL_MODULES.$(LOCAL_MODULE).ALL_DEPS) \ + $(LOCAL_STATIC_LIBRARIES) \ + $(LOCAL_WHOLE_STATIC_LIBRARIES) \ + $(LOCAL_SHARED_LIBRARIES) \ + $(LOCAL_STATIC_JAVA_LIBRARIES) \ + $(LOCAL_JAVA_LIBRARIES)\ + $(LOCAL_JNI_SHARED_LIBRARIES)) + +ALL_DEPS.$(LOCAL_MODULE).LICENSE := $(sort $(ALL_DEPS.$(LOCAL_MODULE).LICENSE) $(license_files)) + +########################################################### +## Take care of my_module_tags +########################################################### + +# Keep track of all the tags we've seen. +ALL_MODULE_TAGS := $(sort $(ALL_MODULE_TAGS) $(my_module_tags)) + +# Add this module name to the tag list of each specified tag. +$(foreach tag,$(my_module_tags),\ + $(eval ALL_MODULE_NAME_TAGS.$(tag) += $(my_register_name))) + +########################################################### +## umbrella targets used to verify builds +########################################################### +j_or_n := +ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))) +j_or_n := native +else +ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS))) +j_or_n := java +endif +endif +ifdef LOCAL_IS_HOST_MODULE +h_or_t := host +else +h_or_t := target +endif + +ifdef j_or_n +$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_t) : $(my_checked_module) +ifneq (,$(filter $(my_module_tags),tests)) +$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module) +endif +endif + +########################################################### +## NOTICE files +########################################################### + +include $(BUILD_NOTICE_FILE) diff --git a/core/binary.mk b/core/binary.mk new file mode 100644 index 0000000000000000000000000000000000000000..7b229032b00a3d43ef82d30947dc255f9297ea02 --- /dev/null +++ b/core/binary.mk @@ -0,0 +1,1444 @@ +########################################################### +## Standard rules for building binary object files from +## asm/c/cpp/yacc/lex/etc source files. +## +## The list of object files is exported in $(all_objects). +########################################################### + +####################################### +include $(BUILD_SYSTEM)/base_rules.mk +####################################### + +################################################## +# Compute the dependency of the shared libraries +################################################## +# On the target, we compile with -nostdlib, so we must add in the +# default system shared libraries, unless they have requested not +# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would +# supply that, for example, when building libc itself. +ifdef LOCAL_IS_HOST_MODULE + ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) + my_system_shared_libraries := + else + my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES) + endif +else + ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none) + my_system_shared_libraries := libc libm + else + my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES) + endif +endif + +# The following LOCAL_ variables will be modified in this file. +# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch, +# we can't modify them in place. +my_src_files := $(LOCAL_SRC_FILES) +my_src_files_exclude := $(LOCAL_SRC_FILES_EXCLUDE) +my_static_libraries := $(LOCAL_STATIC_LIBRARIES) +my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES) +my_shared_libraries := $(LOCAL_SHARED_LIBRARIES) +my_cflags := $(LOCAL_CFLAGS) +my_conlyflags := $(LOCAL_CONLYFLAGS) +my_cppflags := $(LOCAL_CPPFLAGS) +my_cflags_no_override := $(GLOBAL_CFLAGS_NO_OVERRIDE) +my_cppflags_no_override := $(GLOBAL_CPPFLAGS_NO_OVERRIDE) +my_ldflags := $(LOCAL_LDFLAGS) +my_ldlibs := $(LOCAL_LDLIBS) +my_asflags := $(LOCAL_ASFLAGS) +my_cc := $(LOCAL_CC) +my_cc_wrapper := $(CC_WRAPPER) +my_cxx := $(LOCAL_CXX) +my_cxx_wrapper := $(CXX_WRAPPER) +my_c_includes := $(LOCAL_C_INCLUDES) +my_generated_sources := $(LOCAL_GENERATED_SOURCES) +my_native_coverage := $(LOCAL_NATIVE_COVERAGE) +my_additional_dependencies := $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES) +my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS) + +ifdef LOCAL_IS_HOST_MODULE +my_allow_undefined_symbols := true +else +my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)) +endif + +my_ndk_sysroot := +my_ndk_sysroot_include := +my_ndk_sysroot_lib := +ifdef LOCAL_SDK_VERSION + ifdef LOCAL_NDK_VERSION + $(error $(LOCAL_PATH): LOCAL_NDK_VERSION is now retired.) + endif + ifdef LOCAL_IS_HOST_MODULE + $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module) + endif + my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources + my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/current/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) + my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include + + # x86_64 and and mips64 are both multilib toolchains, so their libraries are + # installed in /usr/lib64. Aarch64, on the other hand, is not a multilib + # compiler, so its libraries are in /usr/lib. + # + # Mips32r6 is yet another variation, with libraries installed in libr6. + # + # For the rest, the libraries are installed simply to /usr/lib. + ifneq (,$(filter x86_64 mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) + my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64 + else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) + my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/libr6 + else + my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib + endif + + # The bionic linker now has support for packed relocations and gnu style + # hashes (which are much faster!), but shipping to older devices requires + # the old style hash. Fortunately, we can build with both and it'll work + # anywhere. + # + # This is not currently supported on MIPS architectures. + ifeq (,$(filter mips mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) + my_ldflags += -Wl,--hash-style=both + endif + + # We don't want to expose the relocation packer to the NDK just yet. + LOCAL_PACK_MODULE_RELOCATIONS := false + + # Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location. + # See ndk/docs/CPLUSPLUS-SUPPORT.html + my_ndk_stl_include_path := + my_ndk_stl_shared_lib_fullpath := + my_ndk_stl_shared_lib := + my_ndk_stl_static_lib := + my_ndk_stl_cppflags := + my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI) + ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) + my_cpu_variant := mips32r6 + endif + LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT)) + ifeq (,$(LOCAL_NDK_STL_VARIANT)) + LOCAL_NDK_STL_VARIANT := system + endif + ifneq (1,$(words $(filter none system stlport_static stlport_shared c++_static c++_shared gnustl_static, $(LOCAL_NDK_STL_VARIANT)))) + $(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT)) + endif + ifeq (system,$(LOCAL_NDK_STL_VARIANT)) + my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include + my_system_shared_libraries += libstdc++ + else # LOCAL_NDK_STL_VARIANT is not system + ifneq (,$(filter stlport_%, $(LOCAL_NDK_STL_VARIANT))) + my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/stlport/stlport + my_system_shared_libraries += libstdc++ + ifeq (stlport_static,$(LOCAL_NDK_STL_VARIANT)) + my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_static.a + else + my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/stlport/libs/$(my_cpu_variant)/libstlport_shared.so + my_ndk_stl_shared_lib := -lstlport_shared + endif + else # LOCAL_NDK_STL_VARIANT is not stlport_* either + ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT))) + my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libcxx/include \ + $(my_ndk_source_root)/cxx-stl/llvm-libc++/gabi++/include \ + $(my_ndk_source_root)/android/support/include + ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT)) + my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_static.a + else + my_ndk_stl_shared_lib_fullpath := $(my_ndk_source_root)/cxx-stl/llvm-libc++/libs/$(my_cpu_variant)/libc++_shared.so + my_ndk_stl_shared_lib := -lc++_shared + endif + my_ndk_stl_cppflags := -std=c++11 + else # LOCAL_NDK_STL_VARIANT is not c++_* either + ifneq (,$(filter gnustl_%, $(LOCAL_NDK_STL_VARIANT))) + my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/include \ + $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/include + my_ndk_stl_static_lib := $(my_ndk_source_root)/cxx-stl/gnu-libstdc++/$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_GCC_VERSION)/libs/$(my_cpu_variant)/libgnustl_static.a + else # LOCAL_NDK_STL_VARIANT must be none + # Do nothing. + endif + endif + endif + endif +endif + +# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because +# all code is position independent, and then those warnings get promoted to +# errors. +ifneq ($($(my_prefix)OS),windows) +ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) +my_cflags += -fpie +else +my_cflags += -fPIC +endif +endif + +ifdef LOCAL_IS_HOST_MODULE +my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)OS)) $(LOCAL_SRC_FILES_$($(my_prefix)OS)_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) +my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS)) +my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS)) +my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS)) +my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS)) +my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS)) +my_ldlibs += $(LOCAL_LDLIBS_$($(my_prefix)OS)) +my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)OS)) +my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)OS)) +my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)OS)) +endif + +my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix)) +my_src_files_exclude += $(LOCAL_SRC_FILES_EXCLUDE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_EXCLUDE_$(my_32_64_bit_suffix)) +my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix)) +my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix)) +my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix)) +my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix)) +my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix)) +my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix)) +my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix)) + +my_missing_exclude_files := $(filter-out $(my_src_files),$(my_src_files_exclude)) +ifneq ($(my_missing_exclude_files),) +$(warning Files are listed in LOCAL_SRC_FILES_EXCLUDE but not LOCAL_SRC_FILES) +$(error $(my_missing_exclude_files)) +endif +my_src_files := $(filter-out $(my_src_files_exclude),$(my_src_files)) + +my_clang := $(strip $(LOCAL_CLANG)) +ifdef LOCAL_CLANG_$(my_32_64_bit_suffix) +my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix))) +endif +ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) +my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) +endif + +# clang is enabled by default for host builds +# enable it unless we've specifically disabled clang above +ifdef LOCAL_IS_HOST_MODULE + ifneq ($($(my_prefix)OS),windows) + ifeq ($(my_clang),) + my_clang := true + endif + endif +# Add option to make gcc the default for device build +else ifeq ($(USE_CLANG_PLATFORM_BUILD),false) + ifeq ($(my_clang),) + my_clang := false + endif +else ifeq ($(my_clang),) + my_clang := true +endif + +my_cpp_std_version := -std=gnu++14 + +ifneq ($(my_clang),true) + # GCC uses an invalid C++14 ABI (emits calls to + # __cxa_throw_bad_array_length, which is not a valid C++ RT ABI). + # http://b/25022512 + my_cpp_std_version := -std=gnu++11 +endif + +ifdef LOCAL_SDK_VERSION + # The NDK handles this itself. + my_cpp_std_version := +endif + +ifdef LOCAL_IS_HOST_MODULE + ifneq ($(my_clang),true) + # The host GCC doesn't support C++14 (and is deprecated, so likely + # never will). Build these modules with C++11. + my_cpp_std_version := -std=gnu++11 + endif +endif + +my_cppflags := $(my_cpp_std_version) $(my_cppflags) + + +# arch-specific static libraries go first so that generic ones can depend on them +my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries) +my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries) + +include $(BUILD_SYSTEM)/cxx_stl_setup.mk + +# Add static HAL libraries +ifdef LOCAL_HAL_STATIC_LIBRARIES +$(foreach lib, $(LOCAL_HAL_STATIC_LIBRARIES), \ + $(eval b_lib := $(filter $(lib).%,$(BOARD_HAL_STATIC_LIBRARIES)))\ + $(if $(b_lib), $(eval my_static_libraries += $(b_lib)),\ + $(eval my_static_libraries += $(lib).default))) +b_lib := +endif + +ifneq ($(strip $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)),) + my_linker := $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER) +else + my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LINKER) +endif + +include $(BUILD_SYSTEM)/config_sanitizers.mk + +# Add in libcompiler_rt for all regular device builds +ifeq (,$(LOCAL_SDK_VERSION)$(WITHOUT_LIBCOMPILER_RT)) + my_static_libraries += $(COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES) +endif + +#################################################### +## Add FDO flags if FDO is turned on and supported +## Please note that we will do option filtering during FDO build. +## i.e. Os->O2, remove -fno-early-inline and -finline-limit. +################################################################## +my_fdo_build := +ifneq ($(filter true always, $(LOCAL_FDO_SUPPORT)),) + ifeq ($(BUILD_FDO_INSTRUMENT),true) + my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_CFLAGS) + my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_INSTRUMENT_LDFLAGS) + my_fdo_build := true + else ifneq ($(filter true,$(BUILD_FDO_OPTIMIZE))$(filter always,$(LOCAL_FDO_SUPPORT)),) + my_cflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_FDO_OPTIMIZE_CFLAGS) + my_fdo_build := true + endif + # Disable ccache (or other compiler wrapper) except gomacc, which + # can handle -fprofile-use properly. + my_cc_wrapper := $(filter $(GOMA_CC),$(my_cc_wrapper)) + my_cxx_wrapper := $(filter $(GOMA_CC),$(my_cxx_wrapper)) +endif + +########################################################### +## Explicitly declare assembly-only __ASSEMBLY__ macro for +## assembly source +########################################################### +my_asflags += -D__ASSEMBLY__ + + +########################################################### +## Define PRIVATE_ variables from global vars +########################################################### +ifndef LOCAL_IS_HOST_MODULE +ifdef LOCAL_SDK_VERSION +my_target_project_includes := +my_target_c_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroot_include) +my_target_global_cppflags := $(my_ndk_stl_cppflags) +else +my_target_project_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES) +my_target_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES) +my_target_global_cppflags := +endif # LOCAL_SDK_VERSION + +ifeq ($(my_clang),true) +my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CFLAGS) +my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CONLYFLAGS) +my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_CPPFLAGS) +my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_TARGET_GLOBAL_LDFLAGS) +else +my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS) +my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CONLYFLAGS) +my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS) +my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LDFLAGS) +endif # my_clang + +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_PROJECT_INCLUDES := $(my_target_project_includes) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_C_INCLUDES := $(my_target_c_includes) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags) + +else # LOCAL_IS_HOST_MODULE + +ifeq ($(my_clang),true) +my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS) +my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) +my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) +my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS) +my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) +else +my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS) +my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS) +my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS) +my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS) +my_host_c_includes := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES) +endif # my_clang + +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_C_INCLUDES := $(my_host_c_includes) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags) +endif # LOCAL_IS_HOST_MODULE + +# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and +# build with NATIVE_COVERAGE=true in your enviornment. Note that the build +# system is not sensitive to changes to NATIVE_COVERAGE, so you should do a +# clean build of your module after toggling it. +ifeq ($(NATIVE_COVERAGE),true) + ifeq ($(my_native_coverage),true) + # Note that clang coverage doesn't play nicely with acov out of the box. + # Clang apparently generates .gcno files that aren't compatible with + # gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov + # with `--gcov-tool /usr/bin/gcov-4.6`. + # + # http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output + my_cflags += --coverage -O0 + my_ldflags += --coverage + endif +else + my_native_coverage := false +endif + +ifeq ($(my_clang),true) + my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT) +else + my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCOV) +endif + +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib) + +########################################################### +## Define PRIVATE_ variables used by multiple module types +########################################################### +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \ + $(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)) + +ifeq ($(strip $(WITH_SYNTAX_CHECK)),) + LOCAL_NO_SYNTAX_CHECK := true +endif + +ifeq ($(strip $(WITH_STATIC_ANALYZER)),) + LOCAL_NO_STATIC_ANALYZER := true +endif + +# Clang does not recognize all gcc flags. +# Use static analyzer only if clang is used. +ifneq ($(my_clang),true) + LOCAL_NO_STATIC_ANALYZER := true +endif + +ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),) + my_syntax_arch := host +else + my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) +endif + +ifeq ($(strip $(my_cc)),) + ifeq ($(my_clang),true) + my_cc := $(CLANG) + else + my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC) + endif + my_cc := $(my_cc_wrapper) $(my_cc) +endif + +ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) + my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \ + $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer +else +ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) + my_cc := $(my_cc) -fsyntax-only +endif +endif + +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc) + +ifeq ($(strip $(my_cxx)),) + ifeq ($(my_clang),true) + my_cxx := $(CLANG_CXX) + else + my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX) + endif + my_cxx := $(my_cxx_wrapper) $(my_cxx) +endif + +ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) + my_cxx := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \ + $(SYNTAX_TOOLS_PREFIX)/c++-analyzer +else +ifneq ($(LOCAL_NO_SYNTAX_CHECK),true) + my_cxx := $(my_cxx) -fsyntax-only +endif +endif + +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLANG := $(my_clang) + +# TODO: support a mix of standard extensions so that this isn't necessary +LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION)) +ifeq ($(LOCAL_CPP_EXTENSION),) + LOCAL_CPP_EXTENSION := .cpp +endif + +# Certain modules like libdl have to have symbols resolved at runtime and blow +# up if --no-undefined is passed to the linker. +ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),) +ifeq ($(my_allow_undefined_symbols),) + my_ldflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)NO_UNDEFINED_LDFLAGS) +endif +endif + +ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES)) +$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true +else +$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := +endif + +########################################################### +## Define arm-vs-thumb-mode flags. +########################################################### +LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE)) +ifeq ($($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm) +arm_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),arm) +normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb) + +# Read the values from something like TARGET_arm_CFLAGS or +# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't +# actually used (although they are usually empty). +arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS) +normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS) +ifeq ($(my_clang),true) +arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags)) +normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags)) +endif + +else +arm_objects_mode := +normal_objects_mode := +arm_objects_cflags := +normal_objects_cflags := +endif + +########################################################### +## Define per-module debugging flags. Users can turn on +## debugging for a particular module by setting DEBUG_MODULE_ModuleName +## to a non-empty value in their environment or buildspec.mk, +## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the +## debug flags that they want to use. +########################################################### +ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE)) + debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS) +else + debug_cflags := +endif + +#################################################### +## Keep track of src -> obj mapping +#################################################### + +my_tracked_gen_files := +my_tracked_src_files := + +########################################################### +## Stuff source generated from one-off tools +########################################################### +$(my_generated_sources): PRIVATE_MODULE := $(my_register_name) + +my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources))) + +$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/% | $(ACP) + @echo "Copy: $@" + $(copy-file-to-target) + +my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources)) + +# Generated sources that will actually produce object files. +# Other files (like headers) are allowed in LOCAL_GENERATED_SOURCES, +# since other compiled sources may depend on them, and we set up +# the dependencies. +my_gen_src_files := $(filter %.c %$(LOCAL_CPP_EXTENSION) %.S %.s,$(my_generated_sources)) + +ALL_GENERATED_SOURCES += $(my_generated_sources) + +#################################################### +## Compile RenderScript with reflected C++ +#################################################### + +renderscript_sources := $(filter %.rs %.fs,$(my_src_files)) + +ifneq (,$(renderscript_sources)) + +renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources)) +RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp +renderscript_intermediate := $(intermediates)/renderscript + +renderscript_target_api := + +ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API)) +renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API) +else +ifneq (,$(LOCAL_SDK_VERSION)) +# Set target-api for LOCAL_SDK_VERSIONs other than current. +ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION))) +renderscript_target_api := $(LOCAL_SDK_VERSION) +endif +endif # LOCAL_SDK_VERSION is set +endif # LOCAL_RENDERSCRIPT_TARGET_API is set + + +ifeq ($(LOCAL_RENDERSCRIPT_CC),) +LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC) +endif + +# Turn on all warnings and warnings as errors for RS compiles. +# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error +renderscript_flags := -Wall -Werror +renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS) +# -m32 or -m64 +renderscript_flags += -m$(my_32_64_bit_suffix) + +renderscript_includes := \ + $(TOPDIR)external/clang/lib/Headers \ + $(TOPDIR)frameworks/rs/scriptc \ + $(LOCAL_RENDERSCRIPT_INCLUDES) + +ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),) +renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE) +endif + +bc_dep_files := $(addprefix $(renderscript_intermediate)/, \ + $(patsubst %.fs,%.d, $(patsubst %.rs,%.d, $(notdir $(renderscript_sources))))) + +$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes) +$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC) +$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags) +$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath) +$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate) +$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(renderscript_target_api) +$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files) +$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC) + $(transform-renderscripts-to-cpp-and-bc) + +# include the dependency files (.d/.P) generated by llvm-rs-cc. +$(call include-depfile,$(RenderScript_file_stamp).P,$(RenderScript_file_stamp)) + +LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp) + +rs_generated_cpps := $(addprefix \ + $(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rs,%.cpp, \ + $(notdir $(renderscript_sources))))) + +$(call track-src-file-gen,$(renderscript_sources),$(rs_generated_cpps)) + +# This is just a dummy rule to make sure gmake doesn't skip updating the dependents. +$(rs_generated_cpps) : $(RenderScript_file_stamp) + @echo "Updated RS generated cpp file $@." + $(hide) touch $@ + +my_c_includes += $(renderscript_intermediate) +my_generated_sources += $(rs_generated_cpps) + +endif + + +########################################################### +## Compile the .proto files to .cc (or .c) and then to .o +########################################################### +proto_sources := $(filter %.proto,$(my_src_files)) +ifneq ($(proto_sources),) +proto_gen_dir := $(generated_sources_dir)/proto + +my_rename_cpp_ext := +ifneq (,$(filter nanopb-c nanopb-c-enable_malloc, $(LOCAL_PROTOC_OPTIMIZE_TYPE))) +my_proto_source_suffix := .c +my_proto_c_includes := external/nanopb-c +my_protoc_flags := --nanopb_out=$(proto_gen_dir) \ + --plugin=external/nanopb-c/generator/protoc-gen-nanopb +else +my_proto_source_suffix := $(LOCAL_CPP_EXTENSION) +ifneq ($(my_proto_source_suffix),.cc) +# aprotoc is hardcoded to write out only .cc file. +# We need to rename the extension to $(LOCAL_CPP_EXTENSION) if it's not .cc. +my_rename_cpp_ext := true +endif +my_proto_c_includes := external/protobuf/src +my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI +my_protoc_flags := --cpp_out=$(proto_gen_dir) +endif +my_proto_c_includes += $(proto_gen_dir) + +proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources)) +proto_generated_cpps := $(addprefix $(proto_gen_dir)/, \ + $(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath))) + +# Ensure the transform-proto-to-cc rule is only defined once in multilib build. +ifndef $(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined +$(proto_generated_cpps): PRIVATE_PROTO_INCLUDES := $(TOP) +$(proto_generated_cpps): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags) +$(proto_generated_cpps): PRIVATE_RENAME_CPP_EXT := $(my_rename_cpp_ext) +$(proto_generated_cpps): $(proto_gen_dir)/%.pb$(my_proto_source_suffix): %.proto $(my_protoc_deps) $(PROTOC) + $(transform-proto-to-cc) + +$(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true +endif +# Ideally we can generate the source directly into $(intermediates). +# But many Android.mks assume the .pb.hs are in $(generated_sources_dir). +# As a workaround, we make a copy in the $(intermediates). +proto_intermediate_dir := $(intermediates)/proto +proto_intermediate_cpps := $(patsubst $(proto_gen_dir)/%,$(proto_intermediate_dir)/%,\ + $(proto_generated_cpps)) +$(proto_intermediate_cpps) : $(proto_intermediate_dir)/% : $(proto_gen_dir)/% | $(ACP) + @echo "Copy: $@" + $(copy-file-to-target) + $(hide) cp $(basename $<).h $(basename $@).h +$(call track-src-file-gen,$(proto_sources),$(proto_intermediate_cpps)) + +my_generated_sources += $(proto_intermediate_cpps) + +my_c_includes += $(my_proto_c_includes) +# Auto-export the generated proto source dir. +my_export_c_include_dirs += $(my_proto_c_includes) + +ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc) + my_static_libraries += libprotobuf-c-nano-enable_malloc +else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c) + my_static_libraries += libprotobuf-c-nano +else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full) + ifdef LOCAL_SDK_VERSION + my_static_libraries += libprotobuf-cpp-full-ndk + else + my_shared_libraries += libprotobuf-cpp-full + endif +else + ifdef LOCAL_SDK_VERSION + my_static_libraries += libprotobuf-cpp-lite-ndk + else + my_shared_libraries += libprotobuf-cpp-lite + endif +endif +endif # $(proto_sources) non-empty + +########################################################### +## Compile the .dbus-xml files to c++ headers +########################################################### +dbus_definitions := $(filter %.dbus-xml,$(my_src_files)) +dbus_generated_headers := +ifneq ($(dbus_definitions),) + +dbus_definition_paths := $(addprefix $(LOCAL_PATH)/,$(dbus_definitions)) +dbus_service_config := $(filter %dbus-service-config.json,$(my_src_files)) +dbus_service_config_path := $(addprefix $(LOCAL_PATH)/,$(dbus_service_config)) + +# Mark these source files as not producing objects +$(call track-src-file-obj,$(dbus_definitions) $(dbus_service_config),) + +dbus_gen_dir := $(generated_sources_dir)/dbus_bindings + +ifdef LOCAL_DBUS_PROXY_PREFIX +dbus_header_dir := $(dbus_gen_dir)/include/$(LOCAL_DBUS_PROXY_PREFIX) +dbus_headers := dbus-proxies.h +else +dbus_header_dir := $(dbus_gen_dir) +dbus_headers := $(patsubst %.dbus-xml,%.h,$(dbus_definitions)) +endif +dbus_generated_headers := $(addprefix $(dbus_header_dir)/,$(dbus_headers)) + +# Ensure that we only define build rules once in multilib builds. +ifndef $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined +$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined := true + +$(dbus_generated_headers): PRIVATE_MODULE := $(LOCAL_MODULE) +$(dbus_generated_headers): PRIVATE_DBUS_SERVICE_CONFIG := $(dbus_service_config_path) +$(dbus_generated_headers) : $(dbus_service_config_path) $(DBUS_GENERATOR) +ifdef LOCAL_DBUS_PROXY_PREFIX +$(dbus_generated_headers) : $(dbus_definition_paths) + $(generate-dbus-proxies) +else +$(dbus_generated_headers) : $(dbus_header_dir)/%.h : $(LOCAL_PATH)/%.dbus-xml + $(generate-dbus-adaptors) +endif # $(LOCAL_DBUS_PROXY_PREFIX) +endif # $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined + +ifdef LOCAL_DBUS_PROXY_PREFIX +# Auto-export the generated dbus proxy directory. +my_export_c_include_dirs += $(dbus_gen_dir)/include +my_c_includes += $(dbus_gen_dir)/include +else +my_export_c_include_dirs += $(dbus_header_dir) +my_c_includes += $(dbus_header_dir) +endif # $(LOCAL_DBUS_PROXY_PREFIX) + +my_generated_sources += $(dbus_generated_headers) + +endif # $(dbus_definitions) non-empty + + +########################################################### +## AIDL: Compile .aidl files to .cpp and .h files +########################################################### +aidl_src := $(strip $(filter %.aidl,$(my_src_files))) +aidl_gen_cpp := +ifneq ($(aidl_src),) + +# Use the intermediates directory to avoid writing our own .cpp -> .o rules. +aidl_gen_cpp_root := $(intermediates)/aidl-generated/src +aidl_gen_include_root := $(intermediates)/aidl-generated/include + +# Multi-architecture builds have distinct intermediates directories. +# Thus we'll actually generate source for each architecture. +$(foreach s,$(aidl_src),\ + $(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp))) +$(foreach cpp,$(aidl_gen_cpp), \ + $(call include-depfile,$(addsuffix .aidl.P,$(basename $(cpp))),$(cpp))) +$(call track-src-file-gen,$(aidl_src),$(aidl_gen_cpp)) + +$(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE) +$(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root) +$(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES)) + +# Add generated headers to include paths. +my_c_includes += $(aidl_gen_include_root) +my_export_c_include_dirs += $(aidl_gen_include_root) +# Pick up the generated C++ files later for transformation to .o files. +my_generated_sources += $(aidl_gen_cpp) + +endif # $(aidl_src) non-empty + +########################################################### +## Compile the .vts files to .cc (or .c) and then to .o +########################################################### + +vts_src := $(strip $(filter %.vts,$(my_src_files))) +vts_gen_cpp := +ifneq ($(vts_src),) + +# Use the intermediates directory to avoid writing our own .cpp -> .o rules. +vts_gen_cpp_root := $(intermediates)/vts-generated/src +vts_gen_include_root := $(intermediates)/vts-generated/include + +# Multi-architecture builds have distinct intermediates directories. +# Thus we'll actually generate source for each architecture. +$(foreach s,$(vts_src),\ + $(eval $(call define-vts-cpp-rule,$(s),$(vts_gen_cpp_root),vts_gen_cpp))) +$(foreach cpp,$(vts_gen_cpp), \ + $(call include-depfile,$(addsuffix .vts.P,$(basename $(cpp))),$(cpp))) +$(call track-src-file-gen,$(vts_src),$(vts_gen_cpp)) + +$(vts_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE) +$(vts_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(vts_gen_include_root) +$(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES)) + +# Add generated headers to include paths. +my_c_includes += $(vts_gen_include_root) +my_export_c_include_dirs += $(vts_gen_include_root) +# Pick up the generated C++ files later for transformation to .o files. +my_generated_sources += $(vts_gen_cpp) + +endif # $(vts_src) non-empty + +########################################################### +## YACC: Compile .y/.yy files to .c/.cpp and then to .o. +########################################################### + +y_yacc_sources := $(filter %.y,$(my_src_files)) +y_yacc_cs := $(addprefix \ + $(intermediates)/,$(y_yacc_sources:.y=.c)) +ifneq ($(y_yacc_cs),) +$(y_yacc_cs): $(intermediates)/%.c: \ + $(TOPDIR)$(LOCAL_PATH)/%.y \ + $(my_additional_dependencies) + $(call transform-y-to-c-or-cpp) +$(call track-src-file-gen,$(y_yacc_sources),$(y_yacc_cs)) + +my_generated_sources += $(y_yacc_cs) +endif + +yy_yacc_sources := $(filter %.yy,$(my_src_files)) +yy_yacc_cpps := $(addprefix \ + $(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION))) +ifneq ($(yy_yacc_cpps),) +$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ + $(TOPDIR)$(LOCAL_PATH)/%.yy \ + $(my_additional_dependencies) + $(call transform-y-to-c-or-cpp) +$(call track-src-file-gen,$(yy_yacc_sources),$(yy_yacc_cpps)) + +my_generated_sources += $(yy_yacc_cpps) +endif + +########################################################### +## LEX: Compile .l/.ll files to .c/.cpp and then to .o. +########################################################### + +l_lex_sources := $(filter %.l,$(my_src_files)) +l_lex_cs := $(addprefix \ + $(intermediates)/,$(l_lex_sources:.l=.c)) +ifneq ($(l_lex_cs),) +$(l_lex_cs): $(intermediates)/%.c: \ + $(TOPDIR)$(LOCAL_PATH)/%.l + $(transform-l-to-c-or-cpp) +$(call track-src-file-gen,$(l_lex_sources),$(l_lex_cs)) + +my_generated_sources += $(l_lex_cs) +endif + +ll_lex_sources := $(filter %.ll,$(my_src_files)) +ll_lex_cpps := $(addprefix \ + $(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION))) +ifneq ($(ll_lex_cpps),) +$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \ + $(TOPDIR)$(LOCAL_PATH)/%.ll + $(transform-l-to-c-or-cpp) +$(call track-src-file-gen,$(ll_lex_sources),$(ll_lex_cpps)) + +my_generated_sources += $(ll_lex_cpps) +endif + +########################################################### +## C++: Compile .cpp files to .o. +########################################################### + +# we also do this on host modules, even though +# it's not really arm, because there are files that are shared. +cpp_arm_sources := $(patsubst %$(LOCAL_CPP_EXTENSION).arm,%$(LOCAL_CPP_EXTENSION),$(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files))) +dotdot_arm_sources := $(filter ../%,$(cpp_arm_sources)) +cpp_arm_sources := $(filter-out ../%,$(cpp_arm_sources)) +cpp_arm_objects := $(addprefix $(intermediates)/,$(cpp_arm_sources:$(LOCAL_CPP_EXTENSION)=.o)) +$(call track-src-file-obj,$(patsubst %,%.arm,$(cpp_arm_sources)),$(cpp_arm_objects)) + +# For source files starting with ../, we remove all the ../ in the object file path, +# to avoid object file escaping the intermediate directory. +dotdot_arm_objects := +$(foreach s,$(dotdot_arm_sources),\ + $(eval $(call compile-dotdot-cpp-file,$(s),\ + $(my_additional_dependencies),\ + dotdot_arm_objects))) +$(call track-src-file-obj,$(patsubst %,%.arm,$(dotdot_arm_sources)),$(dotdot_arm_objects)) + +dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files)) +dotdot_objects := +$(foreach s,$(dotdot_sources),\ + $(eval $(call compile-dotdot-cpp-file,$(s),\ + $(my_additional_dependencies),\ + dotdot_objects))) +$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects)) + +cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files))) +cpp_normal_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o)) +$(call track-src-file-obj,$(cpp_normal_sources),$(cpp_normal_objects)) + +$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) +$(dotdot_arm_objects) $(cpp_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) +$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) +$(dotdot_objects) $(cpp_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) + +cpp_objects := $(cpp_arm_objects) $(cpp_normal_objects) + +ifneq ($(strip $(cpp_objects)),) +$(cpp_objects): $(intermediates)/%.o: \ + $(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)cpp-to-o) +$(call include-depfiles-for-objs, $(cpp_objects)) +endif + +cpp_objects += $(dotdot_arm_objects) $(dotdot_objects) + +########################################################### +## C++: Compile generated .cpp files to .o. +########################################################### + +gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources)) +gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o) +$(call track-gen-file-obj,$(gen_cpp_sources),$(gen_cpp_objects)) + +ifneq ($(strip $(gen_cpp_objects)),) +# Compile all generated files as thumb. +# TODO: support compiling certain generated files as arm. +$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) +$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) +$(gen_cpp_objects): $(intermediates)/%.o: \ + $(intermediates)/%$(LOCAL_CPP_EXTENSION) \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)cpp-to-o) +$(call include-depfiles-for-objs, $(gen_cpp_objects)) +endif + +########################################################### +## S: Compile generated .S and .s files to .o. +########################################################### + +gen_S_sources := $(filter %.S,$(my_generated_sources)) +gen_S_objects := $(gen_S_sources:%.S=%.o) +$(call track-gen-file-obj,$(gen_S_sources),$(gen_S_objects)) + +ifneq ($(strip $(gen_S_sources)),) +$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)s-to-o) +$(call include-depfiles-for-objs, $(gen_S_objects)) +endif + +gen_s_sources := $(filter %.s,$(my_generated_sources)) +gen_s_objects := $(gen_s_sources:%.s=%.o) +$(call track-gen-file-obj,$(gen_s_sources),$(gen_s_objects)) + +ifneq ($(strip $(gen_s_objects)),) +$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)s-to-o-no-deps) +endif + +gen_asm_objects := $(gen_S_objects) $(gen_s_objects) +$(gen_asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) + +########################################################### +## o: Include generated .o files in output. +########################################################### + +gen_o_objects := $(filter %.o,$(my_generated_sources)) + +########################################################### +## C: Compile .c files to .o. +########################################################### + +c_arm_sources := $(patsubst %.c.arm,%.c,$(filter %.c.arm,$(my_src_files))) +dotdot_arm_sources := $(filter ../%,$(c_arm_sources)) +c_arm_sources := $(filter-out ../%,$(c_arm_sources)) +c_arm_objects := $(addprefix $(intermediates)/,$(c_arm_sources:.c=.o)) +$(call track-src-file-obj,$(patsubst %,%.arm,$(c_arm_sources)),$(c_arm_objects)) + +# For source files starting with ../, we remove all the ../ in the object file path, +# to avoid object file escaping the intermediate directory. +dotdot_arm_objects := +$(foreach s,$(dotdot_arm_sources),\ + $(eval $(call compile-dotdot-c-file,$(s),\ + $(my_additional_dependencies),\ + dotdot_arm_objects))) +$(call track-src-file-obj,$(patsubst %,%.arm,$(dotdot_arm_sources)),$(dotdot_arm_objects)) + +dotdot_sources := $(filter ../%.c, $(my_src_files)) +dotdot_objects := +$(foreach s, $(dotdot_sources),\ + $(eval $(call compile-dotdot-c-file,$(s),\ + $(my_additional_dependencies),\ + dotdot_objects))) +$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects)) + +c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files))) +c_normal_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o)) +$(call track-src-file-obj,$(c_normal_sources),$(c_normal_objects)) + +$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_MODE := $(arm_objects_mode) +$(dotdot_arm_objects) $(c_arm_objects): PRIVATE_ARM_CFLAGS := $(arm_objects_cflags) +$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) +$(dotdot_objects) $(c_normal_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) + +c_objects := $(c_arm_objects) $(c_normal_objects) + +ifneq ($(strip $(c_objects)),) +$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)c-to-o) +$(call include-depfiles-for-objs, $(c_objects)) +endif + +c_objects += $(dotdot_arm_objects) $(dotdot_objects) + +########################################################### +## C: Compile generated .c files to .o. +########################################################### + +gen_c_sources := $(filter %.c,$(my_generated_sources)) +gen_c_objects := $(gen_c_sources:%.c=%.o) +$(call track-gen-file-obj,$(gen_c_sources),$(gen_c_objects)) + +ifneq ($(strip $(gen_c_objects)),) +# Compile all generated files as thumb. +# TODO: support compiling certain generated files as arm. +$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode) +$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) +$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)c-to-o) +$(call include-depfiles-for-objs, $(gen_c_objects)) +endif + +########################################################### +## ObjC: Compile .m files to .o +########################################################### + +objc_sources := $(filter %.m,$(my_src_files)) +objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o)) +$(call track-src-file-obj,$(objc_sources),$(objc_objects)) + +ifneq ($(strip $(objc_objects)),) +$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)m-to-o) +$(call include-depfiles-for-objs, $(objc_objects)) +endif + +########################################################### +## ObjC++: Compile .mm files to .o +########################################################### + +objcpp_sources := $(filter %.mm,$(my_src_files)) +objcpp_objects := $(addprefix $(intermediates)/,$(objcpp_sources:.mm=.o)) +$(call track-src-file-obj,$(objcpp_sources),$(objcpp_objects)) + +ifneq ($(strip $(objcpp_objects)),) +$(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)mm-to-o) +$(call include-depfiles-for-objs, $(objcpp_objects)) +endif + +########################################################### +## AS: Compile .S files to .o. +########################################################### + +asm_sources_S := $(filter %.S,$(my_src_files)) +dotdot_sources := $(filter ../%,$(asm_sources_S)) +asm_sources_S := $(filter-out ../%,$(asm_sources_S)) +asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o)) +$(call track-src-file-obj,$(asm_sources_S),$(asm_objects_S)) + +dotdot_objects_S := +$(foreach s,$(dotdot_sources),\ + $(eval $(call compile-dotdot-s-file,$(s),\ + $(my_additional_dependencies),\ + dotdot_objects_S))) +$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_S)) + +ifneq ($(strip $(asm_objects_S)),) +$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)s-to-o) +$(call include-depfiles-for-objs, $(asm_objects_S)) +endif + +asm_sources_s := $(filter %.s,$(my_src_files)) +dotdot_sources := $(filter ../%,$(asm_sources_s)) +asm_sources_s := $(filter-out ../%,$(asm_sources_s)) +asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o)) +$(call track-src-file-obj,$(asm_sources_s),$(asm_objects_s)) + +dotdot_objects_s := +$(foreach s,$(dotdot_sources),\ + $(eval $(call compile-dotdot-s-file-no-deps,$(s),\ + $(my_additional_dependencies),\ + dotdot_objects_s))) +$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_s)) + +ifneq ($(strip $(asm_objects_s)),) +$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \ + $(my_additional_dependencies) + $(transform-$(PRIVATE_HOST)s-to-o-no-deps) +endif + +asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s) +$(asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags) + + +# .asm for x86/x86_64 needs to be compiled with yasm. +asm_sources_asm := $(filter %.asm,$(my_src_files)) +ifneq ($(strip $(asm_sources_asm)),) +asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o)) +$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \ + $(my_additional_dependencies) + $(transform-asm-to-o) +$(call track-src-file-obj,$(asm_sources_asm),$(asm_objects_asm)) + +asm_objects += $(asm_objects_asm) +endif + + +########################################################## +## Set up installed module dependency +## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for +## they may cusomize their install path with LOCAL_MODULE_PATH +########################################################## +# Get the list of INSTALLED libraries as module names. +ifdef LOCAL_SDK_VERSION + installed_shared_library_module_names := \ + $(my_shared_libraries) +else + installed_shared_library_module_names := \ + $(my_shared_libraries) $(my_system_shared_libraries) +endif + +# The real dependency will be added after all Android.mks are loaded and the install paths +# of the shared libraries are determined. +ifdef LOCAL_INSTALLED_MODULE +ifdef installed_shared_library_module_names +$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \ + $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(sort $(installed_shared_library_module_names))) +endif +endif + + +#################################################### +## Import includes +#################################################### +import_includes := $(intermediates)/import_includes +import_includes_deps := $(strip \ + $(foreach l, $(installed_shared_library_module_names), \ + $(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes) \ + $(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \ + $(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes)) +$(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps) +$(import_includes) : $(LOCAL_MODULE_MAKEFILE_DEP) $(import_includes_deps) + @echo Import includes file: $@ + $(hide) mkdir -p $(dir $@) && rm -f $@ +ifdef import_includes_deps + $(hide) for f in $(PRIVATE_IMPORT_EXPORT_INCLUDES); do \ + cat $$f >> $@; \ + done +else + $(hide) touch $@ +endif + +########################################################### +## Common object handling. +########################################################### + +my_unused_src_files := $(filter-out $(logtags_sources) $(my_tracked_src_files),$(my_src_files) $(my_gen_src_files)) +ifneq ($(my_unused_src_files),) + $(warning $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unused_src_files)) +endif + +# some rules depend on asm_objects being first. If your code depends on +# being first, it's reasonable to require it to be assembly +normal_objects := \ + $(asm_objects) \ + $(cpp_objects) \ + $(gen_cpp_objects) \ + $(gen_asm_objects) \ + $(c_objects) \ + $(gen_c_objects) \ + $(objc_objects) \ + $(objcpp_objects) + +new_order_normal_objects := $(foreach f,$(my_src_files),$(my_src_file_obj_$(f))) +new_order_normal_objects += $(foreach f,$(my_gen_src_files),$(my_src_file_obj_$(f))) + +ifneq ($(sort $(normal_objects)),$(sort $(new_order_normal_objects))) +$(warning $(LOCAL_MODULE_MAKEFILE) Internal build system warning: New object list does not match old) +$(info Only in old: $(filter-out $(new_order_normal_objects),$(sort $(normal_objects)))) +$(info Only in new: $(filter-out $(normal_objects),$(sort $(new_order_normal_objects)))) +endif + +ifeq ($(BINARY_OBJECTS_ORDER),soong) +normal_objects := $(new_order_normal_objects) +endif + +normal_objects += $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES)) + +all_objects := $(normal_objects) $(gen_o_objects) + +# Cleanup file tracking +$(foreach f,$(my_tracked_gen_files),$(eval my_src_file_gen_$(s):=)) +my_tracked_gen_files := +$(foreach f,$(my_tracked_src_files),$(eval my_src_file_obj_$(s):=)) +my_tracked_src_files := + +my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir) + +ifndef LOCAL_SDK_VERSION + my_c_includes += $(JNI_H_INCLUDE) +endif + +# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES; +# use normal_objects here to avoid creating circular dependencies. This assumes +# that custom build rules which generate .o files don't consume other generated +# sources as input (or if they do they take care of that dependency themselves). +$(normal_objects) : | $(my_generated_sources) +ifeq ($(BUILDING_WITH_NINJA),true) +$(all_objects) : $(import_includes) +else +$(all_objects) : | $(import_includes) +endif +ALL_C_CPP_ETC_OBJECTS += $(all_objects) + + +########################################################### +# Standard library handling. +########################################################### + +########################################################### +# The list of libraries that this module will link against are in +# these variables. Each is a list of bare module names like "libc libm". +# +# LOCAL_SHARED_LIBRARIES +# LOCAL_STATIC_LIBRARIES +# LOCAL_WHOLE_STATIC_LIBRARIES +# +# We need to convert the bare names into the dependencies that +# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE. +# LOCAL_BUILT_MODULE should depend on the BUILT versions of the +# libraries, so that simply building this module doesn't force +# an install of a library. Similarly, LOCAL_INSTALLED_MODULE +# should depend on the INSTALLED versions of the libraries so +# that they get installed when this module does. +########################################################### +# NOTE: +# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the +# module without leaving anything out, which is useful for turning +# a collection of .a files into a .so file. Linking against a +# normal STATIC_LIBRARY will only pull in code/symbols that are +# referenced by the module. (see gcc/ld's --whole-archive option) +########################################################### + +# Get the list of BUILT libraries, which are under +# various intermediates directories. +so_suffix := $($(my_prefix)SHLIB_SUFFIX) +a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX) + +ifdef LOCAL_SDK_VERSION +built_shared_libraries := \ + $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ + $(addsuffix $(so_suffix), \ + $(my_shared_libraries))) +built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries)) + +# Add the NDK libraries to the built module dependency +my_system_shared_libraries_fullpath := \ + $(my_ndk_stl_shared_lib_fullpath) \ + $(addprefix $(my_ndk_sysroot_lib)/, \ + $(addsuffix $(so_suffix), $(my_system_shared_libraries))) + +built_shared_libraries += $(my_system_shared_libraries_fullpath) +else +built_shared_libraries := \ + $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ + $(addsuffix $(so_suffix), \ + $(installed_shared_library_module_names))) +ifdef LOCAL_IS_HOST_MODULE +# Disable .toc optimization for host modules: we may run the host binaries during the build process +# and the libraries' implementation matters. +built_shared_library_deps := $(built_shared_libraries) +else +built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries)) +endif +my_system_shared_libraries_fullpath := +endif + +built_static_libraries := \ + $(foreach lib,$(my_static_libraries), \ + $(call intermediates-dir-for, \ + STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) + +ifdef LOCAL_SDK_VERSION +built_static_libraries += $(my_ndk_stl_static_lib) +endif + +built_whole_libraries := \ + $(foreach lib,$(my_whole_static_libraries), \ + $(call intermediates-dir-for, \ + STATIC_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix)) + +# We don't care about installed static libraries, since the +# libraries have already been linked into the module at that point. +# We do, however, care about the NOTICE files for any static +# libraries that we use. (see notice_files.mk) + +installed_static_library_notice_file_targets := \ + $(foreach lib,$(my_static_libraries) $(my_whole_static_libraries), \ + NOTICE-$(if $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-STATIC_LIBRARIES-$(lib)) + +# Default is -fno-rtti. +ifeq ($(strip $(LOCAL_RTTI_FLAG)),) +LOCAL_RTTI_FLAG := -fno-rtti +endif + +########################################################### +# Rule-specific variable definitions +########################################################### + +ifeq ($(my_clang),true) +my_cflags += $(LOCAL_CLANG_CFLAGS) +my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS) +my_cppflags += $(LOCAL_CLANG_CPPFLAGS) +my_cflags_no_override += $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE) +my_cppflags_no_override += $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE) +my_asflags += $(LOCAL_CLANG_ASFLAGS) +my_ldflags += $(LOCAL_CLANG_LDFLAGS) +my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix)) +my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix)) +my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix)) +my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix)) +my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix)) +my_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cflags)) +my_cppflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_cppflags)) +my_asflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_asflags)) +my_ldflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(my_ldflags)) +endif + +ifeq ($(my_fdo_build), true) + my_cflags := $(patsubst -Os,-O2,$(my_cflags)) + fdo_incompatible_flags := -fno-early-inlining -finline-limit=% + my_cflags := $(filter-out $(fdo_incompatible_flags),$(my_cflags)) +endif + +# No one should ever use this flag. On GCC it's mere presence will disable all +# warnings, even those that are specified after it (contrary to typical warning +# flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the +# warnings that are *always* bugs. +my_illegal_flags := -w +my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags)) +my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags)) +my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags)) + +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORT_INCLUDES := $(import_includes) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs) + +# this is really the way to get the files onto the command line instead +# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries) +$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects) + +########################################################### +# Define library dependencies. +########################################################### +# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE. +all_libraries := \ + $(built_shared_library_deps) \ + $(my_system_shared_libraries_fullpath) \ + $(built_static_libraries) \ + $(built_whole_libraries) + +# Also depend on the notice files for any static libraries that +# are linked into this module. This will force them to be installed +# when this module is. +$(LOCAL_INSTALLED_MODULE): | $(installed_static_library_notice_file_targets) + +########################################################### +# Export includes +########################################################### +export_includes := $(intermediates)/export_includes +$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs) +# By adding $(my_generated_sources) it makes sure the headers get generated +# before any dependent source files get compiled. +$(export_includes) : $(my_generated_sources) $(export_include_deps) + @echo Export includes file: $< -- $@ + $(hide) mkdir -p $(dir $@) && rm -f $@.tmp +ifdef my_export_c_include_dirs + $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \ + echo "-I $$d" >> $@.tmp; \ + done +else + $(hide) touch $@.tmp +endif +ifeq ($(BUILDING_WITH_NINJA),true) + $(hide) if cmp -s $@.tmp $@ ; then \ + rm $@.tmp ; \ + else \ + mv $@.tmp $@ ; \ + fi +else + mv $@.tmp $@ ; +endif + +# Kati adds restat=1 to ninja. GNU make does nothing for this. +.KATI_RESTAT: $(export_includes) + +# Make sure export_includes gets generated when you are running mm/mmm +$(LOCAL_BUILT_MODULE) : | $(export_includes) diff --git a/core/build-system.html b/core/build-system.html new file mode 100644 index 0000000000000000000000000000000000000000..bddde6a4de45aa140da7196defe9f33734f0c651 --- /dev/null +++ b/core/build-system.html @@ -0,0 +1,953 @@ + + + + + + + + Android Build System + + + + + + + + + + + + + + + +

Android Build System

+ + +

+ Status: Draft   + (as of May 18, 2006) +

+ +

Contents

+ + + +

Objective

+

The primary goals of reworking the build system are (1) to make dependencies +work more reliably, so that when files need to rebuilt, they are, and (2) to +improve performance of the build system so that unnecessary modules are not +rebuilt, and so doing a top-level build when little or nothing needs to be done +for a build takes as little time as possible.

+ +

Principles and Use Cases and Policy

+

Given the above objective, these are the overall principles and use cases +that we will support. This is not an exhaustive list.

+

Multiple Targets

+

It needs to be possible to build the Android platform for multiple targets. +This means:

+
    +
  • The build system will support building tools for the host platform, + both ones that are used in the build process itself, and developer tools + like the simulator.
  • +
  • The build system will need to be able to build tools on Linux + (definitely Goobuntu and maybe Grhat), MacOS, and to some degree on + Windows.
  • +
  • The build system will need to be able to build the OS on Linux, and in + the short-term, MacOS. Note that this is a conscious decision to stop + building the OS on Windows. We are going to rely on the emulator there + and not attempt to use the simulator. This is a requirement change now + that the emulator story is looking brighter.
  • +
+

Non-Recursive Make

+

To achieve the objectives, the build system will be rewritten to use make +non-recursively. For more background on this, read Recursive Make Considered Harmful. For those that don't +want PDF, here is the +Google translated version. +

Rapid Compile-Test Cycles

+

When developing a component, for example a C++ shared library, it must be +possible to easily rebuild just that component, and not have to wait more than a +couple seconds for dependency checks, and not have to wait for unneeded +components to be built.

+

Both Environment and Config File Based Settings

+

To set the target, and other options, some people on the team like to have a +configuration file in a directory so they do not have an environment setup +script to run, and others want an environment setup script to run so they can +run builds in different terminals on the same tree, or switch back and forth +in one terminal. We will support both.

+

Object File Directory / make clean

+

Object files and other intermediate files will be generated into a directory +that is separate from the source tree. The goal is to have make clean be +"rm -rf " in the tree root directory. The primary goals of +this are to simplify searching the source tree, and to make "make clean" more +reliable.

+ +

SDK

+

The SDK will be a tarball that will allow non-OS-developers to write apps. +The apps will actually be built by first building the SDK, and then building +the apps against that SDK. This will hopefully (1) make writing apps easier +for us, because we won't have to rebuild the OS as much, and we can use the +standard java-app development tools, and (2) allow us to dog-food the SDK, to +help ensure its quality. Cedric has suggested (and I agree) that apps built +from the SDK should be built with ant. Stay tuned for more details as we +figure out exactly how this will work.

+ +

Dependecies

+

Dependencies should all be automatic. Unless there is a custom tool involved +(e.g. the webkit has several), the dependencies for shared and static libraries, +.c, .cpp, .h, .java, java libraries, etc., should all work without intervention +in the Android.mk file.

+ +

Hiding command lines

+

The default of the build system will be to hide the command lines being +executed for make steps. It will be possible to override this by specifying +the showcommands pseudo-target, and possibly by setting an environment +variable.

+ +

Wildcard source files

+

Wildcarding source file will be discouraged. It may be useful in some +scenarios. The default $(wildcard *) will not work due to the +current directory being set to the root of the build tree.

+ +

Multiple targets in one directory

+

It will be possible to generate more than one target from a given +subdirectory. For example, libutils generates a shared library for the target +and a static library for the host.

+ +

Makefile fragments for modules

+

Android.mk is the standard name for the makefile fragments that +control the building of a given module. Only the top directory should +have a file named "Makefile".

+ +

Use shared libraries

+

Currently, the simulator is not built to use shared libraries. This should +be fixed, and now is a good time to do it. This implies getting shared +libraries to work on Mac OS.

+ + +

Nice to Have

+ +

These things would be nice to have, and this is a good place to record them, +however these are not promises.

+ +

Simultaneous Builds

+

The hope is to be able to do two builds for different combos in the same +tree at the same time, but this is a stretch goal, not a requirement. +Doing two builds in the same tree, not at the same time must work. (update: +it's looking like we'll get the two builds at the same time working)

+ +

Deleting headers (or other dependecies)

+

Problems can arise if you delete a header file that is referenced in +".d" files. The easy way to deal with this is "make clean". There +should be a better way to handle it. (from fadden)

+

One way of solving this is introducing a dependency on the directory. The +problem is that this can create extra dependecies and slow down the build. +It's a tradeoff.

+ +

Multiple builds

+

General way to perform builds across the set of known platforms. This +would make it easy to perform multiple platform builds when testing a +change, and allow a wide-scale "make clean". Right now the buildspec.mk +or environment variables need to be updated before each build. (from fadden)

+ +

Aftermarket Locales and Carrier

+

We will eventually need to add support for creating locales and carrier +customizations to the SDK, but that will not be addressed right now.

+ + +

Usage

+

You've read (or scrolled past) all of the motivations for this build system, +and you want to know how to use it. This is the place.

+ +

Your first build

+

The Building document describes how do do +builds.

+ +

build/envsetup.sh functions

+If you source the file build/envsetup.sh into your bash environment, +. build/envsetup.shyou'll get a few helpful shell functions: + +
    +
  • printconfig - Prints the current configuration as set by the +lunch and choosecombo commands.
  • +
  • m - Runs make from the top of the tree. This is +useful because you can run make from within subdirectories. If you have the +TOP environment variable set, it uses that. If you don't, it looks +up the tree from the current directory, trying to find the top of the tree.
  • +
  • croot - cd to the top of the tree.
  • +
  • sgrep - grep for the regex you provide in all .c, .cpp, .h, .java, +and .xml files below the current directory.
  • +
+ +

Build flavors/types

+

+When building for a particular product, it's often useful to have minor +variations on what is ultimately the final release build. These are the +currently-defined "flavors" or "types" (we need to settle on a real name +for these). +

+ + + + + + + + + + + + + + +
+ eng + + This is the default flavor. A plain "make" is the + same as "make eng". droid is an alias + for eng. +
    +
  • Installs modules tagged with: eng, debug, + user, and/or development. +
  • Installs non-APK modules that have no tags specified. +
  • Installs APKs according to the product definition files, in + addition to tagged APKs. +
  • ro.secure=0 +
  • ro.debuggable=1 +
  • ro.kernel.android.checkjni=1 +
  • adb is enabled by default. +
+ user + + "make user" +

+ This is the flavor intended to be the final release bits. +

    +
  • Installs modules tagged with user. +
  • Installs non-APK modules that have no tags specified. +
  • Installs APKs according to the product definition files; tags + are ignored for APK modules. +
  • ro.adb.secure=1 +
  • ro.secure=1 +
  • ro.debuggable=0 +
  • adb is disabled by default. +
+ userdebug + + "make userdebug" +

+ The same as user, except: +

    +
  • Also installs modules tagged with debug. +
  • ro.debuggable=1 +
  • adb is enabled by default. +
+ +

+If you build one flavor and then want to build another, you should run +"make installclean" between the two makes to guarantee that +you don't pick up files installed by the previous flavor. "make +clean" will also suffice, but it takes a lot longer. +

+ + +

More pseudotargets

+

Sometimes you want to just build one thing. The following pseudotargets are +there for your convenience:

+ +
    +
  • droid - make droid is the normal build. This target +is here because the default target has to have a name.
  • +
  • all - make all builds everything make +droid does, plus everything whose LOCAL_MODULE_TAGS do not +include the "droid" tag. The build server runs this to make sure +that everything that is in the tree and has an Android.mk builds.
  • +
  • clean-$(LOCAL_MODULE) and clean-$(LOCAL_PACKAGE_NAME) - +Let you selectively clean one target. For example, you can type +make clean-libutils and it will delete libutils.so and all of the +intermediate files, or you can type make clean-Home and it will +clean just the Home app.
  • +
  • clean - make clean deletes all of the output and +intermediate files for this configuration. This is the same as rm -rf +out/<configuration>/
  • +
  • clobber - make clobber deletes all of the output +and intermediate files for all configurations. This is the same as +rm -rf out/.
  • +
  • dataclean - make dataclean deletes contents of the data +directory inside the current combo directory. This is especially useful on the +simulator and emulator, where the persistent data remains present between +builds.
  • +
  • showcommands - showcommands is a modifier target +which causes the build system to show the actual command lines for the build +steps, instead of the brief descriptions. Most people don't like seeing the +actual commands, because they're quite long and hard to read, but if you need +to for debugging purposes, you can add showcommands to the list +of targets you build. For example make showcommands will build +the default android configuration, and make runtime showcommands +will build just the runtime, and targets that it depends on, while displaying +the full command lines. Please note that there are a couple places where the +commands aren't shown here. These are considered bugs, and should be fixed, +but they're often hard to track down. Please let +android-build-team know if you find +any.
  • +
  • LOCAL_MODULE - Anything you specify as a LOCAL_MODULE +in an Android.mk is made into a pseudotarget. For example, make +runtime might be shorthand for make +out/linux-x86-debug/system/bin/runtime (which would work), and +make libkjs might be shorthand for make +out/linux-x86-debug/system/lib/libkjs.so (which would also work).
  • +
  • targets - make targets will print a list of all of +the LOCAL_MODULE names you can make.
  • +
+ +

How to add another component to the build - Android.mk templates

+

You have a new library, a new app, or a new executable. For each of the +common types of modules, there is a corresponding file in the templates +directory. It will usually be enough to copy one of these, and fill in your +own values. Some of the more esoteric values are not included in the +templates, but are instead just documented here, as is the documentation +on using custom tools to generate files.

+

Mostly, you can just look for the TODO comments in the templates and do +what it says. Please remember to delete the TODO comments when you're done +to keep the files clean. The templates have minimal documentation in them, +because they're going to be copied, and when that gets stale, the copies just +won't get updated. So read on...

+ +

Apps

+

Use the templates/apps file.

+

This template is pretty self-explanitory. See the variables below for more +details.

+ +

Java Libraries

+

Use the templates/java_library file.

+

The interesting thing here is the value of LOCAL_MODULE, which becomes +the name of the jar file. (Actually right now, we're not making jar files yet, +just directories of .class files, but the directory is named according to +what you put in LOCAL_MODULE). This name will be what goes in the +LOCAL_JAVA_LIBRARIES variable in modules that depend on your java library.

+ +

C/C++ Executables

+

Use the templates/executable file, or the +templates/executable_host file.

+

This template has a couple extra options that you usually don't need. +Please delete the ones you don't need, and remove the TODO comments. It makes +the rest of them easier to read, and you can always refer back to the templates +if you need them again later.

+

By default, on the target these are built into /system/bin, and on the +host, they're built into /host/bin. These can be overridden by setting +LOCAL_MODULE_PATH or LOCAL_MODULE_RELATIVE_PATH. See +Putting targets elsewhere +for more.

+ +

Shared Libraries

+

Use the templates/shared_library file, or the +templates/shared_library_host file.

+

Remember that on the target, we use shared libraries, and on the host, +we use static libraries, since executable size isn't as big an issue, and it +simplifies distribution in the SDK.

+ +

Static Libraries

+

Use the templates/static_library file, or the +templates/static_library_host file.

+

Remember that on the target, we use shared libraries, and on the host, +we use static libraries, since executable size isn't as big an issue, and it +simplifies distribution in the SDK.

+ +

Using Custom Tools

+

If you have a tool that generates source files for you, it's possible +to have the build system get the dependencies correct for it. Here are +a couple of examples. $@ is the make built-in variable for +"the current target." The red parts are the parts you'll +need to change.

+ +

You need to put this after you have declared LOCAL_PATH and +LOCAL_MODULE, because the $(local-generated-sources-dir) +and $(local-host-generated-sources-dir) macros use these variables +to determine where to put the files. + +

Example 1
+

Here, there is one generated file, called +chartables.c, which doesn't depend on anything. And is built by the tool +built to $(HOST_OUT_EXECUTABLES)/dftables. Note on the second to last line +that a dependency is created on the tool.

+
+intermediates:= $(local-generated-sources-dir)
+GEN := $(intermediates)/chartables.c
+$(GEN): PRIVATE_CUSTOM_TOOL = $(HOST_OUT_EXECUTABLES)/dftables $@
+$(GEN): $(HOST_OUT_EXECUTABLES)/dftables
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+ +
Example 2
+

Here as a hypothetical example, we use use cat as if it were to transform +a file. Pretend that it does something useful. Note how we use a +target-specific variable called PRIVATE_INPUT_FILE to store the name of the +input file.

+
+intermediates:= $(local-generated-sources-dir)
+GEN := $(intermediates)/file.c
+$(GEN): PRIVATE_INPUT_FILE := $(LOCAL_PATH)/input.file
+$(GEN): PRIVATE_CUSTOM_TOOL = cat $(PRIVATE_INPUT_FILE) > $@
+$(GEN): $(LOCAL_PATH)/file.c
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+ +
Example 3
+

If you have several files that are all similar in +name, and use the same tool, you can combine them. (here the *.lut.h files are +the generated ones, and the *.cpp files are the input files)

+
+intermediates:= $(local-generated-sources-dir)
+GEN := $(addprefix $(intermediates)/kjs/, \
+            array_object.lut.h \
+            bool_object.lut.h \
+        )
+$(GEN): PRIVATE_CUSTOM_TOOL = perl libs/WebKitLib/WebKit/JavaScriptCore/kjs/create_hash_table $< -i > $@
+$(GEN): $(intermediates)/%.lut.h : $(LOCAL_PATH)/%.cpp
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+ +

Platform specific conditionals

+

Sometimes you need to set flags specifically for different platforms. Here +is a list of which values the different build-system defined variables will be +set to and some examples.

+ + + + + + + + + + +
+ HOST_OS
+ linux
+ darwin +
+ HOST_ARCH
+ x86
+ x86_64 +
+ HOST_BUILD_TYPE
+ release
+ debug +
+ TARGET_ARCH
+ arm
+ arm64
+ mips
+ mips64
+ x86
+ x86_64 +
+ TARGET_BUILD_TYPE
+ release
+ debug +
+ +

There are also special variables to use instead of conditionals. Many of the +normal variables (LOCAL_SRC_FILES, LOCAL_CFLAGS, etc) can be conditionally added +to with _{arch} _{32|64}, and for the host, _{os}.

+ +

Some Examples

+
ifeq ($(TARGET_BUILD_TYPE),release)
+LOCAL_CFLAGS += -DNDEBUG=1
+endif
+
+LOCAL_CFLAGS_arm += -DTARGET_IS_ARM
+
+LOCAL_CFLAGS_64 += -DBIG_POINTER
+
+# from libutils
+# Use the futex based mutex and condition variable
+# implementation from android-arm because it's shared mem safe
+LOCAL_SRC_FILES_linux += futex_synchro.c
+LOCAL_LDLIBS_linux += -lrt -ldl
+
+
+ + +

Putting modules elsewhere

+

If you have modules that normally go somewhere, and you need to have them +build somewhere else, read this.

+

If you have modules that need to go in a subdirectory of their normal +location, for example HAL modules that need to go in /system/lib/hw or +/vendor/lib/hw, set LOCAL_MODULE_RELATIVE_PATH in your Android.mk, for +example:

+
+LOCAL_MODULE_RELATIVE_PATH := hw
+
+

If you have modules that need to go in an entirely different location, for +example the root filesystem instead of in /system, add these lines to your +Android.mk:

+
+LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT_SBIN)
+LOCAL_UNSTRIPPED_PATH := $(TARGET_ROOT_OUT_SBIN_UNSTRIPPED)
+
+

For executables and libraries, you need to specify a +LOCAL_UNSTRIPPED_PATH location if you specified a +LOCAL_MODULE_PATH, because on target builds, we keep +the unstripped executables so GDB can find the symbols. +LOCAL_UNSTRIPPED_PATH is not necessary if you only specified +LOCAL_MODULE_RELATIVE_PATH.

+

Look in core/envsetup.mk for all of the variables defining +places to build things.

+

FYI: If you're installing an executable to /sbin, you probably also want to +set LOCAL_FORCE_STATIC_EXCUTABLE := true in your Android.mk, which +will force the linker to only accept static libraries.

+ + +

Android.mk variables

+

These are the variables that you'll commonly see in Android.mk files, listed +alphabetically.

+

But first, a note on variable naming: +

+

+ +

LOCAL_ASSET_FILES

+

In Android.mk files that include $(BUILD_PACKAGE) set this +to the set of files you want built into your app. Usually:

+

LOCAL_ASSET_FILES += $(call find-subdir-assets)

+

This will probably change when we switch to ant for the apps' build +system.

+ +

LOCAL_CC

+

If you want to use a different C compiler for this module, set LOCAL_CC +to the path to the compiler. If LOCAL_CC is blank, the appropriate default +compiler is used.

+ +

LOCAL_CXX

+

If you want to use a different C++ compiler for this module, set LOCAL_CXX +to the path to the compiler. If LOCAL_CXX is blank, the appropriate default +compiler is used.

+ +

LOCAL_CFLAGS

+

If you have additional flags to pass into the C or C++ compiler, add +them here. For example:

+

LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1

+ +

LOCAL_CPPFLAGS

+

If you have additional flags to pass into only the C++ compiler, add +them here. For example:

+

LOCAL_CPPFLAGS += -ffriend-injection

+LOCAL_CPPFLAGS is guaranteed to be after LOCAL_CFLAGS +on the compile line, so you can use it to override flags listed in +LOCAL_CFLAGS. + +

LOCAL_CPP_EXTENSION

+

If your C++ files end in something other than ".cpp", +you can specify the custom extension here. For example:

+

LOCAL_CPP_EXTENSION := .cc

+Note that all C++ files for a given module must have the same +extension; it is not currently possible to mix different extensions. + +

LOCAL_NO_DEFAULT_COMPILER_FLAGS

+

Normally, the compile line for C and C++ files includes global include +paths and global cflags. If LOCAL_NO_DEFAULT_COMPILER_FLAGS +is non-empty, none of the default includes or flags will be used when compiling +C and C++ files in this module. +LOCAL_C_INCLUDES, LOCAL_CFLAGS, and +LOCAL_CPPFLAGS will still be used in this case, as will +any DEBUG_CFLAGS that are defined for the module. + +

LOCAL_COPY_HEADERS

+

This will be going away.

+

The set of files to copy to the install include tree. You must also +supply LOCAL_COPY_HEADERS_TO.

+

This is going away because copying headers messes up the error messages, and +may lead to people editing those headers instead of the correct ones. It also +makes it easier to do bad layering in the system, which we want to avoid. We +also aren't doing a C/C++ SDK, so there is no ultimate requirement to copy any +headers.

+ +

LOCAL_COPY_HEADERS_TO

+

This will be going away.

+

The directory within "include" to copy the headers listed in +LOCAL_COPY_HEADERS to.

+

This is going away because copying headers messes up the error messages, and +may lead to people editing those headers instead of the correct ones. It also +makes it easier to do bad layering in the system, which we want to avoid. We +also aren't doing a C/C++ SDK, so there is no ultimate requirement to copy any +headers.

+ +

LOCAL_C_INCLUDES

+

Additional directories to instruct the C/C++ compilers to look for header +files in. These paths are rooted at the top of the tree. Use +LOCAL_PATH if you have subdirectories of your own that you +want in the include paths. For example:

+

+LOCAL_C_INCLUDES += extlibs/zlib-1.2.3
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/src +

+

You should not add subdirectories of include to +LOCAL_C_INCLUDES, instead you should reference those files +in the #include statement with their subdirectories. For +example:

+

#include <utils/KeyedVector.h>
+not #include <KeyedVector.h>

+

There are some components that are doing this wrong, and should be cleaned +up.

+ +

LOCAL_MODULE_TAGS

+

Set LOCAL_MODULE_TAGS to any number of whitespace-separated +tags. If the tag list is empty or contains droid, the module +will get installed as part of a make droid. Otherwise, it will +only get installed by running make <your-module> +or with the make all pseudotarget.

+ +

LOCAL_REQUIRED_MODULES

+

Set LOCAL_REQUIRED_MODULES to any number of whitespace-separated +module names, like "libblah" or "Email". If this module is installed, all +of the modules that it requires will be installed as well. This can be +used to, e.g., ensure that necessary shared libraries or providers are +installed when a given app is installed. + +

LOCAL_FORCE_STATIC_EXECUTABLE

+

If your executable should be linked statically, set +LOCAL_FORCE_STATIC_EXECUTABLE:=true. There is a very short +list of libraries that we have in static form (currently only libc). This is +really only used for executables in /sbin on the root filesystem.

+ +

LOCAL_GENERATED_SOURCES

+

Files that you add to LOCAL_GENERATED_SOURCES will be +automatically generated and then linked in when your module is built. +See the Custom Tools template makefile for an +example.

+ +

LOCAL_JAVACFLAGS

+

If you have additional flags to pass into the javac compiler, add +them here. For example:

+

LOCAL_JAVACFLAGS += -Xlint:deprecation

+ +

LOCAL_JAVA_LIBRARIES

+

When linking Java apps and libraries, LOCAL_JAVA_LIBRARIES +specifies which sets of java classes to include. Currently there are +two of these: core and framework. +In most cases, it will look like this:

+

LOCAL_JAVA_LIBRARIES := core framework

+

Note that setting LOCAL_JAVA_LIBRARIES is not necessary +(and is not allowed) when building an APK with +"include $(BUILD_PACKAGE)". The appropriate libraries +will be included automatically.

+ +

LOCAL_LDFLAGS

+

You can pass additional flags to the linker by setting +LOCAL_LDFLAGS. Keep in mind that the order of parameters is +very important to ld, so test whatever you do on all platforms.

+ +

LOCAL_LDLIBS

+

LOCAL_LDLIBS allows you to specify additional libraries +that are not part of the build for your executable or library. Specify +the libraries you want in -lxxx format; they're passed directly to the +link line. However, keep in mind that there will be no dependency generated +for these libraries. It's most useful in simulator builds where you want +to use a library preinstalled on the host. The linker (ld) is a particularly +fussy beast, so it's sometimes necessary to pass other flags here if you're +doing something sneaky. Some examples:

+

LOCAL_LDLIBS += -lcurses -lpthread
+LOCAL_LDLIBS += -Wl,-z,origin +

+ +

LOCAL_NO_MANIFEST

+

If your package doesn't have a manifest (AndroidManifest.xml), then +set LOCAL_NO_MANIFEST:=true. The common resources package +does this.

+ +

LOCAL_PACKAGE_NAME

+

LOCAL_PACKAGE_NAME is the name of an app. For example, +Dialer, Contacts, etc. This will probably change or go away when we switch +to an ant-based build system for the apps.

+ +

LOCAL_PATH

+

The directory your Android.mk file is in. You can set it by putting the +following as the first line in your Android.mk:

+

LOCAL_PATH := $(my-dir)

+

The my-dir macro uses the +MAKEFILE_LIST +variable, so you must call it before you include any other makefiles. Also, +consider that any subdirectories you inlcude might reset LOCAL_PATH, so do your +own stuff before you include them. This also means that if you try to write +several include lines that reference LOCAL_PATH, +it won't work, because those included makefiles might reset LOCAL_PATH. + +

LOCAL_POST_PROCESS_COMMAND

+

For host executables, you can specify a command to run on the module +after it's been linked. You might have to go through some contortions +to get variables right because of early or late variable evaluation:

+

module := $(HOST_OUT_EXECUTABLES)/$(LOCAL_MODULE)
+LOCAL_POST_PROCESS_COMMAND := /Developer/Tools/Rez -d __DARWIN__ -t APPL\
+       -d __WXMAC__ -o $(module) Carbon.r +

+ +

LOCAL_PREBUILT_EXECUTABLES

+

When including $(BUILD_MULTI_PREBUILT) or $(BUILD_HOST_PREBUILT), set these +to executables that you want copied. They're located automatically into the +right bin directory.

+ +

LOCAL_PREBUILT_LIBS

+

When including $(BUILD_MULTI_PREBUILT) or $(BUILD_HOST_PREBUILT), set these +to libraries that you want copied. They're located automatically into the +right lib directory.

+ +

LOCAL_SHARED_LIBRARIES

+

These are the libraries you directly link against. You don't need to +pass transitively included libraries. Specify the name without the suffix:

+

LOCAL_SHARED_LIBRARIES := \
+     libutils \
+     libui \
+     libaudio \
+     libexpat \
+     libsgl +

+ +

LOCAL_SRC_FILES

+

The build system looks at LOCAL_SRC_FILES to know what source +files to compile -- .cpp .c .y .l .java. For lex and yacc files, it knows +how to correctly do the intermediate .h and .c/.cpp files automatically. If +the files are in a subdirectory of the one containing the Android.mk, prefix +them with the directory name:

+

LOCAL_SRC_FILES := \
+     file1.cpp \
+     dir/file2.cpp +

+ +

LOCAL_STATIC_LIBRARIES

+

These are the static libraries that you want to include in your module. +Mostly, we use shared libraries, but there are a couple of places, like +executables in sbin and host executables where we use static libraries instead. +

LOCAL_STATIC_LIBRARIES := \
+     libutils \
+     libtinyxml +

+ +

LOCAL_MODULE

+

LOCAL_MODULE is the name of what's supposed to be generated +from your Android.mk. For exmample, for libkjs, the LOCAL_MODULE +is "libkjs" (the build system adds the appropriate suffix -- .so .dylib .dll). +For app modules, use LOCAL_PACKAGE_NAME instead of +LOCAL_MODULE. We're planning on switching to ant for the apps, +so this might become moot.

+ +

LOCAL_MODULE_PATH

+

Instructs the build system to put the module somewhere other than what's +normal for its type. If you override this, make sure you also set +LOCAL_UNSTRIPPED_PATH if it's an executable or a shared library +so the unstripped binary has somewhere to go. An error will occur if you forget +to.

+

See Putting modules elsewhere for more.

+ +

LOCAL_MODULE_RELATIVE_PATH

+

Instructs the build system to put the module in a subdirectory under the +directory that is normal for its type. If you set this you do not need to +set LOCAL_UNSTRIPPED_PATH, the unstripped binaries will also use +the relative path.

+

See Putting modules elsewhere for more.

+ +

LOCAL_MODULE_HOST_OS

+

This specifies which OSes are supported by this host module. It is not used +for target builds. The accepted values here are combinations of +linux, darwin, and windows. By default, +linux and darwin(MacOS) are considered to be supported. If a module should +build under windows, you must specify windows, and any others to be supported. +Some examples:

+

LOCAL_MODULE_HOST_OS := linux
+LOCAL_MODULE_HOST_OS := darwin linux windows

+ +

LOCAL_UNSTRIPPED_PATH

+

Instructs the build system to put the unstripped version of the module +somewhere other than what's normal for its type. Usually, you override this +because you overrode LOCAL_MODULE_PATH for an executable or a +shared library. If you overrode LOCAL_MODULE_PATH, but not +LOCAL_UNSTRIPPED_PATH, an error will occur.

+

See Putting modules elsewhere for more.

+ +

LOCAL_WHOLE_STATIC_LIBRARIES

+

These are the static libraries that you want to include in your module without allowing +the linker to remove dead code from them. This is mostly useful if you want to add a static library +to a shared library and have the static library's content exposed from the shared library. +

LOCAL_WHOLE_STATIC_LIBRARIES := \
+     libsqlite3_android
+

+ +

LOCAL_YACCFLAGS

+

Any flags to pass to invocations of yacc for your module. A known limitation +here is that the flags will be the same for all invocations of YACC for your +module. This can be fixed. If you ever need it to be, just ask.

+

LOCAL_YACCFLAGS := -p kjsyy

+ + + +

Implementation Details

+ +

You should never have to touch anything in the config directory unless +you're adding a new platform, new tools, or adding new features to the +build system. In general, please consult with the build system owner(s) +(android-build-team) before you go +mucking around in here. That said, here are some notes on what's going on +under the hood.

+ +

Environment Setup / buildspec.mk Versioning

+

In order to make easier for people when the build system changes, when +it is necessary to make changes to buildspec.mk or to rerun the environment +setup scripts, they contain a version number in the variable +BUILD_ENV_SEQUENCE_NUMBER. If this variable does not match what the build +system expects, it fails printing an error message explaining what happened. +If you make a change that requires an update, you need to update two places +so this message will be printed. +

    +
  • In core/envsetup.mk, increment the + CORRECT_BUILD_ENV_SEQUENCE_NUMBER definition.
  • +
  • In buildspec.mk.default, update the BUILD_ENV_SEQUENCE_DUMBER + definition to match the one in core/envsetup.mk
  • +
+The scripts automatically get the value from the build system, so they will +trigger the warning as well. +

+ +

Additional makefile variables

+

You probably shouldn't use these variables. Please consult +android-build-team before using them. +These are mostly there for workarounds for other issues, or things that aren't +completely done right.

+ +

LOCAL_ADDITIONAL_DEPENDENCIES

+

If your module needs to depend on anything else that +isn't actually built in to it, you can add those make targets to +LOCAL_ADDITIONAL_DEPENDENCIES. Usually this is a workaround +for some other dependency that isn't created automatically.

+ +

LOCAL_BUILT_MODULE

+

This should not be used, since multiple binaries are now +created from a single module defintiion.

+

When a module is built, the module is created in an intermediate +directory then copied to its final location. LOCAL_BUILT_MODULE is +the full path to the intermediate file. See LOCAL_INSTALLED_MODULE +for the path to the final installed location of the module.

+ +

LOCAL_IS_HOST_MODULE

+

Set by the host_xxx.mk includes to tell base_rules.mk and the other +includes that we're building for the host.

+ +

LOCAL_INSTALLED_MODULE

+

This should not be used, since multiple binaries are now +created from a single module defintiion.

+

The fully qualified path name of the final location of the module. +See LOCAL_BUILT_MODULE for the location of the intermediate file that +the make rules should actually be constructing.

+ +

LOCAL_MODULE_CLASS

+

Which kind of module this is. This variable is used to construct other +variable names used to locate the modules. See base_rules.mk and +envsetup.mk.

+ +

LOCAL_MODULE_SUFFIX

+

The suffix that will be appended to LOCAL_MODULE to form +LOCAL_MODULE_NAME. For example, .so, .a, .dylib.

+ +

LOCAL_STRIP_MODULE

+

If set to true (the default), the binary will be stripped and a debug +link will be set up so that GDB will still work. If set to no_debuglink, +the binary will be stripped, but no debug link will be added. If set to +keep_symbols, it will strip the debug information, but keep the symbol table. +Any other value will prevent stripping.

+ +

LOCAL_SYSTEM_SHARED_LIBRARIES

+

Used while building the base libraries: libc, libm, libdl. Usually +it should be set to "none," as it is in $(CLEAR_VARS). When building +these libraries, it's set to the ones they link against. For example, +libc, libstdc++ and libdl don't link against anything, and libm links against +libc. Normally, when the value is none, these libraries are automatically +linked in to executables and libraries, so you don't need to specify them +manually.

+ + + + diff --git a/core/build_id.mk b/core/build_id.mk new file mode 100644 index 0000000000000000000000000000000000000000..072f442d9eb5a323ea3805d1942622cb7342ca38 --- /dev/null +++ b/core/build_id.mk @@ -0,0 +1,21 @@ +# +# Copyright (C) 2008 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# BUILD_ID is usually used to specify the branch name +# (like "MAIN") or a branch name and a release candidate +# (like "CRB01"). It must be a single word, and is +# capitalized by convention. + +export BUILD_ID=N6F26Q diff --git a/core/ccache.mk b/core/ccache.mk new file mode 100644 index 0000000000000000000000000000000000000000..5c2ae23da6f6a4f72cf81cfcd397ee187d26feb9 --- /dev/null +++ b/core/ccache.mk @@ -0,0 +1,52 @@ +# +# Copyright (C) 2015 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +ifneq ($(filter-out false,$(USE_CCACHE)),) + # The default check uses size and modification time, causing false misses + # since the mtime depends when the repo was checked out + export CCACHE_COMPILERCHECK := content + + # See man page, optimizations to get more cache hits + # implies that __DATE__ and __TIME__ are not critical for functionality. + # Ignore include file modification time since it will depend on when + # the repo was checked out + export CCACHE_SLOPPINESS := time_macros,include_file_mtime,file_macro + + # Turn all preprocessor absolute paths into relative paths. + # Fixes absolute paths in preprocessed source due to use of -g. + # We don't really use system headers much so the rootdir is + # fine; ensures these paths are relative for all Android trees + # on a workstation. + export CCACHE_BASEDIR := / + + # Workaround for ccache with clang. + # See http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html + export CCACHE_CPP2 := true + + CCACHE_HOST_TAG := $(HOST_PREBUILT_TAG) + ccache := prebuilts/misc/$(CCACHE_HOST_TAG)/ccache/ccache + # Check that the executable is here. + ccache := $(strip $(wildcard $(ccache))) + ifdef ccache + ifndef CC_WRAPPER + CC_WRAPPER := $(ccache) + endif + ifndef CXX_WRAPPER + CXX_WRAPPER := $(ccache) + endif + ccache = + endif +endif diff --git a/core/checktree b/core/checktree new file mode 100755 index 0000000000000000000000000000000000000000..b0b9cfab6d27edc1ebc7e462459342ea7e4760a2 --- /dev/null +++ b/core/checktree @@ -0,0 +1,113 @@ +#!/usr/bin/python -E + +import sys, os, re + +excludes = [r'.*?/\.obj.*?', + r'.*?~', + r'.*?\/.DS_Store', + r'.*?\/.gdb_history', + r'.*?\/buildspec.mk', + r'.*?/\..*?\.swp', + r'.*?/out/.*?', + r'.*?/install/.*?'] + +excludes_compiled = map(re.compile, excludes) + +def filter_excludes(str): + for e in excludes_compiled: + if e.match(str): + return False + return True + +def split_perforce_parts(s): + spaces = ((s.count(" ") + 1) / 3) * 2 + pos = 0 + while spaces > 0: + pos = s.find(" ", pos) + 1 + spaces = spaces - 1 + return s[pos:] + +def quotate(s): + return '"' + s + '"' + +class PerforceError(Exception): + def __init__(self,value): + self.value = value + def __str__(self): + return repr(self.value) + + +def run(command, regex, filt): + def matchit(s): + m = regex_compiled.match(s) + if m: + return m.group(1) + else: + return "" + def filterit(s): + if filt_compiled.match(s): + return True + else: + return False + + fd = os.popen(command); + lines = fd.readlines() + status = fd.close() + if status: + raise PerforceError("error calling " + command) + + regex_compiled = re.compile(regex) + filt_compiled = re.compile(filt) + + if len(lines) >= 1: + lines = filter(filterit, lines) + if len(lines) >= 1: + return map(matchit, lines) + return None + +try: + if len(sys.argv) == 1: + do_exclude = True + elif len(sys.argv) == 2 and sys.argv[1] == "-a": + do_exclude = False + else: + print "usage: checktree [-a]" + print " -a don't filter common crud in the tree" + sys.exit(1) + + have = run("p4 have ...", r'[^#]+#[0-9]+ - (.*)', r'.*') + + cwd = os.getcwd() + files = run("find . -not -type d", r'.(.*)', r'.*') + files = map(lambda s: cwd+s, files) + + added_depot_path = run("p4 opened ...", r'([^#]+)#.*', r'.*?#[0-9]+ - add .*'); + added = [] + if added_depot_path: + added_depot_path = map(quotate, added_depot_path) + + where = "p4 where " + " ".join(added_depot_path) + added = run(where, r'(.*)', r'.*') + added = map(split_perforce_parts, added) + + extras = [] + + # Python 2.3 -- still default on Mac OS X -- does not have set() + # Make dict's here to support the "in" operations below + have = dict().fromkeys(have, 1) + added = dict().fromkeys(added, 1) + + for file in files: + if not file in have: + if not file in added: + extras.append(file) + + if do_exclude: + extras = filter(filter_excludes, extras) + + for s in extras: + print s.replace(" ", "\\ ") + +except PerforceError, e: + sys.exit(2) + diff --git a/core/clang/HOST_CROSS_x86.mk b/core/clang/HOST_CROSS_x86.mk new file mode 100644 index 0000000000000000000000000000000000000000..b78a0743bbec5c0d0f2bd8989390a0e75f8373b7 --- /dev/null +++ b/core/clang/HOST_CROSS_x86.mk @@ -0,0 +1,56 @@ + +include $(BUILD_SYSTEM)/clang/x86.mk + +CLANG_CONFIG_x86_HOST_CROSS_TRIPLE := i686-pc-mingw32 + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_x86_HOST_CROSS_TRIPLE) + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_ASFLAGS) + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_CPPFLAGS) \ + -target $(CLANG_CONFIG_x86_HOST_CROSS_TRIPLE) + +CLANG_CONFIG_x86_HOST_CROSS_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_HOST_CROSS_COMBO_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_x86_HOST_CROSS_TRIPLE) + +$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CFLAGS := \ + $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CFLAGS) + +$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CONLYFLAGS := \ + $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CONLYFLAGS) + +$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CPPFLAGS := \ + $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_CPPFLAGS) + +$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_LDFLAGS := \ + $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_CROSS_EXTRA_LDFLAGS) + +$(clang_2nd_arch_prefix)HOST_CROSS_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686.a diff --git a/core/clang/HOST_CROSS_x86_64.mk b/core/clang/HOST_CROSS_x86_64.mk new file mode 100644 index 0000000000000000000000000000000000000000..b6f2de97681f9629c8b7f36caeb058dd90425249 --- /dev/null +++ b/core/clang/HOST_CROSS_x86_64.mk @@ -0,0 +1,56 @@ + +include $(BUILD_SYSTEM)/clang/x86_64.mk + +CLANG_CONFIG_x86_64_HOST_CROSS_TRIPLE := x86_64-pc-mingw32 + +CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_x86_64_HOST_CROSS_TRIPLE) + +CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_ASFLAGS) + +CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_CPPFLAGS) \ + -target $(CLANG_CONFIG_x86_64_HOST_CROSS_TRIPLE) + +CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_COMBO_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_x86_64_HOST_CROSS_TRIPLE) + +$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CFLAGS := \ + $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CFLAGS) + +$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CONLYFLAGS := \ + $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CONLYFLAGS) + +$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_CPPFLAGS := \ + $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_CPPFLAGS) + +$(clang_2nd_arch_prefix)CLANG_HOST_CROSS_GLOBAL_LDFLAGS := \ + $(call convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_CROSS_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_x86_64_HOST_CROSS_EXTRA_LDFLAGS) + +$(clang_2nd_arch_prefix)HOST_CROSS_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64.a diff --git a/core/clang/HOST_x86.mk b/core/clang/HOST_x86.mk new file mode 100644 index 0000000000000000000000000000000000000000..0ec64adbafa64e316c99462a480af7352ba5139d --- /dev/null +++ b/core/clang/HOST_x86.mk @@ -0,0 +1,77 @@ + +include $(BUILD_SYSTEM)/clang/x86.mk +include $(BUILD_SYSTEM)/clang/HOST_x86_common.mk + +ifeq ($(HOST_OS),linux) +CLANG_CONFIG_x86_HOST_TRIPLE := i686-linux-gnu +CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS) +CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS) +CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS) +CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS) +endif +ifeq ($(HOST_OS),darwin) +CLANG_CONFIG_x86_HOST_TRIPLE := i686-apple-darwin +CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_ASFLAGS) +CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS) +CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CPPFLAGS) +CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_LDFLAGS) +endif + +CLANG_CONFIG_x86_HOST_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_x86_HOST_TRIPLE) + +CLANG_CONFIG_x86_HOST_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_HOST_EXTRA_ASFLAGS) + +CLANG_CONFIG_x86_HOST_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_x86_HOST_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_CPPFLAGS) \ + -target $(CLANG_CONFIG_x86_HOST_TRIPLE) + +CLANG_CONFIG_x86_HOST_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_HOST_COMBO_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_x86_HOST_TRIPLE) + +define $(clang_2nd_arch_prefix)convert-to-host-clang-flags + $(strip \ + $(call subst-clang-incompatible-x86-flags,\ + $(filter-out $(CLANG_CONFIG_x86_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_CFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_EXTRA_CFLAGS) + +$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_CONLYFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_EXTRA_CONLYFLAGS) + +$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_CPPFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_EXTRA_CPPFLAGS) + +$(clang_2nd_arch_prefix)CLANG_HOST_GLOBAL_LDFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-host-clang-flags,$($(clang_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_x86_HOST_EXTRA_LDFLAGS) + +$(clang_2nd_arch_prefix)HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686.a diff --git a/core/clang/HOST_x86_64.mk b/core/clang/HOST_x86_64.mk new file mode 100644 index 0000000000000000000000000000000000000000..d46cb67e433aa4f4898d6e06eb3a59f3ad026286 --- /dev/null +++ b/core/clang/HOST_x86_64.mk @@ -0,0 +1,77 @@ + +include $(BUILD_SYSTEM)/clang/x86_64.mk +include $(BUILD_SYSTEM)/clang/HOST_x86_common.mk + +ifeq ($(HOST_OS),linux) +CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-linux-gnu +CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS) +CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS) +CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS) +CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS) +endif +ifeq ($(HOST_OS),darwin) +CLANG_CONFIG_x86_64_HOST_TRIPLE := x86_64-apple-darwin +CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_ASFLAGS) +CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS) +CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CPPFLAGS) +CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS := $(CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_LDFLAGS) +endif + +CLANG_CONFIG_x86_64_HOST_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_x86_64_HOST_TRIPLE) + +CLANG_CONFIG_x86_64_HOST_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_EXTRA_ASFLAGS) + +CLANG_CONFIG_x86_64_HOST_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_x86_64_HOST_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_CPPFLAGS) \ + -target $(CLANG_CONFIG_x86_64_HOST_TRIPLE) + +CLANG_CONFIG_x86_64_HOST_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_HOST_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_64_HOST_COMBO_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_x86_64_HOST_TRIPLE) + +define convert-to-host-clang-flags + $(strip \ + $(call subst-clang-incompatible-x86_64-flags,\ + $(filter-out $(CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +CLANG_HOST_GLOBAL_CFLAGS := \ + $(call convert-to-host-clang-flags,$(HOST_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_x86_64_HOST_EXTRA_CFLAGS) + +CLANG_HOST_GLOBAL_CONLYFLAGS := \ + $(call convert-to-host-clang-flags,$(HOST_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_x86_64_HOST_EXTRA_CONLYFLAGS) + +CLANG_HOST_GLOBAL_CPPFLAGS := \ + $(call convert-to-host-clang-flags,$(HOST_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_x86_64_HOST_EXTRA_CPPFLAGS) + +CLANG_HOST_GLOBAL_LDFLAGS := \ + $(call convert-to-host-clang-flags,$(HOST_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_x86_64_HOST_EXTRA_LDFLAGS) + +HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64.a diff --git a/core/clang/HOST_x86_common.mk b/core/clang/HOST_x86_common.mk new file mode 100644 index 0000000000000000000000000000000000000000..9e71750c14252f934fbf7f9be4c2eba36393cd8f --- /dev/null +++ b/core/clang/HOST_x86_common.mk @@ -0,0 +1,54 @@ +# Shared by HOST_x86.mk and HOST_x86_64.mk. + +ifeq ($(HOST_OS),darwin) +CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_ASFLAGS := \ + -integrated-as + +CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS := \ + -integrated-as + +CLANG_CONFIG_x86_DARWIN_HOST_EXTRA_CFLAGS += -fstack-protector-strong +endif + +ifeq ($(HOST_OS),linux) +CLANG_CONFIG_x86_LINUX_HOST_EXTRA_ASFLAGS := \ + --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \ + --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot + +CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS := \ + --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) + +CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CFLAGS += -fstack-protector-strong + +ifneq ($(strip $($(clang_2nd_arch_prefix)HOST_IS_64_BIT)),) +CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS := \ + --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \ + --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \ + -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8 \ + -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8/x86_64-linux \ + -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8/backward + +CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS := \ + --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \ + --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \ + -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/bin \ + -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.8 \ + -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.8 \ + -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/lib64/ +else +CLANG_CONFIG_x86_LINUX_HOST_EXTRA_CPPFLAGS := \ + --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \ + --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \ + -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8 \ + -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8/x86_64-linux/32 \ + -isystem $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/include/c++/4.8/backward + +CLANG_CONFIG_x86_LINUX_HOST_EXTRA_LDFLAGS := \ + --gcc-toolchain=$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG) \ + --sysroot $($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/sysroot \ + -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/bin \ + -B$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.8/32 \ + -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/lib/gcc/x86_64-linux/4.8/32 \ + -L$($(clang_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG)/x86_64-linux/lib32/ +endif +endif # Linux diff --git a/core/clang/TARGET_arm.mk b/core/clang/TARGET_arm.mk new file mode 100644 index 0000000000000000000000000000000000000000..5c1bf6f806e7514ba5f2817b98df9756262fa70b --- /dev/null +++ b/core/clang/TARGET_arm.mk @@ -0,0 +1,72 @@ + +include $(BUILD_SYSTEM)/clang/arm.mk + +CLANG_CONFIG_arm_TARGET_TRIPLE := arm-linux-androideabi +CLANG_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX := \ + $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_arm_TARGET_TRIPLE)/bin + +CLANG_CONFIG_arm_TARGET_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_arm_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX) + +CLANG_CONFIG_arm_TARGET_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_arm_EXTRA_CFLAGS) \ + -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) \ + $(CLANG_CONFIG_arm_TARGET_EXTRA_ASFLAGS) + +CLANG_CONFIG_arm_TARGET_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_arm_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_arm_TARGET_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_arm_EXTRA_CPPFLAGS) \ + -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) + +CLANG_CONFIG_arm_TARGET_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_arm_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_arm_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_arm_TARGET_TOOLCHAIN_PREFIX) + + +define $(clang_2nd_arch_prefix)convert-to-clang-flags + $(strip \ + $(call subst-clang-incompatible-arm-flags,\ + $(filter-out $(CLANG_CONFIG_arm_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_arm_TARGET_EXTRA_CFLAGS) + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CONLYFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_arm_TARGET_EXTRA_CONLYFLAGS) + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CPPFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_arm_TARGET_EXTRA_CPPFLAGS) + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_arm_TARGET_EXTRA_LDFLAGS) + +$(clang_2nd_arch_prefix)RS_TRIPLE := armv7-linux-androideabi +$(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := +$(clang_2nd_arch_prefix)RS_COMPAT_TRIPLE := armv7-none-linux-gnueabi + +$(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-arm-android.a + +# Address sanitizer clang config +$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-arm-android +$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan diff --git a/core/clang/TARGET_arm64.mk b/core/clang/TARGET_arm64.mk new file mode 100644 index 0000000000000000000000000000000000000000..15b0172a6ff90df84d0ddaee98a5b1363593799e --- /dev/null +++ b/core/clang/TARGET_arm64.mk @@ -0,0 +1,70 @@ + +include $(BUILD_SYSTEM)/clang/arm64.mk + +CLANG_CONFIG_arm64_TARGET_TRIPLE := aarch64-linux-android +CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX := \ + $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_arm64_TARGET_TRIPLE)/bin + +CLANG_CONFIG_arm64_TARGET_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_arm64_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_arm64_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX) + +CLANG_CONFIG_arm64_TARGET_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_arm64_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_arm64_TARGET_EXTRA_ASFLAGS) + +CLANG_CONFIG_arm64_TARGET_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_arm64_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_arm64_TARGET_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_arm64_EXTRA_CPPFLAGS) \ + +CLANG_CONFIG_arm64_TARGET_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_arm64_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_arm64_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_arm64_TARGET_TOOLCHAIN_PREFIX) + + +define convert-to-clang-flags + $(strip \ + $(call subst-clang-incompatible-arm64-flags,\ + $(filter-out $(CLANG_CONFIG_arm64_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +CLANG_TARGET_GLOBAL_CFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_arm64_TARGET_EXTRA_CFLAGS) + +CLANG_TARGET_GLOBAL_CONLYFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_arm64_TARGET_EXTRA_CONLYFLAGS) + +CLANG_TARGET_GLOBAL_CPPFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_arm64_TARGET_EXTRA_CPPFLAGS) + +CLANG_TARGET_GLOBAL_LDFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_arm64_TARGET_EXTRA_LDFLAGS) + +RS_TRIPLE := aarch64-linux-android +RS_TRIPLE_CFLAGS := +RS_COMPAT_TRIPLE := aarch64-linux-android + +TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-aarch64-android.a + +# Address sanitizer clang config +ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-aarch64-android +ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan64 diff --git a/core/clang/TARGET_mips.mk b/core/clang/TARGET_mips.mk new file mode 100644 index 0000000000000000000000000000000000000000..1a0176a5ab9b73c622df08409c36591ef764f982 --- /dev/null +++ b/core/clang/TARGET_mips.mk @@ -0,0 +1,67 @@ + +include $(BUILD_SYSTEM)/clang/mips.mk + +CLANG_CONFIG_mips_TARGET_TRIPLE := mipsel-linux-android +CLANG_CONFIG_mips_TARGET_TOOLCHAIN_PREFIX := \ + $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/mips64el-linux-android/bin + +CLANG_CONFIG_mips_TARGET_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_mips_EXTRA_ASFLAGS) \ + -fPIC \ + -target $(CLANG_CONFIG_mips_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_mips_TARGET_TOOLCHAIN_PREFIX) + +CLANG_CONFIG_mips_TARGET_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_mips_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_mips_TARGET_EXTRA_ASFLAGS) + +CLANG_CONFIG_mips_TARGET_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_mips_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_mips_TARGET_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_mips_EXTRA_CPPFLAGS) \ + +CLANG_CONFIG_mips_TARGET_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_mips_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_mips_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_mips_TARGET_TOOLCHAIN_PREFIX) + + +define $(clang_2nd_arch_prefix)convert-to-clang-flags + $(strip \ + $(call subst-clang-incompatible-mips-flags,\ + $(filter-out $(CLANG_CONFIG_mips_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_mips_TARGET_EXTRA_CFLAGS) + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CONLYFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_mips_TARGET_EXTRA_CONLYFLAGS) + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CPPFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_mips_TARGET_EXTRA_CPPFLAGS) + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_mips_TARGET_EXTRA_LDFLAGS) + +$(clang_2nd_arch_prefix)RS_TRIPLE := armv7-linux-androideabi +$(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := +RS_COMPAT_TRIPLE := mipsel-linux-android + +$(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-mipsel-android.a diff --git a/core/clang/TARGET_mips64.mk b/core/clang/TARGET_mips64.mk new file mode 100644 index 0000000000000000000000000000000000000000..104fb70217a3a64a3849fe796da01ad4cba243d5 --- /dev/null +++ b/core/clang/TARGET_mips64.mk @@ -0,0 +1,66 @@ + +include $(BUILD_SYSTEM)/clang/mips64.mk + +CLANG_CONFIG_mips64_TARGET_TRIPLE := mips64el-linux-android +CLANG_CONFIG_mips64_TARGET_TOOLCHAIN_PREFIX := \ + $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_mips64_TARGET_TRIPLE)/bin + +CLANG_CONFIG_mips64_TARGET_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_mips64_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_mips64_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_mips64_TARGET_TOOLCHAIN_PREFIX) + +CLANG_CONFIG_mips64_TARGET_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_mips64_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_mips64_TARGET_EXTRA_ASFLAGS) + +CLANG_CONFIG_mips64_TARGET_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_mips64_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_mips64_TARGET_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_mips64_EXTRA_CPPFLAGS) \ + +CLANG_CONFIG_mips64_TARGET_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_mips64_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_mips64_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_mips64_TARGET_TOOLCHAIN_PREFIX) + + +define convert-to-clang-flags + $(strip \ + $(call subst-clang-incompatible-mips64-flags,\ + $(filter-out $(CLANG_CONFIG_mips64_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +CLANG_TARGET_GLOBAL_CFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_mips64_TARGET_EXTRA_CFLAGS) + +CLANG_TARGET_GLOBAL_CONLYFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_mips64_TARGET_EXTRA_CONLYFLAGS) + +CLANG_TARGET_GLOBAL_CPPFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_mips64_TARGET_EXTRA_CPPFLAGS) + +CLANG_TARGET_GLOBAL_LDFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_mips64_TARGET_EXTRA_LDFLAGS) + +RS_TRIPLE := aarch64-linux-android +RS_TRIPLE_CFLAGS := +RS_COMPAT_TRIPLE := mips64el-linux-android + +TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-mips64el-android.a diff --git a/core/clang/TARGET_x86.mk b/core/clang/TARGET_x86.mk new file mode 100644 index 0000000000000000000000000000000000000000..741768b5e2c3d2530e34d111554a83e5346bdc78 --- /dev/null +++ b/core/clang/TARGET_x86.mk @@ -0,0 +1,77 @@ + +include $(BUILD_SYSTEM)/clang/x86.mk + +CLANG_CONFIG_x86_TARGET_TRIPLE := i686-linux-android +# NOTE: There is no i686-linux-android prebuilt, so we must hardcode the +# x86_64 target instead. +CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX := \ + $($(clang_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/x86_64-linux-android/bin + +CLANG_CONFIG_x86_TARGET_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_x86_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX) + +CLANG_CONFIG_x86_TARGET_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_TARGET_EXTRA_ASFLAGS) \ + -mstackrealign + +# -mstackrealign is needed to realign stack in native code +# that could be called from JNI, so that movaps instruction +# will work on assumed stack aligned local variables. + +CLANG_CONFIG_x86_TARGET_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_x86_TARGET_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_CPPFLAGS) \ + +CLANG_CONFIG_x86_TARGET_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_x86_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_x86_TARGET_TOOLCHAIN_PREFIX) + + +define $(clang_2nd_arch_prefix)convert-to-clang-flags + $(strip \ + $(call subst-clang-incompatible-x86-flags,\ + $(filter-out $(CLANG_CONFIG_x86_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_x86_TARGET_EXTRA_CFLAGS) + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CONLYFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_x86_TARGET_EXTRA_CONLYFLAGS) + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_CPPFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_x86_TARGET_EXTRA_CPPFLAGS) + +$(clang_2nd_arch_prefix)CLANG_TARGET_GLOBAL_LDFLAGS := \ + $(call $(clang_2nd_arch_prefix)convert-to-clang-flags,$($(clang_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_x86_TARGET_EXTRA_LDFLAGS) + +$(clang_2nd_arch_prefix)RS_TRIPLE := armv7-linux-androideabi +$(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := -D__i386__ +$(clang_2nd_arch_prefix)RS_COMPAT_TRIPLE := i686-linux-android + +$(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686-android.a + +# Address sanitizer clang config +$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_RUNTIME_LIBRARY := libclang_rt.asan-i686-android +$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan diff --git a/core/clang/TARGET_x86_64.mk b/core/clang/TARGET_x86_64.mk new file mode 100644 index 0000000000000000000000000000000000000000..e44382dcb821a3e0b825adf4a35f77a27aa095b0 --- /dev/null +++ b/core/clang/TARGET_x86_64.mk @@ -0,0 +1,66 @@ + +include $(BUILD_SYSTEM)/clang/x86_64.mk + +CLANG_CONFIG_x86_64_TARGET_TRIPLE := x86_64-linux-android +CLANG_CONFIG_x86_64_TARGET_TOOLCHAIN_PREFIX := \ + $(TARGET_TOOLCHAIN_ROOT)/$(CLANG_CONFIG_x86_64_TARGET_TRIPLE)/bin + +CLANG_CONFIG_x86_64_TARGET_EXTRA_ASFLAGS := \ + $(CLANG_CONFIG_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_ASFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_ASFLAGS) \ + -target $(CLANG_CONFIG_x86_64_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_x86_64_TARGET_TOOLCHAIN_PREFIX) + +CLANG_CONFIG_x86_64_TARGET_EXTRA_CFLAGS := \ + $(CLANG_CONFIG_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_CFLAGS) \ + $(CLANG_CONFIG_x86_64_TARGET_EXTRA_ASFLAGS) + +CLANG_CONFIG_x86_64_TARGET_EXTRA_CONLYFLAGS := \ + $(CLANG_CONFIG_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CONLYFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_CONLYFLAGS) + +CLANG_CONFIG_x86_64_TARGET_EXTRA_CPPFLAGS := \ + $(CLANG_CONFIG_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_CPPFLAGS) \ + +CLANG_CONFIG_x86_64_TARGET_EXTRA_LDFLAGS := \ + $(CLANG_CONFIG_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_TARGET_EXTRA_LDFLAGS) \ + $(CLANG_CONFIG_x86_64_EXTRA_LDFLAGS) \ + -target $(CLANG_CONFIG_x86_64_TARGET_TRIPLE) \ + -B$(CLANG_CONFIG_x86_64_TARGET_TOOLCHAIN_PREFIX) + + +define convert-to-clang-flags + $(strip \ + $(call subst-clang-incompatible-x86_64-flags,\ + $(filter-out $(CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS),\ + $(1)))) +endef + +CLANG_TARGET_GLOBAL_CFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_CFLAGS)) \ + $(CLANG_CONFIG_x86_64_TARGET_EXTRA_CFLAGS) + +CLANG_TARGET_GLOBAL_CONLYFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_CONLYFLAGS)) \ + $(CLANG_CONFIG_x86_64_TARGET_EXTRA_CONLYFLAGS) + +CLANG_TARGET_GLOBAL_CPPFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_CPPFLAGS)) \ + $(CLANG_CONFIG_x86_64_TARGET_EXTRA_CPPFLAGS) + +CLANG_TARGET_GLOBAL_LDFLAGS := \ + $(call convert-to-clang-flags,$(TARGET_GLOBAL_LDFLAGS)) \ + $(CLANG_CONFIG_x86_64_TARGET_EXTRA_LDFLAGS) + +RS_TRIPLE := aarch64-linux-android +RS_TRIPLE_CFLAGS := -D__x86_64__ +RS_COMPAT_TRIPLE := x86_64-linux-android + +TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64-android.a diff --git a/core/clang/arm.mk b/core/clang/arm.mk new file mode 100644 index 0000000000000000000000000000000000000000..4053bb2766ce35f81dbaf1c90a40d034751fb806 --- /dev/null +++ b/core/clang/arm.mk @@ -0,0 +1,38 @@ +# Clang flags for arm arch, target or host. + +CLANG_CONFIG_arm_EXTRA_ASFLAGS := + +CLANG_CONFIG_arm_EXTRA_CFLAGS := + +ifneq (,$(filter krait,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT))) + # Android's clang support's krait as a CPU whereas GCC doesn't. Specify + # -mcpu here rather than the more normal core/combo/arch/arm/armv7-a-neon.mk. + CLANG_CONFIG_arm_EXTRA_CFLAGS += -mcpu=krait -mfpu=neon-vfpv4 +endif + +CLANG_CONFIG_arm_EXTRA_CPPFLAGS := + +CLANG_CONFIG_arm_EXTRA_LDFLAGS := + +# Include common unknown flags +CLANG_CONFIG_arm_UNKNOWN_CFLAGS := \ + $(CLANG_CONFIG_UNKNOWN_CFLAGS) \ + -mthumb-interwork \ + -fgcse-after-reload \ + -frerun-cse-after-loop \ + -frename-registers \ + -fno-align-jumps \ + -fno-builtin-sin \ + -fno-caller-saves \ + -fno-early-inlining \ + -fno-move-loop-invariants \ + -fno-partial-inlining \ + -fno-strict-volatile-bitfields \ + -fno-tree-copy-prop \ + -fno-tree-loop-optimize + +define subst-clang-incompatible-arm-flags + $(subst -march=armv5te,-march=armv5t,\ + $(subst -march=armv5e,-march=armv5,\ + $(1))) +endef diff --git a/core/clang/arm64.mk b/core/clang/arm64.mk new file mode 100644 index 0000000000000000000000000000000000000000..cad7321ec1ebb6ea10adf372c17a5e3ab94b96e3 --- /dev/null +++ b/core/clang/arm64.mk @@ -0,0 +1,21 @@ +# Clang flags for arm64 arch, target or host. + +CLANG_CONFIG_arm64_EXTRA_ASFLAGS := + +CLANG_CONFIG_arm64_EXTRA_CFLAGS := + +CLANG_CONFIG_arm64_EXTRA_LDFLAGS := + +# Include common unknown flags +CLANG_CONFIG_arm64_UNKNOWN_CFLAGS := \ + $(CLANG_CONFIG_UNKNOWN_CFLAGS) \ + -fgcse-after-reload \ + -frerun-cse-after-loop \ + -frename-registers \ + -fno-strict-volatile-bitfields \ + -fno-align-jumps + +# We don't have any arm64 flags to substitute yet. +define subst-clang-incompatible-arm64-flags + $(1) +endef diff --git a/core/clang/config.mk b/core/clang/config.mk new file mode 100644 index 0000000000000000000000000000000000000000..6cc344637e89dded591acbe9874ac9848465ff5d --- /dev/null +++ b/core/clang/config.mk @@ -0,0 +1,181 @@ +## Clang configurations. + +LLVM_PREBUILTS_PATH := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin +LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_PATH)/../lib64/clang/$(LLVM_RELEASE_VERSION)/lib/linux/ + +CLANG := $(LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) +CLANG_CXX := $(LLVM_PREBUILTS_PATH)/clang++$(BUILD_EXECUTABLE_SUFFIX) +LLVM_AS := $(LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) +LLVM_LINK := $(LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) + +CLANG_TBLGEN := $(BUILD_OUT_EXECUTABLES)/clang-tblgen$(BUILD_EXECUTABLE_SUFFIX) +LLVM_TBLGEN := $(BUILD_OUT_EXECUTABLES)/llvm-tblgen$(BUILD_EXECUTABLE_SUFFIX) + +# RenderScript-specific tools +# These are tied to the version of LLVM directly in external/, so they might +# trail the host prebuilts being used for the rest of the build process. +RS_LLVM_PREBUILTS_VERSION := clang-2690385 +RS_LLVM_PREBUILTS_BASE := prebuilts/clang/host +RS_LLVM_PREBUILTS_PATH := $(RS_LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(RS_LLVM_PREBUILTS_VERSION)/bin +RS_CLANG := $(RS_LLVM_PREBUILTS_PATH)/clang$(BUILD_EXECUTABLE_SUFFIX) +RS_LLVM_AS := $(RS_LLVM_PREBUILTS_PATH)/llvm-as$(BUILD_EXECUTABLE_SUFFIX) +RS_LLVM_LINK := $(RS_LLVM_PREBUILTS_PATH)/llvm-link$(BUILD_EXECUTABLE_SUFFIX) + +# Clang flags for all host or target rules +CLANG_CONFIG_EXTRA_ASFLAGS := +CLANG_CONFIG_EXTRA_CFLAGS := +CLANG_CONFIG_EXTRA_CONLYFLAGS := -std=gnu99 +CLANG_CONFIG_EXTRA_CPPFLAGS := +CLANG_CONFIG_EXTRA_LDFLAGS := + +CLANG_CONFIG_EXTRA_CFLAGS += \ + -D__compiler_offsetof=__builtin_offsetof + +# Help catch common 32/64-bit errors. +CLANG_CONFIG_EXTRA_CFLAGS += \ + -Werror=int-conversion + +# Disable overly aggressive warning for macros defined with a leading underscore +# This used to happen in AndroidConfig.h, which was included everywhere. +# TODO: can we remove this now? +CLANG_CONFIG_EXTRA_CFLAGS += \ + -Wno-reserved-id-macro + +# Disable overly aggressive warning for format strings. +# Bug: 20148343 +CLANG_CONFIG_EXTRA_CFLAGS += \ + -Wno-format-pedantic + +# Workaround for ccache with clang. +# See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html. +CLANG_CONFIG_EXTRA_CFLAGS += \ + -Wno-unused-command-line-argument + +# Disable -Winconsistent-missing-override until we can clean up the existing +# codebase for it. +CLANG_CONFIG_EXTRA_CPPFLAGS += \ + -Wno-inconsistent-missing-override + +# Force clang to always output color diagnostics. Ninja will strip the ANSI +# color codes if it is not running in a terminal. +ifdef BUILDING_WITH_NINJA +CLANG_CONFIG_EXTRA_CFLAGS += \ + -fcolor-diagnostics +endif + +CLANG_CONFIG_UNKNOWN_CFLAGS := \ + -finline-functions \ + -finline-limit=64 \ + -fno-canonical-system-headers \ + -Wno-clobbered \ + -fno-devirtualize \ + -fno-tree-sra \ + -fprefetch-loop-arrays \ + -funswitch-loops \ + -Werror=unused-but-set-parameter \ + -Werror=unused-but-set-variable \ + -Wmaybe-uninitialized \ + -Wno-error=clobbered \ + -Wno-error=maybe-uninitialized \ + -Wno-error=unused-but-set-parameter \ + -Wno-error=unused-but-set-variable \ + -Wno-free-nonheap-object \ + -Wno-literal-suffix \ + -Wno-maybe-uninitialized \ + -Wno-old-style-declaration \ + -Wno-psabi \ + -Wno-unused-but-set-parameter \ + -Wno-unused-but-set-variable \ + -Wno-unused-local-typedefs \ + -Wunused-but-set-parameter \ + -Wunused-but-set-variable \ + -fdiagnostics-color \ + -fdebug-prefix-map=/proc/self/cwd= + +# Clang flags for all host rules +CLANG_CONFIG_HOST_EXTRA_ASFLAGS := +CLANG_CONFIG_HOST_EXTRA_CFLAGS := +CLANG_CONFIG_HOST_EXTRA_CPPFLAGS := +CLANG_CONFIG_HOST_EXTRA_LDFLAGS := + +# Clang flags for all host cross rules +CLANG_CONFIG_HOST_CROSS_EXTRA_ASFLAGS := +CLANG_CONFIG_HOST_CROSS_EXTRA_CFLAGS := +CLANG_CONFIG_HOST_CROSS_EXTRA_CPPFLAGS := +CLANG_CONFIG_HOST_CROSS_EXTRA_LDFLAGS := + +# Clang flags for all target rules +CLANG_CONFIG_TARGET_EXTRA_ASFLAGS := +CLANG_CONFIG_TARGET_EXTRA_CFLAGS := -nostdlibinc +CLANG_CONFIG_TARGET_EXTRA_CPPFLAGS := -nostdlibinc +CLANG_CONFIG_TARGET_EXTRA_LDFLAGS := + +CLANG_DEFAULT_UB_CHECKS := \ + bool \ + integer-divide-by-zero \ + return \ + returns-nonnull-attribute \ + shift-exponent \ + unreachable \ + vla-bound \ + +# TODO(danalbert): The following checks currently have compiler performance +# issues. +# CLANG_DEFAULT_UB_CHECKS += alignment +# CLANG_DEFAULT_UB_CHECKS += bounds +# CLANG_DEFAULT_UB_CHECKS += enum +# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow +# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero +# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute +# CLANG_DEFAULT_UB_CHECKS += null +# CLANG_DEFAULT_UB_CHECKS += shift-base +# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow + +# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on. +# https://llvm.org/PR19302 +# http://reviews.llvm.org/D6974 +# CLANG_DEFAULT_UB_CHECKS += object-size + +# HOST config +clang_2nd_arch_prefix := +include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk + +# HOST_2ND_ARCH config +ifdef HOST_2ND_ARCH +clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX) +include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk +endif + +ifdef HOST_CROSS_ARCH +clang_2nd_arch_prefix := +include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_ARCH).mk +ifdef HOST_CROSS_2ND_ARCH +clang_2nd_arch_prefix := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX) +include $(BUILD_SYSTEM)/clang/HOST_CROSS_$(HOST_CROSS_2ND_ARCH).mk +endif +endif + +# TARGET config +clang_2nd_arch_prefix := +include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk + +# TARGET_2ND_ARCH config +ifdef TARGET_2ND_ARCH +clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX) +include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk +endif + +ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS := -fno-omit-frame-pointer +ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS := -Wl,-u,__asan_preinit + +ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES := +ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES := libasan + +# This allows us to use the superset of functionality that compiler-rt +# provides to Clang (for supporting features like -ftrapv). +COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES := libcompiler_rt-extras + +ifeq ($(HOST_PREFER_32_BIT),true) +# We don't have 32-bit prebuilt libLLVM/libclang, so force to build them from source. +FORCE_BUILD_LLVM_COMPONENTS := true +endif diff --git a/core/clang/mips.mk b/core/clang/mips.mk new file mode 100644 index 0000000000000000000000000000000000000000..4a8f81224ffdd0eb28b95fe152f7e36395fa41ae --- /dev/null +++ b/core/clang/mips.mk @@ -0,0 +1,26 @@ +# Clang flags for mips arch, target or host. + +CLANG_CONFIG_mips_EXTRA_ASFLAGS := +CLANG_CONFIG_mips_EXTRA_CFLAGS := +CLANG_CONFIG_mips_EXTRA_LDFLAGS := + +# Include common unknown flags +CLANG_CONFIG_mips_UNKNOWN_CFLAGS := \ + $(CLANG_CONFIG_UNKNOWN_CFLAGS) \ + -fno-strict-volatile-bitfields \ + -fgcse-after-reload \ + -frerun-cse-after-loop \ + -frename-registers \ + -msynci \ + -mno-synci \ + -mno-fused-madd + +# Temporary workaround for Mips clang++ problem, creates +# relocated ptrs in read-only pic .gcc_exception_table; +# permanent fix pending at http://reviews.llvm.org/D9669 +CLANG_CONFIG_mips_UNKNOWN_CFLAGS += -Wl,--warn-shared-textrel + +# We don't have any mips flags to substitute yet. +define subst-clang-incompatible-mips-flags + $(1) +endef diff --git a/core/clang/mips64.mk b/core/clang/mips64.mk new file mode 100644 index 0000000000000000000000000000000000000000..1b72e058fe54f915915f5b27d3fd4a422287293c --- /dev/null +++ b/core/clang/mips64.mk @@ -0,0 +1,26 @@ +# Clang flags for mips64 arch, target or host. + +CLANG_CONFIG_mips64_EXTRA_ASFLAGS := +CLANG_CONFIG_mips64_EXTRA_CFLAGS := +CLANG_CONFIG_mips64_EXTRA_LDFLAGS := + +# Include common unknown flags +CLANG_CONFIG_mips64_UNKNOWN_CFLAGS := \ + $(CLANG_CONFIG_UNKNOWN_CFLAGS) \ + -fno-strict-volatile-bitfields \ + -fgcse-after-reload \ + -frerun-cse-after-loop \ + -frename-registers \ + -msynci \ + -mno-synci \ + -mno-fused-madd + +# Temporary workaround for Mips clang++ problem creating +# relocated ptrs in read-only pic .gcc_exception_table; +# permanent fix pending at http://reviews.llvm.org/D9669 +CLANG_CONFIG_mips64_UNKNOWN_CFLAGS += -Wl,--warn-shared-textrel + +# We don't have any mips64 flags to substitute yet. +define subst-clang-incompatible-mips64-flags + $(1) +endef diff --git a/core/clang/versions.mk b/core/clang/versions.mk new file mode 100644 index 0000000000000000000000000000000000000000..81bd3b873b1bc65c444bc91724fe52a572391ef7 --- /dev/null +++ b/core/clang/versions.mk @@ -0,0 +1,5 @@ +## Clang/LLVM release versions. + +LLVM_RELEASE_VERSION := 3.8 +LLVM_PREBUILTS_VERSION ?= clang-2690385 +LLVM_PREBUILTS_BASE ?= prebuilts/clang/host diff --git a/core/clang/x86.mk b/core/clang/x86.mk new file mode 100644 index 0000000000000000000000000000000000000000..69c3fb2af8198c82dd6ec9e79621780a1cde0257 --- /dev/null +++ b/core/clang/x86.mk @@ -0,0 +1,19 @@ +# Clang flags for x86 arch, target or host. + +CLANG_CONFIG_x86_EXTRA_ASFLAGS := \ + -msse3 +CLANG_CONFIG_x86_EXTRA_CFLAGS := +CLANG_CONFIG_x86_EXTRA_LDFLAGS := + +# Include common unknown flags +CLANG_CONFIG_x86_UNKNOWN_CFLAGS := \ + $(CLANG_CONFIG_UNKNOWN_CFLAGS) \ + -finline-limit=300 \ + -fno-inline-functions-called-once \ + -mfpmath=sse \ + -mbionic + +# We don't have any x86 flags to substitute yet. +define subst-clang-incompatible-x86-flags + $(1) +endef diff --git a/core/clang/x86_64.mk b/core/clang/x86_64.mk new file mode 100644 index 0000000000000000000000000000000000000000..cba10d47b7d0de0bf87c372df0e09bfd4bd48fb3 --- /dev/null +++ b/core/clang/x86_64.mk @@ -0,0 +1,18 @@ +# Clang flags for x86_64 arch, target or host. + +CLANG_CONFIG_x86_64_EXTRA_ASFLAGS := +CLANG_CONFIG_x86_64_EXTRA_CFLAGS := +CLANG_CONFIG_x86_64_EXTRA_LDFLAGS := + +# Include common unknown flags +CLANG_CONFIG_x86_64_UNKNOWN_CFLAGS := \ + $(CLANG_CONFIG_UNKNOWN_CFLAGS) \ + -finline-limit=300 \ + -fno-inline-functions-called-once \ + -mfpmath=sse \ + -mbionic + +# We don't have any x86_64 flags to substitute yet. +define subst-clang-incompatible-x86_64-flags + $(1) +endef diff --git a/core/cleanbuild.mk b/core/cleanbuild.mk new file mode 100644 index 0000000000000000000000000000000000000000..e46d93415399c9962b56745d03a98dbd7a5d1896 --- /dev/null +++ b/core/cleanbuild.mk @@ -0,0 +1,332 @@ +# Copyright (C) 2007 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Don't bother with the cleanspecs if you are running mm/mmm +ifeq ($(ONE_SHOT_MAKEFILE)$(dont_bother),) + +INTERNAL_CLEAN_STEPS := + +# Builds up a list of clean steps. Creates a unique +# id for each step by taking makefile path, INTERNAL_CLEAN_BUILD_VERSION +# and appending an increasing number of '@' characters. +# +# $(1): shell command to run +# $(2): indicate to not use makefile path as part of step id if not empty. +# $(2) should only be used in build/core/cleanspec.mk: just for compatibility. +define _add-clean-step + $(if $(strip $(INTERNAL_CLEAN_BUILD_VERSION)),, \ + $(error INTERNAL_CLEAN_BUILD_VERSION not set)) + $(eval _acs_makefile_prefix := $(lastword $(MAKEFILE_LIST))) + $(eval _acs_makefile_prefix := $(subst /,_,$(_acs_makefile_prefix))) + $(eval _acs_makefile_prefix := $(subst .,-,$(_acs_makefile_prefix))) + $(eval _acs_makefile_prefix := $(_acs_makefile_prefix)_acs) + $(if $($(_acs_makefile_prefix)),,\ + $(eval $(_acs_makefile_prefix) := $(INTERNAL_CLEAN_BUILD_VERSION))) + $(eval $(_acs_makefile_prefix) := $($(_acs_makefile_prefix))@) + $(if $(strip $(2)),$(eval _acs_id := $($(_acs_makefile_prefix))),\ + $(eval _acs_id := $(_acs_makefile_prefix)$($(_acs_makefile_prefix)))) + $(eval INTERNAL_CLEAN_STEPS += $(_acs_id)) + $(eval INTERNAL_CLEAN_STEP.$(_acs_id) := $(1)) + $(eval _acs_id :=) + $(eval _acs_makefile_prefix :=) +endef +define add-clean-step +$(eval # for build/core/cleanspec.mk, dont use makefile path as part of step id) \ +$(if $(filter %/cleanspec.mk,$(lastword $(MAKEFILE_LIST))),\ + $(eval $(call _add-clean-step,$(1),true)),\ + $(eval $(call _add-clean-step,$(1)))) +endef + +# Defines INTERNAL_CLEAN_BUILD_VERSION and the individual clean steps. +# cleanspec.mk is outside of the core directory so that more people +# can have permission to touch it. +include $(BUILD_SYSTEM)/cleanspec.mk +INTERNAL_CLEAN_BUILD_VERSION := $(strip $(INTERNAL_CLEAN_BUILD_VERSION)) +INTERNAL_CLEAN_STEPS := $(strip $(INTERNAL_CLEAN_STEPS)) + +# If the clean_steps.mk file is missing (usually after a clean build) +# then we won't do anything. +CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION) +CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS) + +# Read the current state from the file, if present. +# Will set CURRENT_CLEAN_BUILD_VERSION and CURRENT_CLEAN_STEPS. +# +clean_steps_file := $(PRODUCT_OUT)/clean_steps.mk +-include $(clean_steps_file) + +ifneq ($(CURRENT_CLEAN_BUILD_VERSION),$(INTERNAL_CLEAN_BUILD_VERSION)) + # The major clean version is out-of-date. Do a full clean, and + # don't even bother with the clean steps. + $(info *** A clean build is required because of a recent change.) + $(shell rm -rf $(OUT_DIR)) + $(info *** Done with the cleaning, now starting the real build.) +else + # The major clean version is correct. Find the list of clean steps + # that we need to execute to get up-to-date. + steps := \ + $(filter-out $(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_STEPS)) + $(foreach step,$(steps), \ + $(info Clean step: $(INTERNAL_CLEAN_STEP.$(step))) \ + $(shell $(INTERNAL_CLEAN_STEP.$(step))) \ + ) + + # Rewrite the clean step for the second arch. + ifdef TARGET_2ND_ARCH + # $(1): the clean step cmd + # $(2): the prefix to search for + # $(3): the prefix to replace with + define -cs-rewrite-cleanstep + $(if $(filter $(2)/%,$(1)),\ + $(eval _crs_new_cmd := $(patsubst $(2)/%,$(3)/%,$(1)))\ + $(info Clean step: $(_crs_new_cmd))\ + $(shell $(_crs_new_cmd))) + endef + $(foreach step,$(steps), \ + $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_INTERMEDIATES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES))\ + $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES))\ + $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES))\ + $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES),$(TARGET_OUT_INTERMEDIATES))\ + $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES),$(TARGET_OUT_SHARED_LIBRARIES))\ + $(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES))\ + ) + endif + _crs_new_cmd := + steps := +endif + +# Write the new state to the file. +# +rewrite_clean_steps_file := +ifneq ($(CURRENT_CLEAN_BUILD_VERSION)-$(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_BUILD_VERSION)-$(INTERNAL_CLEAN_STEPS)) +rewrite_clean_steps_file := true +endif +ifeq ($(wildcard $(clean_steps_file)),) +# This is the first build. +rewrite_clean_steps_file := true +endif +ifeq ($(rewrite_clean_steps_file),true) +$(shell \ + mkdir -p $(dir $(clean_steps_file)) && \ + echo "CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION)" > \ + $(clean_steps_file) ;\ + echo "CURRENT_CLEAN_STEPS := $(wordlist 1,500,$(INTERNAL_CLEAN_STEPS))" >> $(clean_steps_file) \ + ) +define -cs-write-clean-steps-if-arg1-not-empty +$(if $(1),$(shell echo "CURRENT_CLEAN_STEPS += $(1)" >> $(clean_steps_file))) +endef +$(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 501,1000,$(INTERNAL_CLEAN_STEPS))) +$(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 1001,1500,$(INTERNAL_CLEAN_STEPS))) +$(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 1501,2000,$(INTERNAL_CLEAN_STEPS))) +$(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 2001,2500,$(INTERNAL_CLEAN_STEPS))) +$(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 2501,3000,$(INTERNAL_CLEAN_STEPS))) +$(call -cs-write-clean-steps-if-arg1-not-empty,$(wordlist 3001,99999,$(INTERNAL_CLEAN_STEPS))) +endif + +CURRENT_CLEAN_BUILD_VERSION := +CURRENT_CLEAN_STEPS := +clean_steps_file := +rewrite_clean_steps_file := +INTERNAL_CLEAN_STEPS := +INTERNAL_CLEAN_BUILD_VERSION := + +endif # if not ONE_SHOT_MAKEFILE dont_bother + +# Since products and build variants (unfortunately) share the same +# PRODUCT_OUT staging directory, things can get out of sync if different +# build configurations are built in the same tree. The following logic +# will notice when the configuration has changed and remove the files +# necessary to keep things consistent. + +previous_build_config_file := $(PRODUCT_OUT)/previous_build_config.mk + +# A change in the list of aapt configs warrants an installclean, too. +aapt_config_list := $(strip $(PRODUCT_AAPT_CONFIG) $(PRODUCT_AAPT_PREF_CONFIG)) + +current_build_config := \ + $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)-{$(aapt_config_list)} +current_sanitize_target := $(strip $(SANITIZE_TARGET)) +ifeq (,$(current_sanitize_target)) + current_sanitize_target := false +endif +aapt_config_list := +force_installclean := false +force_objclean := false + +# Read the current state from the file, if present. +# Will set PREVIOUS_BUILD_CONFIG. +# +PREVIOUS_BUILD_CONFIG := +PREVIOUS_SANITIZE_TARGET := +-include $(previous_build_config_file) +PREVIOUS_BUILD_CONFIG := $(strip $(PREVIOUS_BUILD_CONFIG)) +PREVIOUS_SANITIZE_TARGET := $(strip $(PREVIOUS_SANITIZE_TARGET)) + +ifdef PREVIOUS_BUILD_CONFIG + ifneq "$(current_build_config)" "$(PREVIOUS_BUILD_CONFIG)" + $(info *** Build configuration changed: "$(PREVIOUS_BUILD_CONFIG)" -> "$(current_build_config)") + ifneq ($(DISABLE_AUTO_INSTALLCLEAN),true) + force_installclean := true + else + $(info DISABLE_AUTO_INSTALLCLEAN is set; skipping auto-clean. Your tree may be in an inconsistent state.) + endif + endif +endif # else, this is the first build, so no need to clean. + +ifdef PREVIOUS_SANITIZE_TARGET + ifneq "$(current_sanitize_target)" "$(PREVIOUS_SANITIZE_TARGET)" + $(info *** SANITIZE_TARGET changed: "$(PREVIOUS_SANITIZE_TARGET)" -> "$(current_sanitize_target)") + force_objclean := true + endif +endif # else, this is the first build, so no need to clean. + +# Write the new state to the file. +# +ifneq ($(PREVIOUS_BUILD_CONFIG)-$(PREVIOUS_SANITIZE_TARGET),$(current_build_config)-$(current_sanitize_target)) +$(shell \ + mkdir -p $(dir $(previous_build_config_file)) && \ + echo "PREVIOUS_BUILD_CONFIG := $(current_build_config)" > \ + $(previous_build_config_file) && \ + echo "PREVIOUS_SANITIZE_TARGET := $(current_sanitize_target)" >> \ + $(previous_build_config_file) \ + ) +endif +PREVIOUS_BUILD_CONFIG := +PREVIOUS_SANITIZE_TARGET := +previous_build_config_file := +current_build_config := + +# +# installclean logic +# + +# The files/dirs to delete during an installclean. This includes the +# non-common APPS directory, which may contain the wrong resources. +# +# Deletes all of the files that change between different build types, +# like "make user" vs. "make sdk". This lets you work with different +# build types without having to do a full clean each time. E.g.: +# +# $ make -j8 all +# $ make installclean +# $ make -j8 user +# $ make installclean +# $ make -j8 sdk +# +installclean_files := \ + $(HOST_OUT)/obj/NOTICE_FILES \ + $(HOST_OUT)/sdk \ + $(PRODUCT_OUT)/*.img \ + $(PRODUCT_OUT)/*.ini \ + $(PRODUCT_OUT)/*.txt \ + $(PRODUCT_OUT)/*.xlb \ + $(PRODUCT_OUT)/*.zip \ + $(PRODUCT_OUT)/kernel \ + $(PRODUCT_OUT)/data \ + $(PRODUCT_OUT)/skin \ + $(PRODUCT_OUT)/obj/APPS \ + $(PRODUCT_OUT)/obj/NOTICE_FILES \ + $(PRODUCT_OUT)/obj/PACKAGING \ + $(PRODUCT_OUT)/recovery \ + $(PRODUCT_OUT)/root \ + $(PRODUCT_OUT)/system \ + $(PRODUCT_OUT)/system_other \ + $(PRODUCT_OUT)/vendor \ + $(PRODUCT_OUT)/oem \ + $(PRODUCT_OUT)/dex_bootjars \ + $(PRODUCT_OUT)/obj/JAVA_LIBRARIES \ + $(PRODUCT_OUT)/obj/FAKE \ + $(PRODUCT_OUT)/obj/EXECUTABLES/adbd_intermediates \ + $(PRODUCT_OUT)/obj/EXECUTABLES/logd_intermediates \ + $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libfs_mgr_intermediates \ + $(PRODUCT_OUT)/obj/EXECUTABLES/init_intermediates \ + $(PRODUCT_OUT)/obj/ETC/mac_permissions.xml_intermediates \ + $(PRODUCT_OUT)/obj/ETC/sepolicy_intermediates \ + $(PRODUCT_OUT)/obj/ETC/sepolicy.recovery_intermediates \ + $(PRODUCT_OUT)/obj/ETC/init.environ.rc_intermediates + +# The files/dirs to delete during a dataclean, which removes any files +# in the staging and emulator data partitions. +dataclean_files := \ + $(PRODUCT_OUT)/data/* \ + $(PRODUCT_OUT)/data-qemu/* \ + $(PRODUCT_OUT)/userdata-qemu.img + +# The files/dirs to delete during an objclean, which removes any files +# in the staging and emulator data partitions. +objclean_files := \ + $(TARGET_OUT_INTERMEDIATES) \ + $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES) + +# make sure *_OUT is set so that we won't result in deleting random parts +# of the filesystem. +ifneq (2,$(words $(HOST_OUT) $(PRODUCT_OUT))) + $(error both HOST_OUT and PRODUCT_OUT should be set at this point.) +endif + +# Define the rules for commandline invocation. +.PHONY: dataclean +dataclean: FILES := $(dataclean_files) +dataclean: + $(hide) rm -rf $(FILES) + @echo "Deleted emulator userdata images." + +.PHONY: installclean +installclean: FILES := $(installclean_files) +installclean: dataclean + $(hide) rm -rf $(FILES) + @echo "Deleted images and staging directories." + +.PHONY: objclean +objclean: FILES := $(objclean_files) +objclean: + $(hide) rm -rf $(FILES) + @echo "Deleted images and staging directories." + +ifeq "$(force_installclean)" "true" + $(info *** Forcing "make installclean"...) + $(info *** rm -rf $(dataclean_files) $(installclean_files)) + $(shell rm -rf $(dataclean_files) $(installclean_files)) + $(info *** Done with the cleaning, now starting the real build.) +endif +force_installclean := + +ifeq "$(force_objclean)" "true" + $(info *** Forcing cleanup of intermediate files...) + $(info *** rm -rf $(objclean_files)) + $(shell rm -rf $(objclean_files)) + $(info *** Done with the cleaning, now starting the real build.) +endif +force_objclean := + +########################################################### + +.PHONY: clean-jack-files +clean-jack-files: clean-dex-files + $(hide) find $(OUT_DIR) -name "*.jack" | xargs rm -f + $(hide) find $(OUT_DIR) -type d -name "jack" | xargs rm -rf + @echo "All jack files have been removed." + +.PHONY: clean-dex-files +clean-dex-files: + $(hide) find $(OUT_DIR) -name "*.dex" ! -path "*/jack-incremental/*" | xargs rm -f + $(hide) for i in `find $(OUT_DIR) -name "*.jar" -o -name "*.apk"` ; do ((unzip -l $$i 2> /dev/null | \ + grep -q "\.dex$$" && rm -f $$i) || continue ) ; done + @echo "All dex files and archives containing dex files have been removed." + +.PHONY: clean-jack-incremental +clean-jack-incremental: + $(hide) find $(OUT_DIR) -name "jack-incremental" -type d | xargs rm -rf + @echo "All jack incremental dirs have been removed." diff --git a/core/cleanspec.mk b/core/cleanspec.mk new file mode 100644 index 0000000000000000000000000000000000000000..4441e2ac3f6e0e6458a920113b2bc72071f9f96b --- /dev/null +++ b/core/cleanspec.mk @@ -0,0 +1,69 @@ +# Copyright (C) 2007 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Just bump this if you want to force a clean build. +# ********************************************************************** +# WHEN DOING SO +# 1. DELETE ANY "add-clean-step" ENTRIES THAT HAVE PILED UP IN THIS FILE. +# 2. REMOVE ALL FILES NAMED CleanSpec.mk. +# 3. BUMP THE VERSION. +# IDEALLY, THOSE STEPS SHOULD BE DONE ATOMICALLY. +# ********************************************************************** +# +INTERNAL_CLEAN_BUILD_VERSION := 6 +# +# *********************************************************************** +# Do not touch INTERNAL_CLEAN_BUILD_VERSION if you've added a clean step! +# *********************************************************************** + +# If you don't need to do a full clean build but would like to touch +# a file or delete some intermediate files, add a clean step to the end +# of the list. These steps will only be run once, if they haven't been +# run before. +# +# E.g.: +# $(call add-clean-step, touch -c external/sqlite/sqlite3.h) +# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates) +# +# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with +# files that are missing or have been moved. +# +# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory. +# Use $(OUT_DIR) to refer to the "out" directory. +# +# If you need to re-do something that's already mentioned, just copy +# the command and add it to the bottom of the list. E.g., if a change +# that you made last week required touching a file and a change you +# made today requires touching the same file, just copy the old +# touch step and add it to the end of the list. +# +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ + +# For example: +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates) +#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates) +#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f) +#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*) + +# ************************************************ +# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST +# ************************************************ + +subdir_cleanspecs := \ + $(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) . CleanSpec.mk) +include $(subdir_cleanspecs) +subdir_cleanspecs := diff --git a/core/clear_vars.mk b/core/clear_vars.mk new file mode 100644 index 0000000000000000000000000000000000000000..5886610588895ef30ce87ed4f87b418fa4de4909 --- /dev/null +++ b/core/clear_vars.mk @@ -0,0 +1,371 @@ +########################################################### +## Clear out values of all variables used by rule templates. +########################################################### + +LOCAL_MODULE:= +LOCAL_MODULE_PATH:= +LOCAL_MODULE_RELATIVE_PATH := +LOCAL_MODULE_STEM:= +LOCAL_DONT_CHECK_MODULE:= +LOCAL_CHECKED_MODULE:= +LOCAL_BUILT_MODULE:= +LOCAL_BUILT_MODULE_STEM:= +OVERRIDE_BUILT_MODULE_PATH:= +LOCAL_INSTALLED_MODULE:= +LOCAL_INSTALLED_MODULE_STEM:= +LOCAL_PICKUP_FILES:= +LOCAL_UNINSTALLABLE_MODULE:= +LOCAL_INTERMEDIATE_TARGETS:= +LOCAL_UNSTRIPPED_PATH:= +LOCAL_MODULE_CLASS:= +LOCAL_MODULE_SUFFIX:= +LOCAL_PACKAGE_NAME:= +LOCAL_OVERRIDES_PACKAGES:= +LOCAL_EXPORT_PACKAGE_RESOURCES:= +LOCAL_MANIFEST_PACKAGE_NAME:= +LOCAL_PACKAGE_SPLITS:= +LOCAL_REQUIRED_MODULES:= +LOCAL_ACP_UNAVAILABLE:= +LOCAL_MODULE_TAGS:= +LOCAL_SRC_FILES:= +LOCAL_SRC_FILES_EXCLUDE:= +LOCAL_PREBUILT_OBJ_FILES:= +LOCAL_STATIC_JAVA_LIBRARIES:= +LOCAL_STATIC_JAVA_AAR_LIBRARIES:= +LOCAL_STATIC_LIBRARIES:= +# Group static libraries with "-Wl,--start-group" and "-Wl,--end-group" when linking. +LOCAL_GROUP_STATIC_LIBRARIES:= +LOCAL_WHOLE_STATIC_LIBRARIES:= +LOCAL_SHARED_LIBRARIES:= +LOCAL_IS_HOST_MODULE:= +LOCAL_CC:= +LOCAL_CXX:= +LOCAL_CPP_EXTENSION:= +LOCAL_NO_DEFAULT_COMPILER_FLAGS:= +LOCAL_FDO_SUPPORT:= +LOCAL_ARM_MODE:= +LOCAL_YACCFLAGS:= +LOCAL_ASFLAGS:= +LOCAL_CFLAGS:= +LOCAL_CPPFLAGS:= +LOCAL_CLANG_ASFLAGS:= +LOCAL_CLANG_CFLAGS:= +LOCAL_CLANG_CONLYFLAGS:= +LOCAL_CLANG_CPPFLAGS:= +LOCAL_CONLYFLAGS:= +LOCAL_RTTI_FLAG:= +LOCAL_C_INCLUDES:= +LOCAL_EXPORT_C_INCLUDE_DIRS:= +LOCAL_LDFLAGS:= +LOCAL_CLANG_LDFLAGS:= +LOCAL_LDLIBS:= +LOCAL_AAPT_FLAGS:= +LOCAL_AAPT_INCLUDE_ALL_RESOURCES:= +LOCAL_SYSTEM_SHARED_LIBRARIES:=none +LOCAL_PREBUILT_LIBS:= +LOCAL_PREBUILT_EXECUTABLES:= +LOCAL_PREBUILT_JAVA_LIBRARIES:= +LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:= +LOCAL_PREBUILT_STRIP_COMMENTS:= +LOCAL_INTERMEDIATE_SOURCES:= +LOCAL_INTERMEDIATE_SOURCE_DIR:= +LOCAL_JAVACFLAGS:= +LOCAL_JAVA_LIBRARIES:= +LOCAL_JAVA_LAYERS_FILE:= +LOCAL_NO_STANDARD_LIBRARIES:= +LOCAL_CLASSPATH:= +LOCAL_JACK_CLASSPATH:= +LOCAL_DROIDDOC_USE_STANDARD_DOCLET:= +LOCAL_DROIDDOC_SOURCE_PATH:= +LOCAL_DROIDDOC_TEMPLATE_DIR:= +LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR:= +LOCAL_DROIDDOC_ASSET_DIR:= +LOCAL_DROIDDOC_CUSTOM_ASSET_DIR:= +LOCAL_DROIDDOC_OPTIONS:= +LOCAL_DROIDDOC_HTML_DIR:= +LOCAL_DROIDDOC_STUB_OUT_DIR:= +LOCAL_ADDITIONAL_HTML_DIR:= +LOCAL_ASSET_DIR:= +LOCAL_RESOURCE_DIR:= +LOCAL_JAVA_RESOURCE_DIRS:= +LOCAL_JAVA_RESOURCE_FILES:= +LOCAL_GENERATED_SOURCES:= +LOCAL_COPY_HEADERS_TO:= +LOCAL_COPY_HEADERS:= +LOCAL_FORCE_STATIC_EXECUTABLE:= +LOCAL_ADDITIONAL_DEPENDENCIES:= +LOCAL_STRIP_MODULE:= +LOCAL_PACK_MODULE_RELOCATIONS:= +LOCAL_JNI_SHARED_LIBRARIES:= +LOCAL_JNI_SHARED_LIBRARIES_ABI:= +LOCAL_PREBUILT_JNI_LIBS:= +LOCAL_JAR_MANIFEST:= +LOCAL_INSTRUMENTATION_FOR:= +LOCAL_APK_LIBRARIES:= +LOCAL_RES_LIBRARIES:= +LOCAL_MANIFEST_INSTRUMENTATION_FOR:= +LOCAL_AIDL_INCLUDES:= +LOCAL_VTS_INCLUDES:= +LOCAL_JARJAR_RULES:= +LOCAL_ADDITIONAL_JAVA_DIR:= +LOCAL_ALLOW_UNDEFINED_SYMBOLS:= +LOCAL_DX_FLAGS:= +LOCAL_JACK_ENABLED:=$(DEFAULT_JACK_ENABLED) # '' (ie disabled), disabled, full, incremental +LOCAL_JACK_FLAGS:= +LOCAL_JACK_COVERAGE_INCLUDE_FILTER:= +LOCAL_JACK_COVERAGE_EXCLUDE_FILTER:= +LOCAL_JILL_FLAGS:= +LOCAL_CERTIFICATE:= +LOCAL_SDK_VERSION:= +LOCAL_MIN_SDK_VERSION:= +LOCAL_SDK_RES_VERSION:= +LOCAL_NDK_STL_VARIANT:= +LOCAL_EMMA_INSTRUMENT:= +LOCAL_PROGUARD_ENABLED:= # '',full,custom,nosystem,disabled,obfuscation,optimization +LOCAL_PROGUARD_FLAGS:= +LOCAL_JACK_PROGUARD_FLAGS:= +LOCAL_PROGUARD_FLAG_FILES:= +LOCAL_TEST_MODULE_TO_PROGUARD_WITH:= +LOCAL_EMMA_COVERAGE_FILTER:= +LOCAL_WARNINGS_ENABLE:= +LOCAL_FULL_MANIFEST_FILE:= +LOCAL_MANIFEST_FILE:= +LOCAL_FULL_LIBS_MANIFEST_FILES:= +LOCAL_RENDERSCRIPT_INCLUDES:= +LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE:= +LOCAL_RENDERSCRIPT_CC:= +LOCAL_RENDERSCRIPT_COMPATIBILITY:= +LOCAL_RENDERSCRIPT_FLAGS:= +LOCAL_RENDERSCRIPT_TARGET_API:= +LOCAL_DEX_PREOPT:= # '',true,false,nostripping +LOCAL_DEX_PREOPT_IMAGE_LOCATION:= +LOCAL_DEX_PREOPT_FLAGS:= +LOCAL_PROTOC_OPTIMIZE_TYPE:= # lite(default),micro,nano,full,nanopb-c,nanopb-c-enable_malloc +LOCAL_PROTOC_FLAGS:= +LOCAL_PROTO_JAVA_OUTPUT_PARAMS:= +LOCAL_VTSC_FLAGS:= +LOCAL_NO_CRT:= +LOCAL_NO_LIBGCC:= +LOCAL_PROPRIETARY_MODULE:= +LOCAL_OEM_MODULE:= +LOCAL_ODM_MODULE:= +LOCAL_PRIVILEGED_MODULE:= +LOCAL_MODULE_OWNER:= +LOCAL_COMPATIBILITY_SUITE:= +LOCAL_COMPATIBILITY_SUPPORT_FILES:= +LOCAL_CTS_TEST_PACKAGE:= +LOCAL_CTS_TEST_RUNNER:= +LOCAL_CLANG:= +LOCAL_JAR_EXCLUDE_FILES:= +LOCAL_JAR_PACKAGES:= +LOCAL_JAR_EXCLUDE_PACKAGES:= +LOCAL_SOURCE_FILES_ALL_GENERATED:= # '',true +# Don't delete the META_INF dir when merging static Java libraries. +LOCAL_DONT_DELETE_JAR_META_INF:= +LOCAL_DONT_DELETE_JAR_DIRS:= +LOCAL_ADDITIONAL_CERTIFICATES:= +LOCAL_PREBUILT_MODULE_FILE:= +LOCAL_POST_LINK_CMD:= +LOCAL_POST_INSTALL_CMD:= +LOCAL_HAL_STATIC_LIBRARIES:= +LOCAL_RMTYPEDEFS:= +LOCAL_NO_SYNTAX_CHECK:= +LOCAL_NO_STATIC_ANALYZER:= +LOCAL_32_BIT_ONLY:= # '',true +LOCAL_MULTILIB:= +LOCAL_MODULE_TARGET_ARCH:= +LOCAL_MODULE_TARGET_ARCH_WARN:= +LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:= +LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:= +LOCAL_MODULE_HOST_ARCH:= +LOCAL_MODULE_HOST_ARCH_WARN:= +LOCAL_MODULE_UNSUPPORTED_HOST_ARCH:= +LOCAL_MODULE_UNSUPPORTED_HOST_ARCH_WARN:= +LOCAL_MODULE_HOST_CROSS_ARCH:= +LOCAL_MODULE_HOST_CROSS_ARCH_WARN:= +LOCAL_MODULE_UNSUPPORTED_HOST_CROSS_ARCH:= +LOCAL_MODULE_UNSUPPORTED_HOST_CROSS_ARCH_WARN:= +LOCAL_NO_FPIE := +LOCAL_CXX_STL := default +LOCAL_NATIVE_COVERAGE := +LOCAL_DPI_VARIANTS:= +LOCAL_DPI_FILE_STEM:= +LOCAL_SANITIZE:= +LOCAL_SANITIZE_RECOVER:= +LOCAL_DATA_BINDING:= +LOCAL_DBUS_PROXY_PREFIX:= +LOCAL_INIT_RC:= +LOCAL_MODULE_HOST_OS:= +LOCAL_FINDBUGS_FLAGS:= +LOCAL_NOTICE_FILE:= +LOCAL_USE_AAPT2:=$(USE_AAPT2) +LOCAL_STATIC_ANDROID_LIBRARIES:= +LOCAL_SHARED_ANDROID_LIBRARIES:= +# Used to replace the installed file of a presigned prebuilt apk in PDK fusion build, +# to avoid installing the presigned apks with classes.dex unstripped. +LOCAL_REPLACE_PREBUILT_APK_INSTALLED:= +LOCAL_EXTRACT_APK:= +LOCAL_EXTRACT_DPI_APK:= + +# arch specific variables +LOCAL_SRC_FILES_$(TARGET_ARCH):= +LOCAL_SRC_FILES_EXCLUDE_$(TARGET_ARCH):= +LOCAL_CFLAGS_$(TARGET_ARCH):= +LOCAL_CLANG_CFLAGS_$(TARGET_ARCH):= +LOCAL_CPPFLAGS_$(TARGET_ARCH):= +LOCAL_CLANG_CPPFLAGS_$(TARGET_ARCH):= +LOCAL_C_INCLUDES_$(TARGET_ARCH):= +LOCAL_ASFLAGS_$(TARGET_ARCH):= +LOCAL_CLANG_ASFLAGS_$(TARGET_ARCH):= +LOCAL_LDFLAGS_$(TARGET_ARCH):= +LOCAL_CLANG_LDFLAGS_$(TARGET_ARCH):= +LOCAL_SHARED_LIBRARIES_$(TARGET_ARCH):= +LOCAL_STATIC_LIBRARIES_$(TARGET_ARCH):= +LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_ARCH):= +LOCAL_GENERATED_SOURCES_$(TARGET_ARCH):= +LOCAL_REQUIRED_MODULES_$(TARGET_ARCH):= +LOCAL_CLANG_$(TARGET_ARCH):= +LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH):= +LOCAL_STRIP_MODULE_$(TARGET_ARCH):= +LOCAL_PACK_MODULE_RELOCATIONS_$(TARGET_ARCH):= +ifdef TARGET_2ND_ARCH +LOCAL_SRC_FILES_$(TARGET_2ND_ARCH):= +LOCAL_SRC_FILES_EXCLUDE_$(TARGET_2ND_ARCH):= +LOCAL_CFLAGS_$(TARGET_2ND_ARCH):= +LOCAL_CLANG_CFLAGS_$(TARGET_2ND_ARCH):= +LOCAL_CPPFLAGS_$(TARGET_2ND_ARCH):= +LOCAL_CLANG_CPPFLAGS_$(TARGET_2ND_ARCH):= +LOCAL_C_INCLUDES_$(TARGET_2ND_ARCH):= +LOCAL_ASFLAGS_$(TARGET_2ND_ARCH):= +LOCAL_CLANG_ASFLAGS_$(TARGET_2ND_ARCH):= +LOCAL_LDFLAGS_$(TARGET_2ND_ARCH):= +LOCAL_CLANG_LDFLAGS_$(TARGET_2ND_ARCH):= +LOCAL_SHARED_LIBRARIES_$(TARGET_2ND_ARCH):= +LOCAL_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):= +LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):= +LOCAL_GENERATED_SOURCES_$(TARGET_2ND_ARCH):= +LOCAL_REQUIRED_MODULES_$(TARGET_2ND_ARCH):= +LOCAL_CLANG_$(TARGET_2ND_ARCH):= +LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH):= +LOCAL_STRIP_MODULE_$(TARGET_2ND_ARCH):= +LOCAL_PACK_MODULE_RELOCATIONS_$(TARGET_2ND_ARCH):= +endif +LOCAL_SRC_FILES_$(HOST_ARCH):= +LOCAL_SRC_FILES_EXCLUDE_$(HOST_ARCH):= +LOCAL_CFLAGS_$(HOST_ARCH):= +LOCAL_CLANG_CFLAGS_$(HOST_ARCH):= +LOCAL_CPPFLAGS_$(HOST_ARCH):= +LOCAL_CLANG_CPPFLAGS_$(HOST_ARCH):= +LOCAL_C_INCLUDES_$(HOST_ARCH):= +LOCAL_ASFLAGS_$(HOST_ARCH):= +LOCAL_CLANG_ASFLAGS_$(HOST_ARCH):= +LOCAL_LDFLAGS_$(HOST_ARCH):= +LOCAL_CLANG_LDFLAGS_$(HOST_ARCH):= +LOCAL_SHARED_LIBRARIES_$(HOST_ARCH):= +LOCAL_STATIC_LIBRARIES_$(HOST_ARCH):= +LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_ARCH):= +LOCAL_GENERATED_SOURCES_$(HOST_ARCH):= +LOCAL_REQUIRED_MODULES_$(HOST_ARCH):= +LOCAL_CLANG_$(HOST_ARCH):= +ifdef HOST_2ND_ARCH +LOCAL_SRC_FILES_$(HOST_2ND_ARCH):= +LOCAL_SRC_FILES_EXCLUDE_$(HOST_2ND_ARCH):= +LOCAL_CFLAGS_$(HOST_2ND_ARCH):= +LOCAL_CLANG_CFLAGS_$(HOST_2ND_ARCH):= +LOCAL_CPPFLAGS_$(HOST_2ND_ARCH):= +LOCAL_CLANG_CPPFLAGS_$(HOST_2ND_ARCH):= +LOCAL_C_INCLUDES_$(HOST_2ND_ARCH):= +LOCAL_ASFLAGS_$(HOST_2ND_ARCH):= +LOCAL_CLANG_ASFLAGS_$(HOST_2ND_ARCH):= +LOCAL_LDFLAGS_$(HOST_2ND_ARCH):= +LOCAL_CLANG_LDFLAGS_$(HOST_2ND_ARCH):= +LOCAL_SHARED_LIBRARIES_$(HOST_2ND_ARCH):= +LOCAL_STATIC_LIBRARIES_$(HOST_2ND_ARCH):= +LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_2ND_ARCH):= +LOCAL_GENERATED_SOURCES_$(HOST_2ND_ARCH):= +LOCAL_REQUIRED_MODULES_$(HOST_2ND_ARCH):= +LOCAL_CLANG_$(HOST_2ND_ARCH):= +endif + +LOCAL_SRC_FILES_$(HOST_OS):= +LOCAL_STATIC_LIBRARIES_$(HOST_OS):= +LOCAL_SHARED_LIBRARIES_$(HOST_OS):= +LOCAL_CFLAGS_$(HOST_OS):= +LOCAL_CPPFLAGS_$(HOST_OS):= +LOCAL_LDFLAGS_$(HOST_OS):= +LOCAL_LDLIBS_$(HOST_OS):= +LOCAL_ASFLAGS_$(HOST_OS):= +LOCAL_C_INCLUDES_$(HOST_OS):= +LOCAL_GENERATED_SOURCES_$(HOST_OS):= +LOCAL_REQUIRED_MODULES_$(HOST_OS):= + +ifdef HOST_CROSS_OS +LOCAL_SRC_FILES_$(HOST_CROSS_OS):= +LOCAL_STATIC_LIBRARIES_$(HOST_CROSS_OS):= +LOCAL_SHARED_LIBRARIES_$(HOST_CROSS_OS):= +LOCAL_CFLAGS_$(HOST_CROSS_OS):= +LOCAL_CPPFLAGS_$(HOST_CROSS_OS):= +LOCAL_LDFLAGS_$(HOST_CROSS_OS):= +LOCAL_LDLIBS_$(HOST_CROSS_OS):= +LOCAL_ASFLAGS_$(HOST_CROSS_OS):= +LOCAL_C_INCLUDES_$(HOST_CROSS_OS):= +LOCAL_GENERATED_SOURCES_$(HOST_CROSS_OS):= +LOCAL_REQUIRED_MODULES_$(HOST_CROSS_OS):= +endif + +LOCAL_SRC_FILES_$(HOST_OS)_$(HOST_ARCH):= +ifdef HOST_2ND_ARCH +LOCAL_SRC_FILES_$(HOST_OS)_$(HOST_2ND_ARCH):= +endif +ifdef HOST_CROSS_OS +LOCAL_SRC_FILES_$(HOST_CROSS_OS)_$(HOST_CROSS_ARCH):= +ifdef HOST_CROSS_2ND_ARCH +LOCAL_SRC_FILES_$(HOST_CROSS_OS)_$(HOST_CROSS_2ND_ARCH):= +endif +endif + +LOCAL_SRC_FILES_32:= +LOCAL_SRC_FILES_64:= +LOCAL_SRC_FILES_EXCLUDE_32:= +LOCAL_SRC_FILES_EXCLUDE_64:= +LOCAL_SHARED_LIBRARIES_32:= +LOCAL_SHARED_LIBRARIES_64:= +LOCAL_STATIC_LIBRARIES_32:= +LOCAL_STATIC_LIBRARIES_64:= +LOCAL_WHOLE_STATIC_LIBRARIES_32:= +LOCAL_WHOLE_STATIC_LIBRARIES_64:= +LOCAL_GENERATED_SOURCES_32:= +LOCAL_GENERATED_SOURCES_64:= +LOCAL_CFLAGS_32:= +LOCAL_CFLAGS_64:= +LOCAL_CPPFLAGS_32:= +LOCAL_CPPFLAGS_64:= +LOCAL_LDFLAGS_32:= +LOCAL_LDFLAGS_64:= +LOCAL_ASFLAGS_32:= +LOCAL_ASFLAGS_64:= +LOCAL_CLANG_CFLAGS_32:= +LOCAL_CLANG_CFLAGS_64:= +LOCAL_CLANG_CPPFLAGS_32:= +LOCAL_CLANG_CPPFLAGS_64:= +LOCAL_CLANG_LDFLAGS_32:= +LOCAL_CLANG_LDFLAGS_64:= +LOCAL_CLANG_ASFLAGS_32:= +LOCAL_CLANG_ASFLAGS_64:= +LOCAL_C_INCLUDES_32:= +LOCAL_C_INCLUDES_64:= +LOCAL_MODULE_PATH_32:= +LOCAL_MODULE_PATH_64:= +LOCAL_MODULE_STEM_32:= +LOCAL_MODULE_STEM_64:= +LOCAL_CLANG_32:= +LOCAL_CLANG_64:= +LOCAL_INIT_RC_32:= +LOCAL_INIT_RC_64:= +LOCAL_JAVA_LANGUAGE_VERSION:= + +# Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to +# iterate over thousands of entries every time. +# Leave the current makefile to make sure we don't break anything +# that expects to be able to find the name of the current makefile. +MAKEFILE_LIST := $(lastword $(MAKEFILE_LIST)) diff --git a/core/combo/HOST_CROSS_windows-x86.mk b/core/combo/HOST_CROSS_windows-x86.mk new file mode 100644 index 0000000000000000000000000000000000000000..6180a265a8814985aaf4b278c9250b62678b7db7 --- /dev/null +++ b/core/combo/HOST_CROSS_windows-x86.mk @@ -0,0 +1,65 @@ +# +# Copyright (C) 2006 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Settings to use MinGW as a cross-compiler under Linux +# Included by combo/select.make + +$(combo_var_prefix)GLOBAL_CFLAGS += -DUSE_MINGW -DWIN32_LEAN_AND_MEAN +$(combo_var_prefix)GLOBAL_CFLAGS += -Wno-unused-parameter +$(combo_var_prefix)GLOBAL_CFLAGS += --sysroot prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32 +$(combo_var_prefix)GLOBAL_CFLAGS += -m32 +$(combo_var_prefix)GLOBAL_LDFLAGS += -m32 +TOOLS_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/bin/x86_64-w64-mingw32- +$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/include +$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/lib/gcc/x86_64-w64-mingw32/4.8.3/include +$(combo_var_prefix)GLOBAL_LD_DIRS += -Lprebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib32 + +# Workaround differences in inttypes.h between host and target. +# See bug 12708004. +$(combo_var_prefix)GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS +# Use C99-compliant printf functions (%zd). +$(combo_var_prefix)GLOBAL_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 +# Admit to using >= Vista. Both are needed because of <_mingw.h>. +$(combo_var_prefix)GLOBAL_CFLAGS += -D_WIN32_WINNT=0x0600 -DWINVER=0x0600 +# Get 64-bit off_t and related functions. +$(combo_var_prefix)GLOBAL_CFLAGS += -D_FILE_OFFSET_BITS=64 + +$(combo_var_prefix)CC := $(TOOLS_PREFIX)gcc +$(combo_var_prefix)CXX := $(TOOLS_PREFIX)g++ +$(combo_var_prefix)AR := $(TOOLS_PREFIX)ar +$(combo_var_prefix)NM := $(TOOLS_PREFIX)nm +$(combo_var_prefix)OBJDUMP := $(TOOLS_PREFIX)objdump + +define $(combo_var_prefix)transform-shared-lib-to-toc +$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OBJDUMP) -x $(1) | grep "^Name" | cut -f3 -d" " > $(2) +$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)NM) -g -f p $(1) | cut -f1-2 -d" " >> $(2) +endef + +$(combo_var_prefix)GLOBAL_LDFLAGS += \ + --enable-stdcall-fixup + +ifneq ($(strip $(BUILD_HOST_static)),) +# Statically-linked binaries are desirable for sandboxed environment +$(combo_var_prefix)GLOBAL_LDFLAGS += -static +endif # BUILD_HOST_static + +$(combo_var_prefix)SHLIB_SUFFIX := .dll +$(combo_var_prefix)EXECUTABLE_SUFFIX := .exe + +$(combo_var_prefix)IS_64_BIT := + +# The mingw gcc is 4.8, 4.9 is required for color diagnostics +$(combo_var_prefix)UNKNOWN_CFLAGS := -fdiagnostics-color diff --git a/core/combo/HOST_CROSS_windows-x86_64.mk b/core/combo/HOST_CROSS_windows-x86_64.mk new file mode 100644 index 0000000000000000000000000000000000000000..e9b19cf954302a06b6fc34d134845c5e3880edc2 --- /dev/null +++ b/core/combo/HOST_CROSS_windows-x86_64.mk @@ -0,0 +1,65 @@ +# +# Copyright (C) 2006 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Settings to use MinGW as a cross-compiler under Linux +# Included by combo/select.make + +$(combo_var_prefix)GLOBAL_CFLAGS += -DUSE_MINGW -DWIN32_LEAN_AND_MEAN +$(combo_var_prefix)GLOBAL_CFLAGS += -Wno-unused-parameter +$(combo_var_prefix)GLOBAL_CFLAGS += --sysroot prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32 +$(combo_var_prefix)GLOBAL_CFLAGS += -m64 +$(combo_var_prefix)GLOBAL_LDFLAGS += -m64 +TOOLS_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/bin/x86_64-w64-mingw32- +$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/include +$(combo_var_prefix)C_INCLUDES += prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/lib/gcc/x86_64-w64-mingw32/4.8.3/include +$(combo_var_prefix)GLOBAL_LD_DIRS += -Lprebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/lib64 + +# Workaround differences in inttypes.h between host and target. +# See bug 12708004. +$(combo_var_prefix)GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS +# Use C99-compliant printf functions (%zd). +$(combo_var_prefix)GLOBAL_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1 +# Admit to using >= Vista. Both are needed because of <_mingw.h>. +$(combo_var_prefix)GLOBAL_CFLAGS += -D_WIN32_WINNT=0x0600 -DWINVER=0x0600 +# Get 64-bit off_t and related functions. +$(combo_var_prefix)GLOBAL_CFLAGS += -D_FILE_OFFSET_BITS=64 + +$(combo_var_prefix)CC := $(TOOLS_PREFIX)gcc +$(combo_var_prefix)CXX := $(TOOLS_PREFIX)g++ +$(combo_var_prefix)AR := $(TOOLS_PREFIX)ar +$(combo_var_prefix)NM := $(TOOLS_PREFIX)nm +$(combo_var_prefix)OBJDUMP := $(TOOLS_PREFIX)objdump + +define $(combo_var_prefix)transform-shared-lib-to-toc +$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OBJDUMP) -x $(1) | grep "^Name" | cut -f3 -d" " > $(2) +$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)NM) -g -f p $(1) | cut -f1-2 -d" " >> $(2) +endef + +$(combo_var_prefix)GLOBAL_LDFLAGS += \ + --enable-stdcall-fixup + +ifneq ($(strip $(BUILD_HOST_static)),) +# Statically-linked binaries are desirable for sandboxed environment +$(combo_var_prefix)GLOBAL_LDFLAGS += -static +endif # BUILD_HOST_static + +$(combo_var_prefix)SHLIB_SUFFIX := .dll +$(combo_var_prefix)EXECUTABLE_SUFFIX := .exe + +$(combo_var_prefix)IS_64_BIT := true + +# The mingw gcc is 4.8, 4.9 is required for color diagnostics +$(combo_var_prefix)UNKNOWN_CFLAGS := -fdiagnostics-color diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk new file mode 100644 index 0000000000000000000000000000000000000000..fc56e52996fd85179abe5ffd4ad1f502dc347b3d --- /dev/null +++ b/core/combo/HOST_darwin-x86.mk @@ -0,0 +1,106 @@ +# +# Copyright (C) 2006 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Configuration for Darwin (Mac OS X) on x86. +# Included by combo/select.mk + +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -m32 +$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32 + +ifneq ($(strip $(BUILD_HOST_static)),) +# Statically-linked binaries are desirable for sandboxed environment +$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static +endif # BUILD_HOST_static + +# Workaround differences in inttypes.h between host and target. +# See bug 12708004. +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS + +include $(BUILD_COMBOS)/mac_version.mk + +$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1 +$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version) +$(combo_2nd_arch_prefix)HOST_CC := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-gcc +$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)-g++ + +define $(combo_var_prefix)transform-shared-lib-to-toc +$(call _gen_toc_command_for_macho,$(1),$(2)) +endef + +# gcc location for clang; to be updated when clang is updated +# HOST_TOOLCHAIN_ROOT is a Darwin-specific define +$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_ROOT) + +$(combo_2nd_arch_prefix)HOST_AR := $(AR) + +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version) +$(combo_2nd_arch_prefix)HOST_GLOBAL_CPPFLAGS += -isystem $(mac_sdk_path)/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 +$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) + +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables +$(combo_2nd_arch_prefix)HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error + +$(combo_2nd_arch_prefix)HOST_SHLIB_SUFFIX := .dylib +$(combo_2nd_arch_prefix)HOST_JNILIB_SUFFIX := .jnilib + +$(combo_2nd_arch_prefix)HOST_GLOBAL_ARFLAGS := cqs + +############################################################ +## Macros after this line are shared by the 64-bit config. + +HOST_CUSTOM_LD_COMMAND := true + +define transform-host-o-to-shared-lib-inner +$(hide) $(PRIVATE_CXX) \ + -dynamiclib -single_module -read_only_relocs suppress \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \ + $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ + $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ + ) \ + $(PRIVATE_ALL_OBJECTS) \ + $(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ + $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ + $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ + $(PRIVATE_LDLIBS) \ + -o $@ \ + -install_name @rpath/$(notdir $@) \ + -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ + -Wl,-rpath,@loader_path/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ + $(PRIVATE_LDFLAGS) +endef + +define transform-host-o-to-executable-inner +$(hide) $(PRIVATE_CXX) \ + -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ + -Wl,-rpath,@loader_path/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ + -o $@ \ + -Wl,-headerpad_max_install_names \ + $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \ + $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ + $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ + ) \ + $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ + $(PRIVATE_ALL_OBJECTS) \ + $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \ + $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \ + $(PRIVATE_LDFLAGS) \ + $(PRIVATE_LDLIBS) +endef + +# $(1): The file to check +define get-file-size +stat -f "%z" $(1) +endef diff --git a/core/combo/HOST_darwin-x86_64.mk b/core/combo/HOST_darwin-x86_64.mk new file mode 100644 index 0000000000000000000000000000000000000000..251455f0bf6e914147f526af04c9548380597563 --- /dev/null +++ b/core/combo/HOST_darwin-x86_64.mk @@ -0,0 +1,64 @@ +# +# Copyright (C) 2006 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Configuration for Darwin (Mac OS X) on x86_64. +# Included by combo/select.mk + +HOST_GLOBAL_CFLAGS += -m64 +HOST_GLOBAL_LDFLAGS += -m64 + +ifneq ($(strip $(BUILD_HOST_static)),) +# Statically-linked binaries are desirable for sandboxed environment +HOST_GLOBAL_LDFLAGS += -static +endif # BUILD_HOST_static + +# Workaround differences in inttypes.h between host and target. +# See bug 12708004. +HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS + +include $(BUILD_COMBOS)/mac_version.mk + +HOST_TOOLCHAIN_ROOT := prebuilts/gcc/darwin-x86/host/i686-apple-darwin-4.2.1 +HOST_TOOLCHAIN_PREFIX := $(HOST_TOOLCHAIN_ROOT)/bin/i686-apple-darwin$(gcc_darwin_version) +HOST_CC := $(HOST_TOOLCHAIN_PREFIX)-gcc +HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)-g++ + +define $(combo_var_prefix)transform-shared-lib-to-toc +$(call _gen_toc_command_for_macho,$(1),$(2)) +endef + +# gcc location for clang; to be updated when clang is updated +# HOST_TOOLCHAIN_ROOT is a Darwin-specific define +HOST_TOOLCHAIN_FOR_CLANG := $(HOST_TOOLCHAIN_ROOT) + +HOST_AR := $(AR) + +HOST_GLOBAL_CFLAGS += -isysroot $(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) -DMACOSX_DEPLOYMENT_TARGET=$(mac_sdk_version) +HOST_GLOBAL_CPPFLAGS += -isystem $(mac_sdk_path)/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1 +HOST_GLOBAL_LDFLAGS += -isysroot $(mac_sdk_root) -Wl,-syslibroot,$(mac_sdk_root) -mmacosx-version-min=$(mac_sdk_version) + +HOST_GLOBAL_CFLAGS += -fPIC -funwind-tables +HOST_NO_UNDEFINED_LDFLAGS := -Wl,-undefined,error + +HOST_SHLIB_SUFFIX := .dylib +HOST_JNILIB_SUFFIX := .jnilib + +HOST_GLOBAL_ARFLAGS := cqs + +# We Reuse the following functions with the same name from HOST_darwin-x86.mk: +# transform-host-o-to-shared-lib-inner +# transform-host-o-to-executable-inner +# get-file-size diff --git a/core/combo/HOST_linux-x86.mk b/core/combo/HOST_linux-x86.mk new file mode 100644 index 0000000000000000000000000000000000000000..169e2d2448a31e5c6de3e88d6151a40c63af7b65 --- /dev/null +++ b/core/combo/HOST_linux-x86.mk @@ -0,0 +1,66 @@ +# +# Copyright (C) 2006 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Configuration for builds hosted on linux-x86. +# Included by combo/select.mk + +ifeq ($(strip $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)),) +$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux- +endif +$(combo_2nd_arch_prefix)HOST_CC := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)gcc +$(combo_2nd_arch_prefix)HOST_CXX := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)g++ +$(combo_2nd_arch_prefix)HOST_AR := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)ar +$(combo_2nd_arch_prefix)HOST_READELF := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)readelf +$(combo_2nd_arch_prefix)HOST_NM := $($(combo_2nd_arch_prefix)HOST_TOOLCHAIN_PREFIX)nm + +define $(combo_var_prefix)transform-shared-lib-to-toc +$(call _gen_toc_command_for_elf,$(1),$(2)) +endef + +# gcc location for clang; to be updated when clang is updated +$(combo_2nd_arch_prefix)HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 + +# We expect SSE3 floating point math. +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -msse3 -mfpmath=sse -m32 -Wa,--noexecstack -march=prescott +$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -m32 -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--no-undefined-version + +ifneq ($(strip $(BUILD_HOST_static)),) +# Statically-linked binaries are desirable for sandboxed environment +$(combo_2nd_arch_prefix)HOST_GLOBAL_LDFLAGS += -static +endif # BUILD_HOST_static + +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -fPIC \ + -no-canonical-prefixes \ + +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector + +# Workaround differences in inttypes.h between host and target. +# See bug 12708004. +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS + +# We build a 32-bit host art, and right now that also means building *all* host libraries +# both 32- and 64-bit (whether art uses them or not --- 9d59f417767991246848c3e101cb27d2dfea5988). +$(combo_2nd_arch_prefix)HOST_GLOBAL_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 + +$(combo_2nd_arch_prefix)HOST_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined + +############################################################ +## Macros after this line are shared by the 64-bit config. + +# $(1): The file to check +define get-file-size +stat --format "%s" "$(1)" | tr -d '\n' +endef diff --git a/core/combo/HOST_linux-x86_64.mk b/core/combo/HOST_linux-x86_64.mk new file mode 100644 index 0000000000000000000000000000000000000000..9766f2bde8b538b533fb9d8f1f9d163a406cdb33 --- /dev/null +++ b/core/combo/HOST_linux-x86_64.mk @@ -0,0 +1,53 @@ +# +# Copyright (C) 2006 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Configuration for builds hosted on linux-x86_64. +# Included by combo/select.mk + +ifeq ($(strip $(HOST_TOOLCHAIN_PREFIX)),) +HOST_TOOLCHAIN_PREFIX := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux- +endif +HOST_CC := $(HOST_TOOLCHAIN_PREFIX)gcc +HOST_CXX := $(HOST_TOOLCHAIN_PREFIX)g++ +HOST_AR := $(HOST_TOOLCHAIN_PREFIX)ar +HOST_READELF := $(HOST_TOOLCHAIN_PREFIX)readelf +HOST_NM := $(HOST_TOOLCHAIN_PREFIX)nm + +define $(combo_var_prefix)transform-shared-lib-to-toc +$(call _gen_toc_command_for_elf,$(1),$(2)) +endef + +# gcc location for clang; to be updated when clang is updated +HOST_TOOLCHAIN_FOR_CLANG := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8 + +HOST_GLOBAL_CFLAGS += -m64 -Wa,--noexecstack +HOST_GLOBAL_LDFLAGS += -m64 -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--no-undefined-version + +ifneq ($(strip $(BUILD_HOST_static)),) +# Statically-linked binaries are desirable for sandboxed environment +HOST_GLOBAL_LDFLAGS += -static +endif # BUILD_HOST_static + +HOST_GLOBAL_CFLAGS += -fPIC \ + -no-canonical-prefixes \ + +HOST_GLOBAL_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fstack-protector + +# Workaround differences in inttypes.h between host and target. +# See bug 12708004. +HOST_GLOBAL_CFLAGS += -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS + +HOST_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined diff --git a/core/combo/TARGET_linux-arm.mk b/core/combo/TARGET_linux-arm.mk new file mode 100644 index 0000000000000000000000000000000000000000..510aae52f2d9a1d73096b5adfd9dc618f20fc2b4 --- /dev/null +++ b/core/combo/TARGET_linux-arm.mk @@ -0,0 +1,195 @@ +# +# Copyright (C) 2006 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Configuration for Linux on ARM. +# Included by combo/select.mk + +# You can set TARGET_ARCH_VARIANT to use an arch version other +# than ARMv5TE. Each value should correspond to a file named +# $(BUILD_COMBOS)/arch/.mk which must contain +# makefile variable definitions. Their +# purpose is to allow module Android.mk files to selectively compile +# different versions of code based upon the funtionality and +# instructions available in a given architecture version. +# +# The blocks also define specific arch_variant_cflags, which +# include defines, and compiler settings for the given architecture +# version. +# +ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),) +TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := armv5te +endif + +# Decouple NDK library selection with platform compiler version +$(combo_2nd_arch_prefix)TARGET_NDK_GCC_VERSION := 4.9 + +ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),) +$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := 4.9 +else +$(combo_2nd_arch_prefix)TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP) +endif + +TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_$(combo_2nd_arch_prefix)ARCH)/$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT).mk +ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),) +$(error Unknown ARM architecture version: $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)) +endif + +include $(TARGET_ARCH_SPECIFIC_MAKEFILE) +include $(BUILD_SYSTEM)/combo/fdo.mk + +# You can set TARGET_TOOLS_PREFIX to get gcc from somewhere else +ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)),) +$(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/arm/arm-linux-androideabi-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION) +$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/arm-linux-androideabi- +endif + +$(combo_2nd_arch_prefix)TARGET_CC := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)gcc +$(combo_2nd_arch_prefix)TARGET_CXX := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)g++ +$(combo_2nd_arch_prefix)TARGET_AR := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ar +$(combo_2nd_arch_prefix)TARGET_OBJCOPY := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)objcopy +$(combo_2nd_arch_prefix)TARGET_LD := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)ld +$(combo_2nd_arch_prefix)TARGET_READELF := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)readelf +$(combo_2nd_arch_prefix)TARGET_STRIP := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)strip +$(combo_2nd_arch_prefix)TARGET_NM := $($(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX)nm + +define $(combo_var_prefix)transform-shared-lib-to-toc +$(call _gen_toc_command_for_elf,$(1),$(2)) +endef + +$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined + +$(combo_2nd_arch_prefix)TARGET_arm_CFLAGS := -O2 \ + -fomit-frame-pointer \ + -fstrict-aliasing \ + -funswitch-loops + +# Modules can choose to compile some source as thumb. +$(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS := -mthumb \ + -Os \ + -fomit-frame-pointer \ + -fno-strict-aliasing + +# Set FORCE_ARM_DEBUGGING to "true" in your buildspec.mk +# or in your environment to force a full arm build, even for +# files that are normally built as thumb; this can make +# gdb debugging easier. Don't forget to do a clean build. +# +# NOTE: if you try to build a -O0 build with thumb, several +# of the libraries (libpv, libwebcore, libkjs) need to be built +# with -mlong-calls. When built at -O0, those libraries are +# too big for a thumb "BL