src/Formats/init.luau: withHooks adds opts.decodeModule (F.load of the bytes as music) next to decodeImage / openAudio, so a format never requires another; docs/API.md lists it. Backward compatible (a new optional hook).
35 lines
1.6 KiB
Python
35 lines
1.6 KiB
Python
# UMX fixtures (tools/fixtures.py): Unreal music packages wrapping generated modules (an S3M from tools/fixtures/s3m.py,
|
|
# an IT from tools/fixtures/it.py), rendered by openmpt123 (which unwraps the package itself).
|
|
# tests/gen/umx_cases.luau { name, data (the package), inner (the embedded module), format (its format), ref
|
|
# (features of openmpt's render, tools/fixtures/_tracker.py), duration }
|
|
import importlib.util, os, sys
|
|
|
|
# the shared tracker module, loaded by path (tools/fixtures/ must not go on sys.path: xml.py there would shadow xml)
|
|
T = sys.modules.get("_tracker")
|
|
if T is None:
|
|
_spec = importlib.util.spec_from_file_location("_tracker", os.path.join(os.path.dirname(os.path.abspath(__file__)), "_tracker.py"))
|
|
T = importlib.util.module_from_spec(_spec)
|
|
sys.modules["_tracker"] = T
|
|
_spec.loader.exec_module(T)
|
|
|
|
INPUTS = ["tools/fixtures/_tracker.py", "tools/fixtures/s3m.py", "tools/fixtures/it.py"]
|
|
|
|
|
|
def sibling(name):
|
|
spec = importlib.util.spec_from_file_location("umx_" + name, os.path.join(os.path.dirname(os.path.abspath(__file__)), name + ".py"))
|
|
m = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(m)
|
|
return m
|
|
|
|
|
|
def generate(ctx):
|
|
s3m = sibling("s3m").song_mono()
|
|
it = sibling("it").song_effects()
|
|
cases = []
|
|
items = [("s3m", "Mono_Theme", s3m, 69), ("it", "Effects", it, 63)]
|
|
for fmt, nm, data, ver in items:
|
|
pkg = T.write_umx([(nm, data)], version=ver)
|
|
ref = T.reference(ctx, pkg, "umx")
|
|
cases.append({"name": nm, "data": pkg, "inner": data, "format": fmt, "ref": ref, "duration": ref["duration"]})
|
|
ctx.emit("umx_cases", cases)
|