Revert "mc: Copy over checked-in outputs on non-Windows hosts."
This reverts commit d000a95b5c7189076d3e6d61f243caef3edeaa48. Reason for revert: Speculating that this CL has caused a tree closure - see https://build.chromium.org/p/chromium.chrome/builders/Google%20Chrome%20Win/builds/21668 Original change's description: > mc: Copy over checked-in outputs on non-Windows hosts. > > On Windows hosts, verify that the checked-in outputs are identical to > what mc.exe actually produces. > > Bug: 756607 > Change-Id: If827c2b5d64730a27cf409af25783794366c1843 > Reviewed-on: https://chromium-review.googlesource.com/646659 > Commit-Queue: Nico Weber <thakis@chromium.org> > Reviewed-by: Scott Graham <scottmg@chromium.org> > Cr-Commit-Position: refs/heads/master@{#499221} TBR=thakis@chromium.org,scottmg@chromium.org Change-Id: I9d2dc77942bdba7198ed442cedb2f3d815510f9f No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: 756607 Reviewed-on: https://chromium-review.googlesource.com/648146 Reviewed-by: Łukasz Anforowicz <lukasza@chromium.org> Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#499227} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: ea662297506102da12eb1ee04e40fad15b77a1d5
This commit is contained in:
Родитель
1285fcddfc
Коммит
2fc869313f
|
@ -7,66 +7,22 @@
|
||||||
#
|
#
|
||||||
# Usage: message_compiler.py <environment_file> [<args to mc.exe>*]
|
# Usage: message_compiler.py <environment_file> [<args to mc.exe>*]
|
||||||
|
|
||||||
import distutils.dir_util
|
|
||||||
import filecmp
|
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import shutil
|
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
env_file, rest = sys.argv[1], sys.argv[2:]
|
|
||||||
|
|
||||||
# Parse some argument flags.
|
|
||||||
header_dir = None
|
|
||||||
resource_dir = None
|
|
||||||
input_file = None
|
|
||||||
for i, arg in enumerate(rest):
|
|
||||||
if arg == '-h' and len(rest) > i + 1:
|
|
||||||
assert header_dir == None
|
|
||||||
header_dir = rest[i + 1]
|
|
||||||
elif arg == '-r' and len(rest) > i + 1:
|
|
||||||
assert resource_dir == None
|
|
||||||
resource_dir = rest[i + 1]
|
|
||||||
elif arg.endswith('.mc') or arg.endswith('.man'):
|
|
||||||
assert input_file == None
|
|
||||||
input_file = arg
|
|
||||||
|
|
||||||
# Copy checked-in outputs to final location.
|
|
||||||
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
|
|
||||||
assert header_dir == resource_dir
|
|
||||||
source = os.path.join(THIS_DIR, "..", "..",
|
|
||||||
"third_party", "win_build_output",
|
|
||||||
re.sub(r'^(?:[^/]+/)?gen/', 'mc/', header_dir))
|
|
||||||
distutils.dir_util.copy_tree(source, header_dir, preserve_times=False)
|
|
||||||
|
|
||||||
# On non-Windows, that's all we can do.
|
|
||||||
if sys.platform != 'win32':
|
|
||||||
return
|
|
||||||
|
|
||||||
# On Windows, run mc.exe on the input and check that its outputs are
|
|
||||||
# identical to the checked-in outputs.
|
|
||||||
|
|
||||||
# Read the environment block from the file. This is stored in the format used
|
# Read the environment block from the file. This is stored in the format used
|
||||||
# by CreateProcess. Drop last 2 NULs, one for list terminator, one for
|
# by CreateProcess. Drop last 2 NULs, one for list terminator, one for
|
||||||
# trailing vs. separator.
|
# trailing vs. separator.
|
||||||
env_pairs = open(env_file).read()[:-2].split('\0')
|
env_pairs = open(sys.argv[1]).read()[:-2].split('\0')
|
||||||
env_dict = dict([item.split('=', 1) for item in env_pairs])
|
env_dict = dict([item.split('=', 1) for item in env_pairs])
|
||||||
|
|
||||||
# mc writes to stderr, so this explicitly redirects to stdout and eats it.
|
# mc writes to stderr, so this explicitly redirects to stdout and eats it.
|
||||||
try:
|
try:
|
||||||
tmp_dir = tempfile.mkdtemp()
|
|
||||||
if header_dir:
|
|
||||||
rest[rest.index('-h') + 1] = tmp_dir
|
|
||||||
header_dir = tmp_dir
|
|
||||||
if resource_dir:
|
|
||||||
rest[rest.index('-r') + 1] = tmp_dir
|
|
||||||
resource_dir = tmp_dir
|
|
||||||
|
|
||||||
# This needs shell=True to search the path in env_dict for the mc
|
# This needs shell=True to search the path in env_dict for the mc
|
||||||
# executable.
|
# executable.
|
||||||
|
rest = sys.argv[2:]
|
||||||
subprocess.check_output(['mc.exe'] + rest,
|
subprocess.check_output(['mc.exe'] + rest,
|
||||||
env=env_dict,
|
env=env_dict,
|
||||||
stderr=subprocess.STDOUT,
|
stderr=subprocess.STDOUT,
|
||||||
|
@ -79,6 +35,15 @@ def main():
|
||||||
# it generates an ANSI header, and includes broken versions of the message
|
# it generates an ANSI header, and includes broken versions of the message
|
||||||
# text in the comment before the value. To work around this, for any invalid
|
# text in the comment before the value. To work around this, for any invalid
|
||||||
# // comment lines, we simply drop the line in the header after building it.
|
# // comment lines, we simply drop the line in the header after building it.
|
||||||
|
header_dir = None
|
||||||
|
input_file = None
|
||||||
|
for i, arg in enumerate(rest):
|
||||||
|
if arg == '-h' and len(rest) > i + 1:
|
||||||
|
assert header_dir == None
|
||||||
|
header_dir = rest[i + 1]
|
||||||
|
elif arg.endswith('.mc') or arg.endswith('.man'):
|
||||||
|
assert input_file == None
|
||||||
|
input_file = arg
|
||||||
if header_dir:
|
if header_dir:
|
||||||
header_file = os.path.join(
|
header_file = os.path.join(
|
||||||
header_dir, os.path.splitext(os.path.basename(input_file))[0] + '.h')
|
header_dir, os.path.splitext(os.path.basename(input_file))[0] + '.h')
|
||||||
|
@ -90,20 +55,9 @@ def main():
|
||||||
header_contents.append(line)
|
header_contents.append(line)
|
||||||
with open(header_file, 'wb') as f:
|
with open(header_file, 'wb') as f:
|
||||||
f.write(''.join(header_contents))
|
f.write(''.join(header_contents))
|
||||||
|
|
||||||
# mc.exe invocation and post-processing are complete, now compare the output
|
|
||||||
# in tmp_dir to the checked-in outputs.
|
|
||||||
diff = filecmp.dircmp(tmp_dir, source)
|
|
||||||
if diff.diff_files or set(diff.left_list) != set(diff.right_list):
|
|
||||||
print >>sys.stderr, 'mc.exe output different from files in %s, see %s' % (
|
|
||||||
source, tmp_dir)
|
|
||||||
sys.exit(1) # Intentionally skips finally: that deletes the temp dir.
|
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print e.output
|
print e.output
|
||||||
sys.exit(e.returncode)
|
sys.exit(e.returncode)
|
||||||
finally:
|
|
||||||
if os.path.exists(tmp_dir):
|
|
||||||
shutil.rmtree(tmp_dir)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Загрузка…
Ссылка в новой задаче