Files
kryon/tests/browser_behavior.py
T
waozi e31434063c Decode WebP images on every host
Lossy, lossless and transparent WebP files, and the first frame of
animated ones, load through the existing image paths: raylib and Android
link Kryon's kryonwebp archive built from the locked libwebp source, the
Cairo desktop host opens the system libwebpdemux, and web hosts use the
browser's decoder. Files are recognized by content, not extension.

Fixtures cover each kind on the raylib, Cairo and browser paths, the
renderer artifact ships libkryonwebp.a, and android-webp-link-test links
the decoder for every Android ABI.
2026-11-01 23:03:37 -03:00

31 lines
1.5 KiB
Python

"""Shared compiler setup for private browser behavior tests."""
import os
from pathlib import Path
import subprocess
from toolchain import BIN, ZIRAN_ROOT as ZIRAN
ROOT = Path(__file__).resolve().parents[1]
EMCC = os.environ.get('EMCC', str(Path.home() / 'emsdk/upstream/emscripten/emcc'))
environment = dict(os.environ)
for name in ('DISPLAY', 'WAYLAND_DISPLAY', 'XAUTHORITY', 'GDK_DISPLAY'):
environment.pop(name, None)
environment.setdefault('EM_CACHE', str(ROOT / 'build/emscripten-cache'))
def run(args, **options):
return subprocess.run(list(map(str, args)), env=environment, check=True, **options)
def build_behavior(work, name, module_paths=()):
generated = work / 'generated'
extra = [argument for path in module_paths for argument in ('--module-path', path)]
run([BIN / 'zi2c', '--no-main', '--define', 'PLATFORM_WEB', '--root', ROOT / 'tests',
'--module-path', ROOT / 'src/backend', '--module-path', ZIRAN / 'std', *extra,
'-o', generated, ROOT / 'tests' / (name + '_browser_behavior.zi')])
shell = work / 'shell.html'
shell.write_text('<!doctype html><html><head><meta charset="utf-8"></head><body>'
'<pre id="result">pending</pre>{{{ SCRIPT }}}</body></html>')
run([EMCC, '-O1', '-I' + str(ZIRAN / 'include'), '-iquote', generated, *sorted(generated.rglob('*.c')),
'--js-library', ZIRAN / 'web/ziran_web.js', '-sASYNCIFY', '-sSINGLE_FILE=1',
'-sENVIRONMENT=web', '--shell-file', shell, '-o', work / 'test.html'])