Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / native_client_sdk / src / build_tools / dsc_info.py
blob947f52b48c4dc2b8f7af1f09c26181a1c2b64806
1 #!/usr/bin/env python
2 # Copyright 2013 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Extracts information from a library.dsc file."""
8 import argparse
9 import os
10 import sys
12 import parse_dsc
14 def Error(msg):
15 print >> sys.stderr, 'dsc_info: %s' % msg
16 sys.exit(1)
19 def FindTarget(tree, target_name):
20 targets = tree['TARGETS']
21 for target in targets:
22 if target['NAME'] == target_name:
23 return target
24 Error('Target %s not found' % target_name)
27 def GetSources(lib_dir, tree, target_name):
28 result = []
29 target = FindTarget(tree, target_name)
30 for filename in target['SOURCES']:
31 result.append('/'.join([lib_dir, filename]))
32 return result
35 def DoMain(args):
36 """Entry point for gyp's pymod_do_main command."""
37 parser = argparse.ArgumentParser(description=__doc__)
38 # Give a clearer error message when this is used as a module.
39 parser.prog = 'dsc_info'
40 parser.add_argument('-s', '--sources',
41 help='Print a list of source files for the target',
42 action='store_true', default=False)
43 parser.add_argument('-l', '--libdir',
44 help='Directory where the library.dsc file is located',
45 metavar='DIR')
46 parser.add_argument('target')
47 options = parser.parse_args(args)
48 libdir = options.libdir or ''
49 tree = parse_dsc.LoadProject(os.path.join(libdir, 'library.dsc'))
50 if options.sources:
51 return '\n'.join(GetSources(libdir, tree, options.target))
52 parser.error('No action specified')
55 def main(args):
56 print DoMain(args)
59 if __name__ == '__main__':
60 try:
61 sys.exit(main(sys.argv[1:]))
62 except KeyboardInterrupt:
63 Error('interrupted')