diff --git a/Android.bp b/Android.bp index 3d5382bfbd47..a1fde7b44556 100644 --- a/Android.bp +++ b/Android.bp @@ -28,6 +28,109 @@ kernel_headers_verbose = "" build = ["gen_headers_arm.bp", "gen_headers_arm64.bp"] +soong_config_module_type { + name: "mmi_camera_legacy_genrule_defaults", + module_type: "genrule_defaults", + config_namespace: "mmi_camera_legacy", + variables: ["board_config_camera_legacy_kernel"], + properties: ["cmd"], +} + +soong_config_string_variable { + name: "board_config_camera_legacy_kernel", + values: ["enabled", "disabled"], +} + +mmi_camera_legacy_genrule_defaults { + name: "mmi_kernel_headers_cmdrules_arm", + soong_config_variables: { + board_config_camera_legacy_kernel: { + disabled: { + cmd: "python3 $(location kernel_headers.py) " + + kernel_headers_verbose + + "--header_arch arm " + + "--gen_dir $(genDir) " + + "--arch_asm_kbuild $(location arch/arm/include/uapi/asm/Kbuild) " + + "--arch_include_uapi $(locations arch/arm/include/uapi/**/*.h) " + + "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + + "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild) " + + "headers " + + "--old_gen_headers_bp $(location gen_headers_arm.bp) " + + "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm) " + + "--version_makefile $(location Makefile) " + + "--arch_syscall_tool $(location arch/arm/tools/syscallhdr.sh) " + + "--arch_syscall_tbl $(location arch/arm/tools/syscall.tbl) " + + "--headers_install $(location headers_install.sh) " + + "--unifdef $(location unifdef) " + + "--include_uapi $(locations include/uapi/**/*.h)", + }, + enabled: { + cmd: "python3 $(location kernel_headers.py) " + + kernel_headers_verbose + + "--header_arch arm " + + "--gen_dir $(genDir) " + + "--arch_asm_kbuild $(location arch/arm/include/uapi/asm/Kbuild) " + + "--arch_include_uapi $(locations arch/arm/include/uapi/**/*.h) " + + "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + + "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild) " + + "headers " + + "--old_gen_headers_bp $(location gen_headers_arm.bp) " + + "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm) " + + "--version_makefile $(location Makefile) " + + "--arch_syscall_tool $(location arch/arm/tools/syscallhdr.sh) " + + "--arch_syscall_tbl $(location arch/arm/tools/syscall.tbl) " + + "--headers_install $(location headers_install.sh) " + + "--unifdef $(location unifdef) " + + "--include_uapi $(locations include/uapi/**/*.h) " + + "--camera_legacy ", + }, + }, + }, +} + +mmi_camera_legacy_genrule_defaults { + name: "mmi_kernel_headers_cmdrules_arm64", + soong_config_variables: { + board_config_camera_legacy_kernel: { + disabled: { + cmd: "python3 $(location kernel_headers.py) " + + kernel_headers_verbose + + "--header_arch arm64 " + + "--gen_dir $(genDir) " + + "--arch_asm_kbuild $(location arch/arm64/include/uapi/asm/Kbuild) " + + "--arch_include_uapi $(locations arch/arm64/include/uapi/**/*.h) " + + "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + + "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild) " + + "headers " + + "--old_gen_headers_bp $(location gen_headers_arm64.bp) " + + "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm64) " + + "--version_makefile $(location Makefile) " + + "--headers_install $(location headers_install.sh) " + + "--unifdef $(location unifdef) " + + "--include_uapi $(locations include/uapi/**/*.h)", + }, + enabled: { + cmd: "python3 $(location kernel_headers.py) " + + kernel_headers_verbose + + "--header_arch arm64 " + + "--gen_dir $(genDir) " + + "--arch_asm_kbuild $(location arch/arm64/include/uapi/asm/Kbuild) " + + "--arch_include_uapi $(locations arch/arm64/include/uapi/**/*.h) " + + "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + + "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild) " + + "headers " + + "--old_gen_headers_bp $(location gen_headers_arm64.bp) " + + "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm64) " + + "--version_makefile $(location Makefile) " + + "--headers_install $(location headers_install.sh) " + + "--unifdef $(location unifdef) " + + "--include_uapi $(locations include/uapi/**/*.h) " + + "--camera_legacy ", + }, + }, + }, +} + cc_library_headers { name: "qti_kernel_headers", arch: { diff --git a/Makefile b/Makefile index 8e0f6cfd1ee1..ccd36a0ea656 100644 --- a/Makefile +++ b/Makefile @@ -1334,7 +1334,13 @@ PHONY += archheaders archscripts hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj +ifeq ($(BOARD_CONFIG_CAMERA_KERNEL_NAME),) techpack-dirs := $(shell find $(srctree)/techpack -maxdepth 1 -mindepth 1 -type d -not -name ".*") +else +techpack-dirs := $(shell find $(srctree)/techpack -maxdepth 1 -mindepth 1 -type d -not -name ".*"\ + | grep -v camera) +techpack-dirs += $(shell find $(srctree)/techpack -maxdepth 2 -mindepth 2 -name "$(BOARD_CONFIG_CAMERA_KERNEL_NAME)") +endif techpack-dirs := $(subst $(srctree)/,,$(techpack-dirs)) PHONY += headers diff --git a/gen_headers_arm.bp b/gen_headers_arm.bp index 05661be1f7a8..525d83fa016a 100644 --- a/gen_headers_arm.bp +++ b/gen_headers_arm.bp @@ -1064,22 +1064,6 @@ genrule { ":qti_generate_gen_headers_arm", ], exclude_srcs: gen_headers_exclude_srcs_arm, - cmd: "python3 $(location kernel_headers.py) " + - kernel_headers_verbose + - "--header_arch arm " + - "--gen_dir $(genDir) " + - "--arch_asm_kbuild $(location arch/arm/include/uapi/asm/Kbuild) " + - "--arch_include_uapi $(locations arch/arm/include/uapi/**/*.h) " + - "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + - "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild) " + - "headers " + - "--old_gen_headers_bp $(location gen_headers_arm.bp) " + - "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm) " + - "--version_makefile $(location Makefile) " + - "--arch_syscall_tool $(location arch/arm/tools/syscallhdr.sh) " + - "--arch_syscall_tbl $(location arch/arm/tools/syscall.tbl) " + - "--headers_install $(location headers_install.sh) " + - "--unifdef $(location unifdef) " + - "--include_uapi $(locations include/uapi/**/*.h)", out: ["linux/version.h"] + gen_headers_out_arm, + defaults: ["mmi_kernel_headers_cmdrules_arm"], } diff --git a/gen_headers_arm64.bp b/gen_headers_arm64.bp index bee9c6226a0e..b2130898935f 100644 --- a/gen_headers_arm64.bp +++ b/gen_headers_arm64.bp @@ -1058,20 +1058,6 @@ genrule { ":qti_generate_gen_headers_arm64", ], exclude_srcs: gen_headers_exclude_srcs_arm64, - cmd: "python3 $(location kernel_headers.py) " + - kernel_headers_verbose + - "--header_arch arm64 " + - "--gen_dir $(genDir) " + - "--arch_asm_kbuild $(location arch/arm64/include/uapi/asm/Kbuild) " + - "--arch_include_uapi $(locations arch/arm64/include/uapi/**/*.h) " + - "--techpack_include_uapi $(locations techpack/*/include/uapi/*/**/*.h) " + - "--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild) " + - "headers " + - "--old_gen_headers_bp $(location gen_headers_arm64.bp) " + - "--new_gen_headers_bp $(location :qti_generate_gen_headers_arm64) " + - "--version_makefile $(location Makefile) " + - "--headers_install $(location headers_install.sh) " + - "--unifdef $(location unifdef) " + - "--include_uapi $(locations include/uapi/**/*.h)", out: ["linux/version.h"] + gen_headers_out_arm64, + defaults: ["mmi_kernel_headers_cmdrules_arm64"], } diff --git a/kernel_headers.py b/kernel_headers.py index 27ef474957fd..1d482338a296 100644 --- a/kernel_headers.py +++ b/kernel_headers.py @@ -754,7 +754,7 @@ def gen_headers( verbose, header_arch, gen_dir, arch_asm_kbuild, asm_generic_kbuild, module_dir, old_gen_headers_bp, new_gen_headers_bp, version_makefile, arch_syscall_tool, arch_syscall_tbl, headers_install, unifdef, include_uapi, - arch_include_uapi, techpack_include_uapi): + arch_include_uapi, techpack_include_uapi, camera_legacy): """Generate the kernel headers. This script generates the version.h file, the arch-specific headers including @@ -781,7 +781,6 @@ def gen_headers( Return: The number of errors encountered. """ - if headers_diff(old_gen_headers_bp, new_gen_headers_bp): print('error: gen_headers blueprints file is out of date, suggested fix:') print('#######Please add or remove the above mentioned headers from %s' % (old_gen_headers_bp)) @@ -813,6 +812,10 @@ def gen_headers( arch_uapi_include_prefix, h): error_count += 1 + if camera_legacy == True: + legacy_product = os.getenv('TARGET_PRODUCT').split("_", 1)[0] + techpack_include_uapi = [i.replace('techpack/camera','techpack/camera-legacy/' + legacy_product) for i in techpack_include_uapi] + for h in techpack_include_uapi: techpack_uapi_include_prefix = os.path.join(h.split('/include/uapi')[0], 'include', 'uapi') + os.sep if not run_headers_install( @@ -952,6 +955,11 @@ def main(): required=True, nargs='*', help='The list of include/uapi header files.') + parser_headers.add_argument( + '--camera_legacy', + default=False, + action='store_true', + help='If set, define the camera legacy folder being used. By default, it\'s disabled.') args = parser.parse_args() @@ -1002,7 +1010,7 @@ def main(): args.asm_generic_kbuild, module_dir, args.old_gen_headers_bp, args.new_gen_headers_bp, args.version_makefile, args.arch_syscall_tool, args.arch_syscall_tbl, args.headers_install, args.unifdef, args.include_uapi, args.arch_include_uapi, - args.techpack_include_uapi) + args.techpack_include_uapi, args.camera_legacy) print('error: unknown mode: %s' % args.mode) return 1