OLD | NEW |
---|---|
(Empty) | |
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 | |
3 # found in the LICENSE file. | |
4 | |
5 import argparse | |
6 import os | |
7 import sys | |
8 | |
9 | |
10 def Main(): | |
11 parser = argparse.ArgumentParser( | |
12 description='compile assets catalog for a bundle') | |
13 parser.add_argument( | |
14 '--platform', '-p', required=True, | |
15 choices=('macosx', 'iphoneos', 'iphonesimulator'), | |
Dirk Pranke
2016/06/02 16:32:10
If the underlying arg uses 'mac' instead of 'macos
sdefresne
2016/06/02 16:55:29
The string is passed verbatim to the actool that o
Dirk Pranke
2016/06/02 17:06:20
Ah, I missed the --platform arg in the command lin
| |
16 help='target platform for the compiled assets catalog') | |
17 parser.add_argument( | |
18 '--minimum-deployment-target', '-t', required=True, | |
19 help='minimum deployment target for the compiled assets catalog') | |
20 parser.add_argument( | |
21 '--output', '-o', required=True, | |
22 help='path to the compiled assets catalog') | |
23 parser.add_argument( | |
24 'inputs', nargs='+', | |
25 help='path to input assets catalog sources') | |
26 args = parser.parse_args() | |
27 | |
28 if os.path.basename(args.output) != 'Assets.car': | |
29 sys.stderr.write( | |
30 'output should be path to compiled asset catalog, not ' | |
31 'to the containing bundle: %s\n' % (args.output,)) | |
32 | |
33 command = [ | |
34 'xcrun', 'actool', '--output-format', 'human-readable-text', | |
35 '--compress-pngs', '--notices', '--warnings', '--errors', | |
36 '--platform', args.platform, '--minimum-deployment-target', | |
37 args.minimum_deployment_target, | |
38 ] | |
39 | |
40 if args.platform == 'macosx': | |
41 command.extend(['--target-device', 'mac']) | |
42 else: | |
43 command.extend(['--target-device', 'iphone', '--target-device', 'ipad']) | |
44 | |
45 # actool crashes if paths are relative, so use os.path.abspath to get absolute | |
46 # path for input and outputs. | |
47 command.extend(['--compile', os.path.abspath(os.path.dirname(args.output))]) | |
48 command.extend(map(os.path.abspath, args.inputs)) | |
49 | |
50 os.execvp('xcrun', command) | |
51 sys.exit(1) | |
52 | |
53 if __name__ == '__main__': | |
54 sys.exit(Main()) | |
OLD | NEW |