- assets/audio/music/zombie_industrial_loop.ogg: 57.60 s Ogg Vorbis loop generated locally with YuE2-3B on the Tesla V100 (score written for this track; vocals removed with HTDemucs). The loop is spliced at the track's structural repeat with a 0.6 s crossfade: measured seam dip <= 1.6 dB. - scripts/main.gd: "Music" AudioStreamPlayer at -11 dB, started at boot on desktop and on the start click on Web (browser autoplay policy). It forces stream.loop at runtime because the Web staging step re-imports the OGG with loop=false. - tools/test_music.gd: soundtrack test (loop, length, volume, playback, still playing after player death). - docs/MUSIC.md: source, loop construction, verification, licence. - docs/WEB-DEPLOY.md: release ab6054111f5919a8 notes. Initial commit of the project.
34 lines
1.6 KiB
Python
34 lines
1.6 KiB
Python
"""Immutable content-addressed Web releases with offline gzip compression."""
|
|
from pathlib import Path
|
|
import hashlib, gzip, json, shutil, os
|
|
root=Path(__file__).resolve().parents[1]
|
|
source=root/'build/web'
|
|
output=root/'build/web-deploy'
|
|
files=sorted(p for p in source.iterdir() if p.is_file() and not p.name.endswith(('.gz','.br')))
|
|
identity=hashlib.sha256()
|
|
for p in files:
|
|
identity.update(p.name.encode()+b'\0'+p.read_bytes())
|
|
version=identity.hexdigest()[:16]
|
|
if output.exists(): shutil.rmtree(output)
|
|
release=output/'releases'/version
|
|
release.mkdir(parents=True)
|
|
report=[]
|
|
for p in files:
|
|
destination=release/p.name
|
|
shutil.copyfile(p,destination)
|
|
raw=p.read_bytes()
|
|
if p.suffix in ['.wasm','.pck','.js','.html']:
|
|
compressed=gzip.compress(raw,compresslevel=9,mtime=0)
|
|
assert gzip.decompress(compressed)==raw
|
|
z=destination.with_name(destination.name+'.gz')
|
|
z.write_bytes(compressed)
|
|
os.utime(z,(destination.stat().st_mtime,destination.stat().st_mtime))
|
|
report.append({'file':p.name,'original':len(raw),'gzip':len(compressed),'sha256':hashlib.sha256(raw).hexdigest()})
|
|
html=(source/'index.html').read_text()
|
|
html=html.replace('<head>','<head>\n\t\t<base href="/pub/zombie-fps/releases/'+version+'/">',1)
|
|
(output/'index.html').write_text(html)
|
|
(root/'build/web-compression-report.json').write_text(json.dumps({'version':version,'files':report},indent=2)+'\n')
|
|
print('Release:',version)
|
|
for r in report: print(r['file'],r['original'],'->',r['gzip'])
|
|
print('Total:',sum(r['original'] for r in report),'->',sum(r['gzip'] for r in report))
|