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

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 # This script can either source a file and dump the enironment changes done by
7 # it, or just simply dump the current environment as JSON into a file.
8
9 import json
10 import optparse
11 import os
12 import subprocess
13 import sys
14
15
16 def main():
17 parser = optparse.OptionParser()
18 parser.add_option('-f', '--output-json',
19 help='File to dump the environment as JSON into.')
20 parser.add_option(
21 '-d', '--dump-mode', action='store_true',
22 help='Dump the environment to the file and exit immediately.')
23
24 options, args = parser.parse_args()
25 if not options.output_json:
26 parser.error('Requires --output-json option.')
27
28 if options.dump_mode or not args:
29 with open(options.output_json, 'w') as f:
iannucci 2013/09/14 00:23:31 Actually, I would do if options.dump_mode: if a
30 json.dump(dict(os.environ), f)
31 else:
32 envsetup_cmd = ' '.join(args)
33 full_cmd = [
34 'bash', '-c',
35 '. %s; ./%s -d -f %s' % (envsetup_cmd, __file__, options.output_json)]
36 ret = subprocess.call(full_cmd)
37 if ret:
38 sys.exit('Error running %s and dumping env', envsetup_cmd)
39
40
41 if __name__ == '__main__':
42 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