root: Video, AudioWrap, Rbx, ImageOps required on first use (F.Rbx, F.video.codecs through __index); chunked build: one chunk per unit (format folder, codec, container), small family neighbours packed to 32 KB; Sniffs copies typed as in their module

This commit is contained in:
4DBug committed 2026-11-03 01:24:44 -06:00
1 parent 3468bfb49a
commit 5b2605f514
10 files changed
+7577 -5774

No files matched your search

+24 -6
View File
@@ -249,12 +249,15 @@ def bundle_roblox():
# module with no entry yet requires its chunk (require(script:FindFirstChild(name)); under the luau CLI, with no
# `script`, require("@self/" .. name) over the same files in build/_modules/chunked/Rosetta). So requiring the root
# loads Core (what the root runs at load time) and every other chunk on first use, per Actor.
# Chunks: Core; Detect (DETECT: what F.detect runs, apart from Core); one per hot codec (HOT); the rest packed per family
# (top folder, or codecs/<category>) in path order.
# Chunks: Core; Detect (DETECT: what F.detect runs, apart from Core); one per hot codec (HOT); then one per unit (a
# format folder, a codec or container with its submodules), small neighbours of a family (top folder, or
# codecs/<category>) packed up to UNIT_PACK bytes; a chunk is named after its first unit (image_png, containers_Riff).
# So opening a format compiles its own modules and what they use, not its family.
# A --!native module's functions get @native (a chunk can mix native and non-native modules); a chunk with no native
# module has none. Outputs: build/Rosetta.rbxm (LZ4, written by model/rbxm under the luau CLI), build/Rosetta.rbxmx,
# build/Rosetta.rbxm.linemap.json ({chunk: [[first line, source file], ...]}).
CHUNK_SRC_MAX = 256 * 1024
UNIT_PACK = 32 * 1024
CHUNK_IR_MAX = 1 << 18
CHUNK_ASM_MAX = 4 << 20
CHUNKED = os.path.join(MODULES, "chunked", "Rosetta")
@@ -305,6 +308,13 @@ def eager(src):
return {m.group(1) for line in src.split("\n") if line[:1] not in ("\t", " ") for m in INCLUDES.finditer(line)}
def unit(key):
"""what one format or shared module brings: its folder (image/png, containers/IsoBmff, codecs/text/Text), or the
module itself at the top level"""
parts = key.split("/")
return "/".join(parts[:3] if parts[0] == "codecs" else parts[:2])
def plan_chunks(mods):
"""[(chunk name, [module keys])], deterministic: Core, HOT, then the rest packed per family"""
left = dict(mods)
@@ -345,11 +355,19 @@ def plan_chunks(mods):
if not keys:
sys.exit("bundle: HOT chunk %s matches no module" % name)
pack(name, keys)
fams = {}
units = {}
for k in left:
fams.setdefault(family(k), []).append(k)
for f in sorted(fams):
pack(f, fams[f])
units.setdefault(unit(k), []).append(k)
run, size = [], 0
for u in sorted(units, key=lambda u: (family(u), u)):
sz = sum(len(mods[k][0]) for k in units[u])
if run and (family(run[0]) != family(u) or size + sz > UNIT_PACK):
pack(run[0].replace("/", "_"), [k for x in run for k in units[x]])
run, size = [], 0
run.append(u)
size += sz
if run:
pack(run[0].replace("/", "_"), [k for x in run for k in units[x]])
return chunks