Skip to content

Commit 1fffdd5

Browse files
authored
Only rename closure inputs if needed (#14937)
We rename the files we pass to closure in order to work around google/closure-compiler#3784. However when we do this it makes debugging difficult because the error messages contains temp files rather than actual input files. So, only do the renaming if actually needed.
1 parent b7f995b commit 1fffdd5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tools/building.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,17 @@ def check_closure_compiler(cmd, args, env, allowed_to_fail):
752752
return True
753753

754754

755+
# Remove this once we require python3.7 and can use std.isascii.
756+
# See: https://docs.python.org/3/library/stdtypes.html#str.isascii
757+
def isascii(s):
758+
try:
759+
s.encode('ascii')
760+
except UnicodeEncodeError:
761+
return False
762+
else:
763+
return True
764+
765+
755766
@ToolchainProfiler.profile_block('closure_compiler')
756767
def closure_compiler(filename, pretty, advanced=True, extra_closure_args=None):
757768
env = shared.env_with_node_in_path()
@@ -842,6 +853,8 @@ def add_to_path(dirname):
842853
outfile = tempfiles.get('.cc.js').name # Safe 7-bit filename
843854

844855
def move_to_safe_7bit_ascii_filename(filename):
856+
if isascii(filename):
857+
return filename
845858
safe_filename = tempfiles.get('.js').name # Safe 7-bit filename
846859
shutil.copyfile(filename, safe_filename)
847860
return os.path.relpath(safe_filename, tempfiles.tmpdir)

0 commit comments

Comments
 (0)