From 5ddda38da4f3c8ab8ff9c1a501bcd54df558fb80 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 9 Apr 2021 18:54:46 +0800 Subject: [PATCH] common: extract options into yaml extract the options in common/options.cc into separate .yaml.in files, and preprocess them using CMake before translating them into .cc files using a python script. this change paves the road to render the options using sphinx, and will allow us to further annotate the options to include more metadata. also, a this YAML file can be consumed by applications like dashboard and Sphinx to consume these metadata in a simpler way. * use @variable-name@ for substituting the variables in .yaml.in file * use cmake variable of `mgr_disabled_modules` instead of C macro to define `mgr_disabled_modules` in global.yaml.in * debian/control, ceph.spec.in, win32_deps_build.sh: add python3-yaml as build dep * add y2c.py (short for YAML to C++) to translate .yaml to .cc file * common/options/*.yaml.in: extract and split options into .yaml.in files, the subvars in it is then replaced with CMake variables, and copied to the corresponding .yaml files * include/config-h.in.cmake: remove MGR_DISABLED_MODULES, as it is not a CMake variable. Signed-off-by: Kefu Chai --- CMakeLists.txt | 5 - ceph.spec.in | 2 + debian/control | 2 +- src/CMakeLists.txt | 1 + src/common/CMakeLists.txt | 2 + src/common/options.cc | 8840 +---------------- src/common/options.h | 23 +- src/common/options/CMakeLists.txt | 94 + src/common/options/build_options.cc | 35 + src/common/options/build_options.h | 8 + src/common/options/cephfs-mirror.yaml.in | 82 + src/common/options/global.yaml.in | 6979 +++++++++++++ .../options/immutable-object-cache.yaml.in | 98 + src/common/options/mds-client.yaml.in | 454 + src/common/options/mds.yaml.in | 1168 +++ src/common/options/rbd-mirror.yaml.in | 210 + src/common/options/rbd.yaml.in | 832 ++ src/common/options/rgw.yaml.in | 2569 +++++ src/common/options/y2c.py | 323 + src/crimson/CMakeLists.txt | 3 +- src/include/config-h.in.cmake | 3 - win32_deps_build.sh | 6 +- 22 files changed, 12887 insertions(+), 8852 deletions(-) create mode 100644 src/common/options/CMakeLists.txt create mode 100644 src/common/options/build_options.cc create mode 100644 src/common/options/build_options.h create mode 100644 src/common/options/cephfs-mirror.yaml.in create mode 100644 src/common/options/global.yaml.in create mode 100644 src/common/options/immutable-object-cache.yaml.in create mode 100644 src/common/options/mds-client.yaml.in create mode 100644 src/common/options/mds.yaml.in create mode 100644 src/common/options/rbd-mirror.yaml.in create mode 100644 src/common/options/rbd.yaml.in create mode 100644 src/common/options/rgw.yaml.in create mode 100755 src/common/options/y2c.py diff --git a/CMakeLists.txt b/CMakeLists.txt index f623c5e1b791e..b42f82d7c98c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -487,11 +487,6 @@ if(WITH_MGR) set(MGR_PYTHON_LIBRARIES ${Python3_LIBRARIES}) set(MGR_PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR}) set(MGR_PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR}) - # https://tracker.ceph.com/issues/45147 - if(Python3_VERSION VERSION_GREATER_EQUAL 3.8) - set(MGR_DISABLED_MODULES "diskprediction_local") - message(STATUS "mgr module disabled for ${Python3_VERSION}: ${MGR_DISABLED_MODULES}") - endif() # Boost dependency check deferred to Boost section endif(WITH_MGR) endif(NOT WIN32) diff --git a/ceph.spec.in b/ceph.spec.in index f363361e1e5e5..66e069e5bcdab 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -327,6 +327,7 @@ BuildRequires: cunit-devel BuildRequires: python%{python3_pkgversion}-setuptools BuildRequires: python%{python3_pkgversion}-Cython BuildRequires: python%{python3_pkgversion}-PrettyTable +BuildRequires: python%{python3_pkgversion}-PyYAML BuildRequires: python%{python3_pkgversion}-Sphinx BuildRequires: rdma-core-devel BuildRequires: liblz4-devel >= 1.7 @@ -349,6 +350,7 @@ BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-setuptools BuildRequires: python%{python3_pkgversion}-Cython BuildRequires: python%{python3_pkgversion}-prettytable +BuildRequires: python%{python3_pkgversion}-pyyaml BuildRequires: python%{python3_pkgversion}-sphinx BuildRequires: lz4-devel >= 1.7 %endif diff --git a/debian/control b/debian/control index 1ca1b3b460533..d61dac291a881 100644 --- a/debian/control +++ b/debian/control @@ -98,7 +98,7 @@ Build-Depends: automake, python3-setuptools, python3-sphinx, # Make-Check python3-werkzeug, - python3-setuptools, + python3-yaml, # Crimson ragel, # Make-Check socat, # Crimson systemtap-sdt-dev, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 98db46226bd4a..12e8300efaf08 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -447,6 +447,7 @@ add_subdirectory(arch) set(ceph_common_objs $ $ + $ $ $ $ diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index a2d50aed896f9..2feaa80800d98 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -11,6 +11,8 @@ if(WIN32) add_library(dlfcn_win32 STATIC win32/dlfcn.cc win32/errno.cc) endif() +add_subdirectory(options) + set(common_srcs AsyncOpTracker.cc BackTrace.cc diff --git a/src/common/options.cc b/src/common/options.cc index f2c0104f7d896..5f89980d85a4b 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -4,6 +4,7 @@ #include "acconfig.h" #include "options.h" #include "common/Formatter.h" +#include "common/options/build_options.h" // Helpers for validators #include "include/stringify.h" @@ -336,8843 +337,4 @@ void Option::print(ostream *out) const } } -constexpr unsigned long long operator"" _min (unsigned long long min) { - return min * 60; -} -constexpr unsigned long long operator"" _hr (unsigned long long hr) { - return hr * 60 * 60; -} -constexpr unsigned long long operator"" _day (unsigned long long day) { - return day * 24 * 60 * 60; -} -constexpr unsigned long long operator"" _K (unsigned long long n) { - return n << 10; -} -constexpr unsigned long long operator"" _M (unsigned long long n) { - return n << 20; -} -constexpr unsigned long long operator"" _G (unsigned long long n) { - return n << 30; -} -constexpr unsigned long long operator"" _T (unsigned long long n) { - return n << 40; -} - -std::vector