Files
ElyOffice/scripts/build-libreoffice.sh
T
ZacharyZhang-NYandClaude Opus 5.5 e48035cdd5 Windows kernel no longer hangs on a second start; CI for three platforms
Lightproof, the Python grammar checker in the English dictionaries,
hung the Windows worker whenever a profile was reused; macOS and
Linux carry no Python, so it never ran there. The build now drops it.
A killed worker's profile and document locks hung the next start or
load: the worker runs with SAL_NOLOCK_PROFILE and ely.xcd turns off
LibreOffice's locking; Ely checks conflicts itself.

release.yml runs scripts/ci.sh for each platform on tag push: the
Mac mini builds its engines once in a lasting clone, the Windows
runner links this machine's engines, and Linux builds in WSL on that
runner. makensis reads the script as UTF-8.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 19:39:51 -04:00

155 lines
4.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Builds the pinned LibreOffice with Ely's LOK patches.
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
src=$root/engines/lo-src
pin=$(awk '$1 == "fetch" && $2 == "libreoffice-core" { print $4 }' "$root/scripts/fetch-references.sh")
options=(
--enable-bogus-pkg-config
--enable-mergelibs
--enable-release-build
--without-java
--without-junit
--without-help
--disable-odk
--disable-online-update
--disable-extension-integration
--disable-scripting-beanshell
--disable-scripting-javascript
--disable-firebird-sdbc
--disable-postgresql-sdbc
--disable-ext-nlpsolver
--disable-ext-wiki-publisher
--disable-report-builder
--disable-sdremote
--disable-sdremote-bluetooth
--disable-poppler
--disable-lotuswordpro
--disable-gpgmepp
--disable-cups
--disable-evolution2
--with-galleries=no
--with-lang=
--with-theme=colibre
--with-fonts
--disable-python
--disable-coinmp
--disable-lpsolve
--without-doxygen
--with-myspell-dicts
)
case $(uname) in
Darwin)
app=$src/instdir/LibreOffice.app/Contents/Resources
jobs=$(sysctl -n hw.ncpu)
;;
Linux)
# Collabora's LOKit set: headless, bundled libraries.
options+=(
--disable-gui
--disable-dbus
--disable-gio
--disable-dconf
--disable-randr
--disable-gstreamer-1-0
--without-system-cairo
--without-system-fontconfig
--without-system-freetype
--without-system-graphite
--without-system-harfbuzz
--without-system-openssl
--without-system-libpng
--without-system-libxml
--without-system-jpeg
--without-system-expat
--without-system-curl
--without-system-icu
--without-system-nss
--without-system-zlib
)
app=$src/instdir/share
jobs=$(nproc)
;;
CYGWIN*)
# Unix-only switches; configure refuses them here.
kept=()
for option in "${options[@]}"; do
case $option in
--enable-bogus-pkg-config | --disable-cups | --disable-evolution2 | --disable-python) ;;
*) kept+=("$option") ;;
esac
done
options=("${kept[@]}" --with-visual-studio=2022 --disable-ccache --disable-cli --without-dotnet)
# Cygwin's own make, never Git Bash's; MSYSTEM misleads the build.
unset MSYSTEM MSYSTEM_PREFIX MINGW_PREFIX MSYSTEM_CHOST MSYSTEM_CARCH
PATH=/opt/lo/bin:$PATH
app=$src/instdir/share
jobs=$(nproc)
;;
*)
echo "build-libreoffice.sh: no build for $(uname)" >&2
exit 1
;;
esac
if [ ! -d "$src/.git" ]; then
git init -q "$src"
git -C "$src" remote add origin https://github.com/LibreOffice/core.git
git -C "$src" fetch -q --depth 1 origin "$pin"
git -C "$src" checkout -q FETCH_HEAD
fi
# The bundled spelling dictionaries (DOC-12).
git -C "$src" config submodule.dictionaries.url https://github.com/LibreOffice/dictionaries.git
git -C "$src" submodule update -q --init --depth 1 dictionaries
[ "$(git -C "$src" rev-parse HEAD)" = "$pin" ] || {
echo "build-libreoffice.sh: $src is not at $pin" >&2
exit 1
}
"$root/scripts/apply-lo-patches.sh" "$src"
if [ "$(uname)" = Darwin ]; then
for tool in make gnu-sed bison flex gettext; do
prefix=$(brew --prefix "$tool")
PATH=$prefix/libexec/gnubin:$prefix/bin:$PATH
done
export PATH PKG_CONFIG_LIBDIR=/var/empty PKG_CONFIG_PATH=
fi
cd "$src"
if [ ! -f config_host.mk ] || ! printf '%s\n' "${options[@]}" | cmp -s - autogen.lastrun; then
./autogen.sh "${options[@]}"
fi
make -j"$jobs"
# Bundled dictionaries: English only; each one slows LOK start (PERF-01).
keep=(dict-en)
extensions=$app/extensions
for dict in "$extensions"/dict-*; do
name=$(basename "$dict")
if [[ " ${keep[*]} " != *" $name "* ]]; then
rm -rf "$dict"
fi
done
echo "build-libreoffice.sh: dictionaries kept: $(ls "$extensions" | tr '\n' ' ')"
# Lightproof is Python: inert without it, a hang on Windows.
en=$extensions/dict-en
rm -rf "$en/Lightproof.py" "$en/Lightproof.components" "$en/Linguistic.xcu" "$en/pythonpath" "$en/dialog"
python3 - "$en/META-INF/manifest.xml" <<'PY'
import re, sys
path = sys.argv[1]
text = open(path, encoding="utf-8").read()
gone = r'\s*<manifest:file-entry[^>]*?"(?:Lightproof\.components|Linguistic\.xcu|dialog/[^"]*)"[^>]*/>'
kept = re.sub(gone, "", text, flags=re.S)
for left in ("Lightproof", "Linguistic.xcu", "dialog/"):
if left in kept:
sys.exit(f"build-libreoffice.sh: {left} is still in {path}")
open(path, "w", encoding="utf-8").write(kept)
PY
# Ely's kernel defaults: Excel A1 formulas.
cp "$root/packaging/libreoffice/ely.xcd" "$app/registry/"
if [ "$(uname)" = Darwin ]; then
"$root/scripts/inert-lo.sh" "$src/instdir/LibreOffice.app"
fi