| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 fd.close() | 168 fd.close() |
| 169 | 169 |
| 170 # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). | 170 # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). |
| 171 plist = plistlib.readPlistFromString(lines) | 171 plist = plistlib.readPlistFromString(lines) |
| 172 if keys: | 172 if keys: |
| 173 plist = dict(plist.items() + json.loads(keys[0]).items()) | 173 plist = dict(plist.items() + json.loads(keys[0]).items()) |
| 174 lines = plistlib.writePlistToString(plist) | 174 lines = plistlib.writePlistToString(plist) |
| 175 | 175 |
| 176 # Go through all the environment variables and replace them as variables in | 176 # Go through all the environment variables and replace them as variables in |
| 177 # the file. | 177 # the file. |
| 178 IDENT_RE = re.compile(r'[/\s]') | 178 IDENT_RE = re.compile(r'[_/\s]') |
| 179 for key in os.environ: | 179 for key in os.environ: |
| 180 if key.startswith('_'): | 180 if key.startswith('_'): |
| 181 continue | 181 continue |
| 182 evar = '${%s}' % key | 182 evar = '${%s}' % key |
| 183 evalue = os.environ[key] | 183 evalue = os.environ[key] |
| 184 lines = string.replace(lines, evar, evalue) | 184 lines = string.replace(lines, evar, evalue) |
| 185 | 185 |
| 186 # Xcode supports various suffices on environment variables, which are | 186 # Xcode supports various suffices on environment variables, which are |
| 187 # all undocumented. :rfc1034identifier is used in the standard project | 187 # all undocumented. :rfc1034identifier is used in the standard project |
| 188 # template these days, and :identifier was used earlier. They are used to | 188 # template these days, and :identifier was used earlier. They are used to |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 out.write(struct.pack('<s', '\0')) | 703 out.write(struct.pack('<s', '\0')) |
| 704 base = os.path.dirname(path) + os.sep | 704 base = os.path.dirname(path) + os.sep |
| 705 out.write(struct.pack('<%ds' % len(base), base)) | 705 out.write(struct.pack('<%ds' % len(base), base)) |
| 706 out.write(struct.pack('<s', '\0')) | 706 out.write(struct.pack('<s', '\0')) |
| 707 path = os.path.basename(path) | 707 path = os.path.basename(path) |
| 708 out.write(struct.pack('<%ds' % len(path), path)) | 708 out.write(struct.pack('<%ds' % len(path), path)) |
| 709 out.write(struct.pack('<s', '\0')) | 709 out.write(struct.pack('<s', '\0')) |
| 710 | 710 |
| 711 if __name__ == '__main__': | 711 if __name__ == '__main__': |
| 712 sys.exit(main(sys.argv[1:])) | 712 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |