Merge branch 'main' into feature/filament_id

This commit is contained in:
SoftFever
2026-09-03 12:16:38 +08:00
122 changed files with 5361 additions and 1415 deletions

View File

@@ -122,6 +122,9 @@ sed "/name: OrcaSlicer/{
\1 git_commit_hash: \"$GIT_COMMIT_HASH\"|
}" > "$MANIFEST_DOCKER"
# ---------- pack deps/ ----------
./scripts/flatpak/make_deps_tar.sh
# ---------- run build in Docker ----------
DOCKER="${DOCKER:-docker}"

View File

@@ -1,3 +1,4 @@
builddir
.flatpak-builder
*.docker.yml
deps.tar*

View File

@@ -0,0 +1,52 @@
#!/bin/bash
# Check a Flatpak manifest for `type: dir` sources at or before the orca_deps
# module.
#
# Usage: check_manifest_cacheable.sh [manifest]
# Defaults to com.orcaslicer.OrcaSlicer.yml next to this script.
#
# Exits 0 when none are found, 1 when any are, listing them as file:line, and
# 2 when the manifest is missing or has no orca_deps module.
set -euo pipefail
anchor=orca_deps
manifest=${1:-$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/com.orcaslicer.OrcaSlicer.yml}
module_re='^ - name: '
dir_re='(^|[-{,[:space:]])type:[[:space:]]*dir([,}[:space:]]|$)'
if [ ! -f "$manifest" ]; then
echo "$manifest: no such file" >&2
exit 2
fi
anchor_start=$(grep -n "${module_re}${anchor}[[:space:]]*$" "$manifest" | cut -d: -f1 || true)
if [ -z "$anchor_start" ]; then
echo "$manifest: no module named '$anchor'; this check needs updating" >&2
exit 2
fi
# First module header after the anchor, or EOF if the anchor is last.
anchor_end=$(grep -n "$module_re" "$manifest" | cut -d: -f1 |
awk -v s="$anchor_start" '$1 > s { print $1; exit }')
[ -n "$anchor_end" ] || anchor_end=$(awk 'END { print NR + 1 }' "$manifest")
violations=$(awk -v e="$anchor_end" -v f="$manifest" -v mre="$module_re" -v dre="$dir_re" '
{ sub(/\r$/, "") }
/^[[:space:]]*#/ { next }
$0 ~ mre { module = $3 }
NR < e && $0 ~ dre {
printf "%s:%d: %s (module %s)\n", f, NR, $0, module
}' "$manifest")
if [ -n "$violations" ]; then
printf '%s\n' "$violations" >&2
echo >&2
echo "flatpak-builder cannot checksum a directory, so each of these makes" >&2
echo "$anchor and every module after it rebuild from scratch on every run." >&2
echo "See the $anchor sources in this manifest for the tarball used instead." >&2
exit 1
fi
echo "manifest OK: no 'type: dir' source at or before $anchor"

View File

@@ -144,6 +144,7 @@ modules:
env:
BUILD_DIR: deps/build_flatpak
build-commands:
- tar xf deps.tar
- |
cmake -S deps -B $BUILD_DIR \
-DFLATPAK=ON \
@@ -169,10 +170,10 @@ modules:
- /libpython/include
sources:
# OrcaSlicer deps/ directory (avoids copying .git from worktree)
- type: dir
path: ../../deps
dest: deps
# flatpak-builder cannot checksum a directory, so a `type: dir` here would
# rebuild every dependency on every run. Generated by make_deps_tar.sh.
- type: file
path: deps.tar
# ---------------------------------------------------------------
# Pre-downloaded dependency archives

View File

@@ -0,0 +1,55 @@
#!/bin/bash
# Pack deps/ into scripts/flatpak/deps.tar for the Flatpak manifest's orca_deps
# module.
#
# Usage: make_deps_tar.sh
# Requires GNU tar. On macOS, brew install gnu-tar.
#
# The archive is byte-reproducible. Member order, mtimes, ownership and the
# group/other write bits are pinned, so identical deps/ contents always produce
# an identical file. deps/build* and deps/DL_CACHE are excluded.
#
# Prints the output path, size and sha256.
set -euo pipefail
if [ "$#" -ne 0 ]; then
echo "usage: ${0##*/}" >&2
exit 2
fi
tar_bin=$(command -v gtar || command -v tar || true)
tar_version=$([ -n "$tar_bin" ] && "$tar_bin" --version 2>/dev/null || true)
case $tar_version in
*"GNU tar"*) ;;
*) echo "${0##*/}: needs GNU tar; on macOS run 'brew install gnu-tar'" >&2
exit 2 ;;
esac
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
repo_root=$(cd "$script_dir/../.." && pwd)
out=$script_dir/deps.tar
tmp=$out.tmp
trap 'rm -f "$tmp"' EXIT
"$tar_bin" --format=gnu \
--sort=name \
--mtime=@0 \
--owner=0 --group=0 --numeric-owner \
--mode=go-w \
--exclude='deps/build*' \
--exclude='deps/DL_CACHE' \
-cf "$tmp" \
-C "$repo_root" deps
mv -f "$tmp" "$out"
if command -v sha256sum >/dev/null 2>&1; then
sum=$(sha256sum "$out" | cut -d' ' -f1)
elif command -v shasum >/dev/null 2>&1; then
sum=$(shasum -a 256 "$out" | cut -d' ' -f1)
else
sum=unavailable
fi
echo "Wrote $out ($(du -h "$out" | cut -f1), sha256 $sum)"

View File

@@ -8,8 +8,9 @@ flatpak install flathub org.gnome.Platform//50 org.gnome.Sdk//50 org.freedesktop
##
# in OrcaSlicer folder, run following command to build Orca
# # First time build
# flatpak-builder --state-dir=.flatpak-builder --keep-build-dirs --user --force-clean build-dir scripts/flatpak/com.orcaslicer.OrcaSlicer.yml
# # Subsequent builds (only rebuilding OrcaSlicer)
# # First time build
# ./scripts/flatpak/make_deps_tar.sh && flatpak-builder --state-dir=.flatpak-builder --keep-build-dirs --user --force-clean build-dir scripts/flatpak/com.orcaslicer.OrcaSlicer.yml
# # Subsequent builds (only rebuilding OrcaSlicer; run make_deps_tar.sh first if deps/ changed)
# flatpak-builder --state-dir=.flatpak-builder --keep-build-dirs --user build-dir scripts/flatpak/com.orcaslicer.OrcaSlicer.yml --build-only=OrcaSlicer