This is an automated email from the ASF dual-hosted git repository.

silver pushed a commit to branch cpp-more-operation
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/cpp-more-operation by this 
push:
     new ceadda49f add docs-only option to avoid install dependency in docs ci
ceadda49f is described below

commit ceadda49f2625e6afbc138c9bf86cf6ab8c601be
Author: silver-ymz <[email protected]>
AuthorDate: Fri Sep 1 23:04:31 2023 +0800

    add docs-only option to avoid install dependency in docs ci
    
    Signed-off-by: silver-ymz <[email protected]>
---
 .github/workflows/docs.yml  | 10 ++--------
 bindings/cpp/CMakeLists.txt | 42 ++++++++++++++++++++----------------------
 2 files changed, 22 insertions(+), 30 deletions(-)

diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 35765dcaa..e4e46d42a 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -232,20 +232,14 @@ jobs:
 
       - name: Install dependencies
         run: | 
-          sudo apt-get install doxygen graphviz ninja-build libgtest-dev
-          cd /usr/src/gtest
-          sudo cmake CMakeLists.txt
-          sudo make
-          sudo cp lib/*.a /usr/lib
-          sudo ln -s /usr/lib/libgtest.a /usr/local/lib/libgtest.a
-          sudo ln -s /usr/lib/libgtest_main.a /usr/local/lib/libgtest_main.a
+          sudo apt-get install doxygen graphviz ninja-build
 
       - name: Build Cpp docs
         working-directory: "bindings/cpp"
         run: |
           mkdir build
           cd build
-          cmake -GNinja ..
+          cmake -GNinja -DDOCS_ONLY=ON ..
           ninja docs
 
       - name: Upload docs
diff --git a/bindings/cpp/CMakeLists.txt b/bindings/cpp/CMakeLists.txt
index 9603de8eb..06e89f993 100644
--- a/bindings/cpp/CMakeLists.txt
+++ b/bindings/cpp/CMakeLists.txt
@@ -26,6 +26,25 @@ if (NOT CMAKE_BUILD_TYPE)
 endif()
 
 option(ENABLE_ADDRESS_SANITIZER "Enable address sanitizer" ON)
+option(DOCS_ONLY "Only build documentation" OFF)
+
+# Documentation
+set(PROJECT_DOCUMENT_SOURCE ${CMAKE_SOURCE_DIR}/include 
${CMAKE_SOURCE_DIR}/README.md)
+string(REPLACE ";" " " PROJECT_DOCUMENT_SOURCE "${PROJECT_DOCUMENT_SOURCE}")
+file(DOWNLOAD 
https://cdn.jsdelivr.net/gh/jothepro/[email protected]/doxygen-awesome.min.css
 ${CMAKE_BINARY_DIR}/doxygen-awesome.css)
+find_package(Doxygen REQUIRED)
+set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/Doxyfile)
+set(DOXYGEN_OUT ${CMAKE_BINARY_DIR}/Doxyfile.out)
+configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
+add_custom_target(docs
+    COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
+    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+    COMMENT "Generating API documentation with Doxygen"
+    VERBATIM)
+
+if (DOCS_ONLY)
+    return()
+endif()
 
 # cargo target dir must be absolute, otherwise some build target cannot find it
 get_filename_component(CARGO_TARGET_DIR ${CMAKE_SOURCE_DIR}/../../target 
ABSOLUTE)
@@ -92,25 +111,4 @@ if(APPLE)
 endif()
 
 include(GoogleTest)
-gtest_discover_tests(opendal_cpp_test)
-
-# Documentation
-set(PROJECT_DOCUMENT_SOURCE ${CMAKE_SOURCE_DIR}/include 
${CMAKE_SOURCE_DIR}/README.md)
-string(REPLACE ";" " " PROJECT_DOCUMENT_SOURCE "${PROJECT_DOCUMENT_SOURCE}")
-file(DOWNLOAD 
https://cdn.jsdelivr.net/gh/jothepro/[email protected]/doxygen-awesome.min.css
 ${CMAKE_BINARY_DIR}/doxygen-awesome.css)
-find_package(Doxygen)
-if (DOXYGEN_FOUND)
-    set(DOXYGEN_IN ${CMAKE_SOURCE_DIR}/Doxyfile)
-    set(DOXYGEN_OUT ${CMAKE_BINARY_DIR}/Doxyfile.out)
-
-    configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
-    message("Doxygen build started")
-
-    add_custom_target(docs
-        COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
-        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
-        COMMENT "Generating API documentation with Doxygen"
-        VERBATIM )
-else (DOXYGEN_FOUND)
-    message("Doxygen need to be installed to generate the doxygen 
documentation")
-endif (DOXYGEN_FOUND)
\ No newline at end of file
+gtest_discover_tests(opendal_cpp_test)
\ No newline at end of file

Reply via email to