-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
114 lines (93 loc) · 2.93 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
set(mbusd_DIST_dir ${COMPONENT_DIR}/mbusd)
set(mbusd_SRC_DIR ${mbusd_DIST_dir}/src)
file(READ ${mbusd_SRC_DIR}/tty.c tty_c)
# disable CRTSCTS flags, not supported!
string(REPLACE
"mod->tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD | CRTSCTS);"
"mod->tios.c_cflag &= ~(CSIZE | CSTOPB | PARENB | PARODD /*| CRTSCTS*/);"
tty_c "${tty_c}")
# disable rts control, API not supported, move control to user code
string(REGEX REPLACE "void
tty_set_rts\\(int fd\\)
{(.*)}
.*
tty_clr_rts\\(int fd\\)
{(.*)}
#endif"
" /* DISABLED */
void tty_set_rts(int fd){\\n/*\\1 */ \\n}
void tty_clr_rts(int fd){\\n/*\\2 */ \\n}
#endif"
tty_c "${tty_c}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tty.c "${tty_c}")
file(READ ${mbusd_SRC_DIR}/sock.c sock_c)
string(REPLACE
"fcntl(server_s, F_SETFD, 1) == -1"
"0 /* DISABLED */"
sock_c "${sock_c}")
# setting lwip TX buffer size not implemented
# see http://lwip.100.n7.nabble.com/Setting-TCP-socket-s-send-amp-receive-buffer-size-td10263.html
string(REPLACE
"(setsockopt(server_s, SOL_SOCKET,
SO_SNDBUF, (void *)&sock_opt,
\t\t sizeof(sock_opt)) == -1) ||
(setsockopt(server_s, SOL_SOCKET,
SO_RCVBUF, (void *)&sock_opt,
\t\t sizeof(sock_opt)) == -1)"
"(0 /* DISABLED */) ||
(0 /* DISABLED */)"
sock_c "${sock_c}")
string(REPLACE
"(setsockopt(sd, SOL_SOCKET,
SO_SNDBUF, (void *)&sock_opt,
\t\t sizeof(sock_opt)) == -1) ||
(setsockopt(sd, SOL_SOCKET,
SO_RCVBUF, (void *)&sock_opt,
\t\t sizeof(sock_opt)) == -1)"
"(0 /* DISABLED */) ||
(0 /* DISABLED */)"
sock_c "${sock_c}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/sock.c "${sock_c}")
file(READ ${mbusd_SRC_DIR}/conn.c conn_c)
# wrap select to my_select()
string(REPLACE
"select(max_sd + 1, &sdsetrd, &sdsetwr, NULL, &t_out);"
"my_select(max_sd + 1, &sdsetrd, &sdsetwr, NULL, &t_out, tty.fd);"
conn_c "${conn_c}")
string(REGEX REPLACE
"(#include \"state\\.h\")"
"\\1
extern int my_select(int __nfds, fd_set *__restrict __readfds,
fd_set *__restrict __writefds, fd_set *__restrict __exceptfds,
struct timeval *__restrict __timeout, int skip_d);"
conn_c "${conn_c}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conn.c "${conn_c}")
set(mbusd_SRC
${mbusd_SRC_DIR}/cfg.c
${CMAKE_CURRENT_BINARY_DIR}/conn.c
${mbusd_SRC_DIR}/crc16.c
${mbusd_SRC_DIR}/modbus.c
${mbusd_SRC_DIR}/queue.c
${CMAKE_CURRENT_BINARY_DIR}/sock.c
${mbusd_SRC_DIR}/state.c
${CMAKE_CURRENT_BINARY_DIR}/tty.c
esp_log.c
my_select.c
mbGateway.c
sig.c
)
idf_component_register(SRCS ${mbusd_SRC}
INCLUDE_DIRS ${mbusd_SRC_DIR} ${COMPONENT_DIR}
REQUIRES log esp32 freertos
)
target_compile_definitions(${COMPONENT_LIB}
PUBLIC
-DTRXCTL
-DLOG
PRIVATE
-DDEBUG
)
target_compile_options(${COMPONENT_LIB}
PRIVATE
-Wno-error=maybe-uninitialized
)