Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make vstart work with cmake out of tree builds #5457

Merged
merged 8 commits into from
Aug 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 53 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,58 @@ install(TARGETS rados librados-config DESTINATION bin)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/
DESTINATION ${PYTHON_INSTDIR})

## dencoder
set(dencoder_srcs
test/encoding/ceph_dencoder.cc
krbd.cc
common/secret.c
common/TextTable.cc
)
if(${WITH_RADOSGW})
list(APPEND dencoder_srcs
rgw/rgw_dencoder.cc
rgw/rgw_acl.cc
rgw/rgw_common.cc
rgw/rgw_env.cc
rgw/rgw_json_enc.cc
)
endif(${WITH_RADOSGW})
add_executable(ceph-dencoder ${dencoder_srcs} $<TARGET_OBJECTS:heap_profiler_objs>)
if(${WITH_RADOSGW})
set(DENCODER_EXTRALIBS
rgw_a
cls_rgw_client
curl
expat
fcgi
resolv
)
endif(${WITH_RADOSGW})
target_link_libraries(ceph-dencoder
librados
librbd
global
osd
mds
mon
osdc
cls_lock_client
cls_refcount_client
cls_log_client
cls_statelog_client
cls_version_client
cls_replica_log_client
cls_kvs
cls_user_client
${DENCODER_EXTRALIBS}
blkid
udev
keyutils
${EXTRALIBS}
${TCMALLOC_LIBS}
${CMAKE_DL_LIBS}
)

# Monitor
set(lib_mon_srcs
auth/cephx/CephxKeyServer.cc
Expand Down Expand Up @@ -677,7 +729,7 @@ configure_file(${CMAKE_SOURCE_DIR}/src/ceph-coverage.in
configure_file(${CMAKE_SOURCE_DIR}/src/ceph-debugpack.in
${CMAKE_BINARY_DIR}/ceph-debugpack @ONLY)

configure_file(${CMAKE_SOURCE_DIR}/src/ceph.in.cmake
configure_file(${CMAKE_SOURCE_DIR}/src/ceph.in
${CMAKE_BINARY_DIR}/ceph @ONLY)

configure_file(${CMAKE_SOURCE_DIR}/src/ceph-crush-location.in
Expand Down
9 changes: 4 additions & 5 deletions src/Makefile-client.am
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ bin_PROGRAMS += ceph-syn

ceph: ceph.in ./ceph_ver.h Makefile
rm -f $@ $@.tmp
echo "#!/usr/bin/env python" >$@.tmp
grep "#define CEPH_GIT_NICE_VER" $(srcdir)/ceph_ver.h | \
sed -e 's/#define \(.*VER\) /\1=/' >>$@.tmp
grep "#define CEPH_GIT_VER" $(srcdir)/ceph_ver.h | \
sed -e 's/#define \(.*VER\) /\1=/' -e 's/=\(.*\)$$/="\1"/' >>$@.tmp
cp $@.in $@.tmp
sed -i "s|@PYTHON_EXECUTABLE@|/usr/bin/env python|" $@.tmp
grep CEPH_GIT_NICE_VER ./ceph_ver.h | cut -f 3 -d " " | sed s/\"//g | xargs -I "{}" sed -i "s/@CEPH_GIT_NICE_VER@/{}/g" $@.tmp
grep CEPH_GIT_VER ./ceph_ver.h | cut -f 3 -d " " | sed s/\"//g | xargs -I "{}" sed -i "s/@CEPH_GIT_VER@/{}/g" $@.tmp
cat $(srcdir)/$@.in >>$@.tmp
chmod a+x $@.tmp
chmod a-w $@.tmp
Expand Down
52 changes: 41 additions & 11 deletions src/ceph.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!@PYTHON_EXECUTABLE@
# -*- mode:python -*-
# vim: ts=4 sw=4 smarttab expandtab
#
Expand All @@ -22,6 +23,9 @@ import os
import sys
import platform

CEPH_GIT_VER="@CEPH_GIT_VER@"
CEPH_GIT_NICE_VER="@CEPH_GIT_NICE_VER@"

# Make life easier on developers:
# If in src/, and .libs and pybind exist here, assume we're running
# from a Ceph source dir and tweak PYTHONPATH and LD_LIBRARY_PATH
Expand All @@ -31,33 +35,59 @@ MYPATH = os.path.abspath(__file__)
MYDIR = os.path.dirname(MYPATH)
DEVMODEMSG = '*** DEVELOPER MODE: setting PATH, PYTHONPATH and LD_LIBRARY_PATH ***'

if MYDIR.endswith('src') and \
os.path.exists(os.path.join(MYDIR, '.libs')) and \
os.path.exists(os.path.join(MYDIR, 'pybind')):
def respawn_in_path(lib_path, pybind_path):
execv_cmd = ['python']
if 'CEPH_DBG' in os.environ:
execv_cmd += ['-mpdb']

if platform.system() == "Darwin":
lib_path_var = "DYLD_LIBRARY_PATH"
else:
lib_path_var = "LD_LIBRARY_PATH"

py_binary = os.environ.get("PYTHON", "python")
MYLIBPATH = os.path.join(MYDIR, '.libs')
execv_cmd = ['python']
if 'CEPH_DBG' in os.environ:
execv_cmd += ['-mpdb']

if lib_path_var in os.environ:
if MYLIBPATH not in os.environ[lib_path_var]:
os.environ[lib_path_var] += ':' + MYLIBPATH
if lib_path not in os.environ[lib_path_var]:
os.environ[lib_path_var] += ':' + lib_path
print >> sys.stderr, DEVMODEMSG
os.execvp(py_binary, execv_cmd + sys.argv)
else:
os.environ[lib_path_var] = MYLIBPATH
os.environ[lib_path_var] = lib_path
print >> sys.stderr, DEVMODEMSG
os.execvp(py_binary, execv_cmd + sys.argv)
sys.path.insert(0, os.path.join(MYDIR, 'pybind'))
sys.path.insert(0, os.path.join(MYDIR, pybind_path))

if MYDIR.endswith('src') and \
os.path.exists(os.path.join(MYDIR, '.libs')) and \
os.path.exists(os.path.join(MYDIR, 'pybind')):

respawn_in_path(os.path.join(MYDIR, '.libs'), "pybind")
if os.environ.has_key('PATH') and MYDIR not in os.environ['PATH']:
os.environ['PATH'] += ':' + MYDIR

elif os.path.exists(os.path.join(os.getcwd(), "CMakeCache.txt")) \
and os.path.exists(os.path.join(os.getcwd(), "init-ceph")):
src_path = None
for l in open("./CMakeCache.txt").readlines():
if l.startswith("Ceph_SOURCE_DIR:STATIC="):
src_path = l.split("=")[1].strip()

if src_path is None:
# Huh, maybe we're not really in a cmake environment?
pass
else:
# Developer mode, but in a cmake build dir instead of the src dir
lib_path = os.path.join(os.getcwd(), "src")
pybind_path = os.path.join(src_path, "src", "pybind")
respawn_in_path(lib_path, pybind_path)

sys.path.insert(0, os.path.join(MYDIR, pybind_path))

# Add src/ to path for e.g. ceph-conf
if os.environ.has_key('PATH') and lib_path not in os.environ['PATH']:
os.environ['PATH'] += ':' + lib_path

import argparse
import errno
import json
Expand Down
Loading