Skip to content

Commit

Permalink
MSVC: tools: disable interactive tools
Browse files Browse the repository at this point in the history
I don't feel like porting linenoise to Windows, there's no getline, etc.
  • Loading branch information
jktjkt authored and michalvasko committed Dec 16, 2021
1 parent a3fe12a commit 2e3f935
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
4 changes: 3 additions & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
23 changes: 18 additions & 5 deletions tools/lint/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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()
22 changes: 22 additions & 0 deletions tools/lint/main_ni_only.c
Original file line number Diff line number Diff line change
@@ -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);
}

0 comments on commit 2e3f935

Please sign in to comment.