From 402f60359e046aa5fef5c17b459a5d0a30fa7ebb Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sun, 31 Oct 2021 20:50:45 +0100 Subject: lib: introduce struct library Introduce a new "struct" library which is a port of the Python 3.10 struct module with a reduced set of API functions. It supports the same format patterns and conversions while providing the following methods: struct = require('struct'); buf = struct.pack("fmt", args...); values = struct.unpack("fmt", buf); struct_inst = struct.new("fmt"); buf = struct_inst.pack(args...); values = struct_inst.unpack(buf); Signed-off-by: Jo-Philipp Wich --- CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index e5fb58a..82d0e33 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ OPTION(UCI_SUPPORT "UCI plugin support" ON) OPTION(RTNL_SUPPORT "Route Netlink plugin support" ON) OPTION(NL80211_SUPPORT "Wireless Netlink plugin support" ON) OPTION(RESOLV_SUPPORT "NS resolve plugin support" ON) +OPTION(STRUCT_SUPPORT "Struct plugin support" ON) OPTION(LEGACY_SUPPORT "Support deprecated syntax features" ON) @@ -151,6 +152,16 @@ IF(RESOLV_SUPPORT) ENDIF() ENDIF() +IF(STRUCT_SUPPORT) + SET(LIBRARIES ${LIBRARIES} struct_lib) + ADD_LIBRARY(struct_lib MODULE lib/struct.c) + SET_TARGET_PROPERTIES(struct_lib PROPERTIES OUTPUT_NAME struct PREFIX "") + CHECK_FUNCTION_EXISTS(frexp FREXP_FUNCTION_EXISTS) + IF (NOT FREXP_FUNCTION_EXISTS) + TARGET_LINK_LIBRARIES(struct_lib m) + ENDIF() +ENDIF() + IF(UNIT_TESTING) ENABLE_TESTING() ADD_DEFINITIONS(-DUNIT_TESTING) -- cgit v1.2.3