Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 946ca19d authored by Joey Jiao's avatar Joey Jiao Committed by Gabriel Chen
Browse files

Enable clang coverage

This is to align with build/soong to support clang coverage.
- support env CLANG_COVERAGE and CLANG_COVERAGE_CONTINUOUS_MODE.
- support kill -37 signal to dump coverage.
- support build clang coverage together with hwasan.

Bug: 309894892
Change-Id: I14f75d7fdfdf872d2db3bbceb2c10d6572bcfebf
parent 04591b63
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -145,15 +145,21 @@ endif
ifneq (,$(strip $(foreach dir,$(NATIVE_COVERAGE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
ifeq (,$(strip $(foreach dir,$(NATIVE_COVERAGE_EXCLUDE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
  my_native_coverage := true
  my_clang_coverage := true
else
  my_native_coverage := false
  my_clang_coverage := false
endif
else
  my_native_coverage := false
  my_clang_coverage := false
endif
ifneq ($(NATIVE_COVERAGE),true)
  my_native_coverage := false
endif
ifneq ($(CLANG_COVERAGE),true)
  my_clang_coverage := false
endif

# Exclude directories from checking allowed manual binder interface lists.
# TODO(b/145621474): Move this check into IInterface.h when clang-tidy no longer uses absolute paths.
@@ -270,6 +276,7 @@ ifneq ($(LOCAL_SDK_VERSION),)
  ifneq ($(my_ndk_api),current)
    ifeq ($(call math_lt, $(my_ndk_api),23),true)
      my_native_coverage := false
      my_clang_coverage := false
    endif
  endif
endif
@@ -295,6 +302,36 @@ ifeq ($(NATIVE_COVERAGE),true)
  endif
endif

ifeq ($(CLANG_COVERAGE),true)
  ifndef LOCAL_IS_HOST_MODULE
    my_ldflags += $(CLANG_COVERAGE_HOST_LDFLAGS)
    ifneq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
      my_whole_static_libraries += libclang_rt.profile
      ifeq ($(LOCAL_SDK_VERSION),)
        my_whole_static_libraries += libprofile-clang-extras
      else
        my_whole_static_libraries += libprofile-clang-extras_ndk
      endif
    endif
  endif
  ifeq ($(my_clang_coverage),true)
    my_profile_instr_generate := $(CLANG_COVERAGE_INSTR_PROFILE)
    ifeq ($(CLANG_COVERAGE_CONTINUOUS_MODE),true)
      my_cflags += $(CLANG_COVERAGE_CONTINUOUS_FLAGS)
      my_ldflags += $(CLANG_COVERAGE_CONTINUOUS_FLAGS)
    endif

    my_profile_instr_generate += $(CLANG_COVERAGE_CONFIG_COMMFLAGS)
    my_cflags += $(CLANG_COVERAGE_INSTR_PROFILE) $(CLANG_COVERAGE_CONFIG_CFLAGS) $(CLANG_COVERAGE_CONFIG_COMMFLAGS)
    my_ldflags += $(CLANG_COVERAGE_CONFIG_COMMFLAGS)

    ifneq ($(filter hwaddress,$(my_sanitize)),)
      my_cflags += $(CLANG_COVERAGE_HWASAN_FLAGS)
      my_ldflags += $(CLANG_COVERAGE_HWASAN_FLAGS)
    endif
  endif
endif

ifneq ($(LOCAL_USE_VNDK),)
  my_cflags += -D__ANDROID_VNDK__
  ifneq ($(LOCAL_USE_VNDK_VENDOR),)