generated from TheLartians/ModernCppStarter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86262cd
commit 9a96204
Showing
22 changed files
with
116 additions
and
1,025 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# See: https://github.com/devcontainers/images/blob/main/src/cpp/.devcontainer/Dockerfile | ||
ARG VARIANT=ubuntu-22.04 | ||
FROM mcr.microsoft.com/devcontainers/base:${VARIANT} | ||
USER root | ||
|
||
# Install needed packages. Use a separate RUN statement to add your own dependencies. | ||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get -y install cmake curl git tar xz-utils ninja-build \ | ||
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* | ||
|
||
ARG USERNAME=vscode | ||
|
||
# Install wasi-sdk https://github.com/WebAssembly/wasi-sdk | ||
ARG WASI_VERSION="21" | ||
ENV WASI_VERSION_FULL="${WASI_VERSION}.0" | ||
ENV WASI_LOCATION="${LOCATION:-"/usr/local"}/lib" | ||
ENV WASI_FILE="wasi-sdk-${WASI_VERSION_FULL}-linux.tar.gz" | ||
ENV WASI_SDK_PREFIX="/usr/local/lib/wasi-sdk-${WASI_VERSION_FULL}" | ||
RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_VERSION}/${WASI_FILE} --output ${WASI_FILE} | ||
RUN tar -C ${WASI_LOCATION} -xvf ${WASI_FILE} | ||
RUN rm ${WASI_FILE} | ||
|
||
# Install wit-bindgen https://github.com/bytecodealliance/wit-bindgen | ||
ARG WIT_BINDGEN_VERSION="0.22.0" | ||
RUN curl -L https://github.com/bytecodealliance/wit-bindgen/releases/download/v${WIT_BINDGEN_VERSION}/wit-bindgen-${WIT_BINDGEN_VERSION}-x86_64-linux.tar.gz --output wit-bindgen-${WIT_BINDGEN_VERSION}-x86_64-linux.tar.gz | ||
RUN tar -xvzf wit-bindgen-${WIT_BINDGEN_VERSION}-x86_64-linux.tar.gz | ||
RUN cp wit-bindgen-${WIT_BINDGEN_VERSION}-x86_64-linux/wit-bindgen ${LOCATION}/bin/wit-bindgen | ||
RUN rm -r wit-bindgen-${WIT_BINDGEN_VERSION}-x86_64-linux* | ||
|
||
# Install wasm-tools https://github.com/bytecodealliance/wasm-tools | ||
ARG WASM_TOOLS_VERSION="1.201.0" | ||
RUN curl -L https://github.com/bytecodealliance/wasm-tools/releases/download/v${WASM_TOOLS_VERSION}/wasm-tools-${WASM_TOOLS_VERSION}-x86_64-linux.tar.gz --output wasm-tools-${WASM_TOOLS_VERSION}-x86_64-linux.tar.gz | ||
RUN tar -xvzf wasm-tools-${WASM_TOOLS_VERSION}-x86_64-linux.tar.gz | ||
RUN cp wasm-tools-${WASM_TOOLS_VERSION}-x86_64-linux/wasm-tools ${LOCATION}/bin/wasm-tools | ||
RUN rm -r wasm-tools-${WASM_TOOLS_VERSION}-x86_64-linux* | ||
|
||
# Install wasi adapter https://github.com/bytecodealliance/wasmtime | ||
ARG WASMTIME_VERSION="19.0.0" | ||
RUN curl -L -O https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasi_snapshot_preview1.reactor.wasm | ||
RUN mv wasi_snapshot_preview1.reactor.wasm ${LOCATION}/lib/wasi_snapshot_preview1.reactor.wasm | ||
|
||
# # Install wasmtime | ||
# ENV WASMTIME_VERSION="${WASMTIME_VERSION:-"v9.0.4"}" | ||
# ENV INSTALLER=./wasmtime-install.sh | ||
# RUN curl https://wasmtime.dev/install.sh -L --output ${INSTALLER} | ||
# RUN chmod a+x ${INSTALLER} | ||
# RUN ${INSTALLER} --version ${WASMTIME_VERSION} | ||
# RUN cp ${HOME}/.wasmtime/bin/wasmtime /usr/bin/wasmtime | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "C/C++ WASM", | ||
"build": { | ||
"dockerfile": "./Dockerfile", | ||
"context": "." | ||
}, | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"installZsh": "true", | ||
"username": "vscode", | ||
"userUid": "1000", | ||
"userGid": "1000", | ||
"upgradePackages": "true" | ||
} | ||
}, | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"ms-vscode.cpptools-extension-pack", | ||
"dtsvet.vscode-wasm" | ||
] | ||
} | ||
}, | ||
"remoteUser": "vscode", | ||
"remoteEnv": { | ||
"PATH": "${containerEnv:PATH}:${WASI_SDK_PREFIX}/bin" | ||
}, | ||
"postCreateCommand": "echo 'Done'" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]:-$0}"; )" &> /dev/null && pwd 2> /dev/null; )" | ||
ROOT_DIR="$(pwd)" | ||
|
||
echo "SCRIPT_DIR: ${SCRIPT_DIR}" | ||
echo "ROOT_DIR: $ROOT_DIR" | ||
|
||
function cleanup() | ||
{ | ||
CONTAINER_ID=$(jq -r .containerId ${SCRIPT_DIR}/up.json) | ||
docker rm -f "${CONTAINER_ID}" | ||
rm ${SCRIPT_DIR}/up.json | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
npx -y @devcontainers/cli up --workspace-folder ${SCRIPT_DIR} | jq . > "${SCRIPT_DIR}/up.json" | ||
|
||
CMAKE_OPTIONS="-G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=\${WASI_SDK_PREFIX}/share/cmake/wasi-sdk.cmake -DWASI_SDK_PREFIX=\${WASI_SDK_PREFIX}" | ||
|
||
npx -y @devcontainers/cli exec --workspace-folder ${SCRIPT_DIR} mkdir -p ./build | ||
npx -y @devcontainers/cli exec --workspace-folder ${SCRIPT_DIR} sh -c 'cmake -S . -B ./build -G Ninja -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_TOOLCHAIN_FILE=${WASI_SDK_PREFIX}/share/cmake/wasi-sdk.cmake -DWASI_SDK_PREFIX=${WASI_SDK_PREFIX}' | ||
npx -y @devcontainers/cli exec --workspace-folder ${SCRIPT_DIR} cmake --build ./build --parallel |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
#include "util.hpp" | ||
#include <vector> | ||
#include <cstdint> | ||
|
||
static uint32_t tally = 0; | ||
|
||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.