Эх сурвалжийг харах

msm: synx: build: bazel build DDK change

Add support for synx modules to be built with Bazel DDK framework for pineapple.

Change-Id: I375ea8a722f2afdfd5a9354854675030ebd38d96
Signed-off-by: Ram Nagesh <[email protected]>
NITIN LAXMIDAS NAIK 2 жил өмнө
parent
commit
1fb50c3272
4 өөрчлөгдсөн 184 нэмэгдсэн , 0 устгасан
  1. 27 0
      BUILD.bazel
  2. 15 0
      pineapple.bzl
  3. 117 0
      synx_module_build.bzl
  4. 25 0
      synx_modules.bzl

+ 27 - 0
BUILD.bazel

@@ -0,0 +1,27 @@
+package(
+    default_visibility = [
+        "//visibility:public",
+    ],
+)
+
+load("//build/kernel/kleaf:kernel.bzl", "ddk_headers")
+
+driver_header_globs = [
+    "include/uapi/synx/**/*.h",
+    "include/uapi/synx/media/**/*.h",
+    "msm/synx/**/*.h",
+]
+
+ddk_headers(
+    name = "synx_headers",
+    hdrs = glob(driver_header_globs),
+    includes = [
+        "include/uapi/synx",
+        "include/uapi/synx/media",
+        "msm/synx",
+    ],
+)
+
+load(":pineapple.bzl", "define_pineapple")
+
+define_pineapple()

+ 15 - 0
pineapple.bzl

@@ -0,0 +1,15 @@
+load("//external_modules/synx-kernel:synx_modules.bzl", "synx_modules")
+load("//external_modules/synx-kernel:synx_module_build.bzl", "define_consolidate_gki_modules")
+
+def define_pineapple():
+    define_consolidate_gki_modules(
+        target = "pineapple",
+        registry = synx_modules,
+        modules = [
+            "synx",
+            "ipclite",
+        ],
+        config_options = [
+            "TARGET_SYNX_ENABLE",
+        ],
+    )

+ 117 - 0
synx_module_build.bzl

@@ -0,0 +1,117 @@
+load(
+    "//build/kernel/kleaf:kernel.bzl",
+    "ddk_module",
+    "ddk_submodule",
+    "kernel_module",
+    "kernel_modules_install",
+)
+
+def _register_module_to_map(module_map, name, path, config_option, srcs, config_srcs, deps, config_deps):
+    processed_config_srcs = {}
+    processed_config_deps = {}
+
+    for config_src_name in config_srcs:
+        config_src = config_srcs[config_src_name]
+
+        if type(config_src) == "list":
+            processed_config_srcs[config_src_name] = {True: config_src}
+        else:
+            processed_config_srcs[config_src_name] = config_src
+
+    for config_deps_name in config_deps:
+        config_dep = config_deps[config_deps_name]
+
+        if type(config_dep) == "list":
+            processed_config_deps[config_deps_name] = {True: config_dep}
+        else:
+            processed_config_deps[config_deps_name] = config_dep
+
+    module = struct(
+        name = name,
+        path = path,
+        srcs = srcs,
+        config_srcs = processed_config_srcs,
+        config_option = config_option,
+        deps = deps,
+        config_deps = processed_config_deps,
+    )
+
+    module_map[name] = module
+
+def _get_config_choices(map, options):
+    choices = []
+
+    for option in map:
+        choices.extend(map[option].get(option in options, []))
+
+    return choices
+
+def _get_kernel_build_options(modules, config_options):
+    all_options = {option: True for option in config_options}
+    all_options = all_options | {module.config_option: True for module in modules if module.config_option}
+
+    return all_options
+
+def _get_kernel_build_module_srcs(module, options, formatter):
+    srcs = module.srcs + _get_config_choices(module.config_srcs, options)
+    module_path = "{}/".format(module.path) if module.path else ""
+    globbed_srcs = native.glob(["{}{}".format(module_path, formatter(src)) for src in srcs])
+
+    return globbed_srcs
+
+def _get_kernel_build_module_deps(module, options, formatter):
+    deps = module.deps + _get_config_choices(module.config_deps, options)
+    deps = [formatter(dep) for dep in deps]
+
+    return deps
+
+def create_module_registry(hdrs = []):
+    module_map = {}
+
+    def register(name, path = None, config_option = None, srcs = [], config_srcs = {}, deps = [], config_deps = {}):
+        _register_module_to_map(module_map, name, path, config_option, srcs, config_srcs, deps, config_deps)
+
+    return struct(
+        register = register,
+        get = module_map.get,
+        hdrs = hdrs,
+        module_map = module_map,
+    )
+
+def define_target_variant_modules(target, variant, registry, modules, config_options = []):
+    kernel_build = "{}_{}".format(target, variant)
+    kernel_build_label = "//msm-kernel:{}".format(kernel_build)
+    modules = [registry.get(module_name) for module_name in modules]
+    options = _get_kernel_build_options(modules, config_options)
+    build_print = lambda message: print("{}: {}".format(kernel_build, message))
+    formatter = lambda s: s.replace("%b", kernel_build).replace("%t", target)
+
+    headers = ["//msm-kernel:all_headers"] + registry.hdrs
+    all_module_rules = []
+
+    for module in modules:
+        rule_name = "{}_{}".format(kernel_build, module.name)
+        module_srcs = _get_kernel_build_module_srcs(module, options, formatter)
+
+        if not module_srcs:
+            continue
+
+        ddk_submodule(
+            name = rule_name,
+            srcs = module_srcs,
+            out = "{}.ko".format(module.name),
+            deps = headers + _get_kernel_build_module_deps(module, options, formatter),
+            local_defines = options.keys(),
+        )
+
+        all_module_rules.append(rule_name)
+
+    ddk_module(
+        name = "{}_modules".format(kernel_build),
+        kernel_build = kernel_build_label,
+        deps = all_module_rules,
+    )
+
+def define_consolidate_gki_modules(target, registry, modules, config_options = []):
+    define_target_variant_modules(target, "consolidate", registry, modules, config_options)
+    define_target_variant_modules(target, "gki", registry, modules, config_options)

+ 25 - 0
synx_modules.bzl

@@ -0,0 +1,25 @@
+load(":synx_module_build.bzl", "create_module_registry")
+
+SYNX_KERNEL_ROOT = "synx-kernel"
+
+synx_modules = create_module_registry([":synx_headers"])
+register_synx_module = synx_modules.register
+
+register_synx_module(
+    name = "synx",
+    path = "msm",
+    srcs = [
+        "synx/synx.c",
+        "synx/synx_global.c",
+        "synx/synx_util.c",
+        "synx/synx_debugfs.c",
+    ],
+)
+
+register_synx_module(
+    name = "ipclite",
+    path = "msm",
+    srcs = [
+        "synx/ipclite.c",
+    ],
+)