Files
RedLintu16andClaude Opus 5.5 55a0b90519 Import from Sony 73.1.A.2.74 open source archive
Source: opendevices.sony.net, "Open source archive for 73.1.A.2.74" (Xperia 1 VIII: XQ-GE74, XQ-GE54, SO-51G, SOG17, A601SO, XQ-GE44), unmodified.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-13 22:52:53 +00:00

111 lines
4.3 KiB
Python

load(":target_variants.bzl", "get_all_variants")
load("//build/kernel/kleaf:kernel.bzl", "ddk_module")
load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir")
load(":bt_modules.bzl", "bt_modules")
def _get_config_choices(config_srcs, options):
choices = []
for option in config_srcs:
choices.extend(config_srcs[option].get(option in options, []))
return choices
def _get_module_srcs(module, options):
"""
Gets all the module sources, formats them with the path for that module
and then groups them together
It also includes all the headers within the `include` directory
`native.glob()` returns a new list with every file need for the current package
"""
srcs = module.srcs + _get_config_choices(module.config_srcs, options)
return native.glob(
["{}/{}".format(module.path, src) for src in srcs] + ["include/*.h"],
)
def _get_module_deps(module, options, formatter):
"""
Formats the dependent targets with the necessary prefix
Args:
module: kernel module
options: dependencies that rely on a config option
formatter: function that will replace the format string within `deps`
Example:
kernel build = "pineapple_gki"
dep = "%b_btpower"
The formatted string will look as follow
formatted_dep = formatter(dep) = "pineapple_gki_btpower"
"""
deps = module.deps + _get_config_choices(module.config_deps, options)
return [formatter(dep) for dep in deps]
def _get_build_options(modules, config_options):
all_options = {option: True for option in config_options}
all_options = all_options | {module.config_opt: True for module in modules if module.config_opt}
return all_options
def define_target_variant_modules(target, variant, modules, config_options = []):
"""
Generates the ddk_module for each of our kernel modules
Args:
target: either `pineapple` or `kalama`
variant: either `gki` or `consolidate`
modules: bt_modules dictionary defined in `bt_modules.bzl`
config_options: decides which kernel modules to build
"""
kernel_build = "{}_{}".format(target, variant)
kernel_build_label = select({
"//build/kernel/kleaf:socrepo_true": "//soc-repo:{}_base_kernel".format(kernel_build),
"//build/kernel/kleaf:socrepo_false": "//msm-kernel:{}".format(kernel_build),
})
deps = select({
"//build/kernel/kleaf:socrepo_true": [
"//soc-repo:all_headers",
"//soc-repo:{}/drivers/remoteproc/rproc_qcom_common".format(kernel_build),
"//soc-repo:{}/kernel/trace/qcom_ipc_logging".format(kernel_build),
"//soc-repo:{}/drivers/soc/qcom/qcom_aoss".format(kernel_build),
"//soc-repo:{}/drivers/slimbus/slimbus".format(kernel_build),
"//soc-repo:{}/drivers/pinctrl/qcom/pinctrl-msm".format(kernel_build),
],
"//build/kernel/kleaf:socrepo_false": ["//msm-kernel:all_headers"],
})
modules = [bt_modules.get(module_name) for module_name in modules]
options = _get_build_options(modules, config_options)
formatter = lambda s: s.replace("%b", kernel_build)
all_modules = []
for module in modules:
rule_name = "{}_{}".format(kernel_build, module.name)
module_srcs = _get_module_srcs(module, options)
ddk_module(
name = rule_name,
kernel_build = kernel_build_label,
srcs = module_srcs,
out = "{}.ko".format(module.name),
deps = deps + _get_module_deps(module, options, formatter),
includes = ["include"],
local_defines = options.keys(),
visibility = ["//visibility:public"],
)
all_modules.append(rule_name)
copy_to_dist_dir(
name = "{}_bt-kernel_dist".format(kernel_build),
data = all_modules,
dist_dir = "out/target/product/{}/dlkm/lib/modules".format(target),
flat = True,
wipe_dist_dir = False,
allow_duplicate_filenames = False,
mode_overrides = {"**/*": "644"},
log = "info",
)
def define_bt_modules(target, modules, config_options = []):
for (t, v) in get_all_variants():
if t == target:
define_target_variant_modules(t, v, modules, config_options)