Home | History | Annotate | Download | only in core
      1 # We don't automatically set up rules to build executables for both
      2 # TARGET_ARCH and TARGET_2ND_ARCH.
      3 # By default, an executable is built for TARGET_ARCH.
      4 # To build it for TARGET_2ND_ARCH in a 64bit product, use "LOCAL_MULTILIB := 32"
      5 # To build it for both set LOCAL_MULTILIB := both and specify
      6 # LOCAL_MODULE_PATH_32 and LOCAL_MODULE_PATH_64 or LOCAL_MODULE_STEM_32 and
      7 # LOCAL_MODULE_STEM_64
      8 
      9 my_skip_this_target :=
     10 ifneq ($(filter address,$(SANITIZE_TARGET)),)
     11   ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE))
     12     my_skip_this_target := true
     13   else ifeq (false, $(LOCAL_CLANG))
     14     my_skip_this_target := true
     15   endif
     16 endif
     17 
     18 ifneq (true,$(my_skip_this_target))
     19 $(call record-module-type,EXECUTABLE)
     20 
     21 ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
     22 # If a native test explicity specifies to build only for the translation arch,
     23 # we'll still need LOCAL_MULTILIB=both and let module_arch_supported.mk choose
     24 # to build only for TARGET_2ND_ARCH.
     25 ifneq (1,$(words $(LOCAL_MODULE_TARGET_ARCH)))
     26 LOCAL_MULTILIB := first
     27 endif
     28 endif
     29 
     30 my_prefix := TARGET_
     31 include $(BUILD_SYSTEM)/multilib.mk
     32 
     33 ifeq ($(my_module_multilib),both)
     34 ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
     35 ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),)
     36 $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
     37 endif
     38 ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),)
     39 $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE))
     40 endif
     41 endif
     42 else #!LOCAL_MULTILIB == both
     43 LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true
     44 endif
     45 
     46 # if TARGET_PREFER_32_BIT_EXECUTABLES is set, try to build 32-bit first
     47 ifdef TARGET_2ND_ARCH
     48 ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true)
     49 LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
     50 else
     51 LOCAL_2ND_ARCH_VAR_PREFIX :=
     52 endif
     53 endif
     54 
     55 my_skip_non_preferred_arch :=
     56 
     57 # check if preferred arch is supported
     58 include $(BUILD_SYSTEM)/module_arch_supported.mk
     59 ifeq ($(my_module_arch_supported),true)
     60 # first arch is supported
     61 include $(BUILD_SYSTEM)/executable_internal.mk
     62 ifneq ($(my_module_multilib),both)
     63 my_skip_non_preferred_arch := true
     64 endif
     65 endif
     66 
     67 # check if preferred arch was not supported or asked to build both
     68 ifndef my_skip_non_preferred_arch
     69 ifdef TARGET_2ND_ARCH
     70 
     71 # check if the non-preferred arch is the primary or secondary
     72 ifeq ($(TARGET_PREFER_32_BIT_EXECUTABLES),true)
     73 LOCAL_2ND_ARCH_VAR_PREFIX :=
     74 else
     75 LOCAL_2ND_ARCH_VAR_PREFIX := $(TARGET_2ND_ARCH_VAR_PREFIX)
     76 endif
     77 
     78 # check if non-preferred arch is supported
     79 include $(BUILD_SYSTEM)/module_arch_supported.mk
     80 ifeq ($(my_module_arch_supported),true)
     81 # non-preferred arch is supported
     82 OVERRIDE_BUILT_MODULE_PATH :=
     83 LOCAL_BUILT_MODULE :=
     84 LOCAL_INSTALLED_MODULE :=
     85 LOCAL_INTERMEDIATE_TARGETS :=
     86 include $(BUILD_SYSTEM)/executable_internal.mk
     87 endif
     88 endif # TARGET_2ND_ARCH
     89 endif # !my_skip_non_preferred_arch || LOCAL_MULTILIB
     90 LOCAL_2ND_ARCH_VAR_PREFIX :=
     91 LOCAL_NO_2ND_ARCH_MODULE_SUFFIX :=
     92 
     93 my_module_arch_supported :=
     94 
     95 endif
     96