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

Side by Side Diff: generate_localizer

Issue 11026078: ibtool SDKROOT (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome/tools/build/mac/
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Usage: generate_localizer [xib_path] [output_dot_h_path] [output_dot_mm_path] 7 # Usage: generate_localizer [xib_path] [output_dot_h_path] [output_dot_mm_path]
8 # 8 #
9 # Extracts all the localizable strings that start with "^IDS" from the given 9 # Extracts all the localizable strings that start with "^IDS" from the given
10 # xib file, and then generates a localizer to process those strings. 10 # xib file, and then generates a localizer to process those strings.
(...skipping 24 matching lines...) Expand all
35 %(resource_map_list)s }; 35 %(resource_map_list)s };
36 static const size_t kUIResourcesSize = arraysize(kUIResources); 36 static const size_t kUIResourcesSize = arraysize(kUIResources);
37 37
38 #endif // UI_LOCALIZER_TABLE_H_ 38 #endif // UI_LOCALIZER_TABLE_H_
39 ''' 39 '''
40 40
41 def xib_localizable_strings(xib_path): 41 def xib_localizable_strings(xib_path):
42 """Runs ibtool to extract the localizable strings data from the xib.""" 42 """Runs ibtool to extract the localizable strings data from the xib."""
43 tools_dir = os.environ.get('DEVELOPER_BIN_DIR', '/usr/bin') 43 tools_dir = os.environ.get('DEVELOPER_BIN_DIR', '/usr/bin')
44 tool_path = os.path.join(tools_dir, 'ibtool') 44 tool_path = os.path.join(tools_dir, 'ibtool')
45
46 # Take SDKROOT out of the environment passed to ibtool. ibtool itself has
47 # no need for it, but when ibtool runs via xcrun and Xcode isn't aware of
48 # the SDK in use, its presence causes an error.
49 if 'SDKROOT' in os.environ:
50 ibtool_env = os.environ.copy()
51 del ibtool_env['SDKROOT']
52 else:
53 ibtool_env = os.environ
54
45 ibtool_cmd = subprocess.Popen([tool_path, '--localizable-strings', xib_path], 55 ibtool_cmd = subprocess.Popen([tool_path, '--localizable-strings', xib_path],
46 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 56 stdout=subprocess.PIPE, stderr=subprocess.PIPE,
57 env=ibtool_env)
47 (cmd_out, cmd_err) = ibtool_cmd.communicate() 58 (cmd_out, cmd_err) = ibtool_cmd.communicate()
48 if ibtool_cmd.returncode: 59 if ibtool_cmd.returncode:
49 sys.stderr.write('%s:0: error: ibtool on "%s" failed (%d):\n%s\n' % 60 sys.stderr.write('%s:0: error: ibtool on "%s" failed (%d):\n%s\n' %
50 (generate_localizer, xib_path, ibtool_cmd.returncode, 61 (generate_localizer, xib_path, ibtool_cmd.returncode,
51 cmd_err)) 62 cmd_err))
52 return None 63 return None
53 return cmd_out 64 return cmd_out
54 65
55 def extract_resource_constants(plist_localizable_strings_dict, xib_path): 66 def extract_resource_constants(plist_localizable_strings_dict, xib_path):
56 """Extracts all the values that start with ^IDS from the localizable 67 """Extracts all the values that start with ^IDS from the localizable
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 136
126 # Write out the file 137 # Write out the file
127 file_fd = open(output_path, 'w') 138 file_fd = open(output_path, 'w')
128 file_fd.write(h_file_content) 139 file_fd.write(h_file_content)
129 file_fd.close() 140 file_fd.close()
130 141
131 return 0 142 return 0
132 143
133 if __name__ == '__main__': 144 if __name__ == '__main__':
134 sys.exit(Main(sys.argv)) 145 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698