OLD | NEW |
---|---|
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 """Copies a resource file to the bundle/Resources directory, performing any | 46 """Copies a resource file to the bundle/Resources directory, performing any |
47 necessary compilation on each resource.""" | 47 necessary compilation on each resource.""" |
48 extension = os.path.splitext(source)[1].lower() | 48 extension = os.path.splitext(source)[1].lower() |
49 if os.path.isdir(source): | 49 if os.path.isdir(source): |
50 # Copy tree. | 50 # Copy tree. |
51 if os.path.exists(dest): | 51 if os.path.exists(dest): |
52 shutil.rmtree(dest) | 52 shutil.rmtree(dest) |
53 shutil.copytree(source, dest) | 53 shutil.copytree(source, dest) |
54 elif extension == '.xib': | 54 elif extension == '.xib': |
55 return self._CopyXIBFile(source, dest) | 55 return self._CopyXIBFile(source, dest) |
56 elif extension == '.storyboard': | |
57 return self._CopyXIBFile(source, dest) | |
56 elif extension == '.strings': | 58 elif extension == '.strings': |
57 self._CopyStringsFile(source, dest) | 59 self._CopyStringsFile(source, dest) |
58 else: | 60 else: |
59 shutil.copyfile(source, dest) | 61 shutil.copyfile(source, dest) |
60 | 62 |
61 def _CopyXIBFile(self, source, dest): | 63 def _CopyXIBFile(self, source, dest): |
62 """Compiles a XIB file with ibtool into a binary plist in the bundle.""" | 64 """Compiles a XIB file with ibtool into a binary plist in the bundle.""" |
65 | |
66 # ibtool sometimes fails with relative paths. | |
Nico
2013/11/04 19:20:25
Once you filed the crbug. please add a link to it
justincohen
2013/11/05 18:08:08
Done.
| |
67 base = os.path.dirname(os.path.realpath(__file__)) | |
68 if os.path.relpath(source): | |
69 source = os.path.join(base, source) | |
70 if os.path.relpath(dest): | |
71 dest = os.path.join(base, dest) | |
72 | |
63 args = ['xcrun', 'ibtool', '--errors', '--warnings', '--notices', | 73 args = ['xcrun', 'ibtool', '--errors', '--warnings', '--notices', |
64 '--output-format', 'human-readable-text', '--compile', dest, source] | 74 '--output-format', 'human-readable-text', '--compile', dest, source] |
65 ibtool_section_re = re.compile(r'/\*.*\*/') | 75 ibtool_section_re = re.compile(r'/\*.*\*/') |
66 ibtool_re = re.compile(r'.*note:.*is clipping its content') | 76 ibtool_re = re.compile(r'.*note:.*is clipping its content') |
67 ibtoolout = subprocess.Popen(args, stdout=subprocess.PIPE) | 77 ibtoolout = subprocess.Popen(args, stdout=subprocess.PIPE) |
68 current_section_header = None | 78 current_section_header = None |
69 for line in ibtoolout.stdout: | 79 for line in ibtoolout.stdout: |
70 if ibtool_section_re.match(line): | 80 if ibtool_section_re.match(line): |
71 current_section_header = line | 81 current_section_header = line |
72 elif not ibtool_re.match(line): | 82 elif not ibtool_re.match(line): |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 def _Relink(self, dest, link): | 252 def _Relink(self, dest, link): |
243 """Creates a symlink to |dest| named |link|. If |link| already exists, | 253 """Creates a symlink to |dest| named |link|. If |link| already exists, |
244 it is overwritten.""" | 254 it is overwritten.""" |
245 if os.path.lexists(link): | 255 if os.path.lexists(link): |
246 os.remove(link) | 256 os.remove(link) |
247 os.symlink(dest, link) | 257 os.symlink(dest, link) |
248 | 258 |
249 | 259 |
250 if __name__ == '__main__': | 260 if __name__ == '__main__': |
251 sys.exit(main(sys.argv[1:])) | 261 sys.exit(main(sys.argv[1:])) |
OLD | NEW |