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

Unified Diff: chrome/app/nibs/generate_localizer.py

Issue 2387723002: Test CL to demonstrate GN + hermetic toolchain
Patch Set: more fixes. Created 4 years, 3 months 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
« no previous file with comments | « chrome/app/nibs/BUILD.gn ('k') | chrome/tools/build/mac/run_verify_order.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/nibs/generate_localizer.py
diff --git a/chrome/app/nibs/generate_localizer.py b/chrome/app/nibs/generate_localizer.py
index 3c846e58fb49e241c55360ad82958bc87794fed2..9c0a0e7df8552a329d9ab43640beedc94b96c7a5 100755
--- a/chrome/app/nibs/generate_localizer.py
+++ b/chrome/app/nibs/generate_localizer.py
@@ -9,6 +9,9 @@
# Extracts all the localizable strings that start with "^IDS" from the given
# xib file, and then generates a localizer to process those strings.
+
+import argparse
+import logging
import os
import plistlib
import subprocess
@@ -38,7 +41,7 @@ static const size_t kUIResourcesSize = arraysize(kUIResources);
#endif // CHROME_APP_NIBS_LOCALIZER_TABLE_H_
'''
-def xib_localizable_strings(xib_path):
+def xib_localizable_strings(xib_path, xcode_path):
"""Runs ibtool to extract the localizable strings data from the xib."""
# Take SDKROOT out of the environment passed to ibtool. ibtool itself has
# no need for it, but when ibtool runs via xcrun and Xcode isn't aware of
@@ -49,8 +52,11 @@ def xib_localizable_strings(xib_path):
else:
ibtool_env = os.environ
- ibtool_cmd = subprocess.Popen(['xcrun', 'ibtool',
- '--localizable-strings', xib_path],
+ command = ['xcrun', 'ibtool']
+ if xcode_path:
+ ibtool_env['DEVELOPER_DIR'] = xcode_path
+ command.extend(['--localizable-strings', xib_path])
+ ibtool_cmd = subprocess.Popen(command,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=ibtool_env)
(cmd_out, cmd_err) = ibtool_cmd.communicate()
@@ -104,18 +110,23 @@ def Main(argv=None):
global generate_localizer
generate_localizer = os.path.basename(argv[0])
- # Args
- if len(argv) < 3:
- sys.stderr.write('%s:0: error: Expected output file and then xibs\n' %
- generate_localizer);
- return 1
- output_path = argv[1];
- xib_paths = argv[2:]
+ parser = argparse.ArgumentParser(
+ description='Generates a header file that localizes libs.')
+ parser.add_argument('--output_path', required=True,
+ help='Path to output header file.')
+ parser.add_argument('--developer_dir', required=False,
+ help='Path to xcode.')
+ parser.add_argument('xibs', nargs='+',
+ help='A list of xibs to localize')
+ args = parser.parse_args()
+
+ output_path = args.output_path
+ xib_paths = args.xibs
full_constants_list = []
for xib_path in xib_paths:
# Run ibtool and convert to something Python can deal with
- plist_string = xib_localizable_strings(xib_path)
+ plist_string = xib_localizable_strings(xib_path, args.developer_dir)
if not plist_string:
return 2
plist = plistlib.readPlistFromString(plist_string)
« no previous file with comments | « chrome/app/nibs/BUILD.gn ('k') | chrome/tools/build/mac/run_verify_order.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698