OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 # | |
3 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
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. | |
6 | |
7 """ | |
8 Wrapper around a build action that should only be executed in "release" mode. | |
9 | |
10 The following options are accepted: | |
11 | |
12 --mode=[release,debug] | |
13 | |
14 --outputs=files... | |
15 | |
16 If mode is not 'release', the script will create the files listed in | |
17 outputs. If mode is release, the script will execute the remaining | |
18 command line arguments as a command. | |
kustermann
2013/04/08 12:30:54
Would be nice if you can include an example here e
ahe
2013/04/08 12:42:46
Done.
| |
19 """ | |
20 | |
21 import optparse | |
22 import subprocess | |
23 import sys | |
24 | |
25 | |
26 def BuildOptions(): | |
27 result = optparse.OptionParser() | |
28 result.add_option('-m', '--mode') | |
29 result.add_option('-o', '--outputs') | |
30 return result | |
31 | |
32 | |
33 def Main(): | |
34 (options, arguments) = BuildOptions().parse_args() | |
35 if options.mode != 'release': | |
36 print >> sys.stderr, 'Not running %s in mode=%s' % (arguments, | |
37 options.mode) | |
38 for output in options.outputs.strip('"').split('" "'): | |
39 with open(output, 'w'): | |
kustermann
2013/04/08 12:30:54
Add a comment (or a print statement) saying that y
ahe
2013/04/08 12:42:46
Done.
| |
40 pass | |
41 return 0 | |
42 else: | |
43 try: | |
44 subprocess.check_call(arguments) | |
45 except subprocess.CalledProcessError as e: | |
46 return e.returncode | |
47 return 0 | |
48 | |
49 | |
50 if __name__ == '__main__': | |
51 sys.exit(Main()) | |
OLD | NEW |