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.sh
you'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_ - These variables are set per-module. They are cleared
+ by the include $(CLEAR_VARS)
line, so you can rely on them
+ being empty after including that file. Most of the variables you'll use
+ in most modules are LOCAL_ variables.
+ PRIVATE_ - These variables are make-target-specific variables. That
+ means they're only usable within the commands for that module. It also
+ means that they're unlikely to change behind your back from modules that
+ are included after yours. This
+ link to the make documentation
+ describes more about target-specific variables. Please note that there
+ are a couple of these laying around the tree that aren't prefixed with
+ PRIVATE_. It is safe, and they will be fixed as they are discovered.
+ Sorry for the confusion.
+ INTERNAL_ - These variables are critical to functioning of
+ the build system, so you shouldn't create variables named like this, and
+ you probably shouldn't be messing with these variables in your makefiles.
+
+ HOST_ and TARGET_ - These contain the directories
+ and definitions that are specific to either the host or the target builds.
+ Do not set variables that start with HOST_ or TARGET_ in your makefiles.
+
+ HOST_CROSS_ - These contain the directories and definitions that
+ are specific to cross-building host binaries. The common case is building
+ windows host tools on linux. Do not set variables that start with
+ HOST_CROSS_ in your makefiles.
+
+ BUILD_ and CLEAR_VARS - These contain the names of
+ well-defined template makefiles to include. Some examples are CLEAR_VARS
+ and BUILD_HOST_PACKAGE.
+ Any other name is fair-game for you to use in your Android.mk. However,
+ remember that this is a non-recursive build system, so it is possible that
+ your variable will be changed by another Android.mk included later, and be
+ different when the commands for your rule / module are executed.
+
+
+
+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 " to go from one end to the other.
+ifeq ($(FORCE_ARM_DEBUGGING),true)
+ $(combo_2nd_arch_prefix)TARGET_arm_CFLAGS += -fno-omit-frame-pointer -fno-strict-aliasing
+ $(combo_2nd_arch_prefix)TARGET_thumb_CFLAGS += -marm -fno-omit-frame-pointer
+endif
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
+ -msoft-float \
+ -ffunction-sections \
+ -fdata-sections \
+ -funwind-tables \
+ -fstack-protector-strong \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -fno-short-enums \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+ $(arch_variant_cflags) \
+
+# The "-Wunused-but-set-variable" option often breaks projects that enable
+# "-Wall -Werror" due to a commom idiom "ALOGV(mesg)" where ALOGV is turned
+# into no-op in some builds while mesg is defined earlier. So we explicitly
+# disable "-Wunused-but-set-variable" here.
+ifneq ($(filter 4.6 4.6.% 4.7 4.7.% 4.8 4.9, $($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)),)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -fno-builtin-sin \
+ -fno-strict-volatile-bitfields
+endif
+
+# This is to avoid the dreaded warning compiler message:
+# note: the mangling of 'va_list' has changed in GCC 4.4
+#
+# The fact that the mangling changed does not affect the NDK ABI
+# very fortunately (since none of the exposed APIs used va_list
+# in their exported C++ functions). Also, GCC 4.5 has already
+# removed the warning from the compiler.
+#
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -Wno-psabi
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += \
+ -Wl,-z,noexecstack \
+ -Wl,-z,relro \
+ -Wl,-z,now \
+ -Wl,--build-id=md5 \
+ -Wl,--warn-shared-textrel \
+ -Wl,--fatal-warnings \
+ -Wl,--icf=safe \
+ -Wl,--hash-style=gnu \
+ -Wl,--no-undefined-version \
+ $(arch_variant_ldflags)
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mthumb-interwork
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
+
+# More flags/options can be added here
+$(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \
+ -DNDEBUG \
+ -g \
+ -Wstrict-aliasing=2 \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers
+
+libc_root := bionic/libc
+libm_root := bionic/libm
+
+
+## on some hosts, the target cross-compiler is not available so do not run this command
+ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
+# We compile with the global cflags to ensure that
+# any flags which affect libgcc are correctly taken
+# into account.
+$(combo_2nd_arch_prefix)TARGET_LIBGCC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
+ $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-libgcc-file-name)
+$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
+ $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a)
+$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) \
+ $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcov.a)
+endif
+
+KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
+KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
+KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_$(combo_2nd_arch_prefix)ARCH)
+KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
+
+$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
+ $(libc_root)/arch-arm/include \
+ $(libc_root)/include \
+ $(KERNEL_HEADERS) \
+ $(libm_root)/include \
+ $(libm_root)/include/arm \
+
+$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
+$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
+$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
+
+$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
+$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
+
+$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
+
+$(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
diff --git a/core/combo/TARGET_linux-arm64.mk b/core/combo/TARGET_linux-arm64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6a1d8619fbcfbe2d285b2fcc36d6696a81b92a01
--- /dev/null
+++ b/core/combo/TARGET_linux-arm64.mk
@@ -0,0 +1,168 @@
+#
+# Copyright (C) 2013 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_ARCH_VARIANT)),)
+TARGET_ARCH_VARIANT := armv8
+endif
+
+# Decouple NDK library selection with platform compiler version
+TARGET_NDK_GCC_VERSION := 4.9
+
+ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
+TARGET_GCC_VERSION := 4.9
+else
+TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
+endif
+
+TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
+ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
+$(error Unknown ARM architecture version: $(TARGET_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 $(TARGET_TOOLS_PREFIX)),)
+TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/aarch64/aarch64-linux-android-$(TARGET_GCC_VERSION)
+TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/aarch64-linux-android-
+endif
+
+TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc
+TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++
+TARGET_AR := $(TARGET_TOOLS_PREFIX)ar
+TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy
+TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
+TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
+TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
+TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
+
+TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
+
+TARGET_GLOBAL_CFLAGS += \
+ -fno-strict-aliasing \
+
+TARGET_GLOBAL_CFLAGS += \
+ -fstack-protector-strong \
+ -ffunction-sections \
+ -fdata-sections \
+ -funwind-tables \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -fno-short-enums \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+ $(arch_variant_cflags) \
+
+# Help catch common 32/64-bit errors.
+TARGET_GLOBAL_CFLAGS += \
+ -Werror=pointer-to-int-cast \
+ -Werror=int-to-pointer-cast \
+ -Werror=implicit-function-declaration \
+
+TARGET_GLOBAL_CFLAGS += -fno-strict-volatile-bitfields
+
+# This is to avoid the dreaded warning compiler message:
+# note: the mangling of 'va_list' has changed in GCC 4.4
+#
+# The fact that the mangling changed does not affect the NDK ABI
+# very fortunately (since none of the exposed APIs used va_list
+# in their exported C++ functions). Also, GCC 4.5 has already
+# removed the warning from the compiler.
+#
+TARGET_GLOBAL_CFLAGS += -Wno-psabi
+
+TARGET_GLOBAL_LDFLAGS += \
+ -Wl,-z,noexecstack \
+ -Wl,-z,relro \
+ -Wl,-z,now \
+ -Wl,--build-id=md5 \
+ -Wl,--warn-shared-textrel \
+ -Wl,--fatal-warnings \
+ -Wl,-maarch64linux \
+ -Wl,--hash-style=gnu \
+ -Wl,--fix-cortex-a53-843419 \
+ -fuse-ld=gold \
+ -Wl,--icf=safe \
+ -Wl,--no-undefined-version \
+ $(arch_variant_ldflags)
+
+# Disable transitive dependency library symbol resolving.
+TARGET_GLOBAL_LDFLAGS += -Wl,--allow-shlib-undefined
+
+TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
+
+# More flags/options can be added here
+TARGET_RELEASE_CFLAGS := \
+ -DNDEBUG \
+ -O2 -g \
+ -Wstrict-aliasing=2 \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers
+
+libc_root := bionic/libc
+libm_root := bionic/libm
+
+TARGET_LIBGCC := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
+ -print-libgcc-file-name)
+TARGET_LIBATOMIC := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
+ -print-file-name=libatomic.a)
+TARGET_LIBGCOV := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
+ -print-file-name=libgcov.a)
+
+KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
+KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
+KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH)
+KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
+
+TARGET_C_INCLUDES := \
+ $(libc_root)/arch-arm64/include \
+ $(libc_root)/include \
+ $(KERNEL_HEADERS) \
+ $(libm_root)/include \
+ $(libm_root)/include/arm64 \
+
+TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
+TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
+TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
+
+TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
+TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
+
+TARGET_PACK_MODULE_RELOCATIONS := true
+
+TARGET_LINKER := /system/bin/linker64
diff --git a/core/combo/TARGET_linux-mips.mk b/core/combo/TARGET_linux-mips.mk
new file mode 100644
index 0000000000000000000000000000000000000000..186d88f2596e22c1b1f90ca53397a5e98cf78c17
--- /dev/null
+++ b/core/combo/TARGET_linux-mips.mk
@@ -0,0 +1,170 @@
+#
+# Copyright (C) 2010 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 MIPS.
+# Included by combo/select.mk
+
+# You can set TARGET_ARCH_VARIANT to use an arch version other
+# than mips32r2-fp. 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 := mips32r2-fp
+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 MIPS architecture variant: $(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)/mips/mips64el-linux-android-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)
+$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/mips64el-linux-android-
+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
+
+TARGET_mips_CFLAGS := -O2 \
+ -fomit-frame-pointer \
+ -fno-strict-aliasing \
+ -funswitch-loops
+
+# Set FORCE_MIPS_DEBUGGING to "true" in your buildspec.mk
+# or in your environment to gdb debugging easier.
+# Don't forget to do a clean build.
+ifeq ($(FORCE_MIPS_DEBUGGING),true)
+ TARGET_mips_CFLAGS += -fno-omit-frame-pointer
+endif
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
+ $(TARGET_mips_CFLAGS) \
+ -U__unix -U__unix__ -Umips \
+ -ffunction-sections \
+ -fdata-sections \
+ -funwind-tables \
+ -fstack-protector-strong \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+ $(arch_variant_cflags) \
+
+ifneq ($(ARCH_MIPS_PAGE_SHIFT),)
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -DPAGE_SHIFT=$(ARCH_MIPS_PAGE_SHIFT)
+endif
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += \
+ -Wl,-z,noexecstack \
+ -Wl,-z,relro \
+ -Wl,-z,now \
+ -Wl,--build-id=md5 \
+ -Wl,--warn-shared-textrel \
+ -Wl,--fatal-warnings \
+ -Wl,--no-undefined-version \
+ $(arch_variant_ldflags)
+
+# Disable transitive dependency library symbol resolving.
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--allow-shlib-undefined
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
+
+# More flags/options can be added here
+$(combo_2nd_arch_prefix)TARGET_RELEASE_CFLAGS := \
+ -DNDEBUG \
+ -g \
+ -Wstrict-aliasing=2 \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers
+
+libc_root := bionic/libc
+libm_root := bionic/libm
+
+
+## on some hosts, the target cross-compiler is not available so do not run this command
+ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
+# We compile with the global cflags to ensure that
+# any flags which affect libgcc are correctly taken
+# into account.
+$(combo_2nd_arch_prefix)TARGET_LIBGCC := \
+ $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc.a)
+$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := \
+ $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a)
+LIBGCC_EH := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc_eh.a)
+ifneq ($(LIBGCC_EH),libgcc_eh.a)
+ $(combo_2nd_arch_prefix)TARGET_LIBGCC += $(LIBGCC_EH)
+endif
+$(combo_2nd_arch_prefix)TARGET_LIBGCOV := $(shell $($(combo_2nd_arch_prefix)TARGET_CC) $($(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS) \
+ --print-file-name=libgcov.a)
+endif
+
+KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
+KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
+KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-mips # mips covers both mips and mips64.
+KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
+
+$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
+ $(libc_root)/arch-mips/include \
+ $(libc_root)/include \
+ $(KERNEL_HEADERS) \
+ $(libm_root)/include \
+ $(libm_root)/include/mips \
+
+$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
+$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
+$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
+
+$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
+$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
+
+$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
+
+$(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
diff --git a/core/combo/TARGET_linux-mips64.mk b/core/combo/TARGET_linux-mips64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..3e1f61a0ff578073053f119bb12fb6430e381cb6
--- /dev/null
+++ b/core/combo/TARGET_linux-mips64.mk
@@ -0,0 +1,179 @@
+#
+# Copyright (C) 2013 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 MIPS64.
+# Included by combo/select.mk
+
+# You can set TARGET_ARCH_VARIANT to use an arch version other
+# than mips64r6. 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_ARCH_VARIANT)),)
+TARGET_ARCH_VARIANT := mips64r6
+endif
+
+# Decouple NDK library selection with platform compiler version
+TARGET_NDK_GCC_VERSION := 4.9
+
+ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
+TARGET_GCC_VERSION := 4.9
+else
+TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
+endif
+
+TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
+ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
+$(error Unknown MIPS architecture variant: $(TARGET_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 $(TARGET_TOOLS_PREFIX)),)
+TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/mips/mips64el-linux-android-$(TARGET_GCC_VERSION)
+TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/mips64el-linux-android-
+endif
+
+TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc
+TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++
+TARGET_AR := $(TARGET_TOOLS_PREFIX)ar
+TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy
+TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
+TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
+TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
+TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
+
+TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
+
+TARGET_mips_CFLAGS := -O2 \
+ -fomit-frame-pointer \
+ -fno-strict-aliasing \
+ -funswitch-loops
+
+# Set FORCE_MIPS_DEBUGGING to "true" in your buildspec.mk
+# or in your environment to gdb debugging easier.
+# Don't forget to do a clean build.
+ifeq ($(FORCE_MIPS_DEBUGGING),true)
+ TARGET_mips_CFLAGS += -fno-omit-frame-pointer
+endif
+
+TARGET_GLOBAL_CFLAGS += \
+ $(TARGET_mips_CFLAGS) \
+ -U__unix -U__unix__ -Umips \
+ -ffunction-sections \
+ -fdata-sections \
+ -funwind-tables \
+ -fstack-protector-strong \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+ $(arch_variant_cflags) \
+
+# Help catch common 32/64-bit errors.
+TARGET_GLOBAL_CFLAGS += \
+ -Werror=pointer-to-int-cast \
+ -Werror=int-to-pointer-cast \
+ -Werror=implicit-function-declaration \
+
+ifneq ($(ARCH_MIPS_PAGE_SHIFT),)
+TARGET_GLOBAL_CFLAGS += -DPAGE_SHIFT=$(ARCH_MIPS_PAGE_SHIFT)
+endif
+
+TARGET_GLOBAL_LDFLAGS += \
+ -Wl,-z,noexecstack \
+ -Wl,-z,relro \
+ -Wl,-z,now \
+ -Wl,--build-id=md5 \
+ -Wl,--warn-shared-textrel \
+ -Wl,--fatal-warnings \
+ -Wl,--no-undefined-version \
+ $(arch_variant_ldflags)
+
+# Disable transitive dependency library symbol resolving.
+TARGET_GLOBAL_LDFLAGS += -Wl,--allow-shlib-undefined
+
+TARGET_GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
+
+# More flags/options can be added here
+TARGET_RELEASE_CFLAGS := \
+ -DNDEBUG \
+ -g \
+ -Wstrict-aliasing=2 \
+ -fgcse-after-reload \
+ -frerun-cse-after-loop \
+ -frename-registers
+
+libc_root := bionic/libc
+libm_root := bionic/libm
+
+
+## on some hosts, the target cross-compiler is not available so do not run this command
+ifneq ($(wildcard $(TARGET_CC)),)
+# We compile with the global cflags to ensure that
+# any flags which affect libgcc are correctly taken
+# into account.
+TARGET_LIBGCC := \
+ $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc.a)
+TARGET_LIBATOMIC := \
+ $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libatomic.a)
+LIBGCC_EH := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) -print-file-name=libgcc_eh.a)
+ifneq ($(LIBGCC_EH),libgcc_eh.a)
+ TARGET_LIBGCC += $(LIBGCC_EH)
+endif
+TARGET_LIBGCOV := $(shell $(TARGET_CC) $(TARGET_GLOBAL_CFLAGS) \
+ --print-file-name=libgcov.a)
+endif
+
+KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
+KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
+KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-mips
+# TODO: perhaps use $(libc_root)/kernel/uapi/asm-$(TARGET_ARCH) instead of asm-mips ?
+KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
+
+TARGET_C_INCLUDES := \
+ $(libc_root)/arch-mips64/include \
+ $(libc_root)/include \
+ $(KERNEL_HEADERS) \
+ $(libm_root)/include \
+ $(libm_root)/include/mips \
+
+# TODO: perhaps use $(libm_root)/include/mips64 instead of mips ?
+
+TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
+TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
+TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
+
+TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
+TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
+
+TARGET_PACK_MODULE_RELOCATIONS := true
+
+TARGET_LINKER := /system/bin/linker64
diff --git a/core/combo/TARGET_linux-x86.mk b/core/combo/TARGET_linux-x86.mk
new file mode 100644
index 0000000000000000000000000000000000000000..558ec3b6bd3bd4d61a8fa82dc0a14e67461294db
--- /dev/null
+++ b/core/combo/TARGET_linux-x86.mk
@@ -0,0 +1,152 @@
+#
+# 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 x86 as a target.
+# Included by combo/select.mk
+
+# Provide a default variant.
+ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
+TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := x86
+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
+
+# Include the arch-variant-specific configuration file.
+# Its role is to define various ARCH_X86_HAVE_XXX feature macros,
+# plus initial values for TARGET_GLOBAL_CFLAGS
+#
+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 $(TARGET_$(combo_2nd_arch_prefix)ARCH) 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)/x86/x86_64-linux-android-$($(combo_2nd_arch_prefix)TARGET_GCC_VERSION)
+$(combo_2nd_arch_prefix)TARGET_TOOLS_PREFIX := $($(combo_2nd_arch_prefix)TARGET_TOOLCHAIN_ROOT)/bin/x86_64-linux-android-
+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
+
+ifneq ($(wildcard $($(combo_2nd_arch_prefix)TARGET_CC)),)
+$(combo_2nd_arch_prefix)TARGET_LIBGCC := \
+ $(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libgcc.a)
+$(combo_2nd_arch_prefix)TARGET_LIBATOMIC := \
+ $(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libatomic.a)
+$(combo_2nd_arch_prefix)TARGET_LIBGCOV := \
+ $(shell $($(combo_2nd_arch_prefix)TARGET_CC) -m32 -print-file-name=libgcov.a)
+endif
+
+$(combo_2nd_arch_prefix)TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
+
+libc_root := bionic/libc
+libm_root := bionic/libm
+
+KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
+KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
+KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64.
+KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += \
+ -O2 \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -Wstrict-aliasing=2 \
+ -ffunction-sections \
+ -finline-functions \
+ -finline-limit=300 \
+ -fno-short-enums \
+ -fstrict-aliasing \
+ -funswitch-loops \
+ -funwind-tables \
+ -fstack-protector-strong \
+ -m32 \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers \
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags)
+
+ifeq ($(ARCH_X86_HAVE_SSSE3),true) # yes, really SSSE3, not SSE3!
+ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3
+endif
+ifeq ($(ARCH_X86_HAVE_SSE4),true)
+ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4
+endif
+ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
+ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.1
+endif
+ifeq ($(ARCH_X86_HAVE_SSE4_2),true)
+ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -msse4.2
+endif
+ifeq ($(ARCH_X86_HAVE_AVX),true)
+ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -mavx
+endif
+ifeq ($(ARCH_X86_HAVE_AES_NI),true)
+ $(combo_2nd_arch_prefix)TARGET_GLOBAL_CFLAGS += -maes
+endif
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -m32
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--build-id=md5
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--hash-style=gnu
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_LDFLAGS += -Wl,--no-undefined-version
+
+$(combo_2nd_arch_prefix)TARGET_C_INCLUDES := \
+ $(libc_root)/arch-x86/include \
+ $(libc_root)/include \
+ $(KERNEL_HEADERS) \
+ $(libm_root)/include \
+ $(libm_root)/include/i387 \
+
+$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_STATIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
+$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_DYNAMIC_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
+$(combo_2nd_arch_prefix)TARGET_CRTEND_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
+
+$(combo_2nd_arch_prefix)TARGET_CRTBEGIN_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
+$(combo_2nd_arch_prefix)TARGET_CRTEND_SO_O := $($(combo_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
+
+$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
+
+$(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
+
+$(combo_2nd_arch_prefix)TARGET_GLOBAL_YASM_FLAGS := -f elf32 -m x86
diff --git a/core/combo/TARGET_linux-x86_64.mk b/core/combo/TARGET_linux-x86_64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..12166ec47e3c39f50af87318872cafecea0e12e9
--- /dev/null
+++ b/core/combo/TARGET_linux-x86_64.mk
@@ -0,0 +1,159 @@
+#
+# 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 x86_64 as a target.
+# Included by combo/select.mk
+
+# Provide a default variant.
+ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
+TARGET_ARCH_VARIANT := x86_64
+endif
+
+# Decouple NDK library selection with platform compiler version
+TARGET_NDK_GCC_VERSION := 4.9
+
+ifeq ($(strip $(TARGET_GCC_VERSION_EXP)),)
+TARGET_GCC_VERSION := 4.9
+else
+TARGET_GCC_VERSION := $(TARGET_GCC_VERSION_EXP)
+endif
+
+# Include the arch-variant-specific configuration file.
+# Its role is to define various ARCH_X86_HAVE_XXX feature macros,
+# plus initial values for TARGET_GLOBAL_CFLAGS
+#
+TARGET_ARCH_SPECIFIC_MAKEFILE := $(BUILD_COMBOS)/arch/$(TARGET_ARCH)/$(TARGET_ARCH_VARIANT).mk
+ifeq ($(strip $(wildcard $(TARGET_ARCH_SPECIFIC_MAKEFILE))),)
+$(error Unknown $(TARGET_ARCH) architecture version: $(TARGET_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 $(TARGET_TOOLS_PREFIX)),)
+TARGET_TOOLCHAIN_ROOT := prebuilts/gcc/$(HOST_PREBUILT_TAG)/x86/x86_64-linux-android-$(TARGET_GCC_VERSION)
+TARGET_TOOLS_PREFIX := $(TARGET_TOOLCHAIN_ROOT)/bin/x86_64-linux-android-
+endif
+
+TARGET_CC := $(TARGET_TOOLS_PREFIX)gcc
+TARGET_CXX := $(TARGET_TOOLS_PREFIX)g++
+TARGET_AR := $(TARGET_TOOLS_PREFIX)ar
+TARGET_OBJCOPY := $(TARGET_TOOLS_PREFIX)objcopy
+TARGET_LD := $(TARGET_TOOLS_PREFIX)ld
+TARGET_READELF := $(TARGET_TOOLS_PREFIX)readelf
+TARGET_STRIP := $(TARGET_TOOLS_PREFIX)strip
+TARGET_NM := $(TARGET_TOOLS_PREFIX)nm
+
+define $(combo_var_prefix)transform-shared-lib-to-toc
+$(call _gen_toc_command_for_elf,$(1),$(2))
+endef
+
+ifneq ($(wildcard $(TARGET_CC)),)
+TARGET_LIBGCC := \
+ $(shell $(TARGET_CC) -m64 -print-file-name=libgcc.a)
+TARGET_LIBATOMIC := \
+ $(shell $(TARGET_CC) -m64 -print-file-name=libatomic.a)
+TARGET_LIBGCOV := \
+ $(shell $(TARGET_CC) -m64 -print-file-name=libgcov.a)
+endif
+
+TARGET_NO_UNDEFINED_LDFLAGS := -Wl,--no-undefined
+
+libc_root := bionic/libc
+libm_root := bionic/libm
+
+KERNEL_HEADERS_COMMON := $(libc_root)/kernel/uapi
+KERNEL_HEADERS_COMMON += $(libc_root)/kernel/common
+KERNEL_HEADERS_ARCH := $(libc_root)/kernel/uapi/asm-x86 # x86 covers both x86 and x86_64.
+KERNEL_HEADERS := $(KERNEL_HEADERS_COMMON) $(KERNEL_HEADERS_ARCH)
+
+TARGET_GLOBAL_CFLAGS += \
+ -O2 \
+ -Wa,--noexecstack \
+ -Werror=format-security \
+ -D_FORTIFY_SOURCE=2 \
+ -Wstrict-aliasing=2 \
+ -ffunction-sections \
+ -finline-functions \
+ -finline-limit=300 \
+ -fno-short-enums \
+ -fstrict-aliasing \
+ -funswitch-loops \
+ -funwind-tables \
+ -fstack-protector-strong \
+ -m64 \
+ -no-canonical-prefixes \
+ -fno-canonical-system-headers
+
+# Help catch common 32/64-bit errors.
+TARGET_GLOBAL_CFLAGS += \
+ -Werror=pointer-to-int-cast \
+ -Werror=int-to-pointer-cast \
+ -Werror=implicit-function-declaration \
+
+TARGET_GLOBAL_CFLAGS += $(arch_variant_cflags)
+
+ifeq ($(ARCH_X86_HAVE_SSSE3),true) # yes, really SSSE3, not SSE3!
+ TARGET_GLOBAL_CFLAGS += -DUSE_SSSE3 -mssse3
+endif
+ifeq ($(ARCH_X86_HAVE_SSE4),true)
+ TARGET_GLOBAL_CFLAGS += -msse4
+endif
+ifeq ($(ARCH_X86_HAVE_SSE4_1),true)
+ TARGET_GLOBAL_CFLAGS += -msse4.1
+endif
+ifeq ($(ARCH_X86_HAVE_SSE4_2),true)
+ TARGET_GLOBAL_CFLAGS += -msse4.2
+endif
+ifeq ($(ARCH_X86_HAVE_POPCNT),true)
+ TARGET_GLOBAL_CFLAGS += -mpopcnt
+endif
+ifeq ($(ARCH_X86_HAVE_AVX),true)
+ TARGET_GLOBAL_CFLAGS += -mavx
+endif
+ifeq ($(ARCH_X86_HAVE_AES_NI),true)
+ TARGET_GLOBAL_CFLAGS += -maes
+endif
+
+TARGET_GLOBAL_LDFLAGS += -m64
+
+TARGET_GLOBAL_LDFLAGS += -Wl,-z,noexecstack
+TARGET_GLOBAL_LDFLAGS += -Wl,-z,relro -Wl,-z,now
+TARGET_GLOBAL_LDFLAGS += -Wl,--build-id=md5
+TARGET_GLOBAL_LDFLAGS += -Wl,--warn-shared-textrel
+TARGET_GLOBAL_LDFLAGS += -Wl,--fatal-warnings
+TARGET_GLOBAL_LDFLAGS += -Wl,--gc-sections
+TARGET_GLOBAL_LDFLAGS += -Wl,--hash-style=gnu
+TARGET_GLOBAL_LDFLAGS += -Wl,--no-undefined-version
+
+TARGET_C_INCLUDES := \
+ $(libc_root)/arch-x86_64/include \
+ $(libc_root)/include \
+ $(KERNEL_HEADERS) \
+ $(libm_root)/include \
+ $(libm_root)/include/amd64 \
+
+TARGET_CRTBEGIN_STATIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_static.o
+TARGET_CRTBEGIN_DYNAMIC_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_dynamic.o
+TARGET_CRTEND_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_android.o
+
+TARGET_CRTBEGIN_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtbegin_so.o
+TARGET_CRTEND_SO_O := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/crtend_so.o
+
+TARGET_LINKER := /system/bin/linker64
+
+TARGET_GLOBAL_YASM_FLAGS := -f elf64 -m amd64
diff --git a/core/combo/arch/arm/armv5te-vfp.mk b/core/combo/arch/arm/armv5te-vfp.mk
new file mode 100644
index 0000000000000000000000000000000000000000..75299ac245a36a7fe01b5e4a6cd9a6798e7918b2
--- /dev/null
+++ b/core/combo/arch/arm/armv5te-vfp.mk
@@ -0,0 +1,7 @@
+# At the moment, use the same settings than the one
+# for armv5te, since TARGET_ARCH_VARIANT := armv5te-vfp
+# will only be used to select an optimized VFP-capable assembly
+# interpreter loop for Dalvik.
+#
+include $(BUILD_COMBOS)/arch/arm/armv5te.mk
+
diff --git a/core/combo/arch/arm/armv5te.mk b/core/combo/arch/arm/armv5te.mk
new file mode 100644
index 0000000000000000000000000000000000000000..88e57b726476ca2f4478959786497b5127000d40
--- /dev/null
+++ b/core/combo/arch/arm/armv5te.mk
@@ -0,0 +1,15 @@
+# Configuration for Linux on ARM.
+# Generating binaries for the ARMv5TE architecture and higher
+#
+
+# Note: Hard coding the 'tune' value here is probably not ideal,
+# and a better solution should be found in the future.
+#
+arch_variant_cflags := \
+ -march=armv5te \
+ -mtune=xscale \
+ -D__ARM_ARCH_5__ \
+ -D__ARM_ARCH_5T__ \
+ -D__ARM_ARCH_5E__ \
+ -D__ARM_ARCH_5TE__
+
diff --git a/core/combo/arch/arm/armv7-a-neon.mk b/core/combo/arch/arm/armv7-a-neon.mk
new file mode 100644
index 0000000000000000000000000000000000000000..5d5b050098a59f4de30188f3d7e38bc5ff4c9dd0
--- /dev/null
+++ b/core/combo/arch/arm/armv7-a-neon.mk
@@ -0,0 +1,54 @@
+# Configuration for Linux on ARM.
+# Generating binaries for the ARMv7-a architecture and higher with NEON
+#
+ARCH_ARM_HAVE_ARMV7A := true
+ARCH_ARM_HAVE_VFP := true
+ARCH_ARM_HAVE_VFP_D32 := true
+ARCH_ARM_HAVE_NEON := true
+
+local_arch_has_lpae := false
+
+ifneq (,$(filter cortex-a15 krait denver,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
+ # TODO: krait is not a cortex-a15, we set the variant to cortex-a15 so that
+ # hardware divide operations are generated. This should be removed and a
+ # krait CPU variant added to GCC. For clang we specify -mcpu for krait in
+ # core/clang/arm.mk.
+ arch_variant_cflags := -mcpu=cortex-a15
+
+ local_arch_has_lpae := true
+ arch_variant_ldflags := \
+ -Wl,--no-fix-cortex-a8
+else
+ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)),cortex-a8)
+ arch_variant_cflags := -mcpu=cortex-a8
+ arch_variant_ldflags := \
+ -Wl,--fix-cortex-a8
+else
+ifneq (,$(filter cortex-a7 cortex-a53 cortex-a53.a57,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
+ arch_variant_cflags := -mcpu=cortex-a7
+
+ local_arch_has_lpae := true
+ arch_variant_ldflags := \
+ -Wl,--no-fix-cortex-a8
+else
+ arch_variant_cflags := -march=armv7-a
+ # Generic ARM might be a Cortex A8 -- better safe than sorry
+ arch_variant_ldflags := \
+ -Wl,--fix-cortex-a8
+endif
+endif
+endif
+
+ifeq (true,$(local_arch_has_lpae))
+ # Fake an ARM compiler flag as these processors support LPAE which GCC/clang
+ # don't advertise.
+ # TODO This is a hack and we need to add it for each processor that supports LPAE until some
+ # better solution comes around. See Bug 27340895
+ arch_variant_cflags += -D__ARM_FEATURE_LPAE=1
+endif
+
+local_arch_has_lpae :=
+
+arch_variant_cflags += \
+ -mfloat-abi=softfp \
+ -mfpu=neon
diff --git a/core/combo/arch/arm/armv7-a.mk b/core/combo/arch/arm/armv7-a.mk
new file mode 100644
index 0000000000000000000000000000000000000000..4a519770f5a266411848e8916eb2212d67ec31a9
--- /dev/null
+++ b/core/combo/arch/arm/armv7-a.mk
@@ -0,0 +1,16 @@
+# Configuration for Linux on ARM.
+# Generating binaries for the ARMv7-a architecture and higher
+#
+ARCH_ARM_HAVE_ARMV7A := true
+ARCH_ARM_HAVE_VFP := true
+
+# Note: Hard coding the 'tune' value here is probably not ideal,
+# and a better solution should be found in the future.
+#
+arch_variant_cflags := \
+ -march=armv7-a \
+ -mfloat-abi=softfp \
+ -mfpu=vfpv3-d16
+
+arch_variant_ldflags := \
+ -Wl,--fix-cortex-a8
diff --git a/core/combo/arch/arm64/armv8-a.mk b/core/combo/arch/arm64/armv8-a.mk
new file mode 100644
index 0000000000000000000000000000000000000000..5e27e5abb7301368cb68905257d178676d36a97d
--- /dev/null
+++ b/core/combo/arch/arm64/armv8-a.mk
@@ -0,0 +1,5 @@
+ifneq (,$(filter cortex-a53,$(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
+ arch_variant_cflags := -mcpu=cortex-a53
+else
+ arch_variant_cflags :=
+endif
diff --git a/core/combo/arch/mips/mips32-fp.mk b/core/combo/arch/mips/mips32-fp.mk
new file mode 100644
index 0000000000000000000000000000000000000000..912ff631b5aa630e988a9e57252cf817c1fac9d2
--- /dev/null
+++ b/core/combo/arch/mips/mips32-fp.mk
@@ -0,0 +1,13 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32/hard-float/little-endian
+
+ARCH_MIPS_HAS_FPU :=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+ -mips32 \
+ -mfp32 \
+ -modd-spreg \
+ -mno-synci
+
+arch_variant_ldflags := \
+ -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r2-fp-xburst.mk b/core/combo/arch/mips/mips32r2-fp-xburst.mk
new file mode 100644
index 0000000000000000000000000000000000000000..09b3bc21092b87d41c643dbb9f840832308b7723
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2-fp-xburst.mk
@@ -0,0 +1,16 @@
+# Configuration for Android on Ingenic xb4780/Xburst MIPS CPU.
+# Generating binaries for MIPS32R2/hard-float/little-endian without
+# support for the Madd family of instructions.
+
+ARCH_MIPS_HAS_FPU :=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+ -mips32r2 \
+ -mfp32 \
+ -modd-spreg \
+ -mno-fused-madd \
+ -Wa,-mmxu \
+ -mno-synci
+
+arch_variant_ldflags := \
+ -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r2-fp.mk b/core/combo/arch/mips/mips32r2-fp.mk
new file mode 100644
index 0000000000000000000000000000000000000000..9acb0185fe6aa45ebe29bb539be6790353d0f612
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2-fp.mk
@@ -0,0 +1,13 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R2/hard-float/little-endian
+
+ARCH_MIPS_HAS_FPU :=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+ -mips32r2 \
+ -mfp32 \
+ -modd-spreg \
+ -msynci
+
+arch_variant_ldflags := \
+ -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r2dsp-fp.mk b/core/combo/arch/mips/mips32r2dsp-fp.mk
new file mode 100644
index 0000000000000000000000000000000000000000..c4b49b6c06ce28ccfc72a924e3ebb70489a28ca0
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2dsp-fp.mk
@@ -0,0 +1,16 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R2/hard-float/little-endian/dsp
+
+ARCH_MIPS_HAS_DSP :=true
+ARCH_MIPS_DSP_REV :=1
+ARCH_MIPS_HAS_FPU :=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+ -mips32r2 \
+ -mfp32 \
+ -modd-spreg \
+ -mdsp \
+ -msynci
+
+arch_variant_ldflags := \
+ -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r2dspr2-fp.mk b/core/combo/arch/mips/mips32r2dspr2-fp.mk
new file mode 100644
index 0000000000000000000000000000000000000000..8b05ffc51404c398eaee9f56d21d57a99054e944
--- /dev/null
+++ b/core/combo/arch/mips/mips32r2dspr2-fp.mk
@@ -0,0 +1,16 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R2/hard-float/little-endian/dsp
+
+ARCH_MIPS_HAS_DSP :=true
+ARCH_MIPS_DSP_REV :=2
+ARCH_MIPS_HAS_FPU :=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+ -mips32r2 \
+ -mfp32 \
+ -modd-spreg \
+ -mdspr2 \
+ -msynci
+
+arch_variant_ldflags := \
+ -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips/mips32r6.mk b/core/combo/arch/mips/mips32r6.mk
new file mode 100644
index 0000000000000000000000000000000000000000..315aa60eef569e0ad3314c151ef087109f11a87e
--- /dev/null
+++ b/core/combo/arch/mips/mips32r6.mk
@@ -0,0 +1,12 @@
+# Configuration for Android on MIPS.
+# Generating binaries for MIPS32R6/hard-float/little-endian
+
+ARCH_MIPS_REV6 := true
+arch_variant_cflags := \
+ -mips32r6 \
+ -mfp64 \
+ -mno-odd-spreg \
+ -msynci
+
+arch_variant_ldflags := \
+ -Wl,-melf32ltsmip
diff --git a/core/combo/arch/mips64/mips64r2.mk b/core/combo/arch/mips64/mips64r2.mk
new file mode 100644
index 0000000000000000000000000000000000000000..c5710d0bad6abb23f7cfff696633f789b56cfb37
--- /dev/null
+++ b/core/combo/arch/mips64/mips64r2.mk
@@ -0,0 +1,10 @@
+# Configuration for Android on mips64r2.
+
+# This target is for temporary use only, until mips64r6 is supported by Android's qemu.
+
+ARCH_MIPS_HAS_FPU :=true
+ARCH_HAVE_ALIGNED_DOUBLES :=true
+arch_variant_cflags := \
+ -mips64r2 \
+ -msynci
+
diff --git a/core/combo/arch/mips64/mips64r6.mk b/core/combo/arch/mips64/mips64r6.mk
new file mode 100644
index 0000000000000000000000000000000000000000..443de208b93196be1e0602e4658eca9ac27b1d4a
--- /dev/null
+++ b/core/combo/arch/mips64/mips64r6.mk
@@ -0,0 +1,7 @@
+# Configuration for Android on mips64r6.
+
+ARCH_MIPS_REV6 := true
+arch_variant_cflags := \
+ -mips64r6 \
+ -msynci
+
diff --git a/core/combo/arch/x86/atom.mk b/core/combo/arch/x86/atom.mk
new file mode 100644
index 0000000000000000000000000000000000000000..3800350a391ed6628b7f303c2eba118e02a248f5
--- /dev/null
+++ b/core/combo/arch/x86/atom.mk
@@ -0,0 +1,15 @@
+# This file contains feature macro definitions specific to the
+# 'x86-atom' arch variant. This is an extension of the 'x86' base variant
+# that adds Atom-specific features.
+#
+# See build/core/combo/arch/x86/x86.mk for differences.
+#
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_MOVBE := true
+ARCH_X86_HAVE_POPCNT := false # popcnt is not supported by current Atom CPUs
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=atom \
+ -mfpmath=sse \
+
diff --git a/core/combo/arch/x86/haswell.mk b/core/combo/arch/x86/haswell.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b3922c04510a361d2d2965ebd4f191e3ed619ffa
--- /dev/null
+++ b/core/combo/arch/x86/haswell.mk
@@ -0,0 +1,17 @@
+# Configuration for Linux on x86.
+# Generating binaries for Haswell processors.
+#
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
+ARCH_X86_HAVE_AES_NI := true
+ARCH_X86_HAVE_AVX := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE := true
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=core-avx2 \
+ -mfpmath=sse \
+
diff --git a/core/combo/arch/x86/ivybridge.mk b/core/combo/arch/x86/ivybridge.mk
new file mode 100644
index 0000000000000000000000000000000000000000..c9fc33b01324b66fed91cf7360961907fd972e71
--- /dev/null
+++ b/core/combo/arch/x86/ivybridge.mk
@@ -0,0 +1,17 @@
+# Configuration for Linux on x86.
+# Generating binaries for Ivy Bridge processors.
+#
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
+ARCH_X86_HAVE_AES_NI := true
+ARCH_X86_HAVE_AVX := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE := false
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=core-avx-i \
+ -mfpmath=sse \
+
diff --git a/core/combo/arch/x86/sandybridge.mk b/core/combo/arch/x86/sandybridge.mk
new file mode 100644
index 0000000000000000000000000000000000000000..bca595373d8a92e3e691fc707ee2b8d25dde8c5e
--- /dev/null
+++ b/core/combo/arch/x86/sandybridge.mk
@@ -0,0 +1,17 @@
+# Configuration for Linux on x86.
+# Generating binaries for SandyBridge processors.
+#
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
+ARCH_X86_HAVE_AES_NI := true
+ARCH_X86_HAVE_AVX := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE := false
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=corei7-avx \
+ -mfpmath=sse \
+
diff --git a/core/combo/arch/x86/silvermont.mk b/core/combo/arch/x86/silvermont.mk
new file mode 100644
index 0000000000000000000000000000000000000000..d064b1df27a759aca7d2edb334333ce13383de53
--- /dev/null
+++ b/core/combo/arch/x86/silvermont.mk
@@ -0,0 +1,19 @@
+# This file contains feature macro definitions specific to the
+# silvermont arch variant.
+#
+# See build/core/combo/arch/x86/x86-atom.mk for differences.
+#
+
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
+ARCH_X86_HAVE_AES_NI := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE := true
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=slm \
+ -mfpmath=sse \
+
diff --git a/core/combo/arch/x86/x86.mk b/core/combo/arch/x86/x86.mk
new file mode 100644
index 0000000000000000000000000000000000000000..f0704263b79713e06f78602fd127e56f56c93220
--- /dev/null
+++ b/core/combo/arch/x86/x86.mk
@@ -0,0 +1,19 @@
+# This file contains feature macro definitions specific to the
+# base 'x86' platform ABI.
+#
+# It is also used to build full_x86-eng / sdk_x86-eng platform images that
+# are run in the emulator under KVM emulation (i.e. running directly on
+# the host development machine's CPU).
+
+# These features are optional and shall not be included in the base platform
+# Otherwise, sdk_x86-eng system images might fail to run on some
+# developer machines.
+ARCH_X86_HAVE_SSSE3 := false
+ARCH_X86_HAVE_MOVBE := false
+ARCH_X86_HAVE_POPCNT := false
+
+
+# Some intrinsic functions used by libcxx only exist for prescott or newer CPUs.
+arch_variant_cflags := \
+ -march=prescott \
+
diff --git a/core/combo/arch/x86_64/haswell.mk b/core/combo/arch/x86_64/haswell.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6067eee650873c37d643386de09305c48688fa8c
--- /dev/null
+++ b/core/combo/arch/x86_64/haswell.mk
@@ -0,0 +1,15 @@
+# Configuration for Linux on x86_64.
+# Generating binaries for Haswell processors.
+#
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
+ARCH_X86_HAVE_AES_NI := true
+ARCH_X86_HAVE_AVX := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE := true
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=core-avx2
diff --git a/core/combo/arch/x86_64/ivybridge.mk b/core/combo/arch/x86_64/ivybridge.mk
new file mode 100644
index 0000000000000000000000000000000000000000..90e23a9f22522d237dbbe1a9b1b15e5f6ed6e779
--- /dev/null
+++ b/core/combo/arch/x86_64/ivybridge.mk
@@ -0,0 +1,15 @@
+# Configuration for Linux on x86_64.
+# Generating binaries for Ivy Bridge processors.
+#
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
+ARCH_X86_HAVE_AES_NI := true
+ARCH_X86_HAVE_AVX := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE := false
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=core-avx-i
diff --git a/core/combo/arch/x86_64/sandybridge.mk b/core/combo/arch/x86_64/sandybridge.mk
new file mode 100644
index 0000000000000000000000000000000000000000..865548c6b312127115fa33486f8c5e65944c197a
--- /dev/null
+++ b/core/combo/arch/x86_64/sandybridge.mk
@@ -0,0 +1,15 @@
+# Configuration for Linux on x86_64.
+# Generating binaries for SandyBridge processors.
+#
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
+ARCH_X86_HAVE_AES_NI := true
+ARCH_X86_HAVE_AVX := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE := false
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=corei7-avx
diff --git a/core/combo/arch/x86_64/silvermont.mk b/core/combo/arch/x86_64/silvermont.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6c953a349b18bc1a3a407acc07da9d52cff1ea20
--- /dev/null
+++ b/core/combo/arch/x86_64/silvermont.mk
@@ -0,0 +1,17 @@
+# This file contains feature macro definitions specific to the
+# silvermont arch variant.
+#
+# See build/core/combo/arch/x86/x86-atom.mk for differences.
+#
+
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
+ARCH_X86_HAVE_AES_NI := true
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_MOVBE := true
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=slm \
diff --git a/core/combo/arch/x86_64/x86_64.mk b/core/combo/arch/x86_64/x86_64.mk
new file mode 100755
index 0000000000000000000000000000000000000000..08dd9cd86d0e47637fc0243d1a536200606e2d06
--- /dev/null
+++ b/core/combo/arch/x86_64/x86_64.mk
@@ -0,0 +1,18 @@
+# This file contains feature macro definitions specific to the
+# base 'x86_64' platform ABI.
+#
+# It is also used to build full_x86_64-eng / sdk_x86_64-eng platform images
+# that are run in the emulator under KVM emulation (i.e. running directly on
+# the host development machine's CPU).
+
+ARCH_X86_HAVE_SSSE3 := true
+ARCH_X86_HAVE_MOVBE := false # Only supported on Atom.
+ARCH_X86_HAVE_POPCNT := true
+ARCH_X86_HAVE_SSE4 := true
+ARCH_X86_HAVE_SSE4_1 := true
+ARCH_X86_HAVE_SSE4_2 := true
+
+
+# CFLAGS for this arch
+arch_variant_cflags := \
+ -march=x86-64
diff --git a/core/combo/fdo.mk b/core/combo/fdo.mk
new file mode 100644
index 0000000000000000000000000000000000000000..8fb8fd3a57ee495c0f8b0a3200fa6cc6ade89dfd
--- /dev/null
+++ b/core/combo/fdo.mk
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+# Setup FDO related flags.
+
+$(combo_2nd_arch_prefix)TARGET_FDO_CFLAGS:=
+
+# Set BUILD_FDO_INSTRUMENT=true to turn on FDO instrumentation.
+# The profile will be generated on /sdcard/fdo_profile on the device.
+$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_CFLAGS := -fprofile-generate=/sdcard/fdo_profile -DANDROID_FDO
+$(combo_2nd_arch_prefix)TARGET_FDO_INSTRUMENT_LDFLAGS := -lgcov -lgcc
+
+# Set TARGET_FDO_PROFILE_PATH to set a custom profile directory for your build.
+ifeq ($(strip $($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH)),)
+ $(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH := vendor/google_data/fdo_profile
+endif
+
+$(combo_2nd_arch_prefix)TARGET_FDO_OPTIMIZE_CFLAGS := \
+ -fprofile-use=$($(combo_2nd_arch_prefix)TARGET_FDO_PROFILE_PATH) \
+ -DANDROID_FDO -fprofile-correction -Wcoverage-mismatch -Wno-error
diff --git a/core/combo/javac.mk b/core/combo/javac.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7f66ea83a944350d255372f73fe840dd5e1ab8ae
--- /dev/null
+++ b/core/combo/javac.mk
@@ -0,0 +1,49 @@
+# Selects a Java compiler.
+#
+# Inputs:
+# CUSTOM_JAVA_COMPILER -- "eclipse", "openjdk". or nothing for the system
+# default
+# ALTERNATE_JAVAC -- the alternate java compiler to use
+#
+# Outputs:
+# COMMON_JAVAC -- Java compiler command with common arguments
+#
+
+ifndef ANDROID_COMPILE_WITH_JACK
+# Defines if compilation with jack is enabled by default.
+ANDROID_COMPILE_WITH_JACK := true
+endif
+
+common_jdk_flags := -Xmaxerrs 9999999
+
+# Use the indexer wrapper to index the codebase instead of the javac compiler
+ifeq ($(ALTERNATE_JAVAC),)
+JAVACC := javac
+else
+JAVACC := $(ALTERNATE_JAVAC)
+endif
+
+# The actual compiler can be wrapped by setting the JAVAC_WRAPPER var.
+ifdef JAVAC_WRAPPER
+ ifneq ($(JAVAC_WRAPPER),$(firstword $(JAVACC)))
+ JAVACC := $(JAVAC_WRAPPER) $(JAVACC)
+ endif
+endif
+
+# Whatever compiler is on this system.
+COMMON_JAVAC := $(JAVACC) -J-Xmx1024M $(common_jdk_flags)
+
+# Eclipse.
+ifeq ($(CUSTOM_JAVA_COMPILER), eclipse)
+ COMMON_JAVAC := java -Xmx256m -jar prebuilt/common/ecj/ecj.jar -5 \
+ -maxProblems 9999999 -nowarn
+ $(info CUSTOM_JAVA_COMPILER=eclipse)
+endif
+
+GLOBAL_JAVAC_DEBUG_FLAGS := -g
+
+HOST_JAVAC ?= $(COMMON_JAVAC)
+TARGET_JAVAC ?= $(COMMON_JAVAC)
+
+#$(info HOST_JAVAC=$(HOST_JAVAC))
+#$(info TARGET_JAVAC=$(TARGET_JAVAC))
diff --git a/core/combo/mac_version.mk b/core/combo/mac_version.mk
new file mode 100644
index 0000000000000000000000000000000000000000..51394c64b16ce7a017ba97e0c8aa38d242cfa258
--- /dev/null
+++ b/core/combo/mac_version.mk
@@ -0,0 +1,52 @@
+# Detect Mac OS X and SDK versions.
+# Output variables:
+# build_mac_version
+# mac_sdk_version
+# mac_sdk_root
+# gcc_darwin_version
+
+ifndef build_mac_version
+
+build_mac_version := $(shell sw_vers -productVersion)
+
+mac_sdk_versions_supported := 10.8 10.9 10.10 10.11
+ifneq ($(strip $(MAC_SDK_VERSION)),)
+mac_sdk_version := $(MAC_SDK_VERSION)
+ifeq ($(filter $(mac_sdk_version),$(mac_sdk_versions_supported)),)
+$(warning ****************************************************************)
+$(warning * MAC_SDK_VERSION $(MAC_SDK_VERSION) isn't one of the supported $(mac_sdk_versions_supported))
+$(warning ****************************************************************)
+$(error Stop.)
+endif
+else
+mac_sdk_versions_installed := $(shell xcodebuild -showsdks | grep macosx | sed -e "s/.*macosx//g")
+mac_sdk_version := $(firstword $(filter $(mac_sdk_versions_installed), $(mac_sdk_versions_supported)))
+ifeq ($(mac_sdk_version),)
+mac_sdk_version := $(firstword $(mac_sdk_versions_supported))
+$(warning none of the installed SDKs ($mac_sdk_versions_installed) match supported versions ($(mac_sdk_versions_supported)), trying $(mac_sdk_version))
+endif
+endif
+
+mac_sdk_path := $(shell xcode-select -print-path)
+# try /Applications/Xcode*.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk
+# or /Volume/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.?.sdk
+mac_sdk_root := $(mac_sdk_path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(mac_sdk_version).sdk
+ifeq ($(wildcard $(mac_sdk_root)),)
+# try legacy /Developer/SDKs/MacOSX10.?.sdk
+$(warning no SDK $(mac_sdk_version) at $(mac_sdk_root), trying legacy dir)
+mac_sdk_root := /Developer/SDKs/MacOSX$(mac_sdk_version).sdk
+endif
+ifeq ($(wildcard $(mac_sdk_root)),)
+$(warning *****************************************************)
+$(warning * Can not find SDK $(mac_sdk_version) at $(mac_sdk_root))
+$(warning *****************************************************)
+$(error Stop.)
+endif
+
+ifeq ($(mac_sdk_version),10.6)
+ gcc_darwin_version := 10
+else
+ gcc_darwin_version := 11
+endif
+
+endif # ifndef build_mac_version
diff --git a/core/combo/select.mk b/core/combo/select.mk
new file mode 100644
index 0000000000000000000000000000000000000000..df12e7e384575382a30ca342658224c1cadf795b
--- /dev/null
+++ b/core/combo/select.mk
@@ -0,0 +1,49 @@
+#
+# 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.
+#
+
+# Select a combo based on the compiler being used.
+#
+# Inputs:
+# combo_target -- prefix for final variables (HOST_ or TARGET_)
+# combo_2nd_arch_prefix -- it's defined if this is loaded for the 2nd arch.
+#
+
+# Build a target string like "linux-arm" or "darwin-x86".
+combo_os_arch := $($(combo_target)OS)-$($(combo_target)$(combo_2nd_arch_prefix)ARCH)
+
+combo_var_prefix := $(combo_2nd_arch_prefix)$(combo_target)
+
+# Set reasonable defaults for the various variables
+
+$(combo_var_prefix)CC := $(CC)
+$(combo_var_prefix)CXX := $(CXX)
+$(combo_var_prefix)AR := $(AR)
+$(combo_var_prefix)STRIP := $(STRIP)
+
+$(combo_var_prefix)GLOBAL_CFLAGS := -fno-exceptions -Wno-multichar
+$(combo_var_prefix)RELEASE_CFLAGS := -O2 -g -fno-strict-aliasing
+$(combo_var_prefix)GLOBAL_CPPFLAGS :=
+$(combo_var_prefix)GLOBAL_LDFLAGS :=
+$(combo_var_prefix)GLOBAL_ARFLAGS := crsPD
+$(combo_var_prefix)GLOBAL_LD_DIRS :=
+
+$(combo_var_prefix)EXECUTABLE_SUFFIX :=
+$(combo_var_prefix)SHLIB_SUFFIX := .so
+$(combo_var_prefix)JNILIB_SUFFIX := $($(combo_var_prefix)SHLIB_SUFFIX)
+$(combo_var_prefix)STATIC_LIB_SUFFIX := .a
+
+# Now include the combo for this specific target.
+include $(BUILD_COMBOS)/$(combo_target)$(combo_os_arch).mk
diff --git a/core/config.mk b/core/config.mk
new file mode 100644
index 0000000000000000000000000000000000000000..94c880f7a41d9a7502d2960657936618d7abf756
--- /dev/null
+++ b/core/config.mk
@@ -0,0 +1,870 @@
+# This is included by the top-level Makefile.
+# It sets up standard variables based on the
+# current configuration and platform, which
+# are not specific to what is being built.
+
+# Only use ANDROID_BUILD_SHELL to wrap around bash.
+# DO NOT use other shells such as zsh.
+ifdef ANDROID_BUILD_SHELL
+SHELL := $(ANDROID_BUILD_SHELL)
+else
+# Use bash, not whatever shell somebody has installed as /bin/sh
+# This is repeated from main.mk, since envsetup.sh runs this file
+# directly.
+SHELL := /bin/bash
+endif
+
+# Utility variables.
+empty :=
+space := $(empty) $(empty)
+comma := ,
+# Note that make will eat the newline just before endef.
+define newline
+
+
+endef
+# The pound character "#"
+define pound
+#
+endef
+# Unfortunately you can't simply define backslash as \ or \\.
+backslash := \a
+backslash := $(patsubst %a,%,$(backslash))
+
+# Tell python not to spam the source tree with .pyc files. This
+# only has an effect on python 2.6 and above.
+export PYTHONDONTWRITEBYTECODE := 1
+
+ifneq ($(filter --color=always, $(GREP_OPTIONS)),)
+$(warning The build system needs unmodified output of grep.)
+$(error Please remove --color=always from your $$GREP_OPTIONS)
+endif
+
+# Standard source directories.
+SRC_DOCS:= $(TOPDIR)docs
+# TODO: Enforce some kind of layering; only add include paths
+# when a module links against a particular library.
+# TODO: See if we can remove most of these from the global list.
+SRC_HEADERS := \
+ $(TOPDIR)system/core/include \
+ $(TOPDIR)system/media/audio/include \
+ $(TOPDIR)hardware/libhardware/include \
+ $(TOPDIR)hardware/libhardware_legacy/include \
+ $(TOPDIR)hardware/ril/include \
+ $(TOPDIR)libnativehelper/include \
+ $(TOPDIR)frameworks/native/include \
+ $(TOPDIR)frameworks/native/opengl/include \
+ $(TOPDIR)frameworks/av/include \
+ $(TOPDIR)frameworks/base/include
+SRC_HOST_HEADERS:=$(TOPDIR)tools/include
+SRC_LIBRARIES:= $(TOPDIR)libs
+SRC_SERVERS:= $(TOPDIR)servers
+SRC_TARGET_DIR := $(TOPDIR)build/target
+SRC_API_DIR := $(TOPDIR)prebuilts/sdk/api
+SRC_SYSTEM_API_DIR := $(TOPDIR)prebuilts/sdk/system-api
+SRC_TEST_API_DIR := $(TOPDIR)prebuilts/sdk/test-api
+
+# Some specific paths to tools
+SRC_DROIDDOC_DIR := $(TOPDIR)build/tools/droiddoc
+
+# Various mappings to avoid hard-coding paths all over the place
+include $(BUILD_SYSTEM)/pathmap.mk
+
+# ###############################################################
+# Build system internal files
+# ###############################################################
+
+BUILD_COMBOS:= $(BUILD_SYSTEM)/combo
+
+CLEAR_VARS:= $(BUILD_SYSTEM)/clear_vars.mk
+BUILD_HOST_STATIC_LIBRARY:= $(BUILD_SYSTEM)/host_static_library.mk
+BUILD_HOST_SHARED_LIBRARY:= $(BUILD_SYSTEM)/host_shared_library.mk
+BUILD_STATIC_LIBRARY:= $(BUILD_SYSTEM)/static_library.mk
+BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
+BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
+BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk
+BUILD_PACKAGE:= $(BUILD_SYSTEM)/package.mk
+BUILD_PHONY_PACKAGE:= $(BUILD_SYSTEM)/phony_package.mk
+BUILD_HOST_PREBUILT:= $(BUILD_SYSTEM)/host_prebuilt.mk
+BUILD_PREBUILT:= $(BUILD_SYSTEM)/prebuilt.mk
+BUILD_MULTI_PREBUILT:= $(BUILD_SYSTEM)/multi_prebuilt.mk
+BUILD_JAVA_LIBRARY:= $(BUILD_SYSTEM)/java_library.mk
+BUILD_STATIC_JAVA_LIBRARY:= $(BUILD_SYSTEM)/static_java_library.mk
+BUILD_HOST_JAVA_LIBRARY:= $(BUILD_SYSTEM)/host_java_library.mk
+BUILD_DROIDDOC:= $(BUILD_SYSTEM)/droiddoc.mk
+BUILD_COPY_HEADERS := $(BUILD_SYSTEM)/copy_headers.mk
+BUILD_NATIVE_TEST := $(BUILD_SYSTEM)/native_test.mk
+BUILD_NATIVE_BENCHMARK := $(BUILD_SYSTEM)/native_benchmark.mk
+BUILD_HOST_NATIVE_TEST := $(BUILD_SYSTEM)/host_native_test.mk
+BUILD_FUZZ_TEST := $(BUILD_SYSTEM)/fuzz_test.mk
+BUILD_HOST_FUZZ_TEST := $(BUILD_SYSTEM)/host_fuzz_test.mk
+
+BUILD_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/shared_test_lib.mk
+BUILD_HOST_SHARED_TEST_LIBRARY := $(BUILD_SYSTEM)/host_shared_test_lib.mk
+BUILD_STATIC_TEST_LIBRARY := $(BUILD_SYSTEM)/static_test_lib.mk
+BUILD_HOST_STATIC_TEST_LIBRARY := $(BUILD_SYSTEM)/host_static_test_lib.mk
+
+BUILD_NOTICE_FILE := $(BUILD_SYSTEM)/notice_files.mk
+BUILD_HOST_DALVIK_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_java_library.mk
+BUILD_HOST_DALVIK_STATIC_JAVA_LIBRARY := $(BUILD_SYSTEM)/host_dalvik_static_java_library.mk
+
+
+# ###############################################################
+# Parse out any modifier targets.
+# ###############################################################
+
+# The 'showcommands' goal says to show the full command
+# lines being executed, instead of a short message about
+# the kind of operation being done.
+SHOW_COMMANDS:= $(filter showcommands,$(MAKECMDGOALS))
+hide := $(if $(SHOW_COMMANDS),,@)
+
+################################################################
+# Tools needed in product configuration makefiles.
+################################################################
+NORMALIZE_PATH := build/tools/normalize_path.py
+
+# $(1): the paths to be normalized
+define normalize-paths
+$(if $(1),$(shell $(NORMALIZE_PATH) $(1)))
+endef
+
+# ###############################################################
+# Set common values
+# ###############################################################
+
+# Set the extensions used for various packages
+COMMON_PACKAGE_SUFFIX := .zip
+COMMON_JAVA_PACKAGE_SUFFIX := .jar
+COMMON_ANDROID_PACKAGE_SUFFIX := .apk
+
+ifdef TMPDIR
+JAVA_TMPDIR_ARG := -Djava.io.tmpdir=$(TMPDIR)
+else
+JAVA_TMPDIR_ARG :=
+endif
+
+# ###############################################################
+# Include sub-configuration files
+# ###############################################################
+
+# ---------------------------------------------------------------
+# Try to include buildspec.mk, which will try to set stuff up.
+# If this file doesn't exist, the environment variables will
+# be used, and if that doesn't work, then the default is an
+# arm build
+ifndef ANDROID_BUILDSPEC
+ANDROID_BUILDSPEC := $(TOPDIR)buildspec.mk
+endif
+-include $(ANDROID_BUILDSPEC)
+
+# ---------------------------------------------------------------
+# Define most of the global variables. These are the ones that
+# are specific to the user's build configuration.
+include $(BUILD_SYSTEM)/envsetup.mk
+
+# Pruned directory options used when using findleaves.py
+# See envsetup.mk for a description of SCAN_EXCLUDE_DIRS
+FIND_LEAVES_EXCLUDES := $(addprefix --prune=, $(OUT_DIR) $(SCAN_EXCLUDE_DIRS) .repo .git)
+
+# The build system exposes several variables for where to find the kernel
+# headers:
+# TARGET_DEVICE_KERNEL_HEADERS is automatically created for the current
+# device being built. It is set as $(TARGET_DEVICE_DIR)/kernel-headers,
+# e.g. device/samsung/tuna/kernel-headers. This directory is not
+# explicitly set by anyone, the build system always adds this subdir.
+#
+# TARGET_BOARD_KERNEL_HEADERS is specified by the BoardConfig.mk file
+# to allow other directories to be included. This is useful if there's
+# some common place where a few headers are being kept for a group
+# of devices. For example, device//common/kernel-headers could
+# contain some headers for several of 's devices.
+#
+# TARGET_PRODUCT_KERNEL_HEADERS is generated by the product inheritance
+# graph. This allows architecture products to provide headers for the
+# devices using that architecture. For example,
+# hardware/ti/omap4xxx/omap4.mk will specify
+# PRODUCT_VENDOR_KERNEL_HEADERS variable that specify where the omap4
+# specific headers are, e.g. hardware/ti/omap4xxx/kernel-headers.
+# The build system then combines all the values specified by all the
+# PRODUCT_VENDOR_KERNEL_HEADERS directives in the product inheritance
+# tree and then exports a TARGET_PRODUCT_KERNEL_HEADERS variable.
+#
+# The layout of subdirs in any of the kernel-headers dir should mirror the
+# layout of the kernel include/ directory. For example,
+# device/samsung/tuna/kernel-headers/linux/,
+# hardware/ti/omap4xxx/kernel-headers/media/,
+# etc.
+#
+# NOTE: These directories MUST contain post-processed headers using the
+# bionic/libc/kernel/clean_header.py tool. Additionally, the original kernel
+# headers must also be checked in, but in a different subdirectory. By
+# convention, the originals should be checked into original-kernel-headers
+# directory of the same parent dir. For example,
+# device/samsung/tuna/kernel-headers <----- post-processed
+# device/samsung/tuna/original-kernel-headers <----- originals
+#
+TARGET_DEVICE_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_DEVICE_DIR)/kernel-headers))
+
+define validate-kernel-headers
+$(if $(firstword $(foreach hdr_dir,$(1),\
+ $(filter-out kernel-headers,$(notdir $(hdr_dir))))),\
+ $(error Kernel header dirs must be end in kernel-headers: $(1)))
+endef
+# also allow the board config to provide additional directories since
+# there could be device/oem/base_hw and device/oem/derived_hw
+# that both are valid devices but derived_hw needs to use kernel headers
+# from base_hw.
+TARGET_BOARD_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_BOARD_KERNEL_HEADERS)))
+TARGET_BOARD_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_BOARD_KERNEL_HEADERS))
+$(call validate-kernel-headers,$(TARGET_BOARD_KERNEL_HEADERS))
+
+# then add product-inherited includes, to allow for
+# hardware/sivendor/chip/chip.mk to include their own headers
+TARGET_PRODUCT_KERNEL_HEADERS := $(strip $(wildcard $(PRODUCT_VENDOR_KERNEL_HEADERS)))
+TARGET_PRODUCT_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_PRODUCT_KERNEL_HEADERS))
+$(call validate-kernel-headers,$(TARGET_PRODUCT_KERNEL_HEADERS))
+
+# Clean up/verify variables defined by the board config file.
+TARGET_BOOTLOADER_BOARD_NAME := $(strip $(TARGET_BOOTLOADER_BOARD_NAME))
+TARGET_CPU_ABI := $(strip $(TARGET_CPU_ABI))
+ifeq ($(TARGET_CPU_ABI),)
+ $(error No TARGET_CPU_ABI defined by board config: $(board_config_mk))
+endif
+TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
+
+# Commands to generate .toc file common to ELF .so files.
+define _gen_toc_command_for_elf
+$(hide) ($($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) -d $(1) | grep SONAME || echo "No SONAME for $1") > $(2)
+$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) --dyn-syms $(1) | awk '{$$2=""; $$3=""; print}' >> $(2)
+endef
+
+# Commands to generate .toc file from Darwin dynamic library.
+define _gen_toc_command_for_macho
+$(hide) otool -l $(1) | grep LC_ID_DYLIB -A 5 > $(2)
+$(hide) nm -gP $(1) | cut -f1-2 -d" " | grep -v U$$ >> $(2)
+endef
+
+combo_target := HOST_
+combo_2nd_arch_prefix :=
+include $(BUILD_SYSTEM)/combo/select.mk
+
+# Load the 2nd host arch if it's needed.
+ifdef HOST_2ND_ARCH
+combo_target := HOST_
+combo_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/combo/select.mk
+endif
+
+# Load the windows cross compiler under Linux
+ifdef HOST_CROSS_OS
+combo_target := HOST_CROSS_
+combo_2nd_arch_prefix :=
+include $(BUILD_SYSTEM)/combo/select.mk
+
+ifdef HOST_CROSS_2ND_ARCH
+combo_target := HOST_CROSS_
+combo_2nd_arch_prefix := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/combo/select.mk
+endif
+endif
+
+# on windows, the tools have .exe at the end, and we depend on the
+# host config stuff being done first
+
+combo_target := TARGET_
+combo_2nd_arch_prefix :=
+include $(BUILD_SYSTEM)/combo/select.mk
+
+# Load the 2nd target arch if it's needed.
+ifdef TARGET_2ND_ARCH
+combo_target := TARGET_
+combo_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/combo/select.mk
+endif
+
+include $(BUILD_SYSTEM)/ccache.mk
+include $(BUILD_SYSTEM)/goma.mk
+
+ifdef TARGET_PREFER_32_BIT
+TARGET_PREFER_32_BIT_APPS := true
+TARGET_PREFER_32_BIT_EXECUTABLES := true
+endif
+
+ifeq (,$(TARGET_SUPPORTS_32_BIT_APPS)$(TARGET_SUPPORTS_64_BIT_APPS))
+ TARGET_SUPPORTS_32_BIT_APPS := true
+endif
+
+# "ro.product.cpu.abilist32" and "ro.product.cpu.abilist64" are
+# comma separated lists of the 32 and 64 bit ABIs (in order of
+# preference) that the target supports. If TARGET_CPU_ABI_LIST_{32,64}_BIT
+# are defined by the board config, we use them. Else, we construct
+# these lists based on whether TARGET_IS_64_BIT is set.
+#
+# Note that this assumes that the 2ND_CPU_ABI for a 64 bit target
+# is always 32 bits. If this isn't the case, these variables should
+# be overriden in the board configuration.
+ifeq (,$(TARGET_CPU_ABI_LIST_64_BIT))
+ ifeq (true|true,$(TARGET_IS_64_BIT)|$(TARGET_SUPPORTS_64_BIT_APPS))
+ TARGET_CPU_ABI_LIST_64_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
+ endif
+endif
+
+ifeq (,$(TARGET_CPU_ABI_LIST_32_BIT))
+ ifneq (true,$(TARGET_IS_64_BIT))
+ TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
+ else
+ ifeq (true,$(TARGET_SUPPORTS_32_BIT_APPS))
+ # For a 64 bit target, assume that the 2ND_CPU_ABI
+ # is a 32 bit ABI.
+ TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2)
+ endif
+ endif
+endif
+
+# "ro.product.cpu.abilist" is a comma separated list of ABIs (in order
+# of preference) that the target supports. If a TARGET_CPU_ABI_LIST
+# is specified by the board configuration, we use that. If not, we
+# build a list out of the TARGET_CPU_ABIs specified by the config.
+ifeq (,$(TARGET_CPU_ABI_LIST))
+ ifeq ($(TARGET_IS_64_BIT)|$(TARGET_PREFER_32_BIT_APPS),true|true)
+ TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_32_BIT) $(TARGET_CPU_ABI_LIST_64_BIT)
+ else
+ TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_64_BIT) $(TARGET_CPU_ABI_LIST_32_BIT)
+ endif
+endif
+
+# Strip whitespace from the ABI list string.
+TARGET_CPU_ABI_LIST := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST)))
+TARGET_CPU_ABI_LIST_32_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_32_BIT)))
+TARGET_CPU_ABI_LIST_64_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_64_BIT)))
+
+# Compute TARGET_TOOLCHAIN_ROOT from TARGET_TOOLS_PREFIX
+# if only TARGET_TOOLS_PREFIX is passed to the make command.
+ifndef TARGET_TOOLCHAIN_ROOT
+TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLS_PREFIX)))
+TARGET_TOOLCHAIN_ROOT := $(patsubst %/, %, $(dir $(TARGET_TOOLCHAIN_ROOT)))
+TARGET_TOOLCHAIN_ROOT := $(wildcard $(TARGET_TOOLCHAIN_ROOT))
+endif
+
+# Normalize WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK
+ifeq ($(strip $(WITH_STATIC_ANALYZER)),0)
+ WITH_STATIC_ANALYZER :=
+endif
+ifeq ($(strip $(WITH_SYNTAX_CHECK)),0)
+ WITH_SYNTAX_CHECK :=
+endif
+
+# define clang/llvm versions and base directory.
+include $(BUILD_SYSTEM)/clang/versions.mk
+
+# Disable WITH_STATIC_ANALYZER and WITH_SYNTAX_CHECK if tool can't be found
+SYNTAX_TOOLS_PREFIX := \
+ $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/tools/scan-build/libexec
+ifneq ($(strip $(WITH_STATIC_ANALYZER)),)
+ ifeq ($(wildcard $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer),)
+ $(warning *** Disable WITH_STATIC_ANALYZER because $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer does not exist)
+ WITH_STATIC_ANALYZER :=
+ endif
+endif
+
+# WITH_STATIC_ANALYZER trumps WITH_SYNTAX_CHECK
+ifneq ($(strip $(WITH_STATIC_ANALYZER)),)
+ ifneq ($(strip $(WITH_SYNTAX_CHECK)),)
+ $(warning *** Disable WITH_SYNTAX_CHECK in the presence of static analyzer WITH_STATIC_ANALYZER)
+ WITH_SYNTAX_CHECK :=
+ endif
+endif
+
+# Pick a Java compiler.
+include $(BUILD_SYSTEM)/combo/javac.mk
+
+# ---------------------------------------------------------------
+# Check that the configuration is current. We check that
+# BUILD_ENV_SEQUENCE_NUMBER is current against this value.
+# Don't fail if we're called from envsetup, so they have a
+# chance to update their environment.
+
+ifeq (,$(strip $(CALLED_FROM_SETUP)))
+ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
+ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
+$(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
+$(info *** If you use envsetup/lunch/choosecombo:)
+$(info *** - Re-execute envsetup (". envsetup.sh"))
+$(info *** - Re-run lunch or choosecombo)
+$(info *** If you use buildspec.mk:)
+$(info *** - Look at buildspec.mk.default to see what has changed)
+$(info *** - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
+$(error bailing..)
+endif
+endif
+endif
+
+# Set up PDK so we can use TARGET_BUILD_PDK to select prebuilt tools below
+.PHONY: pdk fusion
+pdk fusion: $(DEFAULT_GOAL)
+
+# What to build:
+# pdk fusion if:
+# 1) PDK_FUSION_PLATFORM_ZIP is passed in from the environment
+# or
+# 2) the platform.zip exists in the default location
+# or
+# 3) fusion is a command line build goal,
+# PDK_FUSION_PLATFORM_ZIP is needed anyway, then do we need the 'fusion' goal?
+# otherwise pdk only if:
+# 1) pdk is a command line build goal
+# or
+# 2) TARGET_BUILD_PDK is passed in from the environment
+
+# if PDK_FUSION_PLATFORM_ZIP is specified, do not override.
+ifndef PDK_FUSION_PLATFORM_ZIP
+# Most PDK project paths should be using vendor/pdk/TARGET_DEVICE
+# but some legacy ones (e.g. mini_armv7a_neon generic PDK) were setup
+# with vendor/pdk/TARGET_PRODUCT.
+_pdk_fusion_default_platform_zip = $(strip \
+ $(wildcard vendor/pdk/$(TARGET_DEVICE)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform/platform.zip) \
+ $(wildcard vendor/pdk/$(TARGET_DEVICE)/$(patsubst aosp_%,full_%,$(TARGET_PRODUCT))-$(TARGET_BUILD_VARIANT)/platform/platform.zip) \
+ $(wildcard vendor/pdk/$(TARGET_PRODUCT)/$(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT)/platform/platform.zip) \
+ $(wildcard vendor/pdk/$(TARGET_PRODUCT)/$(patsubst aosp_%,full_%,$(TARGET_PRODUCT))-$(TARGET_BUILD_VARIANT)/platform/platform.zip))
+ifneq (,$(_pdk_fusion_default_platform_zip))
+PDK_FUSION_PLATFORM_ZIP := $(word 1, $(_pdk_fusion_default_platform_zip))
+TARGET_BUILD_PDK := true
+endif # _pdk_fusion_default_platform_zip
+endif # !PDK_FUSION_PLATFORM_ZIP
+
+ifneq (,$(filter pdk fusion, $(MAKECMDGOALS)))
+TARGET_BUILD_PDK := true
+ifneq (,$(filter fusion, $(MAKECMDGOALS)))
+ifndef PDK_FUSION_PLATFORM_ZIP
+ $(error Specify PDK_FUSION_PLATFORM_ZIP to do a PDK fusion.)
+endif
+endif # fusion
+endif # pdk or fusion
+
+ifdef PDK_FUSION_PLATFORM_ZIP
+TARGET_BUILD_PDK := true
+ifeq (,$(wildcard $(PDK_FUSION_PLATFORM_ZIP)))
+ $(error Cannot find file $(PDK_FUSION_PLATFORM_ZIP).)
+endif
+endif
+
+BUILD_PLATFORM_ZIP := $(filter platform platform-java,$(MAKECMDGOALS))
+
+#
+# Tools that are prebuilts for TARGET_BUILD_APPS
+#
+
+ACP := $(HOST_OUT_EXECUTABLES)/acp
+AIDL := $(HOST_OUT_EXECUTABLES)/aidl
+AAPT := $(HOST_OUT_EXECUTABLES)/aapt
+AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
+ZIPALIGN := $(HOST_OUT_EXECUTABLES)/zipalign
+SIGNAPK_JAR := $(HOST_OUT_JAVA_LIBRARIES)/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
+SIGNAPK_JNI_LIBRARY_PATH := $(HOST_OUT_SHARED_LIBRARIES)
+LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc
+BCC_COMPAT := $(HOST_OUT_EXECUTABLES)/bcc_compat
+
+DX := $(HOST_OUT_EXECUTABLES)/dx
+MAINDEXCLASSES := $(HOST_OUT_EXECUTABLES)/mainDexClasses
+
+USE_PREBUILT_SDK_TOOLS_IN_PLACE := true
+
+# Override the definitions above for unbundled and PDK builds
+ifneq (,$(TARGET_BUILD_APPS)$(filter true,$(TARGET_BUILD_PDK)))
+prebuilt_sdk_tools := prebuilts/sdk/tools
+prebuilt_sdk_tools_bin := $(prebuilt_sdk_tools)/$(HOST_OS)/bin
+
+ACP := $(prebuilt_sdk_tools_bin)/acp
+AIDL := $(prebuilt_sdk_tools_bin)/aidl
+AAPT := $(prebuilt_sdk_tools_bin)/aapt
+AAPT2 := $(prebuilt_sdk_tools_bin)/aapt2
+ZIPALIGN := $(prebuilt_sdk_tools_bin)/zipalign
+SIGNAPK_JAR := $(prebuilt_sdk_tools)/lib/signapk$(COMMON_JAVA_PACKAGE_SUFFIX)
+# Use 64-bit libraries unconditionally because 32-bit JVMs are no longer supported
+SIGNAPK_JNI_LIBRARY_PATH := $(prebuilt_sdk_tools)/$(HOST_OS)/lib64
+
+DX := $(prebuilt_sdk_tools)/dx
+MAINDEXCLASSES := $(prebuilt_sdk_tools)/mainDexClasses
+
+# Don't use prebuilts in PDK
+ifneq ($(TARGET_BUILD_PDK),true)
+LLVM_RS_CC := $(prebuilt_sdk_tools_bin)/llvm-rs-cc
+BCC_COMPAT := $(prebuilt_sdk_tools_bin)/bcc_compat
+endif # TARGET_BUILD_PDK
+endif # TARGET_BUILD_APPS || TARGET_BUILD_PDK
+
+
+# ---------------------------------------------------------------
+# Generic tools.
+JACK := $(HOST_OUT_EXECUTABLES)/jack
+
+LEX := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/flex/flex-2.5.39
+# The default PKGDATADIR built in the prebuilt bison is a relative path
+# external/bison/data.
+# To run bison from elsewhere you need to set up enviromental variable
+# BISON_PKGDATADIR.
+BISON_PKGDATADIR := $(PWD)/external/bison/data
+BISON := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/bison/bison
+YACC := $(BISON) -d
+
+YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
+
+DOXYGEN:= doxygen
+AIDL_CPP := $(HOST_OUT_EXECUTABLES)/aidl-cpp$(HOST_EXECUTABLE_SUFFIX)
+ifeq ($(HOST_OS),linux)
+BREAKPAD_DUMP_SYMS := $(HOST_OUT_EXECUTABLES)/dump_syms
+else
+# For non-supported hosts, do not generate breakpad symbols.
+BREAKPAD_GENERATE_SYMBOLS := false
+endif
+PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
+VTSC := $(HOST_OUT_EXECUTABLES)/vtsc$(HOST_EXECUTABLE_SUFFIX)
+DBUS_GENERATOR := $(HOST_OUT_EXECUTABLES)/dbus-binding-generator
+MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
+MINIGZIP := $(HOST_OUT_EXECUTABLES)/minigzip$(HOST_EXECUTABLE_SUFFIX)
+ifeq (,$(strip $(BOARD_CUSTOM_MKBOOTIMG)))
+MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
+else
+MKBOOTIMG := $(BOARD_CUSTOM_MKBOOTIMG)
+endif
+APICHECK := $(HOST_OUT_EXECUTABLES)/apicheck$(HOST_EXECUTABLE_SUFFIX)
+FS_GET_STATS := $(HOST_OUT_EXECUTABLES)/fs_get_stats$(HOST_EXECUTABLE_SUFFIX)
+MAKE_EXT4FS := $(HOST_OUT_EXECUTABLES)/make_ext4fs$(HOST_EXECUTABLE_SUFFIX)
+BLK_ALLOC_TO_BASE_FS := $(HOST_OUT_EXECUTABLES)/blk_alloc_to_base_fs$(HOST_EXECUTABLE_SUFFIX)
+MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg.sh
+MAKE_SQUASHFS := $(HOST_OUT_EXECUTABLES)/mksquashfs$(HOST_EXECUTABLE_SUFFIX)
+MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage.sh
+MAKE_F2FS := $(HOST_OUT_EXECUTABLES)/make_f2fs$(HOST_EXECUTABLE_SUFFIX)
+MKF2FSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg.sh
+SIMG2IMG := $(HOST_OUT_EXECUTABLES)/simg2img$(HOST_EXECUTABLE_SUFFIX)
+IMG2SIMG := $(HOST_OUT_EXECUTABLES)/img2simg$(HOST_EXECUTABLE_SUFFIX)
+E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
+MKTARBALL := build/tools/mktarball.sh
+TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
+E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
+JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
+DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
+
+ifeq ($(ANDROID_COMPILE_WITH_JACK),true)
+DEFAULT_JACK_ENABLED:=full
+else
+DEFAULT_JACK_ENABLED:=
+endif
+ifneq ($(ANDROID_JACK_EXTRA_ARGS),)
+DEFAULT_JACK_EXTRA_ARGS := $(ANDROID_JACK_EXTRA_ARGS)
+else
+DEFAULT_JACK_EXTRA_ARGS := @$(BUILD_SYSTEM)/jack-default.args
+endif
+# Turn off jack warnings by default.
+DEFAULT_JACK_EXTRA_ARGS += --verbose error
+
+PROGUARD := external/proguard/bin/proguard.sh
+JAVATAGS := build/tools/java-event-log-tags.py
+RMTYPEDEFS := $(HOST_OUT_EXECUTABLES)/rmtypedefs
+APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
+VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
+BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
+BOOT_SIGNER := $(HOST_OUT_EXECUTABLES)/boot_signer
+FUTILITY := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/futility/futility
+VBOOT_SIGNER := prebuilts/misc/scripts/vboot_signer/vboot_signer.sh
+FEC := $(HOST_OUT_EXECUTABLES)/fec
+
+ifndef TARGET_BUILD_APPS
+ZIPTIME := $(HOST_OUT_EXECUTABLES)/ziptime$(HOST_EXECUTABLE_SUFFIX)
+endif
+
+# ijar converts a .jar file to a smaller .jar file which only has its
+# interfaces.
+IJAR := $(HOST_OUT_EXECUTABLES)/ijar$(BUILD_EXECUTABLE_SUFFIX)
+DEXDUMP := $(HOST_OUT_EXECUTABLES)/dexdump2$(BUILD_EXECUTABLE_SUFFIX)
+
+# relocation packer
+RELOCATION_PACKER := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/relocation_packer/relocation_packer
+
+FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin
+FINDBUGS := $(FINDBUGS_DIR)/findbugs
+EMMA_JAR := external/emma/lib/emma$(COMMON_JAVA_PACKAGE_SUFFIX)
+
+# Tool to merge AndroidManifest.xmls
+ANDROID_MANIFEST_MERGER := java -classpath prebuilts/devtools/tools/lib/manifest-merger.jar com.android.manifmerger.Main merge
+
+COLUMN:= column
+
+# We may not have the right JAVA_HOME/PATH set up yet when this is run from envsetup.sh.
+ifneq ($(CALLED_FROM_SETUP),true)
+HOST_JDK_TOOLS_JAR:= $(shell $(BUILD_SYSTEM)/find-jdk-tools-jar.sh)
+
+ifneq ($(HOST_JDK_TOOLS_JAR),)
+ifeq ($(wildcard $(HOST_JDK_TOOLS_JAR)),)
+$(error Error: could not find jdk tools.jar at $(HOST_JDK_TOOLS_JAR), please check if your JDK was installed correctly)
+endif
+endif
+
+# Is the host JDK 64-bit version?
+HOST_JDK_IS_64BIT_VERSION :=
+ifneq ($(filter 64-Bit, $(shell java -version 2>&1)),)
+HOST_JDK_IS_64BIT_VERSION := true
+endif
+endif # CALLED_FROM_SETUP not true
+
+# It's called md5 on Mac OS and md5sum on Linux
+ifeq ($(HOST_OS),darwin)
+MD5SUM:=md5 -q
+else
+MD5SUM:=md5sum
+endif
+
+APICHECK_CLASSPATH := $(HOST_JDK_TOOLS_JAR)
+APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
+APICHECK_CLASSPATH := $(APICHECK_CLASSPATH):$(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX)
+APICHECK_COMMAND := $(APICHECK) -JXmx1024m -J"classpath $(APICHECK_CLASSPATH)"
+
+# The default key if not set as LOCAL_CERTIFICATE
+ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
+ DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
+else
+ DEFAULT_SYSTEM_DEV_CERTIFICATE := build/target/product/security/testkey
+endif
+
+# ###############################################################
+# Set up final options.
+# ###############################################################
+
+ifneq ($(COMMON_GLOBAL_CFLAGS)$(COMMON_GLOBAL_CPPFLAGS),)
+$(warning COMMON_GLOBAL_C(PP)FLAGS changed)
+$(info *** Device configurations are no longer allowed to change the global flags.)
+$(info *** COMMON_GLOBAL_CFLAGS: $(COMMON_GLOBAL_CFLAGS))
+$(info *** COMMON_GLOBAL_CPPFLAGS: $(COMMON_GLOBAL_CPPFLAGS))
+$(error bailing...)
+endif
+
+# These can be changed to modify both host and device modules.
+COMMON_GLOBAL_CFLAGS:= -DANDROID -fmessage-length=0 -W -Wall -Wno-unused -Winit-self -Wpointer-arith
+COMMON_RELEASE_CFLAGS:= -DNDEBUG -UDEBUG
+
+# Force gcc to always output color diagnostics. Ninja will strip the ANSI
+# color codes if it is not running in a terminal.
+ifdef BUILDING_WITH_NINJA
+COMMON_GLOBAL_CFLAGS += -fdiagnostics-color
+endif
+
+COMMON_GLOBAL_CPPFLAGS:= -Wsign-promo
+COMMON_RELEASE_CPPFLAGS:=
+
+GLOBAL_CFLAGS_NO_OVERRIDE := \
+ -Werror=int-to-pointer-cast \
+ -Werror=pointer-to-int-cast \
+
+GLOBAL_CLANG_CFLAGS_NO_OVERRIDE := \
+ -Werror=address-of-temporary \
+ -Werror=null-dereference \
+ -Werror=return-type \
+
+GLOBAL_CPPFLAGS_NO_OVERRIDE :=
+
+# list of flags to turn specific warnings in to errors
+TARGET_ERROR_FLAGS := -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Werror=date-time
+
+# We run gcc/clang with PWD=/proc/self/cwd to remove the $TOP
+# from the debug output. That way two builds in two different
+# directories will create the same output.
+# /proc doesn't exist on Darwin.
+ifeq ($(HOST_OS),linux)
+RELATIVE_PWD := PWD=/proc/self/cwd
+# Remove this useless prefix from the debug output.
+COMMON_GLOBAL_CFLAGS += -fdebug-prefix-map=/proc/self/cwd=
+else
+RELATIVE_PWD :=
+endif
+
+# Allow the C/C++ macros __DATE__ and __TIME__ to be set to the
+# build date and time, so that a build may be repeated.
+# Write the date and time to a file so that the command line
+# doesn't change every time, which would cause ninja to rebuild
+# the files.
+$(shell mkdir -p $(OUT_DIR) && \
+ $(DATE) "+%b %_d %Y" > $(OUT_DIR)/build_c_date.txt && \
+ $(DATE) +%T > $(OUT_DIR)/build_c_time.txt)
+BUILD_DATETIME_C_DATE := $$(cat $(OUT_DIR)/build_c_date.txt)
+BUILD_DATETIME_C_TIME := $$(cat $(OUT_DIR)/build_c_time.txt)
+ifeq ($(OVERRIDE_C_DATE_TIME),true)
+COMMON_GLOBAL_CFLAGS += -Wno-builtin-macro-redefined -D__DATE__="\"$(BUILD_DATETIME_C_DATE)\"" -D__TIME__=\"$(BUILD_DATETIME_C_TIME)\"
+endif
+
+HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
+HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
+
+HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
+HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
+
+TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
+TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
+
+TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
+TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
+
+HOST_GLOBAL_LD_DIRS += -L$(HOST_OUT_INTERMEDIATE_LIBRARIES)
+TARGET_GLOBAL_LD_DIRS += -L$(TARGET_OUT_INTERMEDIATE_LIBRARIES)
+
+HOST_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_OUT_HEADERS)
+TARGET_PROJECT_INCLUDES:= $(SRC_HEADERS) $(TARGET_OUT_HEADERS) \
+ $(TARGET_DEVICE_KERNEL_HEADERS) $(TARGET_BOARD_KERNEL_HEADERS) \
+ $(TARGET_PRODUCT_KERNEL_HEADERS)
+
+# Many host compilers don't support these flags, so we have to make
+# sure to only specify them for the target compilers checked in to
+# the source tree.
+TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
+
+HOST_GLOBAL_CFLAGS += $(HOST_RELEASE_CFLAGS)
+HOST_GLOBAL_CPPFLAGS += $(HOST_RELEASE_CPPFLAGS)
+
+TARGET_GLOBAL_CFLAGS += $(TARGET_RELEASE_CFLAGS)
+TARGET_GLOBAL_CPPFLAGS += $(TARGET_RELEASE_CPPFLAGS)
+
+ifdef TARGET_2ND_ARCH
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS += -L$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES := $(TARGET_PROJECT_INCLUDES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $(TARGET_ERROR_FLAGS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CFLAGS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CPPFLAGS += $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_RELEASE_CPPFLAGS)
+endif
+
+ifdef HOST_2ND_ARCH
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $(COMMON_GLOBAL_CFLAGS)
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS += -L$($(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES)
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_PROJECT_INCLUDES := $(HOST_PROJECT_INCLUDES)
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CFLAGS)
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_CPPFLAGS += $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_RELEASE_CPPFLAGS)
+endif
+
+ifdef HOST_CROSS_OS
+HOST_CROSS_GLOBAL_CFLAGS += $(filter-out $(HOST_CROSS_UNKNOWN_CFLAGS),$(COMMON_GLOBAL_CFLAGS))
+HOST_CROSS_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
+HOST_CROSS_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
+HOST_CROSS_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
+HOST_CROSS_GLOBAL_LD_DIRS += -L$(HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES)
+HOST_CROSS_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $(HOST_CROSS_OUT_HEADERS)
+HOST_CROSS_GLOBAL_CFLAGS += $(HOST_CROSS_RELEASE_CFLAGS)
+HOST_CROSS_GLOBAL_CPPFLAGS += $(HOST_CROSS_RELEASE_CPPFLAGS)
+
+ifdef HOST_CROSS_2ND_ARCH
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CFLAGS += $(filter-out $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_UNKNOWN_CFLAGS),$(COMMON_GLOBAL_CFLAGS))
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CFLAGS += $(COMMON_RELEASE_CFLAGS)
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CPPFLAGS += $(COMMON_GLOBAL_CPPFLAGS)
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CPPFLAGS += $(COMMON_RELEASE_CPPFLAGS)
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_LD_DIRS += -L$($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES)
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_PROJECT_INCLUDES:= $(SRC_HEADERS) $(SRC_HOST_HEADERS) $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_HEADERS)
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CFLAGS += $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CFLAGS)
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_GLOBAL_CPPFLAGS += $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_RELEASE_CPPFLAGS)
+endif
+endif
+
+ifdef BRILLO
+# Add a C define that identifies Brillo targets. __BRILLO__ should only be used
+# to differentiate between Brillo and non-Brillo-but-Android environments. Use
+# __ANDROID__ instead to test if something is being built in an Android-derived
+# environment (including Brillo) as opposed to an entirely different
+# environment (e.g. Chrome OS).
+TARGET_GLOBAL_CFLAGS += -D__BRILLO__
+ifdef TARGET_2ND_ARCH
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_CFLAGS += -D__BRILLO__
+endif
+endif
+
+# allow overriding default Java libraries on a per-target basis
+ifeq ($(TARGET_DEFAULT_JAVA_LIBRARIES),)
+ TARGET_DEFAULT_JAVA_LIBRARIES := core-oj core-libart core-junit ext framework okhttp
+endif
+
+# Flags for DEX2OAT
+first_non_empty_of_three = $(if $(1),$(1),$(if $(2),$(2),$(3)))
+DEX2OAT_TARGET_ARCH := $(TARGET_ARCH)
+DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_CPU_VARIANT),$(TARGET_ARCH_VARIANT),default)
+DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
+
+ifdef TARGET_2ND_ARCH
+$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH := $(TARGET_2ND_ARCH)
+$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_2ND_CPU_VARIANT),$(TARGET_2ND_ARCH_VARIANT),default)
+$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
+endif
+
+# define clang/llvm tools and global flags
+include $(BUILD_SYSTEM)/clang/config.mk
+
+# ###############################################################
+# Collect a list of the SDK versions that we could compile against
+# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
+# ###############################################################
+
+HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/sdk
+HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/ndk
+
+# The path where app can reference the support library resources.
+ifdef TARGET_BUILD_APPS
+SUPPORT_LIBRARY_ROOT := $(HISTORICAL_SDK_VERSIONS_ROOT)/current/support
+else
+SUPPORT_LIBRARY_ROOT := frameworks/support
+endif
+
+# Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N.
+# The 'current' version is whatever this source tree is.
+#
+# sgrax is the opposite of xargs. It takes the list of args and puts them
+# on each line for sort to process.
+# sort -g is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
+
+# Numerically sort a list of numbers
+# $(1): the list of numbers to be sorted
+define numerically_sort
+$(shell function sgrax() { \
+ while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
+ } ; \
+ ( sgrax $(1) | sort -g ) )
+endef
+
+TARGET_AVAILABLE_SDK_VERSIONS := $(call numerically_sort,\
+ $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%, \
+ $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/android.jar)))
+
+# We don't have prebuilt test_current SDK yet.
+TARGET_AVAILABLE_SDK_VERSIONS := test_current $(TARGET_AVAILABLE_SDK_VERSIONS)
+
+INTERNAL_PLATFORM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/public_api.txt
+INTERNAL_PLATFORM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/removed.txt
+INTERNAL_PLATFORM_SYSTEM_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-api.txt
+INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/system-removed.txt
+INTERNAL_PLATFORM_TEST_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/test-api.txt
+INTERNAL_PLATFORM_TEST_REMOVED_API_FILE := $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/test-removed.txt
+
+# This is the standard way to name a directory containing prebuilt target
+# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
+TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
+ifdef TARGET_2ND_ARCH
+TARGET_2ND_PREBUILT_TAG := android-$(TARGET_2ND_ARCH)
+endif
+
+# Set up RS prebuilt variables for compatibility library
+
+RS_PREBUILT_CLCORE := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/librsrt_$(TARGET_ARCH).bc
+RS_PREBUILT_COMPILER_RT := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/libcompiler_rt.a
+ifeq (true,$(TARGET_IS_64_BIT))
+RS_PREBUILT_LIBPATH := -L prebuilts/ndk/current/platforms/android-21/arch-$(TARGET_ARCH)/usr/lib64 \
+ -L prebuilts/ndk/current/platforms/android-21/arch-$(TARGET_ARCH)/usr/lib
+else
+RS_PREBUILT_LIBPATH := -L prebuilts/ndk/current/platforms/android-9/arch-$(TARGET_ARCH)/usr/lib
+endif
+
+# API Level lists for Renderscript Compat lib.
+RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20
+RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13
+
+include $(BUILD_SYSTEM)/dumpvar.mk
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
new file mode 100644
index 0000000000000000000000000000000000000000..dbcf276952c5b16d0d558f30bf1d88eaaecab859
--- /dev/null
+++ b/core/config_sanitizers.mk
@@ -0,0 +1,161 @@
+##############################################
+## Perform configuration steps for sanitizers.
+##############################################
+
+my_sanitize := $(strip $(LOCAL_SANITIZE))
+
+# SANITIZE_HOST is only in effect if the module is already using clang (host
+# modules that haven't set `LOCAL_CLANG := false` and device modules that
+# have set `LOCAL_CLANG := true`.
+my_global_sanitize :=
+ifeq ($(my_clang),true)
+ ifdef LOCAL_IS_HOST_MODULE
+ my_global_sanitize := $(strip $(SANITIZE_HOST))
+
+ # SANITIZE_HOST=true is a deprecated way to say SANITIZE_HOST=address.
+ my_global_sanitize := $(subst true,address,$(my_global_sanitize))
+ else
+ my_global_sanitize := $(strip $(SANITIZE_TARGET))
+ endif
+endif
+
+# The sanitizer specified by the environment wins over the module.
+ifneq ($(my_global_sanitize),)
+ my_sanitize := $(my_global_sanitize)
+endif
+
+# The sanitizer specified in the product configuration wins over the previous.
+ifneq ($(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG),)
+ my_sanitize := $(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
+ ifeq ($(my_sanitize),never)
+ my_sanitize :=
+ endif
+endif
+
+# Add a filter point for 32-bit vs 64-bit sanitization (to lighten the burden).
+SANITIZE_ARCH ?= 32 64
+ifeq ($(filter $(SANITIZE_ARCH),$(my_32_64_bit_suffix)),)
+ my_sanitize :=
+endif
+
+# Add a filter point based on module owner (to lighten the burden). The format is a space- or
+# colon-separated list of owner names.
+ifneq (,$(SANITIZE_NEVER_BY_OWNER))
+ ifneq (,$(LOCAL_MODULE_OWNER))
+ ifneq (,$(filter $(LOCAL_MODULE_OWNER),$(subst :, ,$(SANITIZE_NEVER_BY_OWNER))))
+ $(warning Not sanitizing $(LOCAL_MODULE) based on module owner.)
+ my_sanitize :=
+ endif
+ endif
+endif
+
+# Don't apply sanitizers to NDK code.
+ifdef LOCAL_SDK_VERSION
+ my_sanitize :=
+endif
+
+# Never always wins.
+ifeq ($(LOCAL_SANITIZE),never)
+ my_sanitize :=
+endif
+
+# TSAN is not supported on 32-bit architectures. For non-multilib cases, make
+# its use an error. For multilib cases, don't use it for the 32-bit case.
+ifneq ($(filter thread,$(my_sanitize)),)
+ ifeq ($(my_32_64_bit_suffix),32)
+ ifeq ($(my_module_multilib),both)
+ my_sanitize := $(filter-out thread,$(my_sanitize))
+ else
+ $(error $(LOCAL_PATH): $(LOCAL_MODULE): TSAN cannot be used for 32-bit modules.)
+ endif
+ endif
+endif
+
+# Undefined symbols can occur if a non-sanitized library links
+# sanitized static libraries. That's OK, because the executable
+# always depends on the ASan runtime library, which defines these
+# symbols.
+ifneq ($(strip $(SANITIZE_TARGET)),)
+ ifndef LOCAL_IS_HOST_MODULE
+ ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
+ ifeq ($(my_sanitize),)
+ my_allow_undefined_symbols := true
+ endif
+ endif
+ # Workaround for a bug in AddressSanitizer that breaks stack unwinding.
+ # https://code.google.com/p/address-sanitizer/issues/detail?id=387
+ # Revert when external/compiler-rt is updated past r236014.
+ LOCAL_PACK_MODULE_RELOCATIONS := false
+ endif
+endif
+
+# Sanitizers can only be used with clang.
+ifneq ($(my_clang),true)
+ ifneq ($(my_sanitize),)
+ $(error $(LOCAL_PATH): $(LOCAL_MODULE): Use of sanitizers requires LOCAL_CLANG := true)
+ endif
+endif
+
+ifneq ($(filter default-ub,$(my_sanitize)),)
+ my_sanitize := $(CLANG_DEFAULT_UB_CHECKS)
+endif
+
+ifneq ($(filter coverage,$(my_sanitize)),)
+ ifeq ($(filter address,$(my_sanitize)),)
+ $(error $(LOCAL_PATH): $(LOCAL_MODULE): Use of 'coverage' also requires 'address')
+ endif
+ my_cflags += -fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp
+ my_sanitize := $(filter-out coverage,$(my_sanitize))
+endif
+
+ifneq ($(my_sanitize),)
+ fsanitize_arg := $(subst $(space),$(comma),$(my_sanitize))
+ my_cflags += -fsanitize=$(fsanitize_arg)
+
+ ifdef LOCAL_IS_HOST_MODULE
+ my_cflags += -fno-sanitize-recover=all
+ my_ldflags += -fsanitize=$(fsanitize_arg)
+ my_ldlibs += -lrt -ldl
+ else
+ ifeq ($(filter address,$(my_sanitize)),)
+ my_cflags += -fsanitize-trap=all
+ my_cflags += -ftrap-function=abort
+ endif
+ my_shared_libraries += libdl
+ endif
+endif
+
+ifneq ($(filter address,$(my_sanitize)),)
+ # Frame pointer based unwinder in ASan requires ARM frame setup.
+ LOCAL_ARM_MODE := arm
+ my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
+ my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
+ ifdef LOCAL_IS_HOST_MODULE
+ # -nodefaultlibs (provided with libc++) prevents the driver from linking
+ # libraries needed with -fsanitize=address. http://b/18650275 (WAI)
+ my_ldlibs += -lm -lpthread
+ my_ldflags += -Wl,--no-as-needed
+ else
+ my_cflags += -mllvm -asan-globals=0
+ # ASan runtime library must be the first in the link order.
+ my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
+ $(my_shared_libraries) \
+ $(ADDRESS_SANITIZER_CONFIG_EXTRA_SHARED_LIBRARIES)
+ my_static_libraries += $(ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES)
+
+ my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
+ # Make sure linker_asan get installed.
+ $(LOCAL_INSTALLED_MODULE) : | $(PRODUCT_OUT)$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
+ endif
+endif
+
+ifneq ($(filter undefined,$(my_sanitize)),)
+ ifndef LOCAL_IS_HOST_MODULE
+ $(error ubsan is not yet supported on the target)
+ endif
+endif
+
+ifneq ($(strip $(LOCAL_SANITIZE_RECOVER)),)
+ recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)),
+ my_cflags += -fsanitize-recover=$(recover_arg)
+endif
diff --git a/core/configure_local_jack.mk b/core/configure_local_jack.mk
new file mode 100644
index 0000000000000000000000000000000000000000..2270c88c469e6cc9ca44720c51c99c143b7489a8
--- /dev/null
+++ b/core/configure_local_jack.mk
@@ -0,0 +1,39 @@
+#
+# 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.
+#
+
+ifdef ANDROID_FORCE_JACK_ENABLED
+LOCAL_JACK_ENABLED := $(ANDROID_FORCE_JACK_ENABLED)
+endif
+
+LOCAL_JACK_ENABLED := $(strip $(LOCAL_JACK_ENABLED))
+LOCAL_MODULE := $(strip $(LOCAL_MODULE))
+
+ifneq ($(LOCAL_JACK_ENABLED),full)
+ifneq ($(LOCAL_JACK_ENABLED),incremental)
+ifdef LOCAL_JACK_ENABLED
+ifneq ($(LOCAL_JACK_ENABLED),disabled)
+$(error $(LOCAL_PATH): invalid LOCAL_JACK_ENABLED "$(LOCAL_JACK_ENABLED)" for $(LOCAL_MODULE))
+endif
+endif
+LOCAL_JACK_ENABLED :=
+endif
+endif
+
+ifdef $(LOCAL_MODULE).JACK_VERSION
+LOCAL_JACK_VERSION := $($(LOCAL_MODULE).JACK_VERSION)
+else
+LOCAL_JACK_VERSION := $(JACK_DEFAULT_VERSION)
+endif
diff --git a/core/configure_module_stem.mk b/core/configure_module_stem.mk
new file mode 100644
index 0000000000000000000000000000000000000000..48b77871a02cc610c60dca524218c1ff808dc7bf
--- /dev/null
+++ b/core/configure_module_stem.mk
@@ -0,0 +1,20 @@
+my_multilib_stem := $(LOCAL_MODULE_STEM_$(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32))
+ifdef my_multilib_stem
+ my_module_stem := $(my_multilib_stem)
+else ifdef LOCAL_MODULE_STEM
+ my_module_stem := $(LOCAL_MODULE_STEM)
+else
+ my_module_stem := $(LOCAL_MODULE)
+endif
+
+ifdef LOCAL_BUILT_MODULE_STEM
+ my_built_module_stem := $(LOCAL_BUILT_MODULE_STEM)
+else
+ my_built_module_stem := $(my_module_stem)$(LOCAL_MODULE_SUFFIX)
+endif
+
+ifdef LOCAL_INSTALLED_MODULE_STEM
+ my_installed_module_stem := $(LOCAL_INSTALLED_MODULE_STEM)
+else
+ my_installed_module_stem := $(my_module_stem)$(LOCAL_MODULE_SUFFIX)
+endif
diff --git a/core/copy_headers.mk b/core/copy_headers.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7d5a5d99225c242193dd129bea27d392a1c9e254
--- /dev/null
+++ b/core/copy_headers.mk
@@ -0,0 +1,27 @@
+###########################################################
+## Copy headers to the install tree
+###########################################################
+ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
+ my_prefix := HOST_
+else
+ my_prefix := TARGET_
+endif
+
+# Create a rule to copy each header, and make the
+# all_copied_headers phony target depend on each
+# destination header. copy-one-header defines the
+# actual rule.
+#
+$(foreach header,$(LOCAL_COPY_HEADERS), \
+ $(eval _chFrom := $(LOCAL_PATH)/$(header)) \
+ $(eval _chTo := \
+ $(if $(LOCAL_COPY_HEADERS_TO),\
+ $($(my_prefix)OUT_HEADERS)/$(LOCAL_COPY_HEADERS_TO)/$(notdir $(header)),\
+ $($(my_prefix)OUT_HEADERS)/$(notdir $(header)))) \
+ $(eval ALL_COPIED_HEADERS.$(_chTo).MAKEFILE += $(LOCAL_MODULE_MAKEFILE)) \
+ $(eval ALL_COPIED_HEADERS.$(_chTo).SRC += $(_chFrom)) \
+ $(if $(filter $(_chTo),$(ALL_COPIED_HEADERS)),, \
+ $(eval ALL_COPIED_HEADERS += $(_chTo))) \
+ )
+_chFrom :=
+_chTo :=
diff --git a/core/cxx_stl_setup.mk b/core/cxx_stl_setup.mk
new file mode 100644
index 0000000000000000000000000000000000000000..37be1f7cc8fea286fb58ceeed79860fdd1888c48
--- /dev/null
+++ b/core/cxx_stl_setup.mk
@@ -0,0 +1,123 @@
+#############################################################
+## Set up flags based on LOCAL_CXX_STL.
+## Input variables: LOCAL_CXX_STL, my_prefix
+## Output variables: My_cflags, my_c_includes, my_shared_libraries, etc.
+#############################################################
+
+# Select the appropriate C++ STL
+ifeq ($(strip $(LOCAL_CXX_STL)),default)
+ ifndef LOCAL_SDK_VERSION
+ # Platform code. Select the appropriate STL.
+ my_cxx_stl := libc++
+ ifdef LOCAL_IS_HOST_MODULE
+ ifneq (,$(BUILD_HOST_static))
+ my_cxx_stl := libc++_static
+ endif
+
+ ifeq ($($(my_prefix)OS),windows)
+ # libc++ is not supported on mingw.
+ my_cxx_stl := libstdc++
+ endif
+ endif
+ else
+ my_cxx_stl := ndk
+ endif
+else
+ my_cxx_stl := $(strip $(LOCAL_CXX_STL))
+ ifdef LOCAL_SDK_VERSION
+ # The NDK has historically used LOCAL_NDK_STL_VARIANT to specify the
+ # STL. An Android.mk that specifies both LOCAL_CXX_STL and
+ # LOCAL_SDK_VERSION will incorrectly try (and most likely fail) to use
+ # the platform STL in an NDK binary. Emit an error to direct the user
+ # toward the correct option.
+ #
+ # Note that we could also accept LOCAL_CXX_STL as an alias for
+ # LOCAL_NDK_STL_VARIANT (and in fact soong does use the same name), but
+ # the two options use different names for the STLs.
+ $(error $(LOCAL_PATH): $(LOCAL_MODULE): Must use LOCAL_NDK_STL_VARIANT rather than LOCAL_CXX_STL for NDK binaries)
+ endif
+ ifdef LOCAL_IS_HOST_MODULE
+ ifeq ($($(my_prefix)OS),windows)
+ ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
+ # libc++ is not supported on mingw.
+ my_cxx_stl := libstdc++
+ endif
+ endif
+ endif
+endif
+
+# Yes, this is actually what the clang driver does.
+linux_dynamic_gcclibs := -lgcc_s -lgcc -lc -lgcc_s -lgcc
+linux_static_gcclibs := -Wl,--start-group -lgcc -lgcc_eh -lc -Wl,--end-group
+darwin_dynamic_gcclibs := -lc -lSystem
+darwin_static_gcclibs := NO_STATIC_HOST_BINARIES_ON_DARWIN
+windows_dynamic_gcclibs := \
+ -lmsvcr110 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 \
+ -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lmoldname -lmingwex -lmsvcrt
+windows_static_gcclibs := NO_STATIC_HOST_BINARIES_ON_WINDOWS
+
+my_link_type := dynamic
+ifdef LOCAL_IS_HOST_MODULE
+ ifneq (,$(BUILD_HOST_static))
+ my_link_type := static
+ endif
+ ifeq (-static,$(filter -static,$(my_ldflags)))
+ my_link_type := static
+ endif
+else
+ ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE))
+ my_link_type := static
+ endif
+endif
+
+ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
+ my_cflags += -D_USING_LIBCXX
+
+ # Note that the structure of this means that LOCAL_CXX_STL := libc++ will
+ # use the static libc++ for static executables.
+ ifeq ($(my_link_type),dynamic)
+ ifeq ($(my_cxx_stl),libc++)
+ my_shared_libraries += libc++
+ else
+ my_static_libraries += libc++_static
+ endif
+ else
+ my_static_libraries += libc++_static
+ endif
+
+ ifdef LOCAL_IS_HOST_MODULE
+ my_cppflags += -nostdinc++
+ my_ldflags += -nodefaultlibs
+ my_ldlibs += -lpthread -lm
+ my_ldlibs += $($($(my_prefix)OS)_$(my_link_type)_gcclibs)
+ else
+ ifeq (arm,$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+ my_static_libraries += libunwind_llvm
+ my_ldflags += -Wl,--exclude-libs,libunwind_llvm.a
+ endif
+
+ ifeq ($(my_link_type),static)
+ my_static_libraries += libm libc libdl
+ else
+ my_shared_libraries += libdl
+ endif
+ endif
+else ifeq ($(my_cxx_stl),ndk)
+ # Using an NDK STL. Handled in binary.mk.
+else ifeq ($(my_cxx_stl),libstdc++)
+ # Using bionic's basic libstdc++. Not actually an STL. Only around until the
+ # tree is in good enough shape to not need it.
+ ifndef LOCAL_IS_HOST_MODULE
+ my_c_includes += bionic/libstdc++/include
+ my_system_shared_libraries += libstdc++
+ endif
+ # Host builds will use GNU libstdc++.
+else ifeq ($(my_cxx_stl),none)
+ ifdef LOCAL_IS_HOST_MODULE
+ my_cppflags += -nostdinc++
+ my_ldflags += -nodefaultlibs
+ my_ldlibs += $($($(my_prefix)OS)_$(my_link_type)_gcclibs)
+ endif
+else
+ $(error $(LOCAL_PATH): $(LOCAL_MODULE): $(my_cxx_stl) is not a supported STL.)
+endif
diff --git a/core/definitions.mk b/core/definitions.mk
new file mode 100644
index 0000000000000000000000000000000000000000..84ea80197e135503f46880183643860d35bf7bf9
--- /dev/null
+++ b/core/definitions.mk
@@ -0,0 +1,2934 @@
+#
+# 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.
+#
+
+##
+## Common build system definitions. Mostly standard
+## commands for building various types of targets, which
+## are used by others to construct the final targets.
+##
+
+# These are variables we use to collect overall lists
+# of things being processed.
+
+# Full paths to all of the documentation
+ALL_DOCS:=
+
+# The short names of all of the targets in the system.
+# For each element of ALL_MODULES, two other variables
+# are defined:
+# $(ALL_MODULES.$(target)).BUILT
+# $(ALL_MODULES.$(target)).INSTALLED
+# The BUILT variable contains LOCAL_BUILT_MODULE for that
+# target, and the INSTALLED variable contains the LOCAL_INSTALLED_MODULE.
+# Some targets may have multiple files listed in the BUILT and INSTALLED
+# sub-variables.
+ALL_MODULES:=
+
+# Full paths to targets that should be added to the "make droid"
+# set of installed targets.
+ALL_DEFAULT_INSTALLED_MODULES:=
+
+# The list of tags that have been defined by
+# LOCAL_MODULE_TAGS. Each word in this variable maps
+# to a corresponding ALL_MODULE_TAGS. variable
+# that contains all of the INSTALLED_MODULEs with that tag.
+ALL_MODULE_TAGS:=
+
+# Similar to ALL_MODULE_TAGS, but contains the short names
+# of all targets for a particular tag. The top-level variable
+# won't have the list of tags; ust ALL_MODULE_TAGS to get
+# the list of all known tags. (This means that this variable
+# will always be empty; it's just here as a placeholder for
+# its sub-variables.)
+ALL_MODULE_NAME_TAGS:=
+
+# Full paths to all prebuilt files that will be copied
+# (used to make the dependency on acp)
+ALL_PREBUILT:=
+
+# Full path to all files that are made by some tool
+ALL_GENERATED_SOURCES:=
+
+# Full path to all asm, C, C++, lex and yacc generated C files.
+# These all have an order-only dependency on the copied headers
+ALL_C_CPP_ETC_OBJECTS:=
+
+# The list of dynamic binaries that haven't been stripped/compressed/etc.
+ALL_ORIGINAL_DYNAMIC_BINARIES:=
+
+# These files go into the SDK
+ALL_SDK_FILES:=
+
+# Files for dalvik. This is often build without building the rest of the OS.
+INTERNAL_DALVIK_MODULES:=
+
+# All findbugs xml files
+ALL_FINDBUGS_FILES:=
+
+# GPL module license files
+ALL_GPL_MODULE_LICENSE_FILES:=
+
+# Target and host installed module's dependencies on shared libraries.
+# They are list of "::lib1,lib2...".
+TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES :=
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES :=
+HOST_DEPENDENCIES_ON_SHARED_LIBRARIES :=
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_DEPENDENCIES_ON_SHARED_LIBRARIES :=
+HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES :=
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES :=
+
+# Generated class file names for Android resource.
+# They are escaped and quoted so can be passed safely to a bash command.
+ANDROID_RESOURCE_GENERATED_CLASSES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class'
+
+# Display names for various build targets
+TARGET_DISPLAY := target
+HOST_DISPLAY := host
+HOST_CROSS_DISPLAY := host cross
+
+###########################################################
+## Debugging; prints a variable list to stdout
+###########################################################
+
+# $(1): variable name list, not variable values
+define print-vars
+$(foreach var,$(1), \
+ $(info $(var):) \
+ $(foreach word,$($(var)), \
+ $(info $(space)$(space)$(word)) \
+ ) \
+ )
+endef
+
+###########################################################
+## Evaluates to true if the string contains the word true,
+## and empty otherwise
+## $(1): a var to test
+###########################################################
+
+define true-or-empty
+$(filter true, $(1))
+endef
+
+
+###########################################################
+## Retrieve the directory of the current makefile
+## Must be called before including any other makefile!!
+###########################################################
+
+# Figure out where we are.
+define my-dir
+$(strip \
+ $(eval LOCAL_MODULE_MAKEFILE := $$(lastword $$(MAKEFILE_LIST))) \
+ $(eval LOCAL_MODULE_MAKEFILE_DEP := $(if $(BUILDING_WITH_NINJA),,$$(LOCAL_MODULE_MAKEFILE))) \
+ $(if $(filter $(BUILD_SYSTEM)/% $(OUT_DIR)/%,$(LOCAL_MODULE_MAKEFILE)), \
+ $(error my-dir must be called before including any other makefile.) \
+ , \
+ $(patsubst %/,%,$(dir $(LOCAL_MODULE_MAKEFILE))) \
+ ) \
+ )
+endef
+
+###########################################################
+## Remove any makefiles that are being handled by soong
+###########################################################
+ifeq ($(USE_SOONG),true)
+define filter-soong-makefiles
+$(foreach mk,$(1),\
+ $(if $(wildcard $(patsubst %/Android.mk,%/Android.bp,$(mk))),\
+ $(info skipping $(mk) ...),\
+ $(mk)))
+endef
+else
+define filter-soong-makefiles
+$(1)
+endef
+endif
+
+###########################################################
+## Retrieve a list of all makefiles immediately below some directory
+###########################################################
+
+define all-makefiles-under
+$(sort $(call filter-soong-makefiles,$(wildcard $(1)/*/Android.mk)))
+endef
+
+###########################################################
+## Look under a directory for makefiles that don't have parent
+## makefiles.
+###########################################################
+
+# $(1): directory to search under
+# Ignores $(1)/Android.mk
+define first-makefiles-under
+$(call filter-soong-makefiles,\
+ $(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \
+ --mindepth=2 $(1) Android.mk))
+endef
+
+###########################################################
+## Retrieve a list of all makefiles immediately below your directory
+## Must be called before including any other makefile!!
+###########################################################
+
+define all-subdir-makefiles
+$(call all-makefiles-under,$(call my-dir))
+endef
+
+###########################################################
+## Look in the named list of directories for makefiles,
+## relative to the current directory.
+## Must be called before including any other makefile!!
+###########################################################
+
+# $(1): List of directories to look for under this directory
+define all-named-subdir-makefiles
+$(sort $(call filter-soong-makefiles,\
+ $(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))))
+endef
+
+###########################################################
+## Find all of the directories under the named directories with
+## the specified name.
+## Meant to be used like:
+## INC_DIRS := $(call all-named-dirs-under,inc,.)
+###########################################################
+
+define all-named-dirs-under
+$(call find-subdir-files,$(2) -type d -name "$(1)")
+endef
+
+###########################################################
+## Find all the directories under the current directory that
+## haves name that match $(1)
+###########################################################
+
+define all-subdir-named-dirs
+$(call all-named-dirs-under,$(1),.)
+endef
+
+###########################################################
+## Find all of the files under the named directories with
+## the specified name.
+## Meant to be used like:
+## SRC_FILES := $(call all-named-files-under,*.h,src tests)
+###########################################################
+
+define all-named-files-under
+$(call find-files-in-subdirs,$(LOCAL_PATH),"$(1)",$(2))
+endef
+
+###########################################################
+## Find all of the files under the current directory with
+## the specified name.
+###########################################################
+
+define all-subdir-named-files
+$(call all-named-files-under,$(1),.)
+endef
+
+###########################################################
+## Find all of the java files under the named directories.
+## Meant to be used like:
+## SRC_FILES := $(call all-java-files-under,src tests)
+###########################################################
+
+define all-java-files-under
+$(call all-named-files-under,*.java,$(1))
+endef
+
+###########################################################
+## Find all of the java files from here. Meant to be used like:
+## SRC_FILES := $(call all-subdir-java-files)
+###########################################################
+
+define all-subdir-java-files
+$(call all-java-files-under,.)
+endef
+
+###########################################################
+## Find all of the c files under the named directories.
+## Meant to be used like:
+## SRC_FILES := $(call all-c-files-under,src tests)
+###########################################################
+
+define all-c-files-under
+$(call all-named-files-under,*.c,$(1))
+endef
+
+###########################################################
+## Find all of the c files from here. Meant to be used like:
+## SRC_FILES := $(call all-subdir-c-files)
+###########################################################
+
+define all-subdir-c-files
+$(call all-c-files-under,.)
+endef
+
+###########################################################
+## Find all of the cpp files under the named directories.
+## LOCAL_CPP_EXTENSION is respected if set.
+## Meant to be used like:
+## SRC_FILES := $(call all-cpp-files-under,src tests)
+###########################################################
+
+define all-cpp-files-under
+$(sort $(patsubst ./%,%, \
+ $(shell cd $(LOCAL_PATH) ; \
+ find -L $(1) -name "*$(or $(LOCAL_CPP_EXTENSION),.cpp)" -and -not -name ".*") \
+ ))
+endef
+
+###########################################################
+## Find all of the cpp files from here. Meant to be used like:
+## SRC_FILES := $(call all-subdir-cpp-files)
+###########################################################
+
+define all-subdir-cpp-files
+$(call all-cpp-files-under,.)
+endef
+
+###########################################################
+## Find all files named "I*.aidl" under the named directories,
+## which must be relative to $(LOCAL_PATH). The returned list
+## is relative to $(LOCAL_PATH).
+###########################################################
+
+define all-Iaidl-files-under
+$(call all-named-files-under,I*.aidl,$(1))
+endef
+
+###########################################################
+## Find all of the "I*.aidl" files under $(LOCAL_PATH).
+###########################################################
+
+define all-subdir-Iaidl-files
+$(call all-Iaidl-files-under,.)
+endef
+
+###########################################################
+## Find all files named "*.vts" under the named directories,
+## which must be relative to $(LOCAL_PATH). The returned list
+## is relative to $(LOCAL_PATH).
+###########################################################
+
+define all-vts-files-under
+$(call all-named-files-under,*.vts,$(1))
+endef
+
+###########################################################
+## Find all of the "*.vts" files under $(LOCAL_PATH).
+###########################################################
+
+define all-subdir-vts-files
+$(call all-vts-files-under,.)
+endef
+
+###########################################################
+## Find all of the logtags files under the named directories.
+## Meant to be used like:
+## SRC_FILES := $(call all-logtags-files-under,src)
+###########################################################
+
+define all-logtags-files-under
+$(call all-named-files-under,*.logtags,$(1))
+endef
+
+###########################################################
+## Find all of the .proto files under the named directories.
+## Meant to be used like:
+## SRC_FILES := $(call all-proto-files-under,src)
+###########################################################
+
+define all-proto-files-under
+$(call all-named-files-under,*.proto,$(1))
+endef
+
+###########################################################
+## Find all of the RenderScript files under the named directories.
+## Meant to be used like:
+## SRC_FILES := $(call all-renderscript-files-under,src)
+###########################################################
+
+define all-renderscript-files-under
+$(call find-subdir-files,$(1) \( -name "*.rs" -or -name "*.fs" \) -and -not -name ".*")
+endef
+
+###########################################################
+## Find all of the S files under the named directories.
+## Meant to be used like:
+## SRC_FILES := $(call all-c-files-under,src tests)
+###########################################################
+
+define all-S-files-under
+$(call all-named-files-under,*.S,$(1))
+endef
+
+###########################################################
+## Find all of the html files under the named directories.
+## Meant to be used like:
+## SRC_FILES := $(call all-html-files-under,src tests)
+###########################################################
+
+define all-html-files-under
+$(call all-named-files-under,*.html,$(1))
+endef
+
+###########################################################
+## Find all of the html files from here. Meant to be used like:
+## SRC_FILES := $(call all-subdir-html-files)
+###########################################################
+
+define all-subdir-html-files
+$(call all-html-files-under,.)
+endef
+
+###########################################################
+## Find all of the files matching pattern
+## SRC_FILES := $(call find-subdir-files, )
+###########################################################
+
+define find-subdir-files
+$(sort $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1))))
+endef
+
+###########################################################
+# find the files in the subdirectory $1 of LOCAL_DIR
+# matching pattern $2, filtering out files $3
+# e.g.
+# SRC_FILES += $(call find-subdir-subdir-files, \
+# css, *.cpp, DontWantThis.cpp)
+###########################################################
+
+define find-subdir-subdir-files
+$(sort $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \
+ $(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2)))))
+endef
+
+###########################################################
+## Find all of the files matching pattern
+## SRC_FILES := $(call all-subdir-java-files)
+###########################################################
+
+define find-subdir-assets
+$(sort $(if $(1),$(patsubst ./%,%, \
+ $(shell if [ -d $(1) ] ; then cd $(1) ; find -L ./ -not -name '.*' -and -type f -and -not -type l ; fi)), \
+ $(warning Empty argument supplied to find-subdir-assets) \
+))
+endef
+
+###########################################################
+## Find various file types in a list of directories relative to $(LOCAL_PATH)
+###########################################################
+
+define find-other-java-files
+$(call all-java-files-under,$(1))
+endef
+
+define find-other-html-files
+$(call all-html-files-under,$(1))
+endef
+
+###########################################################
+# Use utility find to find given files in the given subdirs.
+# This function uses $(1), instead of LOCAL_PATH as the base.
+# $(1): the base dir, relative to the root of the source tree.
+# $(2): the file name pattern to be passed to find as "-name".
+# $(3): a list of subdirs of the base dir.
+# Returns: a list of paths relative to the base dir.
+###########################################################
+
+define find-files-in-subdirs
+$(sort $(patsubst ./%,%, \
+ $(shell cd $(1) ; \
+ find -L $(3) -name $(2) -and -not -name ".*") \
+ ))
+endef
+
+###########################################################
+## Scan through each directory of $(1) looking for files
+## that match $(2) using $(wildcard). Useful for seeing if
+## a given directory or one of its parents contains
+## a particular file. Returns the first match found,
+## starting furthest from the root.
+###########################################################
+
+define find-parent-file
+$(strip \
+ $(eval _fpf := $(sort $(wildcard $(foreach f, $(2), $(strip $(1))/$(f))))) \
+ $(if $(_fpf),$(_fpf), \
+ $(if $(filter-out ./ .,$(1)), \
+ $(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \
+ ) \
+ ) \
+)
+endef
+
+###########################################################
+## Function we can evaluate to introduce a dynamic dependency
+###########################################################
+
+define add-dependency
+$(1): $(2)
+endef
+
+###########################################################
+## Reverse order of a list
+###########################################################
+
+define reverse-list
+$(if $(1),$(call reverse-list,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
+endef
+
+###########################################################
+## The intermediates directory. Where object files go for
+## a given target. We could technically get away without
+## the "_intermediates" suffix on the directory, but it's
+## nice to be able to grep for that string to find out if
+## anyone's abusing the system.
+###########################################################
+
+# $(1): target class, like "APPS"
+# $(2): target name, like "NotePad"
+# $(3): if non-empty, this is a HOST target.
+# $(4): if non-empty, force the intermediates to be COMMON
+# $(5): if non-empty, force the intermediates to be for the 2nd arch
+# $(6): if non-empty, force the intermediates to be for the host cross os
+define intermediates-dir-for
+$(strip \
+ $(eval _idfClass := $(strip $(1))) \
+ $(if $(_idfClass),, \
+ $(error $(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \
+ $(eval _idfName := $(strip $(2))) \
+ $(if $(_idfName),, \
+ $(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \
+ $(eval _idfPrefix := $(if $(strip $(3)),$(if $(strip $(6)),HOST_CROSS,HOST),TARGET)) \
+ $(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
+ $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
+ $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \
+ ,$(if $(filter $(_idfClass),$(PER_ARCH_MODULE_CLASSES)),\
+ $(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \
+ ,$(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \
+ ) \
+ ) \
+ $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \
+)
+endef
+
+# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
+# to determine the intermediates directory.
+#
+# $(1): if non-empty, force the intermediates to be COMMON
+# $(2): if non-empty, force the intermediates to be for the 2nd arch
+# $(3): if non-empty, force the intermediates to be for the host cross os
+define local-intermediates-dir
+$(strip \
+ $(if $(strip $(LOCAL_MODULE_CLASS)),, \
+ $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \
+ $(if $(strip $(LOCAL_MODULE)),, \
+ $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \
+ $(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1),$(2),$(3)) \
+)
+endef
+
+###########################################################
+## The generated sources directory. Placing generated
+## source files directly in the intermediates directory
+## causes problems for multiarch builds, where there are
+## two intermediates directories for a single target. Put
+## them in a separate directory, and they will be copied to
+## each intermediates directory automatically.
+###########################################################
+
+# $(1): target class, like "APPS"
+# $(2): target name, like "NotePad"
+# $(3): if non-empty, this is a HOST target.
+# $(4): if non-empty, force the generated sources to be COMMON
+define generated-sources-dir-for
+$(strip \
+ $(eval _idfClass := $(strip $(1))) \
+ $(if $(_idfClass),, \
+ $(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \
+ $(eval _idfName := $(strip $(2))) \
+ $(if $(_idfName),, \
+ $(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \
+ $(eval _idfPrefix := $(if $(strip $(3)),HOST,TARGET)) \
+ $(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
+ $(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_GEN)) \
+ , \
+ $(eval _idfIntBase := $($(_idfPrefix)_OUT_GEN)) \
+ ) \
+ $(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \
+)
+endef
+
+# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
+# to determine the generated sources directory.
+#
+# $(1): if non-empty, force the intermediates to be COMMON
+define local-generated-sources-dir
+$(strip \
+ $(if $(strip $(LOCAL_MODULE_CLASS)),, \
+ $(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \
+ $(if $(strip $(LOCAL_MODULE)),, \
+ $(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \
+ $(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(LOCAL_IS_HOST_MODULE),$(1)) \
+)
+endef
+
+###########################################################
+## Convert "path/to/libXXX.so" to "-lXXX".
+## Any "path/to/libXXX.a" elements pass through unchanged.
+###########################################################
+
+define normalize-libraries
+$(foreach so,$(filter %.so,$(1)),-l$(patsubst lib%.so,%,$(notdir $(so))))\
+$(filter-out %.so,$(1))
+endef
+
+# TODO: change users to call the common version.
+define normalize-host-libraries
+$(call normalize-libraries,$(1))
+endef
+
+define normalize-target-libraries
+$(call normalize-libraries,$(1))
+endef
+
+###########################################################
+## Convert a list of short module names (e.g., "framework", "Browser")
+## into the list of files that are built for those modules.
+## NOTE: this won't return reliable results until after all
+## sub-makefiles have been included.
+## $(1): target list
+###########################################################
+
+define module-built-files
+$(foreach module,$(1),$(ALL_MODULES.$(module).BUILT))
+endef
+
+###########################################################
+## Convert a list of short modules names (e.g., "framework", "Browser")
+## into the list of files that are installed for those modules.
+## NOTE: this won't return reliable results until after all
+## sub-makefiles have been included.
+## $(1): target list
+###########################################################
+
+define module-installed-files
+$(foreach module,$(1),$(ALL_MODULES.$(module).INSTALLED))
+endef
+
+###########################################################
+## Convert a list of short modules names (e.g., "framework", "Browser")
+## into the list of files that should be used when linking
+## against that module as a public API.
+## TODO: Allow this for more than JAVA_LIBRARIES modules
+## NOTE: this won't return reliable results until after all
+## sub-makefiles have been included.
+## $(1): target list
+###########################################################
+
+define module-stubs-files
+$(foreach module,$(1),$(ALL_MODULES.$(module).STUBS))
+endef
+
+###########################################################
+## Evaluates to the timestamp file for a doc module, which
+## is the dependency that should be used.
+## $(1): doc module
+###########################################################
+
+define doc-timestamp-for
+$(OUT_DOCS)/$(strip $(1))-timestamp
+endef
+
+
+###########################################################
+## Convert "core ext framework" to "out/.../javalib.jar ..."
+## $(1): library list
+## $(2): Non-empty if IS_HOST_MODULE
+###########################################################
+
+# $(1): library name
+# $(2): Non-empty if IS_HOST_MODULE
+define _java-lib-dir
+$(call intermediates-dir-for, \
+ JAVA_LIBRARIES,$(1),$(2),COMMON)
+endef
+
+# $(1): library name
+# $(2): Non-empty if IS_HOST_MODULE
+define _java-lib-full-classes.jar
+$(call _java-lib-dir,$(1),$(2))/$(if $(2),javalib,classes)$(COMMON_JAVA_PACKAGE_SUFFIX)
+endef
+
+# Get the jar files (you can pass to "javac -classpath") of static or shared
+# Java libraries that you want to link against.
+# $(1): library name list
+# $(2): Non-empty if IS_HOST_MODULE
+define java-lib-files
+$(foreach lib,$(1),$(call _java-lib-full-classes.jar,$(lib),$(2)))
+endef
+
+# Get the dependency files (you can put on the right side of "|" of a build rule)
+# of the Java libraries.
+# $(1): library name list
+# $(2): Non-empty if IS_HOST_MODULE
+# Historically for target Java libraries we used a different file (javalib.jar)
+# as the dependency.
+# Now we can use classes.jar as dependency, so java-lib-deps is the same
+# as java-lib-files.
+define java-lib-deps
+$(call java-lib-files,$(1),$(2))
+endef
+
+# Get the jar files (you can pass to "javac -classpath") of host dalvik Java libraries.
+# You can also use them as dependency files.
+# A host dalvik Java library is different from a host Java library in that
+# the java lib file is classes.jar, not javalib.jar.
+# $(1): library name list
+define host-dex-java-lib-files
+$(foreach lib,$(1),$(call _java-lib-dir,$(lib),true)/classes.jar)
+endef
+
+###########################################################
+## Convert "core ext framework" to "out/.../classes.jack ..."
+## $(1): library list
+## $(2): Non-empty if IS_HOST_MODULE
+###########################################################
+
+# $(1): library name
+# $(2): Non-empty if IS_HOST_MODULE
+define _jack-lib-full-classes
+$(call _java-lib-dir,$(1),$(2))/classes.jack
+endef
+
+# $(1): library name list
+# $(2): Non-empty if IS_HOST_MODULE
+define jack-lib-files
+$(foreach lib,$(1),$(call _jack-lib-full-classes,$(lib),$(2)))
+endef
+
+# $(1): library name list
+# $(2): Non-empty if IS_HOST_MODULE
+define jack-lib-deps
+$(call jack-lib-files,$(1),$(2))
+endef
+
+###########################################################
+## Run rot13 on a string
+## $(1): the string. Must be one line.
+###########################################################
+define rot13
+$(shell echo $(1) | tr 'a-zA-Z' 'n-za-mN-ZA-M')
+endef
+
+
+###########################################################
+## Returns true if $(1) and $(2) are equal. Returns
+## the empty string if they are not equal.
+###########################################################
+define streq
+$(strip $(if $(strip $(1)),\
+ $(if $(strip $(2)),\
+ $(if $(filter-out __,_$(subst $(strip $(1)),,$(strip $(2)))$(subst $(strip $(2)),,$(strip $(1)))_),,true), \
+ ),\
+ $(if $(strip $(2)),\
+ ,\
+ true)\
+ ))
+endef
+
+###########################################################
+## Convert "a b c" into "a:b:c"
+###########################################################
+define normalize-path-list
+$(subst $(space),:,$(strip $(1)))
+endef
+
+###########################################################
+## Read the word out of a colon-separated list of words.
+## This has the same behavior as the built-in function
+## $(word n,str).
+##
+## The individual words may not contain spaces.
+##
+## $(1): 1 based index
+## $(2): value of the form a:b:c...
+###########################################################
+
+define word-colon
+$(word $(1),$(subst :,$(space),$(2)))
+endef
+
+###########################################################
+## Convert "a=b c= d e = f" into "a=b c=d e=f"
+##
+## $(1): list to collapse
+## $(2): if set, separator word; usually "=", ":", or ":="
+## Defaults to "=" if not set.
+###########################################################
+
+define collapse-pairs
+$(eval _cpSEP := $(strip $(if $(2),$(2),=)))\
+$(subst $(space)$(_cpSEP)$(space),$(_cpSEP),$(strip \
+ $(subst $(_cpSEP), $(_cpSEP) ,$(1))))
+endef
+
+###########################################################
+## Given a list of pairs, if multiple pairs have the same
+## first components, keep only the first pair.
+##
+## $(1): list of pairs
+## $(2): the separator word, such as ":", "=", etc.
+define uniq-pairs-by-first-component
+$(eval _upbfc_fc_set :=)\
+$(strip $(foreach w,$(1), $(eval _first := $(word 1,$(subst $(2),$(space),$(w))))\
+ $(if $(filter $(_upbfc_fc_set),$(_first)),,$(w)\
+ $(eval _upbfc_fc_set += $(_first)))))\
+$(eval _upbfc_fc_set :=)\
+$(eval _first:=)
+endef
+
+###########################################################
+## MODULE_TAG set operations
+###########################################################
+
+# Given a list of tags, return the targets that specify
+# any of those tags.
+# $(1): tag list
+define modules-for-tag-list
+$(sort $(foreach tag,$(1),$(foreach m,$(ALL_MODULE_NAME_TAGS.$(tag)),$(ALL_MODULES.$(m).INSTALLED))))
+endef
+
+# Same as modules-for-tag-list, but operates on
+# ALL_MODULE_NAME_TAGS.
+# $(1): tag list
+define module-names-for-tag-list
+$(sort $(foreach tag,$(1),$(ALL_MODULE_NAME_TAGS.$(tag))))
+endef
+
+# Given an accept and reject list, find the matching
+# set of targets. If a target has multiple tags and
+# any of them are rejected, the target is rejected.
+# Reject overrides accept.
+# $(1): list of tags to accept
+# $(2): list of tags to reject
+#TODO(dbort): do $(if $(strip $(1)),$(1),$(ALL_MODULE_TAGS))
+#TODO(jbq): as of 20100106 nobody uses the second parameter
+define get-tagged-modules
+$(filter-out \
+ $(call modules-for-tag-list,$(2)), \
+ $(call modules-for-tag-list,$(1)))
+endef
+
+###########################################################
+## Append a leaf to a base path. Properly deals with
+## base paths ending in /.
+##
+## $(1): base path
+## $(2): leaf path
+###########################################################
+
+define append-path
+$(subst //,/,$(1)/$(2))
+endef
+
+
+###########################################################
+## Package filtering
+###########################################################
+
+# Given a list of installed modules (short or long names)
+# return a list of the packages (yes, .apk packages, not
+# modules in general) that are overridden by this list and,
+# therefore, should not be installed.
+# $(1): mixed list of installed modules
+# TODO: This is fragile; find a reliable way to get this information.
+define _get-package-overrides
+ $(eval ### Discard any words containing slashes, unless they end in .apk, \
+ ### in which case trim off the directory component and the suffix. \
+ ### If there are no slashes, keep the entire word.)
+ $(eval _gpo_names := $(subst /,@@@ @@@,$(1)))
+ $(eval _gpo_names := \
+ $(filter %.apk,$(_gpo_names)) \
+ $(filter-out %@@@ @@@%,$(_gpo_names)))
+ $(eval _gpo_names := $(patsubst %.apk,%,$(_gpo_names)))
+ $(eval _gpo_names := $(patsubst @@@%,%,$(_gpo_names)))
+
+ $(eval ### Remove any remaining words that contain dots.)
+ $(eval _gpo_names := $(subst .,@@@ @@@,$(_gpo_names)))
+ $(eval _gpo_names := $(filter-out %@@@ @@@%,$(_gpo_names)))
+
+ $(eval ### Now we have a list of any words that could possibly refer to \
+ ### packages, although there may be words that do not. Only \
+ ### real packages will be present under PACKAGES.*, though.)
+ $(foreach _gpo_name,$(_gpo_names),$(PACKAGES.$(_gpo_name).OVERRIDES))
+endef
+
+define get-package-overrides
+$(sort $(strip $(call _get-package-overrides,$(1))))
+endef
+
+###########################################################
+## Output the command lines, or not
+###########################################################
+
+ifeq ($(strip $(SHOW_COMMANDS)),)
+define pretty
+@echo $1
+endef
+else
+define pretty
+endef
+endif
+
+###########################################################
+## Commands for munging the dependency files the compiler generates
+###########################################################
+# $(1): the input .d file
+# $(2): the output .P file
+define transform-d-to-p-args
+$(hide) cp $(1) $(2); \
+ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+ -e '/^$$/ d' -e 's/$$/ :/' < $(1) >> $(2); \
+ rm -f $(1)
+endef
+
+define transform-d-to-p
+$(call transform-d-to-p-args,$(@:%.o=%.d),$(@:%.o=%.P))
+endef
+
+###########################################################
+## Commands for including the dependency files the compiler generates
+###########################################################
+# $(1): the .P file
+# $(2): the main build target
+ifeq ($(BUILDING_WITH_NINJA),true)
+define include-depfile
+$(eval $(2) : .KATI_DEPFILE := $1)
+endef
+else
+define include-depfile
+$(eval -include $1)
+endef
+endif
+
+# $(1): object files
+define include-depfiles-for-objs
+$(foreach obj, $(1), $(call include-depfile, $(obj:%.o=%.P), $(obj)))
+endef
+
+###########################################################
+## Track source files compiled to objects
+###########################################################
+# $(1): list of sources
+# $(2): list of matching objects
+define track-src-file-obj
+$(eval $(call _track-src-file-obj,$(1)))
+endef
+define _track-src-file-obj
+i := w
+$(foreach s,$(1),
+my_tracked_src_files += $(s)
+my_src_file_obj_$(s) := $$(word $$(words $$(i)),$$(2))
+i += w)
+endef
+
+# $(1): list of sources
+# $(2): list of matching generated sources
+define track-src-file-gen
+$(eval $(call _track-src-file-gen,$(2)))
+endef
+define _track-src-file-gen
+i := w
+$(foreach s,$(1),
+my_tracked_gen_files += $(s)
+my_src_file_gen_$(s) := $$(word $$(words $$(i)),$$(1))
+i += w)
+endef
+
+# $(1): list of generated sources
+# $(2): list of matching objects
+define track-gen-file-obj
+$(call track-src-file-obj,$(foreach f,$(1),\
+ $(or $(my_src_file_gen_$(f)),$(f))),$(2))
+endef
+
+###########################################################
+## Commands for running lex
+###########################################################
+
+define transform-l-to-c-or-cpp
+@echo "Lex: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(hide) $(LEX) -o$@ $<
+endef
+
+###########################################################
+## Commands for running yacc
+##
+###########################################################
+
+define transform-y-to-c-or-cpp
+@echo "Yacc: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(YACC) $(PRIVATE_YACCFLAGS) \
+ --defines=$(basename $@).h \
+ -o $@ $<
+endef
+
+###########################################################
+## Commands to compile RenderScript to Java
+###########################################################
+
+## Merge multiple .d files generated by llvm-rs-cc. This is necessary
+## because ninja can handle only a single depfile per build target.
+## .d files generated by llvm-rs-cc define .stamp, .bc, and optionally
+## .java as build targets. However, there's no way to let ninja know
+## dependencies to .bc files and .java files, so we give up build
+## targets for them. As we write the .stamp file as the target by
+## ourselves, the awk script removes the first lines before the colon
+## and append a backslash to the last line to concatenate contents of
+## multiple files.
+# $(1): .d files to be merged
+# $(2): merged .d file
+define _merge-renderscript-d
+$(hide) echo '$@: $(backslash)' > $2
+$(foreach d,$1, \
+ $(hide) awk 'start { sub(/( \\)?$$/, " \\"); print } /:/ { start=1 }' < $d >> $2$(newline))
+$(hide) echo >> $2
+endef
+
+define transform-renderscripts-to-java-and-bc
+@echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)"
+$(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
+$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/res/raw
+$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/src
+$(hide) $(PRIVATE_RS_CC) \
+ -o $(PRIVATE_RS_OUTPUT_DIR)/res/raw \
+ -p $(PRIVATE_RS_OUTPUT_DIR)/src \
+ -d $(PRIVATE_RS_OUTPUT_DIR) \
+ -a $@ -MD \
+ $(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
+ $(PRIVATE_RS_FLAGS) \
+ $(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
+ $(PRIVATE_RS_SOURCE_FILES)
+$(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
+$(call transform-d-to-p-args,$@.d,$@.P)
+$(hide) mkdir -p $(dir $@)
+$(hide) touch $@
+endef
+
+define transform-bc-to-so
+@echo "Renderscript compatibility: $(notdir $@) <= $(notdir $<)"
+$(hide) mkdir -p $(dir $@)
+$(hide) $(BCC_COMPAT) -O3 -o $(dir $@)/$(notdir $(<:.bc=.o)) -fPIC -shared \
+ -rt-path $(RS_PREBUILT_CLCORE) -mtriple $(RS_COMPAT_TRIPLE) $<
+$(hide) $(PRIVATE_CXX) -shared -Wl,-soname,$(notdir $@) -nostdlib \
+ -Wl,-rpath,\$$ORIGIN/../lib \
+ $(dir $@)/$(notdir $(<:.bc=.o)) \
+ $(RS_PREBUILT_COMPILER_RT) \
+ -o $@ $(TARGET_GLOBAL_LDFLAGS) -Wl,--hash-style=sysv -L prebuilts/gcc/ \
+ $(RS_PREBUILT_LIBPATH) -L $(TARGET_OUT_INTERMEDIATE_LIBRARIES) \
+ -lRSSupport -lm -lc
+endef
+
+###########################################################
+## Commands to compile RenderScript to C++
+###########################################################
+
+define transform-renderscripts-to-cpp-and-bc
+@echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)"
+$(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
+$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/
+$(hide) $(PRIVATE_RS_CC) \
+ -o $(PRIVATE_RS_OUTPUT_DIR)/ \
+ -d $(PRIVATE_RS_OUTPUT_DIR) \
+ -a $@ -MD \
+ -reflect-c++ \
+ $(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
+ $(PRIVATE_RS_FLAGS) \
+ $(addprefix -I , $(PRIVATE_RS_INCLUDES)) \
+ $(PRIVATE_RS_SOURCE_FILES)
+$(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
+$(call transform-d-to-p-args,$@.d,$@.P)
+$(hide) mkdir -p $(dir $@)
+$(hide) touch $@
+endef
+
+
+###########################################################
+## Commands for running aidl
+###########################################################
+
+define transform-aidl-to-java
+@mkdir -p $(dir $@)
+@echo "Aidl: $(PRIVATE_MODULE) <= $<"
+$(hide) $(AIDL) -d$(patsubst %.java,%.P,$@) $(PRIVATE_AIDL_FLAGS) $< $@
+endef
+#$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@
+
+define transform-aidl-to-cpp
+@mkdir -p $(dir $@)
+@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
+@echo "Generating C++ from AIDL: $(PRIVATE_MODULE) <= $<"
+$(hide) $(AIDL_CPP) -d$(basename $@).aidl.P $(PRIVATE_AIDL_FLAGS) \
+ $< $(PRIVATE_HEADER_OUTPUT_DIR) $@
+endef
+
+## Given a .aidl file path generate the rule to compile it a .cpp file.
+# $(1): a .aidl source file
+# $(2): a directory to place the generated .cpp files in
+# $(3): name of a variable to add the path to the generated source file to
+#
+# You must call this with $(eval).
+define define-aidl-cpp-rule
+define-aidl-cpp-rule-src := $(patsubst %.aidl,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
+$$(define-aidl-cpp-rule-src) : $(LOCAL_PATH)/$(1) $(AIDL_CPP)
+ $$(transform-aidl-to-cpp)
+$(3) += $$(define-aidl-cpp-rule-src)
+endef
+
+###########################################################
+## Commands for running vts
+###########################################################
+
+define transform-vts-to-cpp
+@mkdir -p $(dir $@)
+@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
+@echo "Generating C++ from VTS: $(PRIVATE_MODULE) <= $<"
+$(hide) $(VTSC) -d$(basename $@).vts.P $(PRIVATE_VTS_FLAGS) \
+ $< $(PRIVATE_HEADER_OUTPUT_DIR) $@
+endef
+
+## Given a .vts file path generate the rule to compile it a .cpp file.
+# $(1): a .vts source file
+# $(2): a directory to place the generated .cpp files in
+# $(3): name of a variable to add the path to the generated source file to
+#
+# You must call this with $(eval).
+define define-vts-cpp-rule
+define-vts-cpp-rule-src := $(patsubst %.vts,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
+$$(define-vts-cpp-rule-src) : $(LOCAL_PATH)/$(1) $(VTSC)
+ $$(transform-vts-to-cpp)
+$(3) += $$(define-vts-cpp-rule-src)
+endef
+
+###########################################################
+## Commands for running java-event-log-tags.py
+###########################################################
+
+define transform-logtags-to-java
+@mkdir -p $(dir $@)
+@echo "logtags: $@ <= $<"
+$(hide) $(JAVATAGS) -o $@ $^
+endef
+
+
+###########################################################
+## Commands for running protoc to compile .proto into .java
+###########################################################
+
+define transform-proto-to-java
+@mkdir -p $(dir $@)
+@echo "Protoc: $@ <= $(PRIVATE_PROTO_SRC_FILES)"
+@rm -rf $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
+@mkdir -p $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
+$(hide) for f in $(PRIVATE_PROTO_SRC_FILES); do \
+ $(PROTOC) \
+ $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
+ $(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)="$(PRIVATE_PROTO_JAVA_OUTPUT_PARAMS):$(PRIVATE_PROTO_JAVA_OUTPUT_DIR)" \
+ $(PRIVATE_PROTOC_FLAGS) \
+ $$f || exit 33; \
+ done
+$(hide) touch $@
+endef
+
+######################################################################
+## Commands for running protoc to compile .proto into .pb.cc (or.pb.c) and .pb.h
+######################################################################
+define transform-proto-to-cc
+@echo "Protoc: $@ <= $<"
+@mkdir -p $(dir $@)
+$(hide) $(PROTOC) \
+ $(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
+ $(PRIVATE_PROTOC_FLAGS) \
+ $<
+@# aprotoc outputs only .cc. Rename it to .cpp if necessary.
+$(if $(PRIVATE_RENAME_CPP_EXT),\
+ $(hide) mv $(basename $@).cc $@)
+endef
+
+
+######################################################################
+## Commands for generating DBus adaptors from .dbus-xml files.
+######################################################################
+define generate-dbus-adaptors
+@echo "Generating DBus adaptors for $(PRIVATE_MODULE)"
+@mkdir -p $(dir $@)
+$(hide) $(DBUS_GENERATOR) \
+ --service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \
+ --adaptor=$@ \
+ $<
+endef
+
+######################################################################
+## Commands for generating DBus proxies from .dbus-xml files.
+######################################################################
+define generate-dbus-proxies
+@echo "Generating DBus proxies for $(PRIVATE_MODULE)"
+@mkdir -p $(dir $@)
+$(hide) $(DBUS_GENERATOR) \
+ --service-config=$(PRIVATE_DBUS_SERVICE_CONFIG) \
+ --proxy=$@ \
+ $(filter %.dbus-xml,$^)
+endef
+
+
+###########################################################
+## Commands for running gcc to compile a C++ file
+###########################################################
+
+define transform-cpp-to-o
+@echo "target $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
+ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+ $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
+ $(addprefix -isystem ,\
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(filter-out $(PRIVATE_C_INCLUDES), \
+ $(PRIVATE_TARGET_PROJECT_INCLUDES) \
+ $(PRIVATE_TARGET_C_INCLUDES)))) \
+ -c \
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
+ $(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \
+ $(PRIVATE_ARM_CFLAGS) \
+ ) \
+ $(PRIVATE_RTTI_FLAG) \
+ $(PRIVATE_CFLAGS) \
+ $(PRIVATE_CPPFLAGS) \
+ $(PRIVATE_DEBUG_CFLAGS) \
+ $(PRIVATE_CFLAGS_NO_OVERRIDE) \
+ $(PRIVATE_CPPFLAGS_NO_OVERRIDE) \
+ -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+$(transform-d-to-p)
+endef
+
+
+###########################################################
+## Commands for running gcc to compile a C file
+###########################################################
+
+# $(1): extra flags
+define transform-c-or-s-to-o-no-deps
+@mkdir -p $(dir $@)
+$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
+ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+ $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
+ $(addprefix -isystem ,\
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(filter-out $(PRIVATE_C_INCLUDES), \
+ $(PRIVATE_TARGET_PROJECT_INCLUDES) \
+ $(PRIVATE_TARGET_C_INCLUDES)))) \
+ -c \
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(PRIVATE_TARGET_GLOBAL_CFLAGS) \
+ $(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \
+ $(PRIVATE_ARM_CFLAGS) \
+ ) \
+ $(1) \
+ -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+endef
+
+define transform-c-to-o-no-deps
+@echo "target $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<"
+$(call transform-c-or-s-to-o-no-deps, \
+ $(PRIVATE_CFLAGS) \
+ $(PRIVATE_CONLYFLAGS) \
+ $(PRIVATE_DEBUG_CFLAGS) \
+ $(PRIVATE_CFLAGS_NO_OVERRIDE))
+endef
+
+define transform-s-to-o-no-deps
+@echo "target asm: $(PRIVATE_MODULE) <= $<"
+$(call transform-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS))
+endef
+
+define transform-c-to-o
+$(transform-c-to-o-no-deps)
+$(transform-d-to-p)
+endef
+
+define transform-s-to-o
+$(transform-s-to-o-no-deps)
+$(transform-d-to-p)
+endef
+
+# YASM compilation
+define transform-asm-to-o
+@mkdir -p $(dir $@)
+$(hide) $(YASM) \
+ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_YASM_FLAGS) \
+ $(PRIVATE_ASFLAGS) \
+ -o $@ $<
+endef
+
+###########################################################
+## Commands for running gcc to compile an Objective-C file
+## This should never happen for target builds but this
+## will error at build time.
+###########################################################
+
+define transform-m-to-o-no-deps
+@echo "target ObjC: $(PRIVATE_MODULE) <= $<"
+$(call transform-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
+endef
+
+define transform-m-to-o
+$(transform-m-to-o-no-deps)
+$(transform-d-to-p)
+endef
+
+###########################################################
+## Commands for running gcc to compile a host C++ file
+###########################################################
+
+define transform-host-cpp-to-o
+@echo "$($(PRIVATE_PREFIX)DISPLAY) C++: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
+ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+ $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
+ $(addprefix -isystem ,\
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(filter-out $(PRIVATE_C_INCLUDES), \
+ $($(PRIVATE_PREFIX)PROJECT_INCLUDES) \
+ $(PRIVATE_HOST_C_INCLUDES)))) \
+ -c \
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(PRIVATE_HOST_GLOBAL_CFLAGS) \
+ $(PRIVATE_HOST_GLOBAL_CPPFLAGS) \
+ ) \
+ $(PRIVATE_CFLAGS) \
+ $(PRIVATE_CPPFLAGS) \
+ $(PRIVATE_DEBUG_CFLAGS) \
+ $(PRIVATE_CFLAGS_NO_OVERRIDE) \
+ $(PRIVATE_CPPFLAGS_NO_OVERRIDE) \
+ -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+$(transform-d-to-p)
+endef
+
+
+###########################################################
+## Commands for running gcc to compile a host C file
+###########################################################
+
+# $(1): extra flags
+define transform-host-c-or-s-to-o-no-deps
+@mkdir -p $(dir $@)
+$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
+ $(addprefix -I , $(PRIVATE_C_INCLUDES)) \
+ $(shell cat $(PRIVATE_IMPORT_INCLUDES)) \
+ $(addprefix -isystem ,\
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(filter-out $(PRIVATE_C_INCLUDES), \
+ $($(PRIVATE_PREFIX)PROJECT_INCLUDES) \
+ $(PRIVATE_HOST_C_INCLUDES)))) \
+ -c \
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(PRIVATE_HOST_GLOBAL_CFLAGS) \
+ $(PRIVATE_HOST_GLOBAL_CONLYFLAGS) \
+ ) \
+ $(1) \
+ $(PRIVATE_CFLAGS_NO_OVERRIDE) \
+ -MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
+endef
+
+define transform-host-c-to-o-no-deps
+@echo "$($(PRIVATE_PREFIX)DISPLAY) C: $(PRIVATE_MODULE) <= $<"
+$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_CONLYFLAGS) $(PRIVATE_DEBUG_CFLAGS))
+endef
+
+define transform-host-s-to-o-no-deps
+@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
+$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_ASFLAGS))
+endef
+
+define transform-host-c-to-o
+$(transform-host-c-to-o-no-deps)
+$(transform-d-to-p)
+endef
+
+define transform-host-s-to-o
+$(transform-host-s-to-o-no-deps)
+$(transform-d-to-p)
+endef
+
+###########################################################
+## Commands for running gcc to compile a host Objective-C file
+###########################################################
+
+define transform-host-m-to-o-no-deps
+@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
+$(call transform-host-c-or-s-to-o-no-deps, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
+endef
+
+define transform-host-m-to-o
+$(transform-host-m-to-o-no-deps)
+$(transform-d-to-p)
+endef
+
+###########################################################
+## Commands for running gcc to compile a host Objective-C++ file
+###########################################################
+
+define transform-host-mm-to-o
+$(transform-host-cpp-to-o)
+endef
+
+
+###########################################################
+## Rules to compile a single C/C++ source with ../ in the path
+###########################################################
+# Replace "../" in object paths with $(DOTDOT_REPLACEMENT).
+DOTDOT_REPLACEMENT := dotdot/
+
+## Rule to compile a C++ source file with ../ in the path.
+## Must be called with $(eval).
+# $(1): the C++ source file in LOCAL_SRC_FILES.
+# $(2): the additional dependencies.
+# $(3): the variable name to collect the output object file.
+define compile-dotdot-cpp-file
+o := $(intermediates)/$(patsubst %$(LOCAL_CPP_EXTENSION),%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
+ $$(transform-$$(PRIVATE_HOST)cpp-to-o)
+$$(call include-depfiles-for-objs, $$(o))
+$(3) += $$(o)
+endef
+
+## Rule to compile a C source file with ../ in the path.
+## Must be called with $(eval).
+# $(1): the C source file in LOCAL_SRC_FILES.
+# $(2): the additional dependencies.
+# $(3): the variable name to collect the output object file.
+define compile-dotdot-c-file
+o := $(intermediates)/$(patsubst %.c,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
+ $$(transform-$$(PRIVATE_HOST)c-to-o)
+$$(call include-depfiles-for-objs, $$(o))
+$(3) += $$(o)
+endef
+
+## Rule to compile a .S source file with ../ in the path.
+## Must be called with $(eval).
+# $(1): the .S source file in LOCAL_SRC_FILES.
+# $(2): the additional dependencies.
+# $(3): the variable name to collect the output object file.
+define compile-dotdot-s-file
+o := $(intermediates)/$(patsubst %.S,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
+ $$(transform-$$(PRIVATE_HOST)s-to-o)
+$$(call include-depfiles-for-objs, $$(o))
+$(3) += $$(o)
+endef
+
+## Rule to compile a .s source file with ../ in the path.
+## Must be called with $(eval).
+# $(1): the .s source file in LOCAL_SRC_FILES.
+# $(2): the additional dependencies.
+# $(3): the variable name to collect the output object file.
+define compile-dotdot-s-file-no-deps
+o := $(intermediates)/$(patsubst %.s,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
+$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2)
+ $$(transform-$$(PRIVATE_HOST)s-to-o-no-deps)
+$(3) += $$(o)
+endef
+
+###########################################################
+## Commands for running ar
+###########################################################
+
+define _concat-if-arg2-not-empty
+$(if $(2),$(hide) $(1) $(2))
+endef
+
+# Split long argument list into smaller groups and call the command repeatedly
+# Call the command at least once even if there are no arguments, as otherwise
+# the output file won't be created.
+#
+# $(1): the command without arguments
+# $(2): the arguments
+define split-long-arguments
+$(hide) $(1) $(wordlist 1,500,$(2))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 501,1000,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 1001,1500,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 1501,2000,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 2001,2500,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 2501,3000,$(2)))
+$(call _concat-if-arg2-not-empty,$(1),$(wordlist 3001,99999,$(2)))
+endef
+
+# $(1): the full path of the source static library.
+define _extract-and-include-single-target-whole-static-lib
+$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
+ rm -rf $$ldir; \
+ mkdir -p $$ldir; \
+ cp $(1) $$ldir; \
+ lib_to_include=$$ldir/$(notdir $(1)); \
+ filelist=; \
+ subdir=0; \
+ for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) t $(1)`; do \
+ if [ -e $$ldir/$$f ]; then \
+ mkdir $$ldir/$$subdir; \
+ ext=$$subdir/; \
+ subdir=$$((subdir+1)); \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) m $$lib_to_include $$f; \
+ else \
+ ext=; \
+ fi; \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
+ filelist="$$filelist $$ldir/$$ext$$f"; \
+ done ; \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
+ $(PRIVATE_ARFLAGS) $@ $$filelist
+
+endef
+
+# $(1): the full path of the source static library.
+define extract-and-include-whole-static-libs-first
+$(if $(strip $(1)),
+$(hide) cp $(1) $@)
+endef
+
+define extract-and-include-target-whole-static-libs
+$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
+$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
+ $(call _extract-and-include-single-target-whole-static-lib, $(lib)))
+endef
+
+# Explicitly delete the archive first so that ar doesn't
+# try to add to an existing archive.
+define transform-o-to-static-lib
+@echo "target StaticLib: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+@rm -f $@
+$(extract-and-include-target-whole-static-libs)
+$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
+ $(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
+endef
+
+###########################################################
+## Commands for running host ar
+###########################################################
+
+# $(1): the full path of the source static library.
+define _extract-and-include-single-host-whole-static-lib
+$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
+ rm -rf $$ldir; \
+ mkdir -p $$ldir; \
+ cp $(1) $$ldir; \
+ lib_to_include=$$ldir/$(notdir $(1)); \
+ filelist=; \
+ subdir=0; \
+ for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) t $(1) | \grep '\.o$$'`; do \
+ if [ -e $$ldir/$$f ]; then \
+ mkdir $$ldir/$$subdir; \
+ ext=$$subdir/; \
+ subdir=$$((subdir+1)); \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) m $$lib_to_include $$f; \
+ else \
+ ext=; \
+ fi; \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
+ filelist="$$filelist $$ldir/$$ext$$f"; \
+ done ; \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \
+ $(PRIVATE_ARFLAGS) $@ $$filelist
+
+endef
+
+define extract-and-include-host-whole-static-libs
+$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
+$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
+ $(call _extract-and-include-single-host-whole-static-lib, $(lib)))
+endef
+
+# Explicitly delete the archive first so that ar doesn't
+# try to add to an existing archive.
+define transform-host-o-to-static-lib
+@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+@rm -f $@
+$(extract-and-include-host-whole-static-libs)
+$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \
+ $(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
+endef
+
+
+###########################################################
+## Commands for running gcc to link a shared library or package
+###########################################################
+
+# ld just seems to be so finicky with command order that we allow
+# it to be overriden en-masse see combo/linux-arm.make for an example.
+ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
+define transform-host-o-to-shared-lib-inner
+$(hide) $(PRIVATE_CXX) \
+ -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \
+ -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
+ -Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
+ -shared -Wl,-soname,$(notdir $@) \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_LD_DIRS) \
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
+ ) \
+ $(PRIVATE_LDFLAGS) \
+ $(PRIVATE_ALL_OBJECTS) \
+ -Wl,--whole-archive \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+ -Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+ -o $@ \
+ $(PRIVATE_LDLIBS)
+endef
+endif
+
+define transform-host-o-to-shared-lib
+@echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(transform-host-o-to-shared-lib-inner)
+endef
+
+define transform-host-o-to-package
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Package: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(transform-host-o-to-shared-lib-inner)
+endef
+
+
+###########################################################
+## Commands for running gcc to link a shared library or package
+###########################################################
+
+define transform-o-to-shared-lib-inner
+$(hide) $(PRIVATE_CXX) \
+ -nostdlib -Wl,-soname,$(notdir $@) \
+ -Wl,--gc-sections \
+ $(if $(filter true,$(PRIVATE_CLANG)),-shared,-Wl$(comma)-shared) \
+ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
+ $(PRIVATE_TARGET_CRTBEGIN_SO_O) \
+ $(PRIVATE_ALL_OBJECTS) \
+ -Wl,--whole-archive \
+ $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+ -Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
+ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
+ $(PRIVATE_TARGET_LIBATOMIC) \
+ $(PRIVATE_TARGET_LIBGCC) \
+ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+ -o $@ \
+ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
+ $(PRIVATE_LDFLAGS) \
+ $(PRIVATE_TARGET_CRTEND_SO_O) \
+ $(PRIVATE_LDLIBS)
+endef
+
+define transform-o-to-shared-lib
+@echo "target SharedLib: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(transform-o-to-shared-lib-inner)
+endef
+
+###########################################################
+## Commands for filtering a target executable or library
+###########################################################
+
+ifneq ($(TARGET_BUILD_VARIANT),user)
+ TARGET_STRIP_EXTRA = && $(PRIVATE_OBJCOPY) --add-gnu-debuglink=$< $@
+ TARGET_STRIP_KEEP_SYMBOLS_EXTRA = --add-gnu-debuglink=$<
+endif
+
+define transform-to-stripped
+@echo "target Strip: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(hide) $(PRIVATE_STRIP) --strip-all $< -o $@ \
+ $(if $(PRIVATE_NO_DEBUGLINK),,$(TARGET_STRIP_EXTRA))
+endef
+
+define transform-to-stripped-keep-symbols
+@echo "target Strip (keep symbols): $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(hide) $(PRIVATE_OBJCOPY) \
+ `$(PRIVATE_READELF) -S $< | awk '/.debug_/ {print "-R " $$2}' | xargs` \
+ $(TARGET_STRIP_KEEP_SYMBOLS_EXTRA) $< $@
+endef
+
+###########################################################
+## Commands for packing a target executable or library
+###########################################################
+
+define pack-elf-relocations
+@echo "target Pack Relocations: $(PRIVATE_MODULE) ($@)"
+$(copy-file-to-target)
+$(hide) $(RELOCATION_PACKER) $@
+endef
+
+###########################################################
+## Commands for running gcc to link an executable
+###########################################################
+
+define transform-o-to-executable-inner
+$(hide) $(PRIVATE_CXX) -pie \
+ -nostdlib -Bdynamic \
+ -Wl,-dynamic-linker,$(PRIVATE_LINKER) \
+ -Wl,--gc-sections \
+ -Wl,-z,nocopyreloc \
+ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
+ -Wl,-rpath-link=$(PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES) \
+ $(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O) \
+ $(PRIVATE_ALL_OBJECTS) \
+ -Wl,--whole-archive \
+ $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+ -Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
+ $(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
+ $(PRIVATE_TARGET_LIBATOMIC) \
+ $(PRIVATE_TARGET_LIBGCC) \
+ $(call normalize-target-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+ -o $@ \
+ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
+ $(PRIVATE_LDFLAGS) \
+ $(PRIVATE_TARGET_CRTEND_O) \
+ $(PRIVATE_LDLIBS)
+endef
+
+define transform-o-to-executable
+@echo "target Executable: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(transform-o-to-executable-inner)
+endef
+
+
+###########################################################
+## Commands for linking a static executable. In practice,
+## we only use this on arm, so the other platforms don't
+## have transform-o-to-static-executable defined.
+## Clang driver needs -static to create static executable.
+## However, bionic/linker uses -shared to overwrite.
+## Linker for x86 targets does not allow coexistance of -static and -shared,
+## so we add -static only if -shared is not used.
+###########################################################
+
+define transform-o-to-static-executable-inner
+$(hide) $(PRIVATE_CXX) \
+ -nostdlib -Bstatic \
+ $(if $(filter $(PRIVATE_LDFLAGS),-shared),,-static) \
+ -Wl,--gc-sections \
+ -o $@ \
+ $(PRIVATE_TARGET_GLOBAL_LD_DIRS) \
+ $(PRIVATE_TARGET_CRTBEGIN_STATIC_O) \
+ $(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
+ $(PRIVATE_LDFLAGS) \
+ $(PRIVATE_ALL_OBJECTS) \
+ -Wl,--whole-archive \
+ $(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+ -Wl,--no-whole-archive \
+ $(call normalize-target-libraries,$(filter-out %libcompiler_rt.a,$(filter-out %libc_nomalloc.a,$(filter-out %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))))) \
+ -Wl,--start-group \
+ $(call normalize-target-libraries,$(filter %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
+ $(call normalize-target-libraries,$(filter %libc_nomalloc.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
+ $(PRIVATE_TARGET_LIBATOMIC) \
+ $(call normalize-target-libraries,$(filter %libcompiler_rt.a,$(PRIVATE_ALL_STATIC_LIBRARIES))) \
+ $(PRIVATE_TARGET_LIBGCC) \
+ -Wl,--end-group \
+ $(PRIVATE_TARGET_CRTEND_O)
+endef
+
+define transform-o-to-static-executable
+@echo "target StaticExecutable: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(transform-o-to-static-executable-inner)
+endef
+
+
+###########################################################
+## Commands for running gcc to link a host executable
+###########################################################
+ifdef BUILD_HOST_static
+HOST_FPIE_FLAGS :=
+else
+HOST_FPIE_FLAGS := -pie
+# Force the correct entry point to workaround a bug in binutils that manifests with -pie
+ifeq ($(HOST_CROSS_OS),windows)
+HOST_CROSS_FPIE_FLAGS += -Wl,-e_mainCRTStartup
+endif
+endif
+
+ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
+define transform-host-o-to-executable-inner
+$(hide) $(PRIVATE_CXX) \
+ $(PRIVATE_ALL_OBJECTS) \
+ -Wl,--whole-archive \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
+ -Wl,--no-whole-archive \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
+ $(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),-lgcov) \
+ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
+ $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \
+ -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \
+ -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
+ -Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
+ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_LD_DIRS) \
+ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
+ $(PRIVATE_HOST_GLOBAL_LDFLAGS) \
+ ) \
+ $(PRIVATE_LDFLAGS) \
+ -o $@ \
+ $(PRIVATE_LDLIBS)
+endef
+endif
+
+define transform-host-o-to-executable
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
+@mkdir -p $(dir $@)
+$(transform-host-o-to-executable-inner)
+endef
+
+
+###########################################################
+## Commands for running javac to make .class files
+###########################################################
+
+# Add BUILD_NUMBER to apps default version name if it's unbundled build.
+ifdef TARGET_BUILD_APPS
+TARGET_BUILD_WITH_APPS_VERSION_NAME := true
+endif
+
+ifdef TARGET_BUILD_WITH_APPS_VERSION_NAME
+APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)-$(BUILD_NUMBER_FROM_FILE)
+else
+APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)
+endif
+
+# TODO: Right now we generate the asset resources twice, first as part
+# of generating the Java classes, then at the end when packaging the final
+# assets. This should be changed to do one of two things: (1) Don't generate
+# any resource files the first time, only create classes during that stage;
+# or (2) Don't use the -c flag with the second stage, instead taking the
+# resource files from the first stage as additional input. My original intent
+# was to use approach (2), but this requires a little more work in the tool.
+# Maybe we should just use approach (1).
+
+# This rule creates the R.java and Manifest.java files, both of which
+# are PRODUCT-neutral. Don't pass PRIVATE_PRODUCT_AAPT_CONFIG to this invocation.
+define create-resource-java-files
+@mkdir -p $(PRIVATE_SOURCE_INTERMEDIATES_DIR)
+@mkdir -p $(dir $(PRIVATE_RESOURCE_PUBLICS_OUTPUT))
+$(hide) $(AAPT) package $(PRIVATE_AAPT_FLAGS) -m \
+ $(eval # PRIVATE_PRODUCT_AAPT_CONFIG is intentionally missing-- see comment.) \
+ $(addprefix -J , $(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \
+ $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \
+ $(addprefix -P , $(PRIVATE_RESOURCE_PUBLICS_OUTPUT)) \
+ $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \
+ $(addprefix -A , $(PRIVATE_ASSET_DIR)) \
+ $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \
+ $(addprefix -G , $(PRIVATE_PROGUARD_OPTIONS_FILE)) \
+ $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+ $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+ $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \
+ $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \
+ $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
+ $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
+ --skip-symbols-without-default-localization
+endef
+
+# Search for generated R.java/Manifest.java, copy the found R.java as $@.
+# Also copy them to a central 'R' directory to make it easier to add the files to an IDE.
+define find-generated-R.java
+$(hide) for GENERATED_MANIFEST_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
+ -name Manifest.java 2> /dev/null`; do \
+ dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_MANIFEST_FILE`; \
+ mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
+ $(ACP) -fp $$GENERATED_MANIFEST_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
+ done;
+$(hide) for GENERATED_R_FILE in `find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) \
+ -name R.java 2> /dev/null`; do \
+ dir=`awk '/package/{gsub(/\./,"/",$$2);gsub(/;/,"",$$2);print $$2;exit}' $$GENERATED_R_FILE`; \
+ mkdir -p $(TARGET_COMMON_OUT_ROOT)/R/$$dir; \
+ $(ACP) -fp $$GENERATED_R_FILE $(TARGET_COMMON_OUT_ROOT)/R/$$dir \
+ || exit 31; \
+ $(ACP) -fp $$GENERATED_R_FILE $@ || exit 32; \
+ done;
+@# Ensure that the target file is always created, i.e. also in case we did not
+@# enter the GENERATED_R_FILE-loop above. This avoids unnecessary rebuilding.
+$(hide) touch $@
+endef
+
+###########################################################
+# AAPT2 compilation and link
+###########################################################
+define aapt2-compile-one-resource-file
+@mkdir -p $(dir $@)
+$(hide) $(AAPT2) compile -o $(dir $@) $(PRIVATE_AAPT2_CFLAGS) --legacy $<
+endef
+
+define aapt2-compile-resource-dirs
+@mkdir -p $(dir $@)
+$(hide) $(AAPT2) compile -o $@ $(addprefix --dir ,$(PRIVATE_SOURCE_RES_DIRS)) \
+ $(PRIVATE_AAPT2_CFLAGS) --legacy
+endef
+
+# Set up rule to compile one resource file with aapt2.
+# Must be called with $(eval).
+# $(1): the source file
+# $(2): the output file
+define aapt2-compile-one-resource-file-rule
+$(2) : $(1) $(AAPT2)
+ @echo "AAPT2 compile $$@ <- $$<"
+ $$(call aapt2-compile-one-resource-file)
+endef
+
+# Convert input resource file path to output file path.
+# values-[config]/.xml -> values-[config]_.arsc.flat;
+# For other resource file, just replace the last "/" with "_" and
+# add .flat extension.
+#
+# $(1): the input resource file path
+# $(2): the base dir of the output file path
+# Returns: the compiled output file path
+define aapt2-compiled-resource-out-file
+$(eval _p_w := $(strip $(subst /,$(space),$(dir $(1)))))$(2)/$(subst $(space),/,$(_p_w))_$(if $(filter values%,$(lastword $(_p_w))),$(patsubst %.xml,%.arsc,$(notdir $(1))),$(notdir $(1))).flat
+endef
+
+define aapt2-link
+@mkdir -p $(dir $@)
+$(call dump-words-to-file,$(PRIVATE_RES_FLAT),$(dir $@)aapt2-flat-list)
+$(hide) $(AAPT2) link -o $@ \
+ $(PRIVATE_AAPT_FLAGS) \
+ $(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
+ $(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \
+ $(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \
+ $(addprefix --java ,$(PRIVATE_SOURCE_INTERMEDIATES_DIR)) \
+ $(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \
+ $(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+ $(addprefix --target-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+ $(if $(filter --product,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --product ,$(PRIVATE_TARGET_AAPT_CHARACTERISTICS))) \
+ $(addprefix -c ,$(PRIVATE_PRODUCT_AAPT_CONFIG)) \
+ $(addprefix --preferred-density ,$(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \
+ $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \
+ $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \
+ $(addprefix --rename-manifest-package ,$(PRIVATE_MANIFEST_PACKAGE_NAME)) \
+ $(addprefix --rename-instrumentation-target-package ,$(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
+ $(addprefix -R , $(PRIVATE_OVERLAY_FLAT)) \
+ \@$(dir $@)aapt2-flat-list
+endef
+
+###########################################################
+xlint_unchecked := -Xlint:unchecked
+
+# emit-line, ,
+define emit-line
+ $(if $(1),echo -n '$(strip $(1)) ' >> $(2))
+endef
+
+# dump-words-to-file, ,
+define dump-words-to-file
+ @rm -f $(2)
+ @touch $(2)
+ @$(call emit-line,$(wordlist 1,500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 501,1000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 1001,1500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 1501,2000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 2001,2500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 2501,3000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 3001,3500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 3501,4000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 4001,4500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 4501,5000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 5001,5500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 5501,6000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 6001,6500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 6501,7000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 7001,7500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 7501,8000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 8001,8500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 8501,9000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 9001,9500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 9501,10000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 10001,10500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 10501,11000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 11001,11500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 11501,12000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 12001,12500,$(1)),$(2))
+ @$(call emit-line,$(wordlist 12501,13000,$(1)),$(2))
+ @$(call emit-line,$(wordlist 13001,13500,$(1)),$(2))
+ @$(if $(wordlist 13501,13502,$(1)),$(error Too many words ($(words $(1)))))
+endef
+
+# For a list of jar files, unzip them to a specified directory,
+# but make sure that no META-INF files come along for the ride,
+# unless PRIVATE_DONT_DELETE_JAR_META_INF is set.
+#
+# $(1): files to unzip
+# $(2): destination directory
+define unzip-jar-files
+ $(hide) for f in $(1); \
+ do \
+ if [ ! -f $$f ]; then \
+ echo Missing file $$f; \
+ exit 1; \
+ fi; \
+ unzip -qo $$f -d $(2); \
+ done
+ $(if $(PRIVATE_DONT_DELETE_JAR_META_INF),,$(hide) rm -rf $(2)/META-INF)
+endef
+
+# Call jack
+#
+define call-jack
+ JACK_VERSION=$(PRIVATE_JACK_VERSION) $(JACK) $(DEFAULT_JACK_EXTRA_ARGS)
+endef
+
+# Common definition to invoke javac on the host and target.
+#
+# Some historical notes:
+# - below we write the list of java files to java-source-list to avoid argument
+# list length problems with Cygwin
+# - we filter out duplicate java file names because eclipse's compiler
+# doesn't like them.
+#
+# $(1): javac
+# $(2): bootclasspath
+define compile-java
+$(hide) rm -f $@
+$(hide) rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR)
+$(hide) mkdir -p $(dir $@)
+$(hide) mkdir -p $(PRIVATE_CLASS_INTERMEDIATES_DIR)
+$(call unzip-jar-files,$(PRIVATE_STATIC_JAVA_LIBRARIES),$(PRIVATE_CLASS_INTERMEDIATES_DIR))
+$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list)
+$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
+ find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' -and -not -name '.*' >> $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list; \
+fi
+$(hide) tr ' ' '\n' < $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list \
+ | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
+$(hide) if [ -s $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
+ $(1) -encoding UTF-8 \
+ $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
+ $(2) \
+ $(addprefix -classpath ,$(strip \
+ $(call normalize-path-list,$(PRIVATE_ALL_JAVA_LIBRARIES)))) \
+ $(if $(findstring true,$(PRIVATE_WARNINGS_ENABLE)),$(xlint_unchecked),) \
+ -extdirs "" -d $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
+ $(PRIVATE_JAVACFLAGS) \
+ \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq \
+ || ( rm -rf $(PRIVATE_CLASS_INTERMEDIATES_DIR) ; exit 41 ) \
+fi
+$(if $(PRIVATE_JAVA_LAYERS_FILE), $(hide) build/tools/java-layers.py \
+ $(PRIVATE_JAVA_LAYERS_FILE) \@$(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq,)
+$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list
+$(hide) rm -f $(PRIVATE_CLASS_INTERMEDIATES_DIR)/java-source-list-uniq
+$(if $(PRIVATE_JAR_EXCLUDE_FILES), $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) \
+ -name $(word 1, $(PRIVATE_JAR_EXCLUDE_FILES)) \
+ $(addprefix -o -name , $(wordlist 2, 999, $(PRIVATE_JAR_EXCLUDE_FILES))) \
+ | xargs rm -rf)
+$(if $(PRIVATE_JAR_PACKAGES), \
+ $(hide) find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -mindepth 1 -type f \
+ $(foreach pkg, $(PRIVATE_JAR_PACKAGES), \
+ -not -path $(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg))/\*) -delete ; \
+ find $(PRIVATE_CLASS_INTERMEDIATES_DIR) -empty -delete)
+$(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) rm -rf \
+ $(foreach pkg, $(PRIVATE_JAR_EXCLUDE_PACKAGES), \
+ $(PRIVATE_CLASS_INTERMEDIATES_DIR)/$(subst .,/,$(pkg))))
+$(if $(PRIVATE_RMTYPEDEFS), $(hide) $(RMTYPEDEFS) -v $(PRIVATE_CLASS_INTERMEDIATES_DIR))
+$(if $(PRIVATE_JAR_MANIFEST), \
+ $(hide) sed -e "s/%BUILD_NUMBER%/$(BUILD_NUMBER_FROM_FILE)/" \
+ $(PRIVATE_JAR_MANIFEST) > $(dir $@)/manifest.mf && \
+ jar -cfm $@ $(dir $@)/manifest.mf \
+ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) ., \
+ $(hide) jar -cf $@ -C $(PRIVATE_CLASS_INTERMEDIATES_DIR) .)
+$(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
+endef
+
+define transform-java-to-classes.jar
+@echo "target Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
+$(call compile-java,$(TARGET_JAVAC),$(PRIVATE_BOOTCLASSPATH))
+endef
+
+# Invoke Jack to compile java from source to dex and jack files.
+#
+# Some historical notes:
+# - below we write the list of java files to java-source-list to avoid argument
+# list length problems with Cygwin
+# - we filter out duplicate java file names because Jack doesn't like them.
+define jack-java-to-dex
+$(hide) rm -f $@
+$(hide) rm -f $(PRIVATE_CLASSES_JACK)
+$(hide) rm -rf $(PRIVATE_JACK_INTERMEDIATES_DIR)
+$(hide) mkdir -p $(dir $@)
+$(hide) mkdir -p $(dir $(PRIVATE_CLASSES_JACK))
+$(hide) mkdir -p $(PRIVATE_JACK_INTERMEDIATES_DIR)
+$(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR))
+$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list)
+$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
+ find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
+fi
+$(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \
+ | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
+$(if $(PRIVATE_JACK_PROGUARD_FLAGS), \
+ $(hide) echo -basedirectory $(CURDIR) > $@.flags; \
+ echo $(PRIVATE_JACK_PROGUARD_FLAGS) >> $@.flags; \
+)
+$(if $(PRIVATE_EXTRA_JAR_ARGS),
+ $(hide) mkdir -p $@.res.tmp
+ $(hide) $(call create-empty-package-at,$@.res.tmp.zip)
+ $(hide) $(call add-java-resources-to,$@.res.tmp.zip)
+ $(hide) unzip -qo $@.res.tmp.zip -d $@.res.tmp
+ $(hide) rm $@.res.tmp.zip)
+$(hide) if [ -s $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
+ export tmpEcjArg="@$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq"; \
+else \
+ export tmpEcjArg=""; \
+fi; \
+$(call call-jack) \
+ $(strip $(PRIVATE_JACK_FLAGS)) \
+ $(strip $(PRIVATE_JACK_COVERAGE_OPTIONS)) \
+ $(if $(NO_OPTIMIZE_DX), \
+ -D jack.dex.optimize="false") \
+ $(if $(PRIVATE_RMTYPEDEFS), \
+ -D jack.android.remove-typedef="true") \
+ $(addprefix --classpath ,$(strip \
+ $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES) $(PRIVATE_ALL_JACK_LIBRARIES)))) \
+ $(addprefix --import ,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES))) \
+ $(if $(PRIVATE_EXTRA_JAR_ARGS),--import-resource $@.res.tmp) \
+ -D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
+ -D jack.import.resource.policy=keep-first \
+ -D jack.import.type.policy=keep-first \
+ --output-jack $(PRIVATE_CLASSES_JACK) \
+ $(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \
+ --output-dex $(PRIVATE_JACK_INTERMEDIATES_DIR) \
+ $(addprefix --config-jarjar ,$(strip $(PRIVATE_JARJAR_RULES))) \
+ $(if $(PRIVATE_JACK_PROGUARD_FLAGS),--config-proguard $@.flags) \
+ $$tmpEcjArg \
+ || ( rm -rf $(PRIVATE_CLASSES_JACK); exit 41 )
+$(hide) mv $(PRIVATE_JACK_INTERMEDIATES_DIR)/classes*.dex $(dir $@)
+$(hide) rm -f $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list
+$(if $(PRIVATE_EXTRA_JAR_ARGS),$(hide) rm -rf $@.res.tmp)
+$(hide) mv $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq $(PRIVATE_JACK_INTERMEDIATES_DIR).java-source-list
+$(if $(PRIVATE_JAR_PACKAGES), $(hide) echo unsupported options PRIVATE_JAR_PACKAGES in $@; exit 53)
+$(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) echo unsupported options JAR_EXCLUDE_PACKAGES in $@; exit 53)
+$(if $(PRIVATE_JAR_MANIFEST), $(hide) echo unsupported options JAR_MANIFEST in $@; exit 53)
+endef
+
+# Invoke Jack to compile java source just to check it compiles correctly.
+#
+# Some historical notes:
+# - below we write the list of java files to java-source-list to avoid argument
+# list length problems with Cygwin
+# - we filter out duplicate java file names because Jack doesn't like them.
+define jack-check-java
+$(hide) rm -f $@
+$(hide) rm -f $@.java-source-list
+$(hide) rm -f $@.java-source-list-uniq
+$(hide) mkdir -p $(dir $@)
+$(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR))
+$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$@.java-source-list)
+$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
+ find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $@.java-source-list; \
+fi
+$(hide) tr ' ' '\n' < $@.java-source-list \
+ | sort -u > $@.java-source-list-uniq
+$(hide) if [ -s $@.java-source-list-uniq ] ; then \
+ $(call call-jack,$(PRIVATE_JACK_EXTRA_ARGS)) \
+ $(strip $(PRIVATE_JACK_FLAGS)) \
+ $(strip $(PRIVATE_JACK_DEBUG_FLAGS)) \
+ $(addprefix --classpath ,$(strip \
+ $(call normalize-path-list,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES)) $(PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES) $(PRIVATE_ALL_JACK_LIBRARIES)))) \
+ -D jack.import.resource.policy=keep-first \
+ -D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
+ -D jack.import.type.policy=keep-first \
+ $(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \
+ @$@.java-source-list-uniq; \
+fi
+touch $@
+endef
+
+define transform-jar-to-jack
+ $(hide) mkdir -p $(dir $@)
+ $(hide) mkdir -p $@.tmpjill.res
+ $(hide) unzip -qo $< -d $@.tmpjill.res
+ $(hide) find $@.tmpjill.res -iname "*.class" -delete
+ $(hide) $(call call-jack) \
+ $(PRIVATE_JACK_FLAGS) \
+ -D jack.import.resource.policy=keep-first \
+ -D jack.import.type.policy=keep-first \
+ -D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
+ --import $< \
+ --import-resource $@.tmpjill.res \
+ --output-jack $@
+ $(hide) rm -rf $@.tmpjill.res
+endef
+
+# Moves $1.tmp to $1 if necessary. This is designed to be used with
+# .KATI_RESTAT. For kati, this function doesn't update the timestamp
+# of $1 when $1.tmp is identical to $1 so that ninja won't rebuild
+# targets which depend on $1. For GNU make, this function simply
+# copies $1.tmp to $1.
+ifeq ($(BUILDING_WITH_NINJA),true)
+define commit-change-for-toc
+$(hide) if cmp -s $1.tmp $1 ; then \
+ rm $1.tmp ; \
+else \
+ mv $1.tmp $1 ; \
+fi
+endef
+else
+define commit-change-for-toc
+@# make doesn't support restat. We always update .toc files so the dependents will always be updated too.
+$(hide) mv $1.tmp $1
+endef
+endif
+
+## Rule to create a table of contents from a .jar file.
+## Must be called with $(eval).
+# $(1): A .jar file
+define _transform-jar-to-toc
+$1.toc: $1 | $(IJAR)
+ @echo Generating TOC: $$@
+ $(hide) $(IJAR) $$< $$@.tmp
+ $$(call commit-change-for-toc,$$@)
+endef
+
+## Define a rule which generates .jar.toc and mark it as .KATI_RESTAT.
+# $(1): A .jar file
+define define-jar-to-toc-rule
+$(eval $(call _transform-jar-to-toc,$1))\
+$(eval .KATI_RESTAT: $1.toc)
+endef
+
+ifeq (,$(TARGET_BUILD_APPS))
+
+## Rule to create a table of contents from a .dex file.
+## Must be called with $(eval).
+# $(1): The directory which contains classes*.dex files
+define _transform-dex-to-toc
+$1/classes.dex.toc: PRIVATE_INPUT_DEX_FILES := $1/classes*.dex
+$1/classes.dex.toc: $1/classes.dex $(DEXDUMP)
+ @echo Generating TOC: $$@
+ $(hide) $(DEXDUMP) -l xml $$(PRIVATE_INPUT_DEX_FILES) > $$@.tmp
+ $$(call commit-change-for-toc,$$@)
+endef
+
+## Define a rule which generates .dex.toc and mark it as .KATI_RESTAT.
+# $(1): The directory which contains classes*.dex files
+define define-dex-to-toc-rule
+$(eval $(call _transform-dex-to-toc,$1))\
+$(eval .KATI_RESTAT: $1/classes.dex.toc)
+endef
+
+else
+
+# Turn off .toc optimization for apps build as we cannot build dexdump.
+define define-dex-to-toc-rule
+endef
+
+endif # TARGET_BUILD_APPS
+
+
+# Invoke Jack to compile java from source to jack files without shrink or obfuscation.
+#
+# Some historical notes:
+# - below we write the list of java files to java-source-list to avoid argument
+# list length problems with Cygwin
+# - we filter out duplicate java file names because Jack doesn't like them.
+define java-to-jack
+$(hide) rm -f $@
+$(hide) rm -rf $(PRIVATE_JACK_INTERMEDIATES_DIR)
+$(hide) mkdir -p $(dir $@)
+$(hide) mkdir -p $(PRIVATE_JACK_INTERMEDIATES_DIR)
+$(if $(PRIVATE_JACK_INCREMENTAL_DIR),$(hide) mkdir -p $(PRIVATE_JACK_INCREMENTAL_DIR))
+$(call dump-words-to-file,$(PRIVATE_JAVA_SOURCES),$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list)
+$(hide) if [ -d "$(PRIVATE_SOURCE_INTERMEDIATES_DIR)" ]; then \
+ find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name '*.java' >> $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list; \
+fi
+$(hide) tr ' ' '\n' < $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list \
+ | $(NORMALIZE_PATH) | sort -u > $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq
+$(if $(PRIVATE_JACK_PROGUARD_FLAGS), \
+ $(hide) echo -basedirectory $(CURDIR) > $@.flags; \
+ echo $(PRIVATE_JACK_PROGUARD_FLAGS) >> $@.flags; \
+)
+$(if $(PRIVATE_EXTRA_JAR_ARGS),
+ $(hide) mkdir -p $@.res.tmp
+ $(hide) $(call create-empty-package-at,$@.res.tmp.zip)
+ $(hide) $(call add-java-resources-to,$@.res.tmp.zip)
+ $(hide) unzip -qo $@.res.tmp.zip -d $@.res.tmp
+ $(hide) rm $@.res.tmp.zip)
+$(hide) if [ -s $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq ] ; then \
+ export tmpEcjArg="@$(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq"; \
+else \
+ export tmpEcjArg=""; \
+fi; \
+$(call call-jack) \
+ $(strip $(PRIVATE_JACK_FLAGS)) \
+ $(if $(NO_OPTIMIZE_DX), \
+ -D jack.dex.optimize="false") \
+ $(addprefix --classpath ,$(strip \
+ $(call normalize-path-list,$(PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES) $(PRIVATE_ALL_JACK_LIBRARIES)))) \
+ $(addprefix --import ,$(call reverse-list,$(PRIVATE_STATIC_JACK_LIBRARIES))) \
+ $(if $(PRIVATE_EXTRA_JAR_ARGS),--import-resource $@.res.tmp) \
+ -D jack.import.resource.policy=keep-first \
+ -D jack.import.type.policy=keep-first \
+ -D jack.android.min-api-level=$(PRIVATE_JACK_MIN_SDK_VERSION) \
+ $(if $(PRIVATE_JACK_INCREMENTAL_DIR),--incremental-folder $(PRIVATE_JACK_INCREMENTAL_DIR)) \
+ --output-jack $@ \
+ $(addprefix --config-jarjar ,$(strip $(PRIVATE_JARJAR_RULES))) \
+ $(if $(PRIVATE_JACK_PROGUARD_FLAGS),--config-proguard $@.flags) \
+ $$tmpEcjArg \
+ || ( rm -f $@ ; exit 41 )
+$(hide) rm -f $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list
+$(if $(PRIVATE_EXTRA_JAR_ARGS),$(hide) rm -rf $@.res.tmp)
+$(hide) mv $(PRIVATE_JACK_INTERMEDIATES_DIR)/java-source-list-uniq $(PRIVATE_JACK_INTERMEDIATES_DIR).java-source-list
+$(if $(PRIVATE_JAR_PACKAGES), $(hide) echo unsupported options PRIVATE_JAR_PACKAGES in $@; exit 53)
+$(if $(PRIVATE_JAR_EXCLUDE_PACKAGES), $(hide) echo unsupported options JAR_EXCLUDE_PACKAGES in $@; exit 53)
+$(if $(PRIVATE_JAR_MANIFEST), $(hide) echo unsupported options JAR_MANIFEST in $@; exit 53)
+endef
+
+define transform-classes.jar-to-emma
+$(hide) java -classpath $(EMMA_JAR) emma instr -outmode fullcopy -outfile \
+ $(PRIVATE_EMMA_COVERAGE_FILE) -ip $< -d $(PRIVATE_EMMA_INTERMEDIATES_DIR) \
+ $(addprefix -ix , $(PRIVATE_EMMA_COVERAGE_FILTER))
+endef
+
+# Create a mostly-empty .jar file that we'll add to later.
+# The MacOS jar tool doesn't like creating empty jar files,
+# so we need to give it something.
+# $(1) package to create
+define create-empty-package-at
+@mkdir -p $(dir $(1))
+$(hide) touch $(dir $(1))zipdummy
+$(hide) (cd $(dir $(1)) && jar cf $(notdir $(1)) zipdummy)
+$(hide) zip -qd $(1) zipdummy
+$(hide) rm $(dir $(1))zipdummy
+endef
+
+# Create a mostly-empty .jar file that we'll add to later.
+# The MacOS jar tool doesn't like creating empty jar files,
+# so we need to give it something.
+define create-empty-package
+$(call create-empty-package-at,$@)
+endef
+
+# Copy an arhchive file and delete any class files and empty folders inside.
+# $(1): the source archive file.
+# $(2): the destination archive file.
+define initialize-package-file
+@mkdir -p $(dir $(2))
+$(hide) cp -f $(1) $(2)
+$(hide) zip -qd $(2) "*.class" \
+ $(if $(strip $(PRIVATE_DONT_DELETE_JAR_DIRS)),,"*/") \
+ || true # Ignore the error when nothing to delete.
+endef
+
+#TODO: we kinda want to build different asset packages for
+# different configurations, then combine them later (or something).
+# Per-locale, etc.
+# A list of dynamic and static parameters; build layers for
+# dynamic params that lay over the static ones.
+#TODO: update the manifest to point to the package file
+#Note that the version numbers are given to aapt as simple default
+#values; applications can override these by explicitly stating
+#them in their manifest.
+define add-assets-to-package
+$(hide) $(AAPT) package -u $(PRIVATE_AAPT_FLAGS) \
+ $(addprefix -c , $(PRIVATE_PRODUCT_AAPT_CONFIG)) \
+ $(addprefix --preferred-density , $(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \
+ $(addprefix -M , $(PRIVATE_ANDROID_MANIFEST)) \
+ $(addprefix -S , $(PRIVATE_RESOURCE_DIR)) \
+ $(addprefix -A , $(PRIVATE_ASSET_DIR)) \
+ $(addprefix -I , $(PRIVATE_AAPT_INCLUDES)) \
+ $(addprefix --min-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+ $(addprefix --target-sdk-version , $(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
+ $(if $(filter --product,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --product , $(PRIVATE_TARGET_AAPT_CHARACTERISTICS))) \
+ $(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \
+ $(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \
+ $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
+ $(addprefix --rename-instrumentation-target-package , $(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
+ --skip-symbols-without-default-localization \
+ -F $@
+endef
+
+# We need the extra blank line, so that the command will be on a separate line.
+# $(1): the ABI name
+# $(2): the list of shared libraies
+define _add-jni-shared-libs-to-package-per-abi
+$(hide) cp $(2) $(dir $@)lib/$(1)
+
+endef
+
+# For apps_only build, don't uncompress/page-align the jni libraries,
+# because the apk may be run on older platforms that don't support loading jni directly from apk.
+ifdef TARGET_BUILD_APPS
+JNI_COMPRESS_FLAGS :=
+ZIPALIGN_PAGE_ALIGN_FLAGS :=
+else
+JNI_COMPRESS_FLAGS := -0
+ZIPALIGN_PAGE_ALIGN_FLAGS := -p
+endif
+
+define add-jni-shared-libs-to-package
+$(hide) rm -rf $(dir $@)lib
+$(hide) mkdir -p $(addprefix $(dir $@)lib/,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI))
+$(foreach abi,$(PRIVATE_JNI_SHARED_LIBRARIES_ABI),\
+ $(call _add-jni-shared-libs-to-package-per-abi,$(abi),\
+ $(patsubst $(abi):%,%,$(filter $(abi):%,$(PRIVATE_JNI_SHARED_LIBRARIES)))))
+$(hide) (cd $(dir $@) && zip -qrX $(JNI_COMPRESS_FLAGS) $(notdir $@) lib)
+$(hide) rm -rf $(dir $@)lib
+endef
+
+#TODO: update the manifest to point to the dex file
+define add-dex-to-package
+$(call add-dex-to-package-arg,$@)
+endef
+
+# $(1): the package file.
+define add-dex-to-package-arg
+$(hide) find $(dir $(PRIVATE_DEX_FILE)) -maxdepth 1 -name "classes*.dex" | sort | xargs zip -qjX $(1)
+endef
+
+# Add java resources added by the current module.
+# $(1) destination package
+#
+define add-java-resources-to
+$(call dump-words-to-file, $(PRIVATE_EXTRA_JAR_ARGS), $(1).jar-arg-list)
+$(hide) jar uf $(1) @$(1).jar-arg-list
+@rm -f $(1).jar-arg-list
+endef
+
+# Add resources carried by static Jack libraries.
+#
+define add-carried-jack-resources
+ $(hide) if [ -d $(PRIVATE_JACK_INTERMEDIATES_DIR) ] ; then \
+ find $(PRIVATE_JACK_INTERMEDIATES_DIR) -type f | sort \
+ | sed -e "s?^$(PRIVATE_JACK_INTERMEDIATES_DIR)/? -C \"$(PRIVATE_JACK_INTERMEDIATES_DIR)\" \"?" -e "s/$$/\"/" \
+ > $(dir $@)jack_res_jar_flags; \
+ if [ -s $(dir $@)jack_res_jar_flags ] ; then \
+ jar uf $@ @$(dir $@)jack_res_jar_flags; \
+ fi; \
+fi
+endef
+
+# Returns the minSdkVersion of the specified APK as a decimal number. If the
+# version is a codename, returns the current platform SDK version (always a
+# decimal number) instead. If the APK does not specify a minSdkVersion, returns
+# 0 to match how the Android platform interprets this situation at runtime.
+#
+# This currently substitutes any version which contains characters other than
+# digits with the current platform's API Level number. This is because I
+# couldn't figure out an easy way to perform the substitution only for the
+# version codes listed in PLATFORM_VERSION_ALL_CODENAMES.
+define get-package-min-sdk-version-int
+$$(($(AAPT) dump badging $(1) 2>&1 | grep '^sdkVersion' || echo "sdkVersion:'0'") \
+ | cut -d"'" -f2 | \
+ sed -e s/^.*[^0-9].*$$/$(PLATFORM_SDK_VERSION)/)
+endef
+
+# Sign a package using the specified key/cert.
+#
+define sign-package
+$(call sign-package-arg,$@)
+endef
+
+# $(1): the package file we are signing.
+define sign-package-arg
+$(hide) mv $(1) $(1).unsigned
+$(hide) java -Djava.library.path=$(SIGNAPK_JNI_LIBRARY_PATH) -jar $(SIGNAPK_JAR) \
+ --min-sdk-version $(call get-package-min-sdk-version-int,$@.unsigned) \
+ $(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) \
+ $(PRIVATE_ADDITIONAL_CERTIFICATES) $(1).unsigned $(1).signed
+$(hide) mv $(1).signed $(1)
+endef
+
+# Align STORED entries of a package on 4-byte boundaries to make them easier to mmap.
+#
+define align-package
+$(hide) if ! $(ZIPALIGN) -c $(ZIPALIGN_PAGE_ALIGN_FLAGS) 4 $@ >/dev/null ; then \
+ mv $@ $@.unaligned; \
+ $(ZIPALIGN) \
+ -f \
+ $(ZIPALIGN_PAGE_ALIGN_FLAGS) \
+ 4 \
+ $@.unaligned $@.aligned; \
+ mv $@.aligned $@; \
+ fi
+endef
+
+# Remove dynamic timestamps from packages
+#
+ifndef TARGET_BUILD_APPS
+define remove-timestamps-from-package
+$(hide) $(ZIPTIME) $@
+endef
+endif
+
+# Uncompress shared libraries embedded in an apk.
+#
+define uncompress-shared-libs
+$(hide) if (zipinfo $@ $(PRIVATE_EMBEDDED_JNI_LIBS) 2>/dev/null | grep -v ' stor ' >/dev/null) ; then \
+ rm -rf $(dir $@)uncompressedlibs && mkdir $(dir $@)uncompressedlibs; \
+ unzip $@ $(PRIVATE_EMBEDDED_JNI_LIBS) -d $(dir $@)uncompressedlibs && \
+ zip -d $@ 'lib/*.so' && \
+ ( cd $(dir $@)uncompressedlibs && find lib -type f | sort | zip -D -X -0 ../$(notdir $@) -@ ) && \
+ rm -rf $(dir $@)uncompressedlibs; \
+ fi
+endef
+
+define install-dex-debug
+$(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.dex" ]; then \
+ mkdir -p $(TOP)/dalvik/DEBUG-FILES; \
+ $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.dex \
+ $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).dex; \
+ fi
+$(hide) if [ -f "$(PRIVATE_INTERMEDIATES_DIR)/classes.lst" ]; then \
+ mkdir -p $(TOP)/dalvik/DEBUG-FILES; \
+ $(ACP) $(PRIVATE_INTERMEDIATES_DIR)/classes.lst \
+ $(TOP)/dalvik/DEBUG-FILES/$(PRIVATE_MODULE).lst; \
+ fi
+endef
+
+# TODO(joeo): If we can ever upgrade to post 3.81 make and get the
+# new prebuilt rules to work, we should change this to copy the
+# resources to the out directory and then copy the resources.
+
+# Note: we intentionally don't clean PRIVATE_CLASS_INTERMEDIATES_DIR
+# in transform-java-to-classes for the sake of vm-tests.
+define transform-host-java-to-package
+@echo "$($(PRIVATE_PREFIX)DISPLAY) Java: $(PRIVATE_MODULE) ($(PRIVATE_CLASS_INTERMEDIATES_DIR))"
+$(call compile-java,$(HOST_JAVAC),$(PRIVATE_BOOTCLASSPATH))
+endef
+
+###########################################################
+## Commands for copying files
+###########################################################
+
+# Define a rule to copy a header. Used via $(eval) by copy_headers.make.
+# $(1): source header
+# $(2): destination header
+define copy-one-header
+$(2): $(1)
+ @echo "Header: $$@"
+ $$(copy-file-to-new-target-with-cp)
+endef
+
+# Define a rule to copy a file. For use via $(eval).
+# $(1): source file
+# $(2): destination file
+define copy-one-file
+$(2): $(1) | $(ACP)
+ @echo "Copy: $$@"
+ $$(copy-file-to-target)
+endef
+
+# Copies many files.
+# $(1): The files to copy. Each entry is a ':' separated src:dst pair
+# Evaluates to the list of the dst files (ie suitable for a dependency list)
+define copy-many-files
+$(foreach f, $(1), $(strip \
+ $(eval _cmf_tuple := $(subst :, ,$(f))) \
+ $(eval _cmf_src := $(word 1,$(_cmf_tuple))) \
+ $(eval _cmf_dest := $(word 2,$(_cmf_tuple))) \
+ $(eval $(call copy-one-file,$(_cmf_src),$(_cmf_dest))) \
+ $(_cmf_dest)))
+endef
+
+# Copy the file only if it's a well-formed xml file. For use via $(eval).
+# $(1): source file
+# $(2): destination file, must end with .xml.
+define copy-xml-file-checked
+$(2): $(1) | $(ACP)
+ @echo "Copy xml: $$@"
+ $(hide) xmllint $$< >/dev/null # Don't print the xml file to stdout.
+ $$(copy-file-to-target)
+endef
+
+# The -t option to acp and the -p option to cp is
+# required for OSX. OSX has a ridiculous restriction
+# where it's an error for a .a file's modification time
+# to disagree with an internal timestamp, and this
+# macro is used to install .a files (among other things).
+
+# Copy a single file from one place to another,
+# preserving permissions and overwriting any existing
+# file.
+# We disable the "-t" option for acp cannot handle
+# high resolution timestamp correctly on file systems like ext4.
+# Therefore copy-file-to-target is the same as copy-file-to-new-target.
+define copy-file-to-target
+@mkdir -p $(dir $@)
+$(hide) $(ACP) -fp $< $@
+endef
+
+# The same as copy-file-to-target, but use the local
+# cp command instead of acp.
+define copy-file-to-target-with-cp
+@mkdir -p $(dir $@)
+$(hide) cp -fp $< $@
+endef
+
+# The same as copy-file-to-target, but use the zipalign tool to do so.
+define copy-file-to-target-with-zipalign
+@mkdir -p $(dir $@)
+$(hide) $(ZIPALIGN) -f 4 $< $@
+endef
+
+# The same as copy-file-to-target, but strip out "# comment"-style
+# comments (for config files and such).
+define copy-file-to-target-strip-comments
+@mkdir -p $(dir $@)
+$(hide) sed -e 's/#.*$$//' -e 's/[ \t]*$$//' -e '/^$$/d' < $< > $@
+endef
+
+# The same as copy-file-to-target, but don't preserve
+# the old modification time.
+define copy-file-to-new-target
+@mkdir -p $(dir $@)
+$(hide) $(ACP) -fp $< $@
+endef
+
+# The same as copy-file-to-new-target, but use the local
+# cp command instead of acp.
+define copy-file-to-new-target-with-cp
+@mkdir -p $(dir $@)
+$(hide) cp -f $< $@
+endef
+
+# Copy a prebuilt file to a target location.
+define transform-prebuilt-to-target
+@echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)"
+$(copy-file-to-target)
+endef
+
+# Copy a prebuilt file to a target location, using zipalign on it.
+define transform-prebuilt-to-target-with-zipalign
+@echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt APK: $(PRIVATE_MODULE) ($@)"
+$(copy-file-to-target-with-zipalign)
+endef
+
+# Copy a prebuilt file to a target location, stripping "# comment" comments.
+define transform-prebuilt-to-target-strip-comments
+@echo "$(if $(PRIVATE_IS_HOST_MODULE),host,target) Prebuilt: $(PRIVATE_MODULE) ($@)"
+$(copy-file-to-target-strip-comments)
+endef
+
+# Copy a list of files/directories to target location, with sub dir structure preserved.
+# For example $(HOST_OUT_EXECUTABLES)/aapt -> $(staging)/bin/aapt .
+# $(1): the source list of files/directories.
+# $(2): the path prefix to strip. In the above example it would be $(HOST_OUT).
+# $(3): the target location.
+define copy-files-with-structure
+$(foreach t,$(1),\
+ $(eval s := $(patsubst $(2)%,%,$(t)))\
+ $(hide) mkdir -p $(dir $(3)/$(s)); cp -Rf $(t) $(3)/$(s)$(newline))
+endef
+
+
+###########################################################
+## Commands to call Proguard
+###########################################################
+define transform-jar-to-proguard
+@echo Proguard: $@
+$(hide) $(PROGUARD) -injars $< -outjars $@ $(PRIVATE_PROGUARD_FLAGS) \
+ $(addprefix -injars , $(PRIVATE_EXTRA_INPUT_JAR))
+endef
+
+###########################################################
+## Stuff source generated from one-off tools
+###########################################################
+
+define transform-generated-source
+@echo "target Generated: $(PRIVATE_MODULE) <= $<"
+@mkdir -p $(dir $@)
+$(hide) $(PRIVATE_CUSTOM_TOOL)
+endef
+
+
+###########################################################
+## Assertions about attributes of the target
+###########################################################
+
+# $(1): The file to check
+ifndef get-file-size
+$(error HOST_OS must define get-file-size)
+endif
+
+# Convert a partition data size (eg, as reported in /proc/mtd) to the
+# size of the image used to flash that partition (which includes a
+# spare area for each page).
+# $(1): the partition data size
+define image-size-from-data-size
+$(strip $(eval _isfds_value := $$(shell echo $$$$(($(1) / $(BOARD_NAND_PAGE_SIZE) * \
+ ($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE))))))\
+$(if $(filter 0, $(_isfds_value)),$(shell echo $$(($(BOARD_NAND_PAGE_SIZE)+$(BOARD_NAND_SPARE_SIZE)))),$(_isfds_value))\
+$(eval _isfds_value :=))
+endef
+
+# $(1): The file(s) to check (often $@)
+# $(2): The maximum total image size, in decimal bytes.
+# Make sure to take into account any reserved space needed for the FS.
+#
+# If $(2) is empty, evaluates to "true"
+#
+# Reserve bad blocks. Make sure that MAX(1% of partition size, 2 blocks)
+# is left over after the image has been flashed. Round the 1% up to the
+# next whole flash block size.
+define assert-max-file-size
+$(if $(2), \
+ size=$$(for i in $(1); do $(call get-file-size,$$i); echo +; done; echo 0); \
+ total=$$(( $$( echo "$$size" ) )); \
+ printname=$$(echo -n "$(1)" | tr " " +); \
+ img_blocksize=$(call image-size-from-data-size,$(BOARD_FLASH_BLOCK_SIZE)); \
+ twoblocks=$$((img_blocksize * 2)); \
+ onepct=$$((((($(2) / 100) - 1) / img_blocksize + 1) * img_blocksize)); \
+ reserve=$$((twoblocks > onepct ? twoblocks : onepct)); \
+ maxsize=$$(($(2) - reserve)); \
+ echo "$$printname maxsize=$$maxsize blocksize=$$img_blocksize total=$$total reserve=$$reserve"; \
+ if [ "$$total" -gt "$$maxsize" ]; then \
+ echo "error: $$printname too large ($$total > [$(2) - $$reserve])"; \
+ false; \
+ elif [ "$$total" -gt $$((maxsize - 32768)) ]; then \
+ echo "WARNING: $$printname approaching size limit ($$total now; limit $$maxsize)"; \
+ fi \
+ , \
+ true \
+ )
+endef
+
+# Like assert-max-file-size, but the second argument is a partition
+# size, which we'll convert to a max image size before checking it
+# against the files.
+#
+# $(1): The file(s) to check (often $@)
+# $(2): The partition size.
+define assert-max-image-size
+$(if $(2), \
+ $(call assert-max-file-size,$(1),$(call image-size-from-data-size,$(2))))
+endef
+
+
+###########################################################
+## Define device-specific radio files
+###########################################################
+INSTALLED_RADIOIMAGE_TARGET :=
+
+# Copy a radio image file to the output location, and add it to
+# INSTALLED_RADIOIMAGE_TARGET.
+# $(1): filename
+define add-radio-file
+ $(eval $(call add-radio-file-internal,$(1),$(notdir $(1))))
+endef
+define add-radio-file-internal
+INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2)
+$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP)
+ $$(transform-prebuilt-to-target)
+endef
+
+# Version of add-radio-file that also arranges for the version of the
+# file to be checked against the contents of
+# $(TARGET_BOARD_INFO_FILE).
+# $(1): filename
+# $(2): name of version variable in board-info (eg, "version-baseband")
+define add-radio-file-checked
+ $(eval $(call add-radio-file-checked-internal,$(1),$(notdir $(1)),$(2)))
+endef
+define add-radio-file-checked-internal
+INSTALLED_RADIOIMAGE_TARGET += $$(PRODUCT_OUT)/$(2)
+BOARD_INFO_CHECK += $(3):$(LOCAL_PATH)/$(1)
+$$(PRODUCT_OUT)/$(2) : $$(LOCAL_PATH)/$(1) | $$(ACP)
+ $$(transform-prebuilt-to-target)
+endef
+
+
+###########################################################
+# Override the package defined in $(1), setting the
+# variables listed below differently.
+#
+# $(1): The makefile to override (relative to the source
+# tree root)
+# $(2): Old LOCAL_PACKAGE_NAME value.
+# $(3): New LOCAL_PACKAGE_NAME value.
+# $(4): New LOCAL_MANIFEST_PACKAGE_NAME value.
+# $(5): New LOCAL_CERTIFICATE value.
+# $(6): New LOCAL_INSTRUMENTATION_FOR value.
+# $(7): New LOCAL_MANIFEST_INSTRUMENTATION_FOR value.
+#
+# Note that LOCAL_PACKAGE_OVERRIDES is NOT cleared in
+# clear_vars.mk.
+###########################################################
+define inherit-package
+ $(eval $(call inherit-package-internal,$(1),$(2),$(3),$(4),$(5),$(6),$(7)))
+endef
+
+define inherit-package-internal
+ LOCAL_PACKAGE_OVERRIDES \
+ := $(strip $(1))||$(strip $(2))||$(strip $(3))||$(strip $(4))||&&$(strip $(5))||&&$(strip $(6))||&&$(strip $(7)) $(LOCAL_PACKAGE_OVERRIDES)
+ include $(1)
+ LOCAL_PACKAGE_OVERRIDES \
+ := $(wordlist 1,$(words $(LOCAL_PACKAGE_OVERRIDES)), $(LOCAL_PACKAGE_OVERRIDES))
+endef
+
+# To be used with inherit-package above
+# Evalutes to true if the package was overridden
+define set-inherited-package-variables
+$(strip $(call set-inherited-package-variables-internal))
+endef
+
+define keep-or-override
+$(eval $(1) := $(if $(2),$(2),$($(1))))
+endef
+
+define set-inherited-package-variables-internal
+ $(eval _o := $(subst ||, ,$(lastword $(LOCAL_PACKAGE_OVERRIDES))))
+ $(eval _n := $(subst ||, ,$(firstword $(LOCAL_PACKAGE_OVERRIDES))))
+ $(if $(filter $(word 2,$(_n)),$(LOCAL_PACKAGE_NAME)), \
+ $(eval LOCAL_PACKAGE_NAME := $(word 3,$(_o))) \
+ $(eval LOCAL_MANIFEST_PACKAGE_NAME := $(word 4,$(_o))) \
+ $(call keep-or-override,LOCAL_CERTIFICATE,$(patsubst &&%,%,$(word 5,$(_o)))) \
+ $(call keep-or-override,LOCAL_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 6,$(_o)))) \
+ $(call keep-or-override,LOCAL_MANIFEST_INSTRUMENTATION_FOR,$(patsubst &&%,%,$(word 7,$(_o)))) \
+ $(eval LOCAL_OVERRIDES_PACKAGES := $(sort $(LOCAL_OVERRIDES_PACKAGES) $(word 2,$(_o)))) \
+ true \
+ ,)
+endef
+
+###########################################################
+## API Check
+###########################################################
+
+# eval this to define a rule that runs apicheck.
+#
+# Args:
+# $(1) target
+# $(2) stable api file
+# $(3) api file to be tested
+# $(4) stable removed api file
+# $(5) removed api file to be tested
+# $(6) arguments for apicheck
+# $(7) command to run if apicheck failed
+# $(8) target dependent on this api check
+# $(9) additional dependencies
+define check-api
+$(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp: $(2) $(3) $(4) $(APICHECK) $(9)
+ @echo "Checking API:" $(1)
+ $(hide) ( $(APICHECK_COMMAND) $(6) $(2) $(3) $(4) $(5) || ( $(7) ; exit 38 ) )
+ $(hide) mkdir -p $$(dir $$@)
+ $(hide) touch $$@
+$(8): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/$(strip $(1))-timestamp
+endef
+
+## Whether to build from source if prebuilt alternative exists
+###########################################################
+# $(1): module name
+# $(2): LOCAL_PATH
+# Expands to empty string if not from source.
+ifeq (true,$(ANDROID_BUILD_FROM_SOURCE))
+define if-build-from-source
+true
+endef
+else
+define if-build-from-source
+$(if $(filter $(ANDROID_NO_PREBUILT_MODULES),$(1))$(filter \
+ $(addsuffix %,$(ANDROID_NO_PREBUILT_PATHS)),$(2)),true)
+endef
+endif
+
+# Include makefile $(1) if build from source for module $(2)
+# $(1): the makefile to include
+# $(2): module name
+# $(3): LOCAL_PATH
+define include-if-build-from-source
+$(if $(call if-build-from-source,$(2),$(3)),$(eval include $(1)))
+endef
+
+# Return the arch for the source file of a prebuilt
+# Return "none" if no matching arch found and return empty
+# if the input is empty, so the result can be passed to
+# LOCAL_MODULE_TARGET_ARCH.
+# $(1) the list of archs supported by the prebuilt
+define get-prebuilt-src-arch
+$(strip $(if $(filter $(TARGET_ARCH),$(1)),$(TARGET_ARCH),\
+ $(if $(filter $(TARGET_2ND_ARCH),$(1)),$(TARGET_2ND_ARCH),$(if $(1),none))))
+endef
+
+###########################################################
+## Other includes
+###########################################################
+
+# -----------------------------------------------------------------
+# Rules and functions to help copy important files to DIST_DIR
+# when requested.
+include $(BUILD_SYSTEM)/distdir.mk
+
+# Include any vendor specific definitions.mk file
+-include $(TOPDIR)vendor/*/build/core/definitions.mk
+-include $(TOPDIR)device/*/build/core/definitions.mk
+-include $(TOPDIR)product/*/build/core/definitions.mk
+
+# broken:
+# $(foreach file,$^,$(if $(findstring,.a,$(suffix $file)),-l$(file),$(file)))
+
+###########################################################
+## Misc notes
+###########################################################
+
+#DEPDIR = .deps
+#df = $(DEPDIR)/$(*F)
+
+#SRCS = foo.c bar.c ...
+
+#%.o : %.c
+# @$(MAKEDEPEND); \
+# cp $(df).d $(df).P; \
+# sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+# -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \
+# rm -f $(df).d
+# $(COMPILE.c) -o $@ $<
+
+#-include $(SRCS:%.c=$(DEPDIR)/%.P)
+
+
+#%.o : %.c
+# $(COMPILE.c) -MD -o $@ $<
+# @cp $*.d $*.P; \
+# sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+# -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
+# rm -f $*.d
diff --git a/core/device.mk b/core/device.mk
new file mode 100644
index 0000000000000000000000000000000000000000..20ff447caa81d377f43b95662f628eb583b5294b
--- /dev/null
+++ b/core/device.mk
@@ -0,0 +1,76 @@
+#
+# 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.
+#
+
+_device_var_list := \
+ DEVICE_NAME \
+ DEVICE_BOARD \
+ DEVICE_REGION
+
+define dump-device
+$(info ==== $(1) ====)\
+$(foreach v,$(_device_var_list),\
+$(info DEVICES.$(1).$(v) := $(DEVICES.$(1).$(v))))\
+$(info --------)
+endef
+
+define dump-devices
+$(foreach p,$(DEVICES),$(call dump-device,$(p)))
+endef
+
+#
+# $(1): device to inherit
+#
+define inherit-device
+ $(foreach v,$(_device_var_list), \
+ $(eval $(v) := $($(v)) $(INHERIT_TAG)$(strip $(1))))
+endef
+
+#
+# $(1): device makefile list
+#
+#TODO: check to make sure that devices have all the necessary vars defined
+define import-devices
+$(call import-nodes,DEVICES,$(1),$(_device_var_list))
+endef
+
+
+#
+# $(1): short device name like "sooner"
+#
+define _resolve-short-device-name
+ $(eval dn := $(strip $(1)))
+ $(eval d := \
+ $(foreach d,$(DEVICES), \
+ $(if $(filter $(dn),$(DEVICES.$(d).DEVICE_NAME)), \
+ $(d) \
+ )) \
+ )
+ $(eval d := $(sort $(d)))
+ $(if $(filter 1,$(words $(d))), \
+ $(d), \
+ $(if $(filter 0,$(words $(d))), \
+ $(error No matches for device "$(dn)"), \
+ $(error Device "$(dn)" ambiguous: matches $(d)) \
+ ) \
+ )
+endef
+
+#
+# $(1): short device name like "sooner"
+#
+define resolve-short-device-name
+$(strip $(call _resolve-short-device-name,$(1)))
+endef
diff --git a/core/dex_preopt.mk b/core/dex_preopt.mk
new file mode 100644
index 0000000000000000000000000000000000000000..5df9dc30a90ae61c7be7bda12a48d7f16c57bdb7
--- /dev/null
+++ b/core/dex_preopt.mk
@@ -0,0 +1,89 @@
+####################################
+# dexpreopt support - typically used on user builds to run dexopt (for Dalvik) or dex2oat (for ART) ahead of time
+#
+####################################
+
+# list of boot classpath jars for dexpreopt
+DEXPREOPT_BOOT_JARS := $(subst $(space),:,$(PRODUCT_BOOT_JARS))
+DEXPREOPT_BOOT_JARS_MODULES := $(PRODUCT_BOOT_JARS)
+PRODUCT_BOOTCLASSPATH := $(subst $(space),:,$(foreach m,$(DEXPREOPT_BOOT_JARS_MODULES),/system/framework/$(m).jar))
+
+PRODUCT_SYSTEM_SERVER_CLASSPATH := $(subst $(space),:,$(foreach m,$(PRODUCT_SYSTEM_SERVER_JARS),/system/framework/$(m).jar))
+
+DEXPREOPT_BUILD_DIR := $(OUT_DIR)
+DEXPREOPT_PRODUCT_DIR_FULL_PATH := $(PRODUCT_OUT)/dex_bootjars
+DEXPREOPT_PRODUCT_DIR := $(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(DEXPREOPT_PRODUCT_DIR_FULL_PATH))
+DEXPREOPT_BOOT_JAR_DIR := system/framework
+DEXPREOPT_BOOT_JAR_DIR_FULL_PATH := $(DEXPREOPT_PRODUCT_DIR_FULL_PATH)/$(DEXPREOPT_BOOT_JAR_DIR)
+
+# The default value for LOCAL_DEX_PREOPT
+DEX_PREOPT_DEFAULT ?= true
+
+# The default filter for which files go into the system_other image (if it is
+# being used). To bundle everything one should set this to '%'
+SYSTEM_OTHER_ODEX_FILTER ?= app/% priv-app/%
+
+# The default values for pre-opting: always preopt PIC.
+# Conditional to building on linux, as dex2oat currently does not work on darwin.
+ifeq ($(HOST_OS),linux)
+ WITH_DEXPREOPT_PIC ?= true
+ WITH_DEXPREOPT ?= true
+# For an eng build only pre-opt the boot image. This gives reasonable performance and still
+# allows a simple workflow: building in frameworks/base and syncing.
+ ifeq (eng,$(TARGET_BUILD_VARIANT))
+ WITH_DEXPREOPT_BOOT_IMG_ONLY ?= true
+ endif
+# Add mini-debug-info to the boot classpath unless explicitly asked not to.
+ ifneq (false,$(WITH_DEXPREOPT_DEBUG_INFO))
+ PRODUCT_DEX_PREOPT_BOOT_FLAGS += --generate-mini-debug-info
+ endif
+endif
+
+GLOBAL_DEXPREOPT_FLAGS :=
+ifeq ($(WITH_DEXPREOPT_PIC),true)
+# Compile boot.oat as position-independent code if WITH_DEXPREOPT_PIC=true
+GLOBAL_DEXPREOPT_FLAGS += --compile-pic
+endif
+
+# $(1): the .jar or .apk to remove classes.dex
+define dexpreopt-remove-classes.dex
+$(hide) zip --quiet --delete $(1) classes.dex; \
+dex_index=2; \
+while zip --quiet --delete $(1) classes$${dex_index}.dex > /dev/null; do \
+ let dex_index=dex_index+1; \
+done
+endef
+
+# Special rules for building stripped boot jars that override java_library.mk rules
+
+# $(1): boot jar module name
+define _dexpreopt-boot-jar-remove-classes.dex
+_dbj_jar_no_dex := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(1)_nodex.jar
+_dbj_src_jar := $(call intermediates-dir-for,JAVA_LIBRARIES,$(1),,COMMON)/javalib.jar
+
+$$(_dbj_jar_no_dex) : $$(_dbj_src_jar) | $(ACP)
+ $$(call copy-file-to-target)
+ifneq ($(DEX_PREOPT_DEFAULT),nostripping)
+ $$(call dexpreopt-remove-classes.dex,$$@)
+endif
+
+_dbj_jar_no_dex :=
+_dbj_src_jar :=
+endef
+
+$(foreach b,$(DEXPREOPT_BOOT_JARS_MODULES),$(eval $(call _dexpreopt-boot-jar-remove-classes.dex,$(b))))
+
+include $(BUILD_SYSTEM)/dex_preopt_libart.mk
+
+# Define dexpreopt-one-file based on current default runtime.
+# $(1): the input .jar or .apk file
+# $(2): the output .odex file
+define dexpreopt-one-file
+$(call dex2oat-one-file,$(1),$(2))
+endef
+
+DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS := $(DEX2OAT_DEPENDENCY)
+DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $(DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
+ifdef TARGET_2ND_ARCH
+$(TARGET_2ND_ARCH_VAR_PREFIX)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT := $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME)
+endif # TARGET_2ND_ARCH
diff --git a/core/dex_preopt_libart.mk b/core/dex_preopt_libart.mk
new file mode 100644
index 0000000000000000000000000000000000000000..acd4a02dd95a51767f46f1f418eb37314a0614cf
--- /dev/null
+++ b/core/dex_preopt_libart.mk
@@ -0,0 +1,130 @@
+####################################
+# dexpreopt support for ART
+#
+####################################
+
+# Default to debug version to help find bugs.
+# Set USE_DEX2OAT_DEBUG to false for only building non-debug versions.
+ifeq ($(USE_DEX2OAT_DEBUG),false)
+DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oat$(HOST_EXECUTABLE_SUFFIX)
+else
+DEX2OAT := $(HOST_OUT_EXECUTABLES)/dex2oatd$(HOST_EXECUTABLE_SUFFIX)
+endif
+
+# Pass special classpath to skip uses library check.
+# Should modify build system to pass used libraries properly later.
+DEX2OAT_CLASSPATH := "&"
+
+DEX2OAT_DEPENDENCY += $(DEX2OAT)
+
+# Use the first preloaded-classes file in PRODUCT_COPY_FILES.
+PRELOADED_CLASSES := $(call word-colon,1,$(firstword \
+ $(filter %system/etc/preloaded-classes,$(PRODUCT_COPY_FILES))))
+
+# Use the first compiled-classes file in PRODUCT_COPY_FILES.
+COMPILED_CLASSES := $(call word-colon,1,$(firstword \
+ $(filter %system/etc/compiled-classes,$(PRODUCT_COPY_FILES))))
+
+# start of image reserved address space
+LIBART_IMG_HOST_BASE_ADDRESS := 0x60000000
+LIBART_IMG_TARGET_BASE_ADDRESS := 0x70000000
+
+define get-product-default-property
+$(strip $(patsubst $(1)=%,%,$(filter $(1)=%,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES))))
+endef
+
+DEX2OAT_IMAGE_XMS := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xms)
+DEX2OAT_IMAGE_XMX := $(call get-product-default-property,dalvik.vm.image-dex2oat-Xmx)
+DEX2OAT_XMS := $(call get-product-default-property,dalvik.vm.dex2oat-Xms)
+DEX2OAT_XMX := $(call get-product-default-property,dalvik.vm.dex2oat-Xmx)
+
+ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),mips mips64))
+# MIPS specific overrides.
+# For MIPS the ART image is loaded at a lower address. This causes issues
+# with the image overlapping with memory on the host cross-compiling and
+# building the image. We therefore limit the Xmx value. This isn't done
+# via a property as we want the larger Xmx value if we're running on a
+# MIPS device.
+LIBART_IMG_TARGET_BASE_ADDRESS := 0x30000000
+DEX2OAT_XMX := 128m
+endif
+
+########################################################################
+# The full system boot classpath
+
+# Returns the path to the .odex file
+# $(1): the arch name.
+# $(2): the full path (including file name) of the corresponding .jar or .apk.
+define get-odex-file-path
+$(dir $(2))oat/$(1)/$(basename $(notdir $(2))).odex
+endef
+
+# Returns the full path to the installed .odex file.
+# This handles BOARD_USES_SYSTEM_OTHER_ODEX to install odex files into another
+# partition.
+# $(1): the arch name.
+# $(2): the full install path (including file name) of the corresponding .apk.
+ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
+define get-odex-installed-file-path
+$(if $(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(2)),
+ $(call get-odex-file-path,$(1),$(patsubst $(TARGET_OUT)/%,$(TARGET_OUT_SYSTEM_OTHER)/%,$(2))),
+ $(call get-odex-file-path,$(1),$(2)))
+endef
+else
+get-odex-installed-file-path = $(get-odex-file-path)
+endif
+
+# Returns the path to the image file (such as "/system/framework//boot.art"
+# $(1): the arch name (such as "arm")
+# $(2): the image location (such as "/system/framework/boot.art")
+define get-image-file-path
+$(dir $(2))$(1)/$(notdir $(2))
+endef
+
+# note we use core-libart.jar in place of core.jar for ART.
+LIBART_TARGET_BOOT_JARS := $(patsubst core, core-libart,$(DEXPREOPT_BOOT_JARS_MODULES))
+LIBART_TARGET_BOOT_DEX_LOCATIONS := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),/$(DEXPREOPT_BOOT_JAR_DIR)/$(jar).jar)
+LIBART_TARGET_BOOT_DEX_FILES := $(foreach jar,$(LIBART_TARGET_BOOT_JARS),$(call intermediates-dir-for,JAVA_LIBRARIES,$(jar),,COMMON)/javalib.jar)
+
+# dex preopt on the bootclasspath produces multiple files. The first dex file
+# is converted into to boot.art (to match the legacy assumption that boot.art
+# exists), and the rest are converted to boot-.art.
+# In addition, each .art file has an associated .oat file.
+LIBART_TARGET_BOOT_ART_EXTRA_FILES := $(foreach jar,$(wordlist 2,999,$(LIBART_TARGET_BOOT_JARS)),boot-$(jar).art boot-$(jar).oat)
+LIBART_TARGET_BOOT_ART_EXTRA_FILES += boot.oat
+
+my_2nd_arch_prefix :=
+include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
+
+ifdef TARGET_2ND_ARCH
+my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/dex_preopt_libart_boot.mk
+my_2nd_arch_prefix :=
+endif
+
+
+########################################################################
+# For a single jar or APK
+
+# $(1): the input .jar or .apk file
+# $(2): the output .odex file
+define dex2oat-one-file
+$(hide) rm -f $(2)
+$(hide) mkdir -p $(dir $(2))
+$(hide) ANDROID_LOG_TAGS="*:e" $(DEX2OAT) \
+ --runtime-arg -Xms$(DEX2OAT_XMS) --runtime-arg -Xmx$(DEX2OAT_XMX) \
+ --runtime-arg -classpath --runtime-arg $(DEX2OAT_CLASSPATH) \
+ --boot-image=$(PRIVATE_DEX_PREOPT_IMAGE_LOCATION) \
+ --dex-file=$(1) \
+ --dex-location=$(PRIVATE_DEX_LOCATION) \
+ --oat-file=$(2) \
+ --android-root=$(PRODUCT_OUT)/system \
+ --instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
+ --instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
+ --instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
+ --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
+ --abort-on-hard-verifier-error \
+ --no-inline-from=core-oj.jar \
+ $(PRIVATE_DEX_PREOPT_FLAGS) \
+ $(GLOBAL_DEXPREOPT_FLAGS)
+endef
diff --git a/core/dex_preopt_libart_boot.mk b/core/dex_preopt_libart_boot.mk
new file mode 100644
index 0000000000000000000000000000000000000000..1a0dc5b07c79764177afbd4489b2db1d68b0eb7c
--- /dev/null
+++ b/core/dex_preopt_libart_boot.mk
@@ -0,0 +1,76 @@
+# Rules to build boot.art
+# Input variables:
+# my_2nd_arch_prefix: indicates if this is to build for the 2nd arch.
+
+# The image "location" is a symbolic path that with multiarchitecture
+# support doesn't really exist on the device. Typically it is
+# /system/framework/boot.art and should be the same for all supported
+# architectures on the device. The concrete architecture specific
+# content actually ends up in a "filename" that contains an
+# architecture specific directory name such as arm, arm64, mips,
+# mips64, x86, x86_64.
+#
+# Here are some example values for an x86_64 / x86 configuration:
+#
+# DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION=out/target/product/generic_x86_64/dex_bootjars/system/framework/boot.art
+# DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME=out/target/product/generic_x86_64/dex_bootjars/system/framework/x86_64/boot.art
+# LIBART_BOOT_IMAGE=/system/framework/x86_64/boot.art
+#
+# 2ND_DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION=out/target/product/generic_x86_64/dex_bootjars/system/framework/boot.art
+# 2ND_DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME=out/target/product/generic_x86_64/dex_bootjars/system/framework/x86/boot.art
+# 2ND_LIBART_BOOT_IMAGE=/system/framework/x86/boot.art
+
+$(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/boot.art
+$(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH)/boot.art
+$(my_2nd_arch_prefix)LIBART_BOOT_IMAGE_FILENAME := /$(DEXPREOPT_BOOT_JAR_DIR)/$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH)/boot.art
+
+# The .oat with symbols
+$(my_2nd_arch_prefix)LIBART_TARGET_BOOT_OAT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)$(patsubst %.art,%.oat,$($(my_2nd_arch_prefix)LIBART_BOOT_IMAGE_FILENAME))
+
+$(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE := $(PRODUCT_OUT)$($(my_2nd_arch_prefix)LIBART_BOOT_IMAGE_FILENAME)
+$(my_2nd_arch_prefix)LIBART_TARGET_BOOT_ART_EXTRA_INSTALLED_FILES := $(addprefix $(dir $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)),\
+ $(LIBART_TARGET_BOOT_ART_EXTRA_FILES))
+
+# If we have a compiled-classes file, create a parameter.
+COMPILED_CLASSES_FLAGS :=
+ifneq ($(COMPILED_CLASSES),)
+ COMPILED_CLASSES_FLAGS := --compiled-classes=$(COMPILED_CLASSES)
+endif
+
+# The rule to install boot.art
+# Depends on installed boot.oat, boot-*.art, boot-*.oat
+$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE) : $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) | $(ACP) $($(my_2nd_arch_prefix)LIBART_TARGET_BOOT_ART_EXTRA_INSTALLED_FILES)
+ @echo "Install: $@"
+ $(copy-file-to-target)
+
+# The rule to install boot.oat, boot-*.art, boot-*.oat
+# Depends on built-but-not-installed boot.art
+$($(my_2nd_arch_prefix)LIBART_TARGET_BOOT_ART_EXTRA_INSTALLED_FILES) : $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) | $(ACP)
+ @echo "Install: $@"
+ @mkdir -p $(dir $@)
+ $(hide) $(ACP) -fp $(dir $<)$(notdir $@) $@
+
+$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME): PRIVATE_2ND_ARCH_VAR_PREFIX := $(my_2nd_arch_prefix)
+# Use dex2oat debug version for better error reporting
+$($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_FILENAME) : $(LIBART_TARGET_BOOT_DEX_FILES) $(DEX2OAT_DEPENDENCY)
+ @echo "target dex2oat: $@"
+ @mkdir -p $(dir $@)
+ @mkdir -p $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))
+ @rm -f $(dir $@)/*.art $(dir $@)/*.oat
+ @rm -f $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))/*.art
+ @rm -f $(dir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED))/*.oat
+ $(hide) ANDROID_LOG_TAGS="*:e" $(DEX2OAT) --runtime-arg -Xms$(DEX2OAT_IMAGE_XMS) \
+ --runtime-arg -Xmx$(DEX2OAT_IMAGE_XMX) \
+ --image-classes=$(PRELOADED_CLASSES) \
+ $(addprefix --dex-file=,$(LIBART_TARGET_BOOT_DEX_FILES)) \
+ $(addprefix --dex-location=,$(LIBART_TARGET_BOOT_DEX_LOCATIONS)) \
+ --oat-symbols=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_TARGET_BOOT_OAT_UNSTRIPPED) \
+ --oat-file=$(patsubst %.art,%.oat,$@) \
+ --oat-location=$(patsubst %.art,%.oat,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)LIBART_BOOT_IMAGE_FILENAME)) \
+ --image=$@ --base=$(LIBART_IMG_TARGET_BASE_ADDRESS) \
+ --instruction-set=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH) \
+ --instruction-set-variant=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT) \
+ --instruction-set-features=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
+ --android-root=$(PRODUCT_OUT)/system --include-patch-information --runtime-arg -Xnorelocate --no-generate-debug-info \
+ --multi-image --no-inline-from=core-oj.jar \
+ $(PRODUCT_DEX_PREOPT_BOOT_FLAGS) $(GLOBAL_DEXPREOPT_FLAGS) $(COMPILED_CLASSES_FLAGS) $(ART_BOOT_IMAGE_EXTRA_ARGS)
diff --git a/core/dex_preopt_odex_install.mk b/core/dex_preopt_odex_install.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b05d4da3d7719ab333f3d4cd0164261947114de7
--- /dev/null
+++ b/core/dex_preopt_odex_install.mk
@@ -0,0 +1,133 @@
+# dexpreopt_odex_install.mk is used to define odex creation rules for JARs and APKs
+# This file depends on variables set in base_rules.mk
+# Output variables: LOCAL_DEX_PREOPT, built_odex, dexpreopt_boot_jar_module
+
+# Setting LOCAL_DEX_PREOPT based on WITH_DEXPREOPT, LOCAL_DEX_PREOPT, etc
+LOCAL_DEX_PREOPT := $(strip $(LOCAL_DEX_PREOPT))
+ifneq (true,$(WITH_DEXPREOPT))
+ LOCAL_DEX_PREOPT :=
+else # WITH_DEXPREOPT=true
+ ifeq (,$(TARGET_BUILD_APPS)) # TARGET_BUILD_APPS empty
+ ifndef LOCAL_DEX_PREOPT # LOCAL_DEX_PREOPT undefined
+ ifneq ($(filter $(TARGET_OUT)/%,$(my_module_path)),) # Installed to system.img.
+ ifeq (,$(LOCAL_APK_LIBRARIES)) # LOCAL_APK_LIBRARIES empty
+ # If we have product-specific config for this module?
+ ifeq (disable,$(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG))
+ LOCAL_DEX_PREOPT := false
+ else
+ LOCAL_DEX_PREOPT := $(DEX_PREOPT_DEFAULT)
+ endif
+ else # LOCAL_APK_LIBRARIES not empty
+ LOCAL_DEX_PREOPT := nostripping
+ endif # LOCAL_APK_LIBRARIES not empty
+ endif # Installed to system.img.
+ endif # LOCAL_DEX_PREOPT undefined
+ endif # TARGET_BUILD_APPS empty
+endif # WITH_DEXPREOPT=true
+ifeq (false,$(LOCAL_DEX_PREOPT))
+ LOCAL_DEX_PREOPT :=
+endif
+ifdef LOCAL_UNINSTALLABLE_MODULE
+LOCAL_DEX_PREOPT :=
+endif
+ifeq (,$(strip $(built_dex)$(my_prebuilt_src_file))) # contains no java code
+LOCAL_DEX_PREOPT :=
+endif
+# if WITH_DEXPREOPT_BOOT_IMG_ONLY=true and module is not in boot class path skip
+ifeq (true,$(WITH_DEXPREOPT_BOOT_IMG_ONLY))
+ifeq ($(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE)),)
+LOCAL_DEX_PREOPT :=
+endif
+endif
+# if installing into system, and odex are being installed into system_other, don't strip
+ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
+ifeq ($(LOCAL_DEX_PREOPT),true)
+ifneq ($(filter $(foreach f,$(SYSTEM_OTHER_ODEX_FILTER),$(TARGET_OUT)/$(f)),$(my_module_path)),)
+LOCAL_DEX_PREOPT := nostripping
+endif
+endif
+endif
+
+built_odex :=
+installed_odex :=
+built_installed_odex :=
+ifdef LOCAL_DEX_PREOPT
+dexpreopt_boot_jar_module := $(filter $(DEXPREOPT_BOOT_JARS_MODULES),$(LOCAL_MODULE))
+ifdef dexpreopt_boot_jar_module
+# For libart, the boot jars' odex files are replaced by $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE).
+# We use this installed_odex trick to get boot.art installed.
+installed_odex := $(DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
+# Append the odex for the 2nd arch if we have one.
+installed_odex += $($(TARGET_2ND_ARCH_VAR_PREFIX)DEFAULT_DEX_PREOPT_INSTALLED_IMAGE)
+else # boot jar
+ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
+# For a Java library, by default we build odex for both 1st arch and 2nd arch.
+# But it can be overridden with "LOCAL_MULTILIB := first".
+ifneq (,$(filter $(PRODUCT_SYSTEM_SERVER_JARS),$(LOCAL_MODULE)))
+# For system server jars, we build for only "first".
+my_module_multilib := first
+else
+my_module_multilib := $(LOCAL_MULTILIB)
+endif
+# #################################################
+# Odex for the 1st arch
+my_2nd_arch_prefix :=
+include $(BUILD_SYSTEM)/setup_one_odex.mk
+# #################################################
+# Odex for the 2nd arch
+ifdef TARGET_2ND_ARCH
+ifneq (first,$(my_module_multilib))
+my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/setup_one_odex.mk
+endif # my_module_multilib is not first.
+endif # TARGET_2ND_ARCH
+# #################################################
+else # must be APPS
+# The preferred arch
+my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/setup_one_odex.mk
+ifdef TARGET_2ND_ARCH
+ifeq ($(LOCAL_MULTILIB),both)
+# The non-preferred arch
+my_2nd_arch_prefix := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),,$(TARGET_2ND_ARCH_VAR_PREFIX))
+include $(BUILD_SYSTEM)/setup_one_odex.mk
+endif # LOCAL_MULTILIB is both
+endif # TARGET_2ND_ARCH
+endif # LOCAL_MODULE_CLASS
+endif # boot jar
+
+built_odex := $(strip $(built_odex))
+installed_odex := $(strip $(installed_odex))
+
+ifdef built_odex
+ifndef LOCAL_DEX_PREOPT_FLAGS
+LOCAL_DEX_PREOPT_FLAGS := $(DEXPREOPT.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
+ifndef LOCAL_DEX_PREOPT_FLAGS
+LOCAL_DEX_PREOPT_FLAGS := $(PRODUCT_DEX_PREOPT_DEFAULT_FLAGS)
+endif
+endif
+
+$(built_odex): PRIVATE_DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
+endif
+
+# Add the installed_odex to the list of installed files for this module.
+ALL_MODULES.$(my_register_name).INSTALLED += $(installed_odex)
+ALL_MODULES.$(my_register_name).BUILT_INSTALLED += $(built_installed_odex)
+
+# Record dex-preopt config.
+DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT := $(LOCAL_DEX_PREOPT)
+DEXPREOPT.$(LOCAL_MODULE).MULTILIB := $(LOCAL_MULTILIB)
+DEXPREOPT.$(LOCAL_MODULE).DEX_PREOPT_FLAGS := $(LOCAL_DEX_PREOPT_FLAGS)
+DEXPREOPT.$(LOCAL_MODULE).PRIVILEGED_MODULE := $(LOCAL_PRIVILEGED_MODULE)
+DEXPREOPT.$(LOCAL_MODULE).PROPRIETARY_MODULE := $(LOCAL_PROPRIETARY_MODULE)
+DEXPREOPT.$(LOCAL_MODULE).TARGET_ARCH := $(LOCAL_MODULE_TARGET_ARCH)
+DEXPREOPT.$(LOCAL_MODULE).INSTALLED := $(installed_odex)
+DEXPREOPT.$(LOCAL_MODULE).INSTALLED_STRIPPED := $(LOCAL_INSTALLED_MODULE)
+DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS) := $(sort \
+ $(DEXPREOPT.MODULES.$(LOCAL_MODULE_CLASS)) $(LOCAL_MODULE))
+
+
+# Make sure to install the .odex when you run "make "
+$(my_register_name): $(installed_odex)
+
+endif # LOCAL_DEX_PREOPT
diff --git a/core/distdir.mk b/core/distdir.mk
new file mode 100644
index 0000000000000000000000000000000000000000..51ec46efeff943d861b051ba86ee2befa77d2c13
--- /dev/null
+++ b/core/distdir.mk
@@ -0,0 +1,79 @@
+#
+# 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.
+#
+
+# When specifying "dist", the user has asked that we copy the important
+# files from this build into DIST_DIR.
+
+.PHONY: dist
+dist: ;
+
+dist_goal := $(strip $(filter dist,$(MAKECMDGOALS)))
+MAKECMDGOALS := $(strip $(filter-out dist,$(MAKECMDGOALS)))
+ifeq (,$(strip $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))))
+# The commandline was something like "make dist" or "make dist showcommands".
+# Add a dependency on a real target.
+dist: $(DEFAULT_GOAL)
+endif
+
+ifdef dist_goal
+
+# $(1): source file
+# $(2): destination file
+# $(3): goals that should copy the file
+#
+define copy-one-dist-file
+$(3): $(2)
+$(2): $(1)
+ @echo "Dist: $$@"
+ $$(copy-file-to-new-target-with-cp)
+endef
+
+# A global variable to remember all dist'ed src:dst pairs.
+# So if a src:dst is already dist'ed by another goal,
+# we should just establish the dependency and don't really call the
+# copy-one-dist-file to avoid multiple rules for the same target.
+_all_dist_src_dst_pairs :=
+# Other parts of the system should use this function to associate
+# certain files with certain goals. When those goals are built
+# and "dist" is specified, the marked files will be copied to DIST_DIR.
+#
+# $(1): a list of goals (e.g. droid, sdk, pdk, ndk)
+# $(2): the dist files to add to those goals. If the file contains ':',
+# the text following the colon is the name that the file is copied
+# to under the dist directory. Subdirs are ok, and will be created
+# at copy time if necessary.
+define dist-for-goals
+$(foreach file,$(2), \
+ $(eval fw := $(subst :,$(space),$(file))) \
+ $(eval src := $(word 1,$(fw))) \
+ $(eval dst := $(word 2,$(fw))) \
+ $(eval dst := $(if $(dst),$(dst),$(notdir $(src)))) \
+ $(if $(filter $(_all_dist_src_dst_pairs),$(src):$(dst)),\
+ $(eval $(call add-dependency,$(1),$(DIST_DIR)/$(dst))),\
+ $(eval $(call copy-one-dist-file,\
+ $(src),$(DIST_DIR)/$(dst),$(1)))\
+ $(eval _all_dist_src_dst_pairs += $(src):$(dst))\
+ )\
+)
+endef
+
+else # !dist_goal
+
+# empty definition when not building dist
+define dist-for-goals
+endef
+
+endif # !dist_goal
diff --git a/core/dpi_specific_apk.mk b/core/dpi_specific_apk.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6bae25d96289c98b001d91178ab2e3b0c0d253cc
--- /dev/null
+++ b/core/dpi_specific_apk.mk
@@ -0,0 +1,82 @@
+# Set up rules to build dpi-specific apk, with whatever else from the base apk.
+# Input variable: my_dpi, and all other variables set up in package_internal.mk.
+#
+
+dpi_apk_name := $(LOCAL_MODULE)_$(my_dpi)
+dpi_intermediate := $(call intermediates-dir-for,APPS,$(dpi_apk_name))
+built_dpi_apk := $(dpi_intermediate)/package.apk
+
+# Set up all the target-specific variables.
+$(built_dpi_apk): PRIVATE_MODULE := $(dpi_apk_name)
+$(built_dpi_apk): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) $(PRODUCT_AAPT_FLAGS) $($(LOCAL_PACKAGE_NAME)_aapt_flags_$(my_dpi))
+# Clear PRIVATE_PRODUCT_AAPT_CONFIG to include everything by default.
+$(built_dpi_apk): PRIVATE_PRODUCT_AAPT_CONFIG :=
+$(built_dpi_apk): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(my_dpi)
+$(built_dpi_apk): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
+$(built_dpi_apk): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
+$(built_dpi_apk): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
+$(built_dpi_apk): PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
+ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
+$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
+else
+$(built_dpi_apk): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
+endif
+$(built_dpi_apk): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME)
+$(built_dpi_apk): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_INSTRUMENTATION_FOR)
+$(built_dpi_apk): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)
+$(built_dpi_apk): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
+$(built_dpi_apk): PRIVATE_PRIVATE_KEY := $(private_key)
+$(built_dpi_apk): PRIVATE_CERTIFICATE := $(certificate)
+$(built_dpi_apk): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\
+ $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
+
+$(built_dpi_apk): PRIVATE_SOURCE_ARCHIVE :=
+ifneq ($(full_classes_jar),)
+$(built_dpi_apk): PRIVATE_DEX_FILE := $(built_dex)
+ifndef LOCAL_JACK_ENABLED
+# Use the jarjar processed arhive as the initial package file.
+$(built_dpi_apk): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
+else
+$(built_dpi_apk): PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
+endif # LOCAL_JACK_ENABLED
+$(built_dpi_apk): $(built_dex)
+else
+$(built_dpi_apk): PRIVATE_DEX_FILE :=
+endif # full_classes_jar
+
+# Set up dependenncies and the build recipe.
+$(built_dpi_apk) : $(R_file_stamp)
+$(built_dpi_apk) : $(all_library_res_package_export_deps)
+$(built_dpi_apk) : $(private_key) $(certificate) $(SIGNAPK_JAR)
+$(built_dpi_apk) : $(AAPT)
+$(built_dpi_apk) : $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
+ @echo "target Package: $(PRIVATE_MODULE) ($@)"
+ $(if $(PRIVATE_SOURCE_ARCHIVE),\
+ $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\
+ $(create-empty-package))
+ $(add-assets-to-package)
+ifneq ($(jni_shared_libraries),)
+ $(add-jni-shared-libs-to-package)
+endif
+ifeq ($(full_classes_jar),)
+# We don't build jar, need to add the Java resources here.
+ $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
+else
+ $(add-dex-to-package)
+ifdef LOCAL_JACK_ENABLED
+ $(add-carried-jack-resources)
+endif
+endif
+ $(sign-package)
+
+# Set up global variables to register this apk to the higher-level dependency graph.
+ALL_MODULES += $(dpi_apk_name)
+ALL_MODULES.$(dpi_apk_name).CLASS := APPS
+ALL_MODULES.$(dpi_apk_name).BUILT := $(built_dpi_apk)
+PACKAGES := $(PACKAGES) $(dpi_apk_name)
+PACKAGES.$(dpi_apk_name).PRIVATE_KEY := $(private_key)
+PACKAGES.$(dpi_apk_name).CERTIFICATE := $(certificate)
+
+# Phony targets used by "apps_only".
+.PHONY: $(dpi_apk_name)
+$(dpi_apk_name) : $(built_dpi_apk)
diff --git a/core/droiddoc.mk b/core/droiddoc.mk
new file mode 100644
index 0000000000000000000000000000000000000000..f1435790f212094a9f61772e84e05e64ff51eb14
--- /dev/null
+++ b/core/droiddoc.mk
@@ -0,0 +1,257 @@
+#
+# 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.
+#
+
+##
+##
+## Common to both droiddoc and javadoc
+##
+##
+
+LOCAL_IS_HOST_MODULE := $(call true-or-empty,$(LOCAL_IS_HOST_MODULE))
+ifeq ($(LOCAL_IS_HOST_MODULE),true)
+my_prefix := HOST_
+LOCAL_HOST_PREFIX :=
+else
+my_prefix := TARGET_
+endif
+
+LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
+ifndef LOCAL_MODULE_CLASS
+$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined)
+endif
+
+full_src_files := $(patsubst %,$(LOCAL_PATH)/%,$(LOCAL_SRC_FILES))
+out_dir := $(OUT_DOCS)/$(LOCAL_MODULE)
+full_target := $(call doc-timestamp-for,$(LOCAL_MODULE))
+
+ifeq ($(LOCAL_DROIDDOC_SOURCE_PATH),)
+LOCAL_DROIDDOC_SOURCE_PATH := $(LOCAL_PATH)
+endif
+
+ifeq ($(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR),)
+LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR := $(SRC_DROIDDOC_DIR)/$(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)
+endif
+
+ifeq ($(LOCAL_DROIDDOC_ASSET_DIR),)
+LOCAL_DROIDDOC_ASSET_DIR := assets
+endif
+ifeq ($(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR),)
+LOCAL_DROIDDOC_CUSTOM_ASSET_DIR := assets
+endif
+
+ifeq ($(LOCAL_IS_HOST_MODULE),true)
+$(full_target): PRIVATE_BOOTCLASSPATH :=
+full_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
+ $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
+full_java_lib_deps := $(full_java_libs)
+
+else
+
+ifneq ($(LOCAL_SDK_VERSION),)
+ ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
+ # Use android_stubs_current if LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
+ LOCAL_JAVA_LIBRARIES := android_stubs_current $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_stubs_current)
+ else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
+ LOCAL_JAVA_LIBRARIES := android_system_stubs_current $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_system_stubs_current)
+ else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current)
+ LOCAL_JAVA_LIBRARIES := android_test_stubs_current $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, android_test_stubs_current)
+ else
+ LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, sdk_v$(LOCAL_SDK_VERSION))
+ endif
+else
+ LOCAL_JAVA_LIBRARIES := core-oj core-libart ext framework $(LOCAL_JAVA_LIBRARIES)
+ $(full_target): PRIVATE_BOOTCLASSPATH := $(call java-lib-files, core-oj):$(call java-lib-files, core-libart)
+endif # LOCAL_SDK_VERSION
+LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES))
+
+full_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH)
+full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES)) $(LOCAL_CLASSPATH)
+endif # !LOCAL_IS_HOST_MODULE
+
+$(full_target): PRIVATE_CLASSPATH := $(subst $(space),:,$(full_java_libs))
+
+
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
+
+$(full_target): PRIVATE_SOURCE_PATH := $(call normalize-path-list,$(LOCAL_DROIDDOC_SOURCE_PATH))
+$(full_target): PRIVATE_JAVA_FILES := $(filter %.java,$(full_src_files))
+$(full_target): PRIVATE_JAVA_FILES += $(addprefix $($(my_prefix)OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
+$(full_target): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
+$(full_target): PRIVATE_SRC_LIST_FILE := $(intermediates.COMMON)/droiddoc-src-list
+
+ifneq ($(strip $(LOCAL_ADDITIONAL_JAVA_DIR)),)
+$(full_target): PRIVATE_ADDITIONAL_JAVA_DIR := $(LOCAL_ADDITIONAL_JAVA_DIR)
+endif
+
+$(full_target): PRIVATE_OUT_DIR := $(out_dir)
+$(full_target): PRIVATE_DROIDDOC_OPTIONS := $(LOCAL_DROIDDOC_OPTIONS)
+$(full_target): PRIVATE_STUB_OUT_DIR := $(LOCAL_DROIDDOC_STUB_OUT_DIR)
+
+# Lists the input files for the doc build into a text file
+# suitable for the @ syntax of javadoc.
+# $(1): the file to create
+# $(2): files to include
+# $(3): list of directories to search for java files in
+define prepare-doc-source-list
+$(hide) mkdir -p $(dir $(1))
+$(call dump-words-to-file, $(2), $(1))
+$(hide) for d in $(3) ; do find $$d -name '*.java' -and -not -name '.*' >> $(1) 2> /dev/null ; done ; true
+endef
+
+ifeq (a,b)
+$(full_target): PRIVATE_PROFILING_OPTIONS := \
+ -J-agentlib:jprofilerti=port=8849 -J-Xbootclasspath/a:/Applications/jprofiler5/bin/agent.jar
+endif
+
+
+ifneq ($(strip $(LOCAL_DROIDDOC_USE_STANDARD_DOCLET)),true)
+##
+##
+## droiddoc only
+##
+##
+
+droiddoc_templates := \
+ $(sort $(shell find $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR) -type f))
+
+droiddoc := \
+ $(HOST_JDK_TOOLS_JAR) \
+ $(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
+
+$(full_target): PRIVATE_DOCLETPATH := $(HOST_OUT_JAVA_LIBRARIES)/jsilver$(COMMON_JAVA_PACKAGE_SUFFIX):$(HOST_OUT_JAVA_LIBRARIES)/doclava$(COMMON_JAVA_PACKAGE_SUFFIX)
+$(full_target): PRIVATE_CURRENT_BUILD := -hdf page.build $(BUILD_ID)-$(BUILD_NUMBER_FROM_FILE)
+$(full_target): PRIVATE_CURRENT_TIME := -hdf page.now "$$($(DATE_FROM_FILE) "+%d %b %Y %k:%M")"
+$(full_target): PRIVATE_CUSTOM_TEMPLATE_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)
+$(full_target): PRIVATE_IN_CUSTOM_ASSET_DIR := $(LOCAL_DROIDDOC_CUSTOM_TEMPLATE_DIR)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR)
+$(full_target): PRIVATE_OUT_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_ASSET_DIR)
+$(full_target): PRIVATE_OUT_CUSTOM_ASSET_DIR := $(out_dir)/$(LOCAL_DROIDDOC_CUSTOM_ASSET_DIR)
+
+html_dir_files :=
+ifneq ($(strip $(LOCAL_DROIDDOC_HTML_DIR)),)
+$(full_target): PRIVATE_DROIDDOC_HTML_DIR := -htmldir $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR)
+html_dir_files := $(sort $(shell find $(LOCAL_PATH)/$(LOCAL_DROIDDOC_HTML_DIR) -type f))
+else
+$(full_target): PRIVATE_DROIDDOC_HTML_DIR :=
+endif
+ifneq ($(strip $(LOCAL_ADDITIONAL_HTML_DIR)),)
+$(full_target): PRIVATE_ADDITIONAL_HTML_DIR := -htmldir2 $(LOCAL_PATH)/$(LOCAL_ADDITIONAL_HTML_DIR)
+else
+$(full_target): PRIVATE_ADDITIONAL_HTML_DIR :=
+endif
+
+# TODO: not clear if this is used any more
+$(full_target): PRIVATE_LOCAL_PATH := $(LOCAL_PATH)
+
+$(full_target): \
+ $(full_src_files) \
+ $(droiddoc_templates) \
+ $(droiddoc) \
+ $(html_dir_files) \
+ $(full_java_lib_deps) \
+ $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ @echo Docs droiddoc: $(PRIVATE_OUT_DIR)
+ $(hide) mkdir -p $(dir $@)
+ $(addprefix $(hide) rm -rf ,$(PRIVATE_STUB_OUT_DIR))
+ $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
+ $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR))
+ $(hide) ( \
+ javadoc \
+ -encoding UTF-8 \
+ \@$(PRIVATE_SRC_LIST_FILE) \
+ -J-Xmx1600m \
+ -XDignore.symbol.file \
+ $(PRIVATE_PROFILING_OPTIONS) \
+ -quiet \
+ -doclet com.google.doclava.Doclava \
+ -docletpath $(PRIVATE_DOCLETPATH) \
+ -templatedir $(PRIVATE_CUSTOM_TEMPLATE_DIR) \
+ $(PRIVATE_DROIDDOC_HTML_DIR) \
+ $(PRIVATE_ADDITIONAL_HTML_DIR) \
+ $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \
+ $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
+ -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \
+ -d $(PRIVATE_OUT_DIR) \
+ $(PRIVATE_CURRENT_BUILD) $(PRIVATE_CURRENT_TIME) \
+ $(PRIVATE_DROIDDOC_OPTIONS) \
+ $(addprefix -stubs ,$(PRIVATE_STUB_OUT_DIR)) \
+ && touch -f $@ \
+ ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45)
+
+
+
+else
+##
+##
+## standard doclet only
+##
+##
+$(full_target): $(full_src_files) $(full_java_lib_deps)
+ @echo Docs javadoc: $(PRIVATE_OUT_DIR)
+ @mkdir -p $(dir $@)
+ $(call prepare-doc-source-list,$(PRIVATE_SRC_LIST_FILE),$(PRIVATE_JAVA_FILES), \
+ $(PRIVATE_SOURCE_INTERMEDIATES_DIR) $(PRIVATE_ADDITIONAL_JAVA_DIR))
+ $(hide) ( \
+ javadoc \
+ -encoding UTF-8 \
+ $(PRIVATE_DROIDDOC_OPTIONS) \
+ \@$(PRIVATE_SRC_LIST_FILE) \
+ -J-Xmx1024m \
+ -XDignore.symbol.file \
+ $(if $(LEGACY_USE_JAVA7),,-Xdoclint:none) \
+ $(PRIVATE_PROFILING_OPTIONS) \
+ $(addprefix -classpath ,$(PRIVATE_CLASSPATH)) \
+ $(addprefix -bootclasspath ,$(PRIVATE_BOOTCLASSPATH)) \
+ -sourcepath $(PRIVATE_SOURCE_PATH)$(addprefix :,$(PRIVATE_CLASSPATH)) \
+ -d $(PRIVATE_OUT_DIR) \
+ -quiet \
+ && touch -f $@ \
+ ) || (rm -rf $(PRIVATE_OUT_DIR) $(PRIVATE_SRC_LIST_FILE); exit 45)
+
+
+endif
+##
+##
+## Common to both droiddoc and javadoc
+##
+##
+
+
+ALL_DOCS += $(full_target)
+
+.PHONY: $(LOCAL_MODULE)-docs
+$(LOCAL_MODULE)-docs : $(full_target)
+
+ifeq ($(strip $(LOCAL_UNINSTALLABLE_MODULE)),)
+
+# Define a rule to create a zip of these docs.
+out_zip := $(OUT_DOCS)/$(LOCAL_MODULE)-docs.zip
+$(out_zip): PRIVATE_DOCS_DIR := $(out_dir)
+$(out_zip): $(full_target)
+ @echo Package docs: $@
+ @rm -f $@
+ @mkdir -p $(dir $@)
+ $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_DOCS_DIR) && zip -rqX $$F * )
+
+$(LOCAL_MODULE)-docs.zip : $(out_zip)
+
+$(call dist-for-goals,docs,$(out_zip))
+
+endif
diff --git a/core/dumpvar.mk b/core/dumpvar.mk
new file mode 100644
index 0000000000000000000000000000000000000000..1bd477765d4ceea1b1fecc9108159352ab275550
--- /dev/null
+++ b/core/dumpvar.mk
@@ -0,0 +1,123 @@
+
+# List of variables we want to print in the build banner.
+print_build_config_vars := \
+ PLATFORM_VERSION_CODENAME \
+ PLATFORM_VERSION \
+ TARGET_PRODUCT \
+ TARGET_BUILD_VARIANT \
+ TARGET_BUILD_TYPE \
+ TARGET_BUILD_APPS \
+ TARGET_ARCH \
+ TARGET_ARCH_VARIANT \
+ TARGET_CPU_VARIANT \
+ TARGET_2ND_ARCH \
+ TARGET_2ND_ARCH_VARIANT \
+ TARGET_2ND_CPU_VARIANT \
+ HOST_ARCH \
+ HOST_2ND_ARCH \
+ HOST_OS \
+ HOST_OS_EXTRA \
+ HOST_CROSS_OS \
+ HOST_CROSS_ARCH \
+ HOST_CROSS_2ND_ARCH \
+ HOST_BUILD_TYPE \
+ BUILD_ID \
+ OUT_DIR
+
+ifeq ($(TARGET_BUILD_PDK),true)
+print_build_config_vars += \
+ TARGET_BUILD_PDK \
+ PDK_FUSION_PLATFORM_ZIP
+endif
+
+# ---------------------------------------------------------------
+# the setpath shell function in envsetup.sh uses this to figure out
+# what to add to the path given the config we have chosen.
+ifeq ($(CALLED_FROM_SETUP),true)
+
+ifneq ($(filter /%,$(HOST_OUT_EXECUTABLES)),)
+ABP:=$(HOST_OUT_EXECUTABLES)
+else
+ABP:=$(PWD)/$(HOST_OUT_EXECUTABLES)
+endif
+
+ANDROID_BUILD_PATHS := $(ABP)
+ANDROID_PREBUILTS := prebuilt/$(HOST_PREBUILT_TAG)
+ANDROID_GCC_PREBUILTS := prebuilts/gcc/$(HOST_PREBUILT_TAG)
+
+# The "dumpvar" stuff lets you say something like
+#
+# CALLED_FROM_SETUP=true \
+# make -f config/envsetup.make dumpvar-TARGET_OUT
+# or
+# CALLED_FROM_SETUP=true \
+# make -f config/envsetup.make dumpvar-abs-HOST_OUT_EXECUTABLES
+#
+# The plain (non-abs) version just dumps the value of the named variable.
+# The "abs" version will treat the variable as a path, and dumps an
+# absolute path to it.
+#
+dumpvar_goals := \
+ $(strip $(patsubst dumpvar-%,%,$(filter dumpvar-%,$(MAKECMDGOALS))))
+ifdef dumpvar_goals
+
+ ifneq ($(words $(dumpvar_goals)),1)
+ $(error Only one "dumpvar-" goal allowed. Saw "$(MAKECMDGOALS)")
+ endif
+
+ # If the goal is of the form "dumpvar-abs-VARNAME", then
+ # treat VARNAME as a path and return the absolute path to it.
+ absolute_dumpvar := $(strip $(filter abs-%,$(dumpvar_goals)))
+ ifdef absolute_dumpvar
+ dumpvar_goals := $(patsubst abs-%,%,$(dumpvar_goals))
+ DUMPVAR_VALUE := $(abspath $($(dumpvar_goals)))
+ dumpvar_target := dumpvar-abs-$(dumpvar_goals)
+ else
+ DUMPVAR_VALUE := $($(dumpvar_goals))
+ dumpvar_target := dumpvar-$(dumpvar_goals)
+ endif
+
+.PHONY: $(dumpvar_target)
+$(dumpvar_target):
+ @echo $(DUMPVAR_VALUE)
+
+endif # dumpvar_goals
+
+ifneq ($(dumpvar_goals),report_config)
+PRINT_BUILD_CONFIG:=
+endif
+
+ifneq ($(filter report_config,$(DUMP_MANY_VARS)),)
+# Construct the shell commands that print the config banner.
+report_config_sh := echo '============================================';
+report_config_sh += $(foreach v,$(print_build_config_vars),echo '$v=$($(v))';)
+report_config_sh += echo '============================================';
+endif
+
+# Dump mulitple variables to "=" pairs, one per line.
+# The output may be executed as bash script.
+# Input variables:
+# DUMP_MANY_VARS: the list of variable names.
+# DUMP_VAR_PREFIX: an optional prefix of the variable name added to the output.
+# DUMP_MANY_ABS_VARS: the list of abs variable names.
+# DUMP_ABS_VAR_PREFIX: an optional prefix of the abs variable name added to the output.
+.PHONY: dump-many-vars
+dump-many-vars :
+ @$(foreach v, $(filter-out report_config, $(DUMP_MANY_VARS)),\
+ echo "$(DUMP_VAR_PREFIX)$(v)='$($(v))'";)
+ifneq ($(filter report_config, $(DUMP_MANY_VARS)),)
+ @# Construct a special variable for report_config.
+ @# Escape \` to defer the execution of report_config_sh to preserve the line breaks.
+ @echo "$(DUMP_VAR_PREFIX)report_config=\`$(report_config_sh)\`"
+endif
+ @$(foreach v, $(sort $(DUMP_MANY_ABS_VARS)),\
+ echo "$(DUMP_ABS_VAR_PREFIX)$(v)='$(abspath $($(v)))'";)
+
+endif # CALLED_FROM_SETUP
+
+ifneq ($(PRINT_BUILD_CONFIG),)
+$(info ============================================)
+$(foreach v, $(print_build_config_vars),\
+ $(info $v=$($(v))))
+$(info ============================================)
+endif
diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk
new file mode 100644
index 0000000000000000000000000000000000000000..91fd27131f13e19b771354fbc538a7719969ba06
--- /dev/null
+++ b/core/dynamic_binary.mk
@@ -0,0 +1,169 @@
+###########################################################
+## Standard rules for building any target-side binaries
+## with dynamic linkage (dynamic libraries or executables
+## that link with dynamic libraries)
+##
+## Files including this file must define a rule to build
+## the target $(linked_module).
+###########################################################
+
+# This constraint means that we can hard-code any $(TARGET_*) variables.
+ifdef LOCAL_IS_HOST_MODULE
+$(error This file should not be used to build host binaries. Included by (or near) $(lastword $(filter-out config/%,$(MAKEFILE_LIST))))
+endif
+
+# The name of the target file, without any path prepended.
+# This duplicates logic from base_rules.mk because we need to
+# know its results before base_rules.mk is included.
+include $(BUILD_SYSTEM)/configure_module_stem.mk
+
+intermediates := $(call local-intermediates-dir,,$(LOCAL_2ND_ARCH_VAR_PREFIX))
+
+# Define the target that is the unmodified output of the linker.
+# The basename of this target must be the same as the final output
+# binary name, because it's used to set the "soname" in the binary.
+# The includer of this file will define a rule to build this target.
+linked_module := $(intermediates)/LINKED/$(my_built_module_stem)
+
+ALL_ORIGINAL_DYNAMIC_BINARIES += $(linked_module)
+
+# Because TARGET_SYMBOL_FILTER_FILE depends on ALL_ORIGINAL_DYNAMIC_BINARIES,
+# the linked_module rules won't necessarily inherit the PRIVATE_
+# variables from LOCAL_BUILT_MODULE. This tells binary.make to explicitly
+# define the PRIVATE_ variables for linked_module as well as for
+# LOCAL_BUILT_MODULE.
+LOCAL_INTERMEDIATE_TARGETS := $(linked_module)
+
+###################################
+include $(BUILD_SYSTEM)/binary.mk
+###################################
+
+###########################################################
+## Pack relocation tables
+###########################################################
+relocation_packer_input := $(linked_module)
+relocation_packer_output := $(intermediates)/PACKED/$(my_built_module_stem)
+
+my_pack_module_relocations := false
+ifneq ($(DISABLE_RELOCATION_PACKER),true)
+ my_pack_module_relocations := $(firstword \
+ $(LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
+ $(LOCAL_PACK_MODULE_RELOCATIONS))
+endif
+
+ifeq ($(my_pack_module_relocations),)
+ my_pack_module_relocations := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PACK_MODULE_RELOCATIONS)
+endif
+
+# Do not pack relocations for executables. Because packing results in
+# non-zero p_vaddr which causes kernel to load executables to lower
+# address (starting at 0x8000) http://b/20665974
+ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+ my_pack_module_relocations := false
+endif
+
+# TODO (dimitry): Relocation packer is not yet available for darwin
+ifneq ($(HOST_OS),linux)
+ my_pack_module_relocations := false
+endif
+
+ifeq (true,$(my_pack_module_relocations))
+# Pack relocations
+$(relocation_packer_output): $(relocation_packer_input) | $(ACP)
+ $(pack-elf-relocations)
+else
+$(relocation_packer_output): $(relocation_packer_input) | $(ACP)
+ @echo "target Unpacked: $(PRIVATE_MODULE) ($@)"
+ $(copy-file-to-target)
+endif
+
+###########################################################
+## Store a copy with symbols for symbolic debugging
+###########################################################
+ifeq ($(LOCAL_UNSTRIPPED_PATH),)
+my_unstripped_path := $(TARGET_OUT_UNSTRIPPED)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
+else
+my_unstripped_path := $(LOCAL_UNSTRIPPED_PATH)
+endif
+symbolic_input := $(relocation_packer_output)
+symbolic_output := $(my_unstripped_path)/$(my_installed_module_stem)
+$(symbolic_output) : $(symbolic_input) | $(ACP)
+ @echo "target Symbolic: $(PRIVATE_MODULE) ($@)"
+ $(copy-file-to-target)
+
+###########################################################
+## Store breakpad symbols
+###########################################################
+
+ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
+my_breakpad_path := $(TARGET_OUT_BREAKPAD)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
+breakpad_input := $(relocation_packer_output)
+breakpad_output := $(my_breakpad_path)/$(my_installed_module_stem).sym
+$(breakpad_output) : $(breakpad_input) | $(BREAKPAD_DUMP_SYMS)
+ @echo "target breakpad: $(PRIVATE_MODULE) ($@)"
+ @mkdir -p $(dir $@)
+ $(hide) $(BREAKPAD_DUMP_SYMS) -c $< > $@
+$(LOCAL_BUILT_MODULE) : $(breakpad_output)
+endif
+
+###########################################################
+## Strip
+###########################################################
+strip_input := $(symbolic_output)
+strip_output := $(LOCAL_BUILT_MODULE)
+
+my_strip_module := $(firstword \
+ $(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
+ $(LOCAL_STRIP_MODULE))
+ifeq ($(my_strip_module),)
+ my_strip_module := true
+endif
+
+$(strip_output): PRIVATE_STRIP := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
+$(strip_output): PRIVATE_OBJCOPY := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OBJCOPY)
+$(strip_output): PRIVATE_READELF := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_READELF)
+ifeq ($(my_strip_module),no_debuglink)
+$(strip_output): PRIVATE_NO_DEBUGLINK := true
+else
+$(strip_output): PRIVATE_NO_DEBUGLINK :=
+endif
+
+ifneq ($(filter true no_debuglink,$(my_strip_module)),)
+# Strip the binary
+$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
+ $(transform-to-stripped)
+else ifeq ($(my_strip_module),keep_symbols)
+# Strip only the debug frames, but leave the symbol table.
+$(strip_output): $(strip_input) | $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP)
+ $(transform-to-stripped-keep-symbols)
+
+# A product may be configured to strip everything in some build variants.
+# We do the stripping as a post-install command so that LOCAL_BUILT_MODULE
+# is still with the symbols and we don't need to clean it (and relink) when
+# you switch build variant.
+ifneq ($(filter $(STRIP_EVERYTHING_BUILD_VARIANTS),$(TARGET_BUILD_VARIANT)),)
+$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := \
+ $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_STRIP) --strip-all $(LOCAL_INSTALLED_MODULE)
+endif
+else
+# Don't strip the binary, just copy it. We can't skip this step
+# because a copy of the binary must appear at LOCAL_BUILT_MODULE.
+#
+# If the binary we're copying is acp or a prerequisite,
+# use cp(1) instead.
+ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
+$(strip_output): $(strip_input) | $(ACP)
+ @echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
+ $(copy-file-to-target)
+else
+$(strip_output): $(strip_input)
+ @echo "target Unstripped: $(PRIVATE_MODULE) ($@)"
+ $(copy-file-to-target-with-cp)
+endif
+endif # my_strip_module
+
+$(cleantarget): PRIVATE_CLEAN_FILES += \
+ $(linked_module) \
+ $(breakpad_output) \
+ $(symbolic_output) \
+ $(strip_output)
diff --git a/core/envsetup.mk b/core/envsetup.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6cfb6a1555a12cc71625ef131d9827fa7281782c
--- /dev/null
+++ b/core/envsetup.mk
@@ -0,0 +1,470 @@
+# Variables we check:
+# HOST_BUILD_TYPE = { release debug }
+# TARGET_BUILD_TYPE = { release debug }
+# and we output a bunch of variables, see the case statement at
+# the bottom for the full list
+# OUT_DIR is also set to "out" if it's not already set.
+# this allows you to set it to somewhere else if you like
+# SCAN_EXCLUDE_DIRS is an optional, whitespace separated list of
+# directories that will also be excluded from full checkout tree
+# searches for source or make files, in addition to OUT_DIR.
+# This can be useful if you set OUT_DIR to be a different directory
+# than other outputs of your build system.
+
+# Set up version information.
+include $(BUILD_SYSTEM)/version_defaults.mk
+
+# ---------------------------------------------------------------
+# If you update the build system such that the environment setup
+# or buildspec.mk need to be updated, increment this number, and
+# people who haven't re-run those will have to do so before they
+# can build. Make sure to also update the corresponding value in
+# buildspec.mk.default and envsetup.sh.
+CORRECT_BUILD_ENV_SEQUENCE_NUMBER := 10
+
+# ---------------------------------------------------------------
+# The product defaults to generic on hardware
+# NOTE: This will be overridden in product_config.mk if make
+# was invoked with a PRODUCT-xxx-yyy goal.
+ifeq ($(TARGET_PRODUCT),)
+TARGET_PRODUCT := aosp_arm
+endif
+
+
+# the variant -- the set of files that are included for a build
+ifeq ($(strip $(TARGET_BUILD_VARIANT)),)
+TARGET_BUILD_VARIANT := eng
+endif
+
+# ---------------------------------------------------------------
+# Set up configuration for host machine. We don't do cross-
+# compiles except for arm/mips, so the HOST is whatever we are
+# running on
+
+UNAME := $(shell uname -sm)
+
+# HOST_OS
+ifneq (,$(findstring Linux,$(UNAME)))
+ HOST_OS := linux
+endif
+ifneq (,$(findstring Darwin,$(UNAME)))
+ HOST_OS := darwin
+endif
+ifneq (,$(findstring Macintosh,$(UNAME)))
+ HOST_OS := darwin
+endif
+
+HOST_OS_EXTRA:=$(shell python -c "import platform; print(platform.platform())")
+
+# BUILD_OS is the real host doing the build.
+BUILD_OS := $(HOST_OS)
+
+HOST_CROSS_OS :=
+# We can cross-build Windows binaries on Linux
+ifeq ($(HOST_OS),linux)
+HOST_CROSS_OS := windows
+HOST_CROSS_ARCH := x86
+HOST_CROSS_2ND_ARCH := x86_64
+endif
+
+ifeq ($(HOST_OS),)
+$(error Unable to determine HOST_OS from uname -sm: $(UNAME)!)
+endif
+
+# HOST_ARCH
+ifneq (,$(findstring x86_64,$(UNAME)))
+ HOST_ARCH := x86_64
+ HOST_2ND_ARCH := x86
+ HOST_IS_64_BIT := true
+else
+ifneq (,$(findstring x86,$(UNAME)))
+$(error Building on a 32-bit x86 host is not supported: $(UNAME)!)
+endif
+endif
+
+BUILD_ARCH := $(HOST_ARCH)
+BUILD_2ND_ARCH := $(HOST_2ND_ARCH)
+
+ifeq ($(HOST_ARCH),)
+$(error Unable to determine HOST_ARCH from uname -sm: $(UNAME)!)
+endif
+
+# the host build defaults to release, and it must be release or debug
+ifeq ($(HOST_BUILD_TYPE),)
+HOST_BUILD_TYPE := release
+endif
+
+ifneq ($(HOST_BUILD_TYPE),release)
+ifneq ($(HOST_BUILD_TYPE),debug)
+$(error HOST_BUILD_TYPE must be either release or debug, not '$(HOST_BUILD_TYPE)')
+endif
+endif
+
+# We don't want to move all the prebuilt host tools to a $(HOST_OS)-x86_64 dir.
+HOST_PREBUILT_ARCH := x86
+# This is the standard way to name a directory containing prebuilt host
+# objects. E.g., prebuilt/$(HOST_PREBUILT_TAG)/cc
+HOST_PREBUILT_TAG := $(BUILD_OS)-$(HOST_PREBUILT_ARCH)
+
+# TARGET_COPY_OUT_* are all relative to the staging directory, ie PRODUCT_OUT.
+# Define them here so they can be used in product config files.
+TARGET_COPY_OUT_SYSTEM := system
+TARGET_COPY_OUT_SYSTEM_OTHER := system_other
+TARGET_COPY_OUT_DATA := data
+TARGET_COPY_OUT_OEM := oem
+TARGET_COPY_OUT_ODM := odm
+TARGET_COPY_OUT_ROOT := root
+TARGET_COPY_OUT_RECOVERY := recovery
+###########################################
+# Define TARGET_COPY_OUT_VENDOR to a placeholder, for at this point
+# we don't know if the device wants to build a separate vendor.img
+# or just build vendor stuff into system.img.
+# A device can set up TARGET_COPY_OUT_VENDOR to "vendor" in its
+# BoardConfig.mk.
+# We'll substitute with the real value after loading BoardConfig.mk.
+_vendor_path_placeholder := ||VENDOR-PATH-PH||
+TARGET_COPY_OUT_VENDOR := $(_vendor_path_placeholder)
+###########################################
+
+# Read the product specs so we can get TARGET_DEVICE and other
+# variables that we need in order to locate the output files.
+include $(BUILD_SYSTEM)/product_config.mk
+
+build_variant := $(filter-out eng user userdebug,$(TARGET_BUILD_VARIANT))
+ifneq ($(build_variant)-$(words $(TARGET_BUILD_VARIANT)),-1)
+$(warning bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT))
+$(error must be empty or one of: eng user userdebug)
+endif
+
+SDK_HOST_ARCH := x86
+
+# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
+# or under vendor/*/$(TARGET_DEVICE). Search in both places, but
+# make sure only one exists.
+# Real boards should always be associated with an OEM vendor.
+board_config_mk := \
+ $(strip $(sort $(wildcard \
+ $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
+ $(shell test -d device && find -L device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
+ $(shell test -d vendor && find -L vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
+ )))
+ifeq ($(board_config_mk),)
+ $(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
+endif
+ifneq ($(words $(board_config_mk)),1)
+ $(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
+endif
+include $(board_config_mk)
+ifeq ($(TARGET_ARCH),)
+ $(error TARGET_ARCH not defined by board config: $(board_config_mk))
+endif
+ifneq ($(MALLOC_IMPL),)
+ $(warning *** Unsupported option MALLOC_IMPL defined by board config: $(board_config_mk).)
+ $(error Use `MALLOC_SVELTE := true` to configure jemalloc for low-memory)
+endif
+TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
+board_config_mk :=
+
+###########################################
+# Now we can substitute with the real value of TARGET_COPY_OUT_VENDOR
+ifeq ($(TARGET_COPY_OUT_VENDOR),$(_vendor_path_placeholder))
+TARGET_COPY_OUT_VENDOR := system/vendor
+else ifeq ($(filter vendor system/vendor,$(TARGET_COPY_OUT_VENDOR)),)
+$(error TARGET_COPY_OUT_VENDOR must be either 'vendor' or 'system/vendor', seeing '$(TARGET_COPY_OUT_VENDOR)'.)
+endif
+PRODUCT_COPY_FILES := $(subst $(_vendor_path_placeholder),$(TARGET_COPY_OUT_VENDOR),$(PRODUCT_COPY_FILES))
+
+BOARD_USES_VENDORIMAGE :=
+ifdef BOARD_PREBUILT_VENDORIMAGE
+BOARD_USES_VENDORIMAGE := true
+endif
+ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
+BOARD_USES_VENDORIMAGE := true
+endif
+ifeq ($(TARGET_COPY_OUT_VENDOR),vendor)
+BOARD_USES_VENDORIMAGE := true
+else ifdef BOARD_USES_VENDORIMAGE
+$(error TARGET_COPY_OUT_VENDOR must be set to 'vendor' to use a vendor image)
+endif
+###########################################
+
+
+# ---------------------------------------------------------------
+# Set up configuration for target machine.
+# The following must be set:
+# TARGET_OS = { linux }
+# TARGET_ARCH = { arm | x86 | mips }
+
+TARGET_OS := linux
+# TARGET_ARCH should be set by BoardConfig.mk and will be checked later
+ifneq ($(filter %64,$(TARGET_ARCH)),)
+TARGET_IS_64_BIT := true
+endif
+
+# the target build type defaults to release
+ifneq ($(TARGET_BUILD_TYPE),debug)
+TARGET_BUILD_TYPE := release
+endif
+
+# ---------------------------------------------------------------
+# figure out the output directories
+
+ifeq (,$(strip $(OUT_DIR)))
+ifeq (,$(strip $(OUT_DIR_COMMON_BASE)))
+OUT_DIR := $(TOPDIR)out
+else
+OUT_DIR := $(OUT_DIR_COMMON_BASE)/$(notdir $(PWD))
+endif
+endif
+
+DEBUG_OUT_DIR := $(OUT_DIR)/debug
+
+# Move the host or target under the debug/ directory
+# if necessary.
+TARGET_OUT_ROOT_release := $(OUT_DIR)/target
+TARGET_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/target
+TARGET_OUT_ROOT := $(TARGET_OUT_ROOT_$(TARGET_BUILD_TYPE))
+
+HOST_OUT_ROOT_release := $(OUT_DIR)/host
+HOST_OUT_ROOT_debug := $(DEBUG_OUT_DIR)/host
+HOST_OUT_ROOT := $(HOST_OUT_ROOT_$(HOST_BUILD_TYPE))
+
+# We want to avoid two host bin directories in multilib build.
+HOST_OUT_release := $(HOST_OUT_ROOT_release)/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
+HOST_OUT_debug := $(HOST_OUT_ROOT_debug)/$(HOST_OS)-$(HOST_PREBUILT_ARCH)
+HOST_OUT := $(HOST_OUT_$(HOST_BUILD_TYPE))
+# TODO: remove
+BUILD_OUT := $(HOST_OUT)
+
+HOST_CROSS_OUT_release := $(HOST_OUT_ROOT_release)/windows-$(HOST_PREBUILT_ARCH)
+HOST_CROSS_OUT_debug := $(HOST_OUT_ROOT_debug)/windows-$(HOST_PREBUILT_ARCH)
+HOST_CROSS_OUT := $(HOST_CROSS_OUT_$(HOST_BUILD_TYPE))
+
+TARGET_PRODUCT_OUT_ROOT := $(TARGET_OUT_ROOT)/product
+
+TARGET_COMMON_OUT_ROOT := $(TARGET_OUT_ROOT)/common
+HOST_COMMON_OUT_ROOT := $(HOST_OUT_ROOT)/common
+
+PRODUCT_OUT := $(TARGET_PRODUCT_OUT_ROOT)/$(TARGET_DEVICE)
+
+OUT_DOCS := $(TARGET_COMMON_OUT_ROOT)/docs
+
+BUILD_OUT_EXECUTABLES := $(BUILD_OUT)/bin
+
+HOST_OUT_EXECUTABLES := $(HOST_OUT)/bin
+HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib64
+HOST_OUT_RENDERSCRIPT_BITCODE := $(HOST_OUT_SHARED_LIBRARIES)
+HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT)/framework
+HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon
+
+HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT)/bin
+HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib
+
+HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj
+HOST_OUT_HEADERS := $(HOST_OUT_INTERMEDIATES)/include
+HOST_OUT_INTERMEDIATE_LIBRARIES := $(HOST_OUT_INTERMEDIATES)/lib
+HOST_OUT_NOTICE_FILES := $(HOST_OUT_INTERMEDIATES)/NOTICE_FILES
+HOST_OUT_COMMON_INTERMEDIATES := $(HOST_COMMON_OUT_ROOT)/obj
+HOST_OUT_FAKE := $(HOST_OUT)/fake_packages
+
+HOST_CROSS_OUT_INTERMEDIATES := $(HOST_CROSS_OUT)/obj
+HOST_CROSS_OUT_HEADERS := $(HOST_CROSS_OUT_INTERMEDIATES)/include
+HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES := $(HOST_CROSS_OUT_INTERMEDIATES)/lib
+HOST_CROSS_OUT_NOTICE_FILES := $(HOST_CROSS_OUT_INTERMEDIATES)/NOTICE_FILES
+
+HOST_OUT_GEN := $(HOST_OUT)/gen
+HOST_OUT_COMMON_GEN := $(HOST_COMMON_OUT_ROOT)/gen
+
+HOST_CROSS_OUT_GEN := $(HOST_CROSS_OUT)/gen
+
+# Out for HOST_2ND_ARCH
+HOST_2ND_ARCH_VAR_PREFIX := 2ND_
+HOST_2ND_ARCH_MODULE_SUFFIX := _32
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj32
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES := $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATES)/lib
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_EXECUTABLES := $(HOST_OUT_EXECUTABLES)
+$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT_JAVA_LIBRARIES)
+
+# The default host library path.
+# It always points to the path where we build libraries in the default bitness.
+ifeq ($(HOST_PREFER_32_BIT),true)
+HOST_LIBRARY_PATH := $($(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)
+else
+HOST_LIBRARY_PATH := $(HOST_OUT_SHARED_LIBRARIES)
+endif
+
+# Out for HOST_CROSS_2ND_ARCH
+HOST_CROSS_2ND_ARCH_VAR_PREFIX := 2ND_
+HOST_CROSS_2ND_ARCH_MODULE_SUFFIX := _64
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATES := $(HOST_CROSS_OUT)/obj64
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES := $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATES)/lib
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib64
+$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT_EXECUTABLES)
+
+TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj
+TARGET_OUT_HEADERS := $(TARGET_OUT_INTERMEDIATES)/include
+TARGET_OUT_INTERMEDIATE_LIBRARIES := $(TARGET_OUT_INTERMEDIATES)/lib
+TARGET_OUT_COMMON_INTERMEDIATES := $(TARGET_COMMON_OUT_ROOT)/obj
+
+TARGET_OUT_GEN := $(PRODUCT_OUT)/gen
+TARGET_OUT_COMMON_GEN := $(TARGET_COMMON_OUT_ROOT)/gen
+
+TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM)
+ifneq ($(filter address,$(SANITIZE_TARGET)),)
+target_out_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
+else
+target_out_shared_libraries_base := $(TARGET_OUT)
+endif
+
+TARGET_OUT_EXECUTABLES := $(TARGET_OUT)/bin
+TARGET_OUT_OPTIONAL_EXECUTABLES := $(TARGET_OUT)/xbin
+ifeq ($(TARGET_IS_64_BIT),true)
+# /system/lib always contains 32-bit libraries,
+# and /system/lib64 (if present) always contains 64-bit libraries.
+TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib64
+else
+TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib
+endif
+TARGET_OUT_RENDERSCRIPT_BITCODE := $(TARGET_OUT_SHARED_LIBRARIES)
+TARGET_OUT_JAVA_LIBRARIES := $(TARGET_OUT)/framework
+TARGET_OUT_APPS := $(TARGET_OUT)/app
+TARGET_OUT_APPS_PRIVILEGED := $(TARGET_OUT)/priv-app
+TARGET_OUT_KEYLAYOUT := $(TARGET_OUT)/usr/keylayout
+TARGET_OUT_KEYCHARS := $(TARGET_OUT)/usr/keychars
+TARGET_OUT_ETC := $(TARGET_OUT)/etc
+TARGET_OUT_NOTICE_FILES := $(TARGET_OUT_INTERMEDIATES)/NOTICE_FILES
+TARGET_OUT_FAKE := $(PRODUCT_OUT)/fake_packages
+
+TARGET_OUT_SYSTEM_OTHER := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM_OTHER)
+
+# Out for TARGET_2ND_ARCH
+TARGET_2ND_ARCH_VAR_PREFIX := $(HOST_2ND_ARCH_VAR_PREFIX)
+TARGET_2ND_ARCH_MODULE_SUFFIX := $(HOST_2ND_ARCH_MODULE_SUFFIX)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj_$(TARGET_2ND_ARCH)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES)/lib
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES := $(target_out_shared_libraries_base)/lib
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_RENDERSCRIPT_BITCODE := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS := $(TARGET_OUT_APPS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_APPS_PRIVILEGED := $(TARGET_OUT_APPS_PRIVILEGED)
+
+TARGET_OUT_DATA := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)
+TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_EXECUTABLES)
+TARGET_OUT_DATA_SHARED_LIBRARIES := $(TARGET_OUT_SHARED_LIBRARIES)
+TARGET_OUT_DATA_JAVA_LIBRARIES := $(TARGET_OUT_DATA)/framework
+TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA)/app
+TARGET_OUT_DATA_KEYLAYOUT := $(TARGET_OUT_KEYLAYOUT)
+TARGET_OUT_DATA_KEYCHARS := $(TARGET_OUT_KEYCHARS)
+TARGET_OUT_DATA_ETC := $(TARGET_OUT_ETC)
+ifeq ($(TARGET_IS_64_BIT),true)
+TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest64
+TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest64
+else
+TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
+TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest
+endif
+TARGET_OUT_DATA_FAKE := $(TARGET_OUT_DATA)/fake_packages
+
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_EXECUTABLES := $(TARGET_OUT_DATA_EXECUTABLES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_SHARED_LIBRARIES := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_APPS := $(TARGET_OUT_DATA_APPS)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS := $(TARGET_OUT_DATA)/nativetest
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_METRIC_TESTS := $(TARGET_OUT_DATA)/benchmarktest
+
+TARGET_OUT_CACHE := $(PRODUCT_OUT)/cache
+
+TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
+ifneq ($(filter address,$(SANITIZE_TARGET)),)
+target_out_vendor_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_DATA)/vendor
+else
+target_out_vendor_shared_libraries_base := $(TARGET_OUT_VENDOR)
+endif
+
+TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR)/bin
+TARGET_OUT_VENDOR_OPTIONAL_EXECUTABLES := $(TARGET_OUT_VENDOR)/xbin
+ifeq ($(TARGET_IS_64_BIT),true)
+TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib64
+else
+TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib
+endif
+TARGET_OUT_VENDOR_JAVA_LIBRARIES := $(TARGET_OUT_VENDOR)/framework
+TARGET_OUT_VENDOR_APPS := $(TARGET_OUT_VENDOR)/app
+TARGET_OUT_VENDOR_ETC := $(TARGET_OUT_VENDOR)/etc
+
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_EXECUTABLES := $(TARGET_OUT_VENDOR_EXECUTABLES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES := $(target_out_vendor_shared_libraries_base)/lib
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_APPS := $(TARGET_OUT_VENDOR_APPS)
+
+TARGET_OUT_OEM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_OEM)
+TARGET_OUT_OEM_EXECUTABLES := $(TARGET_OUT_OEM)/bin
+ifeq ($(TARGET_IS_64_BIT),true)
+TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib64
+else
+TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib
+endif
+# We don't expect Java libraries in the oem.img.
+# TARGET_OUT_OEM_JAVA_LIBRARIES:= $(TARGET_OUT_OEM)/framework
+TARGET_OUT_OEM_APPS := $(TARGET_OUT_OEM)/app
+TARGET_OUT_OEM_ETC := $(TARGET_OUT_OEM)/etc
+
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_EXECUTABLES := $(TARGET_OUT_OEM_EXECUTABLES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_SHARED_LIBRARIES := $(TARGET_OUT_OEM)/lib
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_OEM_APPS := $(TARGET_OUT_OEM_APPS)
+
+TARGET_OUT_ODM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ODM)
+TARGET_OUT_ODM_EXECUTABLES := $(TARGET_OUT_ODM)/bin
+ifeq ($(TARGET_IS_64_BIT),true)
+TARGET_OUT_ODM_SHARED_LIBRARIES := $(TARGET_OUT_ODM)/lib64
+else
+TARGET_OUT_ODM_SHARED_LIBRARIES := $(TARGET_OUT_ODM)/lib
+endif
+TARGET_OUT_ODM_APPS := $(TARGET_OUT_ODM)/app
+TARGET_OUT_ODM_ETC := $(TARGET_OUT_ODM)/etc
+
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_EXECUTABLES := $(TARGET_OUT_ODM_EXECUTABLES)
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_SHARED_LIBRARIES := $(TARGET_OUT_ODM)/lib
+$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_ODM_APPS := $(TARGET_OUT_ODM_APPS)
+
+TARGET_OUT_BREAKPAD := $(PRODUCT_OUT)/breakpad
+
+TARGET_OUT_UNSTRIPPED := $(PRODUCT_OUT)/symbols
+TARGET_OUT_EXECUTABLES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/bin
+TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/system/lib
+TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/$(TARGET_COPY_OUT_VENDOR)/lib
+TARGET_ROOT_OUT_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)
+TARGET_ROOT_OUT_SBIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/sbin
+TARGET_ROOT_OUT_BIN_UNSTRIPPED := $(TARGET_OUT_UNSTRIPPED)/bin
+
+TARGET_ROOT_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ROOT)
+TARGET_ROOT_OUT_BIN := $(TARGET_ROOT_OUT)/bin
+TARGET_ROOT_OUT_SBIN := $(TARGET_ROOT_OUT)/sbin
+TARGET_ROOT_OUT_ETC := $(TARGET_ROOT_OUT)/etc
+TARGET_ROOT_OUT_USR := $(TARGET_ROOT_OUT)/usr
+
+TARGET_RECOVERY_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_RECOVERY)
+TARGET_RECOVERY_ROOT_OUT := $(TARGET_RECOVERY_OUT)/root
+
+TARGET_SYSLOADER_OUT := $(PRODUCT_OUT)/sysloader
+TARGET_SYSLOADER_ROOT_OUT := $(TARGET_SYSLOADER_OUT)/root
+TARGET_SYSLOADER_SYSTEM_OUT := $(TARGET_SYSLOADER_OUT)/root/system
+
+TARGET_INSTALLER_OUT := $(PRODUCT_OUT)/installer
+TARGET_INSTALLER_DATA_OUT := $(TARGET_INSTALLER_OUT)/data
+TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root
+TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system
+
+COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES
+PER_ARCH_MODULE_CLASSES := SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP RENDERSCRIPT_BITCODE
+
+ifeq (,$(strip $(DIST_DIR)))
+ DIST_DIR := $(OUT_DIR)/dist
+endif
+
+ifeq ($(PRINT_BUILD_CONFIG),)
+PRINT_BUILD_CONFIG := true
+endif
+
+ifeq ($(USE_CLANG_PLATFORM_BUILD),)
+USE_CLANG_PLATFORM_BUILD := true
+endif
diff --git a/core/executable.mk b/core/executable.mk
new file mode 100644
index 0000000000000000000000000000000000000000..e22ea0ec00d10ee88f20adf0e1ee4d6b3d2bffd5
--- /dev/null
+++ b/core/executable.mk
@@ -0,0 +1,83 @@
+# We don't automatically set up rules to build executables for both
+# TARGET_ARCH and TARGET_2ND_ARCH.
+# By default, an executable is built for TARGET_ARCH.
+# To build it for TARGET_2ND_ARCH in a 64bit product, use "LOCAL_MULTILIB := 32"
+# To build it for both set LOCAL_MULTILIB := both and specify
+# LOCAL_MODULE_PATH_32 and LOCAL_MODULE_PATH_64 or LOCAL_MODULE_STEM_32 and
+# LOCAL_MODULE_STEM_64
+
+my_skip_this_target :=
+ifneq ($(filter address,$(SANITIZE_TARGET)),)
+ ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE))
+ my_skip_this_target := true
+ else ifeq (false, $(LOCAL_CLANG))
+ my_skip_this_target := true
+ endif
+endif
+
+ifneq (true,$(my_skip_this_target))
+
+my_prefix := TARGET_
+include $(BUILD_SYSTEM)/multilib.mk
+
+ifeq ($(my_module_multilib),both)
+ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),)
+$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
+endif
+ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),)
+$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
+endif
+else #!LOCAL_MULTILIB == both
+LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
+endif
+
+# if TARGET_PREFER_32_BIT_EXECUTABLES is set, try to build 32-bit first
+ifdef TARGET_2ND_ARCH
+ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true)
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+else
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif
+endif
+
+my_skip_non_preferred_arch :=
+
+# check if preferred arch is supported
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# first arch is supported
+include $(BUILD_SYSTEM)/executable_internal.mk
+ifneq ($(my_module_multilib),both)
+my_skip_non_preferred_arch := true
+endif
+endif
+
+# check if preferred arch was not supported or asked to build both
+ifndef my_skip_non_preferred_arch
+ifdef TARGET_2ND_ARCH
+
+# check if the non-preferred arch is the primary or secondary
+ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true)
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+else
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+endif
+
+# check if non-preferred arch is supported
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# non-preferred arch is supported
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+include $(BUILD_SYSTEM)/executable_internal.mk
+endif
+endif # TARGET_2ND_ARCH
+endif # !my_skip_non_preferred_arch || LOCAL_MULTILIB
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+LOCAL_NO_2ND_ARCH_MODULE_SUFFIX :=
+
+my_module_arch_supported :=
+
+endif
diff --git a/core/executable_internal.mk b/core/executable_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..febea98f6d1eea90253eea30385c429fb9312b16
--- /dev/null
+++ b/core/executable_internal.mk
@@ -0,0 +1,85 @@
+###########################################################
+## Standard rules for building an executable file.
+##
+## Additional inputs from base_rules.make:
+## None.
+###########################################################
+
+ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
+LOCAL_MODULE_CLASS := EXECUTABLES
+endif
+ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
+LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
+endif
+
+$(call target-executable-hook)
+
+skip_build_from_source :=
+ifdef LOCAL_PREBUILT_MODULE_FILE
+ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+skip_build_from_source := true
+endif
+endif
+
+ifndef skip_build_from_source
+
+include $(BUILD_SYSTEM)/dynamic_binary.mk
+
+# Check for statically linked libc
+ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+ifneq ($(filter $(my_static_libraries),libc),)
+$(error $(LOCAL_PATH): $(LOCAL_MODULE) is statically linking libc to dynamic executable, please remove libc from static libs or set LOCAL_FORCE_STATIC_EXECUTABLE := true)
+endif
+endif
+
+# Define PRIVATE_ variables from global vars
+my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS)
+ifeq ($(LOCAL_NO_LIBGCC),true)
+my_target_libgcc :=
+else
+my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC)
+endif
+my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC)
+ifeq ($(LOCAL_NO_CRT),true)
+my_target_crtbegin_dynamic_o :=
+my_target_crtbegin_static_o :=
+my_target_crtend_o :=
+else
+my_target_crtbegin_dynamic_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_DYNAMIC_O)
+my_target_crtbegin_static_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_STATIC_O)
+my_target_crtend_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTEND_O)
+endif
+ifdef LOCAL_SDK_VERSION
+# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS,
+# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree.
+my_target_global_ld_dirs := \
+ $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
+ $(my_ndk_sysroot_lib)) \
+ $(my_target_global_ld_dirs)
+my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
+my_target_crtbegin_dynamic_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_dynamic.o)
+my_target_crtbegin_static_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_static.o)
+my_target_crtend_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_android.o)
+endif
+$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs)
+$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
+$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
+$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
+$(linked_module): PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O := $(my_target_crtbegin_dynamic_o)
+$(linked_module): PRIVATE_TARGET_CRTBEGIN_STATIC_O := $(my_target_crtbegin_static_o)
+$(linked_module): PRIVATE_TARGET_CRTEND_O := $(my_target_crtend_o)
+$(linked_module): PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
+$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD)
+
+ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
+$(linked_module): $(my_target_crtbegin_static_o) $(all_objects) $(all_libraries) $(my_target_crtend_o)
+ $(transform-o-to-static-executable)
+ $(PRIVATE_POST_LINK_CMD)
+else
+$(linked_module): $(my_target_crtbegin_dynamic_o) $(all_objects) $(all_libraries) $(my_target_crtend_o)
+ $(transform-o-to-executable)
+ $(PRIVATE_POST_LINK_CMD)
+endif
+
+endif # skip_build_from_source
diff --git a/core/executable_prefer_symlink.mk b/core/executable_prefer_symlink.mk
new file mode 100644
index 0000000000000000000000000000000000000000..931550f4f7dab20209e9b3d495a71e800ad4f160
--- /dev/null
+++ b/core/executable_prefer_symlink.mk
@@ -0,0 +1,58 @@
+# include this makefile to create the LOCAL_MODULE symlink to the primary version binary.
+# but this requires the primary version name specified via LOCAL_MODULE_STEM_32 or LOCAL_MODULE_STEM_64,
+# and different with the LOCAL_MODULE value
+#
+# Note: now only limited to the binaries that will be installed under system/bin directory
+
+# Create link to the one used depending on the target
+# configuration. Note that we require the TARGET_IS_64_BIT
+# check because 32 bit targets may not define TARGET_PREFER_32_BIT_APPS
+# et al. since those variables make no sense in that context.
+ifneq ($(LOCAL_IS_HOST_MODULE),true)
+ my_symlink := $(addprefix $(TARGET_OUT)/bin/, $(LOCAL_MODULE))
+ ifeq ($(TARGET_IS_64_BIT),true)
+ ifeq ($(TARGET_SUPPORTS_64_BIT_APPS)|$(TARGET_SUPPORTS_32_BIT_APPS),true|true)
+ # We support both 32 and 64 bit apps, so we will have to
+ # base our decision on whether the target prefers one or the
+ # other.
+ ifeq ($(TARGET_PREFER_32_BIT_APPS),true)
+ $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_32)
+ else
+ $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_64)
+ endif
+ else ifeq ($(TARGET_SUPPORTS_64_BIT_APPS),true)
+ # We support only 64 bit apps.
+ $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_64)
+ else
+ # We support only 32 bit apps.
+ $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_32)
+ endif
+ else
+ $(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_32)
+ endif
+else
+ my_symlink := $(addprefix $(HOST_OUT)/bin/, $(LOCAL_MODULE))
+ ifneq ($(HOST_PREFER_32_BIT),true)
+$(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_64)
+ else
+$(my_symlink): PRIVATE_SRC_BINARY_NAME := $(LOCAL_MODULE_STEM_32)
+ endif
+endif
+
+# $(my_symlink) doesn't need to depend on $(PRIVATE_SRC_BINARY_NAME): we can generate symlink to nonexistent file.
+# If you add the dependency, make would compare the timestamp of a file against that of its symlink:
+# they are always equal, because make follows symlink.
+$(my_symlink): $(LOCAL_MODULE_MAKEFILE_DEP)
+ @echo "Symlink: $@ -> $(PRIVATE_SRC_BINARY_NAME)"
+ @mkdir -p $(dir $@)
+ @rm -rf $@
+ $(hide) ln -sf $(PRIVATE_SRC_BINARY_NAME) $@
+
+# We need this so that the installed files could be picked up based on the
+# local module name
+ALL_MODULES.$(LOCAL_MODULE).INSTALLED += $(my_symlink)
+
+# Create the symlink when you run mm/mmm or "make "
+$(LOCAL_MODULE) : $(my_symlink)
+
+my_symlink :=
diff --git a/core/filter_symbols.sh b/core/filter_symbols.sh
new file mode 100644
index 0000000000000000000000000000000000000000..ba5057afd13642801d92ac188f6bb0c7257b62ac
--- /dev/null
+++ b/core/filter_symbols.sh
@@ -0,0 +1,25 @@
+NM=$1
+
+shift
+
+PREFIX=$1
+
+shift
+
+SUFFIX=$1
+
+shift
+
+while test "$1" != ""
+do
+ $NM -g -fp $1 | while read -a line
+ do
+ type=${line[1]}
+ # if [[ "$type" != "V" && "$type" != "U" ]]; then
+ #if [[ "$type" != "W" && "$type" != "V" && "$type" != "U" ]]; then
+ echo "$PREFIX${line[0]}$SUFFIX # ${line[1]}"
+ #fi
+ done
+
+ shift
+done
diff --git a/core/find-jdk-tools-jar.sh b/core/find-jdk-tools-jar.sh
new file mode 100755
index 0000000000000000000000000000000000000000..ac0b3b6b59d1ad96ecda0fd8bd3df6f0125b5f51
--- /dev/null
+++ b/core/find-jdk-tools-jar.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+if [ "x$ANDROID_JAVA_HOME" != x ] && [ -e "$ANDROID_JAVA_HOME/lib/tools.jar" ] ; then
+ echo $ANDROID_JAVA_HOME/lib/tools.jar
+else
+ JAVAC=$(realpath $(which javac) 2>/dev/null)
+ if [ -z "$JAVAC" ]; then
+ JAVAC=$(readlink -f $(which javac) 2>/dev/null)
+ fi
+ if [ -z "$JAVAC" ]; then
+ JAVAC=$(which javac)
+ fi
+ if [ -z "$JAVAC" ] ; then
+ exit 1
+ fi
+ while [ -L "$JAVAC" ] ; do
+ LSLINE=$(ls -l "$JAVAC")
+ JAVAC=$(echo -n "$LSLINE" | sed -e "s/.* -> //")
+ done
+ echo $JAVAC | sed -e 's:\(.*\)/javac$:\1/../lib/tools.jar:'
+fi
diff --git a/core/fuzz_test.mk b/core/fuzz_test.mk
new file mode 100644
index 0000000000000000000000000000000000000000..fc582b3feb4e96e3ef06bffec72c42e19a3121c5
--- /dev/null
+++ b/core/fuzz_test.mk
@@ -0,0 +1,34 @@
+###########################################
+## A thin wrapper around BUILD_EXECUTABLE
+## Common flags for fuzz tests are added.
+###########################################
+
+ifdef LOCAL_SDK_VERSION
+ $(error $(LOCAL_PATH): $(LOCAL_MODULE): NDK fuzz tests are not supported.)
+endif
+
+LOCAL_CFLAGS += -fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp
+LOCAL_STATIC_LIBRARIES += libLLVMFuzzer
+
+ifdef LOCAL_MODULE_PATH
+$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE))
+endif
+
+ifdef LOCAL_MODULE_PATH_32
+$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_32 when building test $(LOCAL_MODULE))
+endif
+
+ifdef LOCAL_MODULE_PATH_64
+$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE))
+endif
+
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+
+ifndef LOCAL_MULTILIB
+ifndef LOCAL_32_BIT_ONLY
+LOCAL_MULTILIB := both
+endif
+endif
+
+include $(BUILD_EXECUTABLE)
diff --git a/core/goma.mk b/core/goma.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6535b3e4a8104f52fdd2b1898952d8fd6bb7b010
--- /dev/null
+++ b/core/goma.mk
@@ -0,0 +1,67 @@
+#
+# 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.
+#
+
+# Notice: this works only with Google's Goma build infrastructure.
+ifneq ($(filter-out false,$(USE_GOMA)),)
+ # Check if USE_NINJA is not false because GNU make won't work well
+ # with goma. Note this file is evaluated twice, once by GNU make and
+ # once by kati with USE_NINJA=false. We do this check in the former
+ # pass.
+ ifndef KATI
+ ifeq ($(USE_NINJA),false)
+ $(error USE_GOMA=true is not compatible with USE_NINJA=false)
+ endif
+ endif
+
+ # Goma requires a lot of processes and file descriptors.
+ ifeq ($(shell echo $$(($$(ulimit -u) < 2500 || $$(ulimit -n) < 16000))),1)
+ $(warning Max user processes and/or open files are insufficient)
+ ifeq ($(shell uname),Darwin)
+ $(error See go/ma/how-to-use-goma/how-to-use-goma-for-android to relax the limit)
+ else
+ $(error Adjust the limit by ulimit -u and ulimit -n)
+ endif
+ endif
+
+ ifdef GOMA_DIR
+ goma_dir := $(GOMA_DIR)
+ else
+ goma_dir := $(HOME)/goma
+ endif
+ goma_ctl := $(goma_dir)/goma_ctl.py
+ GOMA_CC := $(goma_dir)/gomacc
+
+ $(if $(wildcard $(goma_ctl)),, \
+ $(warning You should have goma in $$GOMA_DIR or $(HOME)/goma) \
+ $(error See go/ma/how-to-use-goma/how-to-use-goma-for-android for detail))
+
+ # Append gomacc to existing *_WRAPPER variables so it's possible to
+ # use both ccache and gomacc.
+ CC_WRAPPER := $(strip $(CC_WRAPPER) $(GOMA_CC))
+ CXX_WRAPPER := $(strip $(CXX_WRAPPER) $(GOMA_CC))
+
+ # gomacc can start goma client's daemon process automatically, but
+ # it is safer and faster to start up it beforehand. We run this as a
+ # background process so this won't slow down the build.
+ # We use "ensure_start" command when the compiler_proxy is already
+ # running and uses GOMA_HERMETIC=error flag. The compiler_proxy will
+ # restart otherwise.
+ # TODO(hamaji): Remove this condition after http://b/25676777 is fixed.
+ $(shell ( if ( curl http://localhost:$$($(GOMA_CC) port)/flagz | grep GOMA_HERMETIC=error ); then cmd=ensure_start; else cmd=restart; fi; GOMA_HERMETIC=error $(goma_ctl) $${cmd} ) &> /dev/null &)
+
+ goma_ctl :=
+ goma_dir :=
+endif
diff --git a/core/help.mk b/core/help.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6e0b2c02edb078fd61f65a9a96ad88f29ef0d0e9
--- /dev/null
+++ b/core/help.mk
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 2010 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.
+#
+
+.PHONY: help
+help:
+ @echo
+ @echo "Common make targets:"
+ @echo "----------------------------------------------------------------------------------"
+ @echo "droid Default target"
+ @echo "clean (aka clobber) equivalent to rm -rf out/"
+ @echo "snod Quickly rebuild the system image from built packages"
+ @echo "offline-sdk-docs Generate the HTML for the developer SDK docs"
+ @echo "doc-comment-check-docs Check HTML doc links & validity, without generating HTML"
+ @echo "libandroid_runtime All the JNI framework stuff"
+ @echo "framework All the java framework stuff"
+ @echo "services The system server (Java) and friends"
+ @echo "help You're reading it right now"
+
+.PHONY: out
+out:
+ @echo "I'm sure you're nice and all, but no thanks."
diff --git a/core/host_dalvik_java_library.mk b/core/host_dalvik_java_library.mk
new file mode 100644
index 0000000000000000000000000000000000000000..83047d4c3f2be4da501ad2d8c25a62d130740d55
--- /dev/null
+++ b/core/host_dalvik_java_library.mk
@@ -0,0 +1,158 @@
+#
+# Copyright (C) 2013 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.
+#
+
+#
+# Rules for building a host dalvik java library. These libraries
+# are meant to be used by a dalvik VM instance running on the host.
+# They will be compiled against libcore and not the host JRE.
+#
+
+ifeq ($(HOST_OS),linux)
+USE_CORE_LIB_BOOTCLASSPATH := true
+
+#######################################
+include $(BUILD_SYSTEM)/host_java_library_common.mk
+#######################################
+
+ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+ LOCAL_JAVA_LIBRARIES += core-oj-hostdex core-libart-hostdex
+endif
+
+full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
+full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
+full_classes_jar := $(intermediates.COMMON)/classes.jar
+full_classes_jack := $(intermediates.COMMON)/classes.jack
+jack_check_timestamp := $(intermediates.COMMON)/jack.check.timestamp
+built_dex := $(intermediates.COMMON)/classes.dex
+
+LOCAL_INTERMEDIATE_TARGETS += \
+ $(full_classes_compiled_jar) \
+ $(full_classes_jarjar_jar) \
+ $(full_classes_jack) \
+ $(full_classes_jar) \
+ $(jack_check_timestamp) \
+ $(built_dex)
+
+# See comment in java.mk
+ifndef LOCAL_CHECKED_MODULE
+ifdef LOCAL_JACK_ENABLED
+LOCAL_CHECKED_MODULE := $(jack_check_timestamp)
+else
+LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar)
+endif
+endif
+
+#######################################
+include $(BUILD_SYSTEM)/base_rules.mk
+#######################################
+java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \
+ $(filter %.java,$(LOCAL_GENERATED_SOURCES))
+all_java_sources := $(java_sources)
+
+include $(BUILD_SYSTEM)/java_common.mk
+
+# The layers file allows you to enforce a layering between java packages.
+# Run build/tools/java-layers.py for more details.
+layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
+
+$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
+
+$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
+$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
+$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
+$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
+$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
+$(full_classes_compiled_jar): \
+ $(java_sources) \
+ $(java_resource_sources) \
+ $(full_java_lib_deps) \
+ $(jar_manifest_file) \
+ $(proto_java_sources_file_stamp) \
+ $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ $(transform-host-java-to-package)
+
+# Run jarjar if necessary, otherwise just copy the file.
+ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
+$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
+ @echo JarJar: $@
+ $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
+else
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+endif
+
+$(full_classes_jar): $(full_classes_jarjar_jar) | $(ACP)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+
+ifndef LOCAL_JACK_ENABLED
+
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
+$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
+$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
+$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
+ @echo "Host Jar: $(PRIVATE_MODULE) ($@)"
+ $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
+ $(add-dex-to-package)
+
+else # LOCAL_JACK_ENABLED
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
+
+ifeq ($(LOCAL_JACK_ENABLED),incremental)
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
+else
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_JACK_INCREMENTAL_DIR :=
+endif
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_MIN_SDK_VERSION := $(PLATFORM_JACK_MIN_SDK_VERSION)
+
+jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_deps) \
+ $(jar_manifest_file) $(proto_java_sources_file_stamp) $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK)
+$(built_dex): PRIVATE_CLASSES_JACK := $(full_classes_jack)
+$(built_dex): $(jack_all_deps) | setup-jack-server
+ @echo Building with Jack: $@
+ $(jack-java-to-dex)
+
+$(jack_check_timestamp): $(jack_all_deps) | setup-jack-server
+ @echo Checking build with Jack: $@
+ $(jack-check-java)
+
+# $(full_classes_jack) is just by-product of $(built_dex).
+# The dummy command was added because, without it, make misses the fact the $(built_dex) also
+# change $(full_classes_jack).
+$(full_classes_jack): $(built_dex)
+ $(hide) touch $@
+
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
+$(LOCAL_BUILT_MODULE): $(built_dex) $(java_resource_sources)
+ @echo "Host Jar: $(PRIVATE_MODULE) ($@)"
+ $(create-empty-package)
+ $(add-dex-to-package)
+ $(add-carried-jack-resources)
+
+endif # LOCAL_JACK_ENABLED
+
+USE_CORE_LIB_BOOTCLASSPATH :=
+
+endif
diff --git a/core/host_dalvik_static_java_library.mk b/core/host_dalvik_static_java_library.mk
new file mode 100644
index 0000000000000000000000000000000000000000..c296be359e65c68b48728ccee30bc0f08d585257
--- /dev/null
+++ b/core/host_dalvik_static_java_library.mk
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2013 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.
+#
+
+#
+# Rules for building a host dalvik static java library.
+# These libraries will be compiled against libcore and not the host
+# JRE.
+#
+ifeq ($(HOST_OS),linux)
+
+LOCAL_UNINSTALLABLE_MODULE := true
+LOCAL_IS_STATIC_JAVA_LIBRARY := true
+USE_CORE_LIB_BOOTCLASSPATH := true
+LOCAL_JAVA_LIBRARIES += core-oj-hostdex core-libart-hostdex
+
+intermediates.COMMON := $(call intermediates-dir-for,JAVA_LIBRARIES,$(LOCAL_MODULE),true,COMMON,)
+full_classes_jack := $(intermediates.COMMON)/classes.jack
+LOCAL_INTERMEDIATE_TARGETS += \
+ $(full_classes_jack)
+
+include $(BUILD_SYSTEM)/host_java_library.mk
+# proguard is not supported
+# *.proto files are not supported
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_MIN_SDK_VERSION := $(PLATFORM_JACK_MIN_SDK_VERSION)
+
+$(full_classes_jack): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
+$(full_classes_jack): \
+ PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
+ifeq ($(LOCAL_JACK_ENABLED),incremental)
+$(full_classes_jack): \
+ PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
+else
+$(full_classes_jack): \
+ PRIVATE_JACK_INCREMENTAL_DIR :=
+endif
+$(full_classes_jack): $(java_sources) $(java_resource_sources) $(full_jack_deps) \
+ $(jar_manifest_file) $(layers_file) $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
+ $(JACK) | setup-jack-server
+ @echo Building with Jack: $@
+ $(java-to-jack)
+
+USE_CORE_LIB_BOOTCLASSPATH :=
+LOCAL_IS_STATIC_JAVA_LIBRARY :=
+endif
diff --git a/core/host_executable.mk b/core/host_executable.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6f19bd1738d0421c87f5dc36bdd683f376b5811d
--- /dev/null
+++ b/core/host_executable.mk
@@ -0,0 +1,107 @@
+LOCAL_IS_HOST_MODULE := true
+my_prefix := HOST_
+LOCAL_HOST_PREFIX :=
+include $(BUILD_SYSTEM)/multilib.mk
+
+ifndef LOCAL_MODULE_HOST_ARCH
+ifndef my_module_multilib
+ifeq ($(HOST_PREFER_32_BIT),true)
+my_module_multilib := 32
+else
+# By default we only build host module for the first arch.
+my_module_multilib := first
+endif
+endif
+endif
+
+ifeq ($(LOCAL_NO_FPIE),)
+LOCAL_LDFLAGS += $(HOST_FPIE_FLAGS)
+endif
+
+ifeq ($(my_module_multilib),both)
+ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),)
+$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
+endif
+ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),)
+$(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
+endif
+else #!LOCAL_MULTILIB == both
+LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
+endif
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
+include $(BUILD_SYSTEM)/host_executable_internal.mk
+endif
+
+ifdef HOST_2ND_ARCH
+LOCAL_2ND_ARCH_VAR_PREFIX := $(HOST_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# Build for HOST_2ND_ARCH
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+include $(BUILD_SYSTEM)/host_executable_internal.mk
+endif
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif # HOST_2ND_ARCH
+
+ifdef HOST_CROSS_OS
+my_prefix := HOST_CROSS_
+LOCAL_HOST_PREFIX := $(my_prefix)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# Build for Windows
+OVERRIDE_BUILT_MODULE_PATH :=
+# we don't want others using the cross compiled version
+saved_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
+saved_LOCAL_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
+saved_LOCAL_LDFLAGS := $(LOCAL_LDFLAGS)
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+ifeq ($(LOCAL_NO_FPIE),)
+LOCAL_LDFLAGS += $(HOST_CROSS_FPIE_FLAGS)
+endif
+
+include $(BUILD_SYSTEM)/host_executable_internal.mk
+LOCAL_LDFLAGS := $(saved_LOCAL_LDFLAGS)
+LOCAL_BUILT_MODULE := $(saved_LOCAL_BUILT_MODULE)
+LOCAL_INSTALLED_MODULE := $(saved_LOCAL_INSTALLED_MODULE)
+endif
+
+ifdef HOST_CROSS_2ND_ARCH
+LOCAL_2ND_ARCH_VAR_PREFIX := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+OVERRIDE_BUILT_MODULE_PATH :=
+# we don't want others using the cross compiled version
+saved_LOCAL_BUILT_MODULE := $(LOCAL_BUILT_MODULE)
+saved_LOCAL_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
+saved_LOCAL_LDFLAGS := $(LOCAL_LDFLAGS)
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+ifeq ($(LOCAL_NO_FPIE),)
+LOCAL_LDFLAGS += $(HOST_CROSS_FPIE_FLAGS)
+endif
+
+include $(BUILD_SYSTEM)/host_executable_internal.mk
+LOCAL_LDFLAGS := $(saved_LOCAL_LDFLAGS)
+LOCAL_BUILT_MODULE := $(saved_LOCAL_BUILT_MODULE)
+LOCAL_INSTALLED_MODULE := $(saved_LOCAL_INSTALLED_MODULE)
+endif
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif
+LOCAL_HOST_PREFIX :=
+endif
+
+LOCAL_NO_2ND_ARCH_MODULE_SUFFIX :=
+my_module_arch_supported :=
diff --git a/core/host_executable_internal.mk b/core/host_executable_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b682ffdaa9bf66feb14d1f764410d095c6028ee9
--- /dev/null
+++ b/core/host_executable_internal.mk
@@ -0,0 +1,35 @@
+###########################################################
+## Standard rules for building an executable file.
+##
+## Additional inputs from base_rules.make:
+## None.
+###########################################################
+
+ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
+LOCAL_MODULE_CLASS := EXECUTABLES
+endif
+ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
+LOCAL_MODULE_SUFFIX := $($(my_prefix)EXECUTABLE_SUFFIX)
+endif
+
+$(call host-executable-hook)
+
+skip_build_from_source :=
+ifdef LOCAL_PREBUILT_MODULE_FILE
+ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+skip_build_from_source := true
+endif
+endif
+
+ifndef skip_build_from_source
+
+include $(BUILD_SYSTEM)/binary.mk
+
+my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
+$(LOCAL_BUILT_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt)
+
+$(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries)
+ $(transform-host-o-to-executable)
+
+endif # skip_build_from_source
diff --git a/core/host_fuzz_test.mk b/core/host_fuzz_test.mk
new file mode 100644
index 0000000000000000000000000000000000000000..cc7baada157a23f00fda2b0b76bce594c5c958a5
--- /dev/null
+++ b/core/host_fuzz_test.mk
@@ -0,0 +1,9 @@
+################################################
+## A thin wrapper around BUILD_HOST_EXECUTABLE
+## Common flags for host fuzz tests are added.
+################################################
+
+LOCAL_CFLAGS += -fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp
+LOCAL_STATIC_LIBRARIES += libLLVMFuzzer
+
+include $(BUILD_HOST_EXECUTABLE)
diff --git a/core/host_java_library.mk b/core/host_java_library.mk
new file mode 100644
index 0000000000000000000000000000000000000000..97079fd37843d2827b7de0d2661b0aa6a1c87a02
--- /dev/null
+++ b/core/host_java_library.mk
@@ -0,0 +1,109 @@
+#
+# 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.
+#
+
+#
+# Standard rules for building a host java library.
+#
+
+#######################################
+include $(BUILD_SYSTEM)/host_java_library_common.mk
+#######################################
+
+# Enable emma instrumentation only if the module asks so.
+ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
+ifneq (true,$(EMMA_INSTRUMENT))
+LOCAL_EMMA_INSTRUMENT :=
+endif
+endif
+
+full_classes_compiled_jar := $(intermediates.COMMON)/classes-full-debug.jar
+full_classes_jarjar_jar := $(intermediates.COMMON)/classes-jarjar.jar
+emma_intermediates_dir := $(intermediates.COMMON)/emma_out
+# emma is hardcoded to use the leaf name of its input for the output file --
+# only the output directory can be changed
+full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(notdir $(full_classes_jarjar_jar))
+
+LOCAL_INTERMEDIATE_TARGETS += \
+ $(full_classes_compiled_jar) \
+ $(full_classes_jarjar_jar) \
+ $(full_classes_emma_jar)
+
+#######################################
+include $(BUILD_SYSTEM)/base_rules.mk
+#######################################
+
+java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) \
+ $(filter %.java,$(LOCAL_GENERATED_SOURCES))
+all_java_sources := $(java_sources)
+
+include $(BUILD_SYSTEM)/java_common.mk
+
+# The layers file allows you to enforce a layering between java packages.
+# Run build/tools/java-layers.py for more details.
+layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
+
+$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
+$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
+$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES :=
+$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES :=
+$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES :=
+$(full_classes_compiled_jar): \
+ $(java_sources) \
+ $(java_resource_sources) \
+ $(full_java_lib_deps) \
+ $(jar_manifest_file) \
+ $(proto_java_sources_file_stamp) \
+ $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ $(transform-host-java-to-package)
+
+# Run jarjar if necessary, otherwise just copy the file.
+ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
+$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
+ @echo JarJar: $@
+ $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
+else
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+endif
+
+ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.em
+$(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
+ifdef LOCAL_EMMA_COVERAGE_FILTER
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := $(LOCAL_EMMA_COVERAGE_FILTER)
+else
+# by default, avoid applying emma instrumentation onto emma classes itself,
+# otherwise there will be exceptions thrown
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := *,-emma,-emmarun,-com.vladium.*
+endif
+# this rule will generate both $(PRIVATE_EMMA_COVERAGE_FILE) and
+# $(full_classes_emma_jar)
+$(full_classes_emma_jar) : $(full_classes_jarjar_jar) | $(EMMA_JAR)
+ $(transform-classes.jar-to-emma)
+
+$(built_javalib_jar) : $(full_classes_emma_jar)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+
+else # LOCAL_EMMA_INSTRUMENT
+$(built_javalib_jar): $(full_classes_jarjar_jar) | $(ACP)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+endif # LOCAL_EMMA_INSTRUMENT
+
diff --git a/core/host_java_library_common.mk b/core/host_java_library_common.mk
new file mode 100644
index 0000000000000000000000000000000000000000..35a6e28ed20454136ddf86670c910375b31370cd
--- /dev/null
+++ b/core/host_java_library_common.mk
@@ -0,0 +1,64 @@
+#
+# Copyright (C) 2013 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.
+#
+
+#
+# Common rules for building a host java library.
+#
+
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
+LOCAL_IS_HOST_MODULE := true
+LOCAL_BUILT_MODULE_STEM := javalib.jar
+
+intermediates := $(call local-intermediates-dir)
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
+
+built_javalib_jar := $(intermediates)/javalib.jar
+
+#################################
+include $(BUILD_SYSTEM)/configure_local_jack.mk
+#################################
+
+ifdef LOCAL_JACK_ENABLED
+ifdef LOCAL_IS_STATIC_JAVA_LIBRARY
+LOCAL_BUILT_MODULE_STEM := classes.jack
+LOCAL_INTERMEDIATE_TARGETS += $(built_javalib_jar)
+endif
+endif
+
+# base_rules.mk looks at this
+all_res_assets :=
+
+proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
+ifneq ($(proto_sources),)
+ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
+ LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-micro
+else
+ ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
+ LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-nano
+ else
+ ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
+ LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-full
+ else
+ LOCAL_JAVA_LIBRARIES += host-libprotobuf-java-lite
+ endif
+ endif
+endif
+endif
+
+LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
+LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES))
+
diff --git a/core/host_native_test.mk b/core/host_native_test.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7cba1ae9b1f261ac56cc677fd7fd6b56abae183b
--- /dev/null
+++ b/core/host_native_test.mk
@@ -0,0 +1,26 @@
+################################################
+## A thin wrapper around BUILD_HOST_EXECUTABLE
+## Common flags for host native tests are added.
+################################################
+
+include $(BUILD_SYSTEM)/host_test_internal.mk
+
+needs_symlink :=
+ifndef LOCAL_MULTILIB
+ ifndef LOCAL_32_BIT_ONLY
+ LOCAL_MULTILIB := both
+
+ ifeq (,$(LOCAL_MODULE_STEM_32)$(LOCAL_MODULE_STEM_64))
+ LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32
+ LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64
+ needs_symlink := true
+ endif
+ endif
+endif
+
+include $(BUILD_HOST_EXECUTABLE)
+
+ifdef needs_symlink
+include $(BUILD_SYSTEM)/executable_prefer_symlink.mk
+needs_symlink :=
+endif
diff --git a/core/host_prebuilt.mk b/core/host_prebuilt.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7baab69950ac36c0fbbd16ca0624d3622194731a
--- /dev/null
+++ b/core/host_prebuilt.mk
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+LOCAL_IS_HOST_MODULE := true
+include $(BUILD_MULTI_PREBUILT)
diff --git a/core/host_shared_library.mk b/core/host_shared_library.mk
new file mode 100644
index 0000000000000000000000000000000000000000..2e0c9f1ce2e30eff98170e5c02fea44108477d92
--- /dev/null
+++ b/core/host_shared_library.mk
@@ -0,0 +1,83 @@
+LOCAL_IS_HOST_MODULE := true
+my_prefix := HOST_
+LOCAL_HOST_PREFIX :=
+include $(BUILD_SYSTEM)/multilib.mk
+
+ifndef LOCAL_MODULE_HOST_ARCH
+ifndef my_module_multilib
+ifeq ($(HOST_PREFER_32_BIT),true)
+my_module_multilib := 32
+else
+# libraries default to building for both architecturess
+my_module_multilib := both
+endif
+endif
+endif
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
+include $(BUILD_SYSTEM)/host_shared_library_internal.mk
+endif
+
+ifdef HOST_2ND_ARCH
+LOCAL_2ND_ARCH_VAR_PREFIX := $(HOST_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# Build for HOST_2ND_ARCH
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+include $(BUILD_SYSTEM)/host_shared_library_internal.mk
+endif
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif # HOST_2ND_ARCH
+
+ifdef HOST_CROSS_OS
+my_prefix := HOST_CROSS_
+LOCAL_HOST_PREFIX := $(my_prefix)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# Build for Windows
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_MODULE_SUFFIX :=
+# We don't want makefiles using the cross-compiled host tool
+saved_LOCAL_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+include $(BUILD_SYSTEM)/host_shared_library_internal.mk
+LOCAL_INSTALLED_MODULE := $(saved_LOCAL_INSTALLED_MODULE)
+endif
+
+ifdef HOST_CROSS_2ND_ARCH
+LOCAL_2ND_ARCH_VAR_PREFIX := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# Build for HOST_CROSS_2ND_ARCH
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_MODULE_SUFFIX :=
+# We don't want makefiles using the cross-compiled host tool
+saved_LOCAL_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+include $(BUILD_SYSTEM)/host_shared_library_internal.mk
+LOCAL_INSTALLED_MODULE := $(saved_LOCAL_INSTALLED_MODULE)
+endif
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif
+LOCAL_HOST_PREFIX :=
+endif
+
+my_module_arch_supported :=
+
+###########################################################
+## Copy headers to the install tree
+###########################################################
+include $(BUILD_COPY_HEADERS)
diff --git a/core/host_shared_library_internal.mk b/core/host_shared_library_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..272e76f439ccba767ce0793a80c0cabf694b6ff7
--- /dev/null
+++ b/core/host_shared_library_internal.mk
@@ -0,0 +1,51 @@
+###########################################################
+## Standard rules for building a normal shared library.
+##
+## Additional inputs from base_rules.make:
+## None.
+##
+## LOCAL_MODULE_SUFFIX will be set for you.
+###########################################################
+
+ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+endif
+ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
+LOCAL_MODULE_SUFFIX := $($(my_prefix)SHLIB_SUFFIX)
+endif
+ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),)
+$(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
+endif
+ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),)
+$(error $(LOCAL_PATH): Cannot set module stem for a library)
+endif
+
+$(call host-shared-library-hook)
+
+skip_build_from_source :=
+ifdef LOCAL_PREBUILT_MODULE_FILE
+ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+skip_build_from_source := true
+endif
+endif
+
+ifndef skip_build_from_source
+
+# Put the built modules of all shared libraries in a common directory
+# to simplify the link line.
+OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
+
+include $(BUILD_SYSTEM)/binary.mk
+
+my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
+$(LOCAL_BUILD_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt)
+
+$(LOCAL_BUILT_MODULE): \
+ $(all_objects) \
+ $(all_libraries) \
+ $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ $(transform-host-o-to-shared-lib)
+
+endif # skip_build_from_source
diff --git a/core/host_shared_test_lib.mk b/core/host_shared_test_lib.mk
new file mode 100644
index 0000000000000000000000000000000000000000..1eb9b2611639b93d4f04d3f34ac7f39f16326bab
--- /dev/null
+++ b/core/host_shared_test_lib.mk
@@ -0,0 +1,8 @@
+##################################################
+## A thin wrapper around BUILD_HOST_SHARED_LIBRARY
+## Common flags for host native tests are added.
+##################################################
+
+include $(BUILD_SYSTEM)/host_test_internal.mk
+
+include $(BUILD_HOST_SHARED_LIBRARY)
diff --git a/core/host_static_library.mk b/core/host_static_library.mk
new file mode 100644
index 0000000000000000000000000000000000000000..068c702175ac61780df33705dc45d705683b9456
--- /dev/null
+++ b/core/host_static_library.mk
@@ -0,0 +1,75 @@
+LOCAL_IS_HOST_MODULE := true
+my_prefix := HOST_
+LOCAL_HOST_PREFIX :=
+include $(BUILD_SYSTEM)/multilib.mk
+
+ifndef LOCAL_MODULE_HOST_ARCH
+ifndef my_module_multilib
+ifeq ($(HOST_PREFER_32_BIT),true)
+my_module_multilib := 32
+else
+# libraries default to building for both architecturess
+my_module_multilib := both
+endif
+endif
+endif
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
+include $(BUILD_SYSTEM)/host_static_library_internal.mk
+endif
+
+ifdef HOST_2ND_ARCH
+LOCAL_2ND_ARCH_VAR_PREFIX := $(HOST_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# Build for HOST_2ND_ARCH
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+include $(BUILD_SYSTEM)/host_static_library_internal.mk
+endif
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif # HOST_2ND_ARCH
+
+ifdef HOST_CROSS_OS
+my_prefix := HOST_CROSS_
+LOCAL_HOST_PREFIX := $(my_prefix)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# Build for Windows
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+include $(BUILD_SYSTEM)/host_static_library_internal.mk
+endif
+
+ifdef HOST_CROSS_2ND_ARCH
+LOCAL_2ND_ARCH_VAR_PREFIX := $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# Build for HOST_CROSS_2ND_ARCH
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+include $(BUILD_SYSTEM)/host_static_library_internal.mk
+endif
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif
+LOCAL_HOST_PREFIX :=
+endif
+
+my_module_arch_supported :=
+
+###########################################################
+## Copy headers to the install tree
+###########################################################
+include $(BUILD_COPY_HEADERS)
diff --git a/core/host_static_library_internal.mk b/core/host_static_library_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..3946aa7bc9a363a1524090640382564770c83846
--- /dev/null
+++ b/core/host_static_library_internal.mk
@@ -0,0 +1,25 @@
+###########################################################
+## Standard rules for building a static library for the host.
+##
+## Additional inputs from base_rules.make:
+## None.
+##
+## LOCAL_MODULE_SUFFIX will be set for you.
+###########################################################
+
+ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+endif
+ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
+LOCAL_MODULE_SUFFIX := .a
+endif
+ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),)
+$(error $(LOCAL_PATH): Cannot set module stem for a library)
+endif
+LOCAL_UNINSTALLABLE_MODULE := true
+
+include $(BUILD_SYSTEM)/binary.mk
+
+$(LOCAL_BUILT_MODULE): $(built_whole_libraries)
+$(LOCAL_BUILT_MODULE): $(all_objects)
+ $(transform-host-o-to-static-lib)
diff --git a/core/host_static_test_lib.mk b/core/host_static_test_lib.mk
new file mode 100644
index 0000000000000000000000000000000000000000..5423dc6e1404958b3f421fa94fa6016ded3536d3
--- /dev/null
+++ b/core/host_static_test_lib.mk
@@ -0,0 +1,8 @@
+##################################################
+## A thin wrapper around BUILD_HOST_STATIC_LIBRARY
+## Common flags for host native tests are added.
+##################################################
+
+include $(BUILD_SYSTEM)/host_test_internal.mk
+
+include $(BUILD_HOST_STATIC_LIBRARY)
diff --git a/core/host_test_internal.mk b/core/host_test_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7f6aff0cef702a5e9653207513a5f43f6f9766a1
--- /dev/null
+++ b/core/host_test_internal.mk
@@ -0,0 +1,14 @@
+#####################################################
+## Shared definitions for all host test compilations.
+#####################################################
+
+LOCAL_CFLAGS_windows += -DGTEST_OS_WINDOWS
+LOCAL_CFLAGS_linux += -DGTEST_OS_LINUX
+LOCAL_LDLIBS_linux += -lpthread
+LOCAL_CFLAGS_darwin += -DGTEST_OS_LINUX
+LOCAL_LDLIBS_darwin += -lpthread
+
+LOCAL_CFLAGS += -DGTEST_HAS_STD_STRING -O0 -g
+LOCAL_C_INCLUDES += external/gtest/include
+
+LOCAL_STATIC_LIBRARIES += libgtest_main_host libgtest_host
diff --git a/core/install_jni_libs.mk b/core/install_jni_libs.mk
new file mode 100644
index 0000000000000000000000000000000000000000..625a8a22215e1f6341cea29638bd1e99b2cda9e1
--- /dev/null
+++ b/core/install_jni_libs.mk
@@ -0,0 +1,93 @@
+# Decides how to install the jni libraries needed by an apk.
+# Input variables:
+# my_module_multilib, LOCAL_2ND_ARCH_VAR_PREFIX (from package.mk or prebuilt.mk)
+# rs_compatibility_jni_libs (from java.mk)
+# my_module_path (from base_rules.mk)
+# partition_tag (from base_rules.mk)
+# my_prebuilt_src_file (from prebuilt_internal.mk)
+#
+# Output variables:
+# jni_shared_libraries, jni_shared_libraries_abi, jni_shared_libraries_with_abis if we are going to embed the libraries into the apk;
+# embedded_prebuilt_jni_libs, prebuilt jni libs embedded in prebuilt apk.
+#
+
+my_embed_jni :=
+ifneq ($(TARGET_BUILD_APPS),)
+my_embed_jni := true
+endif
+ifneq ($(filter tests samples, $(LOCAL_MODULE_TAGS)),)
+my_embed_jni := true
+endif
+ifeq ($(filter $(TARGET_OUT)/% $(TARGET_OUT_VENDOR)/% $(TARGET_OUT_OEM)/%, $(my_module_path)),)
+# If this app isn't to be installed to system partitions.
+my_embed_jni := true
+endif
+
+jni_shared_libraries :=
+jni_shared_libraries_abis :=
+# jni_shared_libraries_with_abis is a list of :
+jni_shared_libraries_with_abis :=
+embedded_prebuilt_jni_libs :=
+
+#######################################
+# For TARGET_ARCH
+my_2nd_arch_prefix :=
+my_add_jni :=
+# The module is built for TARGET_ARCH
+ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX))
+my_add_jni := true
+endif
+# Or it explicitly requires both
+ifeq ($(my_module_multilib),both)
+my_add_jni := true
+endif
+ifeq ($(my_add_jni),true)
+my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH))
+ifndef my_prebuilt_jni_libs
+my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS)
+endif
+include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
+jni_shared_libraries += $(my_jni_shared_libraries)
+jni_shared_libraries_abis += $(my_jni_shared_libraries_abi)
+jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\
+ $(my_jni_shared_libraries))
+embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs)
+
+# Include RS dynamically-generated libraries as well
+# TODO: Add multilib support once RS supports generating multilib libraries.
+jni_shared_libraries += $(rs_compatibility_jni_libs)
+jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\
+ $(rs_compatibility_jni_libs))
+endif # my_add_jni
+
+#######################################
+# For TARGET_2ND_ARCH
+ifdef TARGET_2ND_ARCH
+my_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
+my_add_jni :=
+# The module is built for TARGET_2ND_ARCH
+ifeq ($(my_2nd_arch_prefix),$(LOCAL_2ND_ARCH_VAR_PREFIX))
+my_add_jni := true
+endif
+# Or it explicitly requires both
+ifeq ($(my_module_multilib),both)
+my_add_jni := true
+endif
+ifeq ($(my_add_jni),true)
+my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH))
+ifndef my_prebuilt_jni_libs
+my_prebuilt_jni_libs := $(LOCAL_PREBUILT_JNI_LIBS)
+endif
+include $(BUILD_SYSTEM)/install_jni_libs_internal.mk
+jni_shared_libraries += $(my_jni_shared_libraries)
+jni_shared_libraries_abis += $(my_jni_shared_libraries_abi)
+jni_shared_libraries_with_abis += $(addprefix $(my_jni_shared_libraries_abi):,\
+ $(my_jni_shared_libraries))
+embedded_prebuilt_jni_libs += $(my_embedded_prebuilt_jni_libs)
+endif # my_add_jni
+endif # TARGET_2ND_ARCH
+
+jni_shared_libraries := $(strip $(jni_shared_libraries))
+jni_shared_libraries_abis := $(sort $(jni_shared_libraries_abis))
+jni_shared_libraries_with_abis := $(strip $(jni_shared_libraries_with_abis))
+embedded_prebuilt_jni_libs := $(strip $(embedded_prebuilt_jni_libs))
diff --git a/core/install_jni_libs_internal.mk b/core/install_jni_libs_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..27b9697e0809070b73b45bd1369d937f4ba4bd34
--- /dev/null
+++ b/core/install_jni_libs_internal.mk
@@ -0,0 +1,100 @@
+# Install jni libraries for one arch.
+# Input variables:
+# my_2nd_arch_prefix: indicate if this is for TARGET_2ND_ARCH.
+# my_embed_jni: indicate if we want to embed the jni libs in the apk.
+# my_prebuilt_jni_libs
+# my_installed_module_stem (from configure_module_stem.mk)
+# partition_tag (from base_rules.mk)
+# my_prebuilt_src_file (from prebuilt_internal.mk)
+#
+# Output variables:
+# my_jni_shared_libraries, my_jni_shared_libraries_abi, if we are going to embed the libraries into the apk;
+# my_embedded_prebuilt_jni_libs, prebuilt jni libs embedded in prebuilt apk.
+#
+
+my_jni_shared_libraries := \
+ $(addprefix $($(my_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/, \
+ $(addsuffix .so, \
+ $(LOCAL_JNI_SHARED_LIBRARIES)))
+
+# App-specific lib path.
+my_app_lib_path := $(dir $(LOCAL_INSTALLED_MODULE))lib/$(TARGET_$(my_2nd_arch_prefix)ARCH)
+my_embedded_prebuilt_jni_libs :=
+
+ifdef my_embed_jni
+# App explicitly requires the prebuilt NDK stl shared libraies.
+# The NDK stl shared libraries should never go to the system image.
+ifneq ($(filter $(LOCAL_NDK_STL_VARIANT), stlport_shared c++_shared),)
+ifndef LOCAL_SDK_VERSION
+$(error LOCAL_SDK_VERSION must be defined with LOCAL_NDK_STL_VARIANT, \
+ LOCAL_PACKAGE_NAME=$(LOCAL_PACKAGE_NAME))
+endif
+endif
+ifeq (stlport_shared,$(LOCAL_NDK_STL_VARIANT))
+my_jni_shared_libraries += \
+ $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/stlport/libs/$(TARGET_$(my_2nd_arch_prefix)CPU_ABI)/libstlport_shared.so
+else ifeq (c++_shared,$(LOCAL_NDK_STL_VARIANT))
+my_jni_shared_libraries += \
+ $(HISTORICAL_NDK_VERSIONS_ROOT)/current/sources/cxx-stl/llvm-libc++/libs/$(TARGET_$(my_2nd_arch_prefix)CPU_ABI)/libc++_shared.so
+endif
+
+# Set the abi directory used by the local JNI shared libraries.
+# (Doesn't change how the local shared libraries are compiled, just
+# sets where they are stored in the apk.)
+ifeq ($(LOCAL_JNI_SHARED_LIBRARIES_ABI),)
+ my_jni_shared_libraries_abi := $(TARGET_$(my_2nd_arch_prefix)CPU_ABI)
+else
+ my_jni_shared_libraries_abi := $(LOCAL_JNI_SHARED_LIBRARIES_ABI)
+endif
+
+else # not my_embed_jni
+
+my_jni_shared_libraries := $(strip $(my_jni_shared_libraries))
+ifneq ($(my_jni_shared_libraries),)
+# The jni libaries will be installed to the system.img.
+my_jni_filenames := $(notdir $(my_jni_shared_libraries))
+# Make sure the JNI libraries get installed
+my_shared_library_path := $($(my_2nd_arch_prefix)TARGET_OUT$(partition_tag)_SHARED_LIBRARIES)
+# Do not use order-only dependency, because we want to rebuild the image if an jni is updated.
+$(LOCAL_INSTALLED_MODULE) : $(addprefix $(my_shared_library_path)/, $(my_jni_filenames))
+
+# Create symlink in the app specific lib path
+ifdef LOCAL_POST_INSTALL_CMD
+# Add a shell command separator
+LOCAL_POST_INSTALL_CMD += ;
+endif
+
+my_symlink_target_dir := $(patsubst $(PRODUCT_OUT)%,%,\
+ $(my_shared_library_path))
+LOCAL_POST_INSTALL_CMD += \
+ mkdir -p $(my_app_lib_path) \
+ $(foreach lib, $(my_jni_filenames), ;ln -sf $(my_symlink_target_dir)/$(lib) $(my_app_lib_path)/$(lib))
+$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
+
+# Clear jni_shared_libraries to not embed it into the apk.
+my_jni_shared_libraries :=
+endif # $(my_jni_shared_libraries) not empty
+endif # my_embed_jni
+
+ifdef my_prebuilt_jni_libs
+# Files like @lib//libfoo.so (path inside the apk) are JNI libs embedded prebuilt apk;
+# Files like path/to/libfoo.so (path relative to LOCAL_PATH) are prebuilts in the source tree.
+my_embedded_prebuilt_jni_libs := $(patsubst @%,%, \
+ $(filter @%, $(my_prebuilt_jni_libs)))
+
+# prebuilt JNI exsiting as separate source files.
+my_prebuilt_jni_libs := $(addprefix $(LOCAL_PATH)/, \
+ $(filter-out @%, $(my_prebuilt_jni_libs)))
+ifdef my_prebuilt_jni_libs
+ifdef my_embed_jni
+# Embed my_prebuilt_jni_libs to the apk
+my_jni_shared_libraries += $(my_prebuilt_jni_libs)
+else # not my_embed_jni
+# Install my_prebuilt_jni_libs as separate files.
+$(foreach lib, $(my_prebuilt_jni_libs), \
+ $(eval $(call copy-one-file, $(lib), $(my_app_lib_path)/$(notdir $(lib)))))
+
+$(LOCAL_INSTALLED_MODULE) : $(addprefix $(my_app_lib_path)/, $(notdir $(my_prebuilt_jni_libs)))
+endif # my_embed_jni
+endif # inner my_prebuilt_jni_libs
+endif # outer my_prebuilt_jni_libs
diff --git a/core/jack-default.args b/core/jack-default.args
new file mode 100644
index 0000000000000000000000000000000000000000..8d70a820d4084b1e77e60f4e9a00b4a383465b8e
--- /dev/null
+++ b/core/jack-default.args
@@ -0,0 +1,5 @@
+-D sched.runner=multi-threaded
+-D sched.runner.thread.kind=fixed
+-D sched.runner.thread.fixed.count=4
+--sanity-checks off
+-D jack.reporter.level.file=error=--,warning=-
\ No newline at end of file
diff --git a/core/java.mk b/core/java.mk
new file mode 100644
index 0000000000000000000000000000000000000000..2602daf53ac7ae83463615a72538c044d4a19063
--- /dev/null
+++ b/core/java.mk
@@ -0,0 +1,749 @@
+# Target Java.
+# Requires:
+# LOCAL_MODULE_SUFFIX
+# LOCAL_MODULE_CLASS
+# all_res_assets
+
+ifeq ($(TARGET_BUILD_PDK),true)
+ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
+# LOCAL_SDK not defined or set to current
+ifeq ($(filter-out current,$(LOCAL_SDK_VERSION)),)
+ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+LOCAL_SDK_VERSION := $(PDK_BUILD_SDK_VERSION)
+endif #!LOCAL_NO_STANDARD_LIBRARIES
+endif
+endif # !PDK_JAVA
+endif #PDK
+
+LOCAL_NO_STANDARD_LIBRARIES:=$(strip $(LOCAL_NO_STANDARD_LIBRARIES))
+LOCAL_SDK_VERSION:=$(strip $(LOCAL_SDK_VERSION))
+
+ifneq ($(LOCAL_SDK_VERSION),)
+ ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+ $(error $(LOCAL_PATH): Must not define both LOCAL_NO_STANDARD_LIBRARIES and LOCAL_SDK_VERSION)
+ else
+ ifeq ($(strip $(filter $(LOCAL_SDK_VERSION),$(TARGET_AVAILABLE_SDK_VERSIONS))),)
+ $(error $(LOCAL_PATH): Invalid LOCAL_SDK_VERSION '$(LOCAL_SDK_VERSION)' \
+ Choices are: $(TARGET_AVAILABLE_SDK_VERSIONS))
+ else
+ ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
+ # Use android_stubs_current if LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
+ LOCAL_JAVA_LIBRARIES := android_stubs_current $(LOCAL_JAVA_LIBRARIES)
+ else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
+ LOCAL_JAVA_LIBRARIES := android_system_stubs_current $(LOCAL_JAVA_LIBRARIES)
+ else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current)
+ LOCAL_JAVA_LIBRARIES := android_test_stubs_current $(LOCAL_JAVA_LIBRARIES)
+ else
+ LOCAL_JAVA_LIBRARIES := sdk_v$(LOCAL_SDK_VERSION) $(LOCAL_JAVA_LIBRARIES)
+ endif
+
+ ifeq ($(LOCAL_SDK_VERSION),current)
+ my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
+ else ifeq ($(LOCAL_SDK_VERSION),system_current)
+ my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
+ else ifeq ($(LOCAL_SDK_VERSION),test_current)
+ my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
+ else
+ my_jack_min_sdk_version := $(LOCAL_SDK_VERSION)
+ endif
+ endif
+ endif
+else
+ my_jack_min_sdk_version := $(PLATFORM_JACK_MIN_SDK_VERSION)
+ ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+ LOCAL_JAVA_LIBRARIES := $(TARGET_DEFAULT_JAVA_LIBRARIES) $(LOCAL_JAVA_LIBRARIES)
+ endif
+endif
+
+ifneq (,$(strip $(LOCAL_MIN_SDK_VERSION)))
+ my_jack_min_sdk_version := $(LOCAL_MIN_SDK_VERSION)
+endif
+
+proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
+ifneq ($(proto_sources),)
+ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
+ LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-micro
+else
+ ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
+ LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-nano
+ else
+ LOCAL_STATIC_JAVA_LIBRARIES += libprotobuf-java-lite
+ endif
+endif
+endif
+
+# LOCAL_STATIC_JAVA_AAR_LIBRARIES and LOCAL_STATIC_ANDROID_LIBRARIES are also LOCAL_STATIC_JAVA_LIBRARIES.
+LOCAL_STATIC_JAVA_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_LIBRARIES) \
+ $(LOCAL_STATIC_JAVA_AAR_LIBRARIES) \
+ $(LOCAL_STATIC_ANDROID_LIBRARIES))
+# LOCAL_SHARED_ANDROID_LIBRARIES are also LOCAL_JAVA_LIBRARIES.
+LOCAL_JAVA_LIBRARIES := $(sort $(LOCAL_JAVA_LIBRARIES) $(LOCAL_SHARED_ANDROID_LIBRARIES))
+
+LOCAL_BUILT_MODULE_STEM := $(strip $(LOCAL_BUILT_MODULE_STEM))
+ifeq ($(LOCAL_BUILT_MODULE_STEM),)
+$(error $(LOCAL_PATH): Target java template must define LOCAL_BUILT_MODULE_STEM)
+endif
+ifneq ($(filter classes-compiled.jar classes.jar,$(LOCAL_BUILT_MODULE_STEM)),)
+$(error LOCAL_BUILT_MODULE_STEM may not be "$(LOCAL_BUILT_MODULE_STEM)")
+endif
+
+
+##############################################################################
+# Define the intermediate targets before including base_rules so they get
+# the correct environment.
+##############################################################################
+
+intermediates := $(call local-intermediates-dir)
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
+
+# Choose leaf name for the compiled jar file.
+ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
+full_classes_compiled_jar_leaf := classes-no-debug-var.jar
+built_dex_intermediate_leaf := no-local
+else
+full_classes_compiled_jar_leaf := classes-full-debug.jar
+built_dex_intermediate_leaf := with-local
+endif
+
+ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
+LOCAL_PROGUARD_ENABLED :=
+endif
+
+ifdef LOCAL_PROGUARD_ENABLED
+proguard_jar_leaf := proguard.classes.jar
+else
+proguard_jar_leaf := noproguard.classes.jar
+endif
+
+full_classes_compiled_jar := $(intermediates.COMMON)/$(full_classes_compiled_jar_leaf)
+jarjar_leaf := classes-jarjar.jar
+full_classes_jarjar_jar := $(intermediates.COMMON)/$(jarjar_leaf)
+emma_intermediates_dir := $(intermediates.COMMON)/emma_out
+# emma is hardcoded to use the leaf name of its input for the output file --
+# only the output directory can be changed
+full_classes_emma_jar := $(emma_intermediates_dir)/lib/$(jarjar_leaf)
+full_classes_proguard_jar := $(intermediates.COMMON)/$(proguard_jar_leaf)
+built_dex_intermediate := $(intermediates.COMMON)/$(built_dex_intermediate_leaf)/classes.dex
+full_classes_stubs_jar := $(intermediates.COMMON)/stubs.jar
+
+ifeq ($(LOCAL_MODULE_CLASS)$(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),APPS)
+# If this is an apk without any Java code (e.g. framework-res), we should skip compiling Java.
+full_classes_jar :=
+built_dex :=
+else
+full_classes_jar := $(intermediates.COMMON)/classes.jar
+built_dex := $(intermediates.COMMON)/classes.dex
+endif
+# final Jack library, shrinked and obfuscated if it must be
+full_classes_jack := $(intermediates.COMMON)/classes.jack
+# intermediate Jack library without shrink and obfuscation
+noshrob_classes_jack := $(intermediates.COMMON)/classes.noshrob.jack
+jack_check_timestamp := $(intermediates.COMMON)/jack.check.timestamp
+
+LOCAL_INTERMEDIATE_TARGETS += \
+ $(full_classes_compiled_jar) \
+ $(full_classes_jarjar_jar) \
+ $(full_classes_emma_jar) \
+ $(full_classes_jar) \
+ $(full_classes_proguard_jar) \
+ $(built_dex_intermediate) \
+ $(full_classes_jack) \
+ $(noshrob_classes_jack) \
+ $(jack_check_timestamp) \
+ $(built_dex) \
+ $(full_classes_stubs_jar)
+
+
+LOCAL_INTERMEDIATE_SOURCE_DIR := $(intermediates.COMMON)/src
+
+###############################################################
+## .rs files: RenderScript sources to .java files and .bc files
+## .fs files: Filterscript sources to .java files and .bc files
+###############################################################
+renderscript_sources := $(filter %.rs %.fs,$(LOCAL_SRC_FILES))
+# Because names of the java files from RenderScript are unknown until the
+# .rs file(s) are compiled, we have to depend on a timestamp file.
+RenderScript_file_stamp :=
+rs_generated_res_dir :=
+rs_compatibility_jni_libs :=
+ifneq ($(renderscript_sources),)
+renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
+RenderScript_file_stamp := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/RenderScript.stamp
+renderscript_intermediate.COMMON := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/renderscript
+
+# Defaulting to an empty string uses the latest available platform SDK.
+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
+
+# For 64-bit, we always have to upgrade to at least 21 for compat build.
+ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),)
+ ifeq ($(TARGET_IS_64_BIT),true)
+ ifneq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),)
+ renderscript_target_api := 21
+ endif
+ endif
+endif
+
+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)
+
+# prepend the RenderScript system include path
+ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current test_current,$(LOCAL_SDK_VERSION))),)
+# if a numeric LOCAL_SDK_VERSION, or current LOCAL_SDK_VERSION with TARGET_BUILD_APPS
+LOCAL_RENDERSCRIPT_INCLUDES := \
+ $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/clang-include \
+ $(HISTORICAL_SDK_VERSIONS_ROOT)/renderscript/include \
+ $(LOCAL_RENDERSCRIPT_INCLUDES)
+else
+LOCAL_RENDERSCRIPT_INCLUDES := \
+ $(TOPDIR)external/clang/lib/Headers \
+ $(TOPDIR)frameworks/rs/scriptc \
+ $(LOCAL_RENDERSCRIPT_INCLUDES)
+endif
+
+ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
+LOCAL_RENDERSCRIPT_INCLUDES := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
+endif
+
+bc_files := $(patsubst %.fs,%.bc, $(patsubst %.rs,%.bc, $(notdir $(renderscript_sources))))
+bc_dep_files := $(addprefix $(renderscript_intermediate.COMMON)/,$(patsubst %.bc,%.d,$(bc_files)))
+
+$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(LOCAL_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)
+# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
+# automatically found by the java compiling function transform-java-to-classes.jar.
+$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate.COMMON)
+$(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-java-and-bc)
+
+# include the dependency files (.d/.P) generated by llvm-rs-cc.
+$(call include-depfile,$(RenderScript_file_stamp).P,$(RenderScript_file_stamp))
+
+ifneq ($(LOCAL_RENDERSCRIPT_COMPATIBILITY),)
+
+
+ifeq ($(filter $(RSCOMPAT_32BIT_ONLY_API_LEVELS),$(renderscript_target_api)),)
+ifeq ($(TARGET_IS_64_BIT),true)
+renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc64/
+else
+renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/bc32/
+endif
+else
+renderscript_intermediate.bc_folder := $(renderscript_intermediate.COMMON)/res/raw/
+endif
+
+rs_generated_bc := $(addprefix \
+ $(renderscript_intermediate.bc_folder), $(bc_files))
+
+renderscript_intermediate := $(intermediates)/renderscript
+
+# We don't need the .so files in bundled branches
+# Prevent these from showing up on the device
+# One exception is librsjni.so, which is needed for
+# both native path and compat path.
+rs_jni_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/librsjni.so
+LOCAL_JNI_SHARED_LIBRARIES += librsjni
+
+ifneq (,$(TARGET_BUILD_APPS)$(FORCE_BUILD_RS_COMPAT))
+
+rs_compatibility_jni_libs := $(addprefix \
+ $(renderscript_intermediate)/librs., \
+ $(patsubst %.bc,%.so, $(bc_files)))
+
+$(rs_generated_bc) : $(RenderScript_file_stamp)
+
+rs_support_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupport.so
+LOCAL_JNI_SHARED_LIBRARIES += libRSSupport
+
+rs_support_io_lib :=
+# check if the target api level support USAGE_IO
+ifeq ($(filter $(RSCOMPAT_NO_USAGEIO_API_LEVELS),$(renderscript_target_api)),)
+rs_support_io_lib := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/libRSSupportIO.so
+LOCAL_JNI_SHARED_LIBRARIES += libRSSupportIO
+endif
+
+
+$(rs_compatibility_jni_libs): $(RenderScript_file_stamp) $(RS_PREBUILT_CLCORE) \
+ $(rs_support_lib) $(rs_support_io_lib) $(rs_jni_lib) $(rs_compiler_rt)
+$(rs_compatibility_jni_libs): $(BCC_COMPAT)
+$(rs_compatibility_jni_libs): PRIVATE_CXX := $(CXX_WRAPPER) $(TARGET_CXX)
+$(rs_compatibility_jni_libs): $(renderscript_intermediate)/librs.%.so: \
+ $(renderscript_intermediate.bc_folder)%.bc
+ $(transform-bc-to-so)
+
+endif
+
+endif
+
+LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
+# Make sure the generated resource will be added to the apk.
+rs_generated_res_dir := $(renderscript_intermediate.COMMON)/res
+LOCAL_RESOURCE_DIR := $(rs_generated_res_dir) $(LOCAL_RESOURCE_DIR)
+endif
+
+
+###########################################################
+## AIDL: Compile .aidl files to .java
+###########################################################
+aidl_sources := $(filter %.aidl,$(LOCAL_SRC_FILES))
+
+ifneq ($(strip $(aidl_sources)),)
+aidl_java_sources := $(patsubst %.aidl,%.java,$(addprefix $(intermediates.COMMON)/src/, $(aidl_sources)))
+aidl_sources := $(addprefix $(LOCAL_PATH)/, $(aidl_sources))
+
+aidl_preprocess_import :=
+ifdef LOCAL_SDK_VERSION
+ifneq ($(filter current system_current test_current, $(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS)),)
+ # LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS
+ aidl_preprocess_import := $(TARGET_OUT_COMMON_INTERMEDIATES)/framework.aidl
+else
+ aidl_preprocess_import := $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_VERSION)/framework.aidl
+endif # not current or system_current
+else
+# build against the platform.
+LOCAL_AIDL_INCLUDES += $(FRAMEWORKS_BASE_JAVA_SRC_DIRS)
+endif # LOCAL_SDK_VERSION
+$(aidl_java_sources): PRIVATE_AIDL_FLAGS := -b $(addprefix -p,$(aidl_preprocess_import)) -I$(LOCAL_PATH) -I$(LOCAL_PATH)/src $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
+
+$(aidl_java_sources): $(intermediates.COMMON)/src/%.java: \
+ $(LOCAL_PATH)/%.aidl \
+ $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) \
+ $(AIDL) \
+ $(aidl_preprocess_import)
+ $(transform-aidl-to-java)
+$(foreach java,$(aidl_java_sources), \
+ $(call include-depfile,$(java:%.java=%.P),$(java)))
+
+else
+aidl_java_sources :=
+endif
+
+##########################################
+
+# All of the rules after full_classes_compiled_jar are very unlikely
+# to fail except for bugs in their respective tools. If you would
+# like to run these rules, add the "all" modifier goal to the make
+# command line.
+ifndef LOCAL_CHECKED_MODULE
+ifdef full_classes_jar
+ifdef LOCAL_JACK_ENABLED
+LOCAL_CHECKED_MODULE := $(jack_check_timestamp)
+else
+LOCAL_CHECKED_MODULE := $(full_classes_compiled_jar)
+endif
+endif
+endif
+
+#######################################
+include $(BUILD_SYSTEM)/base_rules.mk
+#######################################
+
+###########################################################
+## logtags: emit java source
+###########################################################
+ifneq ($(strip $(logtags_sources)),)
+
+logtags_java_sources := $(patsubst %.logtags,%.java,$(addprefix $(intermediates.COMMON)/src/, $(logtags_sources)))
+logtags_sources := $(addprefix $(LOCAL_PATH)/, $(logtags_sources))
+
+$(logtags_java_sources): $(intermediates.COMMON)/src/%.java: $(LOCAL_PATH)/%.logtags $(TARGET_OUT_COMMON_INTERMEDIATES)/all-event-log-tags.txt
+ $(transform-logtags-to-java)
+
+else
+logtags_java_sources :=
+endif
+
+##########################################
+java_sources := $(addprefix $(LOCAL_PATH)/, $(filter %.java,$(LOCAL_SRC_FILES))) $(aidl_java_sources) $(logtags_java_sources) \
+ $(filter %.java,$(LOCAL_GENERATED_SOURCES))
+all_java_sources := $(java_sources) $(addprefix $(TARGET_OUT_COMMON_INTERMEDIATES)/, $(filter %.java,$(LOCAL_INTERMEDIATE_SOURCES)))
+
+include $(BUILD_SYSTEM)/java_common.mk
+
+#######################################
+# defines built_odex along with rule to install odex
+include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
+#######################################
+
+# Make sure there's something to build.
+ifdef full_classes_jar
+ifndef need_compile_java
+$(error $(LOCAL_PATH): Target java module does not define any source or resource files)
+endif
+endif
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_MIN_SDK_VERSION := $(my_jack_min_sdk_version)
+my_jack_min_sdk_version :=
+
+# Since we're using intermediates.COMMON, make sure that it gets cleaned
+# properly.
+$(cleantarget): PRIVATE_CLEAN_FILES += $(intermediates.COMMON)
+
+ifdef full_classes_jar
+
+# Droiddoc isn't currently able to generate stubs for modules, so we're just
+# allowing it to use the classes.jar as the "stubs" that would be use to link
+# against, for the cases where someone needs the jar to link against.
+# - Use the classes.jar instead of the handful of other intermediates that
+# we have, because it's the most processed, but still hasn't had dex run on
+# it, so it's closest to what's on the device.
+# - This extra copy, with the dependency on LOCAL_BUILT_MODULE allows the
+# PRIVATE_ vars to be preserved.
+$(full_classes_stubs_jar): PRIVATE_SOURCE_FILE := $(full_classes_jar)
+$(full_classes_stubs_jar) : $(full_classes_jar) | $(ACP)
+ @echo Copying $(PRIVATE_SOURCE_FILE)
+ $(hide) $(ACP) -fp $(PRIVATE_SOURCE_FILE) $@
+ALL_MODULES.$(LOCAL_MODULE).STUBS := $(full_classes_stubs_jar)
+
+# The layers file allows you to enforce a layering between java packages.
+# Run build/tools/java-layers.py for more details.
+layers_file := $(addprefix $(LOCAL_PATH)/, $(LOCAL_JAVA_LAYERS_FILE))
+$(full_classes_compiled_jar): PRIVATE_JAVA_LAYERS_FILE := $(layers_file)
+$(full_classes_compiled_jar): PRIVATE_WARNINGS_ENABLE := $(LOCAL_WARNINGS_ENABLE)
+
+ifdef LOCAL_RMTYPEDEFS
+$(full_classes_compiled_jar): | $(RMTYPEDEFS)
+endif
+
+# Compile the java files to a .jar file.
+# This intentionally depends on java_sources, not all_java_sources.
+# Deps for generated source files must be handled separately,
+# via deps on the target that generates the sources.
+$(full_classes_compiled_jar): PRIVATE_JAVACFLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JAVACFLAGS)
+$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_FILES := $(LOCAL_JAR_EXCLUDE_FILES)
+$(full_classes_compiled_jar): PRIVATE_JAR_PACKAGES := $(LOCAL_JAR_PACKAGES)
+$(full_classes_compiled_jar): PRIVATE_JAR_EXCLUDE_PACKAGES := $(LOCAL_JAR_EXCLUDE_PACKAGES)
+$(full_classes_compiled_jar): PRIVATE_DONT_DELETE_JAR_META_INF := $(LOCAL_DONT_DELETE_JAR_META_INF)
+$(full_classes_compiled_jar): \
+ $(java_sources) \
+ $(java_resource_sources) \
+ $(full_java_lib_deps) \
+ $(jar_manifest_file) \
+ $(layers_file) \
+ $(RenderScript_file_stamp) \
+ $(proto_java_sources_file_stamp) \
+ $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ $(transform-java-to-classes.jar)
+
+# Run jarjar if necessary, otherwise just copy the file.
+ifneq ($(strip $(LOCAL_JARJAR_RULES)),)
+$(full_classes_jarjar_jar): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) $(LOCAL_JARJAR_RULES) | $(JARJAR)
+ @echo JarJar: $@
+ $(hide) java -jar $(JARJAR) process $(PRIVATE_JARJAR_RULES) $< $@
+else
+$(full_classes_jarjar_jar): $(full_classes_compiled_jar) | $(ACP)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+endif
+
+full_classes_jar_source := $(full_classes_jarjar_jar)
+ifndef LOCAL_JACK_ENABLED
+ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILE := $(intermediates.COMMON)/coverage.emma.ignore
+$(full_classes_emma_jar): PRIVATE_EMMA_INTERMEDIATES_DIR := $(emma_intermediates_dir)
+# module level coverage filter can be defined using LOCAL_EMMA_COVERAGE_FILTER
+# in Android.mk
+ifdef LOCAL_EMMA_COVERAGE_FILTER
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := $(LOCAL_EMMA_COVERAGE_FILTER)
+else
+# by default, avoid applying emma instrumentation onto emma classes itself,
+# otherwise there will be exceptions thrown
+$(full_classes_emma_jar): PRIVATE_EMMA_COVERAGE_FILTER := *,-emma,-emmarun,-com.vladium.*
+endif
+# this rule will generate both $(PRIVATE_EMMA_COVERAGE_FILE) and
+# $(full_classes_emma_jar)
+$(full_classes_emma_jar): $(full_classes_jarjar_jar) | $(EMMA_JAR)
+ $(transform-classes.jar-to-emma)
+full_classes_jar_source := $(full_classes_emma_jar)
+endif
+endif
+
+# Keep a copy of the jar just before proguard processing.
+$(full_classes_jar): $(full_classes_jar_source) | $(ACP)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+
+$(call define-jar-to-toc-rule, $(full_classes_jar))
+
+# Run proguard if necessary, otherwise just copy the file.
+ifdef LOCAL_PROGUARD_ENABLED
+ifneq ($(filter-out full custom nosystem obfuscation optimization shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
+ $(warning while processing: $(LOCAL_MODULE))
+ $(error invalid value for LOCAL_PROGUARD_ENABLED: $(LOCAL_PROGUARD_ENABLED))
+endif
+proguard_dictionary := $(intermediates.COMMON)/proguard_dictionary
+jack_dictionary := $(intermediates.COMMON)/jack_dictionary
+
+# Hack: see b/20667396
+# When an app's LOCAL_SDK_VERSION is lower than the support library's LOCAL_SDK_VERSION,
+# we artifically raises the "SDK version" "linked" by ProGuard, to
+# - suppress ProGuard warnings of referencing symbols unknown to the lower SDK version.
+# - prevent ProGuard stripping subclass in the support library that extends class added in the higher SDK version.
+my_support_library_sdk_raise :=
+ifneq (,$(filter android-support-%,$(LOCAL_STATIC_JAVA_LIBRARIES)))
+ifdef LOCAL_SDK_VERSION
+ifdef TARGET_BUILD_APPS
+ifeq (,$(filter current system_current test_current, $(LOCAL_SDK_VERSION)))
+ my_support_library_sdk_raise := $(call java-lib-files, sdk_vcurrent)
+endif
+else
+ # For platform build, we can't just raise to the "current" SDK,
+ # that would break apps that use APIs removed from the current SDK.
+ my_support_library_sdk_raise := $(call java-lib-files,$(TARGET_DEFAULT_JAVA_LIBRARIES))
+endif
+endif
+endif
+
+# jack already has the libraries in its classpath and doesn't support jars
+legacy_proguard_flags := $(addprefix -libraryjars ,$(my_support_library_sdk_raise) $(full_shared_java_libs))
+
+legacy_proguard_flags += -printmapping $(proguard_dictionary)
+jack_proguard_flags := -printmapping $(jack_dictionary)
+
+common_proguard_flags := -forceprocessing
+
+ifeq ($(filter nosystem,$(LOCAL_PROGUARD_ENABLED)),)
+common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.flags
+ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
+ifdef LOCAL_JACK_ENABLED
+common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
+else
+common_proguard_flags += -include $(BUILD_SYSTEM)/proguard.emma.flags
+endif # LOCAL_JACK_ENABLED
+endif
+# If this is a test package, add proguard keep flags for tests.
+ifneq ($(LOCAL_INSTRUMENTATION_FOR)$(filter tests,$(LOCAL_MODULE_TAGS)),)
+common_proguard_flags += -include $(BUILD_SYSTEM)/proguard_tests.flags
+ifeq ($(filter shrinktests,$(LOCAL_PROGUARD_ENABLED)),)
+common_proguard_flags += -dontshrink # don't shrink tests by default
+endif # shrinktests
+endif # test package
+ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
+# By default no obfuscation
+common_proguard_flags += -dontobfuscate
+endif # No obfuscation
+ifeq ($(filter optimization,$(LOCAL_PROGUARD_ENABLED)),)
+# By default no optimization
+common_proguard_flags += -dontoptimize
+endif # No optimization
+
+ifdef LOCAL_INSTRUMENTATION_FOR
+ifeq ($(filter obfuscation,$(LOCAL_PROGUARD_ENABLED)),)
+# If no obfuscation, link in the instrmented package's classes.jar as a library.
+# link_instr_classes_jar is defined in base_rule.mk
+# jack already has this library in its classpath and doesn't support jars
+legacy_proguard_flags += -libraryjars $(link_instr_classes_jar)
+else # obfuscation
+# If obfuscation is enabled, the main app must be obfuscated too.
+# We need to run obfuscation using the main app's dictionary,
+# and treat the main app's class.jar as injars instead of libraryjars.
+legacy_proguard_flags := -injars $(link_instr_classes_jar) \
+ -outjars $(intermediates.COMMON)/proguard.$(LOCAL_INSTRUMENTATION_FOR).jar \
+ -include $(link_instr_intermediates_dir.COMMON)/proguard_options \
+ -applymapping $(link_instr_intermediates_dir.COMMON)/proguard_dictionary \
+ -verbose \
+ $(legacy_proguard_flags)
+ifdef LOCAL_JACK_ENABLED
+jack_proguard_flags += -applymapping $(link_instr_intermediates_dir.COMMON)/jack_dictionary
+full_jack_deps += $(link_instr_intermediates_dir.COMMON)/jack_dictionary
+endif
+
+# Sometimes (test + main app) uses different keep rules from the main app -
+# apply the main app's dictionary anyway.
+legacy_proguard_flags += -ignorewarnings
+
+# Make sure we run Proguard on the main app first
+$(full_classes_proguard_jar) : $(link_instr_intermediates_dir.COMMON)/proguard.classes.jar
+
+endif # no obfuscation
+endif # LOCAL_INSTRUMENTATION_FOR
+endif # LOCAL_PROGUARD_ENABLED is not nosystem
+
+proguard_flag_files := $(addprefix $(LOCAL_PATH)/, $(LOCAL_PROGUARD_FLAG_FILES))
+LOCAL_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files))
+
+ifdef LOCAL_TEST_MODULE_TO_PROGUARD_WITH
+extra_input_jar := $(call intermediates-dir-for,APPS,$(LOCAL_TEST_MODULE_TO_PROGUARD_WITH),,COMMON)/classes.jar
+else
+extra_input_jar :=
+endif
+$(full_classes_proguard_jar): PRIVATE_EXTRA_INPUT_JAR := $(extra_input_jar)
+$(full_classes_proguard_jar): PRIVATE_PROGUARD_FLAGS := $(legacy_proguard_flags) $(common_proguard_flags) $(LOCAL_PROGUARD_FLAGS)
+$(full_classes_proguard_jar) : $(full_classes_jar) $(extra_input_jar) $(my_support_library_sdk_raise) $(proguard_flag_files) | $(ACP) $(PROGUARD)
+ $(call transform-jar-to-proguard)
+
+else # LOCAL_PROGUARD_ENABLED not defined
+$(full_classes_proguard_jar) : $(full_classes_jar)
+ @echo Copying: $@
+ $(hide) $(ACP) -fp $< $@
+
+endif # LOCAL_PROGUARD_ENABLED defined
+
+ifndef LOCAL_JACK_ENABLED
+# Override PRIVATE_INTERMEDIATES_DIR so that install-dex-debug
+# will work even when intermediates != intermediates.COMMON.
+$(built_dex_intermediate): PRIVATE_INTERMEDIATES_DIR := $(intermediates.COMMON)
+$(built_dex_intermediate): PRIVATE_DX_FLAGS := $(LOCAL_DX_FLAGS)
+# If you instrument class files that have local variable debug information in
+# them emma does not correctly maintain the local variable table.
+# This will cause an error when you try to convert the class files for Android.
+# The workaround here is to build different dex file here based on emma switch
+# then later copy into classes.dex. When emma is on, dx is run with --no-locals
+# option to remove local variable information
+ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
+$(built_dex_intermediate): PRIVATE_DX_FLAGS += --no-locals
+endif
+endif # LOCAL_JACK_ENABLED is disabled
+
+$(built_dex): $(built_dex_intermediate) | $(ACP)
+ @echo Copying: $@
+ $(hide) mkdir -p $(dir $@)
+ $(hide) rm -f $(dir $@)/classes*.dex
+ $(hide) $(ACP) -fp $(dir $<)/classes*.dex $(dir $@)
+ifneq ($(GENERATE_DEX_DEBUG),)
+ $(install-dex-debug)
+endif
+
+findbugs_xml := $(intermediates.COMMON)/findbugs.xml
+$(findbugs_xml): PRIVATE_AUXCLASSPATH := $(addprefix -auxclasspath ,$(strip \
+ $(call normalize-path-list,$(filter %.jar,$(full_java_libs)))))
+$(findbugs_xml): PRIVATE_FINDBUGS_FLAGS := $(LOCAL_FINDBUGS_FLAGS)
+$(findbugs_xml) : $(full_classes_jar) $(filter %.xml, $(LOCAL_FINDBUGS_FLAGS))
+ @echo Findbugs: $@
+ $(hide) $(FINDBUGS) -textui -effort:min -xml:withMessages \
+ $(PRIVATE_AUXCLASSPATH) $(PRIVATE_FINDBUGS_FLAGS) \
+ $< \
+ > $@
+
+ALL_FINDBUGS_FILES += $(findbugs_xml)
+
+findbugs_html := $(PRODUCT_OUT)/findbugs/$(LOCAL_MODULE).html
+$(findbugs_html) : PRIVATE_XML_FILE := $(findbugs_xml)
+$(LOCAL_MODULE)-findbugs : $(findbugs_html)
+$(findbugs_html) : $(findbugs_xml)
+ @mkdir -p $(dir $@)
+ @echo ConvertXmlToText: $@
+ $(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl $(PRIVATE_XML_FILE) \
+ > $@
+
+$(LOCAL_MODULE)-findbugs : $(findbugs_html)
+
+endif # full_classes_jar is defined
+
+ifdef LOCAL_JACK_ENABLED
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-rsc
+ifeq ($(LOCAL_JACK_ENABLED),incremental)
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-incremental
+$(noshrob_classes_jack): PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-noshrob-incremental
+$(jack_check_timestamp): PRIVATE_JACK_INCREMENTAL_DIR := $(intermediates.COMMON)/jack-check-incremental
+else
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_JACK_INCREMENTAL_DIR :=
+$(noshrob_classes_jack): PRIVATE_JACK_INCREMENTAL_DIR :=
+$(jack_check_timestamp): PRIVATE_JACK_INCREMENTAL_DIR :=
+endif
+
+ifdef full_classes_jar
+ifdef LOCAL_PROGUARD_ENABLED
+
+ifndef LOCAL_JACK_PROGUARD_FLAGS
+ LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS)
+endif
+LOCAL_JACK_PROGUARD_FLAGS += $(addprefix -include , $(proguard_flag_files))
+ifdef LOCAL_TEST_MODULE_TO_PROGUARD_WITH
+ $(error $(LOCAL_MODULE): Build with jack when LOCAL_TEST_MODULE_TO_PROGUARD_WITH is defined is not yet implemented)
+endif
+
+# $(jack_dictionary) is just by-product of $(built_dex_intermediate).
+# The dummy command was added because, without it, make misses the fact the $(built_dex) also
+# change $(jack_dictionary).
+$(jack_dictionary): $(full_classes_jack)
+ $(hide) touch $@
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_PROGUARD_FLAGS := $(common_proguard_flags) $(jack_proguard_flags) $(LOCAL_JACK_PROGUARD_FLAGS)
+else # LOCAL_PROGUARD_ENABLED not defined
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_PROGUARD_FLAGS :=
+endif # LOCAL_PROGUARD_ENABLED defined
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_FLAGS := $(GLOBAL_JAVAC_DEBUG_FLAGS) $(LOCAL_JACK_FLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JACK_VERSION := $(LOCAL_JACK_VERSION)
+
+jack_all_deps := $(java_sources) $(java_resource_sources) $(full_jack_deps) \
+ $(jar_manifest_file) $(layers_file) $(RenderScript_file_stamp) $(proguard_flag_files) \
+ $(proto_java_sources_file_stamp) $(LOCAL_ADDITIONAL_DEPENDENCIES) $(LOCAL_JARJAR_RULES) \
+ $(LOCAL_MODULE_MAKEFILE_DEP) $(JACK)
+
+$(jack_check_timestamp): $(jack_all_deps) | setup-jack-server
+ @echo Checking build with Jack: $@
+ $(jack-check-java)
+
+ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
+$(full_classes_jack): $(jack_all_deps) | setup-jack-server
+ @echo Building with Jack: $@
+ $(java-to-jack)
+
+# Update timestamps of .toc files for static java libraries so
+# dependents will be always rebuilt.
+$(built_dex).toc: $(full_classes_jack)
+ touch $@
+
+else #LOCAL_IS_STATIC_JAVA_LIBRARY
+$(built_dex_intermediate): PRIVATE_CLASSES_JACK := $(full_classes_jack)
+
+ifeq ($(LOCAL_EMMA_INSTRUMENT),true)
+$(built_dex_intermediate): PRIVATE_JACK_COVERAGE_OPTIONS := \
+ -D jack.coverage=true \
+ -D jack.coverage.metadata.file=$(intermediates.COMMON)/coverage.em \
+ -D jack.coverage.jacoco.package=$(JACOCO_PACKAGE_NAME) \
+ $(addprefix -D jack.coverage.jacoco.include=,$(LOCAL_JACK_COVERAGE_INCLUDE_FILTER)) \
+ $(addprefix -D jack.coverage.jacoco.exclude=,$(LOCAL_JACK_COVERAGE_EXCLUDE_FILTER))
+else
+$(built_dex_intermediate): PRIVATE_JACK_COVERAGE_OPTIONS :=
+endif
+
+$(built_dex_intermediate): $(jack_all_deps) | setup-jack-server
+ @echo Building with Jack: $@
+ $(jack-java-to-dex)
+
+# $(full_classes_jack) is just by-product of $(built_dex_intermediate).
+# The dummy command was added because, without it, make misses the fact the $(built_dex) also
+# change $(full_classes_jack).
+$(full_classes_jack): $(built_dex_intermediate)
+ $(hide) touch $@
+
+$(call define-dex-to-toc-rule, $(intermediates.COMMON))
+
+endif #LOCAL_IS_STATIC_JAVA_LIBRARY
+
+$(noshrob_classes_jack): PRIVATE_JACK_INTERMEDIATES_DIR := $(intermediates.COMMON)/jack-noshrob-rsc
+$(noshrob_classes_jack): PRIVATE_JACK_PROGUARD_FLAGS :=
+$(noshrob_classes_jack): $(jack_all_deps) | setup-jack-server
+ @echo Building with Jack: $@
+ $(java-to-jack)
+endif # full_classes_jar is defined
+endif # LOCAL_JACK_ENABLED
diff --git a/core/java_common.mk b/core/java_common.mk
new file mode 100644
index 0000000000000000000000000000000000000000..9b7d10fba2cf0960a5a8911149f2f25da3566d8f
--- /dev/null
+++ b/core/java_common.mk
@@ -0,0 +1,401 @@
+# Common to host and target Java modules.
+
+###########################################################
+## Java version
+###########################################################
+# Use the LOCAL_JAVA_LANGUAGE_VERSION if it is set, otherwise
+# use one based on the LOCAL_SDK_VERSION. If it is < 24
+# pass "1.7" to the tools, if it is unset, >= 24 or "current"
+# pass "1.8".
+#
+# The LOCAL_SDK_VERSION behavior is to ensure that, by default,
+# code that is expected to run on older releases of Android
+# does not use any 1.8 language features that are not supported
+# on earlier runtimes (like default / static interface methods).
+# Modules can override this logic by specifying
+# LOCAL_JAVA_LANGUAGE_VERSION explicitly.
+ifeq (,$(LOCAL_JAVA_LANGUAGE_VERSION))
+ private_sdk_versions_without_any_java_18_support := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
+ ifneq (,$(filter $(LOCAL_SDK_VERSION), $(private_sdk_versions_without_any_java_18_support)))
+ LOCAL_JAVA_LANGUAGE_VERSION := 1.7
+ else
+ LOCAL_JAVA_LANGUAGE_VERSION := 1.8
+ endif
+endif
+LOCAL_JAVACFLAGS += -source $(LOCAL_JAVA_LANGUAGE_VERSION) -target $(LOCAL_JAVA_LANGUAGE_VERSION)
+
+###########################################################
+## .proto files: Compile proto files to .java
+###########################################################
+proto_sources := $(filter %.proto,$(LOCAL_SRC_FILES))
+# Because names of the .java files compiled from .proto files are unknown until the
+# .proto files are compiled, we use a timestamp file as depedency.
+proto_java_sources_file_stamp :=
+ifneq ($(proto_sources),)
+proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
+
+# By putting the generated java files into $(LOCAL_INTERMEDIATE_SOURCE_DIR), they will be
+# automatically found by the java compiling function transform-java-to-classes.jar.
+proto_java_intemediate_dir := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/proto
+proto_java_sources_file_stamp := $(proto_java_intemediate_dir)/Proto.stamp
+proto_java_sources_dir := $(proto_java_intemediate_dir)/src
+
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_INCLUDES := $(TOP)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_SRC_FILES := $(proto_sources_fullpath)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_DIR := $(proto_java_sources_dir)
+ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),micro)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javamicro_out
+else
+ ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nano)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --javanano_out
+ else
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_OPTION := --java_out
+ endif
+endif
+$(proto_java_sources_file_stamp): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS)
+$(proto_java_sources_file_stamp): PRIVATE_PROTO_JAVA_OUTPUT_PARAMS := $(LOCAL_PROTO_JAVA_OUTPUT_PARAMS)
+$(proto_java_sources_file_stamp) : $(proto_sources_fullpath) $(PROTOC)
+ $(call transform-proto-to-java)
+
+#TODO: protoc should output the dependencies introduced by imports.
+
+ALL_MODULES.$(my_register_name).PROTO_FILES := $(proto_sources_fullpath)
+endif # proto_sources
+
+#########################################
+## Java resources
+
+# Look for resource files in any specified directories.
+# Non-java and non-doc files will be picked up as resources
+# and included in the output jar file.
+java_resource_file_groups :=
+
+LOCAL_JAVA_RESOURCE_DIRS := $(strip $(LOCAL_JAVA_RESOURCE_DIRS))
+ifneq ($(LOCAL_JAVA_RESOURCE_DIRS),)
+ # This makes a list of words like
+ # ::: :: :
+ # where each of the files is relative to the directory it's grouped with.
+ # Directories that don't contain any resource files will result in groups
+ # that end with a colon, and they are stripped out in the next step.
+ java_resource_file_groups += \
+ $(foreach dir,$(LOCAL_JAVA_RESOURCE_DIRS), \
+ $(subst $(space),:,$(strip \
+ $(LOCAL_PATH)/$(dir): \
+ $(patsubst ./%,%,$(sort $(shell cd $(LOCAL_PATH)/$(dir) && \
+ find . \
+ -type d -a -name ".svn" -prune -o \
+ -type f \
+ -a \! -name "*.java" \
+ -a \! -name "package.html" \
+ -a \! -name "overview.html" \
+ -a \! -name ".*.swp" \
+ -a \! -name ".DS_Store" \
+ -a \! -name "*~" \
+ -print \
+ ))) \
+ )) \
+ )
+ java_resource_file_groups := $(filter-out %:,$(java_resource_file_groups))
+endif # LOCAL_JAVA_RESOURCE_DIRS
+
+LOCAL_JAVA_RESOURCE_FILES := $(strip $(LOCAL_JAVA_RESOURCE_FILES))
+ifneq ($(LOCAL_JAVA_RESOURCE_FILES),)
+ java_resource_file_groups += \
+ $(foreach f,$(LOCAL_JAVA_RESOURCE_FILES), \
+ $(patsubst %/,%,$(dir $(f)))::$(notdir $(f)) \
+ )
+endif # LOCAL_JAVA_RESOURCE_FILES
+
+ifdef java_resource_file_groups
+ # The full paths to all resources, used for dependencies.
+ java_resource_sources := \
+ $(foreach group,$(java_resource_file_groups), \
+ $(addprefix $(word 1,$(subst :,$(space),$(group)))/, \
+ $(wordlist 2,9999,$(subst :,$(space),$(group))) \
+ ) \
+ )
+ # The arguments to jar that will include these files in a jar file.
+ # Quote the file name to handle special characters (such as #) correctly.
+ extra_jar_args := \
+ $(foreach group,$(java_resource_file_groups), \
+ $(addprefix -C "$(word 1,$(subst :,$(space),$(group)))" , \
+ $(foreach w, $(wordlist 2,9999,$(subst :,$(space),$(group))), "$(w)" ) \
+ ) \
+ )
+ java_resource_file_groups :=
+else
+ java_resource_sources :=
+ extra_jar_args :=
+endif # java_resource_file_groups
+
+######################################
+## PRIVATE java vars
+# LOCAL_SOURCE_FILES_ALL_GENERATED is set only if the module does not have static source files,
+# but generated source files in its LOCAL_INTERMEDIATE_SOURCE_DIR.
+# You have to set up the dependency in some other way.
+need_compile_java := $(strip $(all_java_sources)$(all_res_assets)$(java_resource_sources))$(LOCAL_STATIC_JAVA_LIBRARIES)$(filter true,$(LOCAL_SOURCE_FILES_ALL_GENERATED))
+ifdef need_compile_java
+
+full_static_java_libs := \
+ $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
+ $(call intermediates-dir-for, \
+ JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/javalib.jar)
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JAVA_LIBRARIES := $(full_static_java_libs)
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR := $(LOCAL_ASSET_DIR)
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CLASS_INTERMEDIATES_DIR := $(intermediates.COMMON)/classes
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(intermediates.COMMON)/src
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAVA_SOURCES := $(all_java_sources)
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RMTYPEDEFS := $(LOCAL_RMTYPEDEFS)
+
+# full_java_libs: The list of files that should be used as the classpath.
+# Using this list as a dependency list WILL NOT WORK.
+# full_java_lib_deps: Should be specified as a prerequisite of this module
+# to guarantee that the files in full_java_libs will
+# be up-to-date.
+ifndef LOCAL_IS_HOST_MODULE
+ifeq ($(LOCAL_SDK_VERSION),)
+ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+# No bootclasspath. But we still need "" to prevent javac from using default host bootclasspath.
+my_bootclasspath := ""
+else # LOCAL_NO_STANDARD_LIBRARIES
+my_bootclasspath := $(call java-lib-files,core-oj):$(call java-lib-files,core-libart)
+endif # LOCAL_NO_STANDARD_LIBRARIES
+else
+ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
+# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
+my_bootclasspath := $(call java-lib-files,android_stubs_current)
+else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
+my_bootclasspath := $(call java-lib-files,android_system_stubs_current)
+else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current)
+my_bootclasspath := $(call java-lib-files,android_test_stubs_current)
+else
+my_bootclasspath := $(call java-lib-files,sdk_v$(LOCAL_SDK_VERSION))
+endif # current, system_current, or test_current
+endif # LOCAL_SDK_VERSION
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(my_bootclasspath)
+
+# In order to compile lambda code javac requires various invokedynamic-
+# related classes to be present. This change adds stubs needed for
+# javac to compile lambdas.
+my_additional_javac_libs :=
+ifndef TARGET_BUILD_APPS
+# TODO: support to build lamdbas using javac in unbundled build.
+# We may need to check in a prebuilt core-lambda-stubs to prebuilts/sdk.
+ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+my_additional_javac_libs := core-lambda-stubs
+endif
+endif
+
+full_shared_java_libs := $(call java-lib-files,$(LOCAL_JAVA_LIBRARIES) $(my_additional_javac_libs),$(LOCAL_IS_HOST_MODULE))
+full_java_lib_deps := $(call java-lib-deps,$(LOCAL_JAVA_LIBRARIES) $(my_additional_javac_libs),$(LOCAL_IS_HOST_MODULE))
+full_java_lib_deps := $(addsuffix .toc, $(full_java_lib_deps))
+
+else # LOCAL_IS_HOST_MODULE
+
+ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)
+ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+my_bootclasspath := ""
+else
+my_bootclasspath := $(call normalize-path-list,$(call host-dex-java-lib-files,core-oj-hostdex core-libart-hostdex))
+endif
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH := -bootclasspath $(my_bootclasspath)
+
+full_shared_java_libs := $(call host-dex-java-lib-files,$(LOCAL_JAVA_LIBRARIES))
+full_java_lib_deps := $(full_shared_java_libs)
+else # !USE_CORE_LIB_BOOTCLASSPATH
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH :=
+
+full_shared_java_libs := $(addprefix $(HOST_OUT_JAVA_LIBRARIES)/,\
+ $(addsuffix $(COMMON_JAVA_PACKAGE_SUFFIX),$(LOCAL_JAVA_LIBRARIES)))
+full_java_lib_deps := $(full_shared_java_libs)
+endif # USE_CORE_LIB_BOOTCLASSPATH
+endif # !LOCAL_IS_HOST_MODULE
+
+full_java_libs := $(full_shared_java_libs) $(full_static_java_libs) $(LOCAL_CLASSPATH)
+full_java_lib_deps := $(full_java_lib_deps) $(full_static_java_libs) $(LOCAL_CLASSPATH)
+
+ifndef LOCAL_IS_HOST_MODULE
+# This is set by packages that are linking to other packages that export
+# shared libraries, allowing them to make use of the code in the linked apk.
+apk_libraries := $(sort $(LOCAL_APK_LIBRARIES) $(LOCAL_RES_LIBRARIES))
+ifneq ($(apk_libraries),)
+ link_apk_libraries := \
+ $(foreach lib,$(apk_libraries), \
+ $(call intermediates-dir-for, \
+ APPS,$(lib),,COMMON)/classes.jar)
+
+ # link against the jar with full original names (before proguard processing).
+ full_shared_java_libs += $(link_apk_libraries)
+ full_java_libs += $(link_apk_libraries)
+ full_java_lib_deps += $(link_apk_libraries)
+endif
+
+# This is set by packages that contain instrumentation, allowing them to
+# link against the package they are instrumenting. Currently only one such
+# package is allowed.
+LOCAL_INSTRUMENTATION_FOR := $(strip $(LOCAL_INSTRUMENTATION_FOR))
+ifdef LOCAL_INSTRUMENTATION_FOR
+ ifneq ($(words $(LOCAL_INSTRUMENTATION_FOR)),1)
+ $(error \
+ $(LOCAL_PATH): Multiple LOCAL_INSTRUMENTATION_FOR members defined)
+ endif
+
+ link_instr_intermediates_dir.COMMON := $(call intermediates-dir-for, \
+ APPS,$(LOCAL_INSTRUMENTATION_FOR),,COMMON)
+ # link against the jar with full original names (before proguard processing).
+ link_instr_classes_jar := $(link_instr_intermediates_dir.COMMON)/classes.jar
+ full_java_libs += $(link_instr_classes_jar)
+ full_java_lib_deps += $(link_instr_classes_jar)
+endif # LOCAL_INSTRUMENTATION_FOR
+endif # LOCAL_IS_HOST_MODULE
+
+endif # need_compile_java
+
+# We may want to add jar manifest or jar resource files even if there is no java code at all.
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_EXTRA_JAR_ARGS := $(extra_jar_args)
+jar_manifest_file :=
+ifneq ($(strip $(LOCAL_JAR_MANIFEST)),)
+jar_manifest_file := $(LOCAL_PATH)/$(LOCAL_JAR_MANIFEST)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST := $(jar_manifest_file)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JAR_MANIFEST :=
+endif
+
+##########################################################
+ifndef LOCAL_IS_HOST_MODULE
+## AAPT Flags
+# aapt doesn't accept multiple --extra-packages flags.
+# We have to collapse them into a single --extra-packages flag here.
+LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS))
+ifdef LOCAL_AAPT_FLAGS
+ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),)
+aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS))
+aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags)))
+aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages)))
+LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \
+ --extra-packages $(subst $(space),:,$(aapt_flags_extra_packages))
+aapt_flags_extra_packages :=
+aapt_flags :=
+endif
+endif
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) $(PRODUCT_AAPT_FLAGS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS := $(TARGET_AAPT_CHARACTERISTICS)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME := $(LOCAL_MANIFEST_PACKAGE_NAME)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR := $(LOCAL_MANIFEST_INSTRUMENTATION_FOR)
+
+ifdef aidl_sources
+ALL_MODULES.$(my_register_name).AIDL_FILES := $(aidl_sources)
+endif
+ifdef renderscript_sources
+ALL_MODULES.$(my_register_name).RS_FILES := $(renderscript_sources_fullpath)
+endif
+endif # !LOCAL_IS_HOST_MODULE
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JAVA_LIBRARIES := $(full_java_libs)
+
+ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR := \
+ $(ALL_MODULES.$(my_register_name).INTERMEDIATE_SOURCE_DIR) $(LOCAL_INTERMEDIATE_SOURCE_DIR)
+
+###########################################################
+# JACK
+###########################################################
+ifdef LOCAL_JACK_ENABLED
+ifdef need_compile_java
+
+LOCAL_JACK_FLAGS += -D jack.java.source.version=$(LOCAL_JAVA_LANGUAGE_VERSION)
+
+full_static_jack_libs := \
+ $(foreach lib,$(LOCAL_STATIC_JAVA_LIBRARIES), \
+ $(call intermediates-dir-for, \
+ JAVA_LIBRARIES,$(lib),$(LOCAL_IS_HOST_MODULE),COMMON)/classes.jack)
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_STATIC_JACK_LIBRARIES := $(full_static_jack_libs)
+
+ifndef LOCAL_IS_HOST_MODULE
+ifeq ($(LOCAL_SDK_VERSION),)
+ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+my_bootclasspath :=
+else
+my_bootclasspath := $(call jack-lib-files,core-oj core-libart)
+endif
+else # LOCAL_SDK_VERSION
+ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),current)
+# LOCAL_SDK_VERSION is current and no TARGET_BUILD_APPS.
+my_bootclasspath := $(call jack-lib-files,android_stubs_current)
+else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),system_current)
+my_bootclasspath := $(call jack-lib-files,android_system_stubs_current)
+else ifeq ($(LOCAL_SDK_VERSION)$(TARGET_BUILD_APPS),test_current)
+my_bootclasspath := $(call jack-lib-files,android_test_stubs_current)
+else
+my_bootclasspath :=$(call jack-lib-files,sdk_v$(LOCAL_SDK_VERSION))
+endif # current, system_current, or test_current
+endif # LOCAL_SDK_VERSION
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(my_bootclasspath)
+
+full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+full_jack_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+# Turn off .toc optimization for apps build as we cannot build dexdump.
+ifeq (,$(TARGET_BUILD_APPS))
+full_jack_deps := $(patsubst %.jack, %.dex.toc, $(full_jack_deps))
+endif
+
+else # LOCAL_IS_HOST_MODULE
+
+ifeq ($(USE_CORE_LIB_BOOTCLASSPATH),true)
+ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+my_bootclasspath :=
+else
+my_bootclasspath := $(call jack-lib-files,core-oj-hostdex core-libart-hostdex,$(LOCAL_IS_HOST_MODULE))
+endif
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES := $(my_bootclasspath)
+# Compiling against the final jack library. If we want to add support for obfuscated library
+# we'll need to change that to compile against the not obfuscated jack library.
+full_shared_jack_libs := $(call jack-lib-files,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+full_jack_deps := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_BOOTCLASSPATH_JAVA_LIBRARIES :=
+full_shared_jack_libs := $(call jack-lib-deps,$(LOCAL_JAVA_LIBRARIES),$(LOCAL_IS_HOST_MODULE))
+full_jack_deps := $(full_shared_jack_libs)
+endif # USE_CORE_LIB_BOOTCLASSPATH
+endif # !LOCAL_IS_HOST_MODULE
+full_jack_libs := $(full_shared_jack_libs) $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH)
+full_jack_deps += $(full_static_jack_libs) $(LOCAL_JACK_CLASSPATH)
+
+ifndef LOCAL_IS_HOST_MODULE
+# This is set by packages that are linking to other packages that export
+# shared libraries, allowing them to make use of the code in the linked apk.
+ifneq ($(apk_libraries),)
+ link_apk_jack_libraries := \
+ $(foreach lib,$(apk_libraries), \
+ $(call intermediates-dir-for, \
+ APPS,$(lib),,COMMON)/classes.jack)
+
+ # link against the jar with full original names (before proguard processing).
+ full_shared_jack_libs += $(link_apk_jack_libraries)
+ full_jack_libs += $(link_apk_jack_libraries)
+ full_jack_deps += $(link_apk_jack_libraries)
+endif
+
+# This is set by packages that contain instrumentation, allowing them to
+# link against the package they are instrumenting. Currently only one such
+# package is allowed.
+ifdef LOCAL_INSTRUMENTATION_FOR
+ # link against the jar with full original names (before proguard processing).
+ link_instr_classes_jack := $(link_instr_intermediates_dir.COMMON)/classes.noshrob.jack
+ full_jack_libs += $(link_instr_classes_jack)
+ full_jack_deps += $(link_instr_classes_jack)
+endif # LOCAL_INSTRUMENTATION_FOR
+endif # !LOCAL_IS_HOST_MODULE
+
+# Propagate local configuration options to this target.
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_JACK_LIBRARIES:= $(full_jack_libs)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_JARJAR_RULES := $(LOCAL_JARJAR_RULES)
+
+endif # need_compile_java
+endif # LOCAL_JACK_ENABLED
diff --git a/core/java_library.mk b/core/java_library.mk
new file mode 100644
index 0000000000000000000000000000000000000000..81a4a6a30ee4c3319e70ff080bad624ca3326bff
--- /dev/null
+++ b/core/java_library.mk
@@ -0,0 +1,130 @@
+###########################################################
+## Standard rules for building a java library.
+##
+###########################################################
+
+ifdef LOCAL_IS_HOST_MODULE
+$(error $(LOCAL_PATH): Host java libraries must use BUILD_HOST_JAVA_LIBRARY)
+endif
+
+LOCAL_MODULE_SUFFIX := $(COMMON_JAVA_PACKAGE_SUFFIX)
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+ifneq (,$(LOCAL_ASSET_DIR))
+$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_ASSET_DIR)
+endif
+
+ifneq (true,$(LOCAL_IS_STATIC_JAVA_LIBRARY))
+ifneq (,$(LOCAL_RESOURCE_DIR))
+$(error $(LOCAL_PATH): Target java libraries may not set LOCAL_RESOURCE_DIR)
+endif
+# base_rules.mk looks at this
+all_res_assets :=
+endif
+
+LOCAL_BUILT_MODULE_STEM := javalib.jar
+
+#################################
+include $(BUILD_SYSTEM)/configure_local_jack.mk
+#################################
+
+ifdef LOCAL_JACK_ENABLED
+ifdef LOCAL_IS_STATIC_JAVA_LIBRARY
+LOCAL_BUILT_MODULE_STEM := classes.jack
+endif
+endif
+
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
+
+# This file will be the one that other modules should depend on.
+common_javalib.jar := $(intermediates.COMMON)/javalib.jar
+LOCAL_INTERMEDIATE_TARGETS += $(common_javalib.jar)
+
+ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
+ LOCAL_PROGUARD_ENABLED :=
+endif
+
+ifeq (true,$(EMMA_INSTRUMENT))
+ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
+ifeq (true,$(EMMA_INSTRUMENT_STATIC))
+ifdef LOCAL_JACK_ENABLED
+# Jack supports coverage with Jacoco
+LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
+else
+LOCAL_STATIC_JAVA_LIBRARIES += emma
+endif # LOCAL_JACK_ENABLED
+endif # LOCAL_EMMA_INSTRUMENT
+endif # EMMA_INSTRUMENT_STATIC
+else
+LOCAL_EMMA_INSTRUMENT := false
+endif # EMMA_INSTRUMENT
+
+#################################
+include $(BUILD_SYSTEM)/java.mk
+#################################
+
+ifeq ($(LOCAL_IS_STATIC_JAVA_LIBRARY),true)
+# No dex; all we want are the .class files with resources.
+$(common_javalib.jar) : $(java_resource_sources)
+ifdef LOCAL_PROGUARD_ENABLED
+$(common_javalib.jar) : $(full_classes_proguard_jar)
+else
+$(common_javalib.jar) : $(full_classes_jar)
+endif
+ @echo "target Static Jar: $(PRIVATE_MODULE) ($@)"
+ $(copy-file-to-target)
+
+ifdef LOCAL_JACK_ENABLED
+$(LOCAL_BUILT_MODULE) : $(full_classes_jack)
+else
+$(LOCAL_BUILT_MODULE) : $(common_javalib.jar)
+endif
+ $(copy-file-to-target)
+
+else # !LOCAL_IS_STATIC_JAVA_LIBRARY
+
+$(common_javalib.jar): PRIVATE_DEX_FILE := $(built_dex)
+$(common_javalib.jar): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
+$(common_javalib.jar): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
+$(common_javalib.jar) : $(built_dex) $(java_resource_sources) | $(ZIPTIME)
+ @echo "target Jar: $(PRIVATE_MODULE) ($@)"
+ifdef LOCAL_JACK_ENABLED
+ $(create-empty-package)
+else
+ $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@)
+endif
+ $(add-dex-to-package)
+ifdef LOCAL_JACK_ENABLED
+ $(add-carried-jack-resources)
+endif
+ $(remove-timestamps-from-package)
+
+ifdef LOCAL_DEX_PREOPT
+ifneq ($(dexpreopt_boot_jar_module),) # boot jar
+# boot jar's rules are defined in dex_preopt.mk
+dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
+$(LOCAL_BUILT_MODULE) : $(dexpreopted_boot_jar) | $(ACP)
+ $(call copy-file-to-target)
+
+# For libart boot jars, we don't have .odex files.
+else # ! boot jar
+$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
+# Use pattern rule - we may have multiple built odex files.
+$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(common_javalib.jar)
+ @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
+ $(call dexpreopt-one-file,$<,$@)
+
+$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP)
+ $(call copy-file-to-target)
+ifneq (nostripping,$(LOCAL_DEX_PREOPT))
+ $(call dexpreopt-remove-classes.dex,$@)
+endif
+
+endif # ! boot jar
+
+else # LOCAL_DEX_PREOPT
+$(LOCAL_BUILT_MODULE) : $(common_javalib.jar) | $(ACP)
+ $(call copy-file-to-target)
+
+endif # LOCAL_DEX_PREOPT
+endif # !LOCAL_IS_STATIC_JAVA_LIBRARY
diff --git a/core/legacy_prebuilts.mk b/core/legacy_prebuilts.mk
new file mode 100644
index 0000000000000000000000000000000000000000..f4633d019b8fbf203e768786b5c843c9d0f1d34b
--- /dev/null
+++ b/core/legacy_prebuilts.mk
@@ -0,0 +1,32 @@
+#
+# Copyright (C) 2010 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 the list of modules grandfathered to use ALL_PREBUILT
+
+# DO NOT ADD ANY NEW MODULE TO THIS FILE
+#
+# ALL_PREBUILT modules are hard to control and audit and we don't want
+# to add any new such module in the system
+
+GRANDFATHERED_ALL_PREBUILT := \
+ bmgr \
+ ime \
+ input \
+ monkey \
+ pm \
+ RFFspeed_501.bmd \
+ RFFstd_501.bmd \
+ svc
diff --git a/core/main.mk b/core/main.mk
new file mode 100644
index 0000000000000000000000000000000000000000..a612f835d5d7e7fa2d5e50d4d717a42c6d56b614
--- /dev/null
+++ b/core/main.mk
@@ -0,0 +1,1137 @@
+# Only use ANDROID_BUILD_SHELL to wrap around bash.
+# DO NOT use other shells such as zsh.
+ifdef ANDROID_BUILD_SHELL
+SHELL := $(ANDROID_BUILD_SHELL)
+else
+# Use bash, not whatever shell somebody has installed as /bin/sh
+# This is repeated in config.mk, since envsetup.sh runs that file
+# directly.
+SHELL := /bin/bash
+endif
+
+# this turns off the suffix rules built into make
+.SUFFIXES:
+
+# this turns off the RCS / SCCS implicit rules of GNU Make
+% : RCS/%,v
+% : RCS/%
+% : %,v
+% : s.%
+% : SCCS/s.%
+
+# If a rule fails, delete $@.
+.DELETE_ON_ERROR:
+
+# Figure out where we are.
+#TOP := $(dir $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)))
+#TOP := $(patsubst %/,%,$(TOP))
+
+# TOPDIR is the normal variable you should use, because
+# if we are executing relative to the current directory
+# it can be "", whereas TOP must be "." which causes
+# pattern matching problems when make strips off the
+# trailing "./" from paths in various places.
+#ifeq ($(TOP),.)
+#TOPDIR :=
+#else
+#TOPDIR := $(TOP)/
+#endif
+
+# Check for broken versions of make.
+ifneq (1,$(strip $(shell expr $(MAKE_VERSION) \>= 3.81)))
+$(warning ********************************************************************************)
+$(warning * You are using version $(MAKE_VERSION) of make.)
+$(warning * Android can only be built by versions 3.81 and higher.)
+$(warning * see https://source.android.com/source/download.html)
+$(warning ********************************************************************************)
+$(error stopping)
+endif
+
+# Absolute path of the present working direcotry.
+# This overrides the shell variable $PWD, which does not necessarily points to
+# the top of the source tree, for example when "make -C" is used in m/mm/mmm.
+PWD := $(shell pwd)
+
+TOP := .
+TOPDIR :=
+
+BUILD_SYSTEM := $(TOPDIR)build/core
+
+# Ensure JAVA_NOT_REQUIRED is not set externally.
+JAVA_NOT_REQUIRED := false
+
+# This is the default target. It must be the first declared target.
+.PHONY: droid
+DEFAULT_GOAL := droid
+$(DEFAULT_GOAL): droid_targets
+
+.PHONY: droid_targets
+droid_targets:
+
+# Used to force goals to build. Only use for conditionally defined goals.
+.PHONY: FORCE
+FORCE:
+
+# These goals don't need to collect and include Android.mks/CleanSpec.mks
+# in the source tree.
+dont_bother_goals := clean clobber dataclean installclean \
+ help out \
+ snod systemimage-nodeps \
+ stnod systemtarball-nodeps \
+ userdataimage-nodeps userdatatarball-nodeps \
+ cacheimage-nodeps \
+ vendorimage-nodeps \
+ systemotherimage-nodeps \
+ ramdisk-nodeps \
+ bootimage-nodeps \
+ recoveryimage-nodeps \
+ product-graph dump-products
+
+ifneq ($(filter $(dont_bother_goals), $(MAKECMDGOALS)),)
+dont_bother := true
+endif
+
+ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
+
+# Targets that provide quick help on the build system.
+include $(BUILD_SYSTEM)/help.mk
+
+# Set up various standard variables based on configuration
+# and host information.
+include $(BUILD_SYSTEM)/config.mk
+
+relaunch_with_ninja :=
+ifneq ($(USE_NINJA),false)
+ifndef BUILDING_WITH_NINJA
+relaunch_with_ninja := true
+endif
+endif
+
+ifeq ($(relaunch_with_ninja),true)
+# Mark this is a ninja build.
+$(shell mkdir -p $(OUT_DIR) && touch $(OUT_DIR)/ninja_build)
+include build/core/ninja.mk
+else # !relaunch_with_ninja
+ifndef BUILDING_WITH_NINJA
+# Remove ninja build mark if it exists.
+$(shell rm -f $(OUT_DIR)/ninja_build)
+endif
+
+# Write the build number to a file so it can be read back in
+# without changing the command line every time. Avoids rebuilds
+# when using ninja.
+$(shell mkdir -p $(OUT_DIR) && \
+ echo -n $(BUILD_NUMBER) > $(OUT_DIR)/build_number.txt && \
+ echo -n $(BUILD_DATETIME) > $(OUT_DIR)/build_date.txt)
+BUILD_NUMBER_FROM_FILE := $$(cat $(OUT_DIR)/build_number.txt)
+BUILD_DATETIME_FROM_FILE := $$(cat $(OUT_DIR)/build_date.txt)
+ifeq ($(HOST_OS),darwin)
+DATE_FROM_FILE := date -r $(BUILD_DATETIME_FROM_FILE)
+else
+DATE_FROM_FILE := date -d @$(BUILD_DATETIME_FROM_FILE)
+endif
+
+# CTS-specific config.
+-include cts/build/config.mk
+# VTS-specific config.
+-include test/vts/tools/vts-tradefed/build/config.mk
+
+# This allows us to force a clean build - included after the config.mk
+# environment setup is done, but before we generate any dependencies. This
+# file does the rm -rf inline so the deps which are all done below will
+# be generated correctly
+include $(BUILD_SYSTEM)/cleanbuild.mk
+
+# Include the google-specific config
+-include vendor/google/build/config.mk
+
+VERSION_CHECK_SEQUENCE_NUMBER := 6
+-include $(OUT_DIR)/versions_checked.mk
+ifneq ($(VERSION_CHECK_SEQUENCE_NUMBER),$(VERSIONS_CHECKED))
+
+$(info Checking build tools versions...)
+
+# check for a case sensitive file system
+ifneq (a,$(shell mkdir -p $(OUT_DIR) ; \
+ echo a > $(OUT_DIR)/casecheck.txt; \
+ echo B > $(OUT_DIR)/CaseCheck.txt; \
+ cat $(OUT_DIR)/casecheck.txt))
+$(warning ************************************************************)
+$(warning You are building on a case-insensitive filesystem.)
+$(warning Please move your source tree to a case-sensitive filesystem.)
+$(warning ************************************************************)
+$(error Case-insensitive filesystems not supported)
+endif
+
+# Make sure that there are no spaces in the absolute path; the
+# build system can't deal with them.
+ifneq ($(words $(shell pwd)),1)
+$(warning ************************************************************)
+$(warning You are building in a directory whose absolute path contains)
+$(warning a space character:)
+$(warning $(space))
+$(warning "$(shell pwd)")
+$(warning $(space))
+$(warning Please move your source tree to a path that does not contain)
+$(warning any spaces.)
+$(warning ************************************************************)
+$(error Directory names containing spaces not supported)
+endif
+
+ifeq ($(JAVA_NOT_REQUIRED), false)
+java_version_str := $(shell unset _JAVA_OPTIONS && java -version 2>&1)
+javac_version_str := $(shell unset _JAVA_OPTIONS && javac -version 2>&1)
+
+# Check for the correct version of java, should be 1.8 by
+# default and only 1.7 if LEGACY_USE_JAVA7 is set.
+ifeq ($(LEGACY_USE_JAVA7),) # if LEGACY_USE_JAVA7 == ''
+required_version := "1.8.x"
+required_javac_version := "1.8"
+java_version := $(shell echo '$(java_version_str)' | grep '[ "]1\.8[\. "$$]')
+javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.8[\. "$$]')
+else
+required_version := "1.7.x"
+required_javac_version := "1.7"
+java_version := $(shell echo '$(java_version_str)' | grep '^java .*[ "]1\.7[\. "$$]')
+javac_version := $(shell echo '$(javac_version_str)' | grep '[ "]1\.7[\. "$$]')
+endif # if LEGACY_USE_JAVA7 == ''
+
+ifeq ($(strip $(java_version)),)
+$(info ************************************************************)
+$(info You are attempting to build with the incorrect version)
+$(info of java.)
+$(info $(space))
+$(info Your version is: $(java_version_str).)
+$(info The required version is: $(required_version))
+$(info $(space))
+$(info Please follow the machine setup instructions at)
+$(info $(space)$(space)$(space)$(space)https://source.android.com/source/initializing.html)
+$(info ************************************************************)
+$(error stop)
+endif
+
+# Check for the current JDK.
+#
+# For Java 1.7/1.8, we require OpenJDK on linux and Oracle JDK on Mac OS.
+requires_openjdk := false
+ifeq ($(BUILD_OS),linux)
+requires_openjdk := true
+endif
+
+
+# Check for the current jdk
+ifeq ($(requires_openjdk), true)
+# The user asked for openjdk, so check that the host
+# java version is really openjdk and not some other JDK.
+ifeq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
+$(info ************************************************************)
+$(info You asked for an OpenJDK based build but your version is)
+$(info $(java_version_str).)
+$(info ************************************************************)
+$(error stop)
+endif # java version is not OpenJdk
+else # if requires_openjdk
+ifneq ($(shell echo '$(java_version_str)' | grep -i openjdk),)
+$(info ************************************************************)
+$(info You are attempting to build with an unsupported JDK.)
+$(info $(space))
+$(info You use OpenJDK but only Sun/Oracle JDK is supported.)
+$(info Please follow the machine setup instructions at)
+$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
+$(info ************************************************************)
+$(error stop)
+endif # java version is not Sun Oracle JDK
+endif # if requires_openjdk
+
+KNOWN_INCOMPATIBLE_JAVAC_VERSIONS := google
+incompat_javac := $(foreach v,$(KNOWN_INCOMPATIBLE_JAVAC_VERSIONS),$(findstring $(v),$(javac_version_str)))
+ifneq ($(incompat_javac),)
+javac_version :=
+endif
+
+# Check for the correct version of javac
+ifeq ($(strip $(javac_version)),)
+$(info ************************************************************)
+$(info You are attempting to build with the incorrect version)
+$(info of javac.)
+$(info $(space))
+$(info Your version is: $(javac_version_str).)
+ifneq ($(incompat_javac),)
+$(info This '$(incompat_javac)' version is not supported for Android platform builds.)
+$(info Use a publicly available JDK and make sure you have run envsetup.sh / lunch.)
+else
+$(info The required version is: $(required_javac_version))
+endif
+$(info $(space))
+$(info Please follow the machine setup instructions at)
+$(info $(space)$(space)$(space)$(space)https://source.android.com/source/download.html)
+$(info ************************************************************)
+$(error stop)
+endif
+
+endif # if JAVA_NOT_REQUIRED
+
+ifndef BUILD_EMULATOR
+ # Emulator binaries are now provided under prebuilts/android-emulator/
+ BUILD_EMULATOR := false
+endif
+
+$(shell echo 'VERSIONS_CHECKED := $(VERSION_CHECK_SEQUENCE_NUMBER)' \
+ > $(OUT_DIR)/versions_checked.mk)
+$(shell echo 'BUILD_EMULATOR ?= $(BUILD_EMULATOR)' \
+ >> $(OUT_DIR)/versions_checked.mk)
+endif
+
+# These are the modifier targets that don't do anything themselves, but
+# change the behavior of the build.
+# (must be defined before including definitions.make)
+INTERNAL_MODIFIER_TARGETS := showcommands all
+
+# EMMA_INSTRUMENT_STATIC merges the static emma library to each emma-enabled module.
+ifeq (true,$(EMMA_INSTRUMENT_STATIC))
+EMMA_INSTRUMENT := true
+endif
+
+# Bring in standard build system definitions.
+include $(BUILD_SYSTEM)/definitions.mk
+
+# Bring in dex_preopt.mk
+include $(BUILD_SYSTEM)/dex_preopt.mk
+
+ifneq ($(filter user userdebug eng,$(MAKECMDGOALS)),)
+$(info ***************************************************************)
+$(info ***************************************************************)
+$(info Do not pass '$(filter user userdebug eng,$(MAKECMDGOALS))' on \
+ the make command line.)
+$(info Set TARGET_BUILD_VARIANT in buildspec.mk, or use lunch or)
+$(info choosecombo.)
+$(info ***************************************************************)
+$(info ***************************************************************)
+$(error stopping)
+endif
+
+ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
+$(info ***************************************************************)
+$(info ***************************************************************)
+$(info Invalid variant: $(TARGET_BUILD_VARIANT))
+$(info Valid values are: $(INTERNAL_VALID_VARIANTS))
+$(info ***************************************************************)
+$(info ***************************************************************)
+$(error stopping)
+endif
+
+# -----------------------------------------------------------------
+# Variable to check java support level inside PDK build.
+# Not necessary if the components is not in PDK.
+# not defined : not supported
+# "sdk" : sdk API only
+# "platform" : platform API supproted
+TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
+
+# -----------------------------------------------------------------
+# The pdk (Platform Development Kit) build
+include build/core/pdk_config.mk
+
+#
+# -----------------------------------------------------------------
+# Jack version configuration
+-include $(TOPDIR)prebuilts/sdk/tools/jack_versions.mk
+-include $(TOPDIR)prebuilts/sdk/tools/jack_for_module.mk
+
+#
+# -----------------------------------------------------------------
+# Install and start Jack server
+-include $(TOPDIR)prebuilts/sdk/tools/jack_server_setup.mk
+
+#
+# -----------------------------------------------------------------
+# Jacoco package name for Jack
+-include $(TOPDIR)external/jacoco/config.mk
+
+#
+# -----------------------------------------------------------------
+# Enable dynamic linker developer warnings for all builds except
+# final release.
+ifneq ($(PLATFORM_VERSION_CODENAME),REL)
+ ADDITIONAL_BUILD_PROPERTIES += ro.bionic.ld.warning=1
+endif
+
+# -----------------------------------------------------------------
+###
+### In this section we set up the things that are different
+### between the build variants
+###
+
+is_sdk_build :=
+
+ifneq ($(filter sdk win_sdk sdk_addon,$(MAKECMDGOALS)),)
+is_sdk_build := true
+endif
+
+# Add build properties for ART. These define system properties used by installd
+# to pass flags to dex2oat.
+ADDITIONAL_BUILD_PROPERTIES += persist.sys.dalvik.vm.lib.2=libart.so
+ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).variant=$(DEX2OAT_TARGET_CPU_VARIANT)
+ifneq ($(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
+ ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_ARCH).features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
+endif
+
+ifdef TARGET_2ND_ARCH
+ ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).variant=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT)
+ ifneq ($($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES),)
+ ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.isa.$(TARGET_2ND_ARCH).features=$($(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES)
+ endif
+endif
+
+## user/userdebug ##
+
+user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
+enable_target_debugging := true
+tags_to_install :=
+ifneq (,$(user_variant))
+ # Target is secure in user builds.
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=1
+ ADDITIONAL_DEFAULT_PROPERTIES += security.perf_harden=1
+
+ ifeq ($(user_variant),user)
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.adb.secure=1
+ endif
+
+ ifeq ($(user_variant),userdebug)
+ # Pick up some extra useful tools
+ tags_to_install += debug
+ else
+ # Disable debugging in plain user builds.
+ enable_target_debugging :=
+ endif
+
+ # Disallow mock locations by default for user builds
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=0
+
+else # !user_variant
+ # Turn on checkjni for non-user builds.
+ ADDITIONAL_BUILD_PROPERTIES += ro.kernel.android.checkjni=1
+ # Set device insecure for non-user builds.
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.secure=0
+ # Allow mock locations by default for non user builds
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.allow.mock.location=1
+endif # !user_variant
+
+ifeq (true,$(strip $(enable_target_debugging)))
+ # Target is more debuggable and adbd is on by default
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=1
+ # Enable Dalvik lock contention logging.
+ ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.lockprof.threshold=500
+ # Include the debugging/testing OTA keys in this build.
+ INCLUDE_TEST_OTA_KEYS := true
+else # !enable_target_debugging
+ # Target is less debuggable and adbd is off by default
+ ADDITIONAL_DEFAULT_PROPERTIES += ro.debuggable=0
+endif # !enable_target_debugging
+
+## eng ##
+
+ifeq ($(TARGET_BUILD_VARIANT),eng)
+tags_to_install := debug eng
+ifneq ($(filter ro.setupwizard.mode=ENABLED, $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))),)
+ # Don't require the setup wizard on eng builds
+ ADDITIONAL_BUILD_PROPERTIES := $(filter-out ro.setupwizard.mode=%,\
+ $(call collapse-pairs, $(ADDITIONAL_BUILD_PROPERTIES))) \
+ ro.setupwizard.mode=OPTIONAL
+endif
+ifndef is_sdk_build
+ # To speedup startup of non-preopted builds, don't verify or compile the boot image.
+ ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.image-dex2oat-filter=verify-at-runtime
+endif
+endif
+
+## sdk ##
+
+ifdef is_sdk_build
+
+# Detect if we want to build a repository for the SDK
+sdk_repo_goal := $(strip $(filter sdk_repo,$(MAKECMDGOALS)))
+MAKECMDGOALS := $(strip $(filter-out sdk_repo,$(MAKECMDGOALS)))
+
+ifneq ($(words $(sort $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild emulator_tests target-files-package,$(MAKECMDGOALS)))),1)
+$(error The 'sdk' target may not be specified with any other targets)
+endif
+
+# TODO: this should be eng I think. Since the sdk is built from the eng
+# variant.
+tags_to_install := debug eng
+ADDITIONAL_BUILD_PROPERTIES += xmpp.auto-presence=true
+ADDITIONAL_BUILD_PROPERTIES += ro.config.nocheckin=yes
+else # !sdk
+endif
+
+BUILD_WITHOUT_PV := true
+
+ADDITIONAL_BUILD_PROPERTIES += net.bt.name=Android
+
+# enable vm tracing in files for now to help track
+# the cause of ANRs in the content process
+ADDITIONAL_BUILD_PROPERTIES += dalvik.vm.stack-trace-file=/data/anr/traces.txt
+
+# ------------------------------------------------------------
+# Define a function that, given a list of module tags, returns
+# non-empty if that module should be installed in /system.
+
+# For most goals, anything not tagged with the "tests" tag should
+# be installed in /system.
+define should-install-to-system
+$(if $(filter tests,$(1)),,true)
+endef
+
+ifdef is_sdk_build
+# For the sdk goal, anything with the "samples" tag should be
+# installed in /data even if that module also has "eng"/"debug"/"user".
+define should-install-to-system
+$(if $(filter samples tests,$(1)),,true)
+endef
+endif
+
+
+# If they only used the modifier goals (showcommands, etc), we'll actually
+# build the default target.
+ifeq ($(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS)),)
+.PHONY: $(INTERNAL_MODIFIER_TARGETS)
+$(INTERNAL_MODIFIER_TARGETS): $(DEFAULT_GOAL)
+endif
+
+#
+# Typical build; include any Android.mk files we can find.
+#
+subdirs := $(TOP)
+
+FULL_BUILD := true
+
+# Before we go and include all of the module makefiles, stash away
+# the PRODUCT_* values so that later we can verify they are not modified.
+stash_product_vars:=true
+ifeq ($(stash_product_vars),true)
+ $(call stash-product-vars, __STASHED)
+endif
+
+ifneq ($(ONE_SHOT_MAKEFILE),)
+# We've probably been invoked by the "mm" shell function
+# with a subdirectory's makefile.
+include $(ONE_SHOT_MAKEFILE)
+# Change CUSTOM_MODULES to include only modules that were
+# defined by this makefile; this will install all of those
+# modules as a side-effect. Do this after including ONE_SHOT_MAKEFILE
+# so that the modules will be installed in the same place they
+# would have been with a normal make.
+CUSTOM_MODULES := $(sort $(call get-tagged-modules,$(ALL_MODULE_TAGS)))
+FULL_BUILD :=
+# Stub out the notice targets, which probably aren't defined
+# when using ONE_SHOT_MAKEFILE.
+NOTICE-HOST-%: ;
+NOTICE-TARGET-%: ;
+
+# A helper goal printing out install paths
+.PHONY: GET-INSTALL-PATH
+GET-INSTALL-PATH:
+ @echo "Install paths for modules in $(ONE_SHOT_MAKEFILE):"
+ @$(foreach m, $(ALL_MODULES), $(if $(ALL_MODULES.$(m).INSTALLED), \
+ echo 'INSTALL-PATH: $(m) $(ALL_MODULES.$(m).INSTALLED)';))
+
+else # ONE_SHOT_MAKEFILE
+
+ifneq ($(dont_bother),true)
+#
+# Include all of the makefiles in the system
+#
+
+# Can't use first-makefiles-under here because
+# --mindepth=2 makes the prunes not work.
+subdir_makefiles := \
+ $(shell build/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) $(subdirs) Android.mk)
+
+ifeq ($(USE_SOONG),true)
+subdir_makefiles := $(SOONG_ANDROID_MK) $(call filter-soong-makefiles,$(subdir_makefiles))
+endif
+
+$(foreach mk, $(subdir_makefiles),$(info including $(mk) ...)$(eval include $(mk)))
+
+ifdef PDK_FUSION_PLATFORM_ZIP
+# Bring in the PDK platform.zip modules.
+include $(BUILD_SYSTEM)/pdk_fusion_modules.mk
+endif # PDK_FUSION_PLATFORM_ZIP
+
+endif # dont_bother
+
+endif # ONE_SHOT_MAKEFILE
+
+# Now with all Android.mks loaded we can do post cleaning steps.
+include $(BUILD_SYSTEM)/post_clean.mk
+
+ifeq ($(stash_product_vars),true)
+ $(call assert-product-vars, __STASHED)
+endif
+
+include $(BUILD_SYSTEM)/legacy_prebuilts.mk
+ifneq ($(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),)
+ $(warning *** Some files have been added to ALL_PREBUILT.)
+ $(warning *)
+ $(warning * ALL_PREBUILT is a deprecated mechanism that)
+ $(warning * should not be used for new files.)
+ $(warning * As an alternative, use PRODUCT_COPY_FILES in)
+ $(warning * the appropriate product definition.)
+ $(warning * build/target/product/core.mk is the product)
+ $(warning * definition used in all products.)
+ $(warning *)
+ $(foreach bad_prebuilt,$(filter-out $(GRANDFATHERED_ALL_PREBUILT),$(strip $(notdir $(ALL_PREBUILT)))),$(warning * unexpected $(bad_prebuilt) in ALL_PREBUILT))
+ $(warning *)
+ $(error ALL_PREBUILT contains unexpected files)
+endif
+
+# -------------------------------------------------------------------
+# All module makefiles have been included at this point.
+# -------------------------------------------------------------------
+
+
+# -------------------------------------------------------------------
+# Fix up CUSTOM_MODULES to refer to installed files rather than
+# just bare module names. Leave unknown modules alone in case
+# they're actually full paths to a particular file.
+known_custom_modules := $(filter $(ALL_MODULES),$(CUSTOM_MODULES))
+unknown_custom_modules := $(filter-out $(ALL_MODULES),$(CUSTOM_MODULES))
+CUSTOM_MODULES := \
+ $(call module-installed-files,$(known_custom_modules)) \
+ $(unknown_custom_modules)
+
+# -------------------------------------------------------------------
+# Define dependencies for modules that require other modules.
+# This can only happen now, after we've read in all module makefiles.
+#
+# TODO: deal with the fact that a bare module name isn't
+# unambiguous enough. Maybe declare short targets like
+# APPS:Quake or HOST:SHARED_LIBRARIES:libutils.
+# BUG: the system image won't know to depend on modules that are
+# brought in as requirements of other modules.
+#
+# Resolve the required module name to 32-bit or 64-bit variant.
+# Get a list of corresponding 32-bit module names, if one exists.
+define get-32-bit-modules
+$(strip $(foreach m,$(1),\
+ $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS),\
+ $(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX))))
+endef
+# Get a list of corresponding 32-bit module names, if one exists;
+# otherwise return the original module name
+define get-32-bit-modules-if-we-can
+$(strip $(foreach m,$(1),\
+ $(if $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).CLASS),\
+ $(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX),
+ $(m))))
+endef
+
+# If a module is for a cross host os, the required modules must be for
+# that OS too.
+# If a module is built for 32-bit, the required modules must be 32-bit too;
+# Otherwise if the module is an exectuable or shared library,
+# the required modules must be 64-bit;
+# otherwise we require both 64-bit and 32-bit variant, if one exists.
+$(foreach m,$(ALL_MODULES),\
+ $(eval r := $(ALL_MODULES.$(m).REQUIRED))\
+ $(if $(r),\
+ $(if $(ALL_MODULES.$(m).FOR_HOST_CROSS),\
+ $(eval r := $(addprefix host_cross_,$(r))))\
+ $(if $(ALL_MODULES.$(m).FOR_2ND_ARCH),\
+ $(eval r_r := $(call get-32-bit-modules-if-we-can,$(r))),\
+ $(if $(filter EXECUTABLES SHARED_LIBRARIES,$(ALL_MODULES.$(m).CLASS)),\
+ $(eval r_r := $(r)),\
+ $(eval r_r := $(r) $(call get-32-bit-modules,$(r)))\
+ )\
+ )\
+ $(eval ALL_MODULES.$(m).REQUIRED := $(strip $(r_r)))\
+ )\
+)
+r_r :=
+
+define add-required-deps
+$(1): | $(2)
+endef
+
+$(foreach m,$(ALL_MODULES), \
+ $(eval r := $(ALL_MODULES.$(m).REQUIRED)) \
+ $(if $(r), \
+ $(eval r := $(call module-installed-files,$(r))) \
+ $(eval t_m := $(filter $(TARGET_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
+ $(eval h_m := $(filter $(HOST_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
+ $(eval hc_m := $(filter $(HOST_CROSS_OUT_ROOT)/%, $(ALL_MODULES.$(m).INSTALLED))) \
+ $(eval t_r := $(filter $(TARGET_OUT_ROOT)/%, $(r))) \
+ $(eval h_r := $(filter $(HOST_OUT_ROOT)/%, $(r))) \
+ $(eval hc_r := $(filter $(HOST_CROSS_OUT_ROOT)/%, $(r))) \
+ $(eval t_m := $(filter-out $(t_r), $(t_m))) \
+ $(eval h_m := $(filter-out $(h_r), $(h_m))) \
+ $(eval hc_m := $(filter-out $(hc_r), $(hc_m))) \
+ $(if $(t_m), $(eval $(call add-required-deps, $(t_m),$(t_r)))) \
+ $(if $(h_m), $(eval $(call add-required-deps, $(h_m),$(h_r)))) \
+ $(if $(hc_m), $(eval $(call add-required-deps, $(hc_m),$(hc_r)))) \
+ ) \
+ )
+
+t_m :=
+h_m :=
+hc_m :=
+t_r :=
+h_r :=
+hc_r :=
+
+# Establish the dependecies on the shared libraries.
+# It also adds the shared library module names to ALL_MODULES.$(m).REQUIRED,
+# so they can be expanded to product_MODULES later.
+# $(1): TARGET_ or HOST_ or HOST_CROSS_.
+# $(2): non-empty for 2nd arch.
+# $(3): non-empty for host cross compile.
+define resolve-shared-libs-depes
+$(foreach m,$($(if $(2),$($(1)2ND_ARCH_VAR_PREFIX))$(1)DEPENDENCIES_ON_SHARED_LIBRARIES),\
+ $(eval p := $(subst :,$(space),$(m)))\
+ $(eval mod := $(firstword $(p)))\
+ $(eval deps := $(subst $(comma),$(space),$(lastword $(p))))\
+ $(if $(2),$(eval deps := $(addsuffix $($(1)2ND_ARCH_MODULE_SUFFIX),$(deps))))\
+ $(if $(3),$(eval deps := $(addprefix host_cross_,$(deps))))\
+ $(eval r := $(filter $($(1)OUT)/%,$(call module-installed-files,\
+ $(deps))))\
+ $(eval $(call add-required-deps,$(word 2,$(p)),$(r)))\
+ $(eval ALL_MODULES.$(mod).REQUIRED += $(deps)))
+endef
+
+$(call resolve-shared-libs-depes,TARGET_)
+ifdef TARGET_2ND_ARCH
+$(call resolve-shared-libs-depes,TARGET_,true)
+endif
+$(call resolve-shared-libs-depes,HOST_)
+ifdef HOST_2ND_ARCH
+$(call resolve-shared-libs-depes,HOST_,true)
+endif
+ifdef HOST_CROSS_OS
+$(call resolve-shared-libs-depes,HOST_CROSS_,,true)
+endif
+
+m :=
+r :=
+p :=
+deps :=
+add-required-deps :=
+
+# -------------------------------------------------------------------
+# Figure out our module sets.
+#
+# Of the modules defined by the component makefiles,
+# determine what we actually want to build.
+
+###########################################################
+## Expand a module name list with REQUIRED modules
+###########################################################
+# $(1): The variable name that holds the initial module name list.
+# the variable will be modified to hold the expanded results.
+# $(2): The initial module name list.
+# Returns empty string (maybe with some whitespaces).
+define expand-required-modules
+$(eval _erm_new_modules := $(sort $(filter-out $($(1)),\
+ $(foreach m,$(2),$(ALL_MODULES.$(m).REQUIRED)))))\
+$(if $(_erm_new_modules),$(eval $(1) += $(_erm_new_modules))\
+ $(call expand-required-modules,$(1),$(_erm_new_modules)))
+endef
+
+ifdef FULL_BUILD
+ # The base list of modules to build for this product is specified
+ # by the appropriate product definition file, which was included
+ # by product_config.mk.
+ product_MODULES := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES)
+ # Filter out the overridden packages before doing expansion
+ product_MODULES := $(filter-out $(foreach p, $(product_MODULES), \
+ $(PACKAGES.$(p).OVERRIDES)), $(product_MODULES))
+
+ # Resolve the :32 :64 module name
+ modules_32 := $(patsubst %:32,%,$(filter %:32, $(product_MODULES)))
+ modules_64 := $(patsubst %:64,%,$(filter %:64, $(product_MODULES)))
+ modules_rest := $(filter-out %:32 %:64,$(product_MODULES))
+ # Note for 32-bit product, $(modules_32) and $(modules_64) will be
+ # added as their original module names.
+ product_MODULES := $(call get-32-bit-modules-if-we-can, $(modules_32))
+ product_MODULES += $(modules_64)
+ # For the rest we add both
+ product_MODULES += $(call get-32-bit-modules, $(modules_rest))
+ product_MODULES += $(modules_rest)
+
+ $(call expand-required-modules,product_MODULES,$(product_MODULES))
+
+ product_FILES := $(call module-installed-files, $(product_MODULES))
+ ifeq (0,1)
+ $(info product_FILES for $(TARGET_DEVICE) ($(INTERNAL_PRODUCT)):)
+ $(foreach p,$(product_FILES),$(info : $(p)))
+ $(error done)
+ endif
+else
+ # We're not doing a full build, and are probably only including
+ # a subset of the module makefiles. Don't try to build any modules
+ # requested by the product, because we probably won't have rules
+ # to build them.
+ product_FILES :=
+endif
+
+eng_MODULES := $(sort \
+ $(call get-tagged-modules,eng) \
+ $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG)) \
+ )
+debug_MODULES := $(sort \
+ $(call get-tagged-modules,debug) \
+ $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG)) \
+ )
+tests_MODULES := $(sort \
+ $(call get-tagged-modules,tests) \
+ $(call module-installed-files, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS)) \
+ )
+
+# TODO: Remove the 3 places in the tree that use ALL_DEFAULT_INSTALLED_MODULES
+# and get rid of it from this list.
+modules_to_install := $(sort \
+ $(ALL_DEFAULT_INSTALLED_MODULES) \
+ $(product_FILES) \
+ $(foreach tag,$(tags_to_install),$($(tag)_MODULES)) \
+ $(CUSTOM_MODULES) \
+ )
+
+# Some packages may override others using LOCAL_OVERRIDES_PACKAGES.
+# Filter out (do not install) any overridden packages.
+overridden_packages := $(call get-package-overrides,$(modules_to_install))
+ifdef overridden_packages
+# old_modules_to_install := $(modules_to_install)
+ modules_to_install := \
+ $(filter-out $(foreach p,$(overridden_packages),$(p) %/$(p).apk %/$(p).odex), \
+ $(modules_to_install))
+endif
+#$(error filtered out
+# $(filter-out $(modules_to_install),$(old_modules_to_install)))
+
+# Don't include any GNU General Public License shared objects or static
+# libraries in SDK images. GPL executables (not static/dynamic libraries)
+# are okay if they don't link against any closed source libraries (directly
+# or indirectly)
+
+# It's ok (and necessary) to build the host tools, but nothing that's
+# going to be installed on the target (including static libraries).
+
+ifdef is_sdk_build
+ target_gnu_MODULES := \
+ $(filter \
+ $(TARGET_OUT_INTERMEDIATES)/% \
+ $(TARGET_OUT)/% \
+ $(TARGET_OUT_DATA)/%, \
+ $(sort $(call get-tagged-modules,gnu)))
+ target_gnu_MODULES := $(filter-out $(TARGET_OUT_EXECUTABLES)/%,$(target_gnu_MODULES))
+ $(info Removing from sdk:)$(foreach d,$(target_gnu_MODULES),$(info : $(d)))
+ modules_to_install := \
+ $(filter-out $(target_gnu_MODULES),$(modules_to_install))
+
+ # Ensure every module listed in PRODUCT_PACKAGES* gets something installed
+ # TODO: Should we do this for all builds and not just the sdk?
+ dangling_modules :=
+ $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES), \
+ $(if $(strip $(ALL_MODULES.$(m).INSTALLED) $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).INSTALLED)),,\
+ $(eval dangling_modules += $(m))))
+ ifneq ($(dangling_modules),)
+ $(warning: Modules '$(dangling_modules)' in PRODUCT_PACKAGES have nothing to install!)
+ endif
+ $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_DEBUG), \
+ $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
+ $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_DEBUG has nothing to install!)))
+ $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_ENG), \
+ $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
+ $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_ENG has nothing to install!)))
+ $(foreach m, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGES_TESTS), \
+ $(if $(strip $(ALL_MODULES.$(m).INSTALLED)),,\
+ $(warning $(ALL_MODULES.$(m).MAKEFILE): Module '$(m)' in PRODUCT_PACKAGES_TESTS has nothing to install!)))
+endif
+
+# build/core/Makefile contains extra stuff that we don't want to pollute this
+# top-level makefile with. It expects that ALL_DEFAULT_INSTALLED_MODULES
+# contains everything that's built during the current make, but it also further
+# extends ALL_DEFAULT_INSTALLED_MODULES.
+ALL_DEFAULT_INSTALLED_MODULES := $(modules_to_install)
+include $(BUILD_SYSTEM)/Makefile
+modules_to_install := $(sort $(ALL_DEFAULT_INSTALLED_MODULES))
+ALL_DEFAULT_INSTALLED_MODULES :=
+
+
+# These are additional goals that we build, in order to make sure that there
+# is as little code as possible in the tree that doesn't build.
+modules_to_check := $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).CHECKED))
+
+# If you would like to build all goals, and not skip any intermediate
+# steps, you can pass the "all" modifier goal on the commandline.
+ifneq ($(filter all,$(MAKECMDGOALS)),)
+modules_to_check += $(foreach m,$(ALL_MODULES),$(ALL_MODULES.$(m).BUILT))
+endif
+
+# for easier debugging
+modules_to_check := $(sort $(modules_to_check))
+#$(error modules_to_check $(modules_to_check))
+
+# -------------------------------------------------------------------
+# This is used to to get the ordering right, you can also use these,
+# but they're considered undocumented, so don't complain if their
+# behavior changes.
+.PHONY: prebuilt
+prebuilt: $(ALL_PREBUILT)
+
+# An internal target that depends on all copied headers
+# (see copy_headers.make). Other targets that need the
+# headers to be copied first can depend on this target.
+.PHONY: all_copied_headers
+all_copied_headers: ;
+
+$(ALL_C_CPP_ETC_OBJECTS): | all_copied_headers
+
+# All the droid stuff, in directories
+.PHONY: files
+files: prebuilt \
+ $(modules_to_install) \
+ $(INSTALLED_ANDROID_INFO_TXT_TARGET)
+
+# -------------------------------------------------------------------
+
+.PHONY: checkbuild
+checkbuild: $(modules_to_check) droid_targets
+ifeq ($(USE_SOONG),true)
+checkbuild: checkbuild-soong
+endif
+ifeq (true,$(ANDROID_BUILD_EVERYTHING_BY_DEFAULT))
+droid: checkbuild
+endif
+
+.PHONY: ramdisk
+ramdisk: $(INSTALLED_RAMDISK_TARGET)
+
+.PHONY: systemtarball
+systemtarball: $(INSTALLED_SYSTEMTARBALL_TARGET)
+
+.PHONY: boottarball
+boottarball: $(INSTALLED_BOOTTARBALL_TARGET)
+
+.PHONY: userdataimage
+userdataimage: $(INSTALLED_USERDATAIMAGE_TARGET)
+
+ifneq (,$(filter userdataimage, $(MAKECMDGOALS)))
+$(call dist-for-goals, userdataimage, $(BUILT_USERDATAIMAGE_TARGET))
+endif
+
+.PHONY: userdatatarball
+userdatatarball: $(INSTALLED_USERDATATARBALL_TARGET)
+
+.PHONY: cacheimage
+cacheimage: $(INSTALLED_CACHEIMAGE_TARGET)
+
+.PHONY: vendorimage
+vendorimage: $(INSTALLED_VENDORIMAGE_TARGET)
+
+.PHONY: systemotherimage
+systemotherimage: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
+
+.PHONY: bootimage
+bootimage: $(INSTALLED_BOOTIMAGE_TARGET)
+
+# phony target that include any targets in $(ALL_MODULES)
+.PHONY: all_modules
+ifndef BUILD_MODULES_IN_PATHS
+all_modules: $(ALL_MODULES)
+else
+# BUILD_MODULES_IN_PATHS is a list of paths relative to the top of the tree
+build_modules_in_paths := $(patsubst ./%,%,$(BUILD_MODULES_IN_PATHS))
+module_path_patterns := $(foreach p, $(build_modules_in_paths),\
+ $(if $(filter %/,$(p)),$(p)%,$(p)/%))
+my_all_modules := $(sort $(foreach m, $(ALL_MODULES),$(if $(filter\
+ $(module_path_patterns), $(addsuffix /,$(ALL_MODULES.$(m).PATH))),$(m))))
+all_modules: $(my_all_modules)
+endif
+
+
+# Build files and then package it into the rom formats
+.PHONY: droidcore
+droidcore: files \
+ systemimage \
+ $(INSTALLED_BOOTIMAGE_TARGET) \
+ $(INSTALLED_RECOVERYIMAGE_TARGET) \
+ $(INSTALLED_USERDATAIMAGE_TARGET) \
+ $(INSTALLED_CACHEIMAGE_TARGET) \
+ $(INSTALLED_VENDORIMAGE_TARGET) \
+ $(INSTALLED_SYSTEMOTHERIMAGE_TARGET) \
+ $(INSTALLED_FILES_FILE) \
+ $(INSTALLED_FILES_FILE_VENDOR) \
+ $(INSTALLED_FILES_FILE_SYSTEMOTHER)
+
+# dist_files only for putting your library into the dist directory with a full build.
+.PHONY: dist_files
+
+ifneq ($(TARGET_BUILD_APPS),)
+ # If this build is just for apps, only build apps and not the full system by default.
+
+ unbundled_build_modules :=
+ ifneq ($(filter all,$(TARGET_BUILD_APPS)),)
+ # If they used the magic goal "all" then build all apps in the source tree.
+ unbundled_build_modules := $(foreach m,$(sort $(ALL_MODULES)),$(if $(filter APPS,$(ALL_MODULES.$(m).CLASS)),$(m)))
+ else
+ unbundled_build_modules := $(TARGET_BUILD_APPS)
+ endif
+
+ # Dist the installed files if they exist.
+ apps_only_installed_files := $(foreach m,$(unbundled_build_modules),$(ALL_MODULES.$(m).INSTALLED))
+ $(call dist-for-goals,apps_only, $(apps_only_installed_files))
+ # For uninstallable modules such as static Java library, we have to dist the built file,
+ # as .
+ apps_only_dist_built_files := $(foreach m,$(unbundled_build_modules),$(if $(ALL_MODULES.$(m).INSTALLED),,\
+ $(if $(ALL_MODULES.$(m).BUILT),$(ALL_MODULES.$(m).BUILT):$(m)$(suffix $(ALL_MODULES.$(m).BUILT)))\
+ $(if $(ALL_MODULES.$(m).AAR),$(ALL_MODULES.$(m).AAR):$(m).aar)\
+ ))
+ $(call dist-for-goals,apps_only, $(apps_only_dist_built_files))
+
+ ifeq ($(EMMA_INSTRUMENT),true)
+ $(EMMA_META_ZIP) : $(apps_only_installed_files)
+
+ $(call dist-for-goals,apps_only, $(EMMA_META_ZIP))
+ endif
+
+ $(PROGUARD_DICT_ZIP) : $(apps_only_installed_files)
+ $(call dist-for-goals,apps_only, $(PROGUARD_DICT_ZIP))
+
+ $(SYMBOLS_ZIP) : $(apps_only_installed_files)
+ $(call dist-for-goals,apps_only, $(SYMBOLS_ZIP))
+
+.PHONY: apps_only
+apps_only: $(unbundled_build_modules)
+
+droid_targets: apps_only
+
+# Combine the NOTICE files for a apps_only build
+$(eval $(call combine-notice-files, \
+ $(target_notice_file_txt), \
+ $(target_notice_file_html), \
+ "Notices for files for apps:", \
+ $(TARGET_OUT_NOTICE_FILES), \
+ $(apps_only_installed_files)))
+
+
+else # TARGET_BUILD_APPS
+ $(call dist-for-goals, droidcore, \
+ $(INTERNAL_UPDATE_PACKAGE_TARGET) \
+ $(INTERNAL_OTA_PACKAGE_TARGET) \
+ $(BUILT_OTATOOLS_PACKAGE) \
+ $(SYMBOLS_ZIP) \
+ $(INSTALLED_FILES_FILE) \
+ $(INSTALLED_FILES_FILE_VENDOR) \
+ $(INSTALLED_FILES_FILE_SYSTEMOTHER) \
+ $(INSTALLED_BUILD_PROP_TARGET) \
+ $(BUILT_TARGET_FILES_PACKAGE) \
+ $(INSTALLED_ANDROID_INFO_TXT_TARGET) \
+ $(INSTALLED_RAMDISK_TARGET) \
+ )
+
+ # Put a copy of the radio/bootloader files in the dist dir.
+ $(foreach f,$(INSTALLED_RADIOIMAGE_TARGET), \
+ $(call dist-for-goals, droidcore, $(f)))
+
+ ifneq ($(ANDROID_BUILD_EMBEDDED),true)
+ ifneq ($(TARGET_BUILD_PDK),true)
+ $(call dist-for-goals, droidcore, \
+ $(APPS_ZIP) \
+ $(INTERNAL_EMULATOR_PACKAGE_TARGET) \
+ $(PACKAGE_STATS_FILE) \
+ )
+ endif
+ endif
+
+ ifeq ($(EMMA_INSTRUMENT),true)
+ $(EMMA_META_ZIP) : $(INSTALLED_SYSTEMIMAGE)
+
+ $(call dist-for-goals, dist_files, $(EMMA_META_ZIP))
+ endif
+
+# Building a full system-- the default is to build droidcore
+droid_targets: droidcore dist_files
+
+endif # TARGET_BUILD_APPS
+
+.PHONY: docs
+docs: $(ALL_DOCS)
+
+.PHONY: sdk
+ALL_SDK_TARGETS := $(INTERNAL_SDK_TARGET)
+sdk: $(ALL_SDK_TARGETS)
+$(call dist-for-goals,sdk win_sdk, \
+ $(ALL_SDK_TARGETS) \
+ $(SYMBOLS_ZIP) \
+ $(INSTALLED_BUILD_PROP_TARGET) \
+)
+
+# umbrella targets to assit engineers in verifying builds
+.PHONY: java native target host java-host java-target native-host native-target \
+ java-host-tests java-target-tests native-host-tests native-target-tests \
+ java-tests native-tests host-tests target-tests tests
+# some synonyms
+.PHONY: host-java target-java host-native target-native \
+ target-java-tests target-native-tests
+host-java : java-host
+target-java : java-target
+host-native : native-host
+target-native : native-target
+target-java-tests : java-target-tests
+target-native-tests : native-target-tests
+tests : host-tests target-tests
+
+# To catch more build breakage, check build tests modules in eng and userdebug builds.
+ifneq ($(ANDROID_NO_TEST_CHECK),true)
+ifneq ($(TARGET_BUILD_PDK),true)
+ifneq ($(filter eng userdebug,$(TARGET_BUILD_VARIANT)),)
+droidcore : target-tests host-tests
+endif
+endif
+endif
+
+ifneq (,$(filter samplecode, $(MAKECMDGOALS)))
+.PHONY: samplecode
+sample_MODULES := $(sort $(call get-tagged-modules,samples))
+sample_APKS_DEST_PATH := $(TARGET_COMMON_OUT_ROOT)/samples
+sample_APKS_COLLECTION := \
+ $(foreach module,$(sample_MODULES),$(sample_APKS_DEST_PATH)/$(notdir $(module)))
+$(foreach module,$(sample_MODULES),$(eval $(call \
+ copy-one-file,$(module),$(sample_APKS_DEST_PATH)/$(notdir $(module)))))
+sample_ADDITIONAL_INSTALLED := \
+ $(filter-out $(modules_to_install) $(modules_to_check) $(ALL_PREBUILT),$(sample_MODULES))
+samplecode: $(sample_APKS_COLLECTION)
+ @echo "Collect sample code apks: $^"
+ # remove apks that are not intended to be installed.
+ rm -f $(sample_ADDITIONAL_INSTALLED)
+endif # samplecode in $(MAKECMDGOALS)
+
+.PHONY: findbugs
+findbugs: $(INTERNAL_FINDBUGS_HTML_TARGET) $(INTERNAL_FINDBUGS_XML_TARGET)
+
+.PHONY: clean
+clean:
+ @rm -rf $(OUT_DIR)/*
+ @echo "Entire build directory removed."
+
+.PHONY: clobber
+clobber: clean
+
+# The rules for dataclean and installclean are defined in cleanbuild.mk.
+
+#xxx scrape this from ALL_MODULE_NAME_TAGS
+.PHONY: modules
+modules:
+ @echo "Available sub-modules:"
+ @echo "$(call module-names-for-tag-list,$(ALL_MODULE_TAGS))" | \
+ tr -s ' ' '\n' | sort -u | $(COLUMN)
+
+.PHONY: showcommands
+showcommands:
+ @echo >/dev/null
+
+.PHONY: nothing
+nothing:
+ @echo Successfully read the makefiles.
+endif # !relaunch_with_ninja
diff --git a/core/module_arch_supported.mk b/core/module_arch_supported.mk
new file mode 100644
index 0000000000000000000000000000000000000000..62e2643312b076055fd913a6e35f4bc2f32cf159
--- /dev/null
+++ b/core/module_arch_supported.mk
@@ -0,0 +1,72 @@
+###########################################################
+## Determine if a module can be built for an arch
+##
+## Inputs from module makefile:
+## my_prefix TARGET_ or HOST_
+## my_module_multilib
+## LOCAL_MODULE_$(my_prefix)ARCH
+## LOCAL_MODULE_$(my_prefix)ARCH_WARN
+## LOCAL_MODULE_UNSUPPORTED_$(my_prefix)ARCH
+## LOCAL_MODULE_UNSUPPORTED_$(my_prefix)ARCH_WARN
+## LOCAL_IS_HOST_MODULE
+## LOCAL_MODULE_HOST_OS
+##
+## Inputs from build system:
+## $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT
+## LOCAL_2ND_ARCH_VAR_PREFIX
+##
+## Outputs:
+## my_module_arch_supported := (true|false)
+###########################################################
+
+my_module_arch_supported := true
+
+ifeq ($(my_module_multilib),none)
+my_module_arch_supported := false
+endif
+
+ifeq ($($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT)|$(my_module_multilib),true|32)
+my_module_arch_supported := false
+endif
+ifeq ($($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT)|$(my_module_multilib),|64)
+my_module_arch_supported := false
+endif
+
+ifneq ($(LOCAL_2ND_ARCH_VAR_PREFIX),)
+ifeq ($(my_module_multilib),first)
+my_module_arch_supported := false
+endif
+endif
+
+ifneq (,$(LOCAL_MODULE_$(my_prefix)ARCH))
+ifeq (,$(filter $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),$(LOCAL_MODULE_$(my_prefix)ARCH)))
+my_module_arch_supported := false
+endif
+endif
+
+ifneq (,$(LOCAL_MODULE_$(my_prefix)ARCH_WARN))
+ifeq (,$(filter $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),$(LOCAL_MODULE_$(my_prefix)ARCH_WARN)))
+my_module_arch_supported := false
+$(warning $(LOCAL_MODULE): architecture $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) not supported)
+endif
+endif
+
+ifneq (,$(filter $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),$(LOCAL_MODULE_UNSUPPORTED_$(my_prefix)ARCH)))
+my_module_arch_supported := false
+endif
+
+ifneq (,$(filter $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),$(LOCAL_MODULE_UNSUPPORTED_$(my_prefix)ARCH_WARN)))
+my_module_arch_supported := false
+$(warning $(LOCAL_MODULE): architecture $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) unsupported)
+endif
+
+ifdef LOCAL_IS_HOST_MODULE
+ifneq (,$(LOCAL_MODULE_HOST_OS))
+ ifeq (,$(filter $($(my_prefix)OS),$(LOCAL_MODULE_HOST_OS)))
+ my_module_arch_supported := false
+ endif
+else ifeq ($($(my_prefix)OS),windows)
+ # If LOCAL_MODULE_HOST_OS is empty, only linux and darwin are supported
+ my_module_arch_supported := false
+endif
+endif
diff --git a/core/multi_prebuilt.mk b/core/multi_prebuilt.mk
new file mode 100644
index 0000000000000000000000000000000000000000..ed2fed686af5a2fa98b4f2cffcbfaf79d79c09c2
--- /dev/null
+++ b/core/multi_prebuilt.mk
@@ -0,0 +1,135 @@
+#
+# 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.
+#
+
+ifneq ($(LOCAL_MODULE)$(LOCAL_MODULE_CLASS),)
+$(error $(LOCAL_PATH): LOCAL_MODULE or LOCAL_MODULE_CLASS not needed by \
+ BUILD_MULTI_PREBUILT, use BUILD_PREBUILT instead!)
+endif
+
+# Save these before they get cleared by CLEAR_VARS.
+prebuilt_static_libs := $(filter %.a,$(LOCAL_PREBUILT_LIBS))
+prebuilt_shared_libs := $(filter-out %.a,$(LOCAL_PREBUILT_LIBS))
+prebuilt_executables := $(LOCAL_PREBUILT_EXECUTABLES)
+prebuilt_java_libraries := $(LOCAL_PREBUILT_JAVA_LIBRARIES)
+prebuilt_static_java_libraries := $(LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES)
+prebuilt_is_host := $(LOCAL_IS_HOST_MODULE)
+prebuilt_module_tags := $(LOCAL_MODULE_TAGS)
+prebuilt_strip_module := $(LOCAL_STRIP_MODULE)
+
+
+ifndef multi_prebuilt_once
+multi_prebuilt_once := true
+
+# $(1): file list
+# $(2): IS_HOST_MODULE
+# $(3): MODULE_CLASS
+# $(4): MODULE_TAGS
+# $(5): OVERRIDE_BUILT_MODULE_PATH
+# $(6): UNINSTALLABLE_MODULE
+# $(7): BUILT_MODULE_STEM
+# $(8): LOCAL_STRIP_MODULE
+#
+# Elements in the file list may be bare filenames,
+# or of the form ":".
+# If the module name is not specified, the module
+# name will be the filename with the suffix removed.
+#
+define auto-prebuilt-boilerplate
+$(if $(filter %: :%,$(1)), \
+ $(error $(LOCAL_PATH): Leading or trailing colons in "$(1)")) \
+$(foreach t,$(1), \
+ $(eval include $(CLEAR_VARS)) \
+ $(eval LOCAL_IS_HOST_MODULE := $(2)) \
+ $(eval LOCAL_MODULE_CLASS := $(3)) \
+ $(eval LOCAL_MODULE_TAGS := $(4)) \
+ $(eval OVERRIDE_BUILT_MODULE_PATH := $(5)) \
+ $(eval LOCAL_UNINSTALLABLE_MODULE := $(6)) \
+ $(eval tw := $(subst :, ,$(strip $(t)))) \
+ $(if $(word 3,$(tw)),$(error $(LOCAL_PATH): Bad prebuilt filename '$(t)')) \
+ $(if $(word 2,$(tw)), \
+ $(eval LOCAL_MODULE := $(word 1,$(tw))) \
+ $(eval LOCAL_SRC_FILES := $(word 2,$(tw))) \
+ , \
+ $(eval LOCAL_MODULE := $(basename $(notdir $(t)))) \
+ $(eval LOCAL_SRC_FILES := $(t)) \
+ ) \
+ $(if $(7), \
+ $(eval LOCAL_BUILT_MODULE_STEM := $(7)) \
+ , \
+ $(if $(word 2,$(tw)), \
+ $(eval LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)$(suffix $(LOCAL_SRC_FILES))) \
+ , \
+ $(eval LOCAL_BUILT_MODULE_STEM := $(notdir $(LOCAL_SRC_FILES))) \
+ ) \
+ ) \
+ $(eval LOCAL_MODULE_SUFFIX := $(suffix $(LOCAL_SRC_FILES))) \
+ $(eval LOCAL_STRIP_MODULE := $(8)) \
+ $(eval include $(BUILD_PREBUILT)) \
+ )
+endef
+
+endif # multi_prebuilt_once
+
+
+$(call auto-prebuilt-boilerplate, \
+ $(prebuilt_static_libs), \
+ $(prebuilt_is_host), \
+ STATIC_LIBRARIES, \
+ $(prebuilt_module_tags), \
+ , \
+ true)
+
+$(call auto-prebuilt-boilerplate, \
+ $(prebuilt_shared_libs), \
+ $(prebuilt_is_host), \
+ SHARED_LIBRARIES, \
+ $(prebuilt_module_tags), \
+ $($(if $(prebuilt_is_host),HOST,TARGET)_OUT_INTERMEDIATE_LIBRARIES), \
+ , \
+ , \
+ $(prebuilt_strip_module))
+
+$(call auto-prebuilt-boilerplate, \
+ $(prebuilt_executables), \
+ $(prebuilt_is_host), \
+ EXECUTABLES, \
+ $(prebuilt_module_tags))
+
+$(call auto-prebuilt-boilerplate, \
+ $(prebuilt_java_libraries), \
+ $(prebuilt_is_host), \
+ JAVA_LIBRARIES, \
+ $(prebuilt_module_tags), \
+ , \
+ , \
+ javalib.jar)
+
+$(call auto-prebuilt-boilerplate, \
+ $(prebuilt_static_java_libraries), \
+ $(prebuilt_is_host), \
+ JAVA_LIBRARIES, \
+ $(prebuilt_module_tags), \
+ , \
+ true, \
+ javalib.jar)
+
+prebuilt_static_libs :=
+prebuilt_shared_libs :=
+prebuilt_executables :=
+prebuilt_java_libraries :=
+prebuilt_static_java_libraries :=
+prebuilt_is_host :=
+prebuilt_module_tags :=
diff --git a/core/multilib.mk b/core/multilib.mk
new file mode 100644
index 0000000000000000000000000000000000000000..a3ced65d2c1891c63843c1786b6dbe1a99799bc9
--- /dev/null
+++ b/core/multilib.mk
@@ -0,0 +1,15 @@
+# Translate LOCAL_32_BIT_ONLY to LOCAL_MULTILIB,
+# and check LOCAL_MULTILIB is a valid value. Returns module's multilib
+# setting in my_module_multilib, or empty if not set.
+
+my_module_multilib := $(strip $(LOCAL_MULTILIB))
+
+ifndef my_module_multilib
+ifeq ($(LOCAL_32_BIT_ONLY),true)
+my_module_multilib := 32
+endif
+else # my_module_multilib defined
+ifeq (,$(filter 32 64 first both none,$(my_module_multilib)))
+$(error $(LOCAL_PATH): Invalid LOCAL_MULTILIB specified for module $(LOCAL_MODULE))
+endif
+endif # my_module_multilib defined
diff --git a/core/native_benchmark.mk b/core/native_benchmark.mk
new file mode 100644
index 0000000000000000000000000000000000000000..ac377011c202cb6ed566e68713e5d79d9e5592f7
--- /dev/null
+++ b/core/native_benchmark.mk
@@ -0,0 +1,17 @@
+###########################################
+## A thin wrapper around BUILD_EXECUTABLE
+## Common flags for native benchmarks are added.
+###########################################
+
+LOCAL_STATIC_LIBRARIES += libgoogle-benchmark
+
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_METRIC_TESTS)/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_METRIC_TESTS)/$(LOCAL_MODULE)
+
+ifndef LOCAL_MULTILIB
+ifndef LOCAL_32_BIT_ONLY
+LOCAL_MULTILIB := both
+endif
+endif
+
+include $(BUILD_EXECUTABLE)
diff --git a/core/native_test.mk b/core/native_test.mk
new file mode 100644
index 0000000000000000000000000000000000000000..93b7e1a9013b9cdcc01d94203a068d716c9d8266
--- /dev/null
+++ b/core/native_test.mk
@@ -0,0 +1,14 @@
+###########################################
+## A thin wrapper around BUILD_EXECUTABLE
+## Common flags for native tests are added.
+###########################################
+
+include $(BUILD_SYSTEM)/target_test_internal.mk
+
+ifndef LOCAL_MULTILIB
+ifndef LOCAL_32_BIT_ONLY
+LOCAL_MULTILIB := both
+endif
+endif
+
+include $(BUILD_EXECUTABLE)
diff --git a/core/ninja.mk b/core/ninja.mk
new file mode 100644
index 0000000000000000000000000000000000000000..9d0ff9a70b2791c26f0d8e7a3f117db85af32a6d
--- /dev/null
+++ b/core/ninja.mk
@@ -0,0 +1,192 @@
+NINJA ?= prebuilts/ninja/$(HOST_PREBUILT_TAG)/ninja
+
+ifeq ($(USE_SOONG),true)
+USE_SOONG_FOR_KATI := true
+endif
+
+ifeq ($(USE_SOONG_FOR_KATI),true)
+include $(BUILD_SYSTEM)/soong.mk
+else
+KATI ?= $(HOST_OUT_EXECUTABLES)/ckati
+MAKEPARALLEL ?= $(HOST_OUT_EXECUTABLES)/makeparallel
+endif
+
+KATI_OUTPUT_PATTERNS := $(OUT_DIR)/build%.ninja $(OUT_DIR)/ninja%.sh
+
+# Modifier goals we don't need to pass to Ninja.
+NINJA_EXCLUDE_GOALS := showcommands all dist
+.PHONY : $(NINJA_EXCLUDE_GOALS)
+
+# A list of goals which affect parsing of makefiles and we need to pass to Kati.
+PARSE_TIME_MAKE_GOALS := \
+ $(PARSE_TIME_MAKE_GOALS) \
+ $(dont_bother_goals) \
+ all \
+ APP-% \
+ DUMP_% \
+ ECLIPSE-% \
+ PRODUCT-% \
+ boottarball-nodeps \
+ btnod \
+ build-art% \
+ build_kernel-nodeps \
+ clean-oat% \
+ continuous_instrumentation_tests \
+ continuous_native_tests \
+ cts \
+ custom_images \
+ deps-license \
+ dicttool_aosp \
+ dist \
+ dump-products \
+ dumpvar-% \
+ eng \
+ fusion \
+ oem_image \
+ old-cts \
+ online-system-api-sdk-docs \
+ pdk \
+ platform \
+ platform-java \
+ product-graph \
+ samplecode \
+ sdk \
+ sdk_addon \
+ sdk_repo \
+ snod \
+ stnod \
+ systemimage-nodeps \
+ systemtarball-nodeps \
+ target-files-package \
+ test-art% \
+ user \
+ userdataimage \
+ userdebug \
+ valgrind-test-art% \
+ vts \
+ win_sdk \
+ winsdk-tools
+
+-include vendor/google/build/ninja_config.mk
+
+# Any Android goals that need to be built.
+ANDROID_GOALS := $(filter-out $(KATI_OUTPUT_PATTERNS) $(KATI) $(MAKEPARALLEL),\
+ $(sort $(ORIGINAL_MAKECMDGOALS) $(MAKECMDGOALS)))
+# Goals we need to pass to Ninja.
+NINJA_GOALS := $(filter-out $(NINJA_EXCLUDE_GOALS), $(ANDROID_GOALS))
+# Goals we need to pass to Kati.
+KATI_GOALS := $(filter $(PARSE_TIME_MAKE_GOALS), $(ANDROID_GOALS))
+
+define replace_space_and_slash
+$(subst /,_,$(subst $(space),_,$(sort $1)))
+endef
+
+KATI_NINJA_SUFFIX := -$(TARGET_PRODUCT)
+ifneq ($(KATI_GOALS),)
+KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-$(call replace_space_and_slash,$(KATI_GOALS))
+endif
+ifneq ($(ONE_SHOT_MAKEFILE),)
+KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmm-$(call replace_space_and_slash,$(ONE_SHOT_MAKEFILE))
+endif
+ifneq ($(BUILD_MODULES_IN_PATHS),)
+KATI_NINJA_SUFFIX := $(KATI_NINJA_SUFFIX)-mmma-$(call replace_space_and_slash,$(BUILD_MODULES_IN_PATHS))
+endif
+
+my_checksum_suffix :=
+my_ninja_suffix_too_long := $(filter 1, $(shell v='$(KATI_NINJA_SUFFIX)' && echo $$(($${$(pound)v} > 64))))
+ifneq ($(my_ninja_suffix_too_long),)
+# Replace the suffix with a checksum if it gets too long.
+my_checksum_suffix := $(KATI_NINJA_SUFFIX)
+KATI_NINJA_SUFFIX := -$(word 1, $(shell echo $(my_checksum_suffix) | $(MD5SUM)))
+endif
+
+KATI_BUILD_NINJA := $(OUT_DIR)/build$(KATI_NINJA_SUFFIX).ninja
+KATI_ENV_SH := $(OUT_DIR)/env$(KATI_NINJA_SUFFIX).sh
+
+# Write out a file mapping checksum to the real suffix.
+ifneq ($(my_checksum_suffix),)
+my_ninja_suffix_file := $(basename $(KATI_BUILD_NINJA)).suf
+$(shell mkdir -p $(dir $(my_ninja_suffix_file)) && \
+ echo $(my_checksum_suffix) > $(my_ninja_suffix_file))
+endif
+
+ifeq (,$(NINJA_STATUS))
+NINJA_STATUS := [%p %s/%t]$(space)
+endif
+
+ifneq (,$(filter showcommands,$(ORIGINAL_MAKECMDGOALS)))
+NINJA_ARGS += "-v"
+endif
+
+ifdef USE_GOMA
+KATI_MAKEPARALLEL := $(MAKEPARALLEL)
+# Ninja runs remote jobs (i.e., commands which contain gomacc) with
+# this parallelism. Note the parallelism of all other jobs is still
+# limited by the -j flag passed to GNU make.
+NINJA_REMOTE_NUM_JOBS ?= 500
+NINJA_ARGS += -j$(NINJA_REMOTE_NUM_JOBS)
+else
+NINJA_MAKEPARALLEL := $(MAKEPARALLEL) --ninja
+endif
+
+ifeq ($(USE_SOONG),true)
+COMBINED_BUILD_NINJA := $(OUT_DIR)/combined$(KATI_NINJA_SUFFIX).ninja
+
+$(COMBINED_BUILD_NINJA): $(KATI_BUILD_NINJA) $(SOONG_ANDROID_MK)
+ $(hide) echo "builddir = $(OUT_DIR)" > $(COMBINED_BUILD_NINJA)
+ $(hide) echo "subninja $(SOONG_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
+ $(hide) echo "subninja $(KATI_BUILD_NINJA)" >> $(COMBINED_BUILD_NINJA)
+else
+COMBINED_BUILD_NINJA := $(KATI_BUILD_NINJA)
+endif
+
+$(sort $(DEFAULT_GOAL) $(ANDROID_GOALS)) : ninja_wrapper
+ @#empty
+
+.PHONY: ninja_wrapper
+ninja_wrapper: $(COMBINED_BUILD_NINJA) $(MAKEPARALLEL)
+ @echo Starting build with ninja
+ +$(hide) export NINJA_STATUS="$(NINJA_STATUS)" && source $(KATI_ENV_SH) && $(NINJA_MAKEPARALLEL) $(NINJA) $(NINJA_GOALS) -C $(TOP) -f $(COMBINED_BUILD_NINJA) $(NINJA_ARGS)
+
+# Dummy Android.mk and CleanSpec.mk files so that kati won't recurse into the
+# out directory
+DUMMY_OUT_MKS := $(OUT_DIR)/Android.mk $(OUT_DIR)/CleanSpec.mk
+$(DUMMY_OUT_MKS):
+ @mkdir -p $(dir $@)
+ $(hide) echo '# This file prevents findleaves.py from traversing this directory further' >$@
+
+KATI_FIND_EMULATOR := --use_find_emulator
+ifeq ($(KATI_EMULATE_FIND),false)
+ KATI_FIND_EMULATOR :=
+endif
+$(KATI_BUILD_NINJA): $(KATI) $(MAKEPARALLEL) $(DUMMY_OUT_MKS) $(SOONG_ANDROID_MK) FORCE
+ @echo Running kati to generate build$(KATI_NINJA_SUFFIX).ninja...
+ +$(hide) $(KATI_MAKEPARALLEL) $(KATI) --ninja --ninja_dir=$(OUT_DIR) --ninja_suffix=$(KATI_NINJA_SUFFIX) --regen --ignore_dirty=$(OUT_DIR)/% --no_ignore_dirty=$(SOONG_ANDROID_MK) --ignore_optional_include=$(OUT_DIR)/%.P --detect_android_echo $(KATI_FIND_EMULATOR) -f build/core/main.mk $(KATI_GOALS) --gen_all_targets BUILDING_WITH_NINJA=true SOONG_ANDROID_MK=$(SOONG_ANDROID_MK)
+
+ifneq ($(USE_SOONG_FOR_KATI),true)
+KATI_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CFLAGS) $(CLANG_HOST_GLOBAL_CPPFLAGS)
+KATI_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)
+# Build static ckati. Unfortunately Mac OS X doesn't officially support static exectuables.
+ifeq ($(BUILD_OS),linux)
+# We need everything in libpthread.a otherwise C++11's threading library will be disabled.
+KATI_LD += -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -ldl
+endif
+
+KATI_INTERMEDIATES_PATH := $(HOST_OUT_INTERMEDIATES)/EXECUTABLES/ckati_intermediates
+KATI_BIN_PATH := $(HOST_OUT_EXECUTABLES)
+include build/kati/Makefile.ckati
+
+MAKEPARALLEL_CXX := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_CFLAGS) $(CLANG_HOST_GLOBAL_CPPFLAGS)
+MAKEPARALLEL_LD := $(CLANG_CXX) $(CLANG_HOST_GLOBAL_LDFLAGS)
+# Build static makeparallel. Unfortunately Mac OS X doesn't officially support static exectuables.
+ifeq ($(BUILD_OS),linux)
+MAKEPARALLEL_LD += -static
+endif
+
+MAKEPARALLEL_INTERMEDIATES_PATH := $(HOST_OUT_INTERMEDIATES)/EXECUTABLES/makeparallel_intermediates
+MAKEPARALLEL_BIN_PATH := $(HOST_OUT_EXECUTABLES)
+include build/tools/makeparallel/Makefile
+endif
+
+.PHONY: FORCE
+FORCE:
diff --git a/core/node_fns.mk b/core/node_fns.mk
new file mode 100644
index 0000000000000000000000000000000000000000..ccfcc2518350f8a42b6fe01ef52635139c002b60
--- /dev/null
+++ b/core/node_fns.mk
@@ -0,0 +1,256 @@
+#
+# 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.
+#
+
+#
+# Clears a list of variables using ":=".
+#
+# E.g.,
+# $(call clear-var-list,A B C)
+# would be the same as:
+# A :=
+# B :=
+# C :=
+#
+# $(1): list of variable names to clear
+#
+define clear-var-list
+$(foreach v,$(1),$(eval $(v):=))
+endef
+
+#
+# Copies a list of variables into another list of variables.
+# The target list is the same as the source list, but has
+# a dotted prefix affixed to it.
+#
+# E.g.,
+# $(call copy-var-list, PREFIX, A B)
+# would be the same as:
+# PREFIX.A := $(A)
+# PREFIX.B := $(B)
+#
+# $(1): destination prefix
+# $(2): list of variable names to copy
+#
+define copy-var-list
+$(foreach v,$(2),$(eval $(strip $(1)).$(v):=$($(v))))
+endef
+
+#
+# Moves a list of variables into another list of variables.
+# The variable names differ by a prefix. After moving, the
+# source variable is cleared.
+#
+# NOTE: Spaces are not allowed around the prefixes.
+#
+# E.g.,
+# $(call move-var-list,SRC,DST,A B)
+# would be the same as:
+# DST.A := $(SRC.A)
+# SRC.A :=
+# DST.B := $(SRC.B)
+# SRC.B :=
+#
+# $(1): source prefix
+# $(2): destination prefix
+# $(3): list of variable names to move
+#
+define move-var-list
+$(foreach v,$(3), \
+ $(eval $(2).$(v) := $($(1).$(v))) \
+ $(eval $(1).$(v) :=) \
+ )
+endef
+
+#
+# $(1): haystack
+# $(2): needle
+#
+# Guarantees that needle appears at most once in haystack,
+# without changing the order of other elements in haystack.
+# If needle appears multiple times, only the first occurrance
+# will survive.
+#
+# How it works:
+#
+# - Stick everything in haystack into a single word,
+# with "|||" separating the words.
+# - Replace occurrances of "|||$(needle)|||" with "||| |||",
+# breaking haystack back into multiple words, with spaces
+# where needle appeared.
+# - Add needle between the first and second words of haystack.
+# - Replace "|||" with spaces, breaking haystack back into
+# individual words.
+#
+define uniq-word
+$(strip \
+ $(if $(filter-out 0 1,$(words $(filter $(2),$(1)))), \
+ $(eval h := |||$(subst $(space),|||,$(strip $(1)))|||) \
+ $(eval h := $(subst |||$(strip $(2))|||,|||$(space)|||,$(h))) \
+ $(eval h := $(word 1,$(h)) $(2) $(wordlist 2,9999,$(h))) \
+ $(subst |||,$(space),$(h)) \
+ , \
+ $(1) \
+ ))
+endef
+
+INHERIT_TAG := @inherit:
+
+#
+# Walks through the list of variables, each qualified by the prefix,
+# and finds instances of words beginning with INHERIT_TAG. Scrape
+# off INHERIT_TAG from each matching word, and return the sorted,
+# unique set of those words.
+#
+# E.g., given
+# PREFIX.A := A $(INHERIT_TAG)aaa B C
+# PREFIX.B := B $(INHERIT_TAG)aaa C $(INHERIT_TAG)bbb D E
+# Then
+# $(call get-inherited-nodes,PREFIX,A B)
+# returns
+# aaa bbb
+#
+# $(1): variable prefix
+# $(2): list of variables to check
+#
+define get-inherited-nodes
+$(sort \
+ $(subst $(INHERIT_TAG),, \
+ $(filter $(INHERIT_TAG)%, \
+ $(foreach v,$(2),$($(1).$(v))) \
+ )))
+endef
+
+#
+# for each variable ( (prefix + name) * vars ):
+# get list of inherited words; if not empty:
+# for each inherit:
+# replace the first occurrence with (prefix + inherited + var)
+# clear the source var so we can't inherit the value twice
+#
+# $(1): context prefix
+# $(2): name of this node
+# $(3): list of variable names
+#
+define _expand-inherited-values
+ $(foreach v,$(3), \
+ $(eval ### "Shorthand for the name of the target variable") \
+ $(eval _eiv_tv := $(1).$(2).$(v)) \
+ $(eval ### "Get the list of nodes that this variable inherits") \
+ $(eval _eiv_i := \
+ $(sort \
+ $(patsubst $(INHERIT_TAG)%,%, \
+ $(filter $(INHERIT_TAG)%, $($(_eiv_tv)) \
+ )))) \
+ $(foreach i,$(_eiv_i), \
+ $(eval ### "Make sure that this inherit appears only once") \
+ $(eval $(_eiv_tv) := \
+ $(call uniq-word,$($(_eiv_tv)),$(INHERIT_TAG)$(i))) \
+ $(eval ### "Expand the inherit tag") \
+ $(eval $(_eiv_tv) := \
+ $(strip \
+ $(patsubst $(INHERIT_TAG)$(i),$($(1).$(i).$(v)), \
+ $($(_eiv_tv))))) \
+ $(eval ### "Clear the child so DAGs don't create duplicate entries" ) \
+ $(eval $(1).$(i).$(v) :=) \
+ $(eval ### "If we just inherited ourselves, it's a cycle.") \
+ $(if $(filter $(INHERIT_TAG)$(2),$($(_eiv_tv))), \
+ $(warning Cycle detected between "$(2)" and "$(i)" for context "$(1)") \
+ $(error import of "$(2)" failed) \
+ ) \
+ ) \
+ ) \
+ $(eval _eiv_tv :=) \
+ $(eval _eiv_i :=)
+endef
+
+#
+# $(1): context prefix
+# $(2): makefile representing this node
+# $(3): list of node variable names
+#
+# _include_stack contains the list of included files, with the most recent files first.
+define _import-node
+ $(eval _include_stack := $(2) $$(_include_stack))
+ $(call clear-var-list, $(3))
+ $(eval LOCAL_PATH := $(patsubst %/,%,$(dir $(2))))
+ $(eval MAKEFILE_LIST :=)
+ $(eval include $(2))
+ $(eval _included := $(filter-out $(2),$(MAKEFILE_LIST)))
+ $(eval MAKEFILE_LIST :=)
+ $(eval LOCAL_PATH :=)
+ $(call copy-var-list, $(1).$(2), $(3))
+ $(call clear-var-list, $(3))
+
+ $(eval $(1).$(2).inherited := \
+ $(call get-inherited-nodes,$(1).$(2),$(3)))
+ $(call _import-nodes-inner,$(1),$($(1).$(2).inherited),$(3))
+
+ $(call _expand-inherited-values,$(1),$(2),$(3))
+
+ $(eval $(1).$(2).inherited :=)
+ $(eval _include_stack := $(wordlist 2,9999,$$(_include_stack)))
+endef
+
+#
+# This will generate a warning for _included above
+# $(if $(_included), \
+# $(eval $(warning product spec file: $(2)))\
+# $(foreach _inc,$(_included),$(eval $(warning $(space)$(space)$(space)includes: $(_inc)))),)
+#
+
+#
+# $(1): context prefix
+# $(2): list of makefiles representing nodes to import
+# $(3): list of node variable names
+#
+#TODO: Make the "does not exist" message more helpful;
+# should print out the name of the file trying to include it.
+define _import-nodes-inner
+ $(foreach _in,$(2), \
+ $(if $(wildcard $(_in)), \
+ $(if $($(1).$(_in).seen), \
+ $(eval ### "skipping already-imported $(_in)") \
+ , \
+ $(eval $(1).$(_in).seen := true) \
+ $(call _import-node,$(1),$(strip $(_in)),$(3)) \
+ ) \
+ , \
+ $(error $(1): "$(_in)" does not exist) \
+ ) \
+ )
+endef
+
+#
+# $(1): output list variable name, like "PRODUCTS" or "DEVICES"
+# $(2): list of makefiles representing nodes to import
+# $(3): list of node variable names
+#
+define import-nodes
+$(if \
+ $(foreach _in,$(2), \
+ $(eval _node_import_context := _nic.$(1).[[$(_in)]]) \
+ $(if $(_include_stack),$(eval $(error ASSERTION FAILED: _include_stack \
+ should be empty here: $(_include_stack))),) \
+ $(eval _include_stack := ) \
+ $(call _import-nodes-inner,$(_node_import_context),$(_in),$(3)) \
+ $(call move-var-list,$(_node_import_context).$(_in),$(1).$(_in),$(3)) \
+ $(eval _node_import_context :=) \
+ $(eval $(1) := $($(1)) $(_in)) \
+ $(if $(_include_stack),$(eval $(error ASSERTION FAILED: _include_stack \
+ should be empty here: $(_include_stack))),) \
+ ) \
+,)
+endef
diff --git a/core/notice_files.mk b/core/notice_files.mk
new file mode 100644
index 0000000000000000000000000000000000000000..e7f89745b79adca25a88867c842485afbaae6478
--- /dev/null
+++ b/core/notice_files.mk
@@ -0,0 +1,106 @@
+###########################################################
+## Track NOTICE files
+###########################################################
+
+ifneq ($(LOCAL_NOTICE_FILE),)
+notice_file:=$(strip $(LOCAL_NOTICE_FILE))
+else
+notice_file:=$(strip $(wildcard $(LOCAL_PATH)/NOTICE))
+endif
+
+ifeq ($(LOCAL_MODULE_CLASS),GYP)
+ # We ignore NOTICE files for modules of type GYP.
+ notice_file :=
+endif
+
+ifeq ($(LOCAL_MODULE_CLASS),NOTICE_FILES)
+# If this is a NOTICE-only module, we don't include base_rule.mk,
+# so my_prefix is not set at this point.
+ifeq ($(LOCAL_IS_HOST_MODULE),true)
+ my_prefix := HOST_
+ LOCAL_HOST_PREFIX :=
+else
+ my_prefix := TARGET_
+endif
+endif
+
+ifdef notice_file
+
+# This relies on the name of the directory in PRODUCT_OUT matching where
+# it's installed on the target - i.e. system, data, etc. This does
+# not work for root and isn't exact, but it's probably good enough for
+# compliance.
+# Includes the leading slash
+ifdef LOCAL_INSTALLED_MODULE
+ module_installed_filename := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+else
+ # This module isn't installable
+ ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
+ # Stick the static libraries with the dynamic libraries.
+ # We can't use xxx_OUT_STATIC_LIBRARIES because it points into
+ # device-obj or host-obj.
+ module_installed_filename := \
+ $(patsubst $(PRODUCT_OUT)%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
+ else
+ ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
+ # Stick the static java libraries with the regular java libraries.
+ module_leaf := $(notdir $(LOCAL_BUILT_MODULE))
+ # javalib.jar is the default name for the build module (and isn't meaningful)
+ # If that's what we have, substitute the module name instead. These files
+ # aren't included on the device, so this name is synthetic anyway.
+ ifneq ($(filter javalib.jar classes.jack,$(module_leaf)),)
+ module_leaf := $(LOCAL_MODULE).jar
+ endif
+ module_installed_filename := \
+ $(patsubst $(PRODUCT_OUT)%,%,$($(my_prefix)OUT_JAVA_LIBRARIES))/$(module_leaf)
+ else
+ $(error Cannot determine where to install NOTICE file for $(LOCAL_MODULE))
+ endif # JAVA_LIBRARIES
+ endif # STATIC_LIBRARIES
+endif
+
+# In case it's actually a host file
+module_installed_filename := $(patsubst $(HOST_OUT)%,%,$(module_installed_filename))
+module_installed_filename := $(patsubst $(HOST_CROSS_OUT)%,%,$(module_installed_filename))
+
+installed_notice_file := $($(my_prefix)OUT_NOTICE_FILES)/src/$(module_installed_filename).txt
+
+$(installed_notice_file): PRIVATE_INSTALLED_MODULE := $(module_installed_filename)
+
+$(installed_notice_file): $(notice_file)
+ @echo Notice file: $< -- $@
+ $(hide) mkdir -p $(dir $@)
+ $(hide) cat $< > $@
+
+ifdef LOCAL_INSTALLED_MODULE
+# Make LOCAL_INSTALLED_MODULE depend on NOTICE files if they exist
+# libraries so they get installed along with it. Make it an order-only
+# dependency so we don't re-install a module when the NOTICE changes.
+$(LOCAL_INSTALLED_MODULE): | $(installed_notice_file)
+endif
+
+# To facilitate collecting NOTICE files for apps_only build,
+# we install the NOTICE file even if a module gets built but not installed,
+# because shared jni libraries won't be installed to the system image.
+ifdef TARGET_BUILD_APPS
+# for static Java libraries, we don't need to even build LOCAL_BUILT_MODULE,
+# but just javalib.jar in the common intermediate dir.
+ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
+$(intermediates.COMMON)/javalib.jar : | $(installed_notice_file)
+else
+$(LOCAL_BUILT_MODULE): | $(installed_notice_file)
+endif # JAVA_LIBRARIES
+endif # TARGET_BUILD_APPS
+
+else
+# NOTICE file does not exist
+installed_notice_file :=
+endif
+
+# Create a predictable, phony target to build this notice file.
+# Define it even if the notice file doesn't exist so that other
+# modules can depend on it.
+notice_target := NOTICE-$(if \
+ $(LOCAL_IS_HOST_MODULE),HOST,TARGET)-$(LOCAL_MODULE_CLASS)-$(LOCAL_MODULE)
+.PHONY: $(notice_target)
+$(notice_target): $(installed_notice_file)
diff --git a/core/package.mk b/core/package.mk
new file mode 100644
index 0000000000000000000000000000000000000000..78b65db107b8a9e8871ea9855809257f191d576b
--- /dev/null
+++ b/core/package.mk
@@ -0,0 +1,76 @@
+# We don't automatically set up rules to build packages for both
+# TARGET_ARCH and TARGET_2ND_ARCH.
+# To build it for TARGET_2ND_ARCH in a 64bit product, use "LOCAL_MULTILIB := 32".
+
+my_prefix := TARGET_
+include $(BUILD_SYSTEM)/multilib.mk
+
+ifeq ($(TARGET_SUPPORTS_32_BIT_APPS)|$(TARGET_SUPPORTS_64_BIT_APPS),true|true)
+ # packages default to building for either architecture,
+ # the preferred if its supported, otherwise the non-preferred.
+else ifeq ($(TARGET_SUPPORTS_64_BIT_APPS),true)
+ # only 64-bit apps supported
+ ifeq ($(filter $(my_module_multilib),64 both first),$(my_module_multilib))
+ # if my_module_multilib was 64, both, first, or unset, build for 64-bit
+ my_module_multilib := 64
+ else
+ # otherwise don't build this app
+ my_module_multilib := none
+ endif
+else
+ # only 32-bit apps supported
+ ifeq ($(filter $(my_module_multilib),32 both),$(my_module_multilib))
+ # if my_module_multilib was 32, both, or unset, build for 32-bit
+ my_module_multilib := 32
+ else ifeq ($(my_module_multilib),first)
+ ifndef TARGET_IS_64_BIT
+ # if my_module_multilib was first and this is a 32-bit build, build for
+ # 32-bit
+ my_module_multilib := 32
+ else
+ # if my_module_multilib was first and this is a 64-bit build, don't build
+ # this app
+ my_module_multilib := none
+ endif
+ else
+ # my_module_mulitlib was 64 or none, don't build this app
+ my_module_multilib := none
+ endif
+endif
+
+LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
+
+# if TARGET_PREFER_32_BIT_APPS is set, try to build 32-bit first
+ifdef TARGET_2ND_ARCH
+ifeq ($(TARGET_PREFER_32_BIT_APPS),true)
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+else
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif
+endif
+
+# check if preferred arch is supported
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# first arch is supported
+include $(BUILD_SYSTEM)/package_internal.mk
+else ifneq (,$(TARGET_2ND_ARCH))
+# check if the non-preferred arch is the primary or secondary
+ifeq ($(TARGET_PREFER_32_BIT_APPS),true)
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+else
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+endif
+
+# check if non-preferred arch is supported
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# secondary arch is supported
+include $(BUILD_SYSTEM)/package_internal.mk
+endif
+endif # TARGET_2ND_ARCH
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+LOCAL_NO_2ND_ARCH_MODULE_SUFFIX :=
+
+my_module_arch_supported :=
diff --git a/core/package_internal.mk b/core/package_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..551f18e57b14ad3e4b86d144de8f1f3f857d487a
--- /dev/null
+++ b/core/package_internal.mk
@@ -0,0 +1,663 @@
+#
+# 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.
+#
+
+###########################################################
+## Standard rules for building an application package.
+##
+## Additional inputs from base_rules.make:
+## LOCAL_PACKAGE_NAME: The name of the package; the directory
+## will be called this.
+##
+## MODULE, MODULE_PATH, and MODULE_SUFFIX will
+## be set for you.
+###########################################################
+
+# If this makefile is being read from within an inheritance,
+# use the new values.
+skip_definition:=
+ifdef LOCAL_PACKAGE_OVERRIDES
+ package_overridden := $(call set-inherited-package-variables)
+ ifeq ($(strip $(package_overridden)),)
+ skip_definition := true
+ endif
+endif
+
+ifndef skip_definition
+
+LOCAL_PACKAGE_NAME := $(strip $(LOCAL_PACKAGE_NAME))
+ifeq ($(LOCAL_PACKAGE_NAME),)
+$(error $(LOCAL_PATH): Package modules must define LOCAL_PACKAGE_NAME)
+endif
+
+ifneq ($(strip $(LOCAL_MODULE_SUFFIX)),)
+$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE_SUFFIX)
+endif
+LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
+
+ifneq ($(strip $(LOCAL_MODULE)),)
+$(error $(LOCAL_PATH): Package modules may not define LOCAL_MODULE)
+endif
+LOCAL_MODULE := $(LOCAL_PACKAGE_NAME)
+
+ifneq ($(strip $(LOCAL_MODULE_CLASS)),)
+$(error $(LOCAL_PATH): Package modules may not set LOCAL_MODULE_CLASS)
+endif
+LOCAL_MODULE_CLASS := APPS
+
+intermediates := $(call local-intermediates-dir)
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
+
+#################################
+include $(BUILD_SYSTEM)/configure_local_jack.mk
+#################################
+
+# Package LOCAL_MODULE_TAGS default to optional
+LOCAL_MODULE_TAGS := $(strip $(LOCAL_MODULE_TAGS))
+ifeq ($(LOCAL_MODULE_TAGS),)
+LOCAL_MODULE_TAGS := optional
+endif
+
+ifeq ($(filter tests, $(LOCAL_MODULE_TAGS)),)
+# Force localization check if it's not tagged as tests.
+LOCAL_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) -z
+endif
+
+ifdef LOCAL_PACKAGE_SPLITS
+LOCAL_AAPT_FLAGS += $(addprefix --split ,$(LOCAL_PACKAGE_SPLITS))
+endif
+
+need_compile_asset :=
+ifeq (,$(LOCAL_ASSET_DIR))
+LOCAL_ASSET_DIR := $(LOCAL_PATH)/assets
+else
+need_compile_asset := true
+endif
+
+# LOCAL_RESOURCE_DIR may point to resource generated during the build
+need_compile_res :=
+ifeq (,$(LOCAL_RESOURCE_DIR))
+ LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+else
+ need_compile_res := true
+endif
+
+package_resource_overlays := $(strip \
+ $(wildcard $(foreach dir, $(PRODUCT_PACKAGE_OVERLAYS), \
+ $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))) \
+ $(wildcard $(foreach dir, $(DEVICE_PACKAGE_OVERLAYS), \
+ $(addprefix $(dir)/, $(LOCAL_RESOURCE_DIR)))))
+
+LOCAL_RESOURCE_DIR := $(package_resource_overlays) $(LOCAL_RESOURCE_DIR)
+
+all_assets := $(strip \
+ $(foreach dir, $(LOCAL_ASSET_DIR), \
+ $(addprefix $(dir)/, \
+ $(patsubst assets/%,%, \
+ $(call find-subdir-assets, $(dir)) \
+ ) \
+ ) \
+ ))
+
+ifneq ($(all_assets),)
+need_compile_asset := true
+endif
+
+my_res_package :=
+ifdef LOCAL_USE_AAPT2
+# In aapt2 the last takes precedence.
+my_resource_dirs := $(call reverse-list,$(LOCAL_RESOURCE_DIR))
+my_res_dir :=
+my_overlay_res_dirs :=
+
+ifneq ($(LOCAL_STATIC_ANDROID_LIBRARIES),)
+# If we are using static android libraries, every source file becomes an overlay.
+# This is to emulate old AAPT behavior which simulated library support.
+my_res_dir :=
+my_overlay_res_dirs := $(my_resource_dirs)
+else
+# Without static libraries, the first directory is our directory, which can then be
+# overlaid by the rest. (First directory in my_resource_dirs is last directory in
+# $(LOCAL_RESOURCE_DIR) due to it being reversed.
+my_res_dir := $(firstword $(my_resource_dirs))
+my_overlay_res_dirs := $(wordlist 2,999,$(my_resource_dirs))
+endif
+
+my_overlay_resources := $(strip \
+ $(foreach d,$(my_overlay_res_dirs),\
+ $(addprefix $(d)/, \
+ $(call find-subdir-assets,$(d)))))
+
+my_res_resources := $(strip \
+ $(addprefix $(my_res_dir)/, \
+ $(call find-subdir-assets,$(my_res_dir))))
+
+all_resources := $(strip $(my_res_resources) $(my_overlay_resources))
+
+# The linked resource package.
+my_res_package := $(intermediates)/package-res.apk
+LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
+
+# Always run aapt2, because we need to at least compile the AndroidManifest.xml.
+need_compile_res := true
+
+else # LOCAL_USE_AAPT2
+all_resources := $(strip \
+ $(foreach dir, $(LOCAL_RESOURCE_DIR), \
+ $(addprefix $(dir)/, \
+ $(patsubst res/%,%, \
+ $(call find-subdir-assets,$(dir)) \
+ ) \
+ ) \
+ ))
+
+endif # LOCAL_USE_AAPT2
+
+ifneq ($(all_resources),)
+ need_compile_res := true
+endif
+
+all_res_assets := $(strip $(all_assets) $(all_resources))
+
+
+# If no assets or resources were found, clear the directory variables so
+# we don't try to build them.
+ifneq (true,$(need_compile_asset))
+LOCAL_ASSET_DIR:=
+endif
+ifneq (true,$(need_compile_res))
+LOCAL_RESOURCE_DIR:=
+R_file_stamp :=
+else
+# Make sure that R_file_stamp inherits the proper PRIVATE vars.
+# If R.stamp moves, be sure to update the framework makefile,
+# which has intimate knowledge of its location.
+R_file_stamp := $(intermediates.COMMON)/src/R.stamp
+LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
+endif
+
+LOCAL_BUILT_MODULE_STEM := package.apk
+LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
+
+LOCAL_PROGUARD_ENABLED:=$(strip $(LOCAL_PROGUARD_ENABLED))
+ifndef LOCAL_PROGUARD_ENABLED
+ifneq ($(DISABLE_PROGUARD),true)
+ LOCAL_PROGUARD_ENABLED :=full
+endif
+endif
+ifeq ($(LOCAL_PROGUARD_ENABLED),disabled)
+ # the package explicitly request to disable proguard.
+ LOCAL_PROGUARD_ENABLED :=
+endif
+proguard_options_file :=
+ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
+ifeq ($(need_compile_res),true)
+ proguard_options_file := $(intermediates.COMMON)/proguard_options
+endif # need_compile_res
+endif # !custom
+LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
+
+ifdef LOCAL_JACK_ENABLED
+ifndef LOCAL_JACK_PROGUARD_FLAGS
+ LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS)
+endif
+LOCAL_JACK_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_JACK_PROGUARD_FLAGS)
+endif # LOCAL_JACK_ENABLED
+
+ifeq (true,$(EMMA_INSTRUMENT))
+ifndef LOCAL_EMMA_INSTRUMENT
+# No emma for test apks.
+ifeq (,$(LOCAL_INSTRUMENTATION_FOR))
+LOCAL_EMMA_INSTRUMENT := true
+endif # No test apk
+endif # LOCAL_EMMA_INSTRUMENT is not set
+else
+LOCAL_EMMA_INSTRUMENT := false
+endif # EMMA_INSTRUMENT is true
+
+ifeq (true,$(LOCAL_EMMA_INSTRUMENT))
+ifeq (true,$(EMMA_INSTRUMENT_STATIC))
+ifdef LOCAL_JACK_ENABLED
+# Jack supports coverage with Jacoco
+ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
+# Only add jacocoagent if the package contains some java code
+LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
+endif # Contains java code
+else
+LOCAL_STATIC_JAVA_LIBRARIES += emma
+endif # LOCAL_JACK_ENABLED
+else
+ifdef LOCAL_SDK_VERSION
+ifdef TARGET_BUILD_APPS
+# In unbundled build, merge the coverage library into the apk.
+ifdef LOCAL_JACK_ENABLED
+# Jack supports coverage with Jacoco
+ifneq ($(LOCAL_SRC_FILES)$(LOCAL_STATIC_JAVA_LIBRARIES)$(LOCAL_SOURCE_FILES_ALL_GENERATED),)
+# Only add jacocoagent if the package contains some java code
+LOCAL_STATIC_JAVA_LIBRARIES += jacocoagent
+# Exclude jacoco classes from proguard
+LOCAL_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
+LOCAL_JACK_PROGUARD_FLAGS += -include $(BUILD_SYSTEM)/proguard.jacoco.flags
+endif # Contains java code
+else
+LOCAL_STATIC_JAVA_LIBRARIES += emma
+endif # LOCAL_JACK_ENABLED
+else
+# If build against the SDK in full build, core.jar is not used
+# so coverage classes are not present.
+ifdef LOCAL_JACK_ENABLED
+# Jack needs jacoco on the classpath but we do not want it to be in
+# the final apk. While it is a static library, we add it to the
+# LOCAL_JAVA_LIBRARIES which are only present on the classpath.
+# Note: we have nothing to do for proguard since jacoco will be
+# on the classpath only, thus not modified during the compilation.
+LOCAL_JAVA_LIBRARIES += jacocoagent
+else
+# We have to use prebuilt emma.jar to make Proguard happy;
+# Otherwise emma classes are included in core.jar.
+LOCAL_PROGUARD_FLAGS += -libraryjars $(EMMA_JAR)
+endif # LOCAL_JACK_ENABLED
+endif # full build
+endif # LOCAL_SDK_VERSION
+endif # EMMA_INSTRUMENT_STATIC
+endif # LOCAL_EMMA_INSTRUMENT
+
+rs_compatibility_jni_libs :=
+
+ifeq ($(LOCAL_DATA_BINDING),true)
+data_binding_intermediates := $(intermediates.COMMON)/data-binding
+
+LOCAL_JAVACFLAGS += -processorpath $(DATA_BINDING_COMPILER) -s $(data_binding_intermediates)/anno-src
+LOCAL_JACK_FLAGS += --processorpath $(DATA_BINDING_COMPILER)
+
+LOCAL_STATIC_JAVA_LIBRARIES += databinding-baselibrary
+LOCAL_STATIC_JAVA_AAR_LIBRARIES += databinding-library databinding-adapters
+
+data_binding_res_in := $(LOCAL_RESOURCE_DIR)
+data_binding_res_out := $(data_binding_intermediates)/res
+
+# Replace with the processed merged res dir.
+LOCAL_RESOURCE_DIR := $(data_binding_res_out)
+
+LOCAL_AAPT_FLAGS += --auto-add-overlay --extra-packages com.android.databinding.library
+endif # LOCAL_DATA_BINDING
+
+include $(BUILD_SYSTEM)/android_manifest.mk
+
+#################################
+include $(BUILD_SYSTEM)/java.mk
+#################################
+
+LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
+ifeq ($(LOCAL_SDK_RES_VERSION),)
+ LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
+endif
+
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
+ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
+endif
+
+ifeq ($(LOCAL_DATA_BINDING),true)
+data_binding_stamp := $(data_binding_intermediates)/data-binding.stamp
+$(data_binding_stamp): PRIVATE_INTERMEDIATES := $(data_binding_intermediates)
+$(data_binding_stamp): PRIVATE_MANIFEST := $(full_android_manifest)
+# Generate code into $(LOCAL_INTERMEDIATE_SOURCE_DIR) so that the generated .java files
+# will be automatically picked up by function compile-java.
+$(data_binding_stamp): PRIVATE_SRC_OUT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/data-binding
+$(data_binding_stamp): PRIVATE_XML_OUT := $(data_binding_intermediates)/xml
+$(data_binding_stamp): PRIVATE_RES_OUT := $(data_binding_res_out)
+$(data_binding_stamp): PRIVATE_RES_IN := $(data_binding_res_in)
+$(data_binding_stamp): PRIVATE_ANNO_SRC_DIR := $(data_binding_intermediates)/anno-src
+
+$(data_binding_stamp) : $(all_res_assets) $(full_android_manifest) \
+ $(DATA_BINDING_COMPILER)
+ @echo "Data-binding process: $@"
+ @rm -rf $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) && \
+ mkdir -p $(PRIVATE_INTERMEDIATES) $(PRIVATE_SRC_OUT) \
+ $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_ANNO_SRC_DIR)
+ $(hide) java -classpath $(DATA_BINDING_COMPILER) android.databinding.tool.MakeCopy \
+ $(PRIVATE_MANIFEST) $(PRIVATE_SRC_OUT) $(PRIVATE_XML_OUT) $(PRIVATE_RES_OUT) $(PRIVATE_RES_IN)
+ $(hide) touch $@
+
+# Make sure the data-binding process happens before javac and generation of R.java.
+$(R_file_stamp) $(full_classes_compiled_jar) : $(data_binding_stamp)
+# The dependency path when jack is enabled
+$(built_dex_intermediate) : $(data_binding_stamp)
+endif # LOCAL_DATA_BINDING
+
+ifeq ($(need_compile_res),true)
+ifdef LOCAL_USE_AAPT2
+my_compiled_res_base_dir := $(intermediates)/flat-res
+my_generated_res_dirs := $(rs_generated_res_dir)
+my_generated_res_dirs_deps := $(RenderScript_file_stamp)
+# Add AAPT2 link specific flags.
+$(my_res_package): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --no-static-lib-packages
+include $(BUILD_SYSTEM)/aapt2.mk
+else # LOCAL_USE_AAPT2
+
+# Since we don't know where the real R.java file is going to end up,
+# we need to use another file to stand in its place. We'll just
+# copy the generated file to src/R.stamp, which means it will
+# have the same contents and timestamp as the actual file.
+#
+# At the same time, this will copy the R.java file to a central
+# 'R' directory to make it easier to add the files to an IDE.
+#
+
+$(R_file_stamp): PRIVATE_RESOURCE_PUBLICS_OUTPUT := \
+ $(intermediates.COMMON)/public_resources.xml
+$(R_file_stamp): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
+$(R_file_stamp): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT) | $(ACP)
+ @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
+ @rm -rf $@ && mkdir -p $(dir $@)
+ $(create-resource-java-files)
+ $(call find-generated-R.java)
+
+$(proguard_options_file): $(R_file_stamp)
+
+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)
+
+# add-assets-to-package looks at PRODUCT_AAPT_CONFIG, but this target
+# can't know anything about PRODUCT. Clear it out just for this target.
+$(resource_export_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
+$(resource_export_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
+$(resource_export_package): $(all_res_assets) $(full_android_manifest) $(RenderScript_file_stamp) $(AAPT)
+ @echo "target Export Resources: $(PRIVATE_MODULE) ($@)"
+ $(create-empty-package)
+ $(add-assets-to-package)
+endif
+
+endif # LOCAL_USE_AAPT2
+
+# Other modules should depend on the BUILT module if
+# they want to use this module's R.java file.
+$(LOCAL_BUILT_MODULE): $(R_file_stamp)
+
+ifdef LOCAL_JACK_ENABLED
+ifneq ($(built_dex_intermediate),)
+$(built_dex_intermediate): $(R_file_stamp)
+endif
+ifneq ($(noshrob_classes_jack),)
+$(noshrob_classes_jack): $(R_file_stamp)
+endif
+ifneq ($(full_classes_jack),)
+$(full_classes_jack): $(R_file_stamp)
+$(jack_check_timestamp): $(R_file_stamp)
+endif
+endif # LOCAL_JACK_ENABLED
+
+ifneq ($(full_classes_jar),)
+# If full_classes_jar is non-empty, we're building sources.
+# If we're building sources, the initial javac step (which
+# produces full_classes_compiled_jar) needs to ensure the
+# R.java and Manifest.java files have been generated first.
+$(full_classes_compiled_jar): $(R_file_stamp)
+endif
+
+endif # need_compile_res
+
+ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+# We need to explicitly clear this var so that we don't
+# inherit the value from whomever caused us to be built.
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES :=
+else
+# Most packages should link against the resources defined by framework-res.
+# Even if they don't have their own resources, they may use framework
+# resources.
+ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current test_current,$(LOCAL_SDK_RES_VERSION))),)
+# for released sdk versions, the platform resources were built into android.jar.
+framework_res_package_export := \
+ $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar
+framework_res_package_export_deps := $(framework_res_package_export)
+else # LOCAL_SDK_RES_VERSION
+framework_res_package_export := \
+ $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
+# We can't depend directly on the export.apk file; it won't get its
+# PRIVATE_ vars set up correctly if we do. Instead, depend on the
+# corresponding R.stamp file, which lists the export.apk as a dependency.
+framework_res_package_export_deps := \
+ $(dir $(framework_res_package_export))src/R.stamp
+endif # LOCAL_SDK_RES_VERSION
+all_library_res_package_exports := \
+ $(framework_res_package_export) \
+ $(foreach lib,$(LOCAL_RES_LIBRARIES),\
+ $(call intermediates-dir-for,APPS,$(lib),,COMMON)/package-export.apk)
+
+all_library_res_package_export_deps := \
+ $(framework_res_package_export_deps) \
+ $(foreach lib,$(LOCAL_RES_LIBRARIES),\
+ $(call intermediates-dir-for,APPS,$(lib),,COMMON)/src/R.stamp)
+$(resource_export_package) $(R_file_stamp) $(LOCAL_BUILT_MODULE): $(all_library_res_package_export_deps)
+$(LOCAL_INTERMEDIATE_TARGETS): \
+ PRIVATE_AAPT_INCLUDES := $(all_library_res_package_exports)
+
+ifdef LOCAL_USE_AAPT2
+$(my_res_package) : $(all_library_res_package_export_deps)
+endif
+endif # LOCAL_NO_STANDARD_LIBRARIES
+
+ifneq ($(full_classes_jar),)
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE := $(built_dex)
+# Use the jarjar processed arhive as the initial package file.
+$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE := $(full_classes_jarjar_jar)
+$(LOCAL_BUILT_MODULE): $(built_dex)
+else
+$(LOCAL_BUILT_MODULE): PRIVATE_DEX_FILE :=
+$(LOCAL_BUILT_MODULE): PRIVATE_SOURCE_ARCHIVE :=
+endif # full_classes_jar
+
+include $(BUILD_SYSTEM)/install_jni_libs.mk
+
+# Pick a key to sign the package with. If this package hasn't specified
+# an explicit certificate, use the default.
+# Secure release builds will have their packages signed after the fact,
+# so it's ok for these private keys to be in the clear.
+ifeq ($(LOCAL_CERTIFICATE),)
+ LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
+endif
+
+ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
+ # The special value "EXTERNAL" means that we will sign it with the
+ # default devkey, apply predexopt, but then expect the final .apk
+ # (after dexopting) to be signed by an outside tool.
+ LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
+ PACKAGES.$(LOCAL_PACKAGE_NAME).EXTERNAL_KEY := 1
+endif
+
+# If this is not an absolute certificate, assign it to a generic one.
+ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
+ LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
+endif
+private_key := $(LOCAL_CERTIFICATE).pk8
+certificate := $(LOCAL_CERTIFICATE).x509.pem
+
+$(LOCAL_BUILT_MODULE): $(private_key) $(certificate) $(SIGNAPK_JAR)
+$(LOCAL_BUILT_MODULE): PRIVATE_PRIVATE_KEY := $(private_key)
+$(LOCAL_BUILT_MODULE): PRIVATE_CERTIFICATE := $(certificate)
+
+PACKAGES.$(LOCAL_PACKAGE_NAME).PRIVATE_KEY := $(private_key)
+PACKAGES.$(LOCAL_PACKAGE_NAME).CERTIFICATE := $(certificate)
+
+$(LOCAL_BUILT_MODULE): PRIVATE_ADDITIONAL_CERTIFICATES := $(foreach c,\
+ $(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
+
+# Define the rule to build the actual package.
+# PRIVATE_JNI_SHARED_LIBRARIES is a list of :.
+$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries_with_abis)
+# PRIVATE_JNI_SHARED_LIBRARIES_ABI is a list of ABI names.
+$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES_ABI := $(jni_shared_libraries_abis)
+ifneq ($(TARGET_BUILD_APPS),)
+ # Include all resources for unbundled apps.
+ LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
+endif
+ifeq ($(LOCAL_AAPT_INCLUDE_ALL_RESOURCES),true)
+ $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG :=
+ $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
+else
+ $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_CONFIG := $(PRODUCT_AAPT_CONFIG)
+ifdef LOCAL_PACKAGE_SPLITS
+ $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
+else
+ $(my_res_package) $(LOCAL_BUILT_MODULE): PRIVATE_PRODUCT_AAPT_PREF_CONFIG := $(PRODUCT_AAPT_PREF_CONFIG)
+endif
+endif
+$(LOCAL_BUILT_MODULE): PRIVATE_DONT_DELETE_JAR_DIRS := $(LOCAL_DONT_DELETE_JAR_DIRS)
+$(LOCAL_BUILT_MODULE) : $(jni_shared_libraries)
+ifdef LOCAL_USE_AAPT2
+$(LOCAL_BUILT_MODULE): PRIVATE_RES_PACKAGE := $(my_res_package)
+$(LOCAL_BUILT_MODULE) : $(my_res_package) $(AAPT2) | $(ACP)
+else
+$(LOCAL_BUILT_MODULE) : $(all_res_assets) $(full_android_manifest) $(AAPT)
+endif
+ @echo "target Package: $(PRIVATE_MODULE) ($@)"
+ifdef LOCAL_USE_AAPT2
+ifdef LOCAL_JACK_ENABLED
+ $(call copy-file-to-new-target)
+else
+ @# TODO: implement merge-two-packages.
+ $(if $(PRIVATE_SOURCE_ARCHIVE),\
+ $(call merge-two-packages,$(PRIVATE_RES_PACKAGE) $(PRIVATE_SOURCE_ARCHIVE),$@),
+ $(call copy-file-to-new-target))
+endif
+else # LOCAL_USE_AAPT2
+ifdef LOCAL_JACK_ENABLED
+ $(create-empty-package)
+else
+ $(if $(PRIVATE_SOURCE_ARCHIVE),\
+ $(call initialize-package-file,$(PRIVATE_SOURCE_ARCHIVE),$@),\
+ $(create-empty-package))
+endif
+ $(add-assets-to-package)
+endif # LOCAL_USE_AAPT2
+ifneq ($(jni_shared_libraries),)
+ $(add-jni-shared-libs-to-package)
+endif
+ifeq ($(full_classes_jar),)
+# We don't build jar, need to add the Java resources here.
+ $(if $(PRIVATE_EXTRA_JAR_ARGS),$(call add-java-resources-to,$@))
+else # full_classes_jar
+ $(add-dex-to-package)
+endif # full_classes_jar
+ifdef LOCAL_JACK_ENABLED
+ $(add-carried-jack-resources)
+endif
+ifdef LOCAL_DEX_PREOPT
+ifneq ($(BUILD_PLATFORM_ZIP),)
+ @# Keep a copy of apk with classes.dex unstripped
+ $(hide) cp -f $@ $(dir $@)package.dex.apk
+endif # BUILD_PLATFORM_ZIP
+ifneq (nostripping,$(LOCAL_DEX_PREOPT))
+ $(call dexpreopt-remove-classes.dex,$@)
+endif
+endif
+ $(sign-package)
+
+###############################
+## Build dpi-specific apks, if it's apps_only build.
+ifdef TARGET_BUILD_APPS
+ifdef LOCAL_DPI_VARIANTS
+$(foreach d, $(LOCAL_DPI_VARIANTS), \
+ $(eval my_dpi := $(d)) \
+ $(eval include $(BUILD_SYSTEM)/dpi_specific_apk.mk))
+endif
+endif
+
+###############################
+## Rule to build the odex file
+ifdef LOCAL_DEX_PREOPT
+$(built_odex): PRIVATE_DEX_FILE := $(built_dex)
+# Use pattern rule - we may have multiple built odex files.
+$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(built_dex)
+ $(hide) mkdir -p $(dir $@) && rm -f $@
+ $(add-dex-to-package)
+ $(hide) mv $@ $@.input
+ $(call dexpreopt-one-file,$@.input,$@)
+ $(hide) rm $@.input
+endif
+
+###############################
+## APK splits
+ifdef LOCAL_PACKAGE_SPLITS
+# LOCAL_PACKAGE_SPLITS is a list of resource labels.
+# aapt will convert comma inside resource lable to underscore in the file names.
+my_split_suffixes := $(subst $(comma),_,$(LOCAL_PACKAGE_SPLITS))
+built_apk_splits := $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk)
+installed_apk_splits := $(foreach s,$(my_split_suffixes),$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
+
+# The splits should have been built in the same command building the base apk.
+# This rule just runs signing.
+# Note that we explicily check the existence of the split apk and remove the
+# built base apk if the split apk isn't there.
+# That way the build system will rerun the aapt after the user changes the splitting parameters.
+$(built_apk_splits): PRIVATE_PRIVATE_KEY := $(private_key)
+$(built_apk_splits): PRIVATE_CERTIFICATE := $(certificate)
+$(built_apk_splits) : $(built_module_path)/%.apk : $(LOCAL_BUILT_MODULE)
+ $(hide) if [ ! -f $@ ]; then \
+ echo 'No $@ generated, check your apk splitting parameters.' 1>&2; \
+ rm $<; exit 1; \
+ fi
+ $(sign-package)
+
+# Rules to install the splits
+$(installed_apk_splits) : $(my_module_path)/$(LOCAL_MODULE)_%.apk : $(built_module_path)/package_%.apk | $(ACP)
+ @echo "Install: $@"
+ $(copy-file-to-new-target)
+
+# Register the additional built and installed files.
+ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
+ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
+ $(foreach s,$(my_split_suffixes),$(built_module_path)/package_$(s).apk:$(my_module_path)/$(LOCAL_MODULE)_$(s).apk)
+
+# Make sure to install the splits when you run "make ".
+$(my_register_name): $(installed_apk_splits)
+
+ifdef LOCAL_COMPATIBILITY_SUITE
+cts_testcase_file := $(foreach s,$(my_split_suffixes),$(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE)_$(s).apk)
+$(cts_testcase_file) : $(COMPATIBILITY_TESTCASES_OUT_$(LOCAL_COMPATIBILITY_SUITE))/$(LOCAL_MODULE)_%.apk : $(built_module_path)/package_%.apk | $(ACP)
+ $(copy-file-to-new-target)
+
+COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES := \
+ $(COMPATIBILITY.$(LOCAL_COMPATIBILITY_SUITE).FILES) \
+ $(cts_testcase_file)
+
+$(my_register_name) : $(cts_testcase_file)
+endif # LOCAL_COMPATIBILITY_SUITE
+endif # LOCAL_PACKAGE_SPLITS
+
+# Save information about this package
+PACKAGES.$(LOCAL_PACKAGE_NAME).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
+PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_FILES := $(all_resources)
+ifdef package_resource_overlays
+PACKAGES.$(LOCAL_PACKAGE_NAME).RESOURCE_OVERLAYS := $(package_resource_overlays)
+endif
+
+PACKAGES := $(PACKAGES) $(LOCAL_PACKAGE_NAME)
+
+endif # skip_definition
+
+# Reset internal variables.
+all_res_assets :=
diff --git a/core/pathmap.mk b/core/pathmap.mk
new file mode 100644
index 0000000000000000000000000000000000000000..effc8785685bf146a6bdef503b011e643a6b240e
--- /dev/null
+++ b/core/pathmap.mk
@@ -0,0 +1,177 @@
+#
+# 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.
+#
+
+#
+# A central place to define mappings to paths, to avoid hard-coding
+# them in Android.mk files. Not meant for header file include directories,
+# despite the fact that it was historically used for that!
+#
+# If you want this for a library's header files, use LOCAL_EXPORT_C_INCLUDES
+# instead. Then users of the library don't have to do anything --- they'll
+# have the correct header files added to their include path automatically.
+#
+
+#
+# TODO: Allow each project to define stuff like this before the per-module
+# Android.mk files are included, so we don't need to have a big central
+# list.
+#
+
+#
+# A mapping from shorthand names to include directories.
+#
+pathmap_INCL := \
+ camera:system/media/camera/include \
+ frameworks-base:frameworks/base/include \
+ frameworks-native:frameworks/native/include \
+ libhardware:hardware/libhardware/include \
+ libhardware_legacy:hardware/libhardware_legacy/include \
+ libril:hardware/ril/include \
+ opengl-tests-includes:frameworks/native/opengl/tests/include \
+ recovery:bootable/recovery \
+ system-core:system/core/include \
+ audio:system/media/audio/include \
+ audio-effects:system/media/audio_effects/include \
+ audio-utils:system/media/audio_utils/include \
+ audio-route:system/media/audio_route/include \
+ wilhelm:frameworks/wilhelm/include \
+ wilhelm-ut:frameworks/wilhelm/src/ut \
+ mediandk:frameworks/av/media/ndk/ \
+ speex:external/speex/include
+
+#
+# Returns the path to the requested module's include directory,
+# relative to the root of the source tree. Does not handle external
+# modules.
+#
+# $(1): a list of modules (or other named entities) to find the includes for
+#
+define include-path-for
+$(foreach n,$(1),$(patsubst $(n):%,%,$(filter $(n):%,$(pathmap_INCL))))
+endef
+
+#
+# Many modules expect to be able to say "#include ",
+# so make it easy for them to find the correct path.
+#
+JNI_H_INCLUDE := libnativehelper/include/nativehelper
+
+#
+# A list of all source roots under frameworks/base, which will be
+# built into the android.jar.
+#
+FRAMEWORKS_BASE_SUBDIRS := \
+ $(addsuffix /java, \
+ core \
+ graphics \
+ location \
+ media \
+ media/mca/effect \
+ media/mca/filterfw \
+ media/mca/filterpacks \
+ drm \
+ opengl \
+ sax \
+ telecomm \
+ telephony \
+ wifi \
+ keystore \
+ rs \
+ )
+
+#
+# A version of FRAMEWORKS_BASE_SUBDIRS that is expanded to full paths from
+# the root of the tree. This currently needs to be here so that other libraries
+# and apps can find the .aidl files in the framework, though we should really
+# figure out a better way to do this.
+#
+FRAMEWORKS_BASE_JAVA_SRC_DIRS := \
+ $(addprefix frameworks/base/,$(FRAMEWORKS_BASE_SUBDIRS))
+
+#
+# A list of all source roots under frameworks/support.
+#
+FRAMEWORKS_SUPPORT_SUBDIRS := \
+ annotations \
+ compat \
+ media-compat \
+ fragment \
+ core-ui \
+ core-utils \
+ v7/gridlayout \
+ v7/cardview \
+ v7/mediarouter \
+ v7/palette \
+ v8/renderscript \
+ v13 \
+ v17/leanback \
+ design \
+ percent \
+ recommendation \
+ transition \
+ v7/preference \
+ v14/preference \
+ v17/preference-leanback \
+ documents-archive \
+ customtabs
+
+#
+# A list of all source roots under frameworks/multidex.
+#
+FRAMEWORKS_MULTIDEX_SUBDIRS := \
+ multidex/library/src \
+ multidex/instrumentation/src
+
+#
+# A version of FRAMEWORKS_SUPPORT_SUBDIRS that is expanded to full paths from
+# the root of the tree.
+#
+FRAMEWORKS_SUPPORT_JAVA_SRC_DIRS := \
+ $(addprefix frameworks/support/,$(FRAMEWORKS_SUPPORT_SUBDIRS)) \
+ $(addprefix frameworks/,$(FRAMEWORKS_MULTIDEX_SUBDIRS)) \
+ frameworks/support/graphics/drawable/animated \
+ frameworks/support/graphics/drawable/static \
+ frameworks/support/v7/appcompat/src \
+ frameworks/support/v7/recyclerview/src
+
+#
+# A list of support library modules.
+#
+FRAMEWORKS_SUPPORT_JAVA_LIBRARIES := \
+ $(foreach dir,$(FRAMEWORKS_SUPPORT_SUBDIRS),android-support-$(subst /,-,$(dir))) \
+ android-support-v4 \
+ android-support-vectordrawable \
+ android-support-animatedvectordrawable \
+ android-support-v7-appcompat \
+ android-support-v7-recyclerview \
+ android-support-multidex \
+ android-support-multidex-instrumentation
+
+#
+# A list of all documented source roots under frameworks/data-binding.
+#
+FRAMEWORKS_DATA_BINDING_SUBDIRS := \
+ baseLibrary/src/main \
+ extensions/library/src/main \
+ extensions/library/src/doc
+
+#
+# A version of FRAMEWORKS_DATA_BINDING_SUBDIRS that is expanded to full paths from
+# the root of the tree.
+#
+FRAMEWORKS_DATA_BINDING_JAVA_SRC_DIRS := \
+ $(addprefix frameworks/data-binding/,$(FRAMEWORKS_DATA_BINDING_SUBDIRS))
+
diff --git a/core/pdk_config.mk b/core/pdk_config.mk
new file mode 100644
index 0000000000000000000000000000000000000000..c0aaacd9285872e9fcf40ac978deab18cad86010
--- /dev/null
+++ b/core/pdk_config.mk
@@ -0,0 +1,170 @@
+# This file defines the rule to fuse the platform.zip into the current PDK build.
+PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR :=
+PDK_PLATFORM_JAVA_ZIP_JAVA_HOST_LIB_DIR := \
+ host/common/obj/JAVA_LIBRARIES/bouncycastle-host_intermediates
+PDK_PLATFORM_JAVA_ZIP_CONTENTS :=
+
+ifneq (,$(filter platform-java, $(MAKECMDGOALS))$(PDK_FUSION_PLATFORM_ZIP))
+# additional items to add to platform.zip for platform-java build
+# For these dirs, add classes.jar and javalib.jar from the dir to platform.zip
+# all paths under out dir
+PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR += \
+ target/common/obj/JAVA_LIBRARIES/android.test.runner_intermediates \
+ target/common/obj/JAVA_LIBRARIES/android-common_intermediates \
+ target/common/obj/JAVA_LIBRARIES/android-ex-camera2_intermediates \
+ target/common/obj/JAVA_LIBRARIES/android_stubs_current_intermediates \
+ target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates \
+ target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates \
+ target/common/obj/JAVA_LIBRARIES/core-oj_intermediates \
+ target/common/obj/JAVA_LIBRARIES/core-libart_intermediates \
+ target/common/obj/JAVA_LIBRARIES/core-junit_intermediates \
+ target/common/obj/JAVA_LIBRARIES/ext_intermediates \
+ target/common/obj/JAVA_LIBRARIES/framework_intermediates \
+ target/common/obj/JAVA_LIBRARIES/ims-common_intermediates \
+ target/common/obj/JAVA_LIBRARIES/okhttp_intermediates \
+ target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates \
+ target/common/obj/JAVA_LIBRARIES/voip-common_intermediates \
+
+# not java libraries
+PDK_PLATFORM_JAVA_ZIP_CONTENTS += \
+ target/common/obj/APPS/framework-res_intermediates/package-export.apk \
+ target/common/obj/APPS/framework-res_intermediates/src/R.stamp
+endif # platform-java or FUSION build
+
+PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR := \
+ $(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR) \
+ $(PDK_PLATFORM_JAVA_ZIP_JAVA_HOST_LIB_DIR)
+
+PDK_PLATFORM_JAVA_ZIP_CONTENTS += $(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_LIB_DIR),\
+ $(lib_dir)/classes.jack $(lib_dir)/classes.jar $(lib_dir)/classes.jar.toc \
+ $(lib_dir)/javalib.jar $(lib_dir)/classes*.dex \
+ $(lib_dir)/classes.dex.toc )
+
+# check and override java support level
+ifneq ($(TARGET_BUILD_PDK)$(PDK_FUSION_PLATFORM_ZIP),)
+ifneq ($(wildcard external/proguard),)
+TARGET_BUILD_JAVA_SUPPORT_LEVEL := sdk
+else # no proguard
+TARGET_BUILD_JAVA_SUPPORT_LEVEL :=
+endif
+# platform supprot is set after checking platform.zip
+endif # PDK
+
+ifdef PDK_FUSION_PLATFORM_ZIP
+_pdk_fusion_intermediates := $(call intermediates-dir-for, PACKAGING, pdk_fusion)
+_pdk_fusion_stamp := $(_pdk_fusion_intermediates)/pdk_fusion.stamp
+
+_pdk_fusion_file_list := $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) \
+ '*[^/]' -x 'target/common/*' 2>/dev/null)
+_pdk_fusion_java_file_list := \
+ $(shell unzip -Z -1 $(PDK_FUSION_PLATFORM_ZIP) 'target/common/*' 2>/dev/null)
+_pdk_fusion_files := $(addprefix $(_pdk_fusion_intermediates)/,\
+ $(_pdk_fusion_file_list) $(_pdk_fusion_java_file_list))
+
+ifneq ($(_pdk_fusion_java_file_list),)
+# This represents whether java build can use platform API or not
+# This should not be used in Android.mk
+TARGET_BUILD_PDK_JAVA_PLATFORM := true
+ifneq ($(TARGET_BUILD_JAVA_SUPPORT_LEVEL),)
+TARGET_BUILD_JAVA_SUPPORT_LEVEL := platform
+endif
+endif
+
+$(_pdk_fusion_stamp) : $(PDK_FUSION_PLATFORM_ZIP)
+ @echo "Unzip $(dir $@) <- $<"
+ $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
+ $(hide) unzip -qo $< -d $(dir $@)
+ $(call split-long-arguments,-touch,$(_pdk_fusion_files))
+ $(hide) touch $@
+
+
+$(_pdk_fusion_files) : $(_pdk_fusion_stamp)
+
+
+# Implicit pattern rules to copy the fusion files to the system image directory.
+# Note that if there is already explicit rule in the build system to generate a file,
+# the pattern rule will be just ignored by make.
+# That's desired by us: we want only absent files from the platform zip package.
+# Copy with the last-modified time preserved, never follow symbolic links.
+$(PRODUCT_OUT)/% : $(_pdk_fusion_intermediates)/% $(_pdk_fusion_stamp)
+ @mkdir -p $(dir $@)
+ $(hide) rm -rf $@
+ $(hide) cp -fpPR $< $@
+
+# implicit rules for host java files
+$(HOST_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/host/common/% $(_pdk_fusion_stamp)
+ @mkdir -p $(dir $@)
+ $(hide) cp -fpPR $< $@
+
+ifeq (true,$(TARGET_BUILD_PDK_JAVA_PLATFORM))
+
+PDK_FUSION_OUT_DIR := $(OUT_DIR)
+ifeq (debug,$(TARGET_BUILD_TYPE))
+PDK_FUSION_OUT_DIR := $(DEBUG_OUT_DIR)
+endif
+
+define JAVA_dependency_template
+$(call add-dependency,$(PDK_FUSION_OUT_DIR)/$(strip $(1)),\
+ $(foreach d,$(filter $(2),$(_pdk_fusion_java_file_list)),$(PDK_FUSION_OUT_DIR)/$(d)))
+endef
+
+# needs explicit dependency as package-export.apk is not explicitly pulled
+$(eval $(call JAVA_dependency_template,\
+target/common/obj/APPS/framework-res_intermediates/src/R.stamp,\
+target/common/obj/APPS/framework-res_intermediates/package-export.apk))
+
+# javalib.jar should pull classes.jar as classes.jar is not explicitly pulled.
+$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
+$(eval $(call JAVA_dependency_template,$(lib_dir)/javalib.jar,\
+$(lib_dir)/classes.jar)))
+
+# pull .jack and .dex files
+$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
+ $(eval $(call JAVA_dependency_template,$(lib_dir)/classes.jar.toc,\
+ $(lib_dir)/classes.jar $(lib_dir)/classes.jack)))
+$(foreach lib_dir,$(PDK_PLATFORM_JAVA_ZIP_JAVA_TARGET_LIB_DIR),\
+ $(eval $(call JAVA_dependency_template,$(lib_dir)/classes.dex.toc,\
+ $(lib_dir)/classes.jar $(lib_dir)/classes.jack $(lib_dir)/classes%.dex)))
+
+# implicit rules for all other target files
+$(TARGET_COMMON_OUT_ROOT)/% : $(_pdk_fusion_intermediates)/target/common/% $(_pdk_fusion_stamp)
+ @mkdir -p $(dir $@)
+ $(hide) cp -fpPR $< $@
+endif
+
+ALL_PDK_FUSION_FILES := $(addprefix $(PRODUCT_OUT)/, $(_pdk_fusion_file_list))
+
+endif # PDK_FUSION_PLATFORM_ZIP
+
+ifeq ($(TARGET_BUILD_PDK),true)
+$(info PDK TARGET_BUILD_JAVA_SUPPORT_LEVEL $(TARGET_BUILD_JAVA_SUPPORT_LEVEL))
+ifeq ($(TARGET_BUILD_PDK_JAVA_PLATFORM),)
+
+# SDK used for Java build under PDK
+PDK_BUILD_SDK_VERSION := $(lastword $(TARGET_AVAILABLE_SDK_VERSIONS))
+$(info PDK Build uses SDK $(PDK_BUILD_SDK_VERSION))
+
+else # PDK_JAVA
+
+$(info PDK Build uses the current platform API)
+
+endif # PDK_JAVA
+
+endif # BUILD_PDK
+
+ifneq (,$(filter platform platform-java, $(MAKECMDGOALS))$(filter true,$(TARGET_BUILD_PDK)))
+# files under $(PRODUCT_OUT)/symbols to help debugging.
+# Source not included to PDK due to dependency issue, so provide symbols instead.
+
+# We may not be building all of them.
+# The platform.zip just silently ignores the nonexistent ones.
+PDK_SYMBOL_FILES_LIST := \
+ system/bin/app_process32 \
+ system/bin/app_process64
+
+ifdef PDK_FUSION_PLATFORM_ZIP
+# symbols should be explicitly pulled for fusion build
+$(foreach f,$(filter $(PDK_SYMBOL_FILES_LIST), $(_pdk_fusion_file_list)),\
+ $(eval $(call add-dependency,$(PRODUCT_OUT)/$(f),$(PRODUCT_OUT)/symbols/$(f))))
+endif # PLATFORM_ZIP
+endif # platform.zip build or PDK
diff --git a/core/pdk_fusion_modules.mk b/core/pdk_fusion_modules.mk
new file mode 100644
index 0000000000000000000000000000000000000000..49b30dc72ee1d4abb53e7b168522edb1473623ce
--- /dev/null
+++ b/core/pdk_fusion_modules.mk
@@ -0,0 +1,78 @@
+# Auto-generate module defitions from platform.zip.
+# We use these rules to rebuild .odex files of the .jar/.apk inside the platform.zip.
+#
+
+pdk_dexpreopt_config_mk := $(TARGET_OUT_INTERMEDIATES)/pdk_dexpreopt_config.mk
+
+$(shell rm -f $(pdk_dexpreopt_config_mk) && mkdir -p $(dir $(pdk_dexpreopt_config_mk)) && \
+ unzip -qo $(PDK_FUSION_PLATFORM_ZIP) -d $(dir $(pdk_dexpreopt_config_mk)) pdk_dexpreopt_config.mk 2>/dev/null)
+
+-include $(pdk_dexpreopt_config_mk)
+
+# Define a PDK prebuilt module that comes from platform.zip.
+# Must be called with $(eval)
+define prebuilt-pdk-java-module
+include $(CLEAR_VARS)
+LOCAL_MODULE:=$(1)
+LOCAL_MODULE_CLASS:=$(2)
+# Use LOCAL_PREBUILT_MODULE_FILE instead of LOCAL_SRC_FILES so we don't need to deal with LOCAL_PATH.
+LOCAL_PREBUILT_MODULE_FILE:=$(3)
+LOCAL_DEX_PREOPT:=$(4)
+LOCAL_MULTILIB:=$(5)
+LOCAL_DEX_PREOPT_FLAGS:=$(6)
+LOCAL_BUILT_MODULE_STEM:=$(7)
+LOCAL_MODULE_SUFFIX:=$(suffix $(7))
+LOCAL_PRIVILEGED_MODULE:=$(8)
+LOCAL_PROPRIETARY_MODULE:=$(9)
+LOCAL_MODULE_TARGET_ARCH:=$(10)
+LOCAL_REPLACE_PREBUILT_APK_INSTALLED:=$(11)
+LOCAL_CERTIFICATE:=PRESIGNED
+include $(BUILD_PREBUILT)
+
+# The source prebuilts are extracted in the rule of _pdk_fusion_stamp.
+# Use a touch rule to establish the dependency.
+$(3) $(11) : $(_pdk_fusion_stamp)
+ $(hide) if [ ! -f $$@ ]; then \
+ echo 'Error: $$@ does not exist. Check your platform.zip.' 1>&2; \
+ exit 1; \
+ fi
+ $(hide) touch $$@
+endef
+
+# We don't have a LOCAL_PATH for the auto-generated modules, so let it be the $(BUILD_SYSTEM).
+LOCAL_PATH := $(BUILD_SYSTEM)
+
+##### Java libraries.
+# Only set up rules for modules that aren't built from source.
+pdk_prebuilt_libraries := $(foreach l,$(PDK.DEXPREOPT.JAVA_LIBRARIES),\
+ $(if $(MODULE.TARGET.JAVA_LIBRARIES.$(l)),,$(l)))
+
+$(foreach l,$(pdk_prebuilt_libraries), $(eval \
+ $(call prebuilt-pdk-java-module,\
+ $(l),\
+ JAVA_LIBRARIES,\
+ $(_pdk_fusion_intermediates)/$(PDK.DEXPREOPT.$(l).SRC),\
+ $(PDK.DEXPREOPT.$(l).DEX_PREOPT),\
+ $(PDK.DEXPREOPT.$(l).MULTILIB),\
+ $(PDK.DEXPREOPT.$(l).DEX_PREOPT_FLAGS),\
+ javalib.jar,\
+ )))
+
+###### Apps.
+pdk_prebuilt_apps := $(foreach a,$(PDK.DEXPREOPT.APPS),\
+ $(if $(MODULE.TARGET.APPS.$(a)),,$(a)))
+
+$(foreach a,$(pdk_prebuilt_apps), $(eval \
+ $(call prebuilt-pdk-java-module,\
+ $(a),\
+ APPS,\
+ $(_pdk_fusion_intermediates)/$(PDK.DEXPREOPT.$(a).SRC),\
+ $(PDK.DEXPREOPT.$(a).DEX_PREOPT),\
+ $(PDK.DEXPREOPT.$(a).MULTILIB),\
+ $(PDK.DEXPREOPT.$(a).DEX_PREOPT_FLAGS),\
+ package.apk,\
+ $(PDK.DEXPREOPT.$(a).PRIVILEGED_MODULE),\
+ $(PDK.DEXPREOPT.$(a).PROPRIETARY_MODULE),\
+ $(PDK.DEXPREOPT.$(a).TARGET_ARCH),\
+ $(_pdk_fusion_intermediates)/$(PDK.DEXPREOPT.$(a).STRIPPED_SRC),\
+ )))
diff --git a/core/phony_package.mk b/core/phony_package.mk
new file mode 100644
index 0000000000000000000000000000000000000000..866b13c8e320c91412ec31bdccd13255142cc9fa
--- /dev/null
+++ b/core/phony_package.mk
@@ -0,0 +1,13 @@
+ifneq ($(strip $(LOCAL_SRC_FILES)),)
+$(error LOCAL_SRC_FILES are not allowed for phony packages)
+endif
+
+LOCAL_MODULE_CLASS := FAKE
+LOCAL_MODULE_SUFFIX := -timestamp
+
+include $(BUILD_SYSTEM)/base_rules.mk
+
+$(LOCAL_BUILT_MODULE): $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ $(hide) echo "Fake: $@"
+ $(hide) mkdir -p $(dir $@)
+ $(hide) touch $@
diff --git a/core/post_clean.mk b/core/post_clean.mk
new file mode 100644
index 0000000000000000000000000000000000000000..f08abff1d161b9fb6303d73f05b114a1e12de87d
--- /dev/null
+++ b/core/post_clean.mk
@@ -0,0 +1,99 @@
+# Copyright (C) 2012 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.
+
+# Clean steps that need global knowledge of individual modules.
+# This file must be included after all Android.mks have been loaded.
+
+#######################################################
+# Checks the current build configurations against the previous build,
+# clean artifacts in TARGET_COMMON_OUT_ROOT if necessary.
+# If a package's resource overlay has been changed, its R class needs to be
+# regenerated.
+previous_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/previous_overlays.txt
+current_package_overlay_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/current_overlays.txt
+current_all_packages_config := $(dir $(current_package_overlay_config))current_packages.txt
+
+$(shell rm -rf $(current_package_overlay_config) \
+ && mkdir -p $(dir $(current_package_overlay_config)) \
+ && touch $(current_package_overlay_config))
+$(shell echo '$(PACKAGES)' > $(current_all_packages_config))
+$(foreach p, $(PACKAGES), $(if $(PACKAGES.$(p).RESOURCE_OVERLAYS), \
+ $(shell echo '$(p)' '$(PACKAGES.$(p).RESOURCE_OVERLAYS)' >> $(current_package_overlay_config))))
+
+ifneq (,$(wildcard $(previous_package_overlay_config)))
+packages_overlay_changed := $(shell build/tools/diff_package_overlays.py \
+ $(current_all_packages_config) $(current_package_overlay_config) \
+ $(previous_package_overlay_config))
+ifneq (,$(packages_overlay_changed))
+overlay_cleanup_cmd := $(strip rm -rf $(foreach p, $(packages_overlay_changed),\
+ $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/$(p)_intermediates))
+$(info *** Overlay change detected, clean shared intermediate files...)
+$(info *** $(overlay_cleanup_cmd))
+$(shell $(overlay_cleanup_cmd))
+overlay_cleanup_cmd :=
+endif
+packages_overlay_changed :=
+endif
+
+# Now current becomes previous.
+$(shell mv -f $(current_package_overlay_config) $(previous_package_overlay_config))
+
+previous_package_overlay_config :=
+current_package_overlay_config :=
+current_all_packages_config :=
+
+#######################################################
+# Check if we need to delete obsolete generated java files.
+# When an aidl/proto/etc file gets deleted (or renamed), the generated java file is obsolete.
+previous_gen_java_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/previous_gen_java_config.mk
+current_gen_java_config := $(TARGET_OUT_COMMON_INTERMEDIATES)/current_gen_java_config.mk
+
+$(shell rm -rf $(current_gen_java_config) \
+ && mkdir -p $(dir $(current_gen_java_config))\
+ && touch $(current_gen_java_config))
+-include $(previous_gen_java_config)
+
+intermediates_to_clean :=
+modules_with_gen_java_files :=
+$(foreach p, $(ALL_MODULES), \
+ $(eval gs := $(strip $(ALL_MODULES.$(p).AIDL_FILES)\
+ $(ALL_MODULES.$(p).PROTO_FILES)\
+ $(ALL_MODULES.$(p).RS_FILES)))\
+ $(if $(gs),\
+ $(eval modules_with_gen_java_files += $(p))\
+ $(shell echo 'GEN_SRC_FILES.$(p) := $(gs)' >> $(current_gen_java_config)))\
+ $(if $(filter-out $(gs),$(GEN_SRC_FILES.$(p))),\
+ $(eval intermediates_to_clean += $(ALL_MODULES.$(p).INTERMEDIATE_SOURCE_DIR))))
+intermediates_to_clean := $(strip $(intermediates_to_clean))
+ifdef intermediates_to_clean
+$(info *** Obsolete generated java files detected, clean intermediate files...)
+$(info *** rm -rf $(intermediates_to_clean))
+$(shell rm -rf $(intermediates_to_clean))
+intermediates_to_clean :=
+endif
+
+# For modules not loaded by the current build (e.g. you are running mm/mmm),
+# we copy the info from the previous bulid.
+$(foreach p, $(filter-out $(ALL_MODULES),$(MODULES_WITH_GEN_JAVA_FILES)),\
+ $(shell echo 'GEN_SRC_FILES.$(p) := $(GEN_SRC_FILES.$(p))' >> $(current_gen_java_config)))
+MODULES_WITH_GEN_JAVA_FILES := $(sort $(MODULES_WITH_GEN_JAVA_FILES) $(modules_with_gen_java_files))
+$(shell echo 'MODULES_WITH_GEN_JAVA_FILES := $(MODULES_WITH_GEN_JAVA_FILES)' >> $(current_gen_java_config))
+
+# Now current becomes previous.
+$(shell cmp $(current_gen_java_config) $(previous_gen_java_config) > /dev/null 2>&1 || mv -f $(current_gen_java_config) $(previous_gen_java_config))
+
+MODULES_WITH_GEN_JAVA_FILES :=
+modules_with_gen_java_files :=
+previous_gen_java_config :=
+current_gen_java_config :=
diff --git a/core/prebuilt.mk b/core/prebuilt.mk
new file mode 100644
index 0000000000000000000000000000000000000000..428922b08c13a9425b578c8896076fa5b8e5d67a
--- /dev/null
+++ b/core/prebuilt.mk
@@ -0,0 +1,88 @@
+###########################################################
+## Standard rules for copying files that are prebuilt
+##
+## Additional inputs from base_rules.make:
+## None.
+##
+###########################################################
+
+ifdef LOCAL_IS_HOST_MODULE
+ my_prefix := HOST_
+ LOCAL_HOST_PREFIX :=
+else
+ my_prefix := TARGET_
+endif
+
+include $(BUILD_SYSTEM)/multilib.mk
+
+my_skip_non_preferred_arch :=
+
+# check if first arch is supported
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# first arch is supported
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+ifneq ($(my_module_multilib),both)
+my_skip_non_preferred_arch := true
+endif # $(my_module_multilib)
+# For apps, we don't want to set up the prebuilt apk rule twice even if "LOCAL_MULTILIB := both".
+ifeq (APPS,$(LOCAL_MODULE_CLASS))
+my_skip_non_preferred_arch := true
+endif
+endif # $(my_module_arch_supported)
+
+ifndef my_skip_non_preferred_arch
+ifneq (,$($(my_prefix)2ND_ARCH))
+# check if secondary arch is supported
+LOCAL_2ND_ARCH_VAR_PREFIX := $($(my_prefix)2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# secondary arch is supported
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+endif # $(my_module_arch_supported)
+endif # $($(my_prefix)2ND_ARCH)
+endif # $(my_skip_non_preferred_arch) not true
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+
+ifdef LOCAL_IS_HOST_MODULE
+ifdef HOST_CROSS_OS
+ifneq (,$(filter EXECUTABLES STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)))
+my_prefix := HOST_CROSS_
+LOCAL_HOST_PREFIX := $(my_prefix)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+# host cross compilation is supported
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+endif
+LOCAL_HOST_PREFIX :=
+endif
+
+ifdef HOST_CROSS_2ND_ARCH
+my_prefix := HOST_CROSS_
+LOCAL_2ND_ARCH_VAR_PREFIX := $($(my_prefix)2ND_ARCH_VAR_PREFIX)
+LOCAL_HOST_PREFIX := $(my_prefix)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+ifeq ($(my_module_arch_supported),true)
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+endif
+LOCAL_HOST_PREFIX :=
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+endif
+endif
+endif
+
+my_module_arch_supported :=
diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b6727fa6337c641060e000ded90212fcb32b7f02
--- /dev/null
+++ b/core/prebuilt_internal.mk
@@ -0,0 +1,481 @@
+###########################################################
+## Standard rules for copying files that are prebuilt
+##
+## Additional inputs from base_rules.make:
+## None.
+##
+###########################################################
+
+ifneq ($(LOCAL_PREBUILT_LIBS),)
+$(error dont use LOCAL_PREBUILT_LIBS anymore LOCAL_PATH=$(LOCAL_PATH))
+endif
+ifneq ($(LOCAL_PREBUILT_EXECUTABLES),)
+$(error dont use LOCAL_PREBUILT_EXECUTABLES anymore LOCAL_PATH=$(LOCAL_PATH))
+endif
+ifneq ($(LOCAL_PREBUILT_JAVA_LIBRARIES),)
+$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
+endif
+
+# Not much sense to check build prebuilts
+LOCAL_DONT_CHECK_MODULE := true
+
+my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
+
+ifdef LOCAL_PREBUILT_MODULE_FILE
+ my_prebuilt_src_file := $(LOCAL_PREBUILT_MODULE_FILE)
+else
+ ifdef LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
+ my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+ LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) :=
+ else
+ ifdef LOCAL_SRC_FILES_$(my_32_64_bit_suffix)
+ my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
+ LOCAL_SRC_FILES_$(my_32_64_bit_suffix) :=
+ else
+ my_prebuilt_src_file := $(LOCAL_PATH)/$(LOCAL_SRC_FILES)
+ LOCAL_SRC_FILES :=
+ endif
+ endif
+endif
+
+my_strip_module := $(firstword \
+ $(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
+ $(LOCAL_STRIP_MODULE))
+my_pack_module_relocations := $(firstword \
+ $(LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
+ $(LOCAL_PACK_MODULE_RELOCATIONS))
+
+ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
+ # Put the built targets of all shared libraries in a common directory
+ # to simplify the link line.
+ OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)
+ ifeq ($(LOCAL_IS_HOST_MODULE)$(my_strip_module),)
+ # Strip but not try to add debuglink
+ my_strip_module := no_debuglink
+ endif
+
+ ifeq ($(LOCAL_IS_HOST_MODULE)$(my_pack_module_relocations),)
+ # Do not pack relocations by default
+ my_pack_module_relocations := false
+ endif
+
+ ifeq ($(DISABLE_RELOCATION_PACKER),true)
+ my_pack_module_relocations := false
+ endif
+endif
+
+ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
+ prebuilt_module_is_a_library := true
+else
+ prebuilt_module_is_a_library :=
+endif
+
+# Don't install static libraries by default.
+ifndef LOCAL_UNINSTALLABLE_MODULE
+ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
+ LOCAL_UNINSTALLABLE_MODULE := true
+endif
+endif
+
+ifeq (JAVA_LIBRARIES,$(LOCAL_IS_HOST_MODULE)$(LOCAL_MODULE_CLASS)$(filter true,$(LOCAL_UNINSTALLABLE_MODULE)))
+ prebuilt_module_is_dex_javalib := true
+else
+ prebuilt_module_is_dex_javalib :=
+endif
+
+ifeq ($(LOCAL_MODULE_CLASS),APPS)
+LOCAL_BUILT_MODULE_STEM := package.apk
+ifndef LOCAL_INSTALLED_MODULE_STEM
+LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
+endif
+endif
+
+ifneq ($(filter true no_debuglink,$(my_strip_module) $(my_pack_module_relocations)),)
+ ifdef LOCAL_IS_HOST_MODULE
+ $(error Cannot strip/pack host module LOCAL_PATH=$(LOCAL_PATH))
+ endif
+ ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
+ $(error Can strip/pack only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH))
+ endif
+ ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
+ $(error Cannot strip/pack scripts LOCAL_PATH=$(LOCAL_PATH))
+ endif
+ # Set the arch-specific variables to set up the strip/pack rules.
+ LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_strip_module)
+ LOCAL_PACK_MODULE_RELOCATIONS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_pack_module_relocations)
+ include $(BUILD_SYSTEM)/dynamic_binary.mk
+ built_module := $(linked_module)
+
+else # my_strip_module and my_pack_module_relocations not true
+ include $(BUILD_SYSTEM)/base_rules.mk
+ built_module := $(LOCAL_BUILT_MODULE)
+
+ifdef prebuilt_module_is_a_library
+export_includes := $(intermediates)/export_includes
+$(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
+$(export_includes) : $(LOCAL_MODULE_MAKEFILE_DEP)
+ @echo Export includes file: $< -- $@
+ $(hide) mkdir -p $(dir $@) && rm -f $@
+ifdef LOCAL_EXPORT_C_INCLUDE_DIRS
+ $(hide) for d in $(PRIVATE_EXPORT_C_INCLUDE_DIRS); do \
+ echo "-I $$d" >> $@; \
+ done
+else
+ $(hide) touch $@
+endif
+
+$(LOCAL_BUILT_MODULE) : | $(intermediates)/export_includes
+endif # prebuilt_module_is_a_library
+
+# 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 LOCAL_SHARED_LIBRARIES
+my_shared_libraries := $(LOCAL_SHARED_LIBRARIES)
+# Extra shared libraries introduced by LOCAL_CXX_STL.
+include $(BUILD_SYSTEM)/cxx_stl_setup.mk
+$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
+ $(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
+
+# We also need the LOCAL_BUILT_MODULE dependency,
+# since we use -rpath-link which points to the built module's path.
+my_built_shared_libraries := \
+ $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \
+ $(addsuffix $($(my_prefix)SHLIB_SUFFIX), \
+ $(my_shared_libraries)))
+$(LOCAL_BUILT_MODULE) : $(my_built_shared_libraries)
+endif
+endif
+
+# We need to enclose the above export_includes and my_built_shared_libraries in
+# "my_strip_module not true" because otherwise the rules are defined in dynamic_binary.mk.
+endif # my_strip_module not true
+
+ifeq ($(LOCAL_MODULE_CLASS),APPS)
+PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
+
+my_extract_apk := $(strip $(LOCAL_EXTRACT_APK))
+
+# Select dpi-specific source
+ifdef LOCAL_DPI_VARIANTS
+my_dpi := $(firstword $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG) $(PRODUCT_AAPT_PREBUILT_DPI)))
+ifdef my_dpi
+ifdef LOCAL_DPI_FILE_STEM
+my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM)
+else
+my_prebuilt_dpi_file_stem := $(LOCAL_MODULE)_%.apk
+endif
+my_prebuilt_src_file := $(dir $(my_prebuilt_src_file))$(subst %,$(my_dpi),$(my_prebuilt_dpi_file_stem))
+
+ifneq ($(strip $(LOCAL_EXTRACT_DPI_APK)),)
+my_extract_apk := $(subst %,$(my_dpi),$(LOCAL_EXTRACT_DPI_APK))
+endif # LOCAL_EXTRACT_DPI_APK
+endif # my_dpi
+endif # LOCAL_DPI_VARIANTS
+
+ifdef my_extract_apk
+my_extracted_apk := $(intermediates)/extracted.apk
+
+$(my_extracted_apk): PRIVATE_EXTRACT := $(my_extract_apk)
+$(my_extracted_apk): $(my_prebuilt_src_file)
+ @echo Extract APK: $@
+ $(hide) mkdir -p $(dir $@) && rm -f $@
+ $(hide) unzip -p $< $(PRIVATE_EXTRACT) >$@
+
+my_prebuilt_src_file := $(my_extracted_apk)
+my_extracted_apk :=
+my_extract_apk :=
+endif
+
+rs_compatibility_jni_libs :=
+include $(BUILD_SYSTEM)/install_jni_libs.mk
+
+ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
+ # The magic string "EXTERNAL" means this package will be signed with
+ # the default dev key throughout the build process, but we expect
+ # the final package to be signed with a different key.
+ #
+ # This can be used for packages where we don't have access to the
+ # keys, but want the package to be predexopt'ed.
+ LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
+ PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
+
+ $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
+ $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
+endif
+ifeq ($(LOCAL_CERTIFICATE),)
+ # It is now a build error to add a prebuilt .apk without
+ # specifying a key for it.
+ $(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
+else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
+ # The magic string "PRESIGNED" means this package is already checked
+ # signed with its release key.
+ #
+ # By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
+ # mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
+ # but the dexpreopt process will not try to re-sign the app.
+ PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
+ PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
+else
+ # If this is not an absolute certificate, assign it to a generic one.
+ ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
+ LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
+ endif
+
+ PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
+ PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
+ PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
+
+ $(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
+ $(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
+endif
+
+# Disable dex-preopt of prebuilts to save space, if requested.
+ifndef LOCAL_DEX_PREOPT
+ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
+LOCAL_DEX_PREOPT := false
+endif
+endif
+
+#######################################
+# defines built_odex along with rule to install odex
+include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
+#######################################
+ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),)
+# There is a replacement for the prebuilt .apk we can install without any processing.
+$(built_module) : $(LOCAL_REPLACE_PREBUILT_APK_INSTALLED) | $(ACP)
+ $(transform-prebuilt-to-target)
+
+else # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
+# Sign and align non-presigned .apks.
+# The embedded prebuilt jni to uncompress.
+ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
+# For PRESIGNED apks we must uncompress every .so file:
+# even if the .so file isn't for the current TARGET_ARCH,
+# we can't strip the file.
+embedded_prebuilt_jni_libs := 'lib/*.so'
+endif
+ifndef embedded_prebuilt_jni_libs
+# No LOCAL_PREBUILT_JNI_LIBS, uncompress all.
+embedded_prebuilt_jni_libs := 'lib/*.so'
+endif
+$(built_module): PRIVATE_EMBEDDED_JNI_LIBS := $(embedded_prebuilt_jni_libs)
+
+$(built_module) : $(my_prebuilt_src_file) | $(ACP) $(ZIPALIGN) $(SIGNAPK_JAR) $(AAPT)
+ $(transform-prebuilt-to-target)
+ $(uncompress-shared-libs)
+ifdef LOCAL_DEX_PREOPT
+ifneq ($(BUILD_PLATFORM_ZIP),)
+ @# Keep a copy of apk with classes.dex unstripped
+ $(hide) cp -f $@ $(dir $@)package.dex.apk
+endif # BUILD_PLATFORM_ZIP
+endif # LOCAL_DEX_PREOPT
+ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
+ @# Only strip out files if we can re-sign the package.
+ifdef LOCAL_DEX_PREOPT
+ifneq (nostripping,$(LOCAL_DEX_PREOPT))
+ $(call dexpreopt-remove-classes.dex,$@)
+endif # LOCAL_DEX_PREOPT != nostripping
+endif # LOCAL_DEX_PREOPT
+ $(sign-package)
+ # No need for align-package because sign-package takes care of alignment
+else # LOCAL_CERTIFICATE == PRESIGNED
+ $(align-package)
+endif # LOCAL_CERTIFICATE
+endif # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
+
+###############################
+## Rule to build the odex file
+ifdef LOCAL_DEX_PREOPT
+$(built_odex) : $(my_prebuilt_src_file)
+ $(call dexpreopt-one-file,$<,$@)
+endif
+
+###############################
+## Install split apks.
+ifdef LOCAL_PACKAGE_SPLITS
+# LOCAL_PACKAGE_SPLITS is a list of apks to be installed.
+built_apk_splits := $(addprefix $(built_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
+installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
+
+# Rules to sign the split apks.
+my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS)))
+ifneq (1,$(words $(my_src_dir)))
+$(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS))
+endif
+my_src_dir := $(LOCAL_PATH)/$(my_src_dir)
+
+$(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
+$(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
+$(built_apk_splits) : $(built_module_path)/%.apk : $(my_src_dir)/%.apk | $(ACP) $(AAPT)
+ $(copy-file-to-new-target)
+ $(sign-package)
+
+# Rules to install the split apks.
+$(installed_apk_splits) : $(my_module_path)/%.apk : $(built_module_path)/%.apk | $(ACP)
+ @echo "Install: $@"
+ $(copy-file-to-new-target)
+
+# Register the additional built and installed files.
+ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
+ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
+ $(foreach s,$(LOCAL_PACKAGE_SPLITS),$(built_module_path)/$(notdir $(s)):$(my_module_path)/$(notdir $(s)))
+
+# Make sure to install the splits when you run "make ".
+$(my_register_name): $(installed_apk_splits)
+
+endif # LOCAL_PACKAGE_SPLITS
+
+else # LOCAL_MODULE_CLASS != APPS
+ifeq ($(prebuilt_module_is_dex_javalib),true)
+# This is a target shared library, i.e. a jar with classes.dex.
+#######################################
+# defines built_odex along with rule to install odex
+include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
+#######################################
+ifdef LOCAL_DEX_PREOPT
+ifneq ($(dexpreopt_boot_jar_module),) # boot jar
+# boot jar's rules are defined in dex_preopt.mk
+dexpreopted_boot_jar := $(DEXPREOPT_BOOT_JAR_DIR_FULL_PATH)/$(dexpreopt_boot_jar_module)_nodex.jar
+$(built_module) : $(dexpreopted_boot_jar) | $(ACP)
+ $(call copy-file-to-target)
+
+# For libart boot jars, we don't have .odex files.
+else # ! boot jar
+$(built_odex): PRIVATE_MODULE := $(LOCAL_MODULE)
+# Use pattern rule - we may have multiple built odex files.
+$(built_odex) : $(dir $(LOCAL_BUILT_MODULE))% : $(my_prebuilt_src_file)
+ @echo "Dexpreopt Jar: $(PRIVATE_MODULE) ($@)"
+ $(call dexpreopt-one-file,$<,$@)
+
+$(built_module) : $(my_prebuilt_src_file) | $(ACP)
+ $(call copy-file-to-target)
+ifneq (nostripping,$(LOCAL_DEX_PREOPT))
+ $(call dexpreopt-remove-classes.dex,$@)
+endif
+endif # boot jar
+else # ! LOCAL_DEX_PREOPT
+$(built_module) : $(my_prebuilt_src_file) | $(ACP)
+ $(call copy-file-to-target)
+endif # LOCAL_DEX_PREOPT
+
+else # ! prebuilt_module_is_dex_javalib
+ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),)
+$(built_module) : $(my_prebuilt_src_file)
+ $(transform-prebuilt-to-target-strip-comments)
+ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+ $(hide) chmod +x $@
+endif
+else ifneq ($(LOCAL_ACP_UNAVAILABLE),true)
+$(built_module) : $(my_prebuilt_src_file) | $(ACP)
+ $(transform-prebuilt-to-target)
+ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+ $(hide) chmod +x $@
+endif
+else
+$(built_module) : $(my_prebuilt_src_file)
+ $(copy-file-to-target-with-cp)
+ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
+ $(hide) chmod +x $@
+endif
+endif
+endif # ! prebuilt_module_is_dex_javalib
+endif # LOCAL_MODULE_CLASS != APPS
+
+ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
+my_src_jar := $(my_prebuilt_src_file)
+ifeq ($(LOCAL_IS_HOST_MODULE),)
+# for target java libraries, the LOCAL_BUILT_MODULE is in a product-specific dir,
+# while the deps should be in the common dir, so we make a copy in the common dir.
+common_classes_jar := $(intermediates.COMMON)/classes.jar
+common_javalib_jar := $(intermediates.COMMON)/javalib.jar
+
+$(common_classes_jar) $(common_javalib_jar): PRIVATE_MODULE := $(LOCAL_MODULE)
+
+ifeq ($(prebuilt_module_is_dex_javalib),true)
+# For prebuilt shared Java library we don't have classes.jar.
+$(common_javalib_jar) : $(my_src_jar) | $(ACP)
+ $(transform-prebuilt-to-target)
+
+else # ! prebuilt_module_is_dex_javalib
+
+my_src_aar := $(filter %.aar, $(my_prebuilt_src_file))
+ifneq ($(my_src_aar),)
+# This is .aar file, archive of classes.jar and Android resources.
+my_src_jar := $(intermediates.COMMON)/aar/classes.jar
+
+$(my_src_jar) : $(my_src_aar)
+ $(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)
+ $(hide) unzip -qo -d $(dir $@) $<
+ # Make sure the extracted classes.jar has a new timestamp.
+ $(hide) touch $@
+
+endif
+
+$(common_classes_jar) : $(my_src_jar) | $(ACP)
+ $(transform-prebuilt-to-target)
+
+$(common_javalib_jar) : $(common_classes_jar) | $(ACP)
+ $(transform-prebuilt-to-target)
+
+$(call define-jar-to-toc-rule, $(common_classes_jar))
+
+ifdef LOCAL_USE_AAPT2
+ifneq ($(my_src_aar),)
+my_res_package := $(intermediates.COMMON)/package-res.apk
+
+# We needed only very few PRIVATE variables and aapt2.mk input variables. Reset the unnecessary ones.
+$(my_res_package): PRIVATE_AAPT2_CFLAGS :=
+$(my_res_package): PRIVATE_ANDROID_MANIFEST := $(intermediates.COMMON)/aar/AndroidManifest.xml
+$(my_res_package): PRIVATE_AAPT_INCLUDES :=
+$(my_res_package): PRIVATE_SOURCE_INTERMEDIATES_DIR :=
+$(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE :=
+$(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
+$(my_res_package): PRIVATE_DEFAULT_APP_TARGET_SDK :=
+$(my_res_package): PRIVATE_PRODUCT_AAPT_CONFIG :=
+$(my_res_package): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
+$(my_res_package): PRIVATE_TARGET_AAPT_CHARACTERISTICS :=
+
+full_android_manifest :=
+my_res_resources :=
+my_overlay_resources :=
+my_compiled_res_base_dir :=
+R_file_stamp :=
+proguard_options_file :=
+my_generated_res_dirs := $(intermediates.COMMON)/aar/res
+my_generated_res_dirs_deps := $(my_src_jar)
+include $(BUILD_SYSTEM)/aapt2.mk
+
+# Make sure my_res_package is created when you run mm/mmm.
+$(built_module) : $(my_res_package)
+endif # $(my_src_aar)
+endif # LOCAL_USE_AAPT2
+# make sure the classes.jar and javalib.jar are built before $(LOCAL_BUILT_MODULE)
+$(built_module) : $(common_javalib_jar)
+
+endif # ! prebuilt_module_is_dex_javalib
+endif # LOCAL_IS_HOST_MODULE is not set
+
+ifneq ($(prebuilt_module_is_dex_javalib),true)
+ifneq ($(LOCAL_JILL_FLAGS),)
+$(error LOCAL_JILL_FLAGS is not supported any more, please use jack options in LOCAL_JACK_FLAGS instead)
+endif
+
+# We may be building classes.jack from a host jar for host dalvik Java library.
+$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_FLAGS:=$(LOCAL_JACK_FLAGS)
+$(intermediates.COMMON)/classes.jack : PRIVATE_JACK_MIN_SDK_VERSION := 1
+$(intermediates.COMMON)/classes.jack : $(my_src_jar) $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES) $(JACK) | setup-jack-server
+ $(transform-jar-to-jack)
+
+# Update timestamps of .toc files for prebuilts so dependents will be
+# always rebuilt.
+$(intermediates.COMMON)/classes.dex.toc: $(intermediates.COMMON)/classes.jack
+ touch $@
+
+endif # ! prebuilt_module_is_dex_javalib
+endif # JAVA_LIBRARIES
+
+$(built_module) : $(LOCAL_MODULE_MAKEFILE_DEP) $(LOCAL_ADDITIONAL_DEPENDENCIES)
+
+my_prebuilt_src_file :=
diff --git a/core/process_wrapper.sh b/core/process_wrapper.sh
new file mode 100755
index 0000000000000000000000000000000000000000..9c3104ef83e4db4c55132f3a1e220d39aa10502e
--- /dev/null
+++ b/core/process_wrapper.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# When using a process wrapper, this is the top-level
+# command that is executed instead of the server
+# command. It starts a new xterm in which the user can
+# interact with the new process.
+#
+# Inside of the xterm is a gdb session, through which
+# the user can debug the new process.
+
+# Save away these variables, since we may loose them
+# when starting in the xterm.
+export PREV_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
+export PREV_PATH=$PATH
+
+gnome-terminal -t "Wrapper: $1" --disable-factory -x $2/process_wrapper_gdb.sh "$@"
+
diff --git a/core/process_wrapper_gdb.cmds b/core/process_wrapper_gdb.cmds
new file mode 100644
index 0000000000000000000000000000000000000000..f5bdd214e01603ecd6c83be9f66d88579c588ec6
--- /dev/null
+++ b/core/process_wrapper_gdb.cmds
@@ -0,0 +1 @@
+run
diff --git a/core/process_wrapper_gdb.sh b/core/process_wrapper_gdb.sh
new file mode 100755
index 0000000000000000000000000000000000000000..38b948ad2635f34d2c11c9f4b58f4c11efee1fa2
--- /dev/null
+++ b/core/process_wrapper_gdb.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+# This is the command running inside the xterm of our
+# debug wrapper. It needs to take care of starting
+# the server command, so it can attach to the parent
+# process. In addition, here we run the command inside
+# of a gdb session to allow for debugging.
+
+# On some systems, running xterm will cause LD_LIBRARY_PATH
+# to be cleared, so restore it and PATH to be safe.
+export PATH=$PREV_PATH
+export LD_LIBRARY_PATH=$PREV_LD_LIBRARY_PATH
+
+# Start binderproc (or whatever sub-command is being run)
+# inside of gdb, giving gdb an initial command script to
+# automatically run the process without user intervention.
+gdb -q -x $2/process_wrapper_gdb.cmds --args "$@"
diff --git a/core/product-graph.mk b/core/product-graph.mk
new file mode 100644
index 0000000000000000000000000000000000000000..36e903723aa53411199658d9cb02c92c46a46840
--- /dev/null
+++ b/core/product-graph.mk
@@ -0,0 +1,144 @@
+#
+# Copyright (C) 2009 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.
+#
+
+# the foreach and the if remove the single space entries that creep in because of the evals
+define gather-all-products
+$(sort $(foreach p, \
+ $(eval _all_products_visited := )
+ $(call all-products-inner, $(ALL_PRODUCTS)) \
+ , $(if $(strip $(p)),$(strip $(p)),)) \
+)
+endef
+
+define all-products-inner
+ $(foreach p,$(1),\
+ $(if $(filter $(p),$(_all_products_visited)),, \
+ $(p) \
+ $(eval _all_products_visited += $(p)) \
+ $(call all-products-inner, $(PRODUCTS.$(strip $(p)).INHERITS_FROM))
+ ) \
+ )
+endef
+
+
+this_makefile := build/core/product-graph.mk
+
+products_svg := $(OUT_DIR)/products.svg
+products_pdf := $(OUT_DIR)/products.pdf
+products_graph := $(OUT_DIR)/products.dot
+ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),)
+products_list := $(INTERNAL_PRODUCT)
+else
+ifeq ($(strip $(ANDROID_PRODUCT_GRAPH)),--all)
+products_list := --all
+else
+products_list := $(foreach prod,$(ANDROID_PRODUCT_GRAPH),$(call resolve-short-product-name,$(prod)))
+endif
+endif
+
+really_all_products := $(call gather-all-products)
+
+open_parethesis := (
+close_parenthesis := )
+
+# Emit properties of a product node to a file.
+# $(1) the product
+# $(2) the output file
+define emit-product-node-props
+$(hide) echo \"$(1)\" [ \
+label=\"$(dir $(1))\\n$(notdir $(1))\\n\\n$(subst $(close_parenthesis),,$(subst $(open_parethesis),,$(PRODUCTS.$(strip $(1)).PRODUCT_MODEL)))\\n$(PRODUCTS.$(strip $(1)).PRODUCT_DEVICE)\" \
+$(if $(filter $(1),$(PRIVATE_PRODUCTS_FILTER)), style=\"filled\" fillcolor=\"#FFFDB0\",) \
+colorscheme=\"svg\" fontcolor=\"darkblue\" href=\"products/$(1).html\" \
+] >> $(2)
+
+endef
+
+$(products_graph): PRIVATE_PRODUCTS := $(really_all_products)
+$(products_graph): PRIVATE_PRODUCTS_FILTER := $(products_list)
+
+$(products_graph): $(this_makefile)
+ @echo Product graph DOT: $@ for $(PRIVATE_PRODUCTS_FILTER)
+ $(hide) echo 'digraph {' > $@.in
+ $(hide) echo 'graph [ ratio=.5 ];' >> $@.in
+ $(hide) $(foreach p,$(PRIVATE_PRODUCTS), \
+ $(foreach d,$(PRODUCTS.$(strip $(p)).INHERITS_FROM), echo \"$(d)\" -\> \"$(p)\" >> $@.in;))
+ $(foreach p,$(PRIVATE_PRODUCTS),$(call emit-product-node-props,$(p),$@.in))
+ $(hide) echo '}' >> $@.in
+ $(hide) ./build/tools/filter-product-graph.py $(PRIVATE_PRODUCTS_FILTER) < $@.in > $@
+
+# Evaluates to the name of the product file
+# $(1) product file
+define product-debug-filename
+$(OUT_DIR)/products/$(strip $(1)).html
+endef
+
+# Makes a rule for the product debug info
+# $(1) product file
+define transform-product-debug
+$(OUT_DIR)/products/$(strip $(1)).txt: $(this_makefile)
+ @echo Product debug info file: $$@
+ $(hide) rm -f $$@
+ $(hide) mkdir -p $$(dir $$@)
+ $(hide) echo 'FILE=$(strip $(1))' >> $$@
+ $(hide) echo 'PRODUCT_NAME=$$(PRODUCTS.$(strip $(1)).PRODUCT_NAME)' >> $$@
+ $(hide) echo 'PRODUCT_MODEL=$$(PRODUCTS.$(strip $(1)).PRODUCT_MODEL)' >> $$@
+ $(hide) echo 'PRODUCT_LOCALES=$$(PRODUCTS.$(strip $(1)).PRODUCT_LOCALES)' >> $$@
+ $(hide) echo 'PRODUCT_AAPT_CONFIG=$$(PRODUCTS.$(strip $(1)).PRODUCT_AAPT_CONFIG)' >> $$@
+ $(hide) echo 'PRODUCT_AAPT_PREF_CONFIG=$$(PRODUCTS.$(strip $(1)).PRODUCT_AAPT_PREF_CONFIG)' >> $$@
+ $(hide) echo 'PRODUCT_PACKAGES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PACKAGES)' >> $$@
+ $(hide) echo 'PRODUCT_DEVICE=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEVICE)' >> $$@
+ $(hide) echo 'PRODUCT_MANUFACTURER=$$(PRODUCTS.$(strip $(1)).PRODUCT_MANUFACTURER)' >> $$@
+ $(hide) echo 'PRODUCT_PROPERTY_OVERRIDES=$$(PRODUCTS.$(strip $(1)).PRODUCT_PROPERTY_OVERRIDES)' >> $$@
+ $(hide) echo 'PRODUCT_DEFAULT_PROPERTY_OVERRIDES=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_PROPERTY_OVERRIDES)' >> $$@
+ $(hide) echo 'PRODUCT_CHARACTERISTICS=$$(PRODUCTS.$(strip $(1)).PRODUCT_CHARACTERISTICS)' >> $$@
+ $(hide) echo 'PRODUCT_COPY_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_COPY_FILES)' >> $$@
+ $(hide) echo 'PRODUCT_OTA_PUBLIC_KEYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_OTA_PUBLIC_KEYS)' >> $$@
+ $(hide) echo 'PRODUCT_EXTRA_RECOVERY_KEYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_EXTRA_RECOVERY_KEYS)' >> $$@
+ $(hide) echo 'PRODUCT_PACKAGE_OVERLAYS=$$(PRODUCTS.$(strip $(1)).PRODUCT_PACKAGE_OVERLAYS)' >> $$@
+ $(hide) echo 'DEVICE_PACKAGE_OVERLAYS=$$(PRODUCTS.$(strip $(1)).DEVICE_PACKAGE_OVERLAYS)' >> $$@
+ $(hide) echo 'PRODUCT_SDK_ADDON_NAME=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_NAME)' >> $$@
+ $(hide) echo 'PRODUCT_SDK_ADDON_COPY_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_COPY_FILES)' >> $$@
+ $(hide) echo 'PRODUCT_SDK_ADDON_COPY_MODULES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_COPY_MODULES)' >> $$@
+ $(hide) echo 'PRODUCT_SDK_ADDON_DOC_MODULES=$$(PRODUCTS.$(strip $(1)).PRODUCT_SDK_ADDON_DOC_MODULES)' >> $$@
+ $(hide) echo 'PRODUCT_DEFAULT_WIFI_CHANNELS=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_WIFI_CHANNELS)' >> $$@
+ $(hide) echo 'PRODUCT_DEFAULT_DEV_CERTIFICATE=$$(PRODUCTS.$(strip $(1)).PRODUCT_DEFAULT_DEV_CERTIFICATE)' >> $$@
+ $(hide) echo 'PRODUCT_RESTRICT_VENDOR_FILES=$$(PRODUCTS.$(strip $(1)).PRODUCT_RESTRICT_VENDOR_FILES)' >> $$@
+ $(hide) echo 'PRODUCT_VENDOR_KERNEL_HEADERS=$$(PRODUCTS.$(strip $(1)).PRODUCT_VENDOR_KERNEL_HEADERS)' >> $$@
+
+$(call product-debug-filename, $(p)): \
+ $(OUT_DIR)/products/$(strip $(1)).txt \
+ build/tools/product_debug.py \
+ $(this_makefile)
+ @echo Product debug html file: $$@
+ $(hide) mkdir -p $$(dir $$@)
+ $(hide) cat $$< | build/tools/product_debug.py > $$@
+endef
+
+product_debug_files:=
+$(foreach p,$(really_all_products), \
+ $(eval $(call transform-product-debug, $(p))) \
+ $(eval product_debug_files += $(call product-debug-filename, $(p))) \
+ )
+
+$(products_pdf): $(products_graph)
+ @echo Product graph PDF: $@
+ dot -Tpdf -Nshape=box -o $@ $<
+
+$(products_svg): $(products_graph) $(product_debug_files)
+ @echo Product graph SVG: $@
+ dot -Tsvg -Nshape=box -o $@ $<
+
+product-graph: $(products_pdf) $(products_svg)
diff --git a/core/product.mk b/core/product.mk
new file mode 100644
index 0000000000000000000000000000000000000000..332b015fd8f8c52b86fdab58201c571837a5bfbc
--- /dev/null
+++ b/core/product.mk
@@ -0,0 +1,347 @@
+#
+# 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.
+#
+
+#
+# Functions for including AndroidProducts.mk files
+# PRODUCT_MAKEFILES is set up in AndroidProducts.mks.
+# Format of PRODUCT_MAKEFILES:
+# :
+# If the is the same as the base file name (without dir
+# and the .mk suffix) of the product makefile, ":" can be
+# omitted.
+
+# Search for AndroidProducts.mks in the given dir.
+# $(1): the path to the dir
+define _search-android-products-files-in-dir
+$(sort $(shell test -d $(1) && find -L $(1) \
+ -maxdepth 6 \
+ -name .git -prune \
+ -o -name AndroidProducts.mk -print))
+endef
+
+#
+# Returns the list of all AndroidProducts.mk files.
+# $(call ) isn't necessary.
+#
+define _find-android-products-files
+$(foreach d, device vendor product,$(call _search-android-products-files-in-dir,$(d))) \
+ $(SRC_TARGET_DIR)/product/AndroidProducts.mk
+endef
+
+#
+# Returns the sorted concatenation of PRODUCT_MAKEFILES
+# variables set in the given AndroidProducts.mk files.
+# $(1): the list of AndroidProducts.mk files.
+#
+define get-product-makefiles
+$(sort \
+ $(foreach f,$(1), \
+ $(eval PRODUCT_MAKEFILES :=) \
+ $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
+ $(eval include $(f)) \
+ $(PRODUCT_MAKEFILES) \
+ ) \
+ $(eval PRODUCT_MAKEFILES :=) \
+ $(eval LOCAL_DIR :=) \
+ )
+endef
+
+#
+# Returns the sorted concatenation of all PRODUCT_MAKEFILES
+# variables set in all AndroidProducts.mk files.
+# $(call ) isn't necessary.
+#
+define get-all-product-makefiles
+$(call get-product-makefiles,$(_find-android-products-files))
+endef
+
+#
+# Functions for including product makefiles
+#
+
+_product_var_list := \
+ PRODUCT_NAME \
+ PRODUCT_MODEL \
+ PRODUCT_LOCALES \
+ PRODUCT_AAPT_CONFIG \
+ PRODUCT_AAPT_PREF_CONFIG \
+ PRODUCT_AAPT_PREBUILT_DPI \
+ PRODUCT_PACKAGES \
+ PRODUCT_PACKAGES_DEBUG \
+ PRODUCT_PACKAGES_ENG \
+ PRODUCT_PACKAGES_TESTS \
+ PRODUCT_DEVICE \
+ PRODUCT_MANUFACTURER \
+ PRODUCT_BRAND \
+ PRODUCT_PROPERTY_OVERRIDES \
+ PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
+ PRODUCT_CHARACTERISTICS \
+ PRODUCT_COPY_FILES \
+ PRODUCT_OTA_PUBLIC_KEYS \
+ PRODUCT_EXTRA_RECOVERY_KEYS \
+ PRODUCT_PACKAGE_OVERLAYS \
+ DEVICE_PACKAGE_OVERLAYS \
+ PRODUCT_SDK_ATREE_FILES \
+ PRODUCT_SDK_ADDON_NAME \
+ PRODUCT_SDK_ADDON_COPY_FILES \
+ PRODUCT_SDK_ADDON_COPY_MODULES \
+ PRODUCT_SDK_ADDON_DOC_MODULES \
+ PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP \
+ PRODUCT_DEFAULT_WIFI_CHANNELS \
+ PRODUCT_DEFAULT_DEV_CERTIFICATE \
+ PRODUCT_RESTRICT_VENDOR_FILES \
+ PRODUCT_VENDOR_KERNEL_HEADERS \
+ PRODUCT_BOOT_JARS \
+ PRODUCT_SUPPORTS_BOOT_SIGNER \
+ PRODUCT_SUPPORTS_VBOOT \
+ PRODUCT_SUPPORTS_VERITY \
+ PRODUCT_SUPPORTS_VERITY_FEC \
+ PRODUCT_OEM_PROPERTIES \
+ PRODUCT_SYSTEM_PROPERTY_BLACKLIST \
+ PRODUCT_SYSTEM_SERVER_JARS \
+ PRODUCT_VBOOT_SIGNING_KEY \
+ PRODUCT_VBOOT_SIGNING_SUBKEY \
+ PRODUCT_VERITY_SIGNING_KEY \
+ PRODUCT_SYSTEM_VERITY_PARTITION \
+ PRODUCT_VENDOR_VERITY_PARTITION \
+ PRODUCT_DEX_PREOPT_MODULE_CONFIGS \
+ PRODUCT_DEX_PREOPT_DEFAULT_FLAGS \
+ PRODUCT_DEX_PREOPT_BOOT_FLAGS \
+ PRODUCT_SANITIZER_MODULE_CONFIGS \
+ PRODUCT_SYSTEM_BASE_FS_PATH \
+ PRODUCT_VENDOR_BASE_FS_PATH \
+ PRODUCT_SHIPPING_API_LEVEL \
+
+
+
+define dump-product
+$(info ==== $(1) ====)\
+$(foreach v,$(_product_var_list),\
+$(info PRODUCTS.$(1).$(v) := $(PRODUCTS.$(1).$(v))))\
+$(info --------)
+endef
+
+define dump-products
+$(foreach p,$(PRODUCTS),$(call dump-product,$(p)))
+endef
+
+#
+# $(1): product to inherit
+#
+# Does three things:
+# 1. Inherits all of the variables from $1.
+# 2. Records the inheritance in the .INHERITS_FROM variable
+# 3. Records that we've visited this node, in ALL_PRODUCTS
+#
+define inherit-product
+ $(if $(findstring ../,$(1)),\
+ $(eval np := $(call normalize-paths,$(1))),\
+ $(eval np := $(strip $(1))))\
+ $(foreach v,$(_product_var_list), \
+ $(eval $(v) := $($(v)) $(INHERIT_TAG)$(np))) \
+ $(eval inherit_var := \
+ PRODUCTS.$(strip $(word 1,$(_include_stack))).INHERITS_FROM) \
+ $(eval $(inherit_var) := $(sort $($(inherit_var)) $(np))) \
+ $(eval inherit_var:=) \
+ $(eval ALL_PRODUCTS := $(sort $(ALL_PRODUCTS) $(word 1,$(_include_stack))))
+endef
+
+
+#
+# Do inherit-product only if $(1) exists
+#
+define inherit-product-if-exists
+ $(if $(wildcard $(1)),$(call inherit-product,$(1)),)
+endef
+
+#
+# $(1): product makefile list
+#
+#TODO: check to make sure that products have all the necessary vars defined
+define import-products
+$(call import-nodes,PRODUCTS,$(1),$(_product_var_list))
+endef
+
+
+#
+# Does various consistency checks on all of the known products.
+# Takes no parameters, so $(call ) is not necessary.
+#
+define check-all-products
+$(if ,, \
+ $(eval _cap_names :=) \
+ $(foreach p,$(PRODUCTS), \
+ $(eval pn := $(strip $(PRODUCTS.$(p).PRODUCT_NAME))) \
+ $(if $(pn),,$(error $(p): PRODUCT_NAME must be defined.)) \
+ $(if $(filter $(pn),$(_cap_names)), \
+ $(error $(p): PRODUCT_NAME must be unique; "$(pn)" already used by $(strip \
+ $(foreach \
+ pp,$(PRODUCTS),
+ $(if $(filter $(pn),$(PRODUCTS.$(pp).PRODUCT_NAME)), \
+ $(pp) \
+ ))) \
+ ) \
+ ) \
+ $(eval _cap_names += $(pn)) \
+ $(if $(call is-c-identifier,$(pn)),, \
+ $(error $(p): PRODUCT_NAME must be a valid C identifier, not "$(pn)") \
+ ) \
+ $(eval pb := $(strip $(PRODUCTS.$(p).PRODUCT_BRAND))) \
+ $(if $(pb),,$(error $(p): PRODUCT_BRAND must be defined.)) \
+ $(foreach cf,$(strip $(PRODUCTS.$(p).PRODUCT_COPY_FILES)), \
+ $(if $(filter 2 3,$(words $(subst :,$(space),$(cf)))),, \
+ $(error $(p): malformed COPY_FILE "$(cf)") \
+ ) \
+ ) \
+ ) \
+)
+endef
+
+
+#
+# Returns the product makefile path for the product with the provided name
+#
+# $(1): short product name like "generic"
+#
+define _resolve-short-product-name
+ $(eval pn := $(strip $(1)))
+ $(eval p := \
+ $(foreach p,$(PRODUCTS), \
+ $(if $(filter $(pn),$(PRODUCTS.$(p).PRODUCT_NAME)), \
+ $(p) \
+ )) \
+ )
+ $(eval p := $(sort $(p)))
+ $(if $(filter 1,$(words $(p))), \
+ $(p), \
+ $(if $(filter 0,$(words $(p))), \
+ $(error No matches for product "$(pn)"), \
+ $(error Product "$(pn)" ambiguous: matches $(p)) \
+ ) \
+ )
+endef
+define resolve-short-product-name
+$(strip $(call _resolve-short-product-name,$(1)))
+endef
+
+
+_product_stash_var_list := $(_product_var_list) \
+ PRODUCT_BOOTCLASSPATH \
+ PRODUCT_SYSTEM_SERVER_CLASSPATH \
+ TARGET_ARCH \
+ TARGET_ARCH_VARIANT \
+ TARGET_CPU_VARIANT \
+ TARGET_BOARD_PLATFORM \
+ TARGET_BOARD_PLATFORM_GPU \
+ TARGET_BOARD_KERNEL_HEADERS \
+ TARGET_DEVICE_KERNEL_HEADERS \
+ TARGET_PRODUCT_KERNEL_HEADERS \
+ TARGET_BOOTLOADER_BOARD_NAME \
+ TARGET_NO_BOOTLOADER \
+ TARGET_NO_KERNEL \
+ TARGET_NO_RECOVERY \
+ TARGET_NO_RADIOIMAGE \
+ TARGET_HARDWARE_3D \
+ TARGET_CPU_ABI \
+ TARGET_CPU_ABI2 \
+
+
+_product_stash_var_list += \
+ BOARD_WPA_SUPPLICANT_DRIVER \
+ BOARD_WLAN_DEVICE \
+ BOARD_USES_GENERIC_AUDIO \
+ BOARD_KERNEL_CMDLINE \
+ BOARD_KERNEL_BASE \
+ BOARD_HAVE_BLUETOOTH \
+ BOARD_VENDOR_USE_AKMD \
+ BOARD_EGL_CFG \
+ BOARD_BOOTIMAGE_PARTITION_SIZE \
+ BOARD_RECOVERYIMAGE_PARTITION_SIZE \
+ BOARD_SYSTEMIMAGE_PARTITION_SIZE \
+ BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE \
+ BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE \
+ BOARD_USERDATAIMAGE_PARTITION_SIZE \
+ BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE \
+ BOARD_CACHEIMAGE_PARTITION_SIZE \
+ BOARD_FLASH_BLOCK_SIZE \
+ BOARD_VENDORIMAGE_PARTITION_SIZE \
+ BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE \
+ BOARD_INSTALLER_CMDLINE \
+
+
+_product_stash_var_list += \
+ DEFAULT_SYSTEM_DEV_CERTIFICATE \
+ WITH_DEXPREOPT \
+ WITH_DEXPREOPT_BOOT_IMG_ONLY
+
+_product_stash_var_list += \
+ GLOBAL_CFLAGS_NO_OVERRIDE \
+ GLOBAL_CPPFLAGS_NO_OVERRIDE \
+ GLOBAL_CLANG_CFLAGS_NO_OVERRIDE \
+
+#
+# Stash values of the variables in _product_stash_var_list.
+# $(1): Renamed prefix
+#
+define stash-product-vars
+$(foreach v,$(_product_stash_var_list), \
+ $(eval $(strip $(1))_$(call rot13,$(v)):=$$($$(v))) \
+ )
+endef
+
+#
+# Assert that the the variable stashed by stash-product-vars remains untouched.
+# $(1): The prefix as supplied to stash-product-vars
+#
+define assert-product-vars
+$(strip \
+ $(eval changed_variables:=)
+ $(foreach v,$(_product_stash_var_list), \
+ $(if $(call streq,$($(v)),$($(strip $(1))_$(call rot13,$(v)))),, \
+ $(eval $(warning $(v) has been modified: $($(v)))) \
+ $(eval $(warning previous value: $($(strip $(1))_$(call rot13,$(v))))) \
+ $(eval changed_variables := $(changed_variables) $(v))) \
+ ) \
+ $(if $(changed_variables),\
+ $(eval $(error The following variables have been changed: $(changed_variables))),)
+)
+endef
+
+define add-to-product-copy-files-if-exists
+$(if $(wildcard $(word 1,$(subst :, ,$(1)))),$(1))
+endef
+
+# whitespace placeholder when we record module's dex-preopt config.
+_PDPMC_SP_PLACE_HOLDER := |@SP@|
+# Set up dex-preopt config for a module.
+# $(1) list of module names
+# $(2) the modules' dex-preopt config
+define add-product-dex-preopt-module-config
+$(eval _c := $(subst $(space),$(_PDPMC_SP_PLACE_HOLDER),$(strip $(2))))\
+$(eval PRODUCT_DEX_PREOPT_MODULE_CONFIGS += \
+ $(foreach m,$(1),$(m)=$(_c)))
+endef
+
+# whitespace placeholder when we record module's sanitizer config.
+_PSMC_SP_PLACE_HOLDER := |@SP@|
+# Set up sanitizer config for a module.
+# $(1) list of module names
+# $(2) the modules' sanitizer config
+define add-product-sanitizer-module-config
+$(eval _c := $(subst $(space),$(_PSMC_SP_PLACE_HOLDER),$(strip $(2))))\
+$(eval PRODUCT_SANITIZER_MODULE_CONFIGS += \
+ $(foreach m,$(1),$(m)=$(_c)))
+endef
diff --git a/core/product_config.mk b/core/product_config.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6438d51bee97d05ca21624b2668fe4d79c0c258d
--- /dev/null
+++ b/core/product_config.mk
@@ -0,0 +1,421 @@
+#
+# 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.
+#
+
+# ---------------------------------------------------------------
+# Generic functions
+# TODO: Move these to definitions.make once we're able to include
+# definitions.make before config.make.
+
+###########################################################
+## Return non-empty if $(1) is a C identifier; i.e., if it
+## matches /^[a-zA-Z_][a-zA-Z0-9_]*$/. We do this by first
+## making sure that it isn't empty and doesn't start with
+## a digit, then by removing each valid character. If the
+## final result is empty, then it was a valid C identifier.
+##
+## $(1): word to check
+###########################################################
+
+_ici_digits := 0 1 2 3 4 5 6 7 8 9
+_ici_alphaunderscore := \
+ a b c d e f g h i j k l m n o p q r s t u v w x y z \
+ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z _
+define is-c-identifier
+$(strip \
+ $(if $(1), \
+ $(if $(filter $(addsuffix %,$(_ici_digits)),$(1)), \
+ , \
+ $(eval w := $(1)) \
+ $(foreach c,$(_ici_digits) $(_ici_alphaunderscore), \
+ $(eval w := $(subst $(c),,$(w))) \
+ ) \
+ $(if $(w),,TRUE) \
+ $(eval w :=) \
+ ) \
+ ) \
+ )
+endef
+
+# TODO: push this into the combo files; unfortunately, we don't even
+# know HOST_OS at this point.
+trysed := $(shell echo a | sed -E -e 's/a/b/' 2>/dev/null)
+ifeq ($(trysed),b)
+ SED_EXTENDED := sed -E
+else
+ trysed := $(shell echo c | sed -r -e 's/c/d/' 2>/dev/null)
+ ifeq ($(trysed),d)
+ SED_EXTENDED := sed -r
+ else
+ $(error Unknown sed version)
+ endif
+endif
+
+###########################################################
+## List all of the files in a subdirectory in a format
+## suitable for PRODUCT_COPY_FILES and
+## PRODUCT_SDK_ADDON_COPY_FILES
+##
+## $(1): Glob to match file name
+## $(2): Source directory
+## $(3): Target base directory
+###########################################################
+
+define find-copy-subdir-files
+$(sort $(shell find $(2) -name "$(1)" -type f | $(SED_EXTENDED) "s:($(2)/?(.*)):\\1\\:$(3)/\\2:" | sed "s://:/:g"))
+endef
+
+# ---------------------------------------------------------------
+
+# These are the valid values of TARGET_BUILD_VARIANT. Also, if anything else is passed
+# as the variant in the PRODUCT-$TARGET_BUILD_PRODUCT-$TARGET_BUILD_VARIANT form,
+# it will be treated as a goal, and the eng variant will be used.
+INTERNAL_VALID_VARIANTS := user userdebug eng
+
+# ---------------------------------------------------------------
+# Provide "PRODUCT--" targets, which lets you build
+# a particular configuration without needing to set up the environment.
+#
+product_goals := $(strip $(filter PRODUCT-%,$(MAKECMDGOALS)))
+ifdef product_goals
+ # Scrape the product and build names out of the goal,
+ # which should be of the form PRODUCT--.
+ #
+ ifneq ($(words $(product_goals)),1)
+ $(error Only one PRODUCT-* goal may be specified; saw "$(product_goals)")
+ endif
+ goal_name := $(product_goals)
+ product_goals := $(patsubst PRODUCT-%,%,$(product_goals))
+ product_goals := $(subst -, ,$(product_goals))
+ ifneq ($(words $(product_goals)),2)
+ $(error Bad PRODUCT-* goal "$(goal_name)")
+ endif
+
+ # The product they want
+ TARGET_PRODUCT := $(word 1,$(product_goals))
+
+ # The variant they want
+ TARGET_BUILD_VARIANT := $(word 2,$(product_goals))
+
+ ifeq ($(TARGET_BUILD_VARIANT),tests)
+ $(error "tests" has been deprecated as a build variant. Use it as a build goal instead.)
+ endif
+
+ # The build server wants to do make PRODUCT-dream-installclean
+ # which really means TARGET_PRODUCT=dream make installclean.
+ ifneq ($(filter-out $(INTERNAL_VALID_VARIANTS),$(TARGET_BUILD_VARIANT)),)
+ MAKECMDGOALS := $(MAKECMDGOALS) $(TARGET_BUILD_VARIANT)
+ TARGET_BUILD_VARIANT := userdebug
+ default_goal_substitution :=
+ else
+ default_goal_substitution := $(DEFAULT_GOAL)
+ endif
+
+ # Replace the PRODUCT-* goal with the build goal that it refers to.
+ # Note that this will ensure that it appears in the same relative
+ # position, in case it matters.
+ #
+ # Note that modifying this will not affect the goals that make will
+ # attempt to build, but it's important because we inspect this value
+ # in certain situations (like for "make sdk").
+ #
+ MAKECMDGOALS := $(patsubst $(goal_name),$(default_goal_substitution),$(MAKECMDGOALS))
+
+ # Define a rule for the PRODUCT-* goal, and make it depend on the
+ # patched-up command-line goals as well as any other goals that we
+ # want to force.
+ #
+.PHONY: $(goal_name)
+$(goal_name): $(MAKECMDGOALS)
+endif
+# else: Use the value set in the environment or buildspec.mk.
+
+# ---------------------------------------------------------------
+# Provide "APP-" targets, which lets you build
+# an unbundled app.
+#
+unbundled_goals := $(strip $(filter APP-%,$(MAKECMDGOALS)))
+ifdef unbundled_goals
+ ifneq ($(words $(unbundled_goals)),1)
+ $(error Only one APP-* goal may be specified; saw "$(unbundled_goals)")
+ endif
+ TARGET_BUILD_APPS := $(strip $(subst -, ,$(patsubst APP-%,%,$(unbundled_goals))))
+ ifneq ($(filter $(DEFAULT_GOAL),$(MAKECMDGOALS)),)
+ MAKECMDGOALS := $(patsubst $(unbundled_goals),,$(MAKECMDGOALS))
+ else
+ MAKECMDGOALS := $(patsubst $(unbundled_goals),$(DEFAULT_GOAL),$(MAKECMDGOALS))
+ endif
+
+.PHONY: $(unbundled_goals)
+$(unbundled_goals): $(MAKECMDGOALS)
+endif # unbundled_goals
+
+# Default to building dalvikvm on hosts that support it...
+ifeq ($(HOST_OS),linux)
+# ... or if the if the option is already set
+ifeq ($(WITH_HOST_DALVIK),)
+ WITH_HOST_DALVIK := true
+endif
+endif
+
+# ---------------------------------------------------------------
+# Include the product definitions.
+# We need to do this to translate TARGET_PRODUCT into its
+# underlying TARGET_DEVICE before we start defining any rules.
+#
+include $(BUILD_SYSTEM)/node_fns.mk
+include $(BUILD_SYSTEM)/product.mk
+include $(BUILD_SYSTEM)/device.mk
+
+ifneq ($(strip $(TARGET_BUILD_APPS)),)
+# An unbundled app build needs only the core product makefiles.
+all_product_configs := $(call get-product-makefiles,\
+ $(SRC_TARGET_DIR)/product/AndroidProducts.mk)
+else
+# Read in all of the product definitions specified by the AndroidProducts.mk
+# files in the tree.
+all_product_configs := $(get-all-product-makefiles)
+endif
+
+# Find the product config makefile for the current product.
+# all_product_configs consists items like:
+# :
+# or just in case the product name is the
+# same as the base filename of the product config makefile.
+current_product_makefile :=
+all_product_makefiles :=
+$(foreach f, $(all_product_configs),\
+ $(eval _cpm_words := $(subst :,$(space),$(f)))\
+ $(eval _cpm_word1 := $(word 1,$(_cpm_words)))\
+ $(eval _cpm_word2 := $(word 2,$(_cpm_words)))\
+ $(if $(_cpm_word2),\
+ $(eval all_product_makefiles += $(_cpm_word2))\
+ $(if $(filter $(TARGET_PRODUCT),$(_cpm_word1)),\
+ $(eval current_product_makefile += $(_cpm_word2)),),\
+ $(eval all_product_makefiles += $(f))\
+ $(if $(filter $(TARGET_PRODUCT),$(basename $(notdir $(f)))),\
+ $(eval current_product_makefile += $(f)),)))
+_cpm_words :=
+_cpm_word1 :=
+_cpm_word2 :=
+current_product_makefile := $(strip $(current_product_makefile))
+all_product_makefiles := $(strip $(all_product_makefiles))
+
+load_all_product_makefiles :=
+ifneq (,$(filter product-graph, $(MAKECMDGOALS)))
+ifeq ($(ANDROID_PRODUCT_GRAPH),--all)
+load_all_product_makefiles := true
+endif
+endif
+ifneq (,$(filter dump-products,$(MAKECMDGOALS)))
+ifeq ($(ANDROID_DUMP_PRODUCTS),all)
+load_all_product_makefiles := true
+endif
+endif
+
+ifeq ($(load_all_product_makefiles),true)
+# Import all product makefiles.
+$(call import-products, $(all_product_makefiles))
+else
+# Import just the current product.
+ifndef current_product_makefile
+$(error Can not locate config makefile for product "$(TARGET_PRODUCT)")
+endif
+ifneq (1,$(words $(current_product_makefile)))
+$(error Product "$(TARGET_PRODUCT)" ambiguous: matches $(current_product_makefile))
+endif
+$(call import-products, $(current_product_makefile))
+endif # Import all or just the current product makefile
+
+# Sanity check
+$(check-all-products)
+
+ifneq ($(filter dump-products, $(MAKECMDGOALS)),)
+$(dump-products)
+$(error done)
+endif
+
+# Convert a short name like "sooner" into the path to the product
+# file defining that product.
+#
+INTERNAL_PRODUCT := $(call resolve-short-product-name, $(TARGET_PRODUCT))
+ifneq ($(current_product_makefile),$(INTERNAL_PRODUCT))
+$(error PRODUCT_NAME inconsistent in $(current_product_makefile) and $(INTERNAL_PRODUCT))
+endif
+current_product_makefile :=
+all_product_makefiles :=
+all_product_configs :=
+
+
+#############################################################################
+
+# A list of module names of BOOTCLASSPATH (jar files)
+PRODUCT_BOOT_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BOOT_JARS))
+PRODUCT_SYSTEM_SERVER_JARS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SYSTEM_SERVER_JARS))
+
+# Find the device that this product maps to.
+TARGET_DEVICE := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEVICE)
+
+# Figure out which resoure configuration options to use for this
+# product.
+PRODUCT_LOCALES := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_LOCALES))
+# TODO: also keep track of things like "port", "land" in product files.
+
+# If CUSTOM_LOCALES contains any locales not already included
+# in PRODUCT_LOCALES, add them to PRODUCT_LOCALES.
+extra_locales := $(filter-out $(PRODUCT_LOCALES),$(CUSTOM_LOCALES))
+ifneq (,$(extra_locales))
+ ifneq ($(CALLED_FROM_SETUP),true)
+ # Don't spam stdout, because envsetup.sh may be scraping values from it.
+ $(info Adding CUSTOM_LOCALES [$(extra_locales)] to PRODUCT_LOCALES [$(PRODUCT_LOCALES)])
+ endif
+ PRODUCT_LOCALES += $(extra_locales)
+ extra_locales :=
+endif
+
+# Add PRODUCT_LOCALES to PRODUCT_AAPT_CONFIG
+PRODUCT_AAPT_CONFIG := $(strip $(PRODUCT_LOCALES) $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_CONFIG))
+PRODUCT_AAPT_PREF_CONFIG := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_PREF_CONFIG))
+PRODUCT_AAPT_PREBUILT_DPI := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_AAPT_PREBUILT_DPI))
+
+# Keep a copy of the space-separated config
+PRODUCT_AAPT_CONFIG_SP := $(PRODUCT_AAPT_CONFIG)
+
+# Convert spaces to commas.
+PRODUCT_AAPT_CONFIG := \
+ $(subst $(space),$(comma),$(strip $(PRODUCT_AAPT_CONFIG)))
+
+# product-scoped aapt flags
+PRODUCT_AAPT_FLAGS :=
+PRODUCT_AAPT2_CFLAGS :=
+ifneq ($(filter en_XA ar_XB,$(PRODUCT_LOCALES)),)
+ # Force generating resources for pseudo-locales.
+ PRODUCT_AAPT2_CFLAGS += --pseudo-localize
+ PRODUCT_AAPT_FLAGS += --pseudo-localize
+endif
+
+PRODUCT_BRAND := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_BRAND))
+
+PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MODEL))
+ifndef PRODUCT_MODEL
+ PRODUCT_MODEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_NAME))
+endif
+
+PRODUCT_MANUFACTURER := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_MANUFACTURER))
+ifndef PRODUCT_MANUFACTURER
+ PRODUCT_MANUFACTURER := unknown
+endif
+
+ifeq ($(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CHARACTERISTICS),)
+ TARGET_AAPT_CHARACTERISTICS := default
+else
+ TARGET_AAPT_CHARACTERISTICS := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_CHARACTERISTICS))
+endif
+
+PRODUCT_DEFAULT_WIFI_CHANNELS := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_WIFI_CHANNELS))
+
+PRODUCT_DEFAULT_DEV_CERTIFICATE := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_DEV_CERTIFICATE))
+ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
+ifneq (1,$(words $(PRODUCT_DEFAULT_DEV_CERTIFICATE)))
+ $(error PRODUCT_DEFAULT_DEV_CERTIFICATE='$(PRODUCT_DEFAULT_DEV_CERTIFICATE)', \
+ only 1 certificate is allowed.)
+endif
+endif
+
+# A list of words like :[:].
+# The file at the source path should be copied to the destination path
+# when building this product. is relative to
+# $(PRODUCT_OUT), so it should look like, e.g., "system/etc/file.xml".
+# The rules for these copy steps are defined in build/core/Makefile.
+# The optional : is used to indicate the owner of a vendor file.
+PRODUCT_COPY_FILES := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_COPY_FILES))
+
+# A list of property assignments, like "key = value", with zero or more
+# whitespace characters on either side of the '='.
+PRODUCT_PROPERTY_OVERRIDES := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PROPERTY_OVERRIDES))
+
+PRODUCT_SHIPPING_API_LEVEL := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SHIPPING_API_LEVEL))
+ifdef PRODUCT_SHIPPING_API_LEVEL
+ADDITIONAL_BUILD_PROPERTIES += \
+ ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
+endif
+
+# A list of property assignments, like "key = value", with zero or more
+# whitespace characters on either side of the '='.
+# used for adding properties to default.prop
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEFAULT_PROPERTY_OVERRIDES))
+
+# Should we use the default resources or add any product specific overlays
+PRODUCT_PACKAGE_OVERLAYS := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_PACKAGE_OVERLAYS))
+DEVICE_PACKAGE_OVERLAYS := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).DEVICE_PACKAGE_OVERLAYS))
+
+# The list of product-specific kernel header dirs
+PRODUCT_VENDOR_KERNEL_HEADERS := \
+ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VENDOR_KERNEL_HEADERS)
+
+# Add the product-defined properties to the build properties.
+ADDITIONAL_BUILD_PROPERTIES := \
+ $(ADDITIONAL_BUILD_PROPERTIES) \
+ $(PRODUCT_PROPERTY_OVERRIDES)
+
+# The OTA key(s) specified by the product config, if any. The names
+# of these keys are stored in the target-files zip so that post-build
+# signing tools can substitute them for the test key embedded by
+# default.
+PRODUCT_OTA_PUBLIC_KEYS := $(sort \
+ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_OTA_PUBLIC_KEYS))
+
+PRODUCT_EXTRA_RECOVERY_KEYS := $(sort \
+ $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_EXTRA_RECOVERY_KEYS))
+
+PRODUCT_DEX_PREOPT_DEFAULT_FLAGS := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_DEFAULT_FLAGS))
+PRODUCT_DEX_PREOPT_BOOT_FLAGS := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_BOOT_FLAGS))
+# Resolve and setup per-module dex-preopt configs.
+PRODUCT_DEX_PREOPT_MODULE_CONFIGS := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_DEX_PREOPT_MODULE_CONFIGS))
+# If a module has multiple setups, the first takes precedence.
+_pdpmc_modules :=
+$(foreach c,$(PRODUCT_DEX_PREOPT_MODULE_CONFIGS),\
+ $(eval m := $(firstword $(subst =,$(space),$(c))))\
+ $(if $(filter $(_pdpmc_modules),$(m)),,\
+ $(eval _pdpmc_modules += $(m))\
+ $(eval cf := $(patsubst $(m)=%,%,$(c)))\
+ $(eval cf := $(subst $(_PDPMC_SP_PLACE_HOLDER),$(space),$(cf)))\
+ $(eval DEXPREOPT.$(TARGET_PRODUCT).$(m).CONFIG := $(cf))))
+_pdpmc_modules :=
+
+# Resolve and setup per-module sanitizer configs.
+PRODUCT_SANITIZER_MODULE_CONFIGS := \
+ $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SANITIZER_MODULE_CONFIGS))
+# If a module has multiple setups, the first takes precedence.
+_psmc_modules :=
+$(foreach c,$(PRODUCT_SANITIZER_MODULE_CONFIGS),\
+ $(eval m := $(firstword $(subst =,$(space),$(c))))\
+ $(if $(filter $(_psmc_modules),$(m)),,\
+ $(eval _psmc_modules += $(m))\
+ $(eval cf := $(patsubst $(m)=%,%,$(c)))\
+ $(eval cf := $(subst $(_PSMC_SP_PLACE_HOLDER),$(space),$(cf)))\
+ $(eval SANITIZER.$(TARGET_PRODUCT).$(m).CONFIG := $(cf))))
+_psmc_modules :=
diff --git a/core/proguard.emma.flags b/core/proguard.emma.flags
new file mode 100644
index 0000000000000000000000000000000000000000..bf94086217a8cabe1a55a490dd77ddb95ecc9899
--- /dev/null
+++ b/core/proguard.emma.flags
@@ -0,0 +1,4 @@
+# Keep everything for the emma classes
+-keep class com.vladium.** {
+ *;
+}
diff --git a/core/proguard.flags b/core/proguard.flags
new file mode 100644
index 0000000000000000000000000000000000000000..6ed1f9b3bcdb3fc40b1440ae4b66d6f98b69f7e2
--- /dev/null
+++ b/core/proguard.flags
@@ -0,0 +1,18 @@
+# We have moved -dontobfuscate and -dontoptimize to the makefiles.
+# dex does not like code run through proguard optimize and preverify steps.
+# -dontoptimize
+-dontpreverify
+
+# Don't obfuscate. We only need dead code striping.
+# -dontobfuscate
+
+# Add this flag in your package's own configuration if it's needed.
+#-flattenpackagehierarchy
+
+# Keep classes and methods that have the guava @VisibleForTesting annotation
+-keep @**.VisibleForTesting class *
+-keepclassmembers class * {
+@**.VisibleForTesting *;
+}
+
+-include proguard_basic_keeps.flags
diff --git a/core/proguard.jacoco.flags b/core/proguard.jacoco.flags
new file mode 100644
index 0000000000000000000000000000000000000000..c3bed94355f048909a603f15369e8da7d9c9402c
--- /dev/null
+++ b/core/proguard.jacoco.flags
@@ -0,0 +1,8 @@
+# Keep everything for the emma classes
+-keep class com.vladium.** {
+ *;
+}
+# Keep everything for the jacoco classes
+-keep class org.jacoco.** {
+ *;
+}
diff --git a/core/proguard_basic_keeps.flags b/core/proguard_basic_keeps.flags
new file mode 100644
index 0000000000000000000000000000000000000000..4de52219a151bd2544c5f5f28ab5ba35adf7cd8c
--- /dev/null
+++ b/core/proguard_basic_keeps.flags
@@ -0,0 +1,74 @@
+# see http://sourceforge.net/tracker/?func=detail&aid=2787465&group_id=54750&atid=474707
+-optimizations !code/simplification/arithmetic
+-optimizations !code/simplification/cast
+
+# To prevent name conflict in incremental obfuscation.
+-useuniqueclassmembernames
+
+# Some classes in the libraries extend package private classes to chare common functionality
+# that isn't explicitly part of the API
+-dontskipnonpubliclibraryclasses -dontskipnonpubliclibraryclassmembers
+
+# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
+-keepclasseswithmembernames class * {
+ native ;
+}
+
+# class$ methods are inserted by some compilers to implement .class construct,
+# see http://proguard.sourceforge.net/manual/examples.html#library
+-keepclassmembernames class * {
+ java.lang.Class class$(java.lang.String);
+ java.lang.Class class$(java.lang.String, boolean);
+}
+
+# Keep serializable classes and necessary members for serializable classes
+# Copied from the ProGuard manual at http://proguard.sourceforge.net.
+-keepnames class * implements java.io.Serializable
+-keepclassmembers class * implements java.io.Serializable {
+ static final long serialVersionUID;
+ private static final java.io.ObjectStreamField[] serialPersistentFields;
+ !static !transient ;
+ private void writeObject(java.io.ObjectOutputStream);
+ private void readObject(java.io.ObjectInputStream);
+ java.lang.Object writeReplace();
+ java.lang.Object readResolve();
+}
+
+# Keep Throwable's constructor that takes a String argument.
+-keepclassmembers class * extends java.lang.Throwable {
+ (java.lang.String);
+}
+
+# Please specify classes to be kept explicitly in your package's configuration.
+# -keep class * extends android.app.Activity
+# -keep class * extends android.view.View
+# -keep class * extends android.app.Service
+# -keep class * extends android.content.BroadcastReceiver
+# -keep class * extends android.content.ContentProvider
+# -keep class * extends android.preference.Preference
+# -keep class * extends android.app.BackupAgent
+
+# Parcelable CREATORs must be kept for Parcelable functionality
+-keep class * implements android.os.Parcelable {
+ public static final ** CREATOR;
+}
+
+# The support library contains references to newer platform versions.
+# Don't warn about those in case this app is linking against an older
+# platform version. We know about them, and they are safe.
+# See proguard-android.txt in the SDK package.
+#
+# DO NOT USE THIS: We figured it's dangerous to blindly ignore all support library warnings.
+# ProGuard may strip members of subclass of unknown super classes, in case an app is linking against
+# LOCAL_SDK_VERSION lower than the support library's LOCAL_SDK_VERSION.
+# See bug/20658265.
+# -dontwarn android.support.**
+
+# Less spammy.
+-dontnote
diff --git a/core/proguard_tests.flags b/core/proguard_tests.flags
new file mode 100644
index 0000000000000000000000000000000000000000..1f840bc21eb747b304273cde59367a39611a3fa1
--- /dev/null
+++ b/core/proguard_tests.flags
@@ -0,0 +1,26 @@
+# Keep everything for tests
+# This flag has been moved to the makefiles and is set for tests by default.
+#-dontshrink
+
+# But we may want to obfuscate if the main app gets obfuscated.
+# This flag has been moved to the makefiles.
+#-dontobfuscate
+
+#-keep class * extends junit.framework.TestCase {
+# public void test*();
+#}
+
+#-keepclasseswithmembers class * {
+# public static void run();
+# public static junit.framework.Test suite();
+#}
+
+# some AllTests don't include run().
+#-keepclasseswithmembers class * {
+# public static junit.framework.Test suite();
+#}
+
+#-keep class * extends junit.framework.TestSuite
+#-keep class * extends android.app.Instrumentation
+#-keep class * extends android.test.TestSuiteProvider
+
diff --git a/core/root.mk b/core/root.mk
new file mode 100644
index 0000000000000000000000000000000000000000..6c8f7952e9cc029a8cf834762ae4fcbf9d4ab746
--- /dev/null
+++ b/core/root.mk
@@ -0,0 +1,3 @@
+### DO NOT EDIT THIS FILE ###
+include build/core/main.mk
+### DO NOT EDIT THIS FILE ###
diff --git a/core/sdk_font.mk b/core/sdk_font.mk
new file mode 100644
index 0000000000000000000000000000000000000000..c10f19ff34cbf5e0d5a64de358fb10f8d9bbe405
--- /dev/null
+++ b/core/sdk_font.mk
@@ -0,0 +1,66 @@
+###############################################################################
+# Fonts shipped with the SDK need to be renamed for Java to handle them
+# properly. Hence, a special script is used to rename the fonts. We bundle all
+# the fonts that are shipped on a newer non-space-constrained device. However,
+# OpenType fonts used on these devices are not supported by Java. Their
+# replacements are added separately.
+###############################################################################
+
+
+# The script that renames the font.
+sdk_font_rename_script := frameworks/base/tools/layoutlib/rename_font/build_font_single.py
+
+# Location of the fonttools library that the above script depends on.
+fonttools_lib := external/fonttools/Lib
+
+# A temporary location to store the renamed fonts. atree picks all files in
+# this directory and bundles it with the SDK.
+SDK_FONT_TEMP := $(call intermediates-dir-for,PACKAGING,sdk-fonts,HOST,COMMON)
+
+# The font configuration files - system_fonts.xml, fallback_fonts.xml etc.
+sdk_font_config := $(sort $(wildcard frameworks/base/data/fonts/*.xml))
+sdk_font_config := $(addprefix $(SDK_FONT_TEMP)/, $(notdir $(sdk_font_config)))
+
+$(sdk_font_config): $(SDK_FONT_TEMP)/%.xml: \
+ frameworks/base/data/fonts/%.xml
+ $(hide) mkdir -p $(dir $@)
+ $(hide) cp -vf $< $@
+
+# List of fonts on the device that we want to ship. This is all .ttf fonts.
+sdk_fonts_device := $(filter $(TARGET_OUT)/fonts/%.ttf, $(INTERNAL_SYSTEMIMAGE_FILES))
+sdk_fonts_device := $(addprefix $(SDK_FONT_TEMP)/, $(notdir $(sdk_fonts_device)))
+
+# Macro to rename the font.
+sdk_rename_font = PYTHONPATH=$$PYTHONPATH:$(fonttools_lib) $(sdk_font_rename_script) \
+ $1 $2
+
+# TODO: If the font file is a symlink, reuse the font renamed from the symlink
+# target.
+$(sdk_fonts_device): $(SDK_FONT_TEMP)/%.ttf: $(TARGET_OUT)/fonts/%.ttf \
+ $(sdk_font_rename_script)
+ $(hide) mkdir -p $(dir $@)
+ $(hide) $(call sdk_rename_font,$<,$@)
+
+# List of all dependencies - all fonts and configuration files.
+SDK_FONT_DEPS := $(sdk_fonts_device) $(sdk_font_config)
+
+# Define a macro to create rule for addititional fonts that we want to include
+# in the SDK.
+# $1 Output font name
+# $2 Source font path
+define sdk-extra-font-rule
+fontfullname := $$(SDK_FONT_TEMP)/$1
+ifeq ($$(filter $$(fontfullname),$$(sdk_fonts_device)),)
+SDK_FONT_DEPS += $$(fontfullname)
+$$(fontfullname): $2 $$(sdk_font_rename_script)
+ $$(hide) mkdir -p $$(dir $$@)
+ $$(hide) $$(call sdk_rename_font,$$<,$$@)
+endif
+fontfullname :=
+endef
+
+# These extra fonts are used as a replacement for OpenType fonts.
+$(eval $(call sdk-extra-font-rule,NanumGothic.ttf,external/naver-fonts/NanumGothic.ttf))
+$(eval $(call sdk-extra-font-rule,DroidSansFallback.ttf,frameworks/base/data/fonts/DroidSansFallbackFull.ttf))
+
+sdk-extra-font-rule :=
diff --git a/core/setup_one_odex.mk b/core/setup_one_odex.mk
new file mode 100644
index 0000000000000000000000000000000000000000..36b68171b852052b43f39aa8d18516e0045ecd7e
--- /dev/null
+++ b/core/setup_one_odex.mk
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2014 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.
+#
+
+# Set up variables and dependency for one odex file
+# Input variables: my_2nd_arch_prefix
+# Output(modified) variables: built_odex, installed_odex, built_installed_odex
+
+my_built_odex := $(call get-odex-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(LOCAL_BUILT_MODULE))
+ifdef LOCAL_DEX_PREOPT_IMAGE_LOCATION
+my_dex_preopt_image_location := $(LOCAL_DEX_PREOPT_IMAGE_LOCATION)
+else
+my_dex_preopt_image_location := $($(my_2nd_arch_prefix)DEFAULT_DEX_PREOPT_BUILT_IMAGE_LOCATION)
+endif
+my_dex_preopt_image_filename := $(call get-image-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(my_dex_preopt_image_location))
+$(my_built_odex): PRIVATE_2ND_ARCH_VAR_PREFIX := $(my_2nd_arch_prefix)
+$(my_built_odex): PRIVATE_DEX_LOCATION := $(patsubst $(PRODUCT_OUT)%,%,$(LOCAL_INSTALLED_MODULE))
+$(my_built_odex): PRIVATE_DEX_PREOPT_IMAGE_LOCATION := $(my_dex_preopt_image_location)
+$(my_built_odex) : $($(my_2nd_arch_prefix)DEXPREOPT_ONE_FILE_DEPENDENCY_BUILT_BOOT_PREOPT) \
+ $(DEXPREOPT_ONE_FILE_DEPENDENCY_TOOLS) \
+ $(my_dex_preopt_image_filename)
+
+my_installed_odex := $(call get-odex-installed-file-path,$($(my_2nd_arch_prefix)DEX2OAT_TARGET_ARCH),$(LOCAL_INSTALLED_MODULE))
+
+$(eval $(call copy-one-file,$(my_built_odex),$(my_installed_odex)))
+
+built_odex += $(my_built_odex)
+installed_odex += $(my_installed_odex)
+built_installed_odex += $(my_built_odex):$(my_installed_odex)
diff --git a/core/shared_library.mk b/core/shared_library.mk
new file mode 100644
index 0000000000000000000000000000000000000000..2f483414a209f82b8921b30c0d31e7d4a67e9fd3
--- /dev/null
+++ b/core/shared_library.mk
@@ -0,0 +1,56 @@
+my_prefix := TARGET_
+include $(BUILD_SYSTEM)/multilib.mk
+
+ifndef my_module_multilib
+# libraries default to building for both architecturess
+my_module_multilib := both
+endif
+
+ifeq ($(my_module_multilib),both)
+ifneq ($(LOCAL_MODULE_PATH),)
+ifneq ($(TARGET_2ND_ARCH),)
+$(error $(LOCAL_MODULE): LOCAL_MODULE_PATH for shared libraries is unsupported in multiarch builds, use LOCAL_MODULE_RELATIVE_PATH instead)
+endif
+endif
+
+ifneq ($(LOCAL_UNSTRIPPED_PATH),)
+ifneq ($(TARGET_2ND_ARCH),)
+$(error $(LOCAL_MODULE): LOCAL_UNSTRIPPED_PATH for shared libraries is unsupported in multiarch builds)
+endif
+endif
+endif # my_module_multilib == both
+
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
+include $(BUILD_SYSTEM)/shared_library_internal.mk
+endif
+
+ifdef TARGET_2ND_ARCH
+
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
+# Build for TARGET_2ND_ARCH
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+include $(BUILD_SYSTEM)/shared_library_internal.mk
+
+endif
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+
+endif # TARGET_2ND_ARCH
+
+my_module_arch_supported :=
+
+###########################################################
+## Copy headers to the install tree
+###########################################################
+include $(BUILD_COPY_HEADERS)
diff --git a/core/shared_library_internal.mk b/core/shared_library_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b9a5e3e9307473a33412c4d50303947b2484bce0
--- /dev/null
+++ b/core/shared_library_internal.mk
@@ -0,0 +1,83 @@
+###########################################################
+## Standard rules for building a normal shared library.
+##
+## Additional inputs from base_rules.make:
+## None.
+##
+## LOCAL_MODULE_SUFFIX will be set for you.
+###########################################################
+
+ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
+LOCAL_MODULE_CLASS := SHARED_LIBRARIES
+endif
+ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
+LOCAL_MODULE_SUFFIX := $(TARGET_SHLIB_SUFFIX)
+endif
+ifneq ($(strip $(OVERRIDE_BUILT_MODULE_PATH)),)
+$(error $(LOCAL_PATH): Illegal use of OVERRIDE_BUILT_MODULE_PATH)
+endif
+ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)$(LOCAL_MODULE_STEM_32)$(LOCAL_MODULE_STEM_64)),)
+$(error $(LOCAL_PATH): Cannot set module stem for a library)
+endif
+
+$(call target-shared-library-hook)
+
+skip_build_from_source :=
+ifdef LOCAL_PREBUILT_MODULE_FILE
+ifeq (,$(call if-build-from-source,$(LOCAL_MODULE),$(LOCAL_PATH)))
+include $(BUILD_SYSTEM)/prebuilt_internal.mk
+skip_build_from_source := true
+endif
+endif
+
+ifndef skip_build_from_source
+
+# Put the built targets of all shared libraries in a common directory
+# to simplify the link line.
+OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATE_LIBRARIES)
+
+include $(BUILD_SYSTEM)/dynamic_binary.mk
+
+# Define PRIVATE_ variables from global vars
+my_target_global_ld_dirs := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_LD_DIRS)
+ifeq ($(LOCAL_NO_LIBGCC),true)
+my_target_libgcc :=
+else
+my_target_libgcc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBGCC)
+endif
+my_target_libatomic := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBATOMIC)
+ifeq ($(LOCAL_NO_CRT),true)
+my_target_crtbegin_so_o :=
+my_target_crtend_so_o :=
+else
+my_target_crtbegin_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTBEGIN_SO_O)
+my_target_crtend_so_o := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_CRTEND_SO_O)
+endif
+ifdef LOCAL_SDK_VERSION
+# Make sure the prebuilt NDK paths are put ahead of the TARGET_GLOBAL_LD_DIRS,
+# so we don't have race condition when the system libraries (such as libc, libstdc++) are also built in the tree.
+my_target_global_ld_dirs := \
+ $(addprefix -L, $(patsubst %/,%,$(dir $(my_ndk_stl_shared_lib_fullpath))) \
+ $(my_ndk_sysroot_lib)) \
+ $(my_target_global_ld_dirs)
+my_target_global_ldflags := $(my_ndk_stl_shared_lib) $(my_target_global_ldflags)
+my_target_crtbegin_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtbegin_so.o)
+my_target_crtend_so_o := $(wildcard $(my_ndk_sysroot_lib)/crtend_so.o)
+endif
+$(linked_module): PRIVATE_TARGET_GLOBAL_LD_DIRS := $(my_target_global_ld_dirs)
+$(linked_module): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
+$(linked_module): PRIVATE_TARGET_LIBGCC := $(my_target_libgcc)
+$(linked_module): PRIVATE_TARGET_LIBATOMIC := $(my_target_libatomic)
+$(linked_module): PRIVATE_TARGET_CRTBEGIN_SO_O := $(my_target_crtbegin_so_o)
+$(linked_module): PRIVATE_TARGET_CRTEND_SO_O := $(my_target_crtend_so_o)
+
+$(linked_module): \
+ $(all_objects) \
+ $(all_libraries) \
+ $(my_target_crtbegin_so_o) \
+ $(my_target_crtend_so_o) \
+ $(LOCAL_MODULE_MAKEFILE_DEP) \
+ $(LOCAL_ADDITIONAL_DEPENDENCIES)
+ $(transform-o-to-shared-lib)
+
+endif # skip_build_from_source
diff --git a/core/shared_test_lib.mk b/core/shared_test_lib.mk
new file mode 100644
index 0000000000000000000000000000000000000000..fbfdc9c1ce7f5bb9b21cc9e5b69ada1021ea4593
--- /dev/null
+++ b/core/shared_test_lib.mk
@@ -0,0 +1,8 @@
+#############################################
+## A thin wrapper around BUILD_SHARED_LIBRARY
+## Common flags for native tests are added.
+#############################################
+
+include $(BUILD_SYSTEM)/target_test_internal.mk
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/core/soong.mk b/core/soong.mk
new file mode 100644
index 0000000000000000000000000000000000000000..24639532659b6744d0a1175f753acccfecc89f51
--- /dev/null
+++ b/core/soong.mk
@@ -0,0 +1,80 @@
+SOONG_OUT_DIR := $(OUT_DIR)/soong
+SOONG_HOST_EXECUTABLES := $(SOONG_OUT_DIR)/host/$(HOST_PREBUILT_TAG)/bin
+KATI := $(SOONG_HOST_EXECUTABLES)/ckati
+MAKEPARALLEL := $(SOONG_HOST_EXECUTABLES)/makeparallel
+
+SOONG := $(SOONG_OUT_DIR)/soong
+SOONG_BOOTSTRAP := $(SOONG_OUT_DIR)/.soong.bootstrap
+SOONG_BUILD_NINJA := $(SOONG_OUT_DIR)/build.ninja
+SOONG_ANDROID_MK := $(SOONG_OUT_DIR)/Android.mk
+SOONG_IN_MAKE := $(SOONG_OUT_DIR)/.soong.in_make
+SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.variables
+
+# We need to rebootstrap soong if SOONG_OUT_DIR or the reverse path from
+# SOONG_OUT_DIR to TOP changes
+SOONG_NEEDS_REBOOTSTRAP :=
+ifneq ($(wildcard $(SOONG_BOOTSTRAP)),)
+ ifneq ($(SOONG_OUT_DIR),$(strip $(shell source $(SOONG_BOOTSTRAP); echo $$BUILDDIR)))
+ SOONG_NEEDS_REBOOTSTRAP := FORCE
+ $(warning soong_out_dir changed)
+ endif
+ ifneq ($(strip $(shell build/soong/reverse_path.py $(SOONG_OUT_DIR))),$(strip $(shell source $(SOONG_BOOTSTRAP); echo $$SRCDIR_FROM_BUILDDIR)))
+ SOONG_NEEDS_REBOOTSTRAP := FORCE
+ $(warning reverse path changed)
+ endif
+endif
+
+# Bootstrap soong.
+$(SOONG_BOOTSTRAP): bootstrap.bash $(SOONG_NEEDS_REBOOTSTRAP)
+ $(hide) mkdir -p $(dir $@)
+ $(hide) BUILDDIR=$(SOONG_OUT_DIR) ./bootstrap.bash
+
+# Create soong.variables with copies of makefile settings. Runs every build,
+# but only updates soong.variables if it changes
+SOONG_VARIABLES_TMP := $(SOONG_VARIABLES).$$$$
+$(SOONG_VARIABLES): FORCE
+ $(hide) mkdir -p $(dir $@)
+ $(hide) (\
+ echo '{'; \
+ echo ' "Device_uses_jemalloc": $(if $(filter true,$(MALLOC_SVELTE)),false,true),'; \
+ echo ' "Device_uses_dlmalloc": $(if $(filter true,$(MALLOC_SVELTE)),true,false),'; \
+ echo ' "Platform_sdk_version": $(PLATFORM_SDK_VERSION),'; \
+ echo ' "Unbundled_build": $(if $(TARGET_BUILD_APPS),true,false),'; \
+ echo ' "Brillo": $(if $(BRILLO),true,false),'; \
+ echo ''; \
+ echo ' "DeviceName": "$(TARGET_DEVICE)",'; \
+ echo ' "DeviceArch": "$(TARGET_ARCH)",'; \
+ echo ' "DeviceArchVariant": "$(TARGET_ARCH_VARIANT)",'; \
+ echo ' "DeviceCpuVariant": "$(TARGET_CPU_VARIANT)",'; \
+ echo ' "DeviceAbi": ["$(TARGET_CPU_ABI)", "$(TARGET_CPU_ABI2)"],'; \
+ echo ' "DeviceUsesClang": $(if $(USE_CLANG_PLATFORM_BUILD),$(USE_CLANG_PLATFORM_BUILD),false),'; \
+ echo ''; \
+ echo ' "DeviceSecondaryArch": "$(TARGET_2ND_ARCH)",'; \
+ echo ' "DeviceSecondaryArchVariant": "$(TARGET_2ND_ARCH_VARIANT)",'; \
+ echo ' "DeviceSecondaryCpuVariant": "$(TARGET_2ND_CPU_VARIANT)",'; \
+ echo ' "DeviceSecondaryAbi": ["$(TARGET_2ND_CPU_ABI)", "$(TARGET_2ND_CPU_ABI2)"],'; \
+ echo ''; \
+ echo ' "HostArch": "$(HOST_ARCH)",'; \
+ echo ' "HostSecondaryArch": "$(HOST_2ND_ARCH)",'; \
+ echo ''; \
+ echo ' "CrossHost": "$(HOST_CROSS_OS)",'; \
+ echo ' "CrossHostArch": "$(HOST_CROSS_ARCH)",'; \
+ echo ' "CrossHostSecondaryArch": "$(HOST_CROSS_2ND_ARCH)"'; \
+ echo '}') > $(SOONG_VARIABLES_TMP); \
+ if ! cmp -s $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); then \
+ mv $(SOONG_VARIABLES_TMP) $(SOONG_VARIABLES); \
+ else \
+ rm $(SOONG_VARIABLES_TMP); \
+ fi
+
+# Tell soong that it is embedded in make
+$(SOONG_IN_MAKE):
+ $(hide) mkdir -p $(dir $@)
+ $(hide) touch $@
+
+# Build an Android.mk listing all soong outputs as prebuilts
+$(SOONG_ANDROID_MK): $(SOONG_BOOTSTRAP) $(SOONG_VARIABLES) $(SOONG_IN_MAKE) FORCE
+ $(hide) $(SOONG) $(KATI) $(MAKEPARALLEL) $(NINJA_ARGS)
+
+$(KATI): $(SOONG_ANDROID_MK)
+$(MAKEPARALLEL): $(SOONG_ANDROID_MK)
diff --git a/core/static_java_library.mk b/core/static_java_library.mk
new file mode 100644
index 0000000000000000000000000000000000000000..1279878b592fc307a653a4825080b45abb6d084e
--- /dev/null
+++ b/core/static_java_library.mk
@@ -0,0 +1,200 @@
+#
+# 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.
+#
+
+# Standard rules for building a "static" java library.
+# Static java libraries are not installed, nor listed on any
+# classpaths. They can, however, be included wholesale in
+# other java modules.
+
+LOCAL_UNINSTALLABLE_MODULE := true
+LOCAL_IS_STATIC_JAVA_LIBRARY := true
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+#################################
+include $(BUILD_SYSTEM)/configure_local_jack.mk
+#################################
+
+intermediates.COMMON := $(call local-intermediates-dir,COMMON)
+
+my_res_package :=
+
+# Hack to build static Java library with Android resource
+# See bug 5714516
+all_resources :=
+need_compile_res :=
+# A static Java library needs to explicily set LOCAL_RESOURCE_DIR.
+ifdef LOCAL_RESOURCE_DIR
+need_compile_res := true
+endif
+ifdef LOCAL_USE_AAPT2
+ifneq ($(LOCAL_STATIC_ANDROID_LIBRARIES),)
+need_compile_res := true
+endif
+endif
+
+ifeq ($(need_compile_res),true)
+all_resources := $(strip \
+ $(foreach dir, $(LOCAL_RESOURCE_DIR), \
+ $(addprefix $(dir)/, \
+ $(patsubst res/%,%, \
+ $(call find-subdir-assets,$(dir)) \
+ ) \
+ ) \
+ ))
+
+# By default we should remove the R/Manifest classes from a static Java library,
+# because they will be regenerated in the app that uses it.
+# But if the static Java library will be used by a library, then we may need to
+# keep the generated classes with "LOCAL_JAR_EXCLUDE_FILES := none".
+ifndef LOCAL_JAR_EXCLUDE_FILES
+LOCAL_JAR_EXCLUDE_FILES := $(ANDROID_RESOURCE_GENERATED_CLASSES)
+endif
+ifeq (none,$(LOCAL_JAR_EXCLUDE_FILES))
+LOCAL_JAR_EXCLUDE_FILES :=
+endif
+
+proguard_options_file :=
+
+ifneq ($(LOCAL_PROGUARD_ENABLED),custom)
+ proguard_options_file := $(intermediates.COMMON)/proguard_options
+endif
+
+LOCAL_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_PROGUARD_FLAGS)
+
+ifdef LOCAL_JACK_ENABLED
+ifndef LOCAL_JACK_PROGUARD_FLAGS
+ LOCAL_JACK_PROGUARD_FLAGS := $(LOCAL_PROGUARD_FLAGS)
+endif
+LOCAL_JACK_PROGUARD_FLAGS := $(addprefix -include ,$(proguard_options_file)) $(LOCAL_JACK_PROGUARD_FLAGS)
+endif # LOCAL_JACK_ENABLED
+
+R_file_stamp := $(intermediates.COMMON)/src/R.stamp
+LOCAL_INTERMEDIATE_TARGETS += $(R_file_stamp)
+
+ifdef LOCAL_USE_AAPT2
+# For library we treat all the resource equal with no overlay.
+my_res_resources := $(all_resources)
+my_overlay_resources :=
+# For libraries put everything in the COMMON intermediate directory.
+my_res_package := $(intermediates.COMMON)/package-res.apk
+
+LOCAL_INTERMEDIATE_TARGETS += $(my_res_package)
+endif # LOCAL_USE_AAPT2
+endif # LOCAL_RESOURCE_DIR
+
+all_res_assets := $(all_resources)
+
+include $(BUILD_SYSTEM)/java_library.mk
+
+ifeq (true,$(need_compile_res))
+include $(BUILD_SYSTEM)/android_manifest.mk
+
+LOCAL_SDK_RES_VERSION:=$(strip $(LOCAL_SDK_RES_VERSION))
+ifeq ($(LOCAL_SDK_RES_VERSION),)
+ LOCAL_SDK_RES_VERSION:=$(LOCAL_SDK_VERSION)
+endif
+
+framework_res_package_export :=
+framework_res_package_export_deps :=
+# Please refer to package.mk
+ifneq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
+ifneq ($(filter-out current system_current test_current,$(LOCAL_SDK_RES_VERSION))$(if $(TARGET_BUILD_APPS),$(filter current system_current test_current,$(LOCAL_SDK_RES_VERSION))),)
+framework_res_package_export := \
+ $(HISTORICAL_SDK_VERSIONS_ROOT)/$(LOCAL_SDK_RES_VERSION)/android.jar
+framework_res_package_export_deps := $(framework_res_package_export)
+else
+framework_res_package_export := \
+ $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
+framework_res_package_export_deps := \
+ $(dir $(framework_res_package_export))src/R.stamp
+endif
+endif
+
+# add --non-constant-id to prevent inlining constants.
+# AAR needs text symbol file R.txt.
+ifdef LOCAL_USE_AAPT2
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --static-lib --no-static-lib-packages
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PRODUCT_AAPT_CONFIG :=
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PRODUCT_AAPT_PREF_CONFIG :=
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_AAPT_CHARACTERISTICS :=
+else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_FLAGS := $(LOCAL_AAPT_FLAGS) --non-constant-id --output-text-symbols $(LOCAL_INTERMEDIATE_SOURCE_DIR)
+endif
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_SOURCE_INTERMEDIATES_DIR := $(LOCAL_INTERMEDIATE_SOURCE_DIR)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_PUBLICS_OUTPUT := $(intermediates.COMMON)/public_resources.xml
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_AAPT_INCLUDES := $(framework_res_package_export)
+
+ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(LOCAL_SDK_VERSION)
+else
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEFAULT_APP_TARGET_SDK := $(DEFAULT_APP_TARGET_SDK)
+endif
+
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASSET_DIR :=
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_PACKAGE_NAME :=
+$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MANIFEST_INSTRUMENTATION_FOR :=
+
+ifdef LOCAL_USE_AAPT2
+# One more level with name res so we can zip up the flat resources that can be linked by apps.
+my_compiled_res_base_dir := $(intermediates.COMMON)/flat-res/res
+my_generated_res_dirs := $(rs_generated_res_dir)
+my_generated_res_dirs_deps := $(RenderScript_file_stamp)
+include $(BUILD_SYSTEM)/aapt2.mk
+$(my_res_package) : $(framework_res_package_export_deps)
+else
+$(R_file_stamp) : $(all_resources) $(full_android_manifest) $(AAPT) $(framework_res_package_export_deps)
+ @echo "target R.java/Manifest.java: $(PRIVATE_MODULE) ($@)"
+ $(create-resource-java-files)
+ $(hide) find $(PRIVATE_SOURCE_INTERMEDIATES_DIR) -name R.java | xargs cat > $@
+endif # LOCAL_USE_AAPT2
+
+$(LOCAL_BUILT_MODULE): $(R_file_stamp)
+ifdef LOCAL_JACK_ENABLED
+$(noshrob_classes_jack): $(R_file_stamp)
+$(full_classes_jack): $(R_file_stamp)
+$(jack_check_timestamp): $(R_file_stamp)
+endif # LOCAL_JACK_ENABLED
+$(full_classes_compiled_jar): $(R_file_stamp)
+
+# Rule to build AAR, archive including classes.jar, resource, etc.
+built_aar := $(intermediates.COMMON)/javalib.aar
+$(built_aar): PRIVATE_MODULE := $(LOCAL_MODULE)
+$(built_aar): PRIVATE_ANDROID_MANIFEST := $(full_android_manifest)
+$(built_aar): PRIVATE_CLASSES_JAR := $(full_classes_jar)
+$(built_aar): PRIVATE_RESOURCE_DIR := $(LOCAL_RESOURCE_DIR)
+$(built_aar): PRIVATE_R_TXT := $(LOCAL_INTERMEDIATE_SOURCE_DIR)/R.txt
+$(built_aar) : $(full_classes_jar) $(full_android_manifest)
+ @echo "target AAR: $(PRIVATE_MODULE) ($@)"
+ $(hide) rm -rf $(dir $@)aar && mkdir -p $(dir $@)aar/res
+ $(hide) cp $(PRIVATE_ANDROID_MANIFEST) $(dir $@)aar/AndroidManifest.xml
+ $(hide) cp $(PRIVATE_CLASSES_JAR) $(dir $@)aar/classes.jar
+ # Note: Use "cp -n" to honor the resource overlay rules, if multiple res dirs exist.
+ $(hide) $(foreach res,$(PRIVATE_RESOURCE_DIR),cp -Rfn $(res)/* $(dir $@)aar/res;)
+ $(hide) cp $(PRIVATE_R_TXT) $(dir $@)aar/R.txt
+ $(hide) jar -cMf $@ \
+ -C $(dir $@)aar .
+
+# Register the aar file.
+ALL_MODULES.$(LOCAL_MODULE).AAR := $(built_aar)
+endif # need_compile_res
+
+# Reset internal variables.
+all_res_assets :=
+LOCAL_IS_STATIC_JAVA_LIBRARY :=
diff --git a/core/static_library.mk b/core/static_library.mk
new file mode 100644
index 0000000000000000000000000000000000000000..a8ae399b68af56f5c77ea8b2176d7084641e09a5
--- /dev/null
+++ b/core/static_library.mk
@@ -0,0 +1,41 @@
+my_prefix := TARGET_
+include $(BUILD_SYSTEM)/multilib.mk
+
+ifndef my_module_multilib
+# libraries default to building for both architecturess
+my_module_multilib := both
+endif
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
+include $(BUILD_SYSTEM)/static_library_internal.mk
+endif
+
+ifdef TARGET_2ND_ARCH
+
+LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
+include $(BUILD_SYSTEM)/module_arch_supported.mk
+
+ifeq ($(my_module_arch_supported),true)
+# Build for TARGET_2ND_ARCH
+OVERRIDE_BUILT_MODULE_PATH :=
+LOCAL_BUILT_MODULE :=
+LOCAL_INSTALLED_MODULE :=
+LOCAL_INTERMEDIATE_TARGETS :=
+
+include $(BUILD_SYSTEM)/static_library_internal.mk
+
+endif
+
+LOCAL_2ND_ARCH_VAR_PREFIX :=
+
+endif # TARGET_2ND_ARCH
+
+my_module_arch_supported :=
+
+###########################################################
+## Copy headers to the install tree
+###########################################################
+include $(BUILD_COPY_HEADERS)
diff --git a/core/static_library_internal.mk b/core/static_library_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..cabe8232206975206e0dd9564771ef1d788dc544
--- /dev/null
+++ b/core/static_library_internal.mk
@@ -0,0 +1,33 @@
+###########################################################
+## Standard rules for building a static library.
+##
+## Additional inputs from base_rules.make:
+## None.
+##
+## LOCAL_MODULE_SUFFIX will be set for you.
+###########################################################
+
+ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
+LOCAL_MODULE_CLASS := STATIC_LIBRARIES
+endif
+ifeq ($(strip $(LOCAL_MODULE_SUFFIX)),)
+LOCAL_MODULE_SUFFIX := .a
+endif
+LOCAL_UNINSTALLABLE_MODULE := true
+ifneq ($(strip $(LOCAL_MODULE_STEM)$(LOCAL_BUILT_MODULE_STEM)),)
+$(error $(LOCAL_PATH): Cannot set module stem for a library)
+endif
+
+include $(BUILD_SYSTEM)/binary.mk
+
+ifeq ($(LOCAL_RAW_STATIC_LIBRARY),true)
+LOCAL_RAW_STATIC_LIBRARY:=
+$(all_objects) : PRIVATE_TARGET_PROJECT_INCLUDES :=
+$(all_objects) : PRIVATE_TARGET_C_INCLUDES :=
+$(all_objects) : PRIVATE_TARGET_GLOBAL_CFLAGS :=
+$(all_objects) : PRIVATE_TARGET_GLOBAL_CPPFLAGS :=
+endif
+
+$(LOCAL_BUILT_MODULE) : $(built_whole_libraries)
+$(LOCAL_BUILT_MODULE) : $(all_objects)
+ $(transform-o-to-static-lib)
diff --git a/core/static_test_lib.mk b/core/static_test_lib.mk
new file mode 100644
index 0000000000000000000000000000000000000000..9d0bcc8efbb293b007ff00f08eb8e005cc0762e2
--- /dev/null
+++ b/core/static_test_lib.mk
@@ -0,0 +1,8 @@
+#############################################
+## A thin wrapper around BUILD_STATIC_LIBRARY
+## Common flags for native tests are added.
+#############################################
+
+include $(BUILD_SYSTEM)/target_test_internal.mk
+
+include $(BUILD_STATIC_LIBRARY)
diff --git a/core/target_test_internal.mk b/core/target_test_internal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..4715fe8d59017fee53b88e9943a3b2c124993e25
--- /dev/null
+++ b/core/target_test_internal.mk
@@ -0,0 +1,28 @@
+#######################################################
+## Shared definitions for all target test compilations.
+#######################################################
+
+LOCAL_CFLAGS += -DGTEST_OS_LINUX_ANDROID -DGTEST_HAS_STD_STRING
+
+LOCAL_C_INCLUDES += external/gtest/include
+
+ifndef LOCAL_SDK_VERSION
+LOCAL_STATIC_LIBRARIES += libgtest_main libgtest
+else
+LOCAL_STATIC_LIBRARIES += libgtest_main_ndk libgtest_ndk
+endif
+
+ifdef LOCAL_MODULE_PATH
+$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE))
+endif
+
+ifdef LOCAL_MODULE_PATH_32
+$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_32 when building test $(LOCAL_MODULE))
+endif
+
+ifdef LOCAL_MODULE_PATH_64
+$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE))
+endif
+
+LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
+LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE)
diff --git a/core/tasks/apicheck.mk b/core/tasks/apicheck.mk
new file mode 100644
index 0000000000000000000000000000000000000000..3975d2071e11d0e8ac0035c2e1dabcf530ae2b0e
--- /dev/null
+++ b/core/tasks/apicheck.mk
@@ -0,0 +1,165 @@
+# 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.
+
+#
+# Rules for running apicheck to confirm that you haven't broken
+# api compatibility or added apis illegally.
+#
+
+# skip api check for PDK buid
+ifeq (,$(filter true, $(WITHOUT_CHECK_API) $(TARGET_BUILD_PDK)))
+
+.PHONY: checkapi
+
+# Run the checkapi rules by default.
+droidcore: checkapi
+
+last_released_sdk_version := $(lastword $(call numerically_sort, \
+ $(filter-out current, \
+ $(patsubst $(SRC_API_DIR)/%.txt,%, $(wildcard $(SRC_API_DIR)/*.txt)) \
+ )\
+ ))
+
+.PHONY: check-public-api
+checkapi : check-public-api
+
+.PHONY: update-api
+
+# INTERNAL_PLATFORM_API_FILE is the one build by droiddoc.
+# Note that since INTERNAL_PLATFORM_API_FILE is the byproduct of api-stubs module,
+# (See frameworks/base/Android.mk)
+# we need to add api-stubs as additional dependency of the api check.
+
+# Check that the API we're building hasn't broken the last-released
+# SDK version.
+$(eval $(call check-api, \
+ checkpublicapi-last, \
+ $(SRC_API_DIR)/$(last_released_sdk_version).txt, \
+ $(INTERNAL_PLATFORM_API_FILE), \
+ frameworks/base/api/removed.txt, \
+ $(INTERNAL_PLATFORM_REMOVED_API_FILE), \
+ -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 \
+ -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
+ -error 16 -error 17 -error 18 , \
+ cat $(BUILD_SYSTEM)/apicheck_msg_last.txt, \
+ check-public-api, \
+ $(call doc-timestamp-for,api-stubs) \
+ ))
+
+# Check that the API we're building hasn't changed from the not-yet-released
+# SDK version.
+$(eval $(call check-api, \
+ checkpublicapi-current, \
+ frameworks/base/api/current.txt, \
+ $(INTERNAL_PLATFORM_API_FILE), \
+ frameworks/base/api/removed.txt, \
+ $(INTERNAL_PLATFORM_REMOVED_API_FILE), \
+ -error 2 -error 3 -error 4 -error 5 -error 6 \
+ -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
+ -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
+ -error 25 -error 26 -error 27, \
+ cat $(BUILD_SYSTEM)/apicheck_msg_current.txt, \
+ check-public-api, \
+ $(call doc-timestamp-for,api-stubs) \
+ ))
+
+.PHONY: update-public-api
+update-public-api: $(INTERNAL_PLATFORM_API_FILE) | $(ACP)
+ @echo Copying current.txt
+ $(hide) $(ACP) $(INTERNAL_PLATFORM_API_FILE) frameworks/base/api/current.txt
+ @echo Copying removed.txt
+ $(hide) $(ACP) $(INTERNAL_PLATFORM_REMOVED_API_FILE) frameworks/base/api/removed.txt
+
+update-api : update-public-api
+
+#####################Check System API#####################
+.PHONY: check-system-api
+checkapi : check-system-api
+
+# Check that the System API we're building hasn't broken the last-released
+# SDK version.
+$(eval $(call check-api, \
+ checksystemapi-last, \
+ $(SRC_SYSTEM_API_DIR)/$(last_released_sdk_version).txt, \
+ $(INTERNAL_PLATFORM_SYSTEM_API_FILE), \
+ frameworks/base/api/system-removed.txt, \
+ $(INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE), \
+ -hide 2 -hide 3 -hide 4 -hide 5 -hide 6 -hide 24 -hide 25 -hide 26 -hide 27 \
+ -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
+ -error 16 -error 17 -error 18 , \
+ cat $(BUILD_SYSTEM)/apicheck_msg_last.txt, \
+ check-system-api, \
+ $(call doc-timestamp-for,system-api-stubs) \
+ ))
+
+# Check that the System API we're building hasn't changed from the not-yet-released
+# SDK version.
+$(eval $(call check-api, \
+ checksystemapi-current, \
+ frameworks/base/api/system-current.txt, \
+ $(INTERNAL_PLATFORM_SYSTEM_API_FILE), \
+ frameworks/base/api/system-removed.txt, \
+ $(INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE), \
+ -error 2 -error 3 -error 4 -error 5 -error 6 \
+ -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
+ -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
+ -error 25 -error 26 -error 27, \
+ cat $(BUILD_SYSTEM)/apicheck_msg_current.txt, \
+ check-system-api, \
+ $(call doc-timestamp-for,system-api-stubs) \
+ ))
+
+.PHONY: update-system-api
+update-api : update-system-api
+
+update-system-api: $(INTERNAL_PLATFORM_SYSTEM_API_FILE) | $(ACP)
+ @echo Copying system-current.txt
+ $(hide) $(ACP) $(INTERNAL_PLATFORM_SYSTEM_API_FILE) frameworks/base/api/system-current.txt
+ @echo Copying system-removed.txt
+ $(hide) $(ACP) $(INTERNAL_PLATFORM_SYSTEM_REMOVED_API_FILE) frameworks/base/api/system-removed.txt
+
+#####################Check Test API#####################
+.PHONY: check-test-api
+checkapi : check-test-api
+
+# Check that the Test API we're building hasn't changed from the not-yet-released
+# SDK version. Note that we don't check that we haven't broken the previous
+# SDK's API because the test API is meant only for CTS which is always
+# associated with the current release.
+$(eval $(call check-api, \
+ checktestapi-current, \
+ frameworks/base/api/test-current.txt, \
+ $(INTERNAL_PLATFORM_TEST_API_FILE), \
+ frameworks/base/api/test-removed.txt, \
+ $(INTERNAL_PLATFORM_TEST_REMOVED_API_FILE), \
+ -error 2 -error 3 -error 4 -error 5 -error 6 \
+ -error 7 -error 8 -error 9 -error 10 -error 11 -error 12 -error 13 -error 14 -error 15 \
+ -error 16 -error 17 -error 18 -error 19 -error 20 -error 21 -error 23 -error 24 \
+ -error 25 -error 26 -error 27, \
+ cat $(BUILD_SYSTEM)/apicheck_msg_current.txt, \
+ check-test-api, \
+ $(call doc-timestamp-for,test-api-stubs) \
+ ))
+
+.PHONY: update-test-api
+update-api : update-test-api
+
+update-test-api: $(INTERNAL_PLATFORM_TEST_API_FILE) | $(ACP)
+ @echo Copying test-current.txt
+ $(hide) $(ACP) $(INTERNAL_PLATFORM_TEST_API_FILE) frameworks/base/api/test-current.txt
+ @echo Copying test-removed.txt
+ $(hide) $(ACP) $(INTERNAL_PLATFORM_TEST_REMOVED_API_FILE) frameworks/base/api/test-removed.txt
+
+
+endif
diff --git a/core/tasks/boot_jars_package_check.mk b/core/tasks/boot_jars_package_check.mk
new file mode 100644
index 0000000000000000000000000000000000000000..188c267400a10a267e4526b5535b49199ad802fc
--- /dev/null
+++ b/core/tasks/boot_jars_package_check.mk
@@ -0,0 +1,46 @@
+# Copyright (C) 2014 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.
+
+#
+# Rules to check if classes in the boot jars are from the whitelisted packages.
+#
+
+ifneq ($(SKIP_BOOT_JARS_CHECK),true)
+ifneq ($(TARGET_BUILD_PDK),true)
+ifdef PRODUCT_BOOT_JARS
+
+intermediates := $(call intermediates-dir-for, PACKAGING, boot-jars-package-check,,COMMON)
+stamp := $(intermediates)/stamp
+built_boot_jars := $(foreach j, $(PRODUCT_BOOT_JARS), \
+ $(call intermediates-dir-for, JAVA_LIBRARIES, $(j),,COMMON)/classes.jar)
+script := build/core/tasks/check_boot_jars/check_boot_jars.py
+whitelist_file := build/core/tasks/check_boot_jars/package_whitelist.txt
+
+$(stamp): PRIVATE_BOOT_JARS := $(built_boot_jars)
+$(stamp): PRIVATE_SCRIPT := $(script)
+$(stamp): PRIVATE_WHITELIST := $(whitelist_file)
+$(stamp) : $(built_boot_jars) $(script) $(whitelist_file)
+ @echo "Check package name for $(PRIVATE_BOOT_JARS)"
+ $(hide) $(PRIVATE_SCRIPT) $(PRIVATE_WHITELIST) $(PRIVATE_BOOT_JARS)
+ $(hide) mkdir -p $(dir $@) && touch $@
+
+.PHONY: check-boot-jars
+check-boot-jars : $(stamp)
+
+# Run check-boot-jars by default
+droidcore : check-boot-jars
+
+endif # PRODUCT_BOOT_JARS
+endif # TARGET_BUILD_PDK not true
+endif # SKIP_BOOT_JARS_CHECK not true
diff --git a/core/tasks/build_custom_images.mk b/core/tasks/build_custom_images.mk
new file mode 100644
index 0000000000000000000000000000000000000000..8ebf89b0e736aed122ac727d4d644fa1dd358131
--- /dev/null
+++ b/core/tasks/build_custom_images.mk
@@ -0,0 +1,64 @@
+#
+# 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.
+#
+
+# Build additional images requested by the product makefile.
+# This script gives the ability to build multiple additional images and you can
+# configure what modules/files to include in each image.
+# 1. Define PRODUCT_CUSTOM_IMAGE_MAKEFILES in your product makefile.
+# PRODUCT_CUSTOM_IMAGE_MAKEFILES is a list of makefiles.
+# Each makefile configures an image.
+# For image configuration makefile foo/bar/xyz.mk, the built image file name
+# will be xyz.img. So make sure they won't conflict.
+# 2. In each image's configuration makefile, you can define variables:
+# - CUSTOM_IMAGE_MOUNT_POINT, the mount point, such as "oem", "odm" etc.
+# - CUSTOM_IMAGE_PARTITION_SIZE
+# - CUSTOM_IMAGE_FILE_SYSTEM_TYPE
+# - CUSTOM_IMAGE_DICT_FILE, a text file defines a dictionary accepted by
+# BuildImage() in tools/releasetools/build_image.py.
+# - CUSTOM_IMAGE_MODULES, a list of module names you want to include in
+# the image; Not only the module itself will be installed to proper path in
+# the image, you can also piggyback additional files/directories with the
+# module's LOCAL_PICKUP_FILES.
+# - CUSTOM_IMAGE_COPY_FILES, a list of ":" to be copied to the
+# image. is relativ to the root of the image.
+# - CUSTOM_IMAGE_SELINUX, set to "true" if the image supports selinux.
+# - CUSTOM_IMAGE_SUPPORT_VERITY, set to "true" if the product supports verity.
+# - CUSTOM_IMAGE_VERITY_BLOCK_DEVICE
+#
+# To build all those images, run "make custom_images".
+
+ifneq ($(filter $(MAKECMDGOALS),custom_images),)
+
+.PHONY: custom_images
+
+custom_image_parameter_variables := \
+ CUSTOM_IMAGE_MOUNT_POINT \
+ CUSTOM_IMAGE_PARTITION_SIZE \
+ CUSTOM_IMAGE_FILE_SYSTEM_TYPE \
+ CUSTOM_IMAGE_DICT_FILE \
+ CUSTOM_IMAGE_MODULES \
+ CUSTOM_IMAGE_COPY_FILES \
+ CUSTOM_IMAGE_SELINUX \
+ CUSTOM_IMAGE_SUPPORT_VERITY \
+ CUSTOM_IMAGE_VERITY_BLOCK_DEVICE \
+
+# We don't expect product makefile to inherit/override PRODUCT_CUSTOM_IMAGE_MAKEFILES,
+# so we don't put it in the _product_var_list.
+$(foreach mk, $(PRODUCT_CUSTOM_IMAGE_MAKEFILES),\
+ $(eval my_custom_imag_makefile := $(mk))\
+ $(eval include $(BUILD_SYSTEM)/tasks/tools/build_custom_image.mk))
+
+endif
diff --git a/core/tasks/check_boot_jars/check_boot_jars.py b/core/tasks/check_boot_jars/check_boot_jars.py
new file mode 100755
index 0000000000000000000000000000000000000000..5a0ec401635d77f1434959be6349173c5d27f5cc
--- /dev/null
+++ b/core/tasks/check_boot_jars/check_boot_jars.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+
+"""
+Check boot jars.
+
+Usage: check_boot_jars.py ...
+"""
+import logging
+import os.path
+import re
+import subprocess
+import sys
+
+
+# The compiled whitelist RE.
+whitelist_re = None
+
+
+def LoadWhitelist(filename):
+ """ Load and compile whitelist regular expressions from filename.
+ """
+ lines = []
+ with open(filename, 'r') as f:
+ for line in f:
+ line = line.strip()
+ if not line or line.startswith('#'):
+ continue
+ lines.append(line)
+ combined_re = r'^(%s)$' % '|'.join(lines)
+ global whitelist_re
+ try:
+ whitelist_re = re.compile(combined_re)
+ except re.error:
+ logging.exception(
+ 'Cannot compile package whitelist regular expression: %r',
+ combined_re)
+ whitelist_re = None
+ return False
+ return True
+
+
+def CheckJar(jar):
+ """Check a jar file.
+ """
+ # Get the list of files inside the jar file.
+ p = subprocess.Popen(args='jar tf %s' % jar,
+ stdout=subprocess.PIPE, shell=True)
+ stdout, _ = p.communicate()
+ if p.returncode != 0:
+ return False
+ items = stdout.split()
+ for f in items:
+ if f.endswith('.class'):
+ package_name = os.path.dirname(f)
+ package_name = package_name.replace('/', '.')
+ # Skip class without a package name
+ if package_name and not whitelist_re.match(package_name):
+ print >> sys.stderr, ('Error: %s: unknown package name of class file %s'
+ % (jar, f))
+ return False
+ return True
+
+
+def main(argv):
+ if len(argv) < 2:
+ print __doc__
+ return 1
+
+ if not LoadWhitelist(argv[0]):
+ return 1
+
+ passed = True
+ for jar in argv[1:]:
+ if not CheckJar(jar):
+ passed = False
+ if not passed:
+ return 1
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
diff --git a/core/tasks/check_boot_jars/package_whitelist.txt b/core/tasks/check_boot_jars/package_whitelist.txt
new file mode 100644
index 0000000000000000000000000000000000000000..3cb6e2800d6ec04600a0828c8ae2f8f192663ca3
--- /dev/null
+++ b/core/tasks/check_boot_jars/package_whitelist.txt
@@ -0,0 +1,229 @@
+# Boot jar package name whitelist.
+# Each line is interpreted as a regular expression.
+
+###################################################
+# core-libart.jar & core-oj.jar
+java\.awt\.font
+java\.beans
+java\.io
+java\.lang
+java\.lang\.annotation
+java\.lang\.ref
+java\.lang\.reflect
+java\.math
+java\.net
+java\.nio
+java\.nio\.file
+java\.nio\.file\.spi
+java\.nio\.file\.attribute
+java\.nio\.channels
+java\.nio\.channels\.spi
+java\.nio\.charset
+java\.nio\.charset\.spi
+java\.security
+java\.security\.acl
+java\.security\.cert
+java\.security\.interfaces
+java\.security\.spec
+java\.sql
+java\.text
+java\.text\.spi
+java\.util
+java\.util\.concurrent
+java\.util\.concurrent\.atomic
+java\.util\.concurrent\.locks
+java\.util\.function
+java\.util\.jar
+java\.util\.logging
+java\.util\.prefs
+java\.util\.regex
+java\.util\.spi
+java\.util\.stream
+java\.util\.zip
+javax\.crypto
+javax\.crypto\.interfaces
+javax\.crypto\.spec
+javax\.net
+javax\.net\.ssl
+javax\.security\.auth
+javax\.security\.auth\.callback
+javax\.security\.auth\.login
+javax\.security\.auth\.x500
+javax\.security\.cert
+javax\.sql
+javax\.xml
+javax\.xml\.datatype
+javax\.xml\.namespace
+javax\.xml\.parsers
+javax\.xml\.transform
+javax\.xml\.transform\.dom
+javax\.xml\.transform\.sax
+javax\.xml\.transform\.stream
+javax\.xml\.validation
+javax\.xml\.xpath
+org\.w3c\.dom
+org\.w3c\.dom\.ls
+org\.w3c\.dom\.traversal
+# OpenJdk internal implementation.
+sun\.misc
+sun\.util.*
+sun\.text.*
+sun\.security.*
+sun\.reflect.*
+sun\.nio.*
+sun\.net.*
+com\.sun\..*
+
+# TODO: Move these internal org.apache.harmony classes to libcore.*
+org\.apache\.harmony\.crypto\.internal
+org\.apache\.harmony\.dalvik
+org\.apache\.harmony\.dalvik\.ddmc
+org\.apache\.harmony\.luni\.internal\.util
+org\.apache\.harmony\.security
+org\.apache\.harmony\.security\.asn1
+org\.apache\.harmony\.security\.fortress
+org\.apache\.harmony\.security\.pkcs10
+org\.apache\.harmony\.security\.pkcs7
+org\.apache\.harmony\.security\.pkcs8
+org\.apache\.harmony\.security\.provider\.crypto
+org\.apache\.harmony\.security\.utils
+org\.apache\.harmony\.security\.x501
+org\.apache\.harmony\.security\.x509
+org\.apache\.harmony\.security\.x509\.tsp
+org\.apache\.harmony\.xml
+org\.apache\.harmony\.xml\.dom
+org\.apache\.harmony\.xml\.parsers
+
+org\.json
+org\.xmlpull\.v1
+org\.xmlpull\.v1\.sax2
+
+# TODO: jarjar org.kxml2.io to com.android org\.kxml2\.io
+org\.kxml2\.io
+org\.xml
+org\.xml\.sax
+org\.xml\.sax\.ext
+org\.xml\.sax\.helpers
+
+dalvik\..*
+libcore\..*
+android\..*
+com\.android\..*
+
+
+###################################################
+# core-junit.jar
+junit\.extensions
+junit\.framework
+
+
+###################################################
+# ext.jar
+# TODO: jarjar javax.sip to com.android
+javax\.sip
+javax\.sip\.address
+javax\.sip\.header
+javax\.sip\.message
+
+# TODO: jarjar org.apache.commons to com.android
+org\.apache\.commons\.codec
+org\.apache\.commons\.codec\.binary
+org\.apache\.commons\.codec\.language
+org\.apache\.commons\.codec\.net
+org\.apache\.commons\.logging
+org\.apache\.commons\.logging\.impl
+org\.apache\.http
+org\.apache\.http\.auth
+org\.apache\.http\.auth\.params
+org\.apache\.http\.client
+org\.apache\.http\.client\.entity
+org\.apache\.http\.client\.methods
+org\.apache\.http\.client\.params
+org\.apache\.http\.client\.protocol
+org\.apache\.http\.client\.utils
+org\.apache\.http\.conn
+org\.apache\.http\.conn\.params
+org\.apache\.http\.conn\.routing
+org\.apache\.http\.conn\.scheme
+org\.apache\.http\.conn\.ssl
+org\.apache\.http\.conn\.util
+org\.apache\.http\.cookie
+org\.apache\.http\.cookie\.params
+org\.apache\.http\.entity
+org\.apache\.http\.impl
+org\.apache\.http\.impl\.auth
+org\.apache\.http\.impl\.client
+org\.apache\.http\.impl\.client
+org\.apache\.http\.impl\.conn
+org\.apache\.http\.impl\.conn\.tsccm
+org\.apache\.http\.impl\.cookie
+org\.apache\.http\.impl\.entity
+org\.apache\.http\.impl\.io
+org\.apache\.http\.impl\.io
+org\.apache\.http\.io
+org\.apache\.http\.message
+org\.apache\.http\.params
+org\.apache\.http\.protocol
+org\.apache\.http\.util
+
+# TODO: jarjar gov.nist to com.android
+gov\.nist\.core
+gov\.nist\.core\.net
+gov\.nist\.javax\.sip
+gov\.nist\.javax\.sip\.address
+gov\.nist\.javax\.sip\.clientauthutils
+gov\.nist\.javax\.sip\.header
+gov\.nist\.javax\.sip\.header\.extensions
+gov\.nist\.javax\.sip\.header\.ims
+gov\.nist\.javax\.sip\.message
+gov\.nist\.javax\.sip\.parser
+gov\.nist\.javax\.sip\.parser\.extensions
+gov\.nist\.javax\.sip\.parser\.ims
+gov\.nist\.javax\.sip\.stack
+
+org\.ccil\.cowan\.tagsoup
+org\.ccil\.cowan\.tagsoup\.jaxp
+
+###################################################
+# framework.jar
+javax\.microedition\.khronos\.opengles
+javax\.microedition\.khronos\.egl
+
+android
+
+
+###################################################
+# telephony-common.jar
+com\.google\..*
+
+
+###################################################
+# apache-xml.jar
+org\.apache\.xml\.res
+org\.apache\.xml\.utils
+org\.apache\.xml\.utils\.res
+org\.apache\.xml\.dtm
+org\.apache\.xml\.dtm\.ref
+org\.apache\.xml\.dtm\.ref\.dom2dtm
+org\.apache\.xml\.dtm\.ref\.sax2dtm
+org\.apache\.xml\.serializer
+org\.apache\.xml\.serializer\.utils
+org\.apache\.xml\.serializer\.dom3
+org\.apache\.xpath
+org\.apache\.xpath\.operations
+org\.apache\.xpath\.domapi
+org\.apache\.xpath\.functions
+org\.apache\.xpath\.res
+org\.apache\.xpath\.axes
+org\.apache\.xpath\.objects
+org\.apache\.xpath\.patterns
+org\.apache\.xpath\.jaxp
+org\.apache\.xpath\.compiler
+org\.apache\.xalan
+org\.apache\.xalan\.res
+org\.apache\.xalan\.templates
+org\.apache\.xalan\.serialize
+org\.apache\.xalan\.extensions
+org\.apache\.xalan\.processor
+org\.apache\.xalan\.transformer
+org\.apache\.xalan\.xslt
diff --git a/core/tasks/collect_gpl_sources.mk b/core/tasks/collect_gpl_sources.mk
new file mode 100644
index 0000000000000000000000000000000000000000..30ba62b6091b06de14123fb5f1cd9176b0b27933
--- /dev/null
+++ b/core/tasks/collect_gpl_sources.mk
@@ -0,0 +1,31 @@
+# Copyright (C) 2011 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.
+
+gpl_source_tgz := $(call intermediates-dir-for,PACKAGING,gpl_source,HOST,COMMON)/gpl_source.tgz
+
+# FORCE since we can't know whether any of the sources changed
+$(gpl_source_tgz): PRIVATE_PATHS := $(sort $(patsubst %/, %, $(dir $(ALL_GPL_MODULE_LICENSE_FILES))))
+$(gpl_source_tgz) : $(ALL_GPL_MODULE_LICENSE_FILES) FORCE
+ @echo Package gpl sources: $@
+ @rm -rf $(dir $@) && mkdir -p $(dir $@)
+ $(hide) tar cfz $@ --exclude ".git*" $(PRIVATE_PATHS)
+
+
+.PHONY: gpl_source_tgz
+gpl_source_tgz : $(gpl_source_tgz)
+
+# Dist the tgz only if we are doing a full build
+ifeq (,$(TARGET_BUILD_APPS))
+$(call dist-for-goals, droidcore, $(gpl_source_tgz))
+endif
diff --git a/core/tasks/cts.mk b/core/tasks/cts.mk
new file mode 100644
index 0000000000000000000000000000000000000000..fdd9591768ebcd5fbc96c1a0a05b27d22973aac7
--- /dev/null
+++ b/core/tasks/cts.mk
@@ -0,0 +1,27 @@
+# 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.
+
+test_suite_name := cts
+test_suite_tradefed := cts-tradefed
+test_suite_dynamic_config := cts/tools/cts-tradefed/DynamicConfig.xml
+test_suite_readme := cts/tools/cts-tradefed/README
+
+include $(BUILD_SYSTEM)/tasks/tools/compatibility.mk
+
+.PHONY: cts
+cts: $(compatibility_zip)
+$(call dist-for-goals, cts, $(compatibility_zip))
+
+.PHONY: cts_v2
+cts_v2: cts
diff --git a/core/tasks/deps_licenses.mk b/core/tasks/deps_licenses.mk
new file mode 100644
index 0000000000000000000000000000000000000000..bb20fa042eaa54925b32353d33464b2acd799ae6
--- /dev/null
+++ b/core/tasks/deps_licenses.mk
@@ -0,0 +1,59 @@
+#
+# 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.
+#
+
+# Print modules and their transitive dependencies with license files.
+# To invoke, run "make deps-license PROJ_PATH= DEP_PATH=".
+# PROJ_PATH restricts the paths of the source modules; DEP_PATH restricts the paths of the dependency modules.
+# Both can be makefile patterns supported by makefile function $(filter).
+# Example: "make deps-license packages/app/% external/%" prints all modules in packages/app/ with their dpendencies in external/.
+# The printout lines look like " :: :: ".
+
+ifneq (,$(filter deps-license,$(MAKECMDGOALS)))
+ifndef PROJ_PATH
+$(error To "make deps-license" you must specify PROJ_PATH and DEP_PATH.)
+endif
+ifndef DEP_PATH
+$(error To "make deps-license" you must specify PROJ_PATH and DEP_PATH.)
+endif
+
+# Expand a module's dependencies transitively.
+# $(1): the variable name to hold the result.
+# $(2): the initial module name.
+define get-module-all-dependencies
+$(eval _gmad_new := $(sort $(filter-out $($(1)),\
+ $(foreach m,$(2),$(ALL_DEPS.$(m).ALL_DEPS)))))\
+$(if $(_gmad_new),$(eval $(1) += $(_gmad_new))\
+ $(call get-module-all-dependencies,$(1),$(_gmad_new)))
+endef
+
+define print-deps-license
+$(foreach m, $(ALL_DEPS.MODULES),\
+ $(eval m_p := $(sort $(ALL_MODULES.$(m).PATH) $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).PATH)))\
+ $(if $(filter $(PROJ_PATH),$(m_p)),\
+ $(eval deps :=)\
+ $(eval $(call get-module-all-dependencies,deps,$(m)))\
+ $(info $(m) :: $(m_p) :: $(ALL_DEPS.$(m).LICENSE))\
+ $(foreach d,$(deps),\
+ $(eval d_p := $(sort $(ALL_MODULES.$(d).PATH) $(ALL_MODULES.$(d)$(TARGET_2ND_ARCH_MODULE_SUFFIX).PATH)))\
+ $(if $(filter $(DEP_PATH),$(d_p)),\
+ $(info $(space)$(space)$(space)$(space)$(d) :: $(d_p) :: $(ALL_DEPS.$(d).LICENSE))))))
+endef
+
+.PHONY: deps-license
+deps-license:
+ @$(call print-deps-license)
+
+endif
diff --git a/core/tasks/ide.mk b/core/tasks/ide.mk
new file mode 100644
index 0000000000000000000000000000000000000000..e557e6016fbc02cf58feb8f917208681a4ac3583
--- /dev/null
+++ b/core/tasks/ide.mk
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2010 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.
+#
+
+define filter-ide-goals
+$(strip $(filter $(1)-%,$(MAKECMDGOALS)))
+endef
+
+define filter-ide-modules
+$(strip $(subst -,$(space),$(patsubst $(1)-%,%,$(2))))
+endef
+
+# eclipse
+eclipse_project_goals := $(call filter-ide-goals,ECLIPSE)
+ifdef eclipse_project_goals
+ ifneq ($(words $(eclipse_project_goals)),1)
+ $(error Only one ECLIPSE- goal may be specified: $(eclipse_project_goals))
+ endif
+ eclipse_project_modules := $(call filter-ide-modules,ECLIPSE,$(eclipse_project_goals))
+
+ ifneq ($(filter lunch,$(eclipse_project_modules)),)
+ eclipse_project_modules := $(filter-out lunch,$(eclipse_project_modules))
+ installed_modules := $(foreach m,$(ALL_DEFAULT_INSTALLED_MODULES),\
+ $(INSTALLABLE_FILES.$(m).MODULE))
+ java_modules := $(foreach m,$(installed_modules),\
+ $(if $(filter JAVA_LIBRARIES APPS,$(ALL_MODULES.$(m).CLASS)),$(m),))
+ eclipse_project_modules := $(sort $(eclipse_project_modules) $(java_modules))
+ endif
+
+ source_paths := $(foreach m,$(eclipse_project_modules),$(ALL_MODULES.$(m).PATH)) \
+ $(foreach m,$(eclipse_project_modules),$(ALL_MODULES.$(m).INTERMEDIATE_SOURCE_DIR)) \
+ $(INTERNAL_SDK_SOURCE_DIRS)
+ source_paths := $(sort $(source_paths))
+
+.classpath: PRIVATE_MODULES := $(eclipse_project_modules)
+.classpath: PRIVATE_DIRS := $(source_paths)
+
+# the mess below with ./src tries to guess whether the src
+$(eclipse_project_goals): .classpath
+.classpath: FORCE
+ $(hide) echo Generating .classpath for eclipse
+ $(hide) echo '' > $@
+ $(hide) for p in $(PRIVATE_DIRS) ; do \
+ echo -n ' ' >> $@ ; \
+ done
+ $(hide) echo ' ' >> $@
+endif
+
diff --git a/core/tasks/module-info.mk b/core/tasks/module-info.mk
new file mode 100644
index 0000000000000000000000000000000000000000..e9b2ac7a93f641b5bc46f1d30b68d42031b9f120
--- /dev/null
+++ b/core/tasks/module-info.mk
@@ -0,0 +1,24 @@
+# Print a list of the modules that could be built
+
+MODULE_INFO_JSON := $(PRODUCT_OUT)/module-info.json
+
+$(MODULE_INFO_JSON):
+ @echo Generating $@
+ $(hide) echo -ne '{\n ' > $@
+ $(hide) echo -ne $(foreach m, $(sort $(ALL_MODULES)), \
+ ' "$(m)": {' \
+ '"class": [$(foreach w,$(sort $(ALL_MODULES.$(m).CLASS)),"$(w)", )], ' \
+ '"path": [$(foreach w,$(sort $(ALL_MODULES.$(m).PATH)),"$(w)", )], ' \
+ '"tags": [$(foreach w,$(sort $(ALL_MODULES.$(m).TAGS)),"$(w)", )], ' \
+ '"installed": [$(foreach w,$(sort $(ALL_MODULES.$(m).INSTALLED)),"$(w)", )], ' \
+ '},\n' \
+ ) | sed -e 's/, *\]/]/g' -e 's/, *\}/ }/g' -e '$$s/,$$//' >> $@
+ $(hide) echo '}' >> $@
+
+
+# If ONE_SHOT_MAKEFILE is set, our view of the world is smaller, so don't
+# rewrite the file in that came.
+ifndef ONE_SHOT_MAKEFILE
+files: $(MODULE_INFO_JSON)
+endif
+
diff --git a/core/tasks/oem_image.mk b/core/tasks/oem_image.mk
new file mode 100644
index 0000000000000000000000000000000000000000..32d56a76e82dfc56086128be5926b444e659cdb2
--- /dev/null
+++ b/core/tasks/oem_image.mk
@@ -0,0 +1,46 @@
+#
+# Copyright (C) 2014 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.
+#
+
+# We build oem.img only if it's asked for.
+ifneq ($(filter $(MAKECMDGOALS),oem_image),)
+ifndef BOARD_OEMIMAGE_PARTITION_SIZE
+$(error BOARD_OEMIMAGE_PARTITION_SIZE is not set.)
+endif
+
+INTERNAL_OEMIMAGE_FILES := \
+ $(filter $(TARGET_OUT_OEM)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
+
+oemimage_intermediates := \
+ $(call intermediates-dir-for,PACKAGING,oem)
+BUILT_OEMIMAGE_TARGET := $(PRODUCT_OUT)/oem.img
+# We just build this directly to the install location.
+INSTALLED_OEMIMAGE_TARGET := $(BUILT_OEMIMAGE_TARGET)
+
+$(INSTALLED_OEMIMAGE_TARGET) : $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_OEMIMAGE_FILES)
+ $(call pretty,"Target oem fs image: $@")
+ @mkdir -p $(TARGET_OUT_OEM)
+ @mkdir -p $(oemimage_intermediates) && rm -rf $(oemimage_intermediates)/oem_image_info.txt
+ $(call generate-userimage-prop-dictionary, $(oemimage_intermediates)/oem_image_info.txt, skip_fsck=true)
+ $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
+ ./build/tools/releasetools/build_image.py \
+ $(TARGET_OUT_OEM) $(oemimage_intermediates)/oem_image_info.txt $@ $(TARGET_OUT)
+ $(hide) $(call assert-max-image-size,$@,$(BOARD_OEMIMAGE_PARTITION_SIZE))
+
+.PHONY: oem_image
+oem_image : $(INSTALLED_OEMIMAGE_TARGET)
+$(call dist-for-goals, oem_image, $(INSTALLED_OEMIMAGE_TARGET))
+
+endif # oem_image in $(MAKECMDGOALS)
diff --git a/core/tasks/old-cts.mk b/core/tasks/old-cts.mk
new file mode 100644
index 0000000000000000000000000000000000000000..70246387b87ad921f79cb639e83ac6d30e9cc5cb
--- /dev/null
+++ b/core/tasks/old-cts.mk
@@ -0,0 +1,399 @@
+# 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.
+
+cts_dir := $(HOST_OUT)/old-cts
+cts_tools_src_dir := cts/tools
+
+cts_name := old-android-cts
+
+JUNIT_HOST_JAR := $(HOST_OUT_JAVA_LIBRARIES)/junit.jar
+HOSTTESTLIB_JAR := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar
+TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar
+CTS_TF_JAR := $(HOST_OUT_JAVA_LIBRARIES)/old-cts-tradefed.jar
+CTS_TF_EXEC_PATH ?= $(HOST_OUT_EXECUTABLES)/old-cts-tradefed
+CTS_TF_README_PATH := $(cts_tools_src_dir)/tradefed-host/README
+
+VMTESTSTF_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,vm-tests-tf,HOST)
+VMTESTSTF_JAR := $(VMTESTSTF_INTERMEDIATES)/android.core.vm-tests-tf.jar
+
+# The list of test packages that core-tests (libcore/Android.mk)
+# is split into.
+CTS_CORE_CASE_LIST := \
+ android.core.tests.libcore.package.dalvik \
+ android.core.tests.libcore.package.com \
+ android.core.tests.libcore.package.conscrypt \
+ android.core.tests.libcore.package.sun \
+ android.core.tests.libcore.package.tests \
+ android.core.tests.libcore.package.org \
+ android.core.tests.libcore.package.libcore \
+ android.core.tests.libcore.package.jsr166 \
+ android.core.tests.libcore.package.harmony_annotation \
+ android.core.tests.libcore.package.harmony_java_io \
+ android.core.tests.libcore.package.harmony_java_lang \
+ android.core.tests.libcore.package.harmony_java_math \
+ android.core.tests.libcore.package.harmony_java_net \
+ android.core.tests.libcore.package.harmony_java_nio \
+ android.core.tests.libcore.package.harmony_java_text \
+ android.core.tests.libcore.package.harmony_java_util \
+ android.core.tests.libcore.package.harmony_javax_security \
+ android.core.tests.libcore.package.okhttp \
+ android.core.tests.runner
+
+# Additional CTS packages for code under libcore
+CTS_CORE_CASE_LIST += \
+ android.core.tests.libcore.package.tzdata
+
+# The list of test packages that apache-harmony-tests (external/apache-harmony/Android.mk)
+# is split into.
+CTS_CORE_CASE_LIST += \
+ android.core.tests.libcore.package.harmony_beans \
+ android.core.tests.libcore.package.harmony_logging \
+ android.core.tests.libcore.package.harmony_prefs \
+ android.core.tests.libcore.package.harmony_sql
+
+
+CTS_TEST_JAR_LIST := \
+ cts-junit \
+ CtsJdwp \
+ cts-testng \
+ CtsLibcoreOj
+
+# Depend on the full package paths rather than the phony targets to avoid
+# rebuilding the packages every time.
+CTS_CORE_CASES := $(foreach pkg,$(CTS_CORE_CASE_LIST),$(call intermediates-dir-for,APPS,$(pkg))/package.apk)
+CTS_TEST_JAR_FILES := $(foreach c,$(CTS_TEST_JAR_LIST),$(call intermediates-dir-for,JAVA_LIBRARIES,$(c))/javalib.jar)
+
+-include cts/OldCtsTestCaseList.mk
+
+# A module may have mutliple installed files (e.g. split apks)
+CTS_CASE_LIST_APKS :=
+$(foreach m, $(CTS_TEST_CASE_LIST),\
+ $(foreach fp, $(ALL_MODULES.$(m).BUILT_INSTALLED),\
+ $(eval pair := $(subst :,$(space),$(fp)))\
+ $(eval CTS_CASE_LIST_APKS += $(CTS_TESTCASES_OUT)/$(notdir $(word 2,$(pair))))))\
+$(foreach m, $(CTS_CORE_CASE_LIST),\
+ $(foreach fp, $(ALL_MODULES.$(m).BUILT_INSTALLED),\
+ $(eval pair := $(subst :,$(space),$(fp)))\
+ $(eval built := $(word 1,$(pair)))\
+ $(eval installed := $(CTS_TESTCASES_OUT)/$(notdir $(word 2,$(pair))))\
+ $(eval $(call copy-one-file, $(built), $(installed)))\
+ $(eval CTS_CASE_LIST_APKS += $(installed))))
+
+CTS_CASE_LIST_JARS :=
+$(foreach m, $(CTS_TEST_JAR_LIST),\
+ $(eval CTS_CASE_LIST_JARS += $(CTS_TESTCASES_OUT)/$(m).jar))
+
+CTS_SHARED_LIBS :=
+
+DEFAULT_TEST_PLAN := $(cts_dir)/$(cts_name)/resource/plans
+$(cts_dir)/all_cts_files_stamp: $(CTS_CORE_CASES) $(CTS_TEST_JAR_FILES) $(CTS_TEST_CASES) $(CTS_CASE_LIST_APKS) $(CTS_CASE_LIST_JARS) $(JUNIT_HOST_JAR) $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(VMTESTSTF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(CTS_TF_README_PATH) $(ADDITIONAL_TF_JARS) $(ACP) $(CTS_SHARED_LIBS)
+
+# Make necessary directory for CTS
+ $(hide) mkdir -p $(TMP_DIR)
+ $(hide) mkdir -p $(PRIVATE_DIR)/docs
+ $(hide) mkdir -p $(PRIVATE_DIR)/tools
+ $(hide) mkdir -p $(PRIVATE_DIR)/repository/testcases
+ $(hide) mkdir -p $(PRIVATE_DIR)/repository/plans
+# Copy executable and JARs to CTS directory
+ $(hide) $(ACP) -fp $(VMTESTSTF_JAR) $(CTS_TESTCASES_OUT)
+ $(hide) $(ACP) -fp $(HOSTTESTLIB_JAR) $(CTS_HOST_LIBRARY_JARS) $(TF_JAR) $(CTS_TF_JAR) $(CTS_TF_EXEC_PATH) $(ADDITIONAL_TF_JARS) $(CTS_TF_README_PATH) $(PRIVATE_DIR)/tools
+ $(hide) $(call copy-files-with-structure, $(CTS_SHARED_LIBS),$(HOST_OUT)/,$(PRIVATE_DIR))
+ $(hide) touch $@
+
+# Generate the test descriptions for the core-tests
+# Parameters:
+# $1 : The output file where the description should be written (without the '.xml' extension)
+# $2 : The AndroidManifest.xml corresponding to the test package
+# $3 : The jar file name on PRIVATE_CLASSPATH containing junit tests to search for
+# $4 : The package prefix of classes to include, possible empty
+# $5 : The architecture of the current build
+# $6 : The directory containing vogar expectations files
+# $7 : The Android.mk corresponding to the test package (required for host-side tests only)
+define generate-core-test-description
+@echo "Generate core-test description ("$(notdir $(1))")"
+$(hide) java -Xmx256M \
+ -Xbootclasspath/a:$(PRIVATE_CLASSPATH):$(JUNIT_HOST_JAR) \
+ -classpath $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar:$(HOST_JDK_TOOLS_JAR) \
+ $(PRIVATE_PARAMS) CollectAllTests $(1) $(2) $(3) "$(4)" $(5) $(6) $(7)
+endef
+
+OJ_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)
+CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)
+CONSCRYPT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,conscrypt,,COMMON)
+BOUNCYCASTLE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,bouncycastle,,COMMON)
+APACHEXML_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-xml,,COMMON)
+OKHTTP_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp-nojarjar,,COMMON)
+OKHTTPTESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp-tests-nojarjar,,COMMON)
+OKHTTP_REPACKAGED_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,okhttp,,COMMON)
+APACHEHARMONYTESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,apache-harmony-tests,,COMMON)
+SQLITEJDBC_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,sqlite-jdbc,,COMMON)
+JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
+CORETESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-tests,,COMMON)
+JSR166TESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,jsr166-tests,,COMMON)
+CONSCRYPTTESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,conscrypt-tests,,COMMON)
+TZDATAUPDATETESTS_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,tzdata_update-tests,,COMMON)
+
+GEN_CLASSPATH := \
+ $(OJ_INTERMEDIATES)/classes.jar:$(CORE_INTERMEDIATES)/classes.jar:$(CONSCRYPT_INTERMEDIATES)/classes.jar:$(BOUNCYCASTLE_INTERMEDIATES)/classes.jar:$(APACHEXML_INTERMEDIATES)/classes.jar:$(APACHEHARMONYTESTS_INTERMEDIATES)/classes.jar:$(OKHTTP_INTERMEDIATES)/classes.jar:$(OKHTTPTESTS_INTERMEDIATES)/classes.jar:$(OKHTTP_REPACKAGED_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(SQLITEJDBC_INTERMEDIATES)/javalib.jar:$(CORETESTS_INTERMEDIATES)/javalib.jar:$(JSR166TESTS_INTERMEDIATES)/javalib.jar:$(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar:$(TZDATAUPDATETESTS_INTERMEDIATES)/javalib.jar
+
+CTS_CORE_XMLS := \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.conscrypt.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.jsr166.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_annotation.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_io.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_lang.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_math.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_net.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_nio.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_text.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_util.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_javax_security.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_beans.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_logging.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_prefs.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_sql.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.okhttp.xml \
+ $(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tzdata.xml \
+
+$(CTS_CORE_XMLS): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
+# Why does this depend on javalib.jar instead of classes.jar? Because
+# even though the tool will operate on the classes.jar files, the
+# build system requires that dependencies use javalib.jar. If
+# javalib.jar is up-to-date, then classes.jar is as well. Depending
+# on classes.jar will build the files incorrectly.
+CTS_CORE_XMLS_DEPS := $(CTS_CORE_CASES) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(JUNIT_HOST_JAR) $(CORE_INTERMEDIATES)/javalib.jar $(BOUNCYCASTLE_INTERMEDIATES)/javalib.jar $(APACHEXML_INTERMEDIATES)/javalib.jar $(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar $(OKHTTP_INTERMEDIATES)/javalib.jar $(OKHTTPTESTS_INTERMEDIATES)/javalib.jar $(OKHTTP_REPACKAGED_INTERMEDIATES)/javalib.jar $(SQLITEJDBC_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(CORETESTS_INTERMEDIATES)/javalib.jar $(JSR166TESTS_INTERMEDIATES)/javalib.jar $(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar $(TZDATAUPDATETESTS_INTERMEDIATES)/javalib.jar build/core/tasks/cts.mk | $(ACP)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.dalvik,\
+ cts/tests/core/libcore/dalvik/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,dalvik,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.com,\
+ cts/tests/core/libcore/com/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,com,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.conscrypt.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.conscrypt,\
+ cts/tests/core/libcore/conscrypt/AndroidManifest.xml,\
+ $(CONSCRYPTTESTS_INTERMEDIATES)/javalib.jar,,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.sun,\
+ cts/tests/core/libcore/sun/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,sun,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tests,\
+ cts/tests/core/libcore/tests/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,tests,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.org,\
+ cts/tests/core/libcore/org/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,\
+ org.w3c.domts:\
+ org.apache.harmony.security.tests:\
+ org.apache.harmony.nio.tests:\
+ org.apache.harmony.crypto.tests:\
+ org.apache.harmony.regex.tests:\
+ org.apache.harmony.luni.tests:\
+ org.apache.harmony.tests.internal.net.www.protocol:\
+ org.apache.harmony.tests.javax.net:\
+ org.apache.harmony.tests.javax.xml:\
+ org.json,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.libcore,\
+ cts/tests/core/libcore/libcore/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,libcore,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.jsr166.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.jsr166,\
+ cts/tests/core/libcore/jsr166/AndroidManifest.xml,\
+ $(JSR166TESTS_INTERMEDIATES)/javalib.jar,jsr166,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_annotation.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_annotation,\
+ cts/tests/core/libcore/harmony_annotation/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.annotation.tests,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_io.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_io,\
+ cts/tests/core/libcore/harmony_java_io/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.io,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_lang.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_lang,\
+ cts/tests/core/libcore/harmony_java_lang/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.lang,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_math.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_math,\
+ cts/tests/core/libcore/harmony_java_math/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.math,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_net.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_net,\
+ cts/tests/core/libcore/harmony_java_net/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.net,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_nio.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_nio,\
+ cts/tests/core/libcore/harmony_java_nio/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.nio,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_text.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_text,\
+ cts/tests/core/libcore/harmony_java_text/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.text,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_util.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_java_util,\
+ cts/tests/core/libcore/harmony_java_util/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.java.util,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_javax_security.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_javax_security,\
+ cts/tests/core/libcore/harmony_javax_security/AndroidManifest.xml,\
+ $(CORETESTS_INTERMEDIATES)/javalib.jar,org.apache.harmony.tests.javax.security,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_beans.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_beans,\
+ cts/tests/core/libcore/harmony_beans/AndroidManifest.xml,\
+ $(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.beans,\
+ $(TARGET_ARCH),libcore/expectations external/apache-harmony/Android.mk)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_logging.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_logging,\
+ cts/tests/core/libcore/harmony_logging/AndroidManifest.xml,\
+ $(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.logging,\
+ $(TARGET_ARCH),libcore/expectations external/apache-harmony/Android.mk)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_prefs.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_prefs,\
+ cts/tests/core/libcore/harmony_prefs/AndroidManifest.xml,\
+ $(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.prefs,\
+ $(TARGET_ARCH),libcore/expectations external/apache-harmony/Android.mk)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_sql.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.harmony_sql,\
+ cts/tests/core/libcore/harmony_sql/AndroidManifest.xml,\
+ $(APACHEHARMONYTESTS_INTERMEDIATES)/javalib.jar,com.android.org.apache.harmony.sql,\
+ $(TARGET_ARCH),libcore/expectations external/apache-harmony/Android.mk)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.okhttp.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.okhttp,\
+ cts/tests/core/libcore/okhttp/AndroidManifest.xml,\
+ $(OKHTTPTESTS_INTERMEDIATES)/javalib.jar,,\
+ $(TARGET_ARCH),libcore/expectations)
+
+$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tzdata.xml: $(CTS_CORE_XMLS_DEPS)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.tests.libcore.package.tzdata,\
+ cts/tests/core/libcore/tzdata/AndroidManifest.xml,\
+ $(TZDATAUPDATETESTS_INTERMEDIATES)/javalib.jar,,\
+ $(TARGET_ARCH),libcore/expectations)
+
+# ----- Generate the test descriptions for the vm-tests-tf -----
+#
+CORE_VM_TEST_TF_DESC := $(CTS_TESTCASES_OUT)/android.core.vm-tests-tf.xml
+
+# core tests only needed to get hold of junit-framework-classes
+OJ_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-oj,,COMMON)
+CORE_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-libart,,COMMON)
+JUNIT_INTERMEDIATES :=$(call intermediates-dir-for,JAVA_LIBRARIES,core-junit,,COMMON)
+
+GEN_CLASSPATH := $(OJ_INTERMEDIATES)/classes.jar:$(CORE_INTERMEDIATES)/classes.jar:$(JUNIT_INTERMEDIATES)/classes.jar:$(VMTESTSTF_JAR):$(TF_JAR)
+
+$(CORE_VM_TEST_TF_DESC): PRIVATE_CLASSPATH:=$(GEN_CLASSPATH)
+# Please see big comment above on why this line depends on javalib.jar instead of classes.jar
+$(CORE_VM_TEST_TF_DESC): $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(JUNIT_HOST_JAR) $(CORE_INTERMEDIATES)/javalib.jar $(JUNIT_INTERMEDIATES)/javalib.jar $(VMTESTSTF_JAR) | $(ACP)
+ $(hide) mkdir -p $(CTS_TESTCASES_OUT)
+ $(call generate-core-test-description,$(CTS_TESTCASES_OUT)/android.core.vm-tests-tf,\
+ cts/tests/vm-tests-tf/AndroidManifest.xml,\
+ $(VMTESTSTF_JAR),"",\
+ $(TARGET_ARCH),\
+ libcore/expectations,\
+ cts/tools/vm-tests-tf/Android.mk)
+
+# Generate the default test plan for User.
+# Usage: buildCts.py
+
+$(DEFAULT_TEST_PLAN): $(cts_dir)/all_cts_files_stamp $(cts_tools_src_dir)/utils/buildCts.py $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar $(CTS_CORE_XMLS) $(CTS_TEST_XMLS) $(CORE_VM_TEST_TF_DESC)
+ $(hide) $(cts_tools_src_dir)/utils/buildCts.py cts/tests/tests/ $(PRIVATE_DIR) $(TMP_DIR) \
+ $(TOP) $(HOST_OUT_JAVA_LIBRARIES)/descGen.jar
+ $(hide) mkdir -p $(dir $@) && touch $@
+
+# Package CTS and clean up.
+#
+# TODO:
+# Pack cts.bat into the same zip file as well. See http://buganizer/issue?id=1656821 for more details
+INTERNAL_CTS_TARGET := $(cts_dir)/$(cts_name).zip
+$(INTERNAL_CTS_TARGET): PRIVATE_NAME := $(cts_name)
+$(INTERNAL_CTS_TARGET): PRIVATE_CTS_DIR := $(cts_dir)
+$(INTERNAL_CTS_TARGET): PRIVATE_DIR := $(cts_dir)/$(cts_name)
+$(INTERNAL_CTS_TARGET): TMP_DIR := $(cts_dir)/temp
+$(INTERNAL_CTS_TARGET): $(cts_dir)/all_cts_files_stamp $(DEFAULT_TEST_PLAN)
+ $(hide) echo "Package CTS: $@"
+ $(hide) cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME)
+
+.PHONY: old-cts
+old-cts: $(INTERNAL_CTS_TARGET) adb
+$(call dist-for-goals,old-cts,$(INTERNAL_CTS_TARGET))
diff --git a/core/tasks/sdk-addon.mk b/core/tasks/sdk-addon.mk
new file mode 100644
index 0000000000000000000000000000000000000000..362b229351440944a8427cea966c392847ec32c7
--- /dev/null
+++ b/core/tasks/sdk-addon.mk
@@ -0,0 +1,142 @@
+# Copyright (C) 2009 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 they didn't define PRODUCT_SDK_ADDON_NAME, then we won't define
+# any of these rules.
+addon_name := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_NAME))
+ifneq ($(addon_name),)
+
+addon_dir_leaf := $(addon_name)-$(FILE_NAME_TAG)-$(INTERNAL_SDK_HOST_OS_NAME)
+addon_dir_img := $(addon_dir_leaf)-img
+intermediates := $(HOST_OUT_INTERMEDIATES)/SDK_ADDON/$(addon_name)_intermediates
+full_target := $(HOST_OUT_SDK_ADDON)/$(addon_dir_leaf).zip
+full_target_img := $(HOST_OUT_SDK_ADDON)/$(addon_dir_img).zip
+staging := $(intermediates)
+
+sdk_addon_deps :=
+files_to_copy :=
+
+define stub-addon-jar-file
+$(subst .jar,_stub-addon.jar,$(1))
+endef
+
+define stub-addon-jar
+$(call stub-addon-jar-file,$(1)): $(1) | mkstubs
+ $(info Stubbing addon jar using $(PRODUCT_SDK_ADDON_STUB_DEFS))
+ $(hide) java -jar $(call module-installed-files,mkstubs) $(if $(hide),,--v) \
+ "$$<" "$$@" @$(PRODUCT_SDK_ADDON_STUB_DEFS)
+endef
+
+# Files that are built and then copied into the sdk-addon
+ifneq ($(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_MODULES)),)
+$(foreach cf,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_MODULES), \
+ $(eval _src := $(call module-stubs-files,$(call word-colon,1,$(cf)))) \
+ $(eval $(call stub-addon-jar,$(_src))) \
+ $(eval _src := $(call stub-addon-jar-file,$(_src))) \
+ $(if $(_src),,$(eval $(error Unknown or unlinkable module: $(call word-colon,1,$(cf)). Requested by $(INTERNAL_PRODUCT)))) \
+ $(eval _dest := $(call word-colon,2,$(cf))) \
+ $(eval files_to_copy += $(addon_dir_leaf):$(_src):$(_dest)) \
+ )
+endif
+
+# Files that are copied directly into the sdk-addon
+ifneq ($(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_FILES)),)
+$(foreach cf,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_COPY_FILES), \
+ $(eval _src := $(call word-colon,1,$(cf))) \
+ $(eval _dest := $(call word-colon,2,$(cf))) \
+ $(if $(findstring images/,$(_dest)), $(eval _root := $(addon_dir_img)), $(eval _root := $(addon_dir_leaf))) \
+ $(eval files_to_copy += $(_root):$(_src):$(_dest)) \
+ )
+endif
+
+# Files copied in the system-image directory
+files_to_copy += \
+ $(addon_dir_img):$(BUILT_SYSTEMIMAGE):images/$(TARGET_CPU_ABI)/system.img \
+ $(addon_dir_img):$(BUILT_USERDATAIMAGE_TARGET):images/$(TARGET_CPU_ABI)/userdata.img \
+ $(addon_dir_img):$(BUILT_RAMDISK_TARGET):images/$(TARGET_CPU_ABI)/ramdisk.img \
+ $(addon_dir_img):$(PRODUCT_OUT)/system/build.prop:images/$(TARGET_CPU_ABI)/build.prop \
+ $(addon_dir_img):$(target_notice_file_txt):images/$(TARGET_CPU_ABI)/NOTICE.txt \
+ $(addon_dir_img):$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP):images/source.properties
+
+# Generate rules to copy the requested files
+$(foreach cf,$(files_to_copy), \
+ $(eval _root := $(call word-colon,1,$(cf))) \
+ $(eval _src := $(call word-colon,2,$(cf))) \
+ $(eval _dest := $(call append-path,$(call append-path,$(staging),$(_root)),$(call word-colon,3,$(cf)))) \
+ $(eval $(call copy-one-file,$(_src),$(_dest))) \
+ $(eval sdk_addon_deps += $(_dest)) \
+ )
+
+# The system-image source.properties is a template that we directly expand in-place
+addon_img_source_prop := $(call append-path,$(staging),$(addon_dir_img))/images/$(TARGET_CPU_ABI)/source.properties
+sdk_addon_deps += $(addon_img_source_prop)
+
+$(addon_img_source_prop): $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_SYS_IMG_SOURCE_PROP)
+ @echo Generate $@
+ $(hide) mkdir -p $(dir $@)
+ $(hide) sed \
+ -e 's/$${PLATFORM_VERSION}/$(PLATFORM_VERSION)/' \
+ -e 's/$${PLATFORM_SDK_VERSION}/$(PLATFORM_SDK_VERSION)/' \
+ -e 's/$${PLATFORM_VERSION_CODENAME}/$(subst REL,,$(PLATFORM_VERSION_CODENAME))/' \
+ -e 's/$${TARGET_ARCH}/$(TARGET_ARCH)/' \
+ -e 's/$${TARGET_CPU_ABI}/$(TARGET_CPU_ABI)/' \
+ $< > $@ && sed -i -e '/^AndroidVersion.CodeName=\s*$$/d' $@
+
+
+# We don't know about all of the docs files, so depend on the timestamps for
+# them, and record the directories, and the packaging rule will just copy the
+# whole thing.
+doc_modules := $(strip $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_SDK_ADDON_DOC_MODULES))
+sdk_addon_deps += $(foreach dm, $(doc_modules), $(call doc-timestamp-for, $(dm)))
+$(full_target): PRIVATE_DOCS_DIRS := $(addprefix $(OUT_DOCS)/, $(doc_modules))
+
+$(full_target): PRIVATE_STAGING_DIR := $(call append-path,$(staging),$(addon_dir_leaf))
+
+$(full_target): $(sdk_addon_deps) | $(ACP)
+ @echo Packaging SDK Addon: $@
+ $(hide) mkdir -p $(PRIVATE_STAGING_DIR)/docs
+ $(hide) for d in $(PRIVATE_DOCS_DIRS); do \
+ $(ACP) -r $$d $(PRIVATE_STAGING_DIR)/docs ;\
+ done
+ $(hide) mkdir -p $(dir $@)
+ $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rqX $$F $(notdir $(PRIVATE_STAGING_DIR)) )
+
+$(full_target_img): PRIVATE_STAGING_DIR := $(call append-path,$(staging),$(addon_dir_img))/images/$(TARGET_CPU_ABI)
+$(full_target_img): $(full_target) $(addon_img_source_prop)
+ @echo Packaging SDK Addon System-Image: $@
+ $(hide) mkdir -p $(dir $@)
+ $(hide) ( F=$$(pwd)/$@ ; cd $(PRIVATE_STAGING_DIR)/.. && zip -rqX $$F $(notdir $(PRIVATE_STAGING_DIR)) )
+
+
+.PHONY: sdk_addon
+sdk_addon: $(full_target) $(full_target_img)
+
+ifneq ($(sdk_repo_goal),)
+# If we're building the sdk_repo, keep the name of the addon zip
+# around so that development/build/tools/sdk_repo.mk can dist it
+# at the appropriate location.
+ADDON_SDK_ZIP := $(full_target)
+ADDON_SDK_IMG_ZIP := $(full_target_img)
+else
+# When not building an sdk_repo, just dist the addon zip file
+# as-is.
+$(call dist-for-goals, sdk_addon, $(full_target))
+endif
+
+else # addon_name
+ifneq ($(filter sdk_addon,$(MAKECMDGOALS)),)
+$(error Trying to build sdk_addon, but product '$(INTERNAL_PRODUCT)' does not define one)
+endif
+endif # addon_name
diff --git a/core/tasks/tools/build_custom_image.mk b/core/tasks/tools/build_custom_image.mk
new file mode 100644
index 0000000000000000000000000000000000000000..ec491fa85ee703aef67fff4ea8d811dec37fca7f
--- /dev/null
+++ b/core/tasks/tools/build_custom_image.mk
@@ -0,0 +1,117 @@
+#
+# 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.
+#
+
+
+# Define rule to build one custom image.
+# Input variables: my_custom_imag_makefile
+
+$(call clear-var-list, $(custom_image_parameter_variables))
+
+include $(my_custom_imag_makefile)
+
+my_custom_image_name := $(basename $(notdir $(my_custom_imag_makefile)))
+
+intermediates := $(call intermediates-dir-for,PACKAGING,$(my_custom_image_name))
+my_built_custom_image := $(intermediates)/$(my_custom_image_name).img
+my_staging_dir := $(intermediates)/$(CUSTOM_IMAGE_MOUNT_POINT)
+
+# Collect CUSTOM_IMAGE_MODULES's installd files and their PICKUP_FILES.
+my_built_modules :=
+my_copy_pairs :=
+my_pickup_files :=
+
+$(foreach m,$(CUSTOM_IMAGE_MODULES),\
+ $(eval _pickup_files := $(strip $(ALL_MODULES.$(m).PICKUP_FILES)\
+ $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).PICKUP_FILES)))\
+ $(eval _built_files := $(strip $(ALL_MODULES.$(m).BUILT_INSTALLED)\
+ $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT_INSTALLED)))\
+ $(if $(_pickup_files)$(_built_files),,\
+ $(warning Unknown installed file for module '$(m)'))\
+ $(eval my_pickup_files += $(_pickup_files))\
+ $(foreach i, $(_built_files),\
+ $(eval bui_ins := $(subst :,$(space),$(i)))\
+ $(eval ins := $(word 2,$(bui_ins)))\
+ $(if $(filter $(TARGET_OUT_ROOT)/%,$(ins)),\
+ $(eval bui := $(word 1,$(bui_ins)))\
+ $(eval my_built_modules += $(bui))\
+ $(eval my_copy_dest := $(patsubst $(PRODUCT_OUT)/%,%,$(ins)))\
+ $(eval my_copy_dest := $(subst /,$(space),$(my_copy_dest)))\
+ $(eval my_copy_dest := $(wordlist 2,999,$(my_copy_dest)))\
+ $(eval my_copy_dest := $(subst $(space),/,$(my_copy_dest)))\
+ $(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\
+ ))
+
+# Collect CUSTOM_IMAGE_COPY_FILES.
+my_image_copy_files :=
+$(foreach f,$(CUSTOM_IMAGE_COPY_FILES),\
+ $(eval pair := $(subst :,$(space),$(f)))\
+ $(eval src := $(word 1,$(pair)))\
+ $(eval my_image_copy_files += $(src))\
+ $(eval my_copy_pairs += $(src):$(my_staging_dir)/$(word 2,$(pair))))
+
+$(my_built_custom_image): PRIVATE_INTERMEDIATES := $(intermediates)
+$(my_built_custom_image): PRIVATE_MOUNT_POINT := $(CUSTOM_IMAGE_MOUNT_POINT)
+$(my_built_custom_image): PRIVATE_PARTITION_SIZE := $(CUSTOM_IMAGE_PARTITION_SIZE)
+$(my_built_custom_image): PRIVATE_FILE_SYSTEM_TYPE := $(CUSTOM_IMAGE_FILE_SYSTEM_TYPE)
+$(my_built_custom_image): PRIVATE_STAGING_DIR := $(my_staging_dir)
+$(my_built_custom_image): PRIVATE_COPY_PAIRS := $(my_copy_pairs)
+$(my_built_custom_image): PRIVATE_PICKUP_FILES := $(my_pickup_files)
+$(my_built_custom_image): PRIVATE_SELINUX := $(CUSTOM_IMAGE_SELINUX)
+$(my_built_custom_image): PRIVATE_SUPPORT_VERITY := $(CUSTOM_IMAGE_SUPPORT_VERITY)
+$(my_built_custom_image): PRIVATE_VERITY_KEY := $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_VERITY_SIGNING_KEY)
+$(my_built_custom_image): PRIVATE_VERITY_BLOCK_DEVICE := $(CUSTOM_IMAGE_VERITY_BLOCK_DEVICE)
+$(my_built_custom_image): PRIVATE_DICT_FILE := $(CUSTOM_IMAGE_DICT_FILE)
+$(my_built_custom_image): $(INTERNAL_USERIMAGES_DEPS) $(my_built_modules) $(my_image_copy_files) \
+ $(CUSTOM_IMAGE_DICT_FILE)
+ @echo "Build image $@"
+ $(hide) rm -rf $(PRIVATE_INTERMEDIATES) && mkdir -p $(PRIVATE_INTERMEDIATES)
+ $(hide) rm -rf $(PRIVATE_STAGING_DIR) && mkdir -p $(PRIVATE_STAGING_DIR)
+ # Copy all the files.
+ $(hide) $(foreach p,$(PRIVATE_COPY_PAIRS),\
+ $(eval pair := $(subst :,$(space),$(p)))\
+ mkdir -p $(dir $(word 2,$(pair)));\
+ cp -Rf $(word 1,$(pair)) $(word 2,$(pair));)
+ $(if $($(PRIVATE_PICKUP_FILES)),$(hide) cp -Rf $(PRIVATE_PICKUP_FILES) $(PRIVATE_STAGING_DIR))
+ # Generate the dict.
+ $(hide) echo "# For all accepted properties, see BuildImage() in tools/releasetools/build_image.py" > $(PRIVATE_INTERMEDIATES)/image_info.txt
+ $(hide) echo "mount_point=$(PRIVATE_MOUNT_POINT)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt
+ $(hide) echo "fs_type=$(PRIVATE_FILE_SYSTEM_TYPE)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt
+ $(hide) echo "partition_size=$(PRIVATE_PARTITION_SIZE)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt
+ $(if $(PRIVATE_SELINUX),$(hide) echo "selinux_fc=$(SELINUX_FC)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt)
+ $(if $(PRIVATE_SUPPORT_VERITY),\
+ $(hide) echo "verity=$(PRIVATE_SUPPORT_VERITY)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt;\
+ echo "verity_key=$(PRIVATE_VERITY_KEY)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt;\
+ echo "verity_signer_cmd=$(VERITY_SIGNER)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt;\
+ echo "verity_block_device=$(PRIVATE_VERITY_BLOCK_DEVICE)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt)
+ $(if $(PRIVATE_DICT_FILE),\
+ $(hide) echo "# Properties from $(PRIVATE_DICT_FILE)" >> $(PRIVATE_INTERMEDIATES)/image_info.txt;\
+ cat $(PRIVATE_DICT_FILE) >> $(PRIVATE_INTERMEDIATES)/image_info.txt)
+ # Generate the image.
+ $(if $(filter oem,$(PRIVATE_MOUNT_POINT)), \
+ $(hide) echo "oem.buildnumber=$(BUILD_NUMBER)" >> $(PRIVATE_STAGING_DIR)/oem.prop)
+ $(hide) PATH=$(foreach p,$(INTERNAL_USERIMAGES_BINARY_PATHS),$(p):)$$PATH \
+ ./build/tools/releasetools/build_image.py \
+ $(PRIVATE_STAGING_DIR) $(PRIVATE_INTERMEDIATES)/image_info.txt $@ $(TARGET_OUT)
+
+my_installed_custom_image := $(PRODUCT_OUT)/$(notdir $(my_built_custom_image))
+$(my_installed_custom_image) : $(my_built_custom_image)
+ $(call copy-file-to-new-target-with-cp)
+
+.PHONY: $(my_custom_image_name)
+custom_images $(my_custom_image_name) : $(my_installed_custom_image)
+
+# Archive the built image.
+$(call dist-for-goals, $(my_custom_image_name) custom_images,$(my_installed_custom_image))
diff --git a/core/tasks/tools/compatibility.mk b/core/tasks/tools/compatibility.mk
new file mode 100644
index 0000000000000000000000000000000000000000..d8f900e4eb10e2804b80d4d80a49902370fd58dd
--- /dev/null
+++ b/core/tasks/tools/compatibility.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.
+
+# Package up a compatibility test suite in a zip file.
+#
+# Input variables:
+# test_suite_name: the name of this test suite eg. cts
+# test_suite_tradefed: the name of this test suite's tradefed wrapper
+# test_suite_dynamic_config: the path to this test suite's dynamic configuration file
+# test_suite_readme: the path to a README file for this test suite
+# Output variables:
+# compatibility_zip: the path to the output zip file.
+
+out_dir := $(HOST_OUT)/$(test_suite_name)/android-$(test_suite_name)
+test_artifacts := $(COMPATIBILITY.$(test_suite_name).FILES)
+test_tools := $(HOST_OUT_JAVA_LIBRARIES)/hosttestlib.jar \
+ $(HOST_OUT_JAVA_LIBRARIES)/tradefed-prebuilt.jar \
+ $(HOST_OUT_JAVA_LIBRARIES)/compatibility-host-util.jar \
+ $(HOST_OUT_JAVA_LIBRARIES)/$(test_suite_tradefed).jar \
+ $(HOST_OUT_EXECUTABLES)/$(test_suite_tradefed) \
+ $(test_suite_readme)
+
+compatibility_zip := $(out_dir).zip
+$(compatibility_zip): PRIVATE_NAME := android-$(test_suite_name)
+$(compatibility_zip): PRIVATE_OUT_DIR := $(out_dir)
+$(compatibility_zip): PRIVATE_TOOLS := $(test_tools)
+$(compatibility_zip): PRIVATE_SUITE_NAME := $(test_suite_name)
+$(compatibility_zip): PRIVATE_DYNAMIC_CONFIG := $(test_suite_dynamic_config)
+$(compatibility_zip): $(test_artifacts) $(test_tools) $(test_suite_dynamic_config) | $(ADB) $(ACP)
+# Make dir structure
+ $(hide) mkdir -p $(PRIVATE_OUT_DIR)/tools $(PRIVATE_OUT_DIR)/testcases
+# Copy tools
+ $(hide) $(ACP) -fp $(PRIVATE_TOOLS) $(PRIVATE_OUT_DIR)/tools
+ $(if $(PRIVATE_DYNAMIC_CONFIG),$(hide) $(ACP) -fp $(PRIVATE_DYNAMIC_CONFIG) $(PRIVATE_OUT_DIR)/testcases/$(PRIVATE_SUITE_NAME).dynamic)
+ $(hide) cd $(dir $@) && zip -rq $(notdir $@) $(PRIVATE_NAME)
+
+# Reset all input variables
+test_suite_name :=
+test_suite_tradefed :=
+test_suite_dynamic_config :=
+test_suite_readme :=
diff --git a/core/tasks/tools/package-modules.mk b/core/tasks/tools/package-modules.mk
new file mode 100644
index 0000000000000000000000000000000000000000..24a7608b2d4029cefbbfdf7368a78beb31b39b0a
--- /dev/null
+++ b/core/tasks/tools/package-modules.mk
@@ -0,0 +1,62 @@
+# Package up modules to a zip file.
+# It preserves the install path of the modules' installed files.
+#
+# Input variables:
+# my_modules: a list of module names
+# my_package_name: the name of the output zip file.
+# Output variables:
+# my_package_zip: the path to the output zip file.
+#
+#
+
+my_staging_dir := $(call intermediates-dir-for,PACKAGING,$(my_package_name))
+my_built_modules :=
+my_copy_pairs :=
+my_pickup_files :=
+
+# Iterate over modules' built files and installed files;
+# Calculate the dest files in the output zip file.
+
+$(foreach m,$(my_modules),\
+ $(eval _pickup_files := $(strip $(ALL_MODULES.$(m).PICKUP_FILES)\
+ $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).PICKUP_FILES)))\
+ $(eval _built_files := $(strip $(ALL_MODULES.$(m).BUILT_INSTALLED)\
+ $(ALL_MODULES.$(m)$(TARGET_2ND_ARCH_MODULE_SUFFIX).BUILT_INSTALLED)))\
+ $(if $(_pickup_files)$(_built_files),,\
+ $(warning Unknown installed file for module '$(m)'))\
+ $(eval my_pickup_files += $(_pickup_files))\
+ $(foreach i, $(_built_files),\
+ $(eval bui_ins := $(subst :,$(space),$(i)))\
+ $(eval ins := $(word 2,$(bui_ins)))\
+ $(if $(filter $(TARGET_OUT_ROOT)/%,$(ins)),\
+ $(eval bui := $(word 1,$(bui_ins)))\
+ $(eval my_built_modules += $(bui))\
+ $(eval my_copy_dest := $(patsubst data/%,DATA/%,\
+ $(patsubst system/%,DATA/%,\
+ $(patsubst $(PRODUCT_OUT)/%,%,$(ins)))))\
+ $(eval my_copy_pairs += $(bui):$(my_staging_dir)/$(my_copy_dest)))\
+ ))
+
+define copy-tests-in-batch
+$(hide) $(foreach p, $(1),\
+ $(eval pair := $(subst :,$(space),$(p)))\
+ mkdir -p $(dir $(word 2,$(pair)));\
+ cp -Rf $(word 1,$(pair)) $(word 2,$(pair));)
+endef
+
+my_package_zip := $(my_staging_dir)/$(my_package_name).zip
+$(my_package_zip): PRIVATE_COPY_PAIRS := $(my_copy_pairs)
+$(my_package_zip): PRIVATE_PICKUP_FILES := $(my_pickup_files)
+$(my_package_zip) : $(my_built_modules)
+ @echo "Package $@"
+ @rm -rf $(dir $@) && mkdir -p $(dir $@)
+ $(call copy-tests-in-batch,$(wordlist 1,200,$(PRIVATE_COPY_PAIRS)))
+ $(call copy-tests-in-batch,$(wordlist 201,400,$(PRIVATE_COPY_PAIRS)))
+ $(call copy-tests-in-batch,$(wordlist 401,600,$(PRIVATE_COPY_PAIRS)))
+ $(call copy-tests-in-batch,$(wordlist 601,800,$(PRIVATE_COPY_PAIRS)))
+ $(call copy-tests-in-batch,$(wordlist 801,1000,$(PRIVATE_COPY_PAIRS)))
+ $(call copy-tests-in-batch,$(wordlist 1001,1200,$(PRIVATE_COPY_PAIRS)))
+ $(call copy-tests-in-batch,$(wordlist 1201,9999,$(PRIVATE_COPY_PAIRS)))
+ $(hide) $(foreach f, $(PRIVATE_PICKUP_FILES),\
+ cp -RfL $(f) $(dir $@);)
+ $(hide) cd $(dir $@) && zip -rqX $(notdir $@) *
diff --git a/core/tasks/vendor_module_check.mk b/core/tasks/vendor_module_check.mk
new file mode 100644
index 0000000000000000000000000000000000000000..e3761aec532956e01b63db0057f26d4ed7863e05
--- /dev/null
+++ b/core/tasks/vendor_module_check.mk
@@ -0,0 +1,116 @@
+#
+# Copyright (C) 2011 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.
+#
+
+# Restrict the vendor module owners here.
+_vendor_owner_whitelist := \
+ asus \
+ audience \
+ atmel \
+ broadcom \
+ csr \
+ elan \
+ fpc \
+ google \
+ htc \
+ huawei \
+ imgtec \
+ invensense \
+ intel \
+ lge \
+ moto \
+ mtk \
+ nvidia \
+ nxp \
+ nxpsw \
+ qcom \
+ qti \
+ samsung \
+ samsung_arm \
+ sony \
+ synaptics \
+ ti \
+ trusted_logic \
+ verizon \
+ widevine
+
+
+ifneq (,$(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES))
+
+_vendor_check_modules := $(product_MODULES)
+
+_vendor_module_owner_info :=
+# Restrict owners
+ifneq (,$(filter true owner all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)))
+
+ifneq (,$(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS)))
+$(error Error: Product "$(TARGET_PRODUCT)" cannot have overlay in vendor tree: \
+ $(filter vendor/%, $(PRODUCT_PACKAGE_OVERLAYS) $(DEVICE_PACKAGE_OVERLAYS)))
+endif
+_vendor_check_copy_files := $(filter vendor/%, $(PRODUCT_COPY_FILES))
+ifneq (,$(_vendor_check_copy_files))
+$(foreach c, $(_vendor_check_copy_files), \
+ $(if $(filter $(_vendor_owner_whitelist), $(call word-colon,3,$(c))),,\
+ $(error Error: vendor PRODUCT_COPY_FILES file "$(c)" has unknown owner))\
+ $(eval _vendor_module_owner_info += $(call word-colon,2,$(c)):$(call word-colon,3,$(c))))
+endif
+_vendor_check_copy_files :=
+
+$(foreach m, $(_vendor_check_modules), \
+ $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\
+ $(if $(filter-out FAKE, $(ALL_MODULES.$(m).CLASS)),\
+ $(if $(filter $(_vendor_owner_whitelist), $(ALL_MODULES.$(m).OWNER)),,\
+ $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) with unknown owner \
+ "$(ALL_MODULES.$(m).OWNER)" in product "$(TARGET_PRODUCT)"))\
+ $(if $(ALL_MODULES.$(m).INSTALLED),\
+ $(eval _vendor_module_owner_info += $(patsubst $(PRODUCT_OUT)/%,%,$(ALL_MODULES.$(m).INSTALLED)):$(ALL_MODULES.$(m).OWNER))))))
+
+endif
+
+
+# Restrict paths
+ifneq (,$(filter path all, $(PRODUCTS.$(INTERNAL_PRODUCT).PRODUCT_RESTRICT_VENDOR_FILES)))
+
+$(foreach m, $(_vendor_check_modules), \
+ $(if $(filter vendor/%, $(ALL_MODULES.$(m).PATH)),\
+ $(if $(filter-out FAKE, $(ALL_MODULES.$(m).CLASS)),\
+ $(if $(filter-out ,$(ALL_MODULES.$(m).INSTALLED)),\
+ $(if $(filter $(TARGET_OUT_VENDOR)/% $(HOST_OUT)/%, $(ALL_MODULES.$(m).INSTALLED)),,\
+ $(error Error: vendor module "$(m)" in $(ALL_MODULES.$(m).PATH) \
+ in product "$(TARGET_PRODUCT)" being installed to \
+ $(ALL_MODULES.$(m).INSTALLED) which is not in the vendor tree))))))
+
+endif
+
+_vendor_module_owner_info_txt := $(call intermediates-dir-for,PACKAGING,vendor_owner_info)/vendor_owner_info.txt
+$(_vendor_module_owner_info_txt): PRIVATE_INFO := $(_vendor_module_owner_info)
+$(_vendor_module_owner_info_txt):
+ @echo "Write vendor module owner info $@"
+ @mkdir -p $(dir $@) && rm -f $@
+ifdef _vendor_module_owner_info
+ @for w in $(PRIVATE_INFO); \
+ do \
+ echo $$w >> $@; \
+ done
+else
+ @echo "No vendor module owner info." > $@
+endif
+
+$(call dist-for-goals, droidcore, $(_vendor_module_owner_info_txt))
+
+_vendor_module_owner_info_txt :=
+_vendor_module_owner_info :=
+_vendor_check_modules :=
+endif
diff --git a/core/tasks/vts.mk b/core/tasks/vts.mk
new file mode 100644
index 0000000000000000000000000000000000000000..507f22ea8434c53b039413b15e7145318b199ac6
--- /dev/null
+++ b/core/tasks/vts.mk
@@ -0,0 +1,23 @@
+# Copyright (C) 2016 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.
+
+test_suite_name := vts
+test_suite_tradefed := vts-tradefed
+test_suite_readme := test/vts/README.md
+
+include $(BUILD_SYSTEM)/tasks/tools/compatibility.mk
+
+.PHONY: vts
+vts: $(compatibility_zip)
+$(call dist-for-goals, vts, $(compatibility_zip))
diff --git a/core/version_defaults.mk b/core/version_defaults.mk
new file mode 100644
index 0000000000000000000000000000000000000000..550fc70ce70aa6dc00acc6326fbb211f7c0d1205
--- /dev/null
+++ b/core/version_defaults.mk
@@ -0,0 +1,160 @@
+#
+# 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.
+#
+
+#
+# Handle various build version information.
+#
+# Guarantees that the following are defined:
+# PLATFORM_VERSION
+# PLATFORM_SDK_VERSION
+# PLATFORM_VERSION_CODENAME
+# DEFAULT_APP_TARGET_SDK
+# BUILD_ID
+# BUILD_NUMBER
+# BUILD_DATETIME
+# PLATFORM_SECURITY_PATCH
+#
+
+# Look for an optional file containing overrides of the defaults,
+# but don't cry if we don't find it. We could just use -include, but
+# the build.prop target also wants INTERNAL_BUILD_ID_MAKEFILE to be set
+# if the file exists.
+#
+INTERNAL_BUILD_ID_MAKEFILE := $(wildcard $(BUILD_SYSTEM)/build_id.mk)
+ifneq "" "$(INTERNAL_BUILD_ID_MAKEFILE)"
+ include $(INTERNAL_BUILD_ID_MAKEFILE)
+endif
+
+ifeq "" "$(PLATFORM_VERSION)"
+ # This is the canonical definition of the platform version,
+ # which is the version that we reveal to the end user.
+ # Update this value when the platform version changes (rather
+ # than overriding it somewhere else). Can be an arbitrary string.
+ PLATFORM_VERSION := 7.1.1
+endif
+
+ifeq "" "$(PLATFORM_SDK_VERSION)"
+ # This is the canonical definition of the SDK version, which defines
+ # the set of APIs and functionality available in the platform. It
+ # is a single integer that increases monotonically as updates to
+ # the SDK are released. It should only be incremented when the APIs for
+ # the new release are frozen (so that developers don't write apps against
+ # intermediate builds). During development, this number remains at the
+ # SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds
+ # the code-name of the new development work.
+ PLATFORM_SDK_VERSION := 25
+endif
+
+ifeq "" "$(PLATFORM_JACK_MIN_SDK_VERSION)"
+ # This is definition of the min SDK version given to Jack for the current
+ # platform. For released version it should be the same as
+ # PLATFORM_SDK_VERSION. During development, this number may be incremented
+ # before PLATFORM_SDK_VERSION if the plateform starts to add new java
+ # language supports.
+ PLATFORM_JACK_MIN_SDK_VERSION := 25
+endif
+
+ifeq "" "$(PLATFORM_VERSION_CODENAME)"
+ # This is the current development code-name, if the build is not a final
+ # release build. If this is a final release build, it is simply "REL".
+ PLATFORM_VERSION_CODENAME := REL
+
+ # This is all of the development codenames that are active. Should be either
+ # the same as PLATFORM_VERSION_CODENAME or a comma-separated list of additional
+ # codenames after PLATFORM_VERSION_CODENAME.
+ PLATFORM_VERSION_ALL_CODENAMES := $(PLATFORM_VERSION_CODENAME)
+endif
+
+ifeq "REL" "$(PLATFORM_VERSION_CODENAME)"
+ PLATFORM_PREVIEW_SDK_VERSION := 0
+else
+ ifeq "" "$(PLATFORM_PREVIEW_SDK_VERSION)"
+ # This is the definition of a preview SDK version over and above the current
+ # platform SDK version. Unlike the platform SDK version, a higher value
+ # for preview SDK version does NOT mean that all prior preview APIs are
+ # included. Packages reading this value to determine compatibility with
+ # known APIs should check that this value is precisely equal to the preview
+ # SDK version the package was built for, otherwise it should fall back to
+ # assuming the device can only support APIs as of the previous official
+ # public release.
+ # This value will always be 0 for release builds.
+ PLATFORM_PREVIEW_SDK_VERSION := 0
+ endif
+endif
+
+ifeq "" "$(DEFAULT_APP_TARGET_SDK)"
+ # This is the default minSdkVersion and targetSdkVersion to use for
+ # all .apks created by the build system. It can be overridden by explicitly
+ # setting these in the .apk's AndroidManifest.xml. It is either the code
+ # name of the development build or, if this is a release build, the official
+ # SDK version of this release.
+ ifeq "REL" "$(PLATFORM_VERSION_CODENAME)"
+ DEFAULT_APP_TARGET_SDK := $(PLATFORM_SDK_VERSION)
+ else
+ DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME)
+ endif
+endif
+
+ifeq "" "$(PLATFORM_SECURITY_PATCH)"
+ # Used to indicate the security patch that has been applied to the device.
+ # It must signify that the build includes all security patches issued up through the designated Android Public Security Bulletin.
+ # It must be of the form "YYYY-MM-DD" on production devices.
+ # It must match one of the Android Security Patch Level strings of the Public Security Bulletins.
+ # If there is no $PLATFORM_SECURITY_PATCH set, keep it empty.
+ PLATFORM_SECURITY_PATCH := 2017-01-05
+endif
+
+ifeq "" "$(PLATFORM_BASE_OS)"
+ # Used to indicate the base os applied to the device.
+ # Can be an arbitrary string, but must be a single word.
+ #
+ # If there is no $PLATFORM_BASE_OS set, keep it empty.
+ PLATFORM_BASE_OS :=
+endif
+
+ifeq "" "$(BUILD_ID)"
+ # Used to signify special builds. E.g., branches and/or releases,
+ # like "M5-RC7". Can be an arbitrary string, but must be a single
+ # word and a valid file name.
+ #
+ # If there is no BUILD_ID set, make it obvious.
+ BUILD_ID := UNKNOWN
+endif
+
+ifeq "" "$(BUILD_DATETIME)"
+ # Used to reproduce builds by setting the same time. Must be the number
+ # of seconds since the Epoch.
+ BUILD_DATETIME := $(shell date +%s)
+endif
+
+ifneq (,$(findstring Darwin,$(shell uname -sm)))
+DATE := date -r $(BUILD_DATETIME)
+else
+DATE := date -d @$(BUILD_DATETIME)
+endif
+
+ifeq "" "$(BUILD_NUMBER)"
+ # BUILD_NUMBER should be set to the source control value that
+ # represents the current state of the source code. E.g., a
+ # perforce changelist number or a git hash. Can be an arbitrary string
+ # (to allow for source control that uses something other than numbers),
+ # but must be a single word and a valid file name.
+ #
+ # If no BUILD_NUMBER is set, create a useful "I am an engineering build
+ # from this date/time" value. Make it start with a non-digit so that
+ # anyone trying to parse it as an integer will probably get "0".
+ BUILD_NUMBER := eng.$(shell echo $${USER:0:6}).$(shell $(DATE) +%Y%m%d.%H%M%S)
+endif
diff --git a/envsetup.sh b/envsetup.sh
new file mode 100644
index 0000000000000000000000000000000000000000..35df2d5f3e1877c0ffaa8136944b5c40d5cb59bf
--- /dev/null
+++ b/envsetup.sh
@@ -0,0 +1,1632 @@
+function hmm() {
+cat <-
+- tapas: tapas [ ...] [arm|x86|mips|armv5|arm64|x86_64|mips64] [eng|userdebug|user]
+- croot: Changes directory to the top of the tree.
+- m: Makes from the top of the tree.
+- mm: Builds all of the modules in the current directory, but not their dependencies.
+- mmm: Builds all of the modules in the supplied directories, but not their dependencies.
+ To limit the modules being built use the syntax: mmm dir/:target1,target2.
+- mma: Builds all of the modules in the current directory, and their dependencies.
+- mmma: Builds all of the modules in the supplied directories, and their dependencies.
+- provision: Flash device with all required partitions. Options will be passed on to fastboot.
+- cgrep: Greps on all local C/C++ files.
+- ggrep: Greps on all local Gradle files.
+- jgrep: Greps on all local Java files.
+- resgrep: Greps on all local res/*.xml files.
+- mangrep: Greps on all local AndroidManifest.xml files.
+- mgrep: Greps on all local Makefiles files.
+- sepgrep: Greps on all local sepolicy files.
+- sgrep: Greps on all local source files.
+- godir: Go to the directory containing a file.
+
+Environment options:
+- SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note that
+ ASAN_OPTIONS=detect_leaks=0 will be set by default until the
+ build is leak-check clean.
+
+Look at the source to view more functions. The complete list is:
+EOF
+ T=$(gettop)
+ local A
+ A=""
+ for i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
+ A="$A $i"
+ done
+ echo $A
+}
+
+# Get all the build variables needed by this script in a single call to the build system.
+function build_build_var_cache()
+{
+ T=$(gettop)
+ # Grep out the variable names from the script.
+ cached_vars=`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/get_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
+ cached_abs_vars=`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/get_abs_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
+ # Call the build system to dump the "=" pairs as a shell script.
+ build_dicts_script=`\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
+ command make --no-print-directory -f build/core/config.mk \
+ dump-many-vars \
+ DUMP_MANY_VARS="$cached_vars" \
+ DUMP_MANY_ABS_VARS="$cached_abs_vars" \
+ DUMP_VAR_PREFIX="var_cache_" \
+ DUMP_ABS_VAR_PREFIX="abs_var_cache_"`
+ local ret=$?
+ if [ $ret -ne 0 ]
+ then
+ unset build_dicts_script
+ return $ret
+ fi
+ # Excute the script to store the "=" pairs as shell variables.
+ eval "$build_dicts_script"
+ ret=$?
+ unset build_dicts_script
+ if [ $ret -ne 0 ]
+ then
+ return $ret
+ fi
+ BUILD_VAR_CACHE_READY="true"
+}
+
+# Delete the build var cache, so that we can still call into the build system
+# to get build variables not listed in this script.
+function destroy_build_var_cache()
+{
+ unset BUILD_VAR_CACHE_READY
+ for v in $cached_vars; do
+ unset var_cache_$v
+ done
+ unset cached_vars
+ for v in $cached_abs_vars; do
+ unset abs_var_cache_$v
+ done
+ unset cached_abs_vars
+}
+
+# Get the value of a build variable as an absolute path.
+function get_abs_build_var()
+{
+ if [ "$BUILD_VAR_CACHE_READY" = "true" ]
+ then
+ eval echo \"\${abs_var_cache_$1}\"
+ return
+ fi
+
+ T=$(gettop)
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP." >&2
+ return
+ fi
+ (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
+ command make --no-print-directory -f build/core/config.mk dumpvar-abs-$1)
+}
+
+# Get the exact value of a build variable.
+function get_build_var()
+{
+ if [ "$BUILD_VAR_CACHE_READY" = "true" ]
+ then
+ eval echo \"\${var_cache_$1}\"
+ return
+ fi
+
+ T=$(gettop)
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP." >&2
+ return
+ fi
+ (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
+ command make --no-print-directory -f build/core/config.mk dumpvar-$1)
+}
+
+# check to see if the supplied product is one we can build
+function check_product()
+{
+ T=$(gettop)
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP." >&2
+ return
+ fi
+ TARGET_PRODUCT=$1 \
+ TARGET_BUILD_VARIANT= \
+ TARGET_BUILD_TYPE= \
+ TARGET_BUILD_APPS= \
+ get_build_var TARGET_DEVICE > /dev/null
+ # hide successful answers, but allow the errors to show
+}
+
+VARIANT_CHOICES=(user userdebug eng)
+
+# check to see if the supplied variant is valid
+function check_variant()
+{
+ for v in ${VARIANT_CHOICES[@]}
+ do
+ if [ "$v" = "$1" ]
+ then
+ return 0
+ fi
+ done
+ return 1
+}
+
+function setpaths()
+{
+ T=$(gettop)
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ return
+ fi
+
+ ##################################################################
+ # #
+ # Read me before you modify this code #
+ # #
+ # This function sets ANDROID_BUILD_PATHS to what it is adding #
+ # to PATH, and the next time it is run, it removes that from #
+ # PATH. This is required so lunch can be run more than once #
+ # and still have working paths. #
+ # #
+ ##################################################################
+
+ # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
+ # due to "C:\Program Files" being in the path.
+
+ # out with the old
+ if [ -n "$ANDROID_BUILD_PATHS" ] ; then
+ export PATH=${PATH/$ANDROID_BUILD_PATHS/}
+ fi
+ if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
+ export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
+ # strip leading ':', if any
+ export PATH=${PATH/:%/}
+ fi
+
+ # and in with the new
+ prebuiltdir=$(getprebuilt)
+ gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)
+
+ # defined in core/config.mk
+ targetgccversion=$(get_build_var TARGET_GCC_VERSION)
+ targetgccversion2=$(get_build_var 2ND_TARGET_GCC_VERSION)
+ export TARGET_GCC_VERSION=$targetgccversion
+
+ # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
+ export ANDROID_TOOLCHAIN=
+ export ANDROID_TOOLCHAIN_2ND_ARCH=
+ local ARCH=$(get_build_var TARGET_ARCH)
+ case $ARCH in
+ x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
+ ;;
+ x86_64) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
+ ;;
+ arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
+ ;;
+ arm64) toolchaindir=aarch64/aarch64-linux-android-$targetgccversion/bin;
+ toolchaindir2=arm/arm-linux-androideabi-$targetgccversion2/bin
+ ;;
+ mips|mips64) toolchaindir=mips/mips64el-linux-android-$targetgccversion/bin
+ ;;
+ *)
+ echo "Can't find toolchain for unknown architecture: $ARCH"
+ toolchaindir=xxxxxxxxx
+ ;;
+ esac
+ if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
+ export ANDROID_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
+ fi
+
+ if [ -d "$gccprebuiltdir/$toolchaindir2" ]; then
+ export ANDROID_TOOLCHAIN_2ND_ARCH=$gccprebuiltdir/$toolchaindir2
+ fi
+
+ export ANDROID_DEV_SCRIPTS=$T/development/scripts:$T/prebuilts/devtools/tools:$T/external/selinux/prebuilts/bin
+ export ANDROID_BUILD_PATHS=$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_TOOLCHAIN:$ANDROID_TOOLCHAIN_2ND_ARCH:$ANDROID_DEV_SCRIPTS:
+
+ # If prebuilts/android-emulator// exists, prepend it to our PATH
+ # to ensure that the corresponding 'emulator' binaries are used.
+ case $(uname -s) in
+ Darwin)
+ ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/darwin-x86_64
+ ;;
+ Linux)
+ ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/linux-x86_64
+ ;;
+ *)
+ ANDROID_EMULATOR_PREBUILTS=
+ ;;
+ esac
+ if [ -n "$ANDROID_EMULATOR_PREBUILTS" -a -d "$ANDROID_EMULATOR_PREBUILTS" ]; then
+ ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS$ANDROID_EMULATOR_PREBUILTS:
+ export ANDROID_EMULATOR_PREBUILTS
+ fi
+
+ export PATH=$ANDROID_BUILD_PATHS$PATH
+ export PYTHONPATH=$T/development/python-packages:$PYTHONPATH
+
+ unset ANDROID_JAVA_TOOLCHAIN
+ unset ANDROID_PRE_BUILD_PATHS
+ if [ -n "$JAVA_HOME" ]; then
+ export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
+ export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
+ export PATH=$ANDROID_PRE_BUILD_PATHS$PATH
+ fi
+
+ unset ANDROID_PRODUCT_OUT
+ export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT)
+ export OUT=$ANDROID_PRODUCT_OUT
+
+ unset ANDROID_HOST_OUT
+ export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
+
+ # needed for building linux on MacOS
+ # TODO: fix the path
+ #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
+}
+
+function printconfig()
+{
+ T=$(gettop)
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP." >&2
+ return
+ fi
+ get_build_var report_config
+}
+
+function set_stuff_for_environment()
+{
+ settitle
+ set_java_home
+ setpaths
+ set_sequence_number
+
+ export ANDROID_BUILD_TOP=$(gettop)
+ # With this environment variable new GCC can apply colors to warnings/errors
+ export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+ export ASAN_OPTIONS=detect_leaks=0
+}
+
+function set_sequence_number()
+{
+ export BUILD_ENV_SEQUENCE_NUMBER=10
+}
+
+function settitle()
+{
+ if [ "$STAY_OFF_MY_LAWN" = "" ]; then
+ local arch=$(gettargetarch)
+ local product=$TARGET_PRODUCT
+ local variant=$TARGET_BUILD_VARIANT
+ local apps=$TARGET_BUILD_APPS
+ if [ -z "$apps" ]; then
+ export PROMPT_COMMAND="echo -ne \"\033]0;[${arch}-${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
+ else
+ export PROMPT_COMMAND="echo -ne \"\033]0;[$arch $apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
+ fi
+ fi
+}
+
+function addcompletions()
+{
+ local T dir f
+
+ # Keep us from trying to run in something that isn't bash.
+ if [ -z "${BASH_VERSION}" ]; then
+ return
+ fi
+
+ # Keep us from trying to run in bash that's too old.
+ if [ ${BASH_VERSINFO[0]} -lt 3 ]; then
+ return
+ fi
+
+ dir="sdk/bash_completion"
+ if [ -d ${dir} ]; then
+ for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
+ echo "including $f"
+ . $f
+ done
+ fi
+}
+
+function choosetype()
+{
+ echo "Build type choices are:"
+ echo " 1. release"
+ echo " 2. debug"
+ echo
+
+ local DEFAULT_NUM DEFAULT_VALUE
+ DEFAULT_NUM=1
+ DEFAULT_VALUE=release
+
+ export TARGET_BUILD_TYPE=
+ local ANSWER
+ while [ -z $TARGET_BUILD_TYPE ]
+ do
+ echo -n "Which would you like? ["$DEFAULT_NUM"] "
+ if [ -z "$1" ] ; then
+ read ANSWER
+ else
+ echo $1
+ ANSWER=$1
+ fi
+ case $ANSWER in
+ "")
+ export TARGET_BUILD_TYPE=$DEFAULT_VALUE
+ ;;
+ 1)
+ export TARGET_BUILD_TYPE=release
+ ;;
+ release)
+ export TARGET_BUILD_TYPE=release
+ ;;
+ 2)
+ export TARGET_BUILD_TYPE=debug
+ ;;
+ debug)
+ export TARGET_BUILD_TYPE=debug
+ ;;
+ *)
+ echo
+ echo "I didn't understand your response. Please try again."
+ echo
+ ;;
+ esac
+ if [ -n "$1" ] ; then
+ break
+ fi
+ done
+
+ build_build_var_cache
+ set_stuff_for_environment
+ destroy_build_var_cache
+}
+
+#
+# This function isn't really right: It chooses a TARGET_PRODUCT
+# based on the list of boards. Usually, that gets you something
+# that kinda works with a generic product, but really, you should
+# pick a product by name.
+#
+function chooseproduct()
+{
+ if [ "x$TARGET_PRODUCT" != x ] ; then
+ default_value=$TARGET_PRODUCT
+ else
+ default_value=aosp_arm
+ fi
+
+ export TARGET_BUILD_APPS=
+ export TARGET_PRODUCT=
+ local ANSWER
+ while [ -z "$TARGET_PRODUCT" ]
+ do
+ echo -n "Which product would you like? [$default_value] "
+ if [ -z "$1" ] ; then
+ read ANSWER
+ else
+ echo $1
+ ANSWER=$1
+ fi
+
+ if [ -z "$ANSWER" ] ; then
+ export TARGET_PRODUCT=$default_value
+ else
+ if check_product $ANSWER
+ then
+ export TARGET_PRODUCT=$ANSWER
+ else
+ echo "** Not a valid product: $ANSWER"
+ fi
+ fi
+ if [ -n "$1" ] ; then
+ break
+ fi
+ done
+
+ build_build_var_cache
+ set_stuff_for_environment
+ destroy_build_var_cache
+}
+
+function choosevariant()
+{
+ echo "Variant choices are:"
+ local index=1
+ local v
+ for v in ${VARIANT_CHOICES[@]}
+ do
+ # The product name is the name of the directory containing
+ # the makefile we found, above.
+ echo " $index. $v"
+ index=$(($index+1))
+ done
+
+ local default_value=eng
+ local ANSWER
+
+ export TARGET_BUILD_VARIANT=
+ while [ -z "$TARGET_BUILD_VARIANT" ]
+ do
+ echo -n "Which would you like? [$default_value] "
+ if [ -z "$1" ] ; then
+ read ANSWER
+ else
+ echo $1
+ ANSWER=$1
+ fi
+
+ if [ -z "$ANSWER" ] ; then
+ export TARGET_BUILD_VARIANT=$default_value
+ elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
+ if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then
+ export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]}
+ fi
+ else
+ if check_variant $ANSWER
+ then
+ export TARGET_BUILD_VARIANT=$ANSWER
+ else
+ echo "** Not a valid variant: $ANSWER"
+ fi
+ fi
+ if [ -n "$1" ] ; then
+ break
+ fi
+ done
+}
+
+function choosecombo()
+{
+ choosetype $1
+
+ echo
+ echo
+ chooseproduct $2
+
+ echo
+ echo
+ choosevariant $3
+
+ echo
+ build_build_var_cache
+ set_stuff_for_environment
+ printconfig
+ destroy_build_var_cache
+}
+
+# Clear this variable. It will be built up again when the vendorsetup.sh
+# files are included at the end of this file.
+unset LUNCH_MENU_CHOICES
+function add_lunch_combo()
+{
+ local new_combo=$1
+ local c
+ for c in ${LUNCH_MENU_CHOICES[@]} ; do
+ if [ "$new_combo" = "$c" ] ; then
+ return
+ fi
+ done
+ LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
+}
+
+# add the default one here
+add_lunch_combo aosp_arm-eng
+add_lunch_combo aosp_arm64-eng
+add_lunch_combo aosp_mips-eng
+add_lunch_combo aosp_mips64-eng
+add_lunch_combo aosp_x86-eng
+add_lunch_combo aosp_x86_64-eng
+
+function print_lunch_menu()
+{
+ local uname=$(uname)
+ echo
+ echo "You're building on" $uname
+ echo
+ echo "Lunch menu... pick a combo:"
+
+ local i=1
+ local choice
+ for choice in ${LUNCH_MENU_CHOICES[@]}
+ do
+ echo " $i. $choice"
+ i=$(($i+1))
+ done
+
+ echo
+}
+
+function lunch()
+{
+ local answer
+
+ if [ "$1" ] ; then
+ answer=$1
+ else
+ print_lunch_menu
+ echo -n "Which would you like? [aosp_arm-eng] "
+ read answer
+ fi
+
+ local selection=
+
+ if [ -z "$answer" ]
+ then
+ selection=aosp_arm-eng
+ elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
+ then
+ if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
+ then
+ selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
+ fi
+ elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
+ then
+ selection=$answer
+ fi
+
+ if [ -z "$selection" ]
+ then
+ echo
+ echo "Invalid lunch combo: $answer"
+ return 1
+ fi
+
+ export TARGET_BUILD_APPS=
+
+ local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
+ check_variant $variant
+ if [ $? -ne 0 ]
+ then
+ echo
+ echo "** Invalid variant: '$variant'"
+ echo "** Must be one of ${VARIANT_CHOICES[@]}"
+ variant=
+ fi
+
+ local product=$(echo -n $selection | sed -e "s/-.*$//")
+ TARGET_PRODUCT=$product \
+ TARGET_BUILD_VARIANT=$variant \
+ build_build_var_cache
+ if [ $? -ne 0 ]
+ then
+ echo
+ echo "** Don't have a product spec for: '$product'"
+ echo "** Do you have the right repo manifest?"
+ product=
+ fi
+
+ if [ -z "$product" -o -z "$variant" ]
+ then
+ echo
+ return 1
+ fi
+
+ export TARGET_PRODUCT=$product
+ export TARGET_BUILD_VARIANT=$variant
+ export TARGET_BUILD_TYPE=release
+
+ echo
+
+ set_stuff_for_environment
+ printconfig
+ destroy_build_var_cache
+}
+
+# Tab completion for lunch.
+function _lunch()
+{
+ local cur prev opts
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+
+ COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
+ return 0
+}
+complete -F _lunch lunch
+
+# Configures the build to build unbundled apps.
+# Run tapas with one or more app names (from LOCAL_PACKAGE_NAME)
+function tapas()
+{
+ local arch="$(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|armv5|arm64|x86_64|mips64)$' | xargs)"
+ local variant="$(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$' | xargs)"
+ local density="$(echo $* | xargs -n 1 echo | \grep -E '^(ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)"
+ local apps="$(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips|armv5|arm64|x86_64|mips64|ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)"
+
+ if [ $(echo $arch | wc -w) -gt 1 ]; then
+ echo "tapas: Error: Multiple build archs supplied: $arch"
+ return
+ fi
+ if [ $(echo $variant | wc -w) -gt 1 ]; then
+ echo "tapas: Error: Multiple build variants supplied: $variant"
+ return
+ fi
+ if [ $(echo $density | wc -w) -gt 1 ]; then
+ echo "tapas: Error: Multiple densities supplied: $density"
+ return
+ fi
+
+ local product=aosp_arm
+ case $arch in
+ x86) product=aosp_x86;;
+ mips) product=aosp_mips;;
+ armv5) product=generic_armv5;;
+ arm64) product=aosp_arm64;;
+ x86_64) product=aosp_x86_64;;
+ mips64) product=aosp_mips64;;
+ esac
+ if [ -z "$variant" ]; then
+ variant=eng
+ fi
+ if [ -z "$apps" ]; then
+ apps=all
+ fi
+ if [ -z "$density" ]; then
+ density=alldpi
+ fi
+
+ export TARGET_PRODUCT=$product
+ export TARGET_BUILD_VARIANT=$variant
+ export TARGET_BUILD_DENSITY=$density
+ export TARGET_BUILD_TYPE=release
+ export TARGET_BUILD_APPS=$apps
+
+ build_build_var_cache
+ set_stuff_for_environment
+ printconfig
+ destroy_build_var_cache
+}
+
+function gettop
+{
+ local TOPFILE=build/core/envsetup.mk
+ if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
+ # The following circumlocution ensures we remove symlinks from TOP.
+ (cd $TOP; PWD= /bin/pwd)
+ else
+ if [ -f $TOPFILE ] ; then
+ # The following circumlocution (repeated below as well) ensures
+ # that we record the true directory name and not one that is
+ # faked up with symlink names.
+ PWD= /bin/pwd
+ else
+ local HERE=$PWD
+ T=
+ while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
+ \cd ..
+ T=`PWD= /bin/pwd -P`
+ done
+ \cd $HERE
+ if [ -f "$T/$TOPFILE" ]; then
+ echo $T
+ fi
+ fi
+ fi
+}
+
+# Return driver for "make", if any (eg. static analyzer)
+function getdriver()
+{
+ local T="$1"
+ test "$WITH_STATIC_ANALYZER" = "0" && unset WITH_STATIC_ANALYZER
+ if [ -n "$WITH_STATIC_ANALYZER" ]; then
+ echo "\
+$T/prebuilts/misc/linux-x86/analyzer/tools/scan-build/scan-build \
+--use-analyzer $T/prebuilts/misc/linux-x86/analyzer/bin/analyzer \
+--status-bugs \
+--top=$T"
+ fi
+}
+
+function m()
+{
+ local T=$(gettop)
+ local DRV=$(getdriver $T)
+ if [ "$T" ]; then
+ $DRV make -C $T -f build/core/main.mk $@
+ else
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ return 1
+ fi
+}
+
+function findmakefile()
+{
+ TOPFILE=build/core/envsetup.mk
+ local HERE=$PWD
+ T=
+ while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
+ T=`PWD= /bin/pwd`
+ if [ -f "$T/Android.mk" ]; then
+ echo $T/Android.mk
+ \cd $HERE
+ return
+ fi
+ \cd ..
+ done
+ \cd $HERE
+}
+
+function mm()
+{
+ local T=$(gettop)
+ local DRV=$(getdriver $T)
+ # If we're sitting in the root of the build tree, just do a
+ # normal make.
+ if [ -f build/core/envsetup.mk -a -f Makefile ]; then
+ $DRV make $@
+ else
+ # Find the closest Android.mk file.
+ local M=$(findmakefile)
+ local MODULES=
+ local GET_INSTALL_PATH=
+ local ARGS=
+ # Remove the path to top as the makefilepath needs to be relative
+ local M=`echo $M|sed 's:'$T'/::'`
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ return 1
+ elif [ ! "$M" ]; then
+ echo "Couldn't locate a makefile from the current directory."
+ return 1
+ else
+ for ARG in $@; do
+ case $ARG in
+ GET-INSTALL-PATH) GET_INSTALL_PATH=$ARG;;
+ esac
+ done
+ if [ -n "$GET_INSTALL_PATH" ]; then
+ MODULES=
+ ARGS=GET-INSTALL-PATH
+ else
+ MODULES=all_modules
+ ARGS=$@
+ fi
+ ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES $ARGS
+ fi
+ fi
+}
+
+function mmm()
+{
+ local T=$(gettop)
+ local DRV=$(getdriver $T)
+ if [ "$T" ]; then
+ local MAKEFILE=
+ local MODULES=
+ local ARGS=
+ local DIR TO_CHOP
+ local GET_INSTALL_PATH=
+ local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
+ local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+ for DIR in $DIRS ; do
+ MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
+ if [ "$MODULES" = "" ]; then
+ MODULES=all_modules
+ fi
+ DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
+ if [ -f $DIR/Android.mk ]; then
+ local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
+ local TO_CHOP=`expr $TO_CHOP + 1`
+ local START=`PWD= /bin/pwd`
+ local MFILE=`echo $START | cut -c${TO_CHOP}-`
+ if [ "$MFILE" = "" ] ; then
+ MFILE=$DIR/Android.mk
+ else
+ MFILE=$MFILE/$DIR/Android.mk
+ fi
+ MAKEFILE="$MAKEFILE $MFILE"
+ else
+ case $DIR in
+ showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";;
+ GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;;
+ *) if [ -d $DIR ]; then
+ echo "No Android.mk in $DIR.";
+ else
+ echo "Couldn't locate the directory $DIR";
+ fi
+ return 1;;
+ esac
+ fi
+ done
+ if [ -n "$GET_INSTALL_PATH" ]; then
+ ARGS=$GET_INSTALL_PATH
+ MODULES=
+ fi
+ ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS
+ else
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ return 1
+ fi
+}
+
+function mma()
+{
+ local T=$(gettop)
+ local DRV=$(getdriver $T)
+ if [ -f build/core/envsetup.mk -a -f Makefile ]; then
+ $DRV make $@
+ else
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ return 1
+ fi
+ local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'`
+ local MODULES_IN_PATHS=MODULES-IN-$MY_PWD
+ # Convert "/" to "-".
+ MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
+ $DRV make -C $T -f build/core/main.mk $@ $MODULES_IN_PATHS
+ fi
+}
+
+function mmma()
+{
+ local T=$(gettop)
+ local DRV=$(getdriver $T)
+ if [ "$T" ]; then
+ local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
+ local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+ local MY_PWD=`PWD= /bin/pwd`
+ if [ "$MY_PWD" = "$T" ]; then
+ MY_PWD=
+ else
+ MY_PWD=`echo $MY_PWD|sed 's:'$T'/::'`
+ fi
+ local DIR=
+ local MODULES_IN_PATHS=
+ local ARGS=
+ for DIR in $DIRS ; do
+ if [ -d $DIR ]; then
+ # Remove the leading ./ and trailing / if any exists.
+ DIR=${DIR#./}
+ DIR=${DIR%/}
+ if [ "$MY_PWD" != "" ]; then
+ DIR=$MY_PWD/$DIR
+ fi
+ MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$DIR"
+ else
+ case $DIR in
+ showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";;
+ *) echo "Couldn't find directory $DIR"; return 1;;
+ esac
+ fi
+ done
+ # Convert "/" to "-".
+ MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
+ $DRV make -C $T -f build/core/main.mk $DASH_ARGS $ARGS $MODULES_IN_PATHS
+ else
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ return 1
+ fi
+}
+
+function croot()
+{
+ T=$(gettop)
+ if [ "$T" ]; then
+ \cd $(gettop)
+ else
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ fi
+}
+
+function cproj()
+{
+ TOPFILE=build/core/envsetup.mk
+ local HERE=$PWD
+ T=
+ while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
+ T=$PWD
+ if [ -f "$T/Android.mk" ]; then
+ \cd $T
+ return
+ fi
+ \cd ..
+ done
+ \cd $HERE
+ echo "can't find Android.mk"
+}
+
+# simplified version of ps; output in the form
+#
+function qpid() {
+ local prepend=''
+ local append=''
+ if [ "$1" = "--exact" ]; then
+ prepend=' '
+ append='$'
+ shift
+ elif [ "$1" = "--help" -o "$1" = "-h" ]; then
+ echo "usage: qpid [[--exact] "
+ return 255
+ fi
+
+ local EXE="$1"
+ if [ "$EXE" ] ; then
+ qpid | \grep "$prepend$EXE$append"
+ else
+ adb shell ps \
+ | tr -d '\r' \
+ | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
+ fi
+}
+
+function pid()
+{
+ local prepend=''
+ local append=''
+ if [ "$1" = "--exact" ]; then
+ prepend=' '
+ append='$'
+ shift
+ fi
+ local EXE="$1"
+ if [ "$EXE" ] ; then
+ local PID=`adb shell ps \
+ | tr -d '\r' \
+ | \grep "$prepend$EXE$append" \
+ | sed -e 's/^[^ ]* *\([0-9]*\).*$/\1/'`
+ echo "$PID"
+ else
+ echo "usage: pid [--exact] "
+ return 255
+ fi
+}
+
+# coredump_setup - enable core dumps globally for any process
+# that has the core-file-size limit set correctly
+#
+# NOTE: You must call also coredump_enable for a specific process
+# if its core-file-size limit is not set already.
+# NOTE: Core dumps are written to ramdisk; they will not survive a reboot!
+
+function coredump_setup()
+{
+ echo "Getting root...";
+ adb root;
+ adb wait-for-device;
+
+ echo "Remounting root partition read-write...";
+ adb shell mount -w -o remount -t rootfs rootfs;
+ sleep 1;
+ adb wait-for-device;
+ adb shell mkdir -p /cores;
+ adb shell mount -t tmpfs tmpfs /cores;
+ adb shell chmod 0777 /cores;
+
+ echo "Granting SELinux permission to dump in /cores...";
+ adb shell restorecon -R /cores;
+
+ echo "Set core pattern.";
+ adb shell 'echo /cores/core.%p > /proc/sys/kernel/core_pattern';
+
+ echo "Done."
+}
+
+# coredump_enable - enable core dumps for the specified process
+# $1 = PID of process (e.g., $(pid mediaserver))
+#
+# NOTE: coredump_setup must have been called as well for a core
+# dump to actually be generated.
+
+function coredump_enable()
+{
+ local PID=$1;
+ if [ -z "$PID" ]; then
+ printf "Expecting a PID!\n";
+ return;
+ fi;
+ echo "Setting core limit for $PID to infinite...";
+ adb shell prlimit $PID 4 -1 -1
+}
+
+# core - send SIGV and pull the core for process
+# $1 = PID of process (e.g., $(pid mediaserver))
+#
+# NOTE: coredump_setup must be called once per boot for core dumps to be
+# enabled globally.
+
+function core()
+{
+ local PID=$1;
+
+ if [ -z "$PID" ]; then
+ printf "Expecting a PID!\n";
+ return;
+ fi;
+
+ local CORENAME=core.$PID;
+ local COREPATH=/cores/$CORENAME;
+ local SIG=SEGV;
+
+ coredump_enable $1;
+
+ local done=0;
+ while [ $(adb shell "[ -d /proc/$PID ] && echo -n yes") ]; do
+ printf "\tSending SIG%s to %d...\n" $SIG $PID;
+ adb shell kill -$SIG $PID;
+ sleep 1;
+ done;
+
+ adb shell "while [ ! -f $COREPATH ] ; do echo waiting for $COREPATH to be generated; sleep 1; done"
+ echo "Done: core is under $COREPATH on device.";
+}
+
+# systemstack - dump the current stack trace of all threads in the system process
+# to the usual ANR traces file
+function systemstack()
+{
+ stacks system_server
+}
+
+function stacks()
+{
+ if [[ $1 =~ ^[0-9]+$ ]] ; then
+ local PID="$1"
+ elif [ "$1" ] ; then
+ local PIDLIST="$(pid $1)"
+ if [[ $PIDLIST =~ ^[0-9]+$ ]] ; then
+ local PID="$PIDLIST"
+ elif [ "$PIDLIST" ] ; then
+ echo "more than one process: $1"
+ else
+ echo "no such process: $1"
+ fi
+ else
+ echo "usage: stacks [pid|process name]"
+ fi
+
+ if [ "$PID" ] ; then
+ # Determine whether the process is native
+ if adb shell ls -l /proc/$PID/exe | grep -q /system/bin/app_process ; then
+ # Dump stacks of Dalvik process
+ local TRACES=/data/anr/traces.txt
+ local ORIG=/data/anr/traces.orig
+ local TMP=/data/anr/traces.tmp
+
+ # Keep original traces to avoid clobbering
+ adb shell mv $TRACES $ORIG
+
+ # Make sure we have a usable file
+ adb shell touch $TRACES
+ adb shell chmod 666 $TRACES
+
+ # Dump stacks and wait for dump to finish
+ adb shell kill -3 $PID
+ adb shell notify $TRACES >/dev/null
+
+ # Restore original stacks, and show current output
+ adb shell mv $TRACES $TMP
+ adb shell mv $ORIG $TRACES
+ adb shell cat $TMP
+ else
+ # Dump stacks of native process
+ local USE64BIT="$(is64bit $PID)"
+ adb shell debuggerd$USE64BIT -b $PID
+ fi
+ fi
+}
+
+# Read the ELF header from /proc/$PID/exe to determine if the process is
+# 64-bit.
+function is64bit()
+{
+ local PID="$1"
+ if [ "$PID" ] ; then
+ if [[ "$(adb shell cat /proc/$PID/exe | xxd -l 1 -s 4 -ps)" -eq "02" ]] ; then
+ echo "64"
+ else
+ echo ""
+ fi
+ else
+ echo ""
+ fi
+}
+
+case `uname -s` in
+ Darwin)
+ function sgrep()
+ {
+ find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cc|cpp|S|java|xml|sh|mk|aidl|vts)' \
+ -exec grep --color -n "$@" {} +
+ }
+
+ ;;
+ *)
+ function sgrep()
+ {
+ find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cc\|cpp\|S\|java\|xml\|sh\|mk\|aidl\|vts\)' \
+ -exec grep --color -n "$@" {} +
+ }
+ ;;
+esac
+
+function gettargetarch
+{
+ get_build_var TARGET_ARCH
+}
+
+function ggrep()
+{
+ find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" \
+ -exec grep --color -n "$@" {} +
+}
+
+function jgrep()
+{
+ find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.java" \
+ -exec grep --color -n "$@" {} +
+}
+
+function cgrep()
+{
+ find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) \
+ -exec grep --color -n "$@" {} +
+}
+
+function resgrep()
+{
+ for dir in `find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -name res -type d`; do
+ find $dir -type f -name '*\.xml' -exec grep --color -n "$@" {} +
+ done
+}
+
+function mangrep()
+{
+ find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' \
+ -exec grep --color -n "$@" {} +
+}
+
+function sepgrep()
+{
+ find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d \
+ -exec grep --color -n -r --exclude-dir=\.git "$@" {} +
+}
+
+function rcgrep()
+{
+ find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.rc*" \
+ -exec grep --color -n "$@" {} +
+}
+
+case `uname -s` in
+ Darwin)
+ function mgrep()
+ {
+ find -E . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' \
+ -exec grep --color -n "$@" {} +
+ }
+
+ function treegrep()
+ {
+ find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml)' \
+ -exec grep --color -n -i "$@" {} +
+ }
+
+ ;;
+ *)
+ function mgrep()
+ {
+ find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f \
+ -exec grep --color -n "$@" {} +
+ }
+
+ function treegrep()
+ {
+ find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f \
+ -exec grep --color -n -i "$@" {} +
+ }
+
+ ;;
+esac
+
+function getprebuilt
+{
+ get_abs_build_var ANDROID_PREBUILTS
+}
+
+function tracedmdump()
+{
+ T=$(gettop)
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ return
+ fi
+ local prebuiltdir=$(getprebuilt)
+ local arch=$(gettargetarch)
+ local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu
+
+ local TRACE=$1
+ if [ ! "$TRACE" ] ; then
+ echo "usage: tracedmdump tracename"
+ return
+ fi
+
+ if [ ! -r "$KERNEL" ] ; then
+ echo "Error: cannot find kernel: '$KERNEL'"
+ return
+ fi
+
+ local BASETRACE=$(basename $TRACE)
+ if [ "$BASETRACE" = "$TRACE" ] ; then
+ TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE
+ fi
+
+ echo "post-processing traces..."
+ rm -f $TRACE/qtrace.dexlist
+ post_trace $TRACE
+ if [ $? -ne 0 ]; then
+ echo "***"
+ echo "*** Error: malformed trace. Did you remember to exit the emulator?"
+ echo "***"
+ return
+ fi
+ echo "generating dexlist output..."
+ /bin/ls $ANDROID_PRODUCT_OUT/system/framework/*.jar $ANDROID_PRODUCT_OUT/system/app/*.apk $ANDROID_PRODUCT_OUT/data/app/*.apk 2>/dev/null | xargs dexlist > $TRACE/qtrace.dexlist
+ echo "generating dmtrace data..."
+ q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return
+ echo "generating html file..."
+ dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return
+ echo "done, see $TRACE/dmtrace.html for details"
+ echo "or run:"
+ echo " traceview $TRACE/dmtrace"
+}
+
+# communicate with a running device or emulator, set up necessary state,
+# and run the hat command.
+function runhat()
+{
+ # process standard adb options
+ local adbTarget=""
+ if [ "$1" = "-d" -o "$1" = "-e" ]; then
+ adbTarget=$1
+ shift 1
+ elif [ "$1" = "-s" ]; then
+ adbTarget="$1 $2"
+ shift 2
+ fi
+ local adbOptions=${adbTarget}
+ #echo adbOptions = ${adbOptions}
+
+ # runhat options
+ local targetPid=$1
+
+ if [ "$targetPid" = "" ]; then
+ echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
+ return
+ fi
+
+ # confirm hat is available
+ if [ -z $(which hat) ]; then
+ echo "hat is not available in this configuration."
+ return
+ fi
+
+ # issue "am" command to cause the hprof dump
+ local devFile=/data/local/tmp/hprof-$targetPid
+ echo "Poking $targetPid and waiting for data..."
+ echo "Storing data at $devFile"
+ adb ${adbOptions} shell am dumpheap $targetPid $devFile
+ echo "Press enter when logcat shows \"hprof: heap dump completed\""
+ echo -n "> "
+ read
+
+ local localFile=/tmp/$$-hprof
+
+ echo "Retrieving file $devFile..."
+ adb ${adbOptions} pull $devFile $localFile
+
+ adb ${adbOptions} shell rm $devFile
+
+ echo "Running hat on $localFile"
+ echo "View the output by pointing your browser at http://localhost:7000/"
+ echo ""
+ hat -JXmx512m $localFile
+}
+
+function getbugreports()
+{
+ local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`)
+
+ if [ ! "$reports" ]; then
+ echo "Could not locate any bugreports."
+ return
+ fi
+
+ local report
+ for report in ${reports[@]}
+ do
+ echo "/sdcard/bugreports/${report}"
+ adb pull /sdcard/bugreports/${report} ${report}
+ gunzip ${report}
+ done
+}
+
+function getsdcardpath()
+{
+ adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\}
+}
+
+function getscreenshotpath()
+{
+ echo "$(getsdcardpath)/Pictures/Screenshots"
+}
+
+function getlastscreenshot()
+{
+ local screenshot_path=$(getscreenshotpath)
+ local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1`
+ if [ "$screenshot" = "" ]; then
+ echo "No screenshots found."
+ return
+ fi
+ echo "${screenshot}"
+ adb ${adbOptions} pull ${screenshot_path}/${screenshot}
+}
+
+function startviewserver()
+{
+ local port=4939
+ if [ $# -gt 0 ]; then
+ port=$1
+ fi
+ adb shell service call window 1 i32 $port
+}
+
+function stopviewserver()
+{
+ adb shell service call window 2
+}
+
+function isviewserverstarted()
+{
+ adb shell service call window 3
+}
+
+function key_home()
+{
+ adb shell input keyevent 3
+}
+
+function key_back()
+{
+ adb shell input keyevent 4
+}
+
+function key_menu()
+{
+ adb shell input keyevent 82
+}
+
+function smoketest()
+{
+ if [ ! "$ANDROID_PRODUCT_OUT" ]; then
+ echo "Couldn't locate output files. Try running 'lunch' first." >&2
+ return
+ fi
+ T=$(gettop)
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP." >&2
+ return
+ fi
+
+ (\cd "$T" && mmm tests/SmokeTest) &&
+ adb uninstall com.android.smoketest > /dev/null &&
+ adb uninstall com.android.smoketest.tests > /dev/null &&
+ adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk &&
+ adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk &&
+ adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner
+}
+
+# simple shortcut to the runtest command
+function runtest()
+{
+ T=$(gettop)
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP." >&2
+ return
+ fi
+ ("$T"/development/testrunner/runtest.py $@)
+}
+
+function godir () {
+ if [[ -z "$1" ]]; then
+ echo "Usage: godir "
+ return
+ fi
+ T=$(gettop)
+ if [ ! "$OUT_DIR" = "" ]; then
+ mkdir -p $OUT_DIR
+ FILELIST=$OUT_DIR/filelist
+ else
+ FILELIST=$T/filelist
+ fi
+ if [[ ! -f $FILELIST ]]; then
+ echo -n "Creating index..."
+ (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > $FILELIST)
+ echo " Done"
+ echo ""
+ fi
+ local lines
+ lines=($(\grep "$1" $FILELIST | sed -e 's/\/[^/]*$//' | sort | uniq))
+ if [[ ${#lines[@]} = 0 ]]; then
+ echo "Not found"
+ return
+ fi
+ local pathname
+ local choice
+ if [[ ${#lines[@]} > 1 ]]; then
+ while [[ -z "$pathname" ]]; do
+ local index=1
+ local line
+ for line in ${lines[@]}; do
+ printf "%6s %s\n" "[$index]" $line
+ index=$(($index + 1))
+ done
+ echo
+ echo -n "Select one: "
+ unset choice
+ read choice
+ if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
+ echo "Invalid choice"
+ continue
+ fi
+ pathname=${lines[$(($choice-1))]}
+ done
+ else
+ pathname=${lines[0]}
+ fi
+ \cd $T/$pathname
+}
+
+# Force JAVA_HOME to point to java 1.7/1.8 if it isn't already set.
+function set_java_home() {
+ # Clear the existing JAVA_HOME value if we set it ourselves, so that
+ # we can reset it later, depending on the version of java the build
+ # system needs.
+ #
+ # If we don't do this, the JAVA_HOME value set by the first call to
+ # build/envsetup.sh will persist forever.
+ if [ -n "$ANDROID_SET_JAVA_HOME" ]; then
+ export JAVA_HOME=""
+ fi
+
+ if [ ! "$JAVA_HOME" ]; then
+ if [ -n "$LEGACY_USE_JAVA7" ]; then
+ echo Warning: Support for JDK 7 will be dropped. Switch to JDK 8.
+ case `uname -s` in
+ Darwin)
+ export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
+ ;;
+ *)
+ export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
+ ;;
+ esac
+ else
+ case `uname -s` in
+ Darwin)
+ export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
+ ;;
+ *)
+ export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
+ ;;
+ esac
+ fi
+
+ # Keep track of the fact that we set JAVA_HOME ourselves, so that
+ # we can change it on the next envsetup.sh, if required.
+ export ANDROID_SET_JAVA_HOME=true
+ fi
+}
+
+# Print colored exit condition
+function pez {
+ "$@"
+ local retval=$?
+ if [ $retval -ne 0 ]
+ then
+ echo $'\E'"[0;31mFAILURE\e[00m"
+ else
+ echo $'\E'"[0;32mSUCCESS\e[00m"
+ fi
+ return $retval
+}
+
+function get_make_command()
+{
+ echo command make
+}
+
+function make()
+{
+ local start_time=$(date +"%s")
+ $(get_make_command) "$@"
+ local ret=$?
+ local end_time=$(date +"%s")
+ local tdiff=$(($end_time-$start_time))
+ local hours=$(($tdiff / 3600 ))
+ local mins=$((($tdiff % 3600) / 60))
+ local secs=$(($tdiff % 60))
+ local ncolors=$(tput colors 2>/dev/null)
+ if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
+ color_failed=$'\E'"[0;31m"
+ color_success=$'\E'"[0;32m"
+ color_reset=$'\E'"[00m"
+ else
+ color_failed=""
+ color_success=""
+ color_reset=""
+ fi
+ echo
+ if [ $ret -eq 0 ] ; then
+ echo -n "${color_success}#### make completed successfully "
+ else
+ echo -n "${color_failed}#### make failed to build some targets "
+ fi
+ if [ $hours -gt 0 ] ; then
+ printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
+ elif [ $mins -gt 0 ] ; then
+ printf "(%02g:%02g (mm:ss))" $mins $secs
+ elif [ $secs -gt 0 ] ; then
+ printf "(%s seconds)" $secs
+ fi
+ echo " ####${color_reset}"
+ echo
+ return $ret
+}
+
+function provision()
+{
+ if [ ! "$ANDROID_PRODUCT_OUT" ]; then
+ echo "Couldn't locate output files. Try running 'lunch' first." >&2
+ return 1
+ fi
+ if [ ! -e "$ANDROID_PRODUCT_OUT/provision-device" ]; then
+ echo "There is no provisioning script for the device." >&2
+ return 1
+ fi
+
+ # Check if user really wants to do this.
+ if [ "$1" = "--no-confirmation" ]; then
+ shift 1
+ else
+ echo "This action will reflash your device."
+ echo ""
+ echo "ALL DATA ON THE DEVICE WILL BE IRREVOCABLY ERASED."
+ echo ""
+ echo -n "Are you sure you want to do this (yes/no)? "
+ read
+ if [[ "${REPLY}" != "yes" ]] ; then
+ echo "Not taking any action. Exiting." >&2
+ return 1
+ fi
+ fi
+ "$ANDROID_PRODUCT_OUT/provision-device" "$@"
+}
+
+if [ "x$SHELL" != "x/bin/bash" ]; then
+ case `ps -o command -p $$` in
+ *bash*)
+ ;;
+ *)
+ echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
+ ;;
+ esac
+fi
+
+# Execute the contents of any vendorsetup.sh files we can find.
+for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
+ `test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
+ `test -d product && find -L product -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort`
+do
+ echo "including $f"
+ . $f
+done
+unset f
+
+addcompletions
diff --git a/libs/host/Android.mk b/libs/host/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..bc25e4b7638085d752edf2e71512d93906cd5f40
--- /dev/null
+++ b/libs/host/Android.mk
@@ -0,0 +1,22 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ CopyFile.c
+
+LOCAL_CFLAGS := -Werror -Wall
+
+LOCAL_MODULE:= libhost
+LOCAL_MODULE_HOST_OS := darwin linux windows
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+LOCAL_CXX_STL := none
+
+# acp uses libhost, so we can't use
+# acp to install libhost.
+LOCAL_ACP_UNAVAILABLE:= true
+
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+# Include toolchain prebuilt modules if they exist.
+-include $(TARGET_TOOLCHAIN_ROOT)/toolchain.mk
diff --git a/libs/host/CopyFile.c b/libs/host/CopyFile.c
new file mode 100644
index 0000000000000000000000000000000000000000..5be012cf3de8fcc38a6dba21c846fc87cb427f3d
--- /dev/null
+++ b/libs/host/CopyFile.c
@@ -0,0 +1,596 @@
+/*
+ * Copyright 2005 The Android Open Source Project
+ *
+ * Android "cp" replacement.
+ *
+ * The GNU/Linux "cp" uses O_LARGEFILE in its open() calls, utimes() instead
+ * of utime(), and getxattr()/setxattr() instead of chmod(). These are
+ * probably "better", but are non-portable, and not necessary for our
+ * purposes.
+ */
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#if defined(_WIN32)
+#include /* For _mkdir() */
+# define mkdir(path,mode) _mkdir(path)
+# define S_ISLNK(s) 0
+# define lstat stat
+# ifndef EACCESS /* seems to be missing from the Mingw headers */
+# define EACCESS 13
+# endif
+#endif
+
+#ifndef O_BINARY
+# define O_BINARY 0
+#endif
+
+/*#define DEBUG_MSGS*/
+#ifdef DEBUG_MSGS
+# define DBUG(x) printf x
+#else
+# define DBUG(x) ((void)0)
+#endif
+
+#define FSSEP '/' /* filename separator char */
+
+static int copyFileRecursive(const char* src, const char* dst, bool isCmdLine, unsigned int options);
+
+/*
+ * Returns true if the source file is newer than the destination file.
+ *
+ * The check is based on the modification date, whole seconds only. This
+ * also returns true if the file sizes don't match.
+ */
+static bool isSourceNewer(const struct stat* pSrcStat, const struct stat* pDstStat)
+{
+ return (pSrcStat->st_mtime > pDstStat->st_mtime) ||
+ (pSrcStat->st_size != pDstStat->st_size);
+}
+
+/*
+ * Returns true if the source file has high resolution modification
+ * date. Cygwin/Mingw doesn't support st_mtim and always returns false.
+ */
+static bool isHiresMtime(const struct stat* pSrcStat)
+{
+#if defined(_WIN32)
+ return 0;
+#elif defined(__APPLE__)
+ return pSrcStat->st_mtimespec.tv_nsec > 0;
+#else
+ return pSrcStat->st_mtim.tv_nsec > 0;
+#endif
+}
+
+/*
+ * Returns true if the source and destination files are actually the
+ * same thing. We detect this by checking the inode numbers, which seems
+ * to work on Cygwin.
+ */
+static bool isSameFile(const struct stat* pSrcStat, const struct stat* pDstStat)
+{
+#if defined(_WIN32)
+ (void)pSrcStat;
+ (void)pDstStat;
+ /* with MSVCRT.DLL, stat always sets st_ino to 0, and there is no simple way to */
+ /* get the equivalent information with Win32 (Cygwin does some weird stuff in */
+ /* its winsup/cygwin/fhandler_disk_file.cc to emulate this, too complex for us) */
+ return 0;
+#else
+ return (pSrcStat->st_ino == pDstStat->st_ino);
+#endif
+}
+
+static void printCopyMsg(const char* src, const char* dst, unsigned int options)
+{
+ if ((options & COPY_VERBOSE_MASK) > 0)
+ printf(" '%s' --> '%s'\n", src, dst);
+}
+
+static void printNotNewerMsg(const char* src, const char* dst, unsigned int options)
+{
+ (void)src;
+ if ((options & COPY_VERBOSE_MASK) > 1)
+ printf(" '%s' is up-to-date\n", dst);
+}
+
+/*
+ * Copy the contents of one file to another.
+ *
+ * The files are assumed to be seeked to the start.
+ */
+static int copyFileContents(const char* dst, int dstFd, const char* src, int srcFd)
+{
+ unsigned char buf[8192];
+ ssize_t readCount, writeCount;
+
+ /*
+ * Read a chunk, write it, and repeat.
+ */
+ while (1) {
+ readCount = read(srcFd, buf, sizeof(buf));
+ if (readCount < 0) {
+ fprintf(stderr,
+ "acp: failed reading '%s': %s\n", src, strerror(errno));
+ return -1;
+ }
+
+ if (readCount > 0) {
+ writeCount = write(dstFd, buf, readCount);
+ if (writeCount < 0) {
+ fprintf(stderr,
+ "acp: failed writing '%s': %s\n", dst, strerror(errno));
+ return -1;
+ }
+ if (writeCount != readCount) {
+ fprintf(stderr, "acp: partial write to '%s' (%zd of %zd)\n",
+ dst, writeCount, readCount);
+ return -1;
+ }
+ }
+
+ if (readCount < (ssize_t) sizeof(buf))
+ break;
+ }
+
+ return 0;
+}
+
+/*
+ * Set the permissions, owner, and timestamps on the destination file
+ * equal to those of the source file.
+ *
+ * Failures here are "soft"; they don't produce warning messages and don't
+ * cause the cp command to report a failure.
+ */
+static int setPermissions(const char* dst, const struct stat* pSrcStat, unsigned int options)
+{
+ struct utimbuf ut;
+
+ if (options & COPY_TIMESTAMPS) {
+ /*
+ * Start with timestamps. The access and mod dates are not affected
+ * by the next operations.
+ */
+ ut.actime = pSrcStat->st_atime;
+ ut.modtime = pSrcStat->st_mtime;
+ if (isHiresMtime(pSrcStat))
+ ut.modtime += 1;
+ if (utime(dst, &ut) != 0) {
+ DBUG(("--- unable to set timestamps on '%s': %s\n",
+ dst, strerror(errno)));
+ }
+ }
+
+ if (options & COPY_PERMISSIONS) {
+ /*
+ * Set the permissions.
+ */
+ if (chmod(dst, pSrcStat->st_mode & ~(S_IFMT)) != 0) {
+ DBUG(("--- unable to set perms on '%s' to 0%o: %s\n",
+ dst, pSrcStat->st_mode & ~(S_IFMT), strerror(errno)));
+ }
+#ifndef _WIN32
+ /*
+ * Set the owner.
+ */
+ if (chown(dst, pSrcStat->st_uid, pSrcStat->st_gid) != 0) {
+ DBUG(("--- unable to set owner of '%s' to %d/%d: %s\n",
+ dst, pSrcStat->st_uid, pSrcStat->st_gid, strerror(errno)));
+ }
+#endif
+ }
+
+ return 0;
+}
+
+/*
+ * Copy a regular file. If the destination file exists and is not a
+ * regular file, we fail. However, we use stat() rather than lstat(),
+ * because it's okay to write through a symlink (the noDereference stuff
+ * only applies to the source file).
+ *
+ * If the file doesn't exist, create it. If it does exist, truncate it.
+ */
+static int copyRegular(const char* src, const char* dst, const struct stat* pSrcStat, unsigned int options)
+{
+ struct stat dstStat;
+ int srcFd, dstFd, statResult, copyResult;
+
+ DBUG(("--- copying regular '%s' to '%s'\n", src, dst));
+
+ statResult = stat(dst, &dstStat);
+ if (statResult == 0 && !S_ISREG(dstStat.st_mode)) {
+ fprintf(stderr,
+ "acp: destination '%s' exists and is not regular file\n",
+ dst);
+ return -1;
+ } else if (statResult != 0 && errno != ENOENT) {
+ fprintf(stderr, "acp: unable to stat destination '%s'\n", dst);
+ return -1;
+ }
+
+ if (statResult == 0) {
+ if (isSameFile(pSrcStat, &dstStat)) {
+ fprintf(stderr, "acp: '%s' and '%s' are the same file\n",
+ src, dst);
+ return -1;
+ }
+ if (options & COPY_UPDATE_ONLY) {
+ if (!isSourceNewer(pSrcStat, &dstStat)) {
+ DBUG(("--- source is not newer: '%s'\n", src));
+ printNotNewerMsg(src, dst, options);
+ return 0;
+ }
+ }
+ }
+
+ /* open src */
+ srcFd = open(src, O_RDONLY | O_BINARY, 0);
+ if (srcFd < 0) {
+ fprintf(stderr, "acp: unable to open '%s': %s\n", src, strerror(errno));
+ return -1;
+ }
+
+ /* open dest with O_CREAT | O_TRUNC */
+ DBUG(("--- opening '%s'\n", dst));
+ dstFd = open(dst, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
+
+ if (dstFd < 0) {
+ if (errno == ENOENT) {
+ /* this happens if the target directory doesn't exist */
+ fprintf(stderr,
+ "acp: cannot create '%s': %s\n", dst, strerror(errno));
+ (void) close(srcFd);
+ return -1;
+ }
+
+ /* if "force" is set, try removing the destination file and retry */
+ if (options & COPY_FORCE) {
+ if (unlink(dst) != 0) {
+#ifdef _WIN32
+ /* MSVCRT.DLL unlink will fail with EACCESS if the file is set read-only */
+ /* so try to change its mode, and unlink again */
+ if (errno == EACCESS) {
+ if (chmod(dst, S_IWRITE|S_IREAD) == 0 && unlink(dst) == 0)
+ goto Open_File;
+ }
+#endif
+ fprintf(stderr, "acp: unable to remove '%s': %s\n",
+ dst, strerror(errno));
+ (void) close(srcFd);
+ return -1;
+ }
+#ifdef _WIN32
+ Open_File:
+#endif
+ dstFd = open(dst, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0644);
+ }
+ }
+ if (dstFd < 0) {
+ fprintf(stderr, "acp: unable to open '%s': %s\n",
+ dst, strerror(errno));
+ (void) close(srcFd);
+ return -1;
+ }
+
+ copyResult = copyFileContents(dst, dstFd, src, srcFd);
+
+ (void) close(srcFd);
+ (void) close(dstFd);
+ if (copyResult != 0)
+ return -1;
+
+#if defined(__APPLE__)
+ // Copy Mac OS X resource forks too.
+ {
+ char* srcRsrcName = NULL;
+ char* dstRsrcName = NULL;
+ struct stat rsrcStat;
+
+ srcRsrcName = malloc(strlen(src) + 5 + 1);
+ strcpy(srcRsrcName, src);
+ strcat(srcRsrcName, "/rsrc");
+
+ dstRsrcName = malloc(strlen(dst) + 5 + 1);
+ strcpy(dstRsrcName, dst);
+ strcat(dstRsrcName, "/rsrc");
+
+ if (stat(srcRsrcName, &rsrcStat) == 0 && rsrcStat.st_size > 0) {
+ DBUG(("--- RSRC: %s --> %s\n", srcRsrcName, dstRsrcName));
+
+ srcFd = open(srcRsrcName, O_RDONLY);
+ dstFd = open(dstRsrcName, O_TRUNC | O_WRONLY, 0);
+ copyResult = -1;
+ if (srcFd >= 0 && dstFd >= 0) {
+ copyResult = copyFileContents(dstRsrcName, dstFd,
+ srcRsrcName, srcFd);
+ (void) close(srcFd);
+ (void) close(dstFd);
+ }
+
+ if (copyResult != 0)
+ return -1;
+ }
+
+ free(srcRsrcName);
+ free(dstRsrcName);
+ }
+#endif
+
+ setPermissions(dst, pSrcStat, options);
+
+ printCopyMsg(src, dst, options);
+
+ return 0;
+}
+
+
+/*
+ * Copy a symlink. This only happens if we're in "no derefence" mode,
+ * in which we copy the links rather than the files that are pointed at.
+ *
+ * We always discard the destination file. If it's a symlink already,
+ * we want to throw it out and replace it. If it's not a symlink, we
+ * need to trash it so we can create one.
+ */
+#if defined(_WIN32)
+extern int copySymlink(const char* src, const char* dst, const struct stat* pSrcStat, unsigned int options) __attribute__((error("no symlinks on Windows")));
+#else
+static int copySymlink(const char* src, const char* dst, const struct stat* pSrcStat, unsigned int options)
+{
+ struct stat dstStat;
+ char linkBuf[PATH_MAX+1];
+ int statResult, nameLen;
+
+ assert(options & COPY_NO_DEREFERENCE);
+ DBUG(("--- copying symlink '%s' to '%s'\n", src, dst));
+
+ /* NOTE: we use lstat() here */
+ statResult = lstat(dst, &dstStat);
+ if (statResult == 0 && !S_ISREG(dstStat.st_mode)
+ && !S_ISLNK(dstStat.st_mode)
+ )
+ {
+ fprintf(stderr,
+ "acp: destination '%s' exists and is not regular or symlink\n",
+ dst);
+ return -1;
+ }
+
+ if (statResult == 0) {
+ if (isSameFile(pSrcStat, &dstStat)) {
+ fprintf(stderr, "acp: '%s' and '%s' are the same file\n",
+ src, dst);
+ return -1;
+ }
+ if (options & COPY_UPDATE_ONLY) {
+ if (!isSourceNewer(pSrcStat, &dstStat)) {
+ DBUG(("--- source is not newer: '%s'\n", src));
+ printNotNewerMsg(src, dst, options);
+ return 0;
+ }
+ }
+ }
+
+ /* extract the symlink contents */
+ nameLen = readlink(src, linkBuf, sizeof(linkBuf)-1);
+ if (nameLen <= 0) {
+ fprintf(stderr, "acp: unable to read symlink '%s': %s\n",
+ src, strerror(errno));
+ return -1;
+ }
+ linkBuf[nameLen] = '\0';
+ DBUG(("--- creating symlink file '%s' (--> %s)\n", dst, linkBuf));
+
+ if (statResult == 0) {
+ DBUG(("--- removing '%s'\n", dst));
+ if (unlink(dst) != 0) {
+ fprintf(stderr, "acp: unable to remove '%s': %s\n",
+ dst, strerror(errno));
+ return -1;
+ }
+ }
+
+ if (symlink(linkBuf, dst) != 0) {
+ fprintf(stderr, "acp: unable to create symlink '%s' [%s]: %s\n",
+ dst, linkBuf, strerror(errno));
+ return -1;
+ }
+
+ /*
+ * There's no way to set the file date or access permissions, but
+ * it is possible to set the owner.
+ */
+ if (options & COPY_PERMISSIONS) {
+ if (lchown(dst, pSrcStat->st_uid, pSrcStat->st_gid) != 0)
+ DBUG(("--- lchown failed: %s\n", strerror(errno)));
+ }
+
+ printCopyMsg(src, dst, options);
+
+ return 0;
+}
+#endif
+
+/*
+ * Copy the contents of one directory to another. Both "src" and "dst"
+ * must be directories. We will create "dst" if it does not exist.
+ */
+int copyDirectory(const char* src, const char* dst, const struct stat* pSrcStat, unsigned int options)
+{
+ int retVal = 0;
+ struct stat dstStat;
+ DIR* dir;
+ int cc, statResult;
+
+ DBUG(("--- copy dir '%s' to '%s'\n", src, dst));
+
+ statResult = stat(dst, &dstStat);
+ if (statResult == 0 && !S_ISDIR(dstStat.st_mode)) {
+ fprintf(stderr,
+ "acp: destination '%s' exists and is not a directory\n", dst);
+ return -1;
+ } else if (statResult != 0 && errno != ENOENT) {
+ fprintf(stderr, "acp: unable to stat destination '%s'\n", dst);
+ return -1;
+ }
+
+ if (statResult == 0) {
+ if (isSameFile(pSrcStat, &dstStat)) {
+ fprintf(stderr,
+ "acp: cannot copy directory into itself ('%s' and '%s')\n",
+ src, dst);
+ return -1;
+ }
+ } else {
+ DBUG(("--- creating dir '%s'\n", dst));
+ cc = mkdir(dst, 0755);
+ if (cc != 0) {
+ fprintf(stderr, "acp: unable to create directory '%s': %s\n",
+ dst, strerror(errno));
+ return -1;
+ }
+
+ /* only print on mkdir */
+ printCopyMsg(src, dst, options);
+ }
+
+ /*
+ * Open the directory, and plow through its contents.
+ */
+ dir = opendir(src);
+ if (dir == NULL) {
+ fprintf(stderr, "acp: unable to open directory '%s': %s\n",
+ src, strerror(errno));
+ return -1;
+ }
+
+ while (1) {
+ struct dirent* ent;
+ char* srcFile;
+ char* dstFile;
+ int srcLen, dstLen, nameLen;
+
+ ent = readdir(dir);
+ if (ent == NULL)
+ break;
+
+ if (strcmp(ent->d_name, ".") == 0 ||
+ strcmp(ent->d_name, "..") == 0)
+ {
+ continue;
+ }
+
+ nameLen = strlen(ent->d_name);
+ srcLen = strlen(src);
+ dstLen = strlen(dst);
+
+ srcFile = malloc(srcLen +1 + nameLen +1);
+ memcpy(srcFile, src, srcLen);
+ srcFile[srcLen] = FSSEP;
+ memcpy(srcFile + srcLen+1, ent->d_name, nameLen +1);
+
+ dstFile = malloc(dstLen +1 + nameLen +1);
+ memcpy(dstFile, dst, dstLen);
+ dstFile[dstLen] = FSSEP;
+ memcpy(dstFile + dstLen+1, ent->d_name, nameLen +1);
+
+ if (copyFileRecursive(srcFile, dstFile, false, options) != 0)
+ retVal = -1; /* note failure and keep going */
+
+ free(srcFile);
+ free(dstFile);
+ }
+ closedir(dir);
+
+ setPermissions(dst, pSrcStat, options);
+
+ return retVal;
+}
+
+/*
+ * Do the actual copy. This is called recursively from copyDirectory().
+ *
+ * "dst" should only be a directory if "src" is also a directory.
+ *
+ * Returns 0 on success.
+ */
+static int copyFileRecursive(const char* src, const char* dst, bool isCmdLine, unsigned int options)
+{
+ char* srcExe = NULL;
+ char* dstExe = NULL;
+ char* dstDir = NULL;
+ struct stat srcStat;
+ int retVal = 0;
+ int statResult, statErrno;
+ (void)isCmdLine;
+
+ /*
+ * Stat the source file. If it doesn't exist, fail.
+ */
+ if (options & COPY_NO_DEREFERENCE)
+ statResult = lstat(src, &srcStat);
+ else
+ statResult = stat(src, &srcStat);
+ statErrno = errno; /* preserve across .exe attempt */
+
+ if (statResult < 0) {
+ if (statErrno == ENOENT)
+ fprintf(stderr, "acp: file '%s' does not exist\n", src);
+ else
+ fprintf(stderr, "acp: unable to stat '%s': %s\n",
+ src, strerror(statErrno));
+ retVal = -1;
+ goto bail;
+ }
+
+ /*
+ * If "src" is a directory, ignore it if "recursive" isn't set.
+ *
+ * We want to create "dst" as a directory (or verify that it already
+ * exists as a directory), and then copy its contents.
+ */
+ if (S_ISDIR(srcStat.st_mode)) {
+ if (!(options & COPY_RECURSIVE)) {
+ fprintf(stderr, "acp: omitting directory '%s'\n", src);
+ } else {
+ retVal = copyDirectory(src, dst, &srcStat, options);
+ }
+ } else if (S_ISLNK(srcStat.st_mode)) {
+ retVal = copySymlink(src, dst, &srcStat, options);
+ } else if (S_ISREG(srcStat.st_mode)) {
+ retVal = copyRegular(src, dst, &srcStat, options);
+ } else {
+ fprintf(stderr, "acp: skipping unusual file '%s' (mode=0%o)\n",
+ src, srcStat.st_mode);
+ retVal = -1;
+ }
+
+bail:
+ free(srcExe);
+ free(dstExe);
+ free(dstDir);
+ return retVal;
+}
+
+int copyFile(const char* src, const char* dst, unsigned int options)
+{
+ return copyFileRecursive(src, dst, true, options);
+}
+
+
diff --git a/libs/host/include/host/CopyFile.h b/libs/host/include/host/CopyFile.h
new file mode 100644
index 0000000000000000000000000000000000000000..e65712b272fa14d0ff1e789eb782ad8b7086fa16
--- /dev/null
+++ b/libs/host/include/host/CopyFile.h
@@ -0,0 +1,30 @@
+#ifndef _HOST_COPYFILE_H
+#define _HOST_COPYFILE_H
+
+#include
+#include
+
+#if __cplusplus
+extern "C" {
+#endif
+
+// command line options
+enum {
+ COPY_NO_DEREFERENCE = 0x00010000, // copy symlink link instead of target
+ COPY_TRY_EXE = 0x00020000, // on Win32, try adding '.exe' to filename
+ COPY_FORCE = 0x00040000, // override access permissions
+ COPY_PERMISSIONS = 0x00080000, // preserve mode, ownership, timestamps
+ COPY_TIMESTAMPS = 0x00100000, // preserve mode, ownership, timestamps
+ COPY_RECURSIVE = 0x00200000, // copy directories
+ COPY_UPDATE_ONLY = 0x00400000, // only copy if source file is newer
+ COPY_VERBOSE_MASK = 0x000000ff // talk lots
+};
+
+int copyFile(const char* src, const char* dst, unsigned int options);
+
+#if __cplusplus
+} // extern "C"
+#endif
+
+#endif // _HOST_COPYFILE_H
+
diff --git a/target/board/Android.mk b/target/board/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..f8ecc4ef3aece6510326c7b97c19f8ce7ce79c22
--- /dev/null
+++ b/target/board/Android.mk
@@ -0,0 +1,27 @@
+#
+# Set up product-global definitions and include product-specific rules.
+#
+
+-include $(TARGET_DEVICE_DIR)/AndroidBoard.mk
+
+# Generate a file that contains various information about the
+# device we're building for. This file is typically packaged up
+# with everything else.
+#
+# If TARGET_BOARD_INFO_FILE (which can be set in BoardConfig.mk) is
+# defined, it is used, otherwise board-info.txt is looked for in
+# $(TARGET_DEVICE_DIR).
+#
+INSTALLED_ANDROID_INFO_TXT_TARGET := $(PRODUCT_OUT)/android-info.txt
+board_info_txt := $(TARGET_BOARD_INFO_FILE)
+ifndef board_info_txt
+board_info_txt := $(wildcard $(TARGET_DEVICE_DIR)/board-info.txt)
+endif
+$(INSTALLED_ANDROID_INFO_TXT_TARGET): $(board_info_txt)
+ $(hide) build/tools/check_radio_versions.py $< $(BOARD_INFO_CHECK)
+ $(call pretty,"Generated: ($@)")
+ifdef board_info_txt
+ $(hide) grep -v '#' $< > $@
+else
+ $(hide) echo "board=$(TARGET_BOOTLOADER_BOARD_NAME)" > $@
+endif
diff --git a/target/board/generic/AndroidBoard.mk b/target/board/generic/AndroidBoard.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7911f6105fbe0c7c3ab214b87c7df4b4d2302459
--- /dev/null
+++ b/target/board/generic/AndroidBoard.mk
@@ -0,0 +1 @@
+LOCAL_PATH := $(call my-dir)
diff --git a/target/board/generic/BoardConfig.mk b/target/board/generic/BoardConfig.mk
new file mode 100644
index 0000000000000000000000000000000000000000..02c1c88870bb24224a33570cb2847f7933006c1f
--- /dev/null
+++ b/target/board/generic/BoardConfig.mk
@@ -0,0 +1,61 @@
+# config.mk
+#
+# Product-specific compile-time definitions.
+#
+
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+TARGET_ARCH := arm
+
+# Note: we build the platform images for ARMv7-A _without_ NEON.
+#
+# Technically, the emulator supports ARMv7-A _and_ NEON instructions, but
+# emulated NEON code paths typically ends up 2x slower than the normal C code
+# it is supposed to replace (unlike on real devices where it is 2x to 3x
+# faster).
+#
+# What this means is that the platform image will not use NEON code paths
+# that are slower to emulate. On the other hand, it is possible to emulate
+# application code generated with the NDK that uses NEON in the emulator.
+#
+TARGET_ARCH_VARIANT := armv7-a
+TARGET_CPU_VARIANT := generic
+TARGET_CPU_ABI := armeabi-v7a
+TARGET_CPU_ABI2 := armeabi
+
+HAVE_HTC_AUDIO_DRIVER := true
+BOARD_USES_GENERIC_AUDIO := true
+
+# no hardware camera
+USE_CAMERA_STUB := true
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+ ifeq ($(WITH_DEXPREOPT),)
+ WITH_DEXPREOPT := true
+ endif
+endif
+
+# Build OpenGLES emulation guest and host libraries
+BUILD_EMULATOR_OPENGL := true
+
+# Build and enable the OpenGL ES View renderer. When running on the emulator,
+# the GLES renderer disables itself if host GL acceleration isn't available.
+USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1879048192 # 1.75 GB
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
+
+ifeq ($(TARGET_PRODUCT),sdk)
+ # include an expanded selection of fonts for the SDK.
+ EXTENDED_FONT_FOOTPRINT := true
+endif
diff --git a/target/board/generic/README.txt b/target/board/generic/README.txt
new file mode 100644
index 0000000000000000000000000000000000000000..ddac68e784dc2410291da1c7c933f015f7e9e65b
--- /dev/null
+++ b/target/board/generic/README.txt
@@ -0,0 +1,9 @@
+The "generic" product defines a non-hardware-specific target
+without a kernel or bootloader.
+
+It can be used to build the entire user-level system, and
+will work with the emulator, though sound will not work
+(see the "emulator" product for that).
+
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic/device.mk b/target/board/generic/device.mk
new file mode 100644
index 0000000000000000000000000000000000000000..e56a4d1d343ed9ab3beba61ae842b9a24a3aaf0d
--- /dev/null
+++ b/target/board/generic/device.mk
@@ -0,0 +1,32 @@
+#
+# Copyright (C) 2009 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 build configuration for the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.ril.hsxpa=1 \
+ ro.ril.gprsclass=10 \
+ ro.adb.qemud=1
+
+PRODUCT_COPY_FILES := \
+ device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ device/generic/goldfish/camera/media_profiles.xml:system/etc/media_profiles.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
+ device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml \
+ hardware/libhardware_legacy/audio/audio_policy.conf:system/etc/audio_policy.conf
diff --git a/target/board/generic/sepolicy/bootanim.te b/target/board/generic/sepolicy/bootanim.te
new file mode 100644
index 0000000000000000000000000000000000000000..b4b1eef832f7b38ddf486dc618829b6498d81d27
--- /dev/null
+++ b/target/board/generic/sepolicy/bootanim.te
@@ -0,0 +1,4 @@
+allow bootanim self:process execmem;
+allow bootanim ashmem_device:chr_file execute;
+
+set_prop(bootanim, qemu_prop)
diff --git a/target/board/generic/sepolicy/device.te b/target/board/generic/sepolicy/device.te
new file mode 100644
index 0000000000000000000000000000000000000000..d1294411975f50ae85f10e6f0e17cbbbf44e82ec
--- /dev/null
+++ b/target/board/generic/sepolicy/device.te
@@ -0,0 +1 @@
+type qemu_device, dev_type, mlstrustedobject;
diff --git a/target/board/generic/sepolicy/domain.te b/target/board/generic/sepolicy/domain.te
new file mode 100644
index 0000000000000000000000000000000000000000..5d5e4ac36fd4a5d58a2605ae2f0c815922b5605a
--- /dev/null
+++ b/target/board/generic/sepolicy/domain.te
@@ -0,0 +1,6 @@
+# For /sys/qemu_trace files in the emulator.
+allow domain sysfs_writable:dir search;
+allow domain sysfs_writable:file rw_file_perms;
+allow domain qemu_device:chr_file rw_file_perms;
+
+get_prop(domain, qemu_prop)
diff --git a/target/board/generic/sepolicy/file.te b/target/board/generic/sepolicy/file.te
new file mode 100644
index 0000000000000000000000000000000000000000..6fad80acbeab288c059c07ee53f6729da2c9a6f5
--- /dev/null
+++ b/target/board/generic/sepolicy/file.te
@@ -0,0 +1 @@
+type qemud_socket, file_type;
diff --git a/target/board/generic/sepolicy/file_contexts b/target/board/generic/sepolicy/file_contexts
new file mode 100644
index 0000000000000000000000000000000000000000..e9502d94850f8061a192da2f817f88a03e3f5ab0
--- /dev/null
+++ b/target/board/generic/sepolicy/file_contexts
@@ -0,0 +1,20 @@
+# goldfish
+/dev/block/mtdblock0 u:object_r:system_block_device:s0
+/dev/block/mtdblock1 u:object_r:userdata_block_device:s0
+/dev/block/mtdblock2 u:object_r:cache_block_device:s0
+
+# ranchu
+/dev/block/vda u:object_r:system_block_device:s0
+/dev/block/vdb u:object_r:cache_block_device:s0
+/dev/block/vdc u:object_r:userdata_block_device:s0
+
+/dev/goldfish_pipe u:object_r:qemu_device:s0
+/dev/goldfish_sync u:object_r:qemu_device:s0
+/dev/qemu_.* u:object_r:qemu_device:s0
+/dev/socket/qemud u:object_r:qemud_socket:s0
+/dev/ttyGF[0-9]* u:object_r:serial_device:s0
+/dev/ttyS2 u:object_r:console_device:s0
+/system/bin/qemud u:object_r:qemud_exec:s0
+/sys/qemu_trace(/.*)? u:object_r:sysfs_writable:s0
+/system/etc/init.goldfish.sh u:object_r:goldfish_setup_exec:s0
+/system/bin/qemu-props u:object_r:qemu_props_exec:s0
diff --git a/target/board/generic/sepolicy/goldfish_setup.te b/target/board/generic/sepolicy/goldfish_setup.te
new file mode 100644
index 0000000000000000000000000000000000000000..b8f121cda7feada7bdc7b5f0a9dd53820bc5c398
--- /dev/null
+++ b/target/board/generic/sepolicy/goldfish_setup.te
@@ -0,0 +1,27 @@
+# goldfish-setup service: runs init.goldfish.sh script
+type goldfish_setup, domain, domain_deprecated;
+type goldfish_setup_exec, exec_type, file_type;
+
+init_daemon_domain(goldfish_setup)
+
+# Inherit open file to shell (interpreter) for script.
+allow goldfish_setup shell_exec:file rx_file_perms;
+
+# Run ifconfig, route commands to configure interfaces and routes.
+allow goldfish_setup system_file:file execute_no_trans;
+allow goldfish_setup toolbox_exec:file rx_file_perms;
+allow goldfish_setup self:capability { net_admin net_raw };
+allow goldfish_setup self:udp_socket create_socket_perms;
+
+net_domain(goldfish_setup)
+
+# Set net.eth0.dns*, debug.sf.nobootanimation
+set_prop(goldfish_setup, system_prop)
+set_prop(goldfish_setup, debug_prop)
+
+# Set ro.radio.noril
+set_prop(goldfish_setup, radio_noril_prop)
+
+# Stop ril-daemon service (by setting ctl.stop to ril-daemon, which
+# transforms to a permission check on ctl.ril-daemon).
+set_prop(goldfish_setup, ctl_rildaemon_prop)
diff --git a/target/board/generic/sepolicy/init.te b/target/board/generic/sepolicy/init.te
new file mode 100644
index 0000000000000000000000000000000000000000..3aa81d1b5876120d5fa1f22f06f9f046f1116cef
--- /dev/null
+++ b/target/board/generic/sepolicy/init.te
@@ -0,0 +1 @@
+allow init tmpfs:lnk_file create_file_perms;
diff --git a/target/board/generic/sepolicy/logd.te b/target/board/generic/sepolicy/logd.te
new file mode 100644
index 0000000000000000000000000000000000000000..b3e60d78df902ec4ce948de08c00cadbb9af5783
--- /dev/null
+++ b/target/board/generic/sepolicy/logd.te
@@ -0,0 +1,11 @@
+# goldfish logcat service: runs logcat -Q in logd domain
+
+# See global logd.te, these only set for eng & userdebug, allow for all builds
+
+domain_auto_trans(init, logcat_exec, logd)
+
+# Read from logd.
+read_logd(logd)
+
+# Write to /dev/ttyS2 and /dev/ttyGF2.
+allow logd serial_device:chr_file { write open };
diff --git a/target/board/generic/sepolicy/netd.te b/target/board/generic/sepolicy/netd.te
new file mode 100644
index 0000000000000000000000000000000000000000..2b002ec9c6454950bed2e54922e1546e06fc35f5
--- /dev/null
+++ b/target/board/generic/sepolicy/netd.te
@@ -0,0 +1 @@
+dontaudit netd self:capability sys_module;
diff --git a/target/board/generic/sepolicy/property.te b/target/board/generic/sepolicy/property.te
new file mode 100644
index 0000000000000000000000000000000000000000..22d580a568cbfa14547dfd2a895ce446b9fe9521
--- /dev/null
+++ b/target/board/generic/sepolicy/property.te
@@ -0,0 +1,3 @@
+type qemu_prop, property_type;
+type radio_noril_prop, property_type;
+type opengles_prop, property_type;
diff --git a/target/board/generic/sepolicy/property_contexts b/target/board/generic/sepolicy/property_contexts
new file mode 100644
index 0000000000000000000000000000000000000000..142b062de7f16199c5ae98b419584d07dda097de
--- /dev/null
+++ b/target/board/generic/sepolicy/property_contexts
@@ -0,0 +1,5 @@
+qemu. u:object_r:qemu_prop:s0
+ro.emu. u:object_r:qemu_prop:s0
+ro.emulator. u:object_r:qemu_prop:s0
+ro.radio.noril u:object_r:radio_noril_prop:s0
+ro.opengles. u:object_r:opengles_prop:s0
diff --git a/target/board/generic/sepolicy/qemu_props.te b/target/board/generic/sepolicy/qemu_props.te
new file mode 100644
index 0000000000000000000000000000000000000000..6768ce7cd076fe364a1dd5d68caa022a87b0c03c
--- /dev/null
+++ b/target/board/generic/sepolicy/qemu_props.te
@@ -0,0 +1,11 @@
+# qemu-props service: Sets system properties on boot.
+type qemu_props, domain, domain_deprecated;
+type qemu_props_exec, exec_type, file_type;
+
+init_daemon_domain(qemu_props)
+
+# Set properties.
+set_prop(qemu_props, qemu_prop)
+set_prop(qemu_props, dalvik_prop)
+set_prop(qemu_props, config_prop)
+set_prop(qemu_props, opengles_prop)
diff --git a/target/board/generic/sepolicy/qemud.te b/target/board/generic/sepolicy/qemud.te
new file mode 100644
index 0000000000000000000000000000000000000000..797cf5c6b0728c2c6d40f2789f3d3fe11dc07108
--- /dev/null
+++ b/target/board/generic/sepolicy/qemud.te
@@ -0,0 +1,8 @@
+# qemu support daemon
+type qemud, domain, domain_deprecated;
+type qemud_exec, exec_type, file_type;
+
+init_daemon_domain(qemud)
+
+# Access /dev/ttyS1 and /dev/ttyGF1.
+allow qemud serial_device:chr_file rw_file_perms;
diff --git a/target/board/generic/sepolicy/rild.te b/target/board/generic/sepolicy/rild.te
new file mode 100644
index 0000000000000000000000000000000000000000..e148b6c1392a118d24eea82b8983d58d76b707cb
--- /dev/null
+++ b/target/board/generic/sepolicy/rild.te
@@ -0,0 +1 @@
+unix_socket_connect(rild, qemud, qemud)
diff --git a/target/board/generic/sepolicy/shell.te b/target/board/generic/sepolicy/shell.te
new file mode 100644
index 0000000000000000000000000000000000000000..b246d7e3c1357b1df89b26d12b2b93831e45c5d0
--- /dev/null
+++ b/target/board/generic/sepolicy/shell.te
@@ -0,0 +1 @@
+allow shell serial_device:chr_file rw_file_perms;
diff --git a/target/board/generic/sepolicy/surfaceflinger.te b/target/board/generic/sepolicy/surfaceflinger.te
new file mode 100644
index 0000000000000000000000000000000000000000..e03d07ee7f1bd34bfe393358dea0f47ac88715b1
--- /dev/null
+++ b/target/board/generic/sepolicy/surfaceflinger.te
@@ -0,0 +1,4 @@
+allow surfaceflinger self:process execmem;
+allow surfaceflinger ashmem_device:chr_file execute;
+
+set_prop(surfaceflinger, qemu_prop)
diff --git a/target/board/generic/sepolicy/system_server.te b/target/board/generic/sepolicy/system_server.te
new file mode 100644
index 0000000000000000000000000000000000000000..f9e277b8aad7d6a52d4571b5b4f801c86dbe2554
--- /dev/null
+++ b/target/board/generic/sepolicy/system_server.te
@@ -0,0 +1,3 @@
+unix_socket_connect(system_server, qemud, qemud)
+get_prop(system_server, opengles_prop)
+get_prop(system_server, radio_noril_prop)
diff --git a/target/board/generic/sepolicy/zygote.te b/target/board/generic/sepolicy/zygote.te
new file mode 100644
index 0000000000000000000000000000000000000000..a90f02b1ac29a7c914a837c0da7f9cc6ef592e3a
--- /dev/null
+++ b/target/board/generic/sepolicy/zygote.te
@@ -0,0 +1 @@
+set_prop(zygote, qemu_prop)
diff --git a/target/board/generic/system.prop b/target/board/generic/system.prop
new file mode 100644
index 0000000000000000000000000000000000000000..f2424c9704bc1ac2da0f97c29c10d8091f6b377f
--- /dev/null
+++ b/target/board/generic/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_arm64/BoardConfig.mk b/target/board/generic_arm64/BoardConfig.mk
new file mode 100644
index 0000000000000000000000000000000000000000..02d0a6f2091cde848f9df3c807b279e39920cfbc
--- /dev/null
+++ b/target/board/generic_arm64/BoardConfig.mk
@@ -0,0 +1,86 @@
+# Copyright (C) 2013 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.
+#
+
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+TARGET_ARCH := arm64
+TARGET_ARCH_VARIANT := armv8-a
+TARGET_CPU_VARIANT := generic
+TARGET_CPU_ABI := arm64-v8a
+
+TARGET_2ND_ARCH := arm
+TARGET_2ND_CPU_ABI := armeabi-v7a
+TARGET_2ND_CPU_ABI2 := armeabi
+
+ifneq ($(TARGET_BUILD_APPS)$(filter cts,$(MAKECMDGOALS)),)
+# DO NOT USE
+# DO NOT USE
+#
+# This architecture / CPU variant must NOT be used for any 64 bit
+# platform builds. It is the lowest common denominator required
+# to build an unbundled application or cts for all supported 32 and 64 bit
+# platforms.
+#
+# If you're building a 64 bit platform (and not an application) the
+# ARM-v8 specification allows you to assume NEON and all the features
+# available in a cortex-A15 CPU. You should be able to set :
+#
+# TARGET_2ND_ARCH_VARIANT := armv7-a-neon
+# TARGET_2ND_CPU_VARIANT := cortex-a15
+#
+# DO NOT USE
+# DO NOT USE
+TARGET_2ND_ARCH_VARIANT := armv7-a
+# DO NOT USE
+# DO NOT USE
+TARGET_2ND_CPU_VARIANT := generic
+# DO NOT USE
+# DO NOT USE
+else
+TARGET_2ND_ARCH_VARIANT := armv7-a-neon
+TARGET_2ND_CPU_VARIANT := cortex-a15
+endif
+
+
+TARGET_USES_64_BIT_BINDER := true
+
+# no hardware camera
+USE_CAMERA_STUB := true
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+ ifeq ($(WITH_DEXPREOPT),)
+ WITH_DEXPREOPT := true
+ endif
+endif
+
+# Build OpenGLES emulation host and guest libraries
+BUILD_EMULATOR_OPENGL := true
+
+# Build and enable the OpenGL ES View renderer. When running on the emulator,
+# the GLES renderer disables itself if host GL acceleration isn't available.
+USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1879048192 # 1.75 GB
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
diff --git a/target/board/generic_arm64/README.txt b/target/board/generic_arm64/README.txt
new file mode 100644
index 0000000000000000000000000000000000000000..21c71d7edb5095bd1e56d19ed86d8a91332a02d9
--- /dev/null
+++ b/target/board/generic_arm64/README.txt
@@ -0,0 +1,5 @@
+The "generic_arm64" product defines a non-hardware-specific arm64 target
+without a kernel or bootloader.
+
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_arm64/device.mk b/target/board/generic_arm64/device.mk
new file mode 100644
index 0000000000000000000000000000000000000000..9647a4ebe8b508843c1d9f7c41ea880524042e23
--- /dev/null
+++ b/target/board/generic_arm64/device.mk
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2013 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 build configuration for the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.ril.hsxpa=1 \
+ ro.ril.gprsclass=10 \
+ ro.adb.qemud=1
+
+PRODUCT_COPY_FILES := \
+ device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ device/generic/goldfish/camera/media_profiles.xml:system/etc/media_profiles.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
+ device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml
+
+# Adjust the Dalvik heap to be appropriate for a tablet.
+$(call inherit-product-if-exists, frameworks/base/build/tablet-dalvik-heap.mk)
+$(call inherit-product-if-exists, frameworks/native/build/tablet-dalvik-heap.mk)
diff --git a/target/board/generic_arm64/system.prop b/target/board/generic_arm64/system.prop
new file mode 100644
index 0000000000000000000000000000000000000000..aee6b1307886e5ef98a2be7406014ef6c6b635b3
--- /dev/null
+++ b/target/board/generic_arm64/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic arm64 sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_armv5/AndroidBoard.mk b/target/board/generic_armv5/AndroidBoard.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7daff274ac3ad45aa7aae64753ac8a78f8fbcca3
--- /dev/null
+++ b/target/board/generic_armv5/AndroidBoard.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2011 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.
+#
+
+-include build/target/board/generic/AndroidBoard.mk
diff --git a/target/board/generic_armv5/BoardConfig.mk b/target/board/generic_armv5/BoardConfig.mk
new file mode 100644
index 0000000000000000000000000000000000000000..016937a688f58fabe9a7c1b63fe08bcf0b6bfacc
--- /dev/null
+++ b/target/board/generic_armv5/BoardConfig.mk
@@ -0,0 +1,23 @@
+#
+# Copyright (C) 2011 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.
+#
+
+include build/target/board/generic/BoardConfig.mk
+
+TARGET_ARCH_VARIANT := armv5te
+TARGET_CPU_ABI := armeabi
+TARGET_CPU_ABI2 :=
+
+WITH_DEXPREOPT := false
diff --git a/target/board/generic_armv5/README.txt b/target/board/generic_armv5/README.txt
new file mode 100644
index 0000000000000000000000000000000000000000..25d590af0771356786ddecbf6d6969257cae5fdb
--- /dev/null
+++ b/target/board/generic_armv5/README.txt
@@ -0,0 +1,5 @@
+The "generic_armv5" product defines a non-hardware-specific target
+without a kernel or bootloader.
+
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_armv5/device.mk b/target/board/generic_armv5/device.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7c4aaf2082596dad81799ace11e1216fe76079f7
--- /dev/null
+++ b/target/board/generic_armv5/device.mk
@@ -0,0 +1,17 @@
+#
+# Copyright (C) 2011 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.
+#
+
+include build/target/board/generic/device.mk
diff --git a/target/board/generic_armv5/system.prop b/target/board/generic_armv5/system.prop
new file mode 100644
index 0000000000000000000000000000000000000000..137a0f9b1f708fee06288f1b189ca1fea9f16dd2
--- /dev/null
+++ b/target/board/generic_armv5/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_mips/BoardConfig.mk b/target/board/generic_mips/BoardConfig.mk
new file mode 100644
index 0000000000000000000000000000000000000000..1152105bb3df37cd501de5b89a34c3062126b4fb
--- /dev/null
+++ b/target/board/generic_mips/BoardConfig.mk
@@ -0,0 +1,63 @@
+#
+# Copyright (C) 2011 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.
+#
+# BoardConfig.mk
+#
+# Product-specific compile-time definitions.
+#
+
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+
+TARGET_ARCH := mips
+ifeq (,$(TARGET_ARCH_VARIANT))
+TARGET_ARCH_VARIANT := mips32r2-fp
+endif
+TARGET_CPU_ABI := mips
+
+# Make TARGET_CPU_VARIANT the same as TARGET_ARCH_VARIANT
+TARGET_CPU_VARIANT := $(TARGET_ARCH_VARIANT)
+
+HAVE_HTC_AUDIO_DRIVER := true
+BOARD_USES_GENERIC_AUDIO := true
+
+# no hardware camera
+USE_CAMERA_STUB := true
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+ ifeq ($(WITH_DEXPREOPT),)
+ WITH_DEXPREOPT := true
+ endif
+endif
+
+# Build OpenGLES emulation guest and host libraries
+BUILD_EMULATOR_OPENGL := true
+
+# Build and enable the OpenGL ES View renderer. When running on the emulator,
+# the GLES renderer disables itself if host GL acceleration isn't available.
+USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1879048192 # 1.75 GB
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 734003200
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
diff --git a/target/board/generic_mips/README.txt b/target/board/generic_mips/README.txt
new file mode 100644
index 0000000000000000000000000000000000000000..b31a8571a16ed14e9ad963c7b05eb1909854a729
--- /dev/null
+++ b/target/board/generic_mips/README.txt
@@ -0,0 +1,9 @@
+The "generic_mips" product defines a MIPS based non-hardware-specific
+target without a kernel or bootloader.
+
+It can be used to build the entire user-level system, and
+will work with the emulator, though sound will not work
+(see the "emulator" product for that).
+
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_mips/device.mk b/target/board/generic_mips/device.mk
new file mode 100644
index 0000000000000000000000000000000000000000..06a7d8a3e210408a87835d920b11bc00bb4404fa
--- /dev/null
+++ b/target/board/generic_mips/device.mk
@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2009 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 build configuration for the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.ril.hsxpa=1 \
+ ro.ril.gprsclass=10 \
+ ro.adb.qemud=1
+
+PRODUCT_COPY_FILES := \
+ device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ device/generic/goldfish/camera/media_profiles.xml:system/etc/media_profiles.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
+ device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml \
+ hardware/libhardware_legacy/audio/audio_policy.conf:system/etc/audio_policy.conf
+
+PRODUCT_PACKAGES := \
+ audio.primary.goldfish \
+ power.goldfish \
+ vibrator.goldfish
diff --git a/target/board/generic_mips/system.prop b/target/board/generic_mips/system.prop
new file mode 100644
index 0000000000000000000000000000000000000000..137a0f9b1f708fee06288f1b189ca1fea9f16dd2
--- /dev/null
+++ b/target/board/generic_mips/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_mips64/BoardConfig.mk b/target/board/generic_mips64/BoardConfig.mk
new file mode 100644
index 0000000000000000000000000000000000000000..ebc1675ae39c70e149c35998fd7dcba056c703c8
--- /dev/null
+++ b/target/board/generic_mips64/BoardConfig.mk
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2013 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.
+#
+# BoardConfig.mk
+#
+# Product-specific compile-time definitions.
+#
+
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+
+TARGET_ARCH := mips64
+ifeq (,$(TARGET_ARCH_VARIANT))
+TARGET_ARCH_VARIANT := mips64r6
+endif
+TARGET_CPU_ABI := mips64
+
+TARGET_2ND_ARCH := mips
+ifeq (,$(TARGET_2ND_ARCH_VARIANT))
+ifeq ($(TARGET_ARCH_VARIANT),mips64r6)
+TARGET_2ND_ARCH_VARIANT := mips32r6
+else
+TARGET_2ND_ARCH_VARIANT := mips32r2-fp
+endif
+endif
+TARGET_2ND_CPU_ABI := mips
+
+# Make TARGET_XXX_CPU_VARIANT the same as TARGET_XXX_ARCH_VARIANT
+TARGET_CPU_VARIANT := $(TARGET_ARCH_VARIANT)
+TARGET_2ND_CPU_VARIANT := $(TARGET_2ND_ARCH_VARIANT)
+
+# The emulator (qemu) uses the Goldfish devices
+HAVE_HTC_AUDIO_DRIVER := true
+BOARD_USES_GENERIC_AUDIO := true
+
+# no hardware camera
+USE_CAMERA_STUB := true
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+ ifeq ($(WITH_DEXPREOPT),)
+ WITH_DEXPREOPT := true
+ endif
+endif
+
+# Build OpenGLES emulation guest and host libraries
+BUILD_EMULATOR_OPENGL := true
+
+# Build and enable the OpenGL ES View renderer. When running on the emulator,
+# the GLES renderer disables itself if host GL acceleration isn't available.
+USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1879048192 # 1.75 GB
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 1610612736 # 1.5 GB, lots of space for running tests
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += build/target/board/generic/sepolicy
+
+DEX_PREOPT_DEFAULT := nostripping
diff --git a/target/board/generic_mips64/README.txt b/target/board/generic_mips64/README.txt
new file mode 100644
index 0000000000000000000000000000000000000000..cd4e05b7270de003ba6ab67aa060d279f956f62f
--- /dev/null
+++ b/target/board/generic_mips64/README.txt
@@ -0,0 +1,8 @@
+The "generic_mips64" product defines a MIPS64 based non-hardware-specific
+target without a kernel or bootloader.
+
+It can be used to build the entire user-level system, and
+will work with the emulator.
+
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_mips64/device.mk b/target/board/generic_mips64/device.mk
new file mode 100644
index 0000000000000000000000000000000000000000..66ec9db9b9d2e136c5f51e44900dc5155ff755dc
--- /dev/null
+++ b/target/board/generic_mips64/device.mk
@@ -0,0 +1,36 @@
+#
+# Copyright (C) 2009 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 build configuration for the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.ril.hsxpa=1 \
+ ro.ril.gprsclass=10 \
+ ro.adb.qemud=1
+
+PRODUCT_COPY_FILES := \
+ device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ device/generic/goldfish/camera/media_profiles.xml:system/etc/media_profiles.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
+ device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml \
+ hardware/libhardware_legacy/audio/audio_policy.conf:system/etc/audio_policy.conf
+
+PRODUCT_PACKAGES := \
+ audio.primary.goldfish \
+ power.goldfish
diff --git a/target/board/generic_mips64/system.prop b/target/board/generic_mips64/system.prop
new file mode 100644
index 0000000000000000000000000000000000000000..326e4b744e214f1fed5544f8238242141cd613c2
--- /dev/null
+++ b/target/board/generic_mips64/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic mips64 sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_x86/BoardConfig.mk b/target/board/generic_x86/BoardConfig.mk
new file mode 100644
index 0000000000000000000000000000000000000000..50ecb984d2866194b17fe8e13334cd051aced833
--- /dev/null
+++ b/target/board/generic_x86/BoardConfig.mk
@@ -0,0 +1,44 @@
+# config.mk
+#
+# Product-specific compile-time definitions.
+#
+
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+TARGET_CPU_ABI := x86
+TARGET_ARCH := x86
+TARGET_ARCH_VARIANT := x86
+TARGET_PRELINK_MODULE := false
+
+# The IA emulator (qemu) uses the Goldfish devices
+HAVE_HTC_AUDIO_DRIVER := true
+BOARD_USES_GENERIC_AUDIO := true
+
+# no hardware camera
+USE_CAMERA_STUB := true
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+WITH_DEXPREOPT ?= true
+endif
+
+# Build OpenGLES emulation host and guest libraries
+BUILD_EMULATOR_OPENGL := true
+
+# Build and enable the OpenGL ES View renderer. When running on the emulator,
+# the GLES renderer disables itself if host GL acceleration isn't available.
+USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 1610612736
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += \
+ build/target/board/generic/sepolicy \
+ build/target/board/generic_x86/sepolicy
diff --git a/target/board/generic_x86/README.txt b/target/board/generic_x86/README.txt
new file mode 100644
index 0000000000000000000000000000000000000000..938d982e9452ba9cf450d4c7ef7703120d2ec5b1
--- /dev/null
+++ b/target/board/generic_x86/README.txt
@@ -0,0 +1,8 @@
+The "generic_x86" product defines a non-hardware-specific IA target
+without a kernel or bootloader.
+
+It can be used to build the entire user-level system, and
+will work with the IA version of the emulator,
+
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_x86/device.mk b/target/board/generic_x86/device.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b5b0fafb0b69935db8ff5efbbefca10212b60634
--- /dev/null
+++ b/target/board/generic_x86/device.mk
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2009 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 build configuration for the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.ril.hsxpa=1 \
+ ro.ril.gprsclass=10 \
+ ro.adb.qemud=1
+
+PRODUCT_COPY_FILES := \
+ device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ device/generic/goldfish/camera/media_profiles.xml:system/etc/media_profiles.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
+ device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml
+
+PRODUCT_PACKAGES := \
+ audio.primary.goldfish \
+ vibrator.goldfish
diff --git a/target/board/generic_x86/sepolicy/domain.te b/target/board/generic_x86/sepolicy/domain.te
new file mode 100644
index 0000000000000000000000000000000000000000..0bc8d871fffbd7946e69d3f8aada663e1c2d05ec
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/domain.te
@@ -0,0 +1 @@
+allow domain cpuctl_device:dir search;
diff --git a/target/board/generic_x86/sepolicy/healthd.te b/target/board/generic_x86/sepolicy/healthd.te
new file mode 100644
index 0000000000000000000000000000000000000000..95fa8079b0a7ad22ca135e165ebb18d7fd103aaa
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/healthd.te
@@ -0,0 +1 @@
+allow healthd self:capability sys_nice;
diff --git a/target/board/generic_x86/sepolicy/init.te b/target/board/generic_x86/sepolicy/init.te
new file mode 100644
index 0000000000000000000000000000000000000000..3aa81d1b5876120d5fa1f22f06f9f046f1116cef
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/init.te
@@ -0,0 +1 @@
+allow init tmpfs:lnk_file create_file_perms;
diff --git a/target/board/generic_x86/sepolicy/installd.te b/target/board/generic_x86/sepolicy/installd.te
new file mode 100644
index 0000000000000000000000000000000000000000..7a558b129b05f7f658301300b7f2bdcc1a526546
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/installd.te
@@ -0,0 +1 @@
+allow installd self:process execmem;
diff --git a/target/board/generic_x86/sepolicy/zygote.te b/target/board/generic_x86/sepolicy/zygote.te
new file mode 100644
index 0000000000000000000000000000000000000000..93993a47f1da5378005c847b716833e061d953ca
--- /dev/null
+++ b/target/board/generic_x86/sepolicy/zygote.te
@@ -0,0 +1,2 @@
+allow zygote self:process execmem;
+allow zygote self:capability sys_nice;
diff --git a/target/board/generic_x86/system.prop b/target/board/generic_x86/system.prop
new file mode 100644
index 0000000000000000000000000000000000000000..137a0f9b1f708fee06288f1b189ca1fea9f16dd2
--- /dev/null
+++ b/target/board/generic_x86/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/board/generic_x86_64/BoardConfig.mk b/target/board/generic_x86_64/BoardConfig.mk
new file mode 100755
index 0000000000000000000000000000000000000000..283e9cc4cc981498b4c673f2951984c23e24cf53
--- /dev/null
+++ b/target/board/generic_x86_64/BoardConfig.mk
@@ -0,0 +1,50 @@
+# config.mk
+#
+# Product-specific compile-time definitions.
+#
+
+# The generic product target doesn't have any hardware-specific pieces.
+TARGET_NO_BOOTLOADER := true
+TARGET_NO_KERNEL := true
+TARGET_CPU_ABI := x86_64
+TARGET_ARCH := x86_64
+TARGET_ARCH_VARIANT := x86_64
+TARGET_PRELINK_MODULE := false
+
+TARGET_2ND_CPU_ABI := x86
+TARGET_2ND_ARCH := x86
+TARGET_2ND_ARCH_VARIANT := x86
+
+TARGET_USES_64_BIT_BINDER := true
+
+# The IA emulator (qemu) uses the Goldfish devices
+HAVE_HTC_AUDIO_DRIVER := true
+BOARD_USES_GENERIC_AUDIO := true
+
+# no hardware camera
+USE_CAMERA_STUB := true
+
+# Enable dex-preoptimization to speed up the first boot sequence
+# of an SDK AVD. Note that this operation only works on Linux for now
+ifeq ($(HOST_OS),linux)
+WITH_DEXPREOPT ?= true
+endif
+
+# Build OpenGLES emulation host and guest libraries
+BUILD_EMULATOR_OPENGL := true
+
+# Build and enable the OpenGL ES View renderer. When running on the emulator,
+# the GLES renderer disables itself if host GL acceleration isn't available.
+USE_OPENGL_RENDERER := true
+
+TARGET_USERIMAGES_USE_EXT4 := true
+BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648 # 2 GB
+BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800
+BOARD_CACHEIMAGE_PARTITION_SIZE := 69206016
+BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE := ext4
+BOARD_FLASH_BLOCK_SIZE := 512
+TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
+
+BOARD_SEPOLICY_DIRS += \
+ build/target/board/generic/sepolicy \
+ build/target/board/generic_x86/sepolicy
diff --git a/target/board/generic_x86_64/README.txt b/target/board/generic_x86_64/README.txt
new file mode 100644
index 0000000000000000000000000000000000000000..46b015bc3aef7dd50734a48c406978a513a46781
--- /dev/null
+++ b/target/board/generic_x86_64/README.txt
@@ -0,0 +1,8 @@
+The "generic_x86_64" product defines a non-hardware-specific IA target
+without a kernel or bootloader.
+
+It can be used to build the entire user-level system, and
+will work with the IA version of the emulator,
+
+It is not a product "base class"; no other products inherit
+from it or use it in any way.
diff --git a/target/board/generic_x86_64/device.mk b/target/board/generic_x86_64/device.mk
new file mode 100755
index 0000000000000000000000000000000000000000..b5b0fafb0b69935db8ff5efbbefca10212b60634
--- /dev/null
+++ b/target/board/generic_x86_64/device.mk
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2009 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 build configuration for the product aspects that
+# are specific to the emulator.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.ril.hsxpa=1 \
+ ro.ril.gprsclass=10 \
+ ro.adb.qemud=1
+
+PRODUCT_COPY_FILES := \
+ device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ device/generic/goldfish/camera/media_profiles.xml:system/etc/media_profiles.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
+ device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml
+
+PRODUCT_PACKAGES := \
+ audio.primary.goldfish \
+ vibrator.goldfish
diff --git a/target/board/generic_x86_64/system.prop b/target/board/generic_x86_64/system.prop
new file mode 100644
index 0000000000000000000000000000000000000000..137a0f9b1f708fee06288f1b189ca1fea9f16dd2
--- /dev/null
+++ b/target/board/generic_x86_64/system.prop
@@ -0,0 +1,6 @@
+#
+# system.prop for generic sdk
+#
+
+rild.libpath=/system/lib/libreference-ril.so
+rild.libargs=-d /dev/ttyS0
diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk
new file mode 100644
index 0000000000000000000000000000000000000000..69edc72e4ca02967a738b0acb8e62fcf8e8f11db
--- /dev/null
+++ b/target/product/AndroidProducts.mk
@@ -0,0 +1,73 @@
+#
+# 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.
+#
+
+#
+# This file should set PRODUCT_MAKEFILES to a list of product makefiles
+# to expose to the build system. LOCAL_DIR will already be set to
+# the directory containing this file.
+# PRODUCT_MAKEFILES is set up in AndroidProducts.mks.
+# Format of PRODUCT_MAKEFILES:
+# :
+# If the is the same as the base file name (without dir
+# and the .mk suffix) of the product makefile, ":" can be
+# omitted.
+#
+# This file may not rely on the value of any variable other than
+# LOCAL_DIR; do not use any conditionals, and do not look up the
+# value of any variable that isn't set in this file or in a file that
+# it includes.
+#
+
+# Unbundled apps will be built with the most generic product config.
+ifneq ($(TARGET_BUILD_APPS),)
+PRODUCT_MAKEFILES := \
+ $(LOCAL_DIR)/aosp_arm.mk \
+ $(LOCAL_DIR)/full.mk \
+ $(LOCAL_DIR)/generic_armv5.mk \
+ $(LOCAL_DIR)/aosp_x86.mk \
+ $(LOCAL_DIR)/full_x86.mk \
+ $(LOCAL_DIR)/aosp_mips.mk \
+ $(LOCAL_DIR)/full_mips.mk \
+ $(LOCAL_DIR)/aosp_arm64.mk \
+ $(LOCAL_DIR)/aosp_mips64.mk \
+ $(LOCAL_DIR)/aosp_x86_64.mk
+else
+PRODUCT_MAKEFILES := \
+ $(LOCAL_DIR)/core.mk \
+ $(LOCAL_DIR)/generic.mk \
+ $(LOCAL_DIR)/generic_x86.mk \
+ $(LOCAL_DIR)/generic_mips.mk \
+ $(LOCAL_DIR)/aosp_arm.mk \
+ $(LOCAL_DIR)/full.mk \
+ $(LOCAL_DIR)/aosp_x86.mk \
+ $(LOCAL_DIR)/full_x86.mk \
+ $(LOCAL_DIR)/aosp_mips.mk \
+ $(LOCAL_DIR)/full_mips.mk \
+ $(LOCAL_DIR)/aosp_arm64.mk \
+ $(LOCAL_DIR)/aosp_mips64.mk \
+ $(LOCAL_DIR)/aosp_x86_64.mk \
+ $(LOCAL_DIR)/sdk_phone_armv7.mk \
+ $(LOCAL_DIR)/sdk_phone_x86.mk \
+ $(LOCAL_DIR)/sdk_phone_mips.mk \
+ $(LOCAL_DIR)/sdk_phone_arm64.mk \
+ $(LOCAL_DIR)/sdk_phone_x86_64.mk \
+ $(LOCAL_DIR)/sdk_phone_mips64.mk \
+ $(LOCAL_DIR)/sdk.mk \
+ $(LOCAL_DIR)/sdk_x86.mk \
+ $(LOCAL_DIR)/sdk_mips.mk \
+ $(LOCAL_DIR)/sdk_arm64.mk \
+ $(LOCAL_DIR)/sdk_x86_64.mk
+endif
diff --git a/target/product/aosp_arm.mk b/target/product/aosp_arm.mk
new file mode 100644
index 0000000000000000000000000000000000000000..781cae6a012bbf524bd73f7ee501d0291f96f582
--- /dev/null
+++ b/target/product/aosp_arm.mk
@@ -0,0 +1,18 @@
+#
+# Copyright 2013 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.
+#
+include $(SRC_TARGET_DIR)/product/full.mk
+
+PRODUCT_NAME := aosp_arm
diff --git a/target/product/aosp_arm64.mk b/target/product/aosp_arm64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..98afe5f9247c2e5db34fbb78b6a98296301d3ba4
--- /dev/null
+++ b/target/product/aosp_arm64.mk
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 2013 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+# This is for enabling ethernet support for ranchu.
+# Consider removing this after RIL support is provided in ranchu.
+PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_arm64/device.mk)
+
+include $(SRC_TARGET_DIR)/product/emulator.mk
+PRODUCT_NAME := aosp_arm64
+PRODUCT_DEVICE := generic_arm64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on ARM arm64 Emulator
diff --git a/target/product/aosp_base.mk b/target/product/aosp_base.mk
new file mode 100644
index 0000000000000000000000000000000000000000..075c1d3f8f58c03141d280ddeddaf431a4d3f261
--- /dev/null
+++ b/target/product/aosp_base.mk
@@ -0,0 +1,16 @@
+#
+# Copyright 2013 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.
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
diff --git a/target/product/aosp_base_telephony.mk b/target/product/aosp_base_telephony.mk
new file mode 100644
index 0000000000000000000000000000000000000000..0d4e3335613d0f1c86a193836fb63d3176ac04d6
--- /dev/null
+++ b/target/product/aosp_base_telephony.mk
@@ -0,0 +1,19 @@
+#
+# Copyright 2013 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.
+#
+$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base_telephony.mk)
+
+PRODUCT_PACKAGES += \
+ messaging
diff --git a/target/product/aosp_mips.mk b/target/product/aosp_mips.mk
new file mode 100644
index 0000000000000000000000000000000000000000..a76b93a46d566b7eb6b4832e04c570ac6eb40b0a
--- /dev/null
+++ b/target/product/aosp_mips.mk
@@ -0,0 +1,18 @@
+#
+# Copyright 2013 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.
+#
+include $(SRC_TARGET_DIR)/product/full_mips.mk
+
+PRODUCT_NAME := aosp_mips
diff --git a/target/product/aosp_mips64.mk b/target/product/aosp_mips64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..f606858e5f65414ce327d1f71a253322f9ab1f49
--- /dev/null
+++ b/target/product/aosp_mips64.mk
@@ -0,0 +1,36 @@
+#
+# Copyright 2013 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# mips64 build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+# This is for enabling ethernet support for ranchu.
+# Consider removing this after RIL support is provided in ranchu.
+PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_mips64/device.mk)
+
+include $(SRC_TARGET_DIR)/product/emulator.mk
+
+# Overrides
+PRODUCT_NAME := aosp_mips64
+PRODUCT_DEVICE := generic_mips64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on MIPS64 Emulator
diff --git a/target/product/aosp_x86.mk b/target/product/aosp_x86.mk
new file mode 100644
index 0000000000000000000000000000000000000000..cba43c429ff1c09914a99fd7f1e6d871af484d9a
--- /dev/null
+++ b/target/product/aosp_x86.mk
@@ -0,0 +1,18 @@
+#
+# Copyright 2013 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.
+#
+include $(SRC_TARGET_DIR)/product/full_x86.mk
+
+PRODUCT_NAME := aosp_x86
diff --git a/target/product/aosp_x86_64.mk b/target/product/aosp_x86_64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..4006346a822148c9b9e3eeabe92f0878f41fba07
--- /dev/null
+++ b/target/product/aosp_x86_64.mk
@@ -0,0 +1,49 @@
+#
+# Copyright 2013 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+# If running on an emulator or some other device that has a LAN connection
+# that isn't a wifi connection. This will instruct init.rc to enable the
+# network connection so that you can use it with ADB
+
+# This is for enabling ethernet support for ranchu.
+# Consider removing this after RIL support is provided in ranchu.
+PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86_64/device.mk)
+
+include $(SRC_TARGET_DIR)/product/emulator.mk
+
+ifdef NET_ETH0_STARTONBOOT
+ PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
+endif
+
+# Ensure we package the BIOS files too.
+PRODUCT_PACKAGES += \
+ bios.bin \
+ vgabios-cirrus.bin \
+
+# Overrides
+PRODUCT_NAME := aosp_x86_64
+PRODUCT_DEVICE := generic_x86_64
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on IA x86_64 Emulator
diff --git a/target/product/base.mk b/target/product/base.mk
new file mode 100644
index 0000000000000000000000000000000000000000..4d70664677bb88856cdcaa5c36ad1e4ea6852aa8
--- /dev/null
+++ b/target/product/base.mk
@@ -0,0 +1,142 @@
+#
+# Copyright (C) 2012 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.
+#
+
+# Base modules (will move elsewhere, previously user tagged)
+PRODUCT_PACKAGES += \
+ 20-dns.conf \
+ 95-configured \
+ org.apache.http.legacy.boot \
+ appwidget \
+ appops \
+ am \
+ android.policy \
+ android.test.runner \
+ app_process \
+ applypatch \
+ audioserver \
+ blkid \
+ bmgr \
+ bugreport \
+ bugreportz \
+ cameraserver \
+ content \
+ dnsmasq \
+ dpm \
+ framework \
+ fsck_msdos \
+ hid \
+ ime \
+ input \
+ javax.obex \
+ libandroid \
+ libandroid_runtime \
+ libandroid_servers \
+ libaudioeffect_jni \
+ libaudioflinger \
+ libaudiopolicyservice \
+ libaudiopolicymanager \
+ libbundlewrapper \
+ libcamera_client \
+ libcameraservice \
+ libcamera2ndk \
+ libdl \
+ libdrmclearkeyplugin \
+ libeffectproxy \
+ libeffects \
+ libinput \
+ libinputflinger \
+ libiprouteutil \
+ libjnigraphics \
+ libldnhncr \
+ libmedia \
+ libmedia_jni \
+ libmediaplayerservice \
+ libmtp \
+ libnetd_client \
+ libnetlink \
+ libnetutils \
+ libpdfium \
+ libradio \
+ libradioservice \
+ libradio_metadata \
+ libreference-ril \
+ libreverbwrapper \
+ libril \
+ librtp_jni \
+ libsensorservice \
+ libskia \
+ libsonic \
+ libsonivox \
+ libsoundpool \
+ libsoundtrigger \
+ libsoundtriggerservice \
+ libsqlite \
+ libstagefright \
+ libstagefright_amrnb_common \
+ libstagefright_avc_common \
+ libstagefright_enc_common \
+ libstagefright_foundation \
+ libstagefright_omx \
+ libstagefright_yuv \
+ libusbhost \
+ libutils \
+ libvisualizer \
+ libvorbisidec \
+ libmediandk \
+ libvulkan \
+ libwifi-service \
+ media \
+ media_cmd \
+ mediadrmserver \
+ mediaserver \
+ mediacodec \
+ mediaextractor \
+ monkey \
+ mtpd \
+ ndc \
+ netd \
+ ping \
+ ping6 \
+ platform.xml \
+ pppd \
+ pm \
+ racoon \
+ run-as \
+ schedtest \
+ sdcard \
+ secdiscard \
+ services \
+ settings \
+ sgdisk \
+ sm \
+ svc \
+ tc \
+ telecom \
+ vdc \
+ vold \
+ wm
+
+
+PRODUCT_COPY_FILES := $(call add-to-product-copy-files-if-exists,\
+ frameworks/base/preloaded-classes:system/etc/preloaded-classes)
+
+# Note: it is acceptable to not have a compiled-classes file. In that case, all boot classpath
+# classes will be compiled.
+PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,\
+ frameworks/base/compiled-classes:system/etc/compiled-classes)
+
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/embedded.mk)
diff --git a/target/product/core.mk b/target/product/core.mk
new file mode 100644
index 0000000000000000000000000000000000000000..0a4e0fdfed483801687b302c5a32a7f5a621dfe3
--- /dev/null
+++ b/target/product/core.mk
@@ -0,0 +1,62 @@
+#
+# 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.
+#
+
+# Base configuration for communication-oriented android devices
+# (phones, tablets, etc.). If you want a change to apply to ALMOST ALL
+# devices (including non-phones and non-tablets), modify
+# core_minimal.mk instead. If you care about wearables, you need to modify
+# core_tiny.mk in addition to core_minimal.mk.
+
+PRODUCT_PACKAGES += \
+ BasicDreams \
+ BlockedNumberProvider \
+ BookmarkProvider \
+ Browser2 \
+ Calendar \
+ CalendarProvider \
+ CaptivePortalLogin \
+ CertInstaller \
+ Contacts \
+ DeskClock \
+ DocumentsUI \
+ DownloadProviderUi \
+ Email \
+ ExactCalculator \
+ ExternalStorageProvider \
+ FusedLocation \
+ InputDevices \
+ KeyChain \
+ Keyguard \
+ LatinIME \
+ Launcher2 \
+ ManagedProvisioning \
+ MtpDocumentsProvider \
+ PicoTts \
+ PacProcessor \
+ libpac \
+ PrintSpooler \
+ PrintRecommendationService \
+ ProxyHandler \
+ QuickSearchBox \
+ Settings \
+ SharedStorageBackup \
+ StorageManager \
+ Telecom \
+ TeleService \
+ VpnDialogs \
+ MmsService
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_base.mk)
diff --git a/target/product/core_64_bit.mk b/target/product/core_64_bit.mk
new file mode 100644
index 0000000000000000000000000000000000000000..76e2a36a385818b52466f81c9cf967878d3e9778
--- /dev/null
+++ b/target/product/core_64_bit.mk
@@ -0,0 +1,33 @@
+#
+# Copyright (C) 2014 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.
+#
+
+# Inherit from this product for devices that support 64-bit apps using:
+# $(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+# The inheritance for this must come before the inheritance chain that leads
+# to core_minimal.mk
+
+# For now this will allow 64-bit apps, but still compile all apps with JNI
+# for 32-bit only.
+
+# Copy the 64-bit primary, 32-bit secondary zygote startup script
+PRODUCT_COPY_FILES += system/core/rootdir/init.zygote64_32.rc:root/init.zygote64_32.rc
+
+# Set the zygote property to select the 64-bit primary, 32-bit secondary script
+# This line must be parsed before the one in core_minimal.mk
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += ro.zygote=zygote64_32
+
+TARGET_SUPPORTS_32_BIT_APPS := true
+TARGET_SUPPORTS_64_BIT_APPS := true
diff --git a/target/product/core_base.mk b/target/product/core_base.mk
new file mode 100644
index 0000000000000000000000000000000000000000..03d33e1b65de910f65dba4cf1125c6d153ac74f4
--- /dev/null
+++ b/target/product/core_base.mk
@@ -0,0 +1,65 @@
+#
+# Copyright (C) 2013 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.
+#
+# Note that components added here will be also shared in PDK. Components
+# that should not be in PDK should be added in lower level like core.mk.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.config.notification_sound=OnTheHunt.ogg \
+ ro.config.alarm_alert=Alarm_Classic.ogg
+
+PRODUCT_PACKAGES += \
+ ContactsProvider \
+ DefaultContainerService \
+ Home \
+ TelephonyProvider \
+ UserDictionaryProvider \
+ atrace \
+ libandroidfw \
+ libaudiopreprocessing \
+ libaudioutils \
+ libfilterpack_imageproc \
+ libgabi++ \
+ libmdnssd \
+ libnfc_ndef \
+ libpowermanager \
+ libspeexresampler \
+ libstagefright_soft_aacdec \
+ libstagefright_soft_aacenc \
+ libstagefright_soft_amrdec \
+ libstagefright_soft_amrnbenc \
+ libstagefright_soft_amrwbenc \
+ libstagefright_soft_avcdec \
+ libstagefright_soft_avcenc \
+ libstagefright_soft_flacenc \
+ libstagefright_soft_g711dec \
+ libstagefright_soft_gsmdec \
+ libstagefright_soft_hevcdec \
+ libstagefright_soft_mp3dec \
+ libstagefright_soft_mpeg2dec \
+ libstagefright_soft_mpeg4dec \
+ libstagefright_soft_mpeg4enc \
+ libstagefright_soft_opusdec \
+ libstagefright_soft_rawdec \
+ libstagefright_soft_vorbisdec \
+ libstagefright_soft_vpxdec \
+ libstagefright_soft_vpxenc \
+ libvariablespeed \
+ libwebrtc_audio_preprocessing \
+ mdnsd \
+ requestsync \
+ wifi-service
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_minimal.mk)
diff --git a/target/product/core_minimal.mk b/target/product/core_minimal.mk
new file mode 100644
index 0000000000000000000000000000000000000000..009ca529cc83ce2c752cdd3589f5ee02b1e7ee71
--- /dev/null
+++ b/target/product/core_minimal.mk
@@ -0,0 +1,151 @@
+#
+# Copyright (C) 2013 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.
+#
+
+# Base configuration for most consumer android devices. Do not put
+# things that are specific to communication devices (phones, tables,
+# etc.) here -- for that, use core.mk.
+
+PRODUCT_BRAND := generic
+PRODUCT_DEVICE := generic
+PRODUCT_NAME := core
+
+PRODUCT_PACKAGES += \
+ BackupRestoreConfirmation \
+ CtsShimPrebuilt \
+ CtsShimPrivPrebuilt \
+ DownloadProvider \
+ ExtShared \
+ ExtServices \
+ HTMLViewer \
+ MediaProvider \
+ PackageInstaller \
+ SettingsProvider \
+ Shell \
+ StatementService \
+ WallpaperBackup \
+ bcc \
+ bu \
+ com.android.future.usb.accessory \
+ com.android.location.provider \
+ com.android.location.provider.xml \
+ com.android.media.remotedisplay \
+ com.android.media.remotedisplay.xml \
+ com.android.mediadrm.signer \
+ com.android.mediadrm.signer.xml \
+ drmserver \
+ ethernet-service \
+ framework-res \
+ idmap \
+ installd \
+ ims-common \
+ ip \
+ ip-up-vpn \
+ ip6tables \
+ iptables \
+ gatekeeperd \
+ keystore \
+ keystore.default \
+ ld.mc \
+ libbcc \
+ libOpenMAXAL \
+ libOpenSLES \
+ libdownmix \
+ libdrmframework \
+ libdrmframework_jni \
+ libfilterfw \
+ libkeystore \
+ libgatekeeper \
+ libwilhelm \
+ logd \
+ make_ext4fs \
+ e2fsck \
+ resize2fs \
+ screencap \
+ sensorservice \
+ telephony-common \
+ uiautomator \
+ uncrypt \
+ voip-common \
+ webview \
+ wifi-service
+
+PRODUCT_COPY_FILES += \
+ frameworks/native/data/etc/android.software.webview.xml:system/etc/permissions/android.software.webview.xml
+
+# The order of PRODUCT_BOOT_JARS matters.
+PRODUCT_BOOT_JARS := \
+ core-oj \
+ core-libart \
+ conscrypt \
+ okhttp \
+ core-junit \
+ bouncycastle \
+ ext \
+ framework \
+ telephony-common \
+ voip-common \
+ ims-common \
+ apache-xml \
+ org.apache.http.legacy.boot
+
+# The order of PRODUCT_SYSTEM_SERVER_JARS matters.
+PRODUCT_SYSTEM_SERVER_JARS := \
+ services \
+ ethernet-service \
+ wifi-service
+
+# Adoptable external storage supports both ext4 and f2fs
+PRODUCT_PACKAGES += \
+ e2fsck \
+ make_ext4fs \
+ fsck.f2fs \
+ make_f2fs \
+
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ ro.zygote=zygote32
+PRODUCT_COPY_FILES += \
+ system/core/rootdir/init.zygote32.rc:root/init.zygote32.rc
+
+PRODUCT_COPY_FILES += \
+ system/core/rootdir/etc/public.libraries.android.txt:system/etc/public.libraries.txt
+
+# Different dexopt types for different package update/install times.
+# On eng builds, make "boot" reasons do pure JIT for faster turnaround.
+ifeq (eng,$(TARGET_BUILD_VARIANT))
+ PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ pm.dexopt.first-boot=verify-at-runtime \
+ pm.dexopt.boot=verify-at-runtime
+else
+ PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ pm.dexopt.first-boot=interpret-only \
+ pm.dexopt.boot=verify-profile
+endif
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ pm.dexopt.install=interpret-only \
+ pm.dexopt.bg-dexopt=speed-profile \
+ pm.dexopt.ab-ota=speed-profile \
+ pm.dexopt.nsys-library=speed \
+ pm.dexopt.shared-apk=speed \
+ pm.dexopt.forced-dexopt=speed \
+ pm.dexopt.core-app=speed
+
+
+# Enable boot.oat filtering of compiled classes to reduce boot.oat size. b/28026683
+PRODUCT_COPY_FILES += $(call add-to-product-copy-files-if-exists,\
+ frameworks/base/compiled-classes-phone:system/etc/compiled-classes)
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/base.mk)
diff --git a/target/product/core_tiny.mk b/target/product/core_tiny.mk
new file mode 100644
index 0000000000000000000000000000000000000000..ec2fa41d11c7925d63e6a4b43ee5f881878ef915
--- /dev/null
+++ b/target/product/core_tiny.mk
@@ -0,0 +1,143 @@
+#
+# Copyright (C) 2013 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.
+#
+# Tiny configuration for small devices such as wearables. Includes base and embedded.
+# No telephony
+
+PRODUCT_PACKAGES := \
+ Bluetooth \
+ CalendarProvider \
+ ContactsProvider \
+ CertInstaller \
+ FusedLocation \
+ InputDevices
+
+PRODUCT_PACKAGES += \
+ clatd \
+ clatd.conf \
+ pppd
+
+PRODUCT_PACKAGES += \
+ audio.primary.default \
+ audio_policy.default \
+ local_time.default \
+ power.default
+
+PRODUCT_PACKAGES += \
+ BackupRestoreConfirmation \
+ CtsShimPrebuilt \
+ CtsShimPrivPrebuilt \
+ DefaultContainerService \
+ ExtShared \
+ ExtServices \
+ SettingsProvider \
+ Shell \
+ WallpaperBackup \
+ bcc \
+ bu \
+ com.android.location.provider \
+ com.android.location.provider.xml \
+ framework-res \
+ installd \
+ ims-common \
+ ip \
+ ip-up-vpn \
+ ip6tables \
+ iptables \
+ gatekeeperd \
+ keystore \
+ keystore.default \
+ ld.mc \
+ libOpenMAXAL \
+ libOpenSLES \
+ libdownmix \
+ libfilterfw \
+ libgatekeeper \
+ libkeystore \
+ libwilhelm \
+ libdrmframework_jni \
+ libdrmframework \
+ make_ext4fs \
+ e2fsck \
+ resize2fs \
+ nullwebview \
+ screencap \
+ sensorservice \
+ uiautomator \
+ uncrypt \
+ telephony-common \
+ voip-common \
+ logd \
+ wifi-service
+
+# The order matters
+PRODUCT_BOOT_JARS := \
+ core-oj \
+ core-libart \
+ conscrypt \
+ okhttp \
+ core-junit \
+ bouncycastle \
+ ext \
+ framework \
+ telephony-common \
+ voip-common \
+ ims-common \
+ apache-xml \
+ nullwebview \
+ org.apache.http.legacy.boot
+
+# The order of PRODUCT_SYSTEM_SERVER_JARS matters.
+PRODUCT_SYSTEM_SERVER_JARS := \
+ services \
+ wifi-service
+
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ ro.zygote=zygote32
+PRODUCT_COPY_FILES += \
+ system/core/rootdir/init.zygote32.rc:root/init.zygote32.rc
+
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.carrier=unknown
+
+# Different dexopt types for different package update/install times.
+# On eng builds, make "boot" reasons do pure JIT for faster turnaround.
+ifeq (eng,$(TARGET_BUILD_VARIANT))
+ PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ pm.dexopt.first-boot=verify-at-runtime \
+ pm.dexopt.boot=verify-at-runtime
+else
+ PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ pm.dexopt.first-boot=interpret-only \
+ pm.dexopt.boot=verify-profile
+endif
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ pm.dexopt.install=interpret-only \
+ pm.dexopt.bg-dexopt=speed-profile \
+ pm.dexopt.ab-ota=speed-profile \
+ pm.dexopt.nsys-library=speed \
+ pm.dexopt.shared-apk=speed \
+ pm.dexopt.forced-dexopt=speed \
+ pm.dexopt.core-app=speed
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/runtime_libart.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/base.mk)
+$(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
+$(call inherit-product-if-exists, external/roboto-fonts/fonts.mk)
+
+# Overrides
+PRODUCT_BRAND := tiny
+PRODUCT_DEVICE := tiny
+PRODUCT_NAME := core_tiny
diff --git a/target/product/embedded.mk b/target/product/embedded.mk
new file mode 100644
index 0000000000000000000000000000000000000000..55de3b9e9dd796af04a559b7d5a45df25a039b94
--- /dev/null
+++ b/target/product/embedded.mk
@@ -0,0 +1,98 @@
+#
+# Copyright (C) 2009 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 build configuration for a very minimal build of the
+# Open-Source part of the tree.
+
+PRODUCT_PACKAGES += \
+ adb \
+ adbd \
+ atrace \
+ bootanimation \
+ bootstat \
+ cmd \
+ debuggerd \
+ dumpstate \
+ dumpsys \
+ fastboot \
+ gralloc.default \
+ grep \
+ gzip \
+ healthd \
+ init \
+ init.environ.rc \
+ init.rc \
+ libEGL \
+ libETC1 \
+ libFFTEm \
+ libGLESv1_CM \
+ libGLESv2 \
+ libGLESv3 \
+ libbinder \
+ libc \
+ libc_malloc_debug \
+ libcutils \
+ libdl \
+ libgui \
+ libhardware \
+ libhardware_legacy \
+ libjpeg \
+ liblog \
+ libm \
+ libpixelflinger \
+ libpower \
+ libsigchain \
+ libstdc++ \
+ libsurfaceflinger \
+ libsurfaceflinger_ddmconnection \
+ libsysutils \
+ libui \
+ libutils \
+ linker \
+ lmkd \
+ logcat \
+ logwrapper \
+ mkshrc \
+ reboot \
+ recovery \
+ service \
+ servicemanager \
+ sh \
+ surfaceflinger \
+ toolbox \
+ toybox \
+ tzdatacheck \
+
+# SELinux packages
+PRODUCT_PACKAGES += \
+ sepolicy \
+ file_contexts.bin \
+ seapp_contexts \
+ property_contexts \
+ mac_permissions.xml \
+ selinux_version \
+ service_contexts
+
+# Ensure that this property is always defined so that bionic_systrace.cpp
+# can rely on it being initially set by init.
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ debug.atrace.tags.enableflags=0
+
+PRODUCT_COPY_FILES += \
+ system/core/rootdir/init.usb.rc:root/init.usb.rc \
+ system/core/rootdir/init.usb.configfs.rc:root/init.usb.configfs.rc \
+ system/core/rootdir/ueventd.rc:root/ueventd.rc \
+ system/core/rootdir/etc/hosts:system/etc/hosts
diff --git a/target/product/emulator.mk b/target/product/emulator.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b08a28a2a9e8f4d4bcf9437623ce0fbf4feb61e2
--- /dev/null
+++ b/target/product/emulator.mk
@@ -0,0 +1,68 @@
+#
+# Copyright (C) 2012 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 file is included by other product makefiles to add all the
+# emulator-related modules to PRODUCT_PACKAGES.
+#
+
+# Host modules
+PRODUCT_PACKAGES += \
+
+
+# Device modules
+PRODUCT_PACKAGES += \
+ egl.cfg \
+ gralloc.goldfish \
+ gralloc.ranchu \
+ libGLESv1_CM_emulation \
+ lib_renderControl_enc \
+ libEGL_emulation \
+ libGLES_android \
+ libGLESv2_enc \
+ libOpenglSystemCommon \
+ libGLESv2_emulation \
+ libGLESv1_enc \
+ qemu-props \
+ qemud \
+ camera.goldfish \
+ camera.goldfish.jpeg \
+ camera.ranchu \
+ camera.ranchu.jpeg \
+ lights.goldfish \
+ gps.goldfish \
+ gps.ranchu \
+ fingerprint.goldfish \
+ sensors.goldfish \
+ audio.primary.goldfish \
+ vibrator.goldfish \
+ power.goldfish \
+ fingerprint.ranchu \
+ fingerprintd \
+ sensors.ranchu
+
+PRODUCT_COPY_FILES += \
+ device/generic/goldfish/fstab.goldfish:root/fstab.goldfish \
+ device/generic/goldfish/init.goldfish.rc:root/init.goldfish.rc \
+ device/generic/goldfish/init.goldfish.sh:system/etc/init.goldfish.sh \
+ device/generic/goldfish/ueventd.goldfish.rc:root/ueventd.goldfish.rc \
+ device/generic/goldfish/init.ranchu.rc:root/init.ranchu.rc \
+ device/generic/goldfish/fstab.ranchu:root/fstab.ranchu \
+ device/generic/goldfish/ueventd.ranchu.rc:root/ueventd.ranchu.rc \
+ frameworks/native/data/etc/android.hardware.usb.accessory.xml:system/etc/permissions/android.hardware.usb.accessory.xml
+
+PRODUCT_PACKAGE_OVERLAYS := device/generic/goldfish/overlay
+
+PRODUCT_CHARACTERISTICS := emulator
diff --git a/target/product/full.mk b/target/product/full.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b66ae92a53256967058f5a0852ac370868aae298
--- /dev/null
+++ b/target/product/full.mk
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2009 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic/device.mk)
+
+include $(SRC_TARGET_DIR)/product/emulator.mk
+
+# Overrides
+PRODUCT_NAME := full
+PRODUCT_DEVICE := generic
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on ARM Emulator
diff --git a/target/product/full_base.mk b/target/product/full_base.mk
new file mode 100644
index 0000000000000000000000000000000000000000..5fd7be6650c81b4807d0dd643980bb0eb4c4a112
--- /dev/null
+++ b/target/product/full_base.mk
@@ -0,0 +1,58 @@
+#
+# Copyright (C) 2009 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build of the emulator, but all those aspects can be overridden
+# in inherited configurations.
+
+PRODUCT_PACKAGES := \
+ libfwdlockengine \
+ OpenWnn \
+ libWnnEngDic \
+ libWnnJpnDic \
+ libwnndict \
+ WAPPushManager
+
+PRODUCT_PACKAGES += \
+ Galaxy4 \
+ HoloSpiralWallpaper \
+ LiveWallpapers \
+ LiveWallpapersPicker \
+ MagicSmokeWallpapers \
+ NoiseField \
+ PhaseBeam \
+ PhotoTable
+
+# Additional settings used in all AOSP builds
+PRODUCT_PROPERTY_OVERRIDES := \
+ ro.config.ringtone=Ring_Synth_04.ogg \
+ ro.config.notification_sound=pixiedust.ogg
+
+# Put en_US first in the list, so make it default.
+PRODUCT_LOCALES := zh_CN
+
+# Get some sounds
+$(call inherit-product-if-exists, frameworks/base/data/sounds/AllAudio.mk)
+
+# Get the TTS language packs
+$(call inherit-product-if-exists, external/svox/pico/lang/all_pico_languages.mk)
+
+# Get a list of languages.
+$(call inherit-product, $(SRC_TARGET_DIR)/product/locales_full.mk)
+
+# Get everything else from the parent package
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_no_telephony.mk)
diff --git a/target/product/full_base_telephony.mk b/target/product/full_base_telephony.mk
new file mode 100644
index 0000000000000000000000000000000000000000..9a2c63a8d0a64f6b7649052b217191081e873bd1
--- /dev/null
+++ b/target/product/full_base_telephony.mk
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2009 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+PRODUCT_PROPERTY_OVERRIDES := \
+ keyguard.no_require_sim=true \
+ ro.com.android.dataroaming=true
+
+PRODUCT_COPY_FILES := \
+ device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ frameworks/native/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/telephony.mk)
diff --git a/target/product/full_mips.mk b/target/product/full_mips.mk
new file mode 100644
index 0000000000000000000000000000000000000000..61734b43ccb275cf620e9d0af466c45bec371644
--- /dev/null
+++ b/target/product/full_mips.mk
@@ -0,0 +1,31 @@
+#
+# Copyright (C) 2009 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# mips build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_mips/device.mk)
+
+include $(SRC_TARGET_DIR)/product/emulator.mk
+
+# Overrides
+PRODUCT_NAME := full_mips
+PRODUCT_DEVICE := generic_mips
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on MIPS Emulator
diff --git a/target/product/full_x86.mk b/target/product/full_x86.mk
new file mode 100644
index 0000000000000000000000000000000000000000..4dff71342464c32122c876b06bb0e3a8c16fdb9d
--- /dev/null
+++ b/target/product/full_x86.mk
@@ -0,0 +1,44 @@
+#
+# Copyright (C) 2009 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+# If running on an emulator or some other device that has a LAN connection
+# that isn't a wifi connection. This will instruct init.rc to enable the
+# network connection so that you can use it with ADB
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_x86/device.mk)
+
+include $(SRC_TARGET_DIR)/product/emulator.mk
+
+ifdef NET_ETH0_STARTONBOOT
+ PRODUCT_PROPERTY_OVERRIDES += net.eth0.startonboot=1
+endif
+
+# Ensure we package the BIOS files too.
+PRODUCT_PACKAGES += \
+ bios.bin \
+ vgabios-cirrus.bin \
+
+# Overrides
+PRODUCT_NAME := full_x86
+PRODUCT_DEVICE := generic_x86
+PRODUCT_BRAND := Android
+PRODUCT_MODEL := AOSP on IA Emulator
diff --git a/target/product/generic.mk b/target/product/generic.mk
new file mode 100644
index 0000000000000000000000000000000000000000..dd0d663152607bfd59ad1fe07d814772af8c4d6e
--- /dev/null
+++ b/target/product/generic.mk
@@ -0,0 +1,26 @@
+#
+# 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 generic phone product that isn't specialized for a specific device.
+# It includes the base Android platform.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_no_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/telephony.mk)
+
+# Overrides
+PRODUCT_BRAND := generic
+PRODUCT_DEVICE := generic
+PRODUCT_NAME := generic
diff --git a/target/product/generic_armv5.mk b/target/product/generic_armv5.mk
new file mode 100644
index 0000000000000000000000000000000000000000..daa321a5658296e390eafee3c956ceba02726b79
--- /dev/null
+++ b/target/product/generic_armv5.mk
@@ -0,0 +1,25 @@
+#
+# Copyright (C) 2011 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 generic product that isn't specialized for a specific device.
+# It includes the base Android platform.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic.mk)
+
+# Overrides
+PRODUCT_BRAND := generic_armv5
+PRODUCT_DEVICE := generic_armv5
+PRODUCT_NAME := generic_armv5
diff --git a/target/product/generic_mips.mk b/target/product/generic_mips.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7b53d041af7c74a25372ba51bea2669aec46a9af
--- /dev/null
+++ b/target/product/generic_mips.mk
@@ -0,0 +1,26 @@
+#
+# 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 generic phone product that isn't specialized for a specific device.
+# It includes the base Android platform.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/generic_no_telephony.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/telephony.mk)
+
+# Overrides
+PRODUCT_BRAND := generic_mips
+PRODUCT_DEVICE := generic_mips
+PRODUCT_NAME := generic_mips
diff --git a/target/product/generic_no_telephony.mk b/target/product/generic_no_telephony.mk
new file mode 100644
index 0000000000000000000000000000000000000000..5c4835877a5654a16cd9fcfb7e397bff426efb02
--- /dev/null
+++ b/target/product/generic_no_telephony.mk
@@ -0,0 +1,76 @@
+#
+# 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 generic phone product that isn't specialized for a specific device.
+# It includes the base Android platform.
+
+PRODUCT_PACKAGES := \
+ Bluetooth \
+ BluetoothMidiService \
+ Camera2 \
+ Gallery2 \
+ Music \
+ MusicFX \
+ OneTimeInitializer \
+ Provision \
+ SystemUI \
+ EasterEgg \
+ WallpaperCropper
+
+PRODUCT_PACKAGES += \
+ clatd \
+ clatd.conf \
+ pppd \
+ screenrecord
+
+PRODUCT_PACKAGES += \
+ librs_jni \
+ libvideoeditor_jni \
+ libvideoeditor_core \
+ libvideoeditor_osal \
+ libvideoeditor_videofilters \
+ libvideoeditorplayer \
+
+PRODUCT_PACKAGES += \
+ audio.primary.default \
+ audio_policy.default \
+ local_time.default \
+ vibrator.default \
+ power.default
+
+PRODUCT_COPY_FILES := \
+ frameworks/av/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf
+
+PRODUCT_PROPERTY_OVERRIDES += \
+ ro.carrier=unknown
+
+$(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/dancing-script/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/carrois-gothic-sc/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/coming-soon/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/cutive-mono/fonts.mk)
+$(call inherit-product-if-exists, external/noto-fonts/fonts.mk)
+$(call inherit-product-if-exists, external/naver-fonts/fonts.mk)
+$(call inherit-product-if-exists, external/roboto-fonts/fonts.mk)
+$(call inherit-product-if-exists, external/hyphenation-patterns/patterns.mk)
+$(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
+$(call inherit-product-if-exists, frameworks/webview/chromium/chromium.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
+
+# Overrides
+PRODUCT_BRAND := generic
+PRODUCT_DEVICE := generic
+PRODUCT_NAME := generic_no_telephony
diff --git a/target/product/generic_x86.mk b/target/product/generic_x86.mk
new file mode 100644
index 0000000000000000000000000000000000000000..0274b5b24d3a4ab9572cabea65f98f2f26b45d85
--- /dev/null
+++ b/target/product/generic_x86.mk
@@ -0,0 +1,25 @@
+#
+# 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 generic phone product that isn't specialized for a specific device.
+# It includes the base Android platform.
+
+include $(SRC_TARGET_DIR)/product/generic.mk
+
+# Overrides
+PRODUCT_BRAND := generic_x86
+PRODUCT_DEVICE := generic_x86
+PRODUCT_NAME := generic_x86
diff --git a/target/product/languages_full.mk b/target/product/languages_full.mk
new file mode 100644
index 0000000000000000000000000000000000000000..98d8c3ce90a09a90b24db52e845c5b1eb55c095b
--- /dev/null
+++ b/target/product/languages_full.mk
@@ -0,0 +1,24 @@
+#
+# Copyright (C) 2009 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 build configuration that just contains a list of languages.
+# It helps in situations where languages must come first in the list,
+# mostly because screen densities interfere with the list of locales and
+# the system misbehaves when a density is the first locale.
+
+# These are all the locales that have translations and are displayable
+# by TextView in this branch.
+PRODUCT_LOCALES := en_US en_AU en_IN fr_FR it_IT es_ES et_EE de_DE nl_NL cs_CZ pl_PL ja_JP zh_TW zh_CN zh_HK ru_RU ko_KR nb_NO es_US da_DK el_GR tr_TR pt_PT pt_BR sv_SE bg_BG ca_ES en_GB fi_FI hi_IN hr_HR hu_HU in_ID iw_IL lt_LT lv_LV ro_RO sk_SK sl_SI sr_RS uk_UA vi_VN tl_PH ar_EG fa_IR th_TH sw_TZ ms_MY af_ZA zu_ZA am_ET en_XA ar_XB fr_CA km_KH lo_LA ne_NP si_LK mn_MN hy_AM az_AZ ka_GE my_MM mr_IN ml_IN is_IS mk_MK ky_KG eu_ES gl_ES bn_BD ta_IN kn_IN te_IN uz_UZ ur_PK kk_KZ sq_AL gu_IN pa_IN be_BY bs_BA
diff --git a/target/product/languages_small.mk b/target/product/languages_small.mk
new file mode 100644
index 0000000000000000000000000000000000000000..d695ca8dae3549325e420ec810bbb9574785edd5
--- /dev/null
+++ b/target/product/languages_small.mk
@@ -0,0 +1,24 @@
+#
+# Copyright (C) 2009 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 build configuration that just contains a list of languages.
+# It helps in situations where laugnages must come first in the list,
+# mostly because screen densities interfere with the list of locales and
+# the system misbehaves when a density is the first locale.
+
+# This is the list of languages that originally shipped on ADP1
+
+PRODUCT_LOCALES := en_US en_GB fr_FR it_IT de_DE es_ES
diff --git a/target/product/locales_full.mk b/target/product/locales_full.mk
new file mode 100644
index 0000000000000000000000000000000000000000..3a90d2b885b5da79f298a38e744686ae570a2c3e
--- /dev/null
+++ b/target/product/locales_full.mk
@@ -0,0 +1,3 @@
+PRODUCT_LOCALES := en_US cs_CZ da_DK de_AT de_CH de_DE de_LI el_GR en_AU en_CA en_GB en_NZ en_SG eo_EU es_ES fr_CA fr_CH fr_BE fr_FR it_CH it_IT ja_JP ko_KR nb_NO nl_BE nl_NL pl_PL pt_PT ru_RU sv_SE tr_TR zh_CN zh_HK zh_TW am_ET hi_IN
+
+$(call inherit-product, build/target/product/languages_full.mk)
diff --git a/target/product/product_launched_with_l.mk b/target/product/product_launched_with_l.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b86f424f395566956c0fd44aafa26bd906b495af
--- /dev/null
+++ b/target/product/product_launched_with_l.mk
@@ -0,0 +1,2 @@
+#PRODUCT_SHIPPING_API_LEVEL indicates the first api level, device has been commercially launced on.
+PRODUCT_SHIPPING_API_LEVEL := 21
diff --git a/target/product/product_launched_with_l_mr1.mk b/target/product/product_launched_with_l_mr1.mk
new file mode 100644
index 0000000000000000000000000000000000000000..7a5bd0f2da964050543b43ee19a00b906a456968
--- /dev/null
+++ b/target/product/product_launched_with_l_mr1.mk
@@ -0,0 +1,2 @@
+#PRODUCT_SHIPPING_API_LEVEL indicates the first api level, device has been commercially launced on.
+PRODUCT_SHIPPING_API_LEVEL := 22
diff --git a/target/product/product_launched_with_m.mk b/target/product/product_launched_with_m.mk
new file mode 100644
index 0000000000000000000000000000000000000000..afd8647dd8a5d2d68b3922ac00902c3d13e52dae
--- /dev/null
+++ b/target/product/product_launched_with_m.mk
@@ -0,0 +1,2 @@
+#PRODUCT_SHIPPING_API_LEVEL indicates the first api level, device has been commercially launced on.
+PRODUCT_SHIPPING_API_LEVEL := 23
diff --git a/target/product/product_launched_with_n.mk b/target/product/product_launched_with_n.mk
new file mode 100644
index 0000000000000000000000000000000000000000..f7c5d794dc5f9c0752d6db8888824871519e622a
--- /dev/null
+++ b/target/product/product_launched_with_n.mk
@@ -0,0 +1,2 @@
+#PRODUCT_SHIPPING_API_LEVEL indicates the first api level, device has been commercially launced on.
+PRODUCT_SHIPPING_API_LEVEL := 24
diff --git a/target/product/runtime_libart.mk b/target/product/runtime_libart.mk
new file mode 100644
index 0000000000000000000000000000000000000000..5fd4d7ec63385ea2a30027316dae73ec60d52821
--- /dev/null
+++ b/target/product/runtime_libart.mk
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2013 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.
+#
+
+# Provides a functioning ART environment without Android frameworks
+
+PRODUCT_PACKAGES += \
+ apache-xml \
+ ahat \
+ bouncycastle \
+ cacerts \
+ conscrypt \
+ core-oj \
+ core-junit \
+ core-libart \
+ dalvikvm \
+ dex2oat \
+ dexdeps \
+ dexdump \
+ dexlist \
+ dmtracedump \
+ dx \
+ ext \
+ hprof-conv \
+ libart \
+ libart_fake \
+ libcrypto \
+ libexpat \
+ libicui18n \
+ libicuuc \
+ libjavacore \
+ libopenjdk \
+ libopenjdkjvm \
+ libnativehelper \
+ libssl \
+ libz \
+ oatdump \
+ okhttp \
+ patchoat \
+ profman
+
+PRODUCT_DEFAULT_PROPERTY_OVERRIDES += \
+ dalvik.vm.image-dex2oat-Xms=64m \
+ dalvik.vm.image-dex2oat-Xmx=64m \
+ dalvik.vm.dex2oat-Xms=64m \
+ dalvik.vm.dex2oat-Xmx=512m \
+ ro.dalvik.vm.native.bridge=0 \
+ dalvik.vm.usejit=true \
+ dalvik.vm.usejitprofiles=true \
+ dalvik.vm.appimageformat=lz4
diff --git a/target/product/sdk.mk b/target/product/sdk.mk
new file mode 100644
index 0000000000000000000000000000000000000000..96d8cc94e1f1b1e98ccf54dd34c2bb6b58655bf5
--- /dev/null
+++ b/target/product/sdk.mk
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2014 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 modify this file - It's just an alias!
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_phone_armv7.mk)
+
+PRODUCT_NAME := sdk
diff --git a/target/product/sdk_arm64.mk b/target/product/sdk_arm64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..8bb38f41a1d017ffbea4af354417fa9e70ad632b
--- /dev/null
+++ b/target/product/sdk_arm64.mk
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2014 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 modify this file - It's just an alias!
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_phone_arm64.mk)
+
+PRODUCT_NAME := sdk_arm64
diff --git a/target/product/sdk_base.mk b/target/product/sdk_base.mk
new file mode 100644
index 0000000000000000000000000000000000000000..fa257aeffb356ae186b554765662a4857c395d8a
--- /dev/null
+++ b/target/product/sdk_base.mk
@@ -0,0 +1,163 @@
+#
+# 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.
+#
+
+PRODUCT_PROPERTY_OVERRIDES :=
+
+PRODUCT_PACKAGES := \
+ ApiDemos \
+ CubeLiveWallpapers \
+ CustomLocale \
+ Development \
+ Dialer \
+ EmulatorSmokeTests \
+ Fallback \
+ Gallery \
+ GestureBuilder \
+ Launcher3 \
+ LegacyCamera \
+ librs_jni \
+ libwnndict \
+ libWnnEngDic \
+ libWnnJpnDic \
+ LiveWallpapersPicker \
+ Mms \
+ Music \
+ OpenWnn \
+ Protips \
+ rild \
+ SdkSetup \
+ SmokeTest \
+ SmokeTestApp \
+ SoftKeyboard \
+ sqlite3 \
+ SystemUI \
+ EasterEgg \
+ WidgetPreview
+
+# Define the host tools and libs that are parts of the SDK.
+-include sdk/build/product_sdk.mk
+-include development/build/product_sdk.mk
+
+# audio libraries.
+PRODUCT_PACKAGES += \
+ audio.primary.goldfish \
+ audio_policy.default \
+ local_time.default
+
+PRODUCT_PACKAGE_OVERLAYS := development/sdk_overlay
+
+PRODUCT_COPY_FILES := \
+ device/generic/goldfish/data/etc/apns-conf.xml:system/etc/apns-conf.xml \
+ device/sample/etc/old-apns-conf.xml:system/etc/old-apns-conf.xml \
+ frameworks/base/data/sounds/effects/camera_click.ogg:system/media/audio/ui/camera_click.ogg \
+ frameworks/base/data/sounds/effects/VideoRecord.ogg:system/media/audio/ui/VideoRecord.ogg \
+ frameworks/base/data/sounds/effects/VideoStop.ogg:system/media/audio/ui/VideoStop.ogg \
+ device/generic/goldfish/data/etc/handheld_core_hardware.xml:system/etc/permissions/handheld_core_hardware.xml \
+ device/generic/goldfish/camera/media_profiles.xml:system/etc/media_profiles.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_audio.xml:system/etc/media_codecs_google_audio.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_telephony.xml:system/etc/media_codecs_google_telephony.xml \
+ frameworks/av/media/libstagefright/data/media_codecs_google_video.xml:system/etc/media_codecs_google_video.xml \
+ device/generic/goldfish/camera/media_codecs.xml:system/etc/media_codecs.xml \
+ frameworks/native/data/etc/android.hardware.touchscreen.multitouch.jazzhand.xml:system/etc/permissions/android.hardware.touchscreen.multitouch.jazzhand.xml \
+ frameworks/native/data/etc/android.hardware.camera.autofocus.xml:system/etc/permissions/android.hardware.camera.autofocus.xml \
+ frameworks/native/data/etc/android.hardware.fingerprint.xml:system/etc/permissions/android.hardware.fingerprint.xml \
+ frameworks/av/media/libeffects/data/audio_effects.conf:system/etc/audio_effects.conf \
+ hardware/libhardware_legacy/audio/audio_policy.conf:system/etc/audio_policy.conf
+
+include $(SRC_TARGET_DIR)/product/emulator.mk
+
+$(call inherit-product-if-exists, frameworks/base/data/sounds/AllAudio.mk)
+$(call inherit-product-if-exists, frameworks/base/data/fonts/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/dancing-script/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/carrois-gothic-sc/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/coming-soon/fonts.mk)
+$(call inherit-product-if-exists, external/google-fonts/cutive-mono/fonts.mk)
+$(call inherit-product-if-exists, external/noto-fonts/fonts.mk)
+$(call inherit-product-if-exists, external/naver-fonts/fonts.mk)
+$(call inherit-product-if-exists, external/roboto-fonts/fonts.mk)
+$(call inherit-product-if-exists, frameworks/base/data/keyboards/keyboards.mk)
+$(call inherit-product-if-exists, frameworks/webview/chromium/chromium.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core.mk)
+
+# include available languages for TTS in the system image
+-include external/svox/pico/lang/PicoLangDeDeInSystem.mk
+-include external/svox/pico/lang/PicoLangEnGBInSystem.mk
+-include external/svox/pico/lang/PicoLangEnUsInSystem.mk
+-include external/svox/pico/lang/PicoLangEsEsInSystem.mk
+-include external/svox/pico/lang/PicoLangFrFrInSystem.mk
+-include external/svox/pico/lang/PicoLangItItInSystem.mk
+
+# locale. en_US is both first and in alphabetical order to
+# ensure this is the default locale.
+PRODUCT_LOCALES := \
+ en_US \
+ ar_EG \
+ ar_IL \
+ bg_BG \
+ ca_ES \
+ cs_CZ \
+ da_DK \
+ de_AT \
+ de_CH \
+ de_DE \
+ de_LI \
+ el_GR \
+ en_AU \
+ en_CA \
+ en_GB \
+ en_IE \
+ en_IN \
+ en_NZ \
+ en_SG \
+ en_US \
+ en_ZA \
+ es_ES \
+ es_US \
+ fi_FI \
+ fr_BE \
+ fr_CA \
+ fr_CH \
+ fr_FR \
+ he_IL \
+ hi_IN \
+ hr_HR \
+ hu_HU \
+ id_ID \
+ it_CH \
+ it_IT \
+ ja_JP \
+ ko_KR \
+ lt_LT \
+ lv_LV \
+ nb_NO \
+ nl_BE \
+ nl_NL \
+ pl_PL \
+ pt_BR \
+ pt_PT \
+ ro_RO \
+ ru_RU \
+ sk_SK \
+ sl_SI \
+ sr_RS \
+ sv_SE \
+ th_TH \
+ tl_PH \
+ tr_TR \
+ uk_UA \
+ vi_VN \
+ zh_CN \
+ zh_TW
diff --git a/target/product/sdk_mips.mk b/target/product/sdk_mips.mk
new file mode 100644
index 0000000000000000000000000000000000000000..366994a3109db559d56496af25bd8a0f77e2c0cb
--- /dev/null
+++ b/target/product/sdk_mips.mk
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2014 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 modify this file - It's just an alias!
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_phone_mips.mk)
+
+PRODUCT_NAME := sdk_mips
diff --git a/target/product/sdk_phone_arm64.mk b/target/product/sdk_phone_arm64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..a689475b3ba72004e59083b951fb244a867a2e06
--- /dev/null
+++ b/target/product/sdk_phone_arm64.mk
@@ -0,0 +1,36 @@
+#
+# Copyright (C) 2009 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_base.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/board/generic_arm64/device.mk)
+
+# AOSP emulator images build the AOSP messaging app.
+# Google API images override with the Google API app.
+# See vendor/google/products/sdk_google_phone_*.mk
+PRODUCT_PACKAGES += \
+ messaging
+
+# Overrides
+PRODUCT_BRAND := Android
+PRODUCT_NAME := sdk_phone_arm64
+PRODUCT_DEVICE := generic_arm64
+PRODUCT_MODEL := Android SDK built for arm64
diff --git a/target/product/sdk_phone_armv7.mk b/target/product/sdk_phone_armv7.mk
new file mode 100644
index 0000000000000000000000000000000000000000..ebdd0e7f424cb550b87d088acef98bbe3ec9d272
--- /dev/null
+++ b/target/product/sdk_phone_armv7.mk
@@ -0,0 +1,28 @@
+#
+# 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.
+#
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_base.mk)
+
+# AOSP emulator images build the AOSP messaging app.
+# Google API images override with the Google API app.
+# See vendor/google/products/sdk_google_phone_*.mk
+PRODUCT_PACKAGES += \
+ messaging
+
+# Overrides
+PRODUCT_BRAND := Android
+PRODUCT_NAME := sdk_phone_armv7
+PRODUCT_DEVICE := generic
diff --git a/target/product/sdk_phone_mips.mk b/target/product/sdk_phone_mips.mk
new file mode 100644
index 0000000000000000000000000000000000000000..1cc2fe4b554e42866da8402b75823e2872c69cb3
--- /dev/null
+++ b/target/product/sdk_phone_mips.mk
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 2012 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_base.mk)
+
+# AOSP emulator images build the AOSP messaging app.
+# Google API images override with the Google API app.
+# See vendor/google/products/sdk_google_phone_*.mk
+PRODUCT_PACKAGES += \
+ messaging
+
+# Overrides
+PRODUCT_BRAND := Android
+PRODUCT_NAME := sdk_phone_mips
+PRODUCT_DEVICE := generic_mips
+PRODUCT_MODEL := Android SDK for Mips
diff --git a/target/product/sdk_phone_mips64.mk b/target/product/sdk_phone_mips64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..e45d71bd893f37bdabf26c8d03f9a95cd501625b
--- /dev/null
+++ b/target/product/sdk_phone_mips64.mk
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2009 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_base.mk)
+
+# AOSP emulator images build the AOSP messaging app.
+# Google API images override with the Google API app.
+# See vendor/google/products/sdk_google_phone_*.mk
+PRODUCT_PACKAGES += \
+ messaging
+
+# Overrides
+PRODUCT_BRAND := Android
+PRODUCT_NAME := sdk_phone_mips64
+PRODUCT_DEVICE := generic_mips64
+PRODUCT_MODEL := Android SDK built for mips64
diff --git a/target/product/sdk_phone_x86.mk b/target/product/sdk_phone_x86.mk
new file mode 100644
index 0000000000000000000000000000000000000000..01c2e8339f1a09a35bbd43ab7fdfb95f65fa6e2a
--- /dev/null
+++ b/target/product/sdk_phone_x86.mk
@@ -0,0 +1,34 @@
+#
+# Copyright (C) 2009 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_base.mk)
+
+# AOSP emulator images build the AOSP messaging app.
+# Google API images override with the Google API app.
+# See vendor/google/products/sdk_google_phone_*.mk
+PRODUCT_PACKAGES += \
+ messaging
+
+# Overrides
+PRODUCT_BRAND := Android
+PRODUCT_NAME := sdk_phone_x86
+PRODUCT_DEVICE := generic_x86
+PRODUCT_MODEL := Android SDK built for x86
diff --git a/target/product/sdk_phone_x86_64.mk b/target/product/sdk_phone_x86_64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..c3bc5e9589ccdebdfc0968532742e88fc7fc686c
--- /dev/null
+++ b/target/product/sdk_phone_x86_64.mk
@@ -0,0 +1,35 @@
+#
+# Copyright (C) 2009 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 build configuration for a full-featured build of the
+# Open-Source part of the tree. It's geared toward a US-centric
+# build quite specifically for the emulator, and might not be
+# entirely appropriate to inherit from for on-device configurations.
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_base.mk)
+
+# AOSP emulator images build the AOSP messaging app.
+# Google API images override with the Google API app.
+# See vendor/google/products/sdk_google_phone_*.mk
+PRODUCT_PACKAGES += \
+ messaging
+
+# Overrides
+PRODUCT_BRAND := Android
+PRODUCT_NAME := sdk_phone_x86_64
+PRODUCT_DEVICE := generic_x86_64
+PRODUCT_MODEL := Android SDK built for x86_64
diff --git a/target/product/sdk_x86.mk b/target/product/sdk_x86.mk
new file mode 100644
index 0000000000000000000000000000000000000000..13ee57d8055e855aa67ed7e287bfa93373d29ab9
--- /dev/null
+++ b/target/product/sdk_x86.mk
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2014 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 modify this file - It's just an alias!
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_phone_x86.mk)
+
+PRODUCT_NAME := sdk_x86
diff --git a/target/product/sdk_x86_64.mk b/target/product/sdk_x86_64.mk
new file mode 100644
index 0000000000000000000000000000000000000000..5f6553e000cc8e61938ca25a495bf3835f33eb2d
--- /dev/null
+++ b/target/product/sdk_x86_64.mk
@@ -0,0 +1,21 @@
+#
+# Copyright (C) 2014 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 modify this file - It's just an alias!
+
+$(call inherit-product, $(SRC_TARGET_DIR)/product/sdk_phone_x86_64.mk)
+
+PRODUCT_NAME := sdk_x86_64
diff --git a/target/product/security/Android.mk b/target/product/security/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..5a40397abfc96d99d48911dfecb527858e7fd2f2
--- /dev/null
+++ b/target/product/security/Android.mk
@@ -0,0 +1,12 @@
+LOCAL_PATH:= $(call my-dir)
+
+#######################################
+# verity_key
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := verity_key
+LOCAL_SRC_FILES := $(LOCAL_MODULE)
+LOCAL_MODULE_CLASS := ETC
+LOCAL_MODULE_PATH := $(TARGET_ROOT_OUT)
+
+include $(BUILD_PREBUILT)
diff --git a/target/product/security/README b/target/product/security/README
new file mode 100644
index 0000000000000000000000000000000000000000..15f2e93e0f42a5568a5b6ad7c13c96d377f50c1d
--- /dev/null
+++ b/target/product/security/README
@@ -0,0 +1,38 @@
+For detailed information on key types and image signing, please see:
+
+https://source.android.com/devices/tech/ota/sign_builds.html
+
+The test keys in this directory are used in development only and should
+NEVER be used to sign packages in publicly released images (as that would
+open a major security hole).
+
+key generation
+--------------
+
+The following commands were used to generate the test key pairs:
+
+ development/tools/make_key testkey '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
+ development/tools/make_key platform '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
+ development/tools/make_key shared '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
+ development/tools/make_key media '/C=US/ST=California/L=Mountain View/O=Android/OU=Android/CN=Android/emailAddress=android@android.com'
+
+signing using the openssl commandline (for boot/system images)
+--------------------------------------------------------------
+
+1. convert pk8 format key to pem format
+ % openssl pkcs8 -inform DER -nocrypt -in testkey.pk8 -out testkey.pem
+
+2. create a signature using the pem format key
+ % openssl dgst -binary -sha1 -sign testkey.pem FILE > FILE.sig
+
+extracting public keys for embedding
+------------------------------------
+
+dumpkey.jar is a Java tool that takes an x.509 certificate in PEM format as
+input and prints a C structure to standard output:
+
+ $ java -jar out/host/linux-x86/framework/dumpkey.jar build/target/product/security/testkey.x509.pem
+ {64,0xc926ad21,{1795090719,2141396315,950055447,2581568430,4268923165,1920809988,546586521,3498997798,1776797858,3740060814,1805317999,1429410244,129622599,1422441418,1783893377,1222374759,2563319927,323993566,28517732,609753416,1826472888,215237850,4261642700,4049082591,3228462402,774857746,154822455,2497198897,2758199418,3019015328,2794777644,87251430,2534927978,120774784,571297800,3695899472,2479925187,3811625450,3401832990,2394869647,3267246207,950095497,555058928,414729973,1136544882,3044590084,465547824,4058146728,2731796054,1689838846,3890756939,1048029507,895090649,247140249,178744550,3547885223,3165179243,109881576,3944604415,1044303212,3772373029,2985150306,3737520932,3599964420},{3437017481,3784475129,2800224972,3086222688,251333580,2131931323,512774938,325948880,2657486437,2102694287,3820568226,792812816,1026422502,2053275343,2800889200,3113586810,165549746,4273519969,4065247892,1902789247,772932719,3941848426,3652744109,216871947,3164400649,1942378755,3996765851,1055777370,964047799,629391717,2232744317,3910558992,191868569,2758883837,3682816752,2997714732,2702529250,3570700455,3776873832,3924067546,3555689545,2758825434,1323144535,61311905,1997411085,376844204,213777604,4077323584,9135381,1625809335,2804742137,2952293945,1117190829,4237312782,1825108855,3013147971,1111251351,2568837572,1684324211,2520978805,367251975,810756730,2353784344,1175080310}}
+
+This is called by build/core/Makefile to incorporate the OTA signing keys
+into the recovery image.
diff --git a/target/product/security/media.pk8 b/target/product/security/media.pk8
new file mode 100644
index 0000000000000000000000000000000000000000..a6db9ba176d83a1c22f3b7faa57be4aa33033a2d
Binary files /dev/null and b/target/product/security/media.pk8 differ
diff --git a/target/product/security/media.x509.pem b/target/product/security/media.x509.pem
new file mode 100644
index 0000000000000000000000000000000000000000..98cd443db743b98b951ab818a9b698605ee4ff30
--- /dev/null
+++ b/target/product/security/media.x509.pem
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEqDCCA5CgAwIBAgIJAPK5jmEjVyxOMA0GCSqGSIb3DQEBBAUAMIGUMQswCQYD
+VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g
+VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE
+AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
+Fw0wODA0MTUyMzQwNTdaFw0zNTA5MDEyMzQwNTdaMIGUMQswCQYDVQQGEwJVUzET
+MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G
+A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p
+ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI
+hvcNAQEBBQADggENADCCAQgCggEBAK4lDFoW75f8KGmsZRsyF8w2ug6GlkFo1YoE
+n0DOhYZxI6P/tPbZScM88to6BcI+rKpX2AOImxdZvPWefG8hiQriUIW37VaqYmwJ
+ie+czTY2LKDo0blgP9TYModnkmzMCQxot3Wuf/MJNMw2nvKFWiZn3wxmf9DHz12O
+umVYBnNzA7tiRybquu37cvB+16dqs8uaOBxLfc2AmxQNiR8AITvkAfWNagamHq3D
+qcLxxlZyhbCa4JNCpm+kIer5Ot91c6AowzHXBgGrOvfMhAM+znx3KjpbhrDb6dd3
+w6SKqYAe3O4ngVifRNnkETl5YAV2qZQQuoEJElna2YxsaP94S48CAQOjgfwwgfkw
+HQYDVR0OBBYEFMopPKqLwO0+VC7vQgWiv/K1fk11MIHJBgNVHSMEgcEwgb6AFMop
+PKqLwO0+VC7vQgWiv/K1fk11oYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE
+CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH
+QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG
+CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJAPK5jmEjVyxOMAwGA1Ud
+EwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBAITelRbV5KhyF6c9qEhwSPUzc6X3
+M/OQ1hvfPMnlJRYlv8qnwxWcriddFyqa4eh21UWBJ6xUL2gpDdUQwAKdj1Hg7hVr
+e3tazbOUJBuOx4t05cQsXK+uFWyvW9GZojonUk2gct6743hGSlM2MLDk0P+34I7L
+cB+ttjecdEZ/bgDG7YiFlTgHkgOHVgB4csjjAHr0I6V6LKs6KChptkxLe9X8GH0K
+fiQVll1ark4Hpt91G0p16Xk8kYphK4HNC2KK7gFo3ETkexDTWTJghJ1q321yfcJE
+RMIh0/nsw2jK0HmZ8rgQW8HyDTjUEGbMFBHCV6lupDSfV0ZWVQfk6AIKGoE=
+-----END CERTIFICATE-----
diff --git a/target/product/security/platform.pk8 b/target/product/security/platform.pk8
new file mode 100644
index 0000000000000000000000000000000000000000..e27a3933e82ee93d4faa03ed06467bfecf81bf80
Binary files /dev/null and b/target/product/security/platform.pk8 differ
diff --git a/target/product/security/platform.x509.pem b/target/product/security/platform.x509.pem
new file mode 100644
index 0000000000000000000000000000000000000000..087f02e6a97fd21793577e12e4768ed538213a2a
--- /dev/null
+++ b/target/product/security/platform.x509.pem
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEqDCCA5CgAwIBAgIJALOZgIbQVs/6MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYD
+VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g
+VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE
+AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
+Fw0wODA0MTUyMjQwNTBaFw0zNTA5MDEyMjQwNTBaMIGUMQswCQYDVQQGEwJVUzET
+MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G
+A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p
+ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI
+hvcNAQEBBQADggENADCCAQgCggEBAJx4BZKsDV04HN6qZezIpgBuNkgMbXIHsSAR
+vlCGOqvitV0Amt9xRtbyICKAx81Ne9smJDuKgGwms0sTdSOkkmgiSQTcAUk+fArP
+GgXIdPabA3tgMJ2QdNJCgOFrrSqHNDYZUer3KkgtCbIEsYdeEqyYwap3PWgAuer9
+5W1Yvtjo2hb5o2AJnDeoNKbf7be2tEoEngeiafzPLFSW8s821k35CjuNjzSjuqtM
+9TNxqydxmzulh1StDFP8FOHbRdUeI0+76TybpO35zlQmE1DsU1YHv2mi/0qgfbX3
+6iANCabBtJ4hQC+J7RGQiTqrWpGA8VLoL4WkV1PPX8GQccXuyCcCAQOjgfwwgfkw
+HQYDVR0OBBYEFE/koLPdnLop9x1yh8Tnw48ghsKZMIHJBgNVHSMEgcEwgb6AFE/k
+oLPdnLop9x1yh8Tnw48ghsKZoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE
+CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH
+QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG
+CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJALOZgIbQVs/6MAwGA1Ud
+EwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBAFclUbjZOh9z3g9tRp+G2tZwFAAp
+PIigzXzXeLc9r8wZf6t25iEuVsHHYc/EL9cz3lLFCuCIFM78CjtaGkNGBU2Cnx2C
+tCsgSL+ItdFJKe+F9g7dEtctVWV+IuPoXQTIMdYT0Zk4u4mCJH+jISVroS0dao+S
+6h2xw3Mxe6DAN/DRr/ZFrvIkl5+6bnoUvAJccbmBOM7z3fwFlhfPJIRc97QNY4L3
+J17XOElatuWTG5QhdlxJG3L7aOCA29tYwgKdNHyLMozkPvaosVUz7fvpib1qSN1L
+IC7alMarjdW4OZID2q4u1EYjLk/pvZYTlMYwDlE448/Shebk5INTjLixs1c=
+-----END CERTIFICATE-----
diff --git a/target/product/security/shared.pk8 b/target/product/security/shared.pk8
new file mode 100644
index 0000000000000000000000000000000000000000..cf99acd5215ea81649c189155a19ea276435ec4e
Binary files /dev/null and b/target/product/security/shared.pk8 differ
diff --git a/target/product/security/shared.x509.pem b/target/product/security/shared.x509.pem
new file mode 100644
index 0000000000000000000000000000000000000000..7f886a844a5b57fd1106c5c1f9186f2c0a6a0b85
--- /dev/null
+++ b/target/product/security/shared.x509.pem
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEqDCCA5CgAwIBAgIJAPKnM5a9OHZ6MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYD
+VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g
+VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE
+AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
+Fw0wODA3MjMyMTU3NTlaFw0zNTEyMDkyMTU3NTlaMIGUMQswCQYDVQQGEwJVUzET
+MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G
+A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p
+ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI
+hvcNAQEBBQADggENADCCAQgCggEBAMjC2/0JSi30XD/xoy7SGAXscvxY0BeXG9D2
+tSwmLXCBnRkZZ+FY39Oix/Gz4OgM5UXXnShIIgIR64bw/YMS03tCDBE3UMyUYYro
+cvSIZGO9xGJ8qgwEg8hkk+NRVXEXAzi/3MTNat3RwKLzX1zyTtPkBDo+WOKwXmZM
+zeEry2dzX9bfEknDaeYlQrwKRynlORf1w4/6UtF7c8nHN5jdsY7UgVkIdVR+Zr/F
+2spMJabrlg7ZaSNwnaMCumRstJazJehsXIsuejN3srvkx88zJUKRFj9okVKsCIVQ
+yDxQj0v1rfCu1aLcoFg/mrCtF2UNt+6ksj/bRYhVR9D+q3IYOIkCAQOjgfwwgfkw
+HQYDVR0OBBYEFMtMfizbs/CtqY2reZaNFy6dux7RMIHJBgNVHSMEgcEwgb6AFMtM
+fizbs/CtqY2reZaNFy6dux7RoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE
+CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH
+QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG
+CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJAPKnM5a9OHZ6MAwGA1Ud
+EwQFMAMBAf8wDQYJKoZIhvcNAQEEBQADggEBAECo0JaZeVnpF6NsRCRra6wrrgVD
+fs2JeUEY94NHIDUtHG+KObCGmUL02mWYH6opUdM5cRKewZIdeVZxxSfW4knyUoKf
+r1tZExAxHi3gllANVorUEUplbcNKjG9hBFOvwep5ktukqns/hUOm41wHKN53/pfu
+rIN3H9DskPjkRJQ07gtgRXg+cMei5GAkkmDgA892CNw1Kkye9wbe9LJgUOl4ri//
+16MyN4cBSRXrPMh0/MeprpMId8XIx9HC4qjuhjyJGA0YVc7bpADnukPMyqckPTl+
+fA6Ojk19T5K2u+rUnAzwGAae3coufi+0Zo2J2715UNDNJUGA+h6q/CpVb4Q=
+-----END CERTIFICATE-----
diff --git a/target/product/security/testkey.pk8 b/target/product/security/testkey.pk8
new file mode 100644
index 0000000000000000000000000000000000000000..586c1bd5cf96f9358f36b37ea98fef93f4d0a8e3
Binary files /dev/null and b/target/product/security/testkey.pk8 differ
diff --git a/target/product/security/testkey.x509.pem b/target/product/security/testkey.x509.pem
new file mode 100644
index 0000000000000000000000000000000000000000..e242d83e2bf72169ab0abd5280d4d455caef71eb
--- /dev/null
+++ b/target/product/security/testkey.x509.pem
@@ -0,0 +1,27 @@
+-----BEGIN CERTIFICATE-----
+MIIEqDCCA5CgAwIBAgIJAJNurL4H8gHfMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD
+VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4g
+VmlldzEQMA4GA1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UE
+AxMHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
+Fw0wODAyMjkwMTMzNDZaFw0zNTA3MTcwMTMzNDZaMIGUMQswCQYDVQQGEwJVUzET
+MBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4G
+A1UEChMHQW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9p
+ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASAwDQYJKoZI
+hvcNAQEBBQADggENADCCAQgCggEBANaTGQTexgskse3HYuDZ2CU+Ps1s6x3i/waM
+qOi8qM1r03hupwqnbOYOuw+ZNVn/2T53qUPn6D1LZLjk/qLT5lbx4meoG7+yMLV4
+wgRDvkxyGLhG9SEVhvA4oU6Jwr44f46+z4/Kw9oe4zDJ6pPQp8PcSvNQIg1QCAcy
+4ICXF+5qBTNZ5qaU7Cyz8oSgpGbIepTYOzEJOmc3Li9kEsBubULxWBjf/gOBzAzU
+RNps3cO4JFgZSAGzJWQTT7/emMkod0jb9WdqVA2BVMi7yge54kdVMxHEa5r3b97s
+zI5p58ii0I54JiCUP5lyfTwE/nKZHZnfm644oLIXf6MdW2r+6R8CAQOjgfwwgfkw
+HQYDVR0OBBYEFEhZAFY9JyxGrhGGBaR0GawJyowRMIHJBgNVHSMEgcEwgb6AFEhZ
+AFY9JyxGrhGGBaR0GawJyowRoYGapIGXMIGUMQswCQYDVQQGEwJVUzETMBEGA1UE
+CBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMH
+QW5kcm9pZDEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEiMCAG
+CSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbYIJAJNurL4H8gHfMAwGA1Ud
+EwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAHqvlozrUMRBBVEY0NqrrwFbinZa
+J6cVosK0TyIUFf/azgMJWr+kLfcHCHJsIGnlw27drgQAvilFLAhLwn62oX6snb4Y
+LCBOsVMR9FXYJLZW2+TcIkCRLXWG/oiVHQGo/rWuWkJgU134NDEFJCJGjDbiLCpe
++ZTWHdcwauTJ9pUbo8EvHRkU3cYfGmLaLfgn9gP+pWA7LFQNvXwBnDa6sppCccEX
+31I828XzgXpJ4O+mDL1/dBd+ek8ZPUP0IgdyZm5MTYPhvVqGCHzzTy3sIeJFymwr
+sBbmg2OAUNLEMO6nwmocSdN2ClirfxqCzJOLSDE4QyS9BAH6EhY6UFcOaE0=
+-----END CERTIFICATE-----
diff --git a/target/product/security/verity.pk8 b/target/product/security/verity.pk8
new file mode 100644
index 0000000000000000000000000000000000000000..bebf216cb6004b5c6665d044916c8a5a70f4a12b
Binary files /dev/null and b/target/product/security/verity.pk8 differ
diff --git a/target/product/security/verity.x509.pem b/target/product/security/verity.x509.pem
new file mode 100644
index 0000000000000000000000000000000000000000..86399c3c1dd7d5ae8dcee2c0b68b3f12a7237f28
--- /dev/null
+++ b/target/product/security/verity.x509.pem
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIID/TCCAuWgAwIBAgIJAJcPmDkJqolJMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYD
+VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4g
+VmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UE
+AwwHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
+Fw0xNDExMDYxOTA3NDBaFw00MjAzMjQxOTA3NDBaMIGUMQswCQYDVQQGEwJVUzET
+MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G
+A1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UEAwwHQW5kcm9p
+ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASIwDQYJKoZI
+hvcNAQEBBQADggEPADCCAQoCggEBAOjreE0vTVSRenuzO9vnaWfk0eQzYab0gqpi
+6xAzi6dmD+ugoEKJmbPiuE5Dwf21isZ9uhUUu0dQM46dK4ocKxMRrcnmGxydFn6o
+fs3ODJMXOkv2gKXL/FdbEPdDbxzdu8z3yk+W67udM/fW7WbaQ3DO0knu+izKak/3
+T41c5uoXmQ81UNtAzRGzGchNVXMmWuTGOkg6U+0I2Td7K8yvUMWhAWPPpKLtVH9r
+AL5TzjYNR92izdKcz3AjRsI3CTjtpiVABGeX0TcjRSuZB7K9EK56HV+OFNS6I1NP
+jdD7FIShyGlqqZdUOkAUZYanbpgeT5N7QL6uuqcGpoTOkalu6kkCAwEAAaNQME4w
+HQYDVR0OBBYEFH5DM/m7oArf4O3peeKO0ZIEkrQPMB8GA1UdIwQYMBaAFH5DM/m7
+oArf4O3peeKO0ZIEkrQPMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEB
+AHO3NSvDE5jFvMehGGtS8BnFYdFKRIglDMc4niWSzhzOVYRH4WajxdtBWc5fx0ix
+NF/+hVKVhP6AIOQa+++sk+HIi7RvioPPbhjcsVlZe7cUEGrLSSveGouQyc+j0+m6
+JF84kszIl5GGNMTnx0XRPO+g8t6h5LWfnVydgZfpGRRg+WHewk1U2HlvTjIceb0N
+dcoJ8WKJAFWdcuE7VIm4w+vF/DYX/A2Oyzr2+QRhmYSv1cusgAeC1tvH4ap+J1Lg
+UnOu5Kh/FqPLLSwNVQp4Bu7b9QFfqK8Moj84bj88NqRGZgDyqzuTrFxn6FW7dmyA
+yttuAJAEAymk1mipd9+zp38=
+-----END CERTIFICATE-----
diff --git a/target/product/security/verity_key b/target/product/security/verity_key
new file mode 100644
index 0000000000000000000000000000000000000000..31982d95ad57005430b65bb28dbfd39adb231347
Binary files /dev/null and b/target/product/security/verity_key differ
diff --git a/target/product/telephony.mk b/target/product/telephony.mk
new file mode 100644
index 0000000000000000000000000000000000000000..e840ba1268ba66d59172be8f115590aa0e33b796
--- /dev/null
+++ b/target/product/telephony.mk
@@ -0,0 +1,28 @@
+#
+# 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 the list of product-level settings that are specific
+# to products that have telephony hardware.
+
+PRODUCT_PACKAGES := \
+ CarrierConfig \
+ Dialer \
+ CallLogBackup \
+ CellBroadcastReceiver \
+ EmergencyInfo \
+ rild
+
+PRODUCT_COPY_FILES := \
diff --git a/target/product/vboot.mk b/target/product/vboot.mk
new file mode 100644
index 0000000000000000000000000000000000000000..48a4883b43900e9d007538f02efc6c69973b7e21
--- /dev/null
+++ b/target/product/vboot.mk
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+
+# Provides dependencies necessary for verified boot
+
+PRODUCT_SUPPORTS_VBOOT := true
+
+# The dev key is used to sign boot and recovery images.
+# We expect this file to exist with the suffixes ".vbprivk" and ".vbpupk".
+# TODO: find a proper location for this
+PRODUCT_VBOOT_SIGNING_KEY := external/vboot_reference/tests/devkeys/kernel_data_key
+PRODUCT_VBOOT_SIGNING_SUBKEY := external/vboot_reference/tests/devkeys/kernel_subkey
diff --git a/target/product/verity.mk b/target/product/verity.mk
new file mode 100644
index 0000000000000000000000000000000000000000..0badb9feb0a119f1b0dfb4a1a155970ee57a903a
--- /dev/null
+++ b/target/product/verity.mk
@@ -0,0 +1,33 @@
+#
+# Copyright (C) 2014 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.
+#
+
+# Provides dependencies necessary for verified boot (only for user and
+# userdebug builds)
+
+user_variant := $(filter user userdebug,$(TARGET_BUILD_VARIANT))
+ifneq (,$(user_variant))
+ PRODUCT_SUPPORTS_BOOT_SIGNER := true
+ PRODUCT_SUPPORTS_VERITY := true
+ PRODUCT_SUPPORTS_VERITY_FEC := true
+
+ # The dev key is used to sign boot and recovery images, and the verity
+ # metadata table. Actual product deliverables will be re-signed by hand.
+ # We expect this file to exist with the suffixes ".x509.pem" and ".pk8".
+ PRODUCT_VERITY_SIGNING_KEY := build/target/product/security/verity
+
+ PRODUCT_PACKAGES += \
+ verity_key
+endif
diff --git a/tools/Android.mk b/tools/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..9073ac3a2cecf54352c5d8b17e48d146308e257f
--- /dev/null
+++ b/tools/Android.mk
@@ -0,0 +1,19 @@
+#
+# Copyright (C) 2010 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/tools/acp/Android.mk b/tools/acp/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..eec9c9db32a25c58a616271c9bb9981687d26775
--- /dev/null
+++ b/tools/acp/Android.mk
@@ -0,0 +1,17 @@
+# Copyright 2005 The Android Open Source Project
+#
+# Custom version of cp.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ acp.c
+
+LOCAL_STATIC_LIBRARIES := libhost
+LOCAL_MODULE := acp
+LOCAL_ACP_UNAVAILABLE := true
+LOCAL_CXX_STL := none
+
+include $(BUILD_HOST_EXECUTABLE)
diff --git a/tools/acp/README b/tools/acp/README
new file mode 100644
index 0000000000000000000000000000000000000000..a1809d928902fbb51af0a638472c8fa837960f8b
--- /dev/null
+++ b/tools/acp/README
@@ -0,0 +1,40 @@
+README for Android "acp" Command
+
+The "cp" command was judged and found wanting. The issues are:
+
+Mac OS X:
+ - Uses the BSD cp, not the fancy GNU cp. It lacks the "-u" flag, which
+ only copies files if they are newer than the destination. This can
+ slow the build when copying lots of content.
+ - Doesn't take the "-d" flag, which causes symlinks to be copied as
+ links. This is the default behavior, so it's not all bad, but it
+ complains if you supply "-d".
+
+MinGW/Cygwin:
+ - Gets really weird when copying a file called "foo.exe", failing with
+ "cp: skipping file 'foo.exe', as it was replaced while being copied".
+ This only seems to happen when the source file is on an NFS/Samba
+ volume. "cp" works okay copying from local disk.
+
+Linux:
+ - On some systems it's possible to have microsecond-accurate timestamps
+ on an NFS volume, and non-microsecond timestamps on a local volume.
+ If you copy from NFS to local disk, your NFS files will always be
+ newer, because the local disk time stamp is truncated rather than
+ rounded up. This foils the "-u" flag if you also supply the "-p" flag
+ to preserve timestamps.
+ - The Darwin linker insists that ranlib be current. If you copy the
+ library, the time stamp no longer matches. Preserving the time
+ stamp is essential, so simply turning the "-p" flag off doesn't work.
+
+Futzing around these in make with GNU make functions is awkward at best.
+It's easier and more reliable to write a cp command that works properly.
+
+
+The "acp" command takes most of the standard flags, following the GNU
+conventions. It adds a "-e" flag, used when copying executables around.
+On most systems it is ignored, but on MinGW/Cygwin it allows "cp foo bar"
+to work when what is actually meant is "cp foo.exe bar.exe". Unlike the
+default Cygwin cp, "acp foo bar" will not find foo.exe unless you add
+the "-e" flag, avoiding potential ambiguity.
+
diff --git a/tools/acp/acp.c b/tools/acp/acp.c
new file mode 100644
index 0000000000000000000000000000000000000000..eb1de1f96f4147351808a3784c0c496eccec6863
--- /dev/null
+++ b/tools/acp/acp.c
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2005 The Android Open Source Project
+ *
+ * Android "cp" replacement.
+ *
+ * The GNU/Linux "cp" uses O_LARGEFILE in its open() calls, utimes() instead
+ * of utime(), and getxattr()/setxattr() instead of chmod(). These are
+ * probably "better", but are non-portable, and not necessary for our
+ * purposes.
+ */
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/*#define DEBUG_MSGS*/
+#ifdef DEBUG_MSGS
+# define DBUG(x) printf x
+#else
+# define DBUG(x) ((void)0)
+#endif
+
+#define FSSEP '/' /* filename separator char */
+
+
+/*
+ * Process the command-line file arguments.
+ *
+ * Returns 0 on success.
+ */
+int process(int argc, char* const argv[], unsigned int options)
+{
+ int retVal = 0;
+ int i, cc;
+ char* stripDest = NULL;
+ int stripDestLen;
+ struct stat destStat;
+ bool destMustBeDir = false;
+ struct stat sb;
+
+ assert(argc >= 2);
+
+ /*
+ * Check for and trim a trailing slash on the last arg.
+ *
+ * It's useful to be able to say "cp foo bar/" when you want to copy
+ * a single file into a directory. If you say "cp foo bar", and "bar"
+ * does not exist, it will create "bar", when what you really wanted
+ * was for the cp command to fail with "directory does not exist".
+ */
+ stripDestLen = strlen(argv[argc-1]);
+ stripDest = malloc(stripDestLen+1);
+ memcpy(stripDest, argv[argc-1], stripDestLen+1);
+ if (stripDest[stripDestLen-1] == FSSEP) {
+ stripDest[--stripDestLen] = '\0';
+ destMustBeDir = true;
+ }
+
+ if (argc > 2)
+ destMustBeDir = true;
+
+ /*
+ * Start with a quick check to ensure that, if we're expecting to copy
+ * to a directory, the target already exists and is actually a directory.
+ * It's okay if it's a symlink to a directory.
+ *
+ * If it turns out to be a directory, go ahead and raise the
+ * destMustBeDir flag so we do some path concatenation below.
+ */
+ if (stat(stripDest, &sb) < 0) {
+ if (destMustBeDir) {
+ if (errno == ENOENT)
+ fprintf(stderr,
+ "acp: destination directory '%s' does not exist\n",
+ stripDest);
+ else
+ fprintf(stderr, "acp: unable to stat dest dir\n");
+ retVal = 1;
+ goto bail;
+ }
+ } else {
+ if (S_ISDIR(sb.st_mode)) {
+ DBUG(("--- dest exists and is a dir, setting flag\n"));
+ destMustBeDir = true;
+ } else if (destMustBeDir) {
+ fprintf(stderr,
+ "acp: destination '%s' is not a directory\n",
+ stripDest);
+ retVal = 1;
+ goto bail;
+ }
+ }
+
+ /*
+ * Copying files.
+ *
+ * Strip trailing slashes off. They shouldn't be there, but
+ * sometimes file completion will put them in for directories.
+ *
+ * The observed behavior of GNU and BSD cp is that they print warnings
+ * if something fails, but continue on. If any part fails, the command
+ * exits with an error status.
+ */
+ for (i = 0; i < argc-1; i++) {
+ const char* srcName;
+ char* src;
+ char* dst;
+ int copyResult;
+ int srcLen;
+
+ /* make a copy of the source name, and strip trailing '/' */
+ srcLen = strlen(argv[i]);
+ src = malloc(srcLen+1);
+ memcpy(src, argv[i], srcLen+1);
+
+ if (src[srcLen-1] == FSSEP)
+ src[--srcLen] = '\0';
+
+ /* find just the name part */
+ srcName = strrchr(src, FSSEP);
+ if (srcName == NULL) {
+ srcName = src;
+ } else {
+ srcName++;
+ assert(*srcName != '\0');
+ }
+
+ if (destMustBeDir) {
+ /* concatenate dest dir and src name */
+ int srcNameLen = strlen(srcName);
+
+ dst = malloc(stripDestLen +1 + srcNameLen +1);
+ memcpy(dst, stripDest, stripDestLen);
+ dst[stripDestLen] = FSSEP;
+ memcpy(dst + stripDestLen+1, srcName, srcNameLen+1);
+ } else {
+ /* simple */
+ dst = stripDest;
+ }
+
+ /*
+ * Copy the source to the destination.
+ */
+ copyResult = copyFile(src, dst, options);
+
+ if (copyResult != 0)
+ retVal = 1;
+
+ free(src);
+ if (dst != stripDest)
+ free(dst);
+ }
+
+bail:
+ free(stripDest);
+ return retVal;
+}
+
+/*
+ * Set up the options.
+ */
+int main(int argc, char* const argv[])
+{
+ bool wantUsage;
+ int ic, retVal;
+ int verboseLevel;
+ unsigned int options;
+
+ verboseLevel = 0;
+ options = 0;
+ wantUsage = false;
+
+ while (1) {
+ ic = getopt(argc, argv, "defprtuv");
+ if (ic < 0)
+ break;
+
+ switch (ic) {
+ case 'd':
+ options |= COPY_NO_DEREFERENCE;
+ break;
+ case 'e':
+ options |= COPY_TRY_EXE;
+ break;
+ case 'f':
+ options |= COPY_FORCE;
+ break;
+ case 'p':
+ options |= COPY_PERMISSIONS;
+ break;
+ case 't':
+ options |= COPY_TIMESTAMPS;
+ break;
+ case 'r':
+ options |= COPY_RECURSIVE;
+ break;
+ case 'u':
+ options |= COPY_UPDATE_ONLY;
+ break;
+ case 'v':
+ verboseLevel++;
+ break;
+ default:
+ fprintf(stderr, "Unexpected arg -%c\n", ic);
+ wantUsage = true;
+ break;
+ }
+
+ if (wantUsage)
+ break;
+ }
+
+ options |= verboseLevel & COPY_VERBOSE_MASK;
+
+ if (optind == argc-1) {
+ fprintf(stderr, "acp: missing destination file\n");
+ return 2;
+ } else if (optind+2 > argc)
+ wantUsage = true;
+
+ if (wantUsage) {
+ fprintf(stderr, "Usage: acp [OPTION]... SOURCE DEST\n");
+ fprintf(stderr, " or: acp [OPTION]... SOURCE... DIRECTORY\n");
+ fprintf(stderr, "\nOptions:\n");
+ fprintf(stderr, " -d never follow (dereference) symbolic links\n");
+ fprintf(stderr, " -e if source file doesn't exist, try adding "
+ "'.exe' [Win32 only]\n");
+ fprintf(stderr, " -f use force, removing existing file if it's "
+ "not writeable\n");
+ fprintf(stderr, " -p preserve mode, ownership\n");
+ fprintf(stderr, " -r recursive copy\n");
+ fprintf(stderr, " -t preserve timestamps\n");
+ fprintf(stderr, " -u update only: don't copy if dest is newer\n");
+ fprintf(stderr, " -v verbose output (-vv is more verbose)\n");
+ return 2;
+ }
+
+ retVal = process(argc-optind, argv+optind, options);
+ DBUG(("EXIT: %d\n", retVal));
+ return retVal;
+}
+
diff --git a/tools/adbs b/tools/adbs
new file mode 100755
index 0000000000000000000000000000000000000000..a8f06c04ef339ec5bc5a935e0ca4947eb891631a
--- /dev/null
+++ b/tools/adbs
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2009 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.
+
+import os
+import os.path
+import re
+import string
+import sys
+
+sys.path.insert(0, os.path.dirname(__file__) + "/../../development/scripts")
+import stack_core
+import symbol
+
+if __name__ == '__main__':
+ # pass the options to adb
+ adb_cmd = "adb " + ' '.join(sys.argv[1:])
+
+ # create tracer for line parsing
+ tracer = stack_core.TraceConverter()
+
+ # invoke the adb command and filter its output
+ stream = os.popen(adb_cmd)
+ while (True):
+ line = stream.readline()
+ if (line == ''):
+ break
+ if(tracer.ProcessLine(line) == False):
+ print(line.strip())
+ sys.stdout.flush()
+
+ # adb itself aborts
+ stream.close()
diff --git a/tools/apicheck/Android.mk b/tools/apicheck/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..b5470588eab1e57eed686327c4342e7c66536c87
--- /dev/null
+++ b/tools/apicheck/Android.mk
@@ -0,0 +1,29 @@
+# Copyright (C) 2007-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.
+
+ifneq ($(TARGET_BUILD_PDK),true)
+LOCAL_PATH := $(call my-dir)
+
+# the hat script
+# ============================================================
+include $(CLEAR_VARS)
+LOCAL_IS_HOST_MODULE := true
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE := apicheck
+LOCAL_SRC_FILES := etc/apicheck
+LOCAL_REQUIRED_MODULES := doclava
+include $(BUILD_PREBUILT)
+
+# Apicheck is now part of Doclava -- See external/doclava.
+endif
diff --git a/tools/apicheck/etc/apicheck b/tools/apicheck/etc/apicheck
new file mode 100644
index 0000000000000000000000000000000000000000..c710c4624d2d9dbc11f29eaa8020083aa90eeae1
--- /dev/null
+++ b/tools/apicheck/etc/apicheck
@@ -0,0 +1,48 @@
+#!/bin/bash
+#
+# Copyright (C) 2005, 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.
+
+# Set up prog to be the path of this script, including following symlinks,
+# and set up progdir to be the fully-qualified pathname of its directory.
+#
+# The classpath and other java options used in apicheck are specified in
+# build/core/tasks/apicheck.mk.
+
+prog="$0"
+while [ -h "${prog}" ]; do
+ newProg=`/bin/ls -ld "${prog}"`
+ newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
+ if expr "x${newProg}" : 'x/' >/dev/null; then
+ prog="${newProg}"
+ else
+ progdir=`dirname "${prog}"`
+ prog="${progdir}/${newProg}"
+ fi
+done
+oldwd=`pwd`
+progdir=`dirname "${prog}"`
+cd "${progdir}"
+progdir=`pwd`
+prog="${progdir}"/`basename "${prog}"`
+cd "${oldwd}"
+
+javaOpts=""
+while expr "x$1" : 'x-J' >/dev/null; do
+ opt=`expr "x$1" : 'x-J\(.*\)'`
+ javaOpts="${javaOpts} -${opt}"
+ shift
+done
+
+exec java $javaOpts com.google.doclava.apicheck.ApiCheck "$@"
diff --git a/tools/atree/Android.mk b/tools/atree/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..f598db588c5da07592e74a56e94190cc8a2afee9
--- /dev/null
+++ b/tools/atree/Android.mk
@@ -0,0 +1,19 @@
+# Copyright 2007 The Android Open Source Project
+#
+# Copies files into the directory structure described by a manifest
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ atree.cpp \
+ files.cpp \
+ fs.cpp
+
+LOCAL_STATIC_LIBRARIES := \
+ libhost
+
+LOCAL_MODULE := atree
+
+include $(BUILD_HOST_EXECUTABLE)
+
diff --git a/tools/atree/atree.cpp b/tools/atree/atree.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b134e013c86e490f07bc8d269d6e879a0870de62
--- /dev/null
+++ b/tools/atree/atree.cpp
@@ -0,0 +1,360 @@
+#include
+#include
+#include
+#include
+#include
+#include "options.h"
+#include "files.h"
+#include "fs.h"
+#include
+#include
+#include
+
+using namespace std;
+
+bool g_debug = getenv("ATREE_DEBUG") != NULL;
+vector g_listFiles;
+vector g_inputBases;
+map g_variables;
+string g_outputBase;
+string g_dependency;
+bool g_useHardLinks = false;
+
+const char* USAGE =
+"\n"
+"Usage: atree OPTIONS\n"
+"\n"
+"Options:\n"
+" -f FILELIST Specify one or more files containing the\n"
+" list of files to copy.\n"
+" -I INPUTDIR Specify one or more base directories in\n"
+" which to look for the files\n"
+" -o OUTPUTDIR Specify the directory to copy all of the\n"
+" output files to.\n"
+" -l Use hard links instead of copying the files.\n"
+" -m DEPENDENCY Output a make-formatted file containing the list.\n"
+" of files included. It sets the variable ATREE_FILES.\n"
+" -v VAR=VAL Replaces ${VAR} by VAL when reading input files.\n"
+" -d Verbose debug mode.\n"
+"\n"
+"FILELIST file format:\n"
+" The FILELIST files contain the list of files that will end up\n"
+" in the final OUTPUTDIR. Atree will look for files in the INPUTDIR\n"
+" directories in the order they are specified.\n"
+"\n"
+" In a FILELIST file, comment lines start with a #. Other lines\n"
+" are of the format:\n"
+"\n"
+" [rm|strip] DEST\n"
+" SRC [strip] DEST\n"
+" -SRCPATTERN\n"
+"\n"
+" DEST should be path relative to the output directory.\n"
+" 'rm DEST' removes the destination file and fails if it's missing.\n"
+" 'strip DEST' strips the binary destination file.\n"
+" If SRC is supplied, the file names can be different.\n"
+" SRCPATTERN is a pattern for the filenames.\n"
+"\n";
+
+int usage()
+{
+ fwrite(USAGE, strlen(USAGE), 1, stderr);
+ return 1;
+}
+
+static bool
+add_variable(const char* arg) {
+ const char* p = arg;
+ while (*p && *p != '=') p++;
+
+ if (*p == 0 || p == arg || p[1] == 0) {
+ return false;
+ }
+
+ ostringstream var;
+ var << "${" << string(arg, p-arg) << "}";
+ g_variables[var.str()] = string(p+1);
+ return true;
+}
+
+static void
+debug_printf(const char* format, ...)
+{
+ if (g_debug) {
+ fflush(stderr);
+ va_list ap;
+ va_start(ap, format);
+ vprintf(format, ap);
+ va_end(ap);
+ fflush(stdout);
+ }
+}
+
+// Escape the filename so that it can be added to the makefile properly.
+static string
+escape_filename(const string name)
+{
+ ostringstream new_name;
+ for (string::const_iterator iter = name.begin(); iter != name.end(); ++iter)
+ {
+ switch (*iter)
+ {
+ case '$':
+ new_name << "$$";
+ break;
+ default:
+ new_name << *iter;
+ break;
+ }
+ }
+ return new_name.str();
+}
+
+int
+main(int argc, char* const* argv)
+{
+ int err;
+ bool done = false;
+ while (!done) {
+ int opt = getopt(argc, argv, "f:I:o:hlm:v:d");
+ switch (opt)
+ {
+ case -1:
+ done = true;
+ break;
+ case 'f':
+ g_listFiles.push_back(string(optarg));
+ break;
+ case 'I':
+ g_inputBases.push_back(string(optarg));
+ break;
+ case 'o':
+ if (g_outputBase.length() != 0) {
+ fprintf(stderr, "%s: -o may only be supplied once -- "
+ "-o %s\n", argv[0], optarg);
+ return usage();
+ }
+ g_outputBase = optarg;
+ break;
+ case 'l':
+ g_useHardLinks = true;
+ break;
+ case 'm':
+ if (g_dependency.length() != 0) {
+ fprintf(stderr, "%s: -m may only be supplied once -- "
+ "-m %s\n", argv[0], optarg);
+ return usage();
+ }
+ g_dependency = optarg;
+ break;
+ case 'v':
+ if (!add_variable(optarg)) {
+ fprintf(stderr, "%s Invalid expression in '-v %s': "
+ "expected format is '-v VAR=VALUE'.\n",
+ argv[0], optarg);
+ return usage();
+ }
+ break;
+ case 'd':
+ g_debug = true;
+ break;
+ default:
+ case '?':
+ case 'h':
+ return usage();
+ }
+ }
+ if (optind != argc) {
+ fprintf(stderr, "%s: invalid argument -- %s\n", argv[0], argv[optind]);
+ return usage();
+ }
+
+ if (g_listFiles.size() == 0) {
+ fprintf(stderr, "%s: At least one -f option must be supplied.\n",
+ argv[0]);
+ return usage();
+ }
+
+ if (g_inputBases.size() == 0) {
+ fprintf(stderr, "%s: At least one -I option must be supplied.\n",
+ argv[0]);
+ return usage();
+ }
+
+ if (g_outputBase.length() == 0) {
+ fprintf(stderr, "%s: -o option must be supplied.\n", argv[0]);
+ return usage();
+ }
+
+
+#if 0
+ for (vector::iterator it=g_listFiles.begin();
+ it!=g_listFiles.end(); it++) {
+ printf("-f \"%s\"\n", it->c_str());
+ }
+ for (vector::iterator it=g_inputBases.begin();
+ it!=g_inputBases.end(); it++) {
+ printf("-I \"%s\"\n", it->c_str());
+ }
+ printf("-o \"%s\"\n", g_outputBase.c_str());
+ if (g_useHardLinks) {
+ printf("-l\n");
+ }
+#endif
+
+ vector files;
+ vector more;
+ vector excludes;
+ set directories;
+ set deleted;
+
+ // read file lists
+ for (vector::iterator it=g_listFiles.begin();
+ it!=g_listFiles.end(); it++) {
+ err = read_list_file(*it, g_variables, &files, &excludes);
+ if (err != 0) {
+ return err;
+ }
+ }
+
+ // look for input files
+ err = 0;
+ for (vector::iterator it=files.begin();
+ it!=files.end(); it++) {
+ err |= locate(&(*it), g_inputBases);
+ }
+
+ // expand the directories that we should copy into a list of files
+ for (vector::iterator it=files.begin();
+ it!=files.end(); it++) {
+ if (it->sourceIsDir) {
+ err |= list_dir(*it, excludes, &more);
+ }
+ }
+ for (vector::iterator it=more.begin();
+ it!=more.end(); it++) {
+ files.push_back(*it);
+ }
+
+ // get the name and modtime of the output files
+ for (vector::iterator it=files.begin();
+ it!=files.end(); it++) {
+ stat_out(g_outputBase, &(*it));
+ }
+
+ if (err != 0) {
+ return 1;
+ }
+
+ // gather directories
+ for (vector::iterator it=files.begin();
+ it!=files.end(); it++) {
+ if (it->sourceIsDir) {
+ directories.insert(it->outPath);
+ } else {
+ string s = dir_part(it->outPath);
+ if (s != ".") {
+ directories.insert(s);
+ }
+ }
+ }
+
+ // gather files that should become directores
+ // and directories that should become files
+ for (vector::iterator it=files.begin();
+ it!=files.end(); it++) {
+ if (it->outMod != 0 && it->sourceIsDir != it->outIsDir) {
+ deleted.insert(it->outPath);
+ }
+ }
+
+ // delete files
+ for (set::iterator it=deleted.begin();
+ it!=deleted.end(); it++) {
+ debug_printf("deleting %s\n", it->c_str());
+ err = remove_recursively(*it);
+ if (err != 0) {
+ return err;
+ }
+ }
+
+ // remove all files or directories as requested from the input atree file.
+ // must be done before create new directories.
+ for (vector::iterator it=files.begin();
+ it!=files.end(); it++) {
+ if (!it->sourceIsDir) {
+ if (it->fileOp == FILE_OP_REMOVE &&
+ deleted.count(it->outPath) == 0) {
+ debug_printf("remove %s\n", it->outPath.c_str());
+ err = remove_recursively(it->outPath);
+ if (err != 0) {
+ return err;
+ }
+ }
+ }
+ }
+
+ // make directories
+ for (set::iterator it=directories.begin();
+ it!=directories.end(); it++) {
+ debug_printf("mkdir %s\n", it->c_str());
+ err = mkdir_recursively(*it);
+ if (err != 0) {
+ return err;
+ }
+ }
+
+ // copy (or link) files that are newer or of different size
+ for (vector::iterator it=files.begin();
+ it!=files.end(); it++) {
+ if (!it->sourceIsDir) {
+ if (it->fileOp == FILE_OP_REMOVE) {
+ continue;
+ }
+
+ debug_printf("copy %s(%ld) ==> %s(%ld)",
+ it->sourcePath.c_str(), it->sourceMod,
+ it->outPath.c_str(), it->outMod);
+
+ if (it->outSize != it->sourceSize || it->outMod < it->sourceMod) {
+ err = copy_file(it->sourcePath, it->outPath);
+ debug_printf(" done.\n");
+ if (err != 0) {
+ return err;
+ }
+ } else {
+ debug_printf(" skipping.\n");
+ }
+
+ if (it->fileOp == FILE_OP_STRIP) {
+ debug_printf("strip %s\n", it->outPath.c_str());
+ err = strip_file(it->outPath);
+ if (err != 0) {
+ return err;
+ }
+ }
+ }
+ }
+
+ // output the dependency file
+ if (g_dependency.length() != 0) {
+ FILE *f = fopen(g_dependency.c_str(), "w");
+ if (f != NULL) {
+ fprintf(f, "ATREE_FILES := $(ATREE_FILES) \\\n");
+ for (vector::iterator it=files.begin();
+ it!=files.end(); it++) {
+ if (!it->sourceIsDir) {
+ fprintf(f, "%s \\\n",
+ escape_filename(it->sourcePath).c_str());
+ }
+ }
+ fprintf(f, "\n");
+ fclose(f);
+ } else {
+ fprintf(stderr, "error opening manifest file for write: %s\n",
+ g_dependency.c_str());
+ }
+ }
+
+ return 0;
+}
diff --git a/tools/atree/files.cpp b/tools/atree/files.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..d945f589c25e2f457372814c2b38004f4c0d8057
--- /dev/null
+++ b/tools/atree/files.cpp
@@ -0,0 +1,475 @@
+#include "files.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+static bool
+is_comment_line(const char* p)
+{
+ while (*p && isspace(*p)) {
+ p++;
+ }
+ return *p == '#';
+}
+
+static string
+path_append(const string& base, const string& leaf)
+{
+ string full = base;
+ if (base.length() > 0 && leaf.length() > 0) {
+ full += '/';
+ }
+ full += leaf;
+ return full;
+}
+
+static bool
+is_whitespace_line(const char* p)
+{
+ while (*p) {
+ if (!isspace(*p)) {
+ return false;
+ }
+ p++;
+ }
+ return true;
+}
+
+static bool
+is_exclude_line(const char* p) {
+ while (*p) {
+ if (*p == '-') {
+ return true;
+ }
+ else if (isspace(*p)) {
+ p++;
+ }
+ else {
+ return false;
+ }
+ }
+ return false;
+}
+
+void
+split_line(const char* p, vector* out)
+{
+ const char* q = p;
+ enum { WHITE, TEXT, IN_QUOTE } state = WHITE;
+ while (*p) {
+ if (*p == '#') {
+ break;
+ }
+
+ switch (state)
+ {
+ case WHITE:
+ if (!isspace(*p)) {
+ q = p;
+ state = (*p == '"') ? IN_QUOTE : TEXT;
+ }
+ break;
+ case IN_QUOTE:
+ if (*p == '"') {
+ state = TEXT;
+ break;
+ }
+ // otherwise fall-through to TEXT case
+ case TEXT:
+ if (state != IN_QUOTE && isspace(*p)) {
+ if (q != p) {
+ const char* start = q;
+ size_t len = p-q;
+ if (len > 2 && *start == '"' && start[len - 1] == '"') {
+ start++;
+ len -= 2;
+ }
+ out->push_back(string(start, len));
+ }
+ state = WHITE;
+ }
+ break;
+ }
+ p++;
+ }
+ if (state == TEXT) {
+ const char* start = q;
+ size_t len = p-q;
+ if (len > 2 && *start == '"' && start[len - 1] == '"') {
+ start++;
+ len -= 2;
+ }
+ out->push_back(string(start, len));
+ }
+}
+
+static void
+add_file(vector* files, const FileOpType fileOp,
+ const string& listFile, int listLine,
+ const string& sourceName, const string& outName)
+{
+ FileRecord rec;
+ rec.listFile = listFile;
+ rec.listLine = listLine;
+ rec.fileOp = fileOp;
+ rec.sourceName = sourceName;
+ rec.outName = outName;
+ files->push_back(rec);
+}
+
+static string
+replace_variables(const string& input,
+ const map& variables,
+ bool* error) {
+ if (variables.empty()) {
+ return input;
+ }
+
+ // Abort if the variable prefix is not found
+ if (input.find("${") == string::npos) {
+ return input;
+ }
+
+ string result = input;
+
+ // Note: rather than be fancy to detect recursive replacements,
+ // we simply iterate till a given threshold is met.
+
+ int retries = 1000;
+ bool did_replace;
+
+ do {
+ did_replace = false;
+ for (map::const_iterator it = variables.begin();
+ it != variables.end(); ++it) {
+ string::size_type pos = 0;
+ while((pos = result.find(it->first, pos)) != string::npos) {
+ result = result.replace(pos, it->first.length(), it->second);
+ pos += it->second.length();
+ did_replace = true;
+ }
+ }
+ if (did_replace && --retries == 0) {
+ *error = true;
+ fprintf(stderr, "Recursive replacement detected during variables "
+ "substitution. Full list of variables is: ");
+
+ for (map::const_iterator it = variables.begin();
+ it != variables.end(); ++it) {
+ fprintf(stderr, " %s=%s\n",
+ it->first.c_str(), it->second.c_str());
+ }
+
+ return result;
+ }
+ } while (did_replace);
+
+ return result;
+}
+
+int
+read_list_file(const string& filename,
+ const map& variables,
+ vector* files,
+ vector* excludes)
+{
+ int err = 0;
+ FILE* f = NULL;
+ long size;
+ char* buf = NULL;
+ char *p, *q;
+ int i, lineCount;
+
+ f = fopen(filename.c_str(), "r");
+ if (f == NULL) {
+ fprintf(stderr, "Could not open list file (%s): %s\n",
+ filename.c_str(), strerror(errno));
+ err = errno;
+ goto cleanup;
+ }
+
+ err = fseek(f, 0, SEEK_END);
+ if (err != 0) {
+ fprintf(stderr, "Could not seek to the end of file %s. (%s)\n",
+ filename.c_str(), strerror(errno));
+ err = errno;
+ goto cleanup;
+ }
+
+ size = ftell(f);
+
+ err = fseek(f, 0, SEEK_SET);
+ if (err != 0) {
+ fprintf(stderr, "Could not seek to the beginning of file %s. (%s)\n",
+ filename.c_str(), strerror(errno));
+ err = errno;
+ goto cleanup;
+ }
+
+ buf = (char*)malloc(size+1);
+ if (buf == NULL) {
+ // (potentially large)
+ fprintf(stderr, "out of memory (%ld)\n", size);
+ err = ENOMEM;
+ goto cleanup;
+ }
+
+ if (1 != fread(buf, size, 1, f)) {
+ fprintf(stderr, "error reading file %s. (%s)\n",
+ filename.c_str(), strerror(errno));
+ err = errno;
+ goto cleanup;
+ }
+
+ // split on lines
+ p = buf;
+ q = buf+size;
+ lineCount = 0;
+ while (ppush_back(string(p));
+ }
+ else {
+ vector words;
+
+ split_line(p, &words);
+
+#if 0
+ printf("[ ");
+ for (size_t k=0; k::iterator it = words.begin(); it != words.end(); ++it) {
+ const string& word = *it;
+ if (word == "rm") {
+ if (op != FILE_OP_COPY) {
+ errstr = "Error: you can only specifiy 'rm' or 'strip' once per line.";
+ break;
+ }
+ op = FILE_OP_REMOVE;
+ } else if (word == "strip") {
+ if (op != FILE_OP_COPY) {
+ errstr = "Error: you can only specifiy 'rm' or 'strip' once per line.";
+ break;
+ }
+ op = FILE_OP_STRIP;
+ } else if (pcount < 2) {
+ bool error = false;
+ paths[pcount++] = replace_variables(word, variables, &error);
+ if (error) {
+ err = 1;
+ goto cleanup;
+ }
+ } else {
+ errstr = "Error: More than 2 paths per line.";
+ break;
+ }
+ }
+
+ if (pcount == 0 && !errstr.empty()) {
+ errstr = "Error: No path found on line.";
+ }
+
+ if (!errstr.empty()) {
+ fprintf(stderr, "%s:%d: bad format: %s\n%s\nExpected: [SRC] [rm|strip] DEST\n",
+ filename.c_str(), i+1, p, errstr.c_str());
+ err = 1;
+ } else {
+ if (pcount == 1) {
+ // pattern: [rm|strip] DEST
+ paths[1] = paths[0];
+ }
+
+ add_file(files, op, filename, i+1, paths[0], paths[1]);
+ }
+ }
+ p = q;
+ }
+
+cleanup:
+ if (buf != NULL) {
+ free(buf);
+ }
+ if (f != NULL) {
+ fclose(f);
+ }
+ return err;
+}
+
+
+int
+locate(FileRecord* rec, const vector& search)
+{
+ if (rec->fileOp == FILE_OP_REMOVE) {
+ // Don't touch source files when removing a destination.
+ rec->sourceMod = 0;
+ rec->sourceSize = 0;
+ rec->sourceIsDir = false;
+ return 0;
+ }
+
+ int err;
+
+ for (vector::const_iterator it=search.begin();
+ it!=search.end(); it++) {
+ string full = path_append(*it, rec->sourceName);
+ struct stat st;
+ err = stat(full.c_str(), &st);
+ if (err == 0) {
+ rec->sourceBase = *it;
+ rec->sourcePath = full;
+ rec->sourceMod = st.st_mtime;
+ rec->sourceSize = st.st_size;
+ rec->sourceIsDir = S_ISDIR(st.st_mode);
+ return 0;
+ }
+ }
+
+ fprintf(stderr, "%s:%d: couldn't locate source file: %s\n",
+ rec->listFile.c_str(), rec->listLine, rec->sourceName.c_str());
+ return 1;
+}
+
+void
+stat_out(const string& base, FileRecord* rec)
+{
+ rec->outPath = path_append(base, rec->outName);
+
+ int err;
+ struct stat st;
+ err = stat(rec->outPath.c_str(), &st);
+ if (err == 0) {
+ rec->outMod = st.st_mtime;
+ rec->outSize = st.st_size;
+ rec->outIsDir = S_ISDIR(st.st_mode);
+ } else {
+ rec->outMod = 0;
+ rec->outSize = 0;
+ rec->outIsDir = false;
+ }
+}
+
+string
+dir_part(const string& filename)
+{
+ int pos = filename.rfind('/');
+ if (pos <= 0) {
+ return ".";
+ }
+ return filename.substr(0, pos);
+}
+
+static void
+add_more(const string& entry, bool isDir,
+ const FileRecord& rec, vector*more)
+{
+ FileRecord r;
+ r.listFile = rec.listFile;
+ r.listLine = rec.listLine;
+ r.sourceName = path_append(rec.sourceName, entry);
+ r.sourcePath = path_append(rec.sourceBase, r.sourceName);
+ struct stat st;
+ int err = stat(r.sourcePath.c_str(), &st);
+ if (err == 0) {
+ r.sourceMod = st.st_mtime;
+ }
+ r.sourceIsDir = isDir;
+ r.outName = path_append(rec.outName, entry);
+ more->push_back(r);
+}
+
+static bool
+matches_excludes(const char* file, const vector& excludes)
+{
+ for (vector::const_iterator it=excludes.begin();
+ it!=excludes.end(); it++) {
+ if (0 == fnmatch(it->c_str(), file, FNM_PERIOD)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static int
+list_dir(const string& path, const FileRecord& rec,
+ const vector& excludes,
+ vector* more)
+{
+ int err;
+
+ string full = path_append(rec.sourceBase, rec.sourceName);
+ full = path_append(full, path);
+
+ DIR *d = opendir(full.c_str());
+ if (d == NULL) {
+ return errno;
+ }
+
+ vector dirs;
+
+ struct dirent *ent;
+ while (NULL != (ent = readdir(d))) {
+ if (0 == strcmp(".", ent->d_name)
+ || 0 == strcmp("..", ent->d_name)) {
+ continue;
+ }
+ if (matches_excludes(ent->d_name, excludes)) {
+ continue;
+ }
+ string entry = path_append(path, ent->d_name);
+ bool is_directory = (ent->d_type == DT_DIR);
+ add_more(entry, is_directory, rec, more);
+ if (is_directory) {
+ dirs.push_back(entry);
+ }
+ }
+ closedir(d);
+
+ for (vector::iterator it=dirs.begin(); it!=dirs.end(); it++) {
+ list_dir(*it, rec, excludes, more);
+ }
+
+ return 0;
+}
+
+int
+list_dir(const FileRecord& rec, const vector& excludes,
+ vector* files)
+{
+ return list_dir("", rec, excludes, files);
+}
+
+FileRecord::FileRecord() {
+ fileOp = FILE_OP_COPY;
+}
+
diff --git a/tools/atree/files.h b/tools/atree/files.h
new file mode 100644
index 0000000000000000000000000000000000000000..f6bf8a6ad578d4c4884d9b77ef098b9eda9238b9
--- /dev/null
+++ b/tools/atree/files.h
@@ -0,0 +1,50 @@
+#ifndef FILES_H
+#define FILES_H
+
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+enum FileOpType {
+ FILE_OP_COPY = 0,
+ FILE_OP_REMOVE,
+ FILE_OP_STRIP
+};
+
+struct FileRecord
+{
+ FileRecord();
+
+ string listFile;
+ int listLine;
+
+ string sourceBase;
+ string sourceName;
+ string sourcePath;
+ bool sourceIsDir;
+ time_t sourceMod;
+ off_t sourceSize;
+ FileOpType fileOp;
+
+ string outName;
+ string outPath;
+ off_t outSize;
+ time_t outMod;
+ bool outIsDir;
+ unsigned int mode;
+};
+
+int read_list_file(const string& filename,
+ const map& variables,
+ vector* files,
+ vector* excludes);
+int locate(FileRecord* rec, const vector& search);
+void stat_out(const string& base, FileRecord* rec);
+string dir_part(const string& filename);
+int list_dir(const FileRecord& rec, const vector& excludes,
+ vector* files);
+
+#endif // FILES_H
diff --git a/tools/atree/fs.cpp b/tools/atree/fs.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..6cd080e875317692fd79858085696052f454c490
--- /dev/null
+++ b/tools/atree/fs.cpp
@@ -0,0 +1,212 @@
+#include "fs.h"
+#include "files.h"
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+using namespace std;
+
+static bool
+is_dir(const string& path)
+{
+ int err;
+ struct stat st;
+ err = stat(path.c_str(), &st);
+ return err != 0 || S_ISDIR(st.st_mode);
+}
+
+static int
+remove_file(const string& path)
+{
+ int err = unlink(path.c_str());
+ if (err != 0) {
+ fprintf(stderr, "error deleting file %s (%s)\n", path.c_str(),
+ strerror(errno));
+ return errno;
+ }
+ return 0;
+}
+
+int
+remove_recursively(const string& path)
+{
+ int err;
+
+ if (is_dir(path)) {
+ DIR *d = opendir(path.c_str());
+ if (d == NULL) {
+ fprintf(stderr, "error getting directory contents %s (%s)\n",
+ path.c_str(), strerror(errno));
+ return errno;
+ }
+
+ vector files;
+ vector dirs;
+
+ struct dirent *ent;
+ while (NULL != (ent = readdir(d))) {
+ if (0 == strcmp(".", ent->d_name)
+ || 0 == strcmp("..", ent->d_name)) {
+ continue;
+ }
+ string full = path;
+ full += '/';
+ full += ent->d_name;
+ bool is_directory = (ent->d_type == DT_DIR);
+ if (is_directory) {
+ dirs.push_back(full);
+ } else {
+ files.push_back(full);
+ }
+ }
+ closedir(d);
+
+ for (vector::iterator it=files.begin(); it!=files.end(); it++) {
+ err = remove_file(*it);
+ if (err != 0) {
+ return err;
+ }
+ }
+
+ for (vector::iterator it=dirs.begin(); it!=dirs.end(); it++) {
+ err = remove_recursively(*it);
+ if (err != 0) {
+ return err;
+ }
+ }
+
+ err = rmdir(path.c_str());
+ if (err != 0) {
+ fprintf(stderr, "error deleting directory %s (%s)\n", path.c_str(),
+ strerror(errno));
+ return errno;
+ }
+ return 0;
+ } else {
+ return remove_file(path);
+ }
+}
+
+int
+mkdir_recursively(const string& path)
+{
+ int err;
+ size_t pos = 0;
+ // For absolute pathnames, that starts with leading '/'
+ // use appropriate initial value.
+ if (path.length() != 0 and path[0] == '/') pos++;
+
+ while (true) {
+ pos = path.find('/', pos);
+ string p = path.substr(0, pos);
+ struct stat st;
+ err = stat(p.c_str(), &st);
+ if (err != 0) {
+ err = mkdir(p.c_str(), 0770);
+ if (err != 0) {
+ fprintf(stderr, "can't create directory %s (%s)\n",
+ path.c_str(), strerror(errno));
+ return errno;
+ }
+ }
+ else if (!S_ISDIR(st.st_mode)) {
+ fprintf(stderr, "can't create directory %s because %s is a file.\n",
+ path.c_str(), p.c_str());
+ return 1;
+ }
+ pos++;
+ if (p == path) {
+ return 0;
+ }
+ }
+}
+
+int
+copy_file(const string& src, const string& dst)
+{
+ int err;
+
+ err = copyFile(src.c_str(), dst.c_str(),
+ COPY_NO_DEREFERENCE | COPY_FORCE | COPY_PERMISSIONS);
+ return err;
+}
+
+int
+strip_file(const string& path)
+{
+ // Default strip command to run is "strip" unless overridden by the ATREE_STRIP env var.
+ const char* strip_cmd = getenv("ATREE_STRIP");
+ if (!strip_cmd || !strip_cmd[0]) {
+ strip_cmd = "strip";
+ }
+ pid_t pid = fork();
+ if (pid == -1) {
+ // Fork failed. errno should be set.
+ return -1;
+ } else if (pid == 0) {
+ // Exec in the child. Only returns if execve failed.
+
+ int num_args = 0;
+ const char *s = strip_cmd;
+ while (*s) {
+ while (*s == ' ') ++s;
+ if (*s && *s != ' ') {
+ ++num_args;
+ while (*s && *s != ' ') ++s;
+ }
+ }
+
+ if (num_args <= 0) {
+ fprintf(stderr, "Invalid ATREE_STRIP command '%s'\n", strip_cmd);
+ return 1;
+
+ } else if (num_args == 1) {
+ return execlp(strip_cmd, strip_cmd, path.c_str(), (char *)NULL);
+
+ } else {
+ // Split the arguments if more than 1
+ char* cmd = strdup(strip_cmd);
+ const char** args = (const char**) malloc(sizeof(const char*) * (num_args + 2));
+
+ const char** curr = args;
+ char* s = cmd;
+ while (*s) {
+ while (*s == ' ') ++s;
+ if (*s && *s != ' ') {
+ *curr = s;
+ ++curr;
+ while (*s && *s != ' ') ++s;
+ if (*s) {
+ *s = '\0';
+ ++s;
+ }
+ }
+ }
+
+ args[num_args] = path.c_str();
+ args[num_args + 1] = NULL;
+
+ int ret = execvp(args[0], (char* const*)args);
+ free(args);
+ free(cmd);
+ return ret;
+ }
+ } else {
+ // Wait for child pid and return its exit code.
+ int status;
+ waitpid(pid, &status, 0);
+ return status;
+ }
+}
+
diff --git a/tools/atree/fs.h b/tools/atree/fs.h
new file mode 100644
index 0000000000000000000000000000000000000000..fd4ae3e554d0d3fc8b7e44b597b7d6b5fa5bdfb3
--- /dev/null
+++ b/tools/atree/fs.h
@@ -0,0 +1,13 @@
+#ifndef FS_H
+#define FS_H
+
+#include
+
+using namespace std;
+
+int remove_recursively(const string& path);
+int mkdir_recursively(const string& path);
+int copy_file(const string& src, const string& dst);
+int strip_file(const string& path);
+
+#endif // FS_H
diff --git a/tools/atree/options.h b/tools/atree/options.h
new file mode 100644
index 0000000000000000000000000000000000000000..a227d0fdc44a34bf916da447f4dcfc4eb1760ee1
--- /dev/null
+++ b/tools/atree/options.h
@@ -0,0 +1,14 @@
+#ifndef OPTIONS_H
+#define OPTIONS_H
+
+#include
+#include
+
+using namespace std;
+
+extern vector g_listFiles;
+extern vector g_inputBases;
+extern string g_outputBase;
+extern bool g_useHardLinks;
+
+#endif // OPTIONS_H
diff --git a/tools/buildinfo.sh b/tools/buildinfo.sh
new file mode 100755
index 0000000000000000000000000000000000000000..4e1ef8b4143e941a285802da904f4226e1f487b3
--- /dev/null
+++ b/tools/buildinfo.sh
@@ -0,0 +1,73 @@
+#!/bin/bash
+
+echo "# begin build properties"
+echo "# autogenerated by buildinfo.sh"
+
+echo "ro.build.id=$BUILD_ID"
+echo "ro.build.display.id=$BUILD_DISPLAY_ID"
+echo "ro.build.version.incremental=$BUILD_NUMBER"
+echo "ro.build.version.sdk=$PLATFORM_SDK_VERSION"
+echo "ro.build.version.preview_sdk=$PLATFORM_PREVIEW_SDK_VERSION"
+echo "ro.build.version.codename=$PLATFORM_VERSION_CODENAME"
+echo "ro.build.version.all_codenames=$PLATFORM_VERSION_ALL_CODENAMES"
+echo "ro.build.version.release=$PLATFORM_VERSION"
+echo "ro.build.version.security_patch=$PLATFORM_SECURITY_PATCH"
+echo "ro.build.version.base_os=$PLATFORM_BASE_OS"
+echo "ro.build.date=`$DATE`"
+echo "ro.build.date.utc=`$DATE +%s`"
+echo "ro.build.type=$TARGET_BUILD_TYPE"
+echo "ro.build.user=$USER"
+echo "ro.build.host=`hostname`"
+echo "ro.build.tags=$BUILD_VERSION_TAGS"
+echo "ro.build.flavor=$TARGET_BUILD_FLAVOR"
+if [ -n "$BOARD_BUILD_SYSTEM_ROOT_IMAGE" ] ; then
+ echo "ro.build.system_root_image=$BOARD_BUILD_SYSTEM_ROOT_IMAGE"
+fi
+if [ -n "$AB_OTA_UPDATER" ] ; then
+ echo "ro.build.ab_update=$AB_OTA_UPDATER"
+fi
+echo "ro.product.model=$PRODUCT_MODEL"
+echo "ro.product.brand=$PRODUCT_BRAND"
+echo "ro.product.name=$PRODUCT_NAME"
+echo "ro.product.device=$TARGET_DEVICE"
+echo "ro.product.board=$TARGET_BOOTLOADER_BOARD_NAME"
+
+# These values are deprecated, use "ro.product.cpu.abilist"
+# instead (see below).
+echo "# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,"
+echo "# use ro.product.cpu.abilist instead."
+echo "ro.product.cpu.abi=$TARGET_CPU_ABI"
+if [ -n "$TARGET_CPU_ABI2" ] ; then
+ echo "ro.product.cpu.abi2=$TARGET_CPU_ABI2"
+fi
+echo "ro.product.cpu.abilist=$TARGET_CPU_ABI_LIST"
+echo "ro.product.cpu.abilist32=$TARGET_CPU_ABI_LIST_32_BIT"
+echo "ro.product.cpu.abilist64=$TARGET_CPU_ABI_LIST_64_BIT"
+
+echo "ro.product.manufacturer=$PRODUCT_MANUFACTURER"
+if [ -n "$PRODUCT_DEFAULT_LOCALE" ] ; then
+ echo "ro.product.locale=$PRODUCT_DEFAULT_LOCALE"
+fi
+echo "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS"
+echo "ro.board.platform=$TARGET_BOARD_PLATFORM"
+
+echo "# ro.build.product is obsolete; use ro.product.device"
+echo "ro.build.product=$TARGET_DEVICE"
+
+echo "# Do not try to parse description, fingerprint, or thumbprint"
+echo "ro.build.description=$PRIVATE_BUILD_DESC"
+echo "ro.build.fingerprint=$BUILD_FINGERPRINT"
+if [ -n "$BUILD_THUMBPRINT" ] ; then
+ echo "ro.build.thumbprint=$BUILD_THUMBPRINT"
+fi
+echo "ro.build.characteristics=$TARGET_AAPT_CHARACTERISTICS"
+
+echo "# end build properties"
+
+echo "persist.sys.language=zh"
+echo "persist.sys.country=CN"
+echo "persist.sys.localevar="
+echo "persist.sys.timezone=Asia/Shanghai"
+echo "ro.product.locale.language=zh"
+echo "ro.product.locale.region=CN"
+
diff --git a/tools/check_builds.sh b/tools/check_builds.sh
new file mode 100644
index 0000000000000000000000000000000000000000..c255bf00d61d9ae371f1fcc0a0dd59d09449867a
--- /dev/null
+++ b/tools/check_builds.sh
@@ -0,0 +1,92 @@
+# Copyright (C) 2009 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.
+
+#
+# Usage:
+#
+# Source this file into your environment. Then:
+#
+# $ golden_builds sdk-sdk generic-eng generic-userdebug dream-eng
+#
+# will build a set of combos. This might take a while. Then you can
+# go make changes, and run:
+#
+# $ check_builds sdk-sdk generic-eng generic-userdebug dream-eng
+#
+# Go get dinner, and when you get back, there will be a file
+# test-builds/sizes.html that has a pretty chart of which files are
+# in which tree, and how big they are. In that chart, cells for files
+# that are missing are red, and rows where the file sizes are not all
+# the same will be blue.
+#
+
+TEST_BUILD_DIR=test-builds
+
+function do_builds
+{
+ PREFIX=$1
+ shift
+ while [ -n "$1" ]
+ do
+ rm -rf $TEST_BUILD_DIR/$PREFIX-$1
+ make PRODUCT-$(echo $1 | sed "s/-.*//" )-installclean
+ make -j16 PRODUCT-$1 dist DIST_DIR=$TEST_BUILD_DIR/$PREFIX-$1
+ if [ $? -ne 0 ] ; then
+ echo FAILED
+ return
+ fi
+ shift
+ done
+}
+
+function golden_builds
+{
+ rm -rf $TEST_BUILD_DIR/golden-* $TEST_BUILD_DIR/dist-*
+ do_builds golden "$@"
+}
+
+function compare_builds
+{
+ local inputs=
+ while [ -n "$1" ]
+ do
+ inputs="$inputs $TEST_BUILD_DIR/golden-$1/installed-files.txt"
+ inputs="$inputs $TEST_BUILD_DIR/dist-$1/installed-files.txt"
+ shift
+ done
+ build/tools/compare_fileslist.py $inputs > $TEST_BUILD_DIR/sizes.html
+}
+
+function check_builds
+{
+ rm -rf $TEST_BUILD_DIR/dist-*
+ do_builds dist "$@"
+ compare_builds "$@"
+}
+
+function diff_builds
+{
+ local inputs=
+ while [ -n "$1" ]
+ do
+ diff $TEST_BUILD_DIR/golden-$1/installed-files.txt $TEST_BUILD_DIR/dist-$1/installed-files.txt &> /dev/null
+ if [ $? != 0 ]; then
+ echo =========== $1 ===========
+ diff $TEST_BUILD_DIR/golden-$1/installed-files.txt $TEST_BUILD_DIR/dist-$1/installed-files.txt
+ fi
+ shift
+ done
+ build/tools/compare_fileslist.py $inputs > $TEST_BUILD_DIR/sizes.html
+}
+
diff --git a/tools/check_radio_versions.py b/tools/check_radio_versions.py
new file mode 100755
index 0000000000000000000000000000000000000000..ebe621f4669bf9084ad4c3326149e478ef35541e
--- /dev/null
+++ b/tools/check_radio_versions.py
@@ -0,0 +1,79 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2012 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.
+
+import sys
+import os
+
+try:
+ from hashlib import sha1
+except ImportError:
+ from sha import sha as sha1
+
+if len(sys.argv) < 2:
+ sys.exit(0)
+
+build_info = {}
+f = open(sys.argv[1])
+for line in f:
+ line = line.strip()
+ if line.startswith("require"):
+ key, value = line.split()[1].split("=", 1)
+ build_info[key] = value
+f.close()
+
+bad = False
+
+for item in sys.argv[2:]:
+ key, fn = item.split(":", 1)
+
+ values = build_info.get(key, None)
+ if not values:
+ continue
+ values = values.split("|")
+
+ f = open(fn, "rb")
+ digest = sha1(f.read()).hexdigest()
+ f.close()
+
+ versions = {}
+ try:
+ f = open(fn + ".sha1")
+ except IOError:
+ if not bad: print
+ print "*** Error opening \"%s.sha1\"; can't verify %s" % (fn, key)
+ bad = True
+ continue
+ for line in f:
+ line = line.strip()
+ if not line or line.startswith("#"): continue
+ h, v = line.split()
+ versions[h] = v
+
+ if digest not in versions:
+ if not bad: print
+ print "*** SHA-1 hash of \"%s\" doesn't appear in \"%s.sha1\"" % (fn, fn)
+ bad = True
+ continue
+
+ if versions[digest] not in values:
+ if not bad: print
+ print "*** \"%s\" is version %s; not any %s allowed by \"%s\"." % (
+ fn, versions[digest], key, sys.argv[1])
+ bad = True
+
+if bad:
+ print
+ sys.exit(1)
diff --git a/tools/compare_fileslist.py b/tools/compare_fileslist.py
new file mode 100755
index 0000000000000000000000000000000000000000..1f507d8647b7806f02898b1fb423aefbb4044bd5
--- /dev/null
+++ b/tools/compare_fileslist.py
@@ -0,0 +1,106 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2009 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.
+#
+
+import cgi, os, string, sys
+
+def IsDifferent(row):
+ val = None
+ for v in row:
+ if v:
+ if not val:
+ val = v
+ else:
+ if val != v:
+ return True
+ return False
+
+def main(argv):
+ inputs = argv[1:]
+ data = {}
+ index = 0
+ for input in inputs:
+ f = file(input, "r")
+ lines = f.readlines()
+ f.close()
+ lines = map(string.split, lines)
+ lines = map(lambda (x,y): (y,int(x)), lines)
+ for fn,sz in lines:
+ if not data.has_key(fn):
+ data[fn] = {}
+ data[fn][index] = sz
+ index = index + 1
+ rows = []
+ for fn,sizes in data.iteritems():
+ row = [fn]
+ for i in range(0,index):
+ if sizes.has_key(i):
+ row.append(sizes[i])
+ else:
+ row.append(None)
+ rows.append(row)
+ rows = sorted(rows, key=lambda x: x[0])
+ print """
+
+
+
+
+ """
+ print ""
+ print ""
+ for input in inputs:
+ combo = input.split(os.path.sep)[1]
+ print " %s " % cgi.escape(combo)
+ print " "
+
+ for row in rows:
+ print ""
+ for sz in row[1:]:
+ if not sz:
+ print " "
+ elif IsDifferent(row[1:]):
+ print " %d " % sz
+ else:
+ print " %d " % sz
+ print " %s " % cgi.escape(row[0])
+ print " "
+ print "
"
+ print ""
+
+if __name__ == '__main__':
+ main(sys.argv)
+
+
diff --git a/tools/diff_package_overlays.py b/tools/diff_package_overlays.py
new file mode 100755
index 0000000000000000000000000000000000000000..0e2c773d1a9a3720db8200d7d4ddc221b1f03d7b
--- /dev/null
+++ b/tools/diff_package_overlays.py
@@ -0,0 +1,91 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2012 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.
+
+"""
+Prints to stdout the package names that have overlay changes between
+current_overlays.txt and previous_overlays.txt.
+
+Usage: diff_package_overlays.py
+current_packages.txt contains all package names separated by space in the current build.
+This script modfies current_packages.txt if necessary: if there is a package in
+previous_overlays.txt but absent from current_packages.txt, we copy that line
+from previous_overlays.txt over to current_packages.txt. Usually that means we
+just don't care that package in the current build (for example we are switching
+from a full build to a partial build with mm/mmm), and we should carry on the
+previous overlay config so current_overlays.txt always reflects the current
+status of the entire tree.
+
+Format of current_overlays.txt and previous_overlays.txt:
+ [resource_overlay ...]
+ [resource_overlay ...]
+ ...
+"""
+
+import sys
+
+def main(argv):
+ if len(argv) != 4:
+ print >> sys.stderr, __doc__
+ sys.exit(1)
+
+ f = open(argv[1])
+ all_packages = set(f.read().split())
+ f.close()
+
+ def load_overlay_config(filename):
+ f = open(filename)
+ result = {}
+ for line in f:
+ line = line.strip()
+ if not line or line.startswith("#"):
+ continue
+ words = line.split()
+ result[words[0]] = " ".join(words[1:])
+ f.close()
+ return result
+
+ current_overlays = load_overlay_config(argv[2])
+ previous_overlays = load_overlay_config(argv[3])
+
+ result = []
+ carryon = []
+ for p in current_overlays:
+ if p not in previous_overlays:
+ result.append(p)
+ elif current_overlays[p] != previous_overlays[p]:
+ result.append(p)
+ for p in previous_overlays:
+ if p not in current_overlays:
+ if p in all_packages:
+ # overlay changed
+ result.append(p)
+ else:
+ # we don't build p in the current build.
+ carryon.append(p)
+
+ # Add carryon to the current overlay config file.
+ if carryon:
+ f = open(argv[2], "a")
+ for p in carryon:
+ f.write(p + " " + previous_overlays[p] + "\n")
+ f.close()
+
+ # Print out the package names that have overlay change.
+ for r in result:
+ print r
+
+if __name__ == "__main__":
+ main(sys.argv)
diff --git a/tools/droiddoc/Android.mk b/tools/droiddoc/Android.mk
new file mode 100644
index 0000000000000000000000000000000000000000..ff08edc103b3d597014c933d4468ab9825eab09a
--- /dev/null
+++ b/tools/droiddoc/Android.mk
@@ -0,0 +1,17 @@
+# 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.
+
+LOCAL_PATH := $(call my-dir)
+
+# Droiddoc is now Doclava -- See external/doclava.
diff --git a/tools/droiddoc/templates-ndk/assets/GPL-LICENSE.txt b/tools/droiddoc/templates-ndk/assets/GPL-LICENSE.txt
new file mode 100644
index 0000000000000000000000000000000000000000..66a0f18dbf5a31772318b22a16fd1364dbdeab8f
--- /dev/null
+++ b/tools/droiddoc/templates-ndk/assets/GPL-LICENSE.txt
@@ -0,0 +1,278 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin Street, 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 Lesser 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.
\ No newline at end of file
diff --git a/tools/droiddoc/templates-ndk/assets/LICENSE.txt b/tools/droiddoc/templates-ndk/assets/LICENSE.txt
new file mode 100644
index 0000000000000000000000000000000000000000..e84328beda371bcc10d1e52a3ada91a73bee854c
--- /dev/null
+++ b/tools/droiddoc/templates-ndk/assets/LICENSE.txt
@@ -0,0 +1,20 @@
+Copyright (c) 2011 John Resig, http://jquery.com/
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
diff --git a/tools/droiddoc/templates-ndk/assets/android-developer-docs.css b/tools/droiddoc/templates-ndk/assets/android-developer-docs.css
new file mode 100644
index 0000000000000000000000000000000000000000..cd610f74e791395a3e01199d4f4341db0d67de5f
--- /dev/null
+++ b/tools/droiddoc/templates-ndk/assets/android-developer-docs.css
@@ -0,0 +1,2768 @@
+/* file: android-developer-core.css
+ author: smain
+ date: september 2008
+ info: core developer styles (developer.android.com)
+ Required by jdiff
+*/
+
+
+/* RESET STYLES */
+
+html,body,div,h1,h2,h3,h4,h5,h6,p,img,
+dl,dt,dd,ol,ul,li,table,caption,tbody,
+tfoot,thead,tr,th,td,form,fieldset,
+embed,object,applet {
+ margin: 0;
+ padding: 0;
+ border: 0;
+}
+
+/* BASICS */
+
+html, body {
+ overflow:hidden; /* keeps scrollbar off IE */
+ background-color:#fff;
+}
+
+body {
+ font-family:arial,sans-serif;
+ color:#000;
+ font-size:13px;
+ color:#333;
+ background-image:url(images/bg_fade.jpg);
+ background-repeat:repeat-x;
+}
+
+a, a code {
+ color:#006699;
+}
+
+a:active,
+a:active code {
+ color:#f00;
+}
+
+a:visited,
+a:visited code {
+ color:#006699;
+}
+
+input, select,
+textarea, option, label {
+ font-family:inherit;
+ font-size:inherit;
+ padding:0;
+ margin:0;
+ vertical-align:middle;
+}
+
+option {
+ padding:0 4px;
+}
+
+p, form {
+ padding:0;
+ margin:0 0 1em;
+}
+
+code, pre {
+ color:#007000;
+ font-family:monospace;
+ line-height:1em;
+}
+
+var {
+ color:#007000;
+ font-style:italic;
+}
+
+pre {
+ border:1px solid #ccc;
+ background-color:#fafafa;
+ padding:10px;
+ margin:0 0 1em 1em;
+ overflow:auto;
+ line-height:inherit; /* fixes vertical scrolling in webkit */
+}
+
+h1,h2,h3,h4,h5 {
+ margin:1em 0;
+ padding:0;
+}
+
+p,ul,ol,dl,dd,dt,li {
+ line-height:1.3em;
+}
+
+ul,ol {
+ margin:0 0 .8em;
+ padding:0 0 0 2em;
+}
+
+li {
+ padding:0 0 .5em;
+}
+
+dl {
+ margin:0 0 1em 0;
+ padding:0;
+}
+
+dt {
+ margin:0;
+ padding:0;
+}
+
+dd {
+ margin:0 0 1em;
+ padding:0 0 0 2em;
+}
+
+li p {
+ margin:.5em 0 0;
+}
+
+dd p {
+ margin:1em 0 0;
+}
+
+li pre, li table, li img {
+ margin:.5em 0 0 1em;
+}
+
+dd pre,
+#jd-content dd table,
+#jd-content dd img {
+ margin:1em 0 0 1em;
+}
+
+li ul,
+li ol,
+dd ul,
+dd ol {
+ margin:0;
+ padding: 0 0 0 2em;
+}
+
+li li,
+dd li {
+ margin:0;
+ padding:.5em 0 0;
+}
+
+dl dl,
+ol dl,
+ul dl {
+ margin:0 0 1em;
+ padding:0;
+}
+
+table {
+ font-size:1em;
+ margin:0 0 1em;
+ padding:0;
+ border-collapse:collapse;
+ border-width:0;
+ empty-cells:show;
+}
+
+td,th {
+ border:1px solid #ccc;
+ padding:6px 12px;
+ text-align:left;
+ vertical-align:top;
+ background-color:inherit;
+}
+
+th {
+ background-color:#dee8f1;
+}
+
+td > p:last-child {
+ margin:0;
+}
+
+hr.blue {
+ background-color:#DDF0F2;
+ border:none;
+ height:5px;
+ margin:20px 0 10px;
+}
+
+blockquote {
+ margin: 0 0 1em 1em;
+ padding: 0 4em 0 1em;
+ border-left:2px solid #eee;
+}
+/* LAYOUT */
+
+#body-content {
+ /* "Preliminary" watermark for preview releases and interim builds.
+ background:transparent url(images/preliminary.png) repeat scroll 0 0; */
+ margin:0;
+ position:relative;
+ width:100%;
+}
+
+#header {
+ height: 114px;
+ position:relative;
+ z-index:100;
+ min-width:675px; /* min width for the tabs, before they wrap */
+ padding:0 10px;
+ border-bottom:3px solid #94b922;
+}
+
+#headerLeft{
+ padding: 25px 0 0;
+}
+
+#headerLeft img{
+ height:50px;
+ width:180px;
+}
+
+#headerRight {
+ position:absolute;
+ right:0;
+ top:0;
+ text-align:right;
+}
+
+/* Tabs in the header */
+
+#header ul {
+ list-style: none;
+ margin: 7px 0 0;
+ padding: 0;
+ height: 29px;
+}
+
+#header li {
+ float: left;
+ margin: 0px 2px 0px 0px;
+ padding:0;
+}
+
+#header li a {
+ text-decoration: none;
+ display: block;
+ background-image: url(images/bg_images_sprite.png);
+ background-position: 0 -58px;
+ background-repeat: no-repeat;
+ color: #666;
+ font-size: 13px;
+ font-weight: bold;
+ width: 94px;
+ height: 29px;
+ text-align: center;
+ margin: 0px;
+}
+
+#header li a:hover {
+ background-image: url(images/bg_images_sprite.png);
+ background-position: 0 -29px;
+ background-repeat: no-repeat;
+}
+
+#header li a span {
+ position:relative;
+ top:7px;
+}
+
+#header li a span+span {
+ display:none;
+}
+
+/* tab highlighting */
+
+.home #home-link a,
+.guide #guide-link a,
+.reference #reference-link a,
+.sdk #sdk-link a,
+.resources #resources-link a,
+.videos #videos-link a {
+ background-image: url(images/bg_images_sprite.png);
+ background-position: 0 0;
+ background-repeat: no-repeat;
+ color: #fff;
+ font-weight: bold;
+ cursor:default;
+}
+
+.home #home-link a:hover,
+.guide #guide-link a:hover,
+.reference #reference-link a:hover,
+.sdk #sdk-link a:hover,
+.resources #resources-link a:hover,
+.videos #videos-link a:hover {
+ background-image: url(images/bg_images_sprite.png);
+ background-position: 0 0;
+}
+
+#headerLinks {
+ margin:10px 10px 0 0;
+ height:13px;
+ font-size: 11px;
+ vertical-align: top;
+}
+
+#headerLinks a {
+ color: #7FA9B5;
+}
+
+#headerLinks img {
+ vertical-align:middle;
+}
+
+#language {
+ margin:0 10px 0 4px;
+}
+
+#search {
+ height:45px;
+ margin:15px 10px 0 0;
+}
+
+/* MAIN BODY */
+
+#mainBodyFluid {
+ margin: 20px 10px;
+ color:#333;
+}
+
+#mainBodyFixed {
+ margin: 20px 10px;
+ color: #333;
+ width:930px;
+ position:relative;
+}
+
+#mainBodyFixed h3,
+#mainBodyFluid h3 {
+ color:#336666;
+ font-size:1.25em;
+ margin: 0em 0em 0em 0em;
+ padding-bottom:.5em;
+}
+
+#mainBodyFixed h2,
+#mainBodyFluid h2 {
+ color:#336666;
+ font-size:1.25em;
+ margin: 0;
+ padding-bottom:.5em;
+}
+
+#mainBodyFixed h1,
+#mainBodyFluid h1 {
+ color:#435A6E;
+ font-size:1.7em;
+ margin: 1em 0;
+}
+
+#mainBodyFixed .green,
+#mainBodyFluid .green,
+#jd-content .green {
+ color:#7BB026;
+ background-color:none;
+}
+
+#mainBodyLeft {
+ float: left;
+ width: 600px;
+ margin-right: 20px;
+ color: #333;
+ position:relative;
+}
+
+div.indent {
+ margin-left: 40px;
+ margin-right: 70px;
+}
+
+#mainBodyLeft p {
+ color: #333;
+ font-size: 13px;
+}
+
+#mainBodyLeft p.blue {
+ color: #669999;
+}
+
+#mainBodyLeft #communityDiv {
+ float: left;
+ background-image:url(images/bg_community_leftDiv.jpg);
+ background-repeat: no-repeat;
+ width: 581px;
+ height: 347px;
+ padding: 20px 0px 0px 20px;
+}
+
+#mainBodyRight {
+ float: left;
+ width: 300px;
+ color: #333;
+}
+
+#mainBodyRight p {
+ padding-right: 50px;
+ color: #333;
+}
+
+#mainBodyRight table {
+ width: 100%;
+}
+
+#mainBodyRight td {
+ border:0px solid #666;
+ padding:0px 5px;
+ text-align:left;
+}
+
+#mainBodyRight td p {
+ margin:0 0 1em 0;
+}
+
+#mainBodyRight .blueBorderBox {
+ border:5px solid #ddf0f2;
+ padding:18px 18px 18px 18px;
+ text-align:left;
+}
+
+#mainBodyFixed .seperator {
+ background-image:url(images/hr_gray_side.jpg);
+ background-repeat:no-repeat;
+ width: 100%;
+ float: left;
+ clear: both;
+}
+
+#mainBodyBottom {
+ float: left;
+ width: 100%;
+ clear:both;
+ color: #333;
+}
+
+#mainBodyBottom .seperator {
+ background-image:url(images/hr_gray_main.jpg);
+ background-repeat:no-repeat;
+ width: 100%;
+ float: left;
+ clear: both;
+}
+
+/* FOOTER */
+
+#footer {
+ float: left;
+ width:90%;
+ margin: 20px;
+ color: #aaa;
+ font-size: 11px;
+}
+
+#footer a {
+ color: #aaa;
+ font-size: 11px;
+}
+
+#footer a:hover {
+ text-decoration: underline;
+ color:#aaa;
+}
+
+#footerlinks {
+ margin-top:2px;
+}
+
+#footerlinks a,
+#footerlinks a:visited {
+ color:#006699;
+}
+
+/* SEARCH FILTER */
+
+#search_autocomplete {
+ color:#aaa;
+}
+
+#search-button {
+ display:inline;
+}
+
+#search_filtered_div {
+ position:absolute;
+ margin-top:-1px;
+ z-index:101;
+ border:1px solid #BCCDF0;
+ background-color:#fff;
+}
+
+#search_filtered {
+ min-width:100%;
+}
+#search_filtered td{
+ background-color:#fff;
+ border-bottom: 1px solid #669999;
+ line-height:1.5em;
+}
+
+#search_filtered .jd-selected {
+ background-color: #94b922;
+ cursor:pointer;
+}
+#search_filtered .jd-selected,
+#search_filtered .jd-selected a {
+ color:#fff;
+}
+
+.no-display {
+ display: none;
+}
+
+.jd-autocomplete {
+ font-family: Arial, sans-serif;
+ padding-left: 6px;
+ padding-right: 6px;
+ padding-top: 1px;
+ padding-bottom: 1px;
+ font-size: 0.81em;
+ border: none;
+ margin: 0;
+ line-height: 1.05em;
+}
+
+.show-row {
+ display: table-row;
+}
+.hide-row {
+ display: hidden;
+}
+
+/* SEARCH */
+
+/* restrict global search form width */
+#searchForm {
+ width:350px;
+}
+
+#searchTxt {
+ width:200px;
+}
+
+/* disable twiddle and size selectors for left column */
+#leftSearchControl div {
+ width: 100%;
+}
+
+#leftSearchControl .gsc-twiddle {
+ background-image : none;
+}
+
+#leftSearchControl td, #searchForm td {
+ border: 0px solid #000;
+}
+
+#leftSearchControl .gsc-resultsHeader .gsc-title {
+ padding-left : 0px;
+ font-weight : bold;
+ font-size : 13px;
+ color:#006699;
+ display : none;
+}
+
+#leftSearchControl .gsc-resultsHeader div.gsc-results-selector {
+ display : none;
+}
+
+#leftSearchControl .gsc-resultsRoot {
+ padding-top : 6px;
+}
+
+#leftSearchControl div.gs-visibleUrl-long {
+ display : block;
+ color:#006699;
+}
+
+.gsc-webResult div.gs-visibleUrl-short,
+table.gsc-branding,
+.gsc-clear-button {
+ display : none;
+}
+
+.gsc-cursor-box .gsc-cursor div.gsc-cursor-page,
+.gsc-cursor-box .gsc-trailing-more-results a.gsc-trailing-more-results,
+#leftSearchControl a,
+#leftSearchControl a b {
+ color:#006699;
+}
+
+.gsc-resultsHeader {
+ display: none;
+}
+
+/* Disable built in search forms */
+.gsc-control form.gsc-search-box {
+ display : none;
+}
+table.gsc-search-box {
+ margin:6px 0 0 0;
+ border-collapse:collapse;
+}
+
+td.gsc-input {
+ padding:0 2px;
+ width:100%;
+ vertical-align:middle;
+}
+
+input.gsc-input {
+ border:1px solid #BCCDF0;
+ width:99%;
+ padding-left:2px;
+ font-size:.95em;
+}
+
+td.gsc-search-button {
+ text-align: right;
+ padding:0;
+ vertical-align:top;
+}
+
+#search-button {
+ margin:0 0 0 2px;
+ font-size:11px;
+}
+
+/* search result tabs */
+
+#doc-content .gsc-control {
+ position:relative;
+}
+
+#doc-content .gsc-tabsArea {
+ position:relative;
+ white-space:nowrap;
+}
+
+#doc-content .gsc-tabHeader {
+ padding: 3px 6px;
+ position:relative;
+ width:auto;
+}
+
+#doc-content .gsc-tabHeader.gsc-tabhActive {
+ border-top: 2px solid #94B922;
+}
+
+#doc-content h2#searchTitle {
+ padding:0;
+}
+
+#doc-content .gsc-resultsbox-visible {
+ padding:1em 0 0 6px;
+}
+
+/* CAROUSEL */
+
+#homeMiddle {
+ padding: 0px 0px 0px 0px;
+ float: left;
+ width: 584px;
+ height: 627px;
+ position:relative;
+}
+
+#topAnnouncement {
+ background:url(images/home/bg_home_announcement.png) no-repeat 0 0;
+}
+
+#homeTitle {
+ padding:15px 15px 0;
+ height:30px;
+}
+
+#homeTitle h2 {
+ padding:0;
+}
+
+#announcement-block {
+ padding:0 15px 0;
+ overflow:hidden;
+ background: url(images/hr_gray_side.jpg) no-repeat 15px 0;
+ zoom:1;
+}
+
+#announcement-block>* {
+ padding:15px 0 0;
+}
+
+#announcement-block img {
+ float:left;
+ margin:0 30px 0 0;
+}
+
+#announcement {
+ float:left;
+ margin:0;
+}
+
+#carousel {
+ background:url(images/home/bg_home_carousel.png) no-repeat 0 0;
+ position:relative;
+ height:400px;
+}
+
+#carouselMain {
+ background: url(images/home/bg_home_carousel_board.png) 0 0 no-repeat;
+ height:auto;
+ padding: 25px 21px 0;
+ overflow:hidden;
+ position:relative;
+ zoom:1; /*IE6*/
+}
+
+#carouselMain img {
+ margin:0;
+}
+
+#carouselMain .bulletinDesc h3 {
+ margin:0;
+ padding:0;
+}
+
+#carouselMain .bulletinDesc p {
+ margin:0;
+ padding:0.7em 0 0;
+}
+
+#carouselWheel {
+ background: url(images/home/bg_home_carousel_wheel.png) 0 0 no-repeat;
+ padding-top:40px;
+ height:150px;
+}
+
+.clearer { clear:both; }
+
+a#arrow-left, a#arrow-right {
+ float:left;
+ width:42px;
+ height:42px;
+ background-image:url(images/home/carousel_buttons_sprite.png);
+ background-repeat:no-repeat;
+}
+a#arrow-left {
+ margin:35px 3px 0 10px;
+}
+a#arrow-right {
+ margin:35px 10px 0 0;
+}
+a.arrow-left-off,
+a#arrow-left.arrow-left-off:hover {
+ background-position:0 0;
+}
+a.arrow-right-off,
+a#arrow-right.arrow-right-off:hover {
+ background-position:-42px 0;
+}
+a#arrow-left:hover {
+ background-position:0 -42px;
+}
+a#arrow-right:hover {
+ background-position:-42px -42px;
+}
+a.arrow-left-on {
+ background-position:0 0;
+}
+a.arrow-right-on {
+ background-position:-42px 0;
+}
+a.arrow-right-off,
+a.arrow-left-off {
+ cursor:default;
+}
+
+.app-list-container {
+ margin:0 20px;
+ position:relative;
+ width:100%;
+}
+
+div#list-clip {
+ height:110px;
+ width:438px;
+ overflow:hidden;
+ position:relative;
+ float:left;
+}
+
+div#app-list {
+ left:0;
+ z-index:1;
+ position:absolute;
+ margin:11px 0 0;
+ _margin-top:13px;
+ width:1000%;
+}
+
+#app-list a {
+ display:block;
+ float:left;
+ height:90px;
+ width:90px;
+ margin:0 24px 0;
+ padding:3px;
+ background:#99cccc;
+ -webkit-border-radius:7px;
+ -moz-border-radius:7px;
+ border-radius:7px;
+ text-decoration:none;
+ text-align:center;
+ font-size:11px;
+ line-height:11px;
+}
+
+#app-list a span {
+ position:relative;
+ top:-4px;
+}
+
+#app-list img {
+ width:90px;
+ height:70px;
+ margin:0;
+}
+
+#app-list a.selected,
+#app-list a:active.selected,
+#app-list a:hover.selected {
+ background:#A4C639;
+ color:#fff;
+ cursor:default;
+ text-decoration:none;
+}
+
+#app-list a:hover,
+#app-list a:active {
+ background:#ff9900;
+}
+
+#app-list a:hover span,
+#app-list a:active span {
+ text-decoration:underline;
+}
+
+#droid-name {
+ padding-top:.5em;
+ color:#666;
+ padding-bottom:.25em;
+}
+
+/*IE6*/
+* html #app-list a { zoom: 1; margin:0 24px 0 15px;}
+
+* html #list-clip {
+ width:430px !important;
+}
+
+/*carousel bulletin layouts*/
+/*460px width*/
+/*185px height*/
+.img-left {
+ float:left;
+ width:230px;
+ overflow:hidden;
+ padding:8px 0 8px 8px;
+}
+.desc-right {
+ float:left;
+ width:270px;
+ padding:10px;
+}
+.img-right {
+ float:right;
+ width:220px;
+ overflow:hidden;
+ padding:8px 8px 8px 0;
+}
+.desc-left {
+ float:right;
+ width:280px;
+ padding:10px;
+ text-align:right;
+}
+.img-top {
+ padding:20px 20px 0;
+}
+.desc-bottom {
+ padding:10px;
+}
+
+
+/* VIDEO PAGE */
+
+#mainBodyLeft.videoPlayer {
+ width:570px;
+}
+
+#mainBodyRight.videoPlayer {
+ width:330px;
+}
+
+/* player */
+
+#videoPlayerBox {
+ background-color: #DAF3FC;
+ border-radius:7px;
+ -moz-border-radius:7px;
+ -webkit-border-radius:7px;
+ width:530px;
+ padding:20px;
+ border:1px solid #d3ecf5;
+ box-shadow:2px 3px 1px #eee;
+ -moz-box-shadow:2px 3px 1px #eee;
+ -webkit-box-shadow:2px 3px 1px #eee;
+}
+
+#videoBorder {
+ background-color: #FFF;
+ min-height:399px;
+ height:auto !important;
+ border:1px solid #ccdada;
+ border-radius:7px 7px 0 0;
+ -moz-border-radius:7px 7px 0 0;
+ -webkit-border-top-left-radius:7px;
+ -webkit-border-top-right-radius:7px;
+}
+
+#videoPlayerTitle {
+ width:500px;
+ padding:15px 15px 0;
+}
+
+#videoPlayerTitle h2 {
+ font-weight:bold;
+ font-size:1.2em;
+ color:#336666;
+ margin:0;
+ padding:0;
+}
+
+#objectWrapper {
+ padding:15px 15px;
+ height:334px;
+ width:500px;
+}
+
+/* playlist tabs */
+
+ul#videoTabs {
+ list-style-type:none;
+ padding:0;
+ clear:both;
+ margin:0;
+ padding: 20px 0 0 15px;
+ zoom:1; /* IE7/8, otherwise top-padding is double */
+}
+
+ul#videoTabs li {
+ display:inline;
+ padding:0;
+ margin:0 3px 0 0;
+ line-height:2em;
+}
+
+ul#videoTabs li a {
+ border-radius:7px 7px 0 0;
+ -moz-border-radius:7px 7px 0 0;
+ -webkit-border-top-left-radius:7px;
+ -webkit-border-top-right-radius:7px;
+ background:#95c0d0;
+ color:#fff;
+ text-decoration:none;
+ padding:.45em 1.5em;
+ font-weight:bold;
+}
+
+ul#videoTabs li.selected a {
+ font-weight:bold;
+ text-decoration:none;
+ color:#555;
+ background:#daf3fc;
+ border-bottom:1px solid #daf3fc;
+}
+
+ul#videoTabs li:hover a {
+ background:#85acba;
+}
+
+ul#videoTabs li.selected:hover a {
+ background:#daf3fc;
+}
+
+/* playlists */
+
+#videos {
+ background:#daf3fc;
+ margin-bottom:1.5em;
+ padding:15px;
+ border-radius:5px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ box-shadow:2px 3px 1px #eee;
+ -moz-box-shadow:2px 3px 1px #eee;
+ -webkit-box-shadow:2px 3px 1px #eee;
+}
+
+#videos div {
+ display:none;
+}
+
+#videos div.selected {
+ display:block;
+}
+
+ul.videoPreviews {
+ list-style:none;
+ padding:0;
+ margin:0;
+ zoom:1; /* IE, otherwise, layout doesn't update when showing 'more' */
+}
+
+ul.videoPreviews li {
+ margin:0 0 5px;
+ padding:0;
+ overflow:hidden;
+ position:relative;
+}
+
+#mainBodyFixed ul.videoPreviews h3 {
+ font-size: 12px;
+ margin:0 0 1em 130px;
+ padding:0;
+ font-weight:bold;
+ color:inherit;
+}
+
+ul.videoPreviews a {
+ margin:1px;
+ padding:10px;
+ text-decoration:none;
+ height:90px;
+ display:block;
+ border-radius:5px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ background-color:transparent;
+}
+
+ul.videoPreviews a:hover {
+ background-color:#FFF;
+ border:none; /* IE8, otherwise, bg doesn't work */
+}
+
+ul.videoPreviews a.selected {
+ background-color: #FF9900;
+}
+
+ul.videoPreviews img {
+ float:left;
+ clear:left;
+ margin:0;
+}
+
+ul.videoPreviews h3 {
+ font-size:12px;
+ font-weight:bold;
+ text-decoration:none;
+ margin:0 0 1em 130px;
+ padding:0;
+}
+
+ul.videoPreviews p {
+ font-size: 12px;
+ text-decoration:none;
+ margin:0 0 1.2em 130px;
+}
+
+ul.videoPreviews p.full {
+ display:none;
+}
+
+ul.videoPreviews span.more {
+ padding:0 0 0 12px;
+ background:url(images/arrow_bluelink_down.png) 0 2px no-repeat;
+}
+
+ul.videoPreviews span.less {
+ padding:0 0 0 12px;
+ background:url(images/arrow_bluelink_up.png) 0 2px no-repeat;
+ display:none;
+}
+
+ul.videoPreviews p.toggle {
+ position:absolute;
+ margin:0;
+ margin-top:-23px; /* instead of bottom:23px, because IE won't do it correctly */
+ left:140px;
+}
+
+ul.videoPreviews p.toggle a {
+ height:auto;
+ margin:0;
+ padding:0;
+ zoom:1; /* IE6, otherwise the margin considers the img on redraws */
+}
+
+ul.videoPreviews p.toggle a:hover {
+ text-decoration:underline;
+ background:transparent; /* IE6, otherwise it inherits white */
+}
+
+/* featured videos */
+
+#mainBodyRight h2 {
+ padding:0 0 5px;
+}
+
+#mainBodyRight ul.videoPreviews {
+ margin:10px 0 0;
+}
+
+#mainBodyRight ul.videoPreviews li {
+ font-size:11px;
+ line-height:13px;
+ margin:0 0 5px;
+ padding:0;
+}
+
+#mainBodyRight ul.videoPreviews h3 {
+ padding:0;
+ margin:0;
+ font-size:100%;
+}
+
+#mainBodyRight ul.videoPreviews a {
+ text-decoration:none;
+ height:108px;
+ border:1px solid #FFF;
+}
+
+#mainBodyRight ul.videoPreviews a:hover {
+ border:1px solid #CCDADA;
+}
+
+#mainBodyRight ul.videoPreviews a.selected {
+ border:1px solid #FFF;
+}
+
+#mainBodyRight ul.videoPreviews p {
+ line-height:1.2em;
+ padding:0;
+ margin:4px 0 0 130px;
+}
+
+#mainBodyRight ul.videoPreviews img {
+ margin-top:5px;
+}
+
+/* Pretty printing styles. Used with prettify.js. */
+
+.str { color: #080; }
+.kwd { color: #008; }
+.com { color: #800; }
+.typ { color: #606; }
+.lit { color: #066; }
+.pun { color: #660; }
+.pln { color: #000; }
+dl.tag-list dt code,
+.tag { color: #008; }
+dl.atn-list dt code,
+.atn { color: #828; }
+.atv { color: #080; }
+.dec { color: #606; }
+
+@media print {
+ .str { color: #060; }
+ .kwd { color: #006; font-weight: bold; }
+ .com { color: #600; font-style: italic; }
+ .typ { color: #404; font-weight: bold; }
+ .lit { color: #044; }
+ .pun { color: #440; }
+ .pln { color: #000; }
+ .tag { color: #006; font-weight: bold; }
+ .atn { color: #404; }
+ .atv { color: #060; }
+}
+
+
+#title {
+ border-bottom: 4px solid #ccc;
+ display:none;
+}
+
+#title h1 {
+ color:#336666;
+ margin:0;
+ padding: 5px 10px;
+ font-size: 1em;
+ line-height: 15px;
+}
+
+#title h1 .small{
+ color:#000;
+ margin:0;
+ font-size: 13px;
+ padding:0 0 0 15px;
+}
+
+/* SIDE NAVIGATION */
+
+#side-nav {
+ padding:0 6px 0 0;
+ background-color: #fff;
+ font-size:12px;
+}
+
+#resize-packages-nav {
+/* keeps the resize handle below the h-scroll handle */
+ height:270px;
+ overflow:hidden;
+ max-height:100%;
+}
+
+#packages-nav {
+ height:270px;
+ max-height:inherit;
+ position:relative;
+ overflow:auto;
+}
+
+#classes-nav,
+#devdoc-nav {
+ overflow:auto;
+ position:relative;
+}
+
+#side-nav ul {
+ list-style: none;
+ margin: 0;
+ padding:5px 0;
+}
+
+#side-nav ul ul {
+ margin: .5em 0 0 0;
+ padding: 0;
+}
+
+#side-nav li {
+ padding:0;
+ padding:1px 0 1px 0;
+ zoom:1;
+}
+
+#side-nav li span.heading,
+#side-nav li h2 {
+ display:block;
+ font-size:12px;
+ font-weight: bold;
+ margin:.5em 0 0 0;
+ padding: 3px 0 1px 9px;
+}
+
+#side-nav li a {
+ display: inline-block; /* needed to apply padding to line-wraps */
+ text-decoration:none;
+ padding: 0 0 0 18px;
+ zoom:1;
+}
+
+#side-nav li a span+span {
+ display:none;
+}
+
+#side-nav li a:hover {
+ text-decoration:underline;
+}
+
+#side-nav li a+a {
+ padding: 0;
+}
+/*second level (nested) list*/
+#side-nav li li li a {
+ padding: 0 0 0 28px;
+}
+/*third level (nested) list*/
+#side-nav li li li li a {
+ padding: 0 0 0 38px;
+}
+
+#side-nav .selected {
+ background-color: #435a6e;
+ color: #fff;
+ font-weight:bold;
+}
+
+#side-nav .selected a {
+ color: #fff;
+ text-decoration:none;
+}
+
+#side-nav strong {
+ display:block;
+}
+
+#side-nav .toggle-list .toggle-img {
+ margin:0;
+ padding:0;
+ position:absolute;
+ top:0;
+ left:0;
+ height:16px;
+ width:15px;
+ outline-style:none;
+}
+/* second-level toggle */
+#side-nav .toggle-list .toggle-list .toggle-img {
+ left:10px;
+}
+
+#side-nav .closed .toggle-img,
+#side-nav .open .closed .toggle-img {
+ background:url('images/triangle-closed-small.png') 7px 4px no-repeat;
+}
+#side-nav .open .toggle-img {
+ background:url('images/triangle-opened-small.png') 7px 4px no-repeat;
+}
+
+#side-nav .toggle-list {
+ position:relative;
+}
+
+#side-nav .toggle-list ul {
+ margin:0;
+ display:none;
+}
+
+#side-nav .toggle-list div {
+ display:block;
+}
+
+#index-links .selected {
+ background-color: #fff;
+ color: #000;
+ font-weight:normal;
+ text-decoration:none;
+}
+
+#index-links {
+ padding:7px 0 4px 10px;
+}
+
+/* nav tree */
+
+#nav-tree ul {
+ padding:5px 0 1.5em;
+}
+
+#side-nav #nav-tree ul li a,
+#side-nav #nav-tree ul li span.no-children {
+ padding: 0 0 0 0;
+ margin: 0;
+}
+
+#nav-tree .plus {
+ margin: 0 3px 0 0;
+}
+
+#nav-tree ul ul {
+ list-style: none;
+ margin: 0;
+ padding: 0 0 0 0;
+}
+
+#nav-tree ul li {
+ margin: 0;
+ padding: 0 0 0 0;
+ white-space: nowrap;
+}
+
+#nav-tree .children_ul {
+ margin:0;
+}
+
+#nav-tree a.nolink {
+ color: black;
+ text-decoration: none;
+}
+
+#nav-tree span.label {
+ width: 100%;
+}
+
+#nav-tree {
+ overflow-x: auto;
+ overflow-y: scroll;
+}
+
+#nav-swap {
+ font-size:10px;
+ line-height:10px;
+ margin-left:1em;
+ text-decoration:none;
+ display:block;
+}
+
+#tree-link {
+
+}
+
+/* DOCUMENT BODY */
+
+#doc-content {
+ overflow:auto;
+}
+
+#jd-header {
+ background-color: #E2E2E2;
+ padding: 7px 15px;
+}
+
+#jd-header h1 {
+ margin: 0 0 10px;
+ font-size:1.7em;
+}
+
+#jd-header .crumb {
+ font-size:.9em;
+ line-height:1em;
+ color:#777;
+}
+
+#jd-header .crumb a,
+#jd-header .crumb a:visited {
+ text-decoration:none;
+ color:#777;
+}
+
+#jd-header .crumb a:hover {
+ text-decoration:underline;
+}
+
+#jd-header table {
+ margin:0;
+ padding:0;
+}
+
+#jd-header td {
+ border:none;
+ padding:0;
+ vertical-align:top;
+}
+
+#jd-header.guide-header {
+ background-color:#fff;
+ color:#435a6e;
+ height:50px;
+}
+
+#jd-descr {
+ position:relative;
+}
+
+/* summary tables for reference pages */
+.jd-sumtable {
+ margin: .5em 1em 1em 1em;
+ width:95%; /* consistent table widths; within IE's quirks */
+ font-size:.9em;
+}
+
+.jd-sumtable a {
+ text-decoration:none;
+}
+
+.jd-sumtable a:hover {
+ text-decoration:underline;
+}
+
+/* the link inside a sumtable for "Show All/Hide All" */
+.toggle-all {
+ display:block;
+ float:right;
+ font-weight:normal;
+ font-size:0.9em;
+}
+
+/* adjustments for in/direct subclasses tables */
+.jd-sumtable-subclasses {
+ margin: 1em 0 0 0;
+ max-width:968px;
+}
+
+/* extra space between end of method name and open-paren */
+.sympad {
+ margin-right: 2px;
+}
+
+/* right alignment for the return type in sumtable */
+.jd-sumtable .jd-typecol {
+ text-align:right;
+}
+
+/* adjustments for the expando table-in-table */
+.jd-sumtable-expando {
+ margin:.5em 0;
+ padding:0;
+}
+
+/* a div that holds a short description */
+.jd-descrdiv {
+ padding:3px 1em 0 1em;
+ margin:0;
+ border:0;
+}
+
+/* page-top-right container for reference pages (holds
+links to summary tables) */
+#api-info-block {
+ font-size:.8em;
+ padding:6px 10px;
+ font-weight:normal;
+ float:right;
+ text-align:right;
+ color:#999;
+ max-width:70%;
+}
+
+#api-level-toggle {
+ padding:0 10px;
+ font-size:11px;
+ float:right;
+}
+
+#api-level-toggle label.disabled {
+ color:#999;
+}
+
+div.api-level {
+ font-size:.8em;
+ font-weight:normal;
+ color:#999;
+ float:right;
+ padding:0 7px 0;
+ margin-top:-25px;
+}
+
+#api-info-block div.api-level {
+ font-size:1.3em;
+ font-weight:bold;
+ float:none;
+ color:#444;
+ padding:0;
+ margin:0;
+}
+
+/* Force link colors for IE6 */
+div.api-level a {
+ color:#999;
+}
+#api-info-block div.api-level a:link {
+ color:#444;
+}
+#api-level-toggle a {
+ color:#999;
+}
+
+div#deprecatedSticker {
+ display:none;
+ z-index:99;
+ position:fixed;
+ right:15px;
+ top:114px;
+ margin:0;
+ padding:1em;
+ background:#FFF;
+ border:1px solid #dddd00;
+ box-shadow:-5px 5px 10px #ccc;
+ -moz-box-shadow:-5px 5px 10px #ccc;
+ -webkit-box-shadow:-5px 5px 10px #ccc;
+}
+
+div#naMessage {
+ display:none;
+ width:555px;
+ height:0;
+ margin:0 auto;
+}
+
+div#naMessage div {
+ z-index:99;
+ width:450px;
+ position:fixed;
+ margin:50px 0;
+ padding:4em 4em 3em;
+ background:#FFF;
+ border:1px solid #dddd00;
+ box-shadow:-10px 10px 40px #888;
+ -moz-box-shadow:-10px 10px 40px #888;
+ -webkit-box-shadow:-10px 10px 40px #888;
+}
+/* IE6 can't position fixed */
+* html div#naMessage div { position:absolute; }
+
+div#naMessage strong {
+ font-size:1.1em;
+}
+
+.absent,
+.absent a:link,
+.absent a:visited,
+.absent a:hover,
+.absent * {
+ color:#bbb !important;
+ cursor:default !important;
+ text-decoration:none !important;
+}
+
+#api-level-toggle a,
+.api-level a {
+ color:inherit;
+ text-decoration:none;
+}
+
+#api-level-toggle a:hover,
+.api-level a:hover {
+ color:inherit;
+ text-decoration:underline !important;
+ cursor:pointer !important;
+}
+
+#side-nav li.absent.selected,
+#side-nav li.absent.selected *,
+#side-nav div.label.absent.selected,
+#side-nav div.label.absent.selected * {
+ background-color:#eaeaea !important;
+}
+/* IE6 quirk (won't chain classes, so just keep background blue) */
+* html #side-nav li.selected,
+* html #side-nav li.selected *,
+* html #side-nav div.label.selected,
+* html #side-nav div.label.selected * {
+ background-color: #435a6e !important;
+}
+
+
+.absent h4.jd-details-title,
+.absent h4.jd-details-title * {
+ background-color:#f6f6f6 !important;
+}
+
+.absent img {
+ opacity: .3;
+ filter: alpha(opacity=30);
+ -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
+}
+
+
+/* applies to a div containing links to summary tables */
+.sum-details-links {
+ padding:0;
+ font-weight:normal;
+}
+
+.sum-details-links a {
+ text-decoration:none;
+}
+
+.sum-details-links a:hover {
+ text-decoration:underline;
+}
+
+
+/* inheritance table */
+.jd-inheritance-table {
+ border-spacing:0;
+ margin:0;
+ padding:0;
+ font-size:.9em;
+}
+.jd-inheritance-table td {
+ border: none;
+ margin: 0;
+ padding: 0;
+}
+.jd-inheritance-table .jd-inheritance-space {
+ font-weight:bold;
+ width:1em;
+}
+.jd-inheritance-table .jd-inheritance-interface-cell {
+ padding-left: 17px;
+}
+
+#jd-content {
+ padding: 18px 15px;
+}
+
+hr {
+ background-color:#ccc;
+ border-color:#fff;
+ margin:2em 0 1em;
+}
+
+/* DOC CLASSES */
+
+#jd-content h1 {
+/*sdk page*/
+ font-size:1.6em;
+ color:#336666;
+ margin:0 0 .5em;
+}
+
+#jd-content h2 {
+ font-size:1.45em;
+ color:#111;
+ border-top:2px solid #ccc;
+ padding: .5em 0 0;
+ margin: 2em 0 1em 0;
+}
+
+#jd-content h3 {
+ font-size:1.3em;
+ color:#3a3a3a;
+ padding: 0;
+ margin: 1.5em 0 .65em 0;
+}
+
+#jd-content h4 {
+ font-size:1.1em;
+ color:#3a3a3a;
+ padding: 0;
+ margin: 1.25em 0 .65em 0;
+}
+
+#jd-content h5 {
+ font-size:1.0em;
+ color:#3a3a3a;
+ padding: 0;
+ margin: 1em 0 .65em 0;
+}
+
+#jd-content .small-header {
+ font-size:1em;
+ color:#000;
+ font-weight:bold;
+ border:none;
+ padding:0;
+ margin:1em 0 .5em;
+ position:inherit;
+}
+
+#jd-content table {
+ margin: 0 0 1em 1em;
+}
+
+#jd-content img {
+ margin: 0 0 1em 1em;
+}
+
+#jd-content li img,
+#jd-content dd img {
+ margin:.5em 0 .5em 1em;
+}
+
+.nolist {
+ list-style:none;
+ padding:0;
+ margin:0 0 1em 1em;
+}
+
+.nolist li {
+ padding:0 0 2px;
+ margin:0;
+}
+
+h4 .normal {
+ font-size:.9em;
+ font-weight:normal;
+}
+
+.caps {
+ font-variant:small-caps;
+ font-size:1.2em;
+}
+
+dl.tag-list dl.atn-list {
+ padding:0 0 0 2em;
+}
+
+.jd-details {
+/* border:1px solid #669999;
+ padding:4px; */
+ margin:0 0 1em;
+}
+
+/* API reference: a container for the
+.tagdata blocks that make up the detailed
+description */
+.jd-details-descr {
+ padding:0;
+ margin:.5em .25em;
+}
+
+/* API reference: a block containing
+a detailed description, a params table,
+seealso list, etc */
+.jd-tagdata {
+ margin:.5em 1em;
+}
+
+.jd-tagdata p {
+ margin:0 0 1em 1em;
+}
+
+/* API reference: adjustments to
+the detailed description block */
+.jd-tagdescr {
+ margin:.25em 0 .75em 0;
+ line-height:1em;
+}
+
+.jd-tagdescr p {
+ margin:.5em 0;
+ padding:0;
+
+}
+
+.jd-tagdescr ol,
+.jd-tagdescr ul {
+ margin:0 2.5em;
+ padding:0;
+}
+
+.jd-tagdescr table,
+.jd-tagdescr img {
+ margin:.25em 1em;
+}
+
+.jd-tagdescr li {
+margin:0 0 .25em 0;
+padding:0;
+}
+
+/* API reference: heading marking
+the details section for constants,
+attrs, methods, etc. */
+h4.jd-details-title {
+ font-size:1.15em;
+ background-color: #E2E2E2;
+ margin:1.5em 0 .6em;
+ padding:3px 95px 3px 3px; /* room for api-level */
+}
+
+h4.jd-tagtitle {
+ margin:0;
+}
+
+/* API reference: heading for "Parameters", "See Also", etc.,
+in details sections */
+h5.jd-tagtitle {
+ margin:0 0 .25em 0;
+ font-size:1em;
+}
+
+.jd-tagtable {
+ margin:0;
+}
+
+.jd-tagtable td,
+.jd-tagtable th {
+ border:none;
+ background-color:#fff;
+ vertical-align:top;
+ font-weight:normal;
+ padding:2px 10px;
+}
+
+.jd-tagtable th {
+ font-style:italic;
+}
+
+#jd-content table h2 {
+ background-color: #d6d6d6;
+ font-size: 1.1em;
+ margin:0 0 10px;
+ padding:5px;
+ left:0;
+ width:auto;
+}
+
+div.design-announce {
+ border-top:1px solid #33B5E5;
+ border-bottom:1px solid #33B5E5;
+ padding:5px 10px 10px 55px;
+ margin:2em 0;
+ background:url('images/icon_design.png') 5px 13px no-repeat;
+}
+
+div.design-announce p {
+ margin: .5em 0 0 0;
+}
+
+div.special {
+ padding: .5em 1em 1em 1em;
+ margin: 0 0 1em;
+ background-color: #DAF3FC;
+ border:1px solid #d3ecf5;
+ border-radius:5px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+}
+
+div.special p {
+ margin: .5em 0 0 0;
+}
+
+div.special ol {
+ margin: 0;
+}
+
+div.special ol li {
+ margin: 0;
+ padding: 0;
+}
+
+#jd-content div.special h2,
+#jd-content div.special h3 {
+ color:#669999;
+ font-size:1.2em;
+ border:none;
+ margin:0 0 .5em;
+ padding:0;
+}
+
+#jd-content div.special.reference h2,
+#jd-content div.special.reference h3,
+#jd-content div.special.reference h4 {
+ color:#000;
+ font-size:1em;
+ border:none;
+ font-weight:bold;
+ margin:.5em 0;
+ padding:0;
+}
+
+p.note, div.note,
+p.caution, div.caution,
+p.warning, div.warning {
+ margin: 1em;
+ padding: 0 0 0 .5em;
+ border-left: 4px solid;
+}
+
+p.special-note,
+div.special-note {
+ background-color:#EBF3DB;
+ padding:10px 20px;
+ margin:0 0 1em;
+}
+
+p.note,
+div.note {
+ border-color: #99aacc;
+}
+
+p.warning,
+div.warning {
+ border-color: #aa0033;
+}
+
+p.caution,
+div.caution {
+ border-color: #ffcf00;
+}
+
+li .note,
+li .caution,
+li .warning {
+ margin: .5em 0 0 0;
+ padding: .2em .5em .2em .9em;
+}
+
+/* Makes sure the first paragraph does not add top-whitespace within the box*/
+li .note>p:first-child,
+li .caution>p:first-child,
+li .warning>p:first-child {
+ margin-top:0;
+ padding-top:0;
+}
+
+dl.xml dt {
+ font-variant:small-caps;
+ font-size:1.2em;
+}
+
+dl.xml dl {
+ padding:0;
+}
+
+dl.xml dl dt {
+ font-variant:normal;
+ font-size:1em;
+}
+
+.listhead li {
+ font-weight: bold;
+}
+
+.listhead li *, /*ie*/.listhead li li {
+ font-weight: normal;
+}
+
+ol.no-style,
+ul.no-style {
+ list-style:none;
+ padding-left:1em;
+}
+
+.new,
+.new-child {
+ font-size: .78em;
+ font-weight: bold;
+ color: #ff3d3d;
+ text-decoration: none;
+ vertical-align:top;
+ line-height:.9em;
+ white-space:nowrap;
+}
+
+.toggle-list.open .new-child {
+ display:none;
+}
+
+pre.classic {
+ background-color:transparent;
+ border:none;
+ padding:0;
+}
+
+p.img-caption {
+ margin: -0.5em 0 1em 1em; /* matches default img left-margin */
+}
+
+div.figure {
+ float:right;
+ clear:right;
+ margin:1em 0 0 0;
+ padding:0 0 0 3em;
+ background-color:#fff;
+ /* width must be defined w/ an inline style matching the image width */
+}
+
+#jd-content
+div.figure img {
+ margin: 0 0 1em;
+}
+
+div.figure p.img-caption {
+ margin: -0.5em 0 1em 0;
+}
+
+p.table-caption {
+ margin: 0 0 0.5em 1em; /* matches default table left-margin */
+}
+
+
+/* toggle for misc content (such as long sample code)
+ see toggleContent() script in android-developer-docs.js */
+.toggle-content.closed .toggle-content-toggleme {
+ display:none;
+}
+
+.toggle-content a[href="#"] {
+ text-decoration:none;
+ color:inherit;
+}
+
+.toggle-content-toggleme {
+ padding-bottom:1px; /* fixes animation bounce due to margins */
+}
+
+#jd-content .toggle-content img.toggle-content-img {
+ margin:0;
+}
+
+
+/* BEGIN quickview sidebar element styles */
+
+#qv-wrapper {
+ float: right;
+ width:310px; /* +35px padding */
+ background-color:#fff;
+ margin:-48px 0 2px 0;
+ padding:0 0 20px 35px;
+}
+
+#qv {
+ background-color:#fff;
+ border:4px solid #dee8f1;
+ margin:0;
+ padding:0 5px 5px;
+ width:292px; /* +10px padding; +8px border */
+ font-size:.9em;
+}
+
+#qv ol {
+ list-style:none;
+ padding: 0;
+}
+
+#qv ol ol{
+ list-style:none;
+ padding: 0 0 0 12px;
+ margin:0;
+}
+
+#qv ul {
+ padding: 0 10px 0 2em;
+}
+
+#qv li {
+ padding: 0 10px 3px;
+ line-height: 1.2em;
+}
+
+#qv li li {
+ padding: 3px 10px 0;
+}
+
+#qv ul li {
+ padding: 0 10px 0 0;
+}
+
+#qv li.selected a {
+ color:#555;
+ text-decoration:none;
+}
+
+#qv a,
+#qv a code {
+ color:#cc6600;
+}
+
+#qv p {
+ margin:8px 0 0;
+ padding:0 10px;
+}
+
+#jd-content #qv h2 {
+ font-size:1.05em;
+ font-weight:bold;
+ margin:12px 0 .25em 0;
+ padding:0 10px;
+ background-color:transparent;
+ color:#7BB026;
+ border:none;
+ left:0;
+ z-index:1;
+}
+
+#qv-extra #rule {
+ padding: 0 10px;
+ margin: 0;
+}
+
+#qv-sub-rule {
+ padding: 5px 15px 10px;
+ margin: 0;
+}
+
+#jd-content
+#qv-sub-rule h2 {
+ margin: 0 0 .5em 0;
+}
+
+/* END quickview sidebar element styles */
+
+/* Begin sidebox sidebar element styles */
+
+.sidebox-wrapper {
+ float:right;
+ clear:right;
+ width:310px; /* +35px padding */
+ background-color:#fff;
+ margin:0;
+ padding:0 0 20px 35px;
+}
+
+.sidebox {
+ border-left:1px solid #dee8f1;
+ background-color:#ffffee;
+ margin:0;
+ padding:8px 12px;
+ font-size:0.9em;
+ width:285px; /* +24px padding; +1px border */
+}
+
+.sidebox p {
+ margin-bottom: .75em;
+}
+
+.sidebox ul {
+ padding: 0 0 0 1.5em;
+}
+
+.sidebox li ul {
+ margin-top:0;
+ margin-bottom:.1em;
+}
+
+.sidebox li {
+padding:0 0 0 0em;
+}
+
+#jd-content .sidebox h2,
+#jd-content .sidebox h3,
+#jd-content .sidebox h4,
+#jd-content .sidebox h5 {
+ border:none;
+ font-size:1em;
+ margin:0;
+ padding:0 0 8px;
+ left:0;
+ z-index:0;
+}
+
+.sidebox hr {
+ background-color:#ccc;
+ border:none;
+}
+
+/* End sidebox sidebar element styles */
+
+/* BEGIN developer training bar styles */
+
+div#tb-wrapper {
+ float: right;
+ clear:right;
+ width:380px; /* +25px padding = 405 */
+ background-color:#fff;
+ margin:0 0 2px 0;
+ padding:0 0 20px 25px;
+}
+
+div#tb {
+ margin:0;
+ padding:0 15px;
+ width:350px; /* +15px padding = 380 */
+ font-size:.9em;
+ background:#e9e9e9;
+ border:1px solid #aaa;
+ border-radius:5px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ overflow:auto;
+}
+
+div#tb h2 {
+ font-size:1.3em;
+ font-weight:bold;
+ margin:1em 0;
+ padding:0;
+ background-color:transparent;
+ border:none;
+ clear:both;
+}
+
+div.download-box a.button {
+ color: #069;
+ font-size:1.1em;
+ font-weight:bold;
+ text-decoration:none;
+ height:27px;
+ line-height:27px;
+ text-align:center;
+ padding:5px 8px;
+ background-color: #fff;
+ border: 1px solid #aaa;
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+}
+
+div.download-box a.button:hover {
+ border-color: #09C;
+ background-color: #4CADCB;
+ background-image: -webkit-gradient(linear,left top,left bottom,from(#5dbcd9),to(#4cadcb));
+ background-image: -webkit-linear-gradient(top,#5dbcd9,#4cadcb);
+ background-image: -moz-linear-gradient(top,#5dbcd9,#4cadcb);
+ background-image: -ms-linear-gradient(top,#5dbcd9,#4cadcb);
+ background-image: -o-linear-gradient(top,#5dbcd9,#4cadcb);
+ background-image: linear-gradient(top,#5dbcd9,#4cadcb);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#5dbcd9',EndColorStr='#4cadcb');
+ color: #fff;
+}
+
+div.download-box a.button:active {
+ background-color: #1E799A;
+ background-image: none;
+ border-color: #30B7E6;
+}
+
+div.download-box p.filename {
+ font-size:0.85em;
+ color:#888;
+ margin:4px 0 1em 10px;
+}
+
+/* End developer training bar */
+
+/* Training nav bar (previous/next) */
+
+div.training-nav-top {
+ float: right;
+ width:380px; /* +25px padding = 405 */
+ margin:-58px 0 0 0;
+ padding:0 0 20px 25px;
+}
+
+div.training-nav-bottom {
+ padding:1px; /* for weird FF bug (scrollbar appears) */
+ margin:3em 0;
+ overflow:auto;
+}
+
+div.training-nav-button-next a,
+div.training-nav-button-previous a {
+ display:block;
+ width:160px;
+ height:55px;
+ padding:4px 7px;
+ border:1px solid #aaa;
+ border-radius:5px;
+ -moz-border-radius:5px;
+ -webkit-border-radius:5px;
+ text-decoration:none;
+ font-weight:bold;
+}
+
+div.training-nav-button-next a:hover,
+div.training-nav-button-previous a:hover {
+ border:1px solid #069; /* match link color */
+}
+
+div.training-nav-button-next a:active,
+div.training-nav-button-previous a:active {
+ border:1px solid #f00; /* match link color */
+}
+
+div.training-nav-button-previous {
+ float:left;
+ text-align:left;
+}
+
+div.training-nav-button-next {
+ float:right;
+ text-align:right;
+}
+
+span.training-nav-button-title {
+ display:block;
+ font-size:.85em;
+ font-weight:normal;
+ line-height:1.3em;
+ margin:.5em 0 0;
+}
+
+/* End training nav bar */
+
+/* BEGIN image and caption styles (originally for UI Guidelines docs) */
+
+table.image-caption {
+ padding:0;
+ margin:.5em 0;
+ border:0;
+}
+
+td.image-caption-i {
+ font-size:92%;
+ padding:0 5px;
+ margin:0;
+ border:0;
+}
+
+td.image-caption-i img {
+ padding:0 1em;
+ margin:0;
+}
+
+.image-list {
+ width:24px;
+ text-align:center;
+}
+
+td.image-caption-c {
+ font-size:92%;
+ padding:1em 2px 2px 2px;
+ margin:0;
+ border:0;
+ width:350px;
+}
+
+.grad-rule-top {
+background-image:url(images/grad-rule-qv.png);
+background-repeat:no-repeat;
+padding-top:1em;
+margin-top:0;
+}
+
+.image-caption-nested {
+ margin-top:0;
+ padding:0 0 0 1em;
+}
+
+.image-caption-nested td {
+ padding:0 4px 2px 0;
+ margin:0;
+ border:0;
+}
+
+/* END image and caption styles */
+
+/* table of contents */
+
+ol.toc {
+ margin: 0 0 1em 0;
+ padding: 0;
+ list-style: none;
+ font-size:95%;
+}
+
+ol.toc li {
+ font-weight: bold;
+ margin: 0 0 .5em 1em;
+ padding: 0;
+}
+
+ol.toc li p {
+ font-weight: normal;
+}
+
+ol.toc li ol {
+ margin: 0;
+ padding: 0;
+}
+
+ol.toc li li {
+ padding: 0;
+ margin: 0 0 0 1em;
+ font-weight: normal;
+ list-style: none;
+}
+
+table ol.toc {
+ margin-left: 0;
+}
+
+.columns td {
+ padding:0 5px;
+ border:none;
+}
+
+/* link table */
+.jd-linktable {
+ margin: 0 0 1em;
+ border-bottom: 1px solid #888;
+}
+.jd-linktable th,
+.jd-linktable td {
+ padding: 3px 5px;
+ vertical-align: top;
+ text-align: left;
+ border:none;
+}
+.jd-linktable tr {
+ background-color: #fff;
+}
+.jd-linktable td {
+ border-top: 1px solid #888;
+ background-color: inherit;
+}
+.jd-linktable td p {
+ padding: 0 0 5px;
+}
+.jd-linktable .jd-linkcol {
+}
+.jd-linktable .jd-descrcol {
+}
+.jd-linktable .jd-typecol {
+ text-align:right;
+}
+.jd-linktable .jd-valcol {
+}
+.jd-linktable .jd-commentrow {
+ border-top:none;
+ padding-left:25px;
+}
+.jd-deprecated-warning {
+ margin-top: 0;
+ margin-bottom: 10px;
+}
+
+tr.alt-color {
+ background-color: #f6f6f6;
+}
+
+/* expando trigger */
+#jd-content .jd-expando-trigger-img {
+ margin:0;
+}
+
+/* jd-expando */
+.jd-inheritedlinks {
+ padding:0 0 0 13px
+}
+
+/* SDK PAGE */
+table.download tr {
+ background-color:#d9d9d9;
+}
+
+table.download tr.alt-color {
+ background-color:#ededed;
+}
+
+table.download td,
+table.download th {
+ border:2px solid #fff;
+ padding:10px 5px;
+}
+
+table.download th {
+ background-color:#6d8293;
+ color:#fff;
+}
+
+/* INLAY 180 COPY and 240PX EXTENSION */
+/* modified to 43px so that all browsers eliminate the package panel h-scroll */
+.g-tpl-240 .g-unit,
+.g-unit .g-tpl-240 .g-unit,
+.g-unit .g-unit .g-tpl-240 .g-unit {
+ display: block;
+ margin: 0 0 0 243px;
+ width: auto;
+ float: none;
+}
+.g-unit .g-unit .g-tpl-240 .g-first,
+.g-unit .g-tpl-240 .g-first,
+.g-tpl-240 .g-first {
+ display: block;
+ margin: 0;
+ width: 243px;
+ float: left;
+}
+/* 240px alt */
+.g-tpl-240-alt .g-unit,
+.g-unit .g-tpl-240-alt .g-unit,
+.g-unit .g-unit .g-tpl-240-alt .g-unit {
+ display: block;
+ margin: 0 243px 0 0;
+ width: auto;
+ float: none;
+}
+.g-unit .g-unit .g-tpl-240-alt .g-first,
+.g-unit .g-tpl-240-alt .g-first,
+.g-tpl-240-alt .g-first {
+ display: block;
+ margin: 0;
+ width: 243px;
+ float: right;
+}
+
+/* 200px */
+.g-tpl-200 .g-unit,
+.g-unit .g-tpl-200 .g-unit,
+.g-unit .g-unit .g-tpl-200 .g-unit {
+ display: block;
+ margin: 0 0 0 200px;
+ width: auto;
+ float: none;
+}
+.g-unit .g-unit .g-tpl-200 .g-first,
+.g-unit .g-tpl-200 .g-first,
+.g-tpl-200 .g-first {
+ display: block;
+ margin: 0;
+ width: 200px;
+ float: left;
+}
+/* 200px alt */
+.g-tpl-200-alt .g-unit,
+.g-unit .g-tpl-200-alt .g-unit,
+.g-unit .g-unit .g-tpl-200-alt .g-unit {
+ display: block;
+ margin: 0 200px 0 0;
+ width: auto;
+ float: none;
+}
+.g-unit .g-unit .g-tpl-200-alt .g-first,
+.g-unit .g-tpl-200-alt .g-first,
+.g-tpl-200-alt .g-first {
+ display: block;
+ margin: 0;
+ width: 200px;
+ float: right;
+}
+
+/* 190px */
+.g-tpl-190 .g-unit,
+.g-unit .g-tpl-190 .g-unit,
+.g-unit .g-unit .g-tpl-190 .g-unit {
+ display: block;
+ margin: 0 0 0 190px;
+ width: auto;
+ float: none;
+}
+.g-unit .g-unit .g-tpl-190 .g-first,
+.g-unit .g-tpl-190 .g-first,
+.g-tpl-190 .g-first {
+ display: block;
+ margin: 0;
+ width: 190px;
+ float: left;
+}
+/* 190px alt */
+.g-tpl-190-alt .g-unit,
+.g-unit .g-tpl-190-alt .g-unit,
+.g-unit .g-unit .g-tpl-190-alt .g-unit {
+ display: block;
+ margin: 0 190px 0 0;
+ width: auto;
+ float: none;
+}
+.g-unit .g-unit .g-tpl-190-alt .g-first,
+.g-unit .g-tpl-190-alt .g-first,
+.g-tpl-190-alt .g-first {
+ display: block;
+ margin: 0;
+ width: 190px;
+ float: right;
+}
+
+/* 180px */
+.g-tpl-180 .g-unit,
+.g-unit .g-tpl-180 .g-unit,
+.g-unit .g-unit .g-tpl-180 .g-unit {
+ display: block;
+ margin: 0 0 0 180px;
+ width: auto;
+ float: none;
+}
+.g-unit .g-unit .g-tpl-180 .g-first,
+.g-unit .g-tpl-180 .g-first,
+.g-tpl-180 .g-first {
+ display: block;
+ margin: 0;
+ width: 180px;
+ float: left;
+}
+/* 180px alt */
+.g-tpl-180-alt .g-unit,
+.g-unit .g-tpl-180-alt .g-unit,
+.g-unit .g-unit .g-tpl-180-alt .g-unit {
+ display: block;
+ margin: 0 180px 0 0;
+ width: auto;
+ float: none;
+}
+.g-unit .g-unit .g-tpl-180-alt .g-first,
+.g-unit .g-tpl-180-alt .g-first,
+.g-tpl-180-alt .g-first {
+ display: block;
+ margin: 0;
+ width: 180px;
+ float: right;
+}
+
+
+/* JQUERY RESIZABLE STYLES */
+.ui-resizable { position: relative; }
+.ui-resizable-handle { position: absolute; display: none; font-size: 0.1px; z-index:1; }
+.ui-resizable .ui-resizable-handle { display: block; }
+body .ui-resizable-disabled .ui-resizable-handle { display: none; }
+body .ui-resizable-autohide .ui-resizable-handle { display: none; }
+.ui-resizable-s { cursor: s-resize; height: 6px; width: 100%; bottom: 0px; left: 0px;
+ background: transparent url("images/resizable-s2.gif") repeat scroll center top; }
+.ui-resizable-e { cursor: e-resize; width: 6px; right: 0px; top: 0px; height: 100%;
+ background: transparent url("images/resizable-e2.gif") repeat scroll right center; }
+
+@media print {
+
+ body {
+ overflow:visible;
+ }
+
+ #header {
+ height:60px;
+ }
+
+ #headerLeft {
+ padding:0;
+ }
+
+ #header-tabs,
+ #headerRight,
+ #side-nav,
+ #api-info-block {
+ display:none;
+ }
+
+ #body-content {
+ position:inherit;
+ }
+
+ #doc-content {
+ margin-left:0 !important;
+ height:auto !important;
+ width:auto !important;
+ overflow:inherit;
+ display:inline;
+ }
+
+ #jd-header {
+ padding:10px 0;
+ }
+
+ #jd-content {
+ padding:15px 0 0;
+ }
+
+ #footer {
+ float:none;
+ margin:2em 0 0;
+ }
+
+ h4.jd-details-title {
+ border-bottom:1px solid #666;
+ }
+
+ pre {
+ /* these allow lines to break (if there's a white space) */
+ overflow: visible;
+ text-wrap: unrestricted;
+ white-space: -moz-pre-wrap; /* Moz */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ white-space: pre-wrap; /* CSS3 */
+ word-wrap: break-word; /* IE 5.5+ */
+ }
+
+ h1, h2, h3, h4, h5, h6 {
+ page-break-after: avoid;
+ }
+
+ table, img {
+ page-break-inside: avoid;
+ }
+}
diff --git a/tools/droiddoc/templates-ndk/assets/css/default.css b/tools/droiddoc/templates-ndk/assets/css/default.css
new file mode 100644
index 0000000000000000000000000000000000000000..036c0eb378a778b817102143d7da141c4d020dce
--- /dev/null
+++ b/tools/droiddoc/templates-ndk/assets/css/default.css
@@ -0,0 +1,7440 @@
+/* color definitions */
+/* 16 column layout */
+/* clearfix idiom */
+/* common mixins */
+/* page layout + top-level styles */
+::selection {
+ background-color: #0099cc;
+ color: #fff; }
+::-webkit-selection {
+ background-color: #0099cc;
+ color: #fff; }
+::-moz-selection {
+ background-color: #0099cc;
+ color: #fff; }
+
+html, body {
+ height: 100%;
+ margin: 0;
+ padding: 0;
+ background-color:#F9F9F9;
+ -webkit-font-smoothing: antialiased;
+ /* prevent subpixel antialiasing, which thickens the text */
+ /* text-rendering: optimizeLegibility; */
+ /* turned off ligatures due to bug 5945455 */ }
+
+body {
+ color: #222;
+ font: 14px/19px Roboto, sans-serif;
+ font-weight: 400;
+ letter-spacing:.1;
+ padding:0 10px; }
+
+#page-container {
+ width: 940px;
+ margin: 0 40px; }
+
+#page-header {
+ height: 80px;
+ margin-bottom: 20px;
+ font-size: 48px;
+ line-height: 48px;
+ font-weight: 100;
+ padding-left: 10px; }
+ #page-header a {
+ display: block;
+ position: relative;
+ top: 20px;
+ text-decoration: none;
+ color: #555555 !important; }
+
+#main-row {
+ display: inline-block; }
+ #main-row:after {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden; }
+ * html #main-row {
+ height: 1px; }
+
+#page-footer {
+ margin-left: 190px;
+ margin-top: 80px;
+ color: #999999;
+ padding-bottom: 40px;
+ font-size: 12px;
+ line-height: 15px; }
+ #page-footer a {
+ color: #777777; }
+ #page-footer #copyright {
+ margin-bottom: 10px; }
+
+#nav-container {
+ width: 160px;
+ min-height: 10px;
+ margin-right: 20px;
+ float: left; }
+
+#nav {
+ margin:0;
+ padding:0 0 30px;
+}
+
+#side-nav {
+ min-height:5px; /* silly way to avoid doc floating left when nav goes fixed */
+ margin-bottom:1px;
+}
+#devdoc-nav {
+ outline:none;
+ width:auto;
+ margin: 20px 0 0; }
+
+#devdoc-nav h2 {
+ border:0;
+}
+
+#devdoc-nav.fixed {
+ position: fixed;
+ margin:0;
+ top: 65px; /* sticky-header height + 20px gutter */
+}
+
+#devdoc-nav span.small {
+ font-size:12px;
+ font-weight:normal;
+}
+
+#content {
+ width: 760px;
+ float: left; }
+
+a:hover,
+acronym:hover {
+ color: #7aa1b0 !important; }
+
+a:focus,
+a:active {
+ color: #33b5e5 !important; }
+
+a.external-link {
+ background:url('../images/styles/open_new_page.png') no-repeat 100% 50%;
+ padding-right:16px;
+}
+
+img {
+ border: none; }
+#jd-content img {
+ margin-bottom:15px;
+}
+
+ul {
+ margin: 0;
+ padding: 0; }
+
+strong {
+ font-weight: 500; }
+
+em {
+ font-style: italic; }
+
+acronym,
+.tooltip-link {
+ border-bottom: 1px dotted #555555;
+ cursor: help; }
+
+acronym:hover,
+.tooltip-link:hover {
+ color: #7aa1b0;
+ border-bottom-color: #7aa1b0; }
+
+img.with-shadow,
+video.with-shadow {
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25); }
+
+/* disclosures mixin */
+/* content layout */
+.layout-content-row {
+ display: inline-block;
+ margin-bottom: 10px; }
+ * html .layout-content-row {
+ height: 1px; }
+
+.layout-content-col {
+ float: left;
+ margin-left: 20px; }
+ .layout-content-col:first-child {
+ margin-left: 0; }
+ .layout-content-col h3,
+ .layout-content-col h4 {
+ margin-top:0; }
+
+.layout-content-col.span-1 {
+ width: 40px; }
+
+.layout-content-col.span-2 {
+ width: 100px; }
+
+.layout-content-col.span-3 {
+ width: 160px; }
+
+.layout-content-col.span-4 {
+ width: 220px; }
+
+.layout-content-col.span-5 {
+ width: 280px; }
+
+.layout-content-col.span-6 {
+ width: 340px; }
+
+.layout-content-col.span-7 {
+ width: 400px; }
+
+.layout-content-col.span-8 {
+ width: 460px; }
+
+.layout-content-col.span-9 {
+ width: 520px; }
+
+.layout-content-col.span-10 {
+ width: 580px; }
+
+.layout-content-col.span-11 {
+ width: 640px; }
+
+.layout-content-col.span-12 {
+ width: 700px; }
+
+.layout-content-col.span-13 {
+ width: 760px; }
+
+.vspace.size-1 {
+ height: 10px; }
+
+.vspace.size-2 {
+ height: 20px; }
+
+.vspace.size-3 {
+ height: 30px; }
+
+.vspace.size-4 {
+ height: 40px; }
+
+.vspace.size-5 {
+ height: 50px; }
+
+.vspace.size-6 {
+ height: 60px; }
+
+.vspace.size-7 {
+ height: 70px; }
+
+.vspace.size-8 {
+ height: 80px; }
+
+.vspace.size-9 {
+ height: 90px; }
+
+.vspace.size-10 {
+ height: 100px; }
+
+.vspace.size-11 {
+ height: 110px; }
+
+.vspace.size-12 {
+ height: 120px; }
+
+.vspace.size-13 {
+ height: 130px; }
+
+.vspace.size-14 {
+ height: 140px; }
+
+.vspace.size-15 {
+ height: 150px; }
+
+.vspace.size-16 {
+ height: 160px; }
+
+/* nav */
+#nav {
+ /* section header divs */
+ /* expanded section header divs */
+ /* sublinks */ }
+ #nav li {
+ list-style-type: none;
+ font-size: 14px;
+ margin:0;
+ padding:0;
+ line-height: 15px; }
+ #nav a {
+ color: #555555;
+ text-decoration: none;
+ word-wrap:break-word; }
+ #nav .nav-section-header {
+ position: relative;
+ margin-bottom: 1px;
+ padding: 0 30px 0 0; }
+ #nav li.selected a, #nav li.selected > .nav-section-header > a {
+ color: #09C;
+ }
+ #nav li.selected ul li a {
+ /* don't highlight child items */
+ color: #555555; }
+ #nav .nav-section .nav-section .nav-section-header {
+ /* no white line between second level sections */
+ margin-bottom: 0; }
+ /* section header links */
+ #nav > li > div > a {
+ display: block;
+ color: #333333;
+ font-weight: 500;
+ padding: 10px 0 10px 10px; }
+ #nav .nav-section-header:after {
+ content: '';
+ background: transparent url(../images/styles/disclosure_down.png) no-repeat scroll 50% 50%;
+ width: 34px;
+ height: 34px;
+ display: block;
+ position: absolute;
+ top: 0;
+ right: 0; }
+ #nav .nav-section-header.empty {
+ padding:0; }
+ #nav .nav-section-header.empty:after {
+ display: none; }
+ /* nested nav headers */
+ #nav .nav-section .nav-section {
+ position: relative;
+ padding: 0;
+ margin: 0; }
+ #nav .nav-section li a {
+ /* first gen child (2nd level li) */
+ display:block;
+ font-weight: normal;
+ text-transform: none;
+ padding: 7px 5px 7px 10px;
+ }
+ #nav .nav-section li li a {
+ /* second gen child (3rd level li) */
+ padding: 5px 5px 5px 10px;
+ }
+ #nav li.expanded .nav-section-header {
+ background:#e9e9e9;
+ background: rgba(0, 0, 0, 0.05); }
+ #nav li.expanded li .nav-section-header {
+ background: transparent; }
+ #nav li.expanded li ul {
+ /* 3rd level ul */
+ padding:0 0 0 10px;
+ }
+ #nav li.expanded > .nav-section-header:after {
+ content: '';
+ background: transparent url(../images/styles/disclosure_up.png) no-repeat scroll 50% 50%;
+ width: 34px;
+ height: 34px; }
+ #nav li.expanded li ul.tree-list-children {
+ padding: 0;
+ }
+ #nav li.expanded li ul.tree-list-children .tree-list-children {
+ padding:0 0 0 10px;
+ }
+ #nav li span.tree-list-subtitle {
+ display:inline-block;
+ padding:5px 0 0 10px;
+ color:#555;
+ text-transform:uppercase;
+ font-size:12px;
+ }
+ #nav li span.tree-list-subtitle:before {
+ content: '—';
+ }
+ #nav li span.tree-list-subtitle:after {
+ content: '—';
+ }
+ #nav li span.tree-list-subtitle.package {
+ padding-top:15px;
+ cursor:default;
+ }
+ #nav li span.tree-list-subtitle.package:before {
+ content: '';
+ }
+ #nav li span.tree-list-subtitle.package:after {
+ content: '';
+ }
+ #nav li ul.tree-list-children.classes {
+ padding-left:10px;
+ }
+ #nav li ul {
+ display:none;
+ overflow: hidden;
+ margin: 0; }
+ #nav li ul.animate-height-in {
+ -webkit-transition: height 0.25s ease-in;
+ -moz-transition: height 0.25s ease-in;
+ transition: height 0.25s ease-in; }
+ #nav li ul.animate-height-out {
+ -webkit-transition: height 0.25s ease-out;
+ -moz-transition: height 0.25s ease-out;
+ transition: height 0.25s ease-out; }
+ #nav li ul li {
+ padding: 0; }
+ #nav li li li {
+ padding: 0; }
+ #nav li.expanded ul {
+ }
+ #nav li ul > li {
+ padding:0;
+ }
+ #nav li ul > li:last-child {
+ padding-bottom:5px;
+ }
+ #nav li ul.tree-list-children > li:last-child {
+ padding-bottom:0;
+ }
+ #nav li.expanded ul > li {
+ background:#efefef;
+ background: rgba(0, 0, 0, 0.03); }
+ #nav li.expanded ul > li li {
+ background:inherit; }
+ #nav li ul.tree-list-children ul {
+ display:block; }
+
+#nav.samples-nav li li li {
+ font-size:13px;
+}
+#nav.samples-nav li li li a {
+ padding-top:3px;
+ padding-bottom:3px;
+}
+#nav.samples-nav li li ul > li:last-child {
+ padding-bottom:3px;
+}
+
+.new,
+.new-child {
+ font-size: .78em;
+ font-weight: bold;
+ color: #ff3d3d;
+ vertical-align:top;
+ white-space:nowrap;
+}
+
+/* content header */
+.content-header {
+ height: 30px;
+ margin:36px 0 23px; /* same as h1 */
+ padding:0 0 10px;} /* same as h1 */
+.content-header.just-links {
+ margin-bottom:0;
+ padding-bottom:0;}
+
+.content-header h1 {
+ margin:0;
+ padding:0;
+ width: 700px;
+}
+.content-header > div:first-child {
+ height:1px; /* set fixed height for the header div to ensure the
+ next/prev links align with toc on training classes */
+}
+
+.content-footer {
+ border-top: 1px solid #ccc;
+ margin-top: 10px;
+ padding-top:10px;
+ width:100%; }
+
+.content-footer .col-9 {
+ margin-left:0;
+}
+.content-footer .col-4 {
+ margin-right:0;
+}
+.content-footer.wrap {
+ width:940px;
+}
+.content-footer .plus-container {
+ margin:5px 0 0;
+ text-align:right;
+ float:right;
+}
+
+a.back-link {
+ text-decoration: none;
+ text-transform: uppercase;
+}
+
+.content-header .paging-links {
+ margin-top:-25px;
+}
+.paging-links {
+ position: relative;
+ height:30px; }
+ .paging-links a {
+ position: absolute; }
+ .paging-links a,
+ .training-nav-top a {
+ color: #555555;
+ text-decoration: none;
+ text-transform: uppercase; }
+ .paging-links .prev-page-link:before,
+ .training-nav-top .prev-page-link:before,
+ a.back-link:before {
+ content: '';
+ background: transparent url(../images/styles/disclosure_left.png) no-repeat scroll 50% 50%;
+ width: 10px;
+ height: 10px;
+ display: inline-block;
+ margin-right: 5px; }
+ .training-nav-top .next-page-link,
+ .training-nav-top .start-class-link,
+ .training-nav-top .start-course-link {
+ right: 10px; }
+ .paging-links .prev-page-link {
+ left: -15px; }
+ .paging-links .next-page-link {
+ right: 0; }
+ .next-page-link:after,
+ .start-class-link:after,
+ .start-course-link:after,
+ .next-class-link:after,
+ .go-link:after {
+ content: '';
+ background: transparent url(../images/styles/disclosure_right.png) no-repeat scroll 50% 50%;
+ width: 10px;
+ height: 10px;
+ display: inline-block;
+ margin-left: 5px; }
+ .prev-page-link.inline:before {
+ content: none; }
+ .next-page-link.inline:after {
+ content: none; }
+
+ .content-footer .paging-links .next-page-link {
+ left:0;
+ }
+
+ .training-nav-top a {
+ display:block;
+ float:left;
+ width:122px;
+ height:28px;
+ padding: 8px;
+ line-height:28px;
+ text-align:center;
+ border:1px solid #DADADA;
+ border-bottom:0;
+ }
+
+ .training-nav-top a.next-page-link {
+ border-left:0;
+ width:123px;
+ }
+
+ .paging-links a.disabled,
+ .training-nav-top a.disabled,
+ .content-footer a.disabled {
+ color:#bbb;
+ }
+
+ .paging-links a.disabled:hover,
+ .training-nav-top a.disabled:hover,
+ .content-footer a.disabled:hover {
+ cursor:default;
+ color:#bbb !important;
+ }
+
+ .training-nav-top a.start-class-link,
+ .training-nav-top a.start-course-link {
+ width:262px;
+ }
+
+ .paging-links a.start-class-link {
+ width:100%;
+ }
+
+ /* list of classes on course landing page */
+ ol.class-list {
+ list-style:none;
+ margin-left:0;
+ }
+ ol.class-list>li {
+ margin:0 0 15px;
+ padding:5px 0 0;
+ overflow:hidden;
+ border-top:1px solid #ccc;
+ }
+ ol.class-list li a.title {
+ font-size:16px;
+ margin:0;
+ clear:left;
+ display:block;
+ height:32px;
+ padding:0 4px;
+ }
+ ol.class-list li a.title h2 {
+ color:inherit;
+ margin:0 0 10px;
+ display:block;
+ float:left;
+ width:675px;
+ }
+ ol.class-list li a.title span {
+ display:none;
+ float:left;
+ font-size:18px;
+ font-weight:bold;
+ background: transparent url(../images/styles/disclosure_right.png) no-repeat scroll 50% 50%;
+ width: 10px;
+ height: 32px;
+ }
+ ol.class-list li a.title:hover {
+ background:#ddd;
+ color:#258AAF !important;
+ }
+ ol.class-list li a.title:hover span {
+ display:block;
+ }
+
+ #jd-content
+ ol.class-list li img {
+ float:left;
+ clear:left;
+ width:64px;
+ margin:0 20px 0 0;
+ }
+ ol.class-list li p.description {
+ float:left;
+ display:block;
+ width:250px;
+ margin:0;
+ }
+ ol.class-list li p.description.article {
+ width: 550px;
+ }
+ ol.class-list ol {
+ float:left;
+ width:320px;
+ margin:0 0 0 30px;
+ list-style:none;
+ margin:0 0 0 20px;
+ }
+ ol.class-list div.lessons li {
+ margin:0 0 6px;
+ line-height:16px;
+ }
+
+
+ .hide {
+ display:none !important;
+ }
+
+
+
+ /* inner-doc tabs w/ title */
+
+div#title-tabs-wrapper {
+ border-bottom:1px solid #ccc;
+ margin:20px 0 30px;
+}
+h1.with-title-tabs {
+ display:inline-block;
+ margin:0 0 -1px 0;
+ padding:0 60px 0 0;
+ border-bottom:1px solid #F9F9F9;
+}
+ul#title-tabs {
+ list-style:none;
+ padding:0;
+ height:29px;
+ margin:0;
+ font-size:16px;
+ line-height:26px;
+ display:inline-block;
+ vertical-align:bottom;
+}
+ul#title-tabs li {
+ display:block;
+ float:left;
+ margin-right:40px;
+ border-bottom: 3px solid transparent;
+}
+ul#title-tabs li.selected {
+ border-bottom: 3px solid #93C;
+}
+ul#title-tabs li a {
+ color:#333;
+}
+ul#title-tabs li a:hover,
+ul#title-tabs li a:active {
+ color:#93C !important;
+}
+
+
+
+/* content body */
+@-webkit-keyframes glowheader {
+ from {
+ background-color: #33b5e5;
+ color: #000;
+ border-bottom-color: #000; }
+
+ to {
+ background-color: transparent;
+ color: #33b5e5;
+ border-bottom-color: #33b5e5; } }
+
+@-moz-keyframes glowheader {
+ from {
+ background-color: #33b5e5;
+ color: #000;
+ border-bottom-color: #000; }
+
+ to {
+ background-color: transparent;
+ color: #33b5e5;
+ border-bottom-color: #33b5e5; } }
+
+@keyframes glowheader {
+ from {
+ background-color: #33b5e5;
+ color: #000;
+ border-bottom-color: #000; }
+
+ to {
+ background-color: transparent;
+ color: #33b5e5;
+ border-bottom-color: #33b5e5; } }
+
+h1:target,
+h2:target,
+h3:target {
+ -webkit-animation-name: glowheader;
+ -moz-animation-name: glowheader;
+ animation-name: glowheader;
+ -webkit-animation-duration: 0.7s;
+ -moz-animation-duration: 0.7s;
+ animation-duration: 0.7s;
+ -webkit-animation-timing-function: ease-out;
+ -moz-animation-timing-function: ease-out;
+ animation-timing-function: ease-out; }
+
+.design ol h4 {
+ margin-bottom:0;
+}
+.design ol {
+ counter-reset: item; }
+ .design ol>li {
+ font-size: 14px;
+ line-height: 20px;
+ list-style-type: none;
+ position: relative; }
+ .design ol>li:before {
+ content: counter(item) ". ";
+ counter-increment: item;
+ position: absolute;
+ left: -20px;
+ top: 0; }
+ .design ol li.value-1:before {
+ content: "1. "; }
+ .design ol li.value-2:before {
+ content: "2. "; }
+ .design ol li.value-3:before {
+ content: "3. "; }
+ .design ol li.value-4:before {
+ content: "4. "; }
+ .design ol li.value-5:before {
+ content: "5. "; }
+ .design ol li.value-6:before {
+ content: "6. "; }
+ .design ol li.value-7:before {
+ content: "7. "; }
+ .design ol li.value-8:before {
+ content: "8. "; }
+ .design ol li.value-9:before {
+ content: "9. "; }
+ .design ol li.value-10:before {
+ content: "10. "; }
+.design .with-callouts ol>li {
+ list-style-position: inside;
+ margin-left: 0; }
+ .design .with-callouts ol>li:before {
+ display: inline;
+ left: -20px;
+ float: left;
+ width: 17px;
+ color: #33b5e5;
+ font-weight: 500; }
+.design .with-callouts ul>li {
+ list-style-position: outside; }
+
+/* special list items */
+li.no-bullet {
+ list-style-type: none !important; }
+li.no-bullet *{
+ margin:0; }
+
+.design li.with-icon {
+ position: relative;
+ margin-left: 20px;
+ min-height: 30px; }
+ .design li.with-icon p {
+ margin-left: 0 !important; }
+ .design li.with-icon:before {
+ position: absolute;
+ left: -40px;
+ top: 0;
+ content: '';
+ width: 30px;
+ height: 30px; }
+ .design li.with-icon.tablet:before {
+ background-image: url(../images/styles/ico_phone_tablet.png); }
+ .design li.with-icon.web:before {
+ background-image: url(../images/styles/ico_web.png); }
+ .design li.with-icon.action:before {
+ background-image: url(../images/styles/ico_action.png); }
+ .design li.with-icon.use:before {
+ background-image: url(../images/styles/ico_use.png); }
+
+/* figures and callouts */
+.figure {
+ position: relative; }
+ .figure.pad-below {
+ margin-bottom: 20px; }
+ .figure .figure-callout {
+ position: absolute;
+ color: #fff;
+ font-weight: 500;
+ font-size: 16px;
+ line-height: 23px;
+ text-align: center;
+ background: transparent url(../images/styles/callout.png) no-repeat scroll 50% 50%;
+ padding-right: 2px;
+ width: 30px;
+ height: 29px;
+ z-index: 1000; }
+ .figure .figure-callout.top {
+ top: -9px; }
+ .figure .figure-callout.right {
+ right: -5px; }
+
+.figure-caption {
+ margin: 0 10px 20px 0;
+ font-size: 14px;
+ line-height: 20px;
+ font-style: italic; }
+
+/* rows of figures */
+.figure-row {
+ font-size: 0;
+ line-height: 0;
+ /* to prevent space between figures */ }
+ .figure-row .figure {
+ display: inline-block;
+ vertical-align: top; }
+ .figure-row .figure + .figure {
+ margin-left: 10px;
+ /* reintroduce space between figures */ }
+
+/* video containers */
+.framed-galaxynexus-land-span-13 {
+ background: transparent url(../images/styles/device_galaxynexus_blank_land_span13.png) no-repeat
+scroll top left;
+ padding: 42px 122px 62px 126px;
+ overflow: hidden; }
+ .framed-galaxynexus-land-span-13, .framed-galaxynexus-land-span-13 video,
+.framed-galaxynexus-land-span-13 img {
+ width: 512px;
+ height: 286px; }
+
+
+.framed-galaxynexus-land-span-8{
+ background: transparent url(../images/styles/device_galaxynexus_blank_land_span8.png) no-repeat
+scroll top left;
+ padding: 26px 68px 38px 72px;
+ overflow: hidden; }
+ .framed-galaxynexus-land-span-8, .framed-galaxynexus-land-span-8 video,
+.framed-galaxynexus-land-span-8 img {
+ width: 320px;
+ height: 180px; }
+
+.framed-galaxynexus-port-span-9 {
+ background: transparent url(../images/styles/device_galaxynexus_blank_port_span9.png) no-repeat
+scroll top left;
+ padding: 95px 122px 107px 124px;
+ overflow: hidden; }
+ .framed-galaxynexus-port-span-9, .framed-galaxynexus-port-span-9 video,
+.framed-galaxynexus-port-span-9 img {
+ width: 274px;
+ height: 488px; }
+
+.framed-galaxynexus-port-span-5 {
+ background: transparent url(../images/styles/device_galaxynexus_blank_port_span5.png) no-repeat
+scroll top left;
+ padding: 75px 31px 76px 33px;
+ overflow: hidden; }
+ .framed-galaxynexus-port-span-5, .framed-galaxynexus-port-span-5 video,
+.framed-galaxynexus-port-span-5 img {
+ width: 216px;
+ height: 384px; }
+
+.framed-nexus4-port-216 {
+ background: transparent url(../images/styles/device_nexus4_blank_port_432.png) no-repeat
+scroll top left;
+ background-size:240px 465px;
+ padding: 52px 12px 52px 12px;
+ overflow: hidden; }
+ .framed-nexus4-port-216, .framed-nexus4-port-216 video,
+ .framed-nexus4-port-216 img {
+ width: 216px;
+ height: 360px; }
+
+.framed-nexus5-port-span-5 {
+ background: transparent url(../images/styles/device_nexus5_blank_port_span5.png) no-repeat
+ scroll top left;
+ padding: 52px 33px 69px 31px;
+ overflow: hidden;
+}
+
+.framed-nexus5-port-span-5,
+.framed-nexus5-port-span-5 video,
+.framed-nexus5-port-span-5 img {
+ width: 216px;
+ height: 384px;
+}
+
+.framed-nexus5-land-span-13 {
+ background: transparent url(../images/styles/device_nexus5_blank_land_span13.png) no-repeat scroll top left;
+ padding: 36px 119px 54px 108px;
+ overflow: hidden;
+}
+
+.framed-nexus5-land-span-13,
+.framed-nexus5-land-span-13 video,
+.framed-nexus5-land-span-13 img {
+ width: 533px;
+ height: 300px;
+}
+
+.framed-nexus5-port-span-5,
+.framed-nexus5-port-span-5 video,
+.framed-nexus5-port-span-5 img {
+ width: 216px;
+ height: 384px;
+}
+
+/* wear device frames */
+
+.framed-wear-square {
+ background: transparent url(../images/styles/device_wear_square.png) no-repeat scroll top left;
+ background-size: 302px 302px;
+ height:222px;
+ width:222px;
+ padding:40px;
+ overflow:hidden;
+}
+
+.framed-wear-square-small {
+ background: transparent url(../images/styles/device_wear_square_small.png) no-repeat scroll top left;
+ background-size: 169px 200px;
+ height:147px;
+ width:147px;
+ padding:27px 11px;
+ overflow:hidden;
+}
+
+#jd-content
+.framed-wear-square img {
+ height:222px;
+ width: 222px;
+ padding:0;
+ margin:0;
+}
+
+#jd-content
+.framed-wear-square-small img {
+ height:147px;
+ width: 147px;
+ padding:0;
+ margin:0;
+}
+
+
+
+
+
+
+/* landing page disclosures */
+.landing-page-link {
+ text-decoration: none;
+ font-weight: 500;
+ color: #333333; }
+ .landing-page-link:after {
+ content: '';
+ background: transparent url(../images/styles/disclosure_right.png) no-repeat scroll 50% 50%;
+ width: 10px;
+ height: 10px;
+ display: inline-block;
+ margin-left: 5px; }
+
+/* tooltips */
+.tooltip-box {
+ position: absolute;
+ background-color: rgba(0, 0, 0, 0.9);
+ border-radius: 2px;
+ font-size: 14px;
+ line-height: 20px;
+ color: #fff;
+ padding: 6px 10px;
+ max-width: 250px;
+ z-index: 10000; }
+ .tooltip-box.below:after {
+ position: absolute;
+ content: '';
+ line-height: 0;
+ display: block;
+ top: -10px;
+ left: 5px;
+ border: 5px solid transparent;
+ border-bottom-color: rgba(0, 0, 0, 0.9); }
+
+/* video note */
+.video-instructions {
+ margin-top: 10px;
+ margin-bottom: 10px; }
+ .video-instructions:before {
+ content: '';
+ background: transparent url(../images/styles/ico_movie_inline.png) no-repeat scroll top left;
+ display: inline-block;
+ width: 12px;
+ height: 12px;
+ margin-right: 8px; }
+ .video-instructions:after {
+ content: 'Click device screen to replay movie.'; }
+
+/* download buttons */
+.download-button {
+ display: block;
+ margin-bottom: 5px;
+ text-decoration: none;
+ background-color: #33b5e5;
+ color: #fff !important;
+ font-weight: 500;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
+ padding: 6px 12px;
+ border-radius: 2px; }
+ .download-button:hover, .download-button:focus {
+ background-color: #0099cc;
+ color: #fff !important; }
+ .download-button:active {
+ background-color: #006699; }
+
+/* UI tables and other things found in Writing style and Settings pattern */
+.ui-table {
+ width: 100%;
+ background-color: #282828;
+ color: #fff;
+ border-radius: 2px;
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
+ border-collapse: separate; }
+ .ui-table th,
+ .ui-table td {
+ padding: 5px 10px;
+ background-color: inherit;
+ border:0;}
+ .ui-table thead th {
+ font-weight: bold; }
+ .ui-table tfoot td {
+ border-top: 1px solid #494949;
+ border-right: 1px solid #494949;
+ text-align: center; }
+ .ui-table tfoot td:last-child {
+ border-right: 0; }
+
+.layout-with-list-item-margins {
+ margin-left: 30px !important; }
+
+.emulate-content-left-padding {
+ margin-left: 10px; }
+
+.do-dont-label {
+ margin-bottom: 10px;
+ padding-left: 20px;
+ background: transparent none no-repeat scroll 0px 3px; }
+ .do-dont-label.bad {
+ background-image: url(../images/styles/ico_wrong.png); }
+ .do-dont-label.good {
+ background-image: url(../images/styles/ico_good.png); }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/***** PREVIOUSLY style.css ******************/
+
+
+
+
+
+@media screen, projection, print {
+[dir='rtl'] {
+ direction: rtl;
+}
+html {
+ line-height: 20px;
+}
+pre, table, input, textarea, code {
+ font-size: 1em;
+}
+address, abbr, cite {
+ font-style: normal;
+}
+[dir='rtl'] th {
+ text-align: right;
+}
+html[lang^=ja] blockquote, html[lang^=ja] q, html[lang^=ko] blockquote, html[lang^=ko] q,
+html[lang^=zh] blockquote, html[lang^=zh] q {
+ font-style: normal;
+}
+q {
+ font-style: italic;
+}
+fieldset, iframe, img {
+ border: 0;
+}
+img {
+ -ms-interpolation-mode: bicubic;
+ vertical-align: middle;
+ max-width: 100%;
+}
+q {
+ quotes: none;
+}
+sup, sub {
+ font-size: 11px;
+ line-height: 0;
+}
+}
+
+@media screen, projection {
+
+table, fieldset {
+ margin: 0;
+}
+h1 {
+ color:#333;
+ font-size: 34px;
+ margin: 36px 0 27px;
+ padding:0 0 10px;
+ font-weight:300;
+}
+h1, h2 {
+ line-height: 30px;
+}
+h1.short {
+ margin-right:320px;
+}
+h1.short {
+ margin-right:320px;
+}
+h1.super {
+ font-size: 37px;
+}
+h2 {
+ color:#333;
+ font-size: 26px;
+ margin: 32px 0 20px;
+ padding:0;
+ font-weight:300;
+}
+h3 {
+ color:#333;
+ font-size: 21px;
+ font-weight:400;
+ margin:21px 0 14px 0;
+}
+h3, h4 {
+ line-height: 21px;
+}
+h4 {
+ font-size: 18px;
+ margin: 12px 0;
+ font-weight:500;
+}
+h5 {
+ font-size: 14px;
+}
+h5, h6 {
+ margin: 5px 0;
+}
+h6 {
+ font-size: 12px;
+}
+hr { /* applied to the bottom of h2 elements */
+ height: 1px;
+ margin: 3px 0 12px;
+ border: 0;
+ background: #ccc;
+}
+p, pre, table, form {
+ margin: 0 0 15px;
+}
+small {
+ font-size: 11.5px;
+ color: #000;
+}
+ul, ol {
+ margin: 0 0 15px 18px;
+ padding: 0;
+}
+[dir='rtl'] ul, [dir='rtl'] ol {
+ margin: 10px 30px 10px 10px;
+}
+ul ul, ul ol, ol ul, ol ol {
+ margin-bottom: 0;
+ margin-top: 0;
+}
+li {
+ margin:0 0 5px;
+}
+dd {
+ margin:0 0 10px 30px;
+}
+dd p,
+dd pre,
+dd ul,
+dd ol,
+dd dl {
+ margin-top:10px;
+}
+li p,
+li pre,
+li ul,
+li ol,
+li dl {
+ margin-top:5px;
+ margin-bottom:5px;
+}
+dl dd dl:first-child {
+ margin-top:0;
+}
+pre strong, pre b, a strong, a b, a code {
+ color: inherit;
+}
+pre, code {
+ color: #060;
+ font: 13px/1.5 monospace;
+}
+code {
+ font-weight:bold;
+ font: 13px/14px monospace;
+}
+
+legend {
+ display: none;
+}
+a:link, a:visited, .link-color {
+ color: #258aaf;
+ text-decoration: none;
+}
+a:focus, a:hover, a:active {
+ color: #33B5E5;
+ text-decoration: none;
+}
+a.white {
+ color: #fff;
+ text-decoration:underline;
+}
+a.white:hover, a.white:active {
+ color: #ccc !important;
+}
+strong, b {
+ font-weight:bold;
+ color: #222;
+}
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+ border:0;
+ margin: .5em 1em 1em 0;
+ width:100%; /* consistent table widths; within IE's quirks */
+ background-color:#f7f7f7;
+}
+th, td {
+ padding: 4px 12px;
+ vertical-align: top;
+ text-align: left;
+}
+td {
+ background-color:inherit;
+ border:solid 1px #DDD;
+}
+td *:last-child {
+ margin-bottom:0;
+}
+th {
+ background-color: #999;
+ color: #fff;
+ border:solid 1px #DDD;
+ font-weight: normal;
+}
+tr:first-of-type th:first-of-type:empty {
+ visibility: hidden;
+}
+
+/* --------------------------------------------------------------------------
+Footer
+*/
+.line {
+ clear: both;
+ background: #acbc00;
+ background: -moz-linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0, #acbc00),
+color-stop(50%, #acbc00), color-stop(50%, #bdde00), color-stop(100%, #bdde00));
+ background: -webkit-linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
+ background: -o-linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
+ background: -ms-linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
+ background: linear-gradient(top, #acbc00 0, #acbc00 50%, #bdde00 50%, #bdde00 100%);
+ height: 2px;
+ margin-top: 150px;
+ position: relative;
+ z-index: 11;
+}
+#footer {
+ font-size:11px;
+ clear: both;
+ color: #999;
+ padding: 15px 0;
+ margin-top:10px;
+ width:auto;
+}
+#footer-local ul {
+ list-style: none;
+ margin: 5px 0 30px 0;
+}
+#footer-local li {
+ display: inline;
+}
+#footer-local li+li:before {
+ content: '|';
+ padding: 0 3px;
+ color: #e5e5e5;
+}
+#footer-global {
+ padding: 10px 15px;
+ background: #f5f5f5;
+}
+#footer-global {
+ border-top: 1px solid #ebebeb;
+ font-size: 11.5px;
+ line-height: 1.8;
+ list-style: none;
+}
+#footer-global ul {
+ margin: 0;
+}
+#footer-global li {
+ display: inline;
+ font-weight: bold;
+}
+#footer-global li+li:before {
+ content: '¬?';
+ padding: 0 3px;
+}
+* html #footer-global li {
+ margin: 0 13px 0 0;
+}
+* [dir='rtl'] #footer-global li {
+ margin: 0 0 0 13px;
+}
+*+html #footer-global li {
+ margin: 0 13px 0 0;
+}
+*+[dir='rtl'] #footer-global li {
+ margin: 0 0 0 13px;
+}
+#footer-global li a {
+ font-weight: normal;
+}
+.locales {
+ margin: 10px 0 0 0px;
+}
+[dir='rtl'] .locales {
+ background-position: right center;
+ float: left;
+ padding: 0 24px 0 0;
+}
+.locales form {
+ margin: 0;
+}
+.locales select, .sites select {
+ line-height: 3.08;
+ margin: 0px 0;
+ border: solid 1px #EBEBEB;
+ -webkit-appearance: none;
+ background: white url('../images/arrows-up-down.png') right center no-repeat;
+ height: 30px;
+ color: #222;
+ line-height: normal;
+ padding: 5px;
+ width: 230px;
+}
+}
+
+/* =============================================================================
+ Print Only
+ ========================================================================== */
+@media print {
+ /* configure printed page */
+ @page {
+ margin: 0.75in 1in;
+ widows: 4;
+ orphans: 4;
+ }
+
+ /* reset spacing metrics */
+ html, body, .wrap {
+ margin: 0 !important;
+ padding: 0 !important;
+ width: auto !important;
+ }
+
+ /* leave enough space on the left for bullets */
+ body {
+ padding-left: 20px !important;
+ }
+ #doc-col {
+ margin-left: 0;
+ }
+
+ /* hide a bunch of non-content elements */
+ #header, #footer, #nav-x, #side-nav,
+ .training-nav-top, .training-nav-bottom,
+ #doc-col .content-footer,
+ .nav-x, .nav-y,
+ .paging-links {
+ display: none !important;
+ }
+
+ /* remove extra space above page titles */
+ #doc-col .content-header {
+ margin-top: 0;
+ }
+
+ /* bump up spacing above subheadings */
+ h2 {
+ margin-top: 40px !important;
+ }
+
+ /* print link URLs where possible and give links default text color */
+ p a:after {
+ content: " (" attr(href) ")";
+ font-size: 80%;
+ }
+ p a {
+ word-wrap: break-word;
+ }
+ a {
+ color: inherit;
+ }
+
+ /* syntax highlighting rules */
+ .str { color: #060; }
+ .kwd { color: #006; font-weight: bold; }
+ .com { color: #600; font-style: italic; }
+ .typ { color: #404; font-weight: bold; }
+ .lit { color: #044; }
+ .pun { color: #440; }
+ .pln { color: #000; }
+ .tag { color: #006; font-weight: bold; }
+ .atn { color: #404; }
+ .atv { color: #060; }
+}
+
+/* =============================================================================
+ Columns
+ ========================================================================== */
+
+@media screen, projection, print {
+.full {
+ padding: 2.5em 0;
+ border-top: solid 1px #ddd;
+ border-bottom: solid 1px #ddd;
+ background: #f7f7f7;
+}
+.wrap {
+ margin: 0 auto;
+ width: 940px;
+ clear: both;
+}
+.cols {
+ height: 1%;
+ margin: 0 -1.533742331288343558282%;
+ width: 103.06748466257669%}
+*+html .cols {
+ margin-bottom: 20px;
+}
+.cols:after {
+ clear: both;
+ content: ' ';
+ display: block;
+ height: 0;
+ visibility: hidden;
+}
+.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12,
+.col-13, .col-14, .col-15, .col-16 {
+ display: inline;
+ float: left;
+ margin-left: 10px;
+ margin-right: 10px;
+}
+/*
+* html .col-1, * html .col-2, * html .col-3, * html .col-4, * html .col-5, * html .col-6, * html
+.col-7, * html .col-8, * html .col-9, * html .col-10, * html .col-11, * html .col-12 {
+ margin: 0;
+ padding: 0 1.4% 20px;
+}
+[dir='rtl'] .col-1, [dir='rtl'] .col-2, [dir='rtl'] .col-3, [dir='rtl'] .col-4, [dir='rtl'] .col-5,
+[dir='rtl'] .col-6, [dir='rtl'] .col-7, [dir='rtl'] .col-8, [dir='rtl'] .col-9, [dir='rtl'] .col-10,
+[dir='rtl'] .col-11, [dir='rtl'] .col-12 {
+ float: right;
+}
+*/
+.col-1 { width: 40px }
+.col-2 { width: 100px }
+.col-3 { width: 160px }
+.col-4 { width: 220px }
+.col-5 { width: 280px }
+.col-6 { width: 340px }
+.col-7 { width: 400px }
+.col-8 { width: 460px }
+.col-9 { width: 520px }
+.col-10 { width: 580px }
+.col-11 { width: 640px }
+.col-12 { width: 700px }
+.col-13 { width: 760px }
+.col-14 { width: 820px }
+.col-15 { width: 880px }
+.col-16 { width: 940px }
+}
+
+.col-right {
+ margin-right:0px;
+}
+
+@media screen and (max-width:772px) {
+.col-5, .col-6, .col-7 {
+ clear: both;
+ width: 97.0238096%}
+}
+
+/* =============================================================================
+ Layout
+ ========================================================================== */
+@media screen, projection, print {
+
+/* --------------------------------------------------------------------------
+Header, Login, Nav-X, Search
+*/
+#header {
+ margin: 0;
+ padding: 0;
+}
+#header:before, #header:after {
+ content: "";
+ display: table;
+ clear: both
+}
+.logo, .nav-x {
+ float: left;
+}
+.nav-x {
+ margin-top: -2px;
+ list-style-type: none;
+}
+.nav-x a {
+ color: #333;
+ font-size: 16px;
+}
+.about a.selected {
+ color: #9933CC;
+}
+.design a.selected {
+ color: #33b5e5;
+}
+.develop a.selected {
+ color: #F80;
+}
+.distribute a.selected {
+ color: #9C0;
+}
+
+
+
+.nav-x li {
+ display: inline;
+ margin-right: 45px;
+}
+.search {
+ float: right;
+ position: relative;
+ width: 220px
+}
+.search .bottom, .search .left, .search .right {
+ position: absolute;
+ background-color: #a3a3a3;
+}
+.search .bottom {
+ width: 220px;
+ height: 1px;
+ top: 24px;
+ left: 0
+}
+.search .left, .search .right {
+ height: 5px;
+ width: 1px
+}
+.search .left { top: 19px; left: 0 }
+.search .right { top: 19px; right: 0 }
+.search form {
+ float: left;
+ margin-top: 2px;
+ width: inherit;
+}
+.search .close,
+#player-frame .close {
+ position: absolute;
+ right: 8px;
+ bottom: 4px;
+ width: 16px;
+ height: 16px;
+ margin: 0;
+ text-indent: -1000em;
+ background: url(../images/close.png) no-repeat 0 0;
+ z-index:9999;
+}
+.search .close:hover, .search .close:focus,
+#player-frame .close:hover, #player-frame .close:focus {
+ background-position: -16px 0;
+ cursor:pointer;
+}
+#player-frame .close {
+ top: 6px;
+}
+.search form input {
+ color: #999;
+ font-size: 1em;
+ width: inherit;
+ border: none;
+ margin: 0;
+ padding:0 0 0 6px;
+ z-index: 1500;
+ background-color: transparent
+}
+.search:hover .bottom, .search:hover .left, .search:hover .right {
+ background-color: #33b5e5;
+}
+.search:hover .icon {
+ background-position: -8px 0
+}
+.search form input:focus {
+ color: #222;
+ font-weight: bold;
+ outline:0;
+}
+/* Search Dropdown */
+.search-dropdown {
+ padding: 15px;
+ width: 192px;
+ border: solid 1px #c5c5c5;
+ background: #fff;
+ position: absolute;
+ top: 35px;
+ left: 0;
+ -moz-box-shadow: 0 0 10px rgba(0,0,0,0.2);
+ -webkit-box-shadow: 0 0 10px rgba(0,0,0,0.2);
+ box-shadow: 0 0 10px rgba(0,0,0,0.2)
+}
+.search-dropdown ul, .search-dropdown ul li {
+ list-style-type: none;
+ margin: 0;
+ padding: 0
+}
+.search-dropdown ul li {
+ clear: both
+}
+.search-dropdown img {
+ float: left;
+ margin: 0 10px 10px 0
+}
+.search-dropdown h6 {
+ color: #222;
+ margin: 0;
+ line-height: normal
+}
+.search-dropdown .desc {
+ color: #999;
+ font-size: 11.5px;
+ line-height: normal;
+ margin: 0;
+}
+.search-dropdown li a:hover h6, .search-dropdown li a:hover .desc {
+ color: #33b5e5
+}
+/* --------------------------------------------------------------------------
+Buttons
+*/
+.button, a.button, .button-secondary, a.button-secondary {
+ border-image: initial;
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+ cursor: pointer;
+}
+.button, a.button {
+ display:inline-block;
+ background-color: #09c;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#2faddb), to(#09c));
+ background-image: -webkit-linear-gradient(top, #2faddb, #09c);
+ background-image: -moz-linear-gradient(top, #2faddb, #09c);
+ background-image: -ms-linear-gradient(top, #2faddb, #09c);
+ background-image: -o-linear-gradient(top, #2faddb, #09c);
+ background-image: linear-gradient(top, #2faddb, #09c);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#2faddb', EndColorStr='#0099cc',GradientType=0);
+ border: 1px solid #3990ab;
+ color: #fff;
+}
+.button-secondary, a.button-secondary {
+ background-color: #f3f3f3;
+ border: 1px solid #dcdcdc;
+ color: #444;
+}
+a.button, a.button:visited, a.button-secondary, a.button-secondary:visited {
+ margin-right: 16px;
+ font-weight: 400;
+ min-width: 54px;
+ outline: 0;
+ padding: 8px 15px;
+ text-align: center;
+}
+.button, .button-secondary {
+ margin-right: 16px;
+ font-weight: 400;
+ min-width: 54px;
+ outline: 0;
+ padding: 0 15px;
+ text-align: center;
+}
+.button:hover, a.button:hover {
+ border-color: #09c;
+ background-color: #4cadcb;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#5dbcd9), to(#4cadcb));
+ background-image: -webkit-linear-gradient(top, #5dbcd9, #4cadcb);
+ background-image: -moz-linear-gradient(top, #5dbcd9, #4cadcb);
+ background-image: -ms-linear-gradient(top, #5dbcd9, #4cadcb);
+ background-image: -o-linear-gradient(top, #5dbcd9, #4cadcb);
+ background-image: linear-gradient(top, #5dbcd9, #4cadcb);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#5dbcd9',
+EndColorStr='#4cadcb',GradientType=0);
+ color: #fff !important;
+}
+.button:active, a.button:active {
+ background-color: #1e799a;
+ background-image: none;
+ border-color: #30b7e6;
+}
+a.button.big.subtitle {
+ line-height:18px;
+}
+.button-secondary:hover, a.button-secondary:hover {
+ border-color: #dbdbdb;
+ background-color: #f3f3f3;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));
+ background-image: -webkit-linear-gradient(top, #f9f9f9, #ececec);
+ background-image: -moz-linear-gradient(top, #f9f9f9, #ececec);
+ background-image: -ms-linear-gradient(top, #f9f9f9, #ececec);
+ background-image: -o-linear-gradient(top, #f9f9f9, #ececec);
+ background-image: linear-gradient(top, #f9f9f9, #ececec);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f9f9f9',
+EndColorStr='#ececec');
+ color: #33B5E5 !important;
+}
+.button-secondary:active, a.button-secondary:active {
+ border-color: #dadada;
+ background: #ebebeb; /* Old browsers */
+ /* IE9 SVG, needs conditional override of 'filter' to 'none' */
+ background:
+url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/
+Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0Jv
+eD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+
+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIg
+eDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ViZWJl
+YiIgc3RvcC1vcGFjaXR5PSIxIi8+
+CiAgICA8c3RvcCBvZmZzZXQ9IjEwJSIgc3RvcC1jb2xvcj0iI2Y5ZjlmOSIgc3RvcC1vcGFjaXR5PSIxIi8+
+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2ZhZmFmYSIgc3RvcC1vcGFjaXR5PSIxIi8+
+CiAgICA8c3RvcCBvZmZzZXQ9IjkwJSIgc3RvcC1jb2xvcj0iI2Y5ZjlmOSIgc3RvcC1vcGFjaXR5PSIxIi8+
+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmNmY2ZjYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFy
+R3JhZGllbnQ+
+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIg
+Lz4KPC9zdmc+);
+ background: -moz-linear-gradient(top, #ebebeb 0%, #f9f9f9 5%, #fafafa 50%, #f9f9f9 90%,
+#ffffff 100%); /* FF3.6+ */
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ebebeb),
+color-stop(5%,#f9f9f9), color-stop(50%,#fafafa), color-stop(90%,#f9f9f9), color-stop(100%,#ffffff));
+/* Chrome,Safari4+ */
+ background: -webkit-linear-gradient(top, #ebebeb 0%,#f9f9f9 5%,#fafafa 50%,#f9f9f9
+90%,#ffffff 100%); /* Chrome10+,Safari5.1+ */
+ background: -o-linear-gradient(top, #ebebeb 0%,#f9f9f9 5%,#fafafa 50%,#f9f9f9 90%,#ffffff
+100%); /* Opera 11.10+ */
+ background: -ms-linear-gradient(top, #ebebeb 0%,#f9f9f9 5%,#fafafa 50%,#f9f9f9 90%,#ffffff
+100%); /* IE10+ */
+ background: linear-gradient(top, #ebebeb 0%,#f9f9f9 5%,#fafafa 50%,#f9f9f9 90%,#ffffff
+100%); /* W3C */
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ebebeb',
+endColorstr='#ffffff',GradientType=0 ); /* IE6-8 */
+ -webkit-box-shadow: inset 0px 0px 5px 2px rgba(0, 0, 0, .05);
+ -moz-box-shadow: inset 0px 0px 5px 2px rgba(0, 0, 0, .05);
+ box-shadow: inset 0px 0px 5px 2px rgba(0, 0, 0, .05);
+ color: #258AAF !important;
+}
+.button.big {
+ font-size:20px;
+ display:inline-block;
+}
+.button.big span.small {
+ font-size:14px;
+}
+.button-caption {
+ margin-top:10px;
+ font-size:12px;
+ font-style:italic;
+}
+
+.button.disabled,
+.button.disabled:hover,
+.button.disabled:active {
+ background:#ebebeb;
+ color:#999 !important;
+ border-color:#999;
+ cursor:default;
+}
+
+.training-nav-top a.button-secondary,
+.training-nav-bottom a.button-secondary {
+ display:block;
+ float:left;
+ margin:0;
+ width:130px;
+ text-transform:uppercase;
+ font-weight:bold;
+
+ background-color: #f3f3f3;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));
+ background-image: -webkit-linear-gradient(top, #f9f9f9, #ececec);
+ background-image: -moz-linear-gradient(top, #f9f9f9, #ececec);
+ background-image: -ms-linear-gradient(top, #f9f9f9, #ececec);
+ background-image: -o-linear-gradient(top, #f9f9f9, #ececec);
+ background-image: linear-gradient(top, #f9f9f9, #ececec);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f9f9f9',
+EndColorStr='#ececec');
+ color: #33B5E5;
+}
+
+.training-nav-top a.button-secondary:hover,
+.training-nav-bottom a.button-secondary:hover {
+ background-color: #09c;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#2faddb), to(#09c));
+ background-image: -webkit-linear-gradient(top, #2faddb, #09c);
+ background-image: -moz-linear-gradient(top, #2faddb, #09c);
+ background-image: -ms-linear-gradient(top, #2faddb, #09c);
+ background-image: -o-linear-gradient(top, #2faddb, #09c);
+ background-image: linear-gradient(top, #2faddb, #09c);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#2faddb', EndColorStr='#09c');
+ border: 1px solid #3990ab;
+ color: #fff !important;
+}
+
+.training-nav-top a.button-secondary.last,
+.training-nav-bottom a.button-secondary.last {
+ border-left:0;
+}
+
+.training-nav-top a.button-secondary.double-size,
+.training-nav-bottom a.button-secondary.double-size {
+ width:291px;
+}
+
+.training-nav-top,
+.training-nav-bottom {
+ float:right;
+ margin:0 0 0 20px;
+}
+
+.training-nav-top {
+ position:relative;
+ top:73px;
+}
+
+.training-nav-bottom {
+ padding:0 0 20px;
+}
+
+#tb-wrapper,
+#qv-wrapper {
+ float:right;
+ clear:right;
+ margin:6px 0 0 30px; /* negative top-margin to counter the content-header bottom margin */
+ padding:0 0 30px;
+}
+
+#tb-wrapper {
+ margin:51px 0 0 20px; /* negative top-margin to counter the content-header bottom margin */
+}
+
+#tb,
+#qv {
+ font-size:13px;
+ line-height:18px;
+ width:238px;
+ border:1px solid #ccc;
+ float:right;
+}
+
+#tb {
+ width:278px;
+}
+
+#tb h2,
+#qv h2 {
+ margin:10px 15px;
+ padding:0;
+ text-transform:uppercase;
+ border-bottom:1px solid gainsboro;
+}
+
+#tb *,
+#qv * {
+ font-size:inherit;
+}
+
+#tb .download-box,
+#qv .download-box {
+ padding:0 0 0 15px;
+}
+
+#tb .download-box .filename,
+#qv .download-box .filename {
+ font-size:11px;
+ margin:4px 4px 10px;
+ color:#666;
+}
+
+
+/* Dev guide quicknav */
+
+.sidebox-wrapper {
+ float:right;
+ clear:right;
+ margin:0 0 0 20px;
+ padding:0 0 20px;
+}
+
+.sidebox {
+ width:226px;
+ font-size:13px;
+ line-height:18px;
+ border-left:4px solid #99CC00;
+ float:right;
+ padding:0 0 0 10px;
+ margin:0 0 1em 20px;
+}
+
+.sidebox h2,
+.sidebox h3,
+.sidebox h4,
+.sidebox h5 {
+ font-weight:bold;
+ margin:0 0 10px;
+ line-height: 16px;
+}
+
+.sidebox * {
+ font-size:inherit;
+}
+
+.sidebox > *:last-child {
+ margin-bottom:0;
+}
+
+#tb ol,
+#tb ul,
+#qv ul {
+ margin:0 15px 10px 35px;
+}
+
+#tb p {
+ margin:0 15px 10px;
+}
+
+#qv ol {
+ list-style:none;
+ margin:0 15px 15px;
+ font-size:inherit;
+ line-height:inherit;
+}
+
+#tb ol ol,
+#tb ul ul,
+#qv ol ol,
+#qv ul ul,
+.sidebox ol ol,
+.sidebox ul ul {
+ margin-bottom:0;
+}
+
+#qv ol ol {
+ margin:3px 0 3px 15px;
+}
+
+.sidebox p,
+#qv p,
+#tb p {
+ margin: 0 0 10px;
+}
+
+/* related resources blocks in checklists */
+
+/* related resources sections that have dynamic content */
+
+
+
+h3.rel-resources {
+margin:1.25em auto;
+}
+
+/* --------------------------------------------------------------------------
+Form
+*/
+.article form {
+ margin: 0 0 20px;
+}
+.article form .form-required {
+ color: #dd4b39;
+}
+.article form fieldset {
+ margin: 0 0 20px;
+ padding: 0;
+}
+.article form legend {
+ display: block;
+ line-height: 1.5;
+ margin: 0;
+ padding: 0;
+}
+/*
+.article form ol, .article form ul {
+ margin: 0 0 0 1em;
+ padding: 0 0 0 1em;
+}
+[dir='rtl'] .article form ol, [dir='rtl'] .article form ul {
+ margin: 0 1em 0 0;
+ padding: 0 1em 0 0;
+}
+.article form ol ul, .article form ul ul, [dir='rtl'] .article form ol ul, [dir='rtl'] .article form
+ul ul {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+}
+.article form li {
+ margin: 0 0 20px;
+}
+.article form li li {
+ margin: 0 0 5px;
+}
+*/
+.article form label {
+ display: block;
+ margin: 0 0 5px;
+ padding: 0;
+}
+.article form input[type='text'], .article form select, .article form textarea, .article form
+.checkbox-group, .article form .radio-group {
+ margin-bottom: 15px;
+}
+.checkbox-group input {
+ width: 13px;
+ height: 13px;
+ background: #fff;
+ border: solid 1px #c6c6c6;
+ float: left;
+}
+.article form .checkbox-group, .article form .radio-group {
+ display: block
+}
+.article form select {
+ border: solid 1px #ebebeb;
+ border-top-color: #ddd;
+ -webkit-appearance: none;
+ background: #f3f3f3 url(../images/arrows-up-down.png) right center no-repeat;
+ height: 30px;
+ color: #222;
+ line-height: normal;
+ padding: 5px;
+ width: 130px;
+}
+
+.article form .browse .browse-msg {
+ font-size: 11.5px;
+}
+.article form .browse .button-secondary {
+ height: auto;
+ line-height: 25px;
+ font-size: 11px;
+ padding: 0 8px;
+ margin: 0 10px 15px 0;
+}
+.article form input[type='text'], .article form textarea {
+ border: 1px solid #ebebeb;
+ border-top-color: #dcdcdc;
+ color: #222;
+ line-height: normal;
+ padding: 6px 10px;
+ width: 300px;
+}
+.article form textarea {
+ height: 150px;
+}
+.article form input[type='text']:focus, .article form textarea:focus {
+ border-color: #33B5E5;
+ -moz-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
+ -o-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
+ -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
+ outline: 0;
+}
+.article form input[disabled], .article form textarea[disabled], .article form label.form-disabled {
+ color: #999;
+}
+.article form input[type='text'][disabled], .article form textarea[disabled] {
+ background-color: #ebebeb;
+}
+form .form-error input[type='text'], form .form-error textarea {
+ border-color: #dd4b39;
+ margin-right: 20px;
+}
+.aside {
+ -moz-border-radius: 2px;
+ -webkit-border-radius: 2px;
+ border-radius: 2px;
+ margin: 10px 0;
+ padding: 20px;
+ color: #666;
+ position: relative;
+ background: #f9f9f9;
+}
+/*
+.aside, .notification, .promo {
+ -moz-border-radius: 2px;
+ -webkit-border-radius: 2px;
+ border-radius: 2px;
+ margin: 10px 0;
+ padding: 10px;
+ position: relative;
+}
+.aside>:first-child, .notification>:first-child, .promo>:first-child {
+ margin-top: 0;
+}
+.aside>:last-child, .notification>:last-child, .promo>:last-child {
+ margin-bottom: 0;
+}
+.aside {
+ background: #f9f9f9;
+}
+.notification {
+ background: #fffbe4;
+ border-color: #f8f6e6;
+}
+.promo {
+ background: #f6f9ff;
+ border-color: #eff2f9;
+}
+*/
+
+/* SDK TOS styles */
+
+div.sdk-terms {
+ white-space: pre-wrap;
+ word-wrap: break-word;
+ font-family: inherit;
+ font-size: inherit;
+ padding: 10px;
+ height: 370px;
+ width: 738px;
+ border: 1px solid #444;
+ background: transparent;
+ overflow:auto;
+ margin:0 0 10px;
+}
+
+div.sdk-terms.fullsize {
+ padding: 0;
+ height: auto;
+ width: auto;
+ border:none;
+}
+
+div.sdk-terms h3,
+div.sdk-terms h2 {
+ margin:0;
+}
+
+div#sdk-terms-form {
+ padding:0 0 0 10px;
+}
+
+div#sdk-terms-form input {
+ display:inline;
+ margin:4px 4px 4px 0;
+}
+
+
+/* --------------------------------------------------------------------------
+Code Style
+*/
+pre {
+ margin:0 0 1em 0;
+ padding: 1em;
+ overflow: auto;
+ border: solid 1px #ddd;
+ background: #f7f7f7;
+}
+.str { color: #800; } /* Code string */
+.kwd { color: #008; }
+.typ { color: #606; }
+.lit { color: #066; }
+.pun { color: #660; }
+.pln { color: #000; }
+.tag { color: #008; }
+.atn { color: #828; }
+.atv { color: #800; } /* XML string */
+.dec { color: #606; }
+
+/* --------------------------------------------------------------------------
+Three-Pane
+*/
+/* Package Nav & Classes Nav */
+.three-pane {
+ position: relative;
+ border-top: solid 1px #ebebeb;
+}
+#packages-nav .js-pane,
+#classes-nav .js-pane {
+ overflow:visible;
+}
+#packages-nav {
+ height:270px;
+ max-height: inherit;
+ overflow: hidden;
+ position: relative;
+}
+#classes-nav {
+ overflow: hidden;
+ position: relative;
+}
+#packages-nav ul, #classes-nav ul {
+ list-style-type: none;
+ margin: 10px 0 20px 0;
+ padding: 0;
+}
+#classes-nav li {
+ font-weight: bold;
+ margin: 5px 0;
+}
+#packages-nav li,
+#classes-nav li li {
+ margin: 0;
+}
+#packages-nav li a, #packages-nav li a:active, #packages-nav li a:visited,
+#classes-nav li a, #classes-nav li a:active, #classes-nav li a:visited {
+ padding: 0 0 0 4px;
+}
+#packages-nav li a, #packages-nav li a:active, #packages-nav li a:visited,
+#classes-nav li li a, #classes-nav li li a:active, #classes-nav li li a:visited,
+#nav-tree li a, #nav-tree li a:active, #nav-tree li a:visited {
+ color: #222;
+ font-weight: normal;
+}
+#packages-nav li a, #packages-nav li a:active, #packages-nav li a:visited,
+#classes-nav li li a, #classes-nav li li a:active, #classes-nav li li a:visited {
+ display: block;
+}
+#packages-nav li.selected a, #packages-nav li.selected a:active, #packages-nav li.selected
+a:visited,
+#classes-nav li li.selected a, #classes-nav li li.selected a:active, #classes-nav li li.selected
+a:visited,
+#nav-tree li div.selected {
+ font-weight: 500;
+ color: #0099cc;
+ background-color:#fff; }
+ #packages-nav li.selected ul li a,
+ #classes-nav li.selected ul li a {
+ /* don't highlight child items */
+ color: #555555; }
+#nav-tree li div.selected a {
+ font-weight: 500;
+ color: #0099cc;
+}
+#nav-swap {
+ height:30px;
+ border-top:1px solid #ccc;
+}
+#nav-swap a {
+ display:inline-block;
+ height:100%;
+ color: #222;
+ font-size: 12px;
+ padding: 5px 0 5px 5px;
+}
+
+#nav-swap .fullscreen {
+ float: right;
+ width: 24px;
+ height: 24px;
+ text-indent: -1000em;
+ padding:0;
+ margin:3px 5px 0;
+ background: url(../images/fullscreen.png) no-repeat -24px 0;
+}
+#nav-swap .fullscreen.disabled {
+ background-position: 0 0;
+}
+#nav-swap .fullscreen:hover,
+#nav-swap .fullscreen:focus {
+ cursor:pointer;
+}
+
+
+/* nav tree */
+#side-nav, #swapper,
+#nav-tree, #tree-list {
+ overflow:hidden;
+ margin-left:0;
+}
+
+#devdoc-nav {
+ overflow:visible !important; /* To keep the "to top" button visible */
+}
+
+#nav-tree ul {
+ list-style:none;
+ padding:0;
+ margin:10px 0;
+}
+
+#nav-tree ul li div {
+ padding:0 0 0 4px;
+}
+
+#side-nav #nav-tree ul li a,
+#side-nav #nav-tree ul li span.no-children {
+ padding: 0;
+ margin: 0;
+}
+
+#nav-tree .plus {
+ margin: 0 3px 0 0;
+}
+
+#nav-tree ul ul {
+ list-style: none;
+ margin: 0;
+ padding: 0 0 0 0;
+}
+
+#nav-tree ul li {
+ margin: 0;
+ padding: 0 0 0 0;
+ white-space: nowrap;
+}
+
+#nav-tree .children_ul {
+ padding:0;
+ margin:0;
+}
+#nav-tree .children_ul li div {
+ padding:0 0 0 10px;
+}
+#nav-tree .children_ul .children_ul li div {
+ padding:0 0 0 20px;
+}
+
+#nav-tree a.nolink {
+ color: #222;
+ text-decoration: none;
+}
+
+#nav-tree span.label {
+ width: 100%;
+}
+
+#nav-tree {
+ overflow-x: auto;
+ overflow-y: scroll;
+ outline:0;
+}
+
+
+/* Content */
+#doc-col {
+ margin-right:0;
+}
+
+/* Uncomment this for preview release watermark
+#doc-col {
+ background: url('../images/preview.png') repeat;
+}
+*/
+
+#doc-content-container {
+ margin-left: 291px
+}
+#doc-header, #doc-content {
+ padding: 1em 2em;
+}
+#doc-header {
+ background: #f7f7f7;
+}
+#doc-header h1 {
+ line-height: 0;
+ margin-bottom: 15px;
+}
+#api-info-block {
+ float: right;
+ font-weight: bold;
+}
+#api-info-block a, #api-info-block a:active, #api-info-block a:visited {
+ color: #222;
+}
+#api-info-block a:hover, #api-info-block a:focus {
+ color: #33B5E5;
+}
+#api-nav-header {
+ height:19px; /* plus 16px padding = 35; same as #nav li */
+ font-size:14px;
+ padding: 8px 0;
+ margin: 0;
+ border-bottom: 1px solid #CCC;
+ background:#e9e9e9;
+ background: rgba(0, 0, 0, 0.05); /* matches #nav li.expanded */
+
+}
+#api-nav-title {
+ padding:0 5px;
+ white-space:nowrap;
+}
+
+#api-level-toggle {
+ float:right;
+ padding:0 5px;
+}
+
+#api-level-toggle label {
+ margin:0;
+ vertical-align:top;
+ line-height: 19px;
+ font-size:13px;
+ height: 19px;
+}
+
+#api-level-toggle .select-wrapper {
+ width: 35px;
+ display: inline-block;
+ overflow: hidden;
+}
+#api-level-toggle select {
+ border: 0;
+ appearance:none;
+ -moz-appearance:none;
+ -webkit-appearance: none;
+ background: transparent url(../images/arrows-up-down.png) 23px 5px no-repeat;
+ color: #222;
+ height: 19px;
+ line-height: 19px;
+ padding: 0;
+ margin:1px 0 0 0;
+ width:150%;
+ font-size:13px;
+ vertical-align:top;
+ outline:0;
+}
+
+
+/* Toggle for revision notes and stuff */
+div.toggle-content.closed .toggle-content-toggleme {
+ display:none;
+}
+
+#jd-content img.toggle-content-img {
+ margin:0 5px 5px 0;
+}
+
+div.toggle-content-toggleme {
+ padding:0 0 0 15px;
+}
+
+
+/* API LEVEL FILTERED MEMBERS */
+
+.absent,
+.absent a:link,
+.absent a:visited,
+.absent a:hover,
+.absent * {
+ color:#bbb !important;
+ cursor:default !important;
+ text-decoration:none !important;
+}
+#devdoc-nav li.absent.selected,
+#devdoc-nav li.absent.selected *,
+#devdoc-nav div.label.absent.selected,
+#devdoc-nav div.label.absent.selected * {
+ background-color:#eaeaea !important;
+}
+.absent h4.jd-details-title,
+.absent h4.jd-details-title * {
+ background-color:#f6f6f6 !important;
+}
+.absent img {
+ opacity: .3;
+ filter: alpha(opacity=30);
+ -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
+}
+
+
+
+
+
+
+
+
+
+/* JQUERY RESIZABLE STYLES */
+.ui-resizable { position: relative; }
+.ui-resizable-handle { position: absolute; display: none; font-size: 0.1px; z-index:1; }
+.ui-resizable .ui-resizable-handle { display: block; border-bottom: 1px solid #e4e4e4; }
+/*body .ui-resizable-disabled .ui-resizable-handle { display: none; }
+body .ui-resizable-autohide .ui-resizable-handle { display: none; }*/
+.ui-resizable-s { cursor: s-resize; height: 10px; width: 100% !important; bottom: -11px; left: 0;
+border-bottom: solid 1px #ededed;
+ background: #f7f7f7 url("../images/resizable-s2.png") no-repeat scroll center center; }
+/*
+.ui-resizable-e {
+cursor: e-resize; width: 10px; right: 0; top: 0; height: 100%; border-right: solid
+1px #ededed;background: #f7f7f7 url("../images/resizable-e2.png") no-repeat scroll center center; }
+*/
+
+/* --------------------------------------------------------------------------
+Lightbox
+*/
+.lightbox {
+ width: 769px;
+ padding: 1.5em;
+ margin: 0 auto;
+ border: solid 1px #dcdcdc;
+ background: #fff;
+ -moz-box-shadow: 1px 1px 5px rgba(0,0,0,0.1);
+ -webkit-box-shadow: 1px 1px 5px rgba(0,0,0,0.1);
+ box-shadow: 1px 1px 5px rgba(0,0,0,0.1)
+}
+.lightbox .header {
+ float: left;
+ width: 720px;
+ margin: -10px 20px 10px 0;
+}
+.lightbox .close {
+ float: right;
+ width: 10px;
+ height: 10px;
+ margin: -10px -10px 10px 0;
+ text-indent: -1000em;
+ background: url(../images/close.png) no-repeat 0 0;
+}
+.lightbox .close:hover, .lightbox .close:focus {
+ background-position: -10px 0;
+}
+
+/* --------------------------------------------------------------------------
+Styles for samples browser
+*/
+
+#codesample-wrapper {
+ width:100000px; /* super wide to contain floats, but doesn't cause scroll */
+ overflow:visible;
+}
+pre#codesample-block {
+ float:left;
+ overflow:visible;
+ background:transparent;
+ border:none;
+}
+pre#codesample-block a.number {
+ display:none;
+}
+pre#codesample-block .code-line:hover {
+ background:#e7e7e7;
+}
+pre#codesample-line-numbers {
+ float:left;
+ width:2em;
+ background:transparent;
+ border:none;
+ border-right:1px solid #ccc;
+ padding-left:0;
+ font-family:monospace;
+ text-align:right;
+ -webkit-touch-callout: none;
+ -webkit-user-select: none;
+ -khtml-user-select: none;
+ -moz-user-select: -moz-none;
+ -ms-user-select: none;
+ user-select: none;
+}
+pre#codesample-line-numbers a {
+ color:#999;
+}
+pre#codesample-line-numbers.hidden {
+ display:none;
+}
+pre#codesample-block span.code-line {
+ width:100%;
+ display:inline-block;
+}
+
+/*
+Styles for displaying image or video resources in samples browser.
+Resources are marked as no-display if they exceed the size limit.
+*/
+div#codesample-resource img, div#codesample-resource video {
+ border: 1px solid #ececec;
+}
+
+div#codesample-resource.noDisplay div {
+ border: 1px solid #ececec;
+ width:120px;
+ margin-bottom:4px;
+ padding:20px;
+}
+
+div#codesample-resource .noDisplay-message:after {
+ font-style:italic;
+ font-size:12px;
+ content: 'This resource is not available for browsing. To view it, please download the project.';
+}
+
+/*
+Styles for project structure (treeview) page
+*/
+.structure-dir {
+background-image:url(../../assets/images/folder.png);
+background-repeat:no-repeat;
+background-position:16px 2px;
+ margin:.25em 0 0 0;
+ padding:0 0 0 0;
+}
+
+.structure-toggleme {
+ margin:0 0 0 3em;
+ padding:0 0 0 0;
+ text-decoration:none;
+}
+
+.structure-java{
+background-image:url(../../assets/images/file-java.png);
+background-repeat:no-repeat;
+background-position:0px 2px;
+ margin:.3em 0 0 0;
+ padding:.3em 0 .3em 22px;
+}
+
+.structure-file {
+background-image:url(../../assets/images/file-generic.png);
+background-repeat:no-repeat;
+background-position:0px 2px;
+ margin:.3em 0 0 0;
+ padding:.3em 0 .3em 22px;
+}
+
+.structure-xml {
+background-image:url(../../assets/images/file-xml.png);
+background-repeat:no-repeat;
+background-position:0px 2px;
+ margin:.3em 0 0 0;
+ padding:.3em 0 .25em 22px;
+}
+
+.structure-img {
+background-image:url(../../assets/images/file-image.png);
+background-repeat:no-repeat;
+background-position:0px 2px;
+ margin:.3em 0 0 0;
+ padding:.3em 0 .25em 22px;
+}
+
+.structure-manifest {
+background-image:url(../../assets/images/file-manifest.png);
+background-repeat:no-repeat;
+ margin:.0 0 0 1.25em;
+ padding:0 0 0 22px;
+ text-decoration:none;
+}
+
+#jd-content .structure-toggle-img {
+ margin:.5em 0 0 0;
+padding-right:2.1em;
+}
+
+.dirInfo {
+ margin-left:2em;
+}
+
+.structure-dir a {
+ text-decoration:none;
+}
+
+.structure-manifest a {
+ text-decoration: none;
+}
+.structure-file a {
+ text-decoration: none;
+}
+
+.sampleEmbed {
+ background-color:rgb(249, 249, 249);
+}
+
+.sampleEmbed ol.lineNumbers {
+ list-style-type: decimal;
+ padding-left:1em;
+}
+
+.sampleEmbed ol.lineNumbers li {
+border-left:1px solid #ddd;
+border-right:1px solid #ddd;
+color:gray;
+background-color:#f7f7f7;
+margin:0 0 0 24px;
+padding: 2px 2px 2px 6px;
+}
+
+.sampleEmbed ol.lineNumbers li:hover {
+background: #efefef;
+}
+
+.samples-nav li a {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+/* --------------------------------------------------------------------------
+Styles for raw formatted line numbers (not used with listformatted version)
+div.sampleLine div.lineNumber {
+ display: inline;
+}
+div.sampleLine div.lineCode {
+ display: inline;
+ padding-left:6px;
+}
+div.sampleLine {
+ padding:0;
+ margin:0;
+}*/
+
+/* --------------------------------------------------------------------------
+Butterbar
+*/
+#butterbar-wrapper {
+ position:absolute;
+ top:0;
+ left:0;
+ width:100%;
+}
+#butterbar {
+ width:100%;
+ margin:0 auto;
+}
+#butterbar-message {
+ background-color:rgba(255, 187, 51, .4);
+ font-size:13px;
+ padding: 5px 0;
+ text-align:center;
+}
+a#butterbar-message {
+ cursor:pointer;
+ display:block;
+}
+a#butterbar-message:hover {
+ text-decoration:underline;
+}
+
+/* --------------------------------------------------------------------------
+Misc
+*/
+
+
+.clearfix:before, .clearfix:after {
+ content: "";
+ display: table
+}
+.clearfix:after {
+ clear: both
+}
+.clearfix {
+ *zoom: 1
+}
+table.blank th, table.blank td {
+ border: 0;
+ background: none
+}
+.caption {
+ margin: 0.5em 0 2em 0;
+ color: #000;
+ font-size: 11.5px;
+}
+
+.nolist, .nolist ul, .nolist ol {
+ list-style:none;
+ margin-left:0;
+}
+#tb .nolist {
+ margin-left:15px;
+}
+
+dl.xml>dt {
+ text-transform:uppercase;
+}
+dl.xml dl.attr {
+ margin-top:0;
+}
+
+pre.classic {
+ background-color:transparent;
+ border:none;
+ padding:0;
+}
+
+p.img-caption {
+ margin: -10px 0 20px;
+ font-size:13px;
+ color:#666;
+}
+
+div.figure,
+div.figure-right {
+ float:right;
+ clear:right;
+ margin:10px 0 0 0;
+ padding:0 0 0 20px;
+ /* width must be defined w/ an inline style matching the image width */
+}
+
+div.figure-left {
+ float:left;
+ clear:left;
+ margin:10px 0 0 0;
+ padding:0 20px 0 0;
+ /* width must be defined w/ an inline style matching the image width */
+}
+
+img.frame {
+ border:1px solid #DDD;
+ padding:4px;
+}
+
+p.table-caption {
+ margin: 0 0 4px 0;
+ font-size:13px;
+ color:#666;
+}
+
+p.code-caption {
+ margin-bottom: 4px;
+ font: 12px/1.5 monospace;
+ color:#666;
+}
+
+div.note,
+div.caution,
+div.warning {
+ margin: 0 0 15px;
+}
+
+p.note, div.note,
+p.caution, div.caution,
+p.warning, div.warning {
+ padding: 0 0 0 10px;
+ border-left: 4px solid;
+}
+
+p.note, div.note {
+ border-color: #258AAF;
+}
+
+p.caution, div.caution {
+ border-color: #FF8800;
+}
+
+p.warning, div.warning {
+ border-color: #ff4443;
+}
+
+div.note.design {
+ border-left: 4px solid #33B5E5;
+}
+
+div.note.develop {
+ border-left: 4px solid #F80;
+}
+
+div.note.distribute {
+ border-left: 4px solid #9C0;
+}
+
+.note p, .caution p, .warning p {
+ margin:0 0 5px;
+}
+
+.note p:last-child, .caution p:last-child, .warning p:last-child {
+ margin-bottom:0;
+}
+
+body.about blockquote {
+ display:block;
+ float:right;
+ width:280px;
+ font-size:20px;
+ font-style:italic;
+ line-height:24px;
+ color:#33B5E5;
+ margin:0 0 20px 30px;
+}
+
+div.design-announce p {
+ margin:0 0 10px;
+}
+
+.expandable {
+ height:34px;
+ padding-left:20px;
+ position:relative;
+}
+.expandable:before {
+ content: '';
+ background-image: url(../images/styles/disclosure_down.png);
+ background-repeat:no-repeat;
+ background-position: -12px -9px;
+ width: 20px;
+ height: 20px;
+ display: inline-block;
+ position: absolute;
+ top: 0;
+ left: 0; }
+}
+.expandable.expanded:before {
+ background-image: url(../images/styles/disclosure_up.png);
+}
+
+/* notice box for cross links between Design/Develop docs */
+a.notice-developers-video,
+a.notice-developers,
+a.notice-designers-video,
+a.notice-designers {
+ float:right;
+ clear:right;
+ width:238px;
+ min-height:50px;
+ margin:0 0 20px 20px;
+ border:1px solid #ddd;
+}
+a.notice-developers-video.wide,
+a.notice-developers.wide,
+a.notice-designers-video.wide,
+a.notice-designers.wide {
+ width:278px;
+}
+a.notice-developers-video div,
+a.notice-developers div,
+a.notice-designers-video div,
+a.notice-designers div {
+ min-height:40px;
+ background:url('../images/styles/notice-developers@2x.png') no-repeat 10px 10px;
+ background-size:40px 40px;
+ padding:10px 10px 10px 60px;
+}
+a.notice-designers div {
+ background:url('../images/styles/notice-designers@2x.png') no-repeat 10px 10px;
+ background-size:40px 40px;
+}
+a.notice-designers-video div {
+ background:url('../images/styles/notice-designers-video@2x.png') no-repeat 10px 10px;
+ background-size:40px 40px;
+}
+a.notice-developers-video div {
+ background:url('../images/styles/notice-developers-video@2x.png') no-repeat 10px 10px;
+ background-size:40px 40px;
+}
+a.notice-developers-video:hover,
+a.notice-developers:hover,
+a.notice-designers-video:hover,
+a.notice-designers:hover {
+ background:#eee;
+}
+a.notice-developers-video h3,
+a.notice-developers h3,
+a.notice-designers-video h3,
+a.notice-designers h3 {
+ font-size:13px;
+ line-height:18px;
+ font-weight:bold;
+ text-transform:uppercase;
+ color:#000 !important;
+ margin:0 0 1px;
+}
+a.notice-developers-video p,
+a.notice-developers p,
+a.notice-designers-video p,
+a.notice-designers p {
+ margin:0;
+ line-height:14px;
+}
+a.notice-developers-video.left,
+a.notice-developers.left,
+a.notice-designers-video.left,
+a.notice-designers.left {
+ margin-left:0;
+ float:left;
+}
+
+
+/* hide nested list items; companion to hideNestedLists() */
+.hide-nested li ol,
+.hide-nested li ul {
+ display:none;
+}
+
+a.header-toggle {
+ display:block;
+ float:right;
+ text-transform:uppercase;
+ font-size:.8em !important;
+ font-weight:normal;
+ margin-top:2px;
+}
+
+
+/* for IDE instruction toggle (Studio/Eclipse/Other) */
+select.ide {
+ background: transparent;
+ border: 1px solid #bbb;
+ border-left: 0;
+ border-right: 0;
+ margin: 10px 0;
+ padding: 10px 0;
+ color:#666;
+}
+select.ide,
+select.ide option {
+ font-family: inherit;
+ font-size:16px;
+ font-weight:500;
+}
+/* hide all except studio by default */
+.select-ide.eclipse,
+.select-ide.other {
+ display:none;
+}
+/* ... unless studio also includes one of the others */
+.select-ide.studio.eclipse,
+.select-ide.studio.other {
+ display:none;
+}
+
+
+/* -----------------------------------------------
+good/bad example containers
+*/
+
+div.example-block {
+ background-repeat: no-repeat;
+ background-position:10px 8px;
+ background-color:#ccc;
+ padding:4px;
+ margin:.8em auto 1.5em 2em;
+ width:260px;
+ float:right;
+}
+/* red container */
+.example-block.bad {
+ background-image: url(/images/example-bad.png);
+ background-color:#f4cccc;
+}
+/* green container */
+.example-block.good {
+ background-image: url(/images/example-good.png);
+ background-color:#d9ead3;
+}
+/* container heading div */
+#jd-content .example-block .heading {
+ font-weight:bold;
+ margin:6px 0 9px 36px;
+ padding:6px auto;
+}
+/* container image (if any) */
+#jd-content .example-block img {
+ margin:0;
+ padding:0px;
+}
+
+.example-block table {
+ margin:0;
+}
+
+/* -----------------------------------------------
+Dialog box for popup messages
+*/
+
+div.dialog {
+ height:0;
+ margin:0 auto;
+}
+
+div.dialog>div {
+ z-index:99;
+ position:fixed;
+ margin:70px 0;
+ width: 391px;
+ height: 200px;
+ background: #F7F7F7;
+-moz-box-shadow: 0 0 15px rgba(0,0,0,0.5);
+-webkit-box-shadow: 0 0 15px rgba(0,0,0,0.5);
+box-shadow: 0 0 15px rgba(0,0,0,0.5);
+}
+/* IE6 can't position fixed */
+* html div.dialog div { position:absolute; }
+
+
+div#deprecatedSticker {
+ display:none;
+ z-index:99;
+ position:fixed;
+ right:15px;
+ top:114px;
+ margin:0;
+ padding:1em;
+ background:#FFF;
+ border:1px solid #dddd00;
+ box-shadow:-5px 5px 10px #ccc;
+ -moz-box-shadow:-5px 5px 10px #ccc;
+ -webkit-box-shadow:-5px 5px 10px #ccc;
+}
+
+div#langMessage,
+div#naMessage {
+ display:none;
+ width:555px;
+ height:0;
+ margin:0 auto;
+}
+
+
+div#langMessage>div,
+div#naMessage div {
+ z-index:99;
+ width:450px;
+ position:fixed;
+ margin:50px 0;
+ padding:4em 4em 3em;
+ background:#FFF;
+ border:1px solid #999;
+ box-shadow:-10px 10px 40px #888;
+ -moz-box-shadow:-10px 10px 40px #888;
+ -webkit-box-shadow:-10px 10px 40px #888;
+}
+/* IE6 can't position fixed */
+* html div#langMessage>div,
+* html div#naMessage div { position:absolute; }
+
+div#naMessage strong {
+ font-size:1.1em;
+}
+
+div#langMessage .lang {
+ display:none;
+}
+
+/* --------------------------------------------------------------------------
+Slideshow Controls & Next/Prev
+*/
+.slideshow-next, .slideshow-prev {
+ width: 20px;
+ height: 36px;
+ text-indent: -1000em;
+}
+.slideshow-container {
+ margin: 2em 0;
+}
+.slideshow-container:before, .slideshow-container:after {
+ content: "";
+ display: table;
+ clear: both;
+}
+a.slideshow-next, a.slideshow-next:visited {
+
+ float: right;
+
+ background: url(../images/arrow-right.png) no-repeat 0 0
+
+}
+
+a.slideshow-prev, a.slideshow-prev:visited {
+
+ float: left;
+
+ background: url(../images/arrow-left.png) no-repeat 0 0
+
+}
+
+.slideshow-next:hover, .slideshow-prev:hover, .slideshow-next:focus, .slideshow-prev:focus {
+
+ background-position: 0 -36px
+
+}
+
+.slideshow-next:active, .slideshow-prev:active {
+
+ background-position: 0 -72px
+
+}
+.slideshow-nav {
+ width: 74px;
+ margin: 0 auto;
+}
+.slideshow-nav a, .slideshow-nav a:visited {
+ display: inline-block;
+ width: 12px;
+ height: 12px;
+ margin: 0 2px 20px 2px;
+ background: #ccc;
+ -webkit-border-radius: 50%;
+ -moz-border-radius: 50%;
+ border-radius: 50%;
+}
+.slideshow-nav a:hover, .slideshow-nav a:focus {
+
+ background: #33B5E5
+}
+
+.slideshow-nav a:active {
+
+ background: #1e799a;
+ background: #ebebeb;
+ -webkit-box-shadow: inset 0px 0px 5px 2px rgba(0, 0, 0, .05);
+ -moz-box-shadow: inset 0px 0px 5px 2px rgba(0, 0, 0, .05);
+ box-shadow: inset 0px 0px 5px 2px rgba(0, 0, 0, .05);
+}
+.slideshow-nav a.active, .slideshow-nav a.active:active, .slideshow-nav a.active:visited {
+ background: #33B5E5
+}
+/* --------------------------------------------------------------------------
+Tabs
+*/
+ul.tabs {
+ padding: 0;
+ margin: 2em 0 0 0;
+}
+ul.tabs:before, ul.tabs:after {
+ content: "";
+ display: table;
+ clear: both;
+}
+ul.tabs li {
+ list-style-type: none;
+ float: left;
+}
+ul.tabs li a, ul.tabs li a:active, ul.tabs li a:visited {
+ display: block;
+ height: 36px;
+ line-height: 36px;
+ padding: 0 15px;
+ margin-right: 2px;
+ color: #222;
+ -moz-border-radius-topleft: 2px;
+ -moz-border-radius-topright: 2px;
+ -moz-border-radius-bottomright: px;
+ -moz-border-radius-bottomleft: px;
+ -webkit-border-radius: 2px 2px px px;
+ border-radius: 2px 2px px px;
+ border-top: solid 1px #ebebeb;
+ border-left: solid 1px #ebebeb;
+ border-right: solid 1px #ebebeb;
+ background-color: #fff;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#ffffff), to(#fafafa));
+ background-image: -webkit-linear-gradient(top, #ffffff, #fafafa);
+ background-image: -moz-linear-gradient(top, #ffffff, #fafafa);
+ background-image: -ms-linear-gradient(top, #ffffff, #fafafa);
+ background-image: -o-linear-gradient(top, #ffffff, #fafafa);
+ background-image: linear-gradient(top, #ffffff, #fafafa);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffffff',
+EndColorStr='#fafafa');
+}
+ul.tabs li a:hover {
+ color: #33B5E5;
+}
+ul.tabs li a.selected {
+ height: 37px;
+ color: #33B5E5;
+ background-color: #f7f7f7;
+ background-image: none;
+ border-color: #ddd;
+}
+.tab-content {
+ padding: 1.2em;
+ margin: -1px 0 2em 0;
+ -webkit-border-radius: 2px;
+ -moz-border-radius: 2px;
+ border-radius: 2px;
+ border: solid 1px #ddd;
+ background: #f7f7f7;
+}
+/* --------------------------------------------------------------------------
+Feature Boxes
+*/
+.feature-box {
+ width: 291px;
+ height: 200px;
+ position: relative;
+ background: #F7F7F7;
+}
+.box-border .top, .box-border .bottom, .box-border .left, .box-border .right {
+ z-index: 100;
+ position: absolute;
+ background-color: #aaa;
+}
+.box-border .top, .box-border .bottom {
+ width: 291px;
+ height: 1px;
+}
+.dialog .box-border .top,
+.dialog .box-border .bottom { width:391px; }
+
+.box-border .left, .box-border .right {
+ width: 1px;
+ height: 8px;
+}
+.box-border .top { top: 0; left: 0 }
+.box-border .top .left { top: 1px; left: 0 }
+.box-border .top .right { top: 1px; right: 0 }
+.box-border .bottom .left { top: -8px; left: 0 }
+.box-border .bottom { top: 200px; left: 0 }
+.box-border .bottom .right { top: -8px; right: 0 }
+
+.feature-box h4,
+.dialog h4 {
+ margin: 15px 18px 10px;
+ padding:0;
+}
+
+.feature-box p,
+.dialog p {
+ margin: 10px 18px;
+ padding:0;
+}
+.feature-box .link,
+.dialog .link {
+ border-top: 1px solid #dedede;
+ bottom: 0;
+ position: absolute;
+ width: inherit;
+}
+.feature-box a, .feature-box h4,
+.dialog a, .dialog h4 {
+ -webkit-transition: color .4s ease;
+ -moz-transition: color .4s ease;
+ -o-transition: color .4s ease;
+ transition: color .4s ease;
+}
+.feature-box:hover {
+ cursor: pointer;
+}
+.feature-box:hover .box-border .top, .feature-box:hover .box-border .bottom, .feature-box:hover
+.left, .feature-box:hover .right {
+ background-color: #33B5E5;
+}
+.feature-box:hover h4, .feature-box:hover a {
+ color: #33B5E5;
+}
+/* --------------------------------------------------------------------------
+Page-Specific Styles
+*/
+.colors {
+ position: relative;
+ float: left;
+ width: 92px;
+ margin: 40px 0 20px;
+}
+.colors div {
+ color: #fff;
+ font-size: 11.5px;
+ width: 82px;
+ height: 82px;
+ margin-top:-30px;
+ line-height: 82px;
+ text-align: center;
+ border: solid 5px #fff;
+ -webkit-border-radius: 50%;
+ -moz-border-radius: 50%;
+ border-radius: 50%;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* ########### REFERENCE DOCS ################## */
+
+#packages-nav h2,
+#classes-nav h2 {
+ font-size:18px;
+ margin:0;
+ padding:0 0 0 4px;
+}
+
+#jd-header {
+ padding: 0 0 12px;
+ margin: 20px 0 12px;
+ font-size:12px;
+ padding-bottom:12px;
+ border-bottom:solid 1px #ccc;
+}
+
+#jd-header h1 {
+ margin:0;
+ padding:0 0 6px 0;
+}
+
+/* not sure if this is needed in the ref docs, disabling for now
+.jd-descr h2 {
+ margin:16px 0;
+}
+*/
+
+/* page-top-right container for reference pages (holds
+links to summary tables) */
+#api-info-block {
+ font-size:12px;
+ margin:20px 0 0;
+ padding:0 10px 6px;
+ font-weight:normal;
+ float:right;
+ text-align:right;
+ color:#999;
+ max-width:80%;
+ font-size: 12px;
+ line-height:14px;
+}
+
+#api-info-block div.api-level {
+ font-weight:bold;
+ font-size:inherit;
+ float:none;
+ color:#222;
+ padding:0;
+ margin:0;
+}
+
+/* inheritance table */
+.jd-inheritance-table {
+ border-spacing:0;
+ margin:0;
+ padding:0;
+ font-size:12px;
+ line-height:14px;
+ background-color:transparent;
+}
+.jd-inheritance-table tr td {
+ border: none;
+ margin: 0;
+ padding: 0;
+ background-color:transparent;
+}
+.jd-inheritance-table .jd-inheritance-space {
+ font-weight:bold;
+ width:1em;
+}
+.jd-inheritance-table .jd-inheritance-interface-cell {
+ padding-left: 17px;
+}
+
+
+
+.jd-sumtable a {
+ text-decoration:none;
+}
+
+.jd-sumtable a:hover {
+ text-decoration:underline;
+}
+
+/* the link inside a sumtable for "Show All/Hide All" */
+.toggle-all {
+ display:block;
+ float:right;
+ font-weight:normal;
+ font-size:0.9em;
+}
+
+/* adjustments for in/direct subclasses tables */
+.jd-sumtable.jd-sumtable-subclasses {
+ margin: 1em 0 0 0;
+ max-width:968px;
+ background-color:transparent;
+ font-size:13px;
+}
+
+/* extra space between end of method name and open-paren */
+.sympad {
+ margin-right: 2px;
+}
+
+/* right alignment for the return type in sumtable */
+.jd-sumtable .jd-typecol {
+ text-align:right;
+}
+
+/* adjustments for the expando table-in-table */
+.jd-sumtable-expando {
+ margin:.5em 0;
+ padding:0;
+}
+
+/* a div that holds a short description */
+.jd-descrdiv {
+ padding:3px 1em 0 1em;
+ margin:0;
+ border:0;
+}
+
+#jd-content img.jd-expando-trigger-img {
+ padding:0 4px 4px 0;
+ margin:0;
+}
+
+.jd-sumtable-subclasses div#subclasses-direct,
+.jd-sumtable-subclasses div#subclasses-indirect {
+ margin:0 0 0 13px;
+}
+
+
+
+/********* MEMBER REF *************/
+
+
+.jd-details {
+/* border:1px solid #669999;
+ padding:4px; */
+ margin:0 0 1em;
+}
+
+/* API reference: a container for the
+.tagdata blocks that make up the detailed
+description */
+.jd-details-descr {
+ padding:0;
+ margin:.5em .25em;
+}
+
+/* API reference: a block containing
+a detailed description, a params table,
+seealso list, etc */
+.jd-tagdata {
+ margin:.5em 1em;
+}
+
+.jd-tagdata p {
+ margin:0 0 1em 1em;
+}
+
+/* API reference: adjustments to
+the detailed description block */
+.jd-tagdescr {
+ margin:.25em 0 .75em 0;
+}
+
+.jd-tagdescr ol,
+.jd-tagdescr ul {
+ margin:0 2.5em;
+ padding:0;
+}
+
+.jd-tagdescr table,
+.jd-tagdescr img {
+ margin:.25em 1em;
+}
+
+.jd-tagdescr li {
+margin:0 0 .25em 0;
+padding:0;
+}
+
+/* API reference: heading marking
+the details section for constants,
+attrs, methods, etc. */
+h4.jd-details-title {
+ font-size:1.15em;
+ background-color: #E2E2E2;
+ margin:1.5em 0 .6em;
+ padding:3px 95px 3px 3px; /* room for api-level */
+}
+body.google h4.jd-details-title {
+ background-color: #FFF;
+ padding-top:5px;
+ border-top: 1px solid #ccc;
+}
+body.google table.jd-sumtable th {
+ background-color: #FFF;
+ color:#000;
+}
+
+h4.jd-tagtitle {
+ margin:0;
+}
+
+h4 .normal {
+ font-weight:normal;
+}
+
+/* API reference: heading for "Parameters", "See Also", etc.,
+in details sections */
+h5.jd-tagtitle {
+ margin:0 0 .25em 0;
+ font-size:1em;
+}
+
+.jd-tagtable {
+ margin:0;
+ background-color:transparent;
+ width:auto;
+}
+
+.jd-tagtable td,
+.jd-tagtable th {
+ border:none;
+ background-color:#fff;
+ vertical-align:top;
+ font-weight:normal;
+ padding:2px 10px;
+}
+
+.jd-tagtable th {
+ font-style:italic;
+}
+
+/* Inline api level indicator for methods */
+div.api-level {
+ font-size:.8em;
+ font-weight:normal;
+ color:#999;
+ float:right;
+ padding:0 8px 0;
+ margin-top:-30px;
+}
+
+table.jd-tagtable td,
+table.jd-tagtable th {
+ background-color:transparent;
+}
+
+table.jd-tagtable th {
+ color:inherit;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* SEARCH FILTER */
+
+.menu-container {
+ position:relative;
+}
+#search_autocomplete {
+ font-weight:normal;
+}
+
+.search_filtered_wrapper.reference {
+ width: 193px;
+ float: right;
+}
+.search_filtered_wrapper.docs {
+ width:875px;
+ float: left;
+ position:absolute;
+ top:26px;
+ right:66px;
+}
+.suggest-card {
+ position:relative;
+ width:170px;
+ min-height:90px;
+ padding:5px;
+ border: solid 1px #C5C5C5;
+ background: white;
+ top: 15px;
+ margin-right:-5px;
+ -moz-box-shadow: 0 0 10px rgba(0,0,0,0.2);
+ -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
+ box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
+}
+.suggest-card.reference {
+ position:absolute;
+ z-index:999;
+ min-width:171px; /* +padding and border makes this match input width */
+ min-height:93px; /* add 3px because this has 1 not 4px top border */
+ width:auto;
+ top:41px;
+ margin:0;
+}
+.suggest-card.develop {
+ z-index:997;
+ border-top: solid 4px #F80;
+ float:right;
+}
+.suggest-card.design {
+ z-index:996;
+ border-top: solid 4px #33b5e5;
+ float:right;
+}
+.suggest-card.distribute {
+ z-index:995;
+ border-top: solid 4px #9C0;
+ float:right;
+}
+.child-card {
+ width:100%;
+}
+.suggest-card.dummy {
+ width:172px;
+ float:right;
+ border:0;
+ background:transparent;
+ -moz-box-shadow: none;
+ -webkit-box-shadow: none;
+ box-shadow: none;
+}
+
+ul.search_filtered {
+ min-width:100%;
+ list-style: none;
+ margin: 0 0 5px;
+ padding: 0;
+}
+.search_filtered .jd-selected {
+ background:#efefef;
+ cursor:pointer;
+}
+.search_filtered .jd-selected,
+.search_filtered .jd-selected a {
+ color:#09C !important;
+}
+
+.no-display {
+ display: none;
+}
+
+.search_filtered li.jd-autocomplete {
+ font-size: 0.81em;
+ border: none;
+ margin: 0 0 2px;
+ padding: 0;
+ line-height:1.5em;
+}
+
+.search_filtered li a {
+ padding:0 5px;
+ color:#222 !important;
+ display:inline-block;
+ line-height:12px;
+}
+
+.search_filtered li.header {
+ font-weight:bold;
+ color:#444;
+ border: none;
+ margin: 8px 0 2px;
+ padding:1px 5px;
+ line-height:1.5em;
+}
+.search_filtered li.header.small {
+ font-size:0.85em;
+}
+
+.suggest-card.reference
+.search_filtered li.header {
+ color:#aaa;
+ font-size: 0.81em;
+}
+
+.search_filtered li.header:first-child {
+ margin: 0 0 2px;
+}
+
+.show-item {
+ display: table-row;
+}
+.hide-item {
+ display: hidden;
+}
+
+
+
+
+
+/* SEARCH RESULTS */
+
+
+#leftSearchControl .gsc-twiddle {
+ background-image : none;
+}
+
+#leftSearchControl td, #searchForm td {
+ border: 0px solid #000;
+ padding:0;
+}
+
+#leftSearchControl .gsc-resultsHeader .gsc-title {
+ padding-left : 0px;
+ font-weight : bold;
+ font-size : 13px;
+ color:#006699;
+ display : none;
+}
+
+#leftSearchControl .gsc-resultsHeader div.gsc-results-selector {
+ display : none;
+}
+
+#leftSearchControl .gsc-resultsRoot {
+ padding-top : 6px;
+}
+
+#leftSearchControl div.gs-visibleUrl-long {
+ display : block;
+ color:#006699;
+}
+
+#leftSearchControl .gsc-webResult {
+ padding:0 0 20px 0;
+}
+
+.gsc-webResult div.gs-visibleUrl-short,
+table.gsc-branding,
+.gsc-clear-button {
+ display : none;
+}
+
+.gsc-cursor-box .gsc-cursor div.gsc-cursor-page,
+.gsc-cursor-box .gsc-trailing-more-results a.gsc-trailing-more-results,
+#leftSearchControl a,
+#leftSearchControl a b {
+ color:#006699;
+}
+
+.gsc-resultsHeader {
+ display: none;
+}
+
+/* Disable built in search forms */
+.gsc-control form.gsc-search-box {
+ display : none;
+}
+table.gsc-search-box {
+ margin:6px 0 0 0;
+ border-collapse:collapse;
+}
+
+td.gsc-input {
+ padding:0 2px;
+ width:100%;
+ vertical-align:middle;
+}
+
+input.gsc-input {
+ border:1px solid #BCCDF0;
+ width:99%;
+ padding-left:2px;
+ font-size:.95em;
+}
+
+td.gsc-search-button {
+ text-align: right;
+ padding:0;
+ vertical-align:top;
+}
+
+
+#searchResults {
+ overflow:hidden; /* because the repositioned page links makes the section think it needs to scroll
+(it doesn't) */
+ height:auto;
+}
+
+#searchResults .gsc-control {
+ position:relative;
+ width:auto;
+ padding:0 0 10px;
+}
+
+#searchResults .gsc-tabsArea {
+ position:relative;
+ white-space:nowrap;
+ float:left;
+ width:200px;
+}
+
+#searchResults .gsc-above-wrapper-area {
+ display:none;
+}
+
+#searchResults .gsc-resultsbox-visible {
+ float:left;
+ width:720px;
+ margin-left:20px;
+}
+
+#searchResults .gsc-tabHeader {
+ padding: 3px 6px;
+ position:relative;
+ width:auto;
+ display:block;
+}
+
+#searchResults h2#searchTitle {
+ padding:0;
+ margin:5px 0;
+ border:none;
+}
+
+#searchResults h2#searchTitle em {
+ font-style:normal;
+ color:#33B5E5;
+}
+
+#searchResults .gsc-table-result {
+ margin:5px 0 10px 0;
+ background-color:transparent;
+}
+#searchResults .gs-web-image-box, .gs-promotion-image-box {
+ width:120px;
+}
+#searchResults .gs-web-image-box img.gs-image, .gs-promotion-image-box img.gs-promotion-image {
+ max-width:120px;
+}
+
+#searchResults .gsc-table-result .gsc-thumbnail {
+ padding:0 20px 0 0;
+}
+
+#searchResults td {
+ background-color:transparent;
+}
+
+#searchResults .gsc-expansionArea {
+ position:relative;
+}
+#searchResults .gsc-tabsArea .gsc-cursor-box {
+ width:200px;
+ padding:20px 0 0 1px;
+}
+#searchResults .gsc-cursor-page {
+ display:inline-block;
+ float:left;
+ margin:-1px 0 0 -1px;
+ padding:0;
+ height:27px;
+ width:27px;
+ text-align:center;
+ line-height:2;
+}
+
+#searchResults .gsc-tabHeader.gsc-tabhInactive,
+#searchResults .gsc-cursor-page {
+ text-decoration:none;
+ color:#258AAF;
+ border: solid 1px #DADADA;
+}
+
+#searchResults .gsc-tabHeader.gsc-tabhInactive:hover,
+#searchResults .gsc-cursor-page:hover {
+ border-color: #DBDBDB;
+ background-color: #F3F3F3;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#F9F9F9), to(#ECECEC));
+ background-image: -webkit-linear-gradient(top, #F9F9F9, #ECECEC);
+ background-image: -moz-linear-gradient(top, #F9F9F9, #ECECEC);
+ background-image: -ms-linear-gradient(top, #F9F9F9, #ECECEC);
+ background-image: -o-linear-gradient(top, #F9F9F9, #ECECEC);
+ background-image: linear-gradient(top, #F9F9F9, #ECECEC);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#f9f9f9',
+EndColorStr='#ececec');
+ color: #33B5E5;
+}
+
+#searchResults .gsc-tabHeader.gsc-tabhActive,
+#searchResults .gsc-tabHeader.gsc-tabhActive:hover,
+#searchResults .gsc-cursor-page.gsc-cursor-current-page,
+#searchResults .gsc-cursor-page.gsc-cursor-current-page:hover {
+ color:#fff;
+ background-color: #09C;
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#2FADDB), to(#09C));
+ background-image: -webkit-linear-gradient(top, #2FADDB, #09C);
+ background-image: -moz-linear-gradient(top, #2FADDB, #09C);
+ background-image: -ms-linear-gradient(top, #2FADDB, #09C);
+ background-image: -o-linear-gradient(top, #2FADDB, #09C);
+ background-image: linear-gradient(top, #2FADDB, #09C);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#2faddb', EndColorStr='#09c');
+ border: 1px solid #3990AB;
+ z-index:100;
+}
+
+
+
+
+
+/************ STICKY NAV BAR ******************/
+
+#header-wrapper {
+ background: #f9f9f9;
+ margin: 0 -10px 0 -10px;
+ padding: 31px 10px 0px 10px;
+ position: relative;
+}
+#header-wrapper #nav-x div.wrap {
+ max-width: 940px;
+ height: 38px;
+}
+#header-wrapper #nav-x ul.nav-x li {
+ margin-right: 31px !important;
+ margin-top: 5px;
+ margin-bottom: 0px;
+ height: 30px;
+}
+#header-wrapper #nav-x > div.wrap ul.nav-x li.active {
+ color: #669900;
+ border-bottom: 3px solid #669900;
+}
+#header-wrapper #nav-x > div.wrap ul.nav-x li.active a {
+ color: #669900;
+}
+#header-wrapper #nav-x > div.wrap ul.nav-x a {
+ font-size: 14.5px;
+}
+#header-wrapper .developer-console-btn {
+ float: right;
+ background: #fefefe;
+ border-radius: 4px;
+ padding: 8px 14px;
+ box-shadow: 1px 1px 0px #7a7a7a;
+ font-size: 14px;
+ margin-top: -6px;
+ cursor: pointer;
+ color: #464646;
+ margin-right: 20px;
+}
+/* not currently used */
+#header-wrapper .shadow {
+ width: 1034px;
+ height: 4px;
+ position: absolute;
+ left: 50%;
+ margin-left: -517px;
+ bottom: -4px;
+ background-image: url(../images/header-shadow.png);
+}
+
+#context {
+ clear: both;
+ padding-top: 14px;
+}
+#context .breadcrumb {
+ float: left;
+ margin-bottom: 10px;
+}
+#context .util {
+ float: right;
+ margin-right: 20px;
+}
+
+.breadcrumb {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ position: relative;
+}
+.breadcrumb li {
+ float: left;
+ padding: 0 20px 0 0;
+ color: #000;
+ white-space: nowrap;
+}
+.breadcrumb li a {
+ color: #000;
+}
+.breadcrumb li:after {
+ content: url(../images/breadcrumb.png);
+ position: relative;
+ top: 1px;
+ left: 10px;
+ width: 5px;
+ height: 10px;
+}
+.breadcrumb li.current {
+ font-weight: 700;
+}
+.breadcrumb li.current:after {
+ display: none;
+}
+
+/* Sticky Nav overrides */
+.sticky-menu {
+ position: fixed;
+ width: 940px;
+ height: 0px;
+ z-index: 51;
+ top: 12px;
+}
+#sticky-header {
+ display: none;
+ padding: 0 10px;
+ position: fixed;
+ background: #f9f9f9;
+ top: 0px;
+ left: 0px;
+ right: 0px;
+ height: 45px;
+ box-shadow: 0px 1px 5px rgba(0, 0, 0, 0.1);
+ border-bottom: 1px solid #a5c43a;
+ z-index: 50;
+}
+#sticky-header.design {
+ border-bottom: 1px solid #33b5e5;
+}
+#sticky-header.develop {
+ border-bottom: 1px solid #F80;
+}
+#sticky-header.distribute {
+ border-bottom: 1px solid #9C0;
+}
+#sticky-header.about {
+ border-bottom: 1px solid #9933CC;
+}
+#sticky-header > div {
+ overflow: hidden;
+ *zoom: 1;
+ width: 940px;
+ margin: 0 auto;
+ clear: both;
+ padding-top: 9px;
+}
+#sticky-header > div .logo {
+ float: left;
+ width: 26px;
+ height: 25px;
+ background: url(../images/dac_logo.png);
+ background-image: -webkit-image-set(url(../images/dac_logo.png) 1x, url(../images/dac_logo@2x.png) 2x);
+ z-index: 52;
+ position: relative;
+}
+#sticky-header > div .top {
+ float: left;
+ width: 38px;
+ height: 38px;
+ position: relative;
+ background: url(../images/styles/gototop.png);
+ z-index: 52;
+}
+#sticky-header > div .breadcrumb {
+ float: left;
+ padding: 0 0 0 10px;
+ border-left: 1px solid #d2d2d2;
+ line-height: 24px;
+ font-size: 14px;
+ position: relative;
+ top: 0px;
+ z-index: 52;
+}
+
+/* offset the tags to account for sticky nav */
+body.reference a[name]:empty {
+ visibility: hidden;
+ display: block;
+ position: relative;
+ top: -56px;
+}
+
+
+}
+
+
+
+
+
+
+
+/*********** PREVIOUSLY dac-styles.css ***************/
+
+
+#header {
+ border-bottom:0;
+}
+
+#header .wrap {
+ max-width:940px;
+ height:41px;
+ border-bottom:1px solid;
+ border-color: #ccc;
+ position:relative;
+}
+
+.about #header .wrap {
+ border-color: #9933CC;
+}
+
+.design #header .wrap {
+ border-color: #33b5e5;
+}
+
+.develop #header .wrap {
+ border-color: #F80;
+}
+
+.distribute #header .wrap {
+ border-color: #9C0;
+}
+
+.logo a {
+ float:left;
+}
+
+#header .logo {
+ margin-top: -6px;
+ margin-left: 0px;
+ margin-bottom:0px;
+ width: 160px;
+ padding-right:10px;
+}
+
+
+#header-wrap .logo.landing-logo {
+ width:220px;
+ margin:0;
+ padding:0;
+ margin-bottom:22px;
+}
+#header-wrap .logo.landing-logo img {
+ padding:0 0 0 10px;
+}
+
+.search {
+ height:25px;
+ margin-top: -3px;
+ margin-bottom: 0px;
+}
+
+
+
+/* Quicknav */
+.btn-quicknav {
+ width:20px;
+ height:28px;
+ float:left;
+ margin-left:6px;
+ padding-right:10px;
+ position:relative;
+ cursor:pointer;
+ border-right:1px solid #CCC;
+}
+
+.btn-quicknav a {
+ zoom:1;
+ position:absolute;
+ top:13px;
+ left:5px;
+ display:block;
+ text-indent:-9999em;
+ width:10px;
+ height:5px;
+ background:url(../images/quicknav_arrow.png) no-repeat;
+}
+
+.btn-quicknav a.arrow-active {
+ background-position: 0 -5px;
+ display:none;
+}
+
+#header-wrap.quicknav a.arrow-inactive {
+ display:none;
+}
+
+.btn-quicknav.active a.arrow-active {
+ display:block;
+}
+
+.nav-x li {
+ display:block;
+ float:left;
+ margin-right:45px;
+ -webkit-transition: all 0.25s linear;
+ -moz-transition: all 0.25s linear;
+ -ms-transition: all 0.25s linear;
+ -o-transition: all 0.25s linear;
+ transition: all 0.25s linear;
+}
+
+#header-wrap.quicknav .nav-x li {
+ min-width:160px;
+ margin-right:20px;
+}
+
+#header-wrap.quicknav li.last {
+ margin-right:0px;
+}
+
+#quicknav {
+ float:none;
+ clear:both;
+ margin-left:0;
+ margin-top:-30px;
+ display:none;
+ overflow:hidden;
+}
+
+#header-wrap.quicknav #quicknav {
+
+}
+
+#quicknav ul {
+ margin:10px 0;
+ padding:0;
+}
+
+#quicknav ul li.about {
+ border-top:1px solid #9933CC;
+}
+
+#quicknav ul li.design {
+ border-top:1px solid #33b5e5;
+}
+
+#quicknav ul li.develop {
+ border-top:1px solid #FF8800;
+}
+
+#quicknav ul li.distribute {
+ border-top:1px solid #99cc00;
+}
+
+#quicknav ul li {
+ display:block;
+ float:left;
+ margin:0 20px 0 0;
+ min-width:140px;
+}
+
+#quicknav ul li.last {
+ margin-right:0px;
+}
+
+#quicknav ul li ul li {
+ float:none;
+}
+
+#quicknav ul li ul li a {
+ color:#222;
+}
+
+#quicknav ul li li ul,
+#quicknav ul li li ul li {
+ margin:0;
+}
+
+#quicknav ul li li ul li:before {
+ content:"\21B3";
+}
+
+#header-wrap {
+ -webkit-transition: all 0.25s ease-out;
+ -moz-transition: all 0.25s ease-out;
+ -ms-transition: all 0.25s ease-out;
+ -o-transition: all 0.25s ease-out;
+ transition: all 0.25s ease-out;
+
+}
+
+#header-wrap.quicknav {
+ height:216px;
+
+}
+
+/* SEARCH AND MORE */
+.search {
+ position: absolute;
+ width: 50px;
+ height:28px;
+ display: block;
+ margin-top:-3px;
+ margin-bottom:7px;
+ overflow:hidden;
+ z-index:100;
+ right:54px;
+ -webkit-transition: width 0.4s ease;
+ -moz-transition: width 0.4s ease;
+ -o-transition: width 0.4s ease;
+ transition: width 0.4s ease;
+}
+
+.search #search-btn {
+ width:50px;
+ height:28px;
+ background:url(../images/icon_search.png) no-repeat;
+ float:left;
+}
+
+.search-inner {
+ width:245px;
+}
+
+.search:hover, .search.active {
+ width:245px;
+}
+
+.search .bottom, .search .left, .search .right {
+ position: absolute;
+ background-color: #a2a2a2
+}
+
+.search .bottom {
+ width: 214px;
+ height: 1px;
+ top: 24px;
+ left: 0
+}
+
+.search .left, .search .right {
+ height: 5px;
+ width: 1px
+}
+
+.search .left {
+ top: 22px;
+ left: 56px;
+ background-color:#CCC;
+}
+
+.search .right {
+ top: 22px;
+ left: 238px;
+ background-color:#CCC;
+}
+
+.search form {
+ margin-top: 2px;
+ width: 162px;
+ float:left;
+}
+
+.search form input {
+ color: #2f2f2f;
+ font-size: 0.95em;
+ width: 178px;
+ border: none;
+ margin-left: 6px;
+ z-index: 1500;
+ position: relative;
+ background-color: transparent;
+ border-bottom:1px solid #CCC;
+ padding:0 0 0 4px;
+ outline:none;
+ height:24px;
+}
+
+.search:hover form input {
+ border-bottom:1px solid #33B5E5;
+}
+
+.search:hover .bottom, .search:hover .left, .search:hover .right {
+ background-color: #33b5e5;
+}
+
+.search:hover #search-btn {
+ background-position: 0 -28px
+}
+
+.search form input:focus {
+ color: #222;
+ font-weight: bold
+}
+
+.moremenu {
+ float: right;
+ position: relative;
+ width: 50px;
+ height:28px;
+ display: block;
+ margin-top:-3px;
+ margin-bottom:7px;
+ overflow:hidden;
+ -webkit-transition: width 0.25s ease;
+ -moz-transition: width 0.25s ease;
+ -o-transition: width 0.25s ease;
+ transition: width 0.25s ease;
+}
+
+.moremenu #more-btn {
+ width:40px;
+ height:28px;
+ background:url(../images/icon_more.png) no-repeat;
+ border-left:1px solid #CCC;
+ float:left;
+ cursor:pointer;
+}
+
+.moremenu:hover #more-btn {
+ background-position:0 -28px;
+}
+
+.morehover {
+ position:absolute;
+ right:6px;
+ top:-9px;
+ width:40px;
+ height:35px;
+ z-index:99;
+ overflow:hidden;
+
+ -webkit-opacity:0;
+ -moz-opacity:0;
+ -o-opacity:0;
+ opacity:0;
+
+ -webkit-transform-origin:100% 0%;
+ -moz-transform-origin:100% 0%;
+ -o-transform-origin:100% 0%;
+ transform-origin:100% 0%;
+
+ -webkit-transition-property: -webkit-opacity;
+ -webkit-transition-duration: .25s;
+ -webkit-transition-timing-function:ease;
+
+ -moz-transition-property: -moz-opacity;
+ -moz-transition-duration: .25s;
+ -moz-transition-timing-function:ease;
+
+ -o-transition-property: -o-opacity;
+ -o-transition-duration: .25s;
+ -o-transition-timing-function:ease;
+
+ transition-property: opacity;
+ transition-duration: .25s;
+ transition-timing-function:ease;
+}
+
+.morehover:hover,
+.morehover.hover {
+ opacity:1;
+ height:385px;
+ width:268px;
+ -webkit-transition-property:height, -webkit-opacity;
+}
+
+.morehover .top {
+ width:268px;
+ height:39px;
+ background:url(../images/more_top.png) no-repeat;
+}
+
+.morehover .mid {
+ width:228px;
+ background:url(../images/more_mid.png) repeat-y;
+ padding:10px 20px 0 20px;
+}
+
+.morehover .mid .header {
+ border-bottom:1px solid #ccc;
+ font-weight:bold;
+}
+
+.morehover .bottom {
+ width:268px;
+ height:6px;
+ background:url(../images/more_bottom.png) no-repeat;
+}
+
+.morehover ul {
+ margin:10px 10px 20px 0;
+}
+
+.morehover ul li {
+ list-style:none;
+}
+
+.morehover ul li.active a,
+.morehover ul li.active a:hover {
+ color:#222 !important;
+}
+
+.morehover ul li.active img {
+ margin-right:4px;
+}
+
+
+
+
+/* MARQUEE */
+.slideshow-container {
+ width:100%;
+ overflow:hidden;
+ position:relative;
+}
+.slideshow-container .slideshow-prev {
+ position:absolute;
+ top:50%;
+ left:0px;
+ margin-top:-36px;
+ z-index:99;
+}
+.slideshow-container .slideshow-next {
+ position:absolute;
+ top:50%;
+ margin-top:-36px;
+ z-index:99;
+ right:0px;
+}
+
+.slideshow-container .pagination {
+ position:absolute;
+ bottom:20px;
+ width:100%;
+ text-align:center;
+ z-index:99;
+}
+.slideshow-container .pagination ul {
+ margin:0;
+}
+.slideshow-container .pagination ul li{
+ display: inline-block;
+ width:12px;
+ height:12px;
+ text-indent:-8000px;
+ list-style:none;
+ margin: 0 2px;
+ border-radius:6px;
+ background-color:#ccc;
+ cursor:pointer;
+ -webkit-transition:color .5s ease-in;
+ -moz-transition:color .5s ease-in;
+ -o-transition:color .5s ease-in;
+ transition:color .5s ease-in;
+}
+.slideshow-container .pagination ul li:hover {
+ background-color:#999;
+}
+.slideshow-container .pagination ul li.active {
+ background-color:#33b5e5;
+}
+.slideshow-container .pagination ul li.active:hover {
+ background-color:#33b5e5;
+}
+.slideshow-container ul li {
+ display:inline;
+ list-style:none;
+}
+
+
+#landing h1 {
+ margin:17px 0 20px 0 !important;
+}
+
+a.download-sdk {
+ float:right;
+ margin:-10px 0;
+ height:30px;
+ padding-top:4px;
+ padding-bottom:0px;
+}
+
+#nav-x {
+ padding-top: 13px;
+}
+
+#nav-x .wrap {
+ min-height:32px;
+}
+
+#nav-x .wrap,
+#searchResults.wrap {
+ max-width:940px;
+ border-bottom:1px solid #CCC;
+}
+
+#searchResults.wrap #leftSearchControl {
+ min-height:700px
+}
+.nav-x {
+ margin-left:0;
+ margin-bottom:0;
+}
+
+
+
+
+
+
+
+
+
+
+/*
+ * CSS Styles that are needed by jScrollPane for it to operate correctly.
+ */
+
+.jspContainer {
+ overflow: hidden;
+ position: relative;
+}
+
+.jspPane {
+ position: absolute;
+ width:100% !important; /* to avoid cut-off api names in reference in horiz scroll */
+}
+
+.jspVerticalBar {
+ position: absolute;
+ top: 0;
+ right: 0;
+ width: 4px;
+ height: 100%;
+ background: #f5f5f5;
+}
+
+.jspHorizontalBar {
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ height: 4px;
+ background: #f5f5f5;
+}
+
+.jspVerticalBar *,
+.jspHorizontalBar * {
+ margin: 0;
+ padding: 0;
+}
+.jspCap {
+ display: block;
+}
+
+.jspVerticalBar .jspCap {
+ height: 4px;
+}
+
+.jspHorizontalBar .jspCap {
+ width: 0;
+ height: 100%;
+}
+
+.jspHorizontalBar .jspCap {
+ float: left;
+}
+
+.jspTrack {
+ position: relative;
+}
+
+.jspDrag {
+ background: #bbb;
+ position: relative;
+ top: 0;
+ left: 0;
+ cursor: pointer;
+}
+
+.jspDrag:hover,
+.jspDrag:active {
+ border-color: #09c;
+ background-color: #4cadcb;
+ background-image: -webkit-gradient(linear, left top, right top, from(#5dbcd9), to(#4cadcb));
+ background-image: -webkit-linear-gradient(left, #5dbcd9, #4cadcb);
+ background-image: -moz-linear-gradient(left, #5dbcd9, #4cadcb);
+ background-image: -ms-linear-gradient(left, #5dbcd9, #4cadcb);
+ background-image: -o-linear-gradient(left, #5dbcd9, #4cadcb);
+ background-image: linear-gradient(left, #5dbcd9, #4cadcb);
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#5dbcd9', EndColorStr='#4cadcb');
+}
+
+.jspHorizontalBar .jspTrack,
+.jspHorizontalBar .jspDrag {
+ float: left;
+ height: 100%;
+}
+
+.jspArrow {
+ background: #999;
+ text-indent: -20000px;
+ display: block;
+ cursor: pointer;
+}
+
+.jspArrow.jspDisabled {
+ cursor: default;
+ background: #ccc;
+}
+
+.jspVerticalBar .jspArrow {
+ height: 16px;
+}
+
+.jspHorizontalBar .jspArrow {
+ width: 16px;
+ float: left;
+ height: 100%;
+}
+
+.jspVerticalBar .jspArrow:focus {
+ outline: none;
+}
+
+.jspCorner {
+ float: left;
+ height: 100%;
+}
+
+/* Yuk! CSS Hack for IE6 3 pixel bug :( */
+* html .jspCorner {
+ margin: 0 -3px 0 0;
+}
+/******* end of jscrollpane *********/
+
+
+
+
+
+/************ DEVELOP HOMEPAGE ******************/
+
+/* Slideshow */
+.slideshow-develop {
+ height: 316px;
+ width: 940px;
+ position: relative;
+ overflow:hidden;
+}
+.slideshow-develop .frame {
+ width: 940px;
+ height: 316px;
+}
+.slideshow-develop img.play {
+ max-width:350px;
+ max-height:240px;
+ margin:20px 0 0 90px;
+ -webkit-transform: perspective(800px ) rotateY( 35deg );
+ box-shadow: -16px 20px 40px rgba(0, 0, 0, 0.3);
+ -moz-box-shadow: -16px 20px 40px rgba(0, 0, 0, 0.3);
+ -webkit-box-shadow: -16px 20px 40px rgba(0, 0, 0, 0.3);
+}
+.slideshow-develop img.play.no-shadow {
+ box-shadow: none;
+ -moz-box-shadow: none;
+ -webkit-box-shadow: none;
+}
+.slideshow-develop img.play.no-transform {
+ -webkit-transform: none;
+}
+.slideshow-develop a.slideshow-next {
+ background: url(../images/arrow-right-develop.png);
+}
+.slideshow-develop a.slideshow-prev {
+ background: url(../images/arrow-left-develop.png);
+}
+.slideshow-develop .content-right {
+ float: left;
+}
+.slideshow-develop .content-right h2 {
+ padding:0;
+ margin-bottom:10px;
+ border:none;
+ font-size:24px;
+}
+.slideshow-develop .item {
+ height: 300px;
+ width: 940px;
+}
+.slideshow-develop .pagination ul li.active {
+ background-color: #F80;
+}
+.slideshow-develop .pagination ul li.active:hover {
+ background-color: #F80;
+}
+.slideshow-develop .item hr {
+ margin:5px 0 10px;
+}
+.slideshow-develop .item p {
+ margin:10px 0;
+}
+.slideshow-develop .item p.title-intro {
+ position:absolute;
+ margin:0;
+}
+
+/* Feeds */
+.feed ul {
+ margin: 0;
+}
+.feed .feed-nav {
+ height: 25px;
+ border-bottom: 1px solid #CCC;
+}
+.feed .feed-nav li {
+ list-style: none;
+ float: left;
+ height: 21px; /* +4px bottom border = 25px; same as .feed-nav */
+ margin-right: 25px;
+ cursor: pointer;
+}
+.feed .feed-nav li.active {
+ color: #000;
+ border-bottom: 4px solid #F80;
+}
+.feed .feed-container {
+ overflow: hidden;
+ width: 460px;
+}
+.feed .feed-container .feed-frame {
+ width: 1000px;
+}
+.feed .feed-container .feed-frame ul {
+ float: left;
+ width:460px;
+}
+.feed .feed-container .feed-frame ul ul {
+ float: none;
+ margin:10px 0 0 30px;
+}
+.feed .feed-container .feed-frame li {
+ list-style: none;
+ margin: 20px 0 20px 0;
+ width: 460px;
+ height:93px;
+}
+.feed .feed-container .feed-frame li.playlist {
+ height:auto;
+}
+.feed .feed-container .feed-frame li.playlist a {
+ height:93px;
+ display:block;
+}
+.feed .feed-container .feed-frame li.more {
+ height:20px;
+ margin:10px 0 5px 5px;
+}
+.feed .feed-container .feed-frame li.more a {
+ height:inherit;
+}
+.feed .feed-container .feed-frame li.playlist-video {
+ list-style: none;
+ margin: 0;
+ width: 460px;
+ height:55px;
+ font-size:12px;
+}
+.feed .feed-container .feed-frame li.playlist-video a {
+ height:45px;
+ padding:5px;
+}
+.feed .feed-container .feed-frame li.playlist-video h5 {
+ font-size:12px;
+ line-height:13px;
+ margin:0;
+}
+.feed .feed-container .feed-frame li.playlist-video p {
+ margin:5px 0 0;
+ line-height:15px;
+}
+.feed-container .feed-frame div.feed-image {
+ float: left;
+ border: 1px solid #999;
+ margin:0 20px 0 0;
+ width:122px;
+ height:92px;
+ background:url('../images/blog-default.png') no-repeat 0 0;
+ background-size:180px;
+}
+#jd-content .feed .feed-container .feed-frame li img {
+ float: left;
+ border: 1px solid #999;
+ margin:0 20px 0 0;
+ width:122px;
+ height:92px;
+}
+#jd-content .feed .feed-container .feed-frame li.playlist-video img {
+ width:inherit;
+ height:inherit;
+}
+
+.feed .feed-container .feed-frame li a,
+.feed .feed-container .feed-frame li a:active {
+ color:#555 !important;
+}
+
+.feed .feed-container .feed-frame li a:hover,
+.feed .feed-container .feed-frame li a:hover * {
+ color:#7AA1B0 !important;
+}
+
+/* Video player */
+#player-wrapper {
+ display:none;
+ margin: -1px auto 0;
+ position: relative;
+ width: 940px;
+ height: 0px;
+}
+#player-frame {
+ background: #EFEFEF;
+ border: 1px solid #CCC;
+ padding: 0px 207px;
+ z-index: 10; /* stay above marque, but below search suggestions */
+ width: 525px;
+ height: 330px;
+ position: relative;
+}
+
+
+
+/************ DEVELOP TOPIC CONTAINERS ************/
+
+.landing-banner,
+.landing-docs {
+ margin:20px 0;
+}
+.landing-banner > div:first-child,
+.landing-docs > div:first-child,
+.landing-docs > .col-12 {
+ margin-left:0;
+ min-height:280px;
+}
+.landing-banner.short > div {
+ min-height:50px;
+}
+.landing-banner > div:last-child,
+.landing-docs > div:last-child,
+.landing-docs > .col-12 {
+ margin-right:0;
+}
+
+.landing-banner > div > *:last-child {
+ margin-bottom:0;
+}
+.landing-banner h1 {
+ margin-top:16px;
+ padding-bottom:24px;
+}
+.landing-docs,
+.landing-banner {
+ clear:both;
+ overflow:hidden;
+}
+.landing-docs h3 {
+ font-size:14px;
+ line-height:21px;
+ color:#555;
+ text-transform:uppercase;
+ border-bottom:1px solid #CCC;
+ margin:0 0 20px;
+}
+.landing-docs a {
+ color:#333 !important;
+}
+
+.landing-docs a:hover,
+.landing-docs a:hover * {
+ color:#7AA1B0 !important
+}
+
+.landing-docs .normal-links a {
+ color:#258aaf !important;
+}
+
+.plusone {
+ float:right;
+}
+
+
+
+.next-docs {
+ border-top:1px solid #ccc;
+ margin:40px 0 0;
+ padding:5px 0 0;
+ clear:left;
+ overflow:hidden;
+}
+.next-docs div:first-child {
+ margin-left:0;
+}
+.next-docs div:last-child {
+ margin-right:0;
+}
+
+.next-docs h2 {
+ font-size:14px;
+ line-height:21px;
+ color:#555;
+ text-transform:uppercase;
+ border-bottom:none;
+ margin:0 0 1em;
+ padding:5px 0 0;
+}
+
+
+
+/************* HOME/LANDING PAGE *****************/
+
+.slideshow-home {
+ height: 500px;
+ width: 940px;
+ border-bottom: 1px solid #CCC;
+ position: relative;
+ margin: 0;
+}
+.slideshow-home .frame {
+ width: 940px;
+ height: 500px;
+}
+.slideshow-home .content-left {
+ float: left;
+ text-align: center;
+ vertical-align: center;
+ margin: 0 0 0 35px;
+}
+.slideshow-home .content-right {
+ margin: 80px 0 0 0;
+}
+.slideshow-home .content-right p {
+ margin-bottom: 10px;
+}
+.slideshow-home .content-right p:last-child {
+ margin-top: 15px;
+}
+.slideshow-home .content-right h1 {
+ padding:0;
+}
+.slideshow-home .item {
+ height: 500px;
+ width: 940px;
+}
+.home-sections {
+ padding: 30px 20px 20px;
+ margin: 20px 0;
+ background: -webkit-linear-gradient(top, #F6F6F6,#F9F9F9);
+}
+.home-sections ul {
+ margin: 0;
+}
+.home-sections ul li {
+ float: left;
+ display: block;
+ list-style: none;
+ width: 170px;
+ height: 35px;
+ border: 1px solid #ccc;
+ background: white;
+ margin-right: 10px;
+ border-radius: 1px;
+ -webkit-border-radius: 1px;
+ -moz-border-radius: 1px;
+ box-shadow: 1px 1px 5px #EEE;
+ -webkit-box-shadow: 1px 1px 5px #EEE;
+ -moz-box-shadow: 1px 1px 5px #EEE;
+ background: white;
+}
+.home-sections ul li:hover {
+ background: #F9F9F9;
+ border: 1px solid #CCC;
+}
+.home-sections ul li a,
+.home-sections ul li a:hover {
+ font-weight: bold;
+ margin-top: 8px;
+ line-height: 18px;
+ float: left;
+ width: 100%;
+ text-align: center;
+ color: #09c !important;
+}
+.home-sections ul li a {
+ font-weight: bold;
+ margin-top: 8px;
+ line-height: 18px;
+ float: left;
+ width:100%;
+ text-align:center;
+}
+.home-sections ul li img {
+ float: left;
+ margin: -8px 0 0 10px;
+}
+.home-sections ul li.last {
+ margin-right: 0px;
+}
+.fullpage #footer {
+ margin-top: -40px;
+}
+
+/************ DISTRIBUTE PAGES ******************/
+
+.article-detail #body-content {
+ padding-top: 10px;
+}
+
+/* A container for grid sets with uppercase h3 and rule */
+.dynamic-grid h3 {
+ font-size:14px;
+ line-height:21px;
+ color:#555;
+ text-transform:uppercase;
+ border-bottom:1px solid #CCC;
+ padding:8px 0 0 1px;
+ margin-bottom:14px;
+ clear:both;
+}
+
+.top-right-float {
+ float: right;
+}
+
+.clearfloat {
+ float: none;
+ clear: both;
+}
+
+.border-img {
+ border: 1px solid #CCC;
+}
+
+.center-img {
+ margin: auto;
+ text-align: center;
+}
+.center-img img {
+ margin-bottom: 15px;
+}
+
+.figure img, .border-img {
+ margin-bottom: 15px;
+}
+
+/************ RESOURCE CARDS ******************/
+
+/* Resource cards, 12, 13, 16-col */
+
+/* Basic card-styling with shadow */
+.resource-card {
+ border-radius: 1px;
+ box-shadow: 1px 2px 5px rgba(0, 0, 0, 0.12);
+ background: #fefefe;
+}
+
+/* Styling for background image including tinting and section icons in stacks */
+.card-bg {
+ display: block;
+ position: absolute;
+ vertical-align: top;
+ width: 100%;
+ left: 0;
+ top: 0;
+ background-size: cover;
+ background-repeat: no-repeat;
+ background-position: center;
+ background-image: url(../images/resource-card-default-android.jpg);
+}
+.card-bg:after {
+ content: "";
+ display: block;
+ height: 100%;
+ width: 100%;
+ opacity: 1;
+ background: rgba(0, 0, 0, 0.2);
+ -webkit-transition: opacity 0.5s;
+ -moz-transition: opacity 0.5s;
+ -o-transition: opacity 0.5s;
+ transition: opacity 0.5s;
+}
+.static .card-bg:after {
+ display:none;
+}
+.card-bg .card-section-icon {
+ position: absolute;
+ top: 50%;
+ width: 100%;
+ margin-top: -35px;
+ text-align: center;
+ padding-top: 65px;
+ z-index: 100;
+}
+.card-bg .card-section-icon .icon {
+ position: absolute;
+ left: 50%;
+ margin-left: -28px;
+ top: 0px;
+ width: 56px;
+ height: 56px;
+ background-repeat: no-repeat;
+ background-position: 50% 50%;
+ background-image: url(../images/stack-icon.png);
+}
+.card-bg .card-section-icon .section {
+ text-transform: uppercase;
+ color: white;
+ font-size: 14px;
+}
+
+.card-info {
+ position: absolute;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ left: 0;
+ overflow: hidden;
+ background: #fefefe;
+ padding: 4px 12px 6px 12px;
+}
+.card-info .section {
+ text-transform: uppercase;
+ color: #898989;
+ font-size: 12px;
+ margin-bottom: 1px;
+}
+.card-info .title {
+ color: #363636;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ padding-bottom: 5px;
+ margin-bottom: -2px;
+ font-size: 16px;
+}
+.card-info .description {
+ overflow: hidden;
+}
+.card-info .description .text {
+ color: #464646;
+ font: 13px/15px Roboto Condensed;
+ overflow: hidden;
+ width:100%;
+}
+.card-info .description .util {
+ position: absolute;
+ right: 5px;
+ bottom: 70px; /*-2px;*/
+ opacity: 0;
+ -webkit-transition: opacity 0.5s;
+ -moz-transition: opacity 0.5s;
+ -o-transition: opacity 0.5s;
+ transition: opacity 0.5s;
+}
+.card-info.empty-desc .title {
+ white-space: normal;
+ overflow: visible;
+}
+.card-info.empty-desc .description {
+ display: none;
+}
+/* Truncate card summaries at bounding box and
+ * and apply ellipsis at lower right */
+.ellipsis {
+ overflow: hidden;
+ float:right;
+ line-height: 15px;
+ width:100%;
+}
+.resource-card-6x6 .card-info .description .teddddddxt {
+ float:left;
+ position:relative;
+ margin-left:0;
+}
+.ellipsis:before {
+ content:"";
+ float: left;
+ width: 5px;
+ height:100%;
+}
+.ellipsis > *:first-child.text {
+ float: right;
+ width: 100% !important;
+ margin-left: -5px;
+}
+.ellipsis:after {
+ content: "\02026";
+ height:17px;
+ padding-bottom:4px;
+
+ box-sizing: content-box;
+ -webkit-box-sizing: content-box;
+ -moz-box-sizing: content-box;
+
+ float: right; position: relative;
+ top: -16px; left: 100%;
+ width: 4em; margin-left: -4em;
+ padding-right: 5px;
+
+ background: -webkit-gradient(linear, left top, right top,
+ from(rgba(255, 255, 255, 0)), to(white), color-stop(65%, white));
+ background: -moz-linear-gradient(to right, rgba(255, 255, 255, 0), white 65%, white);
+ background: -o-linear-gradient(to right, rgba(255, 255, 255, 0), white 65%, white);
+ background: -ms-linear-gradient(to right, rgba(255, 255, 255, 0), white 65%, white);
+ background: linear-gradient(to right, rgba(255, 255, 255, 0), white 65%, white);
+}
+.ellipsis:after {
+ font-style: normal; color: #aaa;
+ font-size:13px;
+ text-align: right;
+}
+
+/* Flow Layout */
+.resource-flow-layout {
+ display: inline-block;
+}
+.resource-flow-layout .resource-card, .resource-flow-layout .resource-card-stack {
+ float: left;
+ position: relative;
+}
+.resource-flow-layout .resource-card-stack > .resource-card {
+ margin-right: 0px !important;
+}
+.resource-flow-layout:after {
+ content: ".";
+ display: block;
+ height: 0;
+ position:relative;
+ clear: both;
+ visibility: hidden;
+}
+.resource-card:hover {
+ cursor: pointer;
+}
+.static .resource-card:hover {
+ cursor: auto;
+}
+.resource-card:hover .card-bg:after {
+ opacity: 0;
+}
+/* disabled to make way for fade/ellipsis truncation,
+ and the plusone moves up.
+.resource-card:hover .card-info .description .text {
+ padding-right: 70px;
+} */
+.resource-card:hover .card-info .description .util {
+ opacity: 1;
+}
+
+/* Carousel Layout */
+/* Carousel styles for landing page */
+.resource-carousel-layout {
+ margin: 20px 0 20px 0;
+ position: relative;
+ overflow: hidden;
+}
+.resource-carousel-layout .slideshow-prev, .resource-carousel-layout .slideshow-next {
+ display: none;
+}
+.resource-carousel-layout .pagination {
+ bottom: 0px;
+}
+.resource-carousel-layout .frame li {
+ position: relative;
+}
+.resource-carousel-layout .frame li .card-bg {
+ height: 300px;
+}
+.resource-carousel-layout .frame li .card-info {
+ padding: 7px 15px 0px 15px;
+ top: 300px;
+}
+.resource-carousel-layout .frame li .card-info .section {
+ font-size: 13px;
+ margin-bottom: 7px;
+}
+.resource-carousel-layout .frame li .card-info .title {
+ font-size: 25px;
+ margin-bottom: 2px;
+}
+.resource-carousel-layout .frame li .card-info .description {
+ font-family: 15px/16px Roboto Condensed, sans-serif;
+}
+.resource-carousel-layout .frame li .card-info .description .text {
+ height: 40px;
+}
+.resource-carousel-layout .frame li .card-info .description .util {
+ bottom:97px;
+ right:4px;
+}
+
+/* Stack Layout */
+.resource-stack-layout {
+ display: inline-block;
+}
+.resource-stack-layout .resource-card-stack {
+ float: left;
+ position: relative;
+}
+.resource-stack-layout .resource-card {
+ margin-bottom: 20px;
+ display: block;
+ position: relative;
+}
+.resource-stack-layout .section-card-menu > .card-info .section, .resource-stack-layout .section-card > .card-info .title {
+ /*text-transform: uppercase;*/
+ color: #898989;
+ font-size: 17px;
+ line-height: 24px;
+ margin-bottom: 6px;
+}
+.resource-stack-layout .section-card {
+ height: 284px;
+}
+.resource-stack-layout .section-card > .card-bg {
+ height: 192px;
+}
+.resource-stack-layout .section-card > .card-info {
+ padding: 4px 12px 6px 12px;
+ top: 192px;
+}
+.resource-stack-layout .section-card > .card-info .section {
+ display: none;
+}
+.resource-stack-layout .section-card > .card-info .title {
+ font-size: 17px;
+ border-bottom: 1px solid #959595;
+ padding-bottom: 0px;
+}
+.resource-stack-layout .section-card > .card-info .description {
+ font-size: 13px;
+ line-height: 15px;
+}
+.resource-stack-layout .section-card > .card-info .description .text {
+ height: 30px;
+}
+.resource-stack-layout .related-card {
+ height: 90px;
+}
+.resource-stack-layout .related-card > .card-bg {
+ left: 0;
+ top: 0;
+ width: 90px;
+ height: 100%;
+ position: absolute;
+ display: block;
+}
+.resource-stack-layout .related-card > .card-info {
+ left: 90px;
+ padding: 4px 12px 4px 12px;
+}
+.resource-stack-layout .related-card > .card-info .section {
+ font-size: 12px;
+ margin-bottom: 1px;
+ display: none;
+}
+.resource-stack-layout .related-card > .card-info .title {
+ font-size: 16px;
+ margin-bottom: -2px;
+ white-space: normal;
+ overflow: visible;
+ text-overflow: ellipsis;
+}
+.resource-stack-layout .related-card > .card-info .title:after {
+ content: url(../images/link-out.png);
+ display: block;
+}
+.resource-stack-layout .related-card > .card-info .description {
+ display: none;
+}
+.resource-stack-layout .section-card-menu {
+ /* Flexible height */
+ display: block;
+ height: auto;
+ width: auto;
+}
+.resource-stack-layout .section-card-menu .card-bg {
+ height: 155px;
+ /* Flexible height */
+ position: relative;
+ display: inline-block;
+ vertical-align: top;
+}
+.resource-stack-layout .section-card-menu .card-info {
+ padding: 4px 12px 0px 12px;
+ /* Flexible height */
+ position: relative;
+ left: auto;
+ top: auto;
+ right: auto;
+ bottom: auto;
+}
+.resource-stack-layout .section-card-menu .card-info ul {
+ list-style: none;
+ margin: 0;
+}
+.resource-stack-layout .section-card-menu .card-info ul li {
+ list-style: none;
+ margin: 0;
+ padding: 15px 0;
+ border-top-width: 1px;
+ border-top-style: solid;
+ border-top-color: #959595;
+}
+.resource-stack-layout .section-card-menu .card-info ul li a, .resource-stack-layout .section-card-menu .card-info ul li a:focus, .resource-stack-layout .section-card-menu .card-info ul li a:link, .resource-stack-layout .section-card-menu .card-info ul li a:visited, .resource-stack-layout .section-card-menu .card-info ul li a:active, .resource-stack-layout .section-card-menu .card-info ul li a:hover {
+ color: #363636 !important;
+}
+.resource-stack-layout .section-card-menu .card-info ul li:first-child {
+ border-top: none;
+}
+.resource-stack-layout .section-card-menu .card-info ul li:hover .title:after {
+ opacity: 1;
+ -webkit-transition: opacity 0.5s;
+ -moz-transition: opacity 0.5s;
+ -o-transition: opacity 0.5s;
+ transition: opacity 0.5s;
+}
+.resource-stack-layout .section-card-menu .card-info ul li:hover .description {
+ max-height: 30px;
+ opacity: 1;
+ -webkit-transition: max-height 0.5s, opacity 1s;
+ -moz-transition: max-height 0.5s, opacity 1s;
+ -o-transition: max-height 0.5s, opacity 1s;
+ transition: max-height 0.5s, opacity 1s;
+}
+.resource-stack-layout .section-card-menu .card-info .title {
+ font-size: 16px;
+ margin-bottom: -2px;
+ position: relative;
+}
+.resource-stack-layout .section-card-menu .card-info .title:after {
+ background: url(../images/stack-arrow-right.png);
+ content: '';
+ opacity: 0;
+ -webkit-transition: opacity 0.25s;
+ -moz-transition: opacity 0.25s;
+ -o-transition: opacity 0.25s;
+ transition: opacity 0.25s;
+ position: absolute;
+ right: 0px;
+ top: 3px;
+ width: 10px;
+ height: 15px;
+}
+.resource-stack-layout .section-card-menu .card-info .title.more {
+ text-transform: uppercase;
+ color: #898989;
+ display: inline-block;
+}
+.resource-stack-layout .section-card-menu .card-info .title.more:after {
+ background: url(../images/stack-arrow-right.png);
+ content: '';
+ display: block;
+ position: absolute;
+ right: -20px;
+ top: 3px;
+ width: 10px;
+ height: 15px;
+}
+.resource-stack-layout .section-card-menu .card-info .description {
+ max-height: 0px;
+ opacity: 0;
+ overflow: hidden;
+ font-size: 13px;
+ line-height: 15px;
+ /* Hover off */
+ -webkit-transition: max-height 0.5s, opacity 0.5s;
+ -moz-transition: max-height 0.5s, opacity 0.5s;
+ -o-transition: max-height 0.5s, opacity 0.5s;
+ transition: max-height 0.5s, opacity 0.5s;
+}
+.resource-stack-layout .section-card-menu .card-info .description .text {
+ height: 30px;
+}
+.resource-stack-layout:after {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+}
+
+/* Generate the flow layout styles for a 3-column 16-col span */
+.resource-flow-layout.col-16 {
+ margin: 0 -14px 0 0;
+ width: 954px;
+}
+.resource-flow-layout.col-16 .resource-card, .resource-flow-layout.col-16 .resource-card-stack {
+ margin: 0 14px 20px 0;
+}
+.resource-flow-layout.col-16 .resource-card-row-stack-last {
+ margin-bottom: 0px !important;
+}
+.resource-flow-layout.col-16 .resource-card-col-stack-last {
+ margin-bottom: 0px !important;
+}
+.resource-flow-layout.col-16 .resource-card-3x6 {
+ width: 145px;
+ height: 284px;
+}
+.resource-flow-layout.col-16 .resource-card-3x12 {
+ width: 145px;
+ height: 588px;
+}
+.resource-flow-layout.col-16 .resource-card-3x18 {
+ width: 145px;
+ height: 892px;
+}
+.resource-flow-layout.col-16 .resource-card-6x6 {
+ width: 304px;
+ height: 284px;
+}
+.resource-flow-layout.col-16 .resource-card-6x12 {
+ width: 304px;
+ height: 588px;
+}
+.resource-flow-layout.col-16 .resource-card-6x18 {
+ width: 304px;
+ height: 892px;
+}
+.resource-flow-layout.col-16 .resource-card-9x6 {
+ width: 463px;
+ height: 284px;
+}
+.resource-flow-layout.col-16 .resource-card-9x12 {
+ width: 463px;
+ height: 588px;
+}
+.resource-flow-layout.col-16 .resource-card-9x18 {
+ width: 463px;
+ height: 892px;
+}
+.resource-flow-layout.col-16 .resource-card-12x6 {
+ width: 622px;
+ height: 284px;
+}
+.resource-flow-layout.col-16 .resource-card-12x12 {
+ width: 622px;
+ height: 588px;
+}
+.resource-flow-layout.col-16 .resource-card-12x18 {
+ width: 622px;
+ height: 892px;
+}
+.resource-flow-layout.col-16 .resource-card-15x6 {
+ width: 781px;
+ height: 284px;
+}
+.resource-flow-layout.col-16 .resource-card-15x12 {
+ width: 781px;
+ height: 588px;
+}
+.resource-flow-layout.col-16 .resource-card-15x18 {
+ width: 781px;
+ height: 892px;
+}
+.resource-flow-layout.col-16 .resource-card-18x6 {
+ width: 940px;
+ height: 284px;
+}
+.resource-flow-layout.col-16 .resource-card-18x12 {
+ width: 940px;
+ height: 420px;
+}
+.resource-flow-layout.col-16 .resource-card-18x18 {
+ width: 940px;
+ height: 892px;
+}
+.resource-flow-layout.col-16 .resource-card-3x2 {
+ width: 145px;
+ height: 95px;
+}
+.resource-flow-layout.col-16 .resource-card-3x2x3 {
+ width: 145px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-16 .resource-card-3x3 {
+ width: 145px;
+ height: 142px;
+}
+.resource-flow-layout.col-16 .resource-card-3x3x2 {
+ width: 145px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-16 .resource-card-6x2 {
+ width: 304px;
+ height: 95px;
+}
+.resource-flow-layout.col-16 .resource-card-6x2x3 {
+ width: 304px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-16 .resource-card-6x3 {
+ width: 304px;
+ height: 142px;
+}
+.resource-flow-layout.col-16 .resource-card-6x3x2 {
+ width: 304px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-16 .resource-card-9x2 {
+ width: 463px;
+ height: 95px;
+}
+.resource-flow-layout.col-16 .resource-card-9x2x3 {
+ width: 463px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-16 .resource-card-9x3 {
+ width: 463px;
+ height: 142px;
+}
+.resource-flow-layout.col-16 .resource-card-9x3x2 {
+ width: 463px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-16 .resource-card-12x2 {
+ width: 622px;
+ height: 95px;
+}
+.resource-flow-layout.col-16 .resource-card-12x2x3 {
+ width: 622px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-16 .resource-card-12x3 {
+ width: 622px;
+ height: 142px;
+}
+.resource-flow-layout.col-16 .resource-card-12x3x2 {
+ width: 622px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-16 .resource-card-15x2 {
+ width: 781px;
+ height: 95px;
+}
+.resource-flow-layout.col-16 .resource-card-15x2x3 {
+ width: 781px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-16 .resource-card-15x3 {
+ width: 781px;
+ height: 142px;
+}
+.resource-flow-layout.col-16 .resource-card-15x3x2 {
+ width: 781px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-16 .resource-card-18x2 {
+ width: 940px;
+ height: 95px;
+}
+.resource-flow-layout.col-16 .resource-card-18x2x3 {
+ width: 940px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-16 .resource-card-18x3 {
+ width: 940px;
+ height: 142px;
+}
+.resource-flow-layout.col-16 .resource-card-18x3x2 {
+ width: 940px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+
+/* Generate the flow layout styles for a 3-column 16-col span */
+.resource-flow-layout.col-12 {
+ margin: 0 -14px 0 0;
+ width: 714px;
+}
+
+.resource-flow-layout.col-12 .resource-card, .resource-flow-layout.col-12 .resource-card-stack {
+ margin: 0 14px 20px 0;
+}
+.resource-flow-layout.col-12 .resource-card-row-stack-last {
+ margin-bottom: 0px !important;
+}
+.resource-flow-layout.col-12 .resource-card-col-stack-last {
+ margin-bottom: 0px !important;
+}
+.resource-flow-layout.col-12 .resource-card-3x6 {
+ width: 105px;
+ height: 284px;
+}
+.resource-flow-layout.col-12 .resource-card-3x12 {
+ width: 105px;
+ height: 588px;
+}
+.resource-flow-layout.col-12 .resource-card-3x18 {
+ width: 105px;
+ height: 892px;
+}
+.resource-flow-layout.col-12 .resource-card-6x6 {
+ width: 224px;
+ height: 284px;
+}
+.resource-flow-layout.col-12 .resource-card-6x12 {
+ width: 224px;
+ height: 588px;
+}
+.resource-flow-layout.col-12 .resource-card-6x18 {
+ width: 224px;
+ height: 892px;
+}
+.resource-flow-layout.col-12 .resource-card-9x6 {
+ width: 343px;
+ height: 284px;
+}
+.resource-flow-layout.col-12 .resource-card-9x12 {
+ width: 343px;
+ height: 588px;
+}
+.resource-flow-layout.col-12 .resource-card-9x18 {
+ width: 343px;
+ height: 892px;
+}
+.resource-flow-layout.col-12 .resource-card-12x6 {
+ width: 462px;
+ height: 284px;
+}
+.resource-flow-layout.col-12 .resource-card-12x12 {
+ width: 462px;
+ height: 588px;
+}
+.resource-flow-layout.col-12 .resource-card-12x18 {
+ width: 462px;
+ height: 892px;
+}
+.resource-flow-layout.col-12 .resource-card-15x6 {
+ width: 581px;
+ height: 284px;
+}
+.resource-flow-layout.col-12 .resource-card-15x12 {
+ width: 581px;
+ height: 588px;
+}
+.resource-flow-layout.col-12 .resource-card-15x18 {
+ width: 581px;
+ height: 892px;
+}
+.resource-flow-layout.col-12 .resource-card-18x6 {
+ width: 700px;
+ height: 284px;
+}
+.resource-flow-layout.col-12 .resource-card-18x12 {
+ width: 700px;
+ height: 420px;
+}
+.resource-flow-layout.col-12 .resource-card-18x18 {
+ width: 700px;
+ height: 892px;
+}
+.resource-flow-layout.col-12 .resource-card-3x2 {
+ width: 105px;
+ height: 95px;
+}
+.resource-flow-layout.col-12 .resource-card-3x2x3 {
+ width: 105px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-12 .resource-card-3x3 {
+ width: 105px;
+ height: 142px;
+}
+.resource-flow-layout.col-12 .resource-card-3x3x2 {
+ width: 105px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-12 .resource-card-6x2 {
+ width: 224px;
+ height: 95px;
+}
+.resource-flow-layout.col-12 .resource-card-6x2x3 {
+ width: 224px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-12 .resource-card-6x3 {
+ width: 224px;
+ height: 142px;
+}
+.resource-flow-layout.col-12 .resource-card-6x3x2 {
+ width: 224px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-12 .resource-card-9x2 {
+ width: 343px;
+ height: 95px;
+}
+.resource-flow-layout.col-12 .resource-card-9x2x3 {
+ width: 343px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-12 .resource-card-9x3 {
+ width: 343px;
+ height: 142px;
+}
+.resource-flow-layout.col-12 .resource-card-9x3x2 {
+ width: 343px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-12 .resource-card-12x2 {
+ width: 462px;
+ height: 95px;
+}
+.resource-flow-layout.col-12 .resource-card-12x2x3 {
+ width: 462px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-12 .resource-card-12x3 {
+ width: 462px;
+ height: 142px;
+}
+.resource-flow-layout.col-12 .resource-card-12x3x2 {
+ width: 462px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-12 .resource-card-15x2 {
+ width: 581px;
+ height: 95px;
+}
+.resource-flow-layout.col-12 .resource-card-15x2x3 {
+ width: 581px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-12 .resource-card-15x3 {
+ width: 581px;
+ height: 142px;
+}
+.resource-flow-layout.col-12 .resource-card-15x3x2 {
+ width: 581px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-12 .resource-card-18x2 {
+ width: 700px;
+ height: 95px;
+}
+.resource-flow-layout.col-12 .resource-card-18x2x3 {
+ width: 700px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-12 .resource-card-18x3 {
+ width: 700px;
+ height: 142px;
+}
+.resource-flow-layout.col-12 .resource-card-18x3x2 {
+ width: 700px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+
+/* Generate the flow layout styles for a 3-column 13-col span */
+
+.resource-flow-layout.col-13 {
+ margin: 0 -14px 0 0;
+ width: 774px;
+}
+.resource-flow-layout.col-13 .resource-card, .resource-flow-layout.col-13 .resource-card-stack {
+ margin: 0 14px 20px 0;
+}
+.resource-flow-layout.col-13 .resource-card-row-stack-last {
+ margin-bottom: 0px !important;
+}
+.resource-flow-layout.col-13 .resource-card-col-stack-last {
+ margin-bottom: 0px !important;
+}
+.resource-flow-layout.col-13 .resource-card-3x6 {
+ width: 115px;
+ height: 284px;
+}
+.resource-flow-layout.col-13 .resource-card-3x12 {
+ width: 115px;
+ height: 588px;
+}
+.resource-flow-layout.col-13 .resource-card-3x18 {
+ width: 115px;
+ height: 892px;
+}
+.resource-flow-layout.col-13 .resource-card-6x6 {
+ width: 244px;
+ height: 284px;
+}
+.resource-flow-layout.col-13 .resource-card-6x12 {
+ width: 244px;
+ height: 588px;
+}
+.resource-flow-layout.col-13 .resource-card-6x18 {
+ width: 244px;
+ height: 892px;
+}
+.resource-flow-layout.col-13 .resource-card-9x6 {
+ width: 373px;
+ height: 284px;
+}
+.resource-flow-layout.col-13 .resource-card-9x12 {
+ width: 373px;
+ height: 588px;
+}
+.resource-flow-layout.col-13 .resource-card-9x18 {
+ width: 373px;
+ height: 892px;
+}
+.resource-flow-layout.col-13 .resource-card-12x6 {
+ width: 502px;
+ height: 284px;
+}
+.resource-flow-layout.col-13 .resource-card-12x12 {
+ width: 502px;
+ height: 588px;
+}
+.resource-flow-layout.col-13 .resource-card-12x18 {
+ width: 502px;
+ height: 892px;
+}
+.resource-flow-layout.col-13 .resource-card-15x6 {
+ width: 631px;
+ height: 284px;
+}
+.resource-flow-layout.col-13 .resource-card-15x12 {
+ width: 631px;
+ height: 588px;
+}
+.resource-flow-layout.col-13 .resource-card-15x18 {
+ width: 631px;
+ height: 892px;
+}
+.resource-flow-layout.col-13 .resource-card-18x6 {
+ width: 760px;
+ height: 284px;
+}
+.resource-flow-layout.col-13 .resource-card-18x12 {
+ width: 760px;
+ height: 420px;
+}
+.resource-flow-layout.col-13 .resource-card-18x18 {
+ width: 760px;
+ height: 892px;
+}
+.resource-flow-layout.col-13 .resource-card-3x2 {
+ width: 115px;
+ height: 95px;
+}
+.resource-flow-layout.col-13 .resource-card-3x2x3 {
+ width: 115px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-13 .resource-card-3x3 {
+ width: 115px;
+ height: 142px;
+}
+.resource-flow-layout.col-13 .resource-card-3x3x2 {
+ width: 115px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-13 .resource-card-6x2 {
+ width: 244px;
+ height: 95px;
+}
+.resource-flow-layout.col-13 .resource-card-6x2x3 {
+ width: 244px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-13 .resource-card-6x3 {
+ width: 244px;
+ height: 142px;
+}
+.resource-flow-layout.col-13 .resource-card-6x3x2 {
+ width: 244px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-13 .resource-card-9x2 {
+ width: 373px;
+ height: 95px;
+}
+.resource-flow-layout.col-13 .resource-card-9x2x3 {
+ width: 373px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-13 .resource-card-9x3 {
+ width: 373px;
+ height: 142px;
+}
+.resource-flow-layout.col-13 .resource-card-9x3x2 {
+ width: 373px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-13 .resource-card-12x2 {
+ width: 502px;
+ height: 95px;
+}
+.resource-flow-layout.col-13 .resource-card-12x2x3 {
+ width: 502px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-13 .resource-card-12x3 {
+ width: 502px;
+ height: 142px;
+}
+.resource-flow-layout.col-13 .resource-card-12x3x2 {
+ width: 502px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-13 .resource-card-15x2 {
+ width: 631px;
+ height: 95px;
+}
+.resource-flow-layout.col-13 .resource-card-15x2x3 {
+ width: 631px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-13 .resource-card-15x3 {
+ width: 631px;
+ height: 142px;
+}
+.resource-flow-layout.col-13 .resource-card-15x3x2 {
+ width: 631px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+.resource-flow-layout.col-13 .resource-card-18x2 {
+ width: 760px;
+ height: 95px;
+}
+.resource-flow-layout.col-13 .resource-card-18x2x3 {
+ width: 760px;
+ height: 90px;
+ margin-bottom: 7px;
+}
+.resource-flow-layout.col-13 .resource-card-18x3 {
+ width: 760px;
+ height: 142px;
+}
+.resource-flow-layout.col-13 .resource-card-18x3x2 {
+ width: 760px;
+ height: 138px;
+ margin-bottom: 8px;
+}
+
+/*
+ The following are styles for cards in the flowlayout above, styled by the number of rows they span
+*/
+/* Single row items, might be simpler to just apply a class */
+.resource-card-3x6 > .card-bg, .resource-card-6x6 > .card-bg, .resource-card-9x6 > .card-bg, .resource-card-12x6 > .card-bg, .resource-card-15x6 > .card-bg, .resource-card-18x6 > .card-bg {
+ height: 192px;
+}
+.resource-card-3x6 > .card-info, .resource-card-6x6 > .card-info, .resource-card-9x6 > .card-info, .resource-card-12x6 > .card-info, .resource-card-15x6 > .card-info, .resource-card-18x6 > .card-info {
+ padding: 4px 12px 6px 12px;
+ top: 192px;
+}
+.resource-card-3x6 > .card-info .section, .resource-card-6x6 > .card-info .section, .resource-card-9x6 > .card-info .section, .resource-card-12x6 > .card-info .section, .resource-card-15x6 > .card-info .section, .resource-card-18x6 > .card-info .section {
+ font-size: 12px;
+ margin-bottom: 1px;
+}
+.resource-card-3x6 > .card-info .title, .resource-card-6x6 > .card-info .title, .resource-card-9x6 > .card-info .title, .resource-card-12x6 > .card-info .title, .resource-card-15x6 > .card-info .title, .resource-card-18x6 > .card-info .title {
+ font-size: 16px;
+ margin-bottom: -2px;
+}
+.resource-card-3x6 > .card-info .description, .resource-card-6x6 > .card-info .description, .resource-card-9x6 > .card-info .description, .resource-card-12x6 > .card-info .description, .resource-card-15x6 > .card-info .description, .resource-card-18x6 > .card-info .description {
+ font-size: 13px;
+ line-height: 15px;
+}
+.resource-card-3x6 > .card-info .description .text, .resource-card-6x6 > .card-info .description .text, .resource-card-9x6 > .card-info .description .text, .resource-card-12x6 > .card-info .description .text, .resource-card-15x6 > .card-info .description .text, .resource-card-18x6 > .card-info .description .text {
+ height: 30px;
+}
+
+/* Double row items */
+.resource-card-3x12 > .card-bg, .resource-card-6x12 > .card-bg, .resource-card-9x12 > .card-bg, .resource-card-12x12 > .card-bg, .resource-card-15x12 > .card-bg, .resource-card-18x12 > .card-bg {
+ height: 320px;
+}
+.resource-card-3x12 > .card-info, .resource-card-6x12 > .card-info, .resource-card-9x12 > .card-info, .resource-card-12x12 > .card-info, .resource-card-15x12 > .card-info, .resource-card-18x12 > .card-info {
+ padding: 4px 12px 6px 12px;
+ top: 320px;
+}
+.resource-card-3x12 > .card-info .section, .resource-card-6x12 > .card-info .section, .resource-card-9x12 > .card-info .section, .resource-card-12x12 > .card-info .section, .resource-card-15x12 > .card-info .section, .resource-card-18x12 > .card-info .section {
+ font-size: 12px;
+ margin-bottom: 1px;
+}
+.resource-card-3x12 > .card-info .title, .resource-card-6x12 > .card-info .title, .resource-card-9x12 > .card-info .title, .resource-card-12x12 > .card-info .title, .resource-card-15x12 > .card-info .title, .resource-card-18x12 > .card-info .title {
+ font-size: 16px;
+ margin-bottom: -2px;
+ white-space: normal;
+}
+.resource-card-3x12 > .card-info .description, .resource-card-6x12 > .card-info .description, .resource-card-9x12 > .card-info .description, .resource-card-12x12 > .card-info .description, .resource-card-15x12 > .card-info .description, .resource-card-18x12 > .card-info .description {
+ font-size: 13px;
+ line-height: 15px;
+}
+
+/* 1/3 row items */
+.resource-card-3x2 > .card-bg, .resource-card-6x2 > .card-bg, .resource-card-9x2 > .card-bg, .resource-card-12x2 > .card-bg, .resource-card-15x2 > .card-bg, .resource-card-18x2 > .card-bg {
+ left: 0;
+ top: 0;
+ width: 90px;
+ height: 100%;
+ position: absolute;
+ display: block;
+}
+.resource-card-3x2 > .card-info, .resource-card-6x2 > .card-info, .resource-card-9x2 > .card-info, .resource-card-12x2 > .card-info, .resource-card-15x2 > .card-info, .resource-card-18x2 > .card-info {
+ left: 90px;
+ padding: 4px 12px 4px 12px;
+ height: 80px;
+ overflow: hidden;
+}
+.resource-card-3x2 > .card-info .section, .resource-card-6x2 > .card-info .section, .resource-card-6x3 > .card-info .section, .resource-card-9x2 > .card-info .section, .resource-card-12x2 > .card-info .section, .resource-card-15x2 > .card-info .section, .resource-card-18x2 > .card-info .section {
+ font-size: 12px;
+ margin-bottom: 1px;
+ /* display: none; */
+}
+.resource-card-3x2 > .card-info .title, .resource-card-6x2 > .card-info .title, .resource-card-9x2 > .card-info .title, .resource-card-12x2 > .card-info .title, .resource-card-15x2 > .card-info .title, .resource-card-18x2 > .card-info .title {
+ font-size: 16px;
+ margin-bottom: -2px;
+ white-space: normal;
+ overflow: visible;
+ text-overflow: ellipsis;
+}
+.resource-card-3x2 > .card-info .title:after, .resource-card-6x2 > .card-info .title:after, .resource-card-9x2 > .card-info .title:after, .resource-card-12x2 > .card-info .title:after, .resource-card-15x2 > .card-info .title:after, .resource-card-18x2 > .card-info .title:after {
+ /* content: url(../images/link-out.png); */
+ display: block;
+}
+.resource-card-3x2 > .card-info .description, .resource-card-6x2 > .card-info .description, .resource-card-9x2 > .card-info .description, .resource-card-12x2 > .card-info .description, .resource-card-15x2 > .card-info .description, .resource-card-18x2 > .card-info .description {
+ display: none;
+}
+
+
+/* Override to show the description instead of the content section */
+.no-section .resource-card-3x2 > .card-info .section,
+.no-section .resource-card-6x2 > .card-info .section {
+ display: none;
+}
+.no-section .resource-card-3x2 > .card-info .description,
+.no-section .resource-card-6x2 > .card-info .description {
+ display: block;
+}
+
+/* 1/2 row items */
+.resource-card-3x3 > .card-bg, .resource-card-6x3 > .card-bg, .resource-card-9x3 > .card-bg, .resource-card-12x3 > .card-bg, .resource-card-15x3 > .card-bg, .resource-card-18x3 > .card-bg {
+ left: 0;
+ top: 0;
+ width: 90px;
+ height: 100%;
+ position: absolute;
+ display: block;
+}
+.resource-card-3x3 > .card-info, .resource-card-6x3 > .card-info, .resource-card-9x3 > .card-info, .resource-card-12x3 > .card-info, .resource-card-15x3 > .card-info, .resource-card-18x3 > .card-info {
+ left: 90px;
+ padding: 4px 12px 0px 12px;
+}
+.resource-card-3x3 > .card-info .section, .resource-card-6x3 > .card-info .section, .resource-card-9x3 > .card-info .section, .resource-card-12x3 > .card-info .section, .resource-card-15x3 > .card-info .section, .resource-card-18x3 > .card-info .section {
+ font-size: 12px;
+ margin-bottom: 1px;
+ display: none;
+}
+.resource-card-3x3 > .card-info .title, .resource-card-6x3 > .card-info .title, .resource-card-9x3 > .card-info .title, .resource-card-12x3 > .card-info .title, .resource-card-15x3 > .card-info .title, .resource-card-18x3 > .card-info .title {
+ font-size: 16px;
+ margin-bottom: -2px;
+ white-space: normal;
+ overflow: visible;
+}
+.resource-card-3x3 > .card-info .description .text, .resource-card-6x3 > .card-info .description .text, .resource-card-9x3 > .card-info .description .text, .resource-card-12x3 > .card-info .description .text, .resource-card-15x3 > .card-info .description .text, .resource-card-18x3 > .card-info .description .text {
+ font-size: 12px;
+ line-height: 15px;
+ padding-right: 0px !important;
+ height: 80px;
+}
+.resource-card-3x3 > .card-info .description .util, .resource-card-6x3 > .card-info .description .util, .resource-card-9x3 > .card-info .description .util, .resource-card-12x3 > .card-info .description .util, .resource-card-15x3 > .card-info .description .util, .resource-card-18x3 > .card-info .description .util {
+ display: none;
+}
+/* placement of plusone */
+.resource-card-6x12 > .card-info .description .util, .resource-card-9x12 > .card-info .description .util, .resource-card-12x12 > .card-info .description .util, .resource-card-15x12 > .card-info .description .util {
+ bottom:2px;
+}
+.resource-card-18x12 > .card-info .description .util {
+ bottom:2px;
+}
+/* Overrides for col-16 6x6 cards linking to local content on landing pages.
+ Suppresses "section" and puts the title above a hairline rule. */
+.landing .card-info .section, .resource-flow-layout.col-16.landing .resource-card-9x6 .card-info .section {
+ display:none;
+}
+.landing .card-info .title {
+ color: #898989;
+ font-size: 17px;
+ line-height: 24px;
+ margin-bottom: 6px;
+ border-bottom: 1px solid #959595;
+ padding-bottom: 0px;
+}
+.landing .card-info .description {
+ font-size: 13px;
+ line-height: 15px;
+}
+.landing .card-info .description .text {
+height:30px;
+}
+.landing .resource-card-6x6 > .card-info .description .util, .landing .resource-card-9x6 > .card-info .description .util {
+ bottom:2px;
+}
+/*
+ Generate a resource stack layout for a 3 column widget spanning 16 grid cols
+*/
+.resource-stack-layout.col-16 {
+ margin: 0 -14px 0 0;
+ width: 954px;
+}
+.resource-stack-layout.col-16 .resource-card-stack {
+ margin: 0 14px 0 0;
+ width: 304px;
+}
+
+/* Example of card menu tinting */
+.resource-widget[data-section=distribute\/tools] .section-card-menu
+.card-bg:after {
+ background: rgba(126, 55, 148, 0.4) !important;
+}
+.resource-widget[data-section=distribute\/tools] .section-card-menu
+.card-section-icon .icon {
+ background-color: #7e3794 !important;
+}
+.resource-widget[data-section=distribute\/tools] .section-card-menu
+.card-info ul li {
+ border-top-color: #7e3794 !important;
+}
+
+/* tinting for stacks */
+
+div.jd-descr > .resource-widget[data-section=distribute\/tools]
+.section-card-menu .card-info ul li {
+ border-top-color: #7e3794 !important;
+}
+
+
+
+/**
+ * UTILITIES
+ */
+
+
+.border-box {
+ box-sizing: border-box;
+}
+
+.vertical-center-outer {
+ display: table;
+ height: 100%;
+ width: 100%;
+}
+
+.vertical-center-inner {
+ display: table-cell;
+ vertical-align: middle;
+}
+
+/**
+ * TYPE STYLES
+ */
+
+.landing-h1 {
+ font-weight: 100;
+ font-size: 60px;
+ line-height: 78px;
+ text-align: center;
+ letter-spacing: -1px;
+}
+
+.landing-pre-h1 {
+ font-weight: 400;
+ font-size: 28px;
+ color: #93B73F;
+ line-height: 36px;
+ text-align: center;
+ letter-spacing: -1px;
+ text-transform: uppercase;
+
+}
+
+.landing-h1.hero {
+ text-align: left;
+}
+
+.landing-h2 {
+ font-weight: 300;
+ font-size: 42px;
+ line-height: 64px;
+ text-align: center;
+}
+
+.landing-subhead {
+ color: #999999;
+ font-size: 20px;
+ line-height: 28px;
+ font-weight:300;
+ text-align: center;
+}
+.landing-subhead.hero {
+ text-align: left;
+ color: white;
+}
+
+.landing-hero-description {
+ text-align: left;
+ margin: 1em 0;
+}
+
+.landing-hero-description p {
+ font-weight: 300;
+ margin: 0;
+ font-size: 18px;
+ line-height: 24px;
+}
+
+.landing-body .landing-small {
+ font-size: 14px;
+ line-height: 19px;
+}
+
+.landing-body.landing-align-center {
+ text-align: center;
+}
+
+.landing-align-left {
+ text-align: left;
+}
+
+/**
+ * LAYOUT
+ */
+
+#body-content,
+.fullpage,
+#jd-content,
+.jd-descr,
+.landing-body-content {
+ height: 100%;
+}
+
+.landing-section {
+ padding: 80px 10px 80px;
+ width: 100%;
+ margin-left: -10px;
+ text-rendering: optimizeLegibility;
+}
+
+#extending-android-to-wearables {
+ padding-top: 30px;
+}
+
+.landing-short-section {
+ padding: 40px 10px 28px;
+}
+
+.landing-gray-background {
+ background-color: #e9e9e9;
+}
+
+.landing-white-background {
+ background-color: white;
+}
+
+.landing-red-background {
+ color: white;
+ background-color: hsl(8, 70%, 54%);
+}
+
+.landing-subhead-red {
+ color: hsl(8, 71%, 84%);
+ text-align: left;
+}
+
+.landing-subhead-red p {
+ margin-top: 20px;
+}
+
+.landing-hero-container {
+ height: 100%;
+}
+
+
+.preview-hero {
+ height: calc(100% - 110px);
+ min-height: 504px;
+ margin-top: -5px;
+ padding-top: 0;
+ padding-bottom: 0;
+ background-image: url(../../preview/images/hero.jpg);
+ background-size: cover;
+ background-position: right center;
+ color: white;
+ position: relative;
+ overflow: hidden;
+}
+
+.wear-hero {
+ height: calc(100% - 110px);
+ min-height: 504px;
+ margin-top: -5px;
+ padding-top: 0;
+ padding-bottom: 0;
+ background-image: url(../../wear/images/hero.jpg);
+ background-size: cover;
+ background-position: top center;
+ color: white;
+ position: relative;
+ overflow: hidden;
+}
+
+.tv-hero {
+ height: calc(100% - 110px);
+ min-height: 504px;
+ margin-top: -5px;
+ padding-top: 0;
+ padding-bottom: 0;
+ background-image: url(../../tv/images/hero.jpg);
+ background-size: cover;
+ background-position: right center;
+ color: white;
+ position: relative;
+ overflow: hidden;
+}
+
+.auto-hero {
+ height: calc(100% - 110px);
+ min-height: 504px;
+ margin-top: -5px;
+ padding-top: 0;
+ padding-bottom: 0;
+ background-image: url(../../auto/images/hero.jpg);
+ background-size: cover;
+ background-position: right center;
+ color: white;
+ position: relative;
+ overflow: hidden;
+}
+
+.landing-hero-scrim {
+ background: black;
+ opacity: .2;
+ position: absolute;
+ width: 100%;
+ height: 100%;
+ margin-left: -10px;
+}
+
+.landing-hero-wrap {
+ margin: 0 auto;
+ width: 940px;
+ clear: both;
+ height: 100%;
+ position: relative;
+}
+
+.landing-section-header {
+ margin-bottom: 40px;
+}
+
+.landing-hero-wrap .landing-section-header {
+ margin-bottom: 16px;
+}
+
+.landing-body {
+ font-size: 18px;
+ line-height: 24px;
+}
+
+.landing-button {
+ white-space: nowrap;
+ display: inline-block;
+ padding: 16px 32px;
+ font-size: 18px;
+ font-weight: 500;
+ line-height: 24px;
+ cursor: pointer;
+ color: white;
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -o-user-select: none;
+ user-select: none;
+ -webkit-transition: .2s background-color ease-in-out;
+ -moz-transition: .2s background-color ease-in-out;
+ -o-transition: .2s background-color ease-in-out;
+ transition: .2s background-color ease-in-out;
+}
+
+.landing-primary {
+ background-color: hsl(8, 70%, 44%);
+ color: #f8f8f8;
+}
+
+.landing-button.landing-primary:hover {
+ background-color: hsl(8, 70%, 36%);
+}
+
+.landing-button.landing-primary:active {
+ background-color: hsl(8, 70%, 30%);
+}
+
+.landing-button.landing-secondary {
+ background-color: #2faddb;
+}
+
+.landing-button.landing-secondary:hover {
+ background-color: #09c;
+}
+
+.landing-button.landing-secondary:active {
+ background-color: #3990ab;
+}
+
+a.landing-button,
+a.landing-button:hover,
+a.landing-button:visited {
+ color: white !important;
+}
+
+.landing-video-link {
+ white-space: nowrap;
+ display: inline-block;
+ padding: 16px 32px 16px 82px;
+ font-size: 18px;
+ font-weight: 400;
+ line-height: 24px;
+ cursor: pointer;
+ color: hsla(0, 0%, 100%, .8);
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ -o-user-select: none;
+ user-select: none;
+ -webkit-transition: .2s color ease-in-out;
+ -moz-transition: .2s color ease-in-out;
+ -o-transition: .2s color ease-in-out;
+ transition: .2s color ease-in-out;
+}
+
+.landing-video-link:before {
+ height: 64px;
+ width: 64px;
+ display: inline-block;
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAFuklEQVR42u2dXWgcVRSAV9LWtBBTTZVWUhNqEQtq1QeroDRKFRFsROqTYPuo+JCiIoJKFC0USqlUfCiowRcfrBgVUUElefAPkW5T8aeaGn9aRbFsjP0x2cx8PuRMvFxmdjeb2Z17Z8+B85DsZPbO+eaec3/OPSkABdXsVI2gABSAqgJQAKoKQAGoKgAFoKoAFICqAlAAqgpAAai6DqDRAiwDeoFtwB7gPaAInABKwKToCWAMeB/YDdwJrAWWNLh9+QMAXABsBQ4A3wFTwAxQBmaBAAhjNJDPy3L938BXwAvArUCHAkh+kCXAVcA+YBw4bRg7MngtkgTlDPA98CywHmhTAP8/xCbgVeAvMZZpwDQllN7xB/AysKGlAQAXAvuBkzW85UVgCBgENlfQQbmuWAXELPAnsAvoaikAQBtwh/j3coLhS2LIfqCzzu/plL8fkvvFgZiR4L2lHrfkHQBgpQTFUwmGnwC212v0KjC2y/3jQPwDPA+05xYAcBHwubx1YZzhC02QBBBRbxgBzssdAOBy4JgRZE0ZTPuNr7FHDCbEhqNAd24AAN0yUbID7QSwsZChABut3hANXY8Bq70HIMb/Ocb4w81+66v0hmGrN0QQ1ngLQJYRvpWHMWWo4KDIaMnuCcVKgdlZAGL8t2J8vpPGrwChDLyWBMFlAA8D0z4ZvwKEs8D93gCQEc9Jy/jFgkdizaRDGUSs8wXAu1bQLQE9ngHosWbPAXDQeQAypT9rBd3+gociyxi2K9riLABZUj5iuZ6RgsciM2OzFxw2A7JrAO6VwGtKTwpG+Anoy9AVmb3gDHCPcwCAFcChRox6jPu9CazMeFQUAKNRL3AJwE2yopjq228BQPZ/d2bcCyaBTa4BeNGa8Q6naIA4GQWubiKEYWvBbp8zAGQt5VfL/fQ3GEAkTzXDLVkjokA2k5a7AuA2GaLNj/tTfvhq0pQgbcwLQtlQusYVALtlzSR191MjADNI9zbJDZWBR10BMGr5/4GMADQ0SAMDlht62xUAxy0AmzMEEMnhtIO0ZF2YAH5wITd0hQw/5wE04M1bjDyXZpC2hqMlYGnWAHqBf40APOEYgChI35VSWyasWfGqrAH0WVkOIw4CSC1IG2tDoSy7XJE1gPs8ArDoIG0BmJGk30wBDHgGYFFBOgbAtqwB7GxxAHerC8rOBU0Dt2gQzjYIb8gawDor+6HVhqFdrkzEwhabiAVOTMSkUb+06FLEUVfWgj5q0cW4g64AeNo66ZLlcnTDNmesBN4y8KArAG6QU42ttCEzBVzpCoAO4EfLDeV5SzIEvgHaXdqUP2BlQud1Ux55zj2uZUX02cPRnKalRLmu17qYmPWF5YbymJgVAh8Ay5wCII3ZEZOYm6fURGT2u9X43Mnk3CDHybmfmRVYXExPv9nKEcpLejqSC3SjdY2TBzTesHqB7wc0onTEV2KucxLApXKkJy9HlAI5anuJFwCkYQ/EuCJfD+mdBnYkXOssgHY53un7MdVZ4CVgqVcADAhjMafkfTioHc14P04yvvMApIEXy5F/+7S8y6UKolPyR4BVVf7Wi2IdawwIPhTrmAW+rmZ8bwBIQ7vloXwoVzNWS6UUrwAYy9YfOlqwKZDkgneA5Qu4l3cly84F9sqGhislywLmaozuYoGFXr0DII1ukxP1hxJ6QzR7HqLxRfumZaRzXZ3f4XXZyi7gCeB3kqsnzs+kSb9s5XHgMeD8RTxDLgq3rmeuYuFvNYCoR8wqujNi+L3UWBcu9wAMt3QZ8LiMlk5RuU50teq6kcEDgTolveIRYHUQBOek1O5cFu/ukLz7/ZJgNSm+OirebWpgaPS7slxfAr4EngGuX8jopqUBxGzyrAVuB54EXgc+lV4yLhO8cfn5E+ZqUD8kBu9sQvv0Hzj4rmoEBaAAVBWAAlBVAApAVQEoAFUFoABUFYACUFUACkC1CfofXVRJocowZVYAAAAASUVORK5CYII=);
+ background-size: contain;
+ position: absolute;
+ content: "";
+ opacity: .7;
+ margin-top: -19px;
+ margin-left: -64px;
+ -webkit-transition: .2s opacity ease-in-out;
+ -moz-transition: .2s opacity ease-in-out;
+ -o-transition: .2s opacity ease-in-out;
+ transition: .2s opacity ease-in-out;
+}
+
+.landing-video-link:hover {
+ color: hsla(0, 0%, 100%, 1);
+}
+
+.landing-video-link:hover:before {
+ opacity: 1;
+}
+
+.landing-social-image {
+ float: left;
+ margin-right: 14px;
+ height: 64px;
+ width: 64px;
+}
+
+.landing-social-copy {
+ padding-left: 78px;
+}
+
+.landing-scroll-down-affordance {
+ position: absolute;
+ bottom: 0;
+ width: 100%;
+ text-align: center;
+ z-index: 10;
+}
+
+.landing-down-arrow {
+ padding: 24px;
+ display: inline-block;
+ opacity: .5;
+ -webkit-transition: .2s opacity ease-in-out;
+ -moz-transition: .2s opacity ease-in-out;
+ -o-transition: .2s opacity ease-in-out;
+ transition: .2s opacity ease-in-out;
+
+ -webkit-animation-name: pulse-opacity;
+ -webkit-animation-duration: 4s;
+}
+
+.landing-down-arrow:hover {
+ opacity: 1;
+}
+
+.landing-down-arrow img {
+ height: 28px;
+ width: 28px;
+ margin: 0 auto;
+ display: block;
+}
+
+.landing-divider {
+ display: inline-block;
+ height: 2px;
+ background-color: white;
+ position: relative;
+ margin: 10px 0;
+}
+
+/* 3 CLOLUMN LAYOUT */
+
+.landing-breakout {
+ margin-top: 40px;
+ margin-bottom: 40px;
+}
+
+.landing-breakout img {
+ margin-bottom: 20px;
+}
+
+.landing-partners img {
+ margin-bottom: 20px;
+}
+
+.landing-breakout p {
+ padding: 0 23px;
+}
+
+.landing-breakout.landing-partners img {
+ margin-bottom: 20px;
+}
+
+.col-3-wide {
+ display: inline;
+ float: left;
+ margin-left: 10px;
+ margin-right: 10px;
+}
+
+.col-3-wide {
+ width: 302px;
+}
+
+/**
+ * ANIMATION
+ */
+
+@-webkit-keyframes pulse-opacity {
+ 0% {
+ opacity: .5;
+ }
+ 20% {
+ opacity: .5;
+ }
+ 40% {
+ opacity: 1;
+ }
+ 60% {
+ opacity: .5;
+ }
+ 80% {
+ opacity: 1;
+ }
+ 100% {
+ opacity: .5;
+ }
+}
+
+
+
+/**
+ * VIDEO
+ */
+
+#video-container {
+ display:none;
+ position:fixed;
+ top:0;
+ left:0;
+ width:100%;
+ height:100%;
+ background-color:rgba(0,0,0,0.8);
+ z-index:9999;
+}
+
+#video-frame {
+ width:940px;
+ height:100%;
+ margin:72px auto;
+ display:none;
+ position:relative;
+}
+
+.video-close {
+ cursor: pointer;
+ position: absolute;
+ right: -49px;
+ top: -49px;
+ pointer-events: all;
+}
+
+#icon-video-close {
+ background-image: url("../images/close-white.png");
+ background-image: -webkit-image-set(url(../images/close-white.png) 1x, url(../images/close-white_2x.png) 2x);
+ background-repeat: no-repeat;
+ background-position: 0 0;
+ background-size: 36px 36px;
+ height: 36px;
+ width: 36px;
+ display:block;
+}
+
+#icon-video-close:hover {
+ background-image: url("../images/close-grey.png");
+ background-image: -webkit-image-set(url(../images/close-grey.png) 1x, url(../images/close-grey_2x.png) 2x);
+}
+
+/* Preload the hover images */
+a.video-shadowbox-button.white:after {
+ display:none;
+ content:url("../images/close-grey.png") url("../images/close-grey_2x.png");
+}
+
+a.video-shadowbox-button.white {
+ background-image: url("../images/play-circle-white.png");
+ background-image: -webkit-image-set(url(../images/play-circle-white.png) 1x, url(../images/play-circle-white_2x.png) 2x);
+ background-size: 36px 36px;
+ background-repeat: no-repeat;
+ background-position: right;
+ padding: 16px 42px 16px 8px;
+ font-size: 18px;
+ font-weight: 500;
+ line-height: 24px;
+ color: #fff;
+ text-decoration:none;
+}
+
+a.video-shadowbox-button.white:hover {
+ color:#bababa !important;
+ background-image: url("../images/play-circle-grey.png");
+ background-image: -webkit-image-set(url(../images/play-circle-grey.png) 1x, url(../images/play-circle-grey_2x.png) 2x);
+}
+
+/* Preload the hover images */
+a.video-shadowbox-button.white:after {
+ display:none;
+ content:url("../images/play-circle-grey.png") url("../images/play-circle-grey_2x.png");
+}
+
+/******************
+Styles for d.a.c/index:
+*******************/
+
+
+
+/* Generic full screen carousel styling to be used across pages. */
+.fullscreen-carousel {
+ margin: 0 -10px;
+ width: 100%;
+ overflow: hidden;
+ position: relative;
+}
+
+.fullscreen-carousel-content {
+ width: 100%;
+ height: 100%;
+ position: relative;
+ display: table; /* For vertical centering */
+}
+
+.fullscreen-carousel .vcenter {
+ display: table-cell;
+ vertical-align: middle;
+ position: relative;
+}
+
+.fullscreen-carousel .vcenter > div {
+ margin: 10px auto;
+}
+
+/* Styles for the full-bleed hero image type. */
+.fullscreen-carousel .hero, .fullscreen-carousel .hero h1 {
+ color: #fff;
+}
+
+.fullscreen-carousel .hero h1 {
+ font-weight: 300;
+ font-size: 60px;
+ line-height: 68px;
+ letter-spacing: -1px;
+ margin-top: 0;
+}
+
+.fullscreen-carousel .hero p {
+ font-weight: 300;
+ font-size: 18px;
+ line-height: 24px;
+ -webkit-font-smoothing: antialiased;
+}
+
+.fullscreen-carousel .hero .hero-bg {
+ background-size: cover;
+ width: 100%;
+ height: 100%;
+ position: absolute;
+ left: 0px;
+ top: 0px;
+}
+
+
+/* Full screen carousel styling for the resource flow layout type of content */
+.fullscreen-carousel .resource-flow-layout:after {
+ height: 0; /* Dont know why this is set at 10 in default.css */
+}
+
+.fullscreen-carousel .resource-flow-layout {
+ margin-bottom: 20px;
+}
+
+
+
+/* Generic Tab carousel styling to be used across multiple pages. */
+
+.tab-carousel .tab-nav {
+ list-style: none;
+ position: relative;
+ text-align: center;
+}
+
+.tab-carousel .tab-nav li {
+ display: inline-block;
+ font-size: 22px;
+ font-weight: 400;
+ line-height: 50px;
+ list-style: none;
+ margin: 0;
+ padding: 0 25px;
+ position: relative;
+}
+
+.tab-carousel .tab-nav li a,
+.tab-carousel .tab-nav li a:hover {
+ color: #333 !important;
+ padding: 10px 10px 13px 10px;
+ position: relative;
+ z-index: 1000;
+}
+
+.tab-carousel .tab-nav li:after {
+ background: #ddd;
+ bottom: 0;
+ content: '';
+ height: 4px;
+ left: 0;
+ position: absolute;
+ width: 100%;
+ z-index: 0;
+}
+
+.tab-carousel .tab-nav .highlight {
+ position: absolute;
+ height: 4px;
+ width: 100px;
+ bottom: 0;
+ background: #33b5e5;
+}
+
+.tab-carousel .tab-carousel-content {
+ position: relative;
+ overflow: hidden;
+ white-space: nowrap;
+}
+
+.tab-carousel .tab-carousel-content [data-tab] {
+ display: inline-block;
+ white-space: normal;
+}
+
+
+
+/*
+ Resource styling for the tab carousel. The tab carousel contains either
+ a 3 column layout of resources or a single full-width resource. The
+ latter has the 18x12 class applied to it and can be styled differently
+ that way.
+*/
+
+.tab-carousel .resource .image {
+ width: 100%;
+ height: 250px;
+ background-repeat: no-repeat;
+ background-size: contain;
+ background-position: 50% 50%;
+}
+
+.tab-carousel .resource .info .title {
+ font-size: 18px;
+ line-height: 24px;
+}
+
+.tab-carousel .resource .info .summary,
+.tab-carousel .resource .info .cta {
+ line-height: 24px;
+ font-size: 16px;
+}
+
+.tab-carousel .resource-card-18x12 {
+ position: relative;
+ padding-left: 450px;
+ box-sizing: border-box;
+ display: table-cell;
+ vertical-align: middle;
+}
+
+.tab-carousel .resource-card-18x12 .image {
+ position: absolute;
+ width: 420px;
+ height: 100%;
+ left: 0;
+ top: 0;
+}
+
+.tab-carousel .resource-card-18x12 .info {
+ display: inline-block;
+}
+
+.tab-carousel .resource-card-18x12 .info .title {
+ margin-bottom: 26px;
+}
+
+
+
+
+
+/*
+ Styles for the entity link used in the actions bar and in the cta of
+ the resources that appear in the tab carousel.
+*/
+.actions-bar a:after,
+.resource .cta:after {
+ content: '›';
+ font-weight: 400;
+ font-size: 22px;
+ left: 5px;
+ line-height: 1;
+ position: relative;
+ top: 1px;
+ transition: left 190ms ease-out;
+}
+
+.actions-bar a:hover:after,
+.resource .cta:hover:after {
+ left: 10px;
+}
+
+
+
+
+/*
+ Styles for the actions bar.
+*/
+.actions-bar {
+ background: #9acd00;
+ margin: 0 -10px;
+ text-align: center;
+}
+
+.actions-bar .actions {
+ padding: 30px 0 30px;
+ text-align: justify;
+ font-size: 0.1px;
+ line-height: 0.1px;
+ margin: 0 10px 0 0;
+}
+
+.actions-bar .actions:after {
+ content: '';
+ width: 100%;
+ display: inline-block;
+}
+
+.actions-bar .actions > div {
+ display: inline-block;
+}
+
+.actions-bar a {
+ font-size: 21px;
+ line-height: 27px;
+ color: #fff;
+ font-weight: 300;
+ -webkit-font-smoothing: antialiased;
+}
+
+.actions-bar a:after {
+ top: 0px;
+ font-size: 22px;
+}
+
+.actions-bar a:hover {
+ color: #fff !important;
+}
+
+
+
+
+
+/*
+ Specific styles for new home page layout of the carousels.
+*/
+
+/* Big blue button */
+a.home-new-cta-btn,
+.home-new-carousel-1 .resource-card-18x6 .cta {
+ white-space: nowrap;
+ display: inline-block;
+ padding: 14px 32px;
+ font-size: 18px;
+ font-weight: 500;
+ line-height: 24px;
+ cursor: pointer;
+ background: #33b5e6;
+ border-radius: 4px;
+ margin-top: 20px;
+ color: #fff;
+ transition: 0.2s background-color ease-in-out;
+}
+
+.home-new-carousel-1 .resource-card-18x6 .cta:after {
+ display: none; /* Hide the entity for this button */
+}
+
+a.home-new-cta-btn:hover,
+.home-new-carousel-1 .resource-card-18x6 .cta:hover {
+ color: #fff !important;
+ background: #2d9fca;
+}
+
+.home-new-carousel-1 .resource-card-18x6 .cta {
+ position: absolute;
+ bottom: 20px;
+ left: 16px;
+}
+
+/* Fullscreen carousel. */
+.home-new-carousel-1 {
+ max-height: 700px; /* Set max height so doesn't get too long */
+}
+
+.home-new-carousel-1 .fullscreen-carousel-content {
+ min-height: 450px; /* Set min height for all content */
+}
+
+.home-new-carousel-1 .hero {
+ background: #000;
+}
+
+.home-new-carousel-1 .hero-bg {
+ background-image: url(/home-new/images/hero.jpg);
+ background-position: right center;
+ opacity: 0.85;
+}
+
+/*
+ Styling for special top card of full screen layout resource layout.
+ We need to specifically style the 18x6 card to adjust its size and layout,
+ since it's not a standard card, not sure if this is unique to the home page
+ layout or should be namespaced within the fullscreen-carousel container.
+*/
+.home-new-carousel-1 .resource-flow-layout.col-16 .resource-card-18x6 {
+ height: 320px;
+ background-color:#F9F9F9;
+ border-radius: 0px;
+ box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
+
+}
+
+.home-new-carousel-1 .resource-card-18x6 .card-bg {
+ width: 636px;
+ height: 100%;
+}
+
+.home-new-carousel-1 .resource-card-18x6 .card-info {
+ right: 0px;
+ left: 636px;
+ height: 100%;
+ top: 0px;
+ padding: 15px 22px;
+}
+
+.home-new-carousel-1 .resource-card-18x6 .card-info .util {
+ display: none;
+}
+
+.home-new-carousel-1 .resource-card-18x6 .card-info .title {
+ font-size: 20px;
+ font-weight: 500;
+ margin-top: 15px;
+ margin-bottom: 15px;
+}
+
+.home-new-carousel-1 .resource-card-18x6 .card-info .text {
+ font-size: 15px;
+ line-height: 21px;
+}
+
+
+/* Tabbed carousel. */
+.home-new-carousel-2 {
+ margin: 35px auto 100px auto;
+}
+
+.home-new-carousel-2 h1 {
+ font-size: 47px;
+ font-weight: 100;
+ line-height: 54px;
+ text-align: center;
+}
+
+.annotation-message {
+ display: block;
+ font-style: italic;
+ color: #F80;
+}
+
+
+
+/* Helpouts widget */
+.resource-card-6x2.helpouts-card {
+ width: 255px;
+ height: 40px;
+ position:absolute;
+ z-index:999;
+ top:-8px;
+ right:1px;
+}
+
+.resource-card-6x2.helpouts-card > .card-info {
+ left:35px;
+ height:35px;
+ padding:4px 8px 4px 0;
+}
+
+.resource-card-6x2.helpouts-card > .card-info .helpouts-description {
+ display:block;
+ overflow:visible;
+ font-size:12px;
+ line-height:12px;
+ text-align:right;
+ color:#666;
+}
+
+.helpouts-description .link-color {
+ text-transform: uppercase;
+}
+
+.resource-card-6x2 > .card-bg.helpouts-card-bg {
+ width:35px;
+ height:35px;
+ margin:2px 0 0 0;
+ background-image: url(../images/styles/helpouts-logo-35_2x.png);
+ background-image: -webkit-image-set(url(../images/styles/helpouts-logo-35.png) 1x, url(../images/styles/helpouts-logo-35_2x.png) 2x);
+}
+
+.resource-card-6x2 > .card-bg.helpouts-card-bg:after {
+ display:none;
+}
diff --git a/tools/droiddoc/templates-ndk/assets/css/fullscreen.css b/tools/droiddoc/templates-ndk/assets/css/fullscreen.css
new file mode 100644
index 0000000000000000000000000000000000000000..7912e3490a816b05274493b4b16ff7c93a75c13c
--- /dev/null
+++ b/tools/droiddoc/templates-ndk/assets/css/fullscreen.css
@@ -0,0 +1,208 @@
+
+/* =============================================================================
+ Columns
+ ========================================================================== */
+/* Applied to body to debug layout alignments
+.grid {
+ width:100%;
+ height:100%;
+ background:url(../images/grid.png) center repeat-y;
+ top:0px;
+ margin:auto;
+ position:absolute;
+}
+*/
+
+@media screen, projection, print {
+.full {
+ padding: 2.5em 0;
+ border-top: solid 1px #ddd;
+ border-bottom: solid 1px #ddd;
+ background: #f7f7f7;
+}
+.wrap {
+ margin: 0 auto;
+ width: 100%;
+ min-width:600px;
+ clear: both;
+}
+.cols {
+ height: 1%;
+ margin: 0 -1.533742331288343558282%;
+ width: 103.06748466257669%}
+*+html .cols {
+ margin-bottom: 20px;
+}
+.cols:after {
+ clear: both;
+ content: ' ';
+ display: block;
+ height: 0;
+ visibility: hidden;
+}
+.col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12,
+.col-13, .col-14, .col-15, .col-16 {
+ float: left;
+ margin: 0 1.063829787234% 20px 1.063829787234%;
+}
+* html .col-1, * html .col-2, * html .col-3, * html .col-4, * html .col-5, * html .col-6, * html
+.col-7, * html .col-8, * html .col-9, * html .col-10, * html .col-11, * html .col-12, * html
+.col-13, * html .col-14, * html .col-15, * html .col-16 {
+ margin: 0;
+ margin: 0 1.063829787234% 20px 1.063829787234%;
+}
+[dir='rtl'] .col-1, [dir='rtl'] .col-2, [dir='rtl'] .col-3, [dir='rtl'] .col-4, [dir='rtl'] .col-5,
+[dir='rtl'] .col-6, [dir='rtl'] .col-7, [dir='rtl'] .col-8, [dir='rtl'] .col-9, [dir='rtl'] .col-10,
+[dir='rtl'] .col-11, [dir='rtl'] .col-12 {
+ float: right;
+}
+.col-1 {
+ width: 4.16666666666667%;
+}
+.col-2 {
+ width: 10.4166666666667%;
+}
+.col-3 {
+ width: 16.6666666666667%;
+}
+.col-4 {
+ width: 22.9166666666667%;
+}
+.col-5 {
+ width: 29.1666666666667%;
+}
+.col-6 {
+ width: 35.4166666666667%;
+}
+.col-7 {
+ width: 41.6666666666667%;
+}
+.col-8 {
+ width: 47.9166666666667%;
+}
+.col-9 {
+ width: 55.3333333333333%;
+}
+.col-10 {
+ width: 60.4166666666667%;
+}
+.col-11 {
+ width: 66.6666666666667%;
+}
+.col-12 {
+ width: 72.9166666666667%;
+}
+.col-13 {
+ width: 79.1666666666667%;
+}
+.col-14 {
+ width: 85.4166666666667%;
+}
+.col-15 {
+ width: 91.6666666666667%;
+}
+.col-16 {
+ width: 97.9166666666667%;
+}
+
+
+
+
+
+
+
+#header .col-1,
+#nav-x .col-1 { width: 40px }
+#header .col-2,
+#nav-x .col-2 { width: 100px }
+#header .col-3,
+#nav-x .col-3 { width: 160px }
+#header .col-4,
+#nav-x .col-4 { width: 220px }
+#header .col-5,
+#nav-x .col-5 { width: 280px }
+#header .col-6,
+#nav-x .col-6 { width: 340px }
+#header .col-7,
+#nav-x .col-7 { width: 400px }
+#header .col-8,
+#nav-x .col-8 { width: 460px }
+#header .col-9,
+#nav-x .col-9 { width: 520px }
+#header .col-10,
+#nav-x .col-10 { width: 580px }
+#header .col-11,
+#nav-x .col-11 { width: 640px }
+#header .col-12,
+#nav-x .col-12 { width: 700px }
+#header .col-13,
+#nav-x .col-13 { width: 760px }
+#header .col-14,
+#nav-x .col-14 { width: 820px }
+#header .col-15,
+#nav-x .col-15 { width: 880px }
+#header .col-16,
+#nav-x .col-16 { width: 940px }
+
+
+
+body {
+ padding:0 20px;
+}
+#header,
+#searchResults,
+#nav-x {
+ margin:0;
+}
+#body-content {
+ margin:0;
+}
+#body-content > .col-12 {
+ width:77.9804965%;
+ margin:0 0 0 0.97%; /* this percentage chosen to make IE9 happy */
+}
+#side-nav {
+ width: 19.9804965%;
+ margin:0 1.063829787234% 0 0;
+}
+
+#header .wrap {
+ max-width: 100%;
+}
+
+#header-wrapper #nav-x div.wrap,
+#searchResults.wrap {
+ max-width:100%;
+}
+
+.nav-x {
+ margin:-2px 0 0 0;
+}
+
+#devdoc-nav.fixed,
+#devdoc-nav.fixed a.totop {
+ left:20px; /* !important ... for IE i think */
+}
+
+#sticky-header {
+ padding: 0 20px;
+}
+
+#sticky-header > div {
+ width: 100%;
+}
+
+.sticky-menu {
+ width:100%;
+ left:-20px;
+}
+
+.col-right {
+ margin-right:0px;
+}
+
+@media screen and (max-width:772px) {
+.col-5, .col-6, .col-7 {
+ clear: both;
+ width: 97.0238096%}
+}
\ No newline at end of file
diff --git a/tools/droiddoc/templates-ndk/assets/design/default.js b/tools/droiddoc/templates-ndk/assets/design/default.js
new file mode 100644
index 0000000000000000000000000000000000000000..3ba8486860afbff1cf43ae846445416b5890449d
--- /dev/null
+++ b/tools/droiddoc/templates-ndk/assets/design/default.js
@@ -0,0 +1,188 @@
+$(document).ready(function() {
+ // prep nav expandos
+ var pagePath = document.location.pathname;
+ if (pagePath.indexOf(SITE_ROOT) == 0) {
+ pagePath = pagePath.substr(SITE_ROOT.length);
+ if (pagePath == '' || pagePath.charAt(pagePath.length - 1) == '/') {
+ pagePath += 'index.html';
+ }
+ }
+
+ if (SITE_ROOT.match(/\.\.\//) || SITE_ROOT == '') {
+ // If running locally, SITE_ROOT will be a relative path, so account for that by
+ // finding the relative URL to this page. This will allow us to find links on the page
+ // leading back to this page.
+ var pathParts = pagePath.split('/');
+ var relativePagePathParts = [];
+ var upDirs = (SITE_ROOT.match(/(\.\.\/)+/) || [''])[0].length / 3;
+ for (var i = 0; i < upDirs; i++) {
+ relativePagePathParts.push('..');
+ }
+ for (var i = 0; i < upDirs; i++) {
+ relativePagePathParts.push(pathParts[pathParts.length - (upDirs - i) - 1]);
+ }
+ relativePagePathParts.push(pathParts[pathParts.length - 1]);
+ pagePath = relativePagePathParts.join('/');
+ } else {
+ // Otherwise the page path should be an absolute URL.
+ pagePath = SITE_ROOT + pagePath;
+ }
+
+ // select current page in sidenav and set up prev/next links if they exist
+ var $selNavLink = $('.nav-y').find('a[href="' + pagePath + '"]');
+ if ($selNavLink.length) {
+ $selListItem = $selNavLink.closest('li');
+
+ $selListItem.addClass('selected');
+ $selListItem.closest('li>ul').addClass('expanded');
+
+ // set up prev links
+ var $prevLink = [];
+ var $prevListItem = $selListItem.prev('li');
+ if ($prevListItem.length) {
+ if ($prevListItem.hasClass('nav-section')) {
+ // jump to last topic of previous section
+ $prevLink = $prevListItem.find('a:last');
+ } else {
+ // jump to previous topic in this section
+ $prevLink = $prevListItem.find('a:eq(0)');
+ }
+ } else {
+ // jump to this section's index page (if it exists)
+ $prevLink = $selListItem.parents('li').find('a');
+ }
+
+ if ($prevLink.length) {
+ var prevHref = $prevLink.attr('href');
+ if (prevHref == SITE_ROOT + 'index.html') {
+ // Don't show Previous when it leads to the homepage
+ $('.prev-page-link').hide();
+ } else {
+ $('.prev-page-link').attr('href', prevHref).show();
+ }
+ } else {
+ $('.prev-page-link').hide();
+ }
+
+ // set up next links
+ var $nextLink = [];
+ if ($selListItem.hasClass('nav-section')) {
+ // we're on an index page, jump to the first topic
+ $nextLink = $selListItem.find('ul').find('a:eq(0)')
+ } else {
+ // jump to the next topic in this section (if it exists)
+ $nextLink = $selListItem.next('li').find('a:eq(0)');
+ if (!$nextLink.length) {
+ // no more topics in this section, jump to the first topic in the next section
+ $nextLink = $selListItem.parents('li').next('li.nav-section').find('a:eq(0)');
+ }
+ }
+ if ($nextLink.length) {
+ $('.next-page-link').attr('href', $nextLink.attr('href')).show();
+ } else {
+ $('.next-page-link').hide();
+ }
+ }
+
+ // Set up expand/collapse behavior
+ $('.nav-y li').has('ul').click(function() {
+ if ($(this).hasClass('expanded')) {
+ return;
+ }
+
+ // hide other
+ var $old = $('.nav-y li.expanded');
+ if ($old.length) {
+ var $oldUl = $old.children('ul');
+ $oldUl.css('height', $oldUl.height() + 'px');
+ window.setTimeout(function() {
+ $oldUl
+ .addClass('animate-height')
+ .css('height', '');
+ }, 0);
+ $old.removeClass('expanded');
+ }
+
+ // show me
+ $(this).addClass('expanded');
+ var $ul = $(this).children('ul');
+ var expandedHeight = $ul.height();
+ $ul
+ .removeClass('animate-height')
+ .css('height', 0);
+ window.setTimeout(function() {
+ $ul
+ .addClass('animate-height')
+ .css('height', expandedHeight + 'px');
+ }, 0);
+ });
+
+ // Stop expand/collapse behavior when clicking on nav section links (since we're navigating away
+ // from the page)
+ $('.nav-y li').has('ul').find('a:eq(0)').click(function(evt) {
+ window.location.href = $(this).attr('href');
+ return false;
+ });
+
+ // Set up play-on-hover tags.
+ $('video.play-on-hover').bind('click', function(){
+ $(this).get(0).load(); // in case the video isn't seekable
+ $(this).get(0).play();
+ });
+
+ // Set up tooltips
+ var TOOLTIP_MARGIN = 10;
+ $('acronym').each(function() {
+ var $target = $(this);
+ var $tooltip = $('')
+ .addClass('tooltip-box')
+ .text($target.attr('title'))
+ .hide()
+ .appendTo('body');
+ $target.removeAttr('title');
+
+ $target.hover(function() {
+ // in
+ var targetRect = $target.offset();
+ targetRect.width = $target.width();
+ targetRect.height = $target.height();
+
+ $tooltip.css({
+ left: targetRect.left,
+ top: targetRect.top + targetRect.height + TOOLTIP_MARGIN
+ });
+ $tooltip.addClass('below');
+ $tooltip.show();
+ }, function() {
+ // out
+ $tooltip.hide();
+ });
+ });
+
+ // Set up
deeplinks
+ $('h2').click(function() {
+ var id = $(this).attr('id');
+ if (id) {
+ document.location.hash = id;
+ }
+ });
+
+ // Set up fixed navbar
+ var navBarIsFixed = false;
+ $(window).scroll(function() {
+ var scrollTop = $(window).scrollTop();
+ var navBarShouldBeFixed = (scrollTop > (100 - 40));
+ if (navBarIsFixed != navBarShouldBeFixed) {
+ if (navBarShouldBeFixed) {
+ $('#nav')
+ .addClass('fixed')
+ .prependTo('#page-container');
+ } else {
+ $('#nav')
+ .removeClass('fixed')
+ .prependTo('#nav-container');
+ }
+ navBarIsFixed = navBarShouldBeFixed;
+ }
+ });
+});
\ No newline at end of file
diff --git a/tools/droiddoc/templates-ndk/assets/images/icon_more.png b/tools/droiddoc/templates-ndk/assets/images/icon_more.png
new file mode 100644
index 0000000000000000000000000000000000000000..6cd03a39a2540c18159e8ad06b6af663f5c4efaf
Binary files /dev/null and b/tools/droiddoc/templates-ndk/assets/images/icon_more.png differ
diff --git a/tools/droiddoc/templates-ndk/assets/images/icon_search.png b/tools/droiddoc/templates-ndk/assets/images/icon_search.png
new file mode 100644
index 0000000000000000000000000000000000000000..ee90a12acbfa44744fef9fc4e2dc0119ec5ab0ba
Binary files /dev/null and b/tools/droiddoc/templates-ndk/assets/images/icon_search.png differ
diff --git a/tools/droiddoc/templates-ndk/assets/images/more_bottom.png b/tools/droiddoc/templates-ndk/assets/images/more_bottom.png
new file mode 100644
index 0000000000000000000000000000000000000000..632546aacf23ab8c776da6fe8dfe922a916da723
Binary files /dev/null and b/tools/droiddoc/templates-ndk/assets/images/more_bottom.png differ
diff --git a/tools/droiddoc/templates-ndk/assets/images/more_mid.png b/tools/droiddoc/templates-ndk/assets/images/more_mid.png
new file mode 100644
index 0000000000000000000000000000000000000000..99bc99927ac3c4f11aefc1867d9198d379452095
Binary files /dev/null and b/tools/droiddoc/templates-ndk/assets/images/more_mid.png differ
diff --git a/tools/droiddoc/templates-ndk/assets/images/more_top.png b/tools/droiddoc/templates-ndk/assets/images/more_top.png
new file mode 100644
index 0000000000000000000000000000000000000000..8ead1d39392f89b305ed48d10c129f980ec7afe5
Binary files /dev/null and b/tools/droiddoc/templates-ndk/assets/images/more_top.png differ
diff --git a/tools/droiddoc/templates-ndk/assets/js/android_3p-bundle.js b/tools/droiddoc/templates-ndk/assets/js/android_3p-bundle.js
new file mode 100644
index 0000000000000000000000000000000000000000..a67b5b0d8cf6f28f38395793a9d2696f814cd267
--- /dev/null
+++ b/tools/droiddoc/templates-ndk/assets/js/android_3p-bundle.js
@@ -0,0 +1,2766 @@
+//third_party/javascript/google_code_prettify/src/prettify.js
+/**
+ * @license Copyright (C) 2006 Google Inc.
+ *
+ * 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.
+ */
+
+/**
+ * @fileoverview
+ * some functions for browser-side pretty printing of code contained in html.
+ *
+ *
+ * For a fairly comprehensive set of languages see the
+ * README
+ * file that came with this source. At a minimum, the lexer should work on a
+ * number of languages including C and friends, Java, Python, Bash, SQL, HTML,
+ * XML, CSS, Javascript, and Makefiles. It works passably on Ruby, PHP and Awk
+ * and a subset of Perl, but, because of commenting conventions, doesn't work on
+ * Smalltalk, Lisp-like, or CAML-like languages without an explicit lang class.
+ *
+ * Usage:
+ * include this source file in an html page via
+ * {@code }
+ * define style rules. See the example page for examples.
+ * mark the {@code } and {@code } tags in your source with
+ * {@code class=prettyprint.}
+ * You can also use the (html deprecated) {@code } tag, but the pretty
+ * printer needs to do more substantial DOM manipulations to support that, so
+ * some css styles may not be preserved.
+ *
+ * That's it. I wanted to keep the API as simple as possible, so there's no
+ * need to specify which language the code is in, but if you wish, you can add
+ * another class to the {@code
} or {@code } element to specify the
+ * language, as in {@code }. Any class that
+ * starts with "lang-" followed by a file extension, specifies the file type.
+ * See the "lang-*.js" files in this directory for code that implements
+ * per-language file handlers.
+ *
+ * Change log:
+ * cbeust, 2006/08/22
+ *
+ * Java annotations (start with "@") are now captured as literals ("lit")
+ *
+ * @requires console
+ */
+
+// JSLint declarations
+/*global console, document, navigator, setTimeout, window */
+
+/**
+ * Split {@code prettyPrint} into multiple timeouts so as not to interfere with
+ * UI events.
+ * If set to {@code false}, {@code prettyPrint()} is synchronous.
+ */
+window['PR_SHOULD_USE_CONTINUATION'] = true;
+
+/** the number of characters between tab columns */
+window['PR_TAB_WIDTH'] = 8;
+
+/** Walks the DOM returning a properly escaped version of innerHTML.
+ * @param {Node} node
+ * @param {Array.} out output buffer that receives chunks of HTML.
+ */
+window['PR_normalizedHtml']
+
+/** Contains functions for creating and registering new language handlers.
+ * @type {Object}
+ */
+ = window['PR']
+
+/** Pretty print a chunk of code.
+ *
+ * @param {string} sourceCodeHtml code as html
+ * @return {string} code as html, but prettier
+ */
+ = window['prettyPrintOne']
+/** Find all the {@code } and {@code } tags in the DOM with
+ * {@code class=prettyprint} and prettify them.
+ * @param {Function?} opt_whenDone if specified, called when the last entry
+ * has been finished.
+ */
+ = window['prettyPrint'] = void 0;
+
+/** browser detection. @extern @returns false if not IE, otherwise the major version. */
+window['_pr_isIE6'] = function () {
+ var ieVersion = navigator && navigator.userAgent &&
+ navigator.userAgent.match(/\bMSIE ([678])\./);
+ ieVersion = ieVersion ? +ieVersion[1] : false;
+ window['_pr_isIE6'] = function () { return ieVersion; };
+ return ieVersion;
+};
+
+
+(function () {
+ // Keyword lists for various languages.
+ var FLOW_CONTROL_KEYWORDS =
+ "break continue do else for if return while ";
+ var C_KEYWORDS = FLOW_CONTROL_KEYWORDS + "auto case char const default " +
+ "double enum extern float goto int long register short signed sizeof " +
+ "static struct switch typedef union unsigned void volatile ";
+ var COMMON_KEYWORDS = C_KEYWORDS + "catch class delete false import " +
+ "new operator private protected public this throw true try typeof ";
+ var CPP_KEYWORDS = COMMON_KEYWORDS + "alignof align_union asm axiom bool " +
+ "concept concept_map const_cast constexpr decltype " +
+ "dynamic_cast explicit export friend inline late_check " +
+ "mutable namespace nullptr reinterpret_cast static_assert static_cast " +
+ "template typeid typename using virtual wchar_t where ";
+ var JAVA_KEYWORDS = COMMON_KEYWORDS +
+ "abstract boolean byte extends final finally implements import " +
+ "instanceof null native package strictfp super synchronized throws " +
+ "transient ";
+ var CSHARP_KEYWORDS = JAVA_KEYWORDS +
+ "as base by checked decimal delegate descending dynamic event " +
+ "fixed foreach from group implicit in interface internal into is lock " +
+ "object out override orderby params partial readonly ref sbyte sealed " +
+ "stackalloc string select uint ulong unchecked unsafe ushort var ";
+ var COFFEE_KEYWORDS = "all and by catch class else extends false finally " +
+ "for if in is isnt loop new no not null of off on or return super then " +
+ "true try unless until when while yes ";
+ var JSCRIPT_KEYWORDS = COMMON_KEYWORDS +
+ "debugger eval export function get null set undefined var with " +
+ "Infinity NaN ";
+ var PERL_KEYWORDS = "caller delete die do dump elsif eval exit foreach for " +
+ "goto if import last local my next no our print package redo require " +
+ "sub undef unless until use wantarray while BEGIN END ";
+ var PYTHON_KEYWORDS = FLOW_CONTROL_KEYWORDS + "and as assert class def del " +
+ "elif except exec finally from global import in is lambda " +
+ "nonlocal not or pass print raise try with yield " +
+ "False True None ";
+ var RUBY_KEYWORDS = FLOW_CONTROL_KEYWORDS + "alias and begin case class def" +
+ " defined elsif end ensure false in module next nil not or redo rescue " +
+ "retry self super then true undef unless until when yield BEGIN END ";
+ var SH_KEYWORDS = FLOW_CONTROL_KEYWORDS + "case done elif esac eval fi " +
+ "function in local set then until ";
+ var ALL_KEYWORDS = (
+ CPP_KEYWORDS + CSHARP_KEYWORDS + JSCRIPT_KEYWORDS + PERL_KEYWORDS +
+ PYTHON_KEYWORDS + RUBY_KEYWORDS + SH_KEYWORDS);
+
+ // token style names. correspond to css classes
+ /** token style for a string literal */
+ var PR_STRING = 'str';
+ /** token style for a keyword */
+ var PR_KEYWORD = 'kwd';
+ /** token style for a comment */
+ var PR_COMMENT = 'com';
+ /** token style for a type */
+ var PR_TYPE = 'typ';
+ /** token style for a literal value. e.g. 1, null, true. */
+ var PR_LITERAL = 'lit';
+ /** token style for a punctuation string. */
+ var PR_PUNCTUATION = 'pun';
+ /** token style for a punctuation string. */
+ var PR_PLAIN = 'pln';
+
+ /** token style for an sgml tag. */
+ var PR_TAG = 'tag';
+ /** token style for a markup declaration such as a DOCTYPE. */
+ var PR_DECLARATION = 'dec';
+ /** token style for embedded source. */
+ var PR_SOURCE = 'src';
+ /** token style for an sgml attribute name. */
+ var PR_ATTRIB_NAME = 'atn';
+ /** token style for an sgml attribute value. */
+ var PR_ATTRIB_VALUE = 'atv';
+
+ /**
+ * A class that indicates a section of markup that is not code, e.g. to allow
+ * embedding of line numbers within code listings.
+ */
+ var PR_NOCODE = 'nocode';
+
+ /** A set of tokens that can precede a regular expression literal in
+ * javascript.
+ * http://www.mozilla.org/js/language/js20/rationale/syntax.html has the full
+ * list, but I've removed ones that might be problematic when seen in
+ * languages that don't support regular expression literals.
+ *
+ * Specifically, I've removed any keywords that can't precede a regexp
+ * literal in a syntactically legal javascript program, and I've removed the
+ * "in" keyword since it's not a keyword in many languages, and might be used
+ * as a count of inches.
+ *
+ *
The link a above does not accurately describe EcmaScript rules since
+ * it fails to distinguish between (a=++/b/i) and (a++/b/i) but it works
+ * very well in practice.
+ *
+ * @private
+ */
+ var REGEXP_PRECEDER_PATTERN = function () {
+ var preceders = [
+ "!", "!=", "!==", "#", "%", "%=", "&", "&&", "&&=",
+ "&=", "(", "*", "*=", /* "+", */ "+=", ",", /* "-", */ "-=",
+ "->", /*".", "..", "...", handled below */ "/", "/=", ":", "::", ";",
+ "<", "<<", "<<=", "<=", "=", "==", "===", ">",
+ ">=", ">>", ">>=", ">>>", ">>>=", "?", "@", "[",
+ "^", "^=", "^^", "^^=", "{", "|", "|=", "||",
+ "||=", "~" /* handles =~ and !~ */,
+ "break", "case", "continue", "delete",
+ "do", "else", "finally", "instanceof",
+ "return", "throw", "try", "typeof"
+ ];
+ var pattern = '(?:^^|[+-]';
+ for (var i = 0; i < preceders.length; ++i) {
+ pattern += '|' + preceders[i].replace(/([^=<>:&a-z])/g, '\\$1');
+ }
+ pattern += ')\\s*'; // matches at end, and matches empty string
+ return pattern;
+ // CAVEAT: this does not properly handle the case where a regular
+ // expression immediately follows another since a regular expression may
+ // have flags for case-sensitivity and the like. Having regexp tokens
+ // adjacent is not valid in any language I'm aware of, so I'm punting.
+ // TODO: maybe style special characters inside a regexp as punctuation.
+ }();
+
+ // Define regexps here so that the interpreter doesn't have to create an
+ // object each time the function containing them is called.
+ // The language spec requires a new object created even if you don't access
+ // the $1 members.
+ var pr_amp = /&/g;
+ var pr_lt = //g;
+ var pr_quot = /\"/g;
+ /** like textToHtml but escapes double quotes to be attribute safe. */
+ function attribToHtml(str) {
+ return str.replace(pr_amp, '&')
+ .replace(pr_lt, '<')
+ .replace(pr_gt, '>')
+ .replace(pr_quot, '"');
+ }
+
+ /** escapest html special characters to html. */
+ function textToHtml(str) {
+ return str.replace(pr_amp, '&')
+ .replace(pr_lt, '<')
+ .replace(pr_gt, '>');
+ }
+
+
+ var pr_ltEnt = /</g;
+ var pr_gtEnt = />/g;
+ var pr_aposEnt = /'/g;
+ var pr_quotEnt = /"/g;
+ var pr_ampEnt = /&/g;
+ var pr_nbspEnt = / /g;
+ /** unescapes html to plain text. */
+ function htmlToText(html) {
+ var pos = html.indexOf('&');
+ if (pos < 0) { return html; }
+ // Handle numeric entities specially. We can't use functional substitution
+ // since that doesn't work in older versions of Safari.
+ // These should be rare since most browsers convert them to normal chars.
+ for (--pos; (pos = html.indexOf('', pos + 1)) >= 0;) {
+ var end = html.indexOf(';', pos);
+ if (end >= 0) {
+ var num = html.substring(pos + 3, end);
+ var radix = 10;
+ if (num && num.charAt(0) === 'x') {
+ num = num.substring(1);
+ radix = 16;
+ }
+ var codePoint = parseInt(num, radix);
+ if (!isNaN(codePoint)) {
+ html = (html.substring(0, pos) + String.fromCharCode(codePoint) +
+ html.substring(end + 1));
+ }
+ }
+ }
+
+ return html.replace(pr_ltEnt, '<')
+ .replace(pr_gtEnt, '>')
+ .replace(pr_aposEnt, "'")
+ .replace(pr_quotEnt, '"')
+ .replace(pr_nbspEnt, ' ')
+ .replace(pr_ampEnt, '&');
+ }
+
+ /** is the given node's innerHTML normally unescaped? */
+ function isRawContent(node) {
+ return 'XMP' === node.tagName;
+ }
+
+ var newlineRe = /[\r\n]/g;
+ /**
+ * Are newlines and adjacent spaces significant in the given node's innerHTML?
+ */
+ function isPreformatted(node, content) {
+ // PRE means preformatted, and is a very common case, so don't create
+ // unnecessary computed style objects.
+ if ('PRE' === node.tagName) { return true; }
+ if (!newlineRe.test(content)) { return true; } // Don't care
+ var whitespace = '';
+ // For disconnected nodes, IE has no currentStyle.
+ if (node.currentStyle) {
+ whitespace = node.currentStyle.whiteSpace;
+ } else if (window.getComputedStyle) {
+ // Firefox makes a best guess if node is disconnected whereas Safari
+ // returns the empty string.
+ whitespace = window.getComputedStyle(node, null).whiteSpace;
+ }
+ return !whitespace || whitespace === 'pre';
+ }
+
+ function normalizedHtml(node, out, opt_sortAttrs) {
+ switch (node.nodeType) {
+ case 1: // an element
+ var name = node.tagName.toLowerCase();
+
+ out.push('<', name);
+ var attrs = node.attributes;
+ var n = attrs.length;
+ if (n) {
+ if (opt_sortAttrs) {
+ var sortedAttrs = [];
+ for (var i = n; --i >= 0;) { sortedAttrs[i] = attrs[i]; }
+ sortedAttrs.sort(function (a, b) {
+ return (a.name < b.name) ? -1 : a.name === b.name ? 0 : 1;
+ });
+ attrs = sortedAttrs;
+ }
+ for (var i = 0; i < n; ++i) {
+ var attr = attrs[i];
+ if (!attr.specified) { continue; }
+ out.push(' ', attr.name.toLowerCase(),
+ '="', attribToHtml(attr.value), '"');
+ }
+ }
+ out.push('>');
+ for (var child = node.firstChild; child; child = child.nextSibling) {
+ normalizedHtml(child, out, opt_sortAttrs);
+ }
+ if (node.firstChild || !/^(?:br|link|img)$/.test(name)) {
+ out.push('<\/', name, '>');
+ }
+ break;
+ case 3: case 4: // text
+ out.push(textToHtml(node.nodeValue));
+ break;
+ }
+ }
+
+ /**
+ * Given a group of {@link RegExp}s, returns a {@code RegExp} that globally
+ * matches the union o the sets o strings matched d by the input RegExp.
+ * Since it matches globally, if the input strings have a start-of-input
+ * anchor (/^.../), it is ignored for the purposes of unioning.
+ * @param {Array.} regexs non multiline, non-global regexs.
+ * @return {RegExp} a global regex.
+ */
+ function combinePrefixPatterns(regexs) {
+ var capturedGroupIndex = 0;
+
+ var needToFoldCase = false;
+ var ignoreCase = false;
+ for (var i = 0, n = regexs.length; i < n; ++i) {
+ var regex = regexs[i];
+ if (regex.ignoreCase) {
+ ignoreCase = true;
+ } else if (/[a-z]/i.test(regex.source.replace(
+ /\\u[0-9a-f]{4}|\\x[0-9a-f]{2}|\\[^ux]/gi, ''))) {
+ needToFoldCase = true;
+ ignoreCase = false;
+ break;
+ }
+ }
+
+ function decodeEscape(charsetPart) {
+ if (charsetPart.charAt(0) !== '\\') { return charsetPart.charCodeAt(0); }
+ switch (charsetPart.charAt(1)) {
+ case 'b': return 8;
+ case 't': return 9;
+ case 'n': return 0xa;
+ case 'v': return 0xb;
+ case 'f': return 0xc;
+ case 'r': return 0xd;
+ case 'u': case 'x':
+ return parseInt(charsetPart.substring(2), 16)
+ || charsetPart.charCodeAt(1);
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7':
+ return parseInt(charsetPart.substring(1), 8);
+ default: return charsetPart.charCodeAt(1);
+ }
+ }
+
+ function encodeEscape(charCode) {
+ if (charCode < 0x20) {
+ return (charCode < 0x10 ? '\\x0' : '\\x') + charCode.toString(16);
+ }
+ var ch = String.fromCharCode(charCode);
+ if (ch === '\\' || ch === '-' || ch === '[' || ch === ']') {
+ ch = '\\' + ch;
+ }
+ return ch;
+ }
+
+ function caseFoldCharset(charSet) {
+ var charsetParts = charSet.substring(1, charSet.length - 1).match(
+ new RegExp(
+ '\\\\u[0-9A-Fa-f]{4}'
+ + '|\\\\x[0-9A-Fa-f]{2}'
+ + '|\\\\[0-3][0-7]{0,2}'
+ + '|\\\\[0-7]{1,2}'
+ + '|\\\\[\\s\\S]'
+ + '|-'
+ + '|[^-\\\\]',
+ 'g'));
+ var groups = [];
+ var ranges = [];
+ var inverse = charsetParts[0] === '^';
+ for (var i = inverse ? 1 : 0, n = charsetParts.length; i < n; ++i) {
+ var p = charsetParts[i];
+ switch (p) {
+ case '\\B': case '\\b':
+ case '\\D': case '\\d':
+ case '\\S': case '\\s':
+ case '\\W': case '\\w':
+ groups.push(p);
+ continue;
+ }
+ var start = decodeEscape(p);
+ var end;
+ if (i + 2 < n && '-' === charsetParts[i + 1]) {
+ end = decodeEscape(charsetParts[i + 2]);
+ i += 2;
+ } else {
+ end = start;
+ }
+ ranges.push([start, end]);
+ // If the range might intersect letters, then expand it.
+ if (!(end < 65 || start > 122)) {
+ if (!(end < 65 || start > 90)) {
+ ranges.push([Math.max(65, start) | 32, Math.min(end, 90) | 32]);
+ }
+ if (!(end < 97 || start > 122)) {
+ ranges.push([Math.max(97, start) & ~32, Math.min(end, 122) & ~32]);
+ }
+ }
+ }
+
+ // [[1, 10], [3, 4], [8, 12], [14, 14], [16, 16], [17, 17]]
+ // -> [[1, 12], [14, 14], [16, 17]]
+ ranges.sort(function (a, b) { return (a[0] - b[0]) || (b[1] - a[1]); });
+ var consolidatedRanges = [];
+ var lastRange = [NaN, NaN];
+ for (var i = 0; i < ranges.length; ++i) {
+ var range = ranges[i];
+ if (range[0] <= lastRange[1] + 1) {
+ lastRange[1] = Math.max(lastRange[1], range[1]);
+ } else {
+ consolidatedRanges.push(lastRange = range);
+ }
+ }
+
+ var out = ['['];
+ if (inverse) { out.push('^'); }
+ out.push.apply(out, groups);
+ for (var i = 0; i < consolidatedRanges.length; ++i) {
+ var range = consolidatedRanges[i];
+ out.push(encodeEscape(range[0]));
+ if (range[1] > range[0]) {
+ if (range[1] + 1 > range[0]) { out.push('-'); }
+ out.push(encodeEscape(range[1]));
+ }
+ }
+ out.push(']');
+ return out.join('');
+ }
+
+ function allowAnywhereFoldCaseAndRenumberGroups(regex) {
+ // Split into character sets, escape sequences, punctuation strings
+ // like ('(', '(?:', ')', '^'), and runs of characters that do not
+ // include any of the above.
+ var parts = regex.source.match(
+ new RegExp(
+ '(?:'
+ + '\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]' // a character set
+ + '|\\\\u[A-Fa-f0-9]{4}' // a unicode escape
+ + '|\\\\x[A-Fa-f0-9]{2}' // a hex escape
+ + '|\\\\[0-9]+' // a back-reference or octal escape
+ + '|\\\\[^ux0-9]' // other escape sequence
+ + '|\\(\\?[:!=]' // start of a non-capturing group
+ + '|[\\(\\)\\^]' // start/emd of a group, or line start
+ + '|[^\\x5B\\x5C\\(\\)\\^]+' // run of other characters
+ + ')',
+ 'g'));
+ var n = parts.length;
+
+ // Maps captured group numbers to the number they will occupy in
+ // the output or to -1 if that has not been determined, or to
+ // undefined if they need not be capturing in the output.
+ var capturedGroups = [];
+
+ // Walk over and identify back references to build the capturedGroups
+ // mapping.
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ var p = parts[i];
+ if (p === '(') {
+ // groups are 1-indexed, so max group index is count of '('
+ ++groupIndex;
+ } else if ('\\' === p.charAt(0)) {
+ var decimalValue = +p.substring(1);
+ if (decimalValue && decimalValue <= groupIndex) {
+ capturedGroups[decimalValue] = -1;
+ }
+ }
+ }
+
+ // Renumber groups and reduce capturing groups to non-capturing groups
+ // where possible.
+ for (var i = 1; i < capturedGroups.length; ++i) {
+ if (-1 === capturedGroups[i]) {
+ capturedGroups[i] = ++capturedGroupIndex;
+ }
+ }
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ var p = parts[i];
+ if (p === '(') {
+ ++groupIndex;
+ if (capturedGroups[groupIndex] === undefined) {
+ parts[i] = '(?:';
+ }
+ } else if ('\\' === p.charAt(0)) {
+ var decimalValue = +p.substring(1);
+ if (decimalValue && decimalValue <= groupIndex) {
+ parts[i] = '\\' + capturedGroups[groupIndex];
+ }
+ }
+ }
+
+ // Remove any prefix anchors so that the output will match anywhere.
+ // ^^ really does mean an anchored match though.
+ for (var i = 0, groupIndex = 0; i < n; ++i) {
+ if ('^' === parts[i] && '^' !== parts[i + 1]) { parts[i] = ''; }
+ }
+
+ // Expand letters to groupts to handle mixing of case-sensitive and
+ // case-insensitive patterns if necessary.
+ if (regex.ignoreCase && needToFoldCase) {
+ for (var i = 0; i < n; ++i) {
+ var p = parts[i];
+ var ch0 = p.charAt(0);
+ if (p.length >= 2 && ch0 === '[') {
+ parts[i] = caseFoldCharset(p);
+ } else if (ch0 !== '\\') {
+ // TODO: handle letters in numeric escapes.
+ parts[i] = p.replace(
+ /[a-zA-Z]/g,
+ function (ch) {
+ var cc = ch.charCodeAt(0);
+ return '[' + String.fromCharCode(cc & ~32, cc | 32) + ']';
+ });
+ }
+ }
+ }
+
+ return parts.join('');
+ }
+
+ var rewritten = [];
+ for (var i = 0, n = regexs.length; i < n; ++i) {
+ var regex = regexs[i];
+ if (regex.global || regex.multiline) { throw new Error('' + regex); }
+ rewritten.push(
+ '(?:' + allowAnywhereFoldCaseAndRenumberGroups(regex) + ')');
+ }
+
+ return new RegExp(rewritten.join('|'), ignoreCase ? 'gi' : 'g');
+ }
+
+ var PR_innerHtmlWorks = null;
+ function getInnerHtml(node) {
+ // inner html is hopelessly broken in Safari 2.0.4 when the content is
+ // an html description of well formed XML and the containing tag is a PRE
+ // tag, so we detect that case and emulate innerHTML.
+ if (null === PR_innerHtmlWorks) {
+ var testNode = document.createElement('PRE');
+ testNode.appendChild(
+ document.createTextNode('\n '));
+ PR_innerHtmlWorks = !/)[\r\n]+/g, '$1')
+ .replace(/(?:[\r\n]+[ \t]*)+/g, ' ');
+ }
+ return content;
+ }
+
+ var out = [];
+ for (var child = node.firstChild; child; child = child.nextSibling) {
+ normalizedHtml(child, out);
+ }
+ return out.join('');
+ }
+
+ /** returns a function that expand tabs to spaces. This function can be fed
+ * successive chunks of text, and will maintain its own internal state to
+ * keep track of how tabs are expanded.
+ * @return {function (string) : string} a function that takes
+ * plain text and return the text with tabs expanded.
+ * @private
+ */
+ function makeTabExpander(tabWidth) {
+ var SPACES = ' ';
+ var charInLine = 0;
+
+ return function (plainText) {
+ // walk over each character looking for tabs and newlines.
+ // On tabs, expand them. On newlines, reset charInLine.
+ // Otherwise increment charInLine
+ var out = null;
+ var pos = 0;
+ for (var i = 0, n = plainText.length; i < n; ++i) {
+ var ch = plainText.charAt(i);
+
+ switch (ch) {
+ case '\t':
+ if (!out) { out = []; }
+ out.push(plainText.substring(pos, i));
+ // calculate how much space we need in front of this part
+ // nSpaces is the amount of padding -- the number of spaces needed
+ // to move us to the next column, where columns occur at factors of
+ // tabWidth.
+ var nSpaces = tabWidth - (charInLine % tabWidth);
+ charInLine += nSpaces;
+ for (; nSpaces >= 0; nSpaces -= SPACES.length) {
+ out.push(SPACES.substring(0, nSpaces));
+ }
+ pos = i + 1;
+ break;
+ case '\n':
+ charInLine = 0;
+ break;
+ default:
+ ++charInLine;
+ }
+ }
+ if (!out) { return plainText; }
+ out.push(plainText.substring(pos));
+ return out.join('');
+ };
+ }
+
+ var pr_chunkPattern = new RegExp(
+ '[^<]+' // A run of characters other than '<'
+ + '|<\!--[\\s\\S]*?--\>' // an HTML comment
+ + '|' // a CDATA section
+ // a probable tag that should not be highlighted
+ + '|<\/?[a-zA-Z](?:[^>\"\']|\'[^\']*\'|\"[^\"]*\")*>'
+ + '|<', // A '<' that does not begin a larger chunk
+ 'g');
+ var pr_commentPrefix = /^<\!--/;
+ var pr_cdataPrefix = /^) into their textual equivalent.
+ *
+ * @param {string} s html where whitespace is considered significant.
+ * @return {Object} source code and extracted tags.
+ * @private
+ */
+ function extractTags(s) {
+ // since the pattern has the 'g' modifier and defines no capturing groups,
+ // this will return a list of all chunks which we then classify and wrap as
+ // PR_Tokens
+ var matches = s.match(pr_chunkPattern);
+ var sourceBuf = [];
+ var sourceBufLen = 0;
+ var extractedTags = [];
+ if (matches) {
+ for (var i = 0, n = matches.length; i < n; ++i) {
+ var match = matches[i];
+ if (match.length > 1 && match.charAt(0) === '<') {
+ if (pr_commentPrefix.test(match)) { continue; }
+ if (pr_cdataPrefix.test(match)) {
+ // strip CDATA prefix and suffix. Don't unescape since it's CDATA
+ sourceBuf.push(match.substring(9, match.length - 3));
+ sourceBufLen += match.length - 12;
+ } else if (pr_brPrefix.test(match)) {
+ // tags are lexically significant so convert them to text.
+ // This is undone later.
+ sourceBuf.push('\n');
+ ++sourceBufLen;
+ } else {
+ if (match.indexOf(PR_NOCODE) >= 0 && isNoCodeTag(match)) {
+ // A will start a section that should be
+ // ignored. Continue walking the list until we see a matching end
+ // tag.
+ var name = match.match(pr_tagNameRe)[2];
+ var depth = 1;
+ var j;
+ end_tag_loop:
+ for (j = i + 1; j < n; ++j) {
+ var name2 = matches[j].match(pr_tagNameRe);
+ if (name2 && name2[2] === name) {
+ if (name2[1] === '/') {
+ if (--depth === 0) { break end_tag_loop; }
+ } else {
+ ++depth;
+ }
+ }
+ }
+ if (j < n) {
+ extractedTags.push(
+ sourceBufLen, matches.slice(i, j + 1).join(''));
+ i = j;
+ } else { // Ignore unclosed sections.
+ extractedTags.push(sourceBufLen, match);
+ }
+ } else {
+ extractedTags.push(sourceBufLen, match);
+ }
+ }
+ } else {
+ var literalText = htmlToText(match);
+ sourceBuf.push(literalText);
+ sourceBufLen += literalText.length;
+ }
+ }
+ }
+ return { source: sourceBuf.join(''), tags: extractedTags };
+ }
+
+ /** True if the given tag contains a class attribute with the nocode class. */
+ function isNoCodeTag(tag) {
+ return !!tag
+ // First canonicalize the representation of attributes
+ .replace(/\s(\w+)\s*=\s*(?:\"([^\"]*)\"|'([^\']*)'|(\S+))/g,
+ ' $1="$2$3$4"')
+ // Then look for the attribute we want.
+ .match(/[cC][lL][aA][sS][sS]=\"[^\"]*\bnocode\b/);
+ }
+
+ /**
+ * Apply the given language handler to sourceCode and add the resulting
+ * decorations to out.
+ * @param {number} basePos the index of sourceCode within the chunk of source
+ * whose decorations are already present on out.
+ */
+ function appendDecorations(basePos, sourceCode, langHandler, out) {
+ if (!sourceCode) { return; }
+ var job = {
+ source: sourceCode,
+ basePos: basePos
+ };
+ langHandler(job);
+ out.push.apply(out, job.decorations);
+ }
+
+ /** Given triples of [style, pattern, context] returns a lexing function,
+ * The lexing function interprets the patterns to find token boundaries and
+ * returns a decoration list of the form
+ * [index_0, style_0, index_1, style_1, ..., index_n, style_n]
+ * where index_n is an index into the sourceCode, and style_n is a style
+ * constant like PR_PLAIN. index_n-1 <= index_n, and style_n-1 applies to
+ * all characters in sourceCode[index_n-1:index_n].
+ *
+ * The stylePatterns is a list whose elements have the form
+ * [style : string, pattern : RegExp, DEPRECATED, shortcut : string].
+ *
+ * Style is a style constant like PR_PLAIN, or can be a string of the
+ * form 'lang-FOO', where FOO is a language extension describing the
+ * language of the portion of the token in $1 after pattern executes.
+ * E.g., if style is 'lang-lisp', and group 1 contains the text
+ * '(hello (world))', then that portion of the token will be passed to the
+ * registered lisp handler for formatting.
+ * The text before and after group 1 will be restyled using this decorator
+ * so decorators should take care that this doesn't result in infinite
+ * recursion. For example, the HTML lexer rule for SCRIPT elements looks
+ * something like ['lang-js', /<[s]cript>(.+?)<\/script>/]. This may match
+ * '
+ *
+ * Options:
+ * btnPrev: optional identifier for previous button
+ * btnNext: optional identifier for next button
+ * btnPause: optional identifier for pause button
+ * auto: whether or not to auto-proceed
+ * speed: animation speed
+ * autoTime: time between auto-rotation
+ * easing: easing function for transition
+ * start: item to select by default
+ * scroll: direction to scroll in
+ * pagination: whether or not to include dotted pagination
+ *
+ */
+
+ (function($) {
+ $.fn.dacSlideshow = function(o) {
+
+ //Options - see above
+ o = $.extend({
+ btnPrev: null,
+ btnNext: null,
+ btnPause: null,
+ auto: true,
+ speed: 500,
+ autoTime: 12000,
+ easing: null,
+ start: 0,
+ scroll: 1,
+ pagination: true
+
+ }, o || {});
+
+ //Set up a carousel for each
+ return this.each(function() {
+
+ var running = false;
+ var animCss = o.vertical ? "top" : "left";
+ var sizeCss = o.vertical ? "height" : "width";
+ var div = $(this);
+ var ul = $("ul", div);
+ var tLi = $("li", ul);
+ var tl = tLi.size();
+ var timer = null;
+
+ var li = $("li", ul);
+ var itemLength = li.size();
+ var curr = o.start;
+
+ li.css({float: o.vertical ? "none" : "left"});
+ ul.css({margin: "0", padding: "0", position: "relative", "list-style-type": "none", "z-index": "1"});
+ div.css({position: "relative", "z-index": "2", left: "0px"});
+
+ var liSize = o.vertical ? height(li) : width(li);
+ var ulSize = liSize * itemLength;
+ var divSize = liSize;
+
+ li.css({width: li.width(), height: li.height()});
+ ul.css(sizeCss, ulSize+"px").css(animCss, -(curr*liSize));
+
+ div.css(sizeCss, divSize+"px");
+
+ //Pagination
+ if (o.pagination) {
+ var pagination = $("");
+ var pag_ul = $("");
+ if (tl > 1) {
+ for (var i=0;i"+i+"");
+ pag_ul.append(li);
+ if (i==o.start) li.addClass('active');
+ li.click(function() {
+ go(parseInt($(this).text()));
+ })
+ }
+ pagination.append(pag_ul);
+ div.append(pagination);
+ }
+ }
+
+ //Previous button
+ if(o.btnPrev)
+ $(o.btnPrev).click(function(e) {
+ e.preventDefault();
+ return go(curr-o.scroll);
+ });
+
+ //Next button
+ if(o.btnNext)
+ $(o.btnNext).click(function(e) {
+ e.preventDefault();
+ return go(curr+o.scroll);
+ });
+
+ //Pause button
+ if(o.btnPause)
+ $(o.btnPause).click(function(e) {
+ e.preventDefault();
+ if ($(this).hasClass('paused')) {
+ startRotateTimer();
+ } else {
+ pauseRotateTimer();
+ }
+ });
+
+ //Auto rotation
+ if(o.auto) startRotateTimer();
+
+ function startRotateTimer() {
+ clearInterval(timer);
+ timer = setInterval(function() {
+ if (curr == tl-1) {
+ go(0);
+ } else {
+ go(curr+o.scroll);
+ }
+ }, o.autoTime);
+ $(o.btnPause).removeClass('paused');
+ }
+
+ function pauseRotateTimer() {
+ clearInterval(timer);
+ $(o.btnPause).addClass('paused');
+ }
+
+ //Go to an item
+ function go(to) {
+ if(!running) {
+
+ if(to<0) {
+ to = itemLength-1;
+ } else if (to>itemLength-1) {
+ to = 0;
+ }
+ curr = to;
+
+ running = true;
+
+ ul.animate(
+ animCss == "left" ? { left: -(curr*liSize) } : { top: -(curr*liSize) } , o.speed, o.easing,
+ function() {
+ running = false;
+ }
+ );
+
+ $(o.btnPrev + "," + o.btnNext).removeClass("disabled");
+ $( (curr-o.scroll<0 && o.btnPrev)
+ ||
+ (curr+o.scroll > itemLength && o.btnNext)
+ ||
+ []
+ ).addClass("disabled");
+
+
+ var nav_items = $('li', pagination);
+ nav_items.removeClass('active');
+ nav_items.eq(to).addClass('active');
+
+
+ }
+ if(o.auto) startRotateTimer();
+ return false;
+ };
+ });
+ };
+
+ function css(el, prop) {
+ return parseInt($.css(el[0], prop)) || 0;
+ };
+ function width(el) {
+ return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
+ };
+ function height(el) {
+ return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
+ };
+
+ })(jQuery);
+
+
+/*
+ * dacSlideshow 1.0
+ * Used on develop/index.html for side-sliding tabs
+ *
+ * Sample usage:
+ * HTML -
+ *
+ *
+ *
+ *
+ * Options:
+ * btnPrev: optional identifier for previous button
+ * btnNext: optional identifier for next button
+ * auto: whether or not to auto-proceed
+ * speed: animation speed
+ * autoTime: time between auto-rotation
+ * easing: easing function for transition
+ * start: item to select by default
+ * scroll: direction to scroll in
+ * pagination: whether or not to include dotted pagination
+ *
+ */
+ (function($) {
+ $.fn.dacTabbedList = function(o) {
+
+ //Options - see above
+ o = $.extend({
+ speed : 250,
+ easing: null,
+ nav_id: null,
+ frame_id: null
+ }, o || {});
+
+ //Set up a carousel for each
+ return this.each(function() {
+
+ var curr = 0;
+ var running = false;
+ var animCss = "margin-left";
+ var sizeCss = "width";
+ var div = $(this);
+
+ var nav = $(o.nav_id, div);
+ var nav_li = $("li", nav);
+ var nav_size = nav_li.size();
+ var frame = div.find(o.frame_id);
+ var content_width = $(frame).find('ul').width();
+ //Buttons
+ $(nav_li).click(function(e) {
+ go($(nav_li).index($(this)));
+ })
+
+ //Go to an item
+ function go(to) {
+ if(!running) {
+ curr = to;
+ running = true;
+
+ frame.animate({ 'margin-left' : -(curr*content_width) }, o.speed, o.easing,
+ function() {
+ running = false;
+ }
+ );
+
+
+ nav_li.removeClass('active');
+ nav_li.eq(to).addClass('active');
+
+
+ }
+ return false;
+ };
+ });
+ };
+
+ function css(el, prop) {
+ return parseInt($.css(el[0], prop)) || 0;
+ };
+ function width(el) {
+ return el[0].offsetWidth + css(el, 'marginLeft') + css(el, 'marginRight');
+ };
+ function height(el) {
+ return el[0].offsetHeight + css(el, 'marginTop') + css(el, 'marginBottom');
+ };
+
+ })(jQuery);
+
+
+
+
+
+/* ######################################################## */
+/* ################ SEARCH SUGGESTIONS ################## */
+/* ######################################################## */
+
+
+
+var gSelectedIndex = -1; // the index position of currently highlighted suggestion
+var gSelectedColumn = -1; // which column of suggestion lists is currently focused
+
+var gMatches = new Array();
+var gLastText = "";
+var gInitialized = false;
+var ROW_COUNT_FRAMEWORK = 20; // max number of results in list
+var gListLength = 0;
+
+
+var gGoogleMatches = new Array();
+var ROW_COUNT_GOOGLE = 15; // max number of results in list
+var gGoogleListLength = 0;
+
+var gDocsMatches = new Array();
+var ROW_COUNT_DOCS = 100; // max number of results in list
+var gDocsListLength = 0;
+
+function onSuggestionClick(link) {
+ // When user clicks a suggested document, track it
+ ga('send', 'event', 'Suggestion Click', 'clicked: ' + $(link).attr('href'),
+ 'query: ' + $("#search_autocomplete").val().toLowerCase());
+}
+
+function set_item_selected($li, selected)
+{
+ if (selected) {
+ $li.attr('class','jd-autocomplete jd-selected');
+ } else {
+ $li.attr('class','jd-autocomplete');
+ }
+}
+
+function set_item_values(toroot, $li, match)
+{
+ var $link = $('a',$li);
+ $link.html(match.__hilabel || match.label);
+ $link.attr('href',toroot + match.link);
+}
+
+function set_item_values_jd(toroot, $li, match)
+{
+ var $link = $('a',$li);
+ $link.html(match.title);
+ $link.attr('href',toroot + match.url);
+}
+
+function new_suggestion($list) {
+ var $li = $(" ");
+ $list.append($li);
+
+ $li.mousedown(function() {
+ window.location = this.firstChild.getAttribute("href");
+ });
+ $li.mouseover(function() {
+ $('.search_filtered_wrapper li').removeClass('jd-selected');
+ $(this).addClass('jd-selected');
+ gSelectedColumn = $(".search_filtered:visible").index($(this).closest('.search_filtered'));
+ gSelectedIndex = $("li", $(".search_filtered:visible")[gSelectedColumn]).index(this);
+ });
+ $li.append(" ");
+ $li.attr('class','show-item');
+ return $li;
+}
+
+function sync_selection_table(toroot)
+{
+ var $li; //list item jquery object
+ var i; //list item iterator
+
+ // if there are NO results at all, hide all columns
+ if (!(gMatches.length > 0) && !(gGoogleMatches.length > 0) && !(gDocsMatches.length > 0)) {
+ $('.suggest-card').hide(300);
+ return;
+ }
+
+ // if there are api results
+ if ((gMatches.length > 0) || (gGoogleMatches.length > 0)) {
+ // reveal suggestion list
+ $('.suggest-card.dummy').show();
+ $('.suggest-card.reference').show();
+ var listIndex = 0; // list index position
+
+ // reset the lists
+ $(".search_filtered_wrapper.reference li").remove();
+
+ // ########### ANDROID RESULTS #############
+ if (gMatches.length > 0) {
+
+ // determine android results to show
+ gListLength = gMatches.length < ROW_COUNT_FRAMEWORK ?
+ gMatches.length : ROW_COUNT_FRAMEWORK;
+ for (i=0; i 0) {
+ // show header for list
+ $(".suggest-card.reference ul").append("");
+
+ // determine google results to show
+ gGoogleListLength = gGoogleMatches.length < ROW_COUNT_GOOGLE ? gGoogleMatches.length : ROW_COUNT_GOOGLE;
+ for (i=0; i 0) {
+ // reset the lists
+ $(".search_filtered_wrapper.docs li").remove();
+
+ // determine google results to show
+ // NOTE: The order of the conditions below for the sugg.type MUST BE SPECIFIC:
+ // The order must match the reverse order that each section appears as a card in
+ // the suggestion UI... this may be only for the "develop" grouped items though.
+ gDocsListLength = gDocsMatches.length < ROW_COUNT_DOCS ? gDocsMatches.length : ROW_COUNT_DOCS;
+ for (i=0; i 0) {
+ $(".suggest-card.design ul").prepend("");
+ $(".suggest-card.design").show(300);
+ } else {
+ $('.suggest-card.design').hide(300);
+ }
+ if ($(".suggest-card.distribute li").length > 0) {
+ $(".suggest-card.distribute ul").prepend("");
+ $(".suggest-card.distribute").show(300);
+ } else {
+ $('.suggest-card.distribute').hide(300);
+ }
+ if ($(".child-card.guides li").length > 0) {
+ $(".child-card.guides").prepend("");
+ $(".child-card.guides li").appendTo(".suggest-card.develop ul");
+ }
+ if ($(".child-card.training li").length > 0) {
+ $(".child-card.training").prepend("");
+ $(".child-card.training li").appendTo(".suggest-card.develop ul");
+ }
+ if ($(".child-card.samples li").length > 0) {
+ $(".child-card.samples").prepend("");
+ $(".child-card.samples li").appendTo(".suggest-card.develop ul");
+ }
+
+ if ($(".suggest-card.develop li").length > 0) {
+ $(".suggest-card.develop").show(300);
+ } else {
+ $('.suggest-card.develop').hide(300);
+ }
+
+ } else {
+ $('.search_filtered_wrapper.docs .suggest-card:not(.dummy)').hide(300);
+ }
+}
+
+/** Called by the search input's onkeydown and onkeyup events.
+ * Handles navigation with keyboard arrows, Enter key to invoke search,
+ * otherwise invokes search suggestions on key-up event.
+ * @param e The JS event
+ * @param kd True if the event is key-down
+ * @param toroot A string for the site's root path
+ * @returns True if the event should bubble up
+ */
+function search_changed(e, kd, toroot)
+{
+ var currentLang = getLangPref();
+ var search = document.getElementById("search_autocomplete");
+ var text = search.value.replace(/(^ +)|( +$)/g, '');
+ // get the ul hosting the currently selected item
+ gSelectedColumn = gSelectedColumn >= 0 ? gSelectedColumn : 0;
+ var $columns = $(".search_filtered_wrapper").find(".search_filtered:visible");
+ var $selectedUl = $columns[gSelectedColumn];
+
+ // show/hide the close button
+ if (text != '') {
+ $(".search .close").removeClass("hide");
+ } else {
+ $(".search .close").addClass("hide");
+ }
+ // 27 = esc
+ if (e.keyCode == 27) {
+ // close all search results
+ if (kd) $('.search .close').trigger('click');
+ return true;
+ }
+ // 13 = enter
+ else if (e.keyCode == 13) {
+ if (gSelectedIndex < 0) {
+ $('.suggest-card').hide();
+ if ($("#searchResults").is(":hidden") && (search.value != "")) {
+ // if results aren't showing (and text not empty), return true to allow search to execute
+ $('body,html').animate({scrollTop:0}, '500', 'swing');
+ return true;
+ } else {
+ // otherwise, results are already showing, so allow ajax to auto refresh the results
+ // and ignore this Enter press to avoid the reload.
+ return false;
+ }
+ } else if (kd && gSelectedIndex >= 0) {
+ // click the link corresponding to selected item
+ $("a",$("li",$selectedUl)[gSelectedIndex]).get()[0].click();
+ return false;
+ }
+ }
+ // If Google results are showing, return true to allow ajax search to execute
+ else if ($("#searchResults").is(":visible")) {
+ // Also, if search_results is scrolled out of view, scroll to top to make results visible
+ if ((sticky ) && (search.value != "")) {
+ $('body,html').animate({scrollTop:0}, '500', 'swing');
+ }
+ return true;
+ }
+ // 38 UP ARROW
+ else if (kd && (e.keyCode == 38)) {
+ // if the next item is a header, skip it
+ if ($($("li", $selectedUl)[gSelectedIndex-1]).hasClass("header")) {
+ gSelectedIndex--;
+ }
+ if (gSelectedIndex >= 0) {
+ $('li', $selectedUl).removeClass('jd-selected');
+ gSelectedIndex--;
+ $('li:nth-child('+(gSelectedIndex+1)+')', $selectedUl).addClass('jd-selected');
+ // If user reaches top, reset selected column
+ if (gSelectedIndex < 0) {
+ gSelectedColumn = -1;
+ }
+ }
+ return false;
+ }
+ // 40 DOWN ARROW
+ else if (kd && (e.keyCode == 40)) {
+ // if the next item is a header, skip it
+ if ($($("li", $selectedUl)[gSelectedIndex+1]).hasClass("header")) {
+ gSelectedIndex++;
+ }
+ if ((gSelectedIndex < $("li", $selectedUl).length-1) ||
+ ($($("li", $selectedUl)[gSelectedIndex+1]).hasClass("header"))) {
+ $('li', $selectedUl).removeClass('jd-selected');
+ gSelectedIndex++;
+ $('li:nth-child('+(gSelectedIndex+1)+')', $selectedUl).addClass('jd-selected');
+ }
+ return false;
+ }
+ // Consider left/right arrow navigation
+ // NOTE: Order of suggest columns are reverse order (index position 0 is on right)
+ else if (kd && $columns.length > 1 && gSelectedColumn >= 0) {
+ // 37 LEFT ARROW
+ // go left only if current column is not left-most column (last column)
+ if (e.keyCode == 37 && gSelectedColumn < $columns.length - 1) {
+ $('li', $selectedUl).removeClass('jd-selected');
+ gSelectedColumn++;
+ $selectedUl = $columns[gSelectedColumn];
+ // keep or reset the selected item to last item as appropriate
+ gSelectedIndex = gSelectedIndex >
+ $("li", $selectedUl).length-1 ?
+ $("li", $selectedUl).length-1 : gSelectedIndex;
+ // if the corresponding item is a header, move down
+ if ($($("li", $selectedUl)[gSelectedIndex]).hasClass("header")) {
+ gSelectedIndex++;
+ }
+ // set item selected
+ $('li:nth-child('+(gSelectedIndex+1)+')', $selectedUl).addClass('jd-selected');
+ return false;
+ }
+ // 39 RIGHT ARROW
+ // go right only if current column is not the right-most column (first column)
+ else if (e.keyCode == 39 && gSelectedColumn > 0) {
+ $('li', $selectedUl).removeClass('jd-selected');
+ gSelectedColumn--;
+ $selectedUl = $columns[gSelectedColumn];
+ // keep or reset the selected item to last item as appropriate
+ gSelectedIndex = gSelectedIndex >
+ $("li", $selectedUl).length-1 ?
+ $("li", $selectedUl).length-1 : gSelectedIndex;
+ // if the corresponding item is a header, move down
+ if ($($("li", $selectedUl)[gSelectedIndex]).hasClass("header")) {
+ gSelectedIndex++;
+ }
+ // set item selected
+ $('li:nth-child('+(gSelectedIndex+1)+')', $selectedUl).addClass('jd-selected');
+ return false;
+ }
+ }
+
+ // if key-up event and not arrow down/up/left/right,
+ // read the search query and add suggestions to gMatches
+ else if (!kd && (e.keyCode != 40)
+ && (e.keyCode != 38)
+ && (e.keyCode != 37)
+ && (e.keyCode != 39)) {
+ gSelectedIndex = -1;
+ gMatches = new Array();
+ matchedCount = 0;
+ gGoogleMatches = new Array();
+ matchedCountGoogle = 0;
+ gDocsMatches = new Array();
+ matchedCountDocs = 0;
+
+ // Search for Android matches
+ for (var i=0; i= 2) {
+ // Regex to match only the beginning of a word
+ var textRegex = new RegExp("\\b" + text.toLowerCase(), "g");
+
+
+ // Search for Training classes
+ for (var i=0; i= 0; j--) {
+ // it matches a tag
+ if (s.keywords[j].toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_tag = j + 1; // add 1 to index position
+ }
+ }
+ // Don't consider doc title for lessons (only for class landing pages),
+ // unless the lesson has a tag that already matches
+ if ((s.lang == currentLang) &&
+ (!(s.type == "training" && s.url.indexOf("index.html") == -1) || matched)) {
+ // it matches the doc title
+ if (s.title.toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_title = 1;
+ }
+ }
+ if (matched) {
+ gDocsMatches[matchedCountDocs] = s;
+ matchedCountDocs++;
+ }
+ }
+
+
+ // Search for API Guides
+ for (var i=0; i= 0; j--) {
+ // it matches a tag
+ if (s.keywords[j].toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_tag = j + 1; // add 1 to index position
+ }
+ }
+ // Check if query matches the doc title, but only for current language
+ if (s.lang == currentLang) {
+ // if query matches the doc title
+ if (s.title.toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_title = 1;
+ }
+ }
+ if (matched) {
+ gDocsMatches[matchedCountDocs] = s;
+ matchedCountDocs++;
+ }
+ }
+
+
+ // Search for Tools Guides
+ for (var i=0; i= 0; j--) {
+ // it matches a tag
+ if (s.keywords[j].toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_tag = j + 1; // add 1 to index position
+ }
+ }
+ // Check if query matches the doc title, but only for current language
+ if (s.lang == currentLang) {
+ // if query matches the doc title
+ if (s.title.toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_title = 1;
+ }
+ }
+ if (matched) {
+ gDocsMatches[matchedCountDocs] = s;
+ matchedCountDocs++;
+ }
+ }
+
+
+ // Search for About docs
+ for (var i=0; i= 0; j--) {
+ // it matches a tag
+ if (s.keywords[j].toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_tag = j + 1; // add 1 to index position
+ }
+ }
+ // Check if query matches the doc title, but only for current language
+ if (s.lang == currentLang) {
+ // if query matches the doc title
+ if (s.title.toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_title = 1;
+ }
+ }
+ if (matched) {
+ gDocsMatches[matchedCountDocs] = s;
+ matchedCountDocs++;
+ }
+ }
+
+
+ // Search for Design guides
+ for (var i=0; i= 0; j--) {
+ // it matches a tag
+ if (s.keywords[j].toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_tag = j + 1; // add 1 to index position
+ }
+ }
+ // Check if query matches the doc title, but only for current language
+ if (s.lang == currentLang) {
+ // if query matches the doc title
+ if (s.title.toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_title = 1;
+ }
+ }
+ if (matched) {
+ gDocsMatches[matchedCountDocs] = s;
+ matchedCountDocs++;
+ }
+ }
+
+
+ // Search for Distribute guides
+ for (var i=0; i= 0; j--) {
+ // it matches a tag
+ if (s.keywords[j].toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_tag = j + 1; // add 1 to index position
+ }
+ }
+ // Check if query matches the doc title, but only for current language
+ if (s.lang == currentLang) {
+ // if query matches the doc title
+ if (s.title.toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_title = 1;
+ }
+ }
+ if (matched) {
+ gDocsMatches[matchedCountDocs] = s;
+ matchedCountDocs++;
+ }
+ }
+
+
+ // Search for Google guides
+ for (var i=0; i= 0; j--) {
+ // it matches a tag
+ if (s.keywords[j].toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_tag = j + 1; // add 1 to index position
+ }
+ }
+ // Check if query matches the doc title, but only for current language
+ if (s.lang == currentLang) {
+ // if query matches the doc title
+ if (s.title.toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_title = 1;
+ }
+ }
+ if (matched) {
+ gDocsMatches[matchedCountDocs] = s;
+ matchedCountDocs++;
+ }
+ }
+
+
+ // Search for Samples
+ for (var i=0; i= 0; j--) {
+ // it matches a tag
+ if (s.keywords[j].toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_tag = j + 1; // add 1 to index position
+ }
+ }
+ // Check if query matches the doc title, but only for current language
+ if (s.lang == currentLang) {
+ // if query matches the doc title.t
+ if (s.title.toLowerCase().match(textRegex)) {
+ matched = true;
+ s.matched_title = 1;
+ }
+ }
+ if (matched) {
+ gDocsMatches[matchedCountDocs] = s;
+ matchedCountDocs++;
+ }
+ }
+
+ // Rank/sort all the matched pages
+ rank_autocomplete_doc_results(text, gDocsMatches);
+ }
+
+ // draw the suggestions
+ sync_selection_table(toroot);
+ return true; // allow the event to bubble up to the search api
+ }
+}
+
+/* Order the jd doc result list based on match quality */
+function rank_autocomplete_doc_results(query, matches) {
+ query = query || '';
+ if (!matches || !matches.length)
+ return;
+
+ var _resultScoreFn = function(match) {
+ var score = 1.0;
+
+ // if the query matched a tag
+ if (match.matched_tag > 0) {
+ // multiply score by factor relative to position in tags list (max of 3)
+ score *= 3 / match.matched_tag;
+
+ // if it also matched the title
+ if (match.matched_title > 0) {
+ score *= 2;
+ }
+ } else if (match.matched_title > 0) {
+ score *= 3;
+ }
+
+ return score;
+ };
+
+ for (var i=0; i