SPB Git

Repository Public License

build.sh 4.2 KB 89 lines shellscript

1#!/bin/bash2# ORIX Convert — EmbeddedEngines/assimp/build.sh3# Description: Builds the Open Asset Import Library (Assimp) from the pinned source release as one static library with4#              only the OBJ, STL, PLY, glTF/GLB, FBX, COLLADA and 3MF importers/exporters, and wraps it into5#              CAssimp.xcframework (arm64, macOS 15.0+), consumed by Packages/EngineModel3D through its C API.6# Author: Simon-Pierre Boucher — contact@spboucher.ai7set -euo pipefail8cd "$(dirname "$0")"9export LC_ALL=C1011VERSION="6.0.2"12SHA256="d1822d9a19c9205d6e8bc533bf897174ddb360ce504680f294170cc1d6319751"13URL="https://github.com/assimp/assimp/archive/refs/tags/v${VERSION}.tar.gz"14export MACOSX_DEPLOYMENT_TARGET=15.01516if [[ -d CAssimp.xcframework && "${1:-}" != "--force" ]]; then17    echo "CAssimp.xcframework already present (use --force to rebuild)"; exit 018fi1920CMAKE="$(command -v cmake || true)"21[[ -n "$CMAKE" ]] || { echo "cmake is required to build Assimp (build-time only)"; exit 1; }2223rm -rf src prefix CAssimp.xcframework work/build work/Headers24mkdir -p src work prefix25if ! echo "${SHA256}  work/assimp.tar.gz" | shasum -a 256 -c - > /dev/null 2>&1; then26    curl -fsSL -o work/assimp.tar.gz "$URL"27fi28echo "${SHA256}  work/assimp.tar.gz" | shasum -a 256 -c -29# The archive ships ~500 MB of test models; only the sources, the contrib code and the CMake files are extracted.30tar -xzf work/assimp.tar.gz -C src --strip-components 1 --exclude '*/test/*' --exclude '*/samples/*' --exclude '*/doc/*' --exclude '*/fuzz/*'31mkdir -p src/test src/samples3233FORMATS=(OBJ STL PLY GLTF FBX COLLADA 3MF)34FLAGS=()35for f in "${FORMATS[@]}"; do FLAGS+=("-DASSIMP_BUILD_${f}_IMPORTER=ON" "-DASSIMP_BUILD_${f}_EXPORTER=ON"); done3637"$CMAKE" -S src -B work/build -G "Unix Makefiles" \38    -DCMAKE_BUILD_TYPE=Release \39    -DCMAKE_OSX_ARCHITECTURES=arm64 \40    -DCMAKE_OSX_DEPLOYMENT_TARGET=15.0 \41    -DCMAKE_INSTALL_PREFIX="$PWD/prefix" \42    -DCMAKE_POSITION_INDEPENDENT_CODE=ON \43    -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \44    -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \45    -DCMAKE_FIND_FRAMEWORK=NEVER -DCMAKE_FIND_APPBUNDLE=NEVER \46    -DCMAKE_IGNORE_PREFIX_PATH="/opt/homebrew;/usr/local" \47    -DBUILD_SHARED_LIBS=OFF \48    -DASSIMP_BUILD_FRAMEWORK=OFF \49    -DASSIMP_BUILD_TESTS=OFF -DASSIMP_BUILD_ASSIMP_TOOLS=OFF -DASSIMP_BUILD_SAMPLES=OFF \50    -DASSIMP_BUILD_DOCS=OFF -DASSIMP_INSTALL=ON -DASSIMP_INSTALL_PDB=OFF \51    -DASSIMP_BUILD_ZLIB=OFF -DASSIMP_BUILD_DRACO=OFF -DASSIMP_BUILD_USD_IMPORTER=OFF \52    -DASSIMP_BUILD_ASSIMP_VIEW=OFF -DASSIMP_COVERALLS=OFF \53    -DASSIMP_WARNINGS_AS_ERRORS=OFF -DASSIMP_INJECT_DEBUG_POSTFIX=OFF -DASSIMP_IGNORE_GIT_HASH=ON \54    -DASSIMP_NO_EXPORT=OFF -DASSIMP_DOUBLE_PRECISION=OFF \55    -DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=OFF -DASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=OFF \56    "${FLAGS[@]}" > work/configure.log57"$CMAKE" --build work/build --parallel "$(sysctl -n hw.ncpu)" > work/build.log 2>&158"$CMAKE" --install work/build > work/install.log5960cp prefix/lib/libassimp.a work/libCAssimp.a61strip -S work/libCAssimp.a 2> work/strip.log || true6263# Only the C API headers are exposed to Swift.64rm -rf work/Headers && mkdir -p work/Headers65cp -R prefix/include/assimp work/Headers/assimp66cat > work/Headers/module.modulemap <<'MAP'67module CAssimp {68    header "assimp/cimport.h"69    header "assimp/cexport.h"70    header "assimp/scene.h"71    header "assimp/postprocess.h"72    header "assimp/material.h"73    header "assimp/GltfMaterial.h"74    header "assimp/version.h"75    header "assimp/cfileio.h"76    link "z"77    link "c++"78    export *79}80MAP8182xcodebuild -create-xcframework -library work/libCAssimp.a -headers work/Headers -output CAssimp.xcframework > work/xcframework.log83# Record which contrib sources were really compiled (basis of NOTICE.md).84grep -o 'contrib/[A-Za-z0-9_.-]*' work/build/compile_commands.json | sort -u > work/contrib-compiled.txt || true85echo "Assimp ${VERSION} ready: $(lipo -archs work/libCAssimp.a), libCAssimp.a $(stat -f %z work/libCAssimp.a) bytes, $(du -sh CAssimp.xcframework | cut -f1)"8687# Keep module maps out of the shared include directory Xcode builds (see normalize-xcframework.sh).88"$(cd "$(dirname "$0")/.." && pwd)/normalize-xcframework.sh" "$(cd "$(dirname "$0")" && pwd)"/*.xcframework89
Files main
Menu

Theme