forked from ethanchewy/PythonBuddy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdarwin.py
More file actions
118 lines (97 loc) · 4.39 KB
/
darwin.py
File metadata and controls
118 lines (97 loc) · 4.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
"""Support for OS X."""
from rpython.translator.platform import posix
import os
#
# Although Intel 32bit is supported since Apple Mac OS X 10.4, (and PPC since, ever)
# the @rpath handling used in Darwin._args_for_shared is only availabe
# since 10.5, so we use that as minimum requirement. Bumped to 10.6
# because 10.11 does not ship with 10.5 versions of libs
#
DARWIN_VERSION_MIN = '-mmacosx-version-min=10.6'
class Darwin(posix.BasePosix):
name = "darwin"
standalone_only = ('-mdynamic-no-pic',)
shared_only = ()
link_flags = (DARWIN_VERSION_MIN,)
cflags = ('-O3', '-fomit-frame-pointer', DARWIN_VERSION_MIN)
so_ext = 'dylib'
DEFAULT_CC = 'clang'
rpath_flags = ['-Wl,-rpath', '-Wl,@executable_path/']
def get_rpath_flags(self, rel_libdirs):
# needed for cross compiling on ARM, needs fixing if relevant for darwin
if len(rel_libdirs) > 0:
print 'in get_rpath_flags, rel_libdirs is not fixed up',rel_libdirs
return self.rpath_flags
def _args_for_shared(self, args):
if hasattr(self, '_exe_name'):
target = os.path.basename(self._exe_name)
else:
target = '$(TARGET)' # inside a Makefile
return (list(self.shared_only)
+ ['-dynamiclib', '-install_name', '@rpath/' + target, '-undefined', 'dynamic_lookup', '-flat_namespace']
+ args)
def _include_dirs_for_libffi(self):
return self._pkg_config("libffi", "--cflags-only-I",
['/usr/include/ffi'],
check_result_dir=True)
def _library_dirs_for_libffi(self):
return self._pkg_config("libffi", "--libs-only-L",
['/usr/lib'],
check_result_dir=True)
def include_dirs_for_openssl(self):
dirs = self._include_dirs_for_openssl()
if 'PYPY_LOCALBASE' in os.environ:
return [os.environ['PYPY_LOCALBASE'] + '/include'] + dirs
return dirs
def library_dirs_for_openssl(self):
dirs = self._library_dirs_for_openssl()
if 'PYPY_LOCALBASE' in os.environ:
return [os.environ['PYPY_LOCALBASE'] + '/lib'] + dirs
return dirs
def _include_dirs_for_openssl(self):
return self._pkg_config("openssl", "--cflags-only-I",
['/usr/include'],
check_result_dir=True)
def _library_dirs_for_openssl(self):
return self._pkg_config("openssl", "--libs-only-L",
['/usr/lib'],
check_result_dir=True)
def _frameworks(self, frameworks):
args = []
for f in frameworks:
args.append('-framework')
args.append(f)
return args
def _link_args_from_eci(self, eci, standalone):
args = super(Darwin, self)._link_args_from_eci(eci, standalone)
frameworks = self._frameworks(eci.frameworks)
include_dirs = self._includedirs(eci.include_dirs)
return (args + frameworks + include_dirs)
def _exportsymbols_link_flags(self):
# XXX unsure if OS/X requires an option to the linker to tell
# "please export all RPY_EXPORTED symbols even in the case of
# making a binary and not a dynamically-linked library".
# It's not "-exported_symbols_list" but something close.
return []
def gen_makefile(self, cfiles, eci, exe_name=None, path=None,
shared=False, headers_to_precompile=[],
no_precompile_cfiles = [], icon=None):
# ensure frameworks are passed in the Makefile
fs = self._frameworks(eci.frameworks)
if len(fs) > 0:
# concat (-framework, FrameworkName) pairs
self.extra_libs += tuple(map(" ".join, zip(fs[::2], fs[1::2])))
mk = super(Darwin, self).gen_makefile(cfiles, eci, exe_name, path,
shared=shared,
headers_to_precompile=headers_to_precompile,
no_precompile_cfiles = no_precompile_cfiles,
icon=icon)
return mk
class Darwin_PowerPC(Darwin):#xxx fixme, mwp
name = "darwin_powerpc"
class Darwin_i386(Darwin):
name = "darwin_i386"
DEFAULT_CC = 'clang -arch i386'
class Darwin_x86_64(Darwin):
name = "darwin_x86_64"
DEFAULT_CC = 'clang -arch x86_64'