Merge "introduce AUX build class of targets"

This commit is contained in:
Alexey Polyudov 2016-08-02 22:37:02 +00:00 committed by Gerrit Code Review
commit 556526bf95
13 changed files with 537 additions and 35 deletions

183
core/aux_config.mk Normal file
View File

@ -0,0 +1,183 @@
variant_list := $(filter AUX-%,$(MAKECMDGOALS))
ifdef variant_list
AUX_OS_VARIANT_LIST := $(patsubst AUX-%,%,$(variant_list))
else
AUX_OS_VARIANT_LIST := $(TARGET_AUX_OS_VARIANT_LIST)
endif
# exclude AUX targets from build
ifeq ($(AUX_OS_VARIANT_LIST),none)
AUX_OS_VARIANT_LIST :=
endif
# temporary workaround to support external toolchain
ifeq ($(NANOHUB_TOOLCHAIN),)
AUX_OS_VARIANT_LIST :=
endif
# setup toolchain paths for various CPU architectures
# this one will come from android prebuilts eventually
AUX_TOOLCHAIN_cortexm4 := $(NANOHUB_TOOLCHAIN)
ifeq ($(wildcard $(AUX_TOOLCHAIN_cortexm4)gcc),)
AUX_TOOLCHAIN_cortexm4:=
endif
# there is no MAKE var that defines path to HOST toolchain
# all the interesting paths are hardcoded in soong, and are not available from here
# There is no other way but to hardcode them again, as we may need host x86 toolcain for AUX
ifeq ($(HOST_OS),linux)
AUX_TOOLCHAIN_x86 := prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.15-4.8/bin/x86_64-linux-
endif
# setup AUX globals
AUX_SHLIB_SUFFIX := .so
AUX_GLOBAL_ARFLAGS := crsPD
AUX_STATIC_LIB_SUFFIX := .a
# Load ever-lasting "indexed" version of AUX variant environment; it is treated as READ-ONLY from this
# moment on.
#
# $(1) - variant
# no return value
define aux-variant-setup-paths
$(eval AUX_OUT_ROOT_$(1) := $(PRODUCT_OUT)/aux/$(1)) \
$(eval AUX_COMMON_OUT_ROOT_$(1) := $(AUX_OUT_ROOT_$(1))/common) \
$(eval AUX_OUT_$(1) := $(AUX_OUT_ROOT_$(1))/$(AUX_OS_$(1))-$(AUX_ARCH_$(1))-$(AUX_CPU_$(1))) \
$(eval AUX_OUT_INTERMEDIATES_$(1) := $(AUX_OUT_$(1))/obj) \
$(eval AUX_OUT_COMMON_INTERMEDIATES_$(1) := $(AUX_COMMON_OUT_ROOT_$(1))/obj) \
$(eval AUX_OUT_HEADERS_$(1) := $(AUX_OUT_INTERMEDIATES_$(1))/include) \
$(eval AUX_OUT_INTERMEDIATE_LIBRARIES_$(1) := $(AUX_OUT_INTERMEDIATES_$(1))/lib) \
$(eval AUX_OUT_NOTICE_FILES_$(1) := $(AUX_OUT_INTERMEDIATES_$(1))/NOTICE_FILES) \
$(eval AUX_OUT_FAKE_$(1) := $(AUX_OUT_$(1))/fake_packages) \
$(eval AUX_OUT_GEN_$(1) := $(AUX_OUT_$(1))/gen) \
$(eval AUX_OUT_COMMON_GEN_$(1) := $(AUX_COMMON_OUT_ROOT_$(1))/gen) \
$(eval AUX_OUT_EXECUTABLES_$(1) := $(AUX_OUT_$(1))/bin) \
$(eval AUX_OUT_UNSTRIPPED_$(1) := $(AUX_OUT_$(1))/symbols)
endef
# Copy "indexed" AUX environment for given VARIANT into
# volatile not-indexed set of variables for simplicity of access.
# Injection of index support throughout the build system is suboptimal
# hence volatile environment is constructed
# Unlike HOST*, TARGET* variables, AUX* variables are NOT read-only, but their
# indexed versions are.
#
# $(1) - variant
# no return value
define aux-variant-load-env
$(eval AUX_OS_VARIANT:=$(1)) \
$(eval AUX_OS:=$(AUX_OS_$(1))) \
$(eval AUX_ARCH:=$(AUX_ARCH_$(1))) \
$(eval AUX_SUBARCH:=$(AUX_SUBARCH_$(1))) \
$(eval AUX_CPU:=$(AUX_CPU_$(1))) \
$(eval AUX_OS_PATH:=$(AUX_OS_PATH_$(1))) \
$(eval AUX_OUT_ROOT := $(AUX_OUT_ROOT_$(1))) \
$(eval AUX_COMMON_OUT_ROOT := $(AUX_COMMON_OUT_ROOT_$(1))) \
$(eval AUX_OUT := $(AUX_OUT_$(1))) \
$(eval AUX_OUT_INTERMEDIATES := $(AUX_OUT_INTERMEDIATES_$(1))) \
$(eval AUX_OUT_COMMON_INTERMEDIATES := $(AUX_OUT_COMMON_INTERMEDIATES_$(1))) \
$(eval AUX_OUT_HEADERS := $(AUX_OUT_HEADERS_$(1))) \
$(eval AUX_OUT_INTERMEDIATE_LIBRARIES := $(AUX_OUT_INTERMEDIATE_LIBRARIES_$(1))) \
$(eval AUX_OUT_NOTICE_FILES := $(AUX_OUT_NOTICE_FILES_$(1))) \
$(eval AUX_OUT_FAKE := $(AUX_OUT_FAKE_$(1))) \
$(eval AUX_OUT_GEN := $(AUX_OUT_GEN_$(1))) \
$(eval AUX_OUT_COMMON_GEN := $(AUX_OUT_COMMON_GEN_$(1))) \
$(eval AUX_OUT_EXECUTABLES := $(AUX_OUT_EXECUTABLES_$(1))) \
$(eval AUX_OUT_UNSTRIPPED := $(AUX_OUT_UNSTRIPPED_$(1)))
endef
# given a variant:path pair, load the variant conviguration with aux-variant-setup-paths from file
# this is a build system extension mechainsm, since configuration typically resides in non-build
# project space
#
# $(1) - variant:path pair
# $(2) - file suffix
# no return value
define aux-variant-import-from-pair
$(eval _pair := $(subst :, ,$(1))) \
$(eval _name:=$(word 1,$(_pair))) \
$(eval _path:=$(word 2,$(_pair))) \
$(eval include $(_path)/$(_name)$(2)) \
$(eval AUX_OS_VARIANT_LIST_$(AUX_OS_$(1)):=) \
$(call aux-variant-setup-paths,$(_name)) \
$(eval AUX_ALL_VARIANTS += $(_name)) \
$(eval AUX_ALL_OSES := $(filterout $(AUX_OS_$(_name)),$(AUX_ALL_OSES)) $(AUX_OS_$(_name))) \
$(eval AUX_ALL_CPUS := $(filterout $(AUX_CPU_$(_name)),$(AUX_ALL_CPUS)) $(AUX_CPU_$(_name))) \
$(eval AUX_ALL_ARCHS := $(filterout $(AUX_ARCH_$(_name)),$(AUX_ALL_ARCHS)) $(AUX_ARCH_$(_name))) \
$(eval AUX_ALL_SUBARCHS := $(filterout $(AUX_SUBARCH_$(_name)),$(AUX_ALL_SUBARCHS)) $(AUX_SUBARCH_$(_name)))
endef
# Load system configuration referenced by AUX variant config;
# this is a build extension mechanism; typically system config
# resides in a non-build projects;
# system config may define new rules and globally visible BUILD*
# includes to support project-specific build steps and toolchains
# MAintains list of valiants that reference this os config in OS "indexed" var
# this facilitates multivariant build of the OS (or whataver it is the name of common component these variants share)
#
# $(1) - variant
# no return value
define aux-import-os-config
$(eval _aioc_os := $(AUX_OS_$(1))) \
$(eval AUX_OS_PATH_$(1) := $(patsubst $(_aioc_os):%,%,$(filter $(_aioc_os):%,$(AUX_ALL_OS_PATHS)))) \
$(eval _aioc_os_cfg := $(AUX_OS_PATH_$(1))/$(_aioc_os)$(os_sfx)) \
$(if $(wildcard $(_aioc_os_cfg)),,$(error AUX '$(_aioc_os)' OS config file [$(notdir $(_aioc_os_cfg))] required by AUX variant '$(1)' does not exist)) \
$(if $(filter $(_aioc_os),$(_os_list)),,$(eval include $(_aioc_os_cfg))) \
$(eval AUX_OS_VARIANT_LIST_$(_aioc_os) += $(1)) \
$(eval _os_list += $(_aioc_os))
endef
# make sure that AUX config variables are minimally sane;
# as a bare minimum they must contain the vars described by aux_env
# Generate error if requirement is not met.
#
#$(1) - variant
# no return value
define aux-variant-validate
$(eval _all:=) \
$(eval _req:=$(addsuffix _$(1),$(aux_env))) \
$(foreach var,$(_req),$(eval _all += $(var))) \
$(eval _missing := $(filterout $(_all),$(_req))) \
$(if $(_missing),$(error AUX variant $(1) must define vars: $(_missing)))
endef
AUX_ALL_VARIANTS :=
AUX_ALL_OSES :=
AUX_ALL_CPUS :=
AUX_ALL_ARCHS :=
AUX_ALL_SUBARCHS :=
variant_sfx :=_aux_variant_config.mk
os_sfx :=_aux_os_config.mk
all_configs := $(shell find device vendor -maxdepth 4 -name '*$(variant_sfx)' -o -name '*$(os_sfx)' | sort)
all_os_configs := $(filter %$(os_sfx),$(all_configs))
all_variant_configs := $(filter %$(variant_sfx),$(all_configs))
AUX_ALL_OS_PATHS := $(foreach f,$(all_os_configs),$(patsubst %$(os_sfx),%,$(notdir $(f))):$(patsubst %/,%,$(dir $(f))))
AUX_ALL_OS_VARIANT_PATHS := $(foreach f,$(all_variant_configs),$(patsubst %$(variant_sfx),%,$(notdir $(f))):$(patsubst %/,%,$(dir $(f))))
my_variant_pairs := $(foreach v,$(AUX_OS_VARIANT_LIST),$(filter $(v):%,$(AUX_ALL_OS_VARIANT_PATHS)))
my_missing_variants := $(foreach v,$(AUX_OS_VARIANT_LIST),$(if $(filter $(v):%,$(AUX_ALL_OS_VARIANT_PATHS)),,$(v)))
ifneq ($(strip $(my_missing_variants)),)
$(error Don't know how to build variant(s): $(my_missing_variants))
endif
# mandatory variables
aux_env := AUX_OS AUX_ARCH AUX_SUBARCH AUX_CPU
$(foreach v,$(my_variant_pairs),$(if $(filter $(v),$(AUX_ALL_VARIANTS)),,$(call aux-variant-import-from-pair,$(v),$(variant_sfx))))
ifdef AUX_ALL_VARIANTS
_os_list :=
$(foreach v,$(AUX_ALL_VARIANTS),\
$(call aux-import-os-config,$(v)) \
$(call aux-variant-validate,$(v)) \
)
endif
INSTALLED_AUX_TARGETS :=
droidcore: auxiliary

96
core/aux_executable.mk Normal file
View File

@ -0,0 +1,96 @@
# caller might have included aux_toolchain, e.g. if custom build steps are defined
ifeq ($(LOCAL_IS_AUX_MODULE),)
include $(BUILD_SYSTEM)/aux_toolchain.mk
endif
ifeq ($(AUX_BUILD_NOT_COMPATIBLE),)
###########################################################
## Standard rules for building an executable file.
##
## Additional inputs from base_rules.make:
## None.
###########################################################
ifeq ($(strip $(LOCAL_MODULE_CLASS)),)
LOCAL_MODULE_CLASS := EXECUTABLES
endif
$(call $(aux-executable-hook))
###########################################################
## 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).
###########################################################
# 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)
# 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 AUX_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
###################################
aux_output := $(linked_module)
ifneq ($(LOCAL_CUSTOM_BUILD_STEP_INPUT),)
ifneq ($(LOCAL_CUSTOM_BUILD_STEP_OUTPUT),)
# injecting custom build steps
$(LOCAL_CUSTOM_BUILD_STEP_INPUT): $(aux_output)
@echo "$(AUX_DISPLAY) custom copy: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(hide) $(copy-file-to-target)
aux_output := $(LOCAL_CUSTOM_BUILD_STEP_OUTPUT)
endif
endif
$(LOCAL_BUILT_MODULE): $(aux_output)
@echo "$(AUX_DISPLAY) final copy: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(hide) $(copy-file-to-target)
INSTALLED_AUX_TARGETS += $(LOCAL_INSTALLED_MODULE)
$(cleantarget): PRIVATE_CLEAN_FILES += \
$(linked_module) \
# Define PRIVATE_ variables from global vars
$(linked_module): PRIVATE_TARGET_OUT_INTERMEDIATE_LIBRARIES := $(AUX_OUT_INTERMEDIATE_LIBRARIES)
$(linked_module): PRIVATE_POST_LINK_CMD := $(LOCAL_POST_LINK_CMD)
ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
$(linked_module): $(all_objects) $(all_libraries) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-o-to-aux-static-executable)
$(PRIVATE_POST_LINK_CMD)
else
$(linked_module): $(all_objects) $(all_libraries) $(LOCAL_ADDITIONAL_DEPENDENCIES)
$(transform-o-to-aux-executable)
$(PRIVATE_POST_LINK_CMD)
endif
endif # AUX_BUILD_NOT_COMPATIBLE

