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 |
11 import fcntl | 11 import fcntl |
| 12 import json |
12 import os | 13 import os |
13 import plistlib | 14 import plistlib |
14 import re | 15 import re |
15 import shutil | 16 import shutil |
16 import string | 17 import string |
17 import subprocess | 18 import subprocess |
18 import sys | 19 import sys |
19 | 20 |
20 | 21 |
21 def main(args): | 22 def main(args): |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 119 |
119 def ExecCopyInfoPlist(self, source, dest, *keys): | 120 def ExecCopyInfoPlist(self, source, dest, *keys): |
120 """Copies the |source| Info.plist to the destination directory |dest|.""" | 121 """Copies the |source| Info.plist to the destination directory |dest|.""" |
121 # Read the source Info.plist into memory. | 122 # Read the source Info.plist into memory. |
122 fd = open(source, 'r') | 123 fd = open(source, 'r') |
123 lines = fd.read() | 124 lines = fd.read() |
124 fd.close() | 125 fd.close() |
125 | 126 |
126 # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). | 127 # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). |
127 plist = plistlib.readPlistFromString(lines) | 128 plist = plistlib.readPlistFromString(lines) |
128 plist = dict(plist.items() + zip(keys[::2], keys[1::2])) | 129 if keys: |
| 130 plist = dict(plist.items() + json.loads(keys[0]).items()) |
129 lines = plistlib.writePlistToString(plist) | 131 lines = plistlib.writePlistToString(plist) |
130 | 132 |
131 # Go through all the environment variables and replace them as variables in | 133 # Go through all the environment variables and replace them as variables in |
132 # the file. | 134 # the file. |
133 IDENT_RE = re.compile('[/\s]') | 135 IDENT_RE = re.compile('[/\s]') |
134 for key in os.environ: | 136 for key in os.environ: |
135 if key.startswith('_'): | 137 if key.startswith('_'): |
136 continue | 138 continue |
137 evar = '${%s}' % key | 139 evar = '${%s}' % key |
138 evalue = os.environ[key] | 140 evalue = os.environ[key] |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 def _Relink(self, dest, link): | 243 def _Relink(self, dest, link): |
242 """Creates a symlink to |dest| named |link|. If |link| already exists, | 244 """Creates a symlink to |dest| named |link|. If |link| already exists, |
243 it is overwritten.""" | 245 it is overwritten.""" |
244 if os.path.lexists(link): | 246 if os.path.lexists(link): |
245 os.remove(link) | 247 os.remove(link) |
246 os.symlink(dest, link) | 248 os.symlink(dest, link) |
247 | 249 |
248 | 250 |
249 if __name__ == '__main__': | 251 if __name__ == '__main__': |
250 sys.exit(main(sys.argv[1:])) | 252 sys.exit(main(sys.argv[1:])) |
OLD | NEW |