Index: build/env_dump.py |
diff --git a/build/env_dump.py b/build/env_dump.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..6ee994eb07a9a7d269bf893b573d793af879327a |
--- /dev/null |
+++ b/build/env_dump.py |
@@ -0,0 +1,45 @@ |
+#!/usr/bin/python |
+# Copyright 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. |
+ |
+# Output environment setup by src/build/android/envsetup.sh to json file. |
+ |
+import json |
+import optparse |
+import os |
+import subprocess |
+import sys |
+ |
+ |
+def main(): |
+ parser = optparse.OptionParser() |
+ parser.add_option('-f', '--output-json', |
+ help='Output json file to create with environment.') |
+ parser.add_option( |
+ '-d', '--dump-mode', action='store_true', |
+ help='Dump the environment to stdout or file and exit immediately.') |
+ |
+ options, args = parser.parse_args() |
iannucci
2013/09/14 00:08:36
maybe just do
if options.output_json is None:
p
|
+ if options.dump_mode: |
+ if options.output_json: |
+ with open(options.output_json, 'w') as f: |
+ json.dump(dict(os.environ), f) |
+ else: |
+ print json.dumps(dict(os.environ)) |
+ return |
iannucci
2013/09/14 00:08:36
let's do an else: instead of the early return
|
+ |
+ if not options.output_json: |
+ parser.error('Requires --output-json or --dump-mode argument.') |
+ |
+ envsetup_cmd = ' '.join(args) |
+ full_cmd = [ |
+ 'bash', '-c', |
+ '. %s; ./%s -d -f %s' % (envsetup_cmd, __file__, options.output_json)] |
+ ret = subprocess.call(full_cmd) |
+ if ret: |
+ sys.exit('Error running %s and dumping env', envsetup_cmd) |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(main()) |