View File

@ -0,0 +1,27 @@
ifeq ($(LOCAL_IS_AUX_MODULE),)
include $(BUILD_SYSTEM)/aux_toolchain.mk
endif
ifeq ($(AUX_BUILD_NOT_COMPATIBLE),)
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
$(LOCAL_BUILT_MODULE) : PRIVATE_AR := $(AUX_AR)
$(LOCAL_BUILT_MODULE) : $(built_whole_libraries)
$(LOCAL_BUILT_MODULE) : $(all_objects)
$(transform-o-to-aux-static-lib)
endif # AUX_BUILD_NOT_COMPATIBLE

53
core/aux_toolchain.mk Normal file
View File

@ -0,0 +1,53 @@
###########################################################
# takes form LOCAL_AUX_TOOLCHAIN_$(LOCAL_AUX_CPU)
###########################################################
###############################
# setup AUX environment
###############################
# shortcuts for targets with a single instance of OS, ARCH, VARIANT, CPU
AUX_TOOLCHAIN := $(if $(LOCAL_AUX_TOOLCHAIN),$(LOCAL_AUX_TOOLCHAIN),$(AUX_TOOLCHAIN_$(AUX_CPU)))
AUX_BUILD_NOT_COMPATIBLE:=
ifeq ($(strip $(AUX_TOOLCHAIN)),)
ifeq ($(strip $(AUX_CPU)),)
$(warning $(LOCAL_PATH): $(LOCAL_MODULE): Undefined CPU for AUX toolchain)
AUX_BUILD_NOT_COMPATIBLE += TOOLCHAIN
else
$(warning $(LOCAL_PATH): $(LOCAL_MODULE): Undefined AUX toolchain for CPU=$(AUX_CPU))
AUX_BUILD_NOT_COMPATIBLE += TOOLCHAIN
endif
endif
AUX_BUILD_NOT_COMPATIBLE += $(foreach var,OS ARCH SUBARCH CPU OS_VARIANT,$(if $(LOCAL_AUX_$(var)),$(if \
$(filter $(LOCAL_AUX_$(var)),$(AUX_$(var))),,$(var))))
AUX_BUILD_NOT_COMPATIBLE := $(strip $(AUX_BUILD_NOT_COMPATIBLE))
ifneq ($(AUX_BUILD_NOT_COMPATIBLE),)
$(info $(LOCAL_PATH): $(LOCAL_MODULE): not compatible: "$(AUX_BUILD_NOT_COMPATIBLE)" with)
$(info ====> OS=$(AUX_OS) CPU=$(AUX_CPU) ARCH=$(AUX_ARCH) SUBARCH=$(AUX_SUBARCH) OS_VARIANT=$(AUX_OS_VARIANT))
$(info ====> TOOLCHAIN=$(AUX_TOOLCHAIN))
endif
AUX_AR := $(AUX_TOOLCHAIN)ar
AUX_AS := $(AUX_TOOLCHAIN)gcc
AUX_CC := $(AUX_TOOLCHAIN)gcc
AUX_CXX := $(AUX_TOOLCHAIN)g++
AUX_LINKER := $(AUX_TOOLCHAIN)ld
AUX_OBJCOPY := $(AUX_TOOLCHAIN)objcopy
AUX_OBJDUMP := $(AUX_TOOLCHAIN)objdump
###############################
# setup Android environment
###############################
LOCAL_IS_AUX_MODULE := true
LOCAL_2ND_ARCH_VAR_PREFIX :=
LOCAL_CC := $(AUX_CC)
LOCAL_CXX := $(AUX_CXX)
LOCAL_NO_DEFAULT_COMPILER_FLAGS := true
LOCAL_SYSTEM_SHARED_LIBRARIES :=
LOCAL_CXX_STL := none
LOCAL_NO_PIC := true
LOCAL_NO_LIBCOMPILER_RT := true

