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

Unified Diff: build/env_dump.py

Issue 24195006: Dump only salient differences from env_dump.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: redirect envsetup.sh output to /dev/null 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/env_dump.py
diff --git a/build/env_dump.py b/build/env_dump.py
index d6a18c83224cf1d142c1b50b3135b6c056e9fdc4..c896366ec9660c07f4dea1ce8fa2e58fd5af0f2f 100755
--- a/build/env_dump.py
+++ b/build/env_dump.py
@@ -20,27 +20,35 @@ def main():
help='File to dump the environment as JSON into.')
parser.add_option(
'-d', '--dump-mode', action='store_true',
- help='Dump the environment to the file and exit immediately.')
+ help='Dump the environment to sys.stdout and exit immediately.')
options, args = parser.parse_args()
- if not options.output_json:
- parser.error('Requires --output-json option.')
-
if options.dump_mode:
- if args:
- parser.error("Cannot specify args with --dump-mode")
- with open(options.output_json, 'w') as f:
- json.dump(dict(os.environ), f)
+ if args or options.output_json:
+ parser.error('Cannot specify args or --output-json with --dump-mode.')
+ json.dump(dict(os.environ), sys.stdout)
else:
+ if not options.output_json:
+ parser.error('Requires --output-json option.')
+
envsetup_cmd = ' '.join(map(pipes.quote, args))
full_cmd = [
'bash', '-c',
- '. %s; %s -d -f %s' % (envsetup_cmd, os.path.abspath(__file__),
- options.output_json)
+ '. %s > /dev/null; %s -d' % (envsetup_cmd, os.path.abspath(__file__))
]
- ret = subprocess.call(full_cmd)
- if ret:
- sys.exit('Error running %s and dumping env' % envsetup_cmd)
+ try:
+ output = subprocess.check_output(full_cmd)
+ except Exception as e:
+ sys.exit('Error running %s and dumping environment.' % envsetup_cmd)
+
+ env_diff = {}
+ new_env = json.loads(output)
+ for k, val in new_env.items():
+ if k == '_' or (k in os.environ and os.environ[k] == val):
+ continue
+ env_diff[k] = val
+ with open(options.output_json, 'w') as f:
+ json.dump(env_diff, f)
if __name__ == '__main__':
« 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