Add an sdl2 option to SCons.
It allows building Wesnoth with SDL2. False by default. The SDL2 versions of SDL_image, SDL_mixer, SDL_net and SDL_ttf are required, too.
This commit is contained in:
parent
cb4c16749b
commit
7b6c125ffd
2 changed files with 48 additions and 15 deletions
34
SConstruct
34
SConstruct
|
@ -102,7 +102,8 @@ opts.AddVariables(
|
|||
BoolVariable('cxx0x', 'Use C++0x features.', False),
|
||||
BoolVariable('openmp', 'Enable openmp use.', False),
|
||||
BoolVariable("fast", "Make scons faster at cost of less precise dependency tracking.", False),
|
||||
BoolVariable("lockfile", "Create a lockfile to prevent multiple instances of scons from being run at the same time on this working copy.", False)
|
||||
BoolVariable("lockfile", "Create a lockfile to prevent multiple instances of scons from being run at the same time on this working copy.", False),
|
||||
BoolVariable("sdl2", "Build with SDL2 support (experimental!)", False)
|
||||
)
|
||||
|
||||
#
|
||||
|
@ -315,29 +316,44 @@ if env["prereqs"]:
|
|||
conf.CheckLib("vorbis")
|
||||
conf.CheckLib("mikmod")
|
||||
|
||||
have_server_prereqs = \
|
||||
if env['sdl2']:
|
||||
have_sdl_net = \
|
||||
conf.CheckSDL(require_version = '2.0.0') and \
|
||||
conf.CheckSDL("SDL2_net", header_file = "SDL_net")
|
||||
|
||||
have_sdl_other = \
|
||||
conf.CheckSDL("SDL2_ttf", header_file = "SDL_ttf") and \
|
||||
conf.CheckSDL("SDL2_mixer", header_file = "SDL_mixer") and \
|
||||
conf.CheckSDL("SDL2_image", header_file = "SDL_image")
|
||||
|
||||
else:
|
||||
have_sdl_net = \
|
||||
conf.CheckSDL(require_version = '1.2.0') and \
|
||||
conf.CheckSDL('SDL_net')
|
||||
|
||||
have_sdl_other = \
|
||||
conf.CheckSDL("SDL_ttf", require_version = "2.0.8") and \
|
||||
conf.CheckSDL("SDL_mixer", require_version = '1.2.0') and \
|
||||
conf.CheckSDL("SDL_image", require_version = '1.2.0')
|
||||
|
||||
have_server_prereqs = have_sdl_net and \
|
||||
conf.CheckCPlusPlus(gcc_version = "3.3") and \
|
||||
conf.CheckGettextLibintl() and \
|
||||
conf.CheckBoost("iostreams", require_version = "1.34.1") and \
|
||||
conf.CheckBoostIostreamsGZip() and \
|
||||
conf.CheckBoostIostreamsBZip2() and \
|
||||
conf.CheckBoost("smart_ptr", header_only = True) and \
|
||||
conf.CheckSDL(require_version = '1.2.7') and \
|
||||
conf.CheckSDL('SDL_net') or Warning("Base prerequisites are not met.")
|
||||
conf.CheckBoost("smart_ptr", header_only = True) or Warning("Base prerequisites are not met.")
|
||||
|
||||
env = conf.Finish()
|
||||
client_env = env.Clone()
|
||||
conf = client_env.Configure(**configure_args)
|
||||
have_client_prereqs = have_server_prereqs and \
|
||||
have_client_prereqs = have_server_prereqs and have_sdl_other and \
|
||||
CheckAsio(conf) and \
|
||||
conf.CheckPango("cairo", require_version = "1.21.3") and \
|
||||
conf.CheckPKG("fontconfig") and \
|
||||
conf.CheckBoost("program_options", require_version="1.35.0") and \
|
||||
conf.CheckBoost("regex", require_version = "1.35.0") and \
|
||||
conf.CheckSDL("SDL_ttf", require_version = "2.0.8") and \
|
||||
conf.CheckSDL("SDL_mixer", require_version = '1.2.0') and \
|
||||
conf.CheckLib("vorbisfile") and \
|
||||
conf.CheckSDL("SDL_image", require_version = '1.2.0') and \
|
||||
conf.CheckOgg() or Warning("Client prerequisites are not met. wesnoth, cutter and exploder cannot be built.")
|
||||
|
||||
have_X = False
|
||||
|
|
29
scons/sdl.py
29
scons/sdl.py
|
@ -3,7 +3,7 @@ import os
|
|||
from SCons.Script import *
|
||||
from config_check_utils import *
|
||||
|
||||
def CheckSDL(context, sdl_lib = "SDL", require_version = None):
|
||||
def CheckSDL(context, sdl_lib = "SDL", require_version = None, header_file = None):
|
||||
if require_version:
|
||||
version = require_version.split(".", 2)
|
||||
major_version = int(version[0])
|
||||
|
@ -13,6 +13,11 @@ def CheckSDL(context, sdl_lib = "SDL", require_version = None):
|
|||
except (ValueError, IndexError):
|
||||
patch_level = 0
|
||||
|
||||
if header_file:
|
||||
sdl_header = header_file
|
||||
else:
|
||||
sdl_header = sdl_lib
|
||||
|
||||
backup = backup_env(context.env, ["CPPPATH", "LIBPATH", "LIBS"])
|
||||
|
||||
sdldir = context.env.get("sdldir", "")
|
||||
|
@ -21,13 +26,25 @@ def CheckSDL(context, sdl_lib = "SDL", require_version = None):
|
|||
context.Message("Checking for Simple DirectMedia Layer library version >= %d.%d.%d... " % (major_version, minor_version, patchlevel))
|
||||
else:
|
||||
context.Message("Checking for Simple DirectMedia Layer library... ")
|
||||
if major_version == 2:
|
||||
sdl_config_name = "sdl2-config"
|
||||
sdl_include_dir = "include/SDL2"
|
||||
sdl_lib_name = "SDL2"
|
||||
sdl_lib_name_pkgconfig = "sdl2"
|
||||
sdlmain_name = "SDL2main"
|
||||
else:
|
||||
sdl_config_name = "sdl-config"
|
||||
sdl_include_dir = "include/SDL"
|
||||
sdl_lib_name = "SDL"
|
||||
sdl_lib_name_pkgconfig = "sdl"
|
||||
sdlmain_name = "SDLmain"
|
||||
env = context.env
|
||||
if sdldir:
|
||||
env.AppendUnique(CPPPATH = [os.path.join(sdldir, "include/SDL")], LIBPATH = [os.path.join(sdldir, "lib")])
|
||||
env.AppendUnique(CPPPATH = [os.path.join(sdldir, sdl_include_dir)], LIBPATH = [os.path.join(sdldir, "lib")])
|
||||
else:
|
||||
for foo_config in [
|
||||
"pkg-config --cflags --libs sdl",
|
||||
"sdl-config --cflags --libs"
|
||||
"pkg-config --cflags --libs %s" % sdl_lib_name_pkgconfig,
|
||||
"%s --cflags --libs" % sdl_config_name
|
||||
]:
|
||||
try:
|
||||
env.ParseConfig(foo_config)
|
||||
|
@ -37,7 +54,7 @@ def CheckSDL(context, sdl_lib = "SDL", require_version = None):
|
|||
break
|
||||
if env["PLATFORM"] == "win32":
|
||||
env.AppendUnique(CCFLAGS = ["-D_GNU_SOURCE"])
|
||||
env.AppendUnique(LIBS = Split("mingw32 SDLmain SDL"))
|
||||
env.AppendUnique(LIBS = Split("mingw32 %s %s" % (sdlmain_name, sdl_lib_name)))
|
||||
env.AppendUnique(LINKFLAGS = ["-mwindows"])
|
||||
else:
|
||||
if require_version:
|
||||
|
@ -47,7 +64,7 @@ def CheckSDL(context, sdl_lib = "SDL", require_version = None):
|
|||
context.env.AppendUnique(LIBS = [sdl_lib])
|
||||
test_program = """
|
||||
#include <%s.h>
|
||||
\n""" % sdl_lib
|
||||
\n""" % sdl_header
|
||||
if require_version:
|
||||
test_program += "#if SDL_VERSIONNUM(%s, %s, %s) < SDL_VERSIONNUM(%d, %d, %d)\n#error Library is too old!\n#endif\n" % \
|
||||
(sdl_lib.upper() + "_MAJOR_VERSION", \
|
||||
|
|
Loading…
Add table
Reference in a new issue