| 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 # Note that OS is normally set to 'linux' when building for chromeos. |
| 33 CHROMEOS = False |
| 34 |
| 32 USE_ASH = False | 35 USE_ASH = False |
| 33 ENABLE_AUTOFILL_DIALOG = False | 36 ENABLE_AUTOFILL_DIALOG = False |
| 34 | 37 |
| 35 WHITELIST = None | 38 WHITELIST = None |
| 36 | 39 |
| 37 # Extra input files. | 40 # Extra input files. |
| 38 EXTRA_INPUT_FILES = [] | 41 EXTRA_INPUT_FILES = [] |
| 39 | 42 |
| 40 class Usage(Exception): | 43 class Usage(Exception): |
| 41 def __init__(self, msg): | 44 def __init__(self, msg): |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 #e.g. '<(SHARED_INTERMEDIATE_DIR)/components/strings/ | 80 #e.g. '<(SHARED_INTERMEDIATE_DIR)/components/strings/ |
| 78 # components_strings_da.pak', | 81 # components_strings_da.pak', |
| 79 inputs.append(os.path.join(SHARE_INT_DIR, 'components', 'strings', | 82 inputs.append(os.path.join(SHARE_INT_DIR, 'components', 'strings', |
| 80 'components_strings_%s.pak' % locale)) | 83 'components_strings_%s.pak' % locale)) |
| 81 | 84 |
| 82 if USE_ASH: | 85 if USE_ASH: |
| 83 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ash/strings/ash_strings_da.pak', | 86 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ash/strings/ash_strings_da.pak', |
| 84 inputs.append(os.path.join(SHARE_INT_DIR, 'ash', 'strings', | 87 inputs.append(os.path.join(SHARE_INT_DIR, 'ash', 'strings', |
| 85 'ash_strings_%s.pak' % locale)) | 88 'ash_strings_%s.pak' % locale)) |
| 86 | 89 |
| 90 if CHROMEOS: |
| 91 inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'chromeos', 'strings', |
| 92 'ui_chromeos_strings_%s.pak' % locale)) |
| 93 |
| 87 if OS != 'ios': | 94 if OS != 'ios': |
| 88 #e.g. '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_da.pak' | 95 #e.g. '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_da.pak' |
| 89 inputs.append(os.path.join(SHARE_INT_DIR, 'webkit', | 96 inputs.append(os.path.join(SHARE_INT_DIR, 'webkit', |
| 90 'webkit_strings_%s.pak' % locale)) | 97 'webkit_strings_%s.pak' % locale)) |
| 91 | 98 |
| 92 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/strings_da.pak', | 99 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/strings_da.pak', |
| 93 inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'strings', | 100 inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'strings', |
| 94 'ui_strings_%s.pak' % locale)) | 101 'ui_strings_%s.pak' % locale)) |
| 95 | 102 |
| 96 #e.g. '<(SHARED_INTERMEDIATE_DIR)/device/bluetooth/strings/ | 103 #e.g. '<(SHARED_INTERMEDIATE_DIR)/device/bluetooth/strings/ |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 output = calc_output(locale) | 171 output = calc_output(locale) |
| 165 data_pack.DataPack.RePack(output, inputs, whitelist_file=WHITELIST) | 172 data_pack.DataPack.RePack(output, inputs, whitelist_file=WHITELIST) |
| 166 | 173 |
| 167 | 174 |
| 168 def DoMain(argv): | 175 def DoMain(argv): |
| 169 global BRANDING | 176 global BRANDING |
| 170 global GRIT_DIR | 177 global GRIT_DIR |
| 171 global SHARE_INT_DIR | 178 global SHARE_INT_DIR |
| 172 global INT_DIR | 179 global INT_DIR |
| 173 global OS | 180 global OS |
| 181 global CHROMEOS |
| 174 global USE_ASH | 182 global USE_ASH |
| 175 global WHITELIST | 183 global WHITELIST |
| 176 global ENABLE_AUTOFILL_DIALOG | 184 global ENABLE_AUTOFILL_DIALOG |
| 177 global EXTRA_INPUT_FILES | 185 global EXTRA_INPUT_FILES |
| 178 | 186 |
| 179 parser = optparse.OptionParser("usage: %prog [options] locales") | 187 parser = optparse.OptionParser("usage: %prog [options] locales") |
| 180 parser.add_option("-i", action="store_true", dest="inputs", default=False, | 188 parser.add_option("-i", action="store_true", dest="inputs", default=False, |
| 181 help="Print the expected input file list, then exit.") | 189 help="Print the expected input file list, then exit.") |
| 182 parser.add_option("-o", action="store_true", dest="outputs", default=False, | 190 parser.add_option("-o", action="store_true", dest="outputs", default=False, |
| 183 help="Print the expected output file list, then exit.") | 191 help="Print the expected output file list, then exit.") |
| 184 parser.add_option("-g", action="store", dest="grit_dir", | 192 parser.add_option("-g", action="store", dest="grit_dir", |
| 185 help="GRIT build files output directory.") | 193 help="GRIT build files output directory.") |
| 186 parser.add_option("-x", action="store", dest="int_dir", | 194 parser.add_option("-x", action="store", dest="int_dir", |
| 187 help="Intermediate build files output directory.") | 195 help="Intermediate build files output directory.") |
| 188 parser.add_option("-s", action="store", dest="share_int_dir", | 196 parser.add_option("-s", action="store", dest="share_int_dir", |
| 189 help="Shared intermediate build files output directory.") | 197 help="Shared intermediate build files output directory.") |
| 190 parser.add_option("-b", action="store", dest="branding", | 198 parser.add_option("-b", action="store", dest="branding", |
| 191 help="Branding type of this build.") | 199 help="Branding type of this build.") |
| 192 parser.add_option("-e", action="append", dest="extra_input", default=[], | 200 parser.add_option("-e", action="append", dest="extra_input", default=[], |
| 193 help="Full path to an extra input pak file without the\ | 201 help="Full path to an extra input pak file without the\ |
| 194 locale suffix and \".pak\" extension.") | 202 locale suffix and \".pak\" extension.") |
| 195 parser.add_option("-p", action="store", dest="os", | 203 parser.add_option("-p", action="store", dest="os", |
| 196 help="The target OS. (e.g. mac, linux, win, etc.)") | 204 help="The target OS. (e.g. mac, linux, win, etc.)") |
| 197 parser.add_option("--use-ash", action="store", dest="use_ash", | 205 parser.add_option("--use-ash", action="store", dest="use_ash", |
| 198 help="Whether to include ash strings") | 206 help="Whether to include ash strings") |
| 207 parser.add_option("--chromeos", action="store", |
| 208 help="Whether building for Chrome OS") |
| 199 parser.add_option("--whitelist", action="store", help="Full path to the " | 209 parser.add_option("--whitelist", action="store", help="Full path to the " |
| 200 "whitelist used to filter output pak file resource IDs") | 210 "whitelist used to filter output pak file resource IDs") |
| 201 parser.add_option("--enable-autofill-dialog", action="store", | 211 parser.add_option("--enable-autofill-dialog", action="store", |
| 202 dest="enable_autofill_dialog", | 212 dest="enable_autofill_dialog", |
| 203 help="Whether to include strings for autofill dialog") | 213 help="Whether to include strings for autofill dialog") |
| 204 options, locales = parser.parse_args(argv) | 214 options, locales = parser.parse_args(argv) |
| 205 | 215 |
| 206 if not locales: | 216 if not locales: |
| 207 parser.error('Please specificy at least one locale to process.\n') | 217 parser.error('Please specificy at least one locale to process.\n') |
| 208 | 218 |
| 209 print_inputs = options.inputs | 219 print_inputs = options.inputs |
| 210 print_outputs = options.outputs | 220 print_outputs = options.outputs |
| 211 GRIT_DIR = options.grit_dir | 221 GRIT_DIR = options.grit_dir |
| 212 INT_DIR = options.int_dir | 222 INT_DIR = options.int_dir |
| 213 SHARE_INT_DIR = options.share_int_dir | 223 SHARE_INT_DIR = options.share_int_dir |
| 214 BRANDING = options.branding | 224 BRANDING = options.branding |
| 215 EXTRA_INPUT_FILES = options.extra_input | 225 EXTRA_INPUT_FILES = options.extra_input |
| 216 OS = options.os | 226 OS = options.os |
| 227 CHROMEOS = options.chromeos == '1' |
| 217 USE_ASH = options.use_ash == '1' | 228 USE_ASH = options.use_ash == '1' |
| 218 WHITELIST = options.whitelist | 229 WHITELIST = options.whitelist |
| 219 ENABLE_AUTOFILL_DIALOG = options.enable_autofill_dialog == '1' | 230 ENABLE_AUTOFILL_DIALOG = options.enable_autofill_dialog == '1' |
| 220 | 231 |
| 221 if not OS: | 232 if not OS: |
| 222 if sys.platform == 'darwin': | 233 if sys.platform == 'darwin': |
| 223 OS = 'mac' | 234 OS = 'mac' |
| 224 elif sys.platform.startswith('linux'): | 235 elif sys.platform.startswith('linux'): |
| 225 OS = 'linux' | 236 OS = 'linux' |
| 226 elif sys.platform in ('cygwin', 'win32'): | 237 elif sys.platform in ('cygwin', 'win32'): |
| (...skipping 14 matching lines...) Expand all Loading... |
| 241 | 252 |
| 242 if print_outputs: | 253 if print_outputs: |
| 243 return list_outputs(locales) | 254 return list_outputs(locales) |
| 244 | 255 |
| 245 return repack_locales(locales) | 256 return repack_locales(locales) |
| 246 | 257 |
| 247 if __name__ == '__main__': | 258 if __name__ == '__main__': |
| 248 results = DoMain(sys.argv[1:]) | 259 results = DoMain(sys.argv[1:]) |
| 249 if results: | 260 if results: |
| 250 print results | 261 print results |
| OLD | NEW |