| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import argparse | 5 import argparse |
| 6 import os | 6 import os |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 from distutils import sysconfig | 9 from distutils import sysconfig |
| 10 from distutils.command import build_ext | 10 from distutils.command import build_ext |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 action='store_true') | 27 action='store_true') |
| 28 opts = parser.parse_args() | 28 opts = parser.parse_args() |
| 29 | 29 |
| 30 ext = Extension('Dummy', []) | 30 ext = Extension('Dummy', []) |
| 31 b = build_ext.build_ext(Distribution()) | 31 b = build_ext.build_ext(Distribution()) |
| 32 b.initialize_options() | 32 b.initialize_options() |
| 33 b.finalize_options() | 33 b.finalize_options() |
| 34 result = [] | 34 result = [] |
| 35 if opts.libraries: | 35 if opts.libraries: |
| 36 libraries = b.get_libraries(ext) | 36 libraries = b.get_libraries(ext) |
| 37 if sys.platform in ['darwin', 'linux2']: | 37 if sys.platform == 'darwin': |
| 38 # In case of darwin and linux prefix all libraries (if there is any) | 38 libraries.append('python%s' % sys.version[:3]) |
| 39 # so it can be used as a compiler argument. | 39 if not opts.gn and sys.platform in ['darwin', 'linux2']: |
| 40 # In case of GYP output for darwin and linux prefix all |
| 41 # libraries (if there are any) so the result can be used as a |
| 42 # compiler argument. GN handles platform-appropriate prefixing itself. |
| 40 libraries = ['-l%s' % library for library in libraries] | 43 libraries = ['-l%s' % library for library in libraries] |
| 41 if sys.platform == 'darwin': | |
| 42 libraries.append('-lpython%s' % sys.version[:3]) | |
| 43 result.extend(libraries) | 44 result.extend(libraries) |
| 44 if opts.includes: | 45 if opts.includes: |
| 45 result = result + b.include_dirs | 46 result = result + b.include_dirs |
| 46 if opts.library_dirs: | 47 if opts.library_dirs: |
| 47 if sys.platform == 'darwin': | 48 if sys.platform == 'darwin': |
| 48 result.append('%s/lib' % sysconfig.get_config_vars('prefix')[0]) | 49 result.append('%s/lib' % sysconfig.get_config_vars('prefix')[0]) |
| 49 | 50 |
| 50 if opts.gn: | 51 if opts.gn: |
| 51 for x in result: | 52 for x in result: |
| 52 print x | 53 print x |
| 53 else: | 54 else: |
| 54 print ''.join(['"%s"' % x for x in result]) | 55 print ''.join(['"%s"' % x for x in result]) |
| 55 | 56 |
| 56 if __name__ == '__main__': | 57 if __name__ == '__main__': |
| 57 main() | 58 main() |
| OLD | NEW |