iw4x-client/premake5.lua

249 lines
6.3 KiB
Lua
Raw Normal View History

-- Option to allow copying the DLL file to a custom folder after build
newoption {
trigger = "copy-to",
description = "Optional, copy the DLL to a custom folder after build, define the path here if wanted.",
value = "PATH"
}
newoption {
trigger = "no-new-structure",
description = "Do not use new virtual path structure (separating headers and source files)."
}
newaction {
trigger = "version",
description = "Returns the version string for the current commit of the source code.",
onWorkspace = function(wks)
-- get revision number via git
local proc = assert(io.popen("git rev-list --count HEAD", "r"))
local revNumber = assert(proc:read('*a')):gsub("%s+", "")
proc:close()
print(revNumber)
os.exit(0)
end
}
newaction {
trigger = "generate-buildinfo",
description = "Sets up build information file like version.h.",
onWorkspace = function(wks)
-- get revision number via git
local proc = assert(io.popen("git rev-list --count HEAD", "r"))
local revNumber = assert(proc:read('*a')):gsub("%s+", "")
proc:close()
-- get old version number from version.hpp if any
local oldRevNumber = "(none)"
local oldVersionHeader = io.open(wks.location .. "/version.hpp", "r")
if oldVersionHeader ~=nil then
local oldVersionHeaderContent = assert(oldVersionHeader:read('*a'))
oldRevNumber = string.match(oldVersionHeaderContent, "#define REVISION (%d+)")
2016-01-03 08:57:24 -05:00
if oldRevNumber == nil then
-- old version.hpp format?
oldRevNumber = "(none)"
end
end
-- generate version.hpp with a revision number if not equal
if oldRevNumber ~= revNumber then
print ("Update " .. oldRevNumber .. " -> " .. revNumber)
local versionHeader = assert(io.open(wks.location .. "/version.hpp", "w"))
versionHeader:write("/*\n")
versionHeader:write(" * Automatically generated by premake5.\n")
versionHeader:write(" * Do not touch, you fucking moron!\n")
versionHeader:write(" */\n")
versionHeader:write("\n")
versionHeader:write("#define REVISION " .. revNumber .. "\n")
versionHeader:close()
end
end
}
workspace "iw4x"
location "./build"
objdir "%{wks.location}/obj"
targetdir "%{wks.location}/bin/%{cfg.buildcfg}"
2016-01-15 16:51:47 -05:00
configurations { "Debug", "DebugStatic", "Release", "ReleaseStatic" }
architecture "x32"
platforms "x86"
2015-12-28 20:52:31 -05:00
-- VS 2015 toolset only
toolset "msc-140"
2016-01-04 15:07:34 -05:00
configuration "windows"
defines { "_WINDOWS" }
configuration "Release*"
defines { "NDEBUG" }
flags { "MultiProcessorCompile", "Symbols", "LinkTimeOptimization", "No64BitChecks" }
optimize "Full"
configuration "Debug*"
defines { "DEBUG", "_DEBUG" }
flags { "MultiProcessorCompile", "Symbols", "No64BitChecks" }
optimize "Debug"
configuration "*Static"
flags { "StaticRuntime" }
2015-12-28 20:52:31 -05:00
project "iw4x"
kind "SharedLib"
language "C++"
files { "./src/**.hpp", "./src/**.cpp" }
includedirs { "%{prj.location}", "./src" }
2015-12-28 20:52:31 -05:00
-- Pre-compiled header
pchheader "STDInclude.hpp" -- must be exactly same as used in #include directives
pchsource "src/STDInclude.cpp" -- real path
2016-02-06 20:31:30 -05:00
buildoptions { "-Zm88" }
-- Dependency on zlib, json11 and asio
links { "zlib", "json11", "pdcurses", "libtomcrypt", "libtommath" }
includedirs
{
"./deps/zlib",
"./deps/json11",
"./deps/pdcurses",
"./deps/asio/asio/include",
"./deps/libtomcrypt/src/headers",
"./deps/libtommath",
}
2016-01-04 15:07:34 -05:00
-- Virtual paths
if not _OPTIONS["no-new-structure"] then
vpaths {
["Headers/*"] = "./src/**.hpp",
["Sources/*"] = {"./src/**.cpp"}
}
end
vpaths {
["Docs/*"] = {"**.txt","**.md"}
}
-- Pre-build
prebuildcommands {
"cd %{_MAIN_SCRIPT_DIR}",
"premake5 generate-buildinfo"
}
-- Post-build
if _OPTIONS["copy-to"] then
saneCopyToPath = string.gsub(_OPTIONS["copy-to"] .. "\\", "\\\\", "\\")
postbuildcommands {
"copy /y \"$(TargetDir)*.dll\" \"" .. saneCopyToPath .. "\""
}
end
-- Specific configurations
flags { "UndefinedIdentifiers", "ExtraWarnings" }
configuration "Release*"
flags { "FatalCompileWarnings" }
2016-01-04 15:07:34 -05:00
group "External dependencies"
-- zlib
project "zlib"
language "C"
defines { "ZLIB_DLL", "_CRT_SECURE_NO_DEPRECATE" }
2016-01-04 15:07:34 -05:00
files
{
"./deps/zlib/*.h",
"./deps/zlib/*.c"
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
2016-01-04 15:07:34 -05:00
kind "SharedLib"
configuration "*Static"
kind "StaticLib"
removedefines { "ZLIB_DLL" }
-- json11
project "json11"
language "C++"
files
{
"./deps/json11/*.cpp",
"./deps/json11/*.hpp"
}
-- remove dropbox's testing code
removefiles { "./deps/json11/test.cpp" }
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
-- always build as static lib, as json11 doesn't export anything
kind "StaticLib"
2016-01-16 17:48:52 -05:00
-- pdcurses
project "pdcurses"
language "C"
2016-01-16 17:48:52 -05:00
includedirs { "./deps/pdcurses/" }
files
{
2016-01-16 18:22:08 -05:00
"./deps/pdcurses/pdcurses/*.c",
"./deps/pdcurses/win32/*.c"
2016-01-16 17:48:52 -05:00
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
-- always build as static lib, as pdcurses doesn't export anything
kind "StaticLib"
-- libtomcrypt
project "libtomcrypt"
language "C"
defines { "_LIB", "LTC_SOURCE", "LTC_NO_RSA_BLINDING", "LTM_DESC", "USE_LTM" }
2016-01-31 13:50:17 -05:00
links { "libtommath" }
includedirs { "./deps/libtomcrypt/src/headers" }
includedirs { "./deps/libtommath" }
2016-01-31 09:55:32 -05:00
files { "./deps/libtomcrypt/src/**.c" }
-- seems like tab stuff can be omitted
removefiles { "./deps/libtomcrypt/src/**/*tab.c" }
-- remove incorrect files
-- for some reason, they lack the necessary header files
-- i might have to open a pull request which includes them
removefiles
{
"./deps/libtomcrypt/src/pk/dh/dh_sys.c",
"./deps/libtomcrypt/src/hashes/sha2/sha224.c",
"./deps/libtomcrypt/src/hashes/sha2/sha384.c",
"./deps/libtomcrypt/src/encauth/ocb3/**.c",
}
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
-- always build as static lib, as pdcurses doesn't export anything
kind "StaticLib"
2016-01-31 09:55:32 -05:00
-- libtommath
project "libtommath"
2016-01-31 09:55:32 -05:00
language "C"
defines { "_LIB" }
includedirs { "./deps/libtommath" }
2016-01-31 09:55:32 -05:00
files { "./deps/libtommath/*.c" }
2016-01-31 09:55:32 -05:00
-- not our code, ignore POSIX usage warnings for now
warnings "Off"
-- always build as static lib, as pdcurses doesn't export anything
kind "StaticLib"