2009-03-04 11:28:42 +08:00
###########################################################
## Standard rules for building binary object files from
2014-03-22 07:17:04 +08:00
## asm/c/cpp/yacc/lex/etc source files.
2009-03-04 11:28:42 +08:00
##
## The list of object files is exported in $(all_objects).
###########################################################
2014-03-22 07:17:04 +08:00
#######################################
i n c l u d e $( BUILD_SYSTEM ) / b a s e _ r u l e s . m k
#######################################
2014-11-15 07:28:49 +08:00
##################################################
# 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.
i f d e f L O C A L _ I S _ H O S T _ M O D U L E
ifeq ( $( LOCAL_SYSTEM_SHARED_LIBRARIES) ,none)
my_system_shared_libraries :=
else
my_system_shared_libraries := $( LOCAL_SYSTEM_SHARED_LIBRARIES)
endif
e l s e
ifeq ( $( LOCAL_SYSTEM_SHARED_LIBRARIES) ,none)
2015-08-07 03:22:40 +08:00
my_system_shared_libraries := libc libm
2014-11-15 07:28:49 +08:00
else
my_system_shared_libraries := $( LOCAL_SYSTEM_SHARED_LIBRARIES)
endif
e n d i f
2016-08-27 04:27:13 +08:00
my_soong_problems :=
2014-11-15 07:28:49 +08:00
# 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)
2015-07-01 03:21:59 +08:00
my_src_files_exclude := $( LOCAL_SRC_FILES_EXCLUDE)
2014-11-15 07:28:49 +08:00
my_static_libraries := $( LOCAL_STATIC_LIBRARIES)
my_whole_static_libraries := $( LOCAL_WHOLE_STATIC_LIBRARIES)
my_shared_libraries := $( LOCAL_SHARED_LIBRARIES)
my_cflags := $( LOCAL_CFLAGS)
2014-11-26 16:53:46 +08:00
my_conlyflags := $( LOCAL_CONLYFLAGS)
2014-11-15 07:28:49 +08:00
my_cppflags := $( LOCAL_CPPFLAGS)
2015-06-11 07:33:43 +08:00
my_cflags_no_override := $( GLOBAL_CFLAGS_NO_OVERRIDE)
my_cppflags_no_override := $( GLOBAL_CPPFLAGS_NO_OVERRIDE)
2014-11-15 07:28:49 +08:00
my_ldflags := $( LOCAL_LDFLAGS)
my_ldlibs := $( LOCAL_LDLIBS)
my_asflags := $( LOCAL_ASFLAGS)
my_cc := $( LOCAL_CC)
2015-07-21 09:40:18 +08:00
my_cc_wrapper := $( CC_WRAPPER)
2014-11-15 07:28:49 +08:00
my_cxx := $( LOCAL_CXX)
2015-07-21 09:40:18 +08:00
my_cxx_wrapper := $( CXX_WRAPPER)
2014-11-15 07:28:49 +08:00
my_c_includes := $( LOCAL_C_INCLUDES)
my_generated_sources := $( LOCAL_GENERATED_SOURCES)
my_native_coverage := $( LOCAL_NATIVE_COVERAGE)
2016-01-07 06:28:36 +08:00
my_additional_dependencies := $( LOCAL_ADDITIONAL_DEPENDENCIES)
2015-04-08 02:59:34 +08:00
my_export_c_include_dirs := $( LOCAL_EXPORT_C_INCLUDE_DIRS)
2014-11-15 07:28:49 +08:00
2014-11-15 09:15:00 +08:00
i f d e f L O C A L _ I S _ H O S T _ M O D U L E
my_allow_undefined_symbols := true
e l s e
my_allow_undefined_symbols := $( strip $( LOCAL_ALLOW_UNDEFINED_SYMBOLS) )
e n d i f
2014-04-26 14:47:10 +08:00
my_ndk_sysroot :=
my_ndk_sysroot_include :=
my_ndk_sysroot_lib :=
2012-08-15 01:13:16 +08:00
i f d e f L O C A L _ S D K _ V E R S I O N
2010-07-14 05:55:47 +08:00
ifdef LOCAL_IS_HOST_MODULE
2012-10-02 07:36:23 +08:00
$( error $( LOCAL_PATH) : LOCAL_SDK_VERSION cannot be used in host module)
2010-07-14 05:55:47 +08:00
endif
2016-04-07 01:20:02 +08:00
2016-07-22 01:04:12 +08:00
# Make sure we've built the NDK.
2016-07-30 06:09:03 +08:00
my_additional_dependencies += $( SOONG_OUT_DIR) /ndk.timestamp
2016-07-22 01:04:12 +08:00
2016-04-07 01:20:02 +08:00
# mips32r6 is not supported by the NDK. No released NDK contains these
# libraries, but the r10 in prebuilts/ndk had a local hack to add them :(
#
# We need to find a real solution to this problem, but until we do just drop
# mips32r6 things back to r10 to get the tree building again.
ifeq ( mips32r6,$( TARGET_$( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH_VARIANT) )
ifeq ( $( LOCAL_NDK_VERSION) , current)
LOCAL_NDK_VERSION := r10
endif
endif
2016-07-22 01:04:12 +08:00
my_arch := $( TARGET_$( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH)
ifneq ( ,$( filter arm64 mips64 x86_64,$( my_arch) ) )
my_min_sdk_version := 21
else
my_min_sdk_version := 9
endif
# Historically we've just set up a bunch of symlinks in prebuilts/ndk to map
# missing API levels to existing ones where necessary, but we're not doing
# that for the generated libraries. Clip the API level to the minimum where
# appropriate.
my_ndk_api := \
$( shell if [ $( LOCAL_SDK_VERSION) -lt $( my_min_sdk_version) ] ; then \
echo $( my_min_sdk_version) ; else echo $( LOCAL_SDK_VERSION) ; fi )
2016-08-06 07:34:40 +08:00
# Traditionally this has come from android/api-level.h, but with the libc
# headers unified it must be set by the build system since we don't have
# per-API level copies of that header now.
my_cflags += -D__ANDROID_API__= $( my_ndk_api)
2016-07-22 01:04:12 +08:00
my_ndk_source_root := \
$( HISTORICAL_NDK_VERSIONS_ROOT) /$( LOCAL_NDK_VERSION) /sources
my_ndk_sysroot := \
$( HISTORICAL_NDK_VERSIONS_ROOT) /$( LOCAL_NDK_VERSION) /platforms/android-$( my_ndk_api) /arch-$( my_arch)
my_built_ndk := $( SOONG_OUT_DIR) /ndk
my_ndk_triple := $( $( LOCAL_2ND_ARCH_VAR_PREFIX) TARGET_NDK_TRIPLE)
my_ndk_sysroot_include := \
$( my_built_ndk) /sysroot/usr/include \
$( my_built_ndk) /sysroot/usr/include/$( my_ndk_triple) \
$( my_ndk_sysroot) /usr/include \
2015-12-12 04:49:18 +08:00
# 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.
2016-07-22 01:04:12 +08:00
ifneq ( ,$( filter x86_64 mips64,$( my_arch) ) )
my_ndk_libdir_name := lib64
2014-11-09 07:25:18 +08:00
else ifeq ( mips32r6,$( TARGET_$( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH_VARIANT) )
2016-07-22 01:04:12 +08:00
my_ndk_libdir_name := libr6
2014-04-26 14:47:10 +08:00
else
2016-07-22 01:04:12 +08:00
my_ndk_libdir_name := lib
2014-04-26 14:47:10 +08:00
endif
2011-03-04 10:53:53 +08:00
2016-07-22 01:04:12 +08:00
my_ndk_platform_dir := \
$( my_built_ndk) /platforms/android-$( my_ndk_api) /arch-$( my_arch)
my_built_ndk_libs := $( my_ndk_platform_dir) /usr/$( my_ndk_libdir_name)
my_ndk_sysroot_lib := $( my_ndk_sysroot) /usr/$( my_ndk_libdir_name)
2015-04-24 09:48:52 +08:00
# The bionic linker now has support for packed relocations and gnu style
# hashes (which are much faster!), but shipping to older devices requires
2015-12-10 06:52:25 +08:00
# the old style hash. Fortunately, we can build with both and it'll work
# anywhere.
2015-12-10 08:26:20 +08:00
#
# 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
2015-12-10 06:52:25 +08:00
# We don't want to expose the relocation packer to the NDK just yet.
LOCAL_PACK_MODULE_RELOCATIONS := false
2014-11-15 07:28:49 +08:00
2011-03-04 10:53:53 +08:00
# 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_static_lib :=
2014-03-04 17:11:52 +08:00
my_ndk_stl_cppflags :=
2014-11-09 07:25:18 +08:00
my_cpu_variant := $( TARGET_$( LOCAL_2ND_ARCH_VAR_PREFIX) CPU_ABI)
2016-04-07 01:20:02 +08:00
ifeq ( mips32r6,$( TARGET_$( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH_VARIANT) )
my_cpu_variant := mips32r6
endif
2014-03-04 17:11:52 +08:00
LOCAL_NDK_STL_VARIANT := $( strip $( LOCAL_NDK_STL_VARIANT) )
2011-03-04 10:53:53 +08:00
ifeq ( ,$( LOCAL_NDK_STL_VARIANT) )
LOCAL_NDK_STL_VARIANT := system
endif
2015-12-10 06:46:13 +08:00
ifneq ( 1,$( words $( filter none system stlport_static stlport_shared c++_static c++_shared gnustl_static, $( LOCAL_NDK_STL_VARIANT) ) ) )
2012-08-15 01:13:16 +08:00
$( error $( LOCAL_PATH) : Unknown LOCAL_NDK_STL_VARIANT $( LOCAL_NDK_STL_VARIANT) )
2011-03-04 10:53:53 +08:00
endif
ifeq ( system,$( LOCAL_NDK_STL_VARIANT) )
my_ndk_stl_include_path := $( my_ndk_source_root) /cxx-stl/system/include
2015-12-10 06:46:13 +08:00
my_system_shared_libraries += libstdc++
2011-03-04 10:53:53 +08:00
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
2015-12-10 06:46:13 +08:00
my_system_shared_libraries += libstdc++
2011-03-04 10:53:53 +08:00
ifeq ( stlport_static,$( LOCAL_NDK_STL_VARIANT) )
2014-11-09 07:25:18 +08:00
my_ndk_stl_static_lib := $( my_ndk_source_root) /cxx-stl/stlport/libs/$( my_cpu_variant) /libstlport_static.a
2016-03-11 07:17:09 +08:00
my_ldlibs += -ldl
2011-03-04 10:53:53 +08:00
else
2014-11-09 07:25:18 +08:00
my_ndk_stl_shared_lib_fullpath := $( my_ndk_source_root) /cxx-stl/stlport/libs/$( my_cpu_variant) /libstlport_shared.so
2011-03-04 10:53:53 +08:00
endif
2014-03-04 17:11:52 +08:00
else # LOCAL_NDK_STL_VARIANT is not stlport_* either
ifneq ( ,$( filter c++_%, $( LOCAL_NDK_STL_VARIANT) ) )
2016-03-23 08:17:40 +08:00
# Pre-r11 NDKs used libgabi++ for libc++'s C++ ABI, but r11 and later use
# libc++abi.
2016-08-09 08:14:59 +08:00
#
# r13 no longer has the inner directory as a side effect of just using
# external/libcxx.
ifeq ( r10,$( LOCAL_NDK_VERSION) )
my_ndk_stl_include_path := \
$( my_ndk_source_root) /cxx-stl/llvm-libc++/libcxx/include
2016-03-23 08:17:40 +08:00
my_ndk_stl_include_path += \
$( my_ndk_source_root) /cxx-stl/llvm-libc++/gabi++/include
2016-08-09 08:14:59 +08:00
else ifeq ( r11,$( LOCAL_NDK_VERSION) )
my_ndk_stl_include_path := \
$( my_ndk_source_root) /cxx-stl/llvm-libc++/libcxx/include
2016-03-23 08:17:40 +08:00
my_ndk_stl_include_path += \
$( my_ndk_source_root) /cxx-stl/llvm-libc++abi/libcxxabi/include
2016-08-09 08:14:59 +08:00
else
my_ndk_stl_include_path := \
$( my_ndk_source_root) /cxx-stl/llvm-libc++/include
my_ndk_stl_include_path += \
$( my_ndk_source_root) /cxx-stl/llvm-libc++abi/include
2016-03-23 08:17:40 +08:00
endif
2016-08-09 08:14:59 +08:00
my_ndk_stl_include_path += $( my_ndk_source_root) /android/support/include
my_libcxx_libdir := \
$( my_ndk_source_root) /cxx-stl/llvm-libc++/libs/$( my_cpu_variant)
ifneq ( ,$( filter r10 r11,$( LOCAL_NDK_VERSION) ) )
ifeq ( c++_static,$( LOCAL_NDK_STL_VARIANT) )
my_ndk_stl_static_lib := $( my_libcxx_libdir) /libc++_static.a
my_ldlibs += -ldl
else
my_ndk_stl_shared_lib_fullpath := $( my_libcxx_libdir) /libc++_shared.so
endif
2014-03-04 17:11:52 +08:00
else
2016-08-09 08:14:59 +08:00
ifeq ( c++_static,$( LOCAL_NDK_STL_VARIANT) )
my_ndk_stl_static_lib := \
$( my_libcxx_libdir) /libc++_static.a \
$( my_libcxx_libdir) /libc++abi.a
my_ldlibs += -ldl
else
my_ndk_stl_shared_lib_fullpath := $( my_libcxx_libdir) /libc++_shared.so
endif
my_ndk_stl_static_lib += $( my_libcxx_libdir) /libandroid_support.a
ifneq ( ,$( filter armeabi armeabi-v7a,$( my_cpu_variant) ) )
my_ndk_stl_static_lib += $( my_libcxx_libdir) /libunwind.a
endif
2014-03-04 17:11:52 +08:00
endif
2016-08-09 08:14:59 +08:00
2014-03-04 17:11:52 +08:00
my_ndk_stl_cppflags := -std= c++11
2015-12-10 06:46:13 +08:00
else # LOCAL_NDK_STL_VARIANT is not c++_* either
ifneq ( ,$( filter gnustl_%, $( LOCAL_NDK_STL_VARIANT) ) )
2014-11-09 07:25:18 +08:00
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 \
2014-04-11 13:46:26 +08:00
$( my_ndk_source_root) /cxx-stl/gnu-libstdc++/$( $( LOCAL_2ND_ARCH_VAR_PREFIX) TARGET_NDK_GCC_VERSION) /include
2014-11-09 07:25:18 +08:00
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
2015-12-10 06:46:13 +08:00
else # LOCAL_NDK_STL_VARIANT must be none
# Do nothing.
endif
2011-03-04 10:53:53 +08:00
endif
endif
2014-03-04 17:11:52 +08:00
endif
2016-08-05 05:14:50 +08:00
e n d i f
2016-07-22 01:04:12 +08:00
2016-08-05 05:14:50 +08:00
i f n d e f L O C A L _ I S _ H O S T _ M O D U L E
# For device libraries, move LOCAL_LDLIBS references to my_shared_libraries. We
# no longer need to use my_ldlibs to pick up NDK prebuilt libraries since we're
# linking my_shared_libraries by full path now.
my_allowed_ldlibs :=
# Sort ldlibs and ldflags between -l and other linker flags
# We'll do this again later, since there are still changes happening, but that's fine.
my_ldlib_flags := $( my_ldflags) $( my_ldlibs)
my_ldlibs := $( filter -l%,$( my_ldlib_flags) )
my_ldflags := $( filter-out -l%,$( my_ldlib_flags) )
my_ldlib_flags :=
# Move other ldlibs back to shared libraries
my_shared_libraries += $( patsubst -l%,lib%,$( filter-out $( my_allowed_ldlibs) ,$( my_ldlibs) ) )
my_ldlibs := $( filter $( my_allowed_ldlibs) ,$( my_ldlibs) )
e n d i f
i f d e f L O C A L _ S D K _ V E R S I O N
my_all_ndk_libraries := \
$( NDK_MIGRATED_LIBS) $( addprefix lib,$( NDK_PREBUILT_SHARED_LIBRARIES) )
my_ndk_shared_libraries := \
$( filter $( my_all_ndk_libraries) ,\
$( my_shared_libraries) $( my_system_shared_libraries) )
my_shared_libraries := \
$( filter-out $( my_all_ndk_libraries) ,$( my_shared_libraries) )
2016-07-22 01:04:12 +08:00
my_system_shared_libraries := \
2016-08-05 05:14:50 +08:00
$( filter-out $( my_all_ndk_libraries) ,$( my_system_shared_libraries) )
2011-09-16 04:50:52 +08:00
e n d i f
2011-03-04 10:53:53 +08:00
2014-08-08 09:29:11 +08:00
# 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.
2016-08-02 08:36:39 +08:00
i f n e q ( $( LOCAL_NO_PIC ) , t r u e )
2015-08-15 03:59:50 +08:00
i f n e q ( $( $ ( my_prefix ) OS ) , w i n d o w s )
Add NATIVE_TESTS class, move host native tests
Host native tests have been getting installed into
out/host/linux-x86/bin/..., but this pollutes the bin directory with a
lot of poorly named tests. Also, to support 32-bit and 64-bit tests, we
need to have different names with different suffixes. This causes
problems when tests expect to be named something specific (like gtest).
It's also convenient to store test data next to the test itself.
So with this change, native tests will be installed in
out/host/linux-x86/nativetest[64]/$(LOCAL_MODULE)/$(LOCAL_MODULE_STEM)
just like target tests get installed into /data/nativetest[64].
Implement this using a new NATIVE_TESTS class, which is like
EXECUTABLES, but sets up the install path differently, and configures
the rpath to load shared libraries with the proper relative path.
LOCAL_MODULE_RELATIVE_PATH can be used to control the directory name, it
will default to $(LOCAL_MODULE). This way multiple related tests can be
grouped together.
Target native tests also use NATIVE_TESTS now, but nothing should change
other than LOCAL_MODULE_RELATIVE_PATH can be used.
Change-Id: I535e42b1a6b21c5b8d6a580aa2f944d2be35e27d
2016-03-03 05:54:51 +08:00
i f n e q ( $( filter EXECUTABLES NATIVE_TESTS ,$ ( LOCAL_MODULE_CLASS ) ) , )
2014-08-07 03:36:46 +08:00
my_cflags += -fpie
e l s e
my_cflags += -fPIC
e n d i f
2014-08-08 09:29:11 +08:00
e n d i f
2016-08-02 08:36:39 +08:00
e n d i f
2014-08-07 03:36:46 +08:00
2015-08-14 08:51:40 +08:00
i f d e f L O C A L _ I S _ H O S T _ M O D U L E
2015-08-19 08:47:06 +08:00
my_src_files += $( LOCAL_SRC_FILES_$( $( my_prefix) OS) ) $( LOCAL_SRC_FILES_$( $( my_prefix) OS) _$( $( my_prefix) $( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH) )
2015-08-14 08:51:40 +08:00
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) )
e n d i f
2014-04-18 01:03:35 +08:00
my_src_files += $( LOCAL_SRC_FILES_$( $( my_prefix) $( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH) ) $( LOCAL_SRC_FILES_$( my_32_64_bit_suffix) )
2015-07-01 03:21:59 +08:00
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) )
2014-04-18 01:03:35 +08:00
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) )
2014-02-13 13:15:12 +08:00
2015-12-04 14:58:39 +08:00
my_missing_exclude_files := $( filter-out $( my_src_files) ,$( my_src_files_exclude) )
i f n e q ( $( my_missing_exclude_files ) , )
$( warning Files are listed in LOCAL_SRC_FILES_EXCLUDE but not LOCAL_SRC_FILES )
$( error $ ( my_missing_exclude_files ) )
e n d i f
2015-07-01 03:21:59 +08:00
my_src_files := $( filter-out $( my_src_files_exclude) ,$( my_src_files) )
2014-08-19 02:14:38 +08:00
my_clang := $( strip $( LOCAL_CLANG) )
2014-05-28 04:03:36 +08:00
i f d e f L O C A L _ C L A N G _ $( my_ 32_ 64_bit_suffix )
2014-08-19 02:14:38 +08:00
my_clang := $( strip $( LOCAL_CLANG_$( my_32_64_bit_suffix) ) )
2014-05-28 04:03:36 +08:00
e n d i f
i f d e f L O C A L _ C L A N G _ $( $ ( my_prefix ) $ ( LOCAL_ 2ND_ARCH_VAR_PREFIX ) ARCH )
2014-08-19 02:14:38 +08:00
my_clang := $( strip $( LOCAL_CLANG_$( $( my_prefix) $( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH) ) )
2014-05-28 04:03:36 +08:00
e n d i f
2016-06-25 02:22:51 +08:00
# if custom toolchain is in use, default is not to use clang, if not explicitly required
i f n e q ( $( my_cc ) $( my_cxx ) , )
ifeq ( $( my_clang) ,)
my_clang := false
endif
e n d i f
2016-08-03 05:22:06 +08:00
# Issue warning if LOCAL_CLANG* is set to false and the local makefile is not found
# in the exception project list.
i f e q ( $( my_clang ) , f a l s e )
ifeq ( $( call find_in_local_clang_exception_projects,$( LOCAL_MODULE_MAKEFILE) ) ,)
2016-08-05 06:35:51 +08:00
$( error $( LOCAL_MODULE_MAKEFILE) : $( LOCAL_MODULE) : LOCAL_CLANG is set to false )
2016-08-03 05:22:06 +08:00
endif
e n d i f
2016-06-25 02:22:51 +08:00
2014-04-05 05:38:29 +08:00
# clang is enabled by default for host builds
# enable it unless we've specifically disabled clang above
i f d e f L O C A L _ I S _ H O S T _ M O D U L E
2016-03-30 03:34:03 +08:00
ifeq ( $( $( my_prefix) OS) ,windows)
ifeq ( $( my_clang) ,true)
$( error $( LOCAL_MODULE_MAKEFILE) : $( LOCAL_MODULE) : Clang is not yet supported for windows binaries)
endif
my_clang := false
else
ifeq ( $( my_clang) ,)
my_clang := true
endif
2014-07-25 05:42:53 +08:00
endif
2016-01-07 03:49:25 +08:00
# Add option to make gcc the default for device build
e l s e i f e q ( $( USE_CLANG_PLATFORM_BUILD ) , f a l s e )
2015-09-10 06:45:21 +08:00
ifeq ( $( my_clang) ,)
2016-01-07 03:49:25 +08:00
my_clang := false
2015-09-10 06:45:21 +08:00
endif
2016-01-07 03:49:25 +08:00
e l s e i f e q ( $( my_clang ) , )
my_clang := true
2015-09-10 06:45:21 +08:00
e n d i f
2015-07-30 06:13:57 +08:00
my_cpp_std_version := -std= gnu++14
2015-10-27 02:09:24 +08:00
i f n e q ( $( my_clang ) , t r u e )
# 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
e n d i f
2015-07-30 06:13:57 +08:00
i f d e f L O C A L _ S D K _ V E R S I O N
# The NDK handles this itself.
my_cpp_std_version :=
e n d i f
i f d e f L O C A L _ I S _ H O S T _ M O D U L E
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
e n d i f
my_cppflags := $( my_cpp_std_version) $( my_cppflags)
2014-08-14 02:53:07 +08:00
2014-02-13 13:15:12 +08:00
# arch-specific static libraries go first so that generic ones can depend on them
2014-04-18 01:03:35 +08:00
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)
2014-01-16 08:02:16 +08:00
2014-10-08 04:03:29 +08:00
i n c l u d e $( BUILD_SYSTEM ) / c x x _ s t l _ s e t u p . m k
2014-05-24 07:42:37 +08:00
2013-08-14 03:35:10 +08:00
# Add static HAL libraries
i f d e f L O C A L _ H A L _ S T A T I C _ L I B R A R I E S
$( foreach lib , $ ( LOCAL_HAL_STATIC_LIBRARIES ) , \
$( eval b_lib := $( filter $( lib) .%,$( BOARD_HAL_STATIC_LIBRARIES) ) ) \
2014-01-16 08:02:16 +08:00
$( if $( b_lib) , $( eval my_static_libraries += $( b_lib) ) ,\
$( eval my_static_libraries += $( lib) .default) ) )
2013-08-14 03:35:10 +08:00
b_lib :=
e n d i f
2015-09-25 20:54:09 +08:00
i f n e q ( $( strip $ ( CUSTOM_ $ ( my_prefix ) $ ( LOCAL_ 2ND_ARCH_VAR_PREFIX ) LINKER ) ) , )
my_linker := $( CUSTOM_$( my_prefix) $( LOCAL_2ND_ARCH_VAR_PREFIX) LINKER)
e l s e
2016-08-02 08:41:49 +08:00
my_linker := $( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) LINKER)
2015-09-25 20:54:09 +08:00
e n d i f
2015-07-11 09:06:51 +08:00
2014-11-01 07:23:08 +08:00
i n c l u d e $( BUILD_SYSTEM ) / c o n f i g _ s a n i t i z e r s . m k
2012-03-30 16:15:12 +08:00
2016-08-02 08:38:35 +08:00
i f n e q ( $( LOCAL_NO_LIBCOMPILER_RT ) , t r u e )
2013-01-27 17:45:59 +08:00
# Add in libcompiler_rt for all regular device builds
2015-04-10 05:41:06 +08:00
i f e q ( , $( LOCAL_SDK_VERSION ) $( WITHOUT_LIBCOMPILER_RT ) )
2014-01-16 08:02:16 +08:00
my_static_libraries += $( COMPILER_RT_CONFIG_EXTRA_STATIC_LIBRARIES)
2012-06-12 05:53:34 +08:00
e n d i f
2016-08-02 08:38:35 +08:00
e n d i f
2012-06-12 05:53:34 +08:00
2016-08-27 04:27:13 +08:00
i f n e q ( $( filter ../%,$ ( my_src_files ) ) , )
my_soong_problems += dotdot_srcs
e n d i f
i f n e q ( $( foreach i ,$ ( my_c_includes ) ,$ ( filter %/..,$ ( i ) ) $ ( findstring /../,$ ( i ) ) ) , )
my_soong_problems += dotdot_incs
e n d i f
i f n e q ( $( filter %.arm ,$ ( my_src_files ) ) , )
my_soong_problems += srcs_dotarm
e n d i f
2009-09-22 07:31:50 +08:00
####################################################
## Add FDO flags if FDO is turned on and supported
2014-09-20 01:18:12 +08:00
## Please note that we will do option filtering during FDO build.
## i.e. Os->O2, remove -fno-early-inline and -finline-limit.
##################################################################
2014-10-29 05:50:59 +08:00
my_fdo_build :=
i f n e q ( $( 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
2013-08-05 17:44:37 +08:00
endif
2015-09-24 16:51:20 +08:00
# 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) )
2009-09-22 07:31:50 +08:00
e n d i f
2010-07-14 05:55:47 +08:00
###########################################################
2010-10-14 16:15:56 +08:00
## Explicitly declare assembly-only __ASSEMBLY__ macro for
## assembly source
###########################################################
2014-01-16 08:02:16 +08:00
my_asflags += -D__ASSEMBLY__
2010-10-14 16:15:56 +08:00
2014-03-22 07:17:04 +08:00
2010-10-20 06:19:45 +08:00
###########################################################
2010-07-14 05:55:47 +08:00
## Define PRIVATE_ variables from global vars
###########################################################
2014-01-10 06:39:41 +08:00
i f n d e f L O C A L _ I S _ H O S T _ M O D U L E
2012-08-15 01:13:16 +08:00
i f d e f L O C A L _ S D K _ V E R S I O N
2016-07-21 03:22:57 +08:00
my_target_global_c_includes :=
my_target_global_c_system_includes := $( my_ndk_stl_include_path) $( my_ndk_sysroot_include)
2014-03-04 17:11:52 +08:00
my_target_global_cppflags := $( my_ndk_stl_cppflags)
2010-07-14 05:55:47 +08:00
e l s e
2016-07-21 03:22:57 +08:00
my_target_global_c_includes := $( SRC_HEADERS) \
2016-08-02 08:41:49 +08:00
$( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) PROJECT_INCLUDES) \
$( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) C_INCLUDES)
2016-07-21 03:22:57 +08:00
my_target_global_c_system_includes := $( SRC_SYSTEM_HEADERS) \
2016-08-02 08:41:49 +08:00
$( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) PROJECT_SYSTEM_INCLUDES) \
$( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) C_SYSTEM_INCLUDES)
2014-03-04 17:11:52 +08:00
my_target_global_cppflags :=
2013-08-16 02:01:10 +08:00
e n d i f # LOCAL_SDK_VERSION
2014-05-28 04:03:36 +08:00
i f e q ( $( my_clang ) , t r u e )
2016-08-02 08:41:49 +08:00
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)
2012-08-17 07:45:01 +08:00
e l s e
2016-08-02 08:41:49 +08:00
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)
2014-05-28 04:03:36 +08:00
e n d i f # my_clang
2012-08-17 07:45:01 +08:00
2016-07-20 04:19:21 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_GLOBAL_C_INCLUDES := $( my_target_global_c_includes )
2016-07-21 03:22:57 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $( my_target_global_c_system_includes )
2010-07-14 05:55:47 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_TARGET_GLOBAL_CFLAGS := $( my_target_global_cflags )
2014-11-26 16:53:46 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $( my_target_global_conlyflags )
2013-12-10 19:07:41 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_TARGET_GLOBAL_CPPFLAGS := $( my_target_global_cppflags )
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_TARGET_GLOBAL_LDFLAGS := $( my_target_global_ldflags )
2014-01-10 06:39:41 +08:00
e l s e # LOCAL_IS_HOST_MODULE
2016-07-21 03:22:57 +08:00
my_host_global_c_includes := $( SRC_HEADERS) \
$( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) PROJECT_INCLUDES) \
2016-07-20 04:19:21 +08:00
$( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) C_INCLUDES)
2016-07-21 03:22:57 +08:00
my_host_global_c_system_includes := $( SRC_SYSTEM_HEADERS) \
$( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) PROJECT_SYSTEM_INCLUDES) \
$( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) C_SYSTEM_INCLUDES)
2016-07-20 04:19:21 +08:00
2014-05-28 04:03:36 +08:00
i f e q ( $( my_clang ) , t r u e )
2015-08-15 03:59:50 +08:00
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)
2013-12-10 19:07:41 +08:00
e l s e
2015-08-15 03:59:50 +08:00
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)
2014-05-28 04:03:36 +08:00
e n d i f # my_clang
2013-12-10 19:07:41 +08:00
2016-07-20 04:19:21 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_GLOBAL_C_INCLUDES := $( my_host_global_c_includes )
2016-07-21 03:22:57 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $( my_host_global_c_system_includes )
2013-12-10 19:07:41 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST_GLOBAL_CFLAGS := $( my_host_global_cflags )
2014-11-26 16:53:46 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST_GLOBAL_CONLYFLAGS := $( my_host_global_conlyflags )
2013-12-10 19:07:41 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST_GLOBAL_CPPFLAGS := $( my_host_global_cppflags )
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST_GLOBAL_LDFLAGS := $( my_host_global_ldflags )
e n d i f # LOCAL_IS_HOST_MODULE
2010-07-14 05:55:47 +08:00
2015-01-24 08:12:57 +08:00
# 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.
i f e q ( $( NATIVE_COVERAGE ) , t r u e )
ifeq ( $( my_native_coverage) ,true)
2015-01-26 08:20:57 +08:00
# 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
2015-01-25 07:14:35 +08:00
my_cflags += --coverage -O0
2015-01-26 08:20:57 +08:00
my_ldflags += --coverage
2015-01-24 08:12:57 +08:00
endif
e l s e
my_native_coverage := false
e n d i f
2015-10-09 05:16:39 +08:00
i f e q ( $( my_clang ) , t r u e )
2016-08-02 08:41:49 +08:00
my_coverage_lib := $( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) LIBPROFILE_RT)
2015-10-09 05:16:39 +08:00
e l s e
2016-08-02 08:41:49 +08:00
my_coverage_lib := $( call intermediates-dir-for,STATIC_LIBRARIES,libgcov,$( filter AUX,$( my_kind) ) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ) /libgcov.a
2015-10-09 05:16:39 +08:00
e n d i f
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_TARGET_COVERAGE_LIB := $( my_coverage_lib )
2009-03-04 11:28:42 +08:00
###########################################################
## Define PRIVATE_ variables used by multiple module types
###########################################################
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
2012-03-23 02:26:22 +08:00
$( strip $( LOCAL_NO_DEFAULT_COMPILER_FLAGS) )
2009-03-04 11:28:42 +08:00
2013-08-27 17:33:06 +08:00
i f e q ( $( strip $ ( WITH_SYNTAX_CHECK ) ) , )
LOCAL_NO_SYNTAX_CHECK := true
e n d i f
2013-09-10 17:37:14 +08:00
i f e q ( $( strip $ ( WITH_STATIC_ANALYZER ) ) , )
LOCAL_NO_STATIC_ANALYZER := true
e n d i f
2016-02-03 03:30:39 +08:00
# Clang does not recognize all gcc flags.
# Use static analyzer only if clang is used.
i f n e q ( $( my_clang ) , t r u e )
LOCAL_NO_STATIC_ANALYZER := true
e n d i f
2013-08-27 17:33:06 +08:00
i f n e q ( $( strip $ ( LOCAL_IS_HOST_MODULE ) ) , )
my_syntax_arch := host
e l s e
2016-08-02 08:41:49 +08:00
my_syntax_arch := $( $( my_prefix) $( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH)
2013-08-27 17:33:06 +08:00
e n d i f
2014-01-16 08:02:16 +08:00
i f e q ( $( strip $ ( my_cc ) ) , )
2014-08-19 02:14:38 +08:00
ifeq ( $( my_clang) ,true)
2014-01-16 08:02:16 +08:00
my_cc := $( CLANG)
2012-03-20 22:00:16 +08:00
else
2014-01-16 08:02:16 +08:00
my_cc := $( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) CC)
2012-03-20 22:00:16 +08:00
endif
2015-07-21 09:40:18 +08:00
my_cc := $( my_cc_wrapper) $( my_cc)
2009-03-04 11:28:42 +08:00
e n d i f
2016-02-03 03:30:39 +08:00
2013-09-10 17:37:14 +08:00
i f n e q ( $( LOCAL_NO_STATIC_ANALYZER ) , t r u e )
2016-02-03 03:30:39 +08:00
my_cc := CCC_CC = $( CLANG) CLANG = $( CLANG) \
$( SYNTAX_TOOLS_PREFIX) /ccc-analyzer
2013-09-10 17:37:14 +08:00
e l s e
2013-08-27 17:33:06 +08:00
i f n e q ( $( LOCAL_NO_SYNTAX_CHECK ) , t r u e )
2016-02-03 03:30:39 +08:00
my_cc := $( my_cc) -fsyntax-only
2013-08-27 17:33:06 +08:00
e n d i f
2013-09-10 17:37:14 +08:00
e n d i f
2016-02-03 03:30:39 +08:00
2014-01-16 08:02:16 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_CC := $( my_cc )
2009-03-04 11:28:42 +08:00
2014-01-16 08:02:16 +08:00
i f e q ( $( strip $ ( my_cxx ) ) , )
2014-08-19 02:14:38 +08:00
ifeq ( $( my_clang) ,true)
2014-01-16 08:02:16 +08:00
my_cxx := $( CLANG_CXX)
2012-03-20 22:00:16 +08:00
else
2014-01-16 08:02:16 +08:00
my_cxx := $( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) CXX)
2012-03-20 22:00:16 +08:00
endif
2015-07-21 09:40:18 +08:00
my_cxx := $( my_cxx_wrapper) $( my_cxx)
2009-03-04 11:28:42 +08:00
e n d i f
2016-02-03 03:30:39 +08:00
2013-09-10 17:37:14 +08:00
i f n e q ( $( LOCAL_NO_STATIC_ANALYZER ) , t r u e )
2016-02-03 03:30:39 +08:00
my_cxx := CCC_CXX = $( CLANG_CXX) CLANG_CXX = $( CLANG_CXX) \
$( SYNTAX_TOOLS_PREFIX) /c++-analyzer
2013-09-10 17:37:14 +08:00
e l s e
2013-08-27 17:33:06 +08:00
i f n e q ( $( LOCAL_NO_SYNTAX_CHECK ) , t r u e )
2016-02-03 03:30:39 +08:00
my_cxx := $( my_cxx) -fsyntax-only
2013-08-27 17:33:06 +08:00
e n d i f
2013-09-10 17:37:14 +08:00
e n d i f
2016-02-03 03:30:39 +08:00
2015-07-11 09:06:51 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_LINKER := $( my_linker )
2014-01-16 08:02:16 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_CXX := $( my_cxx )
2014-08-06 05:44:41 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_CLANG := $( my_clang )
2009-03-04 11:28:42 +08:00
# TODO: support a mix of standard extensions so that this isn't necessary
LOCAL_CPP_EXTENSION := $( strip $( LOCAL_CPP_EXTENSION) )
i f e q ( $( LOCAL_CPP_EXTENSION ) , )
LOCAL_CPP_EXTENSION := .cpp
e n d i f
# Certain modules like libdl have to have symbols resolved at runtime and blow
# up if --no-undefined is passed to the linker.
i f e q ( $( strip $ ( LOCAL_NO_DEFAULT_COMPILER_FLAGS ) ) , )
2014-11-15 09:15:00 +08:00
i f e q ( $( my_allow_undefined_symbols ) , )
2016-05-19 03:50:53 +08:00
my_ldflags += -Wl,--no-undefined
2009-03-04 11:28:42 +08:00
e n d i f
e n d i f
2011-04-26 05:22:41 +08:00
i f e q ( t r u e , $( LOCAL_GROUP_STATIC_LIBRARIES ) )
$(LOCAL_BUILT_MODULE) : PRIVATE_GROUP_STATIC_LIBRARIES := true
e l s e
$(LOCAL_BUILT_MODULE) : PRIVATE_GROUP_STATIC_LIBRARIES :=
e n d i f
2009-03-04 11:28:42 +08:00
###########################################################
## Define arm-vs-thumb-mode flags.
###########################################################
LOCAL_ARM_MODE := $( strip $( LOCAL_ARM_MODE) )
2015-04-08 02:59:34 +08:00
i f e q ( $( $ ( my_prefix ) $ ( LOCAL_ 2ND_ARCH_VAR_PREFIX ) ARCH ) , a r m )
2009-03-04 11:28:42 +08:00
arm_objects_mode := $( if $( LOCAL_ARM_MODE) ,$( LOCAL_ARM_MODE) ,arm)
normal_objects_mode := $( if $( LOCAL_ARM_MODE) ,$( LOCAL_ARM_MODE) ,thumb)
2009-04-24 09:44:55 +08:00
# 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).
2014-01-16 08:02:16 +08:00
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)
2014-08-19 02:14:38 +08:00
i f e q ( $( my_clang ) , t r u e )
2016-05-20 05:39:25 +08:00
arm_objects_cflags := $( call convert-to-clang-flags,$( arm_objects_cflags) )
normal_objects_cflags := $( call convert-to-clang-flags,$( normal_objects_cflags) )
2012-04-05 15:44:37 +08:00
e n d i f
2010-07-09 10:07:52 +08:00
e l s e
arm_objects_mode :=
normal_objects_mode :=
arm_objects_cflags :=
normal_objects_cflags :=
e n d i f
2009-03-04 11:28:42 +08:00
###########################################################
## 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.
###########################################################
i f d e f D E B U G _ M O D U L E _ $( strip $ ( LOCAL_MODULE ) )
debug_cflags := $( $( my_prefix) CUSTOM_DEBUG_CFLAGS)
e l s e
debug_cflags :=
e n d i f
2016-01-20 12:07:08 +08:00
####################################################
## 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) ) )
2016-03-01 09:52:39 +08:00
$(my_gen_sources_copy) : $( intermediates ) /% : $( generated_sources_dir ) /%
2016-01-20 12:07:08 +08:00
@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.
2016-02-05 06:18:48 +08:00
my_gen_src_files := $( filter %.c %$( LOCAL_CPP_EXTENSION) %.S %.s,$( my_generated_sources) )
2016-01-20 12:07:08 +08:00
ALL_GENERATED_SOURCES += $( my_generated_sources)
2012-10-30 07:06:00 +08:00
####################################################
## Compile RenderScript with reflected C++
####################################################
2014-01-24 07:09:04 +08:00
renderscript_sources := $( filter %.rs %.fs,$( my_src_files) )
2012-10-30 07:06:00 +08:00
i f n e q ( , $( renderscript_sources ) )
2016-08-27 04:27:13 +08:00
my_soong_problems += rs
2012-10-30 07:06:00 +08:00
renderscript_sources_fullpath := $( addprefix $( LOCAL_PATH) /, $( renderscript_sources) )
RenderScript_file_stamp := $( intermediates) /RenderScriptCPP.stamp
renderscript_intermediate := $( intermediates) /renderscript
2015-08-14 08:04:10 +08:00
renderscript_target_api :=
i f n e q ( , $( LOCAL_RENDERSCRIPT_TARGET_API ) )
renderscript_target_api := $( LOCAL_RENDERSCRIPT_TARGET_API)
e l s e
i f n e q ( , $( LOCAL_SDK_VERSION ) )
# Set target-api for LOCAL_SDK_VERSIONs other than current.
2015-11-06 23:20:51 +08:00
i f n e q ( , $( filter -out current system_current test_current , $ ( LOCAL_SDK_VERSION ) ) )
2015-08-14 08:04:10 +08:00
renderscript_target_api := $( LOCAL_SDK_VERSION)
e n d i f
e n d i f # LOCAL_SDK_VERSION is set
e n d i f # LOCAL_RENDERSCRIPT_TARGET_API is set
2012-10-30 07:06:00 +08:00
i f e q ( $( LOCAL_RENDERSCRIPT_CC ) , )
LOCAL_RENDERSCRIPT_CC := $( LLVM_RS_CC)
e n d i f
# 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)
2014-09-11 07:11:41 +08:00
# -m32 or -m64
renderscript_flags += -m$( my_32_64_bit_suffix)
2014-09-11 06:11:01 +08:00
2014-01-16 08:02:16 +08:00
renderscript_includes := \
2012-10-30 07:06:00 +08:00
$( TOPDIR) external/clang/lib/Headers \
$( TOPDIR) frameworks/rs/scriptc \
$( LOCAL_RENDERSCRIPT_INCLUDES)
i f n e q ( $( LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE ) , )
2014-01-16 08:02:16 +08:00
renderscript_includes := $( LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
2012-10-30 07:06:00 +08:00
e n d i f
2015-04-04 07:15:28 +08:00
bc_dep_files := $( addprefix $( renderscript_intermediate) /, \
$( patsubst %.fs,%.d, $( patsubst %.rs,%.d, $( notdir $( renderscript_sources) ) ) ) )
2014-01-16 08:02:16 +08:00
$(RenderScript_file_stamp) : PRIVATE_RS_INCLUDES := $( renderscript_includes )
2012-10-30 07:06:00 +08:00
$(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 )
2015-08-14 08:04:10 +08:00
$(RenderScript_file_stamp) : PRIVATE_RS_TARGET_API := $( renderscript_target_api )
2015-04-04 07:15:28 +08:00
$(RenderScript_file_stamp) : PRIVATE_DEP_FILES := $( bc_dep_files )
2012-10-30 07:06:00 +08:00
$(RenderScript_file_stamp) : $( renderscript_sources_fullpath ) $( LOCAL_RENDERSCRIPT_CC )
$( transform-renderscripts-to-cpp-and-bc)
2015-04-04 07:15:28 +08:00
# include the dependency files (.d/.P) generated by llvm-rs-cc.
2016-01-25 17:59:43 +08:00
$( call include -depfile ,$ ( RenderScript_file_stamp ) .P ,$ ( RenderScript_file_stamp ) )
2012-10-30 07:06:00 +08:00
LOCAL_INTERMEDIATE_TARGETS += $( RenderScript_file_stamp)
rs_generated_cpps := $( addprefix \
$( renderscript_intermediate) /ScriptC_,$( patsubst %.fs,%.cpp, $( patsubst %.rs,%.cpp, \
$( notdir $( renderscript_sources) ) ) ) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -gen ,$ ( renderscript_sources ) ,$ ( rs_generated_cpps ) )
2014-06-07 03:51:47 +08:00
# This is just a dummy rule to make sure gmake doesn't skip updating the dependents.
2012-10-30 07:06:00 +08:00
$(rs_generated_cpps) : $( RenderScript_file_stamp )
2014-05-29 07:17:09 +08:00
@echo " Updated RS generated cpp file $@ . "
2015-02-27 10:47:21 +08:00
$( hide) touch $@
2012-10-30 07:06:00 +08:00
2014-01-16 08:02:16 +08:00
my_c_includes += $( renderscript_intermediate)
my_generated_sources += $( rs_generated_cpps)
2012-10-30 07:06:00 +08:00
e n d i f
2014-05-07 06:45:57 +08:00
###########################################################
2015-04-08 02:59:34 +08:00
## Compile the .proto files to .cc (or .c) and then to .o
2010-11-03 09:43:16 +08:00
###########################################################
2014-01-24 07:09:04 +08:00
proto_sources := $( filter %.proto,$( my_src_files) )
2010-11-03 09:43:16 +08:00
i f n e q ( $( proto_sources ) , )
2016-08-27 04:27:13 +08:00
my_soong_problems += proto
2016-05-06 11:02:08 +08:00
proto_gen_dir := $( generated_sources_dir) /proto
2016-04-05 16:34:51 +08:00
proto_sources_fullpath := $( addprefix $( LOCAL_PATH) /, $( proto_sources) )
2015-04-08 02:59:34 +08:00
2016-05-06 11:02:08 +08:00
my_rename_cpp_ext :=
2015-04-08 02:59:34 +08:00
i f n e q ( , $( filter nanopb -c nanopb -c -enable_malloc , $ ( LOCAL_PROTOC_OPTIMIZE_TYPE ) ) )
my_proto_source_suffix := .c
my_proto_c_includes := external/nanopb-c
2016-05-06 11:02:08 +08:00
my_protoc_flags := --nanopb_out= $( proto_gen_dir) \
2015-04-08 02:59:34 +08:00
--plugin= external/nanopb-c/generator/protoc-gen-nanopb
2016-04-05 16:34:51 +08:00
my_protoc_deps := $( NANOPB_SRCS) $( proto_sources_fullpath:%.proto= %.options)
2015-04-08 02:59:34 +08:00
e l s e
2016-05-06 11:02:08 +08:00
my_proto_source_suffix := $( LOCAL_CPP_EXTENSION)
i f n e q ( $( my_proto_source_suffix ) , . c c )
# 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
e n d i f
2015-04-08 02:59:34 +08:00
my_proto_c_includes := external/protobuf/src
my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
2016-05-06 11:02:08 +08:00
my_protoc_flags := --cpp_out= $( proto_gen_dir)
2016-04-05 16:34:51 +08:00
my_protoc_deps :=
2015-04-08 02:59:34 +08:00
e n d i f
2016-05-06 11:02:08 +08:00
my_proto_c_includes += $( proto_gen_dir)
2015-04-08 02:59:34 +08:00
2016-05-06 11:02:08 +08:00
proto_generated_cpps := $( addprefix $( proto_gen_dir) /, \
2015-04-08 02:59:34 +08:00
$( patsubst %.proto,%.pb$( my_proto_source_suffix) ,$( proto_sources_fullpath) ) )
2010-11-03 09:43:16 +08:00
2014-02-26 03:18:40 +08:00
# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
2016-05-06 11:02:08 +08:00
i f n d e f $( my_host ) $( LOCAL_MODULE_CLASS ) _ $( LOCAL_MODULE ) _ p r o t o _ d e f i n e d
$(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 )
2010-11-03 09:43:16 +08:00
$( transform-proto-to-cc)
2016-05-06 11:02:08 +08:00
$(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
2015-04-08 02:59:34 +08:00
e n d i f
2016-05-06 11:02:08 +08:00
# 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 ) /%
@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)
2010-11-03 09:43:16 +08:00
2015-04-08 02:59:34 +08:00
my_c_includes += $( my_proto_c_includes)
# Auto-export the generated proto source dir.
my_export_c_include_dirs += $( my_proto_c_includes)
i f e q ( $( LOCAL_PROTOC_OPTIMIZE_TYPE ) , n a n o p b - c - e n a b l e _ m a l l o c )
2015-04-09 00:54:34 +08:00
my_static_libraries += libprotobuf-c-nano-enable_malloc
2015-04-08 02:59:34 +08:00
e l s e i f e q ( $( LOCAL_PROTOC_OPTIMIZE_TYPE ) , n a n o p b - c )
2015-04-09 00:54:34 +08:00
my_static_libraries += libprotobuf-c-nano
2015-04-08 02:59:34 +08:00
e l s e i f e q ( $( LOCAL_PROTOC_OPTIMIZE_TYPE ) , f u l l )
2014-11-12 02:42:17 +08:00
ifdef LOCAL_SDK_VERSION
2015-09-09 01:47:03 +08:00
my_static_libraries += libprotobuf-cpp-full-ndk
2014-11-12 02:42:17 +08:00
else
my_shared_libraries += libprotobuf-cpp-full
endif
2016-06-08 10:21:12 +08:00
e l s e i f e q ( $( LOCAL_PROTOC_OPTIMIZE_TYPE ) , l i t e - s t a t i c )
my_static_libraries += libprotobuf-cpp-lite
2010-11-03 09:43:16 +08:00
e l s e
2014-11-12 02:42:17 +08:00
ifdef LOCAL_SDK_VERSION
2015-09-09 01:47:03 +08:00
my_static_libraries += libprotobuf-cpp-lite-ndk
2014-11-12 02:42:17 +08:00
else
my_shared_libraries += libprotobuf-cpp-lite
endif
2010-11-03 09:43:16 +08:00
e n d i f
2014-02-26 03:18:40 +08:00
e n d i f # $(proto_sources) non-empty
2010-11-03 09:43:16 +08:00
2015-07-30 08:14:24 +08:00
###########################################################
2015-08-21 00:08:17 +08:00
## Compile the .dbus-xml files to c++ headers
2015-07-30 08:14:24 +08:00
###########################################################
2015-08-21 00:08:17 +08:00
dbus_definitions := $( filter %.dbus-xml,$( my_src_files) )
2015-08-15 05:55:32 +08:00
dbus_generated_headers :=
i f n e q ( $( dbus_definitions ) , )
2016-08-27 04:27:13 +08:00
my_soong_problems += dbus
2015-07-30 08:14:24 +08:00
2015-08-15 05:55:32 +08:00
dbus_definition_paths := $( addprefix $( LOCAL_PATH) /,$( dbus_definitions) )
2015-07-30 08:14:24 +08:00
dbus_service_config := $( filter %dbus-service-config.json,$( my_src_files) )
2015-08-15 05:55:32 +08:00
dbus_service_config_path := $( addprefix $( LOCAL_PATH) /,$( dbus_service_config) )
2015-07-30 08:14:24 +08:00
2016-01-20 12:07:08 +08:00
# Mark these source files as not producing objects
$( call track -src -file -obj ,$ ( dbus_definitions ) $ ( dbus_service_config ) ,)
2015-08-15 05:55:32 +08:00
dbus_gen_dir := $( generated_sources_dir) /dbus_bindings
2015-07-30 08:14:24 +08:00
2015-08-15 05:55:32 +08:00
i f d e f L O C A L _ D B U S _ P R O X Y _ P R E F I X
dbus_header_dir := $( dbus_gen_dir) /include/$( LOCAL_DBUS_PROXY_PREFIX)
dbus_headers := dbus-proxies.h
e l s e
dbus_header_dir := $( dbus_gen_dir)
2015-08-21 00:08:17 +08:00
dbus_headers := $( patsubst %.dbus-xml,%.h,$( dbus_definitions) )
2015-08-15 05:55:32 +08:00
e n d i f
dbus_generated_headers := $( addprefix $( dbus_header_dir) /,$( dbus_headers) )
2015-07-30 08:14:24 +08:00
# Ensure that we only define build rules once in multilib builds.
i f n d e f $( my_prefix ) _ $( LOCAL_MODULE_CLASS ) _ $( LOCAL_MODULE ) _ d b u s _ b i n d i n g s _ d e f i n e d
$(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined := true
2015-08-15 05:55:32 +08:00
$(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 )
i f d e f L O C A L _ D B U S _ P R O X Y _ P R E F I X
$(dbus_generated_headers) : $( dbus_definition_paths )
$( generate-dbus-proxies)
2015-10-15 07:46:41 +08:00
e l s e
$(dbus_generated_headers) : $( dbus_header_dir ) /%.h : $( LOCAL_PATH ) /%.dbus -xml
$( generate-dbus-adaptors)
e n d i f # $(LOCAL_DBUS_PROXY_PREFIX)
e n d i f # $(my_prefix)_$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_dbus_bindings_defined
2015-08-15 05:55:32 +08:00
2015-10-15 07:46:41 +08:00
i f d e f L O C A L _ D B U S _ P R O X Y _ P R E F I X
2015-08-15 05:55:32 +08:00
# Auto-export the generated dbus proxy directory.
my_export_c_include_dirs += $( dbus_gen_dir) /include
my_c_includes += $( dbus_gen_dir) /include
e l s e
my_export_c_include_dirs += $( dbus_header_dir)
my_c_includes += $( dbus_header_dir)
e n d i f # $(LOCAL_DBUS_PROXY_PREFIX)
2015-07-30 08:14:24 +08:00
2015-08-15 05:55:32 +08:00
my_generated_sources += $( dbus_generated_headers)
e n d i f # $(dbus_definitions) non-empty
2015-07-30 08:14:24 +08:00
2015-10-15 08:27:24 +08:00
###########################################################
## AIDL: Compile .aidl files to .cpp and .h files
###########################################################
aidl_src := $( strip $( filter %.aidl,$( my_src_files) ) )
aidl_gen_cpp :=
i f n e q ( $( aidl_src ) , )
2016-08-27 04:27:13 +08:00
my_soong_problems += aidl
2015-10-15 08:27:24 +08:00
2016-01-20 00:58:35 +08:00
# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
2015-10-15 08:27:24 +08:00
aidl_gen_cpp_root := $( intermediates) /aidl-generated/src
aidl_gen_include_root := $( intermediates) /aidl-generated/include
2016-01-20 00:58:35 +08:00
# 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) ) )
2016-01-20 01:26:10 +08:00
$( foreach cpp ,$ ( aidl_gen_cpp ) , \
2016-01-25 17:59:43 +08:00
$( call include-depfile,$( addsuffix .aidl.P,$( basename $( cpp) ) ) ,$( cpp) ) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -gen ,$ ( aidl_src ) ,$ ( aidl_gen_cpp ) )
2015-10-15 08:27:24 +08:00
$(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 ) )
2015-11-19 23:06:01 +08:00
# Add generated headers to include paths.
2015-10-15 08:27:24 +08:00
my_c_includes += $( aidl_gen_include_root)
2015-11-19 23:06:01 +08:00
my_export_c_include_dirs += $( aidl_gen_include_root)
2015-10-15 08:27:24 +08:00
# Pick up the generated C++ files later for transformation to .o files.
my_generated_sources += $( aidl_gen_cpp)
e n d i f # $(aidl_src) non-empty
2016-02-20 03:06:58 +08:00
###########################################################
## Compile the .vts files to .cc (or .c) and then to .o
###########################################################
vts_src := $( strip $( filter %.vts,$( my_src_files) ) )
vts_gen_cpp :=
i f n e q ( $( vts_src ) , )
2016-08-27 04:27:13 +08:00
my_soong_problems += vts
2016-02-20 03:06:58 +08:00
# 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)
e n d i f # $(vts_src) non-empty
2009-03-04 11:28:42 +08:00
###########################################################
2016-01-12 08:28:45 +08:00
## YACC: Compile .y/.yy files to .c/.cpp and then to .o.
2009-03-04 11:28:42 +08:00
###########################################################
2014-03-03 23:57:06 +08:00
y_yacc_sources := $( filter %.y,$( my_src_files) )
2016-01-12 08:28:45 +08:00
y_yacc_cs := $( addprefix \
$( intermediates) /,$( y_yacc_sources:.y= .c) )
i f n e q ( $( y_yacc_cs ) , )
$(y_yacc_cs) : $( intermediates ) /%.c : \
2016-04-05 19:12:48 +08:00
$( TOPDIR) $( LOCAL_PATH) /%.y $( BISON) $( BISON_DATA) \
2016-01-12 08:28:45 +08:00
$( my_additional_dependencies)
$( call transform-y-to-c-or-cpp)
2016-01-20 12:07:08 +08:00
$( call track -src -file -gen ,$ ( y_yacc_sources ) ,$ ( y_yacc_cs ) )
2016-01-12 08:28:45 +08:00
my_generated_sources += $( y_yacc_cs)
e n d i f
2014-03-03 23:57:06 +08:00
yy_yacc_sources := $( filter %.yy,$( my_src_files) )
yy_yacc_cpps := $( addprefix \
$( intermediates) /,$( yy_yacc_sources:.yy= $( LOCAL_CPP_EXTENSION) ) )
2016-01-12 08:28:45 +08:00
i f n e q ( $( yy_yacc_cpps ) , )
2014-03-03 23:57:06 +08:00
$(yy_yacc_cpps) : $( intermediates ) /%$( LOCAL_CPP_EXTENSION ) : \
2016-04-05 19:12:48 +08:00
$( TOPDIR) $( LOCAL_PATH) /%.yy $( BISON) $( BISON_DATA) \
2016-01-12 08:28:45 +08:00
$( my_additional_dependencies)
$( call transform-y-to-c-or-cpp)
2016-01-20 12:07:08 +08:00
$( call track -src -file -gen ,$ ( yy_yacc_sources ) ,$ ( yy_yacc_cpps ) )
2009-03-04 11:28:42 +08:00
2016-01-12 08:28:45 +08:00
my_generated_sources += $( yy_yacc_cpps)
2009-03-04 11:28:42 +08:00
e n d i f
###########################################################
2016-01-12 08:28:45 +08:00
## LEX: Compile .l/.ll files to .c/.cpp and then to .o.
2009-03-04 11:28:42 +08:00
###########################################################
2014-03-03 23:57:06 +08:00
l_lex_sources := $( filter %.l,$( my_src_files) )
2016-01-12 08:28:45 +08:00
l_lex_cs := $( addprefix \
$( intermediates) /,$( l_lex_sources:.l= .c) )
i f n e q ( $( l_lex_cs ) , )
$(l_lex_cs) : $( intermediates ) /%.c : \
$( TOPDIR) $( LOCAL_PATH) /%.l
$( transform-l-to-c-or-cpp)
2016-01-20 12:07:08 +08:00
$( call track -src -file -gen ,$ ( l_lex_sources ) ,$ ( l_lex_cs ) )
2016-01-12 08:28:45 +08:00
my_generated_sources += $( l_lex_cs)
e n d i f
2014-03-03 23:57:06 +08:00
ll_lex_sources := $( filter %.ll,$( my_src_files) )
ll_lex_cpps := $( addprefix \
$( intermediates) /,$( ll_lex_sources:.ll= $( LOCAL_CPP_EXTENSION) ) )
2016-01-12 08:28:45 +08:00
i f n e q ( $( ll_lex_cpps ) , )
2014-03-03 23:57:06 +08:00
$(ll_lex_cpps) : $( intermediates ) /%$( LOCAL_CPP_EXTENSION ) : \
$( TOPDIR) $( LOCAL_PATH) /%.ll
2016-01-12 08:28:45 +08:00
$( transform-l-to-c-or-cpp)
2016-01-20 12:07:08 +08:00
$( call track -src -file -gen ,$ ( ll_lex_sources ) ,$ ( ll_lex_cpps ) )
2014-03-03 23:57:06 +08:00
2016-01-12 08:28:45 +08:00
my_generated_sources += $( ll_lex_cpps)
2009-03-04 11:28:42 +08:00
e n d i f
###########################################################
## C++: Compile .cpp files to .o.
###########################################################
2011-07-12 13:11:46 +08:00
# we also do this on host modules, even though
2009-03-04 11:28:42 +08:00
# it's not really arm, because there are files that are shared.
2015-03-11 09:03:11 +08:00
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) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( patsubst %,%.arm ,$ ( cpp_arm_sources ) ) ,$ ( cpp_arm_objects ) )
2015-03-11 09:03:11 +08:00
# 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) ,\
2016-05-06 11:02:08 +08:00
$( my_additional_dependencies) ,\
2015-03-11 09:03:11 +08:00
dotdot_arm_objects) ) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( patsubst %,%.arm ,$ ( dotdot_arm_sources ) ) ,$ ( dotdot_arm_objects ) )
2015-03-11 09:03:11 +08:00
dotdot_sources := $( filter ../%$( LOCAL_CPP_EXTENSION) ,$( my_src_files) )
dotdot_objects :=
$( foreach s ,$ ( dotdot_sources ) ,\
$( eval $( call compile-dotdot-cpp-file,$( s) ,\
2016-05-06 11:02:08 +08:00
$( my_additional_dependencies) ,\
2015-03-11 09:03:11 +08:00
dotdot_objects) ) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( dotdot_sources ) ,$ ( dotdot_objects ) )
2015-03-11 09:03:11 +08:00
cpp_normal_sources := $( filter-out ../%,$( filter %$( LOCAL_CPP_EXTENSION) ,$( my_src_files) ) )
2009-03-04 11:28:42 +08:00
cpp_normal_objects := $( addprefix $( intermediates) /,$( cpp_normal_sources:$( LOCAL_CPP_EXTENSION) = .o) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( cpp_normal_sources ) ,$ ( cpp_normal_objects ) )
2009-03-04 11:28:42 +08:00
2015-03-11 09:03:11 +08:00
$(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 )
2009-03-04 11:28:42 +08:00
cpp_objects := $( cpp_arm_objects) $( cpp_normal_objects)
i f n e q ( $( strip $ ( cpp_objects ) ) , )
$(cpp_objects) : $( intermediates ) /%.o : \
2012-03-23 02:26:22 +08:00
$( TOPDIR) $( LOCAL_PATH) /%$( LOCAL_CPP_EXTENSION) \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2009-03-04 11:28:42 +08:00
$( transform-$( PRIVATE_HOST) cpp-to-o)
2016-03-03 17:12:52 +08:00
$( call include -depfiles -for -objs , $ ( cpp_objects ) )
2009-03-04 11:28:42 +08:00
e n d i f
2015-03-11 09:03:11 +08:00
cpp_objects += $( dotdot_arm_objects) $( dotdot_objects)
2009-03-04 11:28:42 +08:00
###########################################################
## C++: Compile generated .cpp files to .o.
###########################################################
2014-01-17 08:21:03 +08:00
gen_cpp_sources := $( filter %$( LOCAL_CPP_EXTENSION) ,$( my_generated_sources) )
2009-03-04 11:28:42 +08:00
gen_cpp_objects := $( gen_cpp_sources:%$( LOCAL_CPP_EXTENSION) = %.o)
2016-01-20 12:07:08 +08:00
$( call track -gen -file -obj ,$ ( gen_cpp_sources ) ,$ ( gen_cpp_objects ) )
2009-03-04 11:28:42 +08:00
i f n e q ( $( 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 )
2012-03-20 22:00:16 +08:00
$(gen_cpp_objects) : $( intermediates ) /%.o : \
2016-05-06 11:02:08 +08:00
$( intermediates) /%$( LOCAL_CPP_EXTENSION) \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2009-03-04 11:28:42 +08:00
$( transform-$( PRIVATE_HOST) cpp-to-o)
2016-03-03 17:12:52 +08:00
$( call include -depfiles -for -objs , $ ( gen_cpp_objects ) )
2009-03-04 11:28:42 +08:00
e n d i f
###########################################################
## S: Compile generated .S and .s files to .o.
###########################################################
2014-01-17 08:21:03 +08:00
gen_S_sources := $( filter %.S,$( my_generated_sources) )
2009-03-04 11:28:42 +08:00
gen_S_objects := $( gen_S_sources:%.S= %.o)
2016-01-20 12:07:08 +08:00
$( call track -gen -file -obj ,$ ( gen_S_sources ) ,$ ( gen_S_objects ) )
2009-03-04 11:28:42 +08:00
i f n e q ( $( strip $ ( gen_S_sources ) ) , )
2012-03-20 22:00:16 +08:00
$(gen_S_objects) : $( intermediates ) /%.o : $( intermediates ) /%.S \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2009-03-04 11:28:42 +08:00
$( transform-$( PRIVATE_HOST) s-to-o)
2016-03-03 17:12:52 +08:00
$( call include -depfiles -for -objs , $ ( gen_S_objects ) )
2009-03-04 11:28:42 +08:00
e n d i f
2014-01-17 08:21:03 +08:00
gen_s_sources := $( filter %.s,$( my_generated_sources) )
2009-03-04 11:28:42 +08:00
gen_s_objects := $( gen_s_sources:%.s= %.o)
2016-01-20 12:07:08 +08:00
$( call track -gen -file -obj ,$ ( gen_s_sources ) ,$ ( gen_s_objects ) )
2009-03-04 11:28:42 +08:00
i f n e q ( $( strip $ ( gen_s_objects ) ) , )
2012-03-20 22:00:16 +08:00
$(gen_s_objects) : $( intermediates ) /%.o : $( intermediates ) /%.s \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2009-03-04 11:28:42 +08:00
$( transform-$( PRIVATE_HOST) s-to-o-no-deps)
e n d i f
gen_asm_objects := $( gen_S_objects) $( gen_s_objects)
2016-01-16 08:38:46 +08:00
$(gen_asm_objects) : PRIVATE_ARM_CFLAGS := $( normal_objects_cflags )
2009-03-04 11:28:42 +08:00
2013-02-21 22:01:35 +08:00
###########################################################
## o: Include generated .o files in output.
###########################################################
2014-01-17 08:21:03 +08:00
gen_o_objects := $( filter %.o,$( my_generated_sources) )
2013-02-21 22:01:35 +08:00
2009-03-04 11:28:42 +08:00
###########################################################
## C: Compile .c files to .o.
###########################################################
2015-03-11 09:03:11 +08:00
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) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( patsubst %,%.arm ,$ ( c_arm_sources ) ) ,$ ( c_arm_objects ) )
2015-03-11 09:03:11 +08:00
# 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) ,\
2016-05-06 11:02:08 +08:00
$( my_additional_dependencies) ,\
2015-03-11 09:03:11 +08:00
dotdot_arm_objects) ) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( patsubst %,%.arm ,$ ( dotdot_arm_sources ) ) ,$ ( dotdot_arm_objects ) )
2015-03-11 09:03:11 +08:00
dotdot_sources := $( filter ../%.c, $( my_src_files) )
dotdot_objects :=
$( foreach s , $ ( dotdot_sources ) ,\
$( eval $( call compile-dotdot-c-file,$( s) ,\
2016-05-06 11:02:08 +08:00
$( my_additional_dependencies) ,\
2015-03-11 09:03:11 +08:00
dotdot_objects) ) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( dotdot_sources ) ,$ ( dotdot_objects ) )
2009-03-04 11:28:42 +08:00
2015-03-11 09:03:11 +08:00
c_normal_sources := $( filter-out ../%,$( filter %.c,$( my_src_files) ) )
2009-03-04 11:28:42 +08:00
c_normal_objects := $( addprefix $( intermediates) /,$( c_normal_sources:.c= .o) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( c_normal_sources ) ,$ ( c_normal_objects ) )
2009-03-04 11:28:42 +08:00
2015-03-11 09:03:11 +08:00
$(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 )
2009-03-04 11:28:42 +08:00
c_objects := $( c_arm_objects) $( c_normal_objects)
i f n e q ( $( strip $ ( c_objects ) ) , )
2016-05-06 11:02:08 +08:00
$(c_objects) : $( intermediates ) /%.o : $( TOPDIR ) $( LOCAL_PATH ) /%.c \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2009-03-04 11:28:42 +08:00
$( transform-$( PRIVATE_HOST) c-to-o)
2016-03-03 17:12:52 +08:00
$( call include -depfiles -for -objs , $ ( c_objects ) )
2009-03-04 11:28:42 +08:00
e n d i f
2015-03-11 09:03:11 +08:00
c_objects += $( dotdot_arm_objects) $( dotdot_objects)
2009-05-05 05:32:44 +08:00
###########################################################
## C: Compile generated .c files to .o.
###########################################################
2014-01-17 08:21:03 +08:00
gen_c_sources := $( filter %.c,$( my_generated_sources) )
2009-05-05 05:32:44 +08:00
gen_c_objects := $( gen_c_sources:%.c= %.o)
2016-01-20 12:07:08 +08:00
$( call track -gen -file -obj ,$ ( gen_c_sources ) ,$ ( gen_c_objects ) )
2009-05-05 05:32:44 +08:00
i f n e q ( $( 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 )
2016-05-06 11:02:08 +08:00
$(gen_c_objects) : $( intermediates ) /%.o : $( intermediates ) /%.c \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2009-05-05 05:32:44 +08:00
$( transform-$( PRIVATE_HOST) c-to-o)
2016-03-03 17:12:52 +08:00
$( call include -depfiles -for -objs , $ ( gen_c_objects ) )
2009-05-05 05:32:44 +08:00
e n d i f
2009-05-14 22:00:09 +08:00
###########################################################
## ObjC: Compile .m files to .o
###########################################################
2014-01-24 07:09:04 +08:00
objc_sources := $( filter %.m,$( my_src_files) )
2009-05-14 22:00:09 +08:00
objc_objects := $( addprefix $( intermediates) /,$( objc_sources:.m= .o) )
2016-02-02 10:55:23 +08:00
$( call track -src -file -obj ,$ ( objc_sources ) ,$ ( objc_objects ) )
2009-05-14 22:00:09 +08:00
i f n e q ( $( strip $ ( objc_objects ) ) , )
2016-08-27 04:27:13 +08:00
my_soong_problems += objc
2016-05-06 11:02:08 +08:00
$(objc_objects) : $( intermediates ) /%.o : $( TOPDIR ) $( LOCAL_PATH ) /%.m \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2009-05-14 22:00:09 +08:00
$( transform-$( PRIVATE_HOST) m-to-o)
2016-03-03 17:12:52 +08:00
$( call include -depfiles -for -objs , $ ( objc_objects ) )
2009-05-14 22:00:09 +08:00
e n d i f
2015-09-18 06:40:49 +08:00
###########################################################
## ObjC++: Compile .mm files to .o
###########################################################
objcpp_sources := $( filter %.mm,$( my_src_files) )
objcpp_objects := $( addprefix $( intermediates) /,$( objcpp_sources:.mm= .o) )
2016-02-02 10:55:23 +08:00
$( call track -src -file -obj ,$ ( objcpp_sources ) ,$ ( objcpp_objects ) )
2015-09-18 06:40:49 +08:00
i f n e q ( $( strip $ ( objcpp_objects ) ) , )
2016-08-27 04:27:13 +08:00
my_soong_problems += objc
2016-05-06 11:02:08 +08:00
$(objcpp_objects) : $( intermediates ) /%.o : $( TOPDIR ) $( LOCAL_PATH ) /%.mm \
2015-09-18 06:40:49 +08:00
$( my_additional_dependencies)
$( transform-$( PRIVATE_HOST) mm-to-o)
2016-03-03 17:12:52 +08:00
$( call include -depfiles -for -objs , $ ( objcpp_objects ) )
2015-09-18 06:40:49 +08:00
e n d i f
2009-03-04 11:28:42 +08:00
###########################################################
## AS: Compile .S files to .o.
###########################################################
2014-01-24 07:09:04 +08:00
asm_sources_S := $( filter %.S,$( my_src_files) )
2015-03-11 09:03:11 +08:00
dotdot_sources := $( filter ../%,$( asm_sources_S) )
asm_sources_S := $( filter-out ../%,$( asm_sources_S) )
2009-03-04 11:28:42 +08:00
asm_objects_S := $( addprefix $( intermediates) /,$( asm_sources_S:.S= .o) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( asm_sources_S ) ,$ ( asm_objects_S ) )
2009-03-04 11:28:42 +08:00
2015-03-11 09:03:11 +08:00
dotdot_objects_S :=
$( foreach s ,$ ( dotdot_sources ) ,\
$( eval $( call compile-dotdot-s-file,$( s) ,\
$( my_additional_dependencies) ,\
dotdot_objects_S) ) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( dotdot_sources ) ,$ ( dotdot_objects_S ) )
2015-03-11 09:03:11 +08:00
2009-03-04 11:28:42 +08:00
i f n e q ( $( strip $ ( asm_objects_S ) ) , )
2012-03-20 22:00:16 +08:00
$(asm_objects_S) : $( intermediates ) /%.o : $( TOPDIR ) $( LOCAL_PATH ) /%.S \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2009-03-04 11:28:42 +08:00
$( transform-$( PRIVATE_HOST) s-to-o)
2016-03-16 05:40:04 +08:00
$( call include -depfiles -for -objs , $ ( asm_objects_S ) )
2009-03-04 11:28:42 +08:00
e n d i f
2014-01-24 07:09:04 +08:00
asm_sources_s := $( filter %.s,$( my_src_files) )
2015-03-11 09:03:11 +08:00
dotdot_sources := $( filter ../%,$( asm_sources_s) )
asm_sources_s := $( filter-out ../%,$( asm_sources_s) )
2009-03-04 11:28:42 +08:00
asm_objects_s := $( addprefix $( intermediates) /,$( asm_sources_s:.s= .o) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( asm_sources_s ) ,$ ( asm_objects_s ) )
2009-03-04 11:28:42 +08:00
2015-03-11 09:03:11 +08:00
dotdot_objects_s :=
$( foreach s ,$ ( dotdot_sources ) ,\
$( eval $( call compile-dotdot-s-file-no-deps,$( s) ,\
$( my_additional_dependencies) ,\
dotdot_objects_s) ) )
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( dotdot_sources ) ,$ ( dotdot_objects_s ) )
2015-03-11 09:03:11 +08:00
2009-03-04 11:28:42 +08:00
i f n e q ( $( strip $ ( asm_objects_s ) ) , )
2012-03-20 22:00:16 +08:00
$(asm_objects_s) : $( intermediates ) /%.o : $( TOPDIR ) $( LOCAL_PATH ) /%.s \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2009-03-04 11:28:42 +08:00
$( transform-$( PRIVATE_HOST) s-to-o-no-deps)
e n d i f
2015-03-11 09:03:11 +08:00
asm_objects := $( dotdot_objects_S) $( dotdot_objects_s) $( asm_objects_S) $( asm_objects_s)
2016-01-16 08:38:46 +08:00
$(asm_objects) : PRIVATE_ARM_CFLAGS := $( normal_objects_cflags )
2009-03-04 11:28:42 +08:00
2015-03-10 09:57:40 +08:00
# .asm for x86/x86_64 needs to be compiled with yasm.
2014-06-06 10:05:47 +08:00
asm_sources_asm := $( filter %.asm,$( my_src_files) )
i f n e q ( $( strip $ ( asm_sources_asm ) ) , )
asm_objects_asm := $( addprefix $( intermediates) /,$( asm_sources_asm:.asm= .o) )
$(asm_objects_asm) : $( intermediates ) /%.o : $( TOPDIR ) $( LOCAL_PATH ) /%.asm \
2014-11-09 14:20:03 +08:00
$( my_additional_dependencies)
2014-06-06 10:05:47 +08:00
$( transform-asm-to-o)
2016-01-20 12:07:08 +08:00
$( call track -src -file -obj ,$ ( asm_sources_asm ) ,$ ( asm_objects_asm ) )
2014-06-06 10:05:47 +08:00
asm_objects += $( asm_objects_asm)
e n d i f
2015-01-09 10:25:30 +08:00
##########################################################
## 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.
i f d e f L O C A L _ S D K _ V E R S I O N
installed_shared_library_module_names := \
$( my_shared_libraries)
e l s e
installed_shared_library_module_names := \
$( my_shared_libraries) $( my_system_shared_libraries)
e n d i f
# The real dependency will be added after all Android.mks are loaded and the install paths
# of the shared libraries are determined.
i f d e f L O C A L _ I N S T A L L E D _ M O D U L E
i f d e f i n s t a l l e d _ s h a r e d _ l i b r a r y _ m o d u l e _ n a m e s
$(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) ) )
e n d i f
e n d i f
2011-11-09 01:31:21 +08:00
####################################################
## Import includes
####################################################
import_includes := $( intermediates) /import_includes
import_includes_deps := $( strip \
$( foreach l, $( installed_shared_library_module_names) , \
2016-08-02 08:41:49 +08:00
$( call intermediates-dir-for,SHARED_LIBRARIES,$( l) ,$( my_kind) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ,$( my_host_cross) ) /export_includes) \
2014-02-05 06:53:25 +08:00
$( foreach l, $( my_static_libraries) $( my_whole_static_libraries) , \
2016-08-02 08:41:49 +08:00
$( call intermediates-dir-for,STATIC_LIBRARIES,$( l) ,$( my_kind) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ,$( my_host_cross) ) /export_includes) )
2015-01-23 07:44:04 +08:00
$(import_includes) : PRIVATE_IMPORT_EXPORT_INCLUDES := $( import_includes_deps )
2016-01-07 06:28:36 +08:00
$(import_includes) : $( import_includes_deps )
2011-11-09 01:31:21 +08:00
@echo Import includes file: $@
$( hide) mkdir -p $( dir $@ ) && rm -f $@
i f d e f i m p o r t _ i n c l u d e s _ d e p s
2015-01-23 07:44:04 +08:00
$( hide) for f in $( PRIVATE_IMPORT_EXPORT_INCLUDES) ; do \
2011-11-09 01:31:21 +08:00
cat $$ f >> $@ ; \
done
e l s e
$( hide) touch $@
e n d i f
2016-06-08 05:25:14 +08:00
####################################################
## Verify that NDK-built libraries only link against
## other NDK-built libraries
####################################################
my_link_type := $( intermediates) /link_type
i f d e f L O C A L _ S D K _ V E R S I O N
$(my_link_type) : PRIVATE_LINK_TYPE := ndk
$(my_link_type) : PRIVATE_ALLOWED_TYPES := ndk
e l s e
$(my_link_type) : PRIVATE_LINK_TYPE := platform
$(my_link_type) : PRIVATE_ALLOWED_TYPES := (ndk | platform )
e n d i f
my_link_type_deps := $( strip \
$( foreach l,$( my_whole_static_libraries) $( my_static_libraries) , \
2016-08-02 08:41:49 +08:00
$( call intermediates-dir-for,STATIC_LIBRARIES,$( l) ,$( my_kind) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ,$( my_host_cross) ) /link_type) )
2016-06-08 05:25:14 +08:00
i f n e q ( $( LOCAL_MODULE_CLASS ) , S T A T I C _ L I B R A R I E S )
my_link_type_deps += $( strip \
$( foreach l,$( my_shared_libraries) , \
2016-08-02 08:41:49 +08:00
$( call intermediates-dir-for,SHARED_LIBRARIES,$( l) ,$( my_kind) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ,$( my_host_cross) ) /link_type) )
2016-06-08 05:25:14 +08:00
e n d i f
$(my_link_type) : PRIVATE_DEPS := $( my_link_type_deps )
$(my_link_type) : PRIVATE_MODULE := $( LOCAL_MODULE )
$(my_link_type) : PRIVATE_MAKEFILE := $( LOCAL_MODULE_MAKEFILE )
$(my_link_type) : $( my_link_type_deps )
@echo Check module type: $@
$( hide) mkdir -p $( dir $@ ) && rm -f $@
i f d e f m y _ l i n k _ t y p e _ d e p s
$( hide) for f in $( PRIVATE_DEPS) ; do \
grep -qE '^$(PRIVATE_ALLOWED_TYPES)$$' $$ f || \
2016-07-13 04:10:31 +08:00
( $( call echo-error," $( PRIVATE_MAKEFILE) : $( PRIVATE_MODULE) ( $( PRIVATE_LINK_TYPE) ) should not link to $$ (basename $$ {f%_intermediates/link_type}) ( $$ (cat $$ f)) " ) ; exit 1) \
2016-06-08 05:25:14 +08:00
done
e n d i f
$( hide) echo $( PRIVATE_LINK_TYPE) >$@
2009-03-04 11:28:42 +08:00
###########################################################
## Common object handling.
###########################################################
2016-01-20 12:07:08 +08:00
my_unused_src_files := $( filter-out $( logtags_sources) $( my_tracked_src_files) ,$( my_src_files) $( my_gen_src_files) )
i f n e q ( $( my_unused_src_files ) , )
2016-06-29 01:22:08 +08:00
$( error $( LOCAL_MODULE_MAKEFILE) : $( LOCAL_MODULE) : Unused source files: $( my_unused_src_files) )
2016-01-20 12:07:08 +08:00
e n d i f
2009-03-04 11:28:42 +08:00
# some rules depend on asm_objects being first. If your code depends on
# being first, it's reasonable to require it to be assembly
2013-08-29 22:36:34 +08:00
normal_objects := \
2012-03-23 02:26:22 +08:00
$( asm_objects) \
$( cpp_objects) \
$( gen_cpp_objects) \
$( gen_asm_objects) \
$( c_objects) \
$( gen_c_objects) \
$( objc_objects) \
2016-05-06 11:02:08 +08:00
$( objcpp_objects)
2016-01-20 12:07:08 +08:00
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) ) )
i f n e q ( $( 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 ) ) ) )
e n d i f
i f e q ( $( BINARY_OBJECTS_ORDER ) , s o o n g )
normal_objects := $( new_order_normal_objects)
e n d i f
normal_objects += $( addprefix $( TOPDIR) $( LOCAL_PATH) /,$( LOCAL_PREBUILT_OBJ_FILES) )
2013-08-29 22:36:34 +08:00
all_objects := $( normal_objects) $( gen_o_objects)
2009-03-04 11:28:42 +08:00
2016-01-20 12:07:08 +08:00
# 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 :=
2014-02-14 05:41:52 +08:00
my_c_includes += $( TOPDIR) $( LOCAL_PATH) $( intermediates) $( generated_sources_dir)
2009-03-04 11:28:42 +08:00
2012-08-15 01:13:16 +08:00
i f n d e f L O C A L _ S D K _ V E R S I O N
2014-01-16 08:02:16 +08:00
my_c_includes += $( JNI_H_INCLUDE)
2010-07-23 06:51:56 +08:00
e n d i f
2016-05-25 04:06:07 +08:00
my_outside_includes := $( filter-out $( OUT_DIR) /%,$( filter /%,$( my_c_includes) ) )
i f n e q ( $( my_outside_includes ) , )
$(error $(LOCAL_MODULE_MAKEFILE) : $( LOCAL_MODULE ) : C_INCLUDES must be under the source or output directories : $( my_outside_includes ) )
e n d i f
2013-08-29 22:36:34 +08:00
# 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).
2014-01-17 08:21:03 +08:00
$(normal_objects) : | $( my_generated_sources )
2015-12-01 09:33:26 +08:00
$(all_objects) : $( import_includes )
2009-03-04 11:28:42 +08:00
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)
2012-08-15 01:13:16 +08:00
i f d e f L O C A L _ S D K _ V E R S I O N
2009-03-04 11:28:42 +08:00
built_shared_libraries := \
2014-01-16 08:02:16 +08:00
$( addprefix $( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) OUT_INTERMEDIATE_LIBRARIES) /, \
2009-03-04 11:28:42 +08:00
$( addsuffix $( so_suffix) , \
2014-01-16 08:02:16 +08:00
$( my_shared_libraries) ) )
2015-12-16 02:00:19 +08:00
built_shared_library_deps := $( addsuffix .toc, $( built_shared_libraries) )
2009-03-04 11:28:42 +08:00
2014-03-22 07:17:04 +08:00
# Add the NDK libraries to the built module dependency
2011-03-04 10:53:53 +08:00
my_system_shared_libraries_fullpath := \
$( my_ndk_stl_shared_lib_fullpath) \
2014-04-26 14:47:10 +08:00
$( addprefix $( my_ndk_sysroot_lib) /, \
2014-03-22 07:17:04 +08:00
$( addsuffix $( so_suffix) , $( my_system_shared_libraries) ) )
2010-07-14 05:55:47 +08:00
2016-08-05 05:14:50 +08:00
# We need to preserve the ordering of LOCAL_SHARED_LIBRARIES regardless of
# whether the libs are generated or prebuilt, so we simply can't split into two
# lists and use addprefix.
my_ndk_shared_libraries_fullpath := \
$( foreach _lib,$( my_ndk_shared_libraries) ,\
$( if $( filter $( NDK_MIGRATED_LIBS) ,$( _lib) ) ,\
$( my_built_ndk_libs) /$( _lib) $( so_suffix) ,\
$( my_ndk_sysroot_lib) /$( _lib) $( so_suffix) ) )
2016-07-22 01:04:12 +08:00
built_shared_libraries += \
2016-08-05 05:14:50 +08:00
$( my_ndk_shared_libraries_fullpath) \
2016-07-22 01:04:12 +08:00
$( my_system_shared_libraries_fullpath) \
2010-07-14 05:55:47 +08:00
e l s e
built_shared_libraries := \
2014-01-16 08:02:16 +08:00
$( addprefix $( $( LOCAL_2ND_ARCH_VAR_PREFIX) $( my_prefix) OUT_INTERMEDIATE_LIBRARIES) /, \
2010-07-14 05:55:47 +08:00
$( addsuffix $( so_suffix) , \
2014-03-22 07:17:04 +08:00
$( installed_shared_library_module_names) ) )
2015-12-16 02:00:19 +08:00
i f d e f L O C A L _ I S _ H O S T _ M O D U L E
# 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)
e l s e
built_shared_library_deps := $( addsuffix .toc, $( built_shared_libraries) )
e n d i f
2015-10-09 13:36:04 +08:00
my_system_shared_libraries_fullpath :=
2010-07-14 05:55:47 +08:00
e n d i f
2009-03-04 11:28:42 +08:00
built_static_libraries := \
2014-01-16 08:02:16 +08:00
$( foreach lib,$( my_static_libraries) , \
2009-03-04 11:28:42 +08:00
$( call intermediates-dir-for, \
2016-08-02 08:41:49 +08:00
STATIC_LIBRARIES,$( lib) ,$( my_kind) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ,$( my_host_cross) ) /$( lib) $( a_suffix) )
2009-03-04 11:28:42 +08:00
2012-08-15 01:13:16 +08:00
i f d e f L O C A L _ S D K _ V E R S I O N
2011-03-04 10:53:53 +08:00
built_static_libraries += $( my_ndk_stl_static_lib)
e n d i f
2009-03-04 11:28:42 +08:00
built_whole_libraries := \
2014-02-05 06:53:25 +08:00
$( foreach lib,$( my_whole_static_libraries) , \
2009-03-04 11:28:42 +08:00
$( call intermediates-dir-for, \
2016-08-02 08:41:49 +08:00
STATIC_LIBRARIES,$( lib) ,$( my_kind) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ,$( my_host_cross) ) /$( lib) $( a_suffix) )
2009-03-04 11:28:42 +08:00
# 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
2012-03-01 19:34:41 +08:00
# libraries that we use. (see notice_files.mk)
2009-03-04 11:28:42 +08:00
installed_static_library_notice_file_targets := \
2014-02-05 06:53:25 +08:00
$( foreach lib,$( my_static_libraries) $( my_whole_static_libraries) , \
2009-03-04 11:28:42 +08:00
NOTICE-$( if $( LOCAL_IS_HOST_MODULE) ,HOST,TARGET) -STATIC_LIBRARIES-$( lib) )
2011-05-11 12:50:58 +08:00
# Default is -fno-rtti.
2011-06-08 01:55:48 +08:00
i f e q ( $( strip $ ( LOCAL_RTTI_FLAG ) ) , )
LOCAL_RTTI_FLAG := -fno-rtti
e n d i f
2011-05-11 12:50:58 +08:00
2009-03-04 11:28:42 +08:00
###########################################################
# Rule-specific variable definitions
###########################################################
2013-12-10 19:07:41 +08:00
2014-05-28 04:03:36 +08:00
i f e q ( $( my_clang ) , t r u e )
2014-09-05 08:15:47 +08:00
my_cflags += $( LOCAL_CLANG_CFLAGS)
2014-11-26 16:53:46 +08:00
my_conlyflags += $( LOCAL_CLANG_CONLYFLAGS)
2014-11-29 06:00:12 +08:00
my_cppflags += $( LOCAL_CLANG_CPPFLAGS)
2015-06-11 07:33:43 +08:00
my_cflags_no_override += $( GLOBAL_CLANG_CFLAGS_NO_OVERRIDE)
my_cppflags_no_override += $( GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE)
2014-09-05 08:15:47 +08:00
my_asflags += $( LOCAL_CLANG_ASFLAGS)
my_ldflags += $( LOCAL_CLANG_LDFLAGS)
2014-09-27 08:13:48 +08:00
my_cflags += $( LOCAL_CLANG_CFLAGS_$( $( my_prefix) $( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH) ) $( LOCAL_CLANG_CFLAGS_$( my_32_64_bit_suffix) )
2014-11-26 16:53:46 +08:00
my_conlyflags += $( LOCAL_CLANG_CONLYFLAGS_$( $( my_prefix) $( LOCAL_2ND_ARCH_VAR_PREFIX) ARCH) ) $( LOCAL_CLANG_CONLYFLAGS_$( my_32_64_bit_suffix) )
2014-09-27 08:13:48 +08:00
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) )
2016-05-20 05:39:25 +08:00
my_cflags := $( call convert-to-clang-flags,$( my_cflags) )
my_cppflags := $( call convert-to-clang-flags,$( my_cppflags) )
my_asflags := $( call convert-to-clang-flags,$( my_asflags) )
my_ldflags := $( call convert-to-clang-flags,$( my_ldflags) )
2016-04-07 02:18:30 +08:00
e l s e
# gcc does not handle hidden functions in a manner compatible with LLVM libcxx
# see b/27908145
my_cflags += -Wno-attributes
2013-12-10 19:07:41 +08:00
e n d i f
2014-10-29 05:50:59 +08:00
i f e q ( $( my_fdo_build ) , t r u e )
my_cflags := $( patsubst -Os,-O2,$( my_cflags) )
fdo_incompatible_flags := -fno-early-inlining -finline-limit= %
my_cflags := $( filter-out $( fdo_incompatible_flags) ,$( my_cflags) )
2014-09-20 01:18:12 +08:00
e n d i f
2015-08-13 05:54:16 +08:00
# 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) )
2016-01-30 08:51:51 +08:00
# We can enforce some rules more strictly in the code we own. my_strict
# indicates if this is code that we can be stricter with. If we have rules that
# we want to apply to *our* code (but maybe can't for vendor/device specific
# things), we could extend this to be a ternary value.
my_strict := true
i f n e q ( $( filter external /%,$ ( LOCAL_PATH ) ) , )
my_strict := false
e n d i f
# Can be used to make some annotations stricter for code we can fix (such as
# when we mark functions as deprecated).
i f e q ( $( my_strict ) , t r u e )
my_cflags += -DANDROID_STRICT
e n d i f
2016-04-01 07:30:23 +08:00
# Disable clang-tidy if it is not found.
i f e q ( $( PATH_TO_CLANG_TIDY ) , )
my_tidy_enabled := false
e l s e
# If LOCAL_TIDY is not defined, use global WITH_TIDY
my_tidy_enabled := $( LOCAL_TIDY)
ifeq ( $( my_tidy_enabled) ,)
my_tidy_enabled := $( WITH_TIDY)
endif
e n d i f
# my_tidy_checks is empty if clang-tidy is disabled.
my_tidy_checks :=
my_tidy_flags :=
i f n e q ( , $( filter 1 true ,$ ( my_tidy_enabled ) ) )
ifneq ( $( my_clang) ,true)
# Disable clang-tidy if clang is disabled.
my_tidy_enabled := false
else
tidy_only: $( cpp_objects) $( c_objects)
# Set up global default checks
my_tidy_checks := $( WITH_TIDY_CHECKS)
ifeq ( $( my_tidy_checks) ,)
2016-04-22 06:37:24 +08:00
my_tidy_checks := $( call default_global_tidy_checks,$( LOCAL_PATH) )
2016-04-01 07:30:23 +08:00
endif
# Append local clang-tidy checks.
ifneq ( $( LOCAL_TIDY_CHECKS) ,)
my_tidy_checks := $( my_tidy_checks) ,$( LOCAL_TIDY_CHECKS)
endif
# Set up global default clang-tidy flags, which is none.
my_tidy_flags := $( WITH_TIDY_FLAGS)
# Use local clang-tidy flags if specified.
ifneq ( $( LOCAL_TIDY_FLAGS) ,)
my_tidy_flags := $( LOCAL_TIDY_FLAGS)
endif
2016-06-03 06:20:05 +08:00
# If tidy flags are not specified, default to check all header files.
ifeq ( $( my_tidy_flags) ,)
2016-09-07 11:06:28 +08:00
my_tidy_flags := $( call default_tidy_header_filter,$( LOCAL_PATH) )
2016-06-03 06:20:05 +08:00
endif
2016-04-01 07:30:23 +08:00
endif
e n d i f
2016-08-17 07:27:30 +08:00
my_tidy_checks := $( subst $( space) ,,$( my_tidy_checks) )
Rewrite LDLIBS and SHARED_LIBRARIES
LOCAL_LDLIBS was the only correct way to use NDK libraries, but few used
it correctly. It also often got confused with LOCAL_LDFLAGS, so move the
flags to the correct variable.
For binaries that weren't using the NDK (empty LOCAL_SDK_VERSION), it
was never valid to use LOCAL_LDLIBS, as dependencies would not be
properly set up, and could lead to random build failures. So convert any
-l linker flags to using LOCAL_SHARED_LIBRARIES automatically.
For binaries built using the NDK (LOCAL_SDK_VERSION set), they were
required to use LOCAL_LDLIBS for prebuilt NDK libraries, otherwise they
would get headers and dependencies to the platform versions. Any
non-prebuilt LOCAL_LDLIBS would miss dependencies. So move the NDK
prebuilt libraries to LDLIBS from SHARED_LIBRARIES, and move everything
else to SHARED_LIBRARIES.
So now, for device modules, LOCAL_SHARED_LIBRARIES should always be
used, and we'll do the right thing. LOCAL_LDLIBS should only be used for
host libraries from the system.
Change-Id: Ide34c7afdcfb6507a378d45a42471729e489a9e0
2016-06-08 07:55:57 +08:00
# Move -l* entries from ldflags to ldlibs, and everything else to ldflags
my_ldlib_flags := $( my_ldflags) $( my_ldlibs)
my_ldlibs := $( filter -l%,$( my_ldlib_flags) )
my_ldflags := $( filter-out -l%,$( my_ldlib_flags) )
# One last verification check for ldlibs
i f n d e f L O C A L _ I S _ H O S T _ M O D U L E
my_allowed_ldlibs :=
i f d e f L O C A L _ S D K _ V E R S I O N
my_allowed_ldlibs := $( addprefix -l,$( NDK_PREBUILT_SHARED_LIBRARIES) )
e n d i f
my_bad_ldlibs := $( filter-out $( my_allowed_ldlibs) ,$( my_ldlibs) )
i f n e q ( $( my_bad_ldlibs ) , )
$( error $( LOCAL_MODULE_MAKEFILE) : $( LOCAL_MODULE) : Bad LOCAL_LDLIBS entries: $( my_bad_ldlibs) )
e n d i f
e n d i f
2009-03-04 11:28:42 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_YACCFLAGS := $( LOCAL_YACCFLAGS )
2014-01-16 08:02:16 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ASFLAGS := $( my_asflags )
2014-11-26 16:53:46 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_CONLYFLAGS := $( my_conlyflags )
2014-01-16 08:02:16 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_CFLAGS := $( my_cflags )
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_CPPFLAGS := $( my_cppflags )
2015-06-11 07:33:43 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_CFLAGS_NO_OVERRIDE := $( my_cflags_no_override )
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_CPPFLAGS_NO_OVERRIDE := $( my_cppflags_no_override )
2011-05-11 12:50:58 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_RTTI_FLAG := $( LOCAL_RTTI_FLAG )
2009-03-04 11:28:42 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_DEBUG_CFLAGS := $( debug_cflags )
2014-01-16 08:02:16 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_C_INCLUDES := $( my_c_includes )
2011-11-09 01:31:21 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IMPORT_INCLUDES := $( import_includes )
2014-01-16 08:02:16 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_LDFLAGS := $( my_ldflags )
2014-09-13 05:46:57 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_LDLIBS := $( my_ldlibs )
2016-04-01 07:30:23 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_TIDY_CHECKS := $( my_tidy_checks )
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_TIDY_FLAGS := $( my_tidy_flags )
2009-03-04 11:28:42 +08:00
# 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 )
2016-03-23 09:23:13 +08:00
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_ALL_OBJECTS := $( strip $ ( all_objects ) )
2009-03-04 11:28:42 +08:00
###########################################################
# Define library dependencies.
###########################################################
# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
all_libraries := \
2015-12-16 02:00:19 +08:00
$( built_shared_library_deps) \
2015-10-09 13:36:04 +08:00
$( my_system_shared_libraries_fullpath) \
2009-03-04 11:28:42 +08:00
$( 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 )
2011-11-09 01:31:21 +08:00
###########################################################
# Export includes
###########################################################
export_includes := $( intermediates) /export_includes
2015-04-08 02:59:34 +08:00
$(export_includes) : PRIVATE_EXPORT_C_INCLUDE_DIRS := $( my_export_c_include_dirs )
2016-04-12 03:40:36 +08:00
# Headers exported by whole static libraries are also exported by this library.
2016-03-05 04:40:25 +08:00
export_include_deps := $( strip \
$( foreach l,$( my_whole_static_libraries) , \
2016-08-02 08:41:49 +08:00
$( call intermediates-dir-for,STATIC_LIBRARIES,$( l) ,$( my_kind) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ,$( my_host_cross) ) /export_includes) )
2016-04-12 03:40:36 +08:00
# Re-export requested headers from shared libraries.
export_include_deps += $( strip \
$( foreach l,$( LOCAL_EXPORT_SHARED_LIBRARY_HEADERS) , \
2016-08-02 08:41:49 +08:00
$( call intermediates-dir-for,SHARED_LIBRARIES,$( l) ,$( my_kind) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ,$( my_host_cross) ) /export_includes) )
2016-04-12 03:40:36 +08:00
# Re-export requested headers from static libraries.
export_include_deps += $( strip \
$( foreach l,$( LOCAL_EXPORT_STATIC_LIBRARY_HEADERS) , \
2016-08-02 08:41:49 +08:00
$( call intermediates-dir-for,STATIC_LIBRARIES,$( l) ,$( my_kind) ,,$( LOCAL_2ND_ARCH_VAR_PREFIX) ,$( my_host_cross) ) /export_includes) )
2016-03-05 04:40:25 +08:00
$(export_includes) : PRIVATE_REEXPORTED_INCLUDES := $( export_include_deps )
2016-05-06 11:02:08 +08:00
# 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 )
2011-11-09 01:31:21 +08:00
@echo Export includes file: $< -- $@
2016-03-05 04:40:25 +08:00
$( hide) mkdir -p $( dir $@ ) && rm -f $@ .tmp && touch $@ .tmp
2015-04-08 02:59:34 +08:00
i f d e f m y _ e x p o r t _ c _ i n c l u d e _ d i r s
2011-11-09 01:31:21 +08:00
$( hide) for d in $( PRIVATE_EXPORT_C_INCLUDE_DIRS) ; do \
2015-12-01 09:33:26 +08:00
echo " -I $$ d " >> $@ .tmp; \
2011-11-09 01:31:21 +08:00
done
2016-03-05 04:40:25 +08:00
e n d i f
i f d e f e x p o r t _ i n c l u d e _ d e p s
$( hide) for f in $( PRIVATE_REEXPORTED_INCLUDES) ; do \
cat $$ f >> $@ .tmp; \
done
2015-12-01 09:33:26 +08:00
e n d i f
$( hide) if cmp -s $@ .tmp $@ ; then \
rm $@ .tmp ; \
else \
mv $@ .tmp $@ ; \
fi
2012-04-19 08:35:55 +08:00
2015-12-01 09:33:26 +08:00
# Kati adds restat=1 to ninja. GNU make does nothing for this.
.KATI_RESTAT : $( export_includes )
2012-04-19 08:35:55 +08:00
# Make sure export_includes gets generated when you are running mm/mmm
2016-06-08 05:25:14 +08:00
$(LOCAL_BUILT_MODULE) : | $( export_includes ) $( my_link_type )
2016-08-27 04:27:13 +08:00
i f n e q ( $( LOCAL_MODULE_MAKEFILE ) , $( SOONG_ANDROID_MK ) )
SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \
$( SOONG_CONV.$( LOCAL_MODULE) .PROBLEMS) $( my_soong_problems)
SOONG_CONV.$(LOCAL_MODULE).DEPS := \
$( SOONG_CONV.$( LOCAL_MODULE) .DEPS) \
$( my_static_libraries) \
$( my_whole_static_libraries) \
$( my_shared_libraries) \
$( my_system_shared_libraries)
SOONG_CONV := $( SOONG_CONV) $( LOCAL_MODULE)
e n d i f