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)."
|
|
|
|
}
|
|
|
|
|
2016-01-17 15:47:40 -05:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
|
2016-03-14 20:44:40 -04:00
|
|
|
-- get whether this is a clean revision (no uncommitted changes)
|
|
|
|
local proc = assert(io.popen("git status --porcelain", "r"))
|
|
|
|
local revClean = 1
|
|
|
|
local revCleanSuffix = ""
|
|
|
|
if assert(proc:read('*a')) ~= "" then
|
|
|
|
revClean = 0
|
|
|
|
revCleanSuffix = " (unclean)"
|
|
|
|
end
|
|
|
|
proc:close()
|
|
|
|
|
2015-12-30 21:59:33 -05:00
|
|
|
-- get old version number from version.hpp if any
|
2015-12-30 22:18:04 -05:00
|
|
|
local oldRevNumber = "(none)"
|
2016-03-14 20:44:40 -04:00
|
|
|
local oldRevClean = 1
|
|
|
|
local oldRevCleanSuffix = ""
|
2016-02-10 08:54:50 -05:00
|
|
|
local oldVersionHeader = io.open(wks.location .. "/src/version.hpp", "r")
|
2015-12-30 21:59:33 -05:00
|
|
|
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
|
2016-03-14 20:44:40 -04:00
|
|
|
oldRevClean = string.match(oldVersionHeaderContent, "#define REVISION_CLEAN (%d+)")
|
|
|
|
if oldRevClean == nil then
|
|
|
|
-- old version.hpp format?
|
|
|
|
oldRevClean = 1
|
|
|
|
elseif oldRevClean ~= "1" then
|
|
|
|
oldRevClean = 0
|
|
|
|
else
|
|
|
|
oldRevClean = 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if oldRevClean == 0 then
|
|
|
|
oldRevCleanSuffix = " (unclean)"
|
2015-12-30 21:59:33 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- generate version.hpp with a revision number if not equal
|
2016-03-14 20:44:40 -04:00
|
|
|
if oldRevNumber ~= revNumber or oldRevClean ~= revClean then
|
|
|
|
print ("Update " .. oldRevNumber .. oldRevCleanSuffix .. " -> " .. revNumber .. revCleanSuffix)
|
2016-02-10 08:54:50 -05:00
|
|
|
local versionHeader = assert(io.open(wks.location .. "/src/version.hpp", "w"))
|
2015-12-30 21:59:33 -05:00
|
|
|
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")
|
2016-03-14 20:44:40 -04:00
|
|
|
versionHeader:write("#define REVISION_CLEAN " .. revClean .. "\n")
|
2015-12-30 21:59:33 -05:00
|
|
|
versionHeader:close()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2016-01-04 14:03:56 -05:00
|
|
|
workspace "iw4x"
|
2016-01-04 15:00:17 -05:00
|
|
|
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" }
|
2016-01-20 19:00:18 -05:00
|
|
|
architecture "x32"
|
|
|
|
platforms "x86"
|
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 15:07:34 -05:00
|
|
|
configuration "windows"
|
2016-02-08 08:27:15 -05:00
|
|
|
defines { "_WINDOWS", "WIN32" }
|
2016-01-04 13:42:19 -05:00
|
|
|
|
2016-01-04 14:06:00 -05:00
|
|
|
configuration "Release*"
|
2016-01-04 13:42:19 -05:00
|
|
|
defines { "NDEBUG" }
|
|
|
|
flags { "MultiProcessorCompile", "Symbols", "LinkTimeOptimization", "No64BitChecks" }
|
|
|
|
optimize "Full"
|
|
|
|
|
2016-01-04 14:06:00 -05:00
|
|
|
configuration "Debug*"
|
2016-01-31 15:27:43 -05:00
|
|
|
defines { "DEBUG", "_DEBUG" }
|
2016-01-04 14:06:00 -05:00
|
|
|
flags { "MultiProcessorCompile", "Symbols", "No64BitChecks" }
|
|
|
|
optimize "Debug"
|
|
|
|
|
|
|
|
configuration "*Static"
|
|
|
|
flags { "StaticRuntime" }
|
2016-01-04 13:42:19 -05:00
|
|
|
|
2015-12-28 20:52:31 -05:00
|
|
|
project "iw4x"
|
|
|
|
kind "SharedLib"
|
|
|
|
language "C++"
|
2016-02-11 09:09:32 -05:00
|
|
|
files {
|
2016-03-14 07:54:59 -04:00
|
|
|
"./src/**.rc",
|
2016-02-11 09:09:32 -05:00
|
|
|
"./src/**.hpp",
|
|
|
|
"./src/**.cpp",
|
|
|
|
"./src/**.proto",
|
|
|
|
}
|
|
|
|
includedirs {
|
|
|
|
"%{prj.location}/src",
|
|
|
|
"./src"
|
|
|
|
}
|
2016-03-14 19:31:58 -04:00
|
|
|
resincludedirs {
|
|
|
|
"$(ProjectDir)src" -- fix for VS IDE
|
|
|
|
}
|
2015-12-28 20:52:31 -05:00
|
|
|
|
2016-01-04 14:58:00 -05:00
|
|
|
-- Pre-compiled header
|
|
|
|
pchheader "STDInclude.hpp" -- must be exactly same as used in #include directives
|
|
|
|
pchsource "src/STDInclude.cpp" -- real path
|
2016-06-08 11:28:58 -04:00
|
|
|
buildoptions { "/Zm200" }
|
2016-02-11 09:09:32 -05:00
|
|
|
filter "files:**.pb.*"
|
2016-02-11 09:21:20 -05:00
|
|
|
flags {
|
|
|
|
"NoPCH",
|
|
|
|
}
|
|
|
|
buildoptions {
|
|
|
|
"/wd4100", -- "Unused formal parameter"
|
2016-02-11 18:36:52 -05:00
|
|
|
"/wd6011", -- "Dereferencing NULL pointer"
|
2016-02-12 09:06:06 -05:00
|
|
|
"/wd4125", -- "Decimal digit terminates octal escape sequence"
|
2016-02-11 09:21:20 -05:00
|
|
|
}
|
|
|
|
defines {
|
|
|
|
"_SCL_SECURE_NO_WARNINGS",
|
|
|
|
}
|
2016-02-11 09:09:32 -05:00
|
|
|
filter {}
|
2016-01-03 09:01:55 -05:00
|
|
|
|
2016-02-17 12:44:33 -05:00
|
|
|
-- Dependency libraries
|
2016-06-04 11:06:49 -04:00
|
|
|
links { "zlib", "json11", "pdcurses", "libtomcrypt", "libtommath", "protobuf", "mongoose" }
|
2016-01-28 18:20:28 -05:00
|
|
|
includedirs
|
2016-02-10 08:54:50 -05:00
|
|
|
{
|
2016-01-28 18:20:28 -05:00
|
|
|
"./deps/zlib",
|
|
|
|
"./deps/json11",
|
|
|
|
"./deps/pdcurses",
|
2016-06-04 11:06:49 -04:00
|
|
|
"./deps/mongoose",
|
2016-01-28 18:20:28 -05:00
|
|
|
"./deps/libtomcrypt/src/headers",
|
2016-01-31 15:53:51 -05:00
|
|
|
"./deps/libtommath",
|
2016-02-10 08:54:50 -05:00
|
|
|
"./deps/protobuf/src",
|
2016-02-11 05:26:41 -05:00
|
|
|
"./deps/Wink-Signals",
|
2016-01-28 18:20:28 -05:00
|
|
|
}
|
2016-02-11 11:58:25 -05:00
|
|
|
|
|
|
|
-- fix vpaths for protobuf sources
|
|
|
|
vpaths {
|
|
|
|
["*"] = { "./src/**" },
|
2016-02-12 09:08:52 -05:00
|
|
|
["Proto/Generated"] = { "**.pb.*" }, -- meh.
|
2016-02-11 11:58:25 -05:00
|
|
|
}
|
2016-01-04 15:07:34 -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 {
|
2016-02-10 08:54:50 -05:00
|
|
|
["Headers/*"] = { "./src/**.hpp" },
|
2016-02-11 09:09:32 -05:00
|
|
|
["Sources/*"] = { "./src/**.cpp" },
|
2016-03-14 07:54:59 -04:00
|
|
|
["Resource/*"] = { "./src/**.rc" },
|
2016-02-11 09:09:32 -05:00
|
|
|
["Proto/Definitions/*"] = { "./src/Proto/**.proto" },
|
|
|
|
["Proto/Generated/*"] = { "**.pb.*" }, -- meh.
|
2015-12-30 22:07:16 -05:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2015-12-30 21:58:43 -05:00
|
|
|
vpaths {
|
2016-02-10 08:54:50 -05:00
|
|
|
["Docs/*"] = { "**.txt","**.md" },
|
2015-12-30 21:58:43 -05:00
|
|
|
}
|
2016-02-10 08:54:50 -05:00
|
|
|
|
2016-01-04 13:42:19 -05:00
|
|
|
-- Pre-build
|
2015-12-30 21:59:33 -05:00
|
|
|
prebuildcommands {
|
|
|
|
"cd %{_MAIN_SCRIPT_DIR}",
|
2016-02-13 08:03:23 -05:00
|
|
|
"tools\\premake5 generate-buildinfo"
|
2015-12-30 21:59:33 -05:00
|
|
|
}
|
|
|
|
|
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 {
|
2016-01-04 15:36:55 -05:00
|
|
|
"copy /y \"$(TargetDir)*.dll\" \"" .. saneCopyToPath .. "\""
|
2015-12-30 20:44:04 -05:00
|
|
|
}
|
|
|
|
end
|
2016-01-03 20:19:12 -05:00
|
|
|
|
2016-01-04 13:42:19 -05:00
|
|
|
-- Specific configurations
|
2016-01-24 06:19:34 -05:00
|
|
|
flags { "UndefinedIdentifiers", "ExtraWarnings" }
|
2016-01-04 14:06:00 -05:00
|
|
|
|
|
|
|
configuration "Release*"
|
|
|
|
flags { "FatalCompileWarnings" }
|
2016-02-11 09:09:32 -05:00
|
|
|
configuration {}
|
|
|
|
|
|
|
|
-- Generate source code from protobuf definitions
|
|
|
|
rules { "ProtobufCompiler" }
|
|
|
|
|
|
|
|
-- Workaround: Consume protobuf generated source files
|
|
|
|
matches = os.matchfiles(path.join("src/Proto/**.proto"))
|
|
|
|
for i, srcPath in ipairs(matches) do
|
|
|
|
basename = path.getbasename(srcPath)
|
|
|
|
files {
|
|
|
|
string.format("%%{prj.location}/src/proto/%s.pb.h", basename),
|
|
|
|
string.format("%%{prj.location}/src/proto/%s.pb.cc", basename),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
includedirs {
|
|
|
|
"%{prj.location}/src/proto"
|
|
|
|
}
|
2016-01-04 14:06:00 -05:00
|
|
|
|
2016-01-04 15:07:34 -05:00
|
|
|
group "External dependencies"
|
|
|
|
|
|
|
|
-- zlib
|
|
|
|
project "zlib"
|
|
|
|
language "C"
|
2016-01-04 15:37:14 -05:00
|
|
|
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 13:42:19 -05:00
|
|
|
|
2016-01-04 15:07:34 -05:00
|
|
|
kind "SharedLib"
|
|
|
|
configuration "*Static"
|
|
|
|
kind "StaticLib"
|
2016-01-04 15:37:14 -05:00
|
|
|
removedefines { "ZLIB_DLL" }
|
2016-01-05 08:39:04 -05:00
|
|
|
|
|
|
|
-- 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
|
|
|
|
2016-06-04 15:24:03 -04:00
|
|
|
-- mongoose
|
2016-06-04 11:06:49 -04:00
|
|
|
project "mongoose"
|
|
|
|
language "C"
|
|
|
|
|
|
|
|
files
|
|
|
|
{
|
|
|
|
"./deps/mongoose/*.c",
|
|
|
|
"./deps/mongoose/*.h"
|
|
|
|
}
|
|
|
|
|
|
|
|
-- 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"
|
2016-01-27 05:03:26 -05:00
|
|
|
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"
|
|
|
|
|
2016-01-27 05:03:26 -05:00
|
|
|
-- always build as static lib, as pdcurses doesn't export anything
|
|
|
|
kind "StaticLib"
|
2016-01-28 18:20:28 -05:00
|
|
|
|
|
|
|
-- libtomcrypt
|
|
|
|
project "libtomcrypt"
|
|
|
|
language "C"
|
2016-02-19 23:02:30 -05:00
|
|
|
defines { "_LIB", "LTC_SOURCE", "LTC_NO_FAST", "LTC_NO_RSA_BLINDING", "LTM_DESC", "USE_LTM", "WIN32" }
|
2016-01-31 13:50:17 -05:00
|
|
|
|
2016-01-31 15:53:51 -05:00
|
|
|
links { "libtommath" }
|
2016-01-28 18:20:28 -05:00
|
|
|
includedirs { "./deps/libtomcrypt/src/headers" }
|
2016-01-31 15:53:51 -05:00
|
|
|
includedirs { "./deps/libtommath" }
|
2016-01-28 18:20:28 -05:00
|
|
|
|
2016-01-31 09:55:32 -05:00
|
|
|
files { "./deps/libtomcrypt/src/**.c" }
|
2016-01-28 18:20:28 -05:00
|
|
|
|
2016-02-04 16:10:50 -05:00
|
|
|
-- seems like tab stuff can be omitted
|
|
|
|
removefiles { "./deps/libtomcrypt/src/**/*tab.c" }
|
|
|
|
|
2016-02-04 15:58:49 -05:00
|
|
|
-- 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",
|
|
|
|
}
|
2016-01-28 18:20:28 -05:00
|
|
|
|
|
|
|
-- not our code, ignore POSIX usage warnings for now
|
|
|
|
warnings "Off"
|
|
|
|
|
2016-02-11 05:35:57 -05:00
|
|
|
-- always build as static lib, as libtomcrypt doesn't export anything
|
2016-01-28 18:20:28 -05:00
|
|
|
kind "StaticLib"
|
2016-01-31 09:55:32 -05:00
|
|
|
|
2016-01-31 15:53:51 -05:00
|
|
|
-- libtommath
|
|
|
|
project "libtommath"
|
2016-01-31 09:55:32 -05:00
|
|
|
language "C"
|
|
|
|
defines { "_LIB" }
|
2016-01-31 15:53:51 -05:00
|
|
|
includedirs { "./deps/libtommath" }
|
2016-01-31 09:55:32 -05:00
|
|
|
|
2016-01-31 15:53:51 -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"
|
|
|
|
|
2016-02-11 05:35:57 -05:00
|
|
|
-- always build as static lib, as libtommath doesn't export anything
|
2016-01-31 09:55:32 -05:00
|
|
|
kind "StaticLib"
|
2016-02-09 19:56:06 -05:00
|
|
|
|
|
|
|
-- protobuf
|
|
|
|
project "protobuf"
|
|
|
|
language "C++"
|
|
|
|
links { "zlib" }
|
|
|
|
defines { "_SCL_SECURE_NO_WARNINGS" }
|
|
|
|
includedirs
|
|
|
|
{
|
|
|
|
"./deps/zlib",
|
|
|
|
"./deps/protobuf/src",
|
|
|
|
}
|
|
|
|
|
2016-02-10 08:54:50 -05:00
|
|
|
-- default protobuf sources
|
2016-02-09 19:56:06 -05:00
|
|
|
files { "./deps/protobuf/src/**.cc" }
|
2016-02-11 09:09:32 -05:00
|
|
|
|
2016-02-09 19:56:06 -05:00
|
|
|
-- remove unnecessary sources
|
|
|
|
removefiles
|
|
|
|
{
|
|
|
|
"./deps/protobuf/src/**/*test.cc",
|
|
|
|
"./deps/protobuf/src/google/protobuf/*test*.cc",
|
|
|
|
|
|
|
|
"./deps/protobuf/src/google/protobuf/testing/**.cc",
|
|
|
|
"./deps/protobuf/src/google/protobuf/compiler/**.cc",
|
|
|
|
|
|
|
|
"./deps/protobuf/src/google/protobuf/arena_nc.cc",
|
|
|
|
"./deps/protobuf/src/google/protobuf/util/internal/error_listener.cc",
|
|
|
|
"./deps/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc",
|
|
|
|
}
|
|
|
|
|
|
|
|
-- not our code, ignore POSIX usage warnings for now
|
|
|
|
warnings "Off"
|
|
|
|
|
2016-02-11 05:35:57 -05:00
|
|
|
-- always build as static lib, as we include our custom classes and therefore can't perform shared linking
|
2016-02-09 19:56:06 -05:00
|
|
|
kind "StaticLib"
|
2016-02-11 09:09:32 -05:00
|
|
|
|
|
|
|
rule "ProtobufCompiler"
|
|
|
|
display "Protobuf compiler"
|
|
|
|
location "./build"
|
|
|
|
fileExtension ".proto"
|
|
|
|
buildmessage "Compiling %(Identity) with protoc..."
|
|
|
|
buildcommands {
|
|
|
|
'@echo off',
|
|
|
|
'path "$(SolutionDir)\\..\\tools"',
|
|
|
|
'if not exist "$(ProjectDir)\\src\\proto" mkdir "$(ProjectDir)\\src\\proto"',
|
2016-02-11 12:46:24 -05:00
|
|
|
'protoc --error_format=msvs -I=%(RelativeDir) --cpp_out=src\\proto %(Identity)',
|
2016-02-11 09:09:32 -05:00
|
|
|
}
|
|
|
|
buildoutputs {
|
|
|
|
'$(ProjectDir)\\src\\proto\\%(Filename).pb.cc',
|
|
|
|
'$(ProjectDir)\\src\\proto\\%(Filename).pb.h',
|
|
|
|
}
|