Skip to content

Commit

Permalink
cmake: Cython modules add to cmake
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Maredia <amaredia@redhat.com>
  • Loading branch information
alimaredia committed Mar 4, 2016
1 parent 6bad855 commit de1619f
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cmake/modules/AddCephTest.cmake
Expand Up @@ -12,7 +12,7 @@ function(add_ceph_test test_name test_path)
CEPH_LIB=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib
PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:${CMAKE_SOURCE_DIR}/src:$ENV{PATH}
PYTHONPATH=${CMAKE_SOURCE_DIR}/src/pybind:${CMAKE_SOURCE_DIR}/src/pybind/rados)
PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules/lib.linux-x86_64-2.7:${CMAKE_SOURCE_DIR}/src/pybind:${CMAKE_SOURCE_DIR}/src/pybind/rados)
endfunction()

#sets uniform compiler flags and link libraries
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Expand Up @@ -522,6 +522,7 @@ install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/

add_subdirectory(ceph-disk)
add_subdirectory(ceph-detect-init)
add_subdirectory(pybind)

## dencoder
set(dencoder_srcs
Expand Down
2 changes: 1 addition & 1 deletion src/ceph.in
Expand Up @@ -92,7 +92,7 @@ elif os.path.exists(os.path.join(os.getcwd(), "CMakeCache.txt")) \
# 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")
pythonlib_path = os.path.join(src_path, "src", get_pythonlib_dir())
pythonlib_path = os.path.join(os.getcwd(), "../src/pybind", get_pythonlib_dir())
respawn_in_path(lib_path, pybind_path, pythonlib_path)

sys.path.insert(0, os.path.join(MYDIR, pybind_path))
Expand Down
5 changes: 5 additions & 0 deletions src/pybind/CMakeLists.txt
@@ -0,0 +1,5 @@
set(CYTHON_MODULE_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules)

add_subdirectory(rados)
add_subdirectory(rbd)
add_subdirectory(cephfs)
9 changes: 9 additions & 0 deletions src/pybind/cephfs/CMakeLists.txt
@@ -0,0 +1,9 @@
add_custom_target(cython_cephfs ALL
COMMAND
LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/cephfs
CFLAGS=\"-I${CMAKE_SOURCE_DIR}/src -I${CMAKE_BINARY_DIR}/include -I${CMAKE_SOURCE_DIR}/src/include -std=c++11\"
python ${CMAKE_SOURCE_DIR}/src/pybind/cephfs/setup.py build --build-base ${CYTHON_MODULE_DIR} --verbose
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS rados cephfs)

3 changes: 2 additions & 1 deletion src/pybind/cephfs/setup.py
Expand Up @@ -42,7 +42,8 @@ def cythonize(x, **kwargs):
ext_modules = cythonize([
Extension("cephfs",
["cephfs.pyx"],
libraries=["cephfs"]
libraries=["cephfs"],
language="c++"
)
], build_dir=os.environ.get("CYTHON_BUILD_DIR", None), include_path=[
os.path.join(os.path.dirname(__file__), "..", "rados")]
Expand Down
9 changes: 9 additions & 0 deletions src/pybind/rados/CMakeLists.txt
@@ -0,0 +1,9 @@
add_custom_target(cython_rados ALL
COMMAND
LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/rados
CFLAGS=\"-I${CMAKE_SOURCE_DIR}/src/include -std=c++11\"
python ${CMAKE_SOURCE_DIR}/src/pybind/rados/setup.py build --build-base ${CYTHON_MODULE_DIR} --verbose
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS rados)

3 changes: 2 additions & 1 deletion src/pybind/rados/setup.py
Expand Up @@ -42,7 +42,8 @@ def cythonize(x, **kwargs):
ext_modules = cythonize([
Extension("rados",
["rados.pyx"],
libraries=["rados"]
libraries=["rados"],
language="c++"
)
], build_dir=os.environ.get("CYTHON_BUILD_DIR", None)),
cmdclass={
Expand Down
9 changes: 9 additions & 0 deletions src/pybind/rbd/CMakeLists.txt
@@ -0,0 +1,9 @@
add_custom_target(cython_rbd ALL
COMMAND
LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
CYTHON_BUILD_DIR=${CMAKE_BINARY_DIR}/src/pybind/rbd
CFLAGS=\"-I${CMAKE_SOURCE_DIR}/src/include -std=c++11\"
python ${CMAKE_SOURCE_DIR}/src/pybind/rbd/setup.py build --build-base ${CYTHON_MODULE_DIR} --verbose
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS rbd)

3 changes: 2 additions & 1 deletion src/pybind/rbd/setup.py
Expand Up @@ -42,7 +42,8 @@ def cythonize(x, **kwargs):
ext_modules = cythonize([
Extension("rbd",
["rbd.pyx"],
libraries=["rbd"]
libraries=["rbd"],
language="c++"
)
], build_dir=os.environ.get("CYTHON_BUILD_DIR", None), include_path=[
os.path.join(os.path.dirname(__file__), "..", "rados")]
Expand Down
10 changes: 6 additions & 4 deletions src/test/CMakeLists.txt
Expand Up @@ -381,7 +381,10 @@ add_dependencies(check
ceph_erasure_code_non_regression
ceph_erasure_code
ceph-disk
ceph-detect-init)
ceph-detect-init
cython_rados
cython_rbd
cython_cephfs)

add_ceph_test(test-ceph-helpers.sh ${CMAKE_CURRENT_SOURCE_DIR}/test-ceph-helpers.sh)
add_ceph_test(erasure-decode-non-regression.sh ${CMAKE_SOURCE_DIR}/qa/workunits/erasure-code/encode-decode-non-regression.sh)
Expand Down Expand Up @@ -410,9 +413,8 @@ set_property(TEST
CEPH_BIN=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
CEPH_LIB=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib
PATH=$ENV{PATH}:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:${CMAKE_SOURCE_DIR}/src
PYTHONPATH=${CMAKE_SOURCE_DIR}/src/pybind
)
PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:${CMAKE_SOURCE_DIR}/src:$ENV{PATH}
PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules/lib.linux-x86_64-2.7:${CMAKE_SOURCE_DIR}/src/pybind:${CMAKE_SOURCE_DIR}/src/pybind/rados)

# unittest_admin_socket
add_executable(unittest_admin_socket EXCLUDE_FROM_ALL
Expand Down
6 changes: 2 additions & 4 deletions src/test/osd/CMakeLists.txt
Expand Up @@ -35,10 +35,8 @@ set_property(TEST
CEPH_BIN=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
CEPH_LIB=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib
PATH=$ENV{PATH}:${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:${CMAKE_SOURCE_DIR}/src
PYTHONPATH=${CMAKE_SOURCE_DIR}/src/pybind
)

PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:${CMAKE_SOURCE_DIR}/src:$ENV{PATH}
PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules/lib.linux-x86_64-2.7:${CMAKE_SOURCE_DIR}/src/pybind:${CMAKE_SOURCE_DIR}/src/pybind/rados)

# unittest_osdmap
add_executable(unittest_osdmap EXCLUDE_FROM_ALL
Expand Down

0 comments on commit de1619f

Please sign in to comment.