• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) PLUMgrid, Inc.
2# Licensed under the Apache License, Version 2.0 (the "License")
3
4set(PYTHON_SRC __init__.py perf.py tcp.py utils.py libbcc.py table.py usdt.py)
5
6foreach (PY_SRC ${PYTHON_SRC})
7  configure_file(bcc/${PY_SRC} ${CMAKE_CURRENT_BINARY_DIR}/bcc/${PY_SRC} COPYONLY)
8endforeach()
9
10if(NOT PYTHON_CMD)
11  set(PYTHON_CMD "python")
12endif()
13
14configure_file(setup.py.in ${CMAKE_CURRENT_BINARY_DIR}/setup.py @ONLY)
15configure_file(bcc/version.py.in ${CMAKE_CURRENT_BINARY_DIR}/bcc/version.py @ONLY)
16if(EXISTS "/etc/debian_version")
17  set(PYTHON_FLAGS "${PYTHON_FLAGS} --install-layout deb")
18endif()
19
20foreach(PY_CMD ${PYTHON_CMD})
21  string(REPLACE "/" "-" PY_CMD_ESCAPED ${PY_CMD})
22
23  set(PY_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/bcc/__init__.py ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
24  if (PREVIOUS_PY)
25    set(PY_DEPENDS ${PY_DEPENDS} ${PREVIOUS_PY})
26  endif()
27
28  set(PIP_INSTALLABLE "${CMAKE_CURRENT_BINARY_DIR}/dist-${PY_CMD_ESCAPED}/bcc-${REVISION}.tar.gz")
29  # build the pip installable
30  add_custom_command(OUTPUT ${PIP_INSTALLABLE}
31    COMMAND ${PY_CMD} setup.py sdist --dist-dir dist-${PY_CMD_ESCAPED}
32    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
33    DEPENDS ${PY_DEPENDS}
34    )
35  add_custom_target(bcc_py_${PY_CMD_ESCAPED} ALL DEPENDS ${PIP_INSTALLABLE})
36
37  install(CODE "execute_process(COMMAND ${PY_CMD} setup.py install -f ${PYTHON_FLAGS}
38    --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})"
39    COMPONENT python)
40
41  set(PREVIOUS_PY ${PIP_INSTALLABLE})
42endforeach()
43