diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-10-31 20:50:45 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-10-31 21:39:16 +0100 |
commit | 402f60359e046aa5fef5c17b459a5d0a30fa7ebb (patch) | |
tree | 86cd34fab1438fea01c058a40eb50fa6677b0785 /CMakeLists.txt | |
parent | c6dae4249c8211aab78af500e9753ba0d51b2de0 (diff) |
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 <jo@mein.io>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 11 |
1 files changed, 11 insertions, 0 deletions
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) |