Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Third Party] Add libwebsockets #24280

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,7 @@
url = https://github.com/bouffalolab/bl_iot_sdk_tiny.git
branch = main
platforms = bouffalolab
[submodule "third_party/libwebsockets/repo"]
path = third_party/libwebsockets/repo
url = https://github.com/warmcat/libwebsockets
vivien-apple marked this conversation as resolved.
Show resolved Hide resolved
platforms = linux,darwin
109 changes: 109 additions & 0 deletions third_party/libwebsockets/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Copyright (c) 2023 Project CHIP Authors
#
# 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.

config("libwebsockets_config") {
include_dirs = [
".",
"repo/include",
]

cflags = [
"-Wno-shadow",
"-Wno-unreachable-code",
"-Wno-format-nonliteral",
]

defines = []
}

source_set("libwebsockets") {
include_dirs = [
"repo/lib/plat/windows",
"repo/lib/plat/freertos",
"repo/lib/plat/unix",
"repo/lib/secure-streams",
"repo/lib/event-libs",
"repo/lib/roles",
"repo/lib/roles/http",
"repo/lib/roles/h1",
"repo/lib/roles/h2",
"repo/lib/roles/ws",
"repo/lib/system/metrics",
"repo/lib/system/smd",
"repo/lib/system/async-dns",
"repo/lib/core",
"repo/lib/core-net",
]

sources = [
"repo/lib/core-net/adopt.c",
"repo/lib/core-net/close.c",
"repo/lib/core-net/dummy-callback.c",
"repo/lib/core-net/network.c",
"repo/lib/core-net/output.c",
"repo/lib/core-net/pollfd.c",
"repo/lib/core-net/service.c",
"repo/lib/core-net/sorted-usec-list.c",
"repo/lib/core-net/vhost.c",
"repo/lib/core-net/wsi-timeout.c",
"repo/lib/core-net/wsi.c",
"repo/lib/core/alloc.c",
"repo/lib/core/buflist.c",
"repo/lib/core/context.c",
"repo/lib/core/libwebsockets.c",
"repo/lib/core/logs.c",
"repo/lib/core/lws_dll2.c",
"repo/lib/event-libs/poll/poll.c",
"repo/lib/misc/base64-decode.c",
"repo/lib/misc/sha-1.c",
"repo/lib/roles/h1/ops-h1.c",
"repo/lib/roles/http/date.c",
"repo/lib/roles/http/header.c",
"repo/lib/roles/http/parsers.c",
"repo/lib/roles/http/server/server.c",
"repo/lib/roles/listen/ops-listen.c",
"repo/lib/roles/pipe/ops-pipe.c",
"repo/lib/roles/raw-skt/ops-raw-skt.c",
"repo/lib/roles/ws/ops-ws.c",
"repo/lib/roles/ws/server-ws.c",
"repo/lib/system/system.c",
]

if (current_os == "freertos") {
sources += [
"repo/lib/plat/freertos/freertos-fds.c",
"repo/lib/plat/freertos/freertos-init.c",
"repo/lib/plat/freertos/freertos-misc.c",
"repo/lib/plat/freertos/freertos-pipe.c",
"repo/lib/plat/freertos/freertos-service.c",
"repo/lib/plat/freertos/freertos-sockets.c",
]

cflags = [ "-DLWS_PLAT_FREERTOS" ]
} else {
sources += [
"repo/lib/plat/unix/unix-caps.c",
"repo/lib/plat/unix/unix-fds.c",
"repo/lib/plat/unix/unix-init.c",
"repo/lib/plat/unix/unix-misc.c",
"repo/lib/plat/unix/unix-pipe.c",
"repo/lib/plat/unix/unix-service.c",
"repo/lib/plat/unix/unix-sockets.c",
]

cflags = [ "-DLWS_PLAT_UNIX" ]
}

public_configs = [ ":libwebsockets_config" ]
}
65 changes: 65 additions & 0 deletions third_party/libwebsockets/lws_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2023 Project CHIP Authors
* All rights reserved.
*
* 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.
*
*/

#pragma once

#define LWS_LIBRARY_VERSION "4.3.99"

//
// Major individual features
//
#define LWS_WITH_NETWORK // "Compile with network-related code" - default: ON
#define LWS_ROLE_H1 // "Compile with support for http/1 (needed for ws)" - default: ON
#define LWS_ROLE_WS // "Compile with support for websockets" - default: ON
#define LWS_WITH_IPV6 // "Compile with support for ipv6" - default: OFF
#define LWS_UNIX_SOCK // "Compile with support for UNIX domain socket if OS supports it" - default: ON

//
// Client / Server / Test Apps build control
//
#define LWS_WITHOUT_CLIENT // "Don't build the client part of the library" default - OFF

//
// Extensions (permessage-deflate)
//
#define LWS_WITHOUT_EXTENSIONS // "Don't compile with extensions" - default: ON

//
// Helpers + misc
//
#define LWS_WITHOUT_DAEMONIZE // "Don't build the daemonization api" - default: ON
#define LWS_LOGS_TIMESTAMP // "Timestamp at start of logs" - default: ON
#define LWS_LOG_TAG_LIFECYCLE // "Log tagged object lifecycle as NOTICE" - default: ON

//
// Implied Options
//
#define LWS_WITH_POLL
#define LWS_MAX_SMP 1

#ifdef LWS_WITHOUT_DAEMONIZE
#define LWS_NO_DAEMONIZE
#endif

#ifdef LWS_WITH_HTTP2
#define LWS_ROLE_H2
#endif

#ifndef LWS_WITHOUT_SERVER
#define LWS_WITH_SERVER
#endif
19 changes: 19 additions & 0 deletions third_party/libwebsockets/lws_config_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2023 Project CHIP Authors
* All rights reserved.
*
* 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.
*
*/

#pragma once
1 change: 1 addition & 0 deletions third_party/libwebsockets/repo
Submodule repo added at ec6d5a