[Lldb-commits] [lldb] r359465 - [Docs] Generate the python reference without building all of LLDB

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Mon Apr 29 09:29:10 PDT 2019


Author: jdevlieghere
Date: Mon Apr 29 09:29:10 2019
New Revision: 359465

URL: http://llvm.org/viewvc/llvm-project?rev=359465&view=rev
Log:
[Docs] Generate the python reference without building all of LLDB

As discussed on the mailing list, we should be able to generate the
Python reference without building all of LLDB. To make that possible I
create a dummy python package, which is then parsed by epydoc. The
latter will complain that it couldn't import lldb, but that doesn't
matter as far as generation of the docs is concerned.

Differential revision: https://reviews.llvm.org/D61216

Modified:
    lldb/trunk/CMakeLists.txt
    lldb/trunk/docs/CMakeLists.txt

Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=359465&r1=359464&r2=359465&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Mon Apr 29 09:29:10 2019
@@ -30,12 +30,12 @@ if (WIN32)
   add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
 endif()
 
-add_subdirectory(docs)
 if (NOT LLDB_DISABLE_PYTHON)
   add_subdirectory(scripts)
 endif ()
 add_subdirectory(source)
 add_subdirectory(tools)
+add_subdirectory(docs)
 
 option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
 option(LLDB_TEST_USE_CUSTOM_C_COMPILER "Use the C compiler provided via LLDB_TEST_C_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF)

Modified: lldb/trunk/docs/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/docs/CMakeLists.txt?rev=359465&r1=359464&r2=359465&view=diff
==============================================================================
--- lldb/trunk/docs/CMakeLists.txt (original)
+++ lldb/trunk/docs/CMakeLists.txt Mon Apr 29 09:29:10 2019
@@ -13,31 +13,46 @@ if(DOXYGEN_FOUND)
     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
     COMMENT "Generating LLDB C++ API reference with Doxygen" VERBATIM
   )
-endif(DOXYGEN_FOUND)
+endif()
 
-find_package(PythonInterp REQUIRED)
 find_program(EPYDOC_EXECUTABLE NAMES epydoc epydoc.py)
 if(EPYDOC_EXECUTABLE)
+  message(STATUS "Found epydoc - ${EPYDOC_EXECUTABLE}")
+
   find_program(DOT_EXECUTABLE dot)
-    if(DOT_EXECUTABLE)
-      set(EPYDOC_OPTIONS ${EPYDOC_OPTIONS} --graph all --dotpath ${DOT_EXECUTABLE})
-    endif()
-    set(DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc")
-    file(MAKE_DIRECTORY "${DOC_DIR}")
-    #set(ENV{PYTHONPATH} ${CMAKE_CURRENT_BINARY_DIR}/../../../lib/python2.7/site-packages)
-    add_custom_target(lldb-python-doc
-      ${EPYDOC_EXECUTABLE}
-      --html
-      lldb
-      -o ${CMAKE_CURRENT_BINARY_DIR}/python_reference
-      --name "LLDB python API"
-      --url "http://lldb.llvm.org"
-      ${EPYDOC_OPTIONS}
-      DEPENDS swig_wrapper liblldb
-      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../../../lib${LLVM_LIBDIR_SUFFIX}/python2.7/site-packages
-      COMMENT "Generating LLDB Python API reference with epydoc" VERBATIM
-    )
-endif(EPYDOC_EXECUTABLE)
+  if(DOT_EXECUTABLE)
+    set(EPYDOC_OPTIONS ${EPYDOC_OPTIONS} --graph all --dotpath ${DOT_EXECUTABLE})
+    message(STATUS "Found dot - ${DOT_EXECUTABLE}")
+  endif()
+
+  # Pretend to make a python package so that we can generate the reference.
+  # Because we don't build liblldb, epydoc will complain that the import of
+  # _lldb.so failed, but that doesn't prevent it from generating the docs.
+  file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lldb)
+  get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
+  add_custom_target(lldb-python-doc-package
+    COMMAND "${CMAKE_COMMAND}" -E copy "${lldb_scripts_dir}/lldb.py" "${CMAKE_CURRENT_BINARY_DIR}/lldb/__init__.py"
+    DEPENDS swig_wrapper
+    COMMENT "Copying lldb.py to pretend package.")
+
+  set(DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc")
+  file(MAKE_DIRECTORY "${DOC_DIR}")
+  add_custom_target(lldb-python-doc
+    ${EPYDOC_EXECUTABLE}
+    --html
+    lldb
+    -o ${CMAKE_CURRENT_BINARY_DIR}/python_reference
+    --name "LLDB python API"
+    --url "http://lldb.llvm.org"
+    ${EPYDOC_OPTIONS}
+    DEPENDS swig_wrapper
+    DEPENDS lldb-python-doc-package
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+    COMMENT "Generating LLDB Python API reference with epydoc" VERBATIM
+  )
+else()
+  message(STATUS "Could NOT find epydoc")
+endif()
 
 if (LLVM_ENABLE_SPHINX)
   include(AddSphinxTarget)




More information about the lldb-commits mailing list