Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
FROM ubuntu:24.10

RUN userdel -f -r ubuntu

RUN apt-get update && apt-get install -y \
bash-completion \
build-essential \
clang-format \
clangd \
cmake \
lldb \
ninja-build \
pipx \
python3-pip \
python3-venv \
valgrind \
wget

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 \
&& dpkg -i /tmp/watchexec-2.2.0-$(uname -m)-unknown-linux-gnu.deb \
&& rm -f /tmp/watchexec-2.2.0-$(uname -m)-unknown-linux-gnu.deb

RUN wget -nd -P /tmp/ https://github.com/bytecodealliance/wasmtime/releases/download/v25.0.2/wasmtime-v25.0.2-$(uname -m)-linux.tar.xz \
&& tar -C /usr/local/bin -xvf /tmp/wasmtime-v25.0.2-$(uname -m)-linux.tar.xz --strip-components=1 --wildcards 'wasmtime-*-linux/wasmtime' \
&& rm -f /tmp/wasmtime-v25.0.2-$(uname -m)-linux.tar.xz
37 changes: 23 additions & 14 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,40 @@

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

"hostRequirements": {
"cpus": 4
},

"remoteUser": "vscode",
"postCreateCommand": "./scripts/devcontainer-post-create.sh",

"postCreateCommand": "npm ci",
"containerUser": "vscode",

"features": {
"ghcr.io/devcontainers/features/common-utils": {},
"ghcr.io/devcontainers/features/github-cli": "latest",
"ghcr.io/devcontainers/features/node": "latest"
"ghcr.io/devcontainers/features/common-utils:2": {
"configureZshAsDefaultShell": false,
"installOhMyZsh": false,
"installOhMyZshConfig": false,
"installZsh": false,
"nonFreePackages": false,
"upgradePackages": true,
"userUid": "1000",
"userGid": "1000"
},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/node:1": {
"version": "latest"
},
"./features/emscripten": {},
"./features/wasi-sdk": {}
},

"customizations": {
"vscode": {
"extensions": [
"llvm-vs-code-extensions.vscode-clangd",
"llvm-vs-code-extensions.lldb-dap"
"llvm-vs-code-extensions.lldb-dap",
"twxs.cmake",
"ms-vscode.cmake-tools",
"esbenp.prettier-vscode"
],
"settings": {
"clangd.arguments": [
"--compile-commands-dir=build",
"--completion-style=bundled"
]
"clangd.arguments": ["--completion-style=bundled"]
}
}
}
Expand Down
26 changes: 0 additions & 26 deletions .devcontainer/emscripten_dev/Dockerfile

This file was deleted.

45 changes: 0 additions & 45 deletions .devcontainer/emscripten_dev/devcontainer.json

This file was deleted.

11 changes: 11 additions & 0 deletions .devcontainer/features/emscripten/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "emscripten",
"version": "1.0.0",
"name": "Emscripten",
"dependsOn": {
"ghcr.io/devcontainers/features/common-utils": {}
},
"containerEnv": {
"EMSCRIPTEN_ROOT": "/opt/emsdk/upstream/emscripten"
}
}
8 changes: 8 additions & 0 deletions .devcontainer/features/emscripten/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -e

git clone --depth 1 http://github.com/emscripten-core/emsdk.git /opt/emsdk
cd /opt/emsdk
./emsdk install latest
./emsdk activate latest
11 changes: 11 additions & 0 deletions .devcontainer/features/wasi-sdk/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "wasi-sdk",
"version": "1.0.0",
"name": "Wasi SDK",
"dependsOn": {
"ghcr.io/devcontainers/features/common-utils": {}
},
"containerEnv": {
"WASI_SDK_ROOT": "/opt/wasi-sdk"
}
}
13 changes: 13 additions & 0 deletions .devcontainer/features/wasi-sdk/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -e

arch=$(uname -m)

if [ "$arch" == "aarch64" ]; then
arch="arm64"
fi

wget -nd -P /tmp/ https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-${arch}-linux.deb

