Skip to content

Commit

Permalink
wasi toolchain cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
petersalomonsen committed Dec 17, 2023
1 parent 3eda5ee commit 6f8e666
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions wasibuild/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Makefile
*.a
tests
wasi-sdk*
!wasi_toolchain.cmake
CopyOfCMakeCache.txt
5 changes: 1 addition & 4 deletions wasibuild/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ if [ "$1" == "Release" ]; then
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
cmake -DCMAKE_TOOLCHAIN_FILE=`pwd`/wasi_toolchain.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_C_FLAGS="$EXTRA_CMAKE_C_FLAGS" -DREGEX_BACKEND=regcomp -DSONAME=OFF -DUSE_HTTPS=OFF -DBUILD_SHARED_LIBS=OFF -DUSE_THREADS=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
10 changes: 10 additions & 0 deletions wasibuild/wasi_toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SET(CMAKE_C_COMPILER clang)
SET(CMAKE_FIND_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/wasi-sdk-20.0/share/wasi-sysroot/)
SET(CMAKE_SYSROOT ${CMAKE_CURRENT_LIST_DIR}/wasi-sdk-20.0/share/wasi-sysroot/)
set(CMAKE_C_FLAGS "--target=wasm32-wasi -D_WASI_EMULATED_MMAN -lwasi-emulated-mman ${CMAKE_C_FLAGS}")

set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "${CMAKE_SYSROOT}/include")

SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

0 comments on commit 6f8e666

Please sign in to comment.