diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-14 03:08:12 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-14 03:08:12 +0000 |
commit | 8e43f26413194b1deecb1cfc14bb046cf84c9aa7 (patch) | |
tree | ee1eb25ae09cda0134fe9275f265934197fec1a2 | |
parent | 56a2bf61dab7c421af89a17f21705402b503e1ff (diff) | |
parent | 9e62edd92976437c5b3a0048510b362f91ebea10 (diff) | |
download | configs-8e43f26413194b1deecb1cfc14bb046cf84c9aa7.tar.gz |
Snap for 8451773 from 9e62edd92976437c5b3a0048510b362f91ebea10 to tm-qpr1-release
Change-Id: I042783d4fc59d183b9be2e602cf95b8dba17171d
-rw-r--r-- | tools/Android.bp | 9 | ||||
-rwxr-xr-x | tools/kconfig_xml_fixup.py | 65 |
2 files changed, 29 insertions, 45 deletions
diff --git a/tools/Android.bp b/tools/Android.bp index 4149318..016775a 100644 --- a/tools/Android.bp +++ b/tools/Android.bp @@ -10,13 +10,4 @@ python_binary_host { srcs: [ "kconfig_xml_fixup.py", ], - - version: { - py2: { - enabled: true, - }, - py3: { - enabled: false, - }, - }, } diff --git a/tools/kconfig_xml_fixup.py b/tools/kconfig_xml_fixup.py index d833a1a..bbdbf41 100755 --- a/tools/kconfig_xml_fixup.py +++ b/tools/kconfig_xml_fixup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # The format of the kernel configs in the framework compatibility matrix # has a couple properties that would make it confusing or cumbersome to @@ -24,47 +24,40 @@ import re import sys def fixup(args): - source_f = open(args.input) or die ("Could not open %s" % args.input) - - # The first line of the conditional xml has the tag containing - # the kernel min LTS version. - line = source_f.readline() - exp_re = re.compile(r"^<kernel minlts=\"(\d+).(\d+).(\d+)\"\s+/>") - exp_match = re.match(exp_re, line) - assert exp_match, "Malformatted kernel conditional config file.\n" - - major = exp_match.group(1) - minor = exp_match.group(2) - tiny = exp_match.group(3) + with open(args.input) as source_f: + # The first line of the conditional xml has the tag containing + # the kernel min LTS version. + line = source_f.readline() + exp_re = re.compile(r"^<kernel minlts=\"(\d+).(\d+).(\d+)\"\s+/>") + exp_match = re.match(exp_re, line) + assert exp_match, "Malformatted kernel conditional config file.\n" - if args.output_version: - version_f = (open(args.output_version, "w+") or - die("Could not open version file")) - version_f.write("{}.{}.{}".format(major, minor, tiny)) - version_f.close() + major = exp_match.group(1) + minor = exp_match.group(2) + tiny = exp_match.group(3) - if args.output_matrix: - dest_f = (open(args.output_matrix, "w+") or - die("Could not open destination file")) - dest_f.write("<compatibility-matrix version=\"1.0\" type=\"framework\">\n") + if args.output_version: + with open(args.output_version, "w+") as version_f: + version_f.write("{}.{}.{}".format(major, minor, tiny)) - # First <kernel> must not have <condition> for libvintf backwards compatibility. - dest_f.write("<kernel version=\"{}.{}.{}\" />".format(major, minor, tiny)) + if args.output_matrix: + with open(args.output_matrix, "w+") as dest_f: + dest_f.write("<compatibility-matrix version=\"1.0\" type=\"framework\">\n") - line = source_f.readline() - while line: - line = line.replace("<value type=\"bool\">", - "<value type=\"tristate\">") - line = line.replace("<group>", - "<kernel version=\"{}.{}.{}\">".format(major, minor, tiny)) - line = line.replace("</group>", "</kernel>") - dest_f.write(line) - line = source_f.readline() + # First <kernel> must not have <condition> for libvintf backwards compatibility. + dest_f.write("<kernel version=\"{}.{}.{}\" />".format(major, minor, tiny)) - dest_f.write("</compatibility-matrix>") - dest_f.close() + line = source_f.readline() + while line: + line = line.replace("<value type=\"bool\">", + "<value type=\"tristate\">") + line = line.replace("<group>", + "<kernel version=\"{}.{}.{}\">".format(major, minor, tiny)) + line = line.replace("</group>", "</kernel>") + dest_f.write(line) + line = source_f.readline() - source_f.close() + dest_f.write("</compatibility-matrix>") if __name__ == '__main__': parser = argparse.ArgumentParser(description=__doc__) |