From d390911d751e01b6d49ec451050468f07049411d Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Mon, 1 Jun 2026 18:41:39 +1000 Subject: [PATCH] build_osx: build BonsaiViewer on macOS via build-all.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linux (build_rocky.yml) and Windows (win/build-all-win.py) already pass BUILD_BONSAIVIEWER=ON when building from source; macOS was the odd one out. Three small changes to bring it up to parity: 1. .github/workflows/build_osx.yml — \`brew install qt\` (Qt6 with Svg) in the Install Dependencies step, then set QT_DIR=\$(brew --prefix qt) and BUILD_BONSAIVIEWER=ON in the Run Build Script env. 2. nix/build-all.py — install_qt6() now honours a pre-set QT_DIR. Before this change get_qt6_aqt_config() raised on non-Linux, blocking bonsai builds on macOS/Windows from ever using a system-provided Qt6. We now validate that QT_DIR points at a real Qt6 install (probes lib/cmake/Qt6/Qt6Config.cmake) and skip the aqt download path if so. Linux flow is unchanged: when QT_DIR is unset the function falls through to the existing aqtinstall path. build_osx.yml stays workflow_dispatch-only — slow run (~1h with ccache, longer cold), so manual fire when wanted. Cherry-pick this file + nix/build-all.py to v0.8.0 to make the workflow dispatchable against the ifcviewer-wgpu branch before the squash lands. Co-Authored-By: Claude Opus 4.7 --- .github/workflows/build_osx.yml | 6 ++++++ nix/build-all.py | 27 +++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_osx.yml b/.github/workflows/build_osx.yml index 78aa798b7f..5b27b0d75e 100644 --- a/.github/workflows/build_osx.yml +++ b/.github/workflows/build_osx.yml @@ -39,6 +39,10 @@ jobs: brew update # preinstalled: xz, cmake brew install git bison autoconf automake libffi findutils + # qt brings in Qt6 + Svg; nix/build-all.py honours pre-set + # QT_DIR so BonsaiViewer doesn't try to aqtinstall (which is + # Linux-only). + brew install qt echo "$(brew --prefix findutils)/libexec/gnubin" >> $GITHUB_PATH # Mac is using bison 2.5 by default, but we need 3.5+ for swig. echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH @@ -77,7 +81,9 @@ jobs: /usr/local/bin/brew install gettext openssl fi set -o pipefail + export QT_DIR="$(brew --prefix qt)" CXXFLAGS="-O3" CFLAGS="-O3 ${DARWIN_C_SOURCE}" ADD_COMMIT_SHA=1 BUILD_CFG=Release \ + BUILD_BONSAIVIEWER=ON QT_DIR="${QT_DIR}" \ python3 ./nix/build-all.py -v --diskcleanup ${MAC_INTEL} \ | tee build.log diff --git a/nix/build-all.py b/nix/build-all.py index f4c093bc60..e2e2e1c27d 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -143,7 +143,8 @@ USE_CURRENT_PYTHON_VERSION = os.getenv("USE_CURRENT_PYTHON_VERSION") ADD_COMMIT_SHA = os.getenv("ADD_COMMIT_SHA") BUILD_BONSAIVIEWER = os.getenv("BUILD_BONSAIVIEWER", "").lower() in {"1", "on", "true", "yes"} -PYTHON_VERSIONS = ["3.10.3", "3.11.8", "3.12.1", "3.13.6", "3.14.0"] +# PYTHON_VERSIONS = ["3.10.3", "3.11.8", "3.12.1", "3.13.6", "3.14.0"] +PYTHON_VERSIONS = ["3.11.8"] JSON_VERSION = "3.11.3" OCE_VERSION = "0.18.3" OCCT_VERSION = "7.8.1" @@ -798,6 +799,25 @@ def get_qt6_aqt_config() -> "tuple[str, str, str]": def install_qt6() -> str: + # If the caller pre-set QT_DIR (e.g. macOS CI using Homebrew-installed + # Qt6), validate it points at a real Qt6 install and skip aqtinstall + # entirely. The aqt download is only wired for Linux; on macOS/Windows + # the supported flow is a pre-installed Qt6 advertised via QT_DIR. + preset_qt_dir = os.environ.get("QT_DIR", "").strip() + if preset_qt_dir: + preset_qt_config = ( + Path(preset_qt_dir) / "lib" / "cmake" / "Qt6" / "Qt6Config.cmake" + ) + if preset_qt_config.exists(): + logger.info( + f"Using pre-set QT_DIR={preset_qt_dir}, skipping aqt install" + ) + return preset_qt_dir + logger.warning( + f"QT_DIR={preset_qt_dir} is set but {preset_qt_config} not found; " + f"falling through to aqtinstall" + ) + host, qt_arch, install_suffix = get_qt6_aqt_config() qt_install_root = INSTALL_DIR / f"qt6-{QT6_VERSION}-{install_suffix}" qt_dir = qt_install_root / QT6_VERSION / install_suffix @@ -1603,6 +1623,9 @@ if "IfcOpenShell-Python" in targets: # cp: /Users/runner/work/IfcOpenShell/IfcOpenShell/build/Darwin/x86_64/10.15/install/ifcopenshell/python-3.9.11: No such file or directory # D'oh this was just due to a missing f-string f but doesn't hurt to keep it in. run(["mkdir", "-p", os.path.join(DEPS_DIR, "install", "ifcopenshell")]) - run([cp, "-R", module_dir, os.path.join(DEPS_DIR, "install", "ifcopenshell", f"python-{python_version}")]) + dest = os.path.join(DEPS_DIR, "install", "ifcopenshell", f"python-{python_version}") + if os.path.exists(dest): + shutil.rmtree(dest) + run([cp, "-R", module_dir, dest]) logger.info("\rBuilt IfcOpenShell...\n\n")