iw4x-client/premake5.lua
/dev/urandom 614c36fbe2
premake5: Map "Debug" and "Release" configurations to "Normal".
The general standard for any C++ project normally is to have a Debug and a Release version of the binaries, however in our case we only have one configuration that mixes both. Setting up aliases for this in order to prevent confusion on why the standard configurations don't work.
2016-01-04 01:52:14 +01:00

98 lines
2.7 KiB
Lua

-- 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 = "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+)")
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
}
solution "iw4x"
location ("./build")
configurations { "Normal", "Debug", "Release" }
project "iw4x"
kind "SharedLib"
language "C++"
files { "./src/**.hpp", "./src/**.cpp" }
includedirs { "%{prj.location}" }
architecture "x32"
configmap {
["Debug"] = "Normal",
["Release"] = "Normal"
}
-- Allow newer Microsoft toolsets but fall back to VS2013
if _ACTION == "vs2015" then
toolset "msc-140"
else
toolset "msc-120"
end
configuration "Normal"
defines { "NDEBUG" }
flags { "MultiProcessorCompile", "Symbols" }
optimize "on"
if not _OPTIONS["no-new-structure"] then
vpaths {
["Headers/*"] = "src/**.hpp",
["Sources/*"] = {"src/**.cpp"}
}
end
vpaths {
["Docs/*"] = {"**.txt","**.md"}
}
prebuildcommands {
"cd %{_MAIN_SCRIPT_DIR}",
"premake5 generate-buildinfo"
}
if _OPTIONS["copy-to"] then
saneCopyToPath = string.gsub(_OPTIONS["copy-to"] .. "\\", "\\\\", "\\")
postbuildcommands {
"copy /y \"$(TargetPath)\" \"" .. saneCopyToPath .. "\""
}
end