diff options
author | Jo-Philipp Wich <jo@mein.io> | 2024-04-19 09:19:12 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2024-04-24 12:30:28 +0200 |
commit | e8d78a26da0c6a3144b2b08bee989564a516b951 (patch) | |
tree | 6ef6a1e786df552d2efb7c697306f834475ebe59 /CMakeLists.txt | |
parent | cfe137be068a7ba1895d3c9bcb7b38d21e5a95dd (diff) |
lib: introduce socket library
Introduce a new socket module which provides bindings for the BSD sockets
API to ucode scripts.
Example usage:
import * as socket from 'socket';
let sk = socket.create(socket.AF_INET, socket.SOCK_STREAM);
sk.connect("192.168.1.1", 80);
sk.send("GET / HTTP/1.0\r\n\r\n");
print(sk.recv(4096));
sk.close();
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ade8aac..084c441 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,6 +60,7 @@ option(RESOLV_SUPPORT "NS resolve plugin support" ON) option(STRUCT_SUPPORT "Struct plugin support" ON) option(ULOOP_SUPPORT "Uloop plugin support" ${DEFAULT_ULOOP_SUPPORT}) option(LOG_SUPPORT "Log plugin support" ON) +option(SOCKET_SUPPORT "Socket plugin support" ON) set(LIB_SEARCH_PATH "${CMAKE_INSTALL_PREFIX}/lib/ucode/*.so:${CMAKE_INSTALL_PREFIX}/share/ucode/*.uc:./*.so:./*.uc" CACHE STRING "Default library search path") string(REPLACE ":" "\", \"" LIB_SEARCH_DEFINE "${LIB_SEARCH_PATH}") @@ -266,6 +267,13 @@ if(LOG_SUPPORT) endif() endif() +if(SOCKET_SUPPORT) + set(LIBRARIES ${LIBRARIES} socket_lib) + add_library(socket_lib MODULE lib/socket.c) + set_target_properties(socket_lib PROPERTIES OUTPUT_NAME socket PREFIX "") + target_link_options(socket_lib PRIVATE ${UCODE_MODULE_LINK_OPTIONS}) +endif() + if(UNIT_TESTING) enable_testing() add_definitions(-DUNIT_TESTING) |