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/timer.c", 24 "//third_party/libuv/src/uv-common.c", 25 "//third_party/libuv/src/uv-data-getter-setters.c", 26 "//third_party/libuv/src/version.c", 27] 28if (!is_mingw && !is_win) { 29 nonwin_srcs = [ 30 "//third_party/libuv/src/unix/epoll.c", 31 "//third_party/libuv/src/unix/async.c", 32 "//third_party/libuv/src/unix/core.c", 33 "//third_party/libuv/src/unix/dl.c", 34 "//third_party/libuv/src/unix/fs.c", 35 "//third_party/libuv/src/unix/getaddrinfo.c", 36 "//third_party/libuv/src/unix/getnameinfo.c", 37 "//third_party/libuv/src/unix/loop.c", 38 "//third_party/libuv/src/unix/loop-watcher.c", 39 "//third_party/libuv/src/unix/pipe.c", 40 "//third_party/libuv/src/unix/poll.c", 41 "//third_party/libuv/src/unix/process.c", 42 "//third_party/libuv/src/unix/random-devurandom.c", 43 "//third_party/libuv/src/unix/signal.c", 44 "//third_party/libuv/src/unix/stream.c", 45 "//third_party/libuv/src/unix/tcp.c", 46 "//third_party/libuv/src/unix/thread.c", 47 "//third_party/libuv/src/unix/tty.c", 48 "//third_party/libuv/src/unix/udp.c", 49 ] 50} 51 52# This is the configuration needed to use libuv. 53config("libuv_config") { 54 include_dirs = [ 55 "//third_party/libuv/include", 56 "//third_party/libuv/src", 57 "//third_party/libuv/src/unix", 58 ] 59 cflags = [ "-Wno-unused-parameter" ] 60 if (is_linux || is_ohos) { 61 cflags += [ 62 "-Wno-incompatible-pointer-types", 63 "-D_GNU_SOURCE", 64 "-D_POSIX_C_SOURCE=200112", 65 ] 66 67 # Adding NDEBUG macro manually to avoid compilation 68 # error in debug version, FIX ME 69 # https://gitee.com/openharmony/build/pulls/1206/files 70 defines = [ "NDEBUG" ] 71 } else if (is_mingw || is_win) { 72 cflags += [ 73 "-Wno-missing-braces", 74 "-Wno-implicit-function-declaration", 75 "-Wno-error=return-type", 76 "-Wno-error=sign-compare", 77 "-Wno-error=unused-variable", 78 "-Wno-error=unknown-pragmas", 79 "-Wno-unused-variable", 80 ] 81 defines = [ 82 "WIN32_LEAN_AND_MEAN", 83 "_WIN32_WINNT=0x0600", 84 ] 85 86 # Adding NDEBUG macro manually to avoid compilation 87 # error in debug version, FIX ME 88 # https://gitee.com/openharmony/build/pulls/1206/files 89 defines += [ "NDEBUG" ] 90 91 libs = [ 92 "psapi", 93 "user32", 94 "advapi32", 95 "iphlpapi", 96 "userenv", 97 "ws2_32", 98 ] 99 } else if (is_android) { 100 defines = [ "_GNU_SOURCE" ] 101 } 102} 103 104# This is the configuration used to build libuv itself. 105# It should not be needed outside of this library. 106config("libuv_private_config") { 107 visibility = [ ":*" ] 108 include_dirs = [ 109 "//third_party/libuv/include", 110 "//third_party/libuv/src", 111 "//third_party/libuv/src/unix", 112 ] 113 114 # Adding NDEBUG macro manually to avoid compilation 115 # error in debug version, FIX ME 116 # https://gitee.com/openharmony/build/pulls/1206/files 117 defines = [ "NDEBUG" ] 118} 119 120ohos_source_set("libuv_source") { 121 stack_protector_ret = false 122 configs = [ ":libuv_config" ] 123 sources = common_source 124 125 if (is_mac || (defined(is_ios) && is_ios)) { 126 sources += nonwin_srcs + [ 127 "//third_party/libuv/src/unix/bsd-ifaddrs.c", 128 "//third_party/libuv/src/unix/kqueue.c", 129 "//third_party/libuv/src/unix/random-getentropy.c", 130 "//third_party/libuv/src/unix/darwin-proctitle.c", 131 "//third_party/libuv/src/unix/darwin.c", 132 "//third_party/libuv/src/unix/fsevents.c", 133 "//third_party/libuv/src/unix/os390-proctitle.c", 134 ] 135 sources -= [ "//third_party/libuv/src/unix/epoll.c" ] 136 } else if (is_mingw || is_win) { 137 sources += [ 138 "//third_party/libuv/src/win/async.c", 139 "//third_party/libuv/src/win/core.c", 140 "//third_party/libuv/src/win/detect-wakeup.c", 141 "//third_party/libuv/src/win/dl.c", 142 "//third_party/libuv/src/win/error.c", 143 "//third_party/libuv/src/win/fs-event.c", 144 "//third_party/libuv/src/win/fs.c", 145 "//third_party/libuv/src/win/getaddrinfo.c", 146 "//third_party/libuv/src/win/getnameinfo.c", 147 "//third_party/libuv/src/win/handle.c", 148 "//third_party/libuv/src/win/loop-watcher.c", 149 "//third_party/libuv/src/win/pipe.c", 150 "//third_party/libuv/src/win/poll.c", 151 "//third_party/libuv/src/win/process-stdio.c", 152 "//third_party/libuv/src/win/process.c", 153 "//third_party/libuv/src/win/signal.c", 154 "//third_party/libuv/src/win/snprintf.c", 155 "//third_party/libuv/src/win/stream.c", 156 "//third_party/libuv/src/win/tcp.c", 157 "//third_party/libuv/src/win/thread.c", 158 "//third_party/libuv/src/win/tty.c", 159 "//third_party/libuv/src/win/udp.c", 160 "//third_party/libuv/src/win/util.c", 161 "//third_party/libuv/src/win/winapi.c", 162 "//third_party/libuv/src/win/winsock.c", 163 ] 164 } else if (is_ohos || (defined(is_android) && is_android)) { 165 sources += nonwin_srcs + [ 166 "//third_party/libuv/src/unix/linux-core.c", 167 "//third_party/libuv/src/unix/linux-inotify.c", 168 "//third_party/libuv/src/unix/linux-syscalls.c", 169 "//third_party/libuv/src/unix/procfs-exepath.c", 170 "//third_party/libuv/src/unix/pthread-fixes.c", 171 "//third_party/libuv/src/unix/random-getentropy.c", 172 "//third_party/libuv/src/unix/random-getrandom.c", 173 "//third_party/libuv/src/unix/random-sysctl-linux.c", 174 "//third_party/libuv/src/unix/proctitle.c", 175 ] 176 } else if (is_linux) { 177 sources += nonwin_srcs + [ 178 "//third_party/libuv/src/unix/linux-core.c", 179 "//third_party/libuv/src/unix/linux-inotify.c", 180 "//third_party/libuv/src/unix/linux-syscalls.c", 181 "//third_party/libuv/src/unix/procfs-exepath.c", 182 "//third_party/libuv/src/unix/random-getrandom.c", 183 "//third_party/libuv/src/unix/random-sysctl-linux.c", 184 "//third_party/libuv/src/unix/proctitle.c", 185 ] 186 } else { 187 sources += nonwin_srcs + [ 188 "//third_party/libuv/src/unix/linux-core.c", 189 "//third_party/libuv/src/unix/linux-inotify.c", 190 "//third_party/libuv/src/unix/linux-syscalls.c", 191 "//third_party/libuv/src/unix/procfs-exepath.c", 192 "//third_party/libuv/src/unix/random-getrandom.c", 193 "//third_party/libuv/src/unix/random-sysctl-linux.c", 194 "//third_party/libuv/src/unix/proctitle.c", 195 ] 196 } 197 subsystem_name = "thirdparty" 198 part_name = "libuv" 199} 200 201ohos_static_library("uv_static") { 202 stack_protector_ret = false 203 deps = [ ":libuv_source" ] 204 public_configs = [ ":libuv_config" ] 205 subsystem_name = "thirdparty" 206 part_name = "libuv" 207} 208 209ohos_shared_library("uv") { 210 stack_protector_ret = false 211 deps = [ ":libuv_source" ] 212 public_configs = [ ":libuv_config" ] 213 subsystem_name = "thirdparty" 214 part_name = "libuv" 215 if (is_ohos) { 216 output_extension = "so" 217 } 218 install_images = [ 219 "system", 220 "updater", 221 ] 222} 223