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

Side by Side Diff: tools/only_in_release_mode.py

Issue 350483003: Build Tools Cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: more fixes as reviewed by ricow Created 6 years, 5 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 | « tools/make_version.py ('k') | tools/publish_pkg.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 """ 7 """
8 Wrapper around a build action that should only be executed in release mode. 8 Wrapper around a build action that should only be executed in release mode.
9 9
10 The mode is defined via an environment varible DART_BUILD_MODE. 10 The mode is defined via an environment variable DART_BUILD_MODE.
11 11
12 The arguments to the script are: 12 The arguments to the script are:
13 13
14 only_in_release_mode.py files... -- command arguments... 14 only_in_release_mode.py files... -- command arguments...
15 15
16 If mode is not 'release', the script will create the files listed 16 If mode is not 'release', the script will create the files listed
17 before --. If mode is release, the script will execute the command 17 before --. If mode is release, the script will execute the command
18 after --. 18 after --.
19 """ 19 """
20 20
21 import os 21 import os
22 import subprocess 22 import subprocess
23 import sys 23 import sys
24 24
25 25
26 def Main(): 26 def Main():
27 # Throws an error if '--' is not in the argument list. 27 # Throws an error if '--' is not in the argument list.
28 separator_index = sys.argv.index('--') 28 separator_index = sys.argv.index('--')
29 outputs = sys.argv[1:separator_index] 29 outputs = sys.argv[1:separator_index]
30 arguments = sys.argv[separator_index + 1:] 30 arguments = sys.argv[separator_index + 1:]
31 arguments[0] = os.path.normpath(arguments[0]) 31 arguments[0] = os.path.normpath(arguments[0])
32 mode = os.getenv('DART_BUILD_MODE', default='release') 32 mode = os.getenv('DART_BUILD_MODE', 'release')
33 if mode != 'release': 33 if mode != 'release':
34 print >> sys.stderr, 'Not running %s in mode=%s' % (arguments, mode) 34 print >> sys.stderr, 'Not running %s in mode=%s' % (arguments, mode)
35 for output in outputs: 35 for output in outputs:
36 with open(output, 'w'): 36 with open(output, 'w'):
37 # Create an empty file to ensure that we don't rerun this 37 # Create an empty file to ensure that we don't rerun this
38 # command unnecessarily. 38 # command unnecessarily.
39 pass 39 pass
40 return 0 40 return 0
41 else: 41 else:
42 try: 42 try:
43 subprocess.check_call(arguments) 43 subprocess.check_call(arguments)
44 except subprocess.CalledProcessError as e: 44 except subprocess.CalledProcessError as e:
45 return e.returncode 45 return e.returncode
46 return 0 46 return 0
47 47
48 48
49 if __name__ == '__main__': 49 if __name__ == '__main__':
50 sys.exit(Main()) 50 sys.exit(Main())
OLDNEW
« no previous file with comments | « tools/make_version.py ('k') | tools/publish_pkg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698