Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(227)

Unified Diff: native_client_sdk/src/build_tools/dsc_info.py

Issue 61763014: Add build target for nacl_io from the NaCl SDK. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Unhook from all.gyp Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/build_tools/dsc_info.py
diff --git a/native_client_sdk/src/build_tools/dsc_info.py b/native_client_sdk/src/build_tools/dsc_info.py
new file mode 100755
index 0000000000000000000000000000000000000000..00fed64bb1bea0644bb15b722cde0d3a11cff068
--- /dev/null
+++ b/native_client_sdk/src/build_tools/dsc_info.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Extracts information from a library.dsc file."""
+
+import optparse
+import os
+import sys
+
+import parse_dsc
+
+def Error(msg):
+ print >> sys.stderr, 'dsc_info: msg'
binji 2013/11/12 19:41:42 'dsc_info: %s' % msg
+ sys.exit(1)
+
binji 2013/11/12 19:41:42 nit: two lines between top-level functions
+def FindTarget(tree, target_name):
+ targets = tree['TARGETS']
+ for target in targets:
+ if target['NAME'] == target_name:
+ return target
+ Error('Target %s not found' % target_name)
+
+def GetSources(lib_dir, tree, target_name):
+ result = []
+ target = FindTarget(tree, target_name)
+ for filename in target['SOURCES']:
+ result.append('/'.join([lib_dir, filename]))
+ return result
+
+def DoMain(argv):
binji 2013/11/12 19:41:42 we usually just have: def main(args): and pass a
+ "Entry point for gyp's pymod_do_main command."
+ parser = optparse.OptionParser(usage='%prog [OPTIONS] LIB_DIR')
+ parser.add_option('-s', '--sources',
+ help='Print a list of source for the target',
+ action='store_true', default=False)
+ parser.add_option('-t', '--target',
binji 2013/11/12 19:41:42 use positional args for this instead, and have a o
+ help='Target to display information for')
+ options, args = parser.parse_args(argv)
+ if len(args) != 1:
+ parser.error('Wrong numer of arguments')
binji 2013/11/12 19:41:42 sp: number
+ lib_dir = args[0]
+ tree = parse_dsc.LoadProject(os.path.join(lib_dir, 'library.dsc'))
+ if options.sources:
+ if not options.target:
+ parser.error('Missing --target')
+ return '\n'.join(GetSources(lib_dir, tree, options.target))
+ parser.error('No action specified')
+
+def main(argv):
+ print DoMain(argv[1:])
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv))
binji 2013/11/12 19:41:42 for consistency, please add KeyboardInterrupt exce

Powered by Google App Engine
This is Rietveld 408576698