2018-12-23 21:25:26 +01:00
#!/bin/sh
2018-12-24 00:30:54 +01:00
emconfigure 2> /dev/null || { echo 'emconfigure not found. Install emsdk and add emconfigure and emmake to PATH environment variable. See instruction at https://kripken.github.io/emscripten-site/docs/getting_started/downloads.html. Do not forget to add `emconfigure` and `emmake` to the PATH environment variable via `emsdk/emsdk_env.sh` script.' ; exit 1; }
2018-12-22 22:46:48 +01:00
2018-12-23 21:25:26 +01:00
rm -rf build/generate
rm -rf build/asmjs
rm -rf build/wasm
2018-12-21 17:03:26 +01:00
mkdir -p build/generate
mkdir -p build/asmjs
mkdir -p build/wasm
TD_ROOT = $( realpath ../../)
#OPENSSL_OPTIONS="-DOPENSSL_ROOT=$TD_ROOT/third_party/crypto/emscripten"
OPENSSL_ROOT = $( realpath ./build/crypto/)
OPENSSL_CRYPTO_LIBRARY = $OPENSSL_ROOT /lib/libcrypto.a
OPENSSL_SSL_LIBRARY = $OPENSSL_ROOT /lib/libssl.a
OPENSSL_OPTIONS = " -DOPENSSL_FOUND=1 \
-DOPENSSL_ROOT_DIR= \" $OPENSSL_ROOT \" \
-DOPENSSL_INCLUDE_DIR= \" $OPENSSL_ROOT /include\" \
-DOPENSSL_CRYPTO_LIBRARY= \" $OPENSSL_CRYPTO_LIBRARY \" \
-DOPENSSL_SSL_LIBRARY= \" $OPENSSL_SSL_LIBRARY \" \
-DOPENSSL_LIBRARIES= \" $OPENSSL_SSL_LIBRARY ; $OPENSSL_CRYPTO_LIBRARY \" \
-DOPENSSL_VERSION= \" 1.1.0j\" "
2018-12-23 22:56:44 +01:00
cd build/generate
cmake $TD_ROOT || exit 1
cd ../..
2018-12-21 17:03:26 +01:00
cd build/wasm
2018-12-24 00:50:12 +01:00
eval emconfigure cmake -DCMAKE_BUILD_TYPE= Release $OPENSSL_OPTIONS $TD_ROOT || exit 1
2018-12-23 22:41:38 +01:00
cd ../..
2018-12-21 17:03:26 +01:00
cd build/asmjs
2018-12-24 00:50:12 +01:00
eval emconfigure cmake -DCMAKE_BUILD_TYPE= Release $OPENSSL_OPTIONS -DASMJS= 1 $TD_ROOT || exit 1
2018-12-23 22:41:38 +01:00
cd ../..
2018-12-21 17:03:26 +01:00
2018-12-23 21:25:26 +01:00
echo "Generating TDLib autogenerated source files..."
2018-12-27 19:06:30 +01:00
cmake --build build/generate -j --target prepare_cross_compiling || exit 1
2018-12-23 21:25:26 +01:00
echo "Building TDLib to WebAssembly..."
2018-12-27 19:06:30 +01:00
cmake --build build/wasm -j --target td_wasm || exit 1
2018-12-23 21:25:26 +01:00
echo "Building TDLib to asm.js..."
2018-12-27 19:06:30 +01:00
cmake --build build/asmjs -j --target td_asmjs || exit 1