# Copyright (c) 2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("$build_root/ark.gni") common_source = [ "//third_party/libuv/src/fs-poll.c", "//third_party/libuv/src/idna.c", "//third_party/libuv/src/inet.c", "//third_party/libuv/src/random.c", "//third_party/libuv/src/strscpy.c", "//third_party/libuv/src/threadpool.c", "//third_party/libuv/src/timer.c", "//third_party/libuv/src/uv-common.c", "//third_party/libuv/src/uv-data-getter-setters.c", "//third_party/libuv/src/version.c", ] if (!is_mingw && !is_win) { nonwin_srcs = [ "//third_party/libuv/src/unix/epoll.c", "//third_party/libuv/src/unix/async.c", "//third_party/libuv/src/unix/core.c", "//third_party/libuv/src/unix/dl.c", "//third_party/libuv/src/unix/fs.c", "//third_party/libuv/src/unix/getaddrinfo.c", "//third_party/libuv/src/unix/getnameinfo.c", "//third_party/libuv/src/unix/loop.c", "//third_party/libuv/src/unix/loop-watcher.c", "//third_party/libuv/src/unix/pipe.c", "//third_party/libuv/src/unix/poll.c", "//third_party/libuv/src/unix/process.c", "//third_party/libuv/src/unix/random-devurandom.c", "//third_party/libuv/src/unix/signal.c", "//third_party/libuv/src/unix/stream.c", "//third_party/libuv/src/unix/tcp.c", "//third_party/libuv/src/unix/thread.c", "//third_party/libuv/src/unix/tty.c", "//third_party/libuv/src/unix/udp.c", ] } # This is the configuration needed to use libuv. config("libuv_config") { include_dirs = [ "//third_party/libuv/include", "//third_party/libuv/src", "//third_party/libuv/src/unix", ] cflags = [ "-Wno-unused-parameter" ] if (is_linux || is_ohos) { cflags += [ "-Wno-incompatible-pointer-types", "-D_GNU_SOURCE", "-D_POSIX_C_SOURCE=200112", ] # Adding NDEBUG macro manually to avoid compilation # error in debug version, FIX ME # https://gitee.com/openharmony/build/pulls/1206/files defines = [ "NDEBUG" ] } else if (is_mingw || is_win) { cflags += [ "-Wno-missing-braces", "-Wno-implicit-function-declaration", "-Wno-error=return-type", "-Wno-error=sign-compare", "-Wno-error=unused-variable", "-Wno-error=unknown-pragmas", "-Wno-unused-variable", ] defines = [ "WIN32_LEAN_AND_MEAN", "_WIN32_WINNT=0x0600", ] # Adding NDEBUG macro manually to avoid compilation # error in debug version, FIX ME # https://gitee.com/openharmony/build/pulls/1206/files defines += [ "NDEBUG" ] libs = [ "psapi", "user32", "advapi32", "iphlpapi", "userenv", "ws2_32", ] } else if (is_android) { defines = [ "_GNU_SOURCE" ] } } # This is the configuration used to build libuv itself. # It should not be needed outside of this library. config("libuv_private_config") { visibility = [ ":*" ] include_dirs = [ "//third_party/libuv/include", "//third_party/libuv/src", "//third_party/libuv/src/unix", ] # Adding NDEBUG macro manually to avoid compilation # error in debug version, FIX ME # https://gitee.com/openharmony/build/pulls/1206/files defines = [ "NDEBUG" ] } ohos_source_set("libuv_source") { stack_protector_ret = false configs = [ ":libuv_config" ] sources = common_source if (is_mac || (defined(is_ios) && is_ios)) { sources += nonwin_srcs + [ "//third_party/libuv/src/unix/bsd-ifaddrs.c", "//third_party/libuv/src/unix/kqueue.c", "//third_party/libuv/src/unix/random-getentropy.c", "//third_party/libuv/src/unix/darwin-proctitle.c", "//third_party/libuv/src/unix/darwin.c", "//third_party/libuv/src/unix/fsevents.c", "//third_party/libuv/src/unix/os390-proctitle.c", ] sources -= [ "//third_party/libuv/src/unix/epoll.c" ] } else if (is_mingw || is_win) { sources += [ "//third_party/libuv/src/win/async.c", "//third_party/libuv/src/win/core.c", "//third_party/libuv/src/win/detect-wakeup.c", "//third_party/libuv/src/win/dl.c", "//third_party/libuv/src/win/error.c", "//third_party/libuv/src/win/fs-event.c", "//third_party/libuv/src/win/fs.c", "//third_party/libuv/src/win/getaddrinfo.c", "//third_party/libuv/src/win/getnameinfo.c", "//third_party/libuv/src/win/handle.c", "//third_party/libuv/src/win/loop-watcher.c", "//third_party/libuv/src/win/pipe.c", "//third_party/libuv/src/win/poll.c", "//third_party/libuv/src/win/process-stdio.c", "//third_party/libuv/src/win/process.c", "//third_party/libuv/src/win/signal.c", "//third_party/libuv/src/win/snprintf.c", "//third_party/libuv/src/win/stream.c", "//third_party/libuv/src/win/tcp.c", "//third_party/libuv/src/win/thread.c", "//third_party/libuv/src/win/tty.c", "//third_party/libuv/src/win/udp.c", "//third_party/libuv/src/win/util.c", "//third_party/libuv/src/win/winapi.c", "//third_party/libuv/src/win/winsock.c", ] } else if (is_ohos || (defined(is_android) && is_android)) { sources += nonwin_srcs + [ "//third_party/libuv/src/unix/linux-core.c", "//third_party/libuv/src/unix/linux-inotify.c", "//third_party/libuv/src/unix/linux-syscalls.c", "//third_party/libuv/src/unix/procfs-exepath.c", "//third_party/libuv/src/unix/pthread-fixes.c", "//third_party/libuv/src/unix/random-getentropy.c", "//third_party/libuv/src/unix/random-getrandom.c", "//third_party/libuv/src/unix/random-sysctl-linux.c", "//third_party/libuv/src/unix/proctitle.c", ] } else if (is_linux) { sources += nonwin_srcs + [ "//third_party/libuv/src/unix/linux-core.c", "//third_party/libuv/src/unix/linux-inotify.c", "//third_party/libuv/src/unix/linux-syscalls.c", "//third_party/libuv/src/unix/procfs-exepath.c", "//third_party/libuv/src/unix/random-getrandom.c", "//third_party/libuv/src/unix/random-sysctl-linux.c", "//third_party/libuv/src/unix/proctitle.c", ] } else { sources += nonwin_srcs + [ "//third_party/libuv/src/unix/linux-core.c", "//third_party/libuv/src/unix/linux-inotify.c", "//third_party/libuv/src/unix/linux-syscalls.c", "//third_party/libuv/src/unix/procfs-exepath.c", "//third_party/libuv/src/unix/random-getrandom.c", "//third_party/libuv/src/unix/random-sysctl-linux.c", "//third_party/libuv/src/unix/proctitle.c", ] } subsystem_name = "thirdparty" part_name = "libuv" } ohos_static_library("uv_static") { stack_protector_ret = false deps = [ ":libuv_source" ] public_configs = [ ":libuv_config" ] subsystem_name = "thirdparty" part_name = "libuv" } ohos_shared_library("uv") { stack_protector_ret = false deps = [ ":libuv_source" ] public_configs = [ ":libuv_config" ] subsystem_name = "thirdparty" part_name = "libuv" if (is_ohos) { output_extension = "so" } install_images = [ "system", "updater", ] }