Skip to content

Commit f7dfe3b

Browse files
authored
Update devcontainer configuration
Set up dev container with ubuntu 24.10, emsdk, wasi-sdk and clangd Update emsdk and wasi-sdk to latest versions and add cmake presets to configure for emscripten and wasi. Inside the devcontainer the following workflows should produce correct builds for emscripten and wasi ```bash cmake --workflow --preset emscripten cmake --workflow --preset wasi ````
1 parent 7020551 commit f7dfe3b

File tree

20 files changed

+349
-99
lines changed

20 files changed

+349
-99
lines changed

.devcontainer/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
FROM ubuntu:24.10
22

3+
RUN userdel -f -r ubuntu
4+
35
RUN apt-get update && apt-get install -y \
46
bash-completion \
57
build-essential \
68
clang-format \
79
clangd \
810
cmake \
11+
lldb \
912
ninja-build \
13+
pipx \
1014
python3-pip \
1115
python3-venv \
16+
valgrind \
1217
wget
1318

1419
RUN wget -nd -P /tmp/ https://github.com/watchexec/watchexec/releases/download/v2.2.0/watchexec-2.2.0-$(uname -m)-unknown-linux-gnu.deb \
1520
&& dpkg -i /tmp/watchexec-2.2.0-$(uname -m)-unknown-linux-gnu.deb \
1621
&& rm -f /tmp/watchexec-2.2.0-$(uname -m)-unknown-linux-gnu.deb
22+
23+
RUN wget -nd -P /tmp/ https://github.com/bytecodealliance/wasmtime/releases/download/v25.0.2/wasmtime-v25.0.2-$(uname -m)-linux.tar.xz \
24+
&& tar -C /usr/local/bin -xvf /tmp/wasmtime-v25.0.2-$(uname -m)-linux.tar.xz --strip-components=1 --wildcards 'wasmtime-*-linux/wasmtime' \
25+
&& rm -f /tmp/wasmtime-v25.0.2-$(uname -m)-linux.tar.xz

.devcontainer/devcontainer.json

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,40 @@
77

88
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
99

10-
"hostRequirements": {
11-
"cpus": 4
12-
},
13-
14-
"remoteUser": "vscode",
10+
"postCreateCommand": "./scripts/devcontainer-post-create.sh",
1511

16-
"postCreateCommand": "npm ci",
12+
"containerUser": "vscode",
1713

1814
"features": {
19-
"ghcr.io/devcontainers/features/common-utils": {},
20-
"ghcr.io/devcontainers/features/github-cli": "latest",
21-
"ghcr.io/devcontainers/features/node": "latest"
15+
"ghcr.io/devcontainers/features/common-utils:2": {
16+
"configureZshAsDefaultShell": false,
17+
"installOhMyZsh": false,
18+
"installOhMyZshConfig": false,
19+
"installZsh": false,
20+
"nonFreePackages": false,
21+
"upgradePackages": true,
22+
"userUid": "1000",
23+
"userGid": "1000"
24+
},
25+
"ghcr.io/devcontainers/features/github-cli:1": {},
26+
"ghcr.io/devcontainers/features/node:1": {
27+
"version": "latest"
28+
},
29+
"./features/emscripten": {},
30+
"./features/wasi-sdk": {}
2231
},
2332

2433
"customizations": {
2534
"vscode": {
2635
"extensions": [
2736
"llvm-vs-code-extensions.vscode-clangd",
28-
"llvm-vs-code-extensions.lldb-dap"
37+
"llvm-vs-code-extensions.lldb-dap",
38+
"twxs.cmake",
39+
"ms-vscode.cmake-tools",
40+
"esbenp.prettier-vscode"
2941
],
3042
"settings": {
31-
"clangd.arguments": [
32-
"--compile-commands-dir=build",
33-
"--completion-style=bundled"
34-
]
43+
"clangd.arguments": ["--completion-style=bundled"]
3544
}
3645
}
3746
}

.devcontainer/emscripten_dev/Dockerfile

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

.devcontainer/emscripten_dev/devcontainer.json

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"id": "emscripten",
3+
"version": "1.0.0",
4+
"name": "Emscripten",
5+
"dependsOn": {
6+
"ghcr.io/devcontainers/features/common-utils": {}
7+
},
8+
"containerEnv": {
9+
"EMSCRIPTEN_ROOT": "/opt/emsdk/upstream/emscripten"
10+
}
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
git clone --depth 1 http://github.com/emscripten-core/emsdk.git /opt/emsdk
6+
cd /opt/emsdk
7+
./emsdk install latest
8+
./emsdk activate latest
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"id": "wasi-sdk",
3+
"version": "1.0.0",
4+
"name": "Wasi SDK",
5+
"dependsOn": {
6+
"ghcr.io/devcontainers/features/common-utils": {}
7+
},
8+
"containerEnv": {
9+
"WASI_SDK_ROOT": "/opt/wasi-sdk"
10+
}
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
arch=$(uname -m)
6+
7+
if [ "$arch" == "aarch64" ]; then
8+
arch="arm64"
9+
fi
10+
11+
wget -nd -P /tmp/ https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-${arch}-linux.deb
12+
13+
dpkg -i /tmp/wasi-sdk-24.0-${arch}-linux.deb

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ node_modules
66
*.tgz
77
.vscode/launch.json
88
.cache
9+
.clangd
10+
*.pch

CMakeLists.txt

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ endif()
3232
include(FetchContent)
3333
include(GNUInstallDirs)
3434
include(CMakePackageConfigHelpers)
35+
include(ExternalProject)
3536

3637
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/package.json" package_json)
3738

@@ -59,12 +60,9 @@ FetchContent_Declare(
5960
GIT_SHALLOW 1
6061
)
6162

62-
FetchContent_Populate(utfcpp)
63+
FetchContent_MakeAvailable(utfcpp)
6364
FetchContent_GetProperties(utfcpp)
6465

65-
add_library(utf8cpp::utf8cpp INTERFACE IMPORTED)
66-
set_target_properties(utf8cpp::utf8cpp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${utfcpp_SOURCE_DIR}/source")
67-
6866
FetchContent_Declare(
6967
wasi_sysroot
7068
URL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sysroot-22.0.tar.gz
@@ -96,7 +94,26 @@ if (CXX_ENABLE_FLATBUFFERS)
9694
set_target_properties(flatbuffers::header-only PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${flatbuffers_SOURCE_DIR}/include")
9795
endif()
9896

99-
add_subdirectory(tools/kwgen)
97+
if (NOT KWGEN_EXECUTABLE AND CMAKE_SYSTEM_NAME STREQUAL "WASI")
98+
99+
ExternalProject_Add(
100+
kwgen_host
101+
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/kwgen
102+
INSTALL_COMMAND ""
103+
)
104+
105+
ExternalProject_Get_property(kwgen_host BINARY_DIR)
106+
107+
add_executable(kwgen IMPORTED)
108+
set_target_properties(kwgen PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/kwgen")
109+
add_dependencies(kwgen kwgen_host)
110+
111+
else()
112+
113+
add_subdirectory(tools/kwgen)
114+
115+
endif()
116+
100117
add_subdirectory(src)
101118

102119
if (CXX_BUILD_TESTS)
@@ -128,3 +145,15 @@ install(FILES
128145
"${CMAKE_CURRENT_BINARY_DIR}/cxxConfigVersion.cmake"
129146
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cxx
130147
)
148+
149+
set(CLANGD_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/clangd.in")
150+
151+
if (EMSCRIPTEN)
152+
set(CLANGD_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/clangd_emscripten.in")
153+
endif()
154+
155+
configure_file(
156+
${CLANGD_CONFIG_FILE}
157+
${CMAKE_CURRENT_SOURCE_DIR}/.clangd
158+
@ONLY
159+
)

0 commit comments

Comments
 (0)