-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpremake4.lua
More file actions
248 lines (212 loc) · 8.55 KB
/
premake4.lua
File metadata and controls
248 lines (212 loc) · 8.55 KB
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
-------------------------------------------------------------------
-- This software is released under the terms of the MIT License
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-- THE SOFTWARE.
--
-- @copyright 2009-2012 Roberto Perpuly
-- @license http://www.opensource.org/licenses/mit-license.php The MIT License
-------------------------------------------------------------------
dofile "premake_functions.lua"
dofile "premake_action_generate.lua"
newoption {
trigger = "icu-include",
value = "path",
description = "Directory Location of the ICU header files. " ..
"This option should only be used on Win32 systems"
}
newoption {
trigger = "icu-lib",
value = "path",
description = "Directory Location of the ICU library shared object files. " ..
"This option should only be used on Win32 systems"
}
newoption {
trigger = "icu-config",
value = "path",
description = "File location of the icu-config binary. If given, " ..
"it will be used to get the appropriate compiler and linker flags. " ..
"This option should only be used on linux systems"
}
-- these are the ICU unicode string libraries (in Win32)
ICU_LIBS_RELEASE = {
"icudt", "icuin", "icuio", "icule",
"iculx", "icutu", "icuuc"
}
-- these are the ICU unicode string libraries (in Win32)
ICU_LIBS_DEBUG = {
"icudt", "icuind", "icuiod", "iculed",
"iculxd", "icutud", "icuucd"
}
-- this configuration uses the command line options to get the ICU header & library locations
function icuconfiguration(config, action)
if config == "Debug" and _OPTIONS['icu-include'] then
includedirs { _OPTIONS['icu-include'] }
libdirs { _OPTIONS['icu-lib'] }
links { ICU_LIBS_DEBUG }
elseif config == "Release" and _OPTIONS['icu-include'] then
includedirs { _OPTIONS['icu-include'] }
libdirs { _OPTIONS['icu-lib'] }
links { ICU_LIBS_RELEASE }
elseif _OPTIONS['icu-config'] then
-- use the execution operator '``' because the icu-config program
-- will be used to generate the correct compile and linker flags
buildoptions { "`" .. _OPTIONS['icu-config'] .. " --cppflags`" }
linkoptions { "`" .. _OPTIONS['icu-config'] .. " --ldflags --ldflags-icuio`" }
end
end
function pickywarnings(action)
if action == "vs2008" then
flags { "FatalWarnings" }
elseif action == "gmake" or action == "codelite" then
-- when compiling strict warning checks; also check against variable length arrays
-- since Visual Studio is not C99 compliant
buildoptions { "-Wall", "-Wvla" }
end
end
if ((not _OPTIONS.help) and (_ACTION ~= 'clean') and (_ACTION ~= 'generate')) then
if ((not _OPTIONS['icu-include']) and (not _OPTIONS['icu-config'])) then
error("Missing one of --icu-include or --icu-config. See --help for details")
end
end
-- solution directory structure
-- the toolset files will be deposited in the build/ directory
-- each toolset will have its own directory
-- the executable files will be placed in the configuration directory (Debug/ or Release/)
-- compile flags will be set to be stricter than normal
solution "pelet"
if _ACTION then
location ("build/" .. _ACTION)
end
configurations { "Debug", "Release"}
configuration "Debug"
objdir "Debug"
targetdir "Debug"
flags { "Symbols" }
configuration "Release"
objdir "Release"
targetdir "Release"
configuration { "Debug", "vs2008" }
-- prevent "warning LNK4098: defaultlib 'MSVCRTD' conflicts with use of other libs; use /NODEFAULTLIB:library"
buildoptions { "/MDd" }
project "sample"
language "C++"
kind "ConsoleApp"
files { "sample/sample.cpp" }
includedirs { "include" }
links { "pelet", "tests" }
defines { "PELET_USE_DLL" }
configuration "Release"
pickywarnings(_ACTION)
icuconfiguration("Release", _ACTION)
configuration { "Debug", "vs2008" }
icuconfiguration("Debug", _ACTION)
postbuildcommands { "cd " .. normalizepath("Debug") .. " && tests.exe" }
configuration { "Debug", "gmake or codelite" }
icuconfiguration("Debug", _ACTION)
postbuildcommands { "cd " .. normalizepath("Debug") .. " && ./tests" }
configuration { "Release", "vs2008" }
icuconfiguration("Debug", _ACTION)
postbuildcommands { "cd " .. normalizepath("Release") .. " && tests.exe" }
configuration { "Release", "gmake or codelite" }
icuconfiguration("Debug", _ACTION)
postbuildcommands { "cd " .. normalizepath("Release") .. " && ./tests" }
project "pelet"
language "C++"
kind "SharedLib"
files { "src/*", "include/**", "*.lua", "src/**.re", "src/**.y", "README.md", "ChangeLog" }
includedirs { "include" }
defines { "PELET_MAKING_DLL" }
pickywarnings(_ACTION)
-- for mac osx, change the shared library ID so that
-- it is the full path, that way we can run the executable
-- from any location and the lib will always be found
-- it becomes painful when running from the command line
-- vs. finder vs. the debugger vs. the codelite terminal,
-- they all have different working directories and this
-- makes relative install names not easy to work with
-- when passing arguments to the linker, must replace
-- spaces with commas
if os.is "macosx" then
configuration { "Debug" }
linkoptions { "-Wl,-install_name," .. normalizepath("Debug/libpelet.dylib") }
configuration { "Release" }
linkoptions { "-Wl,-install_name," .. normalizepath("Release/libpelet.dylib") }
end
configuration "Release"
icuconfiguration("Release", _ACTION)
configuration { "Debug" }
icuconfiguration("Debug", _ACTION)
project "tests"
language "C++"
kind "ConsoleApp"
files {
"tests/**.cpp",
"tests/**.h"
}
includedirs { "include/", "lib/UnitTest++/src/", "tests/" }
links { "pelet", "unit_test++" }
defines { "PELET_USE_DLL" }
-- dont bother with warnings with using 'unsafe' fopen
configuration { "vs2008" }
defines { "_CRT_SECURE_NO_WARNINGS" }
if os.is "linux" then
configuration { "gmake or codelite" }
-- make it so that the test executable can find the pelet shared lib
linkoptions { "-Wl,-rpath=./" }
elseif os.is "macosx" then
-- this is a workaround for a premake issue where it will use
-- bad compiler flags "-Wl,x" for a workaround that is longer
-- needed in GCC, but it just prevents clang from compiling
-- see http://industriousone.com/topic/how-remove-flags-ldflags
flags { "Symbols" }
end
configuration "Debug"
pickywarnings(_ACTION)
icuconfiguration("Debug", _ACTION)
configuration "Release"
pickywarnings(_ACTION)
icuconfiguration("Release", _ACTION)
project "unit_test++"
language "C++"
kind "StaticLib"
files { "lib/UnitTest++/src/*.cpp" }
-- enable the "Use Unicode Character Set" option under General .. Character Set
-- enable Stuctured Exception Handling needed by UnitTest++
flags { "Unicode", "SEH" }
-- For this project, no need to differentiate between Debug or Release
configuration { "vs2008" }
files { "lib/UnitTest++/src/Win32/*.cpp" }
-- dont bother with warnings with using 'unsafe' strcopy
defines { "_CRT_SECURE_NO_WARNINGS", "_LIB" }
configuration { "gmake or codelite" }
files { "lib/UnitTest++/src/Posix/*.cpp" }
project "unit_test++_test"
language "C++"
kind "ConsoleApp"
links { "unit_test++" }
files { "lib/UnitTest++/src/tests/*.cpp" }
-- enable Stuctured Exception Handling needed by UnitTest++
flags { "SEH" }
-- enable the "Use Unicode Character Set" option under General .. Character Set
flags { "Unicode" }
configuration { "vs2008" }
-- dont bother with warnings with using 'unsafe' strcopy
defines { "_CRT_SECURE_NO_WARNINGS" }
flags { "WinMain" }
-- For this project, no need to differentiate between Debug or Release