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
|
--
-- premake.lua
-- Main (top level) application logic for Premake.
-- Copyright (c) 2002-2008 Jason Perkins and the Premake project
--
--
-- Check the specified tools (/cc, /csc, etc.) against the current action
-- to make sure they are compatible and supported.
--
function premake.checktools()
local action = premake.actions[_ACTION]
if (not action.valid_tools) then
return true
end
for tool, values in pairs(action.valid_tools) do
if (_OPTIONS[tool]) then
if (not table.contains(values, _OPTIONS[tool])) then
return nil, "the " .. action.shortname .. " action does not support /" .. tool .. "=" .. _OPTIONS[tool]
end
else
_OPTIONS[tool] = values[1]
end
end
return true
end
--
-- Check to see if the value exists in a list of values, using a
-- case-insensitive match. If the value does exist, the canonical
-- version contained in the list is returned, so future tests can
-- use case-sensitive comparisions.
--
function premake.checkvalue(value, allowed)
if (allowed) then
for _,v in ipairs(allowed) do
if (value:lower() == v:lower()) then
return v
end
end
else
return value
end
end
--
-- Fire a particular action. Generates the output files from the templates
-- listed in the action descriptor, and calls any registered handler functions.
--
function premake.doaction(name)
local action = premake.actions[name]
-- walk the session objects and generate files from the templates
local function generatefiles(this, templates)
if (templates) then
for _,tmpl in ipairs(templates) do
local fname = premake.getoutputname(this, tmpl[1])
premake.template.generate(tmpl[2], fname, this)
end
end
end
for _,sln in ipairs(_SOLUTIONS) do
generatefiles(sln, action.solutiontemplates)
for prj in premake.project.projects(sln) do
generatefiles(prj, action.projecttemplates)
end
end
if (action.execute) then
action.execute()
end
end
--
-- Returns a list of all of the active terms from the current environment.
--
local _terms
function premake.getactiveterms()
if (not _terms) then
_terms = { }
table.insert(_terms, _ACTION)
table.insert(_terms, _OS)
for k,_ in pairs(_OPTIONS) do
table.insert(_terms, k)
end
end
return _terms
end
--
-- Converts a project object and a template filespec (the first value in an
-- action's template reference) into a filename for that template's output.
-- The filespec may be either a file extension, or a function.
--
function premake.getoutputname(this, namespec)
local fname
if (type(namespec) == "function") then
fname = namespec(this)
else
fname = this.name .. namespec
end
return path.join(this.location, fname)
end
|