2016-01-03 20:12:05 -05:00
|
|
|
|
2015-12-30 20:44:04 -05:00
|
|
|
-- Option to allow copying the DLL file to a custom folder after build
|
|
|
|
newoption {
|
|
|
|
trigger = "copy-to",
|
2015-12-30 21:58:16 -05:00
|
|
|
description = "Optional, copy the DLL to a custom folder after build, define the path here if wanted.",
|
|
|
|
value = "PATH"
|
2015-12-30 20:44:04 -05:00
|
|
|
}
|
|
|
|
|
2015-12-30 22:07:16 -05:00
|
|
|
newoption {
|
|
|
|
trigger = "no-new-structure",
|
|
|
|
description = "Do not use new virtual path structure (separating headers and source files)."
|
|
|
|
}
|
|
|
|
|
2015-12-30 21:59:33 -05:00
|
|
|
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
|
2015-12-30 22:18:04 -05:00
|
|
|
local oldRevNumber = "(none)"
|
2015-12-30 21:59:33 -05:00
|
|
|
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
|
2016-01-03 08:54:35 -05:00
|
|
|
-- old version.hpp format?
|
|
|
|
oldRevNumber = "(none)"
|
|
|
|
end
|
2015-12-30 21:59:33 -05:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2015-12-28 20:52:31 -05:00
|
|
|
solution "iw4x"
|
|
|
|
location ("./build")
|
2016-01-03 20:12:05 -05:00
|
|
|
configurations { "Normal", "Debug", "DebugStatic", "Release", "ReleaseStatic" }
|
2015-12-28 20:52:31 -05:00
|
|
|
|
2016-01-04 13:40:32 -05:00
|
|
|
-- VS 2015 toolset only
|
|
|
|
toolset "msc-140"
|
|
|
|
|
2016-01-04 13:42:19 -05:00
|
|
|
configuration "Debug"
|
|
|
|
defines { "DEBUG" }
|
|
|
|
flags { "MultiProcessorCompile", "Symbols", "No64BitChecks" }
|
|
|
|
optimize "Debug"
|
|
|
|
|
|
|
|
configuration "DebugStatic"
|
|
|
|
defines { "NDEBUG" }
|
|
|
|
flags { "MultiProcessorCompile", "Symbols", "No64BitChecks", "StaticRuntime" }
|
|
|
|
optimize "Debug"
|
|
|
|
|
|
|
|
configuration "Release"
|
|
|
|
defines { "NDEBUG" }
|
|
|
|
flags { "MultiProcessorCompile", "Symbols", "LinkTimeOptimization", "No64BitChecks" }
|
|
|
|
optimize "Full"
|
|
|
|
|
|
|
|
configuration "ReleaseStatic"
|
|
|
|
defines { "NDEBUG" }
|
|
|
|
flags { "MultiProcessorCompile", "Symbols", "LinkTimeOptimization", "No64BitChecks", "StaticRuntime" }
|
|
|
|
optimize "Full"
|
|
|
|
|
2015-12-28 20:52:31 -05:00
|
|
|
project "iw4x"
|
|
|
|
kind "SharedLib"
|
|
|
|
language "C++"
|
2015-12-29 08:46:17 -05:00
|
|
|
files { "./src/**.hpp", "./src/**.cpp" }
|
2015-12-30 21:59:33 -05:00
|
|
|
includedirs { "%{prj.location}" }
|
2016-01-03 08:59:38 -05:00
|
|
|
architecture "x32"
|
2016-01-03 09:18:47 -05:00
|
|
|
configmap {
|
2016-01-03 20:12:05 -05:00
|
|
|
["Normal"] = "Debug"
|
2016-01-03 09:18:47 -05:00
|
|
|
}
|
2015-12-28 20:52:31 -05:00
|
|
|
|
2016-01-03 09:01:55 -05:00
|
|
|
|
2016-01-04 13:42:19 -05:00
|
|
|
-- Virtual paths
|
2015-12-30 22:07:16 -05:00
|
|
|
if not _OPTIONS["no-new-structure"] then
|
|
|
|
vpaths {
|
|
|
|
["Headers/*"] = "src/**.hpp",
|
|
|
|
["Sources/*"] = {"src/**.cpp"}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-12-30 21:58:43 -05:00
|
|
|
vpaths {
|
|
|
|
["Docs/*"] = {"**.txt","**.md"}
|
|
|
|
}
|
|
|
|
|
2016-01-04 13:42:19 -05:00
|
|
|
-- Pre-build
|
2015-12-30 21:59:33 -05:00
|
|
|
prebuildcommands {
|
|
|
|
"cd %{_MAIN_SCRIPT_DIR}",
|
|
|
|
"premake5 generate-buildinfo"
|
|
|
|
}
|
|
|
|
|
2016-01-04 13:42:19 -05:00
|
|
|
-- Post-build
|
2015-12-30 20:44:04 -05:00
|
|
|
if _OPTIONS["copy-to"] then
|
|
|
|
saneCopyToPath = string.gsub(_OPTIONS["copy-to"] .. "\\", "\\\\", "\\")
|
|
|
|
postbuildcommands {
|
|
|
|
"copy /y \"$(TargetPath)\" \"" .. saneCopyToPath .. "\""
|
|
|
|
}
|
|
|
|
end
|
2016-01-03 20:19:12 -05:00
|
|
|
|
2016-01-04 13:42:19 -05:00
|
|
|
-- Specific configurations
|
2016-01-03 20:19:12 -05:00
|
|
|
configuration "Debug"
|
|
|
|
defines { "DEBUG" }
|
2016-01-04 13:42:19 -05:00
|
|
|
flags { "UndefinedIdentifiers" }
|
2016-01-03 20:19:12 -05:00
|
|
|
optimize "Debug"
|
|
|
|
|
|
|
|
configuration "DebugStatic"
|
|
|
|
defines { "NDEBUG" }
|
2016-01-04 13:42:19 -05:00
|
|
|
flags { "UndefinedIdentifiers" }
|
2016-01-03 20:19:12 -05:00
|
|
|
optimize "Debug"
|
|
|
|
|
|
|
|
configuration "Release"
|
|
|
|
defines { "NDEBUG" }
|
2016-01-04 13:42:19 -05:00
|
|
|
flags { "FatalCompileWarnings", "UndefinedIdentifiers" }
|
2016-01-03 20:19:12 -05:00
|
|
|
optimize "Full"
|
|
|
|
|
|
|
|
configuration "ReleaseStatic"
|
|
|
|
defines { "NDEBUG" }
|
2016-01-04 13:42:19 -05:00
|
|
|
flags { "FatalCompileWarnings", "UndefinedIdentifiers" }
|
|
|
|
optimize "Full"
|
|
|
|
|