Convert kconfig_xml_fixup to python 3 am: 9cb0c67c72
am: b5867e2adf
am: eb376fd02b
Original change: https://android-review.googlesource.com/c/kernel/configs/+/2061123 Change-Id: I1187a30ce762a7b3de8aa7ab9c18035dcc3ca1bd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
27873243a0
2 changed files with 32 additions and 48 deletions
|
@ -10,13 +10,4 @@ python_binary_host {
|
|||
srcs: [
|
||||
"kconfig_xml_fixup.py",
|
||||
],
|
||||
|
||||
version: {
|
||||
py2: {
|
||||
enabled: true,
|
||||
},
|
||||
py3: {
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
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()
|
||||
|
||||
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")
|
||||
|
||||
# First <kernel> must not have <condition> for libvintf backwards compatibility.
|
||||
dest_f.write("<kernel version=\"{}.{}.{}\" />".format(major, minor, tiny))
|
||||
|
||||
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()
|
||||
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()
|
||||
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"
|
||||
|
||||
dest_f.write("</compatibility-matrix>")
|
||||
dest_f.close()
|
||||
major = exp_match.group(1)
|
||||
minor = exp_match.group(2)
|
||||
tiny = exp_match.group(3)
|
||||
|
||||
source_f.close()
|
||||
if args.output_version:
|
||||
with open(args.output_version, "w+") as version_f:
|
||||
version_f.write("{}.{}.{}".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")
|
||||
|
||||
# First <kernel> must not have <condition> for libvintf backwards compatibility.
|
||||
dest_f.write("<kernel version=\"{}.{}.{}\" />".format(major, minor, tiny))
|
||||
|
||||
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()
|
||||
|
||||
dest_f.write("</compatibility-matrix>")
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
|
|
Loading…
Reference in a new issue