-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.lua
More file actions
83 lines (57 loc) · 1.9 KB
/
Copy pathproject.lua
File metadata and controls
83 lines (57 loc) · 1.9 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
local enosi = require "enosi"
local proj = enosi.thisProject()
local recipes = require "recipes"
local Driver = require "driver"
local list = require "list"
local mode = enosi.mode
local cwd = lake.cwd()
local builddir = cwd.."/build/"..mode.."/"
lake.mkdir(builddir, {make_parents = true})
proj:setCleaner(function()
lake.rm(builddir, {recursive = true, force = true})
end)
proj:dependsOn "iro"
local exe = lake.target(builddir.."lake")
proj:reportExecutable(exe.path)
local cpp_driver = Driver.Cpp.new()
cpp_driver.include_dirs:push { "src", proj:collectIncludeDirs() }
if mode == "debug" then
cpp_driver.opt = "none"
cpp_driver.debug_info = true
proj:reportDefine { "LAKE_DEBUG", "1" }
else
cpp_driver.opt = "speed"
end
cpp_driver.defines = proj:collectDefines()
lake.find("src/**/*.cpp"):each(function(cfile)
local ofile = builddir..cfile..".o"
local dfile = builddir..cfile..".d"
cfile = cwd.."/"..cfile
cpp_driver.input = cfile
cpp_driver.output = ofile
proj:reportObjFile(ofile)
lake.target(ofile):dependsOn(cfile)
:recipe(recipes.objFile(cpp_driver, proj))
lake.target(dfile):dependsOn(cfile)
:recipe(recipes.depfile(
Driver.Depfile.fromCpp(cpp_driver),
proj, ofile, dfile))
end)
local lua_driver = Driver.LuaObj.new()
lake.find("src/*.lua"):each(function(lfile)
local ofile = builddir..lfile..".o"
lfile = cwd.."/"..lfile
proj:reportObjFile(ofile)
lua_driver.input = lfile
lua_driver.output = ofile
lake.target(ofile):dependsOn { lfile, proj.path }
:recipe(recipes.luaObjFile(lua_driver, proj))
end)
exe:dependsOn(proj:collectObjFiles())
local link_driver = Driver.Linker.new()
link_driver.static_libs = proj:collectStaticLibs()
link_driver.shared_libs = proj:collectSharedLibs()
link_driver.inputs = proj:collectObjFiles()
link_driver.libdirs = proj:collectLibDirs()
link_driver.output = exe.path
exe:recipe(recipes.linker(link_driver, proj))