Repository navigation
Expand file tree
/
Copy path.make.lua
More file actions
135 lines (108 loc) · 5.69 KB
/
Copy path.make.lua
File metadata and controls
135 lines (108 loc) · 5.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
-- tagdata's build, as recipes. This replaced the Makefile; there is no other.
--
-- make the recipes, with what each of them says it does
-- make build the library
-- make test the suite
-- make verify the whole local gate
--
-- At an oslo prompt in this directory `make` is enough; everywhere else it is `oslo make`.
-- The dev shell's toolchain comes from `.env.lua`'s `nix_develop()`, so recipes call `cargo`
-- directly rather than wrapping every command in `nix develop -c`.
local make = oslo.make
local function need(tool, why)
assert(oslo.run{ "sh", "-c", "command -v " .. tool, capture = true }.ok, why)
end
make.recipe{ name = "build", desc = "the library",
run = function() sh.cargo("build", "--lib") end }
make.alias("b", "build")
make.recipe{ name = "compile", desc = "clean, then build", deps = { "clean", "build" } }
make.alias("c", "compile")
make.recipe{
name = "run",
desc = "run a development example",
params = { { "--example", desc = "which example to run", default = "main" } },
run = function(a) sh.cargo("run", "--example", a.example or "main") end,
}
make.alias("r", "run")
make.recipe{ name = "benchmark", desc = "the release-mode smoke benchmark",
run = function() sh.cargo("run", "--release", "--example", "benchmark") end }
make.recipe{ name = "benchmark-compare", desc = "compare tagdata with jammdb 0.11.0",
run = function() sh.cargo("run", "--release", "--example", "benchmark_jammdb") end }
make.recipe{ name = "benchmark-memory", desc = "measure reopen and write-transaction heap allocations",
run = function() sh.cargo("run", "--release", "--example", "benchmark_memory") end }
make.recipe{ name = "benchmark-merge", desc = "merge two 500k-entry random KV databases",
run = function() sh.cargo("run", "--release", "--example", "benchmark_merge") end }
make.recipe{ name = "benchmark-typed", desc = "compare direct typed scans with the previous lookup path",
run = function() sh.cargo("run", "--release", "--features", "typed", "--example", "benchmark_typed_reads") end }
make.recipe{ name = "benchmark-write-verification", desc = "compare write-safety policies",
run = function() sh.cargo("run", "--release", "--example", "benchmark_write_verification") end }
make.recipe{ name = "fixtures", desc = "regenerate the frozen current-format fixture",
run = function() sh.cargo("run", "--example", "fixture_gen") end }
make.recipe{ name = "operator", desc = "build the release-mode operator CLI",
run = function() sh.cargo("build", "--release", "--features", "operator", "--bin", "tagdata") end }
make.recipe{ name = "operator-size", desc = "build the size-optimized operator CLI",
run = function() sh.cargo("build", "--profile", "size", "--features", "operator", "--bin", "tagdata") end }
make.recipe{ name = "package", desc = "verify and package the locked crate",
run = function() sh.cargo("package", "--locked") end }
make.recipe{ name = "test", desc = "run all tests",
run = function() sh.cargo("test", "--all-targets") end }
make.alias("t", "test")
make.recipe{ name = "check", desc = "cargo check on all targets",
run = function() sh.cargo("check", "--all-targets") end }
make.recipe{ name = "check-all", desc = "cargo check on all targets/all features",
run = function() sh.cargo("check", "--all-targets", "--all-features") end }
make.recipe{ name = "fmt", desc = "format the workspace",
run = function() sh.cargo("fmt", "--all") end }
make.recipe{ name = "fmt-check", desc = "check formatting",
run = function() sh.cargo("fmt", "--all", "--", "--check") end }
make.recipe{ name = "clippy", desc = "clippy with warnings denied",
run = function() sh.cargo("clippy", "--all-targets", "--all-features", "--", "-D", "warnings") end }
make.recipe{
name = "rustdoc",
desc = "build docs with warnings denied",
run = function()
assert(oslo.run{ "env", "RUSTDOCFLAGS=-Dwarnings", "cargo", "doc", "--all-features", "--no-deps" }.ok,
"rustdoc failed")
end,
}
-- No Rust source or test file over 800 lines — read in groups or not at all.
make.recipe{
name = "loc-check",
desc = "reject Rust source or test files over 800 lines",
run = function()
local failed = {}
for _, dir in ipairs{ "src", "tests", "examples" } do
for path in oslo.fs.walk(dir) do
if path:match("%.rs$") then
local content = oslo.fs.read(path) or ""
local _, lines = content:gsub("\n", "")
if lines > 800 then
failed[#failed + 1] = ("%s has %d lines (maximum 800)"):format(path, lines)
end
end
end
end
for _, message in ipairs(failed) do print("error: " .. message) end
assert(#failed == 0, ("%d file(s) over the line limit"):format(#failed))
end,
}
make.recipe{ name = "test-all", desc = "cargo test on all targets/all features",
run = function() sh.cargo("test", "--all-targets", "--all-features") end }
make.recipe{ name = "clean", desc = "remove Cargo build artifacts",
run = function() sh.cargo("clean") end }
make.recipe{
name = "verify",
desc = "the whole local gate",
deps = { "fmt-check", "loc-check", "check", "test", "check-all", "test-all", "clippy", "rustdoc" },
}
make.recipe{
name = "release",
desc = "cut a version: --type patch | minor | major | M.m.p",
params = { { "--type", desc = "patch | minor | major | M.m.p" } },
run = function(a)
need("git-rel", "git-rel is not installed; install it first")
assert(type(a.type) == "string",
"which release? make release --type patch|minor|major|M.m.p")
sh.git("rel", a.type)
end,
}