Skip to content

Commit b2eacee

Browse files
committed
Migrate to cmake script
1 parent 2275318 commit b2eacee

File tree

3 files changed

+31
-30
lines changed

3 files changed

+31
-30
lines changed

.github/workflows/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: build book
2525
run: |
2626
cd guide
27-
mdbook build
27+
cmake -P build-books.cmake
2828
ls book
2929
- name: setup pages
3030
uses: actions/configure-pages@v4

guide/CMakeLists.txt

Lines changed: 0 additions & 29 deletions
This file was deleted.

guide/build-books.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Function to configure the book file and add a custom target to build it.
2+
function(BuildBook LANGUAGE AUTHORS)
3+
# Set the variables for substitution.
4+
set(AUTHORS "${AUTHORS}")
5+
set(LANGUAGE "${LANGUAGE}")
6+
set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
7+
set(TARGET_DIR "${ROOT_DIR}/src/${LANGUAGE}")
8+
9+
# Create a custom target that calls mdbook with the generated config.
10+
if(EXISTS "${TARGET_DIR}/SUMMARY.md")
11+
# Configure the template file with the substitutions.
12+
configure_file(
13+
${ROOT_DIR}/book-template.config
14+
${TARGET_DIR}/book.toml
15+
@ONLY
16+
)
17+
18+
message(STATUS "Building book for language: ${LANGUAGE}")
19+
execute_process(
20+
COMMAND mdbook build -d ${ROOT_DIR}/book/${LANGUAGE}
21+
WORKING_DIRECTORY ${TARGET_DIR}
22+
)
23+
else()
24+
message(WARNING "Skipping '${LANGUAGE}' – SUMMARY.md not found at ${SUMMARY_FILE}")
25+
endif()
26+
endfunction()
27+
28+
# Create configurations for both languages.
29+
BuildBook("en" "Karn Kaul")
30+
BuildBook("zh-TW" "Mes")

0 commit comments

Comments
 (0)