Skip to content

Commit

Permalink
iiod: Support compiling without v0.x compatibility
Browse files Browse the repository at this point in the history
Add WITH_IIOD_V0_COMPAT option, which defaults to ON.

When set to OFF, IIOD won't support the old ASCII protocol of Libiio
v0.x, and will only support the new binary protocol of Libiio v1.x.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
  • Loading branch information
pcercuei committed Dec 11, 2023
1 parent 50cbf50 commit a87bd33
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions README_BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ Cmake Options | Default | Description |
`WITH_IIOD` | ON | Build the IIO Daemon |
`WITH_IIOD_SERIAL` | ON | Add serial (UART) support |
`WITH_IIOD_USBD` | ON | Add support for USB through FunctionFS within IIOD |
`WITH_IIOD_V0_COMPAT` | ON | Add support for Libiio v0.x protocol and clients |
`WITH_AIO` | ON | Build IIOD with async. I/O support |
`WITH_SYSTEMD` | OFF | Enable installation of systemd service file for iiod |
`SYSTEMD_UNIT_INSTALL_DIR` | /lib/systemd/system | default install path for systemd unit files |
Expand Down
1 change: 1 addition & 0 deletions iio-config.h.cmakein
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#cmakedefine01 WITH_NETWORK_EVENTFD
#cmakedefine01 WITH_IIOD_USBD
#cmakedefine01 WITH_IIOD_SERIAL
#cmakedefine01 WITH_IIOD_V0_COMPAT
#cmakedefine01 WITH_LOCAL_CONFIG
#cmakedefine01 WITH_LOCAL_DMABUF_API
#cmakedefine01 WITH_LOCAL_MMAP_API
Expand Down
27 changes: 16 additions & 11 deletions iiod/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
cmake_minimum_required(VERSION 3.10)
project(iiod C)

include(FindBISON)
include(FindFLEX)

flex_target(lexer
${CMAKE_CURRENT_SOURCE_DIR}/lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.c)
bison_target(parser
${CMAKE_CURRENT_SOURCE_DIR}/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.c)
add_flex_bison_dependency(lexer parser)

include(CheckSymbolExists)
set(CMAKE_REQUIRED_LIBRARIES ${PTHREAD_LIBRARIES})
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
Expand All @@ -21,8 +12,7 @@ set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_DEFINITIONS)

add_executable(iiod
iiod.c interpreter.c ops.c responder.c thread-pool.c
${BISON_parser_OUTPUTS} ${FLEX_lexer_OUTPUTS}
iiod.c interpreter.c responder.c thread-pool.c
)
set_target_properties(iiod PROPERTIES
C_STANDARD 99
Expand All @@ -41,6 +31,20 @@ if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
set_source_files_properties(${BISON_parser_OUTPUTS} PROPERTIES COMPILE_FLAGS "-Wno-sign-compare")
endif ()

option(WITH_IIOD_V0_COMPAT "Build support for Libiio v0.x protocol" ON)
if (WITH_IIOD_V0_COMPAT)
include(FindBISON)
include(FindFLEX)

flex_target(lexer
${CMAKE_CURRENT_SOURCE_DIR}/lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.c)
bison_target(parser
${CMAKE_CURRENT_SOURCE_DIR}/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.c)
add_flex_bison_dependency(lexer parser)

target_sources(iiod PRIVATE ops.c ${BISON_parser_OUTPUTS} ${FLEX_lexer_OUTPUTS})
endif (WITH_IIOD_V0_COMPAT)

option(WITH_AIO "Build IIOD with async. I/O support" ON)
if (WITH_AIO)
find_library(LIBAIO_LIBRARIES aio)
Expand Down Expand Up @@ -133,6 +137,7 @@ if (WITH_UPSTART)
endif()

toggle_iio_feature("${WITH_IIOD_SERIAL}" iiod-serial)
toggle_iio_feature("${WITH_IIOD_V0_COMPAT}" iiod-v0-compat)
toggle_iio_feature("${WITH_AIO}" iiod-aio)
toggle_iio_feature("${WITH_IIOD_USBD}" iiod-usb)
toggle_iio_feature("${WITH_SYSTEMD}" iiod-systemd)
Expand Down
4 changes: 3 additions & 1 deletion iiod/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ void interpreter(struct iio_context *ctx, int fd_in, int fd_out, bool verbose,
pdata.fd_out = fd_out;
pdata.verbose = verbose;
pdata.pool = pool;
pdata.binary = !WITH_IIOD_V0_COMPAT;

pdata.xml_zstd = xml_zstd;
pdata.xml_zstd_len = xml_zstd_len;
Expand Down Expand Up @@ -287,7 +288,8 @@ void interpreter(struct iio_context *ctx, int fd_in, int fd_out, bool verbose,
pdata.writefd = writefd_io;
}

ascii_interpreter(&pdata, verbose);
if (WITH_IIOD_V0_COMPAT)
ascii_interpreter(&pdata, verbose);

if (pdata.binary)
binary_parse(&pdata);
Expand Down

0 comments on commit a87bd33

Please sign in to comment.