Skip to content

Commit e2c8f19

Browse files
committed
build: use duktape package
This commit changes the Duktape setup to use the CMake find_package command to locate and configure the Duktape library. Direct access to source files through DUKTAPE_SOURCE_ROOT has been removed in order to respond to Duktape providing its own CMake integration scripts via vcpkg. Additionally, installation instructions for Duktape and references to DUKTAPE_SOURCE_ROOT have been removed from relevant files and examples. Instead, the Duktape dependency is now managed by vcpkg in CI. This simplifies the setup of the development environment.
1 parent 57238d7 commit e2c8f19

File tree

7 files changed

+25
-78
lines changed

7 files changed

+25
-78
lines changed

.github/workflows/ci.yml

+2-15
Original file line numberDiff line numberDiff line change
@@ -112,19 +112,6 @@ jobs:
112112
echo "llvm_root=$llvm_root"
113113
echo -E "llvm-root=$llvm_root" >> $GITHUB_OUTPUT
114114
115-
- name: Install Duktape
116-
id: duktape-install
117-
shell: bash
118-
run: |
119-
set -xe
120-
curl -L -o "duktape-2.7.0.tar.xz" "https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz"
121-
duktape_dir="${{runner.tool_cache}}/duktape"
122-
duktape_dir=$(echo "$duktape_dir" | sed 's/\\/\//g')
123-
mkdir -p "$duktape_dir"
124-
tar -xvf "duktape-2.7.0.tar.xz" -C "$duktape_dir"
125-
echo "duktape-dir=$duktape_dir/duktape-2.7.0" >> $GITHUB_OUTPUT
126-
echo "duktape_dir=$duktape_dir/duktape-2.7.0"
127-
128115
- name: Install Node.js
129116
uses: actions/setup-node@v3
130117
with:
@@ -143,7 +130,7 @@ jobs:
143130
id: package-install
144131
with:
145132
apt-get: ${{ matrix.install }} openjdk-11-jdk ninja-build ${{ matrix.compiler == 'clang' && 'libstdc++-12-dev' || '' }}
146-
vcpkg: fmt libxml2[tools]
133+
vcpkg: fmt duktape libxml2[tools]
147134
cc: ${{ steps.setup-cpp.outputs.cc || matrix.cc }}
148135
ccflags: ${{ matrix.ccflags }}
149136
cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }}
@@ -162,7 +149,7 @@ jobs:
162149
cxx: ${{ steps.setup-cpp.outputs.cxx || matrix.cxx }}
163150
cxxflags: ${{ matrix.cxxflags }}${{ ( matrix.compiler == 'gcc' && ' -static-libstdc++') || '' }}${{ ( matrix.asan && ' -static-libasan') || '' }}${{ ( matrix.tsan && ' -static-libtsan') || '' }}
164151
install-prefix: .local
165-
extra-args: ${{ format('-D LLVM_ROOT="{0}" -D Clang_ROOT="{0}" -D DUKTAPE_SOURCE_ROOT="{1}" -D CMAKE_EXPORT_COMPILE_COMMANDS=ON', steps.llvm-install.outputs.llvm-root || '/usr/local', steps.duktape-install.outputs.duktape-dir) }}
152+
extra-args: ${{ format('-D LLVM_ROOT="{0}" -D Clang_ROOT="{0}" -D CMAKE_EXPORT_COMPILE_COMMANDS=ON', steps.llvm-install.outputs.llvm-root || '/usr/local') }}
166153
export-compile-commands: ${{ matrix.time-trace }}
167154
package: ${{ matrix.is-main }}
168155
package-dir: packages

CMakeLists.txt

