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

Side by Side Diff: pylib/gyp/mac_tool.py

Issue 9423022: mac ninja&make: Filter out useless 'This view is clipping its content' message. (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 8 years, 10 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/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 Google Inc. All rights reserved. 2 # Copyright (c) 2012 Google Inc. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Utility functions to perform Xcode-style build steps. 6 """Utility functions to perform Xcode-style build steps.
7 7
8 These functions are executed via gyp-mac-tool when using the Makefile generator. 8 These functions are executed via gyp-mac-tool when using the Makefile generator.
9 """ 9 """
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 def ExecCopyBundleResource(self, source, dest): 44 def ExecCopyBundleResource(self, source, dest):
45 """Copies a resource file to the bundle/Resources directory, performing any 45 """Copies a resource file to the bundle/Resources directory, performing any
46 necessary compilation on each resource.""" 46 necessary compilation on each resource."""
47 extension = os.path.splitext(source)[1].lower() 47 extension = os.path.splitext(source)[1].lower()
48 if os.path.isdir(source): 48 if os.path.isdir(source):
49 # Copy tree. 49 # Copy tree.
50 if os.path.exists(dest): 50 if os.path.exists(dest):
51 shutil.rmtree(dest) 51 shutil.rmtree(dest)
52 shutil.copytree(source, dest) 52 shutil.copytree(source, dest)
53 elif extension == '.xib': 53 elif extension == '.xib':
54 self._CopyXIBFile(source, dest) 54 return self._CopyXIBFile(source, dest)
55 elif extension == '.strings': 55 elif extension == '.strings':
56 self._CopyStringsFile(source, dest) 56 self._CopyStringsFile(source, dest)
57 # TODO: Given that files with arbitrary extensions can be copied to the 57 # TODO: Given that files with arbitrary extensions can be copied to the
58 # bundle, we will want to get rid of this whitelist eventually. 58 # bundle, we will want to get rid of this whitelist eventually.
59 elif extension in [ 59 elif extension in [
60 '.icns', '.manifest', '.pak', '.pdf', '.png', '.sb', '.sh', 60 '.icns', '.manifest', '.pak', '.pdf', '.png', '.sb', '.sh',
61 '.ttf', '.sdef']: 61 '.ttf', '.sdef']:
62 shutil.copyfile(source, dest) 62 shutil.copyfile(source, dest)
63 else: 63 else:
64 raise NotImplementedError( 64 raise NotImplementedError(
65 "Don't know how to copy bundle resources of type %s while copying " 65 "Don't know how to copy bundle resources of type %s while copying "
66 "%s to %s)" % (extension, source, dest)) 66 "%s to %s)" % (extension, source, dest))
67 67
68 def _CopyXIBFile(self, source, dest): 68 def _CopyXIBFile(self, source, dest):
69 """Compiles a XIB file with ibtool into a binary plist in the bundle.""" 69 """Compiles a XIB file with ibtool into a binary plist in the bundle."""
70 args = ['/Developer/usr/bin/ibtool', '--errors', '--warnings', 70 args = ['/Developer/usr/bin/ibtool', '--errors', '--warnings',
71 '--notices', '--output-format', 'human-readable-text', '--compile', 71 '--notices', '--output-format', 'human-readable-text', '--compile',
72 dest, source] 72 dest, source]
73 subprocess.call(args) 73 ibtool_section_re = re.compile(r'/\*.*\*/')
74 ibtool_re = re.compile(r'.*note:.*is clipping its content')
75 ibtoolout = subprocess.Popen(args, stdout=subprocess.PIPE)
76 current_section_header = None
77 for line in ibtoolout.stdout:
78 if ibtool_section_re.match(line):
79 current_section_header = line
80 elif not ibtool_re.match(line):
81 if current_section_header:
82 sys.stdout.write(current_section_header)
83 current_section_header = None
Robert Sesek 2012/02/21 15:53:28 Can there be multiple lines of output under the sa
Nico 2012/02/21 16:23:46 Yes: /* com.apple.ibtool.document.notices */ /b/b
84 sys.stdout.write(line)
85 return ibtoolout.returncode
74 86
75 def _CopyStringsFile(self, source, dest): 87 def _CopyStringsFile(self, source, dest):
76 """Copies a .strings file using iconv to reconvert the input into UTF-16.""" 88 """Copies a .strings file using iconv to reconvert the input into UTF-16."""
77 input_code = self._DetectInputEncoding(source) or "UTF-8" 89 input_code = self._DetectInputEncoding(source) or "UTF-8"
78 fp = open(dest, 'w') 90 fp = open(dest, 'w')
79 args = ['/usr/bin/iconv', '--from-code', input_code, '--to-code', 91 args = ['/usr/bin/iconv', '--from-code', input_code, '--to-code',
80 'UTF-16', source] 92 'UTF-16', source]
81 subprocess.call(args, stdout=fp) 93 subprocess.call(args, stdout=fp)
82 fp.close() 94 fp.close()
83 95
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 def _Relink(self, dest, link): 207 def _Relink(self, dest, link):
196 """Creates a symlink to |dest| named |link|. If |link| already exists, 208 """Creates a symlink to |dest| named |link|. If |link| already exists,
197 it is overwritten.""" 209 it is overwritten."""
198 if os.path.lexists(link): 210 if os.path.lexists(link):
199 os.remove(link) 211 os.remove(link)
200 os.symlink(dest, link) 212 os.symlink(dest, link)
201 213
202 214
203 if __name__ == '__main__': 215 if __name__ == '__main__':
204 sys.exit(main(sys.argv[1:])) 216 sys.exit(main(sys.argv[1:]))
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