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