Index: ps/trunk/build/jenkins/build-patch.sh =================================================================== --- ps/trunk/build/jenkins/build-patch.sh (revision 20380) +++ ps/trunk/build/jenkins/build-patch.sh (revision 20381) @@ -1,98 +1,98 @@ #!/bin/sh set -e # This script allows Jenkins to build and test a patch inside the phabricator # workspace. # The important thing is determining how much cleanup is needed. For instance, # if a patch adds a source file, it is necessary to delete it afterwards and # remove all related build artifacts. It will also be necessary to rebuild the game # for testing the next patch, even if that new patch doesn't change the code. # However, rebuilding everything each time is expensive and prevents us from # handling a decent input of patches on Phabricator. # This script does its best to determine a somewhat minimal necessary amount of # cleanup, and resorts to a clean checkout in case of failure. if [ -z "$DIFF_ID" ]; then echo 'No patch ID provided, aborting' exit 1 fi # Build environment JOBS=${JOBS:="-j2"} # Move to the root of the repository (this script is in build/jenkins/) cd "$(dirname $0)"/../../ # Utility functions fully_cleaned=false patch() { # Revert previously applied changes or deleted files (see full_cleanup). svn revert -R . # Removing non-ignored files from binaries/data/ might be necessary and # doesn't impact the build, so do it each time. svn status binaries/data/ | cut -c 9- | xargs rm -rf # If we have non-ignored files under source/, we must delete them and # clean the workspaces. if [ "$(svn status source/)" ]; then svn status source/ | cut -c 9- | xargs rm -rf build/workspaces/clean-workspaces.sh --preserve-libs fi # Apply the patch # Patch errors (including successful hunks) are written to the Phab comment. # If patching is successful, this will be overwritten in the build() step. # If patching fails, the comment will be explicit about it. arc patch --diff "$DIFF_ID" --force 2> .phabricator-comment } full_cleanup() { fully_cleaned=true svn st --no-ignore | cut -c 9- | xargs rm -rf patch # patch will revert everything, so don't worry about deleted files } build() { { echo 'Updating workspaces...' - build/workspaces/update-workspaces.sh "${JOBS}" --with-system-nvtt --without-miniupnpc 2>&1 1>/dev/null + build/workspaces/update-workspaces.sh "${JOBS}" --premake4 --with-system-nvtt --without-miniupnpc 2>&1 1>/dev/null cd build/workspaces/gcc echo 'Build (release)...' make "${JOBS}" config=release 2>&1 1>/dev/null echo 'Build (debug)...' make "${JOBS}" config=debug 2>&1 1>/dev/null cd ../../../binaries/system echo 'Running release tests...' ./test 2>&1 echo 'Running debug tests...' ./test_dbg 2>&1 cd ../../source/tools/xmlvalidator echo 'Checking XML files...' perl validate.pl 2>&1 1>/dev/null } > .phabricator-comment } # Try to patch, if that manages to fail, clean up everything. # If it patches, make sure the libraries are not touched. if ! patch; then full_cleanup elif svn status libraries/source/ | grep -v '^?' >/dev/null 2>&1; then full_cleanup fi # Try to build, if that fails, clean up everything. if ! build && [ "$fully_cleaned" != true ]; then full_cleanup build fi Index: ps/trunk/build/premake/cxxtest/README.md =================================================================== --- ps/trunk/build/premake/cxxtest/README.md (nonexistent) +++ ps/trunk/build/premake/cxxtest/README.md (revision 20381) @@ -0,0 +1 @@ +This premake module adds supports for CxxTest (http://cxxtest.com/). Index: ps/trunk/build/premake/cxxtest/cxxtest.lua =================================================================== --- ps/trunk/build/premake/cxxtest/cxxtest.lua (nonexistent) +++ ps/trunk/build/premake/cxxtest/cxxtest.lua (revision 20381) @@ -0,0 +1,57 @@ +local m = {} +m._VERSION = "1.0.0-dev" + +m.path = nil + +-- We need to create .cpp files from the .h files before they can be compiled. +-- This is done by the cxxtestgen utility. + +-- We use a custom build rule for headers in order to generate the .cpp files. +-- This has several advantages over using pre-build commands: +-- - It cannot break when running parallel builds +-- - No new generation happens when the header files are untouched + +function m.configure_project(rootfile, hdrfiles, rootoptions, testoptions) + if rootoptions == nil then + rootoptions = '' + end + if testoptions == nil then + testoptions = '' + end + + local abspath = path.getabsolute(m.path) + local rootpath = path.getabsolute(rootfile) + + -- Add headers + + for _,hdrfile in ipairs(hdrfiles) do + files { hdrfile } + end + + -- Generate the source files from headers + + -- This first one is a hack, precompiled has nothing to do with the test runner, + -- but we need to make the file compilation depend on its generation (which + -- buildoutputs does). + -- Ideally premake should have an API to specify pre-build commands per file. + filter { "files:**precompiled.h" } + buildmessage 'Generating root file' + buildcommands { abspath.." --root "..rootoptions.." -o "..rootpath } + buildoutputs { rootpath } + filter { "files:**.h", "files:not **precompiled.h" } + buildmessage 'Generating %{file.basename}.cpp' + buildcommands { abspath.." --part "..testoptions.." -o %{file.directory}/%{file.basename}.cpp %{file.relpath}" } + buildoutputs { "%{file.directory}/%{file.basename}.cpp" } + filter {} + + -- Add source files + + files { rootfile } + + for _,hdrfile in ipairs(hdrfiles) do + local srcfile = string.sub(hdrfile, 1, -3) .. ".cpp" + files { srcfile } + end +end + +return m Index: ps/trunk/build/premake/extern_libs5.lua =================================================================== --- ps/trunk/build/premake/extern_libs5.lua (nonexistent) +++ ps/trunk/build/premake/extern_libs5.lua (revision 20381) @@ -0,0 +1,713 @@ +-- this file provides project_add_extern_libs, which takes care of the +-- dirty details of adding the libraries' include and lib paths. +-- +-- TYPICAL TASK: add new library. Instructions: +-- 1) add a new extern_lib_defs entry +-- 2) add library name to extern_libs tables in premake.lua for all 'projects' that want to use it + +-- directory in which OS-specific library subdirectories reside. +if os.istarget("macosx") then + libraries_dir = rootdir.."/libraries/osx/" +elseif os.istarget("windows") then + libraries_dir = rootdir.."/libraries/win32/" +else + -- No Unix-specific libs yet (use source directory instead!) +end +-- directory for shared, bundled libraries +libraries_source_dir = rootdir.."/libraries/source/" +third_party_source_dir = rootdir.."/source/third_party/" + +local function add_default_lib_paths(extern_lib) + libdirs { libraries_dir .. extern_lib .. "/lib" } +end + +local function add_source_lib_paths(extern_lib) + libdirs { libraries_source_dir .. extern_lib .. "/lib" } +end + +local function add_default_include_paths(extern_lib) + sysincludedirs { libraries_dir .. extern_lib .. "/include" } +end + +local function add_source_include_paths(extern_lib) + sysincludedirs { libraries_source_dir .. extern_lib .. "/include" } +end + +local function add_third_party_include_paths(extern_lib) + sysincludedirs { third_party_source_dir .. extern_lib .. "/include" } +end + +pkgconfig = require "pkgconfig" + + +local function add_delayload(name, suffix, def) + + if def["no_delayload"] then + return + end + + -- currently only supported by VC; nothing to do on other platforms. + if not os.istarget("windows") then + return + end + + -- no extra debug version; use same library in all configs + if suffix == "" then + linkoptions { "/DELAYLOAD:"..name..".dll" } + -- extra debug version available; use in debug config + else + local dbg_cmd = "/DELAYLOAD:" .. name .. suffix .. ".dll" + local cmd = "/DELAYLOAD:" .. name .. ".dll" + + filter "Debug" + linkoptions { dbg_cmd } + filter "Release" + linkoptions { cmd } + filter { } + end + +end + +local function add_default_links(def) + + -- careful: make sure to only use *_names when on the correct platform. + local names = {} + if os.istarget("windows") then + if def.win_names then + names = def.win_names + end + elseif _OPTIONS["android"] and def.android_names then + names = def.android_names + elseif os.istarget("linux") and def.linux_names then + names = def.linux_names + elseif os.istarget("macosx") and def.osx_names then + names = def.osx_names + elseif os.istarget("bsd") and def.bsd_names then + names = def.bsd_names + elseif def.unix_names then + names = def.unix_names + end + + local suffix = "d" + -- library is overriding default suffix (typically "" to indicate there is none) + if def["dbg_suffix"] then + suffix = def["dbg_suffix"] + end + -- non-Windows doesn't have the distinction of debug vs. release libraries + -- (to be more specific, they do, but the two are binary compatible; + -- usually only one type - debug or release - is installed at a time). + if not os.istarget("windows") then + suffix = "" + end + + -- OS X "Frameworks" are added to the links as "name.framework" + if os.istarget("macosx") and def.osx_frameworks then + for i,name in pairs(def.osx_frameworks) do + links { name .. ".framework" } + end + else + for i,name in pairs(names) do + filter "Debug" + links { name .. suffix } + filter "Release" + links { name } + filter { } + + add_delayload(name, suffix, def) + end + end +end + +-- Library definitions +-- In a perfect world, libraries would have a common installation template, +-- i.e. location of include directory, naming convention for .lib, etc. +-- this table provides a means of working around each library's differences. +-- +-- The basic approach is defining two functions per library: +-- +-- 1. compile_settings +-- This function should set all settings requred during the compile-phase like +-- includedirs, defines etc... +-- +-- 2. link_settings +-- This function should set all settings required during the link-phase like +-- libdirs, linkflag etc... +-- +-- The main reason for separating those settings is different linking behaviour +-- on osx and xcode. For more details, read the comment in project_add_extern_libs. +-- +-- There are some helper functions for the most common tasks. You should use them +-- if they can be used in your situation to make the definitions more consistent and +-- use their default beviours as a guideline. +-- +-- +-- add_default_lib_paths(extern_lib) +-- Description: Add '//lib'to the libpaths +-- Parameters: +-- * extern_lib: to be used in the libpath. +-- +-- add_default_include_paths(extern_lib) +-- Description: Add '//include' to the includepaths +-- Parameters: +-- * extern_lib: to be used in the libpath. +-- +-- add_default_links +-- Description: Adds links to libraries and configures delayloading. +-- If the *_names parameter for a plattform is missing, no linking will be done +-- on that plattform. +-- The default assumptions are: +-- * debug import library and DLL are distinguished with a "d" suffix +-- * the library should be marked for delay-loading. +-- Parameters: +-- * win_names: table of import library / DLL names (no extension) when +-- running on Windows. +-- * unix_names: as above; shared object names when running on non-Windows. +-- * osx_names: as above; for OS X specifically (overrides unix_names if both are +-- specified) +-- * bsd_names: as above; for BSD specifically (overrides unix_names if both are +-- specified) +-- * linux_names: ditto for Linux (overrides unix_names if both given) +-- * dbg_suffix: changes the debug suffix from the above default. +-- can be "" to indicate the library doesn't have a debug build; +-- in that case, the same library (without suffix) is used in +-- all build configurations. +-- * no_delayload: indicate the library is not to be delay-loaded. +-- this is necessary for some libraries that do not support it, +-- e.g. Xerces (which is so stupid as to export variables). + +extern_lib_defs = { + boost = { + compile_settings = function() + if os.istarget("windows") then + add_default_include_paths("boost") + elseif os.istarget("macosx") then + -- Suppress all the Boost warnings on OS X by including it as a system directory + buildoptions { "-isystem../" .. libraries_dir .. "boost/include" } + end + -- TODO: This actually applies to most libraries we use on BSDs, make this a global setting. + if os.istarget("bsd") then + sysincludedirs { "/usr/local/include" } + end + end, + link_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_lib_paths("boost") + end + add_default_links({ + -- The following are not strictly link dependencies on all systems, but + -- are included for compatibility with different versions of Boost + android_names = { "boost_filesystem-gcc-mt", "boost_system-gcc-mt" }, + unix_names = { os.findlib("boost_filesystem-mt") and "boost_filesystem-mt" or "boost_filesystem", os.findlib("boost_system-mt") and "boost_system-mt" or "boost_system" }, + osx_names = { "boost_filesystem-mt", "boost_system-mt" }, + }) + end, + }, + comsuppw = { + link_settings = function() + add_default_links({ + win_names = { "comsuppw" }, + dbg_suffix = "d", + no_delayload = 1, + }) + end, + }, + cxxtest = { + compile_settings = function() + sysincludedirs { libraries_source_dir .. "cxxtest-4.4" } + end, + }, + enet = { + compile_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_include_paths("enet") + end + end, + link_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_lib_paths("enet") + end + add_default_links({ + win_names = { "enet" }, + unix_names = { "enet" }, + }) + end, + }, + fcollada = { + compile_settings = function() + add_source_include_paths("fcollada") + end, + link_settings = function() + add_source_lib_paths("fcollada") + if os.istarget("windows") then + filter "Debug" + links { "FColladaD" } + filter "Release" + links { "FCollada" } + filter { } + else + filter "Debug" + links { "FColladaSD" } + filter "Release" + links { "FColladaSR" } + filter { } + end + end, + }, + gloox = { + compile_settings = function() + if os.istarget("windows") then + add_default_include_paths("gloox") + elseif os.istarget("macosx") then + -- Support GLOOX_CONFIG for overriding the default PATH-based gloox-config + gloox_config_path = os.getenv("GLOOX_CONFIG") + if not gloox_config_path then + gloox_config_path = "gloox-config" + end + pkgconfig.add_includes(nil, gloox_config_path.." --cflags") + end + end, + link_settings = function() + if os.istarget("windows") then + add_default_lib_paths("gloox") + end + if os.istarget("macosx") then + gloox_config_path = os.getenv("GLOOX_CONFIG") + if not gloox_config_path then + gloox_config_path = "gloox-config" + end + pkgconfig.add_links(nil, gloox_config_path.." --libs") + else + -- TODO: consider using pkg-config on non-Windows (for compile_settings too) + add_default_links({ + win_names = { "gloox-1.0" }, + unix_names = { "gloox" }, + no_delayload = 1, + }) + end + end, + }, + iconv = { + compile_settings = function() + if os.istarget("windows") then + add_default_include_paths("iconv") + defines { "HAVE_ICONV_CONST" } + defines { "ICONV_CONST=const" } + defines { "LIBICONV_STATIC" } + elseif os.istarget("macosx") then + add_default_include_paths("iconv") + defines { "LIBICONV_STATIC" } + elseif os.getversion().description == "FreeBSD" then + defines { "HAVE_ICONV_CONST" } + defines { "ICONV_CONST=const" } + end + end, + link_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_lib_paths("iconv") + end + add_default_links({ + win_names = { "libiconv" }, + osx_names = { "iconv" }, + dbg_suffix = "", + no_delayload = 1, + }) + -- glibc (used on Linux and GNU/kFreeBSD) has iconv + -- FreeBSD 10+ has iconv as a part of libc + if os.istarget("bsd") + and not (os.getversion().description == "FreeBSD" and os.getversion().majorversion >= 10 + or os.getversion().description == "GNU/kFreeBSD") then + add_default_links({ + bsd_names = { "iconv" }, + }) + end + end, + }, + icu = { + compile_settings = function() + if os.istarget("windows") then + add_default_include_paths("icu") + elseif os.istarget("macosx") then + -- Support ICU_CONFIG for overriding the default PATH-based icu-config + icu_config_path = os.getenv("ICU_CONFIG") + if not icu_config_path then + icu_config_path = "icu-config" + end + pkgconfig.add_includes(nil, icu_config_path.." --cppflags") + end + end, + link_settings = function() + if os.istarget("windows") then + add_default_lib_paths("icu") + end + if os.istarget("macosx") then + icu_config_path = os.getenv("ICU_CONFIG") + if not icu_config_path then + icu_config_path = "gloox-config" + end + pkgconfig.add_links(nil, icu_config_path.." --ldflags-searchpath --ldflags-libsonly --ldflags-system") + else + add_default_links({ + win_names = { "icuuc", "icuin" }, + unix_names = { "icui18n", "icuuc" }, + dbg_suffix = "", + no_delayload = 1, + }) + end + end, + }, + libcurl = { + compile_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_include_paths("libcurl") + end + end, + link_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_lib_paths("libcurl") + end + add_default_links({ + win_names = { "libcurl" }, + unix_names = { "curl" }, + }) + end, + }, + libpng = { + compile_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_include_paths("libpng") + end + if os.getversion().description == "OpenBSD" then + sysincludedirs { "/usr/local/include/libpng" } + end + end, + link_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_lib_paths("libpng") + end + add_default_links({ + win_names = { "libpng16" }, + unix_names = { "png" }, + -- Otherwise ld will sometimes pull in ancient 1.2 from the SDK, which breaks the build :/ + -- TODO: Figure out why that happens + osx_names = { "png16" }, + }) + end, + }, + libxml2 = { + compile_settings = function() + if os.istarget("windows") then + add_default_include_paths("libxml2") + elseif os.istarget("macosx") then + -- Support XML2_CONFIG for overriding for the default PATH-based xml2-config + xml2_config_path = os.getenv("XML2_CONFIG") + if not xml2_config_path then + xml2_config_path = "xml2-config" + end + + -- use xml2-config instead of pkg-config on OS X + pkgconfig.add_includes(nil, xml2_config_path.." --cflags") + -- libxml2 needs _REENTRANT or __MT__ for thread support; + -- OS X doesn't get either set by default, so do it manually + defines { "_REENTRANT" } + else + pkgconfig.add_includes("libxml-2.0") + end + end, + link_settings = function() + if os.istarget("windows") then + add_default_lib_paths("libxml2") + filter "Debug" + links { "libxml2" } + filter "Release" + links { "libxml2" } + filter { } + elseif os.istarget("macosx") then + xml2_config_path = os.getenv("XML2_CONFIG") + if not xml2_config_path then + xml2_config_path = "xml2-config" + end + pkgconfig.add_links(nil, xml2_config_path.." --libs") + else + pkgconfig.add_links("libxml-2.0") + end + end, + }, + miniupnpc = { + compile_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_include_paths("miniupnpc") + end + end, + link_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_lib_paths("miniupnpc") + end + add_default_links({ + win_names = { "miniupnpc" }, + unix_names = { "miniupnpc" }, + }) + end, + }, + nvtt = { + compile_settings = function() + if not _OPTIONS["with-system-nvtt"] then + add_source_include_paths("nvtt") + end + defines { "NVTT_SHARED=1" } + end, + link_settings = function() + if not _OPTIONS["with-system-nvtt"] then + add_source_lib_paths("nvtt") + end + add_default_links({ + win_names = { "nvtt" }, + unix_names = { "nvcore", "nvmath", "nvimage", "nvtt" }, + osx_names = { "nvcore", "nvmath", "nvimage", "nvtt", "squish" }, + dbg_suffix = "", -- for performance we always use the release-mode version + }) + end, + }, + openal = { + compile_settings = function() + if os.istarget("windows") then + add_default_include_paths("openal") + end + end, + link_settings = function() + if os.istarget("windows") then + add_default_lib_paths("openal") + end + add_default_links({ + win_names = { "openal32" }, + unix_names = { "openal" }, + osx_frameworks = { "OpenAL" }, + dbg_suffix = "", + no_delayload = 1, -- delayload seems to cause errors on startup + }) + end, + }, + opengl = { + compile_settings = function() + if os.istarget("windows") then + add_default_include_paths("opengl") + end + end, + link_settings = function() + if os.istarget("windows") then + add_default_lib_paths("opengl") + end + if _OPTIONS["gles"] then + add_default_links({ + unix_names = { "GLESv2" }, + dbg_suffix = "", + }) + else + add_default_links({ + win_names = { "opengl32", "gdi32" }, + unix_names = { "GL" }, + osx_frameworks = { "OpenGL" }, + dbg_suffix = "", + no_delayload = 1, -- delayload seems to cause errors on startup + }) + end + end, + }, + sdl = { + compile_settings = function() + if os.istarget("windows") then + includedirs { libraries_dir .. "sdl2/include/SDL" } + elseif not _OPTIONS["android"] then + -- Support SDL2_CONFIG for overriding the default PATH-based sdl2-config + sdl_config_path = os.getenv("SDL2_CONFIG") + if not sdl_config_path then + sdl_config_path = "sdl2-config" + end + + pkgconfig.add_includes(nil, sdl_config_path.." --cflags") + end + end, + link_settings = function() + if os.istarget("windows") then + add_default_lib_paths("sdl2") + elseif not _OPTIONS["android"] then + sdl_config_path = os.getenv("SDL2_CONFIG") + if not sdl_config_path then + sdl_config_path = "sdl2-config" + end + pkgconfig.add_links(nil, sdl_config_path.." --libs") + end + end, + }, + spidermonkey = { + compile_settings = function() + if _OPTIONS["with-system-mozjs38"] then + if not _OPTIONS["android"] then + pkgconfig.add_includes("mozjs-38") + end + else + if os.istarget("windows") then + include_dir = "include-win32" + buildoptions { "/FI\"js/RequiredDefines.h\"" } + else + include_dir = "include-unix" + end + filter "Debug" + sysincludedirs { libraries_source_dir.."spidermonkey/"..include_dir.."-debug" } + defines { "DEBUG" } + filter "Release" + sysincludedirs { libraries_source_dir.."spidermonkey/"..include_dir.."-release" } + filter { } + end + end, + link_settings = function() + if _OPTIONS["with-system-mozjs38"] then + if _OPTIONS["android"] then + links { "mozjs-38" } + else + pkgconfig.add_links("nspr") + pkgconfig.add_links("mozjs-38") + end + else + if os.istarget("macosx") then + add_default_lib_paths("nspr") + links { "nspr4", "plc4", "plds4" } + end + filter "Debug" + links { "mozjs38-ps-debug" } + filter "Release" + links { "mozjs38-ps-release" } + filter { } + add_source_lib_paths("spidermonkey") + end + end, + }, + tinygettext = { + compile_settings = function() + add_third_party_include_paths("tinygettext") + end, + }, + valgrind = { + compile_settings = function() + add_source_include_paths("valgrind") + end, + }, + vorbis = { + compile_settings = function() + if os.istarget("windows") then + add_default_include_paths("vorbis") + elseif os.istarget("macosx") then + add_default_include_paths("libogg") + add_default_include_paths("vorbis") + end + end, + link_settings = function() + if os.istarget("windows") then + add_default_lib_paths("vorbis") + elseif os.istarget("macosx") then + add_default_lib_paths("libogg") + add_default_lib_paths("vorbis") + end + -- TODO: We need to force linking with these as currently + -- they need to be loaded explicitly on execution + if os.getversion().description == "OpenBSD" then + add_default_links({ + unix_names = { "ogg", + "vorbis" }, + }) + end + add_default_links({ + win_names = { "vorbisfile" }, + unix_names = { "vorbisfile" }, + osx_names = { "vorbis", "vorbisenc", "vorbisfile", "ogg" }, + dbg_suffix = "_d", + }) + end, + }, + wxwidgets = { + compile_settings = function() + if os.istarget("windows") then + includedirs { libraries_dir.."wxwidgets/include/msvc" } + add_default_include_paths("wxwidgets") + else + + -- Support WX_CONFIG for overriding for the default PATH-based wx-config + wx_config_path = os.getenv("WX_CONFIG") + if not wx_config_path then + wx_config_path = "wx-config" + end + + pkgconfig.add_includes(nil, wx_config_path.." --unicode=yes --cxxflags") + end + end, + link_settings = function() + if os.istarget("windows") then + libdirs { libraries_dir.."wxwidgets/lib/vc_lib" } + else + wx_config_path = os.getenv("WX_CONFIG") + if not wx_config_path then + wx_config_path = "wx-config" + end + pkgconfig.add_links(nil, wx_config_path.." --unicode=yes --libs std,gl") + end + end, + }, + x11 = { + link_settings = function() + add_default_links({ + win_names = { }, + unix_names = { "X11" }, + }) + end, + }, + xcursor = { + link_settings = function() + add_default_links({ + unix_names = { "Xcursor" }, + }) + end, + }, + zlib = { + compile_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_include_paths("zlib") + end + end, + link_settings = function() + if os.istarget("windows") or os.istarget("macosx") then + add_default_lib_paths("zlib") + end + add_default_links({ + win_names = { "zlib1" }, + unix_names = { "z" }, + no_delayload = 1, + }) + end, + }, +} + + +-- add a set of external libraries to the project; takes care of +-- include / lib path and linking against the import library. +-- extern_libs: table of library names [string] +-- target_type: String defining the projects kind [string] +function project_add_extern_libs(extern_libs, target_type) + + for i,extern_lib in pairs(extern_libs) do + local def = extern_lib_defs[extern_lib] + assert(def, "external library " .. extern_lib .. " not defined") + + if def.compile_settings then + def.compile_settings() + end + + -- Linking to external libraries will only be done in the main executable and not in the + -- static libraries. Premake would silently skip linking into static libraries for some + -- actions anyway (e.g. vs2010). + -- On osx using xcode, if this linking would be defined in the static libraries, it would fail to + -- link if only dylibs are available. If both *.a and *.dylib are available, it would link statically. + -- I couldn't find any problems with that approach. + if target_type ~= "StaticLib" and def.link_settings then + def.link_settings() + end + end +end Property changes on: ps/trunk/build/premake/extern_libs5.lua ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Index: ps/trunk/build/premake/pkgconfig/README.md =================================================================== --- ps/trunk/build/premake/pkgconfig/README.md (nonexistent) +++ ps/trunk/build/premake/pkgconfig/README.md (revision 20381) @@ -0,0 +1,12 @@ +This premake module adds supports for pkgconfig. + +It allows one to use the `pkg-config` command (or an alternative one like +`sdl2-config` to determine the names of libraries to be passed to the linker. + +The solution of putting directly the output (like "-Lxml2") into the linker +options creates an inconsistency between libraries using pkgconfig and the +libraries not using it. + +We should always use premake's linkoptions to specify global options and +links to specify libraries, in order to avoid ordering problems in the +list of libraries statically linked. Index: ps/trunk/build/premake/pkgconfig/pkgconfig.lua =================================================================== --- ps/trunk/build/premake/pkgconfig/pkgconfig.lua (nonexistent) +++ ps/trunk/build/premake/pkgconfig/pkgconfig.lua (revision 20381) @@ -0,0 +1,61 @@ +local m = {} +m._VERSION = "1.0.0-dev" + +local function os_capture(cmd) + return io.popen(cmd, 'r'):read('*a'):gsub("\n", " ") +end + +function m.add_includes(lib, alternative_cmd) + local result + if not alternative_cmd then + result = os_capture("pkg-config --cflags "..lib) + else + result = os_capture(alternative_cmd) + end + + local dirs = {} + local options = {} + for w in string.gmatch(result, "[^' ']+") do + if string.sub(w,1,2) == "-I" then + table.insert(dirs, string.sub(w,3)) + else + table.insert(options, w) + end + end + + sysincludedirs(dirs) + buildoptions(options) +end + +function m.add_links(lib, alternative_cmd) + local result + if not alternative_cmd then + result = os_capture("pkg-config --libs "..lib) + else + result = os_capture(alternative_cmd) + end + + -- On OSX, wx-config outputs "-framework foo" instead of "-Wl,-framework,foo" + -- which doesn't fare well with the splitting into libs, libdirs and options + -- we perform afterwards. + result = result:gsub("%-framework +(%g+)", "-Wl,-framework,%1") + + local libs = {} + local dirs = {} + local options = {} + for w in string.gmatch(result, "[^' ']+") do + if string.sub(w,1,2) == "-l" then + table.insert(libs, string.sub(w,3)) + elseif string.sub(w,1,2) == "-L" then + table.insert(dirs, string.sub(w,3)) + else + table.insert(options, w) + end + end + + links(libs) + libdirs(dirs) + linkoptions(options) +end + +return m Index: ps/trunk/build/premake/premake5.lua =================================================================== --- ps/trunk/build/premake/premake5.lua (nonexistent) +++ ps/trunk/build/premake/premake5.lua (revision 20381) @@ -0,0 +1,1457 @@ +newoption { trigger = "android", description = "Use non-working Android cross-compiling mode" } +newoption { trigger = "atlas", description = "Include Atlas scenario editor projects" } +newoption { trigger = "coverage", description = "Enable code coverage data collection (GCC only)" } +newoption { trigger = "gles", description = "Use non-working OpenGL ES 2.0 mode" } +newoption { trigger = "icc", description = "Use Intel C++ Compiler (Linux only; should use either \"--cc icc\" or --without-pch too, and then set CXX=icpc before calling make)" } +newoption { trigger = "jenkins-tests", description = "Configure CxxTest to use the XmlPrinter runner which produces Jenkins-compatible output" } +newoption { trigger = "minimal-flags", description = "Only set compiler/linker flags that are really needed. Has no effect on Windows builds" } +newoption { trigger = "outpath", description = "Location for generated project files" } +newoption { trigger = "with-system-mozjs38", description = "Search standard paths for libmozjs38, instead of using bundled copy" } +newoption { trigger = "with-system-nvtt", description = "Search standard paths for nvidia-texture-tools library, instead of using bundled copy" } +newoption { trigger = "without-audio", description = "Disable use of OpenAL/Ogg/Vorbis APIs" } +newoption { trigger = "without-lobby", description = "Disable the use of gloox and the multiplayer lobby" } +newoption { trigger = "without-miniupnpc", description = "Disable use of miniupnpc for port forwarding" } +newoption { trigger = "without-nvtt", description = "Disable use of NVTT" } +newoption { trigger = "without-pch", description = "Disable generation and usage of precompiled headers" } +newoption { trigger = "without-tests", description = "Disable generation of test projects" } + +-- OS X specific options +newoption { trigger = "macosx-bundle", description = "Enable OSX bundle, the argument is the bundle identifier string (e.g. com.wildfiregames.0ad)" } +newoption { trigger = "macosx-version-min", description = "Set minimum required version of the OS X API, the build will possibly fail if an older SDK is used, while newer API functions will be weakly linked (i.e. resolved at runtime)" } +newoption { trigger = "sysroot", description = "Set compiler system root path, used for building against a non-system SDK. For example /usr/local becomes SYSROOT/user/local" } + +-- Windows specific options +newoption { trigger = "build-shared-glooxwrapper", description = "Rebuild glooxwrapper DLL for Windows. Requires the same compiler version that gloox was built with" } +newoption { trigger = "use-shared-glooxwrapper", description = "Use prebuilt glooxwrapper DLL for Windows" } +newoption { trigger = "large-address-aware", description = "Make the executable large address aware. Do not use for development, in order to spot memory issues easily" } + +-- Install options +newoption { trigger = "bindir", description = "Directory for executables (typically '/usr/games'); default is to be relocatable" } +newoption { trigger = "datadir", description = "Directory for data files (typically '/usr/share/games/0ad'); default is ../data/ relative to executable" } +newoption { trigger = "libdir", description = "Directory for libraries (typically '/usr/lib/games/0ad'); default is ./ relative to executable" } + +-- Root directory of project checkout relative to this .lua file +rootdir = "../.." + +dofile("extern_libs5.lua") + +-- detect compiler for non-Windows +if os.istarget("macosx") then + cc = "clang" +elseif os.istarget("linux") and _OPTIONS["icc"] then + cc = "icc" +elseif not os.istarget("windows") then + cc = os.getenv("CC") + if cc == nil or cc == "" then + local hasgcc = os.execute("which gcc > .gccpath") + local f = io.open(".gccpath", "r") + local gccpath = f:read("*line") + f:close() + os.execute("rm .gccpath") + if gccpath == nil then + cc = "clang" + else + cc = "gcc" + end + end +end + +-- detect CPU architecture (simplistic, currently only supports x86, amd64 and ARM) +arch = "x86" +if _OPTIONS["android"] then + arch = "arm" +elseif os.istarget("windows") then + if os.getenv("PROCESSOR_ARCHITECTURE") == "amd64" or os.getenv("PROCESSOR_ARCHITEW6432") == "amd64" then + arch = "amd64" + end +else + arch = os.getenv("HOSTTYPE") + if arch == "x86_64" or arch == "amd64" then + arch = "amd64" + else + os.execute(cc .. " -dumpmachine > .gccmachine.tmp") + local f = io.open(".gccmachine.tmp", "r") + local machine = f:read("*line") + f:close() + if string.find(machine, "x86_64") == 1 or string.find(machine, "amd64") == 1 then + arch = "amd64" + elseif string.find(machine, "i.86") == 1 then + arch = "x86" + elseif string.find(machine, "arm") == 1 then + arch = "arm" + elseif string.find(machine, "aarch64") == 1 then + arch = "aarch64" + else + print("WARNING: Cannot determine architecture from GCC, assuming x86") + end + end +end + +-- Set up the Workspace +workspace "pyrogenesis" +targetdir(rootdir.."/binaries/system") +libdirs(rootdir.."/binaries/system") +if not _OPTIONS["outpath"] then + error("You must specify the 'outpath' parameter") +end +location(_OPTIONS["outpath"]) +configurations { "Release", "Debug" } + +source_root = rootdir.."/source/" -- default for most projects - overridden by local in others + +-- Rationale: projects should not have any additional include paths except for +-- those required by external libraries. Instead, we should always write the +-- full relative path, e.g. #include "maths/Vector3d.h". This avoids confusion +-- ("which file is meant?") and avoids enormous include path lists. + + +-- projects: engine static libs, main exe, atlas, atlas frontends, test. + +-------------------------------------------------------------------------------- +-- project helper functions +-------------------------------------------------------------------------------- + +function project_set_target(project_name) + + -- Note: On Windows, ".exe" is added on the end, on unices the name is used directly + + local obj_dir_prefix = _OPTIONS["outpath"].."/obj/"..project_name.."_" + + filter "Debug" + objdir(obj_dir_prefix.."Debug") + targetsuffix("_dbg") + + filter "Release" + objdir(obj_dir_prefix.."Release") + + filter { } + +end + + +function project_set_build_flags() + + editandcontinue "Off" + + if not _OPTIONS["minimal-flags"] then + symbols "On" + end + + if cc ~= "icc" and (os.istarget("windows") or not _OPTIONS["minimal-flags"]) then + -- adds the -Wall compiler flag + warnings "Extra" -- this causes far too many warnings/remarks on ICC + end + + -- disable Windows debug heap, since it makes malloc/free hugely slower when + -- running inside a debugger + if os.istarget("windows") then + debugenvs { "_NO_DEBUG_HEAP=1" } + end + + filter "Debug" + defines { "DEBUG" } + + filter "Release" + if os.istarget("windows") or not _OPTIONS["minimal-flags"] then + optimize "Speed" + end + defines { "NDEBUG", "CONFIG_FINAL=1" } + + filter { } + + if _OPTIONS["gles"] then + defines { "CONFIG2_GLES=1" } + end + + if _OPTIONS["without-audio"] then + defines { "CONFIG2_AUDIO=0" } + end + + if _OPTIONS["without-nvtt"] then + defines { "CONFIG2_NVTT=0" } + end + + if _OPTIONS["without-lobby"] then + defines { "CONFIG2_LOBBY=0" } + end + + if _OPTIONS["without-miniupnpc"] then + defines { "CONFIG2_MINIUPNPC=0" } + end + + -- required for the lowlevel library. must be set from all projects that use it, otherwise it assumes it is + -- being used as a DLL (which is currently not the case in 0ad) + defines { "LIB_STATIC_LINK" } + + -- various platform-specific build flags + if os.istarget("windows") then + + -- use native wchar_t type (not typedef to unsigned short) + nativewchar "on" + + else -- *nix + + -- TODO, FIXME: This check is incorrect because it means that some additional flags will be added inside the "else" branch if the + -- compiler is ICC and minimal-flags is specified (ticket: #2994) + if cc == "icc" and not _OPTIONS["minimal-flags"] then + buildoptions { + "-w1", + -- "-Wabi", + -- "-Wp64", -- complains about OBJECT_TO_JSVAL which is annoying + "-Wpointer-arith", + "-Wreturn-type", + -- "-Wshadow", + "-Wuninitialized", + "-Wunknown-pragmas", + "-Wunused-function", + "-wd1292" -- avoid lots of 'attribute "__nonnull__" ignored' + } + filter "Debug" + buildoptions { "-O0" } -- ICC defaults to -O2 + filter { } + if os.istarget("macosx") then + linkoptions { "-multiply_defined","suppress" } + end + else + -- exclude most non-essential build options for minimal-flags + if not _OPTIONS["minimal-flags"] then + buildoptions { + -- enable most of the standard warnings + "-Wno-switch", -- enumeration value not handled in switch (this is sometimes useful, but results in lots of noise) + "-Wno-reorder", -- order of initialization list in constructors (lots of noise) + "-Wno-invalid-offsetof", -- offsetof on non-POD types (see comment in renderer/PatchRData.cpp) + + "-Wextra", + "-Wno-missing-field-initializers", -- (this is common in external headers we can't fix) + + -- add some other useful warnings that need to be enabled explicitly + "-Wunused-parameter", + "-Wredundant-decls", -- (useful for finding some multiply-included header files) + -- "-Wformat=2", -- (useful sometimes, but a bit noisy, so skip it by default) + -- "-Wcast-qual", -- (useful for checking const-correctness, but a bit noisy, so skip it by default) + "-Wnon-virtual-dtor", -- (sometimes noisy but finds real bugs) + "-Wundef", -- (useful for finding macro name typos) + + -- enable security features (stack checking etc) that shouldn't have + -- a significant effect on performance and can catch bugs + "-fstack-protector-all", + "-U_FORTIFY_SOURCE", -- (avoid redefinition warning if already defined) + "-D_FORTIFY_SOURCE=2", + + -- always enable strict aliasing (useful in debug builds because of the warnings) + "-fstrict-aliasing", + + -- don't omit frame pointers (for now), because performance will be impacted + -- negatively by the way this breaks profilers more than it will be impacted + -- positively by the optimisation + "-fno-omit-frame-pointer" + } + + if not _OPTIONS["without-pch"] then + buildoptions { + -- do something (?) so that ccache can handle compilation with PCH enabled + -- (ccache 3.1+ also requires CCACHE_SLOPPINESS=time_macros for this to work) + "-fpch-preprocess" + } + end + + if os.istarget("linux") or os.istarget("bsd") then + buildoptions { "-fPIC" } + linkoptions { "-Wl,--no-undefined", "-Wl,--as-needed" } + end + + if arch == "x86" then + buildoptions { + -- To support intrinsics like __sync_bool_compare_and_swap on x86 + -- we need to set -march to something that supports them (i686). + -- We use pentium3 to also enable other features like mmx and sse, + -- while tuning for generic to have good performance on every + -- supported CPU. + -- Note that all these features are already supported on amd64. + "-march=pentium3 -mtune=generic" + } + end + end + + buildoptions { + -- Enable C++11 standard. + "-std=c++0x" + } + + if arch == "arm" then + -- disable warnings about va_list ABI change and use + -- compile-time flags for futher configuration. + buildoptions { "-Wno-psabi" } + if _OPTIONS["android"] then + -- Android uses softfp, so we should too. + buildoptions { "-mfloat-abi=softfp" } + end + end + + if _OPTIONS["coverage"] then + buildoptions { "-fprofile-arcs", "-ftest-coverage" } + links { "gcov" } + end + + -- We don't want to require SSE2 everywhere yet, but OS X headers do + -- require it (and Intel Macs always have it) so enable it here + if os.istarget("macosx") then + buildoptions { "-msse2" } + end + + -- Check if SDK path should be used + if _OPTIONS["sysroot"] then + buildoptions { "-isysroot " .. _OPTIONS["sysroot"] } + linkoptions { "-Wl,-syslibroot," .. _OPTIONS["sysroot"] } + end + + -- On OS X, sometimes we need to specify the minimum API version to use + if _OPTIONS["macosx-version-min"] then + buildoptions { "-mmacosx-version-min=" .. _OPTIONS["macosx-version-min"] } + -- clang and llvm-gcc look at mmacosx-version-min to determine link target + -- and CRT version, and use it to set the macosx_version_min linker flag + linkoptions { "-mmacosx-version-min=" .. _OPTIONS["macosx-version-min"] } + end + + -- Check if we're building a bundle + if _OPTIONS["macosx-bundle"] then + defines { "BUNDLE_IDENTIFIER=" .. _OPTIONS["macosx-bundle"] } + end + + -- On OS X, force using libc++ since it has better C++11 support, + -- now required by the game + if os.istarget("macosx") then + buildoptions { "-stdlib=libc++" } + linkoptions { "-stdlib=libc++" } + end + end + + buildoptions { + -- Hide symbols in dynamic shared objects by default, for efficiency and for equivalence with + -- Windows - they should be exported explicitly with __attribute__ ((visibility ("default"))) + "-fvisibility=hidden" + } + + if _OPTIONS["bindir"] then + defines { "INSTALLED_BINDIR=" .. _OPTIONS["bindir"] } + end + if _OPTIONS["datadir"] then + defines { "INSTALLED_DATADIR=" .. _OPTIONS["datadir"] } + end + if _OPTIONS["libdir"] then + defines { "INSTALLED_LIBDIR=" .. _OPTIONS["libdir"] } + end + + if os.istarget("linux") or os.istarget("bsd") then + -- To use our local shared libraries, they need to be found in the + -- runtime dynamic linker path. Add their path to -rpath. + if _OPTIONS["libdir"] then + linkoptions {"-Wl,-rpath," .. _OPTIONS["libdir"] } + else + -- On FreeBSD we need to allow use of $ORIGIN + if os.istarget("bsd") then + linkoptions { "-Wl,-z,origin" } + end + + -- Adding the executable path and taking care of correct escaping + if _ACTION == "gmake" then + linkoptions { "-Wl,-rpath,'$$ORIGIN'" } + elseif _ACTION == "codeblocks" then + linkoptions { "-Wl,-R\\\\$$$ORIGIN" } + end + end + end + + end +end + +-- add X11 includes paths after all the others so they don't conflict with +-- bundled libs +function project_add_x11_dirs() + if not os.istarget("windows") and not os.istarget("macosx") then + -- X11 includes may be installed in one of a gadzillion of five places + -- Famous last words: "You can't include too much! ;-)" + sysincludedirs { + "/usr/X11R6/include/X11", + "/usr/X11R6/include", + "/usr/local/include/X11", + "/usr/local/include", + "/usr/include/X11" + } + libdirs { "/usr/X11R6/lib" } + end +end + +-- create a project and set the attributes that are common to all projects. +function project_create(project_name, target_type) + + project(project_name) + language "C++" + kind(target_type) + + filter "action:vs2013" + characterset "MBCS" + toolset "v120_xp" + filter {} + + project_set_target(project_name) + project_set_build_flags() +end + + +-- OSX creates a .app bundle if the project type of the main application is set to "WindowedApp". +-- We don't want this because this bundle would be broken (it lacks all the resources and external dependencies, Info.plist etc...) +-- Windows opens a console in the background if it's set to ConsoleApp, which is not what we want. +-- I didn't check if this setting matters for linux, but WindowedApp works there. +function get_main_project_target_type() + if _OPTIONS["android"] then + return "SharedLib" + elseif os.istarget("macosx") then + return "ConsoleApp" + else + return "WindowedApp" + end +end + + +-- source_root: rel_source_dirs and rel_include_dirs are relative to this directory +-- rel_source_dirs: A table of subdirectories. All source files in these directories are added. +-- rel_include_dirs: A table of subdirectories to be included. +-- extra_params: table including zero or more of the following: +-- * no_pch: If specified, no precompiled headers are used for this project. +-- * pch_dir: If specified, this directory will be used for precompiled headers instead of the default +-- /pch//. +-- * extra_files: table of filenames (relative to source_root) to add to project +-- * extra_links: table of library names to add to link step +function project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) + + for i,v in pairs(rel_source_dirs) do + local prefix = source_root..v.."/" + files { prefix.."*.cpp", prefix.."*.h", prefix.."*.inl", prefix.."*.js", prefix.."*.asm", prefix.."*.mm" } + end + + -- Put the project-specific PCH directory at the start of the + -- include path, so '#include "precompiled.h"' will look in + -- there first + local pch_dir + if not extra_params["pch_dir"] then + pch_dir = source_root .. "pch/" .. project().name .. "/" + else + pch_dir = extra_params["pch_dir"] + end + includedirs { pch_dir } + + -- Precompiled Headers + -- rationale: we need one PCH per static lib, since one global header would + -- increase dependencies. To that end, we can either include them as + -- "projectdir/precompiled.h", or add "source/PCH/projectdir" to the + -- include path and put the PCH there. The latter is better because + -- many projects contain several dirs and it's unclear where there the + -- PCH should be stored. This way is also a bit easier to use in that + -- source files always include "precompiled.h". + -- Notes: + -- * Visual Assist manages to use the project include path and can + -- correctly open these files from the IDE. + -- * precompiled.cpp (needed to "Create" the PCH) also goes in + -- the abovementioned dir. + if (not _OPTIONS["without-pch"] and not extra_params["no_pch"]) then + filter "action:vs*" + pchheader("precompiled.h") + filter "action:xcode*" + pchheader("../"..pch_dir.."precompiled.h") + filter { "action:not vs*", "action:not xcode*" } + pchheader(pch_dir.."precompiled.h") + filter {} + pchsource(pch_dir.."precompiled.cpp") + defines { "USING_PCH" } + files { pch_dir.."precompiled.h", pch_dir.."precompiled.cpp" } + else + flags { "NoPCH" } + end + + -- next is source root dir, for absolute (nonrelative) includes + -- (e.g. "lib/precompiled.h") + includedirs { source_root } + + for i,v in pairs(rel_include_dirs) do + includedirs { source_root .. v } + end + + if extra_params["extra_files"] then + for i,v in pairs(extra_params["extra_files"]) do + -- .rc files are only needed on Windows + if path.getextension(v) ~= ".rc" or os.istarget("windows") then + files { source_root .. v } + end + end + end + + if extra_params["extra_links"] then + links { extra_params["extra_links"] } + end +end + + +-- Add command-line options to set up the manifest dependencies for Windows +-- (See lib/sysdep/os/win/manifest.cpp) +function project_add_manifest() + linkoptions { "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df'\"" } +end + +-------------------------------------------------------------------------------- +-- engine static libraries +-------------------------------------------------------------------------------- + +-- the engine is split up into several static libraries. this eases separate +-- distribution of those components, reduces dependencies a bit, and can +-- also speed up builds. +-- more to the point, it is necessary to efficiently support a separate +-- test executable that also includes much of the game code. + +-- names of all static libs created. automatically added to the +-- main app project later (see explanation at end of this file) +static_lib_names = {} +static_lib_names_debug = {} +static_lib_names_release = {} + +-- set up one of the static libraries into which the main engine code is split. +-- extra_params: +-- no_default_link: If specified, linking won't be done by default. +-- For the rest of extra_params, see project_add_contents(). +-- note: rel_source_dirs and rel_include_dirs are relative to global source_root. +function setup_static_lib_project (project_name, rel_source_dirs, extern_libs, extra_params) + + local target_type = "StaticLib" + project_create(project_name, target_type) + project_add_contents(source_root, rel_source_dirs, {}, extra_params) + project_add_extern_libs(extern_libs, target_type) + project_add_x11_dirs() + + if not extra_params["no_default_link"] then + table.insert(static_lib_names, project_name) + end + + if os.istarget("windows") then + rtti "off" + end +end + +function setup_third_party_static_lib_project (project_name, rel_source_dirs, extern_libs, extra_params) + + setup_static_lib_project(project_name, rel_source_dirs, extern_libs, extra_params) + includedirs { source_root .. "third_party/" .. project_name .. "/include/" } +end + +function setup_shared_lib_project (project_name, rel_source_dirs, extern_libs, extra_params) + + local target_type = "SharedLib" + project_create(project_name, target_type) + project_add_contents(source_root, rel_source_dirs, {}, extra_params) + project_add_extern_libs(extern_libs, target_type) + project_add_x11_dirs() + + if not extra_params["no_default_link"] then + table.insert(static_lib_names, project_name) + end + + if os.istarget("windows") then + rtti "off" + links { "delayimp" } + end +end + + +-- this is where the source tree is chopped up into static libs. +-- can be changed very easily; just copy+paste a new setup_static_lib_project, +-- or remove existing ones. static libs are automagically added to +-- main_exe link step. +function setup_all_libs () + + -- relative to global source_root. + local source_dirs = {} + -- names of external libraries used (see libraries_dir comment) + local extern_libs = {} + + + source_dirs = { + "network", + } + extern_libs = { + "spidermonkey", + "enet", + "boost", -- dragged in via server->simulation.h->random + } + if not _OPTIONS["without-miniupnpc"] then + table.insert(extern_libs, "miniupnpc") + end + setup_static_lib_project("network", source_dirs, extern_libs, {}) + + source_dirs = { + "third_party/tinygettext/src", + } + extern_libs = { + "iconv", + "boost", + } + setup_third_party_static_lib_project("tinygettext", source_dirs, extern_libs, { } ) + + -- it's an external library and we don't want to modify its source to fix warnings, so we just disable them to avoid noise in the compile output + if _ACTION == "vs2013" then + buildoptions { + "/wd4127", + "/wd4309", + "/wd4800", + "/wd4100", + "/wd4996", + "/wd4099", + "/wd4503" + } + end + + + if not _OPTIONS["without-lobby"] then + source_dirs = { + "lobby", + "lobby/scripting", + "i18n", + "third_party/encryption" + } + + extern_libs = { + "spidermonkey", + "boost", + "enet", + "gloox", + "icu", + "iconv", + "tinygettext" + } + setup_static_lib_project("lobby", source_dirs, extern_libs, {}) + + if _OPTIONS["use-shared-glooxwrapper"] and not _OPTIONS["build-shared-glooxwrapper"] then + table.insert(static_lib_names_debug, "glooxwrapper_dbg") + table.insert(static_lib_names_release, "glooxwrapper") + else + source_dirs = { + "lobby/glooxwrapper", + } + extern_libs = { + "boost", + "gloox", + } + if _OPTIONS["build-shared-glooxwrapper"] then + setup_shared_lib_project("glooxwrapper", source_dirs, extern_libs, {}) + else + setup_static_lib_project("glooxwrapper", source_dirs, extern_libs, {}) + end + end + else + source_dirs = { + "lobby/scripting", + "third_party/encryption" + } + extern_libs = { + "spidermonkey", + "boost" + } + setup_static_lib_project("lobby", source_dirs, extern_libs, {}) + files { source_root.."lobby/Globals.cpp" } + end + + + source_dirs = { + "simulation2", + "simulation2/components", + "simulation2/helpers", + "simulation2/scripting", + "simulation2/serialization", + "simulation2/system", + "simulation2/testcomponents", + } + extern_libs = { + "boost", + "opengl", + "spidermonkey", + } + setup_static_lib_project("simulation2", source_dirs, extern_libs, {}) + + + source_dirs = { + "scriptinterface", + "scriptinterface/third_party" + } + extern_libs = { + "boost", + "spidermonkey", + "valgrind", + "sdl", + } + setup_static_lib_project("scriptinterface", source_dirs, extern_libs, {}) + + + source_dirs = { + "ps", + "ps/scripting", + "network/scripting", + "ps/GameSetup", + "ps/XML", + "soundmanager", + "soundmanager/data", + "soundmanager/items", + "soundmanager/scripting", + "maths", + "maths/scripting", + "i18n", + "i18n/scripting", + "third_party/cppformat", + } + extern_libs = { + "spidermonkey", + "sdl", -- key definitions + "libxml2", + "opengl", + "zlib", + "boost", + "enet", + "libcurl", + "tinygettext", + "icu", + "iconv", + } + + if not _OPTIONS["without-audio"] then + table.insert(extern_libs, "openal") + table.insert(extern_libs, "vorbis") + end + + setup_static_lib_project("engine", source_dirs, extern_libs, {}) + + + source_dirs = { + "graphics", + "graphics/scripting", + "renderer", + "renderer/scripting", + "third_party/mikktspace" + } + extern_libs = { + "opengl", + "sdl", -- key definitions + "spidermonkey", -- for graphics/scripting + "boost" + } + if not _OPTIONS["without-nvtt"] then + table.insert(extern_libs, "nvtt") + end + setup_static_lib_project("graphics", source_dirs, extern_libs, {}) + + + source_dirs = { + "tools/atlas/GameInterface", + "tools/atlas/GameInterface/Handlers" + } + extern_libs = { + "boost", + "sdl", -- key definitions + "opengl", + "spidermonkey" + } + setup_static_lib_project("atlas", source_dirs, extern_libs, {}) + + + source_dirs = { + "gui", + "gui/scripting", + "i18n" + } + extern_libs = { + "spidermonkey", + "sdl", -- key definitions + "opengl", + "boost", + "enet", + "tinygettext", + "icu", + "iconv", + } + if not _OPTIONS["without-audio"] then + table.insert(extern_libs, "openal") + end + setup_static_lib_project("gui", source_dirs, extern_libs, {}) + + + source_dirs = { + "lib", + "lib/adts", + "lib/allocators", + "lib/external_libraries", + "lib/file", + "lib/file/archive", + "lib/file/common", + "lib/file/io", + "lib/file/vfs", + "lib/pch", + "lib/posix", + "lib/res", + "lib/res/graphics", + "lib/sysdep", + "lib/tex" + } + extern_libs = { + "boost", + "sdl", + "openal", + "opengl", + "libpng", + "zlib", + "valgrind", + "cxxtest", + } + + -- CPU architecture-specific + if arch == "amd64" then + table.insert(source_dirs, "lib/sysdep/arch/amd64"); + table.insert(source_dirs, "lib/sysdep/arch/x86_x64"); + elseif arch == "x86" then + table.insert(source_dirs, "lib/sysdep/arch/ia32"); + table.insert(source_dirs, "lib/sysdep/arch/x86_x64"); + elseif arch == "arm" then + table.insert(source_dirs, "lib/sysdep/arch/arm"); + elseif arch == "aarch64" then + table.insert(source_dirs, "lib/sysdep/arch/aarch64"); + end + + -- OS-specific + sysdep_dirs = { + linux = { "lib/sysdep/os/linux", "lib/sysdep/os/unix" }, + -- note: RC file must be added to main_exe project. + -- note: don't add "lib/sysdep/os/win/aken.cpp" because that must be compiled with the DDK. + windows = { "lib/sysdep/os/win", "lib/sysdep/os/win/wposix", "lib/sysdep/os/win/whrt" }, + macosx = { "lib/sysdep/os/osx", "lib/sysdep/os/unix" }, + bsd = { "lib/sysdep/os/bsd", "lib/sysdep/os/unix", "lib/sysdep/os/unix/x" }, + } + for i,v in pairs(sysdep_dirs[os.target()]) do + table.insert(source_dirs, v); + end + + if os.istarget("linux") then + if _OPTIONS["android"] then + table.insert(source_dirs, "lib/sysdep/os/android") + else + table.insert(source_dirs, "lib/sysdep/os/unix/x") + end + end + + -- On OSX, disable precompiled headers because C++ files and Objective-C++ files are + -- mixed in this project. To fix that, we would need per-file basis configuration which + -- is not yet supported by the gmake action in premake. We should look into using gmake2. + extra_params = {} + if os.istarget("macosx") then + extra_params = { no_pch = 1 } + end + + -- runtime-library-specific + if _ACTION == "vs2013" then + table.insert(source_dirs, "lib/sysdep/rtl/msc"); + else + table.insert(source_dirs, "lib/sysdep/rtl/gcc"); + end + + setup_static_lib_project("lowlevel", source_dirs, extern_libs, extra_params) + + + -- Third-party libraries that are built as part of the main project, + -- not built externally and then linked + source_dirs = { + "third_party/mongoose", + } + extern_libs = { + } + setup_static_lib_project("mongoose", source_dirs, extern_libs, { no_pch = 1 }) + + + -- CxxTest mock function support + extern_libs = { + "boost", + "cxxtest", + } + + -- 'real' implementations, to be linked against the main executable + -- (files are added manually and not with setup_static_lib_project + -- because not all files in the directory are included) + setup_static_lib_project("mocks_real", {}, extern_libs, { no_default_link = 1, no_pch = 1 }) + files { "mocks/*.h", source_root.."mocks/*_real.cpp" } + -- 'test' implementations, to be linked against the test executable + setup_static_lib_project("mocks_test", {}, extern_libs, { no_default_link = 1, no_pch = 1 }) + files { source_root.."mocks/*.h", source_root.."mocks/*_test.cpp" } +end + +-------------------------------------------------------------------------------- +-- main EXE +-------------------------------------------------------------------------------- + +-- used for main EXE as well as test +used_extern_libs = { + "opengl", + "sdl", + + "libpng", + "zlib", + + "spidermonkey", + "libxml2", + + "boost", + "cxxtest", + "comsuppw", + "enet", + "libcurl", + "tinygettext", + "icu", + "iconv", + + "valgrind", +} + +if not os.istarget("windows") and not _OPTIONS["android"] and not os.istarget("macosx") then + -- X11 should only be linked on *nix + table.insert(used_extern_libs, "x11") + table.insert(used_extern_libs, "xcursor") +end + +if not _OPTIONS["without-audio"] then + table.insert(used_extern_libs, "openal") + table.insert(used_extern_libs, "vorbis") +end + +if not _OPTIONS["without-nvtt"] then + table.insert(used_extern_libs, "nvtt") +end + +if not _OPTIONS["without-lobby"] then + table.insert(used_extern_libs, "gloox") +end + +if not _OPTIONS["without-miniupnpc"] then + table.insert(used_extern_libs, "miniupnpc") +end + +-- Bundles static libs together with main.cpp and builds game executable. +function setup_main_exe () + + local target_type = get_main_project_target_type() + project_create("pyrogenesis", target_type) + + filter "system:not macosx" + linkgroups 'On' + filter {} + + links { "mocks_real" } + + local extra_params = { + extra_files = { "main.cpp" }, + no_pch = 1 + } + project_add_contents(source_root, {}, {}, extra_params) + project_add_extern_libs(used_extern_libs, target_type) + project_add_x11_dirs() + + dependson { "Collada" } + + -- Platform Specifics + if os.istarget("windows") then + + files { source_root.."lib/sysdep/os/win/icon.rc" } + -- from "lowlevel" static lib; must be added here to be linked in + files { source_root.."lib/sysdep/os/win/error_dialog.rc" } + + rtti "off" + + linkoptions { + -- wraps main thread in a __try block(see wseh.cpp). replace with mainCRTStartup if that's undesired. + "/ENTRY:wseh_EntryPoint", + + -- see wstartup.h + "/INCLUDE:_wstartup_InitAndRegisterShutdown", + + -- allow manual unload of delay-loaded DLLs + "/DELAY:UNLOAD", + } + + -- allow the executable to use more than 2GB of RAM. + -- this should not be enabled during development, so that memory issues are easily spotted. + if _OPTIONS["large-address-aware"] then + linkoptions { "/LARGEADDRESSAWARE" } + end + + -- see manifest.cpp + project_add_manifest() + + elseif os.istarget("linux") or os.istarget("bsd") then + + if not _OPTIONS["android"] and not (os.getversion().description == "OpenBSD") then + links { "rt" } + end + + if _OPTIONS["android"] then + -- NDK's STANDALONE-TOOLCHAIN.html says this is required + linkoptions { "-Wl,--fix-cortex-a8" } + + links { "log" } + end + + if os.istarget("linux") or os.getversion().description == "GNU/kFreeBSD" then + links { + -- Dynamic libraries (needed for linking for gold) + "dl", + } + elseif os.istarget("bsd") then + links { + -- Needed for backtrace* on BSDs + "execinfo", + } + end + + -- Threading support + buildoptions { "-pthread" } + if not _OPTIONS["android"] then + linkoptions { "-pthread" } + end + + -- For debug_resolve_symbol + filter "Debug" + linkoptions { "-rdynamic" } + filter { } + + elseif os.istarget("macosx") then + + links { "pthread" } + links { "ApplicationServices.framework", "Cocoa.framework", "CoreFoundation.framework" } + + end +end + + +-------------------------------------------------------------------------------- +-- atlas +-------------------------------------------------------------------------------- + +-- setup a typical Atlas component project +-- extra_params, rel_source_dirs and rel_include_dirs: as in project_add_contents; +function setup_atlas_project(project_name, target_type, rel_source_dirs, rel_include_dirs, extern_libs, extra_params) + + local source_root = rootdir.."/source/tools/atlas/" .. project_name .. "/" + project_create(project_name, target_type) + + -- if not specified, the default for atlas pch files is in the project root. + if not extra_params["pch_dir"] then + extra_params["pch_dir"] = source_root + end + + project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) + project_add_extern_libs(extern_libs, target_type) + project_add_x11_dirs() + + -- Platform Specifics + if os.istarget("windows") then + defines { "_UNICODE" } + -- Link to required libraries + links { "winmm", "comctl32", "rpcrt4", "delayimp", "ws2_32" } + + elseif os.istarget("linux") or os.istarget("bsd") then + buildoptions { "-rdynamic", "-fPIC" } + linkoptions { "-fPIC", "-rdynamic" } + + -- warnings triggered by wxWidgets + buildoptions { "-Wno-unused-local-typedefs" } + + elseif os.istarget("macosx") then + -- install_name settings aren't really supported yet by premake, but there are plans for the future. + -- we currently use this hack to work around some bugs with wrong install_names. + if target_type == "SharedLib" then + if _OPTIONS["macosx-bundle"] then + -- If we're building a bundle, it will be in ../Frameworks + filter "Debug" + linkoptions { "-install_name @executable_path/../Frameworks/lib"..project_name.."_dbg.dylib" } + filter "Release" + linkoptions { "-install_name @executable_path/../Frameworks/lib"..project_name..".dylib" } + filter { } + else + filter "Debug" + linkoptions { "-install_name @executable_path/lib"..project_name.."_dbg.dylib" } + filter "Release" + linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" } + filter { } + end + end + end + +end + + +-- build all Atlas component projects +function setup_atlas_projects() + + setup_atlas_project("AtlasObject", "StaticLib", + { -- src + ".", + "../../../third_party/jsonspirit" + + },{ -- include + "../../../third_party/jsonspirit" + },{ -- extern_libs + "boost", + "iconv", + "libxml2", + "wxwidgets" + },{ -- extra_params + no_pch = 1 + }) + + atlas_src = { + "ActorEditor", + "CustomControls/Buttons", + "CustomControls/Canvas", + "CustomControls/ColorDialog", + "CustomControls/DraggableListCtrl", + "CustomControls/EditableListCtrl", + "CustomControls/FileHistory", + "CustomControls/HighResTimer", + "CustomControls/MapDialog", + "CustomControls/SnapSplitterWindow", + "CustomControls/VirtualDirTreeCtrl", + "CustomControls/Windows", + "General", + "General/VideoRecorder", + "Misc", + "ScenarioEditor", + "ScenarioEditor/Sections/Common", + "ScenarioEditor/Sections/Cinema", + "ScenarioEditor/Sections/Environment", + "ScenarioEditor/Sections/Map", + "ScenarioEditor/Sections/Object", + "ScenarioEditor/Sections/Player", + "ScenarioEditor/Sections/Terrain", + "ScenarioEditor/Tools", + "ScenarioEditor/Tools/Common", + } + atlas_extra_links = { + "AtlasObject" + } + + atlas_extern_libs = { + "boost", + "comsuppw", + "iconv", + "libxml2", + "sdl", -- key definitions + "wxwidgets", + "zlib", + } + if not os.istarget("windows") and not os.istarget("macosx") then + -- X11 should only be linked on *nix + table.insert(atlas_extern_libs, "x11") + end + + setup_atlas_project("AtlasUI", "SharedLib", atlas_src, + { -- include + "..", + "CustomControls", + "Misc" + }, + atlas_extern_libs, + { -- extra_params + pch_dir = rootdir.."/source/tools/atlas/AtlasUI/Misc/", + no_pch = false, + extra_links = atlas_extra_links, + extra_files = { "Misc/atlas.rc" } + }) +end + + +-- Atlas 'frontend' tool-launching projects +function setup_atlas_frontend_project (project_name) + + local target_type = get_main_project_target_type() + project_create(project_name, target_type) + project_add_x11_dirs() + + local source_root = rootdir.."/source/tools/atlas/AtlasFrontends/" + files { source_root..project_name..".cpp" } + + if os.istarget("windows") then + files { source_root..project_name..".rc" } + end + + includedirs { source_root .. ".." } + + -- Platform Specifics + if os.istarget("windows") then + defines { "_UNICODE" } + + -- see manifest.cpp + project_add_manifest() + + else -- Non-Windows, = Unix + links { "AtlasObject" } + end + + links { "AtlasUI" } + +end + +function setup_atlas_frontends() + setup_atlas_frontend_project("ActorEditor") +end + + +-------------------------------------------------------------------------------- +-- collada +-------------------------------------------------------------------------------- + +function setup_collada_project(project_name, target_type, rel_source_dirs, rel_include_dirs, extern_libs, extra_params) + + project_create(project_name, target_type) + local source_root = source_root.."collada/" + extra_params["pch_dir"] = source_root + project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params) + project_add_extern_libs(extern_libs, target_type) + project_add_x11_dirs() + + -- Platform Specifics + if os.istarget("linux") then + defines { "LINUX" } + + links { + "dl", + } + + -- FCollada is not aliasing-safe, so disallow dangerous optimisations + -- (TODO: It'd be nice to fix FCollada, but that looks hard) + buildoptions { "-fno-strict-aliasing" } + + buildoptions { "-rdynamic" } + linkoptions { "-rdynamic" } + + elseif os.istarget("bsd") then + if os.getversion().description == "OpenBSD" then + links { "c", } + end + + if os.getversion().description == "GNU/kFreeBSD" then + links { + "dl", + } + end + + buildoptions { "-fno-strict-aliasing" } + + buildoptions { "-rdynamic" } + linkoptions { "-rdynamic" } + + elseif os.istarget("macosx") then + -- define MACOS-something? + + -- install_name settings aren't really supported yet by premake, but there are plans for the future. + -- we currently use this hack to work around some bugs with wrong install_names. + if target_type == "SharedLib" then + if _OPTIONS["macosx-bundle"] then + -- If we're building a bundle, it will be in ../Frameworks + linkoptions { "-install_name @executable_path/../Frameworks/lib"..project_name..".dylib" } + else + linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" } + end + end + + buildoptions { "-fno-strict-aliasing" } + -- On OSX, fcollada uses a few utility functions from coreservices + links { "CoreServices.framework" } + end + +end + +-- build all Collada component projects +function setup_collada_projects() + + setup_collada_project("Collada", "SharedLib", + { -- src + "." + },{ -- include + },{ -- extern_libs + "fcollada", + "iconv", + "libxml2" + },{ -- extra_params + }) + +end + + +-------------------------------------------------------------------------------- +-- tests +-------------------------------------------------------------------------------- + +function configure_cxxtestgen() + local lcxxtestrootfile = source_root.."test_root.cpp" + + -- Define the options used for cxxtestgen + local lcxxtestoptions = "--have-std" + local lcxxtestrootoptions = "--have-std" + + if _OPTIONS["jenkins-tests"] then + lcxxtestrootoptions = lcxxtestrootoptions .. " --runner=XmlPrinter" + else + lcxxtestrootoptions = lcxxtestrootoptions .. " --runner=ErrorPrinter" + end + + -- Precompiled headers - the header is added to all generated .cpp files + -- note that the header isn't actually precompiled here, only #included + -- so that the build stage can use it as a precompiled header. + local include = " --include=precompiled.h" + -- This is required to build against SDL 2.0.4 on Windows + include = include .. " --include=lib/external_libraries/libsdl.h" + lcxxtestrootoptions = lcxxtestrootoptions .. include + lcxxtestoptions = lcxxtestoptions .. include + + -- Find header files in 'test' subdirectories + local all_files = os.matchfiles(source_root .. "**/tests/*.h") + local test_files = {} + for i,v in pairs(all_files) do + -- Don't include sysdep tests on the wrong sys + -- Don't include Atlas tests unless Atlas is being built + if not (string.find(v, "/sysdep/os/win/") and not os.istarget("windows")) and + not (string.find(v, "/tools/atlas/") and not _OPTIONS["atlas"]) and + not (string.find(v, "/sysdep/arch/x86_x64/") and ((arch ~= "amd64") or (arch ~= "x86"))) + then + table.insert(test_files, v) + end + end + + local cxxtest = require "cxxtest" + + if os.istarget("windows") then + cxxtest.path = rootdir.."/build/bin/cxxtestgen.exe" + else + cxxtest.path = rootdir.."/libraries/source/cxxtest-4.4/bin/cxxtestgen" + end + + cxxtest.configure_project(lcxxtestrootfile, test_files, lcxxtestrootoptions, lcxxtestoptions) +end + + +function setup_tests() + + local target_type = get_main_project_target_type() + project_create("test", target_type) + + configure_cxxtestgen() + + filter "system:not macosx" + linkgroups 'On' + filter {} + + links { static_lib_names } + filter "Debug" + links { static_lib_names_debug } + filter "Release" + links { static_lib_names_release } + filter { } + + links { "mocks_test" } + if _OPTIONS["atlas"] then + links { "AtlasObject" } + project_add_extern_libs({"wxwidgets"}, target_type) + end + extra_params = { + extra_files = { "test_setup.cpp" }, + } + + project_add_contents(source_root, {}, {}, extra_params) + project_add_extern_libs(used_extern_libs, target_type) + project_add_x11_dirs() + + dependson { "Collada" } + + -- TODO: should fix the duplication between this OS-specific linking + -- code, and the similar version in setup_main_exe + + if os.istarget("windows") then + -- from "lowlevel" static lib; must be added here to be linked in + files { source_root.."lib/sysdep/os/win/error_dialog.rc" } + + rtti "off" + + -- see wstartup.h + linkoptions { "/INCLUDE:_wstartup_InitAndRegisterShutdown" } + -- Enables console for the TEST project on Windows + linkoptions { "/SUBSYSTEM:CONSOLE" } + + project_add_manifest() + + elseif os.istarget("linux") or os.istarget("bsd") then + + if not _OPTIONS["android"] and not (os.getversion().description == "OpenBSD") then + links { "rt" } + end + + if _OPTIONS["android"] then + -- NDK's STANDALONE-TOOLCHAIN.html says this is required + linkoptions { "-Wl,--fix-cortex-a8" } + end + + if os.istarget("linux") or os.getversion().description == "GNU/kFreeBSD" then + links { + -- Dynamic libraries (needed for linking for gold) + "dl", + } + elseif os.istarget("bsd") then + links { + -- Needed for backtrace* on BSDs + "execinfo", + } + end + + -- Threading support + buildoptions { "-pthread" } + if not _OPTIONS["android"] then + linkoptions { "-pthread" } + end + + -- For debug_resolve_symbol + filter "Debug" + linkoptions { "-rdynamic" } + filter { } + + includedirs { source_root .. "pch/test/" } + end +end + +-- must come first, so that VC sets it as the default project and therefore +-- allows running via F5 without the "where is the EXE" dialog. +setup_main_exe() + +setup_all_libs() + +-- add the static libs to the main EXE project. only now (after +-- setup_all_libs has run) are the lib names known. cannot move +-- setup_main_exe to run after setup_all_libs (see comment above). +-- we also don't want to hardcode the names - that would require more +-- work when changing the static lib breakdown. +project("pyrogenesis") -- Set the main project active + links { static_lib_names } + filter "Debug" + links { static_lib_names_debug } + filter "Release" + links { static_lib_names_release } + filter { } + +if _OPTIONS["atlas"] then + setup_atlas_projects() + setup_atlas_frontends() +end + +setup_collada_projects() + +if not _OPTIONS["without-tests"] then + setup_tests() +end Property changes on: ps/trunk/build/premake/premake5.lua ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +author date id revision \ No newline at end of property Index: ps/trunk/build/workspaces/clean-workspaces.sh =================================================================== --- ps/trunk/build/workspaces/clean-workspaces.sh (revision 20380) +++ ps/trunk/build/workspaces/clean-workspaces.sh (revision 20381) @@ -1,64 +1,67 @@ #!/bin/sh # Some of our makefiles depend on GNU make, so we set some sane defaults if MAKE # is not set. case "`uname -s`" in "FreeBSD" | "OpenBSD" ) MAKE=${MAKE:="gmake"} ;; * ) MAKE=${MAKE:="make"} ;; esac # Check the preserve-libs CL option preserve_libs=false for i in "$@"; do case "$i" in --preserve-libs ) preserve_libs=true ;; esac done # (We don't attempt to clean up every last file here - output in # binaries/system/ will still be there, etc. This is mostly just # to quickly fix problems in the bundled dependencies.) cd "$(dirname $0)" # Now in build/workspaces/ (where we assume this script resides) if [ "$preserve_libs" != "true" ]; then echo "Cleaning bundled third-party dependencies..." (cd ../../libraries/source/fcollada/src && rm -rf ./output) (cd ../../libraries/source/nvtt/src && rm -rf ./build) (cd ../../libraries/source/spidermonkey && rm -f .already-built) (cd ../../libraries/source/spidermonkey && rm -rf ./mozjs-38.0.0) fi # Still delete the directory of previous SpiderMonkey versions to # avoid wasting disk space if people clean workspaces after updating. (cd ../../libraries/source/spidermonkey && rm -rf ./mozjs31) (cd ../../libraries/source/spidermonkey && rm -rf ./mozjs24) (cd ../premake/premake4/build/gmake.bsd && ${MAKE} clean) (cd ../premake/premake4/build/gmake.macosx && ${MAKE} clean) (cd ../premake/premake4/build/gmake.unix && ${MAKE} clean) +(cd ../premake/premake5/build/gmake.bsd && ${MAKE} clean) +(cd ../premake/premake5/build/gmake.macosx && ${MAKE} clean) +(cd ../premake/premake5/build/gmake.unix && ${MAKE} clean) echo "Removing generated test files..." find ../../source -name "test_*.cpp" -type f -not -name "test_setup.cpp" -exec rm {} \; echo "Cleaning build output..." # Remove workspaces/gcc if present rm -rf ./gcc # Remove workspaces/codeblocks if present rm -rf ./codeblocks # Remove workspaces/xcode3 if present rm -rf ./xcode3 # Remove workspaces/xcode4 if present rm -rf ./xcode4 echo echo "Done. Try running update-workspaces.sh again now." Index: ps/trunk/build/workspaces/update-workspaces.bat =================================================================== --- ps/trunk/build/workspaces/update-workspaces.bat (revision 20380) +++ ps/trunk/build/workspaces/update-workspaces.bat (revision 20381) @@ -1,7 +1,6 @@ @echo off rem ** Create Visual Studio Workspaces on Windows ** cd ..\premake -rem ** Support for Visual Studio versions <2013 has been dropped (check #2669). -if not exist ..\workspaces\vc2013\SKIP_PREMAKE_HERE premake4\bin\release\premake4 --outpath="../workspaces/vc2013" --collada --use-shared-glooxwrapper %* vs2013 +if not exist ..\workspaces\vc2013\SKIP_PREMAKE_HERE premake5\bin\release\premake5 --outpath="../workspaces/vc2013" --use-shared-glooxwrapper %* vs2013 cd ..\workspaces Index: ps/trunk/build/workspaces/update-workspaces.sh =================================================================== --- ps/trunk/build/workspaces/update-workspaces.sh (revision 20380) +++ ps/trunk/build/workspaces/update-workspaces.sh (revision 20381) @@ -1,134 +1,138 @@ #!/bin/sh if [ "$(id -u)" = "0" ]; then echo "Running as root will mess up file permissions. Aborting ..." 1>&2 exit 1 fi die() { echo ERROR: $* exit 1 } # Check for whitespace in absolute path; this will cause problems in the # SpiderMonkey build (https://bugzilla.mozilla.org/show_bug.cgi?id=459089) # and maybe elsewhere, so we just forbid it # Use perl as an alternative to readlink -f, which isn't available on BSD or OS X SCRIPTPATH=`perl -MCwd -e 'print Cwd::abs_path shift' "$0"` case "$SCRIPTPATH" in *\ * ) die "Absolute path contains whitespace, which will break the build - move the game to a path without spaces" ;; esac JOBS=${JOBS:="-j2"} # Some of our makefiles depend on GNU make, so we set some sane defaults if MAKE # is not set. case "`uname -s`" in "FreeBSD" | "OpenBSD" ) MAKE=${MAKE:="gmake"} ;; * ) MAKE=${MAKE:="make"} ;; esac # Parse command-line options: +premake_version="premake5" premake_args="" without_nvtt=false with_system_nvtt=false with_system_mozjs38=false enable_atlas=true for i in "$@" do case $i in --without-nvtt ) without_nvtt=true; premake_args="${premake_args} --without-nvtt" ;; --with-system-nvtt ) with_system_nvtt=true; premake_args="${premake_args} --with-system-nvtt" ;; --with-system-mozjs38 ) with_system_mozjs38=true; premake_args="${premake_args} --with-system-mozjs38" ;; --enable-atlas ) enable_atlas=true ;; --disable-atlas ) enable_atlas=false ;; + --premake4 ) premake_version="premake4"; premake_args="${premake_args} --collada" ;; -j* ) JOBS=$i ;; # Assume any other --options are for Premake --* ) premake_args="${premake_args} $i" ;; esac done -premake_args="${premake_args} --collada" if [ "$enable_atlas" = "true" ]; then premake_args="${premake_args} --atlas" fi cd "$(dirname $0)" # Now in build/workspaces/ (where we assume this script resides) if [ "`uname -s`" = "Darwin" ]; then # Set *_CONFIG variables on OS X, to override the path to e.g. sdl2-config export GLOOX_CONFIG=${GLOOX_CONFIG:="$(pwd)/../../libraries/osx/gloox/bin/gloox-config"} export ICU_CONFIG=${ICU_CONFIG:="$(pwd)/../../libraries/osx/icu/bin/icu-config"} export SDL2_CONFIG=${SDL2_CONFIG:="$(pwd)/../../libraries/osx/sdl2/bin/sdl2-config"} export WX_CONFIG=${WX_CONFIG:="$(pwd)/../../libraries/osx/wxwidgets/bin/wx-config"} export XML2_CONFIG=${XML2_CONFIG:="$(pwd)/../../libraries/osx/libxml2/bin/xml2-config"} fi # Don't want to build bundled libs on OS X # (build-osx-libs.sh is used instead) if [ "`uname -s`" != "Darwin" ]; then echo "Updating bundled third-party dependencies..." echo # Build/update bundled external libraries (cd ../../libraries/source/fcollada/src && ${MAKE} ${JOBS}) || die "FCollada build failed" echo if [ "$with_system_mozjs38" = "false" ]; then (cd ../../libraries/source/spidermonkey && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "SpiderMonkey build failed" fi echo if [ "$with_system_nvtt" = "false" ] && [ "$without_nvtt" = "false" ]; then (cd ../../libraries/source/nvtt && MAKE=${MAKE} JOBS=${JOBS} ./build.sh) || die "NVTT build failed" fi echo fi # Now build premake and run it to create the makefiles -cd ../premake/premake4 +cd ../premake/"$premake_version" PREMAKE_BUILD_DIR=build/gmake.unix # BSD and OS X need different Makefiles case "`uname -s`" in "GNU/kFreeBSD" ) # use default gmake.unix (needs -ldl as we have a GNU userland and libc) ;; *"BSD" ) PREMAKE_BUILD_DIR=build/gmake.bsd ;; "Darwin" ) PREMAKE_BUILD_DIR=build/gmake.macosx ;; esac ${MAKE} -C $PREMAKE_BUILD_DIR ${JOBS} || die "Premake build failed" echo cd .. # If we're in bash then make HOSTTYPE available to Premake, for primitive arch-detection export HOSTTYPE="$HOSTTYPE" echo "Premake args: ${premake_args}" -premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed" -premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/codeblocks/" ${premake_args} codeblocks || die "Premake failed" - +"$premake_version"/bin/release/"$premake_version" --file="$premake_version.lua" --outpath="../workspaces/gcc/" ${premake_args} gmake || die "Premake failed" +if [ "$premake_version" = "premake4" ]; then + "$premake_version"/bin/release/"$premake_version" --file="$premake_version.lua" --outpath="../workspaces/codeblocks/" ${premake_args} codeblocks || die "Premake failed" +fi # Also generate xcode workspaces if on OS X if [ "`uname -s`" = "Darwin" ]; then - premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode3" ${premake_args} xcode3 || die "Premake failed" - premake4/bin/release/premake4 --file="premake4.lua" --outpath="../workspaces/xcode4" ${premake_args} xcode4 || die "Premake failed" + if [ "$premake_version" = "premake4" ]; then + "$premake_version"/bin/release/"$premake_version" --file="$premake_version.lua" --outpath="../workspaces/xcode3" ${premake_args} xcode3 || die "Premake failed" + fi + "$premake_version"/bin/release/"$premake_version" --file="$premake_version.lua" --outpath="../workspaces/xcode4" ${premake_args} xcode4 || die "Premake failed" fi # test_root.cpp gets generated by cxxtestgen and passing different arguments to premake could require a regeneration of this file. # It doesn't depend on anything in the makefiles, so make won't notice that the prebuild command for creating test_root.cpp needs to be triggered. # We force this by deleting the file. rm -f ../../source/test_root.cpp Index: ps/trunk/source/tools/atlas/AtlasFrontends/ActorEditor.cpp =================================================================== --- ps/trunk/source/tools/atlas/AtlasFrontends/ActorEditor.cpp (revision 20380) +++ ps/trunk/source/tools/atlas/AtlasFrontends/ActorEditor.cpp (revision 20381) @@ -1,43 +1,43 @@ /* Copyright (C) 2011 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * 0 A.D. is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with 0 A.D. If not, see . */ #ifdef _WIN32 # define WIN32_LEAN_AND_MEAN # include -/* Don't use pragmas here to set the manifests, instead do this in premake4.lua +/* Don't use pragmas here to set the manifests, instead do this in premake.lua * since pragmas get ignored by the autobuilder * (see comments in lib\sysdep\os\win\manifest.cpp) */ # define ATLASDLLIMPEXP extern "C" __declspec(dllimport) #else # define ATLASDLLIMPEXP extern "C" #endif #include "AtlasUI/Misc/DLLInterface.h" #ifdef _WIN32 int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int) #else int main() #endif { Atlas_StartWindow(L"ActorEditor"); return 0; }