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 @@
'remoting_app_name': '>(_app_name)',
'remoting_app_description': '>(_app_description)',
'ar_webapp_locales_listfile': '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)_locales.txt',
'conditions': [
['ar_internal != 1', {
'ar_app_name': 'sample_app',
......@@ -87,6 +89,23 @@
}, # variables
'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',
'inputs': [
......@@ -98,6 +117,7 @@
'<@(ar_generated_html_files)',
'<(ar_app_manifest_app)',
'<(DEPTH)/remoting/<(ar_app_manifest_common)',
'<(ar_webapp_locales_listfile)',
],
'outputs': [
'<(output_dir)',
......@@ -113,8 +133,8 @@
'app_remoting', # Web app type
'<@(ar_webapp_files)',
'<@(ar_generated_html_files)',
'--locales',
'<@(remoting_webapp_locale_files)',
'--locales_listfile',
'<(ar_webapp_locales_listfile)',
'--jinja_paths',
'<(DEPTH)/remoting/webapp/app_remoting',
'<@(remoting_app_id)',
......
......@@ -13,6 +13,7 @@
'<(SHARED_INTERMEDIATE_DIR)/wcs_sandbox.html',
'<(SHARED_INTERMEDIATE_DIR)/background.html',
],
'dr_webapp_locales_listfile': '<(SHARED_INTERMEDIATE_DIR)/>(_target_name)_locales.txt',
},
'dependencies': [
'remoting_resources',
......@@ -46,6 +47,23 @@
}],
],
'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',
'inputs': [
......@@ -53,6 +71,7 @@
'webapp/crd/manifest.json.jinja2',
'<(chrome_version_path)',
'<(remoting_version_path)',
'<(dr_webapp_locales_listfile)',
'<@(generated_html_files)',
'<@(remoting_webapp_crd_files)',
'<@(remoting_webapp_locale_files)',
......@@ -73,7 +92,8 @@
'<@(generated_html_files)',
'<@(remoting_webapp_crd_files)',
'<@(extra_files)',
'--locales', '<@(remoting_webapp_locale_files)',
'--locales_listfile',
'<(dr_webapp_locales_listfile)',
],
},
],
......
......@@ -720,7 +720,7 @@ def Localize(source, locales, options):
template_file_name = target.safe_substitute(context)
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),
options.encoding)
else:
......@@ -733,6 +733,11 @@ def Localize(source, locales, options):
# it into a list.
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
......@@ -760,6 +765,9 @@ def DoMain(argv):
parser.add_option(
'--print_only', dest='print_only', action='store_true',
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(
'-t', '--template', dest='template', type='string',
help="specify the template file name.")
......@@ -773,11 +781,12 @@ def DoMain(argv):
if bool(options.output) == bool(options.locale_output):
parser.error(
'Either --output or --locale_output must be specified but not both')
if not options.template and not options.print_only:
parser.error('The template name is required unless --print_only is used')
if (not options.template and
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)
if __name__ == '__main__':
sys.exit(DoMain(sys.argv[1:]))
......@@ -365,14 +365,14 @@ def main():
'--app_description <description> '
'--app_capabilities <capabilities...> '
'[--appid <appid>] '
'[--locales <locales...>] '
'[--locales_listfile <locales-listfile-name>] '
'[--jinja_paths <paths...>] '
'[--service_environment <service_environment>]')
return 1
arg_type = ''
files = []
locales = []
locales_listfile = ''
jinja_paths = []
app_id = None
app_name = None
......@@ -381,7 +381,7 @@ def main():
service_environment = ''
for arg in sys.argv[7:]:
if arg in ['--locales',
if arg in ['--locales_listfile',
'--jinja_paths',
'--appid',
'--app_name',
......@@ -389,8 +389,9 @@ def main():
'--app_capabilities',
'--service_environment']:
arg_type = arg
elif arg_type == '--locales':
locales.append(arg)
elif arg_type == '--locales_listfile':
locales_listfile = arg
arg_type = ''
elif arg_type == '--jinja_paths':
jinja_paths.append(arg)
elif arg_type == '--appid':
......@@ -410,6 +411,14 @@ def main():
else:
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],
sys.argv[5], sys.argv[6], app_id, app_name,
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