From: Andrea Righi Date: Mon, 5 Dec 2022 17:06:38 +0000 (+0100) Subject: annotations: introduce --source X-Git-Tag: v0.1~45 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=88e27ba6ae7c3add8f6b08009b21e9562774ee6a;p=annotations.git annotations: introduce --source Add an option to jump to the definition of a specific config option in the kernel source code (this requires a prior `make tags` to work). Signed-off-by: Andrea Righi --- diff --git a/annotations b/annotations index c74dbe7..877ee22 100755 --- a/annotations +++ b/annotations @@ -5,6 +5,7 @@ import sys sys.dont_write_bytecode = True +import os import argparse import json from kconfig.annotations import Annotation, KConfig @@ -39,6 +40,8 @@ def make_parser(): help='Write a specific note to a config option in annotations') parser.add_argument('--autocomplete', action='store_true', help='Enable config bash autocomplete: `source <(annotations --autocomplete)`') + parser.add_argument('--source', '-t', action='store_true', + help='Jump to a config definition in the kernel source code') ga = parser.add_argument_group(title='Action').add_mutually_exclusive_group(required=False) ga.add_argument('--write', '-w', action='store', @@ -84,6 +87,18 @@ def do_autocomplete(args): res = (c.removeprefix('CONFIG_') for c in a.search_config()) print('complete -W "{}" annotations'.format(' '.join(res))) +def do_source(args): + if args.config is None: + arg_fail('error: --source requires --config') + if args.config.startswith('CONFIG_'): + config = args.config + else: + config = 'CONFIG_' + args.config + if not os.path.exists('tags'): + print('tags not found in the current directory, try: `make tags`') + exit(1) + os.system(f'vim -t {config}') + def do_note(args): if args.config is None: arg_fail('error: --note requires --config') @@ -235,6 +250,8 @@ def main(): do_check(args) elif args.autocomplete: do_autocomplete(args) + elif args.source: + do_source(args) else: do_query(args)