Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Helper script to repack paks for a list of locales. | 6 """Helper script to repack paks for a list of locales. |
| 7 | 7 |
| 8 Gyp doesn't have any built-in looping capability, so this just provides a way to | 8 Gyp doesn't have any built-in looping capability, so this just provides a way to |
| 9 loop over a list of locales when repacking pak files, thus avoiding a | 9 loop over a list of locales when repacking pak files, thus avoiding a |
| 10 proliferation of mostly duplicate, cut-n-paste gyp actions. | 10 proliferation of mostly duplicate, cut-n-paste gyp actions. |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 BRANDING = None | 22 BRANDING = None |
| 23 | 23 |
| 24 # Some build paths defined by gyp. | 24 # Some build paths defined by gyp. |
| 25 GRIT_DIR = None | 25 GRIT_DIR = None |
| 26 SHARE_INT_DIR = None | 26 SHARE_INT_DIR = None |
| 27 INT_DIR = None | 27 INT_DIR = None |
| 28 | 28 |
| 29 # The target platform. If it is not defined, sys.platform will be used. | 29 # The target platform. If it is not defined, sys.platform will be used. |
| 30 OS = None | 30 OS = None |
| 31 | 31 |
| 32 USE_ASH = False | |
| 33 | |
| 32 # Extra input files. | 34 # Extra input files. |
| 33 EXTRA_INPUT_FILES = [] | 35 EXTRA_INPUT_FILES = [] |
| 34 | 36 |
| 35 class Usage(Exception): | 37 class Usage(Exception): |
| 36 def __init__(self, msg): | 38 def __init__(self, msg): |
| 37 self.msg = msg | 39 self.msg = msg |
| 38 | 40 |
| 39 | 41 |
| 40 def calc_output(locale): | 42 def calc_output(locale): |
| 41 """Determine the file that will be generated for the given locale.""" | 43 """Determine the file that will be generated for the given locale.""" |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 67 | 69 |
| 68 #e.g. '<(grit_out_dir)/platform_locale_settings_da.pak' | 70 #e.g. '<(grit_out_dir)/platform_locale_settings_da.pak' |
| 69 inputs.append(os.path.join(GRIT_DIR, | 71 inputs.append(os.path.join(GRIT_DIR, |
| 70 'platform_locale_settings_%s.pak' % locale)) | 72 'platform_locale_settings_%s.pak' % locale)) |
| 71 | 73 |
| 72 #e.g. '<(SHARED_INTERMEDIATE_DIR)/components/strings/ | 74 #e.g. '<(SHARED_INTERMEDIATE_DIR)/components/strings/ |
| 73 # component_strings_da.pak', | 75 # component_strings_da.pak', |
| 74 inputs.append(os.path.join(SHARE_INT_DIR, 'components', 'strings', | 76 inputs.append(os.path.join(SHARE_INT_DIR, 'components', 'strings', |
| 75 'component_strings_%s.pak' % locale)) | 77 'component_strings_%s.pak' % locale)) |
| 76 | 78 |
| 79 if USE_ASH: | |
| 80 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ash_strings/ash_strings_da.pak', | |
| 81 inputs.append(os.path.join(SHARE_INT_DIR, 'ash_strings', | |
| 82 'ash_strings_%s.pak' % locale)) | |
| 83 | |
| 77 if OS != 'ios': | 84 if OS != 'ios': |
| 78 #e.g. '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_da.pak' | 85 #e.g. '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_da.pak' |
| 79 inputs.append(os.path.join(SHARE_INT_DIR, 'webkit', | 86 inputs.append(os.path.join(SHARE_INT_DIR, 'webkit', |
| 80 'webkit_strings_%s.pak' % locale)) | 87 'webkit_strings_%s.pak' % locale)) |
| 81 | 88 |
| 82 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings_da.pak', | 89 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings_da.pak', |
| 83 inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'ui_strings', | 90 inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'ui_strings', |
| 84 'ui_strings_%s.pak' % locale)) | 91 'ui_strings_%s.pak' % locale)) |
| 85 | 92 |
| 86 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ash_strings/ash_strings_da.pak', | |
| 87 inputs.append(os.path.join(SHARE_INT_DIR, 'ash_strings', | |
| 88 'ash_strings_%s.pak' % locale)) | |
| 89 | |
| 90 #e.g. '<(SHARED_INTERMEDIATE_DIR)/device/bluetooth/strings/ | 93 #e.g. '<(SHARED_INTERMEDIATE_DIR)/device/bluetooth/strings/ |
| 91 # device_bluetooth_strings_da.pak', | 94 # device_bluetooth_strings_da.pak', |
| 92 inputs.append(os.path.join(SHARE_INT_DIR, 'device', 'bluetooth', 'strings', | 95 inputs.append(os.path.join(SHARE_INT_DIR, 'device', 'bluetooth', 'strings', |
| 93 'device_bluetooth_strings_%s.pak' % locale)) | 96 'device_bluetooth_strings_%s.pak' % locale)) |
| 94 | 97 |
| 95 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings_da.pak', | 98 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings_da.pak', |
| 96 inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'app_locale_settings', | 99 inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'app_locale_settings', |
| 97 'app_locale_settings_%s.pak' % locale)) | 100 'app_locale_settings_%s.pak' % locale)) |
| 98 | 101 |
| 99 #e.g. '<(grit_out_dir)/google_chrome_strings_da.pak' | 102 #e.g. '<(grit_out_dir)/google_chrome_strings_da.pak' |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 output = calc_output(locale) | 148 output = calc_output(locale) |
| 146 data_pack.DataPack.RePack(output, inputs) | 149 data_pack.DataPack.RePack(output, inputs) |
| 147 | 150 |
| 148 | 151 |
| 149 def DoMain(argv): | 152 def DoMain(argv): |
| 150 global BRANDING | 153 global BRANDING |
| 151 global GRIT_DIR | 154 global GRIT_DIR |
| 152 global SHARE_INT_DIR | 155 global SHARE_INT_DIR |
| 153 global INT_DIR | 156 global INT_DIR |
| 154 global OS | 157 global OS |
| 158 global USE_ASH | |
| 155 global EXTRA_INPUT_FILES | 159 global EXTRA_INPUT_FILES |
| 156 | 160 |
| 157 parser = optparse.OptionParser("usage: %prog [options] locales") | 161 parser = optparse.OptionParser("usage: %prog [options] locales") |
| 158 parser.add_option("-i", action="store_true", dest="inputs", default=False, | 162 parser.add_option("-i", action="store_true", dest="inputs", default=False, |
| 159 help="Print the expected input file list, then exit.") | 163 help="Print the expected input file list, then exit.") |
| 160 parser.add_option("-o", action="store_true", dest="outputs", default=False, | 164 parser.add_option("-o", action="store_true", dest="outputs", default=False, |
| 161 help="Print the expected output file list, then exit.") | 165 help="Print the expected output file list, then exit.") |
| 162 parser.add_option("-g", action="store", dest="grit_dir", | 166 parser.add_option("-g", action="store", dest="grit_dir", |
| 163 help="GRIT build files output directory.") | 167 help="GRIT build files output directory.") |
| 164 parser.add_option("-x", action="store", dest="int_dir", | 168 parser.add_option("-x", action="store", dest="int_dir", |
| 165 help="Intermediate build files output directory.") | 169 help="Intermediate build files output directory.") |
| 166 parser.add_option("-s", action="store", dest="share_int_dir", | 170 parser.add_option("-s", action="store", dest="share_int_dir", |
| 167 help="Shared intermediate build files output directory.") | 171 help="Shared intermediate build files output directory.") |
| 168 parser.add_option("-b", action="store", dest="branding", | 172 parser.add_option("-b", action="store", dest="branding", |
| 169 help="Branding type of this build.") | 173 help="Branding type of this build.") |
| 170 parser.add_option("-e", action="append", dest="extra_input", default=[], | 174 parser.add_option("-e", action="append", dest="extra_input", default=[], |
| 171 help="Full path to an extra input pak file without the\ | 175 help="Full path to an extra input pak file without the\ |
| 172 locale suffix and \".pak\" extension.") | 176 locale suffix and \".pak\" extension.") |
| 173 parser.add_option("-p", action="store", dest="os", | 177 parser.add_option("-p", action="store", dest="os", |
| 174 help="The target OS. (e.g. mac, linux, win, etc.)") | 178 help="The target OS. (e.g. mac, linux, win, etc.)") |
| 179 parser.add_option("--use-ash", action="store", dest="use_ash", | |
| 180 help="Whether to include ash strings") | |
| 175 options, locales = parser.parse_args(argv) | 181 options, locales = parser.parse_args(argv) |
| 176 | 182 |
| 177 if not locales: | 183 if not locales: |
| 178 parser.error('Please specificy at least one locale to process.\n') | 184 parser.error('Please specificy at least one locale to process.\n') |
| 179 | 185 |
| 180 print_inputs = options.inputs | 186 print_inputs = options.inputs |
| 181 print_outputs = options.outputs | 187 print_outputs = options.outputs |
| 182 GRIT_DIR = options.grit_dir | 188 GRIT_DIR = options.grit_dir |
| 183 INT_DIR = options.int_dir | 189 INT_DIR = options.int_dir |
| 184 SHARE_INT_DIR = options.share_int_dir | 190 SHARE_INT_DIR = options.share_int_dir |
| 185 BRANDING = options.branding | 191 BRANDING = options.branding |
| 186 EXTRA_INPUT_FILES = options.extra_input | 192 EXTRA_INPUT_FILES = options.extra_input |
| 187 OS = options.os | 193 OS = options.os |
| 194 USE_ASH = options.use_ash == 1 | |
|
Nico
2014/01/14 19:14:01
Is this ever true? options are strings, no?
aurimas (slooooooooow)
2014/01/14 19:30:36
Good catch. Fixed.
| |
| 188 | 195 |
| 189 if not OS: | 196 if not OS: |
| 190 if sys.platform == 'darwin': | 197 if sys.platform == 'darwin': |
| 191 OS = 'mac' | 198 OS = 'mac' |
| 192 elif sys.platform.startswith('linux'): | 199 elif sys.platform.startswith('linux'): |
| 193 OS = 'linux' | 200 OS = 'linux' |
| 194 elif sys.platform in ('cygwin', 'win32'): | 201 elif sys.platform in ('cygwin', 'win32'): |
| 195 OS = 'win' | 202 OS = 'win' |
| 196 else: | 203 else: |
| 197 OS = sys.platform | 204 OS = sys.platform |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 209 | 216 |
| 210 if print_outputs: | 217 if print_outputs: |
| 211 return list_outputs(locales) | 218 return list_outputs(locales) |
| 212 | 219 |
| 213 return repack_locales(locales) | 220 return repack_locales(locales) |
| 214 | 221 |
| 215 if __name__ == '__main__': | 222 if __name__ == '__main__': |
| 216 results = DoMain(sys.argv[1:]) | 223 results = DoMain(sys.argv[1:]) |
| 217 if results: | 224 if results: |
| 218 print results | 225 print results |
| OLD | NEW |