mirror of
https://github.com/odin-lang/Odin.git
synced 2026-07-17 21:21:04 +00:00
rexcode: wire the ir/ packages into build.lua
build.lua was ISA-centric; add an IRS catalog (ir/<name>) and route it through the gen / check / test tasks. IR packages have a single-stage generator (gen.odin emits Odin directly), a plain odin check, and a tests/ suite -- no mnemonic builders or external-assembler verify, so only those three tasks apply. Purely additive: the ISA catalog, task functions, and verify-tool probing are untouched. luajit build.lua --check --test now reports spirv alongside the ISAs (check ok, test 5 passed).
This commit is contained in:
@@ -135,6 +135,13 @@ local ISAS = {
|
||||
}
|
||||
local ISA_BY_NAME = {}; for _, a in ipairs(ISAS) do ISA_BY_NAME[a.name] = a end
|
||||
|
||||
-- IR packages live under <root>/ir/<name>. Unlike the ISAs they have a single-
|
||||
-- stage generator (gen.odin emits Odin source directly) and no mnemonic builders
|
||||
-- or external-assembler verify -- only gen / check / test apply.
|
||||
local IRS = {
|
||||
{ name="spirv", dir="ir/spirv" },
|
||||
}
|
||||
|
||||
-- ----------------------------------------------------------------------------
|
||||
-- argument parsing
|
||||
-- ----------------------------------------------------------------------------
|
||||
@@ -316,6 +323,27 @@ local function do_idempotent(isa)
|
||||
return false, "changed on re-gen: "..table.concat(changed, ", ")
|
||||
end
|
||||
|
||||
-- IR package tasks (ir/<name>): single-stage gen, plain check, plain test.
|
||||
local function ir_pkg(ir, sub) return ROOT .. "/" .. ir.dir .. (sub and ("/"..sub) or "") end
|
||||
local function do_ir_gen(ir)
|
||||
local ok, out = run(odin_run(ir_pkg(ir, "tablegen")))
|
||||
if not ok then return false, "gen failed:\n"..out:sub(-400) end
|
||||
return true, (out:match("tablegen:%s*(.-)\n") or "generated"):gsub("%s+$","")
|
||||
end
|
||||
local function do_ir_check(ir)
|
||||
local ok, out = run(odin_check(ir_pkg(ir)))
|
||||
if not ok then return false, "odin check failed:\n"..(out:match("(.-Error:.-)\n") or out) end
|
||||
return true, "compile"
|
||||
end
|
||||
local function do_ir_test(ir)
|
||||
local ok, out = run(odin_run(ir_pkg(ir, "tests")))
|
||||
local fails = out:match("([1-9]%d* failed)")
|
||||
if not ok or fails then return false, (fails or "test run failed").."\n"..out:sub(-400) end
|
||||
local n = 0; for p in out:gmatch("(%d+) passed") do n = n + tonumber(p) end
|
||||
return true, (n > 0 and (n.." passed") or "passed")
|
||||
end
|
||||
local IR_TASK_FN = { gen=do_ir_gen, check=do_ir_check, test=do_ir_test }
|
||||
|
||||
local TASK_FN = { gen=do_gen, builders=do_builders, check=do_check, test=do_test, verify=do_verify, idempotent=do_idempotent }
|
||||
local TASK_ORDER = { "gen", "builders", "check", "test", "verify", "idempotent" }
|
||||
local TASK_LABEL = { gen="generate", builders="builders", check="validate", test="test", verify="verify", idempotent="idempotent" }
|
||||
@@ -432,6 +460,17 @@ local function main()
|
||||
else nfail = nfail + 1; print(red("FAIL") .. " " .. (detail or ""):gsub("\n", "\n ")) end
|
||||
end
|
||||
end
|
||||
for _, ir in ipairs(IRS) do
|
||||
local fn = IR_TASK_FN[task]
|
||||
if fn then
|
||||
results[ir.name] = results[ir.name] or {}
|
||||
io.write((" %-10s %-11s "):format(ir.name, task)); io.flush()
|
||||
local ok, detail = fn(ir)
|
||||
results[ir.name][task] = ok and "ok" or "fail"
|
||||
if ok then print(green("ok") .. " " .. dim(detail or ""))
|
||||
else nfail = nfail + 1; print(red("FAIL") .. " " .. (detail or ""):gsub("\n", "\n ")) end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- summary matrix
|
||||
@@ -449,6 +488,15 @@ local function main()
|
||||
end
|
||||
print()
|
||||
end
|
||||
for _, ir in ipairs(IRS) do
|
||||
io.write((" %-10s"):format(ir.name))
|
||||
for _, t in ipairs(tasks) do
|
||||
local s = (results[ir.name] or {})[t] or "--"
|
||||
local c = (s == "ok" and green("ok")) or (s == "fail" and red("FAIL")) or (s == "skip" and yellow("skip")) or dim("--")
|
||||
io.write(c .. string.rep(" ", math.max(2, 12 - #s)))
|
||||
end
|
||||
print()
|
||||
end
|
||||
print()
|
||||
if nfail == 0 then
|
||||
print(green(bold("PASS")) .. (" (%d skipped)"):format(nskip))
|
||||
|
||||
Reference in New Issue
Block a user