[iOS] Add a repack steps to iOS upstream for unit tests
//ios unit tests will soon required access to packed resources (both theme and strings) so add steps required to repack data. Those steps only pack what is required by //ios unit tests and thus pack to repack_ios to avoid collision with downstream packing steps. Eventually the upstream and downstream repack steps will be merged. This forks some steps from //chrome since //ios cannot depends on //chrome and those steps are too specific to Chrome to be moved higher in //build. BUG=429756,475514 Review URL: https://codereview.chromium.org/1164983004 Cr-Commit-Position: refs/heads/master@{#333229}
This commit is contained in:
@ -32,6 +32,7 @@ sys.path.insert(1, os.path.join(chrome_src, 'android_webview', 'tools'))
|
||||
sys.path.insert(1, os.path.join(chrome_src, 'build', 'android', 'gyp'))
|
||||
sys.path.insert(1, os.path.join(chrome_src, 'chrome', 'tools', 'build'))
|
||||
sys.path.insert(1, os.path.join(chrome_src, 'chromecast', 'tools', 'build'))
|
||||
sys.path.insert(1, os.path.join(chrome_src, 'ios', 'chrome', 'tools', 'build'))
|
||||
sys.path.insert(1, os.path.join(chrome_src, 'native_client', 'build'))
|
||||
sys.path.insert(1, os.path.join(chrome_src, 'native_client_sdk', 'src',
|
||||
'build_tools'))
|
||||
|
@ -1 +0,0 @@
|
||||
IDR_INFOBAR_TRANSLATE_IOS
|
@ -52,8 +52,7 @@
|
||||
{
|
||||
'action_name': 'ios_theme_resources',
|
||||
'variables': {
|
||||
# TODO(lliabraa): Remove this whitelist.
|
||||
'grit_whitelist': '<(DEPTH)/ios/build/grit_whitelist.txt',
|
||||
'grit_whitelist': '',
|
||||
'grit_grd_file': 'app/theme/ios_theme_resources.grd',
|
||||
},
|
||||
'includes': [ '../../build/grit_action.gypi' ],
|
||||
@ -71,6 +70,93 @@
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
'target_name': 'ios_packed_resources',
|
||||
'type': 'none',
|
||||
'dependencies': [
|
||||
'../../components/components_strings.gyp:components_strings',
|
||||
'../../net/net.gyp:net_resources',
|
||||
'../../ui/resources/ui_resources.gyp:ui_resources',
|
||||
'../../ui/strings/ui_strings.gyp:ui_strings',
|
||||
'ios_chrome_resources',
|
||||
],
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'repack_ios_locales',
|
||||
'variables': {
|
||||
'repack_locales_path': 'tools/build/ios_repack_locales.py',
|
||||
},
|
||||
'inputs': [
|
||||
'tools/build/ios_repack_locales.py',
|
||||
'<!@pymod_do_main(ios_repack_locales -i '
|
||||
'-s <(SHARED_INTERMEDIATE_DIR) '
|
||||
'-x <(SHARED_INTERMEDIATE_DIR)/repack_ios '
|
||||
'<(locales))'
|
||||
],
|
||||
'outputs': [
|
||||
'<!@pymod_do_main(ios_repack_locales -o '
|
||||
'-s <(SHARED_INTERMEDIATE_DIR) '
|
||||
'-x <(SHARED_INTERMEDIATE_DIR)/repack_ios '
|
||||
'<(locales))'
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'tools/build/ios_repack_locales.py',
|
||||
'-x', '<(SHARED_INTERMEDIATE_DIR)/repack_ios',
|
||||
'-s', '<(SHARED_INTERMEDIATE_DIR)',
|
||||
'<@(locales)',
|
||||
],
|
||||
},
|
||||
{
|
||||
'action_name': 'repack_ios_resources_100_percent',
|
||||
'variables': {
|
||||
'pak_inputs': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources_100_percent.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/ios/chrome/ios_theme_resources_100_percent.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_100_percent.pak',
|
||||
],
|
||||
'pak_output': '<(SHARED_INTERMEDIATE_DIR)/repack_ios/chrome_100_percent.pak',
|
||||
},
|
||||
'includes': [ '../../build/repack_action.gypi' ],
|
||||
},
|
||||
{
|
||||
'action_name': 'repack_ios_resources_200_percent',
|
||||
'variables': {
|
||||
'pak_inputs': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources_200_percent.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/ios/chrome/ios_theme_resources_200_percent.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_200_percent.pak',
|
||||
],
|
||||
'pak_output': '<(SHARED_INTERMEDIATE_DIR)/repack_ios/chrome_200_percent.pak',
|
||||
},
|
||||
'includes': [ '../../build/repack_action.gypi' ],
|
||||
},
|
||||
{
|
||||
'action_name': 'repack_ios_resources_300_percent',
|
||||
'variables': {
|
||||
'pak_inputs': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources_300_percent.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/ios/chrome/ios_theme_resources_300_percent.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/ui_resources_300_percent.pak',
|
||||
],
|
||||
'pak_output': '<(SHARED_INTERMEDIATE_DIR)/repack_ios/chrome_300_percent.pak',
|
||||
},
|
||||
'includes': [ '../../build/repack_action.gypi' ],
|
||||
},
|
||||
{
|
||||
'action_name': 'repack_ios_resources',
|
||||
'variables': {
|
||||
'pak_inputs': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/components/components_resources.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/net/net_resources.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/ui/resources/webui_resources.pak',
|
||||
],
|
||||
'pak_output': '<(SHARED_INTERMEDIATE_DIR)/repack_ios/resources.pak',
|
||||
},
|
||||
'includes': [ '../../build/repack_action.gypi' ],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
16
ios/chrome/ios_chrome_resources_bundle.gypi
Normal file
16
ios/chrome/ios_chrome_resources_bundle.gypi
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright 2015 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.
|
||||
{
|
||||
'dependencies': [
|
||||
'<(DEPTH)/ios/chrome/ios_chrome_resources.gyp:ios_packed_resources',
|
||||
],
|
||||
'mac_bundle_resources': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/repack_ios/chrome_100_percent.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/repack_ios/chrome_200_percent.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/repack_ios/chrome_300_percent.pak',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/repack_ios/resources.pak',
|
||||
'<!@pymod_do_main(ios_repack_locales -o -s <(SHARED_INTERMEDIATE_DIR) '
|
||||
'-x <(SHARED_INTERMEDIATE_DIR)/repack_ios <(locales))',
|
||||
],
|
||||
}
|
@ -45,6 +45,7 @@
|
||||
'browser/ui/uikit_ui_util_unittest.mm',
|
||||
'common/string_util_unittest.mm',
|
||||
],
|
||||
'includes': ['ios_chrome_resources_bundle.gypi'],
|
||||
},
|
||||
{
|
||||
'target_name': 'ios_chrome_test_support',
|
||||
|
155
ios/chrome/tools/build/ios_repack_locales.py
Executable file
155
ios/chrome/tools/build/ios_repack_locales.py
Executable file
@ -0,0 +1,155 @@
|
||||
#!/usr/bin/env python
|
||||
# Copyright 2015 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.
|
||||
|
||||
"""Helper script to repack paks for a list of locales for iOS.
|
||||
|
||||
Gyp doesn't have any built-in looping capability, so this just provides a way to
|
||||
loop over a list of locales when repacking pak files, thus avoiding a
|
||||
proliferation of mostly duplicate, cut-n-paste gyp actions.
|
||||
"""
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import sys
|
||||
|
||||
script_dir = os.path.dirname(__file__)
|
||||
src_dir = os.path.join(script_dir, os.pardir, os.pardir, os.pardir, os.pardir)
|
||||
sys.path.append(os.path.join(src_dir, 'tools', 'grit'))
|
||||
|
||||
from grit.format import data_pack
|
||||
|
||||
|
||||
def calc_output(options, locale):
|
||||
"""Determine the file that will be generated for the given locale."""
|
||||
#e.g. '<(INTERMEDIATE_DIR)/repack/da.pak',
|
||||
# For Fake Bidi, generate it at a fixed path so that tests can safely
|
||||
# reference it.
|
||||
if locale == 'fake-bidi':
|
||||
return os.path.join(options.share_int_dir, locale + '.pak')
|
||||
# For Cocoa to find the locale at runtime, it needs to use '_' instead
|
||||
# of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
|
||||
# simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
|
||||
if locale == 'en-US':
|
||||
locale = 'en'
|
||||
else:
|
||||
locale = locale.replace('-', '_')
|
||||
return os.path.join(options.out_dir, locale + '.lproj', 'locale.pak')
|
||||
|
||||
|
||||
def calc_inputs(options, locale):
|
||||
"""Determine the files that need processing for the given locale."""
|
||||
inputs = []
|
||||
|
||||
#e.g. '<(SHARED_INTERMEDIATE_DIR)/components/strings/
|
||||
# components_strings_da.pak',
|
||||
inputs.append(os.path.join(options.share_int_dir, 'components', 'strings',
|
||||
'components_strings_%s.pak' % locale))
|
||||
|
||||
#e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/strings/ui_strings_da.pak',
|
||||
inputs.append(os.path.join(options.share_int_dir, 'ui', 'strings',
|
||||
'ui_strings_%s.pak' % locale))
|
||||
|
||||
#e.g. '<(SHARED_INTERMEDIATE_DIR)/ios/chrome/ios_strings_resources_da.pak'
|
||||
inputs.append(os.path.join(options.share_int_dir, 'ios', 'chrome',
|
||||
'ios_strings_resources_%s.pak' % locale))
|
||||
|
||||
if options.branding:
|
||||
#e.g. '<(SHARED_INTERMEDIATE_DIR)/ios/chrome/google_chrome_strings_da.pak'
|
||||
# or
|
||||
# '<(SHARED_INTERMEDIATE_DIR)/ios/chrome/chromium_strings_da.pak'
|
||||
inputs.append(os.path.join(options.share_int_dir, 'ios', 'chrome',
|
||||
'%s_strings_%s.pak' % (options.branding, locale)))
|
||||
|
||||
# Add any extra input files.
|
||||
for extra_file in options.extra_input:
|
||||
inputs.append('%s_%s.pak' % (extra_file, locale))
|
||||
|
||||
return inputs
|
||||
|
||||
|
||||
def list_outputs(options, locales):
|
||||
"""Returns the names of files that will be generated for the given locales.
|
||||
|
||||
This is to provide gyp the list of output files, so build targets can
|
||||
properly track what needs to be built.
|
||||
"""
|
||||
outputs = []
|
||||
for locale in locales:
|
||||
outputs.append(calc_output(options, locale))
|
||||
return outputs
|
||||
|
||||
|
||||
def list_inputs(options, locales):
|
||||
"""Returns the names of files that will be processed for the given locales.
|
||||
|
||||
This is to provide gyp the list of input files, so build targets can properly
|
||||
track their prerequisites.
|
||||
"""
|
||||
inputs = []
|
||||
for locale in locales:
|
||||
inputs.extend(calc_inputs(options, locale))
|
||||
return inputs
|
||||
|
||||
|
||||
def quote_filenames(filenames):
|
||||
"""Quote each elements so filename spaces don't mess up gyp's attempt to parse
|
||||
it into a list."""
|
||||
return " ".join(['"%s"' % x for x in filenames])
|
||||
|
||||
|
||||
def repack_locales(options, locales):
|
||||
""" Loop over and repack the given locales."""
|
||||
for locale in locales:
|
||||
inputs = calc_inputs(options, locale)
|
||||
output = calc_output(options, locale)
|
||||
data_pack.DataPack.RePack(output, inputs, whitelist_file=options.whitelist)
|
||||
|
||||
|
||||
def DoMain(argv):
|
||||
parser = optparse.OptionParser("usage: %prog [options] locales")
|
||||
parser.add_option(
|
||||
"-i", action="store_true", dest="print_inputs", default=False,
|
||||
help="Print the expected input file list, then exit.")
|
||||
parser.add_option(
|
||||
"-o", action="store_true", dest="print_outputs", default=False,
|
||||
help="Print the expected output file list, then exit.")
|
||||
parser.add_option(
|
||||
"-x", action="store", dest="out_dir",
|
||||
help="Intermediate build files output directory.")
|
||||
parser.add_option(
|
||||
"-s", action="store", dest="share_int_dir",
|
||||
help="Shared intermediate build files output directory.")
|
||||
parser.add_option(
|
||||
"-b", action="store", dest="branding",
|
||||
help="Branding type of this build.")
|
||||
parser.add_option(
|
||||
"-e", action="append", dest="extra_input", default=[],
|
||||
help="Full path to an extra input pak file without the "
|
||||
"locale suffix and \".pak\" extension.")
|
||||
parser.add_option(
|
||||
"--whitelist", action="store", help="Full path to the "
|
||||
"whitelist used to filter output pak file resource IDs")
|
||||
options, locales = parser.parse_args(argv)
|
||||
|
||||
if not locales:
|
||||
parser.error('Please specificy at least one locale to process.\n')
|
||||
|
||||
if not (options.out_dir and options.share_int_dir):
|
||||
parser.error('Please specify all of "-x" and "-s".\n')
|
||||
if options.print_inputs and options.print_outputs:
|
||||
parser.error('Please specify only one of "-i" or "-o".\n')
|
||||
|
||||
if options.print_inputs:
|
||||
return quote_filenames(list_inputs(options, locales))
|
||||
|
||||
if options.print_outputs:
|
||||
return quote_filenames(list_outputs(options, locales))
|
||||
|
||||
return repack_locales(options, locales)
|
||||
|
||||
if __name__ == '__main__':
|
||||
results = DoMain(sys.argv[1:])
|
||||
if results:
|
||||
print results
|
Reference in New Issue
Block a user