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
|
-- define rule: markdown
rule("markdown")
set_extensions(".md", ".markdown")
on_build(function (target, sourcefile)
os.cp(sourcefile, path.join(target:targetdir(), path.basename(sourcefile) .. ".html"))
end)
-- define rule: man
rule("man")
add_imports("core.project.rule")
on_build_all(function (target, sourcefiles)
for _, sourcefile in ipairs(sourcefiles) do
print("generating man: %s", sourcefile)
end
rule.build("markdown", target, sourcefiles)
end)
-- define rule: c code
rule("c code")
add_imports("core.tool.compiler")
on_build(function (target, sourcefile)
local objectfile_o = os.tmpfile() .. ".o"
local sourcefile_c = os.tmpfile() .. ".c"
os.cp(sourcefile, sourcefile_c)
compiler.compile(sourcefile_c, objectfile_o)
table.insert(target:objectfiles(), objectfile_o)
end)
-- define rule: stub
rule("stub")
on_build(function (target, sourcefile)
print("on_build: %s", sourcefile)
end)
on_clean(function (target, sourcefile)
print("on_clean: %s", sourcefile)
end)
on_install(function (target, sourcefile)
print("on_install: %s", sourcefile)
end)
on_uninstall(function (target, sourcefile)
print("on_uninstall: %s", sourcefile)
end)
on_package(function (target, sourcefile)
print("on_package: %s", sourcefile)
end)
-- define target
target("test")
-- set kind
set_kind("binary")
-- add rules
add_rules("markdown")
-- add files
add_files("src/*.c")
add_files("src/man/*.in", {rule = "man"})
add_files("src/index.md")
add_files("src/test.c.in", {rule = "c code"})
add_files("src/empty.stub", {rule = "stub"})
|