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:
Marshall Greenblatt 2013-08-19 18:31:42 +00:00
parent 940d2c474d
commit 405ea14138
2 changed files with 206 additions and 245 deletions

77
cef.gyp
View File

@ -584,70 +584,25 @@
'<(DEPTH)/webkit/webkit_resources.gyp:webkit_strings',
'cef_strings',
],
'variables': {
'repack_locales_cmd': ['python', 'tools/repack_locales.py'],
},
'copies': [
'actions': [
{
'destination': '<(PRODUCT_DIR)/locales',
'files': [
'<!@pymod_do_main(repack_locales -o -g <(grit_out_dir) -s <(SHARED_INTERMEDIATE_DIR) -x <(INTERMEDIATE_DIR) <(locales))'
'action_name': 'repack_locales',
'inputs': [
'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',
@ -663,7 +618,7 @@
'<(generator_path)',
],
'outputs': [
'<(about_credits_file)',
'<(PRODUCT_DIR)/cef_generate_about_credits.stamp',
],
'hard_dependency': 1,
'action': ['python',

View File

@ -29,9 +29,9 @@ class Usage(Exception):
self.msg = msg
def calc_output(locale):
def calc_output(locale, create_dir):
"""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
# reference it.
if locale == 'fake-bidi':
@ -42,9 +42,12 @@ def calc_output(locale):
# simply as 'en' (http://crbug.com/19165, http://crbug.com/25578).
if locale == 'en-US':
locale = 'en'
return '%s/repack/%s.lproj/locale.pak' % (INT_DIR, locale.replace('-', '_'))
dir = '%s/%s.lproj' % (INT_DIR, locale.replace('-', '_'))
if create_dir and not os.path.exists(dir):
os.makedirs(dir)
return dir + '/locale.pak'
else:
return os.path.join(INT_DIR, 'repack', locale + '.pak')
return os.path.join(INT_DIR, locale + '.pak')
def calc_inputs(locale):
@ -88,7 +91,7 @@ def list_outputs(locales):
"""
outputs = []
for locale in locales:
outputs.append(calc_output(locale))
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.
return " ".join(['"%s"' % x for x in outputs])
@ -113,7 +116,7 @@ def repack_locales(locales):
for locale in locales:
inputs = []
inputs += calc_inputs(locale)
output = calc_output(locale)
output = calc_output(locale, True)
data_pack.DataPack.RePack(output, inputs)
@ -176,6 +179,9 @@ Usage: %s [-h] [-i | -o] -g <DIR> -x <DIR> -s <DIR> <locale> [...]
if print_outputs:
return list_outputs(locales)
if not os.path.exists(INT_DIR):
os.makedirs(INT_DIR)
return repack_locales(locales)
if __name__ == '__main__':