dpkg -i /tmp/wasi-sdk-24.0-${arch}-linux.deb
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ jobs:
runs-on: ubuntu-24.04

env:
WASMTIME_VERSION: 20.0.2
WASMTIME_VERSION: 25.0.2

steps:
- uses: actions/checkout@v4
Expand All @@ -181,12 +181,12 @@ jobs:

- name: Install wasmtime
run: |
wget https://github.com/bytecodealliance/wasmtime/releases/download/v${{ env.WASMTIME_VERSION }}/wasmtime-v${{ env.WASMTIME_VERSION }}-x86_64-linux.tar.xz
tar Jxvf wasmtime-v${{ env.WASMTIME_VERSION }}-x86_64-linux.tar.xz -C ~/
wget -nd -P /tmp/ https://github.com/bytecodealliance/wasmtime/releases/download/v${{ env.WASMTIME_VERSION }}/wasmtime-v${{ env.WASMTIME_VERSION }}-$(uname -m)-linux.tar.xz
tar -C /usr/local/bin -xvf /tmp/wasmtime-v${{ env.WASMTIME_VERSION }}-$(uname -m)-linux.tar.xz --strip-components=1 --wildcards 'wasmtime-*-linux/wasmtime'

- name: Test
run: |
~/wasmtime-v${{ env.WASMTIME_VERSION }}-x86_64-linux/wasmtime \
wasmtime \
--dir ${{github.workspace}}/build.wasi/install::/ \
--dir tests::tests \
${{github.workspace}}/build.wasi/install/usr/bin/cxx.wasm -v tests/manual/source.cc
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ node_modules
*.tgz
.vscode/launch.json
.cache
.clangd
*.pch
44 changes: 36 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ endif()
include(FetchContent)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(ExternalProject)

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

Expand All @@ -54,17 +55,13 @@ endif()

FetchContent_Declare(
utfcpp
GIT_REPOSITORY https://github.com/nemtrif/utfcpp
GIT_TAG v4.0.5
GIT_SHALLOW 1
URL https://github.com/nemtrif/utfcpp/archive/refs/tags/v4.0.5.tar.gz
PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/patches/utfcpp.patch
)

FetchContent_Populate(utfcpp)
FetchContent_MakeAvailable(utfcpp)
FetchContent_GetProperties(utfcpp)

add_library(utf8cpp::utf8cpp INTERFACE IMPORTED)
set_target_properties(utf8cpp::utf8cpp PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${utfcpp_SOURCE_DIR}/source")

FetchContent_Declare(
wasi_sysroot
URL https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sysroot-22.0.tar.gz
Expand Down Expand Up @@ -96,7 +93,26 @@ if (CXX_ENABLE_FLATBUFFERS)
set_target_properties(flatbuffers::header-only PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${flatbuffers_SOURCE_DIR}/include")
endif()

add_subdirectory(tools/kwgen)
if (NOT KWGEN_EXECUTABLE AND CMAKE_SYSTEM_NAME STREQUAL "WASI")

ExternalProject_Add(
kwgen_host
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/kwgen
INSTALL_COMMAND ""
)

ExternalProject_Get_property(kwgen_host BINARY_DIR)

add_executable(kwgen IMPORTED)
set_target_properties(kwgen PROPERTIES IMPORTED_LOCATION "${BINARY_DIR}/kwgen")
add_dependencies(kwgen kwgen_host)

else()

add_subdirectory(tools/kwgen)

endif()

add_subdirectory(src)

if (CXX_BUILD_TESTS)
Expand Down Expand Up @@ -128,3 +144,15 @@ install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/cxxConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/cxx
)

set(CLANGD_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/clangd.in")

if (EMSCRIPTEN)
set(CLANGD_CONFIG_FILE "${CMAKE_CURRENT_SOURCE_DIR}/clangd_emscripten.in")
endif()

configure_file(
${CLANGD_CONFIG_FILE}
${CMAKE_CURRENT_SOURCE_DIR}/.clangd
@ONLY
)
Loading