Commit 87430f2e authored by garykac's avatar garykac Committed by Commit bot

[Chromoting] Pass list of locale files into build-webapp in a single file.

Previously each locale filename was passed separately on the command
line. This causes problems on Windows because of the 8K command line limit.

A follow-up cl will move the webapp filenames into separate files to reduce
the liklihood that we'll encounter this limit in the future.

BUG=

Review URL: https://codereview.chromium.org/905553002

Cr-Commit-Position: refs/heads/master@{#314966}
parent 7602e721
...@@ -71,6 +71,8 @@ ...@@ -71,6 +71,8 @@
'remoting_app_name': '>(_app_name)', 'remoting_app_name': '>(_app_name)',
'remoting_app_description': '>(_app_description)', 'remoting_app_description': '>(_app_description)',
'ar_webapp_locales_listfile': '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)_locales.txt',
'conditions': [ 'conditions': [
['ar_internal != 1', { ['ar_internal != 1', {
'ar_app_name': 'sample_app', 'ar_app_name': 'sample_app',
...@@ -87,6 +89,23 @@ ...@@ -87,6 +89,23 @@
}, # variables }, # variables
'actions': [ 'actions': [
{
'action_name': 'Build ">(ar_app_name)" locales listfile',
'inputs': [
'<(remoting_localize_path)',
],
'outputs': [
'<(ar_webapp_locales_listfile)',
],
'action': [
'python', '<(remoting_localize_path)',
'--locale_output',
'"<(webapp_locale_dir)/@{json_suffix}/messages.json"',
'--locales_listfile',
'<(ar_webapp_locales_listfile)',
'<@(remoting_locales)',
],
},
{ {
'action_name': 'Build ">(ar_app_name)" application stub', 'action_name': 'Build ">(ar_app_name)" application stub',
'inputs': [ 'inputs': [
...@@ -98,6 +117,7 @@ ...@@ -98,6 +117,7 @@
'<@(ar_generated_html_files)', '<@(ar_generated_html_files)',
'<(ar_app_manifest_app)', '<(ar_app_manifest_app)',
'<(DEPTH)/remoting/<(ar_app_manifest_common)', '<(DEPTH)/remoting/<(ar_app_manifest_common)',
'<(ar_webapp_locales_listfile)',
], ],
'outputs': [ 'outputs': [
'<(output_dir)', '<(output_dir)',
...@@ -113,8 +133,8 @@ ...@@ -113,8 +133,8 @@
'app_remoting', # Web app type 'app_remoting', # Web app type
'<@(ar_webapp_files)', '<@(ar_webapp_files)',
'<@(ar_generated_html_files)', '<@(ar_generated_html_files)',
'--locales', '--locales_listfile',
'<@(remoting_webapp_locale_files)', '<(ar_webapp_locales_listfile)',
'--jinja_paths', '--jinja_paths',
'<(DEPTH)/remoting/webapp/app_remoting', '<(DEPTH)/remoting/webapp/app_remoting',
'<@(remoting_app_id)', '<@(remoting_app_id)',
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
'<(SHARED_INTERMEDIATE_DIR)/wcs_sandbox.html', '<(SHARED_INTERMEDIATE_DIR)/wcs_sandbox.html',
'<(SHARED_INTERMEDIATE_DIR)/background.html', '<(SHARED_INTERMEDIATE_DIR)/background.html',
], ],
'dr_webapp_locales_listfile': '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)_locales.txt',
}, },
'dependencies': [ 'dependencies': [
'remoting_resources', 'remoting_resources',
...@@ -46,6 +47,23 @@ ...@@ -46,6 +47,23 @@
}], }],
], ],
'actions': [ 'actions': [
{
'action_name': 'Build Remoting locales listfile',
'inputs': [
'<(remoting_localize_path)',
],
'outputs': [
'<(dr_webapp_locales_listfile)',
],
'action': [
'python', '<(remoting_localize_path)',
'--locale_output',
'"<(webapp_locale_dir)/@{json_suffix}/messages.json"',
'--locales_listfile',
'<(dr_webapp_locales_listfile)',
'<@(remoting_locales)',
],
},
{ {
'action_name': 'Build Remoting WebApp', 'action_name': 'Build Remoting WebApp',
'inputs': [ 'inputs': [
...@@ -53,6 +71,7 @@ ...@@ -53,6 +71,7 @@
'webapp/crd/manifest.json.jinja2', 'webapp/crd/manifest.json.jinja2',
'<(chrome_version_path)', '<(chrome_version_path)',
'<(remoting_version_path)', '<(remoting_version_path)',
'<(dr_webapp_locales_listfile)',
'<@(generated_html_files)', '<@(generated_html_files)',
'<@(remoting_webapp_crd_files)', '<@(remoting_webapp_crd_files)',
'<@(remoting_webapp_locale_files)', '<@(remoting_webapp_locale_files)',
...@@ -73,7 +92,8 @@ ...@@ -73,7 +92,8 @@
'<@(generated_html_files)', '<@(generated_html_files)',
'<@(remoting_webapp_crd_files)', '<@(remoting_webapp_crd_files)',
'<@(extra_files)', '<@(extra_files)',
'--locales', '<@(remoting_webapp_locale_files)', '--locales_listfile',
'<(dr_webapp_locales_listfile)',
], ],
}, },
], ],
......
...@@ -720,7 +720,7 @@ def Localize(source, locales, options): ...@@ -720,7 +720,7 @@ def Localize(source, locales, options):
template_file_name = target.safe_substitute(context) template_file_name = target.safe_substitute(context)
outputs.append(template_file_name) outputs.append(template_file_name)
if not options.print_only: if not options.print_only and not options.locales_listfile:
WriteIfChanged(template_file_name, template.render(context), WriteIfChanged(template_file_name, template.render(context),
options.encoding) options.encoding)
else: else:
...@@ -733,6 +733,11 @@ def Localize(source, locales, options): ...@@ -733,6 +733,11 @@ def Localize(source, locales, options):
# it into a list. # it into a list.
return " ".join(['"%s"' % x for x in outputs]) return " ".join(['"%s"' % x for x in outputs])
if options.locales_listfile:
# Strip off the quotes from each filename when writing into a listfile.
content = u'\n'.join([x.strip('"') for x in outputs])
WriteIfChanged(options.locales_listfile, content, options.encoding)
return return
...@@ -760,6 +765,9 @@ def DoMain(argv): ...@@ -760,6 +765,9 @@ def DoMain(argv):
parser.add_option( parser.add_option(
'--print_only', dest='print_only', action='store_true', '--print_only', dest='print_only', action='store_true',
default=False, help='print the output file names only.') default=False, help='print the output file names only.')
parser.add_option(
'--locales_listfile', dest='locales_listfile', type='string',
help='print the output file names into the specified file.')
parser.add_option( parser.add_option(
'-t', '--template', dest='template', type='string', '-t', '--template', dest='template', type='string',
help="specify the template file name.") help="specify the template file name.")
...@@ -773,11 +781,12 @@ def DoMain(argv): ...@@ -773,11 +781,12 @@ def DoMain(argv):
if bool(options.output) == bool(options.locale_output): if bool(options.output) == bool(options.locale_output):
parser.error( parser.error(
'Either --output or --locale_output must be specified but not both') 'Either --output or --locale_output must be specified but not both')
if not options.template and not options.print_only: if (not options.template and
parser.error('The template name is required unless --print_only is used') not options.print_only and not options.locales_listfile):
parser.error('The template name is required unless either --print_only '
'or --locales_listfile is used')
return Localize(options.template, locales, options) return Localize(options.template, locales, options)
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(DoMain(sys.argv[1:])) sys.exit(DoMain(sys.argv[1:]))
...@@ -365,14 +365,14 @@ def main(): ...@@ -365,14 +365,14 @@ def main():
'--app_description <description> ' '--app_description <description> '
'--app_capabilities <capabilities...> ' '--app_capabilities <capabilities...> '
'[--appid <appid>] ' '[--appid <appid>] '
'[--locales <locales...>] ' '[--locales_listfile <locales-listfile-name>] '
'[--jinja_paths <paths...>] ' '[--jinja_paths <paths...>] '
'[--service_environment <service_environment>]') '[--service_environment <service_environment>]')
return 1 return 1
arg_type = '' arg_type = ''
files = [] files = []
locales = [] locales_listfile = ''
jinja_paths = [] jinja_paths = []
app_id = None app_id = None
app_name = None app_name = None
...@@ -381,7 +381,7 @@ def main(): ...@@ -381,7 +381,7 @@ def main():
service_environment = '' service_environment = ''
for arg in sys.argv[7:]: for arg in sys.argv[7:]:
if arg in ['--locales', if arg in ['--locales_listfile',
'--jinja_paths', '--jinja_paths',
'--appid', '--appid',
'--app_name', '--app_name',
...@@ -389,8 +389,9 @@ def main(): ...@@ -389,8 +389,9 @@ def main():
'--app_capabilities', '--app_capabilities',
'--service_environment']: '--service_environment']:
arg_type = arg arg_type = arg
elif arg_type == '--locales': elif arg_type == '--locales_listfile':
locales.append(arg) locales_listfile = arg
arg_type = ''
elif arg_type == '--jinja_paths': elif arg_type == '--jinja_paths':
jinja_paths.append(arg) jinja_paths.append(arg)
elif arg_type == '--appid': elif arg_type == '--appid':
...@@ -410,6 +411,14 @@ def main(): ...@@ -410,6 +411,14 @@ def main():
else: else:
files.append(arg) files.append(arg)
# Load the locales files from the locales_listfile.
if not locales_listfile:
raise Exception('You must specify a locales_listfile')
locales = []
with open(locales_listfile) as input:
for s in input:
locales.append(s.rstrip())
return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], return buildWebApp(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4],
sys.argv[5], sys.argv[6], app_id, app_name, sys.argv[5], sys.argv[6], app_id, app_name,
app_description, app_capabilities, files, locales, app_description, app_capabilities, files, locales,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment