-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.lua
127 lines (111 loc) · 3.86 KB
/
actions.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
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
122
123
124
125
126
127
_G.package.path=[[./?.lua;./?/?.lua;]].._G.package.path
local config = require 'config'
local actions = {}
local configs = function()
local res = configurations()
if _PREMAKE_VERSION:sub(1,1) ~= '4' then --wait for official premake5
res = { 'Debug', 'Release' }
end
return res
end
local plats = function()
local res = platforms()
if _PREMAKE_VERSION:sub(1,1) ~= '4' then --wait for official premake5
res = { "x32", "x64", "native" }
end
return res
end
actions.default_config = function ()
configuration "Debug"
defines { "_DEBUG" }
flags { "Symbols" }
configuration "Release"
-- defines { "_RELEASE" }
flags { "Optimize" }
configuration "*" -- reset configuration filter
if config.get_objects_location then
local project_name = project().name
objdir ( config:get_objects_location('','',project_name) )
for _, plat_ in ipairs(plats() or {''}) do
for __, config_ in ipairs( configs() ) do
configuration { plat_, config_ }
local loc_ = config:get_objects_location(plat_,config_,project_name)
objdir ( loc_ )
end
end
end
configuration "*" --reset
end
actions.make_project = function (project_type,name,files_,language_)
project(name)
kind(project_type)
files(files_)
language(language_ or 'C++')
actions.default_config()
end
actions.make_solution = function (name)
solution(name)
------------------------------------
configurations ( config.configurations or { 'Debug', 'Release' } )
platforms ( config.platforms or { "x32", "x64" } )
------------------------------------
if config.get_location then
location ( config:get_location() )
else
location ( 'Build' )
end
------------------------------------
if config.get_binaries_location then
local loc = config:get_binaries_location()
targetdir ( loc )
for _, plat_ in ipairs(plats() or {''}) do
for __, config_ in ipairs( configs() ) do
configuration { plat_, config_ }
local loc = config:get_binaries_location(plat_,config_)
print(loc)
targetdir ( loc )
end
end
end
configuration "*" --reset
end
----------------------------------------------------------------------------------------------------------------
actions.make_static_lib = function(name,files_)
actions.make_project("StaticLib",name,files_)
end
----------------------------------------------------------------------------------------------------------------
actions.make_shared_lib = function(name,files_)
actions.make_project("SharedLib",name,files_)
end
----------------------------------------------------------------------------------------------------------------
actions.make_console_app = function (name,files_)
actions.make_project("ConsoleApp",name,files_)
end
----------------------------------------------------------------------------------------------------------------
actions.run_target_after_build = function ()
configuration {"xcode*" }
postbuildcommands {"$TARGET_BUILD_DIR/$TARGET_NAME"}
configuration {"gmake"}
postbuildcommands { "$(TARGET)" }
configuration {"codeblocks" }
postbuildcommands { "$(TARGET_OUTPUT_FILE)"}
configuration { "vs*"}
postbuildcommands { "\"$(TargetPath)\"" }
configuration { "*" }
end
----------------------------------------------------------------------------------------------------------------
actions.use_standard = function (standard)
configuration {"gmake"}
buildoptions { "-std="..standard }
configuration {"xcode*"}
buildoptions { "-std="..standard }
linkoptions "-stdlib=libc++"
configuration { "*" }
end
actions.make_cpp11 = function() actions.use_standard("c++11") end
----------------------------------------------------------------------------------------------------------------
-- actions.get_recipe = function(name)
-- return assert(dofile 'recipes/'..name..'.lua')
-- end
----------------------------------------------------------------------------------------------------------------
return actions