forked from randrew/layout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
genie.lua
171 lines (154 loc) · 5.63 KB
/
genie.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
local action = _ACTION or ""
newaction {
trigger = "clean",
description = "Clean everything",
execute = function ()
os.rmdir("./build")
end
}
newaction {
trigger = "asm",
description = "Emit GCC assembly output for a file",
-- Hard-coded for windows+gmake, probably has shell quote bugs
execute = function ()
os.execute("gcc -ggdb1 -Ofast -S -fno-stack-check -fno-dwarf2-cfi-asm -fno-asynchronous-unwind-tables -masm=intel -march=nehalem -fverbose-asm -DNDEBUG " .. _ARGS[1])
end
}
newoption {
trigger = "coords",
value = "coordtype",
description = "Use either integer or floating point for coordinates and sizes",
allowed = {
{ "integer", "16-bit signed integer" },
{ "float", "32-bit floating point" },
}
}
local targetDir = path.join("./build", _ACTION, "bin")
function incl_luajit()
configuration {}
includedirs {
"./thirdparty/LuaJIT-2.0.0/src",
}
-- Note: you will need to manually rebuild LuaJIT with the correct
-- compiler (mingw, msvc) first
libdirs {
"./thirdparty/LuaJIT-2.0.0/src",
}
-- lua51.dll
links { "lua51" }
end
function as_console_app()
kind "ConsoleApp"
-- Needed in mingw when building console app, genie/premake
-- automatically adds this for WindowedApp.
links { "gdi32" }
end
function as_shared_lib()
kind "SharedLib"
end
function lay_project(project_name, as_build_type, src_file)
project(project_name)
platforms { "x32", "x64" }
-- kind "ConsoleApp"
-- kind "WindowedApp"
language "C"
-- regular
--files { "**.h", "**.c" }
files { "**.h", src_file }
if _ACTION == "vs2015" or _ACTION == "vs2017" then
-- Build as C++ even with .c filename extension, because we
-- need [] operator for our vector types (GCC provides this in
-- C with vector_size special attribute, but need operator
-- overload in C++)
options { "ForceCpp" }
end
configuration {}
flags { "ExtraWarnings" }
targetdir(targetDir)
as_build_type()
configuration { "float" }
defines { "LAY_FLOAT=1" }
configuration { "vs*", "windows" }
defines { "_CRT_SECURE_NO_WARNINGS" }
buildoptions {
-- Disable "unreferenced formal parameter" warning
"-wd4100"
}
configuration { "gmake", "windows" }
-- Nehalem chips were released in 2008, and include SSE4.
--
-- Note that gcc -Q --help=target -march=nehalem (or whatever other
-- arch) will not correctly display the enabled/disabled flags for
-- stuff like SSE, etc. This is a known problem with gcc (it's on
-- their bug tracker). -march=native, however, will show the
-- enabled/disabled flags correctly.
buildoptions {
"-std=c99",
"-Wno-unused-parameter",
-- We want strict overflow on regardless of optimization level,
-- because it will change program semantics.
"-fstrict-overflow",
"-fstrict-aliasing",
"-Wstrict-aliasing=3",
"-march=nehalem"
}
configuration "Debug or Develop"
flags { "Symbols" }
configuration { "Debug" }
defines { "DEBUG" }
configuration { "Debug", "gmake" }
buildoptions {
"-ggdb",
"-fstack-protector-strong",
}
-- need to manually link -lssp for stack protector stuff
links { "ssp" }
configuration { "Develop or Release", "gmake" }
-- Remove some extra junk from the asm we don't need
buildoptions {
"-fno-stack-check",
"-fno-dwarf2-cfi-asm",
"-fno-asynchronous-unwind-tables",
}
configuration "Release"
defines { "NDEBUG", "WIN32_LEAN_AND_MEAN", "VC_EXTRALEAN" }
flags {
"Optimize",
"NoBufferSecurityCheck",
"NoWinRT",
"NoFramePointer",
}
windowstargetplatformversion "7"
configuration { "Release", "gmake" }
buildoptions {
"-Ofast",
"-fuse-linker-plugin",
"-flto",
"-fno-fat-lto-objects"
}
linkoptions {
"-flto",
"-fuse-linker-plugin",
"-s"
}
-- SSE2 in msvc must be explicitly enabled when building 32-bit. In
-- x64, /arch:SSE2 will produce a compiler warning, because it's
-- redundant (SSE2 always available in x64).
configuration { "Release or Develop", "x32" }
flags { "EnableSSE2" }
-- msvc builds are forced to C++, and we always want to disable
-- exceptions and RTTI.
configuration { "vs*" }
flags { "NoExceptions", "NoRTTI" }
configuration { "Release", "vs*" }
flags { "FloatFast" }
end
solution "layout"
location ( "build/" .. action )
configurations { "Debug", "Develop", "Release" }
lay_project("tests", as_console_app, "test_layout.c")
lay_project("benchmark", as_console_app, "benchmark_layout.c")
lay_project("luamodule", as_shared_lib, "luamodule_layout.c")
incl_luajit()
configuration {}
targetname("layout")