bgfx/premake/premake4.lua

320 lines
7.5 KiB
Lua
Raw Normal View History

2012-04-04 07:30:07 +04:00
--
2012-09-17 04:36:08 +04:00
-- Copyright 2010-2012 Branimir Karadzic. All rights reserved.
2012-04-04 07:30:07 +04:00
-- License: http://www.opensource.org/licenses/BSD-2-Clause
--
solution "bgfx"
configurations {
"Debug",
"Release",
}
platforms {
"x32",
"x64",
"Xbox360",
}
language "C++"
newoption {
trigger = "gcc",
value = "GCC",
description = "Choose GCC flavor",
allowed = {
2012-10-22 09:09:14 +04:00
{ "emscripten", "Emscripten" },
2012-06-02 23:44:37 +04:00
{ "linux", "Linux" },
2012-04-04 07:30:07 +04:00
{ "mingw", "MinGW" },
2012-12-09 03:24:51 +04:00
{ "nacl", "Native Client" },
{ "pnacl", "Native Client - PNaCl" },
2012-04-04 07:30:07 +04:00
}
}
-- Avoid error when invoking premake4 --help.
if (_ACTION == nil) then return end
2012-06-02 06:55:56 +04:00
BGFX_DIR = (path.getabsolute("..") .. "/")
local BGFX_BUILD_DIR = (BGFX_DIR .. ".build/")
local BGFX_THIRD_PARTY_DIR = (BGFX_DIR .. "3rdparty/")
2012-04-04 07:30:07 +04:00
2012-12-09 03:24:51 +04:00
BX_DIR = (BGFX_DIR .. "../bx/")
2012-09-17 04:36:08 +04:00
2012-04-04 07:30:07 +04:00
local XEDK = os.getenv("XEDK")
if not XEDK then XEDK = "<you must install XBOX SDK>" end
2012-06-02 06:55:56 +04:00
location (BGFX_BUILD_DIR .. "projects/" .. _ACTION)
2012-04-04 07:30:07 +04:00
2012-06-02 23:44:37 +04:00
if _ACTION == "clean" then
os.rmdir(BUILD_DIR)
end
2012-04-04 07:30:07 +04:00
if _ACTION == "gmake" then
2012-06-02 23:44:37 +04:00
if nil == _OPTIONS["gcc"] then
print("GCC flavor must be specified!")
os.exit(1)
end
2012-05-07 03:45:30 +04:00
flags {
"ExtraWarnings",
}
2012-10-22 09:09:14 +04:00
if "emscripten" == _OPTIONS["gcc"] then
2012-10-23 06:39:59 +04:00
if not os.getenv("EMSCRIPTEN") then
print("Set EMSCRIPTEN enviroment variables.")
end
premake.gcc.cc = "$(EMSCRIPTEN)/emcc"
premake.gcc.cxx = "$(EMSCRIPTEN)/em++"
premake.gcc.ar = "$(EMSCRIPTEN)/emar"
2012-10-22 09:09:14 +04:00
location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-emscripten")
end
2012-06-02 23:44:37 +04:00
if "linux" == _OPTIONS["gcc"] then
location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-linux")
2012-04-04 07:30:07 +04:00
end
if "mingw" == _OPTIONS["gcc"] then
premake.gcc.cc = "$(MINGW)/bin/mingw32-gcc"
premake.gcc.cxx = "$(MINGW)/bin/mingw32-g++"
premake.gcc.ar = "$(MINGW)/bin/ar"
2012-06-02 23:44:37 +04:00
location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-mingw")
2012-04-04 07:30:07 +04:00
end
2012-05-07 03:45:30 +04:00
if "nacl" == _OPTIONS["gcc"] then
if not os.getenv("NACL") then
print("Set NACL enviroment variables.")
end
premake.gcc.cc = "$(NACL)/bin/x86_64-nacl-gcc"
premake.gcc.cxx = "$(NACL)/bin/x86_64-nacl-g++"
premake.gcc.ar = "$(NACL)/bin/x86_64-nacl-ar"
2012-06-02 06:55:56 +04:00
location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-nacl")
2012-05-07 03:45:30 +04:00
end
2012-12-09 03:24:51 +04:00
if "pnacl" == _OPTIONS["gcc"] then
if not os.getenv("PNACL") then
print("Set PNACL enviroment variables.")
end
premake.gcc.cc = "$(PNACL)/bin/pnacl-clang"
premake.gcc.cxx = "$(PNACL)/bin/pnacl-clang++"
premake.gcc.ar = "$(PNACL)/bin/pnacl-ar"
location (BGFX_BUILD_DIR .. "projects/" .. _ACTION .. "-pnacl")
end
2012-04-04 07:30:07 +04:00
end
flags {
"StaticRuntime",
"NoMinimalRebuild",
"NoPCH",
"NativeWChar",
"NoRTTI",
"NoExceptions",
2012-05-07 03:45:30 +04:00
"NoEditAndContinue",
2012-04-04 07:30:07 +04:00
"Symbols",
}
2012-06-02 23:44:37 +04:00
defines {
"__STDC_LIMIT_MACROS",
"__STDC_FORMAT_MACROS",
"__STDC_CONSTANT_MACROS",
}
2012-04-04 07:30:07 +04:00
configuration "Debug"
targetsuffix "Debug"
configuration "Release"
2012-05-07 03:45:30 +04:00
flags {
"OptimizeSpeed",
2012-04-04 07:30:07 +04:00
}
targetsuffix "Release"
configuration { "vs*" }
2012-09-17 04:36:08 +04:00
includedirs { BX_DIR .. "include/compat/msvc" }
2012-04-04 07:30:07 +04:00
defines {
2012-06-02 23:44:37 +04:00
"WIN32",
"_WIN32",
2012-04-04 07:30:07 +04:00
"_HAS_EXCEPTIONS=0",
"_HAS_ITERATOR_DEBUGGING=0",
"_SCL_SECURE=0",
2012-06-02 23:44:37 +04:00
"_SECURE_SCL=0",
"_SCL_SECURE_NO_WARNINGS",
2012-04-04 07:30:07 +04:00
"_CRT_SECURE_NO_WARNINGS",
"_CRT_SECURE_NO_DEPRECATE",
2012-06-02 23:44:37 +04:00
}
buildoptions {
"/Oy-", -- Suppresses creation of frame pointers on the call stack.
"/Ob2", -- The Inline Function Expansion
2012-04-04 07:30:07 +04:00
}
configuration { "x32", "vs*" }
2012-06-02 06:55:56 +04:00
targetdir (BGFX_BUILD_DIR .. "win32_" .. _ACTION .. "/bin")
objdir (BGFX_BUILD_DIR .. "win32_" .. _ACTION .. "/obj")
libdirs {
BGFX_THIRD_PARTY_DIR .. "lib/win32_" .. _ACTION,
"$(DXSDK_DIR)/lib/x86",
}
2012-04-04 07:30:07 +04:00
configuration { "x64", "vs*" }
2012-06-02 23:44:37 +04:00
defines { "_WIN64" }
2012-06-02 06:55:56 +04:00
targetdir (BGFX_BUILD_DIR .. "win64_" .. _ACTION .. "/bin")
objdir (BGFX_BUILD_DIR .. "win64_" .. _ACTION .. "/obj")
libdirs {
BGFX_THIRD_PARTY_DIR .. "lib/win64_" .. _ACTION,
"$(DXSDK_DIR)/lib/x64",
}
2012-04-04 07:30:07 +04:00
2012-06-02 23:44:37 +04:00
configuration { "mingw" }
2012-04-04 07:30:07 +04:00
defines { "WIN32" }
2012-09-17 04:36:08 +04:00
includedirs { BX_DIR .. "include/compat/mingw" }
2012-06-02 23:44:37 +04:00
buildoptions {
2012-10-28 10:59:44 +04:00
"-std=c++0x",
2012-06-02 23:44:37 +04:00
"-U__STRICT_ANSI__",
"-Wunused-value",
"-fdata-sections",
"-ffunction-sections",
-- "-fmerge-all-constants"
}
linkoptions {
"-Wl,--gc-sections",
}
configuration { "x32", "mingw" }
2012-06-02 06:55:56 +04:00
targetdir (BGFX_BUILD_DIR .. "win32_mingw" .. "/bin")
objdir (BGFX_BUILD_DIR .. "win32_mingw" .. "/obj")
libdirs {
BGFX_THIRD_PARTY_DIR .. "lib/win32_mingw",
"$(DXSDK_DIR)/lib/x86",
}
2012-06-02 23:44:37 +04:00
buildoptions { "-m32" }
2012-04-04 07:30:07 +04:00
configuration { "x64", "mingw" }
2012-06-02 06:55:56 +04:00
targetdir (BGFX_BUILD_DIR .. "win64_mingw" .. "/bin")
objdir (BGFX_BUILD_DIR .. "win64_mingw" .. "/obj")
libdirs {
BGFX_THIRD_PARTY_DIR .. "lib/win64_mingw",
"$(DXSDK_DIR)/lib/x64",
}
2012-06-02 23:44:37 +04:00
buildoptions { "-m64" }
configuration { "linux" }
buildoptions {
2012-10-28 10:59:44 +04:00
"-std=c++0x",
2012-06-02 23:44:37 +04:00
"-U__STRICT_ANSI__",
"-Wunused-value",
"-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
"-msse2",
}
2012-11-12 01:12:16 +04:00
links {
"rt",
}
2012-06-02 23:44:37 +04:00
linkoptions {
"-Wl,--gc-sections",
}
configuration { "linux", "x32" }
targetdir (BGFX_BUILD_DIR .. "linux32_gcc" .. "/bin")
objdir (BGFX_BUILD_DIR .. "linux32_gcc" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/linux32_gcc" }
buildoptions {
"-m32",
}
configuration { "linux", "x64" }
targetdir (BGFX_BUILD_DIR .. "linux64_gcc" .. "/bin")
objdir (BGFX_BUILD_DIR .. "linux64_gcc" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/linux64_gcc" }
buildoptions {
"-m64",
}
2012-04-04 07:30:07 +04:00
2012-10-22 09:09:14 +04:00
configuration { "emscripten" }
targetdir (BGFX_BUILD_DIR .. "emscripten" .. "/bin")
objdir (BGFX_BUILD_DIR .. "emscripten" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/emscripten" }
2012-10-23 06:39:59 +04:00
includedirs { "$(EMSCRIPTEN)/system/include" }
buildoptions {
"-pthread",
}
2012-10-22 09:09:14 +04:00
2012-05-07 03:45:30 +04:00
configuration { "nacl" }
defines { "_BSD_SOURCE=1", "_POSIX_C_SOURCE=199506", "_XOPEN_SOURCE=600" }
2012-09-17 04:36:08 +04:00
includedirs { BX_DIR .. "include/compat/nacl" }
2012-05-07 03:45:30 +04:00
buildoptions {
2012-10-28 10:59:44 +04:00
"-std=c++0x",
2012-05-07 03:45:30 +04:00
"-U__STRICT_ANSI__",
"-pthread",
"-fno-stack-protector",
"-fdiagnostics-show-option",
"-Wunused-value",
"-fdata-sections",
"-ffunction-sections",
"-mfpmath=sse", -- force SSE to get 32-bit and 64-bit builds deterministic.
"-msse2",
-- "-fmerge-all-constants",
}
linkoptions {
"-Wl,--gc-sections",
}
configuration { "x32", "nacl" }
2012-06-02 06:55:56 +04:00
targetdir (BGFX_BUILD_DIR .. "nacl-x86" .. "/bin")
objdir (BGFX_BUILD_DIR .. "nacl-x86" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/nacl-x86" }
2012-06-02 23:44:37 +04:00
linkoptions { "-melf32_nacl" }
2012-05-07 03:45:30 +04:00
configuration { "x64", "nacl" }
2012-06-02 06:55:56 +04:00
targetdir (BGFX_BUILD_DIR .. "nacl-x64" .. "/bin")
objdir (BGFX_BUILD_DIR .. "nacl-x64" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/nacl-x64" }
2012-06-02 23:44:37 +04:00
linkoptions { "-melf64_nacl" }
2012-04-04 07:30:07 +04:00
2012-12-09 03:24:51 +04:00
configuration { "pnacl" }
defines { "_BSD_SOURCE=1", "_POSIX_C_SOURCE=199506", "_XOPEN_SOURCE=600", "__native_client__", "__LITTLE_ENDIAN__" }
includedirs { BX_DIR .. "include/compat/nacl" }
buildoptions {
"-std=c++0x",
"-U__STRICT_ANSI__",
"-fno-stack-protector",
"-fdiagnostics-show-option",
"-Wunused-value",
"-fdata-sections",
"-ffunction-sections",
}
targetdir (BGFX_BUILD_DIR .. "pnacl" .. "/bin")
objdir (BGFX_BUILD_DIR .. "pnacl" .. "/obj")
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/pnacl" }
includedirs { "$(PNACL)/sysroot/include" }
2012-04-04 07:30:07 +04:00
configuration { "Xbox360" }
2012-06-02 06:55:56 +04:00
targetdir (BGFX_BUILD_DIR .. "xbox360" .. "/bin")
objdir (BGFX_BUILD_DIR .. "xbox360" .. "/obj")
2012-09-17 04:36:08 +04:00
includedirs { BX_DIR .. "include/compat/msvc" }
2012-06-02 23:44:37 +04:00
libdirs { BGFX_THIRD_PARTY_DIR .. "lib/xbox360" }
defines {
"NOMINMAX",
"_XBOX",
}
2012-04-04 07:30:07 +04:00
configuration {} -- reset configuration
2012-06-02 08:56:20 +04:00
function copyLib()
end
2012-06-02 06:55:56 +04:00
dofile "bgfx.lua"
dofile "makedisttex.lua"
dofile "shaderc.lua"
dofile "texturec.lua"
2012-10-08 07:41:18 +04:00
dofile "openctm.lua"
2012-09-17 04:36:08 +04:00
dofile "example-00-helloworld.lua"
dofile "example-01-cubes.lua"
dofile "example-02-metaballs.lua"
2012-10-08 07:41:18 +04:00
dofile "example-03-raymarch.lua"
dofile "example-04-mesh.lua"
2012-10-09 10:24:10 +04:00
dofile "example-05-instancing.lua"
2012-10-28 08:34:41 +04:00
dofile "example-06-bump.lua"