mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-07-03 11:53:41 +02:00
Adding WASM build using Emscripten
This commit is contained in:
parent
65710a8cd2
commit
d6db107594
4 changed files with 64 additions and 2 deletions
11
README.md
11
README.md
|
|
@ -66,6 +66,17 @@ C:\repo\build> cmake -D OPENSSL_ROOT_DIR="C:/path/to/openssl-1.1/x86" ..
|
|||
C:\repo\build> cmake --build . --config Release
|
||||
```
|
||||
|
||||
### WebAssembly (Emscripten / Linux)
|
||||
|
||||
It is possible to build WASM code using [emscripten](https://emscripten.org/).
|
||||
Consult the manual for how to get it setup. No dependencies are needed as the build
|
||||
script will download and compile `openssl` for wasm by itself.
|
||||
|
||||
Once your emscripten environment is setup, call `build.sh` with the following flag.
|
||||
```sh
|
||||
$ ./build.sh em-wasm
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
After the project has been compiled. run `sudo ./install.sh` or the following code if you dont want to use that:
|
||||
|
|
|
|||
14
build.sh
14
build.sh
|
|
@ -1,7 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
mkdir build 2> /dev/null
|
||||
pushd build > /dev/null
|
||||
cmake .. $@
|
||||
make -B
|
||||
|
||||
# Emscripten WASM build.
|
||||
if [ $# -gt 0 ] && [ "$1" = "em-wasm" ]; then
|
||||
shift 1
|
||||
. ${BASE_DIR}/scripts/emscripten.sh $@
|
||||
else
|
||||
cmake $@ ..
|
||||
make -B
|
||||
fi
|
||||
|
||||
popd > /dev/null
|
||||
|
|
|
|||
16
scripts/emscripten.sh
Normal file
16
scripts/emscripten.sh
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
# Build openssl
|
||||
. "${BASE_DIR}/emscripten_openssl.sh" "openssl"
|
||||
|
||||
# Configure cmake
|
||||
emconfigure cmake \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DOPENSSL_ROOT_DIR="openssl" \
|
||||
-DOPENSSL_CRYPTO_LIBRARY="openssl/libcrypto.a" \
|
||||
-DOPENSSL_SSL_LIBRARY="openssl/libssl.a" \
|
||||
-G "Unix Makefiles" $@ ..
|
||||
|
||||
emmake make
|
||||
25
scripts/emscripten_openssl.sh
Normal file
25
scripts/emscripten_openssl.sh
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env bash
|
||||
# Build OpenSSL
|
||||
|
||||
BUILD_DIR=$1
|
||||
OPENSSL_VERSION=1.1.1d
|
||||
|
||||
if [ ! -d "$BUILD_DIR" ]; then
|
||||
mkdir -p "$BUILD_DIR"
|
||||
|
||||
wget https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz
|
||||
tar xf openssl-${OPENSSL_VERSION}.tar.gz -C "$BUILD_DIR" --strip 1
|
||||
rm -f openssl-${OPENSSL_VERSION}.tar.gz
|
||||
fi
|
||||
|
||||
pushd "$BUILD_DIR"
|
||||
|
||||
emconfigure ./Configure gcc -no-tests -no-asm -static -no-sock \
|
||||
-no-afalgeng -DOPENSSL_SYS_NETWARE -DSIG_DFL=0 -DSIG_IGN=0 \
|
||||
-DHAVE_FORK=0 -DOPENSSL_NO_AFALGENG=1 --with-rand-seed=getrandom
|
||||
|
||||
sed -i 's|^CROSS_COMPILE.*$|CROSS_COMPILE=|g' Makefile
|
||||
#sed -i -E 's|^CFLAGS=(.*)$|CFLAGS=\1 -D__STDC_NO_ATOMICS__=1|g' Makefile
|
||||
|
||||
emmake make -j 12 build_generated libssl.a libcrypto.a
|
||||
popd
|
||||
Loading…
Add table
Add a link
Reference in a new issue