kernel_headers: Fix headers not detected in incremental builds

Currently the Soong logic doesn't kick in if a change updates
headers but doesn't update gen_headers_arm*.bp files for
incremental builds. Fix the issue by making inputs to the
kernel_headers.py script as variables instead of a list.

Change-Id: I9737f6d655848458bfda70b8c6f4d9aa896a98fc
Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org>
Signed-off-by: Prateek Sood <prsood@codeaurora.org>
tirimbino
Rishabh Bhatnagar 5 years ago committed by Prateek Sood
parent 83b2445d32
commit b7f14559bc
  1. 35
      gen_headers_arm.bp
  2. 35
      gen_headers_arm64.bp
  3. 60
      kernel_headers.py

@ -1,7 +1,20 @@
// ***** DO NOT EDIT *****
// This file is generated by kernel_headers.py
gen_headers_arm = [
gen_headers_srcs_arm = [
"arch/arm/include/uapi/asm/Kbuild",
"include/uapi/asm-generic/Kbuild.asm",
"Makefile",
"arch/arm/tools/syscall.tbl",
"include/uapi/**/*.h",
"arch/arm/include/uapi/**/*.h",
]
gen_headers_exclude_srcs_arm = [
"include/uapi/linux/a.out.h",
]
gen_headers_out_arm = [
// Matching generated-y:
@ -952,7 +965,8 @@ genrule {
// checked later to ensure that it matches the checked-
// in version (this file).
name: "qti_generate_gen_headers_arm",
srcs: ["arch/arm/include/uapi/asm/Kbuild", "include/uapi/asm-generic/Kbuild.asm", "arch/arm/include/uapi/**/*.h"],
srcs: gen_headers_srcs_arm,
exclude_srcs: gen_headers_exclude_srcs_arm,
tool_files: ["kernel_headers.py"],
cmd: "python3 $(location kernel_headers.py) " +
kernel_headers_verbose +
@ -961,7 +975,8 @@ genrule {
"--arch_asm_kbuild $(location arch/arm/include/uapi/asm/Kbuild) " +
"--arch_include_uapi $(locations arch/arm/include/uapi/**/*.h) " +
"--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild.asm) " +
"blueprints",
"blueprints " +
"# $(in)",
out: ["gen_headers_arm.bp"],
}
@ -972,19 +987,11 @@ genrule {
"kernel_headers.py",
"arch/arm/tools/syscallhdr.sh",
],
srcs: [
"arch/arm/include/uapi/asm/Kbuild",
"include/uapi/asm-generic/Kbuild.asm",
srcs: gen_headers_srcs_arm +[
"gen_headers_arm.bp",
":qti_generate_gen_headers_arm",
"Makefile",
"arch/arm/tools/syscall.tbl",
"include/uapi/**/*.h",
"arch/arm/include/uapi/**/*.h",
],
exclude_srcs: [
"include/uapi/linux/a.out.h",
],
exclude_srcs: gen_headers_exclude_srcs_arm,
cmd: "python3 $(location kernel_headers.py) " +
kernel_headers_verbose +
"--header_arch arm " +
@ -1000,5 +1007,5 @@ genrule {
"--arch_syscall_tbl $(location arch/arm/tools/syscall.tbl) " +
"--headers_install $(location headers_install.sh) " +
"--include_uapi $(locations include/uapi/**/*.h)",
out: ["linux/version.h"] + gen_headers_arm,
out: ["linux/version.h"] + gen_headers_out_arm,
}

@ -1,7 +1,20 @@
// ***** DO NOT EDIT *****
// This file is generated by kernel_headers.py
gen_headers_arm64 = [
gen_headers_srcs_arm64 = [
"arch/arm64/include/uapi/asm/Kbuild",
"include/uapi/asm-generic/Kbuild.asm",
"Makefile",
"include/uapi/**/*.h",
"arch/arm64/include/uapi/**/*.h",
]
gen_headers_exclude_srcs_arm64 = [
"include/uapi/linux/a.out.h",
"include/uapi/linux/kvm_para.h",
]
gen_headers_out_arm64 = [
// Matching generic-y:
@ -946,7 +959,8 @@ genrule {
// checked later to ensure that it matches the checked-
// in version (this file).
name: "qti_generate_gen_headers_arm64",
srcs: ["arch/arm64/include/uapi/asm/Kbuild", "include/uapi/asm-generic/Kbuild.asm", "arch/arm64/include/uapi/**/*.h"],
srcs: gen_headers_srcs_arm64,
exclude_srcs: gen_headers_exclude_srcs_arm64,
tool_files: ["kernel_headers.py"],
cmd: "python3 $(location kernel_headers.py) " +
kernel_headers_verbose +
@ -955,7 +969,8 @@ genrule {
"--arch_asm_kbuild $(location arch/arm64/include/uapi/asm/Kbuild) " +
"--arch_include_uapi $(locations arch/arm64/include/uapi/**/*.h) " +
"--asm_generic_kbuild $(location include/uapi/asm-generic/Kbuild.asm) " +
"blueprints",
"blueprints " +
"# $(in)",
out: ["gen_headers_arm64.bp"],
}
@ -965,19 +980,11 @@ genrule {
tool_files: [
"kernel_headers.py",
],
srcs: [
"arch/arm64/include/uapi/asm/Kbuild",
"include/uapi/asm-generic/Kbuild.asm",
srcs: gen_headers_srcs_arm64 +[
"gen_headers_arm64.bp",
":qti_generate_gen_headers_arm64",
"Makefile",
"include/uapi/**/*.h",
"arch/arm64/include/uapi/**/*.h",
],
exclude_srcs: [
"include/uapi/linux/a.out.h",
"include/uapi/linux/kvm_para.h",
],
exclude_srcs: gen_headers_exclude_srcs_arm64,
cmd: "python3 $(location kernel_headers.py) " +
kernel_headers_verbose +
"--header_arch arm64 " +
@ -991,5 +998,5 @@ genrule {
"--version_makefile $(location Makefile) " +
"--headers_install $(location headers_install.sh) " +
"--include_uapi $(locations include/uapi/**/*.h)",
out: ["linux/version.h"] + gen_headers_arm64,
out: ["linux/version.h"] + gen_headers_out_arm64,
}

@ -522,7 +522,7 @@ def gen_blueprints(
arch_prefix = os.path.join('arch', header_arch, generic_prefix)
generic_src = os.path.join(generic_prefix, rel_glob)
arch_src = os.path.join(arch_prefix, rel_glob)
techpack_src = 'techpack/*'
techpack_src = os.path.join('techpack/*',generic_prefix, '*',rel_glob)
# Excluded sources, architecture specific.
exclude_srcs = []
@ -561,7 +561,27 @@ def gen_blueprints(
f.write('// ***** DO NOT EDIT *****\n')
f.write('// This file is generated by %s\n' % kernel_headers_py)
f.write('\n')
f.write('gen_headers_%s = [\n' % header_arch)
f.write('gen_headers_srcs_%s = [\n' % header_arch)
f.write(' "%s",\n' % rel_arch_asm_kbuild)
f.write(' "%s",\n' % rel_asm_generic_kbuild)
f.write(' "%s",\n' % makefile)
if header_arch == "arm":
f.write(' "%s",\n' % arm_syscall_tbl)
f.write(' "%s",\n' % generic_src)
f.write(' "%s",\n' % arch_src)
f.write(']\n')
f.write('\n')
if exclude_srcs:
f.write('gen_headers_exclude_srcs_%s = [\n' % header_arch)
for h in exclude_srcs:
f.write(' "%s",\n' % os.path.join(generic_prefix, h))
f.write(']\n')
f.write('\n')
f.write('gen_headers_out_%s = [\n' % header_arch)
if generated_list:
f.write('\n')
@ -616,7 +636,10 @@ def gen_blueprints(
f.write(' // checked later to ensure that it matches the checked-\n')
f.write(' // in version (this file).\n')
f.write(' name: "%s",\n' % gen_blueprints_module_name)
f.write(' srcs: ["%s", "%s", "%s"],\n' % (rel_arch_asm_kbuild, rel_asm_generic_kbuild, arch_src))
f.write(' srcs: gen_headers_srcs_%s,\n' % header_arch)
if exclude_srcs:
f.write(' exclude_srcs: gen_headers_exclude_srcs_%s,\n' % header_arch)
f.write(' tool_files: ["kernel_headers.py"],\n')
f.write(' cmd: "python3 $(location kernel_headers.py) " +\n')
f.write(' kernel_headers_verbose +\n')
@ -625,7 +648,8 @@ def gen_blueprints(
f.write(' "--arch_asm_kbuild $(location %s) " +\n' % rel_arch_asm_kbuild)
f.write(' "--arch_include_uapi $(locations %s) " +\n' % arch_src)
f.write(' "--asm_generic_kbuild $(location %s) " +\n' % rel_asm_generic_kbuild)
f.write(' "blueprints",\n')
f.write(' "blueprints " +\n')
f.write(' "# $(in)",\n')
f.write(' out: ["gen_headers_%s.bp"],\n' % header_arch)
f.write('}\n')
f.write('\n')
@ -640,25 +664,13 @@ def gen_blueprints(
f.write(' "%s",\n' % arm_syscall_tool)
f.write(' ],\n')
f.write(' srcs: [\n')
f.write(' "%s",\n' % rel_arch_asm_kbuild)
f.write(' "%s",\n' % rel_asm_generic_kbuild)
f.write(' srcs: gen_headers_srcs_%s +[\n' % header_arch)
f.write(' "%s",\n' % old_gen_headers_bp)
f.write(' ":%s",\n' % gen_blueprints_module_name)
f.write(' "%s",\n' % makefile)
if header_arch == "arm":
f.write(' "%s",\n' % arm_syscall_tbl)
f.write(' "%s",\n' % generic_src)
f.write(' "%s",\n' % arch_src)
f.write(' ],\n')
if exclude_srcs:
f.write(' exclude_srcs: [\n')
for h in exclude_srcs:
f.write(' "%s",\n' % os.path.join(generic_prefix, h))
f.write(' ],\n')
f.write(' exclude_srcs: gen_headers_exclude_srcs_%s,\n' % header_arch)
f.write(' cmd: "python3 $(location %s) " +\n' % kernel_headers_py)
f.write(' kernel_headers_verbose +\n')
@ -678,14 +690,14 @@ def gen_blueprints(
f.write(' "--headers_install $(location %s) " +\n' % headers_install_sh)
f.write(' "--include_uapi $(locations %s)",\n' % generic_src)
f.write(' out: ["linux/version.h"] + gen_headers_%s,\n' % header_arch)
f.write(' out: ["linux/version.h"] + gen_headers_out_%s,\n' % header_arch)
f.write('}\n')
return 0
def parse_bp_for_headers(file_name, headers):
parsing_headers = False
pattern = re.compile("gen_headers_[a-zA-Z0-9]+\s*=\s*\[\s*")
pattern = re.compile("gen_headers_out_[a-zA-Z0-9]+\s*=\s*\[\s*")
with open(file_name, 'r') as f:
for line in f:
line = line.strip()
@ -949,13 +961,13 @@ def main():
if args.verbose:
print('module_dir [%s]' % module_dir)
# Get list of techpack uapi headers to be exported from techpack/* directories.
techpack_uapi = extract_techpack_uapi_headers(args.verbose, module_dir)
techpack_include_uapi = []
if args.mode == 'blueprints':
return gen_blueprints(
args.verbose, args.header_arch, args.gen_dir, args.arch_asm_kbuild,
args.asm_generic_kbuild, module_dir, rel_arch_asm_kbuild, rel_asm_generic_kbuild, args.arch_include_uapi, techpack_uapi)
args.asm_generic_kbuild, module_dir, rel_arch_asm_kbuild, rel_asm_generic_kbuild, args.arch_include_uapi, techpack_include_uapi)
if args.mode == 'headers':
if args.verbose:
@ -970,7 +982,7 @@ def main():
args.verbose, args.header_arch, args.gen_dir, args.arch_asm_kbuild,
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.include_uapi, args.arch_include_uapi, techpack_uapi)
args.headers_install, args.include_uapi, args.arch_include_uapi, techpack_include_uapi)
print('error: unknown mode: %s' % args.mode)
return 1

Loading…
Cancel
Save