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/561777 Reviewed-by: Dirk Pranke <dpranke@chromium.org> Reviewed-by: Justin Cohen <justincohen@chromium.org> Commit-Queue: Sylvain Defresne <sdefresne@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#485208} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 7c708332548f834d469be0af9659ceecb3ab3fa9
This commit is contained in:
Родитель
4dba73a4c5
Коммит
89f39ee351
|
@ -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__':
|
||||
|
|
Загрузка…
Ссылка в новой задаче