apfl/webpage/build.sh

58 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/sh
set -e
headline() {
printf '\033[34m\033[1m===== %s =====\e[0m\n' "$1"
}
PCRE2VER=10.42
webpage_dir="$(pwd)"
apfl_root="$webpage_dir/.."
headline 'Building native apflc'
cd playground
rm -rf build-native
mkdir build-native
cd build-native
cmake ../../../CMakeLists.txt
make -j"$(nproc)" apflc
cd ..
headline 'Building PCRE'
rm -rf deps
mkdir deps
cd deps
curl -L -o pcre2.tar.bz2 "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${PCRE2VER}/pcre2-${PCRE2VER}.tar.bz2"
sha256sum pcre2.tar.bz2
tar xjf pcre2.tar.bz2
cd "pcre2-${PCRE2VER}"
mkdir build
cd build
emcmake cmake -DCMAKE_INSTALL_PREFIX="$webpage_dir/playground/deps/prefix" ../CMakeLists.txt
emmake make -j"$(nproc)" pcre2-8-static
emmake make -j"$(nproc)" install
cd ../../..
headline 'Building apfl lib'
2022-09-16 21:04:20 +00:00
rm -rf build
mkdir build
cd build
emcmake cmake -DCMAKE_C_FLAGS="-O2" -DBUILD_SHARED_LIBS=NO -DApflApflcNative_DIR="$(pwd)/../build-native/" -DCMAKE_PREFIX_PATH="$webpage_dir/playground/deps/prefix" ../../../CMakeLists.txt
2022-09-16 21:04:20 +00:00
emmake make -j"$(nproc)" apfl
cd ..
headline 'Building apfl playground'
emcc \
`PKG_CONFIG_PATH="$webpage_dir/playground/deps/prefix/lib/pkgconfig" pkg-config --static --cflags --libs libpcre2-8` \
-O3 \
-oplayground.js \
-sEXPORTED_FUNCTIONS=_repl_new_for_playground,_repl_run,_repl_destroy \
-sEXPORTED_RUNTIME_METHODS=ccall,cwrap \
-sMODULARIZE -sEXPORT_NAME=WasmApflPlayground \
playground.c "$apfl_root/src/repl.c" build/src/libapfl.a