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