1# Copyright (c) 2021-2022 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/ohos.gni") 15 16platform = "${current_os}_${current_cpu}" 17 18ohos_static_library("websockets") { 19 sources = [ 20 "//third_party/libwebsockets/lib/core-net/adopt.c", 21 "//third_party/libwebsockets/lib/core-net/client/client.c", 22 "//third_party/libwebsockets/lib/core-net/client/conmon.c", 23 "//third_party/libwebsockets/lib/core-net/client/connect.c", 24 "//third_party/libwebsockets/lib/core-net/client/connect2.c", 25 "//third_party/libwebsockets/lib/core-net/client/connect3.c", 26 "//third_party/libwebsockets/lib/core-net/client/connect4.c", 27 "//third_party/libwebsockets/lib/core-net/client/sort-dns.c", 28 "//third_party/libwebsockets/lib/core-net/close.c", 29 "//third_party/libwebsockets/lib/core-net/dummy-callback.c", 30 "//third_party/libwebsockets/lib/core-net/network.c", 31 "//third_party/libwebsockets/lib/core-net/output.c", 32 "//third_party/libwebsockets/lib/core-net/pollfd.c", 33 "//third_party/libwebsockets/lib/core-net/route.c", 34 "//third_party/libwebsockets/lib/core-net/service.c", 35 "//third_party/libwebsockets/lib/core-net/sorted-usec-list.c", 36 "//third_party/libwebsockets/lib/core-net/state.c", 37 "//third_party/libwebsockets/lib/core-net/vhost.c", 38 "//third_party/libwebsockets/lib/core-net/wsi-timeout.c", 39 "//third_party/libwebsockets/lib/core-net/wsi.c", 40 "//third_party/libwebsockets/lib/core/alloc.c", 41 "//third_party/libwebsockets/lib/core/buflist.c", 42 "//third_party/libwebsockets/lib/core/context.c", 43 "//third_party/libwebsockets/lib/core/libwebsockets.c", 44 "//third_party/libwebsockets/lib/core/logs.c", 45 "//third_party/libwebsockets/lib/core/lws_dll2.c", 46 "//third_party/libwebsockets/lib/core/lws_map.c", 47 "//third_party/libwebsockets/lib/core/vfs.c", 48 "//third_party/libwebsockets/lib/event-libs/poll/poll.c", 49 "//third_party/libwebsockets/lib/misc/base64-decode.c", 50 "//third_party/libwebsockets/lib/misc/cache-ttl/file.c", 51 "//third_party/libwebsockets/lib/misc/cache-ttl/heap.c", 52 "//third_party/libwebsockets/lib/misc/cache-ttl/lws-cache-ttl.c", 53 "//third_party/libwebsockets/lib/misc/dir.c", 54 "//third_party/libwebsockets/lib/misc/lejp.c", 55 "//third_party/libwebsockets/lib/misc/lws-ring.c", 56 "//third_party/libwebsockets/lib/misc/lwsac/cached-file.c", 57 "//third_party/libwebsockets/lib/misc/lwsac/lwsac.c", 58 "//third_party/libwebsockets/lib/misc/prng.c", 59 "//third_party/libwebsockets/lib/misc/sha-1.c", 60 "//third_party/libwebsockets/lib/plat/unix/unix-caps.c", 61 "//third_party/libwebsockets/lib/plat/unix/unix-fds.c", 62 "//third_party/libwebsockets/lib/plat/unix/unix-file.c", 63 "//third_party/libwebsockets/lib/plat/unix/unix-init.c", 64 "//third_party/libwebsockets/lib/plat/unix/unix-misc.c", 65 "//third_party/libwebsockets/lib/plat/unix/unix-pipe.c", 66 "//third_party/libwebsockets/lib/plat/unix/unix-service.c", 67 "//third_party/libwebsockets/lib/plat/unix/unix-sockets.c", 68 "//third_party/libwebsockets/lib/roles/h1/ops-h1.c", 69 "//third_party/libwebsockets/lib/roles/h2/hpack.c", 70 "//third_party/libwebsockets/lib/roles/h2/http2.c", 71 "//third_party/libwebsockets/lib/roles/h2/ops-h2.c", 72 "//third_party/libwebsockets/lib/roles/http/client/client-http.c", 73 "//third_party/libwebsockets/lib/roles/http/cookie.c", 74 "//third_party/libwebsockets/lib/roles/http/date.c", 75 "//third_party/libwebsockets/lib/roles/http/header.c", 76 "//third_party/libwebsockets/lib/roles/http/parsers.c", 77 "//third_party/libwebsockets/lib/roles/http/server/lejp-conf.c", 78 "//third_party/libwebsockets/lib/roles/http/server/lws-spa.c", 79 "//third_party/libwebsockets/lib/roles/http/server/server.c", 80 "//third_party/libwebsockets/lib/roles/listen/ops-listen.c", 81 "//third_party/libwebsockets/lib/roles/netlink/ops-netlink.c", 82 "//third_party/libwebsockets/lib/roles/pipe/ops-pipe.c", 83 "//third_party/libwebsockets/lib/roles/raw-file/ops-raw-file.c", 84 "//third_party/libwebsockets/lib/roles/raw-skt/ops-raw-skt.c", 85 "//third_party/libwebsockets/lib/roles/ws/client-parser-ws.c", 86 "//third_party/libwebsockets/lib/roles/ws/client-ws.c", 87 "//third_party/libwebsockets/lib/roles/ws/ops-ws.c", 88 "//third_party/libwebsockets/lib/roles/ws/server-ws.c", 89 "//third_party/libwebsockets/lib/system/smd/smd.c", 90 "//third_party/libwebsockets/lib/system/system.c", 91 "//third_party/libwebsockets/lib/tls/openssl/openssl-client.c", 92 "//third_party/libwebsockets/lib/tls/openssl/openssl-server.c", 93 "//third_party/libwebsockets/lib/tls/openssl/openssl-session.c", 94 "//third_party/libwebsockets/lib/tls/openssl/openssl-ssl.c", 95 "//third_party/libwebsockets/lib/tls/openssl/openssl-tls.c", 96 "//third_party/libwebsockets/lib/tls/openssl/openssl-x509.c", 97 "//third_party/libwebsockets/lib/tls/tls-client.c", 98 "//third_party/libwebsockets/lib/tls/tls-network.c", 99 "//third_party/libwebsockets/lib/tls/tls-server.c", 100 "//third_party/libwebsockets/lib/tls/tls-sessions.c", 101 "//third_party/libwebsockets/lib/tls/tls.c", 102 ] 103 104 include_dirs = [ 105 "//third_party/libwebsockets/include", 106 "//third_party/libwebsockets/include/libwebsockets", 107 "//third_party/libwebsockets/include/libwebsockets/abstract", 108 "//third_party/libwebsockets/include/libwebsockets/abstract/protocols", 109 110 ################################################# 111 "//third_party/libwebsockets/lib", 112 "//third_party/libwebsockets/lib/plat", 113 "//third_party/libwebsockets/lib/plat/windows", 114 "//third_party/libwebsockets/lib/plat/unix", 115 "//third_party/libwebsockets/lib/plat/unix/android", 116 "//third_party/libwebsockets/lib/plat/optee", 117 "//third_party/libwebsockets/lib/plat/freertos", 118 "//third_party/libwebsockets/lib/plat/freertos/esp32", 119 "//third_party/libwebsockets/lib/plat/freertos/esp32/drivers", 120 "//third_party/libwebsockets/lib/plat/freertos/esp32/drivers/netdev", 121 "//third_party/libwebsockets/lib/event-libs", 122 "//third_party/libwebsockets/lib/event-libs/libevent", 123 "//third_party/libwebsockets/lib/event-libs/libuv", 124 "//third_party/libwebsockets/lib/event-libs/uloop", 125 "//third_party/libwebsockets/lib/event-libs/libev", 126 "//third_party/libwebsockets/lib/event-libs/sdevent", 127 "//third_party/libwebsockets/lib/event-libs/poll", 128 "//third_party/libwebsockets/lib/event-libs/glib", 129 "//third_party/libwebsockets/lib/cose", 130 "//third_party/libwebsockets/lib/core-net", 131 "//third_party/libwebsockets/lib/core-net/client", 132 "//third_party/libwebsockets/lib/tls", 133 "//third_party/libwebsockets/lib/tls/openssl", 134 "//third_party/libwebsockets/lib/abstract", 135 "//third_party/libwebsockets/lib/abstract/protocols", 136 "//third_party/libwebsockets/lib/abstract/protocols/smtp", 137 "//third_party/libwebsockets/lib/abstract/transports", 138 "//third_party/libwebsockets/lib/core", 139 "//third_party/libwebsockets/lib/misc", 140 "//third_party/libwebsockets/lib/misc/threadpool", 141 "//third_party/libwebsockets/lib/misc/fts", 142 "//third_party/libwebsockets/lib/misc/cache-ttl", 143 "//third_party/libwebsockets/lib/misc/lwsac", 144 "//third_party/libwebsockets/lib/secure-streams", 145 "//third_party/libwebsockets/lib/secure-streams/plugins", 146 "//third_party/libwebsockets/lib/secure-streams/plugins/ssp-h1url", 147 "//third_party/libwebsockets/lib/secure-streams/cpp", 148 "//third_party/libwebsockets/lib/secure-streams/protocols", 149 "//third_party/libwebsockets/lib/secure-streams/system", 150 "//third_party/libwebsockets/lib/secure-streams/system/auth-sigv4", 151 "//third_party/libwebsockets/lib/secure-streams/system/auth-api.amazon.com", 152 "//third_party/libwebsockets/lib/secure-streams/system/fetch-policy", 153 "//third_party/libwebsockets/lib/secure-streams/system/captive-portal-detect", 154 "//third_party/libwebsockets/lib/jose", 155 "//third_party/libwebsockets/lib/jose/jwk", 156 "//third_party/libwebsockets/lib/jose/jwe", 157 "//third_party/libwebsockets/lib/jose/jwe/enc", 158 "//third_party/libwebsockets/lib/jose/jws", 159 "//third_party/libwebsockets/lib/drivers", 160 "//third_party/libwebsockets/lib/drivers/spi", 161 "//third_party/libwebsockets/lib/drivers/spi/bitbang", 162 "//third_party/libwebsockets/lib/drivers/pwm", 163 "//third_party/libwebsockets/lib/drivers/netdev", 164 "//third_party/libwebsockets/lib/drivers/devices", 165 "//third_party/libwebsockets/lib/drivers/devices/display", 166 "//third_party/libwebsockets/lib/drivers/i2c", 167 "//third_party/libwebsockets/lib/drivers/i2c/bitbang", 168 "//third_party/libwebsockets/lib/drivers/display", 169 "//third_party/libwebsockets/lib/drivers/button", 170 "//third_party/libwebsockets/lib/drivers/settings", 171 "//third_party/libwebsockets/lib/drivers/led", 172 "//third_party/libwebsockets/lib/system", 173 "//third_party/libwebsockets/lib/system/fault-injection", 174 "//third_party/libwebsockets/lib/system/dhcpclient", 175 "//third_party/libwebsockets/lib/system/ntpclient", 176 "//third_party/libwebsockets/lib/system/metrics", 177 "//third_party/libwebsockets/lib/system/async-dns", 178 "//third_party/libwebsockets/lib/system/smd", 179 "//third_party/libwebsockets/lib/roles", 180 "//third_party/libwebsockets/lib/roles/raw-proxy", 181 "//third_party/libwebsockets/lib/roles/http", 182 "//third_party/libwebsockets/lib/roles/http/server", 183 "//third_party/libwebsockets/lib/roles/http/client", 184 "//third_party/libwebsockets/lib/roles/http/compression", 185 "//third_party/libwebsockets/lib/roles/http/compression/deflate", 186 "//third_party/libwebsockets/lib/roles/http/compression/brotli", 187 "//third_party/libwebsockets/lib/roles/h2", 188 "//third_party/libwebsockets/lib/roles/netlink", 189 "//third_party/libwebsockets/lib/roles/raw-skt", 190 "//third_party/libwebsockets/lib/roles/mqtt", 191 "//third_party/libwebsockets/lib/roles/mqtt/client", 192 "//third_party/libwebsockets/lib/roles/cgi", 193 "//third_party/libwebsockets/lib/roles/dbus", 194 "//third_party/libwebsockets/lib/roles/pipe", 195 "//third_party/libwebsockets/lib/roles/h1", 196 "//third_party/libwebsockets/lib/roles/listen", 197 "//third_party/libwebsockets/lib/roles/ws", 198 "//third_party/libwebsockets/lib/roles/ws/ext", 199 "//third_party/libwebsockets/lib/roles/raw-file", 200 201 ################################################# 202 "//third_party/openssl/include/openssl", 203 "//third_party/openssl/crypto/evp", 204 "//third_party/glib/glib", 205 "//third_party/glib", 206 ] 207 208 defines = [ "OHOS_LIBWEBSOCKETS=1" ] 209 210 cflags = [ 211 "-fPIC", 212 "-Os", 213 "-g", 214 "-Wall", 215 "-fno-strict-aliasing", 216 "-fvisibility=hidden", 217 "-Wmissing-declarations", 218 "-Waggregate-return", 219 "-pipe", 220 ] 221 222 deps = [ 223 "//third_party/openssl:libcrypto_static", 224 "//third_party/openssl:ssl_source", 225 "//third_party/zlib:libz", 226 ] 227} 228 229config("websocket_config") { 230 cflags = [ 231 "-Wall", 232 "-Wsign-compare", 233 "-Wstrict-aliasing", 234 "-Wuninitialized", 235 "-fvisibility=hidden", 236 "-Wtype-limits", 237 "-Wignored-qualifiers", 238 "-Wno-deprecated-declarations", 239 "-pthread", 240 "-Wno-unused-command-line-argument", 241 "-Wno-unused-parameter", 242 "-Wno-implicit-function-declaration", 243 ] 244} 245 246config("websockets_public_config") { 247 include_dirs = [ 248 "//third_party/libwebsockets/plugins", 249 "//third_party/libwebsockets/lib/core", 250 "//third_party/libwebsockets/lib/core-net", 251 "//third_party/libwebsockets/lib/event-libs", 252 "//third_party/libwebsockets/lib/abstract", 253 "//third_party/libwebsockets/lib/tls", 254 "//third_party/libwebsockets/lib/roles", 255 "//third_party/libwebsockets/lib/event-libs/libuv", 256 "//third_party/libwebsockets/lib/event-libs/poll", 257 "//third_party/libwebsockets/lib/event-libs/libevent", 258 "//third_party/libwebsockets/lib/event-libs/glib", 259 "//third_party/libwebsockets/lib/event-libs/libev", 260 "//third_party/libwebsockets/lib/jose/jwe", 261 "//third_party/libwebsockets/lib/jose/jws", 262 "//third_party/libwebsockets/lib/jose", 263 "//third_party/libwebsockets/lib/misc", 264 "//third_party/libwebsockets/lib/roles/http", 265 "//third_party/libwebsockets/lib/roles/http/compression", 266 "//third_party/libwebsockets/lib/roles/h1", 267 "//third_party/libwebsockets/lib/roles/h2", 268 "//third_party/libwebsockets/lib/roles/ws", 269 "//third_party/libwebsockets/lib/roles/cgi", 270 "//third_party/libwebsockets/lib/roles/dbus", 271 "//third_party/libwebsockets/lib/roles/raw-proxy", 272 "//third_party/libwebsockets/lib/abstract", 273 "//third_party/libwebsockets/lib/system/async-dns", 274 "//third_party/libwebsockets/lib/roles/mqtt", 275 "//third_party/libwebsockets/lib/system/metrics", 276 "//third_party/libwebsockets/lib", 277 "//third_party/libwebsockets/win32port/win32helpers", 278 "//third_party/libwebsockets/include", 279 ] 280 if (platform == "mingw_x86_64") { 281 include_dirs += [ "//third_party/libwebsockets/lib/plat/windows" ] 282 } else if (platform == "mac_arm64" || platform == "mac_x64" || 283 platform == "linux_x64") { 284 include_dirs += [ "//third_party/libwebsockets/lib/plat/unix" ] 285 } 286 cflags = [ "-Wno-error=#warnings" ] 287} 288 289ohos_static_library("websockets_static") { 290 sources = [ 291 "//third_party/libwebsockets/lib/core-net/adopt.c", 292 "//third_party/libwebsockets/lib/core-net/client/client.c", 293 "//third_party/libwebsockets/lib/core-net/client/connect.c", 294 "//third_party/libwebsockets/lib/core-net/client/connect2.c", 295 "//third_party/libwebsockets/lib/core-net/client/connect3.c", 296 "//third_party/libwebsockets/lib/core-net/client/connect4.c", 297 "//third_party/libwebsockets/lib/core-net/client/sort-dns.c", 298 "//third_party/libwebsockets/lib/core-net/close.c", 299 "//third_party/libwebsockets/lib/core-net/dummy-callback.c", 300 "//third_party/libwebsockets/lib/core-net/network.c", 301 "//third_party/libwebsockets/lib/core-net/output.c", 302 "//third_party/libwebsockets/lib/core-net/pollfd.c", 303 "//third_party/libwebsockets/lib/core-net/sequencer.c", 304 "//third_party/libwebsockets/lib/core-net/service.c", 305 "//third_party/libwebsockets/lib/core-net/sorted-usec-list.c", 306 "//third_party/libwebsockets/lib/core-net/state.c", 307 "//third_party/libwebsockets/lib/core-net/vhost.c", 308 "//third_party/libwebsockets/lib/core-net/wsi-timeout.c", 309 "//third_party/libwebsockets/lib/core-net/wsi.c", 310 "//third_party/libwebsockets/lib/core/alloc.c", 311 "//third_party/libwebsockets/lib/core/buflist.c", 312 "//third_party/libwebsockets/lib/core/context.c", 313 "//third_party/libwebsockets/lib/core/libwebsockets.c", 314 "//third_party/libwebsockets/lib/core/logs.c", 315 "//third_party/libwebsockets/lib/core/lws_dll2.c", 316 "//third_party/libwebsockets/lib/core/vfs.c", 317 "//third_party/libwebsockets/lib/event-libs/poll/poll.c", 318 "//third_party/libwebsockets/lib/misc/base64-decode.c", 319 "//third_party/libwebsockets/lib/misc/lejp.c", 320 "//third_party/libwebsockets/lib/misc/lws-ring.c", 321 "//third_party/libwebsockets/lib/misc/lwsac/cached-file.c", 322 "//third_party/libwebsockets/lib/misc/lwsac/lwsac.c", 323 "//third_party/libwebsockets/lib/misc/peer-limits.c", 324 "//third_party/libwebsockets/lib/misc/sha-1.c", 325 "//third_party/libwebsockets/lib/roles/h1/ops-h1.c", 326 "//third_party/libwebsockets/lib/roles/h2/hpack.c", 327 "//third_party/libwebsockets/lib/roles/h2/http2.c", 328 "//third_party/libwebsockets/lib/roles/h2/ops-h2.c", 329 "//third_party/libwebsockets/lib/roles/http/client/client-http.c", 330 "//third_party/libwebsockets/lib/roles/http/date.c", 331 "//third_party/libwebsockets/lib/roles/http/header.c", 332 "//third_party/libwebsockets/lib/roles/http/parsers.c", 333 "//third_party/libwebsockets/lib/roles/http/server/server.c", 334 "//third_party/libwebsockets/lib/roles/listen/ops-listen.c", 335 "//third_party/libwebsockets/lib/roles/pipe/ops-pipe.c", 336 "//third_party/libwebsockets/lib/roles/raw-file/ops-raw-file.c", 337 "//third_party/libwebsockets/lib/roles/raw-skt/ops-raw-skt.c", 338 "//third_party/libwebsockets/lib/roles/ws/client-parser-ws.c", 339 "//third_party/libwebsockets/lib/roles/ws/client-ws.c", 340 "//third_party/libwebsockets/lib/roles/ws/ops-ws.c", 341 "//third_party/libwebsockets/lib/roles/ws/server-ws.c", 342 "//third_party/libwebsockets/lib/system/system.c", 343 ] 344 if (platform == "mingw_x86_64") { 345 sources += [ 346 "//third_party/libwebsockets/lib/plat/windows/windows-fds.c", 347 "//third_party/libwebsockets/lib/plat/windows/windows-file.c", 348 "//third_party/libwebsockets/lib/plat/windows/windows-init.c", 349 "//third_party/libwebsockets/lib/plat/windows/windows-misc.c", 350 "//third_party/libwebsockets/lib/plat/windows/windows-pipe.c", 351 "//third_party/libwebsockets/lib/plat/windows/windows-plugins.c", 352 "//third_party/libwebsockets/lib/plat/windows/windows-service.c", 353 "//third_party/libwebsockets/lib/plat/windows/windows-sockets.c", 354 ] 355 } else if (platform == "mac_arm64" || platform == "mac_x64" || 356 platform == "linux_x64") { 357 defines = [ "LWS_HAVE_SYS_RESOURCE_H" ] 358 sources += [ 359 "//third_party/libwebsockets/lib/plat/unix/unix-caps.c", 360 "//third_party/libwebsockets/lib/plat/unix/unix-fds.c", 361 "//third_party/libwebsockets/lib/plat/unix/unix-file.c", 362 "//third_party/libwebsockets/lib/plat/unix/unix-init.c", 363 "//third_party/libwebsockets/lib/plat/unix/unix-misc.c", 364 "//third_party/libwebsockets/lib/plat/unix/unix-pipe.c", 365 "//third_party/libwebsockets/lib/plat/unix/unix-service.c", 366 "//third_party/libwebsockets/lib/plat/unix/unix-sockets.c", 367 ] 368 } 369 configs = [ ":websocket_config" ] 370 public_configs = [ ":websockets_public_config" ] 371} 372