blob: 48582ce666729dcb8057332b3b1610463237a0bf [file] [log] [blame]
Eric Fiselier2d9feb52015-03-20 22:09:29 +00001#!/usr/bin/env python
Eric Fiseliera9e91f32016-01-19 21:58:49 +00002#===----------------------------------------------------------------------===##
3#
4# The LLVM Compiler Infrastructure
5#
6# This file is dual licensed under the MIT and the University of Illinois Open
7# Source Licenses. See LICENSE.TXT for details.
8#
9#===----------------------------------------------------------------------===##
10
Eric Fiselier2d9feb52015-03-20 22:09:29 +000011"""
12sym_match - Match all symbols in a list against a list of regexes.
13"""
14from argparse import ArgumentParser
15import sys
Eric Fiselier11477532017-02-09 22:53:14 +000016from libcxx.sym_check import util, match, extract
Eric Fiselier2d9feb52015-03-20 22:09:29 +000017
18
19def main():
20 parser = ArgumentParser(
21 description='Extract a list of symbols from a shared library.')
22 parser.add_argument(
23 '--blacklist', dest='blacklist',
24 type=str, action='store', default=None)
25 parser.add_argument(
26 'symbol_list', metavar='symbol_list', type=str,
27 help='The file containing the old symbol list')
28 parser.add_argument(
29 'regexes', metavar='regexes', default=[], nargs='*',
30 help='The file containing the new symbol list or a library')
31 args = parser.parse_args()
32
33 if not args.regexes and args.blacklist is None:
34 sys.stderr.write('Either a regex or a blacklist must be specified.\n')
35 sys.exit(1)
36 if args.blacklist:
37 search_list = util.read_blacklist(args.blacklist)
38 else:
39 search_list = args.regexes
40
41 symbol_list = util.extract_or_load(args.symbol_list)
42
43 matching_count, report = match.find_and_report_matching(
44 symbol_list, search_list)
45 sys.stdout.write(report)
46 if matching_count != 0:
47 print('%d matching symbols found...' % matching_count)
48
49
50if __name__ == '__main__':
51 main()