-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cargo.knit
44 lines (39 loc) · 947 Bytes
/
Cargo.knit
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
function genSrc(files)
local result = ""
local mods = {}
for _, file in ipairs(files) do
local skip = false; for _, mod in ipairs(mods) do
if file:match(mod) then skip = true end
end
if not skip then
local name = file:gsub("%.rs", ""):gsub("/", "-")
if base(file) == "mod.rs" then
name = name:gsub("-mod", "")
table.insert(mods, dir(file))
end
result = result .. f([=[
[[example]]
name = "$name"
path = "$file"
crate-type = ["lib"]
]=])
end
end
return result
end
return function(files)
local toml = f[[
[package]
name = "nusa"
version = "0.0.1-Jan.2023"
edition = "2021"
[profile.release]
lto = true
strip = true
[workspace]
members = ["libs/rust", "examples/rust/*/*"]
$(genSrc(files))
]]
local formatted = toml:gsub("(\n+)%s+", "%1"):gsub("^%s*(.-)%s*$", "%1")
return formatted
end