wlan_platform_modules.bzl 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. load("//build/bazel_common_rules/dist:dist.bzl", "copy_to_dist_dir")
  2. load("//build/kernel/kleaf:kernel.bzl", "ddk_module")
  3. load("//msm-kernel:target_variants.bzl", "get_all_variants")
  4. _module_enablement_map = {
  5. # "ALL" will enable for all target/variant combos
  6. "cnss2": ["ALL"],
  7. # Empty list disables the module build
  8. "icnss2": [],
  9. "cnss_nl": ["ALL"],
  10. "cnss_prealloc": ["ALL"],
  11. # List specific target/variants if needed
  12. "cnss_utils": [
  13. "pineapple_consolidate",
  14. ],
  15. "wlan_firmware_service": ["ALL"],
  16. "cnss_plat_ipc_qmi_svc": ["ALL"],
  17. }
  18. def _get_module_list(target, variant):
  19. tv = "{}_{}".format(target, variant)
  20. ret = []
  21. for (mod, enabled_platforms) in _module_enablement_map.items():
  22. if "ALL" in enabled_platforms or tv in enabled_platforms:
  23. ret.append(mod)
  24. continue
  25. return [":{}_{}".format(tv, mod) for mod in ret]
  26. def _define_modules_for_target_variant(target, variant):
  27. tv = "{}_{}".format(target, variant)
  28. ddk_module(
  29. name = "{}_cnss2".format(tv),
  30. srcs = native.glob([
  31. "cnss2/main.c",
  32. "cnss2/bus.c",
  33. "cnss2/debug.c",
  34. "cnss2/pci.c",
  35. "cnss2/pci_platform.h",
  36. "cnss2/power.c",
  37. "cnss2/genl.c",
  38. "cnss2/*.h",
  39. "cnss_utils/*.h",
  40. ]),
  41. includes = ["cnss", "cnss_utils"],
  42. kconfig = "cnss2/Kconfig",
  43. defconfig = "build/{}_defconfig".format(tv),
  44. conditional_srcs = {
  45. "CONFIG_CNSS2_QMI": {
  46. True: [
  47. "cnss2/qmi.c",
  48. "cnss2/coexistence_service_v01.c",
  49. "cnss2/ip_multimedia_subsystem_private_service_v01.c",
  50. ]
  51. },
  52. "CONFIG_PCI_MSM": {
  53. True: [
  54. "cnss2/pci_qcom.c",
  55. ],
  56. },
  57. },
  58. out = "cnss2.ko",
  59. kernel_build = "//msm-kernel:{}".format(tv),
  60. deps = [
  61. "//vendor/qcom/opensource/securemsm-kernel:{}_smcinvoke_dlkm".format(tv),
  62. ":{}_cnss_utils".format(tv),
  63. ":{}_wlan_firmware_service".format(tv),
  64. ":{}_cnss_plat_ipc_qmi_svc".format(tv),
  65. "//msm-kernel:all_headers",
  66. ":wlan-platform-headers",
  67. ],
  68. )
  69. ddk_module(
  70. name = "{}_icnss2".format(tv),
  71. srcs = native.glob([
  72. "icnss2/main.c",
  73. "icnss2/debug.c",
  74. "icnss2/power.c",
  75. "icnss2/genl.c",
  76. "icnss2/*.h",
  77. "cnss_utils/*.h",
  78. ]),
  79. includes = ["icnss2", "cnss_utils"],
  80. kconfig = "icnss2/Kconfig",
  81. defconfig = "build/{}_defconfig".format(tv),
  82. conditional_srcs = {
  83. "CONFIG_ICNSS2_QMI": {
  84. True: [
  85. "icnss2/qmi.c",
  86. ],
  87. },
  88. },
  89. out = "icnss2.ko",
  90. kernel_build = "//msm-kernel:{}".format(tv),
  91. deps = [
  92. "//msm-kernel:all_headers",
  93. ":wlan-platform-headers",
  94. ],
  95. )
  96. ddk_module(
  97. name = "{}_cnss_nl".format(tv),
  98. srcs = [
  99. "cnss_genl/cnss_nl.c",
  100. ],
  101. kconfig = "cnss_genl/Kconfig",
  102. defconfig = "build/{}_defconfig".format(tv),
  103. out = "cnss_nl.ko",
  104. kernel_build = "//msm-kernel:{}".format(tv),
  105. deps = [
  106. "//msm-kernel:all_headers",
  107. ":wlan-platform-headers",
  108. ],
  109. )
  110. ddk_module(
  111. name = "{}_cnss_prealloc".format(tv),
  112. srcs = [
  113. "cnss_prealloc/cnss_prealloc.c",
  114. ],
  115. kconfig = "cnss_prealloc/Kconfig",
  116. defconfig = "build/{}_defconfig".format(tv),
  117. out = "cnss_prealloc.ko",
  118. kernel_build = "//msm-kernel:{}".format(tv),
  119. deps = [
  120. "//msm-kernel:all_headers",
  121. ":wlan-platform-headers",
  122. ],
  123. )
  124. ddk_module(
  125. name = "{}_cnss_utils".format(tv),
  126. srcs = native.glob([
  127. "cnss_utils/cnss_utils.c",
  128. "cnss_utils/*.h"
  129. ]),
  130. kconfig = "cnss_utils/Kconfig",
  131. defconfig = "build/{}_defconfig".format(tv),
  132. out = "cnss_utils.ko",
  133. kernel_build = "//msm-kernel:{}".format(tv),
  134. deps = [
  135. "//msm-kernel:all_headers",
  136. ":wlan-platform-headers",
  137. ],
  138. )
  139. ddk_module(
  140. name = "{}_wlan_firmware_service".format(tv),
  141. srcs = native.glob([
  142. "cnss_utils/wlan_firmware_service_v01.c",
  143. "cnss_utils/device_management_service_v01.c",
  144. "cnss_utils/*.h"
  145. ]),
  146. kconfig = "cnss_utils/Kconfig",
  147. defconfig = "build/{}_defconfig".format(tv),
  148. out = "wlan_firmware_service.ko",
  149. kernel_build = "//msm-kernel:{}".format(tv),
  150. deps = ["//msm-kernel:all_headers"],
  151. )
  152. ddk_module(
  153. name = "{}_cnss_plat_ipc_qmi_svc".format(tv),
  154. srcs = native.glob([
  155. "cnss_utils/cnss_plat_ipc_qmi.c",
  156. "cnss_utils/cnss_plat_ipc_service_v01.c",
  157. "cnss_utils/*.h"
  158. ]),
  159. kconfig = "cnss_utils/Kconfig",
  160. defconfig = "build/{}_defconfig".format(tv),
  161. out = "cnss_plat_ipc_qmi_svc.ko",
  162. kernel_build = "//msm-kernel:{}".format(tv),
  163. deps = ["//msm-kernel:all_headers"],
  164. )
  165. copy_to_dist_dir(
  166. name = "{}_modules_dist".format(tv),
  167. data = _get_module_list(target, variant),
  168. dist_dir = "out/target/product/{}/dlkm/lib/modules/".format(target),
  169. flat = True,
  170. wipe_dist_dir = False,
  171. allow_duplicate_filenames = False,
  172. mode_overrides = {"**/*": "644"},
  173. log = "info"
  174. )
  175. def define_modules():
  176. for (t, v) in get_all_variants():
  177. _define_modules_for_target_variant(t, v)