Have cmake also execute the conftests.
This commit is contained in:
parent
ea83e36bdb
commit
0aa8dc3c6c
13 changed files with 327 additions and 223 deletions
5
.github/workflows/ci-scripts/docker.sh
vendored
5
.github/workflows/ci-scripts/docker.sh
vendored
|
@ -99,8 +99,9 @@ else
|
||||||
|
|
||||||
cmake -DCMAKE_BUILD_TYPE="$CFG" -DENABLE_GAME=true -DENABLE_SERVER=true -DENABLE_CAMPAIGN_SERVER=true -DENABLE_TESTS=true -DENABLE_NLS="$NLS" \
|
cmake -DCMAKE_BUILD_TYPE="$CFG" -DENABLE_GAME=true -DENABLE_SERVER=true -DENABLE_CAMPAIGN_SERVER=true -DENABLE_TESTS=true -DENABLE_NLS="$NLS" \
|
||||||
-DEXTRA_FLAGS_CONFIG="-pipe" -DENABLE_STRICT_COMPILATION=true -DENABLE_LTO="$LTO" -DLTO_JOBS=2 -DENABLE_MYSQL=true \
|
-DEXTRA_FLAGS_CONFIG="-pipe" -DENABLE_STRICT_COMPILATION=true -DENABLE_LTO="$LTO" -DLTO_JOBS=2 -DENABLE_MYSQL=true \
|
||||||
-DCXX_STD="$CXX_STD" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache . && \
|
-DCXX_STD="$CXX_STD" -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache . || exit 1
|
||||||
make VERBOSE=1 -j2
|
make conftests || exit 1
|
||||||
|
make VERBOSE=1 -j2
|
||||||
EXIT_VAL=$?
|
EXIT_VAL=$?
|
||||||
|
|
||||||
ccache -s
|
ccache -s
|
||||||
|
|
9
.gitignore
vendored
9
.gitignore
vendored
|
@ -19,6 +19,15 @@ uninstall.cmake
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
install_manifest.txt
|
install_manifest.txt
|
||||||
out/**/*
|
out/**/*
|
||||||
|
CTestTestfile.cmake
|
||||||
|
DartConfiguration.tcl
|
||||||
|
Testing/*
|
||||||
|
doc/CTestTestfile.cmake
|
||||||
|
doc/design/CTestTestfile.cmake
|
||||||
|
doc/man/CTestTestfile.cmake
|
||||||
|
doc/manual/CTestTestfile.cmake
|
||||||
|
src/CTestTestfile.cmake
|
||||||
|
src/Testing/
|
||||||
|
|
||||||
# scons
|
# scons
|
||||||
.scons-option-cache
|
.scons-option-cache
|
||||||
|
|
|
@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 3.14)
|
||||||
project(wesnoth)
|
project(wesnoth)
|
||||||
|
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
# use our own version of FindBoost.cmake and other Find* scripts
|
# use our own version of FindBoost.cmake and other Find* scripts
|
||||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
|
|
|
@ -350,9 +350,9 @@ if env["prereqs"]:
|
||||||
|
|
||||||
def have_sdl_other():
|
def have_sdl_other():
|
||||||
return \
|
return \
|
||||||
conf.CheckSDL(require_version = '2.0.8') & \
|
conf.CheckSDL2('2.0.8') & \
|
||||||
conf.CheckSDL("SDL2_mixer", header_file = "SDL_mixer") & \
|
conf.CheckSDL2Mixer() & \
|
||||||
conf.CheckSDL("SDL2_image", header_file = "SDL_image")
|
conf.CheckSDL2Image()
|
||||||
|
|
||||||
if sys.platform == "msys":
|
if sys.platform == "msys":
|
||||||
env["PKG_CONFIG_FLAGS"] = "--dont-define-prefix"
|
env["PKG_CONFIG_FLAGS"] = "--dont-define-prefix"
|
||||||
|
|
362
scons/sdl.py
362
scons/sdl.py
|
@ -1,151 +1,117 @@
|
||||||
# vi: syntax=python:et:ts=4
|
# vi: syntax=python:et:ts=4
|
||||||
import os
|
import os
|
||||||
|
import os.path
|
||||||
from SCons.Script import *
|
from SCons.Script import *
|
||||||
from config_check_utils import *
|
from config_check_utils import *
|
||||||
from os import environ
|
from os import environ
|
||||||
from SCons.Util import PrependPath
|
from SCons.Util import PrependPath
|
||||||
|
|
||||||
def CheckSDL(context, sdl_lib = "SDL", require_version = None, header_file = None):
|
def CheckSDL2(context, require_version):
|
||||||
if require_version:
|
version = require_version.split(".", 2)
|
||||||
version = require_version.split(".", 2)
|
major_version = version[0]
|
||||||
major_version = int(version[0])
|
minor_version = version[1]
|
||||||
minor_version = int(version[1])
|
patchlevel = version[2]
|
||||||
try:
|
|
||||||
patchlevel = int(version[2])
|
|
||||||
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"])
|
backup = backup_env(context.env, ["CPPPATH", "LIBPATH", "LIBS"])
|
||||||
|
|
||||||
sdldir = context.env.get("sdldir", "")
|
sdldir = context.env.get("sdldir", "")
|
||||||
if sdl_lib == "SDL":
|
context.Message("Checking for Simple DirectMedia Layer library version >= %s.%s.%s... " % (major_version, minor_version, patchlevel))
|
||||||
if require_version:
|
|
||||||
context.Message("Checking for Simple DirectMedia Layer library version >= %d.%d.%d... " % (major_version, minor_version, patchlevel))
|
env = context.env
|
||||||
else:
|
if sdldir:
|
||||||
context.Message("Checking for Simple DirectMedia Layer library... ")
|
env["ENV"]["PATH"] = PrependPath(environ["PATH"], join(sdldir, "bin"))
|
||||||
if major_version == 2:
|
env["ENV"]["PKG_CONFIG_PATH"] = PrependPath(environ.get("PKG_CONFIG_PATH", ""), join(sdldir, "lib/pkgconfig"))
|
||||||
sdl_config_name = "sdl2-config"
|
|
||||||
sdl_include_dir = "include/SDL2"
|
if env["PLATFORM"] != "win32" or sys.platform == "msys":
|
||||||
sdl_lib_name = "SDL2"
|
for foo_config in [
|
||||||
sdl_lib_name_pkgconfig = "sdl2"
|
"pkg-config --cflags --libs $PKG_CONFIG_FLAGS sdl2",
|
||||||
sdlmain_name = "SDL2main"
|
"sdl2-config --cflags --libs"
|
||||||
else:
|
]:
|
||||||
sdl_config_name = "sdl-config"
|
try:
|
||||||
sdl_include_dir = "include/SDL"
|
env.ParseConfig(foo_config)
|
||||||
sdl_lib_name = "SDL"
|
except OSError:
|
||||||
sdl_lib_name_pkgconfig = "sdl"
|
pass
|
||||||
sdlmain_name = "SDLmain"
|
else:
|
||||||
env = context.env
|
break
|
||||||
|
else:
|
||||||
if sdldir:
|
if sdldir:
|
||||||
env["ENV"]["PATH"] = PrependPath(environ["PATH"], join(sdldir, "bin"))
|
env.AppendUnique(CPPPATH = [os.path.join(sdldir, "include/SDL2")], LIBPATH = [os.path.join(sdldir, "lib")])
|
||||||
env["ENV"]["PKG_CONFIG_PATH"] = PrependPath(environ.get("PKG_CONFIG_PATH", ""), join(sdldir, "lib/pkgconfig"))
|
env.AppendUnique(CCFLAGS = ["-D_GNU_SOURCE"])
|
||||||
if env["PLATFORM"] != "win32" or sys.platform == "msys":
|
env.AppendUnique(LIBS = Split("mingw32 SDL2main SDL2"))
|
||||||
for foo_config in [
|
env.AppendUnique(LINKFLAGS = ["-mwindows"])
|
||||||
"pkg-config --cflags --libs $PKG_CONFIG_FLAGS %s" % sdl_lib_name_pkgconfig,
|
|
||||||
"%s --cflags --libs" % sdl_config_name
|
cpp_file = File("src/conftests/sdl2.cpp").rfile().abspath
|
||||||
]:
|
if not os.path.isfile(cpp_file):
|
||||||
try:
|
cpp_file = "src/conftests/sdl2.cpp"
|
||||||
env.ParseConfig(foo_config)
|
|
||||||
except OSError:
|
with open(cpp_file, 'r') as file:
|
||||||
pass
|
test_program = file.read().replace("argv[1]", "\""+major_version+"\"").replace("argv[2]", "\""+minor_version+"\"").replace("argv[3]", "\""+patchlevel+"\"")
|
||||||
else:
|
|
||||||
break
|
if context.TryLink(test_program, ".cpp"):
|
||||||
|
context.Result("yes")
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
if sdldir:
|
context.Result("no")
|
||||||
env.AppendUnique(CPPPATH = [os.path.join(sdldir, sdl_include_dir)], LIBPATH = [os.path.join(sdldir, "lib")])
|
restore_env(context.env, backup)
|
||||||
env.AppendUnique(CCFLAGS = ["-D_GNU_SOURCE"])
|
return False
|
||||||
env.AppendUnique(LIBS = Split("mingw32 %s %s" % (sdlmain_name, sdl_lib_name)))
|
|
||||||
env.AppendUnique(LINKFLAGS = ["-mwindows"])
|
def CheckSDL2Image(context):
|
||||||
else:
|
backup = backup_env(context.env, ["CPPPATH", "LIBPATH", "LIBS"])
|
||||||
if require_version:
|
context.Message("Checking for SDL2_image library... ")
|
||||||
context.Message("Checking for %s library version >= %d.%d.%d... " % (sdl_lib, major_version, minor_version, patchlevel))
|
context.env.AppendUnique(LIBS = ["SDL2_image"])
|
||||||
|
|
||||||
|
cpp_file = File("src/conftests/sdl2_image.cpp").rfile().abspath
|
||||||
|
if not os.path.isfile(cpp_file):
|
||||||
|
cpp_file = "src/conftests/sdl2_image.cpp"
|
||||||
|
|
||||||
|
with open(cpp_file, 'r') as file:
|
||||||
|
test_program = file.read()
|
||||||
|
|
||||||
|
if context.TryLink(test_program, ".cpp"):
|
||||||
|
context.Result("yes")
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
context.Message("Checking for %s library... " % sdl_lib)
|
context.Result("no")
|
||||||
context.env.AppendUnique(LIBS = [sdl_lib])
|
restore_env(context.env, backup)
|
||||||
test_program = """
|
return False
|
||||||
#include <%s.h>
|
|
||||||
\n""" % sdl_header
|
def CheckSDL2Mixer(context):
|
||||||
if require_version:
|
backup = backup_env(context.env, ["CPPPATH", "LIBPATH", "LIBS"])
|
||||||
test_program += "#if SDL_VERSIONNUM(%s, %s, %s) < SDL_VERSIONNUM(%d, %d, %d)\n#error Library is too old!\n#endif\n" % \
|
context.Message("Checking for SDL2_mixer library... ")
|
||||||
(sdl_lib.upper() + "_MAJOR_VERSION", \
|
context.env.AppendUnique(LIBS = ["SDL2_mixer"])
|
||||||
sdl_lib.upper() + "_MINOR_VERSION", \
|
|
||||||
sdl_lib.upper() + "_PATCHLEVEL", \
|
cpp_file = File("src/conftests/sdl2_mixer.cpp").rfile().abspath
|
||||||
major_version, minor_version, patchlevel)
|
if not os.path.isfile(cpp_file):
|
||||||
test_program += """
|
cpp_file = "src/conftests/sdl2_mixer.cpp"
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
with open(cpp_file, 'r') as file:
|
||||||
SDL_Init(0);
|
test_program = file.read()
|
||||||
SDL_Quit();
|
|
||||||
}
|
if context.TryLink(test_program, ".cpp"):
|
||||||
\n"""
|
context.Result("yes")
|
||||||
if context.TryLink(test_program, ".c"):
|
return True
|
||||||
context.Result("yes")
|
else:
|
||||||
return True
|
context.Result("no")
|
||||||
else:
|
restore_env(context.env, backup)
|
||||||
context.Result("no")
|
return False
|
||||||
restore_env(context.env, backup)
|
|
||||||
return False
|
|
||||||
|
|
||||||
def CheckOgg(context):
|
def CheckOgg(context):
|
||||||
test_program = '''
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <SDL.h>
|
|
||||||
#include <SDL_mixer.h>
|
|
||||||
|
|
||||||
int main(int argc, char ** argv)
|
|
||||||
{
|
|
||||||
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
|
||||||
fprintf(stdout, "Cannot initialize SDL Audio: %s\\n", SDL_GetError());
|
|
||||||
return (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1) {
|
|
||||||
fprintf(stdout, "Cannot initialize SDL Mixer: %s\\n", Mix_GetError());
|
|
||||||
return (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Mix_Init(MIX_INIT_OGG) != MIX_INIT_OGG) {
|
|
||||||
fprintf(stdout, "Cannot initialize OGG codec: %s\\n", Mix_GetError());
|
|
||||||
Mix_CloseAudio();
|
|
||||||
return (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
Mix_Music* music = Mix_LoadMUS("$TESTFILE");
|
|
||||||
if (music == NULL) {
|
|
||||||
fprintf(stdout, "Cannot load music file: %s\\n", Mix_GetError());
|
|
||||||
Mix_CloseAudio();
|
|
||||||
return (EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stdout, "Success\\n");
|
|
||||||
Mix_FreeMusic(music);
|
|
||||||
Mix_CloseAudio();
|
|
||||||
return (EXIT_SUCCESS);
|
|
||||||
}
|
|
||||||
\n
|
|
||||||
'''
|
|
||||||
nodepath = File("data/core/music/main_menu.ogg").rfile().abspath.replace("\\", "\\\\")
|
|
||||||
test_program1 = context.env.Clone(TESTFILE = nodepath).subst(test_program)
|
|
||||||
#context.env.AppendUnique(LIBS = "SDL_mixer")
|
|
||||||
context.Message("Checking for Ogg Vorbis support in SDL... ")
|
|
||||||
if context.env["host"]:
|
|
||||||
context.Result("n/a (cross-compile)")
|
|
||||||
return True
|
|
||||||
context.env["ENV"]["SDL_AUDIODRIVER"] = "dummy"
|
context.env["ENV"]["SDL_AUDIODRIVER"] = "dummy"
|
||||||
(result, output) = context.TryRun(test_program1, ".c")
|
|
||||||
if result:
|
cpp_file = File("src/conftests/sdl2_audio.cpp").rfile().abspath
|
||||||
context.Result("yes")
|
if not os.path.isfile(cpp_file):
|
||||||
return True
|
cpp_file = "src/conftests/sdl2_audio.cpp"
|
||||||
else:
|
|
||||||
test_program2 = context.env.Clone(TESTFILE = "data/core/music/main_menu.ogg").subst(test_program)
|
ogg_file = File("data/core/music/main_menu.ogg").rfile().abspath
|
||||||
(result, output) = context.TryRun(test_program2, ".c")
|
if not os.path.isfile(ogg_file):
|
||||||
|
ogg_file = "data/core/music/main_menu.ogg"
|
||||||
|
|
||||||
|
with open(cpp_file, 'r') as file:
|
||||||
|
test_program = file.read().replace("argv[1]", "\""+ogg_file+"\"")
|
||||||
|
|
||||||
|
context.Message("Checking for audio support in SDL... ")
|
||||||
|
if context.env["host"]:
|
||||||
|
context.Result("n/a (cross-compile)")
|
||||||
|
return True
|
||||||
|
(result, output) = context.TryRun(test_program, ".cpp")
|
||||||
if result:
|
if result:
|
||||||
context.Result("yes")
|
context.Result("yes")
|
||||||
return True
|
return True
|
||||||
|
@ -154,36 +120,22 @@ int main(int argc, char ** argv)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def CheckPNG(context):
|
def CheckPNG(context):
|
||||||
test_program = '''
|
cpp_file = File("src/conftests/sdl2_png.cpp").rfile().abspath
|
||||||
#include <SDL_image.h>
|
if not os.path.isfile(cpp_file):
|
||||||
#include <stdlib.h>
|
cpp_file = "src/conftests/sdl2_png.cpp"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
img_file = File("data/core/images/scons_conftest_images/end-n.png").rfile().abspath
|
||||||
{
|
if not os.path.isfile(img_file):
|
||||||
SDL_RWops *src;
|
img_file = "data/core/images/scons_conftest_images/end-n.png"
|
||||||
char *testimage = "$TESTFILE";
|
|
||||||
|
|
||||||
src = SDL_RWFromFile(testimage, "rb");
|
with open(cpp_file, 'r') as file:
|
||||||
if (src == NULL) {
|
test_program = file.read().replace("argv[1]", "\""+img_file+"\"")
|
||||||
exit(2);
|
|
||||||
}
|
context.Message("Checking for PNG support in SDL... ")
|
||||||
exit(!IMG_isPNG(src));
|
if context.env["host"]:
|
||||||
}
|
context.Result("n/a (cross-compile)")
|
||||||
\n
|
return True
|
||||||
'''
|
(result, output) = context.TryRun(test_program, ".cpp")
|
||||||
nodepath = File("data/core/images/scons_conftest_images/end-n.png").rfile().abspath.replace("\\", "\\\\")
|
|
||||||
test_program1 = context.env.Clone(TESTFILE = nodepath).subst(test_program)
|
|
||||||
context.Message("Checking for PNG support in SDL... ")
|
|
||||||
if context.env["host"]:
|
|
||||||
context.Result("n/a (cross-compile)")
|
|
||||||
return True
|
|
||||||
(result, output) = context.TryRun(test_program1, ".c")
|
|
||||||
if result:
|
|
||||||
context.Result("yes")
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
test_program2 = context.env.Clone(TESTFILE = "data/core/images/scons_conftest_images/end-n.png").subst(test_program)
|
|
||||||
(result, output) = context.TryRun(test_program2, ".c")
|
|
||||||
if result:
|
if result:
|
||||||
context.Result("yes")
|
context.Result("yes")
|
||||||
return True
|
return True
|
||||||
|
@ -192,36 +144,22 @@ def CheckPNG(context):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def CheckWebP(context):
|
def CheckWebP(context):
|
||||||
test_program = '''
|
cpp_file = File("src/conftests/sdl2_webp.cpp").rfile().abspath
|
||||||
#include <SDL_image.h>
|
if not os.path.isfile(cpp_file):
|
||||||
#include <stdlib.h>
|
cpp_file = "src/conftests/sdl2_webp.cpp"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
img_file = File("data/core/images/scons_conftest_images/end-n.webp").rfile().abspath
|
||||||
{
|
if not os.path.isfile(img_file):
|
||||||
SDL_RWops *src;
|
img_file = "data/core/images/scons_conftest_images/end-n.webp"
|
||||||
char *testimage = "$TESTFILE";
|
|
||||||
|
|
||||||
src = SDL_RWFromFile(testimage, "rb");
|
with open(cpp_file, 'r') as file:
|
||||||
if (src == NULL) {
|
test_program = file.read().replace("argv[1]", "\""+img_file+"\"")
|
||||||
exit(2);
|
|
||||||
}
|
context.Message("Checking for WEBP support in SDL... ")
|
||||||
exit(!IMG_isWEBP(src));
|
if context.env["host"]:
|
||||||
}
|
context.Result("n/a (cross-compile)")
|
||||||
\n
|
return True
|
||||||
'''
|
(result, output) = context.TryRun(test_program, ".cpp")
|
||||||
nodepath = File("data/core/images/scons_conftest_images/end-n.webp").rfile().abspath.replace("\\", "\\\\")
|
|
||||||
test_program1 = context.env.Clone(TESTFILE = nodepath).subst(test_program)
|
|
||||||
context.Message("Checking for WebP support in SDL... ")
|
|
||||||
if context.env["host"]:
|
|
||||||
context.Result("n/a (cross-compile)")
|
|
||||||
return True
|
|
||||||
(result, output) = context.TryRun(test_program1, ".c")
|
|
||||||
if result:
|
|
||||||
context.Result("yes")
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
test_program2 = context.env.Clone(TESTFILE = "data/core/images/scons_conftest_images/end-n.webp").subst(test_program)
|
|
||||||
(result, output) = context.TryRun(test_program2, ".c")
|
|
||||||
if result:
|
if result:
|
||||||
context.Result("yes")
|
context.Result("yes")
|
||||||
return True
|
return True
|
||||||
|
@ -230,36 +168,22 @@ def CheckWebP(context):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def CheckJPG(context):
|
def CheckJPG(context):
|
||||||
test_program = '''
|
cpp_file = File("src/conftests/sdl2_jpg.cpp").rfile().abspath
|
||||||
#include <SDL_image.h>
|
if not os.path.isfile(cpp_file):
|
||||||
#include <stdlib.h>
|
cpp_file = "src/conftests/sdl2_jpg.cpp"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
img_file = File("data/core/images/scons_conftest_images/end-n.jpg").rfile().abspath
|
||||||
{
|
if not os.path.isfile(img_file):
|
||||||
SDL_RWops *src;
|
img_file = "data/core/images/scons_conftest_images/end-n.jpg"
|
||||||
char *testimage = "$TESTFILE";
|
|
||||||
|
|
||||||
src = SDL_RWFromFile(testimage, "rb");
|
with open(cpp_file, 'r') as file:
|
||||||
if (src == NULL) {
|
test_program = file.read().replace("argv[1]", "\""+img_file+"\"")
|
||||||
exit(2);
|
|
||||||
}
|
context.Message("Checking for JPG support in SDL... ")
|
||||||
exit(!IMG_isJPG(src));
|
if context.env["host"]:
|
||||||
}
|
context.Result("n/a (cross-compile)")
|
||||||
\n
|
return True
|
||||||
'''
|
(result, output) = context.TryRun(test_program, ".cpp")
|
||||||
nodepath = File("data/core/images/scons_conftest_images/end-n.jpg").rfile().abspath.replace("\\", "\\\\")
|
|
||||||
test_program1 = context.env.Clone(TESTFILE = nodepath).subst(test_program)
|
|
||||||
context.Message("Checking for JPG support in SDL... ")
|
|
||||||
if context.env["host"]:
|
|
||||||
context.Result("n/a (cross-compile)")
|
|
||||||
return True
|
|
||||||
(result, output) = context.TryRun(test_program1, ".c")
|
|
||||||
if result:
|
|
||||||
context.Result("yes")
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
test_program2 = context.env.Clone(TESTFILE = "data/core/images/scons_conftest_images/end-n.jpg").subst(test_program)
|
|
||||||
(result, output) = context.TryRun(test_program2, ".c")
|
|
||||||
if result:
|
if result:
|
||||||
context.Result("yes")
|
context.Result("yes")
|
||||||
return True
|
return True
|
||||||
|
@ -267,7 +191,9 @@ def CheckJPG(context):
|
||||||
context.Result("no")
|
context.Result("no")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
config_checks = { 'CheckSDL' : CheckSDL,
|
config_checks = { 'CheckSDL2Image' : CheckSDL2Image,
|
||||||
|
'CheckSDL2Mixer' : CheckSDL2Mixer,
|
||||||
|
'CheckSDL2': CheckSDL2,
|
||||||
'CheckOgg' : CheckOgg,
|
'CheckOgg' : CheckOgg,
|
||||||
'CheckPNG' : CheckPNG,
|
'CheckPNG' : CheckPNG,
|
||||||
'CheckJPG' : CheckJPG,
|
'CheckJPG' : CheckJPG,
|
||||||
|
|
|
@ -142,6 +142,65 @@ if(ENABLE_DISPLAY_REVISION)
|
||||||
set_source_files_properties(game_config.cpp PROPERTIES COMPILE_DEFINITIONS "LOAD_REVISION")
|
set_source_files_properties(game_config.cpp PROPERTIES COMPILE_DEFINITIONS "LOAD_REVISION")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
########### Conf Tests ###########
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
# test for SDL2
|
||||||
|
add_executable(sdl2 conftests/sdl2.cpp)
|
||||||
|
set_target_properties(sdl2 PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Testing)
|
||||||
|
target_link_libraries(sdl2 ${game-external-libs})
|
||||||
|
# cmake checks the version elsewhere already, but scons uses this, which is why the three arguments for major.minor.patchlevel are 0 here
|
||||||
|
add_test(NAME SDL2_SUPPORT COMMAND sdl2 0 0 0)
|
||||||
|
|
||||||
|
# test for SDL2_image
|
||||||
|
add_executable(sdl2_image conftests/sdl2_image.cpp)
|
||||||
|
set_target_properties(sdl2_image PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Testing)
|
||||||
|
target_link_libraries(sdl2_image ${game-external-libs})
|
||||||
|
add_test(NAME SDL2_IMAGE_SUPPORT COMMAND sdl2_image)
|
||||||
|
|
||||||
|
# test for SDL2_mixer
|
||||||
|
add_executable(sdl2_mixer conftests/sdl2_mixer.cpp)
|
||||||
|
set_target_properties(sdl2_mixer PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Testing)
|
||||||
|
target_link_libraries(sdl2_mixer ${game-external-libs})
|
||||||
|
add_test(NAME SDL2_MIXER_SUPPORT COMMAND sdl2_mixer)
|
||||||
|
|
||||||
|
# test for JPG support in SDL2
|
||||||
|
add_executable(sdl2_jpg conftests/sdl2_jpg.cpp)
|
||||||
|
set_target_properties(sdl2_jpg PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Testing)
|
||||||
|
target_link_libraries(sdl2_jpg ${game-external-libs})
|
||||||
|
add_test(NAME SDL2_JPG_SUPPORT COMMAND sdl2_jpg "${CMAKE_SOURCE_DIR}/data/core/images/scons_conftest_images/end-n.jpg")
|
||||||
|
|
||||||
|
# test for PNG support in SDL2
|
||||||
|
add_executable(sdl2_png conftests/sdl2_png.cpp)
|
||||||
|
set_target_properties(sdl2_png PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Testing)
|
||||||
|
target_link_libraries(sdl2_png ${game-external-libs})
|
||||||
|
add_test(NAME SDL2_PNG_SUPPORT COMMAND sdl2_png "${CMAKE_SOURCE_DIR}/data/core/images/scons_conftest_images/end-n.png")
|
||||||
|
|
||||||
|
# test for WEBP support in SDL2
|
||||||
|
add_executable(sdl2_webp conftests/sdl2_webp.cpp)
|
||||||
|
set_target_properties(sdl2_webp PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Testing)
|
||||||
|
target_link_libraries(sdl2_webp ${game-external-libs})
|
||||||
|
add_test(NAME SDL2_WEBP_SUPPORT COMMAND sdl2_webp "${CMAKE_SOURCE_DIR}/data/core/images/scons_conftest_images/end-n.webp")
|
||||||
|
|
||||||
|
# test for audio support in SDL2
|
||||||
|
add_executable(sdl2_audio conftests/sdl2_audio.cpp)
|
||||||
|
set_target_properties(sdl2_audio PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Testing)
|
||||||
|
target_link_libraries(sdl2_audio ${game-external-libs})
|
||||||
|
add_test(NAME SDL2_AUDIO_SUPPORT COMMAND sdl2_audio "${CMAKE_SOURCE_DIR}/data/core/music/main_menu.ogg")
|
||||||
|
|
||||||
|
add_custom_target(conftests
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E env "SDL_AUDIODRIVER=dummy" ${CMAKE_CTEST_COMMAND}
|
||||||
|
DEPENDS
|
||||||
|
sdl2
|
||||||
|
sdl2_image
|
||||||
|
sdl2_mixer
|
||||||
|
sdl2_jpg
|
||||||
|
sdl2_png
|
||||||
|
sdl2_webp
|
||||||
|
sdl2_audio
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
########### Wesnoth ###############
|
########### Wesnoth ###############
|
||||||
|
|
||||||
add_library(wesnoth-common STATIC ${wesnoth_core_sources})
|
add_library(wesnoth-common STATIC ${wesnoth_core_sources})
|
||||||
|
|
19
src/conftests/sdl2.cpp
Normal file
19
src/conftests/sdl2.cpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
int main(int, char** argv)
|
||||||
|
{
|
||||||
|
int major = std::stoi(argv[1]);
|
||||||
|
int minor = std::stoi(argv[2]);
|
||||||
|
int patchlevel = std::stoi(argv[3]);
|
||||||
|
|
||||||
|
if(!SDL_VERSION_ATLEAST(major, minor, patchlevel)) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Init(0);
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
36
src/conftests/sdl2_audio.cpp
Normal file
36
src/conftests/sdl2_audio.cpp
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_mixer.h>
|
||||||
|
|
||||||
|
int main(int, char** argv)
|
||||||
|
{
|
||||||
|
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||||
|
fprintf(stdout, "Cannot initialize SDL Audio: %s\\n", SDL_GetError());
|
||||||
|
return (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024) == -1) {
|
||||||
|
fprintf(stdout, "Cannot initialize SDL Mixer: %s\\n", Mix_GetError());
|
||||||
|
return (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Mix_Init(MIX_INIT_OGG) != MIX_INIT_OGG) {
|
||||||
|
fprintf(stdout, "Cannot initialize OGG codec: %s\\n", Mix_GetError());
|
||||||
|
Mix_CloseAudio();
|
||||||
|
return (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
Mix_Music* music = Mix_LoadMUS(argv[1]);
|
||||||
|
if (music == NULL) {
|
||||||
|
fprintf(stdout, "Cannot load music file: %s\\n", Mix_GetError());
|
||||||
|
Mix_CloseAudio();
|
||||||
|
return (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stdout, "Success\\n");
|
||||||
|
Mix_FreeMusic(music);
|
||||||
|
Mix_CloseAudio();
|
||||||
|
return (EXIT_SUCCESS);
|
||||||
|
}
|
10
src/conftests/sdl2_image.cpp
Normal file
10
src/conftests/sdl2_image.cpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_image.h>
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
SDL_Init(0);
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
11
src/conftests/sdl2_jpg.cpp
Normal file
11
src/conftests/sdl2_jpg.cpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include <SDL2/SDL_image.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(int, char** argv)
|
||||||
|
{
|
||||||
|
SDL_RWops *src = SDL_RWFromFile(argv[1], "rb");
|
||||||
|
if (src == NULL) {
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
exit(!IMG_isJPG(src));
|
||||||
|
}
|
10
src/conftests/sdl2_mixer.cpp
Normal file
10
src/conftests/sdl2_mixer.cpp
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
#include <SDL2/SDL_mixer.h>
|
||||||
|
|
||||||
|
int main(int, char**)
|
||||||
|
{
|
||||||
|
SDL_Init(0);
|
||||||
|
SDL_Quit();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
11
src/conftests/sdl2_png.cpp
Normal file
11
src/conftests/sdl2_png.cpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include <SDL2/SDL_image.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(int, char** argv)
|
||||||
|
{
|
||||||
|
SDL_RWops *src = SDL_RWFromFile(argv[1], "rb");
|
||||||
|
if (src == NULL) {
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
exit(!IMG_isPNG(src));
|
||||||
|
}
|
11
src/conftests/sdl2_webp.cpp
Normal file
11
src/conftests/sdl2_webp.cpp
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#include <SDL2/SDL_image.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main(int, char** argv)
|
||||||
|
{
|
||||||
|
SDL_RWops *src = SDL_RWFromFile(argv[1], "rb");
|
||||||
|
if (src == NULL) {
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
exit(!IMG_isWEBP(src));
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue