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

Commit b335f4d4 authored by Nelson Li's avatar Nelson Li
Browse files

Convert `asan.options` and `asan_extract` to Android.bp

In the original Android.mk, `asan.option` is only enabled when
"address" is present in SANITIZE_TARGET.
`asan_extract` is only enabled when `SANITIZE_TARGET_SYSTEM` is `true`
and `address` is present in SANITIZE_TARGET.

However, in the normal build system design, a module should `not`
decide when it should be enabled.
Therefore, the `ifeq` condition should be directly removed during
conversion.

The correct approach is:
Wait until converting `init.environ.rc`, then use `select` or similar
methods to determine whether it should use `asan.option` or
`asan_extract`.

Bug: 353164536
Test: SANITIZE_TARGET=address m init.environ.rc
      SANITIZE_TARGET_SYSTEM=true SANITIZE_TARGET=address m init.environ.rc
Change-Id: I69af3199536a3ba9f54dcfa198295826303e2d22
parent c36f4f05
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -114,6 +114,19 @@ prebuilt_etc {
    sub_dir: "init",
}

prebuilt_etc {
    name: "asan.options",
    src: "asan.options",
}

sh_binary {
    name: "asan_extract",
    src: "asan_extract.sh",
    init_rc: ["asan_extract.rc"],
    // We need bzip2 on device for extraction.
    required: ["bzip2"],
}

llndk_libraries_txt {
    name: "llndk.libraries.txt",
}
+0 −27
Original line number Diff line number Diff line
@@ -3,39 +3,12 @@ LOCAL_PATH:= $(call my-dir)
$(eval $(call declare-1p-copy-files,system/core/rootdir,))

#######################################
# asan.options
ifneq ($(filter address,$(SANITIZE_TARGET)),)

include $(CLEAR_VARS)

LOCAL_MODULE := asan.options
LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0
LOCAL_LICENSE_CONDITIONS := notice
LOCAL_MODULE_CLASS := ETC
LOCAL_SRC_FILES := $(LOCAL_MODULE)
LOCAL_MODULE_PATH := $(TARGET_OUT)

include $(BUILD_PREBUILT)

# ASAN extration.
ASAN_EXTRACT_FILES :=
ifeq ($(SANITIZE_TARGET_SYSTEM),true)
include $(CLEAR_VARS)
LOCAL_MODULE:= asan_extract
LOCAL_LICENSE_KINDS:= SPDX-license-identifier-Apache-2.0
LOCAL_LICENSE_CONDITIONS:= notice
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := EXECUTABLES
LOCAL_SRC_FILES := asan_extract.sh
LOCAL_INIT_RC := asan_extract.rc
# We need bzip2 on device for extraction.
LOCAL_REQUIRED_MODULES := bzip2
include $(BUILD_PREBUILT)
ASAN_EXTRACT_FILES := asan_extract
endif

endif

#######################################
# init.environ.rc