OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import argparse | 5 import argparse |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 | 8 |
9 | 9 |
10 def Main(): | 10 def Main(): |
11 parser = argparse.ArgumentParser( | 11 parser = argparse.ArgumentParser( |
12 description='compile assets catalog for a bundle') | 12 description='compile assets catalog for a bundle') |
13 parser.add_argument( | 13 parser.add_argument( |
| 14 '--version-for-gn', choices=('1',), |
| 15 help='version need to be increased in this script and in the file ' |
| 16 '//build/toolchain/mac/BUILD.gn to force build until issue ' |
| 17 'http://crbug.com/619083 is fixed') |
| 18 parser.add_argument( |
14 '--platform', '-p', required=True, | 19 '--platform', '-p', required=True, |
15 choices=('macosx', 'iphoneos', 'iphonesimulator'), | 20 choices=('macosx', 'iphoneos', 'iphonesimulator'), |
16 help='target platform for the compiled assets catalog') | 21 help='target platform for the compiled assets catalog') |
17 parser.add_argument( | 22 parser.add_argument( |
18 '--minimum-deployment-target', '-t', required=True, | 23 '--minimum-deployment-target', '-t', required=True, |
19 help='minimum deployment target for the compiled assets catalog') | 24 help='minimum deployment target for the compiled assets catalog') |
20 parser.add_argument( | 25 parser.add_argument( |
21 '--output', '-o', required=True, | 26 '--output', '-o', required=True, |
22 help='path to the compiled assets catalog') | 27 help='path to the compiled assets catalog') |
23 parser.add_argument( | 28 parser.add_argument( |
24 'inputs', nargs='+', | 29 'inputs', nargs='+', |
25 help='path to input assets catalog sources') | 30 help='path to input assets catalog sources') |
26 args = parser.parse_args() | 31 args = parser.parse_args() |
27 | 32 |
28 if os.path.basename(args.output) != 'Assets.car': | 33 if os.path.basename(args.output) != 'Assets.car': |
29 sys.stderr.write( | 34 sys.stderr.write( |
30 'output should be path to compiled asset catalog, not ' | 35 'output should be path to compiled asset catalog, not ' |
31 'to the containing bundle: %s\n' % (args.output,)) | 36 'to the containing bundle: %s\n' % (args.output,)) |
32 | 37 |
| 38 if os.path.exists(args.output): |
| 39 os.unlink(args.output) |
| 40 |
33 command = [ | 41 command = [ |
34 'xcrun', 'actool', '--output-format', 'human-readable-text', | 42 'xcrun', 'actool', '--output-format', 'human-readable-text', |
35 '--compress-pngs', '--notices', '--warnings', '--errors', | 43 '--compress-pngs', '--notices', '--warnings', '--errors', |
36 '--platform', args.platform, '--minimum-deployment-target', | 44 '--platform', args.platform, '--minimum-deployment-target', |
37 args.minimum_deployment_target, | 45 args.minimum_deployment_target, |
38 ] | 46 ] |
39 | 47 |
40 if args.platform == 'macosx': | 48 if args.platform == 'macosx': |
41 command.extend(['--target-device', 'mac']) | 49 command.extend(['--target-device', 'mac']) |
42 else: | 50 else: |
43 command.extend(['--target-device', 'iphone', '--target-device', 'ipad']) | 51 command.extend(['--target-device', 'iphone', '--target-device', 'ipad']) |
44 | 52 |
45 # actool crashes if paths are relative, so use os.path.abspath to get absolute | 53 # actool crashes if paths are relative, so use os.path.abspath to get absolute |
46 # path for input and outputs. | 54 # path for input and outputs. |
47 command.extend(['--compile', os.path.abspath(os.path.dirname(args.output))]) | 55 command.extend(['--compile', os.path.abspath(os.path.dirname(args.output))]) |
48 command.extend(map(os.path.abspath, args.inputs)) | 56 command.extend(map(os.path.abspath, args.inputs)) |
49 | 57 |
50 os.execvp('xcrun', command) | 58 os.execvp('xcrun', command) |
51 sys.exit(1) | 59 sys.exit(1) |
52 | 60 |
53 if __name__ == '__main__': | 61 if __name__ == '__main__': |
54 sys.exit(Main()) | 62 sys.exit(Main()) |
OLD | NEW |