]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: make libcurses optional 32780/head
authorLucian Petrut <lpetrut@cloudbasesolutions.com>
Tue, 29 Oct 2019 14:05:32 +0000 (14:05 +0000)
committerLucian Petrut <lpetrut@cloudbasesolutions.com>
Thu, 30 Jul 2020 06:41:57 +0000 (06:41 +0000)
libcurses may not be available on some platforms (e.g. Windows),
so we'll make it optional.

If libcurses is not available, we'll disable the rbd iotop
command.

Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
src/tools/rbd/CMakeLists.txt
src/tools/rbd/action/Perf.cc

index cf069e8f58b408b6ff4fc847319554cdd58f082e..f1ee02c2ba801898936ddcc22cf45ad44ecf085d 100644 (file)
@@ -1,5 +1,6 @@
 set(CURSES_NEED_NCURSES TRUE)
-find_package(Curses REQUIRED)
+# libcurses may not be available on some platforms (e.g. Windows).
+find_package(Curses)
 
 set(rbd_srcs
   rbd.cc
@@ -61,8 +62,12 @@ target_link_libraries(rbd librbd
   journal
   libneorados
   librados
-  ceph-common global ${CURSES_LIBRARIES}
+  ceph-common global
   ${BLKID_LIBRARIES} ${CMAKE_DL_LIBS})
+if(CURSES_FOUND)
+  target_compile_definitions(rbd PRIVATE HAVE_CURSES)
+  target_link_libraries(rbd ${CURSES_LIBRARIES})
+endif()
 if(WITH_KRBD)
   target_link_libraries(rbd 
     krbd)
index 64e9fd21067da05590399ac72451b3c165c274bc..c30121021595b3abbfd526b5fc239cb7c162c75f 100644 (file)
@@ -11,7 +11,9 @@
 #include "common/Formatter.h"
 #include "common/TextTable.h"
 #include "global/global_context.h"
+#ifdef HAVE_CURSES
 #include <ncurses.h>
+#endif
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/time.h>
@@ -338,6 +340,7 @@ void format(const ImageStats& image_stats, Formatter* f, bool global_search) {
 
 } // namespace iostat
 
+#ifdef HAVE_CURSES
 namespace iotop {
 
 class MainWindow {
@@ -560,6 +563,7 @@ private:
 };
 
 } // namespace iotop
+#endif // HAVE_CURSES
 
 
 void get_arguments_iostat(po::options_description *positional,
@@ -651,6 +655,7 @@ int execute_iostat(const po::variables_map &vm,
   return 0;
 }
 
+#ifdef HAVE_CURSES
 void get_arguments_iotop(po::options_description *positional,
                          po::options_description *options) {
   at::add_pool_options(positional, options, true);
@@ -688,13 +693,15 @@ int execute_iotop(const po::variables_map &vm,
   return 0;
 }
 
-Shell::Action stat_action(
-  {"perf", "image", "iostat"}, {}, "Display image IO statistics.", "",
-  &get_arguments_iostat, &execute_iostat);
 Shell::Action top_action(
   {"perf", "image", "iotop"}, {}, "Display a top-like IO monitor.", "",
   &get_arguments_iotop, &execute_iotop);
 
+#endif // HAVE_CURSES
+
+Shell::Action stat_action(
+  {"perf", "image", "iostat"}, {}, "Display image IO statistics.", "",
+  &get_arguments_iostat, &execute_iostat);
 } // namespace perf
 } // namespace action
 } // namespace rbd