summaryrefslogtreecommitdiffstats
path: root/src/ceph.in
diff options
context:
space:
mode:
authorKefu Chai <kchai@redhat.com>2018-10-22 07:13:49 +0200
committerKefu Chai <kchai@redhat.com>2018-10-22 08:40:03 +0200
commite85146297708e59a41a463e1bd390d1e9de4d49c (patch)
treee23df2f5e230c830865fd4f9a47fab5d972d469e /src/ceph.in
parentcmake: should compile libzstd with -fPIC (diff)
downloadceph-e85146297708e59a41a463e1bd390d1e9de4d49c.tar.xz
ceph-e85146297708e59a41a463e1bd390d1e9de4d49c.zip
ceph.in: extract get_cmake_variables()
so it can be reused Signed-off-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'src/ceph.in')
-rwxr-xr-xsrc/ceph.in19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/ceph.in b/src/ceph.in
index 07461856917..82d6239486c 100755
--- a/src/ceph.in
+++ b/src/ceph.in
@@ -98,12 +98,23 @@ def get_pythonlib_dir():
"""Returns the name of a distutils build directory"""
return "lib.{version[0]}".format(version=sys.version_info)
+
+def get_cmake_variables(names):
+ vars = dict((name, None) for name in names)
+ for line in open(os.path.join(MYPDIR, "CMakeCache.txt")):
+ # parse lines like "WITH_ASAN:BOOL=ON"
+ for name in names:
+ if line.startswith("{}:".format(name)):
+ vars[name] = line.split("=")[1].strip()
+ break
+ if all(vars.itervalues()):
+ break
+ return vars
+
+
if os.path.exists(os.path.join(MYPDIR, "CMakeCache.txt")) \
and os.path.exists(os.path.join(MYPDIR, "bin/init-ceph")):
- src_path = None
- for l in open(os.path.join(MYPDIR, "CMakeCache.txt")):
- if l.startswith("ceph_SOURCE_DIR:STATIC="):
- src_path = l.split("=")[1].strip()
+ src_path = get_cmake_variables(["ceph_SOURCE_DIR"])["ceph_SOURCE_DIR"]
if src_path is None:
# Huh, maybe we're not really in a cmake environment?