diff --git a/core/base_rules.mk b/core/base_rules.mk index 30b6c1cd4..a84ea27b5 100644 --- a/core/base_rules.mk +++ b/core/base_rules.mk @@ -156,6 +156,8 @@ ifeq ($(my_module_path),) partition_tag := _OEM else ifeq (true,$(LOCAL_ODM_MODULE)) partition_tag := _ODM + else ifeq (NATIVE_TESTS,$(LOCAL_MODULE_CLASS)) + partition_tag := _DATA else # The definition of should-install-to-system will be different depending # on which goal (e.g., sdk or just droid) is being built. @@ -457,7 +459,7 @@ $(foreach tag,$(my_module_tags),\ ## umbrella targets used to verify builds ########################################################### j_or_n := -ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))) +ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS))) j_or_n := native else ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS))) diff --git a/core/binary.mk b/core/binary.mk index 493bed8a6..d6445d4e1 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -186,7 +186,7 @@ endif # all code is position independent, and then those warnings get promoted to # errors. ifneq ($($(my_prefix)OS),windows) -ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) +ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) my_cflags += -fpie else my_cflags += -fPIC diff --git a/core/combo/HOST_darwin-x86.mk b/core/combo/HOST_darwin-x86.mk index 9e1ecc5ba..534c82308 100644 --- a/core/combo/HOST_darwin-x86.mk +++ b/core/combo/HOST_darwin-x86.mk @@ -49,8 +49,8 @@ endef define transform-host-o-to-executable-inner $(hide) $(PRIVATE_CXX) \ - -Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ - -Wl,-rpath,@loader_path/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \ + $(foreach path,$(PRIVATE_RPATHS), \ + -Wl,-rpath,@loader_path/$(path)) \ -o $@ \ -Wl,-headerpad_max_install_names \ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_GLOBAL_LD_DIRS) \ diff --git a/core/definitions.mk b/core/definitions.mk index 757207064..4fc21d5ac 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1877,8 +1877,8 @@ $(hide) $(PRIVATE_CXX) \ $(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \ $(call normalize-host-libraries,$(PRIVATE_ALL_SHARED_LIBRARIES)) \ -Wl,-rpath-link=$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_INTERMEDIATE_LIBRARIES) \ - -Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ - -Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \ + $(foreach path,$(PRIVATE_RPATHS), \ + -Wl,-rpath,\$$ORIGIN/$(path)) \ $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_LD_DIRS) \ $(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \ $(PRIVATE_HOST_GLOBAL_LDFLAGS) \ diff --git a/core/dynamic_binary.mk b/core/dynamic_binary.mk index 58f76b002..579338e67 100644 --- a/core/dynamic_binary.mk +++ b/core/dynamic_binary.mk @@ -58,7 +58,7 @@ endif # Do not pack relocations for executables. Because packing results in # non-zero p_vaddr which causes kernel to load executables to lower # address (starting at 0x8000) http://b/20665974 -ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) +ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) my_pack_module_relocations := false endif diff --git a/core/envsetup.mk b/core/envsetup.mk index 4b48b2723..0a7472af3 100644 --- a/core/envsetup.mk +++ b/core/envsetup.mk @@ -247,9 +247,11 @@ HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib64 HOST_OUT_RENDERSCRIPT_BITCODE := $(HOST_OUT_SHARED_LIBRARIES) HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT)/framework HOST_OUT_SDK_ADDON := $(HOST_OUT)/sdk_addon +HOST_OUT_NATIVE_TESTS := $(HOST_OUT)/nativetest64 HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT)/bin HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib +HOST_CROSS_OUT_NATIVE_TESTS := $(HOST_CROSS_OUT)/nativetest HOST_OUT_INTERMEDIATES := $(HOST_OUT)/obj HOST_OUT_HEADERS := $(HOST_OUT_INTERMEDIATES)/include @@ -276,6 +278,7 @@ $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_INTERMEDIATE_LIBRARIES := $($(HOST_2ND_ARCH_ $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES := $(HOST_OUT)/lib $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_EXECUTABLES := $(HOST_OUT_EXECUTABLES) $(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_JAVA_LIBRARIES := $(HOST_OUT_JAVA_LIBRARIES) +$(HOST_2ND_ARCH_VAR_PREFIX)HOST_OUT_NATIVE_TESTS := $(HOST_OUT)/nativetest # The default host library path. # It always points to the path where we build libraries in the default bitness. @@ -292,6 +295,7 @@ $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATES := $(HOST_CROSS_OU $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATE_LIBRARIES := $($(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_INTERMEDIATES)/lib $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_SHARED_LIBRARIES := $(HOST_CROSS_OUT)/lib64 $(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_EXECUTABLES := $(HOST_CROSS_OUT_EXECUTABLES) +$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_OUT_NATIVE_TESTS := $(HOST_CROSS_OUT)/nativetest64 TARGET_OUT_INTERMEDIATES := $(PRODUCT_OUT)/obj TARGET_OUT_HEADERS := $(TARGET_OUT_INTERMEDIATES)/include @@ -467,7 +471,7 @@ TARGET_INSTALLER_ROOT_OUT := $(TARGET_INSTALLER_OUT)/root TARGET_INSTALLER_SYSTEM_OUT := $(TARGET_INSTALLER_OUT)/root/system COMMON_MODULE_CLASSES := TARGET-NOTICE_FILES HOST-NOTICE_FILES HOST-JAVA_LIBRARIES -PER_ARCH_MODULE_CLASSES := SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP RENDERSCRIPT_BITCODE +PER_ARCH_MODULE_CLASSES := SHARED_LIBRARIES STATIC_LIBRARIES EXECUTABLES GYP RENDERSCRIPT_BITCODE NATIVE_TESTS ifeq (,$(strip $(DIST_DIR))) DIST_DIR := $(OUT_DIR)/dist diff --git a/core/executable.mk b/core/executable.mk index 27c033d1c..865207750 100644 --- a/core/executable.mk +++ b/core/executable.mk @@ -30,12 +30,14 @@ my_prefix := TARGET_ include $(BUILD_SYSTEM)/multilib.mk ifeq ($(my_module_multilib),both) +ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),) $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE)) endif ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),) $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE)) endif +endif else #!LOCAL_MULTILIB == both LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true endif diff --git a/core/host_executable.mk b/core/host_executable.mk index 6f19bd173..0060c3e62 100644 --- a/core/host_executable.mk +++ b/core/host_executable.mk @@ -19,12 +19,14 @@ LOCAL_LDFLAGS += $(HOST_FPIE_FLAGS) endif ifeq ($(my_module_multilib),both) +ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) ifeq ($(LOCAL_MODULE_PATH_32)$(LOCAL_MODULE_STEM_32),) $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_32 or LOCAL_MODULE_PATH_32 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE)) endif ifeq ($(LOCAL_MODULE_PATH_64)$(LOCAL_MODULE_STEM_64),) $(error $(LOCAL_PATH): LOCAL_MODULE_STEM_64 or LOCAL_MODULE_PATH_64 is required for LOCAL_MULTILIB := both for module $(LOCAL_MODULE)) endif +endif else #!LOCAL_MULTILIB == both LOCAL_NO_2ND_ARCH_MODULE_SUFFIX := true endif diff --git a/core/host_executable_internal.mk b/core/host_executable_internal.mk index b682ffdaa..19200fd57 100644 --- a/core/host_executable_internal.mk +++ b/core/host_executable_internal.mk @@ -29,6 +29,14 @@ include $(BUILD_SYSTEM)/binary.mk my_host_libprofile_rt := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT) $(LOCAL_BUILT_MODULE): PRIVATE_HOST_LIBPROFILE_RT := $(my_host_libprofile_rt) +my_libdir := $(notdir $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES)) +ifeq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) +$(LOCAL_BUILT_MODULE): PRIVATE_RPATHS := ../../$(my_libdir) +else +$(LOCAL_BUILT_MODULE): PRIVATE_RPATHS := ../$(my_libdir) $(my_libdir) +endif +my_libdir := + $(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries) $(transform-host-o-to-executable) diff --git a/core/host_native_test.mk b/core/host_native_test.mk index 7cba1ae9b..c6d6f521e 100644 --- a/core/host_native_test.mk +++ b/core/host_native_test.mk @@ -3,24 +3,24 @@ ## Common flags for host native tests are added. ################################################ +ifdef LOCAL_MODULE_CLASS +ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) +$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must be NATIVE_TESTS with BUILD_HOST_NATIVE_TEST) +endif +endif + +LOCAL_MODULE_CLASS := NATIVE_TESTS + include $(BUILD_SYSTEM)/host_test_internal.mk -needs_symlink := ifndef LOCAL_MULTILIB - ifndef LOCAL_32_BIT_ONLY - LOCAL_MULTILIB := both +ifndef LOCAL_32_BIT_ONLY +LOCAL_MULTILIB := both +endif +endif - ifeq (,$(LOCAL_MODULE_STEM_32)$(LOCAL_MODULE_STEM_64)) - LOCAL_MODULE_STEM_32 := $(LOCAL_MODULE)32 - LOCAL_MODULE_STEM_64 := $(LOCAL_MODULE)64 - needs_symlink := true - endif - endif +ifndef LOCAL_MODULE_RELATIVE_PATH +LOCAL_MODULE_RELATIVE_PATH := $(LOCAL_MODULE) endif include $(BUILD_HOST_EXECUTABLE) - -ifdef needs_symlink -include $(BUILD_SYSTEM)/executable_prefer_symlink.mk -needs_symlink := -endif diff --git a/core/host_shared_test_lib.mk b/core/host_shared_test_lib.mk index 1eb9b2611..2c2063d57 100644 --- a/core/host_shared_test_lib.mk +++ b/core/host_shared_test_lib.mk @@ -3,6 +3,8 @@ ## Common flags for host native tests are added. ################################################## +$(error BUILD_HOST_SHARED_TEST_LIBRARY is obsolete) + include $(BUILD_SYSTEM)/host_test_internal.mk include $(BUILD_HOST_SHARED_LIBRARY) diff --git a/core/host_test_internal.mk b/core/host_test_internal.mk index 6c52e6472..70f011b60 100644 --- a/core/host_test_internal.mk +++ b/core/host_test_internal.mk @@ -11,3 +11,15 @@ LOCAL_LDLIBS_darwin += -lpthread LOCAL_CFLAGS += -DGTEST_HAS_STD_STRING -O0 -g LOCAL_STATIC_LIBRARIES += libgtest_main_host libgtest_host + +ifdef LOCAL_MODULE_PATH +$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH when building test $(LOCAL_MODULE)) +endif + +ifdef LOCAL_MODULE_PATH_32 +$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_32 when building test $(LOCAL_MODULE)) +endif + +ifdef LOCAL_MODULE_PATH_64 +$(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE)) +endif diff --git a/core/main.mk b/core/main.mk index 2c97fcf0c..a2f80ef43 100644 --- a/core/main.mk +++ b/core/main.mk @@ -630,7 +630,7 @@ $(foreach m,$(ALL_MODULES),\ $(eval r := $(addprefix host_cross_,$(r))))\ $(if $(ALL_MODULES.$(m).FOR_2ND_ARCH),\ $(eval r_r := $(call get-32-bit-modules-if-we-can,$(r))),\ - $(if $(filter EXECUTABLES SHARED_LIBRARIES,$(ALL_MODULES.$(m).CLASS)),\ + $(if $(filter EXECUTABLES SHARED_LIBRARIES NATIVE_TESTS,$(ALL_MODULES.$(m).CLASS)),\ $(eval r_r := $(r)),\ $(eval r_r := $(r) $(call get-32-bit-modules,$(r)))\ )\ diff --git a/core/native_test.mk b/core/native_test.mk index 93b7e1a90..d4b2a5b2e 100644 --- a/core/native_test.mk +++ b/core/native_test.mk @@ -3,6 +3,11 @@ ## Common flags for native tests are added. ########################################### +# TODO: enforce NATIVE_TESTS once current users are gone +ifndef LOCAL_MODULE_CLASS +LOCAL_MODULE_CLASS := NATIVE_TESTS +endif + include $(BUILD_SYSTEM)/target_test_internal.mk ifndef LOCAL_MULTILIB @@ -11,4 +16,10 @@ LOCAL_MULTILIB := both endif endif +ifneq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) +$(warning $(LOCAL_PATH): $(LOCAL_MODULE): LOCAL_MODULE_CLASS should be NATIVE_TESTS with BUILD_NATIVE_TEST) +LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE) +LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE) +endif + include $(BUILD_EXECUTABLE) diff --git a/core/prebuilt.mk b/core/prebuilt.mk index 7b8346795..cbe2079da 100644 --- a/core/prebuilt.mk +++ b/core/prebuilt.mk @@ -59,7 +59,7 @@ LOCAL_2ND_ARCH_VAR_PREFIX := ifdef LOCAL_IS_HOST_MODULE ifdef HOST_CROSS_OS -ifneq (,$(filter EXECUTABLES STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))) +ifneq (,$(filter EXECUTABLES STATIC_LIBRARIES SHARED_LIBRARIES NATIVE_TESTS,$(LOCAL_MODULE_CLASS))) my_prefix := HOST_CROSS_ LOCAL_HOST_PREFIX := $(my_prefix) include $(BUILD_SYSTEM)/module_arch_supported.mk diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index c4f1a7a82..3f89d80a8 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -92,7 +92,7 @@ ifneq ($(filter true no_debuglink,$(my_strip_module) $(my_pack_module_relocation ifdef LOCAL_IS_HOST_MODULE $(error Cannot strip/pack host module LOCAL_PATH=$(LOCAL_PATH)) endif - ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),) + ifeq ($(filter SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) $(error Can strip/pack only shared libraries or executables LOCAL_PATH=$(LOCAL_PATH)) endif ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) @@ -346,7 +346,7 @@ ifneq ($(LOCAL_PREBUILT_STRIP_COMMENTS),) else $(transform-prebuilt-to-target) endif -ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES) +ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) $(hide) chmod +x $@ endif endif # ! prebuilt_module_is_dex_javalib diff --git a/core/shared_test_lib.mk b/core/shared_test_lib.mk index fbfdc9c1c..f3b880718 100644 --- a/core/shared_test_lib.mk +++ b/core/shared_test_lib.mk @@ -3,6 +3,8 @@ ## Common flags for native tests are added. ############################################# +$(error BUILD_SHARED_TEST_LIBRARY is obsolete) + include $(BUILD_SYSTEM)/target_test_internal.mk include $(BUILD_SHARED_LIBRARY) diff --git a/core/target_test_internal.mk b/core/target_test_internal.mk index 9e2567433..d321aaadd 100644 --- a/core/target_test_internal.mk +++ b/core/target_test_internal.mk @@ -33,5 +33,8 @@ ifdef LOCAL_MODULE_PATH_64 $(error $(LOCAL_PATH): Do not set LOCAL_MODULE_PATH_64 when building test $(LOCAL_MODULE)) endif -LOCAL_MODULE_PATH_64 := $(TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE) -LOCAL_MODULE_PATH_32 := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/$(LOCAL_MODULE) +ifeq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS) +ifndef LOCAL_MODULE_RELATIVE_PATH +LOCAL_MODULE_RELATIVE_PATH := $(LOCAL_MODULE) +endif +endif