| 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 15 matching lines...) Expand all Loading... |
| 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. | 32 # Note that OS is normally set to 'linux' when building for chromeos. |
| 33 CHROMEOS = False | 33 CHROMEOS = False |
| 34 | 34 |
| 35 USE_ASH = False | 35 USE_ASH = False |
| 36 USE_ATHENA = False | |
| 37 ENABLE_AUTOFILL_DIALOG = False | 36 ENABLE_AUTOFILL_DIALOG = False |
| 38 ENABLE_EXTENSIONS = False | 37 ENABLE_EXTENSIONS = False |
| 39 | 38 |
| 40 WHITELIST = None | 39 WHITELIST = None |
| 41 | 40 |
| 42 # Extra input files. | 41 # Extra input files. |
| 43 EXTRA_INPUT_FILES = [] | 42 EXTRA_INPUT_FILES = [] |
| 44 | 43 |
| 45 class Usage(Exception): | 44 class Usage(Exception): |
| 46 def __init__(self, msg): | 45 def __init__(self, msg): |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 #e.g. '<(SHARED_INTERMEDIATE_DIR)/components/strings/ | 81 #e.g. '<(SHARED_INTERMEDIATE_DIR)/components/strings/ |
| 83 # components_strings_da.pak', | 82 # components_strings_da.pak', |
| 84 inputs.append(os.path.join(SHARE_INT_DIR, 'components', 'strings', | 83 inputs.append(os.path.join(SHARE_INT_DIR, 'components', 'strings', |
| 85 'components_strings_%s.pak' % locale)) | 84 'components_strings_%s.pak' % locale)) |
| 86 | 85 |
| 87 if USE_ASH: | 86 if USE_ASH: |
| 88 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ash/strings/ash_strings_da.pak', | 87 #e.g. '<(SHARED_INTERMEDIATE_DIR)/ash/strings/ash_strings_da.pak', |
| 89 inputs.append(os.path.join(SHARE_INT_DIR, 'ash', 'strings', | 88 inputs.append(os.path.join(SHARE_INT_DIR, 'ash', 'strings', |
| 90 'ash_strings_%s.pak' % locale)) | 89 'ash_strings_%s.pak' % locale)) |
| 91 | 90 |
| 92 if USE_ATHENA: | |
| 93 #e.g. '<(SHARED_INTERMEDIATE_DIR)/athena/strings/athena_strings_da.pak', | |
| 94 inputs.append(os.path.join(SHARE_INT_DIR, 'athena', 'strings', | |
| 95 'athena_strings_%s.pak' % locale)) | |
| 96 | |
| 97 if CHROMEOS: | 91 if CHROMEOS: |
| 98 inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'chromeos', 'strings', | 92 inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'chromeos', 'strings', |
| 99 'ui_chromeos_strings_%s.pak' % locale)) | 93 'ui_chromeos_strings_%s.pak' % locale)) |
| 100 inputs.append(os.path.join(SHARE_INT_DIR, 'remoting', 'resources', | 94 inputs.append(os.path.join(SHARE_INT_DIR, 'remoting', 'resources', |
| 101 '%s.pak' % locale)) | 95 '%s.pak' % locale)) |
| 102 | 96 |
| 103 if OS != 'ios': | 97 if OS != 'ios': |
| 104 #e.g. | 98 #e.g. |
| 105 # '<(SHARED_INTERMEDIATE_DIR)/content/app/strings/content_strings_da.pak' | 99 # '<(SHARED_INTERMEDIATE_DIR)/content/app/strings/content_strings_da.pak' |
| 106 inputs.append(os.path.join(SHARE_INT_DIR, 'content', 'app', 'strings', | 100 inputs.append(os.path.join(SHARE_INT_DIR, 'content', 'app', 'strings', |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 178 |
| 185 | 179 |
| 186 def DoMain(argv): | 180 def DoMain(argv): |
| 187 global BRANDING | 181 global BRANDING |
| 188 global GRIT_DIR | 182 global GRIT_DIR |
| 189 global SHARE_INT_DIR | 183 global SHARE_INT_DIR |
| 190 global INT_DIR | 184 global INT_DIR |
| 191 global OS | 185 global OS |
| 192 global CHROMEOS | 186 global CHROMEOS |
| 193 global USE_ASH | 187 global USE_ASH |
| 194 global USE_ATHENA | |
| 195 global WHITELIST | 188 global WHITELIST |
| 196 global ENABLE_AUTOFILL_DIALOG | 189 global ENABLE_AUTOFILL_DIALOG |
| 197 global ENABLE_EXTENSIONS | 190 global ENABLE_EXTENSIONS |
| 198 global EXTRA_INPUT_FILES | 191 global EXTRA_INPUT_FILES |
| 199 | 192 |
| 200 parser = optparse.OptionParser("usage: %prog [options] locales") | 193 parser = optparse.OptionParser("usage: %prog [options] locales") |
| 201 parser.add_option("-i", action="store_true", dest="inputs", default=False, | 194 parser.add_option("-i", action="store_true", dest="inputs", default=False, |
| 202 help="Print the expected input file list, then exit.") | 195 help="Print the expected input file list, then exit.") |
| 203 parser.add_option("-o", action="store_true", dest="outputs", default=False, | 196 parser.add_option("-o", action="store_true", dest="outputs", default=False, |
| 204 help="Print the expected output file list, then exit.") | 197 help="Print the expected output file list, then exit.") |
| 205 parser.add_option("-g", action="store", dest="grit_dir", | 198 parser.add_option("-g", action="store", dest="grit_dir", |
| 206 help="GRIT build files output directory.") | 199 help="GRIT build files output directory.") |
| 207 parser.add_option("-x", action="store", dest="int_dir", | 200 parser.add_option("-x", action="store", dest="int_dir", |
| 208 help="Intermediate build files output directory.") | 201 help="Intermediate build files output directory.") |
| 209 parser.add_option("-s", action="store", dest="share_int_dir", | 202 parser.add_option("-s", action="store", dest="share_int_dir", |
| 210 help="Shared intermediate build files output directory.") | 203 help="Shared intermediate build files output directory.") |
| 211 parser.add_option("-b", action="store", dest="branding", | 204 parser.add_option("-b", action="store", dest="branding", |
| 212 help="Branding type of this build.") | 205 help="Branding type of this build.") |
| 213 parser.add_option("-e", action="append", dest="extra_input", default=[], | 206 parser.add_option("-e", action="append", dest="extra_input", default=[], |
| 214 help="Full path to an extra input pak file without the\ | 207 help="Full path to an extra input pak file without the\ |
| 215 locale suffix and \".pak\" extension.") | 208 locale suffix and \".pak\" extension.") |
| 216 parser.add_option("-p", action="store", dest="os", | 209 parser.add_option("-p", action="store", dest="os", |
| 217 help="The target OS. (e.g. mac, linux, win, etc.)") | 210 help="The target OS. (e.g. mac, linux, win, etc.)") |
| 218 parser.add_option("--use-ash", action="store", dest="use_ash", | 211 parser.add_option("--use-ash", action="store", dest="use_ash", |
| 219 help="Whether to include ash strings") | 212 help="Whether to include ash strings") |
| 220 parser.add_option("--use-athena", action="store", dest="use_athena", | |
| 221 help="Whether to include athena strings") | |
| 222 parser.add_option("--chromeos", action="store", | 213 parser.add_option("--chromeos", action="store", |
| 223 help="Whether building for Chrome OS") | 214 help="Whether building for Chrome OS") |
| 224 parser.add_option("--whitelist", action="store", help="Full path to the " | 215 parser.add_option("--whitelist", action="store", help="Full path to the " |
| 225 "whitelist used to filter output pak file resource IDs") | 216 "whitelist used to filter output pak file resource IDs") |
| 226 parser.add_option("--enable-autofill-dialog", action="store", | 217 parser.add_option("--enable-autofill-dialog", action="store", |
| 227 dest="enable_autofill_dialog", | 218 dest="enable_autofill_dialog", |
| 228 help="Whether to include strings for autofill dialog") | 219 help="Whether to include strings for autofill dialog") |
| 229 parser.add_option("--enable-extensions", action="store", | 220 parser.add_option("--enable-extensions", action="store", |
| 230 dest="enable_extensions", | 221 dest="enable_extensions", |
| 231 help="Whether to include strings for extensions") | 222 help="Whether to include strings for extensions") |
| 232 options, locales = parser.parse_args(argv) | 223 options, locales = parser.parse_args(argv) |
| 233 | 224 |
| 234 if not locales: | 225 if not locales: |
| 235 parser.error('Please specificy at least one locale to process.\n') | 226 parser.error('Please specificy at least one locale to process.\n') |
| 236 | 227 |
| 237 print_inputs = options.inputs | 228 print_inputs = options.inputs |
| 238 print_outputs = options.outputs | 229 print_outputs = options.outputs |
| 239 GRIT_DIR = options.grit_dir | 230 GRIT_DIR = options.grit_dir |
| 240 INT_DIR = options.int_dir | 231 INT_DIR = options.int_dir |
| 241 SHARE_INT_DIR = options.share_int_dir | 232 SHARE_INT_DIR = options.share_int_dir |
| 242 BRANDING = options.branding | 233 BRANDING = options.branding |
| 243 EXTRA_INPUT_FILES = options.extra_input | 234 EXTRA_INPUT_FILES = options.extra_input |
| 244 OS = options.os | 235 OS = options.os |
| 245 CHROMEOS = options.chromeos == '1' | 236 CHROMEOS = options.chromeos == '1' |
| 246 USE_ASH = options.use_ash == '1' | 237 USE_ASH = options.use_ash == '1' |
| 247 USE_ATHENA = options.use_athena == '1' | |
| 248 WHITELIST = options.whitelist | 238 WHITELIST = options.whitelist |
| 249 ENABLE_AUTOFILL_DIALOG = options.enable_autofill_dialog == '1' | 239 ENABLE_AUTOFILL_DIALOG = options.enable_autofill_dialog == '1' |
| 250 ENABLE_EXTENSIONS = options.enable_extensions == '1' | 240 ENABLE_EXTENSIONS = options.enable_extensions == '1' |
| 251 | 241 |
| 252 if not OS: | 242 if not OS: |
| 253 if sys.platform == 'darwin': | 243 if sys.platform == 'darwin': |
| 254 OS = 'mac' | 244 OS = 'mac' |
| 255 elif sys.platform.startswith('linux'): | 245 elif sys.platform.startswith('linux'): |
| 256 OS = 'linux' | 246 OS = 'linux' |
| 257 elif sys.platform in ('cygwin', 'win32'): | 247 elif sys.platform in ('cygwin', 'win32'): |
| (...skipping 14 matching lines...) Expand all Loading... |
| 272 | 262 |
| 273 if print_outputs: | 263 if print_outputs: |
| 274 return list_outputs(locales) | 264 return list_outputs(locales) |
| 275 | 265 |
| 276 return repack_locales(locales) | 266 return repack_locales(locales) |
| 277 | 267 |
| 278 if __name__ == '__main__': | 268 if __name__ == '__main__': |
| 279 results = DoMain(sys.argv[1:]) | 269 results = DoMain(sys.argv[1:]) |
| 280 if results: | 270 if results: |
| 281 print results | 271 print results |
| OLD | NEW |