Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Stale Issues / stale (push) Has been cancelled
134 lines
4.6 KiB
Bash
Executable File
134 lines
4.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
source_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
workspace_dir=$(cd "$source_dir/.." && pwd)
|
|
base_lib_dir=${FREECAD_WEB_BASE_LIB_DIR:-"$workspace_dir/FreeCADBaseLib"}
|
|
build_root=${FREECAD_WEB_BUILD_ROOT:-"$source_dir/build-web"}
|
|
jobs=${FREECAD_WEB_JOBS:-8}
|
|
emscripten_config=${FREECAD_WEB_EMSCRIPTEN_CONFIG:-"$build_root/emscripten-config.py"}
|
|
|
|
openssl_source="$base_lib_dir/sources/src/OpenSSL-3.2.2"
|
|
curl_source="$base_lib_dir/sources/src/CURL-8.8.0"
|
|
zlib_install="$build_root/zlib-install"
|
|
openssl_build="$build_root/openssl-cloud-build"
|
|
openssl_install="$build_root/openssl-install"
|
|
curl_build="$build_root/curl-cloud-build"
|
|
curl_install="$build_root/curl-install"
|
|
|
|
if [[ ! -f "$openssl_source/.source-complete" ||
|
|
! -f "$curl_source/.source-complete" ]]; then
|
|
"$base_lib_dir/download_sources.sh"
|
|
fi
|
|
|
|
toolchain=${FREECAD_WEB_EMSCRIPTEN_TOOLCHAIN:-}
|
|
if [[ -z "$toolchain" ]]; then
|
|
emcc_path=$(realpath "$(command -v emcc)")
|
|
toolchain="$(dirname "$emcc_path")/cmake/Modules/Platform/Emscripten.cmake"
|
|
fi
|
|
if [[ ! -f "$toolchain" ]]; then
|
|
printf 'Emscripten toolchain not found: %s\n' "$toolchain" >&2
|
|
exit 1
|
|
fi
|
|
if [[ ! -f "$emscripten_config" ]]; then
|
|
printf 'Project Emscripten config not found: %s\n' "$emscripten_config" >&2
|
|
printf 'Run tools/prepare_web_dependencies.sh first.\n' >&2
|
|
exit 1
|
|
fi
|
|
if [[ ! -f "$zlib_install/include/zlib.h" ||
|
|
! -f "$zlib_install/lib/libz.a" ]]; then
|
|
printf 'Cloud dependency build requires the existing Web zlib installation at %s\n' \
|
|
"$zlib_install" >&2
|
|
printf 'Run tools/prepare_web_dependencies.sh first.\n' >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Both build directories are task-owned generated paths. A fresh tree is
|
|
# required because OpenSSL does not rebuild every object when Configure
|
|
# feature flags change.
|
|
rm -rf -- "$openssl_build" "$openssl_install" "$curl_build" "$curl_install"
|
|
mkdir -p "$openssl_build" "$openssl_install" "$curl_install"
|
|
|
|
(
|
|
cd "$openssl_build"
|
|
env \
|
|
CC="$(command -v emcc)" \
|
|
CXX="$(command -v em++)" \
|
|
AR="$(command -v emar)" \
|
|
RANLIB="$(command -v emranlib)" \
|
|
"$openssl_source/Configure" \
|
|
linux-generic32 \
|
|
no-shared no-tests no-apps no-asm no-afalgeng no-engine \
|
|
no-threads no-dso no-module \
|
|
--prefix="$openssl_install" \
|
|
--openssldir="$openssl_install/ssl"
|
|
make --jobs="$jobs"
|
|
make install_sw
|
|
)
|
|
|
|
EM_CONFIG="$emscripten_config" cmake -S "$curl_source" -B "$curl_build" -G Ninja \
|
|
-DCMAKE_TOOLCHAIN_FILE="$toolchain" \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_INSTALL_PREFIX="$curl_install" \
|
|
-DCMAKE_INSTALL_LIBDIR=lib \
|
|
-DBUILD_CURL_EXE=OFF \
|
|
-DBUILD_EXAMPLES=OFF \
|
|
-DBUILD_LIBCURL_DOCS=OFF \
|
|
-DBUILD_MISC_DOCS=OFF \
|
|
-DBUILD_SHARED_LIBS=OFF \
|
|
-DBUILD_STATIC_LIBS=ON \
|
|
-DBUILD_TESTING=OFF \
|
|
-DCURL_BROTLI=OFF \
|
|
-DCURL_USE_LIBPSL=OFF \
|
|
-DCURL_USE_OPENSSL=ON \
|
|
-DCURL_ZSTD=OFF \
|
|
-DENABLE_CURL_MANUAL=OFF \
|
|
-DENABLE_UNIX_SOCKETS=OFF \
|
|
-DUSE_LIBIDN2=OFF \
|
|
-DUSE_LIBSSH2=OFF \
|
|
-DUSE_NGHTTP2=OFF \
|
|
-DSIZEOF_INT=4 \
|
|
-DSIZEOF_LONG=4 \
|
|
-DSIZEOF_LONG_LONG=8 \
|
|
-DSIZEOF_OFF_T=8 \
|
|
-DSIZEOF_CURL_OFF_T=8 \
|
|
-DSIZEOF_CURL_SOCKET_T=4 \
|
|
-DSIZEOF_SIZE_T=4 \
|
|
-DSIZEOF_SSIZE_T=4 \
|
|
-DSIZEOF_TIME_T=8 \
|
|
-DOPENSSL_ROOT_DIR="$openssl_install" \
|
|
-DOPENSSL_INCLUDE_DIR="$openssl_install/include" \
|
|
-DOPENSSL_CRYPTO_LIBRARY="$openssl_install/lib/libcrypto.a" \
|
|
-DOPENSSL_SSL_LIBRARY="$openssl_install/lib/libssl.a" \
|
|
-DOPENSSL_USE_STATIC_LIBS=TRUE \
|
|
-DZLIB_ROOT="$zlib_install" \
|
|
-DZLIB_USE_STATIC_LIBS=ON
|
|
EM_CONFIG="$emscripten_config" cmake --build "$curl_build" --parallel "$jobs"
|
|
EM_CONFIG="$emscripten_config" cmake --install "$curl_build"
|
|
|
|
required_files=(
|
|
"$openssl_install/include/openssl/opensslv.h"
|
|
"$openssl_install/lib/libcrypto.a"
|
|
"$openssl_install/lib/libssl.a"
|
|
"$curl_install/include/curl/curl.h"
|
|
"$curl_install/lib/libcurl.a"
|
|
)
|
|
for required_file in "${required_files[@]}"; do
|
|
if [[ ! -f "$required_file" ]]; then
|
|
printf 'Missing Cloud Web dependency artifact: %s\n' "$required_file" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
if llvm-nm --undefined-only "$openssl_install/lib/libcrypto.a" \
|
|
| grep -Eq ' (ENGINE_|engine_|ossl_err_load_ENGINE)'; then
|
|
printf 'OpenSSL Web archive contains unresolved ENGINE references.\n' >&2
|
|
exit 1
|
|
fi
|
|
|
|
file \
|
|
"$openssl_install/lib/libcrypto.a" \
|
|
"$openssl_install/lib/libssl.a" \
|
|
"$curl_install/lib/libcurl.a"
|
|
printf 'Cloud Web dependencies are ready under %s\n' "$build_root"
|