Keep native widget composition package-private while preserving typed TSX, native policy and custom drawing. Repair hybrid portable app context ownership, unpublished bitmap rollback, browser line rendering and font storage, and current real-browser fixtures. Record the complete local project-test, push-check and test run, all 180 behavior fixtures and 31 laws, and newly verified consumer migrations. The full breaking migration remains Unreleased.
33 lines
1.6 KiB
Python
33 lines
1.6 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', '--target-os', 'web', '--target-cpu', 'wasm32',
|
|
'--define', 'PLATFORM_WEB', '--root', ROOT / 'tests',
|
|
'--module-path', ROOT / 'src/backend', '--module-path', ROOT / 'src/ui',
|
|
'--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'])
|