mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-27 09:17:39 +00:00
crates/engine keeps the package photocraft-engine: src/facade.rs re-exports photocraft-engine-core, and its Session wraps core's and installs every engine command. Core's Session::new() installs nothing; core gets install() and session(). The command registry keeps main's behaviour (empty before an install). The top crate's dev-dependencies cover tests/ and examples/, including craft-develop-model (camera raw baseline test) and photocraft-testkit (the corpus-gated Photoshop oracle test). Dependents that need the core type or borrowed two fields through the wrapper are fixed at the call site, and tests that reach the registry before any session install first. Tooling follows the package: workspace dependency, cl selection, xtask layers, i18n report, scorecard and corpus paths, nextest overrides, ci-test-times rows, display-names roots, prefs_usage paths, the engine split scripts, docs, and the two release-perf steps in ci.yml. Corpus .atn paths, the layer_menu registry read and the craft-develop-model dev-dependency are FredApps' fixes from #16431. Part of #15710
72 lines
2.6 KiB
Bash
72 lines
2.6 KiB
Bash
# shellcheck shell=bash
|
|
# Shared setup for the packaging scripts. Source it: `. "$(dirname "$0")/../env.sh"`.
|
|
#
|
|
# Exports:
|
|
# ROOT workspace root
|
|
# VERSION [workspace.package] version from Cargo.toml (override: PHOTOCRAFT_VERSION)
|
|
# DIST output directory for release artifacts (default: $ROOT/dist/release)
|
|
# PHOTOCRAFT_BUILD_SHA git commit baked into the binaries (see crates/engine-core/src/build_info.rs)
|
|
# PHOTOCRAFT_BUILD_DATE UTC build date, YYYY-MM-DD
|
|
# CARGO_TARGET_DIR cargo's target dir (default: $ROOT/target)
|
|
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
export ROOT
|
|
|
|
# The version lives in exactly one place: `[workspace.package] version` in the root Cargo.toml.
|
|
# (`cargo xtask version` prints the same thing; awk avoids compiling xtask here.)
|
|
workspace_version() {
|
|
awk '
|
|
/^\[/ { in_pkg = ($0 == "[workspace.package]") ; next }
|
|
in_pkg && $1 == "version" { gsub(/[" ]/, "", $3); print $3; exit }
|
|
' "$ROOT/Cargo.toml"
|
|
}
|
|
|
|
VERSION="${PHOTOCRAFT_VERSION:-$(workspace_version)}"
|
|
if [[ -z "$VERSION" ]]; then
|
|
echo "error: could not read [workspace.package] version from $ROOT/Cargo.toml" >&2
|
|
exit 1
|
|
fi
|
|
export VERSION
|
|
|
|
DIST="${DIST:-$ROOT/dist/release}"
|
|
mkdir -p "$DIST"
|
|
export DIST
|
|
|
|
if [[ -z "${PHOTOCRAFT_BUILD_SHA:-}" ]]; then
|
|
PHOTOCRAFT_BUILD_SHA="$(git -C "$ROOT" rev-parse HEAD 2>/dev/null || true)"
|
|
fi
|
|
export PHOTOCRAFT_BUILD_SHA
|
|
export PHOTOCRAFT_BUILD_DATE="${PHOTOCRAFT_BUILD_DATE:-$(date -u +%Y-%m-%d)}"
|
|
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$ROOT/target}"
|
|
|
|
# Emit a GitHub Actions warning (plain stderr outside Actions).
|
|
warn() {
|
|
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then echo "::warning::$*"; else echo "warning: $*" >&2; fi
|
|
}
|
|
|
|
# Copy licence and readme files that exist into a package directory.
|
|
copy_docs() {
|
|
local dest="$1" f
|
|
for f in README.md LICENSE LICENSE-MIT LICENSE-APACHE COPYRIGHT NOTICE ATTRIBUTION.md; do
|
|
if [[ -f "$ROOT/$f" ]]; then cp "$ROOT/$f" "$dest/"; fi
|
|
done
|
|
copy_font_licences "$dest"
|
|
}
|
|
|
|
# Builds made with craft-fonts (CRAFT_FONTS_DIR, all official releases) embed its fonts, which
|
|
# are OFL-1.1: ship each font's licence as OFL-<family-dir>.txt. No-op without CRAFT_FONTS_DIR.
|
|
copy_font_licences() {
|
|
local dest="$1" lic fam
|
|
[[ -n "${CRAFT_FONTS_DIR:-}" ]] || return 0
|
|
for lic in "$CRAFT_FONTS_DIR"/fonts/*/OFL.txt; do
|
|
[[ -f "$lic" ]] || continue
|
|
fam="$(basename "$(dirname "$lic")")"
|
|
cp "$lic" "$dest/OFL-$fam.txt"
|
|
done
|
|
}
|
|
|
|
# Portable SHA-256 of a file (prints just the hash).
|
|
sha256() {
|
|
if command -v sha256sum >/dev/null; then sha256sum "$1" | cut -d' ' -f1; else shasum -a 256 "$1" | cut -d' ' -f1; fi
|
|
}
|