1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

added make script and customizable assert

This commit is contained in:
rwachtfogel 2023-05-31 18:39:35 +03:00
parent 010502731c
commit 4fbca1a26c
5 changed files with 456 additions and 409 deletions

3
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"cmake.configureOnOpen": true
}

View file

@ -25,39 +25,40 @@
include_directories(.)
list(APPEND SOURCES
core/lws_dll2.c
core/lws_dll2.c
)
if (NOT LWS_ONLY_SSPC)
list(APPEND SOURCES
core/alloc.c
core/buflist.c
core/context.c
core/lws_map.c
core/libwebsockets.c
core/logs.c
)
if (LWS_WITH_FILE_OPS)
list(APPEND SOURCES core/vfs.c)
endif()
list(APPEND SOURCES
core/alloc.c
core/assert.c
core/buflist.c
core/context.c
core/lws_map.c
core/libwebsockets.c
core/logs.c
)
if (LWS_WITH_FILE_OPS)
list(APPEND SOURCES core/vfs.c)
endif()
else()
#
# libwebsockets.a with only SSPC pieces in
#
list(APPEND SOURCES
secure-streams/serialized/client/sspc.c
secure-streams/serialized/client/sspc-transport.c
secure-streams/serialized/client/sspc-deserialize.c
core-net/lws-dsh.c
core-net/transport-mux-client.c
core-net/transport-mux-common.c
)
#
# libwebsockets.a with only SSPC pieces in
#
list(APPEND SOURCES
secure-streams/serialized/client/sspc.c
secure-streams/serialized/client/sspc-transport.c
secure-streams/serialized/client/sspc-deserialize.c
core-net/lws-dsh.c
core-net/transport-mux-client.c
core-net/transport-mux-common.c
)
endif()
exports_to_parent_scope()

25
lib/core/assert.c Normal file
View file

@ -0,0 +1,25 @@
#include "private-lib-core.h"
#ifdef LWS_ENABLE_CUSTOM_ASSERT
typedef void (*lws_assert_cb)(const char *file, int line, const char *expression);
void lws_set_assert_cb(lws_assert_cb cb);
void lws_assert(const char *file, int line, const char *expression);
#define assert(expression) (void)((expression) || (lws_assert(__FILE__, __LINE__, #expression), 0))
#endif
static lws_assert_cb assert_cb = NULL;
void lws_set_assert_cb(lws_assert_cb cb) {
assert_cb = cb;
}
void lws_assert(const char *file, int line, const char *expression) {
if (assert_cb != NULL) {
assert_cb(file, line, expression);
} else {
fprintf(stderr, "Assertion failed: %s, file %s, line %d\n", expression, file, line);
abort();
}
}

File diff suppressed because it is too large Load diff

5
make.sh Executable file
View file

@ -0,0 +1,5 @@
rm -rf build
mkdir build
cd build
cmake .. -DLWS_WITH_MINIMAL_EXAMPLES=1
make