Skip to content

Commit

Permalink
allow disabling Python bindings
Browse files Browse the repository at this point in the history
Summary:
Add an `PYTHON_EXTENSIONS` option (defaulting to `ON` to preserve current behavior)
that can be toggled off. When off, the Thrift bindings will be generated for C++ only.

Fixes #3.
Fixes #4.

Tested with the fb303 package being submitted for Fedora:
https://bugzilla.redhat.com/show_bug.cgi?id=1900147

Reviewed By: yfeldblum

Differential Revision: D25138287

fbshipit-source-id: 0be272fd35d47bff55c4ee010afc4aaea66ce66b
  • Loading branch information
michel-slm authored and facebook-github-bot committed Nov 22, 2020
1 parent b0ade42 commit de82ce8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Expand Up @@ -21,6 +21,11 @@ if (NOT DEFINED CPACK_GENERATOR)
endif()
include(CPack)

option(PYTHON_EXTENSIONS
"Build Python bindings for fb303"
ON
)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down
20 changes: 14 additions & 6 deletions fb303/thrift/CMakeLists.txt
Expand Up @@ -12,10 +12,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

if (PYTHON_EXTENSIONS)
set(FB303_LANG cpp py)
else ()
set(FB303_LANG cpp)
endif ()

add_fbthrift_library(
fb303_thrift
fb303_core.thrift
LANGUAGES cpp py
LANGUAGES ${FB303_LANG}
THRIFT_INCLUDE_DIR "${INCLUDE_INSTALL_DIR}/thrift-files"
SERVICES
BaseService
Expand All @@ -38,8 +44,10 @@ install(
DESTINATION "$<TARGET_PROPERTY:fb303_thrift_cpp,THRIFT_INSTALL_DIR>"
)

install_fb_python_library(fb303_thrift_py EXPORT fb303-exports)
install(
TARGETS fb303_thrift_py.thrift_includes
EXPORT fb303-exports
)
if (PYTHON_EXTENSIONS)
install_fb_python_library(fb303_thrift_py EXPORT fb303-exports)
install(
TARGETS fb303_thrift_py.thrift_includes
EXPORT fb303-exports
)
endif ()

0 comments on commit de82ce8

Please sign in to comment.