Chromium Code Reviews| Index: build/toolchain/mac/compile_xcassets.py |
| diff --git a/build/toolchain/mac/compile_xcassets.py b/build/toolchain/mac/compile_xcassets.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b78854416bab5852420995b49ff181cef29f3544 |
| --- /dev/null |
| +++ b/build/toolchain/mac/compile_xcassets.py |
| @@ -0,0 +1,54 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import argparse |
| +import os |
| +import sys |
| + |
| + |
| +def Main(): |
| + parser = argparse.ArgumentParser( |
| + description='compile assets catalog for a bundle') |
| + parser.add_argument( |
| + '--platform', '-p', required=True, |
| + 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
|
| + help='target platform for the compiled assets catalog') |
| + parser.add_argument( |
| + '--minimum-deployment-target', '-t', required=True, |
| + help='minimum deployment target for the compiled assets catalog') |
| + parser.add_argument( |
| + '--output', '-o', required=True, |
| + help='path to the compiled assets catalog') |
| + parser.add_argument( |
| + 'inputs', nargs='+', |
| + help='path to input assets catalog sources') |
| + args = parser.parse_args() |
| + |
| + if os.path.basename(args.output) != 'Assets.car': |
| + sys.stderr.write( |
| + 'output should be path to compiled asset catalog, not ' |
| + 'to the containing bundle: %s\n' % (args.output,)) |
| + |
| + command = [ |
| + 'xcrun', 'actool', '--output-format', 'human-readable-text', |
| + '--compress-pngs', '--notices', '--warnings', '--errors', |
| + '--platform', args.platform, '--minimum-deployment-target', |
| + args.minimum_deployment_target, |
| + ] |
| + |
| + if args.platform == 'macosx': |
| + command.extend(['--target-device', 'mac']) |
| + else: |
| + command.extend(['--target-device', 'iphone', '--target-device', 'ipad']) |
| + |
| + # actool crashes if paths are relative, so use os.path.abspath to get absolute |
| + # path for input and outputs. |
| + command.extend(['--compile', os.path.abspath(os.path.dirname(args.output))]) |
| + command.extend(map(os.path.abspath, args.inputs)) |
| + |
| + os.execvp('xcrun', command) |
| + sys.exit(1) |
| + |
| +if __name__ == '__main__': |
| + sys.exit(Main()) |