mirror of
https://github.com/Nexoniarz/YAPF.git
synced 2026-11-02 20:44:27 +00:00
Format (version 1, replaces the earlier experimental versions): - per-tile YCoCg-R or subtract-green colour transform, 8-bit modular - 12 row filters per 8-row band (Left, Gradient, Up-right, Up-average, Up 1-8 rows), none with more than a one-add serial dependency - residuals in groups of 8 at the group's width (w bits x 8 = w bytes), 4-bit control codes with repeat-previous-width runs chosen by DP - constant and stored tiles, independent 64x64 tiles, mips, GPU hints - all sizes validated before decoding; corrupt input is rejected Library: - SIMD on by default: SSSE3 (runtime CPUID check; GCC, Clang, MSVC, MinGW) and NEON on ARM64; -DYAPF_NO_SIMD for plain C - yapf_load_memory, yapf_load_mt, yapf_load_memory_mt - 6-10x faster decoding than PNG (stb_image) on one core; -O2 and -O3 builds perform the same - fixes for macOS (sysconf) and the Windows import library exports Tools and integrations: - `yapf` CLI: convert PNG/JPG/TGA/BMP/PSD/GIF <-> YAPF, info, bench, thumbnail, mips - JavaScript and Python bindings (byte-identical to the C encoder) - GIMP 3 plugin: exports the flattened image, optional mipmaps - Blender extension: import (also as plane), export, drag and drop - VS Code preview, Figma plugin, Photoshop scripts, Linux MIME type and thumbnailer - Makefile, updated build.sh / build.bat, tools/build_release.sh - tests/test_yapf.c (784 checks) and bindings/js/test.js Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
58 lines
2.7 KiB
Shell
Executable file
58 lines
2.7 KiB
Shell
Executable file
#!/usr/bin/env bash
|
|
# Builds every release download into dist/release/ — for maintainers.
|
|
#
|
|
# tools/build_release.sh
|
|
#
|
|
# Needs: zig (cross-compiles all six platforms from one machine), python3,
|
|
# and node + npx for the VS Code package. Outputs:
|
|
# yapf-<platform>.zip command-line tool + shared/static library + header
|
|
# yapf_image-blender.zip Blender extension with libraries for all platforms
|
|
# yapf-preview.vsix VS Code extension
|
|
# yapf-figma.zip Figma plugin (import via manifest.json)
|
|
# yapf-photoshop.zip Photoshop scripts
|
|
# yapf-gimp-source.zip GIMP plugin source (build with gimptool)
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
OUT=dist/release
|
|
LIBS=dist/libs
|
|
rm -rf "$OUT" "$LIBS"
|
|
mkdir -p "$OUT" "$LIBS"
|
|
|
|
command -v zig >/dev/null || { echo "zig not found: https://ziglang.org/download/" >&2; exit 1; }
|
|
export ZIG_GLOBAL_CACHE_DIR=${ZIG_GLOBAL_CACHE_DIR:-$PWD/dist/.zig-cache}
|
|
|
|
# zig target folder library tool
|
|
targets="x86_64-linux-gnu.2.17 linux-x64 libyapf.so yapf
|
|
aarch64-linux-gnu.2.17 linux-arm64 libyapf.so yapf
|
|
x86_64-windows-gnu windows-x64 yapf.dll yapf.exe
|
|
aarch64-windows-gnu windows-arm64 yapf.dll yapf.exe
|
|
x86_64-macos macos-x64 libyapf.dylib yapf
|
|
aarch64-macos macos-arm64 libyapf.dylib yapf"
|
|
|
|
echo "$targets" | while read -r tgt dir lib tool; do
|
|
pkg=dist/pkg/yapf-$dir
|
|
rm -rf "$pkg" && mkdir -p "$pkg" "$LIBS/$dir"
|
|
zig cc -target "$tgt" -O2 -std=c99 -shared -fPIC -s yapf.c -o "$LIBS/$dir/$lib"
|
|
zig cc -target "$tgt" -O2 -std=c99 -s tools/yapf_cli.c yapf.c -o "$pkg/$tool" -lm
|
|
zig cc -target "$tgt" -O2 -std=c99 -c yapf.c -o "$pkg/yapf.o"
|
|
zig ar rcs "$pkg/libyapf.a" "$pkg/yapf.o" && rm "$pkg/yapf.o"
|
|
cp "$LIBS/$dir/$lib" yapf.h LICENSE "$pkg/"
|
|
rm -f "$pkg"/*.lib "$pkg"/*.pdb "$LIBS/$dir"/*.lib "$LIBS/$dir"/*.pdb
|
|
(cd dist/pkg && python3 -m zipfile -c "../../$OUT/yapf-$dir.zip" "yapf-$dir")
|
|
echo "built yapf-$dir.zip"
|
|
done
|
|
|
|
python3 extensions/blender/build.py "$LIBS"
|
|
mv dist/yapf_image-blender.zip "$OUT/"
|
|
|
|
if command -v npx >/dev/null; then
|
|
(cd extensions/vscode && npm run --silent package && mv yapf-preview-*.vsix "../../$OUT/yapf-preview.vsix")
|
|
else
|
|
echo "node/npx not found: skipped the VS Code package" >&2
|
|
fi
|
|
|
|
(cd extensions/figma && node build.js 2>/dev/null || true)
|
|
python3 -m zipfile -c "$OUT/yapf-figma.zip" extensions/figma/manifest.json extensions/figma/code.js extensions/figma/ui.html
|
|
python3 -m zipfile -c "$OUT/yapf-photoshop.zip" extensions/photoshop
|
|
python3 -m zipfile -c "$OUT/yapf-gimp-source.zip" extensions/gimp yapf.c yapf.h
|
|
ls -la "$OUT"
|