summaryrefslogtreecommitdiff
path: root/kernel_headers.py
diff options
context:
space:
mode:
authorSiddharth Gupta <sidgup@codeaurora.org>2020-01-29 17:22:38 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2020-06-01 04:53:03 -0700
commita4a4ea7df67a117e6679e9b0c2da368d749a8f69 (patch)
tree2c6202302094919489caf280a8ef4f6f7e176542 /kernel_headers.py
parent04e6f16c0c30ccfc08eb8fa2261d57c611ac802b (diff)
kernel headers: Update comparison logic
Update comparison logic used to figure out the headers that need to be added or removed from the corresponding blueprint file. Change-Id: I1f8eeea9750074d57868593a9693c016644e3682 Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org> Signed-off-by: Rishabh Bhatnagar <rishabhb@codeaurora.org> Signed-off-by: Naitik Bharadiya <bharad@codeaurora.org> Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
Diffstat (limited to 'kernel_headers.py')
-rw-r--r--kernel_headers.py48
1 files changed, 46 insertions, 2 deletions
diff --git a/kernel_headers.py b/kernel_headers.py
index 7a7660cfa531..1dacc4d974a3 100644
--- a/kernel_headers.py
+++ b/kernel_headers.py
@@ -767,6 +767,50 @@ def gen_blueprints(
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*")
+ with open(file_name, 'r') as f:
+ for line in f:
+ line = line.strip()
+ if pattern.match(line):
+ parsing_headers = True
+ continue
+
+ if line.find("]") != -1 and parsing_headers:
+ break
+
+ if not parsing_headers:
+ continue
+
+ if line.find("//") == 0:
+ continue
+
+ headers.add(line[1:-2])
+
+def headers_diff(old_file, new_file):
+ old_headers = set()
+ new_headers = set()
+ diff_detected = False
+
+ parse_bp_for_headers(old_file, old_headers)
+ parse_bp_for_headers(new_file, new_headers)
+
+ diff = old_headers - new_headers
+ if len(diff):
+ diff_detected = True
+ print("Headers to remove:")
+ for x in diff:
+ print("\t{}".format(x))
+
+ diff = new_headers - old_headers
+ if len(diff):
+ diff_detected = True
+ print("Headers to add:")
+ for x in diff:
+ print("\t{}".format(x))
+
+ return diff_detected
def gen_headers(
verbose, header_arch, gen_dir, arch_asm_kbuild, asm_generic_kbuild, module_dir,
@@ -799,9 +843,9 @@ def gen_headers(
The number of errors encountered.
"""
- if not filecmp.cmp(old_gen_headers_bp, new_gen_headers_bp):
+ if headers_diff(old_gen_headers_bp, new_gen_headers_bp):
print('error: gen_headers blueprints file is out of date, suggested fix:')
- print('cp %s %s' % (new_gen_headers_bp, old_gen_headers_bp))
+ print('#######Please add or remove the above mentioned headers from %s' % (old_gen_headers_bp))
print('then re-run the build')
return 1