forked from premake/premake-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgmakelegacy_utility.lua
67 lines (54 loc) · 1.41 KB
/
gmakelegacy_utility.lua
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
--
-- make_utility.lua
-- Generate a C/C++ project makefile.
-- Copyright (c) 2002-2014 Jess Perkins and the Premake project
--
local p = premake
p.makelegacy.utility = {}
local make = p.makelegacy
local utility = p.makelegacy.utility
local project = p.project
local config = p.config
local fileconfig = p.fileconfig
---
-- Add namespace for element definition lists for p.callarray()
---
utility.elements = {}
--
-- Generate a GNU make utility project makefile.
--
utility.elements.makefile = {
"header",
"phonyRules",
"utilityConfigs",
"utilityTargetRules"
}
function make.utility.generate(prj)
p.eol("\n")
p.callarray(make, utility.elements.makefile, prj)
end
utility.elements.configuration = {
"target",
"preBuildCmds",
"postBuildCmds",
}
function make.utilityConfigs(prj)
for cfg in project.eachconfig(prj) do
-- identify the toolset used by this configurations (would be nicer if
-- this were computed and stored with the configuration up front)
local toolset, version = p.tools.canonical(cfg.toolset or p.GCC)
if not toolset then
error("Invalid toolset '" .. cfg.toolset .. "'")
end
_x('ifeq ($(config),%s)', cfg.shortname)
p.callarray(make, utility.elements.configuration, cfg, toolset)
_p('endif')
_p('')
end
end
function make.utilityTargetRules(prj)
_p('$(TARGET):')
_p('\t$(PREBUILDCMDS)')
_p('\t$(POSTBUILDCMDS)')
_p('')
end