]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: Cython modules building with cmake
authorAli Maredia <amaredia@redhat.com>
Thu, 3 Mar 2016 17:05:18 +0000 (12:05 -0500)
committerJohn Spray <john.spray@redhat.com>
Tue, 29 Mar 2016 11:23:31 +0000 (12:23 +0100)
Signed-off-by: Ali Maredia <amaredia@redhat.com>
CMakeLists.txt
src/CMakeLists.txt
src/ceph.in
src/pybind/CMakeLists.txt [new file with mode: 0644]
src/pybind/cephfs/CMakeLists.txt [new file with mode: 0644]
src/pybind/cephfs/setup.py
src/pybind/rados/CMakeLists.txt [new file with mode: 0644]
src/pybind/rados/setup.py
src/pybind/rbd/CMakeLists.txt [new file with mode: 0644]
src/pybind/rbd/setup.py

index bb9e28b67116fa3c59521482d33e88ddaadc63cc..3391b4294b51c778f7a23e5f24551db8751248fa 100644 (file)
@@ -48,6 +48,11 @@ include(CheckIncludeFiles)
 include(CheckIncludeFileCXX)
 include(CheckFunctionExists)
 
+#put all the libs and binaries in one place
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+
 CHECK_FUNCTION_EXISTS(fallocate CEPH_HAVE_FALLOCATE)
 CHECK_FUNCTION_EXISTS(posix_fadvise HAVE_POSIX_FADVISE)
 CHECK_FUNCTION_EXISTS(posix_fallocate HAVE_POSIX_FALLOCATE)
index a032662776a731d23c1fa124bdbbdf4d09a3b0f1..168842baafc2fb807ddd533b350f2b2cf4b1b834 100644 (file)
@@ -524,6 +524,8 @@ install(TARGETS rados librados-config DESTINATION bin)
 install(DIRECTORY ${CMAKE_SOURCE_DIR}/src/pybind/
   DESTINATION ${PYTHON_INSTDIR})
 
+add_subdirectory(pybind)
+
 ## dencoder
 set(dencoder_srcs
   test/encoding/ceph_dencoder.cc
@@ -883,25 +885,25 @@ target_link_libraries(ceph-authtool global ${EXTRALIBS} ${CRYPTO_LIBS})
 install(TARGETS ceph-authtool DESTINATION bin)
 
 configure_file(${CMAKE_SOURCE_DIR}/src/ceph-coverage.in
-  ${CMAKE_BINARY_DIR}/ceph-coverage @ONLY)
+    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-coverage @ONLY)
 
 configure_file(${CMAKE_SOURCE_DIR}/src/ceph-debugpack.in
-  ${CMAKE_BINARY_DIR}/ceph-debugpack @ONLY)
+    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-debugpack @ONLY)
 
 configure_file(${CMAKE_SOURCE_DIR}/src/ceph.in
-  ${CMAKE_BINARY_DIR}/ceph @ONLY)
+    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph @ONLY)
 
 configure_file(${CMAKE_SOURCE_DIR}/src/ceph-crush-location.in
-  ${CMAKE_BINARY_DIR}/ceph-crush-location @ONLY)
+    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-crush-location @ONLY)
 
 configure_file(${CMAKE_SOURCE_DIR}/src/init-ceph.in
-  ${CMAKE_BINARY_DIR}/init-ceph @ONLY)
+    ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/init-ceph @ONLY)
 
 install(PROGRAMS
-  ${CMAKE_BINARY_DIR}/ceph
-  ${CMAKE_BINARY_DIR}/ceph-debugpack
-  ${CMAKE_BINARY_DIR}/ceph-coverage
-  ${CMAKE_BINARY_DIR}/init-ceph
+  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph
+  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-debugpack
+  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ceph-coverage
+  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/init-ceph
   ${CMAKE_SOURCE_DIR}/src/ceph-run
   ${CMAKE_SOURCE_DIR}/src/vstart.sh
   ${CMAKE_SOURCE_DIR}/src/ceph-clsinfo
@@ -1313,6 +1315,7 @@ add_custom_target(vstart DEPENDS
 add_custom_target(cephfs_testing DEPENDS
     vstart
     rados
+    cython_modules
     cephfs
     cls_cephfs
     ceph-fuse
index 79c226351253e556f436a24a80d474cad7608189..7fa4ebca0c6e4d0b4499675c0ca58f7337c00001 100755 (executable)
@@ -98,7 +98,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))
diff --git a/src/pybind/CMakeLists.txt b/src/pybind/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5fbbc7f
--- /dev/null
@@ -0,0 +1,8 @@
+set(CYTHON_MODULE_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules)
+
+add_subdirectory(rados)
+add_subdirectory(rbd)
+add_subdirectory(cephfs)
+
+add_custom_target(cython_modules ALL
+    DEPENDS cython_rados cython_cephfs cython_rbd)
diff --git a/src/pybind/cephfs/CMakeLists.txt b/src/pybind/cephfs/CMakeLists.txt
new file mode 100644 (file)
index 0000000..91d36ce
--- /dev/null
@@ -0,0 +1,9 @@
+add_custom_target(cython_cephfs
+  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_SOURCE_DIR}/src/pybind/cephfs
+  DEPENDS rados cephfs)
+
index cf29229dc3c334b4327cce451b7a69e72cedcd9f..73488eb8c54348a04081c7cb85baa03ea7d54d2e 100755 (executable)
@@ -42,7 +42,8 @@ setup(
     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")]
diff --git a/src/pybind/rados/CMakeLists.txt b/src/pybind/rados/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3b2cd38
--- /dev/null
@@ -0,0 +1,9 @@
+add_custom_target(cython_rados
+  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_SOURCE_DIR}/src/pybind/rados
+  DEPENDS rados)
+
index 6a7b9bd4ca91ed03af69749c6bb404702288cbd0..2b0f0b6077caeee1dc4745fd24376315f913225a 100755 (executable)
@@ -42,7 +42,8 @@ setup(
     ext_modules = cythonize([
         Extension("rados",
             ["rados.pyx"],
-            libraries=["rados"]
+            libraries=["rados"],
+            language="c++"
             )
     ], build_dir=os.environ.get("CYTHON_BUILD_DIR", None)),
     cmdclass={
diff --git a/src/pybind/rbd/CMakeLists.txt b/src/pybind/rbd/CMakeLists.txt
new file mode 100644 (file)
index 0000000..b588153
--- /dev/null
@@ -0,0 +1,9 @@
+add_custom_target(cython_rbd
+  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_SOURCE_DIR}/src/pybind/rbd
+  DEPENDS rbd)
+
index ec2f3a2ca19aabf28daa2273067810d33fd4cf3c..7ca00b4f59e85672cf57ce034ed91d3c0444ff00 100755 (executable)
@@ -42,7 +42,8 @@ setup(
     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")]