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

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

Issue 2141973002: Fix :rfc1034identifier when the value contains underscore. (Closed) Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Created 4 years, 5 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
« 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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:]))
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