+8-36
Original file line numberDiff line numberDiff line change
@@ -100,35 +100,11 @@ string(REGEX REPLACE " /W[0-4]" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
100100
string(REGEX REPLACE " /W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
101101

102102
# Duktape
103-
set(DUKTAPE_SOURCE_ROOT "" CACHE STRING "Root of the Duktape source tree")
104-
if (NOT DUKTAPE_SOURCE_ROOT)
105-
message(FATAL_ERROR
106-
"Duktape source root not found.\n"
107-
"Please set DUKTAPE_SOURCE_ROOT to the root of the Duktape source tree.\n"
108-
"https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz\n")
109-
endif()
110-
if (NOT EXISTS "${DUKTAPE_SOURCE_ROOT}")
111-
message(FATAL_ERROR
112-
"DUKTAPE_SOURCE_ROOT (${DUKTAPE_SOURCE_ROOT}) does not exist.\n")
113-
endif()
114-
if (NOT EXISTS "${DUKTAPE_SOURCE_ROOT}/src/duktape.c")
115-
message(FATAL_ERROR
116-
"DUKTAPE_SOURCE_ROOT (${DUKTAPE_SOURCE_ROOT}) is invalid.\n"
117-
"No /src/duktape.c found.\n"
118-
"Please set DUKTAPE_SOURCE_ROOT to the root of the Duktape source tree.\n")
119-
endif()
120-
get_filename_component(DUKTAPE_SOURCE_ROOT "${DUKTAPE_SOURCE_ROOT}" ABSOLUTE)
121-
add_library(duktape ${DUKTAPE_SOURCE_ROOT}/src/duktape.c ${DUKTAPE_SOURCE_ROOT}/src/duktape.h)
122-
target_include_directories(
123-
duktape PUBLIC
124-
"$<BUILD_INTERFACE:${DUKTAPE_SOURCE_ROOT}/src>"
125-
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
126-
add_library(duktape::duktape ALIAS duktape)
127-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
128-
target_compile_options(duktape PRIVATE -w)
129-
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
130-
target_compile_options(duktape PRIVATE /w)
103+
set(DUKTAPE_PACKAGE_NAME duktape)
104+
if (WIN32)
105+
set(DUKTAPE_PACKAGE_NAME Duktape)
131106
endif()
107+
find_package(${DUKTAPE_PACKAGE_NAME} REQUIRED)
132108

133109
# fmt
134110
find_package(fmt REQUIRED CONFIG)
@@ -167,7 +143,9 @@ target_compile_definitions(
167143
# Deps
168144
target_include_directories(mrdocs-core SYSTEM PUBLIC ${LLVM_INCLUDE_DIRS})
169145
target_include_directories(mrdocs-core SYSTEM PUBLIC ${CLANG_INCLUDE_DIRS})
170-
target_link_libraries(mrdocs-core PUBLIC fmt::fmt duktape::duktape)
146+
target_link_libraries(mrdocs-core PUBLIC fmt::fmt)
147+
target_include_directories(mrdocs-core SYSTEM PRIVATE ${DUKTAPE_INCLUDE_DIRS})
148+
target_link_libraries(mrdocs-core PRIVATE ${DUKTAPE_LIBRARY})
171149

172150
# Clang
173151
if (CLANG_SIMPLE_LIBS)
@@ -408,7 +386,7 @@ if (MRDOCS_INSTALL)
408386
#-------------------------------------------------
409387
# lib
410388
#-------------------------------------------------
411-
install(TARGETS mrdocs-core duktape
389+
install(TARGETS mrdocs-core
412390
EXPORT mrdocs-targets
413391
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
414392
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -429,12 +407,6 @@ if (MRDOCS_INSTALL)
429407
FILES_MATCHING
430408
PATTERN "*.[hi]pp")
431409

432-
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/third-party/duktape/src/
433-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
434-
COMPONENT development
435-
FILES_MATCHING
436-
PATTERN "*.h")
437-
438410
#-------------------------------------------------
439411
# share
440412
#-------------------------------------------------

CMakePresets.json

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
1818
"LLVM_ROOT": "$env{LLVM_ROOT}",
1919
"Clang_ROOT": "$env{LLVM_ROOT}",
20-
"DUKTAPE_SOURCE_ROOT": "$env{DUKTAPE_SOURCE_ROOT}",
2120
"MRDOCS_BUILD_TESTS": "ON"
2221
},
2322
"vendor": {

CMakeUserPresets.json.example

-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"cacheVariables": {
1616
"LLVM_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\Debug",
1717
"Clang_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\llvm-project\\llvm\\install\\MSVC\\Debug",
18-
"DUKTAPE_SOURCE_ROOT": "C:\\Users\\$env{USERNAME}\\Libraries\\duktape-2.7.0",
1918
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
2019
},
2120
"condition": {
@@ -71,7 +70,6 @@
7170
"CMAKE_C_COMPILER": "/usr/bin/gcc-13",
7271
"LLVM_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release",
7372
"Clang_ROOT": "/home/$env{USER}/libraries/llvm-project/llvm/install/Linux/Release",
74-
"DUKTAPE_SOURCE_ROOT": "/home/$env{USER}/libraries/duktape-2.7.0",
7573
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
7674
},
7775
"vendor": {

docs/modules/ROOT/pages/install.adoc

+1-19
Original file line numberDiff line numberDiff line change
@@ -214,30 +214,12 @@ Return from `./third-party/llvm-project/build` to the parent `third-party` direc
214214
cd ../..
215215
----
216216

217-
[#duktape]
218-
=== Downloading Duktape
219-
220-
MrDocs contains functionality to allow users to define their own templates for the documentation.
221-
Duktape is a JavaScript engine that is used by MrDocs to parse and evaluate template helpers.
222-
223-
The release files can be obtained from the Duktape repository:
224-
225-
[source,bash]
226-
----
227-
curl -L -o "duktape-2.7.0.tar.xz" "https://github.com/svaarala/duktape/releases/download/v2.7.0/duktape-2.7.0.tar.xz"
228-
tar -xvf "duktape-2.7.0.tar.xz"
229-
----
230-
231-
Duktape provides no CMake integration scripts.
232-
For this reason, MrDocs needs direct access to the source files for Duktape.
233-
This means that's all you need to do for `duktape`.
234-
235217
=== CMake dependencies
236218

237219
All other dependencies provide CMake integration scripts and can be obtained from https://www.vcpkg.io/[vcpkg] or installed manually.
238220

239221
* `fmt` >= 10
240-
* `zlib`
222+
* `duktape`
241223

242224
For development builds, which include tests, you will also need:
243225

mrdocs-config.cmake.in

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_INSTALL_DATAROOTDIR}/mrdocs/cmake")
2121
# Find dependencies
2222
find_dependency(LLVM)
2323
find_dependency(Clang)
24+
find_dependency(@DUKTAPE_PACKAGE_NAME@)
2425
find_dependency(fmt)
2526

2627
# Create imported targets

vcpkg.json.example

+13-5
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
"name": "fmt",
77
"version>=": "10.0.0"
88
},
9-
{
10-
"name": "libxml2",
11-
"features": [
12-
"tools"
9+
"duktape"
10+
],
11+
"features": {
12+
"tests": {
13+
"description": "Build tests",
14+
"dependencies": [
15+
{
16+
"name": "libxml2",
17+
"features": [
18+
"tools"
19+
]
20+
}
1321
]
1422
}
15-
],
23+
},
1624
"builtin-baseline": "3715d743ac08146d9b7714085c1babdba9f262d5"
1725
}

0 commit comments

Comments
 (0)