summaryrefslogtreecommitdiffstats
path: root/ios
diff options
context:
space:
mode:
authorsdefresne <sdefresne@chromium.org>2015-06-07 01:58:04 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-07 08:58:41 +0000
commit6248cdd125afa37ac0f81f5bfda9219d153fcf1e (patch)
tree6583c396a09325fa8665ff84ebec38e70d53df16 /ios
parent5a98e0e4d63de19e17356d49facbb26da7c97840 (diff)
downloadchromium_src-6248cdd125afa37ac0f81f5bfda9219d153fcf1e.zip
chromium_src-6248cdd125afa37ac0f81f5bfda9219d153fcf1e.tar.gz
chromium_src-6248cdd125afa37ac0f81f5bfda9219d153fcf1e.tar.bz2
[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}
Diffstat (limited to 'ios')
-rw-r--r--ios/build/grit_whitelist.txt1
-rw-r--r--ios/chrome/ios_chrome_resources.gyp90
-rw-r--r--ios/chrome/ios_chrome_resources_bundle.gypi16
-rw-r--r--ios/chrome/ios_chrome_tests.gyp1
-rwxr-xr-xios/chrome/tools/build/ios_repack_locales.py155
5 files changed, 260 insertions, 3 deletions
diff --git a/ios/build/grit_whitelist.txt b/ios/build/grit_whitelist.txt
deleted file mode 100644
index b1ba0ed..0000000
--- a/ios/build/grit_whitelist.txt
+++ /dev/null
@@ -1 +0,0 @@
-IDR_INFOBAR_TRANSLATE_IOS
diff --git a/ios/chrome/ios_chrome_resources.gyp b/ios/chrome/ios_chrome_resources.gyp
index 5e99526d..fa00362 100644
--- a/ios/chrome/ios_chrome_resources.gyp
+++ b/ios/chrome/ios_chrome_resources.gyp
@@ -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' ],
+ },
+ ],
+ },
],
}
diff --git a/ios/chrome/ios_chrome_resources_bundle.gypi b/ios/chrome/ios_chrome_resources_bundle.gypi
new file mode 100644
index 0000000..f37a61a
--- /dev/null
+++ b/ios/chrome/ios_chrome_resources_bundle.gypi
@@ -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))',
+ ],
+}
diff --git a/ios/chrome/ios_chrome_tests.gyp b/ios/chrome/ios_chrome_tests.gyp
index 55597fc..d6bb2ed 100644
--- a/ios/chrome/ios_chrome_tests.gyp
+++ b/ios/chrome/ios_chrome_tests.gyp
@@ -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',
diff --git a/ios/chrome/tools/build/ios_repack_locales.py b/ios/chrome/tools/build/ios_repack_locales.py
new file mode 100755
index 0000000..4801f06
--- /dev/null
+++ b/ios/chrome/tools/build/ios_repack_locales.py
@@ -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