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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 fd.close() | 139 fd.close() |
140 | 140 |
141 # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). | 141 # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). |
142 plist = plistlib.readPlistFromString(lines) | 142 plist = plistlib.readPlistFromString(lines) |
143 if keys: | 143 if keys: |
144 plist = dict(plist.items() + json.loads(keys[0]).items()) | 144 plist = dict(plist.items() + json.loads(keys[0]).items()) |
145 lines = plistlib.writePlistToString(plist) | 145 lines = plistlib.writePlistToString(plist) |
146 | 146 |
147 # Go through all the environment variables and replace them as variables in | 147 # Go through all the environment variables and replace them as variables in |
148 # the file. | 148 # the file. |
149 IDENT_RE = re.compile('[/\s]') | 149 IDENT_RE = re.compile(r'[/\s]') |
150 for key in os.environ: | 150 for key in os.environ: |
151 if key.startswith('_'): | 151 if key.startswith('_'): |
152 continue | 152 continue |
153 evar = '${%s}' % key | 153 evar = '${%s}' % key |
154 evalue = os.environ[key] | 154 evalue = os.environ[key] |
155 lines = string.replace(lines, evar, evalue) | 155 lines = string.replace(lines, evar, evalue) |
156 | 156 |
157 # Xcode supports various suffices on environment variables, which are | 157 # Xcode supports various suffices on environment variables, which are |
158 # all undocumented. :rfc1034identifier is used in the standard project | 158 # all undocumented. :rfc1034identifier is used in the standard project |
159 # template these days, and :identifier was used earlier. They are used to | 159 # template these days, and :identifier was used earlier. They are used to |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 data = data.replace('$(%s)' % key, value) | 578 data = data.replace('$(%s)' % key, value) |
579 return data | 579 return data |
580 if isinstance(data, list): | 580 if isinstance(data, list): |
581 return [self._ExpandVariables(v, substitutions) for v in data] | 581 return [self._ExpandVariables(v, substitutions) for v in data] |
582 if isinstance(data, dict): | 582 if isinstance(data, dict): |
583 return {k: self._ExpandVariables(data[k], substitutions) for k in data} | 583 return {k: self._ExpandVariables(data[k], substitutions) for k in data} |
584 return data | 584 return data |
585 | 585 |
586 if __name__ == '__main__': | 586 if __name__ == '__main__': |
587 sys.exit(main(sys.argv[1:])) | 587 sys.exit(main(sys.argv[1:])) |
OLD | NEW |