View File

@ -33,6 +33,7 @@ ifeq ($(LOCAL_MODULE),)
endif
LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
LOCAL_IS_AUX_MODULE := $(strip $(LOCAL_IS_AUX_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)")
@ -43,8 +44,18 @@ ifdef LOCAL_IS_HOST_MODULE
my_prefix := $(LOCAL_HOST_PREFIX)
endif
my_host := host-
my_kind := HOST
else
my_prefix := TARGET_
ifdef LOCAL_IS_AUX_MODULE
ifneq ($(LOCAL_IS_AUX_MODULE),true)
$(error $(LOCAL_PATH): LOCAL_IS_AUX_MODULE must be "true" or empty, not "$(LOCAL_IS_AUX_MODULE)")
endif
my_prefix := AUX_
my_kind := AUX
else
my_prefix := TARGET_
my_kind :=
endif
my_host :=
endif
@ -195,9 +206,13 @@ ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX
my_register_name := $(my_register_name)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX)
endif
endif
# variant is enough to make nano class unique; it serves as a key to lookup (OS,ARCH) tuple
aux_class := $($(my_prefix)OS_VARIANT)
# 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)
$(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),$(if \
$(LOCAL_IS_AUX_MODULE),$(aux_class),TARGET)).$(LOCAL_MODULE_CLASS).$(my_register_name)
ifdef $(module_id)
$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
endif
@ -292,6 +307,7 @@ $(cleantarget)::
###########################################################
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_AUX_MODULE := $(LOCAL_IS_AUX_MODULE)
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix)

View File

@ -338,7 +338,7 @@ 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)
my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LINKER)
endif
include $(BUILD_SYSTEM)/config_sanitizers.mk
@ -388,24 +388,24 @@ my_target_global_c_system_includes := $(my_ndk_stl_include_path) $(my_ndk_sysroo
my_target_global_cppflags := $(my_ndk_stl_cppflags)
else
my_target_global_c_includes := $(SRC_HEADERS) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_INCLUDES) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_INCLUDES)
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_INCLUDES) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_PROJECT_SYSTEM_INCLUDES) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_C_SYSTEM_INCLUDES)
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)PROJECT_SYSTEM_INCLUDES) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_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)
my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS)
my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS)
my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)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)
my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CFLAGS)
my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CONLYFLAGS)
my_target_global_cppflags += $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_CPPFLAGS)
my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)GLOBAL_LDFLAGS)
endif # my_clang
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes)
@ -464,9 +464,9 @@ else
endif
ifeq ($(my_clang),true)
my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBPROFILE_RT)
my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
else
my_coverage_lib := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcov,,,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcov.a
my_coverage_lib := $(call intermediates-dir-for,STATIC_LIBRARIES,libgcov,$(filter AUX,$(my_kind)),,$(LOCAL_2ND_ARCH_VAR_PREFIX))/libgcov.a
endif
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib)
@ -494,7 +494,7 @@ endif
ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
my_syntax_arch := host
else
my_syntax_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
my_syntax_arch := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
endif
ifeq ($(strip $(my_cc)),)
@ -1249,9 +1249,9 @@ endif
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) \
$(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(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))
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
$(import_includes): PRIVATE_IMPORT_EXPORT_INCLUDES := $(import_includes_deps)
$(import_includes) : $(import_includes_deps)
@echo Import includes file: $@
@ -1264,7 +1264,6 @@ else
$(hide) touch $@
endif
####################################################
## Verify that NDK-built libraries only link against
## other NDK-built libraries
@ -1280,11 +1279,11 @@ $(my_link_type): PRIVATE_ALLOWED_TYPES := (ndk|platform)
endif
my_link_type_deps := $(strip \
$(foreach l,$(my_whole_static_libraries) $(my_static_libraries), \
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
ifneq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
my_link_type_deps += $(strip \
$(foreach l,$(my_shared_libraries), \
$(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
$(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/link_type))
endif
$(my_link_type): PRIVATE_DEPS := $(my_link_type_deps)
$(my_link_type): PRIVATE_MODULE := $(LOCAL_MODULE)
@ -1437,7 +1436,7 @@ 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))
STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
ifdef LOCAL_SDK_VERSION
built_static_libraries += $(my_ndk_stl_static_lib)
@ -1446,7 +1445,7 @@ 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))
STATIC_LIBRARIES,$(lib),$(my_kind),,$(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.
@ -1625,15 +1624,15 @@ $(export_includes): PRIVATE_EXPORT_C_INCLUDE_DIRS := $(my_export_c_include_dirs)
# Headers exported by whole static libraries are also exported by this library.
export_include_deps := $(strip \
$(foreach l,$(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))
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
# Re-export requested headers from shared libraries.
export_include_deps += $(strip \
$(foreach l,$(LOCAL_EXPORT_SHARED_LIBRARY_HEADERS), \
$(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
$(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
# Re-export requested headers from static libraries.
export_include_deps += $(strip \
$(foreach l,$(LOCAL_EXPORT_STATIC_LIBRARY_HEADERS), \
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(LOCAL_IS_HOST_MODULE),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/export_includes))
$(export_includes): PRIVATE_REEXPORTED_INCLUDES := $(export_include_deps)
# By adding $(my_generated_sources) it makes sure the headers get generated
# before any dependent source files get compiled.

View File

@ -365,6 +365,16 @@ LOCAL_MODULE_SYMLINKS_64:=
LOCAL_JAVA_LANGUAGE_VERSION:=
LOCAL_CTS_GTEST_LIST_EXECUTABLE:=
LOCAL_IS_AUX_MODULE :=
LOCAL_AUX_TOOLCHAIN :=
LOCAL_AUX_OS :=
LOCAL_AUX_ARCH :=
LOCAL_AUX_SUBARCH :=
LOCAL_AUX_CPU :=
LOCAL_AUX_OS_VARIANT :=
LOCAL_CUSTOM_BUILD_STEP_INPUT:=
LOCAL_CUSTOM_BUILD_STEP_OUTPUT:=
# 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

View File

@ -70,6 +70,8 @@ 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_AUX_STATIC_LIBRARY:= $(BUILD_SYSTEM)/aux_static_library.mk
BUILD_AUX_EXECUTABLE:= $(BUILD_SYSTEM)/aux_executable.mk
BUILD_SHARED_LIBRARY:= $(BUILD_SYSTEM)/shared_library.mk
BUILD_EXECUTABLE:= $(BUILD_SYSTEM)/executable.mk
BUILD_HOST_EXECUTABLE:= $(BUILD_SYSTEM)/host_executable.mk

View File

@ -92,6 +92,7 @@ ANDROID_RESOURCE_GENERATED_CLASSES := 'R.class' 'R$$*.class' 'Manifest.class' 'M
# Display names for various build targets
TARGET_DISPLAY := target
AUX_DISPLAY := aux
HOST_DISPLAY := host
HOST_CROSS_DISPLAY := host cross
@ -456,6 +457,28 @@ define reverse-list
$(if $(1),$(call reverse-list,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
endef
define def-host-aux-target
$(eval _idf_val_:=$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST,$(if $(strip $(LOCAL_IS_AUX_MODULE)),AUX,))) \
$(_idf_val_)
endef
###########################################################
## Returns correct _idfPrefix from the list:
## { HOST, HOST_CROSS, AUX, TARGET }
###########################################################
# the following rules checked in order:
# ($1 is in {AUX, HOST_CROSS} => $1;
# ($1 is empty) => TARGET;
# ($2 is not empty) => HOST_CROSS;
# => HOST;
define find-idf-prefix
$(strip \
$(eval _idf_pfx_:=$(strip $(filter AUX HOST_CROSS,$(1)))) \
$(eval _idf_pfx_:=$(if $(strip $(1)),$(if $(_idf_pfx_),$(_idf_pfx_),$(if $(strip $(2)),HOST_CROSS,HOST)),TARGET)) \
$(_idf_pfx_)
)
endef
###########################################################
## The intermediates directory. Where object files go for
## a given target. We could technically get away without
@ -466,7 +489,7 @@ endef
# $(1): target class, like "APPS"
# $(2): target name, like "NotePad"
# $(3): if non-empty, this is a HOST target.
# $(3): { HOST, HOST_CROSS, AUX, <empty (TARGET)>, <other non-empty (HOST)> }
# $(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
@ -478,7 +501,7 @@ $(strip \
$(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 _idfPrefix := $(call find-idf-prefix,$(3),$(6))) \
$(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
$(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
$(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \
@ -503,7 +526,7 @@ $(strip \
$(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)) \
$(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(call def-host-aux-target),$(1),$(2),$(3)) \
)
endef
@ -518,7 +541,7 @@ endef
# $(1): target class, like "APPS"
# $(2): target name, like "NotePad"
# $(3): if non-empty, this is a HOST target.
# $(3): { HOST, HOST_CROSS, AUX, <empty (TARGET)>, <other non-empty (HOST)> }
# $(4): if non-empty, force the generated sources to be COMMON
define generated-sources-dir-for
$(strip \
@ -528,7 +551,7 @@ $(strip \
$(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)) \
$(eval _idfPrefix := $(call find-idf-prefix,$(3),)) \
$(if $(filter $(_idfPrefix)-$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
$(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_GEN)) \
, \
@ -548,7 +571,7 @@ $(strip \
$(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)) \
$(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(call def-host-aux-target),$(1)) \
)
endef
@ -1558,6 +1581,89 @@ $(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
$(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
endef
# $(1): the full path of the source static library.
define _extract-and-include-single-aux-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_AR) t $(1)`; do \
if [ -e $$ldir/$$f ]; then \
mkdir $$ldir/$$subdir; \
ext=$$subdir/; \
subdir=$$((subdir+1)); \
$(PRIVATE_AR) m $$lib_to_include $$f; \
else \
ext=; \
fi; \
$(PRIVATE_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
filelist="$$filelist $$ldir/$$ext$$f"; \
done ; \
$(PRIVATE_AR) $(AUX_GLOBAL_ARFLAGS) \
$(PRIVATE_ARFLAGS) $@ $$filelist
endef
define extract-and-include-aux-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-aux-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-aux-static-lib
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
@rm -f $@
$(extract-and-include-aux-whole-static-libs)
$(call split-long-arguments,$(PRIVATE_AR) \
$(AUX_GLOBAL_ARFLAGS) \
$(PRIVATE_ARFLAGS) $@,$(PRIVATE_ALL_OBJECTS))
endef
define transform-o-to-aux-executable-inner
$(hide) $(PRIVATE_CXX) -pie \
-Bdynamic \
-Wl,--gc-sections \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(PRIVATE_LDFLAGS) \
-o $@
endef
define transform-o-to-aux-executable
@echo "$(AUX_DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(transform-o-to-aux-executable-inner)
endef
define transform-o-to-aux-static-executable-inner
$(hide) $(PRIVATE_CXX) \
-Bstatic \
-Wl,--gc-sections \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
-Wl,--no-whole-archive \
$(call normalize-target-libraries,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(PRIVATE_LDFLAGS) \
-Wl,-Map=$(@).map \
-o $@
endef
define transform-o-to-aux-static-executable
@echo "$(AUX_DISPLAY) StaticExecutable: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(transform-o-to-aux-static-executable-inner)
endef
###########################################################
## Commands for running host ar
###########################################################

View File

@ -22,7 +22,8 @@ print_build_config_vars := \
HOST_CROSS_2ND_ARCH \
HOST_BUILD_TYPE \
BUILD_ID \
OUT_DIR
OUT_DIR \
AUX_OS_VARIANT_LIST
ifeq ($(TARGET_BUILD_PDK),true)
print_build_config_vars += \

View File

@ -273,6 +273,9 @@ 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
# Nano environment config
include $(BUILD_SYSTEM)/aux_config.mk
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

View File

@ -457,6 +457,9 @@ ifneq ($(words $(sort $(filter-out $(INTERNAL_MODIFIER_TARGETS) checkbuild emula
$(error The 'sdk' target may not be specified with any other targets)
endif
# AUX dependencies are already added by now; remove triggers from the MAKECMDGOALS
MAKECMDGOALS := $(strip $(filter-out AUX-%,$(MAKECMDGOALS)))
# TODO: this should be eng I think. Since the sdk is built from the eng
# variant.
tags_to_install := debug eng
@ -934,6 +937,8 @@ my_all_modules := $(sort $(foreach m, $(ALL_MODULES),$(if $(filter\
all_modules: $(my_all_modules)
endif
.PHONY: auxiliary
auxiliary: $(INSTALLED_AUX_TARGETS)
# Build files and then package it into the rom formats
.PHONY: droidcore

View File

@ -17,6 +17,7 @@ PARSE_TIME_MAKE_GOALS := \
DUMP_% \
ECLIPSE-% \
PRODUCT-% \
AUX-% \
boottarball-nodeps \
brillo_tests \
btnod \