summaryrefslogtreecommitdiff
path: root/kernel_headers.py
diff options
context:
space:
mode:
Diffstat (limited to 'kernel_headers.py')
-rw-r--r--kernel_headers.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/kernel_headers.py b/kernel_headers.py
index 5dfaadc0c955..7a7660cfa531 100644
--- a/kernel_headers.py
+++ b/kernel_headers.py
@@ -478,6 +478,81 @@ def find_out(verbose, module_dir, prefix, rel_glob, excludes, outs):
return error_count
+def scan_no_export_headers(verbose, module_dir, prefix):
+ """Scan include/uapi kbuild for no-export-headers
+
+ This function processes the Kbuild file to scan for no-export files that
+ should not export to usr/include/uapi which is identified by adding
+ to the no-export-headers make variable.
+
+ Args:
+ verbose: Set True to print progress messages.
+ module_dir: The root directory of the kernel source.
+ prefix: The prefix with in the kernel source tree to search for headers.
+ Return:
+ lists of no-export-headers.
+ """
+
+ no_export_headers_re = re.compile(r'no-export-headers\s*\+=\s*(\S+)')
+ header_re = re.compile(r'include/uapi/')
+ full_dirs_ = os.path.join(module_dir, prefix)
+ full_dirs = [full_dirs_]
+
+ if verbose:
+ print('scan_no_export_headers: processing [%s]' % full_dirs)
+
+ full_srcs = []
+ no_export_headers_lists = []
+
+ while full_dirs:
+ full_dir = full_dirs.pop(0)
+ items = sorted(os.listdir(full_dir))
+
+ for item in items:
+ full_item = os.path.join(full_dir, item)
+
+ if os.path.isdir(full_item):
+ full_dirs.append(full_item)
+ continue
+
+ if (full_item.find('Kbuild') != -1):
+ full_srcs.append(full_item)
+
+ for full_src in full_srcs:
+ with open(full_src, 'r') as f:
+ while True:
+ line = f.readline()
+
+ if not line:
+ break
+
+ line = line.rstrip()
+
+ match = no_export_headers_re.match(line)
+
+ if match:
+ if verbose:
+ print('scan_no_export_headers: matched [%s]' % line)
+
+ if (match.group(1) == "kvm.h" or
+ match.group(1) == "kvm_para.h" or
+ match.group(1) == "a.out.h"):
+ continue
+
+ (full_src_dir_name, full_src_base_name) = full_src.split('include/uapi/')
+ no_export_header_file_name = os.path.join(os.path.dirname(full_src_base_name),match.group(1))
+
+ if verbose:
+ print('scan_no_export_headers: no_export_header_file_name = ',no_export_header_file_name)
+
+ no_export_headers_lists.append(no_export_header_file_name)
+ continue
+
+ if verbose:
+ for x in no_export_headers_lists:
+ print('scan_no_export_headers: no_export_headers_lists [%s]' % x)
+
+ return no_export_headers_lists
def gen_blueprints(
verbose, header_arch, gen_dir, arch_asm_kbuild, asm_generic_kbuild, module_dir,
@@ -533,6 +608,15 @@ def gen_blueprints(
if header_arch == "arm64":
exclude_srcs = ['linux/a.out.h', 'linux/kvm_para.h']
+ no_export_headers_lists = scan_no_export_headers(verbose, module_dir, generic_prefix)
+
+ for no_export_headers_list in no_export_headers_lists:
+ exclude_srcs.append(no_export_headers_list)
+
+ if verbose:
+ for x in exclude_srcs:
+ print('gen_blueprints : exclude_srcs [%s]' % x)
+
# Scan the arch_asm_kbuild file for files that need to be generated and those
# that are generic (i.e., need to be wrapped).