Commit e510762b authored by David Tseng's avatar David Tseng Committed by Commit Bot

Revert "Support compressed .json grit files and compress chromevox messages"

This reverts commit 00f512ce.

Reason for revert: <INSERT REASONING HERE>
Speculative fix for crbug.com/1026473
Tests are unable to find any message strings.
Bug: 1026473
Original change's description:
> Support compressed .json grit files and compress chromevox messages
>
> This provides support for --gzip-output in grit/build.py, which:
> 1. Compresses individual output files.
> 2. Appends .gz to the compressed output files
>    (e.g. messages.json -> messages.json.gz).
>
> This makes it fairly simple to convert an extension (e.g. chromevox)
> to use compressed l10n files. Other than setting gzip_output = true
> in the .gn file, the only other required change is updating any
> test dependencies.
>
> Bug: 1023568
> Change-Id: I8318b1d87b828b512f890c6f2cf6d4d22462ed7d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1913610
> Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
> Reviewed-by: David Tseng <dtseng@chromium.org>
> Reviewed-by: Andrew Grieve <agrieve@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#716284}

TBR=stevenjb@chromium.org,dtseng@chromium.org,agrieve@chromium.org

NOTRY=true

Bug: 1023568
Change-Id: I4b506ef6d574a1e300383359aa2fbdc81b332252
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925888Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Commit-Queue: David Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716900}
parent f0e3fb7a
...@@ -400,7 +400,7 @@ if (is_chromeos) { ...@@ -400,7 +400,7 @@ if (is_chromeos) {
action("chromevox_test_messages_js") { action("chromevox_test_messages_js") {
script = "tools/generate_test_messages.py" script = "tools/generate_test_messages.py"
sources = [ sources = [
"$chromevox_out_dir/_locales/en/messages.json.gz", "$chromevox_out_dir/_locales/en/messages.json",
] ]
output_file = "$root_out_dir/test_data/chrome/browser/resources/chromeos/chromevox/host/testing/test_messages.js" output_file = "$root_out_dir/test_data/chrome/browser/resources/chromeos/chromevox/host/testing/test_messages.js"
outputs = [ outputs = [
......
...@@ -10,59 +10,59 @@ template("chromevox_strings") { ...@@ -10,59 +10,59 @@ template("chromevox_strings") {
source = "//chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd" source = "//chrome/browser/resources/chromeos/chromevox/strings/chromevox_strings.grd"
defines = chrome_grit_defines defines = chrome_grit_defines
outputs = [ outputs = [
"_locales/am/messages.json.gz", "_locales/am/messages.json",
"_locales/ar/messages.json.gz", "_locales/ar/messages.json",
"_locales/bg/messages.json.gz", "_locales/bg/messages.json",
"_locales/bn/messages.json.gz", "_locales/bn/messages.json",
"_locales/ca/messages.json.gz", "_locales/ca/messages.json",
"_locales/cs/messages.json.gz", "_locales/cs/messages.json",
"_locales/da/messages.json.gz", "_locales/da/messages.json",
"_locales/de/messages.json.gz", "_locales/de/messages.json",
"_locales/el/messages.json.gz", "_locales/el/messages.json",
"_locales/en_GB/messages.json.gz", "_locales/en_GB/messages.json",
"_locales/en/messages.json.gz", "_locales/en/messages.json",
"_locales/es/messages.json.gz", "_locales/es/messages.json",
"_locales/es_419/messages.json.gz", "_locales/es_419/messages.json",
"_locales/et/messages.json.gz", "_locales/et/messages.json",
"_locales/fa/messages.json.gz", "_locales/fa/messages.json",
"_locales/fi/messages.json.gz", "_locales/fi/messages.json",
"_locales/fil/messages.json.gz", "_locales/fil/messages.json",
"_locales/fr/messages.json.gz", "_locales/fr/messages.json",
"_locales/gu/messages.json.gz", "_locales/gu/messages.json",
"_locales/he/messages.json.gz", "_locales/he/messages.json",
"_locales/hi/messages.json.gz", "_locales/hi/messages.json",
"_locales/hr/messages.json.gz", "_locales/hr/messages.json",
"_locales/hu/messages.json.gz", "_locales/hu/messages.json",
"_locales/id/messages.json.gz", "_locales/id/messages.json",
"_locales/it/messages.json.gz", "_locales/it/messages.json",
"_locales/ja/messages.json.gz", "_locales/ja/messages.json",
"_locales/kn/messages.json.gz", "_locales/kn/messages.json",
"_locales/ko/messages.json.gz", "_locales/ko/messages.json",
"_locales/lt/messages.json.gz", "_locales/lt/messages.json",
"_locales/lv/messages.json.gz", "_locales/lv/messages.json",
"_locales/ml/messages.json.gz", "_locales/ml/messages.json",
"_locales/mr/messages.json.gz", "_locales/mr/messages.json",
"_locales/ms/messages.json.gz", "_locales/ms/messages.json",
"_locales/nl/messages.json.gz", "_locales/nl/messages.json",
"_locales/nb/messages.json.gz", "_locales/nb/messages.json",
"_locales/pl/messages.json.gz", "_locales/pl/messages.json",
"_locales/pt_BR/messages.json.gz", "_locales/pt_BR/messages.json",
"_locales/pt_PT/messages.json.gz", "_locales/pt_PT/messages.json",
"_locales/ro/messages.json.gz", "_locales/ro/messages.json",
"_locales/ru/messages.json.gz", "_locales/ru/messages.json",
"_locales/sk/messages.json.gz", "_locales/sk/messages.json",
"_locales/sl/messages.json.gz", "_locales/sl/messages.json",
"_locales/sr/messages.json.gz", "_locales/sr/messages.json",
"_locales/sv/messages.json.gz", "_locales/sv/messages.json",
"_locales/sw/messages.json.gz", "_locales/sw/messages.json",
"_locales/ta/messages.json.gz", "_locales/ta/messages.json",
"_locales/te/messages.json.gz", "_locales/te/messages.json",
"_locales/th/messages.json.gz", "_locales/th/messages.json",
"_locales/tr/messages.json.gz", "_locales/tr/messages.json",
"_locales/uk/messages.json.gz", "_locales/uk/messages.json",
"_locales/vi/messages.json.gz", "_locales/vi/messages.json",
"_locales/zh_CN/messages.json.gz", "_locales/zh_CN/messages.json",
"_locales/zh_TW/messages.json.gz", "_locales/zh_TW/messages.json",
] ]
output_dir = invoker.out_dir output_dir = invoker.out_dir
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
'''Generates test_messages.js from an extension message json file.''' '''Generates test_messages.js from an extension message json file.'''
import gzip
import optparse import optparse
import sys import sys
...@@ -36,11 +35,7 @@ def main(): ...@@ -36,11 +35,7 @@ def main():
if len(args) != 1: if len(args) != 1:
Die('Exactly one input file must be specified') Die('Exactly one input file must be specified')
in_file_name = args[0] in_file_name = args[0]
def _OpenFile(filename): with open(in_file_name) as in_file:
if filename.endswith('.gz'):
return gzip.open(filename)
return open(filename)
with _OpenFile(in_file_name) as in_file:
json = in_file.read().strip() json = in_file.read().strip()
with open(options.output_file, 'w') as out_file: with open(options.output_file, 'w') as out_file:
out_file.write(_JS_TEMPLATE % {'in_file': in_file_name, 'json': json}) out_file.write(_JS_TEMPLATE % {'in_file': in_file_name, 'json': json})
......
...@@ -10,7 +10,6 @@ from __future__ import print_function ...@@ -10,7 +10,6 @@ from __future__ import print_function
import codecs import codecs
import filecmp import filecmp
import getopt import getopt
import gzip
import os import os
import shutil import shutil
import sys import sys
...@@ -35,7 +34,6 @@ _format_modules = { ...@@ -35,7 +34,6 @@ _format_modules = {
'android': 'android_xml', 'android': 'android_xml',
'c_format': 'c_format', 'c_format': 'c_format',
'chrome_messages_json': 'chrome_messages_json', 'chrome_messages_json': 'chrome_messages_json',
'chrome_messages_json_gzip': 'chrome_messages_json',
'data_package': 'data_pack', 'data_package': 'data_pack',
'policy_templates': 'policy_templates_json', 'policy_templates': 'policy_templates_json',
'rc_all': 'rc', 'rc_all': 'rc',
...@@ -361,7 +359,7 @@ are exported to translation interchange files (e.g. XMB files), etc. ...@@ -361,7 +359,7 @@ are exported to translation interchange files (e.g. XMB files), etc.
return 'cp1252' return 'cp1252'
if output_type in ('android', 'c_format', 'plist', 'plist_strings', 'doc', if output_type in ('android', 'c_format', 'plist', 'plist_strings', 'doc',
'json', 'android_policy', 'chrome_messages_json', 'json', 'android_policy', 'chrome_messages_json',
'chrome_messages_json_gzip', 'policy_templates'): 'policy_templates'):
return 'utf_8' return 'utf_8'
# TODO(gfeher) modify here to set utf-8 encoding for admx/adml # TODO(gfeher) modify here to set utf-8 encoding for admx/adml
return 'utf_16' return 'utf_16'
...@@ -394,34 +392,24 @@ are exported to translation interchange files (e.g. XMB files), etc. ...@@ -394,34 +392,24 @@ are exported to translation interchange files (e.g. XMB files), etc.
# Write the results to a temporary file and only overwrite the original # Write the results to a temporary file and only overwrite the original
# if the file changed. This avoids unnecessary rebuilds. # if the file changed. This avoids unnecessary rebuilds.
out_filename = output.GetOutputFilename() outfile = self.fo_create(output.GetOutputFilename() + '.tmp', 'wb')
tmp_filename = out_filename + '.tmp'
tmpfile = self.fo_create(tmp_filename, 'wb')
output_type = output.GetType() if output.GetType() != 'data_package':
if output_type != 'data_package': encoding = self._EncodingForOutputType(output.GetType())
encoding = self._EncodingForOutputType(output_type) outfile = util.WrapOutputStream(outfile, encoding)
tmpfile = util.WrapOutputStream(tmpfile, encoding)
# Iterate in-order through entire resource tree, calling formatters on # Iterate in-order through entire resource tree, calling formatters on
# the entry into a node and on exit out of it. # the entry into a node and on exit out of it.
with tmpfile: with outfile:
self.ProcessNode(self.res, output, tmpfile) self.ProcessNode(self.res, output, outfile)
if output_type == 'chrome_messages_json_gzip':
gz_filename = tmp_filename + '.gz'
with open(tmp_filename, 'rb') as tmpfile, open(gz_filename, 'wb') as f:
with gzip.GzipFile(filename='', mode='wb', fileobj=f, mtime=0) as fgz:
shutil.copyfileobj(tmpfile, fgz)
os.remove(tmp_filename)
tmp_filename = gz_filename
# Now copy from the temp file back to the real output, but on Windows, # Now copy from the temp file back to the real output, but on Windows,
# only if the real output doesn't exist or the contents of the file # only if the real output doesn't exist or the contents of the file
# changed. This prevents identical headers from being written and .cc # changed. This prevents identical headers from being written and .cc
# files from recompiling (which is painful on Windows). # files from recompiling (which is painful on Windows).
if not os.path.exists(out_filename): if not os.path.exists(output.GetOutputFilename()):
os.rename(tmp_filename, out_filename) os.rename(output.GetOutputFilename() + '.tmp',
output.GetOutputFilename())
else: else:
# CHROMIUM SPECIFIC CHANGE. # CHROMIUM SPECIFIC CHANGE.
# This clashes with gyp + vstudio, which expect the output timestamp # This clashes with gyp + vstudio, which expect the output timestamp
...@@ -430,11 +418,13 @@ are exported to translation interchange files (e.g. XMB files), etc. ...@@ -430,11 +418,13 @@ are exported to translation interchange files (e.g. XMB files), etc.
if not self.write_only_new: if not self.write_only_new:
write_file = True write_file = True
else: else:
files_match = filecmp.cmp(out_filename, tmp_filename) files_match = filecmp.cmp(output.GetOutputFilename(),
output.GetOutputFilename() + '.tmp')
write_file = not files_match write_file = not files_match
if write_file: if write_file:
shutil.copy2(tmp_filename, out_filename) shutil.copy2(output.GetOutputFilename() + '.tmp',
os.remove(tmp_filename) output.GetOutputFilename())
os.remove(output.GetOutputFilename() + '.tmp')
self.VerboseOut(' done.\n') self.VerboseOut(' done.\n')
......
...@@ -480,8 +480,7 @@ template("grit") { ...@@ -480,8 +480,7 @@ template("grit") {
sources = [] sources = []
foreach(output, grit_outputs) { foreach(output, grit_outputs) {
extension = get_path_info(output, "extension") extension = get_path_info(output, "extension")
if (extension != "json" && extension != "gz" && extension != "pak" && if (extension != "json" && extension != "pak" && extension != "xml") {
extension != "xml") {
sources += [ output ] sources += [ output ]
} }
} }
......
...@@ -459,7 +459,7 @@ chromevox_strings("chromevox_strings") { ...@@ -459,7 +459,7 @@ chromevox_strings("chromevox_strings") {
action("chromevox_test_messages_js") { action("chromevox_test_messages_js") {
script = "//chrome/browser/resources/chromeos/chromevox/tools/generate_test_messages.py" script = "//chrome/browser/resources/chromeos/chromevox/tools/generate_test_messages.py"
sources = [ sources = [
"$chromevox_out_dir/_locales/en/messages.json.gz", "$chromevox_out_dir/_locales/en/messages.json",
] ]
output_file = "$root_out_dir/test_data/ui/accessibility/extensions/chromevoxclassic/host/testing/test_messages.js" output_file = "$root_out_dir/test_data/ui/accessibility/extensions/chromevoxclassic/host/testing/test_messages.js"
outputs = [ outputs = [
......
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