diff options
author | Yongqin Liu <yongqin.liu@linaro.org> | 2020-08-08 14:32:47 +0800 |
---|---|---|
committer | Yongqin Liu <yongqin.liu@linaro.org> | 2020-08-08 17:15:19 +0800 |
commit | 2c8b8eca5ed8b5ee4754cfc137ae7be5716b04da (patch) | |
tree | 313618f29ebd2c8d118f34f21971ba8e2383c9a8 /tools/extract_kernel.py | |
parent | c4e9bf20ce420e36c075349bbb23ddffffd59363 (diff) |
extract_kernel.py: add support to output compiler information
Test: tested with android-mainline gki kernel from
https://android.googlesource.com/kernel/prebuilts/mainline/arm64/
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Change-Id: Ibf3eeb3679b233cd0d54501d385f442e0c0c34ec
Diffstat (limited to 'tools/extract_kernel.py')
-rwxr-xr-x | tools/extract_kernel.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tools/extract_kernel.py b/tools/extract_kernel.py index 92a647be3c..0046b38faf 100755 --- a/tools/extract_kernel.py +++ b/tools/extract_kernel.py @@ -40,7 +40,7 @@ COMPRESSION_ALGO = ( # LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n"; LINUX_BANNER_PREFIX = b'Linux version ' LINUX_BANNER_REGEX = LINUX_BANNER_PREFIX + \ - r'(?P<release>(?P<version>[0-9]+[.][0-9]+[.][0-9]+).*) \(.*@.*\) \(.*\) .*\n' + r'(?P<release>(?P<version>[0-9]+[.][0-9]+[.][0-9]+).*) \(.*@.*\) \((?P<compiler>.*)\) .*\n' def get_from_release(input_bytes, start_idx, key): @@ -82,6 +82,14 @@ def dump_version(input_bytes): return dump_from_release(input_bytes, "version") +def dump_compiler(input_bytes): + """ + Dump kernel version, w.x.y, from input_bytes. Search for the string + "Linux version " and do pattern matching after it. See LINUX_BANNER_REGEX. + """ + return dump_from_release(input_bytes, "compiler") + + def dump_release(input_bytes): """ Dump kernel release, w.x.y-..., from input_bytes. Search for the string @@ -208,6 +216,13 @@ def main(): nargs='?', type=argparse.FileType('wb'), const=sys.stdout) + parser.add_argument('--output-compiler', + help='If specified, write the compiler information. Use stdout if no file ' + 'is specified.', + metavar='FILE', + nargs='?', + type=argparse.FileType('wb'), + const=sys.stdout) parser.add_argument('--tools', help='Decompression tools to use. If not specified, PATH ' 'is searched.', @@ -234,6 +249,10 @@ def main(): "kernel release in {}".format(args.input.name)): ret = 1 + if not dump_to_file(args.output_compiler, dump_compiler, input_bytes, + "kernel compiler in {}".format(args.input.name)): + ret = 1 + return ret |