mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-05 13:37:41 +01:00
Fix ninja build generation of locale files (issue #1052).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1372 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
parent
940d2c474d
commit
405ea14138
77
cef.gyp
77
cef.gyp
@ -584,70 +584,25 @@
|
|||||||
'<(DEPTH)/webkit/webkit_resources.gyp:webkit_strings',
|
'<(DEPTH)/webkit/webkit_resources.gyp:webkit_strings',
|
||||||
'cef_strings',
|
'cef_strings',
|
||||||
],
|
],
|
||||||
'variables': {
|
'actions': [
|
||||||
'repack_locales_cmd': ['python', 'tools/repack_locales.py'],
|
|
||||||
},
|
|
||||||
'copies': [
|
|
||||||
{
|
{
|
||||||
'destination': '<(PRODUCT_DIR)/locales',
|
'action_name': 'repack_locales',
|
||||||
'files': [
|
'inputs': [
|
||||||
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(INTERMEDIATE_DIR) <(locales))'
|
'tools/repack_locales.py',
|
||||||
|
],
|
||||||
|
'outputs': [
|
||||||
|
'<(PRODUCT_DIR)/cef_repack_locales.stamp',
|
||||||
|
],
|
||||||
|
'action': [
|
||||||
|
'python',
|
||||||
|
'tools/repack_locales.py',
|
||||||
|
'-g', '<(grit_out_dir)',
|
||||||
|
'-s', '<(SHARED_INTERMEDIATE_DIR)',
|
||||||
|
'-x', '<(PRODUCT_DIR)/locales',
|
||||||
|
'<@(locales)',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
'conditions': [
|
|
||||||
['OS=="win"', {
|
|
||||||
'actions': [
|
|
||||||
{
|
|
||||||
'action_name': 'repack_locales',
|
|
||||||
'inputs': [
|
|
||||||
'tools/repack_locales.py',
|
|
||||||
# NOTE: Ideally the common command args would be shared
|
|
||||||
# amongst inputs/outputs/action, but the args include shell
|
|
||||||
# variables which need to be passed intact, and command
|
|
||||||
# expansion wants to expand the shell variables. Adding the
|
|
||||||
# explicit quoting here was the only way it seemed to work.
|
|
||||||
'>!@(<(repack_locales_cmd) -i -g \"<(grit_out_dir)\" -s \"<(SHARED_INTERMEDIATE_DIR)\" -x \"<(INTERMEDIATE_DIR)\" <(locales))',
|
|
||||||
],
|
|
||||||
'outputs': [
|
|
||||||
'>!@(<(repack_locales_cmd) -o -g \"<(grit_out_dir)\" -s \"<(SHARED_INTERMEDIATE_DIR)\" -x \"<(INTERMEDIATE_DIR)\" <(locales))',
|
|
||||||
],
|
|
||||||
'action': [
|
|
||||||
'<@(repack_locales_cmd)',
|
|
||||||
'-g', '<(grit_out_dir)',
|
|
||||||
'-s', '<(SHARED_INTERMEDIATE_DIR)',
|
|
||||||
'-x', '<(INTERMEDIATE_DIR)',
|
|
||||||
'<@(locales)',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}, { # OS!="win"
|
|
||||||
'actions': [
|
|
||||||
{
|
|
||||||
'action_name': 'repack_locales',
|
|
||||||
'inputs': [
|
|
||||||
'tools/repack_locales.py',
|
|
||||||
# NOTE: Ideally the common command args would be shared
|
|
||||||
# amongst inputs/outputs/action, but the args include shell
|
|
||||||
# variables which need to be passed intact, and command
|
|
||||||
# expansion wants to expand the shell variables. Adding the
|
|
||||||
# explicit quoting here was the only way it seemed to work.
|
|
||||||
'>!@(<(repack_locales_cmd) -i -g \'<(grit_out_dir)\' -s \'<(SHARED_INTERMEDIATE_DIR)\' -x \'<(INTERMEDIATE_DIR)\' <(locales))',
|
|
||||||
],
|
|
||||||
'outputs': [
|
|
||||||
'>!@(<(repack_locales_cmd) -o -g \'<(grit_out_dir)\' -s \'<(SHARED_INTERMEDIATE_DIR)\' -x \'<(INTERMEDIATE_DIR)\' <(locales))',
|
|
||||||
],
|
|
||||||
'action': [
|
|
||||||
'<@(repack_locales_cmd)',
|
|
||||||
'-g', '<(grit_out_dir)',
|
|
||||||
'-s', '<(SHARED_INTERMEDIATE_DIR)',
|
|
||||||
'-x', '<(INTERMEDIATE_DIR)',
|
|
||||||
'<@(locales)',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'target_name': 'about_credits',
|
'target_name': 'about_credits',
|
||||||
@ -663,7 +618,7 @@
|
|||||||
'<(generator_path)',
|
'<(generator_path)',
|
||||||
],
|
],
|
||||||
'outputs': [
|
'outputs': [
|
||||||
'<(about_credits_file)',
|
'<(PRODUCT_DIR)/cef_generate_about_credits.stamp',
|
||||||
],
|
],
|
||||||
'hard_dependency': 1,
|
'hard_dependency': 1,
|
||||||
'action': ['python',
|
'action': ['python',
|
||||||
|
@ -1,184 +1,190 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
"""Helper script to repack paks for a list of locales.
|
"""Helper script to repack paks for a list of locales.
|
||||||
|
|
||||||
Gyp doesn't have any built-in looping capability, so this just provides a way to
|
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
|
loop over a list of locales when repacking pak files, thus avoiding a
|
||||||
proliferation of mostly duplicate, cut-n-paste gyp actions.
|
proliferation of mostly duplicate, cut-n-paste gyp actions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import getopt
|
import getopt
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..',
|
||||||
'tools', 'grit'))
|
'tools', 'grit'))
|
||||||
from grit.format import data_pack
|
from grit.format import data_pack
|
||||||
|
|
||||||
# Some build paths defined by gyp.
|
# Some build paths defined by gyp.
|
||||||
GRIT_DIR = None
|
GRIT_DIR = None
|
||||||
SHARE_INT_DIR = None
|
SHARE_INT_DIR = None
|
||||||
INT_DIR = None
|
INT_DIR = None
|
||||||
|
|
||||||
|
|
||||||
class Usage(Exception):
|
class Usage(Exception):
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
self.msg = msg
|
self.msg = msg
|
||||||
|
|
||||||
|
|
||||||
def calc_output(locale):
|
def calc_output(locale, create_dir):
|
||||||
"""Determine the file that will be generated for the given locale."""
|
"""Determine the file that will be generated for the given locale."""
|
||||||
#e.g. '<(INTERMEDIATE_DIR)/repack/da.pak',
|
#e.g. '<(INTERMEDIATE_DIR)/da.pak',
|
||||||
# For Fake Bidi, generate it at a fixed path so that tests can safely
|
# For Fake Bidi, generate it at a fixed path so that tests can safely
|
||||||
# reference it.
|
# reference it.
|
||||||
if locale == 'fake-bidi':
|
if locale == 'fake-bidi':
|
||||||
return '%s/%s.pak' % (INT_DIR, locale)
|
return '%s/%s.pak' % (INT_DIR, locale)
|
||||||
if sys.platform in ('darwin',):
|
if sys.platform in ('darwin',):
|
||||||
# For Cocoa to find the locale at runtime, it needs to use '_' instead
|
# For Cocoa to find the locale at runtime, it needs to use '_' instead
|
||||||
# of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
|
# of '-' (http://crbug.com/20441). Also, 'en-US' should be represented
|
||||||
# simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
|
# simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
|
||||||
if locale == 'en-US':
|
if locale == 'en-US':
|
||||||
locale = 'en'
|
locale = 'en'
|
||||||
return '%s/repack/%s.lproj/locale.pak' % (INT_DIR, locale.replace('-', '_'))
|
dir = '%s/%s.lproj' % (INT_DIR, locale.replace('-', '_'))
|
||||||
else:
|
if create_dir and not os.path.exists(dir):
|
||||||
return os.path.join(INT_DIR, 'repack', locale + '.pak')
|
os.makedirs(dir)
|
||||||
|
return dir + '/locale.pak'
|
||||||
|
else:
|
||||||
def calc_inputs(locale):
|
return os.path.join(INT_DIR, locale + '.pak')
|
||||||
"""Determine the files that need processing for the given locale."""
|
|
||||||
inputs = []
|
|
||||||
|
def calc_inputs(locale):
|
||||||
#e.g. '<(grit_out_dir)/generated_resources_da.pak'
|
"""Determine the files that need processing for the given locale."""
|
||||||
#inputs.append(os.path.join(GRIT_DIR, 'generated_resources_%s.pak' % locale))
|
inputs = []
|
||||||
|
|
||||||
#e.g. '<(grit_out_dir)/locale_settings_da.pak'
|
#e.g. '<(grit_out_dir)/generated_resources_da.pak'
|
||||||
#inputs.append(os.path.join(GRIT_DIR, 'locale_settings_%s.pak' % locale))
|
#inputs.append(os.path.join(GRIT_DIR, 'generated_resources_%s.pak' % locale))
|
||||||
|
|
||||||
#e.g. '<(grit_out_dir)/platform_locale_settings_da.pak'
|
#e.g. '<(grit_out_dir)/locale_settings_da.pak'
|
||||||
#inputs.append(os.path.join(GRIT_DIR,
|
#inputs.append(os.path.join(GRIT_DIR, 'locale_settings_%s.pak' % locale))
|
||||||
# 'platform_locale_settings_%s.pak' % locale))
|
|
||||||
|
#e.g. '<(grit_out_dir)/platform_locale_settings_da.pak'
|
||||||
#e.g. '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_da.pak'
|
#inputs.append(os.path.join(GRIT_DIR,
|
||||||
inputs.append(os.path.join(SHARE_INT_DIR, 'webkit',
|
# 'platform_locale_settings_%s.pak' % locale))
|
||||||
'webkit_strings_%s.pak' % locale))
|
|
||||||
|
#e.g. '<(SHARED_INTERMEDIATE_DIR)/webkit/webkit_strings_da.pak'
|
||||||
#e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings_da.pak',
|
inputs.append(os.path.join(SHARE_INT_DIR, 'webkit',
|
||||||
inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'ui_strings',
|
'webkit_strings_%s.pak' % locale))
|
||||||
'ui_strings_%s.pak' % locale))
|
|
||||||
|
#e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/ui_strings_da.pak',
|
||||||
#e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings_da.pak',
|
inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'ui_strings',
|
||||||
inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'app_locale_settings',
|
'ui_strings_%s.pak' % locale))
|
||||||
'app_locale_settings_%s.pak' % locale))
|
|
||||||
|
#e.g. '<(SHARED_INTERMEDIATE_DIR)/ui/app_locale_settings_da.pak',
|
||||||
#e.g. '<(SHARED_INTERMEDIATE_DIR)/cef/cef_strings_da.pak'
|
inputs.append(os.path.join(SHARE_INT_DIR, 'ui', 'app_locale_settings',
|
||||||
inputs.append(os.path.join(SHARE_INT_DIR, 'cef',
|
'app_locale_settings_%s.pak' % locale))
|
||||||
'cef_strings_%s.pak' % locale))
|
|
||||||
|
#e.g. '<(SHARED_INTERMEDIATE_DIR)/cef/cef_strings_da.pak'
|
||||||
return inputs
|
inputs.append(os.path.join(SHARE_INT_DIR, 'cef',
|
||||||
|
'cef_strings_%s.pak' % locale))
|
||||||
|
|
||||||
def list_outputs(locales):
|
return inputs
|
||||||
"""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
|
def list_outputs(locales):
|
||||||
properly track what needs to be built.
|
"""Returns the names of files that will be generated for the given locales.
|
||||||
"""
|
|
||||||
outputs = []
|
This is to provide gyp the list of output files, so build targets can
|
||||||
for locale in locales:
|
properly track what needs to be built.
|
||||||
outputs.append(calc_output(locale))
|
"""
|
||||||
# Quote each element so filename spaces don't mess up gyp's attempt to parse
|
outputs = []
|
||||||
# it into a list.
|
for locale in locales:
|
||||||
return " ".join(['"%s"' % x for x in outputs])
|
outputs.append(calc_output(locale, False))
|
||||||
|
# Quote each element so filename spaces don't mess up gyp's attempt to parse
|
||||||
|
# it into a list.
|
||||||
def list_inputs(locales):
|
return " ".join(['"%s"' % x for x in outputs])
|
||||||
"""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
|
def list_inputs(locales):
|
||||||
track their prerequisites.
|
"""Returns the names of files that will be processed for the given locales.
|
||||||
"""
|
|
||||||
inputs = []
|
This is to provide gyp the list of input files, so build targets can properly
|
||||||
for locale in locales:
|
track their prerequisites.
|
||||||
inputs += calc_inputs(locale)
|
"""
|
||||||
# Quote each element so filename spaces don't mess up gyp's attempt to parse
|
inputs = []
|
||||||
# it into a list.
|
for locale in locales:
|
||||||
return " ".join(['"%s"' % x for x in inputs])
|
inputs += calc_inputs(locale)
|
||||||
|
# Quote each element so filename spaces don't mess up gyp's attempt to parse
|
||||||
|
# it into a list.
|
||||||
def repack_locales(locales):
|
return " ".join(['"%s"' % x for x in inputs])
|
||||||
""" Loop over and repack the given locales."""
|
|
||||||
for locale in locales:
|
|
||||||
inputs = []
|
def repack_locales(locales):
|
||||||
inputs += calc_inputs(locale)
|
""" Loop over and repack the given locales."""
|
||||||
output = calc_output(locale)
|
for locale in locales:
|
||||||
data_pack.DataPack.RePack(output, inputs)
|
inputs = []
|
||||||
|
inputs += calc_inputs(locale)
|
||||||
|
output = calc_output(locale, True)
|
||||||
def DoMain(argv):
|
data_pack.DataPack.RePack(output, inputs)
|
||||||
global GRIT_DIR
|
|
||||||
global SHARE_INT_DIR
|
|
||||||
global INT_DIR
|
def DoMain(argv):
|
||||||
|
global GRIT_DIR
|
||||||
short_options = 'iog:s:x:b:h'
|
global SHARE_INT_DIR
|
||||||
long_options = 'help'
|
global INT_DIR
|
||||||
|
|
||||||
print_inputs = False
|
short_options = 'iog:s:x:b:h'
|
||||||
print_outputs = False
|
long_options = 'help'
|
||||||
usage_msg = ''
|
|
||||||
|
print_inputs = False
|
||||||
helpstr = """\
|
print_outputs = False
|
||||||
Usage: %s [-h] [-i | -o] -g <DIR> -x <DIR> -s <DIR> <locale> [...]
|
usage_msg = ''
|
||||||
-h, --help Print this help, then exit.
|
|
||||||
-i Print the expected input file list, then exit.
|
helpstr = """\
|
||||||
-o Print the expected output file list, then exit.
|
Usage: %s [-h] [-i | -o] -g <DIR> -x <DIR> -s <DIR> <locale> [...]
|
||||||
-g DIR GRIT build files output directory.
|
-h, --help Print this help, then exit.
|
||||||
-x DIR Intermediate build files output directory.
|
-i Print the expected input file list, then exit.
|
||||||
-s DIR Shared intermediate build files output directory.
|
-o Print the expected output file list, then exit.
|
||||||
locale [...] One or more locales to repack.""" % (
|
-g DIR GRIT build files output directory.
|
||||||
os.path.basename(__file__))
|
-x DIR Intermediate build files output directory.
|
||||||
|
-s DIR Shared intermediate build files output directory.
|
||||||
try:
|
locale [...] One or more locales to repack.""" % (
|
||||||
opts, locales = getopt.getopt(argv, short_options, long_options)
|
os.path.basename(__file__))
|
||||||
except getopt.GetoptError, msg:
|
|
||||||
raise Usage(str(msg))
|
try:
|
||||||
|
opts, locales = getopt.getopt(argv, short_options, long_options)
|
||||||
if not locales:
|
except getopt.GetoptError, msg:
|
||||||
usage_msg = 'Please specificy at least one locale to process.\n'
|
raise Usage(str(msg))
|
||||||
|
|
||||||
for o, a in opts:
|
if not locales:
|
||||||
if o in ('-i'):
|
usage_msg = 'Please specificy at least one locale to process.\n'
|
||||||
print_inputs = True
|
|
||||||
elif o in ('-o'):
|
for o, a in opts:
|
||||||
print_outputs = True
|
if o in ('-i'):
|
||||||
elif o in ('-g'):
|
print_inputs = True
|
||||||
GRIT_DIR = a
|
elif o in ('-o'):
|
||||||
elif o in ('-s'):
|
print_outputs = True
|
||||||
SHARE_INT_DIR = a
|
elif o in ('-g'):
|
||||||
elif o in ('-x'):
|
GRIT_DIR = a
|
||||||
INT_DIR = a
|
elif o in ('-s'):
|
||||||
elif o in ('-h', '--help'):
|
SHARE_INT_DIR = a
|
||||||
raise Usage(helpstr)
|
elif o in ('-x'):
|
||||||
|
INT_DIR = a
|
||||||
if not (GRIT_DIR and INT_DIR and SHARE_INT_DIR):
|
elif o in ('-h', '--help'):
|
||||||
usage_msg += 'Please specify all of "-g" and "-x" and "-s".\n'
|
raise Usage(helpstr)
|
||||||
if print_inputs and print_outputs:
|
|
||||||
usage_msg += 'Please specify only one of "-i" or "-o".\n'
|
if not (GRIT_DIR and INT_DIR and SHARE_INT_DIR):
|
||||||
|
usage_msg += 'Please specify all of "-g" and "-x" and "-s".\n'
|
||||||
if usage_msg:
|
if print_inputs and print_outputs:
|
||||||
raise Usage(usage_msg)
|
usage_msg += 'Please specify only one of "-i" or "-o".\n'
|
||||||
|
|
||||||
if print_inputs:
|
if usage_msg:
|
||||||
return list_inputs(locales)
|
raise Usage(usage_msg)
|
||||||
|
|
||||||
if print_outputs:
|
if print_inputs:
|
||||||
return list_outputs(locales)
|
return list_inputs(locales)
|
||||||
|
|
||||||
return repack_locales(locales)
|
if print_outputs:
|
||||||
|
return list_outputs(locales)
|
||||||
if __name__ == '__main__':
|
|
||||||
results = DoMain(sys.argv[1:])
|
if not os.path.exists(INT_DIR):
|
||||||
if results:
|
os.makedirs(INT_DIR)
|
||||||
print results
|
|
||||||
|
return repack_locales(locales)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
results = DoMain(sys.argv[1:])
|
||||||
|
if results:
|
||||||
|
print results
|
||||||
|
Loading…
x
Reference in New Issue
Block a user