import sys
sys.dont_write_bytecode = True
+import os
import argparse
import json
from kconfig.annotations import Annotation, KConfig
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',
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')
do_check(args)
elif args.autocomplete:
do_autocomplete(args)
+ elif args.source:
+ do_source(args)
else:
do_query(args)