rename: src/Formats -> src/Rosetta, @formats -> @rosetta requires, build/luajit/rosetta + rosetta._compat, build/roblox/Rosetta, ROSETTA_* env/globals, writer vendor strings

This commit is contained in:
4DBug committed 2026-11-01 01:19:16 -05:00
1 parent 2956576d7f
commit 22ddcd78fa
941 files changed
+3364 -3364

No files matched your search

+15 -15
View File
@@ -2,9 +2,9 @@
# The structural lint rules (python3 -I tools/lint_rules.py), run by tools/lint.sh. Prints one line per violation and
# exits 1 if there is any. The rules (docs/STYLE.md explains each):
# HEADER every src module starts with --!strict (then optional --!native / --!optimize N) and a comment line
# "-- <module path>: ..." (core/Bytes, image/png, image/png/Decode, Formats for the root, ...); every test
# "-- <module path>: ..." (core/Bytes, image/png, image/png/Decode, Rosetta for the root, ...); every test
# starts with a comment.
# REQUIRE requires are string literals "@formats/<path>" (tests / tools may also use "@tests/<path>") naming an
# REQUIRE requires are string literals "@rosetta/<path>" (tests / tools may also use "@tests/<path>") naming an
# existing module; no script / @self / relative requires in src.
# NATIVE native code never throws: a --!native module has no error( / assert( and requires no module that has
# one; an @native function body has no error( / assert(. A format's init.luau is never --!native.
@@ -26,7 +26,7 @@
import os, re, sys
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SRC = os.path.join(ROOT, "src", "Formats")
SRC = os.path.join(ROOT, "src", "Rosetta")
CATEGORIES = ["image", "audio", "video", "model", "cad", "font", "archive", "data", "vector", "layered", "subtitle",
"music", "playlist"]
SECTIONS = ["requires", "contract", "types", "constants", "sniff", "decode", "encode", "open", "extras"]
@@ -47,7 +47,7 @@ def code(line):
def modpath(path):
"""src/Formats/image/png/init.luau -> image/png; src/Formats/init.luau -> '' (the root)"""
"""src/Rosetta/image/png/init.luau -> image/png; src/Rosetta/init.luau -> '' (the root)"""
rel = os.path.relpath(path, SRC)[:-5].replace(os.sep, "/")
if rel == "init":
return ""
@@ -110,13 +110,13 @@ for f, lines in text.items():
for i, l in enumerate(lines, 1):
for m in REQ.finditer(code(l)):
arg = m.group(1).strip()
mm = re.fullmatch(r'"@formats(?:/([\w/]+))?"', arg)
mm = re.fullmatch(r'"@rosetta(?:/([\w/]+))?"', arg)
if not mm:
bad(f, i, "REQUIRE: requires in src must be require(\"@formats/<path>\"), got require(%s)" % arg)
bad(f, i, "REQUIRE: requires in src must be require(\"@rosetta/<path>\"), got require(%s)" % arg)
continue
target = mm.group(1) or ""
if not resolve(target):
bad(f, i, "REQUIRE: no module @formats/%s" % target)
bad(f, i, "REQUIRE: no module @rosetta/%s" % target)
continue
reqs.append((i, target))
requires[f] = reqs
@@ -130,7 +130,7 @@ for f, lines in text.items():
if not re.fullmatch(r"--!(strict|native|optimize [012])", lines[i].strip()):
bad(f, i + 1, "HEADER: unknown directive " + lines[i])
i += 1
want = mods[f] or "Formats"
want = mods[f] or "Rosetta"
if i >= len(lines) or not lines[i].startswith("-- %s:" % want):
bad(f, i + 1, "HEADER: the first comment line must start with \"-- %s:\"" % want)
@@ -146,8 +146,8 @@ for d, _, fs in os.walk(TESTS):
bad(p, 1, "HEADER: a test starts with a comment saying what it covers")
for i, l in enumerate(open(p).read().split("\n"), 1):
for m in REQ.finditer(code(l)):
if not re.fullmatch(r'"@(formats|tests)(/[\w/]+)?"', m.group(1).strip()):
bad(p, i, "REQUIRE: tests require \"@formats/...\" or \"@tests/...\"")
if not re.fullmatch(r'"@(rosetta|tests)(/[\w/]+)?"', m.group(1).strip()):
bad(p, i, "REQUIRE: tests require \"@rosetta/...\" or \"@tests/...\"")
# ---------------------------------------------------------------------------------------------------- NATIVE
throwing = {mods[f] for f, lines in text.items() if any(THROW.search(code(l)) for l in lines)}
@@ -201,7 +201,7 @@ for f in files:
"codecs/ or containers/" % (mine, theirs))
continue
if tgroup not in ALLOWED[group]:
bad(f, i, "LAYERS: %s (%s) may not require %s (%s)" % (mod or "Formats", group, target, tgroup))
bad(f, i, "LAYERS: %s (%s) may not require %s (%s)" % (mod or "Rosetta", group, target, tgroup))
CODEC_DOMAINS = {"compress", "entropy", "image", "audio", "video", "text", "font", "model"}
for f in files:
@@ -319,7 +319,7 @@ for key, where in bodies.items():
# ---------------------------------------------------------------------------------------------------- DOCS
def module_names(rel):
"""the module names directly under src/Formats/<rel>: Foo.luau and Foo/ (a folder module)"""
"""the module names directly under src/Rosetta/<rel>: Foo.luau and Foo/ (a folder module)"""
d = os.path.join(SRC, rel)
names = set()
for n in os.listdir(d):
@@ -331,10 +331,10 @@ def module_names(rel):
def layout_block(path):
"""(first line, text) of the first fenced block of a markdown file that starts with src/Formats/"""
"""(first line, text) of the first fenced block of a markdown file that starts with src/Rosetta/"""
lines = open(path, encoding="utf-8").read().split("\n")
for i, line in enumerate(lines):
if line.startswith("```") and i + 1 < len(lines) and lines[i + 1].startswith("src/Formats/"):
if line.startswith("```") and i + 1 < len(lines) and lines[i + 1].startswith("src/Rosetta/"):
j = i + 1
while j < len(lines) and not lines[j].startswith("```"):
j += 1
@@ -351,7 +351,7 @@ for doc in ("README.md", os.path.join("docs", "STYLE.md")):
path = os.path.join(ROOT, doc)
ln, block = layout_block(path)
if not block:
bad(path, 1, "DOCS: no layout block (a ``` block starting with src/Formats/)")
bad(path, 1, "DOCS: no layout block (a ``` block starting with src/Rosetta/)")
continue
for m in modules:
if not re.search(r"(?<![\w/])" + re.escape(m.rsplit("/", 1)[1]) + r"\b", block):