Skip to content

Commit

Permalink
wasi build
Browse files Browse the repository at this point in the history
  • Loading branch information
petersalomonsen committed Dec 17, 2023
1 parent b72e686 commit 3eda5ee
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"postCreateCommand": "/workspaces/wasm-git/.devcontainer/post-create.sh",
"customizations": {
"vscode": {
"extensions": []
"extensions": ["dtsvet.vscode-wasm","ms-vscode.cpptools-extension-pack"]
}
}
}
20 changes: 19 additions & 1 deletion .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash

curl https://wasmtime.dev/install.sh -sSf | bash
npm install
sh setup.sh

Expand All @@ -9,3 +9,21 @@ git pull
./emsdk install latest
./emsdk activate latest
cd ..

sudo apt update
sudo apt install -y clang-12
sudo apt install -y lld-12
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-12 100
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-12 100

sudo ln -s /usr/bin/wasm-ld-12 /usr/bin/wasm-ld

cd wasibuild

wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz
tar -xvzf wasi-sdk-20.0-linux.tar.gz
sudo cp -r wasi-sdk-20.0/lib/clang/16/lib/wasi /usr/lib/llvm-12/lib/clang/12.0.0/lib/

cd ..

curl https://wasmtime.dev/install.sh -sSf | bash
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ package
.idea
emsdk
nodefsclonetest
google-chrome-stable_current_amd64.deb
google-chrome-stable_current_amd64.deb
2 changes: 2 additions & 0 deletions setup.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/bin/bash

curl -L https://github.com/libgit2/libgit2/archive/refs/tags/v1.7.1.tar.gz --output libgit2.tar.gz
tar -xzf libgit2.tar.gz
mv libgit2-1.7.1 libgit2
Expand Down
6 changes: 6 additions & 0 deletions setup_wasi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

curl -L https://github.com/libgit2/libgit2/archive/refs/tags/v1.7.1.tar.gz --output libgit2.tar.gz
tar -xzf libgit2.tar.gz
mv libgit2-1.7.1 libgit2
rm libgit2.tar.gz
11 changes: 11 additions & 0 deletions wasibuild/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CMake*
src
deps
examples
libgit2*
include
Makefile
*.cmake
*.a
tests
wasi-sdk*
14 changes: 14 additions & 0 deletions wasibuild/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
BUILD_TYPE=Debug

# Set build type to Release for release
if [ "$1" == "Release" ]; then
BUILD_TYPE=Release
EXTRA_CMAKE_C_FLAGS="-Oz"
fi

cmake -D CMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_FLAGS="--target=wasm32-wasi --sysroot=wasi-sdk-20.0/share/wasi-sysroot $EXTRA_CMAKE_C_FLAGS" -DREGEX_BACKEND=regcomp -DSONAME=OFF -DUSE_HTTPS=OpenSSL -DBUILD_SHARED_LIBS=OFF -DTHREADSAFE=OFF -DUSE_SSH=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=ON ../libgit2
make lg2 VERBOSE=1


cd /workspaces/wasm-git/wasibuild/src/util && /usr/bin/clang -DOPENSSL_API_COMPAT=0x10100000L -DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"git2_util.h\" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"git2_util.h\" -DSHA1DC_NO_STANDARD_INCLUDES=1 -I/workspaces/wasm-git/wasibuild/src/util -I/workspaces/wasm-git/wasibuild/include -I/workspaces/wasm-git/libgit2/src/util -I/workspaces/wasm-git/libgit2/include -I/workspaces/wasm-git/libgit2/deps/http-parser -I/workspaces/wasm-git/libgit2/deps/xdiff -I/workspaces/wasm-git/libgit2/deps/ntlmclient -D_GNU_SOURCE -Wall -Wextra -Wdocumentation -Wno-documentation-deprecated-sync -Wno-missing-field-initializers -Wmissing-declarations -Wstrict-aliasing -Wstrict-prototypes -Wdeclaration-after-statement -Wshift-count-overflow -Wunused-const-variable -Wunused-function -Wint-conversion -Wc11-extensions -Wformat -Wformat-security -g -D_DEBUG -O0 -std=gnu90 -o CMakeFiles/util.dir/alloc.c.o -c /workspaces/wasm-git/libgit2/src/util/alloc.c

0 comments on commit 3eda5ee

Please sign in to comment.