MSVC: tools: disable interactive tools
I don't feel like porting linenoise to Windows, there's no getline, etc.
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 317c1c8..94b4eed 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 10d5758..b41ad2b 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 @@
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 @@
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 0000000..d55f2c2
--- /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);
+}