forked from jagt/clumsy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake4.lua
149 lines (133 loc) · 5.76 KB
/
premake4.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
-- currently only supports vs2010.
-- and premake4 4.4 doesn't have vs2012 support yet. but seems auto upgrade works fine
if _ACTION == 'clean' then
os.rmdir('./build')
os.rmdir('./bin')
os.rmdir('./obj_vs')
os.rmdir('./obj_gmake')
end
local LIB_DIVERT_VC11 = 'external/WinDivert-1.1.7-MSVC'
local LIB_DIVERT_MINGW = 'external/WinDivert-1.1.7-MINGW'
local LIB_IUP_WIN32_VC11 = 'external/iup-3.16_Win32_dll11_lib'
local LIB_IUP_WIN64_VC11 = 'external/iup-3.16_Win64_dll11_lib'
local LIB_IUP_WIN32_MINGW = 'external/iup-3.16_Win32_mingw4_lib'
local LIB_IUP_WIN64_MINGW = 'external/iup-3.16_Win64_mingw4_lib'
solution('clumsy')
location("./build")
configurations({'Debug', 'Release'})
platforms({'x32', 'x64'})
project('clumsy')
language("C")
files({'src/**.c', 'src/**.h'})
links({'WinDivert', 'iup', 'comctl32', 'Winmm', 'ws2_32'})
if string.match(_ACTION, '^vs') then -- only vs can include rc file in solution
files({'./etc/clumsy.rc'})
elseif _ACTION == 'gmake' then
files({'./etc/clumsy.rc'})
end
configuration('Debug')
flags({'ExtraWarnings', 'Symbols'})
defines({'_DEBUG'})
kind("ConsoleApp")
configuration('Release')
flags({'Optimize'})
flags({'Symbols'}) -- keep the debug symbols for development
defines({'NDEBUG'})
kind("WindowedApp")
configuration("gmake")
links({'kernel32', 'gdi32', 'comdlg32', 'uuid', 'ole32'}) -- additional libs
buildoptions({'-Wno-missing-braces', '--std=c99'}) -- suppress a bug in gcc warns about {0} initialization
--linkoptions({'--std=c90'})
-- notice that tdm-gcc use static runtime by default
objdir('obj_vs')
configuration("vs*")
defines({"_CRT_SECURE_NO_WARNINGS"})
flags({'NoManifest'})
buildoptions({'/wd"4214"'})
includedirs({LIB_DIVERT_VC11 .. '/include'})
objdir('obj_gmake')
configuration({'x32', 'vs*'})
-- defines would be passed to resource compiler for whatever reason
-- and ONLY can be put here not under 'configuration('x32')' or it won't work
defines({'X32'})
includedirs({LIB_IUP_WIN32_VC11 .. '/include'})
libdirs({
LIB_DIVERT_VC11 .. '/x86',
LIB_IUP_WIN32_VC11 .. ''
})
configuration({'x64', 'vs*'})
defines({'X64'})
includedirs({LIB_IUP_WIN64_VC11 .. '/include'})
libdirs({
LIB_DIVERT_VC11 .. '/amd64',
LIB_IUP_WIN64_VC11 .. ''
})
configuration({'x32', 'gmake'})
defines({'X32'}) -- defines would be passed to resource compiler for whatever reason
includedirs({LIB_DIVERT_MINGW .. '/include',
LIB_IUP_WIN32_MINGW .. '/include'})
libdirs({
LIB_DIVERT_MINGW .. '/x86',
LIB_IUP_WIN32_MINGW .. ''
})
resoptions({'-O coff', '-F pe-i386'}) -- mingw64 defaults to x64
configuration({'x64', 'gmake'})
defines({'X64'})
includedirs({LIB_DIVERT_MINGW .. '/include',
LIB_IUP_WIN64_MINGW .. '/include'})
libdirs({
LIB_DIVERT_MINGW .. '/amd64',
LIB_IUP_WIN64_MINGW .. ''
})
local function set_bin(platform, config, arch)
local platform_str
if platform == 'vs*' then
platform_str = 'vs'
else
platform_str = platform
end
local subdir = 'bin/' .. platform_str .. '/' .. config .. '/' .. arch
local divert_lib, iup_lib
if platform == 'vs*' then
if arch == 'x64' then
divert_lib = '../' .. LIB_DIVERT_VC11 .. '/amd64/'
iup_lib = '../' .. LIB_IUP_WIN64_VC11 .. ''
else
divert_lib = '../' .. LIB_DIVERT_VC11 .. '/x86/'
iup_lib = '../' .. LIB_IUP_WIN32_VC11 .. ''
end
elseif platform == 'gmake' then
if arch == 'x64' then
divert_lib = '../' .. LIB_DIVERT_MINGW .. '/amd64/'
iup_lib = '../' .. LIB_IUP_WIN64_MINGW .. ''
else
divert_lib = '../' .. LIB_DIVERT_MINGW .. '/x86/'
iup_lib = '../' .. LIB_IUP_WIN32_MINGW .. ''
end
end
configuration({platform, config, arch})
targetdir(subdir)
debugdir(subdir)
if platform == 'vs*' then
postbuildcommands({
"robocopy " .. divert_lib .." ../" .. subdir .. ' *.dll *.sys > robolog.txt',
"robocopy " .. iup_lib .. " ../" .. subdir .. ' iup.dll >> robolog.txt',
"robocopy ../etc/ ../" .. subdir .. ' config.txt >> robolog.txt',
"exit /B 0"
})
elseif platform == 'gmake' then
postbuildcommands({
-- robocopy returns non 0 will fail make
'cp ' .. divert_lib .. "WinDivert* ../" .. subdir,
"cp ../etc/config.txt ../" .. subdir,
})
end
end
set_bin('vs*', 'Debug', "x32")
set_bin('vs*', 'Debug', "x64")
set_bin('vs*', 'Release', "x32")
set_bin('vs*', 'Release', "x64")
set_bin('gmake', 'Debug', "x32")
set_bin('gmake', 'Debug', "x64")
set_bin('gmake', 'Release', "x32")
set_bin('gmake', 'Release', "x64")