Commit 7c708332 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Add option to control recompression of images by actool.

During compilation of assets catalogs, actool has the option of
recompressing the images (likely with pngcrush as used by older
version of Xcode). Add an option to wrapper script to control
whether this is enabled and disable it on iOS (as images have
already been optimised with imageoptim).

Bug: 738359
Change-Id: I8a2b855798bf5f2d221fe9dc1098f8649f77e5a4
Reviewed-on: https://chromium-review.googlesource.com/561777Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485208}
parent 578cc29a
......@@ -431,14 +431,17 @@ template("mac_toolchain") {
if (is_ios) {
_sdk_name = ios_sdk_name
_min_deployment_target = ios_deployment_target
_compress_pngs = ""
} else {
_sdk_name = mac_sdk_name
_min_deployment_target = mac_deployment_target
_compress_pngs = " -c "
}
command = "$env_wrapper rm -f {{output}} && " +
"TOOL_VERSION=${tool_versions.compile_xcassets} " +
"python $_tool -p $_sdk_name -t $_min_deployment_target " +
"-T {{bundle_product_type}} -o {{output}} {{inputs}}"
"$_compress_pngs -T {{bundle_product_type}} -o {{output}} " +
"{{inputs}}"
description = "COMPILE_XCASSETS {{output}}"
pool = ":bundle_pool($default_toolchain)"
......
......@@ -76,8 +76,8 @@ def FilterCompilerOutput(compiler_output, relative_paths):
return ''.join(filtered_output)
def CompileAssetCatalog(
output, platform, product_type, min_deployment_target, inputs):
def CompileAssetCatalog(output, platform, product_type, min_deployment_target,
inputs, compress_pngs):
"""Compile the .xcassets bundles to an asset catalog using actool.
Args:
......@@ -86,14 +86,17 @@ def CompileAssetCatalog(
product_type: the bundle type
min_deployment_target: minimum deployment target
inputs: list of absolute paths to .xcassets bundles
compress_pngs: whether to enable compression of pngs
"""
command = [
'xcrun', 'actool', '--output-format=human-readable-text',
'--compress-pngs', '--notices', '--warnings', '--errors',
'--platform', platform, '--minimum-deployment-target',
min_deployment_target,
'--notices', '--warnings', '--errors', '--platform', platform,
'--minimum-deployment-target', min_deployment_target,
]
if compress_pngs:
command.extend(['--compress-pngs'])
if product_type != '':
command.extend(['--product-type', product_type])
......@@ -144,6 +147,9 @@ def Main():
parser.add_argument(
'--output', '-o', required=True,
help='path to the compiled assets catalog')
parser.add_argument(
'--compress-pngs', '-c', action='store_true', default=False,
help='recompress PNGs while compiling assets catalog')
parser.add_argument(
'--product-type', '-T',
help='type of the containing bundle')
......@@ -163,7 +169,8 @@ def Main():
args.platform,
args.product_type,
args.minimum_deployment_target,
args.inputs)
args.inputs,
args.compress_pngs)
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment