1# 2# Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3# 4# SPDX-License-Identifier: GPL-2.0-only 5# 6 7''' generate a text file with matched compatible strings from the device tree ''' 8import argparse 9from hardware.config import Config 10from hardware.fdt import FdtParser 11from hardware.utils.rule import HardwareYaml 12 13 14def run(tree: FdtParser, hw_yaml: HardwareYaml, config: Config, 15 args: argparse.Namespace): 16 if not args.compat_strings_out: 17 raise ValueError('You need to specify a compat-strings-out to use compat strings output') 18 chosen = tree.get_kernel_devices() 19 20 compatibles = set() 21 for dev in chosen: 22 compatibles.add(hw_yaml.get_matched_compatible(dev)) 23 24 args.compat_strings_out.write(';'.join(sorted(compatibles)) + ';\n') 25 args.compat_strings_out.close() 26 27 28def add_args(parser): 29 parser.add_argument('--compat-strings-out', 30 help='output file for compat strings list', type=argparse.FileType('w')) 31