Add build support for webp images.

This commit is contained in:
Pentarctagon 2021-12-14 23:15:11 -06:00 committed by Pentarctagon
parent 2c0b0bac68
commit f44acd68c2
8 changed files with 48 additions and 9 deletions

View file

@ -390,8 +390,7 @@ if env["prereqs"]:
have_client_prereqs = have_client_prereqs & conf.CheckLib("vorbisfile") & conf.CheckOgg() have_client_prereqs = have_client_prereqs & conf.CheckLib("vorbisfile") & conf.CheckOgg()
have_client_prereqs = have_client_prereqs & conf.CheckPNG() have_client_prereqs = have_client_prereqs & conf.CheckPNG()
have_client_prereqs = have_client_prereqs & conf.CheckJPG() have_client_prereqs = have_client_prereqs & conf.CheckJPG()
# have_client_prereqs = have_client_prereqs & conf.CheckOpenGL() have_client_prereqs = have_client_prereqs & conf.CheckWebP()
# have_client_prereqs = have_client_prereqs & conf.CheckGLEW()
have_client_prereqs = have_client_prereqs & conf.CheckCairo(min_version = "1.10") have_client_prereqs = have_client_prereqs & conf.CheckCairo(min_version = "1.10")
have_client_prereqs = have_client_prereqs & conf.CheckPango("cairo", require_version = "1.22.0") have_client_prereqs = have_client_prereqs & conf.CheckPango("cairo", require_version = "1.22.0")
have_client_prereqs = have_client_prereqs & conf.CheckPKG("fontconfig") have_client_prereqs = have_client_prereqs & conf.CheckPKG("fontconfig")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 MiB

View file

@ -62,7 +62,7 @@
[images] [images]
game_title="maps/titlescreen.png" game_title="maps/titlescreen.png"
game_title_background="maps/background.jpg" game_title_background="maps/background.webp"
game_logo="misc/logo.png" game_logo="misc/logo.png"
game_logo_background="misc/logo-bg.png" game_logo_background="misc/logo-bg.png"

View file

@ -191,6 +191,44 @@ def CheckPNG(context):
context.Result("no") context.Result("no")
return False return False
def CheckWebP(context):
test_program = '''
#include <SDL_image.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
SDL_RWops *src;
char *testimage = "$TESTFILE";
src = SDL_RWFromFile(testimage, "rb");
if (src == NULL) {
exit(2);
}
exit(!IMG_isWEBP(src));
}
\n
'''
nodepath = File("data/core/images/maps/background.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/maps/background.webp").subst(test_program)
(result, output) = context.TryRun(test_program2, ".c")
if result:
context.Result("yes")
return True
else:
context.Result("no")
return False
def CheckJPG(context): def CheckJPG(context):
test_program = ''' test_program = '''
#include <SDL_image.h> #include <SDL_image.h>
@ -209,7 +247,7 @@ def CheckJPG(context):
} }
\n \n
''' '''
nodepath = File("data/core/images/maps/background.jpg").rfile().abspath.replace("\\", "\\\\") nodepath = File("attic/northlands.jpg").rfile().abspath.replace("\\", "\\\\")
test_program1 = context.env.Clone(TESTFILE = nodepath).subst(test_program) test_program1 = context.env.Clone(TESTFILE = nodepath).subst(test_program)
context.Message("Checking for JPG support in SDL... ") context.Message("Checking for JPG support in SDL... ")
if context.env["host"]: if context.env["host"]:
@ -220,7 +258,7 @@ def CheckJPG(context):
context.Result("yes") context.Result("yes")
return True return True
else: else:
test_program2 = context.env.Clone(TESTFILE = "data/core/images/maps/background.jpg").subst(test_program) test_program2 = context.env.Clone(TESTFILE = "attic/northlands.jpg").subst(test_program)
(result, output) = context.TryRun(test_program2, ".c") (result, output) = context.TryRun(test_program2, ".c")
if result: if result:
context.Result("yes") context.Result("yes")
@ -232,4 +270,5 @@ def CheckJPG(context):
config_checks = { 'CheckSDL' : CheckSDL, config_checks = { 'CheckSDL' : CheckSDL,
'CheckOgg' : CheckOgg, 'CheckOgg' : CheckOgg,
'CheckPNG' : CheckPNG, 'CheckPNG' : CheckPNG,
'CheckJPG' : CheckJPG } 'CheckJPG' : CheckJPG,
'CheckWebP' : CheckWebP }

View file

@ -8,7 +8,7 @@ command -v isutf8 >/dev/null || { echo "Install 'isutf8' from moreutils to use t
exit_code=0 exit_code=0
find src/ -type f -not -path "src/modules/*" -print0 | xargs -0 isutf8 -- || exit_code=1 find src/ -type f -not -path "src/modules/*" -print0 | xargs -0 isutf8 -- || exit_code=1
for ex in png ogg jpg wav gif xcf bin; do args+=(! -name "*.$ex"); done for ex in png ogg jpg wav gif xcf bin webp; do args+=(! -name "*.$ex"); done
find data/ -type f "${args[@]}" ! -name "test_cve_2018_1999023_2.cfg" -print0 | xargs -0 isutf8 -- || exit_code=1 find data/ -type f "${args[@]}" ! -name "test_cve_2018_1999023_2.cfg" -print0 | xargs -0 isutf8 -- || exit_code=1
find po/ -type f -print0 | xargs -0 isutf8 -- || exit_code=1 find po/ -type f -print0 | xargs -0 isutf8 -- || exit_code=1

View file

@ -2,7 +2,7 @@
VALVEFILE=com.valvesoftware.SteamRuntime.Sdk-amd64,i386-scout-sysroot.Dockerfile VALVEFILE=com.valvesoftware.SteamRuntime.Sdk-amd64,i386-scout-sysroot.Dockerfile
VALVETAR=com.valvesoftware.SteamRuntime.Sdk-amd64,i386-scout-sysroot.tar.gz VALVETAR=com.valvesoftware.SteamRuntime.Sdk-amd64,i386-scout-sysroot.tar.gz
VALVE_SNAPSHOT=0.20211207.0 VALVE_SNAPSHOT=0.20220119.0
DOCKERBASEIMAGE=steamrt_scout_amd64 DOCKERBASEIMAGE=steamrt_scout_amd64
DOCKERLOCALIMAGE=wesnoth/wesnoth:steamrt-master DOCKERLOCALIMAGE=wesnoth/wesnoth:steamrt-master

View file

@ -6,8 +6,9 @@
"sdl2", "sdl2",
{ {
"name": "sdl2-image", "name": "sdl2-image",
"features": [ "libjpeg-turbo" ] "features": [ "libjpeg-turbo", "libwebp" ]
}, },
"libwebp",
{ {
"name": "sdl2-mixer", "name": "sdl2-mixer",
"features": [ "libvorbis", "dynamic-load" ] "features": [ "libvorbis", "dynamic-load" ]