| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return subprocess.call(cmd_list) | 216 return subprocess.call(cmd_list) |
| 217 | 217 |
| 218 def ExecFilterLibtool(self, *cmd_list): | 218 def ExecFilterLibtool(self, *cmd_list): |
| 219 """Calls libtool and filters out '/path/to/libtool: file: foo.o has no | 219 """Calls libtool and filters out '/path/to/libtool: file: foo.o has no |
| 220 symbols'.""" | 220 symbols'.""" |
| 221 libtool_re = re.compile(r'^.*libtool: file: .* has no symbols$') | 221 libtool_re = re.compile(r'^.*libtool: file: .* has no symbols$') |
| 222 libtool_re5 = re.compile( | 222 libtool_re5 = re.compile( |
| 223 r'^.*libtool: warning for library: ' + | 223 r'^.*libtool: warning for library: ' + |
| 224 r'.* the table of contents is empty ' + | 224 r'.* the table of contents is empty ' + |
| 225 r'\(no object file members in the library define global symbols\)$') | 225 r'\(no object file members in the library define global symbols\)$') |
| 226 env = os.environ.copy() | 226 libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE) |
| 227 # Ref: | |
| 228 # http://www.opensource.apple.com/source/cctools/cctools-809/misc/libtool.c | |
| 229 # The problem with this flag is that it resets the file mtime on the file to | |
| 230 # epoch=0, e.g. 1970-1-1 or 1969-12-31 depending on daylight saving. | |
| 231 env['ZERO_AR_DATE'] = '1' | |
| 232 libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE, env=env) | |
| 233 _, err = libtoolout.communicate() | 227 _, err = libtoolout.communicate() |
| 234 for line in err.splitlines(): | 228 for line in err.splitlines(): |
| 235 if not libtool_re.match(line) and not libtool_re5.match(line): | 229 if not libtool_re.match(line) and not libtool_re5.match(line): |
| 236 print >>sys.stderr, line | 230 print >>sys.stderr, line |
| 237 # Unconditionally touch any file .a file on the command line if present if | |
| 238 # succeeded. A bit hacky. | |
| 239 if not libtoolout.returncode: | |
| 240 archives = [ | |
| 241 cmd for cmd in cmd_list if cmd.endswith('.a') and os.path.isfile(cmd) | |
| 242 ] | |
| 243 if len(archives) == 1: | |
| 244 os.utime(archives[0], None) | |
| 245 return libtoolout.returncode | 231 return libtoolout.returncode |
| 246 | 232 |
| 247 def ExecPackageFramework(self, framework, version): | 233 def ExecPackageFramework(self, framework, version): |
| 248 """Takes a path to Something.framework and the Current version of that and | 234 """Takes a path to Something.framework and the Current version of that and |
| 249 sets up all the symlinks.""" | 235 sets up all the symlinks.""" |
| 250 # Find the name of the binary based on the part before the ".framework". | 236 # Find the name of the binary based on the part before the ".framework". |
| 251 binary = os.path.basename(framework).split('.')[0] | 237 binary = os.path.basename(framework).split('.')[0] |
| 252 | 238 |
| 253 CURRENT = 'Current' | 239 CURRENT = 'Current' |
| 254 RESOURCES = 'Resources' | 240 RESOURCES = 'Resources' |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 data = data.replace('$(%s)' % key, value) | 578 data = data.replace('$(%s)' % key, value) |
| 593 return data | 579 return data |
| 594 if isinstance(data, list): | 580 if isinstance(data, list): |
| 595 return [self._ExpandVariables(v, substitutions) for v in data] | 581 return [self._ExpandVariables(v, substitutions) for v in data] |
| 596 if isinstance(data, dict): | 582 if isinstance(data, dict): |
| 597 return {k: self._ExpandVariables(data[k], substitutions) for k in data} | 583 return {k: self._ExpandVariables(data[k], substitutions) for k in data} |
| 598 return data | 584 return data |
| 599 | 585 |
| 600 if __name__ == '__main__': | 586 if __name__ == '__main__': |
| 601 sys.exit(main(sys.argv[1:])) | 587 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |