forked from jamesroberts/fastwsgi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_libuv.py
123 lines (114 loc) · 4.25 KB
/
setup_libuv.py
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
119
120
121
122
123
import os
import sys
import glob
SOURCES = glob.glob('libuv/src/*.c')
if sys.platform == 'win32':
SOURCES += glob.glob("libuv/src/win/*.c")
else:
SOURCES += [
'libuv/src/unix/async.c',
'libuv/src/unix/core.c',
'libuv/src/unix/dl.c',
'libuv/src/unix/fs.c',
'libuv/src/unix/getaddrinfo.c',
'libuv/src/unix/getnameinfo.c',
'libuv/src/unix/loop-watcher.c',
'libuv/src/unix/loop.c',
'libuv/src/unix/pipe.c',
'libuv/src/unix/poll.c',
'libuv/src/unix/process.c',
'libuv/src/unix/signal.c',
'libuv/src/unix/stream.c',
'libuv/src/unix/tcp.c',
'libuv/src/unix/thread.c',
'libuv/src/unix/tty.c',
'libuv/src/unix/udp.c',
'libuv/src/unix/random-getrandom.c',
'libuv/src/unix/random-devurandom.c',
]
if sys.platform.startswith('linux'):
SOURCES += [
'libuv/src/unix/linux-core.c',
'libuv/src/unix/linux-inotify.c',
'libuv/src/unix/linux-syscalls.c',
'libuv/src/unix/procfs-exepath.c',
'libuv/src/unix/proctitle.c',
'libuv/src/unix/random-sysctl-linux.c',
'libuv/src/unix/epoll.c',
]
elif sys.platform == 'darwin':
SOURCES += [
'libuv/src/unix/bsd-ifaddrs.c',
'libuv/src/unix/darwin.c',
'libuv/src/unix/darwin-proctitle.c',
'libuv/src/unix/fsevents.c',
'libuv/src/unix/kqueue.c',
'libuv/src/unix/proctitle.c',
'libuv/src/unix/pthread-fixes.c',
'libuv/src/unix/random-getentropy.c',
]
elif sys.platform.startswith(('freebsd', 'dragonfly')):
SOURCES += [
'libuv/src/unix/bsd-ifaddrs.c',
'libuv/src/unix/freebsd.c',
'libuv/src/unix/kqueue.c',
'libuv/src/unix/posix-hrtime.c',
]
elif sys.platform.startswith('openbsd'):
SOURCES += [
'libuv/src/unix/bsd-ifaddrs.c',
'libuv/src/unix/kqueue.c',
'libuv/src/unix/openbsd.c',
'libuv/src/unix/posix-hrtime.c',
]
elif sys.platform.startswith('netbsd'):
SOURCES += [
'libuv/src/unix/bsd-ifaddrs.c',
'libuv/src/unix/kqueue.c',
'libuv/src/unix/netbsd.c',
'libuv/src/unix/posix-hrtime.c',
]
elif sys.platform.startswith('sunos'):
SOURCES += [
'libuv/src/unix/no-proctitle.c',
'libuv/src/unix/sunos.c',
]
def build_libuv(build_ext):
self = build_ext
self.libuv_dir = os.path.join('libuv')
if True:
self.compiler.add_include_dir(os.path.join(self.libuv_dir, 'include'))
self.compiler.add_include_dir(os.path.join(self.libuv_dir, 'src'))
self.extensions[0].sources += SOURCES
if sys.platform != 'win32':
self.compiler.define_macro('_LARGEFILE_SOURCE', 1)
self.compiler.define_macro('_FILE_OFFSET_BITS', 64)
if sys.platform.startswith('linux'):
self.compiler.define_macro('_GNU_SOURCE', 1)
self.compiler.add_library('dl')
self.compiler.add_library('rt')
elif sys.platform == 'darwin':
self.compiler.define_macro('_DARWIN_USE_64_BIT_INODE', 1)
self.compiler.define_macro('_DARWIN_UNLIMITED_SELECT', 1)
elif sys.platform.startswith('netbsd'):
self.compiler.add_library('kvm')
elif sys.platform.startswith('sunos'):
self.compiler.define_macro('__EXTENSIONS__', 1)
self.compiler.define_macro('_XOPEN_SOURCE', 500)
self.compiler.add_library('kstat')
self.compiler.add_library('nsl')
self.compiler.add_library('sendfile')
self.compiler.add_library('socket')
elif sys.platform == 'win32':
self.compiler.define_macro('WIN32', 1)
self.compiler.define_macro('_CRT_SECURE_NO_DEPRECATE', 1)
self.compiler.define_macro('_CRT_NONSTDC_NO_DEPRECATE', 1)
self.compiler.define_macro('_WIN32_WINNT', '0x0600')
self.compiler.add_library('advapi32')
self.compiler.add_library('iphlpapi')
self.compiler.add_library('psapi')
self.compiler.add_library('shell32')
self.compiler.add_library('user32')
self.compiler.add_library('userenv')
self.compiler.add_library('ws2_32')
self.compiler.add_library('secur32')