mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
cmake: make sphinx use a python-staging folder instead of site-packages
This means that you no longer need to install UPM in oder to be able to use `make pydoc`. The target pydoc now depends on target doc which with SWIG will cause python modules to be built, making parralel builds work as expected. We wipe the python-staging directory on each make pydoc as it's a custom_target and will rerun at every time anyways, copy is cheap and in case a module gets deleted it avoids the doc still getting built Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
parent
54c2c8db76
commit
f537a5cd4c
@ -79,7 +79,7 @@ if (BUILDDOC)
|
||||
string (REPLACE "." ";" PYTHON_VERSION_LIST ${PYTHONLIBS_VERSION_STRING})
|
||||
list (GET PYTHON_VERSION_LIST 0 PYTHON_VERSION_MAJOR)
|
||||
list (GET PYTHON_VERSION_LIST 1 PYTHON_VERSION_MINOR)
|
||||
set (SITE_PACKAGES ${CMAKE_INSTALL_LIBDIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
|
||||
set (SITE_PACKAGES ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages)
|
||||
|
||||
# throw a warning if site-packages doesn't exist, might need a more robust way on adding make install dependency and paths
|
||||
if (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/${SITE_PACKAGES})
|
||||
@ -89,14 +89,15 @@ if (BUILDDOC)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/conf.py.in ${CMAKE_CURRENT_BINARY_DIR}/pydoc/conf.py @ONLY)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/doxy/index.rst ${CMAKE_CURRENT_BINARY_DIR}/pydoc/index.rst COPYONLY)
|
||||
add_custom_target (pydoc
|
||||
${SPHINX_API_EXECUTABLE} -f -o pydoc ${SITE_PACKAGES}
|
||||
COMMAND rm -r ${CMAKE_BINARY_DIR}/python-staging && mkdir -p ${CMAKE_BINARY_DIR}/python-staging
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -name "_pyupm_*.so" -exec cp {} ${CMAKE_BINARY_DIR}/python-staging \;
|
||||
COMMAND find ${CMAKE_BINARY_DIR}/src -name "pyupm_*.py" -exec cp {} ${CMAKE_BINARY_DIR}/python-staging \;
|
||||
COMMAND ${SPHINX_API_EXECUTABLE} -f -o pydoc ${CMAKE_BINARY_DIR}/python-staging
|
||||
# todo: use a separate cmake FILE module for string replacement instead
|
||||
COMMAND sed -i.bak s|site-packages|sensor-drivers|g pydoc/modules.rst
|
||||
COMMAND ${SPHINX_EXECUTABLE} -b html pydoc html/python
|
||||
COMMAND sed -i.bak s|\">pyupm_|\">|g html/python/index.html html/python/modules.html
|
||||
COMMAND sed -i.bak s|[[:space:]]module</a>|</a>|g html/python/index.html html/python/modules.html
|
||||
# cleanup .pyc files
|
||||
COMMAND find ${SITE_PACKAGES} -name *.pyc -exec rm {} \;
|
||||
DEPENDS doc
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating API documentation with Sphinx" VERBATIM
|
||||
)
|
||||
|
@ -20,8 +20,7 @@ import shlex
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
sys.path.insert(0, "@CMAKE_INSTALL_LIBDIR@/python@PYTHON_VERSION_MAJOR@.@PYTHON_VERSION_MINOR@/site-packages/")
|
||||
sys.path.insert(0, "@CMAKE_INSTALL_LIBDIR@")
|
||||
sys.path.insert(0, "@CMAKE_CURRENT_BINARY_DIR@/python-staging/")
|
||||
sys.path.insert(0, "@MRAA_LIBDIR@@LIB_SUFFIX@")
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user