• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2023 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("$build_root/ark.gni")
15
16common_source = [
17  "//third_party/libuv/src/fs-poll.c",
18  "//third_party/libuv/src/idna.c",
19  "//third_party/libuv/src/inet.c",
20  "//third_party/libuv/src/random.c",
21  "//third_party/libuv/src/strscpy.c",
22  "//third_party/libuv/src/threadpool.c",
23  "//third_party/libuv/src/thread-common.c",
24  "//third_party/libuv/src/timer.c",
25  "//third_party/libuv/src/uv-common.c",
26  "//third_party/libuv/src/uv-data-getter-setters.c",
27  "//third_party/libuv/src/version.c",
28  "//third_party/libuv/src/strtok.c",
29]
30if (!is_mingw && !is_win) {
31  nonwin_srcs = [
32    "//third_party/libuv/src/unix/async.c",
33    "//third_party/libuv/src/unix/core.c",
34    "//third_party/libuv/src/unix/dl.c",
35    "//third_party/libuv/src/unix/fs.c",
36    "//third_party/libuv/src/unix/getaddrinfo.c",
37    "//third_party/libuv/src/unix/getnameinfo.c",
38    "//third_party/libuv/src/unix/loop.c",
39    "//third_party/libuv/src/unix/loop-watcher.c",
40    "//third_party/libuv/src/unix/pipe.c",
41    "//third_party/libuv/src/unix/poll.c",
42    "//third_party/libuv/src/unix/process.c",
43    "//third_party/libuv/src/unix/random-devurandom.c",
44    "//third_party/libuv/src/unix/signal.c",
45    "//third_party/libuv/src/unix/stream.c",
46    "//third_party/libuv/src/unix/tcp.c",
47    "//third_party/libuv/src/unix/thread.c",
48    "//third_party/libuv/src/unix/tty.c",
49    "//third_party/libuv/src/unix/udp.c",
50  ]
51}
52
53# This is the configuration needed to use libuv.
54config("libuv_config") {
55  include_dirs = [
56    "//third_party/libuv/include",
57    "//third_party/libuv/src",
58    "//third_party/libuv/src/unix",
59  ]
60  defines = []
61  cflags = [ "-Wno-unused-parameter" ]
62  if (is_linux || is_ohos) {
63    cflags += [
64      "-Wno-incompatible-pointer-types",
65      "-D_GNU_SOURCE",
66      "-D_POSIX_C_SOURCE=200112",
67    ]
68  } else if (is_mingw || is_win) {
69    cflags += [
70      "-Wno-missing-braces",
71      "-Wno-implicit-function-declaration",
72      "-Wno-error=return-type",
73      "-Wno-error=sign-compare",
74      "-Wno-error=unused-variable",
75      "-Wno-error=unknown-pragmas",
76      "-Wno-unused-variable",
77    ]
78    defines += [
79      "WIN32_LEAN_AND_MEAN",
80      "_WIN32_WINNT=0x0600",
81    ]
82
83    libs = [
84      "psapi",
85      "user32",
86      "advapi32",
87      "iphlpapi",
88      "userenv",
89      "ws2_32",
90    ]
91  } else if (is_android) {
92    defines += [ "_GNU_SOURCE" ]
93  }
94}
95
96# This is the configuration used to build libuv itself.
97# It should not be needed outside of this library.
98config("libuv_private_config") {
99  visibility = [ ":*" ]
100  include_dirs = [
101    "//third_party/libuv/include",
102    "//third_party/libuv/src",
103    "//third_party/libuv/src/unix",
104  ]
105}
106
107ohos_source_set("libuv_source") {
108  stack_protector_ret = false
109  configs = [ ":libuv_config" ]
110  sources = common_source
111  external_deps = []
112  if (is_mac || (defined(is_ios) && is_ios)) {
113    sources += nonwin_srcs + [
114                 "//third_party/libuv/src/unix/bsd-ifaddrs.c",
115                 "//third_party/libuv/src/unix/darwin-proctitle.c",
116                 "//third_party/libuv/src/unix/darwin.c",
117                 "//third_party/libuv/src/unix/fsevents.c",
118                 "//third_party/libuv/src/unix/kqueue.c",
119                 "//third_party/libuv/src/unix/log_unix.c",
120                 "//third_party/libuv/src/unix/os390-proctitle.c",
121                 "//third_party/libuv/src/unix/random-getentropy.c",
122                 "//third_party/libuv/src/unix/trace_unix.c",
123               ]
124  } else if (is_mingw || is_win) {
125    sources += [
126      "//third_party/libuv/src/win/async.c",
127      "//third_party/libuv/src/win/core.c",
128      "//third_party/libuv/src/win/detect-wakeup.c",
129      "//third_party/libuv/src/win/dl.c",
130      "//third_party/libuv/src/win/error.c",
131      "//third_party/libuv/src/win/fs-event.c",
132      "//third_party/libuv/src/win/fs.c",
133      "//third_party/libuv/src/win/getaddrinfo.c",
134      "//third_party/libuv/src/win/getnameinfo.c",
135      "//third_party/libuv/src/win/handle.c",
136      "//third_party/libuv/src/win/log_win.c",
137      "//third_party/libuv/src/win/loop-watcher.c",
138      "//third_party/libuv/src/win/pipe.c",
139      "//third_party/libuv/src/win/poll.c",
140      "//third_party/libuv/src/win/process-stdio.c",
141      "//third_party/libuv/src/win/process.c",
142      "//third_party/libuv/src/win/signal.c",
143      "//third_party/libuv/src/win/snprintf.c",
144      "//third_party/libuv/src/win/stream.c",
145      "//third_party/libuv/src/win/tcp.c",
146      "//third_party/libuv/src/win/thread.c",
147      "//third_party/libuv/src/win/trace_win.c",
148      "//third_party/libuv/src/win/tty.c",
149      "//third_party/libuv/src/win/udp.c",
150      "//third_party/libuv/src/win/util.c",
151      "//third_party/libuv/src/win/winapi.c",
152      "//third_party/libuv/src/win/winsock.c",
153    ]
154  } else if (is_ohos || (defined(is_android) && is_android)) {
155    sources += nonwin_srcs + [
156                 "//third_party/libuv/src/unix/linux.c",
157                 "//third_party/libuv/src/unix/procfs-exepath.c",
158                 "//third_party/libuv/src/unix/proctitle.c",
159                 "//third_party/libuv/src/unix/random-getentropy.c",
160                 "//third_party/libuv/src/unix/random-getrandom.c",
161                 "//third_party/libuv/src/unix/random-sysctl-linux.c",
162               ]
163    sources += [
164      "src/log_ohos.c",
165      "src/trace_ohos.c",
166    ]
167  } else if (is_linux) {
168    sources += nonwin_srcs + [
169                 "//third_party/libuv/src/unix/linux.c",
170                 "//third_party/libuv/src/unix/log_unix.c",
171                 "//third_party/libuv/src/unix/procfs-exepath.c",
172                 "//third_party/libuv/src/unix/proctitle.c",
173                 "//third_party/libuv/src/unix/random-getrandom.c",
174                 "//third_party/libuv/src/unix/random-sysctl-linux.c",
175                 "//third_party/libuv/src/unix/trace_unix.c",
176               ]
177  } else {
178    sources += nonwin_srcs + [
179                 "//third_party/libuv/src/unix/linux.c",
180                 "//third_party/libuv/src/unix/procfs-exepath.c",
181                 "//third_party/libuv/src/unix/proctitle.c",
182                 "//third_party/libuv/src/unix/random-getrandom.c",
183                 "//third_party/libuv/src/unix/random-sysctl-linux.c",
184               ]
185  }
186  subsystem_name = "thirdparty"
187  part_name = "libuv"
188}
189
190ohos_static_library("uv_static") {
191  stack_protector_ret = false
192  deps = [ ":libuv_source" ]
193  public_configs = [ ":libuv_config" ]
194  subsystem_name = "thirdparty"
195  part_name = "libuv"
196}
197
198ohos_shared_library("uv") {
199  stack_protector_ret = false
200  deps = [ ":libuv_source" ]
201  public_configs = [ ":libuv_config" ]
202  subsystem_name = "thirdparty"
203  part_name = "libuv"
204  if (is_ohos) {
205    output_extension = "so"
206  }
207  install_images = [
208    "system",
209    "updater",
210  ]
211}
212