# 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.
# Returns all words in $1 up to and including $2 define find_and_earlier
$(strip $(if $(1),
$(firstword $(1))
$(if $(filter $(firstword $(1)),$(2)),,
$(call find_and_earlier,$(wordlist 2,$(words $(1)),$(1)),$(2))))) endef
#$(warning $(call find_and_earlier,A B C,A)) #$(warning $(call find_and_earlier,A B C,B)) #$(warning $(call find_and_earlier,A B C,C)) #$(warning $(call find_and_earlier,A B C,D))
# Runs a starlark file, and sets all the variables in its top-level # variables_to_export_to_make variable as make variables. # # In order to avoid running starlark every time the stamp file is checked, we use # $(KATI_shell_no_rerun). Then, to make sure that we actually do rerun kati when # modifying the starlark files, we add the starlark files to the kati stamp file with # $(KATI_extra_file_deps). # # Arguments: # $(1): A single starlark file to use as the entrypoint # $(2): An optional list of starlark files to NOT include as kati dependencies. # $(3): An optional list of extra flags to pass to rbcrun define run-starlark
$(eval _starlark_results := $(OUT_DIR)/starlark_results/$(subst /,_,$(1)).mk)
$(KATI_shell_no_rerun mkdir -p $(OUT_DIR)/starlark_results && $(OUT_DIR)/rbcrun --mode=make $(3) $(1) >$(_starlark_results) && touch -t 200001010000 $(_starlark_results))
$(if $(filter-out 0,$(.SHELLSTATUS)),$(error Starlark failed to run))
$(evalinclude $(_starlark_results))
$(KATI_extra_file_deps $(filter-out $(2),$(LOADED_STARLARK_FILES)))
$(eval LOADED_STARLARK_FILES :=)
$(eval _starlark_results :=) endef
# --------------------------------------------------------------- # Release config include $(BUILD_SYSTEM)/release_config.mk
# --------------------------------------------------------------- # Set up version information include $(BUILD_SYSTEM)/version_util.mk
# This used to be calculated, but is now fixed and not expected # to change over time anymore. New code attempting to use a # variable like IS_AT_LAST_* should instead use a # build system flag.
# --------------------------------------------------------------- # 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 := 13
# --------------------------------------------------------------- # The product defaults to generic on hardware ifeq ($(TARGET_PRODUCT),)
TARGET_PRODUCT := aosp_arm64 endif
# the variant -- the set of files that are included for a build ifeq ($(strip $(TARGET_BUILD_VARIANT)),)
TARGET_BUILD_VARIANT := eng endif
# Set to true for an unbundled build, i.e. a build without # support for platform targets like the system image. This also # disables consistency checks that only apply to full platform # builds.
TARGET_BUILD_UNBUNDLED ?=
# TARGET_BUILD_APPS implies unbundled build, otherwise we default # to bundled (i.e. platform targets such as the system image are # included). ifneq ($(TARGET_BUILD_APPS),)
TARGET_BUILD_UNBUNDLED := true endif
# TARGET_BUILD_UNBUNDLED_IMAGE also implies unbundled build. # (i.e. it targets to only unbundled image, such as the vendor image, # ,or the product image). ifneq ($(TARGET_BUILD_UNBUNDLED_IMAGE),)
TARGET_BUILD_UNBUNDLED := true endif
# --------------------------------------------------------------- # Set up configuration for host machine. We don't do cross- # compiles except for arm, so the HOST is whatever we are # running on
# HOST_OS ifneq (,$(findstring Linux,$(UNAME)))
HOST_OS := linux endif ifneq (,$(findstring Darwin,$(UNAME)))
HOST_OS := darwin endif
# BUILD_OS is the real host doing the build.
BUILD_OS := $(HOST_OS)
# We can do the cross-build only on Linux ifeq ($(HOST_OS),linux) # Windows has been the default host_cross OS ifeq (,$(filter-out windows,$(HOST_CROSS_OS))) # We can only create static host binaries for Linux, so if static host # binaries are requested, turn off Windows cross-builds. ifeq ($(BUILD_HOST_static),)
HOST_CROSS_OS := windows
HOST_CROSS_ARCH := x86
HOST_CROSS_2ND_ARCH := x86_64 2ND_HOST_CROSS_IS_64_BIT := true endif elseifeq ($(HOST_CROSS_OS),linux_bionic) ifeq (,$(HOST_CROSS_ARCH))
$(error HOST_CROSS_ARCH missing.) endif else
$(error Unsupported HOST_CROSS_OS $(HOST_CROSS_OS)) endif elseifeq ($(HOST_OS),darwin)
HOST_CROSS_OS := darwin
HOST_CROSS_ARCH := arm64
HOST_CROSS_2ND_ARCH := 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 i686,$(UNAME))$(findstring x86,$(UNAME)))
$(error Building on a 32-bit x86 host is not supported: $(UNAME)!) endif endif
ifeq ($(HOST_OS),darwin) # Mac no longer supports 32-bit executables
HOST_2ND_ARCH := endif
combo_target := HOST_
combo_2nd_arch_prefix := include $(BUILD_COMBOS)/select.mk
ifdef HOST_2ND_ARCH
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_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
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 # This must match the logic in get_host_prebuilt_prefix in envsetup.sh
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_DLKM := system_dlkm
TARGET_COPY_OUT_SYSTEM_OTHER := system_other
TARGET_COPY_OUT_DATA := data
TARGET_COPY_OUT_ASAN := $(TARGET_COPY_OUT_DATA)/asan
TARGET_COPY_OUT_OEM := oem
TARGET_COPY_OUT_RAMDISK := ramdisk
TARGET_COPY_OUT_DEBUG_RAMDISK := debug_ramdisk
TARGET_COPY_OUT_VENDOR_DEBUG_RAMDISK := vendor_debug_ramdisk
TARGET_COPY_OUT_TEST_HARNESS_RAMDISK := test_harness_ramdisk
TARGET_COPY_OUT_ROOT := root
TARGET_COPY_OUT_RECOVERY := recovery # The directory used for optional partitions depend on the BoardConfig, so # they're defined to placeholder values here and swapped after reading the # BoardConfig, to be either the partition dir, or a subdir within 'system'.
_vendor_path_placeholder := ||VENDOR-PATH-PH||
_product_path_placeholder := ||PRODUCT-PATH-PH||
_system_ext_path_placeholder := ||SYSTEM_EXT-PATH-PH||
_odm_path_placeholder := ||ODM-PATH-PH||
_vendor_dlkm_path_placeholder := ||VENDOR_DLKM-PATH-PH||
_odm_dlkm_path_placeholder := ||ODM_DLKM-PATH-PH||
_system_dlkm_path_placeholder := ||SYSTEM_DLKM-PATH-PH||
TARGET_COPY_OUT_VENDOR := $(_vendor_path_placeholder)
TARGET_COPY_OUT_VENDOR_RAMDISK := vendor_ramdisk
TARGET_COPY_OUT_VENDOR_KERNEL_RAMDISK := vendor_kernel_ramdisk
TARGET_COPY_OUT_PRODUCT := $(_product_path_placeholder) # TODO(b/135957588) TARGET_COPY_OUT_PRODUCT_SERVICES will copy the target to # product
TARGET_COPY_OUT_PRODUCT_SERVICES := $(_product_path_placeholder)
TARGET_COPY_OUT_SYSTEM_EXT := $(_system_ext_path_placeholder)
TARGET_COPY_OUT_ODM := $(_odm_path_placeholder)
TARGET_COPY_OUT_VENDOR_DLKM := $(_vendor_dlkm_path_placeholder)
TARGET_COPY_OUT_ODM_DLKM := $(_odm_dlkm_path_placeholder)
TARGET_COPY_OUT_SYSTEM_DLKM := $(_system_dlkm_path_placeholder)
# Returns the non-sanitized version of the path provided in $1. define get_non_asan_path
$(patsubst $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/%,$(PRODUCT_OUT)/%,$1) endef
################################################################# # Set up minimal BOOTCLASSPATH list of jars to build/execute # java code with dalvikvm/art. # Jars present in the ART apex. These should match exactly the list of Java # libraries in art-bootclasspath-fragment. The APEX variant name # (com.android.art) is the same regardless which Soong module provides the ART # APEX. See the long comment in build/soong/java/dexprepopt_bootjars.go for # details.
ART_APEX_JARS := \
com.android.art:core-oj \
com.android.art:core-libart \
com.android.art:okhttp \
com.android.art:bouncycastle \
com.android.art:apache-xml # With EMMA_INSTRUMENT_FRAMEWORK=true the Core libraries depend on jacoco. ifeq (true,$(EMMA_INSTRUMENT_FRAMEWORK))
ART_APEX_JARS += com.android.art:jacocoagent endif #################################################################
# Dumps all variables that match [A-Z][A-Z0-9_]* (with a few exceptions) # to the file at $(1). It is used to print only the variables that are # likely to be relevant to the product or board configuration. # Soong config variables are dumped as $(call soong_config_set) calls # instead of the raw variable values, because mk2rbc can't read the # raw ones. There is a final sed command on the output file to # remove leading spaces because I couldn't figure out how to remove # them in pure make code. define dump-variables-rbc
$(eval _dump_variables_rbc_excluded := \
BUILD_NUMBER \
DATE \
LOCAL_PATH \
MAKEFILE_LIST \
PRODUCTS \
PRODUCT_COPY_OUT_% \
RBC_PRODUCT_CONFIG \
RBC_BOARD_CONFIG \
SOONG_% \
TARGET_RELEASE \
TOPDIR \
TRACE_BEGIN_SOONG \
USER)
$(file >$(OUT_DIR)/dump-variables-rbc-temp-$(TARGET_PRODUCT).txt,$(subst $(space),$(newline),$(sort $(filter-out $(_dump_variables_rbc_excluded),$(.VARIABLES)))))
$(file >$(1),\
$(foreach v, $(shell grep -he "^[A-Z][A-Z0-9_]*$$" $(OUT_DIR)/dump-variables-rbc-temp-$(TARGET_PRODUCT).txt),\
$(v) := $(strip $($(v)))$(newline))\
$(foreach ns,$(sort $(SOONG_CONFIG_NAMESPACES)),\
$(foreach v,$(sort $(SOONG_CONFIG_$(ns))),\
$$(call soong_config_set,$(ns),$(v),$(SOONG_CONFIG_$(ns)_$(v)))$(newline))))
$(shell sed -i "s/^ *//g" $(1)) endef
# 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)
$(error bad TARGET_BUILD_VARIANT: $(TARGET_BUILD_VARIANT). Must be empty or one of: eng user userdebug) endif
# The default host library path. # It always points to the path where we build libraries in the default bitness.
HOST_LIBRARY_PATH := $(HOST_OUT_SHARED_LIBRARIES)
.KATI_READONLY := HOST_LIBRARY_PATH
TARGET_OUT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM)
.KATI_READONLY := TARGET_OUT ifneq ($(filter address,$(SANITIZE_TARGET)),)
target_out_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/system ifeq ($(SANITIZE_LITE),true) # When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not # work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
target_out_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/system else
target_out_app_base := $(TARGET_OUT) endif else
target_out_shared_libraries_base := $(TARGET_OUT)
target_out_app_base := $(TARGET_OUT) endif
ifeq ($(SANITIZE_LITE),true) # When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not # work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
TARGET_OUT_SYSTEM_OTHER := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_SYSTEM_OTHER) else
TARGET_OUT_SYSTEM_OTHER := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM_OTHER) endif
.KATI_READONLY := TARGET_OUT_SYSTEM_OTHER
# Out for TARGET_2ND_ARCH
TARGET_2ND_ARCH_MODULE_SUFFIX := $(HOST_2ND_ARCH_MODULE_SUFFIX)
.KATI_READONLY := TARGET_2ND_ARCH_MODULE_SUFFIX
TARGET_OUT_VENDOR := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_VENDOR)
.KATI_READONLY := TARGET_OUT_VENDOR ifneq ($(filter address,$(SANITIZE_TARGET)),)
target_out_vendor_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_VENDOR) ifeq ($(SANITIZE_LITE),true) # When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not # work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
target_out_vendor_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_VENDOR) else
target_out_vendor_app_base := $(TARGET_OUT_VENDOR) endif else
target_out_vendor_shared_libraries_base := $(TARGET_OUT_VENDOR)
target_out_vendor_app_base := $(TARGET_OUT_VENDOR) endif
TARGET_OUT_ODM := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ODM) ifneq ($(filter address,$(SANITIZE_TARGET)),)
target_out_odm_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_OEM) ifeq ($(SANITIZE_LITE),true) # When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not # work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
target_out_odm_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_OEM) else
target_out_odm_app_base := $(TARGET_OUT_ODM) endif else
target_out_odm_shared_libraries_base := $(TARGET_OUT_ODM)
target_out_odm_app_base := $(TARGET_OUT_ODM) endif
# Unlike other partitions, system_dlkm should only contain kernel modules.
TARGET_OUT_SYSTEM_DLKM_EXECUTABLES :=
TARGET_OUT_SYSTEM_DLKM_OPTIONAL_EXECUTABLES :=
TARGET_OUT_SYSTEM_DLKM_SHARED_LIBRARIES :=
TARGET_OUT_SYSTEM_DLKM_RENDERSCRIPT_BITCODE :=
TARGET_OUT_SYSTEM_DLKM_JAVA_LIBRARIES :=
TARGET_OUT_SYSTEM_DLKM_APPS :=
TARGET_OUT_SYSTEM_DLKM_APPS_PRIVILEGED :=
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_EXECUTABLES :=
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_SHARED_LIBRARIES :=
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_RENDERSCRIPT_BITCODE :=
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_APPS :=
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_APPS_PRIVILEGED :=
$(KATI_obsolete_var \
TARGET_OUT_SYSTEM_DLKM_EXECUTABLES \
TARGET_OUT_SYSTEM_DLKM_OPTIONAL_EXECUTABLES \
TARGET_OUT_SYSTEM_DLKM_SHARED_LIBRARIES \
TARGET_OUT_SYSTEM_DLKM_RENDERSCRIPT_BITCODE \
TARGET_OUT_SYSTEM_DLKM_JAVA_LIBRARIES \
TARGET_OUT_SYSTEM_DLKM_APPS \
TARGET_OUT_SYSTEM_DLKM_APPS_PRIVILEGED \
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_EXECUTABLES \
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_SHARED_LIBRARIES \
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_RENDERSCRIPT_BITCODE \
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_APPS \
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SYSTEM_DLKM_APPS_PRIVILEGED \
, system_dlkm should not contain any executables, libraries, or apps)
TARGET_OUT_PRODUCT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_PRODUCT)
TARGET_OUT_PRODUCT_EXECUTABLES := $(TARGET_OUT_PRODUCT)/bin
.KATI_READONLY := TARGET_OUT_PRODUCT ifneq ($(filter address,$(SANITIZE_TARGET)),)
target_out_product_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_PRODUCT) ifeq ($(SANITIZE_LITE),true) # When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not # work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
target_out_product_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_PRODUCT) else
target_out_product_app_base := $(TARGET_OUT_PRODUCT) endif else
target_out_product_shared_libraries_base := $(TARGET_OUT_PRODUCT)
target_out_product_app_base := $(TARGET_OUT_PRODUCT) endif
TARGET_OUT_SYSTEM_EXT := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_SYSTEM_EXT) ifneq ($(filter address,$(SANITIZE_TARGET)),)
target_out_system_ext_shared_libraries_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_SYSTEM_EXT) ifeq ($(SANITIZE_LITE),true) # When using SANITIZE_LITE, APKs must not be packaged with sanitized libraries, as they will not # work with unsanitized app_process. For simplicity, generate APKs into /data/asan/.
target_out_system_ext_app_base := $(PRODUCT_OUT)/$(TARGET_COPY_OUT_ASAN)/$(TARGET_COPY_OUT_SYSTEM_EXT) else
target_out_system_ext_app_base := $(TARGET_OUT_SYSTEM_EXT) endif else
target_out_system_ext_shared_libraries_base := $(TARGET_OUT_SYSTEM_EXT)
target_out_system_ext_app_base := $(TARGET_OUT_SYSTEM_EXT) endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.