build_osx: --shared + skip geometry-writer plug-ins (~3x bundle shrink)

Mirrors the Rocky workflow's two-part size reduction (27249770e
"Reduce Rocky package size") on macOS:

1. Pass `--shared` to nix/build-all.py. The default builds
   IfcOpenShell as static libs, which means every plug-in dylib
   (schemas × 8, kernels × 3, mappings × 8, writers × 8, document
   serializers × ~4, linework processing) statically embeds a full
   copy of libIfcParse + libIfcGeom. With --shared the plug-ins
   reference @rpath/libIfcParse.dylib + @rpath/libIfcGeom.dylib and
   the per-plug-in dylib drops from ~30-50 MB to a few MB each.
   Dominant size win.

2. Filter `ifcopenshell.geometry.writer.*.dylib` out of BonsaiViewer's
   plug-in staging step in src/bonsaiviewer/CMakeLists.txt. These are
   the per-schema OBJ / glTF / DAE / STP / IGS / SVG / TTL export
   converters — heavy because each one inlines the full schema, and
   BonsaiViewer is a viewer, never an exporter, so they're pure
   deadweight inside the bundle. Additive on top of --shared.

Bundle went 300 MB → expected ~100 MB, in line with Linux (~100 MB)
and Windows (~80 MB).

The IFCOPENSHELL_BUILD_PYTHON_WRAPPER=off gate is unchanged for now
— once we confirm BonsaiViewer.app size + functionality look sane,
we can ungate the Python wrapper and see if shared-builds-on-macOS
shake out its install issues too.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Dion Moult
2026-06-03 08:06:42 +10:00
parent 37aa68e66c
commit ddee88bed3
2 changed files with 13 additions and 1 deletions
+6 -1
View File
@@ -88,10 +88,15 @@ jobs:
# actually drops ifcopenshell.document.rdb.dylib into # actually drops ifcopenshell.document.rdb.dylib into
# site-packages/ifcopenshell/ (see the commit that added this # site-packages/ifcopenshell/ (see the commit that added this
# gate for the full history + the rocksdb/macdeployqt write-up). # gate for the full history + the rocksdb/macdeployqt write-up).
# --shared mirrors build_rocky.yml after 27249770e: builds
# IfcOpenShell as shared libs so each plug-in dylib references
# libIfcParse / libIfcGeom via @rpath instead of statically
# embedding them — the dominant size win for BonsaiViewer.app
# (per-plugin libs go from ~30-50 MB to a few MB).
CXXFLAGS="-O3" CFLAGS="-O3 ${DARWIN_C_SOURCE}" ADD_COMMIT_SHA=1 BUILD_CFG=Release \ CXXFLAGS="-O3" CFLAGS="-O3 ${DARWIN_C_SOURCE}" ADD_COMMIT_SHA=1 BUILD_CFG=Release \
BUILD_BONSAIVIEWER=ON QT_DIR="${QT_DIR}" \ BUILD_BONSAIVIEWER=ON QT_DIR="${QT_DIR}" \
IFCOS_BUILD_PYTHON_WRAPPER=off \ IFCOS_BUILD_PYTHON_WRAPPER=off \
python3 ./nix/build-all.py -v --diskcleanup ${MAC_INTEL} \ python3 ./nix/build-all.py -v --diskcleanup --shared ${MAC_INTEL} \
| tee build.log | tee build.log
- name: Upload Build Logs - name: Upload Build Logs
+7
View File
@@ -180,6 +180,13 @@ if(APPLE)
install(CODE [[ install(CODE [[
file(GLOB _ifc_plugins file(GLOB _ifc_plugins
"${CMAKE_INSTALL_PREFIX}/lib/ifcopenshell.*.dylib") "${CMAKE_INSTALL_PREFIX}/lib/ifcopenshell.*.dylib")
# Skip ifcopenshell.geometry.writer.*.dylib — those are heavy
# schema-specific OBJ / glTF / DAE / STP / IGS / SVG / TTL export
# converters. BonsaiViewer is a viewer; it never writes geometry
# out, so they're pure deadweight. Mirrors the Rocky workflow's
# filter in `stage_runtime_payload` (see 27249770e). Cuts the
# macOS .app by ~100-150 MB.
list(FILTER _ifc_plugins EXCLUDE REGEX "ifcopenshell\\.geometry\\.writer\\.")
if(_ifc_plugins) if(_ifc_plugins)
message(STATUS "Staging IfcOpenShell plug-ins into BonsaiViewer.app/Contents/Frameworks") message(STATUS "Staging IfcOpenShell plug-ins into BonsaiViewer.app/Contents/Frameworks")
file(COPY ${_ifc_plugins} file(COPY ${_ifc_plugins}