-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake4_util.lua
73 lines (66 loc) · 2.49 KB
/
premake4_util.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
67
68
69
70
71
72
73
-- Utility functions for Premake v4
-- Copyright 2012 Green Code LLC
--
-- This library is free software; you can redistribute it and/or
-- modify it under the terms of the GNU Lesser General Public
-- License as published by the Free Software Foundation; either
-- version 2.1 of the License, or (at your option) any later version.
--
-- This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public
-- License along with this library; if not, see
-- <http://www.gnu.org/licenses/>.
--
-- Contributors:
-- James Domingo, Green Code LLC
-- ==========================================================================
-- Release history:
-- 2012-08-26 : Initial release
-- 2012-09-01 : Changed license from BSD to LGPL.
-- Improved documentation in comments.
-- ==========================================================================
-- Returns a boolean indicating whether Premake is running on Windows or not
function runningOnWindows()
if string.match(_PREMAKE_VERSION, "^4.[123]") then
-- Premake 4.3 or earlier. Since os.getversion() added in Premake 4.4, use
-- a simple test (does PATH env var have ";"?) to determine if on Windows.
return string.find(os.getenv("PATH"), ";")
else
-- Premake 4.4 or later
local osVersion = os.getversion()
return string.find(osVersion.description, "Windows")
end
end
-- ==========================================================================
-- Hook in a custom function that will be called *after* the selected Premake
-- action is executed.
--
-- Example:
--
-- afterAction_call(myCustomFunc)
--
-- function myCustomFunc()
-- if _ACTION and _ACTION ~= "clean" then
-- -- do something with generated project files
-- ...
-- end
-- end
function afterAction_call(func)
if _ACTION then
local action = premake.action.get(_ACTION)
if not action then
-- An unknown action was specified (user made typing mistake?)
else
local triggerAction = premake.action.get(action.trigger)
local originalExecute = triggerAction.execute
triggerAction.execute = function()
if originalExecute then originalExecute() end
func()
end
end
end
end