Skip to content

Commit

Permalink
[wasm][mt] Add MT option to container configs (dotnet#99615)
Browse files Browse the repository at this point in the history
* Add MT option.

* Add configuration, fix function not defined.
  • Loading branch information
ilonatommy authored Mar 13, 2024
1 parent 8790a2f commit cb7154d
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 7 deletions.
30 changes: 24 additions & 6 deletions .devcontainer/scripts/onCreateCommand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

set -e

function wasm_common() {
# prebuild for WASM, so it is ready for wasm development
make -C src/mono/browser provision-wasm
export EMSDK_PATH=$PWD/src/mono/browser/emsdk
case "$1" in
wasm)
# Put your common commands for wasm here
./build.sh mono+libs -os browser -c Release
;;
wasm-multithread)
# Put your common commands for wasm-multithread here
./build.sh mono+libs -os browser -c Release /p:WasmEnableThreads=true
;;
*)
# install dotnet-serve for running wasm samples
./dotnet.sh tool install dotnet-serve --version 1.10.172 --tool-path ./.dotnet-tools-global
;;
esac
}

opt=$1
case "$opt" in

Expand All @@ -20,13 +40,11 @@ case "$opt" in
;;

wasm)
# prebuild for WASM, so it is ready for wasm development
make -C src/mono/browser provision-wasm
export EMSDK_PATH=$PWD/src/mono/browser/emsdk
./build.sh mono+libs -os browser -c Release
wasm_common $opt
;;

# install dotnet-serve for running wasm samples
./dotnet.sh tool install dotnet-serve --version 1.10.172 --tool-path ./.dotnet-tools-global
wasm-multithread)
wasm_common $opt
;;
esac

Expand Down
60 changes: 60 additions & 0 deletions .devcontainer/wasm-multiThreaded/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.192.0/containers/dotnet/.devcontainer/base.Dockerfile
# For details on dotnet specific container, see: https://github.com/microsoft/vscode-dev-containers/tree/main/containers/dotnet

# [Choice] .NET version: 6.0, 7.0
ARG VARIANT="6.0-jammy"
FROM mcr.microsoft.com/devcontainers/dotnet:0-${VARIANT}

# Set up machine requirements to build the repo and the gh CLI
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
cmake \
llvm \
clang \
build-essential \
python3 \
curl \
git \
lldb \
liblldb-dev \
libunwind8 \
libunwind8-dev \
gettext \
libicu-dev \
liblttng-ust-dev \
libssl-dev \
libkrb5-dev \
zlib1g-dev \
ninja-build

SHELL ["/bin/bash", "-c"]

# Install LTS npm and node
RUN source /usr/local/share/nvm/nvm.sh && nvm install --lts

# Install V8 Engine
RUN curl -sSL "https://netcorenativeassets.blob.core.windows.net/resource-packages/external/linux/chromium-v8/v8-linux64-rel-10.8.168.zip" -o ./v8.zip \
&& unzip ./v8.zip -d /usr/local/v8 \
&& echo $'#!/usr/bin/env bash\n\
"/usr/local/v8/d8" --snapshot_blob="/usr/local/v8/snapshot_blob.bin" "$@"\n' > /usr/local/bin/v8 \
&& chmod +x /usr/local/bin/v8

# install chromium dependencies to run debugger tests:
RUN sudo apt-get install libnss3 -y \
&& apt-get install libatk1.0-0 -y \
&& apt-get install libatk-bridge2.0-0 -y \
&& apt-get install libcups2 -y \
&& apt-get install libdrm2 -y \
&& apt-get install libxkbcommon-x11-0 -y \
&& apt-get install libxcomposite-dev -y \
&& apt-get install libxdamage1 -y \
&& apt-get install libxrandr2 -y \
&& apt-get install libgbm-dev -y \
&& apt-get install libpango-1.0-0 -y \
&& apt-get install libcairo2 -y \
&& apt-get install libasound2 -y

# install firefox dependencies to run debugger tests:
RUN sudo apt-get install libdbus-glib-1-2 -y \
&& apt-get install libgtk-3-0 -y \
&& apt-get install libx11-xcb-dev -y
65 changes: 65 additions & 0 deletions .devcontainer/wasm-multiThreaded/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "WASM multithreaded development (prebuilt)",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update 'VARIANT' to pick a .NET Core version: 6.0, 7.0
"VARIANT": "6.0-jammy"
}
},
"hostRequirements": {
"cpus": 4,
"memory": "8gb"
},

"features": {
"ghcr.io/devcontainers/features/github-cli:1": {}
},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp"
],
"settings": {
// Loading projects on demand is better for larger codebases
"omnisharp.enableMsBuildLoadProjectsOnDemand": true,
"omnisharp.enableRoslynAnalyzers": true,
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableAsyncCompletion": true,
"omnisharp.testRunSettings": "${containerWorkspaceFolder}/artifacts/obj/vscode/.runsettings"
}
}
},

// Use 'onCreateCommand' to run pre-build commands inside the codespace
"onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/onCreateCommand.sh wasm-multithreaded",

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "${containerWorkspaceFolder}/.devcontainer/scripts/postCreateCommand.sh",

// Add the locally installed dotnet to the path to ensure that it is activated
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
// Add the global tools dir to the PATH so that globally installed tools will work
"remoteEnv": {
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
"DOTNET_MULTILEVEL_LOOKUP": "0",
// Path to provisioned Emscripten SDK, for rebuilding the wasm runtime
"EMSDK_PATH": "${containerWorkspaceFolder}/src/mono/browser/emsdk",
},

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",

// Forward mono samples port
"forwardPorts": [8000],
"portsAttributes": {
"8000": {
"label": "mono wasm samples (8000)",
}
}
}
2 changes: 1 addition & 1 deletion .devcontainer/wasm/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "WASM development (prebuilt)",
"name": "WASM singlethreaded development (prebuilt)",
"build": {
"dockerfile": "Dockerfile",
"args": {
Expand Down

0 comments on commit cb7154d

Please sign in to comment.