From 2e3f935ed6f4a47e65b31de5aeebcd8877d5a09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Sat, 11 Dec 2021 02:16:27 +0100 Subject: [PATCH] MSVC: tools: disable interactive tools I don't feel like porting linenoise to Windows, there's no getline, etc. --- tools/CMakeLists.txt | 4 +++- tools/lint/CMakeLists.txt | 23 ++++++++++++++++++----- tools/lint/main_ni_only.c | 22 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 tools/lint/main_ni_only.c diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 317c1c80b..94b4eed46 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -2,7 +2,9 @@ configure_file(${PROJECT_SOURCE_DIR}/tools/config.h.in ${PROJECT_BINARY_DIR}/tools/config.h @ONLY) add_subdirectory(lint) -add_subdirectory(re) +if(NOT WIN32) + add_subdirectory(re) +endif() set(format_sources ${format_sources} diff --git a/tools/lint/CMakeLists.txt b/tools/lint/CMakeLists.txt index 10d5758e5..b41ad2bc6 100644 --- a/tools/lint/CMakeLists.txt +++ b/tools/lint/CMakeLists.txt @@ -1,7 +1,12 @@ # yanglint +if(WIN32) + set(YANGLINT_INTERACTIVE OFF) +else() + set(YANGLINT_INTERACTIVE ON) +endif() + set(lintsrc - main.c main_ni.c cmd.c cmd_add.c @@ -13,9 +18,17 @@ set(lintsrc cmd_print.c cmd_searchpath.c common.c - completion.c - configuration.c - linenoise/linenoise.c) +) +if(YANGLINT_INTERACTIVE) + set(lintsrc ${lintsrc} + main.c + completion.c + configuration.c + linenoise/linenoise.c) +else() + set(lintsrc ${lintsrc} + main_ni_only.c) +endif() set(format_sources ${format_sources} @@ -53,7 +66,7 @@ if(ENABLE_TESTS) find_program(PATH_EXPECT NAMES expect) if(NOT PATH_EXPECT) message(WARNING "'expect' not found! The yanglint(1) interactive tests will not be available.") - else() + elseif(YANGLINT_INTERACTIVE) # add_yanglint_test(NAME in_list SCRIPT expect/list.exp) endif() endif() diff --git a/tools/lint/main_ni_only.c b/tools/lint/main_ni_only.c new file mode 100644 index 000000000..d55f2c2a6 --- /dev/null +++ b/tools/lint/main_ni_only.c @@ -0,0 +1,22 @@ +/** + * @file main_ni_only.c + * @brief non-interactive implementation of main() for those platforms without the linenoise library + * + * Copyright (c) 2015-2021 CESNET, z.s.p.o. + * + * This source code is licensed under BSD 3-Clause License (the "License"). + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + */ + +int main_ni(int argc, char *argv[]); + +int done; /* for cmd.c */ + +int +main(int argc, char *argv[]) +{ + return main_ni(argc, argv); +}