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

Side by Side Diff: build/env_dump.py

Issue 23618049: Helper script which can source a bash script and dump environment as JSON. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/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.
5
6 # Output environment setup by src/build/android/envsetup.sh to json file.
7
8 import json
9 import optparse
10 import os
11 import subprocess
12 import sys
13
14
15 def main():
16 parser = optparse.OptionParser()
17 parser.add_option('-f', '--output-json',
18 help='Output json file to create with environment.')
19 parser.add_option(
20 '-d', '--dump-mode', action='store_true',
21 help='Dump the environment to stdout or file and exit immediately.')
22
23 options, args = parser.parse_args()
iannucci 2013/09/14 00:08:36 maybe just do if options.output_json is None: p
24 if options.dump_mode:
25 if options.output_json:
26 with open(options.output_json, 'w') as f:
27 json.dump(dict(os.environ), f)
28 else:
29 print json.dumps(dict(os.environ))
30 return
iannucci 2013/09/14 00:08:36 let's do an else: instead of the early return
31
32 if not options.output_json:
33 parser.error('Requires --output-json or --dump-mode argument.')
34
35 envsetup_cmd = ' '.join(args)
36 full_cmd = [
37 'bash', '-c',
38 '. %s; ./%s -d -f %s' % (envsetup_cmd, __file__, options.output_json)]
39 ret = subprocess.call(full_cmd)
40 if ret:
41 sys.exit('Error running %s and dumping env', envsetup_cmd)
42
43
44 if __name__ == '__main__':
45 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698