|
160
|
1 load("@rules_cc//cc:defs.bzl", "cc_library")
|
|
|
2
|
|
|
3 package(default_visibility = ["//visibility:public"])
|
|
|
4
|
|
|
5 # Common source files for all platforms
|
|
|
6 COMMON_SRCS = [
|
|
|
7 "src/fs-poll.c",
|
|
|
8 "src/idna.c",
|
|
|
9 "src/inet.c",
|
|
|
10 "src/random.c",
|
|
|
11 "src/strscpy.c",
|
|
|
12 "src/strtok.c",
|
|
|
13 "src/thread-common.c",
|
|
|
14 "src/threadpool.c",
|
|
|
15 "src/timer.c",
|
|
|
16 "src/uv-common.c",
|
|
|
17 "src/uv-data-getter-setters.c",
|
|
|
18 "src/version.c",
|
|
|
19 ]
|
|
|
20
|
|
|
21 # Unix common source files
|
|
|
22 UNIX_SRCS = [
|
|
|
23 "src/unix/async.c",
|
|
|
24 "src/unix/core.c",
|
|
|
25 "src/unix/dl.c",
|
|
|
26 "src/unix/fs.c",
|
|
|
27 "src/unix/getaddrinfo.c",
|
|
|
28 "src/unix/getnameinfo.c",
|
|
|
29 "src/unix/loop-watcher.c",
|
|
|
30 "src/unix/loop.c",
|
|
|
31 "src/unix/pipe.c",
|
|
|
32 "src/unix/poll.c",
|
|
|
33 "src/unix/process.c",
|
|
|
34 "src/unix/random-devurandom.c",
|
|
|
35 "src/unix/signal.c",
|
|
|
36 "src/unix/stream.c",
|
|
|
37 "src/unix/tcp.c",
|
|
|
38 "src/unix/thread.c",
|
|
|
39 "src/unix/tty.c",
|
|
|
40 "src/unix/udp.c",
|
|
|
41 ]
|
|
|
42
|
|
|
43 # macOS/Darwin specific sources
|
|
|
44 DARWIN_SRCS = [
|
|
|
45 "src/unix/bsd-ifaddrs.c",
|
|
|
46 "src/unix/darwin.c",
|
|
|
47 "src/unix/darwin-proctitle.c",
|
|
|
48 "src/unix/fsevents.c",
|
|
|
49 "src/unix/kqueue.c",
|
|
|
50 "src/unix/proctitle.c",
|
|
|
51 "src/unix/random-getentropy.c",
|
|
|
52 ]
|
|
|
53
|
|
|
54 # Linux specific sources
|
|
|
55 LINUX_SRCS = [
|
|
|
56 "src/unix/linux.c",
|
|
|
57 "src/unix/procfs-exepath.c",
|
|
|
58 "src/unix/proctitle.c",
|
|
|
59 "src/unix/random-getrandom.c",
|
|
|
60 "src/unix/random-sysctl-linux.c",
|
|
|
61 ]
|
|
|
62
|
|
|
63 # Windows specific sources
|
|
|
64 WIN_SRCS = [
|
|
|
65 "src/win/async.c",
|
|
|
66 "src/win/core.c",
|
|
|
67 "src/win/detect-wakeup.c",
|
|
|
68 "src/win/dl.c",
|
|
|
69 "src/win/error.c",
|
|
|
70 "src/win/fs.c",
|
|
|
71 "src/win/fs-event.c",
|
|
|
72 "src/win/getaddrinfo.c",
|
|
|
73 "src/win/getnameinfo.c",
|
|
|
74 "src/win/handle.c",
|
|
|
75 "src/win/loop-watcher.c",
|
|
|
76 "src/win/pipe.c",
|
|
|
77 "src/win/poll.c",
|
|
|
78 "src/win/process.c",
|
|
|
79 "src/win/process-stdio.c",
|
|
|
80 "src/win/signal.c",
|
|
|
81 "src/win/snprintf.c",
|
|
|
82 "src/win/stream.c",
|
|
|
83 "src/win/tcp.c",
|
|
|
84 "src/win/thread.c",
|
|
|
85 "src/win/tty.c",
|
|
|
86 "src/win/udp.c",
|
|
|
87 "src/win/util.c",
|
|
|
88 "src/win/winapi.c",
|
|
|
89 "src/win/winsock.c",
|
|
|
90 ]
|
|
|
91
|
|
|
92 COMMON_HDRS = glob(["include/**/*.h"]) + glob(["src/*.h"]) + glob(["src/unix/*.h"]) + glob(["src/win/*.h"])
|
|
|
93
|
|
|
94 cc_library(
|
|
|
95 name = "libuv",
|
|
|
96 srcs = COMMON_SRCS + select({
|
|
|
97 "@platforms//os:macos": UNIX_SRCS + DARWIN_SRCS,
|
|
|
98 "@platforms//os:linux": UNIX_SRCS + LINUX_SRCS,
|
|
|
99 "@platforms//os:windows": WIN_SRCS,
|
|
|
100 }),
|
|
|
101 hdrs = COMMON_HDRS,
|
|
|
102 includes = ["include", "src"],
|
|
|
103 local_defines = select({
|
|
|
104 "@platforms//os:macos": [
|
|
|
105 "_DARWIN_UNLIMITED_SELECT=1",
|
|
|
106 "_DARWIN_USE_64_BIT_INODE=1",
|
|
|
107 "_FILE_OFFSET_BITS=64",
|
|
|
108 "_LARGEFILE_SOURCE",
|
|
|
109 ],
|
|
|
110 "@platforms//os:linux": [
|
|
|
111 "_GNU_SOURCE",
|
|
|
112 "_POSIX_C_SOURCE=200112",
|
|
|
113 "_FILE_OFFSET_BITS=64",
|
|
|
114 "_LARGEFILE_SOURCE",
|
|
|
115 ],
|
|
|
116 "@platforms//os:windows": [
|
|
|
117 "WIN32_LEAN_AND_MEAN",
|
|
|
118 "_WIN32_WINNT=0x0A00",
|
|
|
119 "_CRT_DECLARE_NONSTDC_NAMES=0",
|
|
|
120 ],
|
|
|
121 }),
|
|
|
122 linkopts = select({
|
|
|
123 "@platforms//os:macos": ["-lpthread"],
|
|
|
124 "@platforms//os:linux": ["-lpthread", "-ldl", "-lrt", "-lm"],
|
|
|
125 "@platforms//os:windows": [
|
|
|
126 "-lpsapi",
|
|
|
127 "-luser32",
|
|
|
128 "-ladvapi32",
|
|
|
129 "-liphlpapi",
|
|
|
130 "-luserenv",
|
|
|
131 "-lws2_32",
|
|
|
132 "-ldbghelp",
|
|
|
133 "-lole32",
|
|
|
134 "-lshell32",
|
|
|
135 ],
|
|
|
136 }),
|
|
|
137 copts = select({
|
|
|
138 "@platforms//os:windows": [],
|
|
|
139 "//conditions:default": [
|
|
|
140 "-fno-strict-aliasing",
|
|
|
141 "-Wno-unused-parameter",
|
|
|
142 ],
|
|
|
143 }),
|
|
|
144 )
|