Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(802)

Unified Diff: pylib/gyp/mac_tool.py

Issue 825453002: Convert plist and strings to binary for iOS. (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: spacing Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pylib/gyp/mac_tool.py
diff --git a/pylib/gyp/mac_tool.py b/pylib/gyp/mac_tool.py
index c871765ca2bb69182c067a2436e3945234dbbe1d..76c9298b5be3d787e68322215b3720ee2d881ccc 100755
--- a/pylib/gyp/mac_tool.py
+++ b/pylib/gyp/mac_tool.py
@@ -45,7 +45,7 @@ class MacTool(object):
"""Transforms a tool name like copy-info-plist to CopyInfoPlist"""
return name_string.title().replace('-', '')
- def ExecCopyBundleResource(self, source, dest):
+ def ExecCopyBundleResource(self, source, dest, convert_to_binary):
"""Copies a resource file to the bundle/Resources directory, performing any
necessary compilation on each resource."""
extension = os.path.splitext(source)[1].lower()
@@ -62,7 +62,7 @@ class MacTool(object):
elif extension == '.storyboard':
return self._CopyXIBFile(source, dest)
elif extension == '.strings':
- self._CopyStringsFile(source, dest)
+ self._CopyStringsFile(source, dest, convert_to_binary)
else:
shutil.copy(source, dest)
@@ -92,7 +92,11 @@ class MacTool(object):
sys.stdout.write(line)
return ibtoolout.returncode
- def _CopyStringsFile(self, source, dest):
+ def _ConvertToBinary(self, dest):
+ subprocess.check_call([
+ 'xcrun', 'plutil', '-convert', 'binary1', '-o', dest, dest])
+
+ def _CopyStringsFile(self, source, dest, convert_to_binary):
"""Copies a .strings file using iconv to reconvert the input into UTF-16."""
input_code = self._DetectInputEncoding(source) or "UTF-8"
@@ -112,6 +116,9 @@ class MacTool(object):
fp.write(s.decode(input_code).encode('UTF-16'))
fp.close()
+ if convert_to_binary == 'True':
+ self._ConvertToBinary(dest)
+
def _DetectInputEncoding(self, file_name):
"""Reads the first few bytes from file_name and tries to guess the text
encoding. Returns None as a guess if it can't detect it."""
@@ -131,7 +138,7 @@ class MacTool(object):
else:
return None
- def ExecCopyInfoPlist(self, source, dest, *keys):
+ def ExecCopyInfoPlist(self, source, dest, convert_to_binary, *keys):
"""Copies the |source| Info.plist to the destination directory |dest|."""
# Read the source Info.plist into memory.
fd = open(source, 'r')
@@ -185,6 +192,9 @@ class MacTool(object):
# "compiled".
self._WritePkgInfo(dest)
+ if convert_to_binary == 'True':
+ self._ConvertToBinary(dest)
+
def _WritePkgInfo(self, info_plist):
"""This writes the PkgInfo file from the data stored in Info.plist."""
plist = plistlib.readPlist(info_plist)

Powered by Google App Engine
This is Rietveld 408576698