diff --git a/src/posix/console_cli.cpp b/src/posix/console_cli.cpp index ef3c6fa2a..735e983d4 100644 --- a/src/posix/console_cli.cpp +++ b/src/posix/console_cli.cpp @@ -28,6 +28,8 @@ #include "console_cli.h" +#if OPENTHREAD_CONFIG_CLI_TRANSPORT == OT_CLI_TRANSPORT_CONSOLE + #include #include @@ -129,3 +131,5 @@ void otxConsoleProcess(const otSysMainloopContext *aMainloop) } #endif // HAVE_LIBEDIT || HAVE_LIBREADLINE + +#endif // OPENTHREAD_CONFIG_CLI_TRANSPORT == OT_CLI_TRANSPORT_CONSOLE diff --git a/src/posix/console_cli.h b/src/posix/console_cli.h index 2728e18e7..16682d508 100644 --- a/src/posix/console_cli.h +++ b/src/posix/console_cli.h @@ -35,6 +35,24 @@ #include +#include "cli/cli_config.h" + +#ifndef HAVE_LIBEDIT +#define HAVE_LIBEDIT 0 +#endif + +#ifndef HAVE_LIBREADLINE +#define HAVE_LIBREADLINE 0 +#endif + +#if OPENTHREAD_CONFIG_CLI_TRANSPORT == OT_CLI_TRANSPORT_CONSOLE +#define OPENTHREAD_USE_CONSOLE 1 +#if !(HAVE_LIBEDIT || HAVE_LIBREADLINE) || OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE +#error \ + "When OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_CONSOLE, HAVE_LIBEDIT or HAVE_LIBREADLINE MUST be defined and OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE MUST be 0" +#endif +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/src/posix/main.c b/src/posix/main.c index baefa15f7..4614d6f3c 100644 --- a/src/posix/main.c +++ b/src/posix/main.c @@ -66,12 +66,8 @@ #elif OPENTHREAD_POSIX_APP_TYPE == OT_POSIX_APP_TYPE_CLI #include -#include "cli/cli_config.h" -#if (HAVE_LIBEDIT || HAVE_LIBREADLINE) && !OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE && \ - (OPENTHREAD_CONFIG_CLI_TRANSPORT == OT_CLI_TRANSPORT_CONSOLE) -#define OPENTHREAD_USE_CONSOLE 1 #include "console_cli.h" -#endif +#include "cli/cli_config.h" #else #error "Unknown posix app type!" #endif