From 49f32a8f1e8b67f7080f53fd03a4edb3ea82723a Mon Sep 17 00:00:00 2001 From: Ulises Mendez Martinez Date: Mon, 7 Aug 2023 12:42:40 +0000 Subject: [PATCH] ANDROID: Add arch specific gki module list targets * This is a no-op change preparing for the split of target and files based on the architecture used. Bug: 293529933 Change-Id: I7783b60e591aaad23b5446af5cb04af5765f4b3f Signed-off-by: Ulises Mendez Martinez --- BUILD.bazel | 42 +++++++++++++++++++++++++++++++++++------- modules.bzl | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index d1d581c176f8..18d496473a44 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -12,7 +12,7 @@ load( "kernel_modules_install", "merged_kernel_uapi_headers", ) -load(":modules.bzl", "COMMON_GKI_MODULES_LIST") +load(":modules.bzl", "get_gki_modules_list") package( default_visibility = [ @@ -39,10 +39,38 @@ _GKI_X86_64_MAKE_GOALS = [ "modules", ] +# Deprecated - Use arch specific files from below. write_file( name = "gki_system_dlkm_modules", out = "android/gki_system_dlkm_modules", - content = COMMON_GKI_MODULES_LIST + [ + content = get_gki_modules_list("arm64") + [ + # Ensure new line at the end. + "", + ], +) + +write_file( + name = "gki_system_dlkm_modules_arm64", + out = "android/gki_system_dlkm_modules_arm64", + content = get_gki_modules_list("arm64") + [ + # Ensure new line at the end. + "", + ], +) + +write_file( + name = "gki_system_dlkm_modules_x86_64", + out = "android/gki_system_dlkm_modules_x86_64", + content = get_gki_modules_list("x86_64") + [ + # Ensure new line at the end. + "", + ], +) + +write_file( + name = "gki_system_dlkm_modules_risc64", + out = "android/gki_system_dlkm_modules_riscv64", + content = get_gki_modules_list("riscv64") + [ # Ensure new line at the end. "", ], @@ -50,16 +78,16 @@ write_file( define_common_kernels(target_configs = { "kernel_aarch64": { - "module_implicit_outs": COMMON_GKI_MODULES_LIST, + "module_implicit_outs": get_gki_modules_list("arm64"), "make_goals": _GKI_AARCH64_MAKE_GOALS, }, "kernel_riscv64": { - "module_implicit_outs": COMMON_GKI_MODULES_LIST, + "module_implicit_outs": get_gki_modules_list("riscv64"), "make_goals": _GKI_RISCV64_MAKE_GOALS, }, "kernel_x86_64": { "kmi_symbol_list_strict_mode": False, - "module_implicit_outs": COMMON_GKI_MODULES_LIST, + "module_implicit_outs": get_gki_modules_list("x86_64"), "make_goals": _GKI_X86_64_MAKE_GOALS, }, }) @@ -411,7 +439,7 @@ kernel_build( "modules", "rk3399-rock-pi-4b.dtb", ], - module_outs = COMMON_GKI_MODULES_LIST + _ROCKPI4_MODULE_OUTS + _ROCKPI4_WATCHDOG_MODULE_OUTS, + module_outs = get_gki_modules_list("arm64") + _ROCKPI4_MODULE_OUTS + _ROCKPI4_WATCHDOG_MODULE_OUTS, visibility = ["//visibility:private"], ) @@ -434,7 +462,7 @@ kernel_build( "modules", "rk3399-rock-pi-4b.dtb", ], - module_outs = COMMON_GKI_MODULES_LIST + _ROCKPI4_MODULE_OUTS, + module_outs = get_gki_modules_list("arm64") + _ROCKPI4_MODULE_OUTS, visibility = ["//visibility:private"], ) diff --git a/modules.bzl b/modules.bzl index d79719bd3ad6..b705a895ecf9 100644 --- a/modules.bzl +++ b/modules.bzl @@ -6,7 +6,7 @@ This module contains a full list of kernel modules compiled by GKI. """ -COMMON_GKI_MODULES_LIST = [ +_COMMON_GKI_MODULES_LIST = [ # keep sorted "drivers/block/zram/zram.ko", "drivers/bluetooth/btbcm.ko", @@ -71,3 +71,43 @@ COMMON_GKI_MODULES_LIST = [ "net/tipc/tipc.ko", "net/wireless/cfg80211.ko", ] + +# Deprecated - Use `get_gki_modules_list` function instead. +COMMON_GKI_MODULES_LIST = _COMMON_GKI_MODULES_LIST + +_ARM64_GKI_MODULES_LIST = [ + # keep sorted +] + +_RISCV64_GKI_MODULES_LIST = [ + # keep sorted +] + +_X86_64_GKI_MODULES_LIST = [ + # keep sorted +] + +# buildifier: disable=unnamed-macro +def get_gki_modules_list(arch = None): + """ Provides the list of GKI modules. + + Args: + arch: One of [arm64, x86_64, riscv64]. + + Returns: + The list of GKI modules for the given |arch|. + """ + gki_modules_list = [] + _COMMON_GKI_MODULES_LIST + if arch == "arm64": + gki_modules_list += _ARM64_GKI_MODULES_LIST + elif arch == "x86_64": + gki_modules_list += _X86_64_GKI_MODULES_LIST + elif arch == "riscv64": + gki_modules_list += _RISCV64_GKI_MODULES_LIST + else: + fail("{}: arch {} not supported. Use one of [arm64, x86_64, riscv64]".format( + str(native.package_relative_label(":x")).removesuffix(":x"), + arch, + )) + + return gki_modules_list