From dacded439b41d1800d03b2a0f944ca23b5d140c5 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Mon, 27 Feb 2023 15:55:15 +0100 Subject: [PATCH] fix #131: add build time option: CLIENT_PREFIX --- CMakeConfig.txt | 3 + CMakeLists.txt | 26 ++++----- docs/CMakeLists.txt | 4 +- docs/conf.py.in | 55 +++++++++++++------ docs/source/bin/common/env.rst | 7 +++ .../bin/common/note_contrib_options.rst | 8 +++ .../source/bin/common/note_program_prefix.rst | 10 ++++ docs/source/bin/memaslap.rst | 12 ++-- docs/source/bin/memcapable.rst | 10 ++-- docs/source/bin/memcat.rst | 10 ++-- docs/source/bin/memcp.rst | 14 ++--- docs/source/bin/memdump.rst | 13 +++-- docs/source/bin/memerror.rst | 11 ++-- docs/source/bin/memexist.rst | 10 ++-- docs/source/bin/memflush.rst | 11 ++-- docs/source/bin/memparse.rst | 8 ++- docs/source/bin/memping.rst | 10 ++-- docs/source/bin/memrm.rst | 10 ++-- docs/source/bin/memslap.rst | 10 ++-- docs/source/bin/memstat.rst | 10 ++-- docs/source/bin/memtouch.rst | 9 ++- .../source/libmemcached/memcached_analyze.rst | 2 +- src/bin/CMakeLists.txt | 10 ++-- test/CMakeLists.txt | 2 +- 24 files changed, 169 insertions(+), 106 deletions(-) create mode 100644 docs/source/bin/common/env.rst create mode 100644 docs/source/bin/common/note_contrib_options.rst create mode 100644 docs/source/bin/common/note_program_prefix.rst diff --git a/CMakeConfig.txt b/CMakeConfig.txt index 714ee94e..2a8617f1 100644 --- a/CMakeConfig.txt +++ b/CMakeConfig.txt @@ -23,6 +23,9 @@ else() set(TARGET_NAMELINK_COMPONENT NAMELINK_COMPONENT dev DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() +set(CLIENT_PREFIX mem + CACHE STRING "client prefix (default mem; i.e.: memstat, memcp, memcat ...)") + option(BUILD_SHARED_LIBS "whether to build shared libraries" ON) option(BUILD_TESTING "whether to enable build of the test suite" diff --git a/CMakeLists.txt b/CMakeLists.txt index 1603c2c4..1396a42a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,19 +30,19 @@ if(NOT BUILD_DOCSONLY) include(CMake/_Include.cmake) set(CLIENTS - memcapable - memcat - memcp - memdump - memerror - memexist - memflush - memparse - memping - memrm - memslap - memstat - memtouch + capable + cat + cp + dump + error + exist + flush + parse + ping + rm + slap + stat + touch ) add_subdirectory(include) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index c2d6325a..86710793 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -50,7 +50,7 @@ else() COMMAND ${CMAKE_COMMAND} -E touch "${SPHINX_HTML_DIR}" BYPRODUCTS ${SPHINX_HTML_DIR} - DEPENDS "${DOCS_SOURCE}" + DEPENDS "${DOCS_SOURCE}" conf.py.in ) add_custom_target(html ALL DEPENDS "${SPHINX_HTML_DIR}") @@ -73,7 +73,7 @@ else() COMMAND ${CMAKE_COMMAND} -E touch "${SPHINX_MAN_DIR}" BYPRODUCTS ${SPHINX_MAN_DIR} - DEPENDS "${DOCS_SOURCE}" + DEPENDS "${DOCS_SOURCE}" conf.py.in ) add_custom_target(man ALL DEPENDS "${SPHINX_MAN_DIR}") diff --git a/docs/conf.py.in b/docs/conf.py.in index 2c3c6130..690df358 100644 --- a/docs/conf.py.in +++ b/docs/conf.py.in @@ -191,27 +191,46 @@ man_pages = [ ('libmemcachedutil/memcached_pool' ,'memcached_pool_st' ,u'libmemcached Documentation' ,man_authors,3), ('libmemcachedutil/memcached_pool' ,'memcached_pool' ,u'libmemcached Documentation' ,man_authors,3), - ('bin/memcapable' , 'memcapable' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memcat' , 'memcat' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memcp' , 'memcp' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memdump' , 'memdump' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memerror' , 'memerror' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memflush' , 'memflush' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memrm' , 'memrm' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memaslap' , 'memaslap' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memslap' , 'memslap' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memstat' , 'memstat' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memexist' , 'memexist' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memparse' , 'memparse' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memping' , 'memping' , u'libmemcached Documentation' , man_authors, 1), - ('bin/memtouch' , 'memtouch' , u'libmemcached Documentation' , man_authors, 1), + ('bin/memcapable' , 'memcapable' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memcat' , 'memcat' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memcp' , 'memcp' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memdump' , 'memdump' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memerror' , 'memerror' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memflush' , 'memflush' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memrm' , 'memrm' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memaslap' , 'memaslap' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memslap' , 'memslap' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memstat' , 'memstat' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memexist' , 'memexist' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memparse' , 'memparse' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memping' , 'memping' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memtouch' , 'memtouch' ,u'libmemcached Documentation' , man_authors, 1), ] +if '@CLIENT_PREFIX@' != 'mem' : + man_pages.extend([ + ('bin/memcapable' , '@CLIENT_PREFIX@capable' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memcat' , '@CLIENT_PREFIX@cat' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memcp' , '@CLIENT_PREFIX@cp' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memdump' , '@CLIENT_PREFIX@dump' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memerror' , '@CLIENT_PREFIX@error' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memflush' , '@CLIENT_PREFIX@flush' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memrm' , '@CLIENT_PREFIX@rm' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memaslap' , '@CLIENT_PREFIX@aslap' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memslap' , '@CLIENT_PREFIX@slap' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memstat' , '@CLIENT_PREFIX@stat' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memexist' , '@CLIENT_PREFIX@exist' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memparse' , '@CLIENT_PREFIX@parse' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memping' , '@CLIENT_PREFIX@ping' ,u'libmemcached Documentation' , man_authors, 1), + ('bin/memtouch' , '@CLIENT_PREFIX@touch' ,u'libmemcached Documentation' , man_authors, 1), + ]) + rst_prolog = """ -.. |libhashkit_version| replace:: 1.0 -.. |libmemcached_version| replace:: 1.0 -.. |libmemcachedprotocol_version| replace:: 0.0 -.. |libmemcachedutil_version| replace:: 1.0 +.. |client_prefix| replace:: @CLIENT_PREFIX@ +.. |libhashkit_version| replace:: @LIBHASHKIT_VERSION_INC@ +.. |libmemcached_version| replace:: @LIBMEMCACHED_VERSION_INC@ +.. |libmemcachedprotocol_version| replace:: @LIBMEMCACHEDPROTOCOL_VERSION_INC@ +.. |libmemcachedutil_version| replace:: @LIBMEMCACHEDUTIL_VERSION_INC@ """ @SPHINX_CONF_APPEND@ diff --git a/docs/source/bin/common/env.rst b/docs/source/bin/common/env.rst new file mode 100644 index 00000000..ac1d42e8 --- /dev/null +++ b/docs/source/bin/common/env.rst @@ -0,0 +1,7 @@ +ENVIRONMENT +----------- + +.. envvar:: MEMCACHED_SERVERS + + Specify a list of servers. + diff --git a/docs/source/bin/common/note_contrib_options.rst b/docs/source/bin/common/note_contrib_options.rst new file mode 100644 index 00000000..3f8f2ab7 --- /dev/null +++ b/docs/source/bin/common/note_contrib_options.rst @@ -0,0 +1,8 @@ + +CONTRIBUTED PROGRAM +................... + +This is a contributed program. + +This program doesn't follow the standard flag/option scheme. + diff --git a/docs/source/bin/common/note_program_prefix.rst b/docs/source/bin/common/note_program_prefix.rst new file mode 100644 index 00000000..86d7099e --- /dev/null +++ b/docs/source/bin/common/note_program_prefix.rst @@ -0,0 +1,10 @@ + +PROGRAM PREFIX +.............. + +The prefix of this program is variable, i.e. it can be configured at build time. + +Usually the client programs of ``libmemcached-awesome`` are prefixed with ``mem``, like ``memcat`` or ``memcp``. + +It can be configured, though, to replace the prefix with something else like ``mc``, in case of that, +the client programs of ``libmemcached-awesome`` would be called ``mccat``, ``mccp``, etc. respectively. diff --git a/docs/source/bin/memaslap.rst b/docs/source/bin/memaslap.rst index ab311d73..6ac3e21a 100644 --- a/docs/source/bin/memaslap.rst +++ b/docs/source/bin/memaslap.rst @@ -5,7 +5,7 @@ memaslap - Load testing and benchmarking a server SYNOPSIS -------- -memaslap [options] +|client_prefix|\aslap [options] .. program:: memaslap @@ -1000,13 +1000,11 @@ memaslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m memaslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m -p 2 -NOTE ----- - -This is a contributed program. - -This program doesn't follow the standard flag/option scheme. +NOTES +----- +.. include:: common/note_program_prefix.rst +.. include:: common/note_contrib_options.rst SEE ALSO -------- diff --git a/docs/source/bin/memcapable.rst b/docs/source/bin/memcapable.rst index 374c9c33..ed93bd1d 100644 --- a/docs/source/bin/memcapable.rst +++ b/docs/source/bin/memcapable.rst @@ -6,7 +6,7 @@ SYNOPSIS .. program:: memcapable -memcapable [options] +|client_prefix|\capable [options] Check a memcached server's capabilities and compatibility. @@ -39,10 +39,12 @@ OPTIONS Set the timeout for an IO operation to/from the server to \ *n*\ seconds. -NOTE ----- -This program doesn't follow the standard flag/option scheme. +NOTES +----- + +.. include:: common/note_program_prefix.rst +.. include:: common/note_contrib_options.rst SEE ALSO diff --git a/docs/source/bin/memcat.rst b/docs/source/bin/memcat.rst index 36f6a6bb..6bb5ebc8 100644 --- a/docs/source/bin/memcat.rst +++ b/docs/source/bin/memcat.rst @@ -6,7 +6,7 @@ SYNOPSIS .. program:: memcat -memcat [options] key [key...] +|client_prefix|\cat [options] key [key...] Read and output the value of one key or the values of a set of keys. @@ -28,12 +28,12 @@ OPTIONS .. include:: options/hash.rst .. include:: options/file_out.rst -ENVIRONMENT ------------ +.. include:: common/env.rst -.. envvar:: MEMCACHED_SERVERS +NOTES +----- - Specify a list of servers. +.. include:: common/note_program_prefix.rst SEE ALSO -------- diff --git a/docs/source/bin/memcp.rst b/docs/source/bin/memcp.rst index 7d82a590..9106d694 100644 --- a/docs/source/bin/memcp.rst +++ b/docs/source/bin/memcp.rst @@ -6,7 +6,7 @@ SYNOPSIS .. program:: memcp -memcp [options] \-\-servers +|client_prefix|\cp [options] \-\-servers Copy files to a collection of memcached servers. @@ -49,14 +49,14 @@ OPTIONS .. option:: -/|--absolute Use absolute path (real path), instead of basename only. - - -ENVIRONMENT ------------ -.. envvar:: MEMCACHED_SERVERS - Specify the list of servers. +.. include:: common/env.rst + +NOTES +----- + +.. include:: common/note_program_prefix.rst SEE ALSO -------- diff --git a/docs/source/bin/memdump.rst b/docs/source/bin/memdump.rst index a24e4085..7724ad31 100644 --- a/docs/source/bin/memdump.rst +++ b/docs/source/bin/memdump.rst @@ -6,7 +6,7 @@ SYNOPSIS .. program:: memdump -memdump [options] +|client_prefix|\dump [options] Dump a list of keys from a server. @@ -22,13 +22,14 @@ OPTIONS .. include:: options/common_get.rst .. include:: options/file_out.rst - -ENVIRONMENT ------------ -.. envvar:: MEMCACHED_SERVERS - Specify the list of servers. +.. include:: common/env.rst + +NOTES +----- + +.. include:: common/note_program_prefix.rst SEE ALSO -------- diff --git a/docs/source/bin/memerror.rst b/docs/source/bin/memerror.rst index caa6b497..e00a5b75 100644 --- a/docs/source/bin/memerror.rst +++ b/docs/source/bin/memerror.rst @@ -6,7 +6,7 @@ SYNOPSIS .. program:: memerror -memerror [options] +|client_prefix|\error [options] Translate a memcached error code into a string. @@ -22,12 +22,13 @@ OPTIONS .. include:: options/all.rst .. include:: options/common.rst -ENVIRONMENT ------------ -.. envvar:: MEMCACHED_SERVERS +.. include:: common/env.rst + +NOTES +----- - Specify the list of servers. +.. include:: common/note_program_prefix.rst SEE ALSO -------- diff --git a/docs/source/bin/memexist.rst b/docs/source/bin/memexist.rst index 52832b16..85b7fd08 100644 --- a/docs/source/bin/memexist.rst +++ b/docs/source/bin/memexist.rst @@ -6,7 +6,7 @@ SYNOPSIS .. program:: memexist -memexist [options] +|client_prefix|\exist [options] Check for the existence of a key. @@ -21,12 +21,12 @@ OPTIONS .. include:: options/common_get.rst .. include:: options/hash.rst -ENVIRONMENT ------------ +.. include:: common/env.rst -.. envvar:: MEMCACHED_SERVERS +NOTES +----- - Specify the list of servers. +.. include:: common/note_program_prefix.rst SEE ALSO -------- diff --git a/docs/source/bin/memflush.rst b/docs/source/bin/memflush.rst index b752b6eb..dc04ca63 100644 --- a/docs/source/bin/memflush.rst +++ b/docs/source/bin/memflush.rst @@ -4,7 +4,7 @@ memflush SYNOPSIS -------- -memflush [options] +|client_prefix|\flush [options] .. program:: memflush @@ -51,12 +51,13 @@ OPTIONS .. _memcached protocol documentation: https://github.com/memcached/memcached/blob/master/doc/protocol.txt -ENVIRONMENT ------------ -.. envvar:: MEMCACHED_SERVERS +.. include:: common/env.rst + +NOTES +----- - Specify the list of servers. +.. include:: common/note_program_prefix.rst SEE ALSO -------- diff --git a/docs/source/bin/memparse.rst b/docs/source/bin/memparse.rst index 4a6f4135..4c96aae1 100644 --- a/docs/source/bin/memparse.rst +++ b/docs/source/bin/memparse.rst @@ -6,7 +6,7 @@ SYNOPSIS .. program:: memparse -memparse