Fix build with GLib >= 2.69

GLibD for GLib 2.69 changed some API, so we need to account for that
while still having the code build for older versions of GLib.
This commit is contained in:
Matthias Klumpp 2021-08-29 01:45:29 +02:00
parent 148a2f3b28
commit 0644bc10d1
5 changed files with 41 additions and 15 deletions

View File

@ -15,6 +15,7 @@ build_root = meson.build_root()
#
src_dir = include_directories('src/')
glib_dep = dependency('glib-2.0')
glibd_dep = dependency('glibd-2.0')
appstream_dep = dependency('appstream', version : '>= 0.14.5')
ascompose_dep = dependency('appstream-compose', version : '>= 0.14.5')

View File

@ -224,7 +224,6 @@ void main(string[] args)
default:
writeln (format ("The command '%s' is unknown.", command));
exit (1);
break;
}
}

View File

@ -25,3 +25,6 @@ public enum DATADIR = "@datadir@";
// current version of the tool
public enum ASGEN_VERSION = "@asgen_version@";
// Used for GLib/GLibD API change tests
public enum GLIB_GE_2_69 = @glib_ge_2_29@;

View File

@ -35,6 +35,7 @@ import ascompose.c.types : ImageFormat, ImageLoadFlags, ImageSaveFlags;
static import ascompose.Image;
static import std.file;
import asgen.defines : GLIB_GE_2_69;
import asgen.config : Config;
import asgen.result : GeneratorResult;
import asgen.downloader : Downloader;
@ -124,20 +125,37 @@ private VideoInfo checkVideoInfo (GeneratorResult gres, Component cpt, const Con
try {
// NOTE: We are currently extracting information from ffprobe's simple output, but it also has a JSON
// mode. Parsing JSON is a bit slower, but if it is more reliable we should switch to that.
Spawn.sync (null, // working directory
[conf.ffprobeBinary,
"-v", "quiet",
"-show_entries", "stream=width,height,codec_name,codec_type",
"-show_entries", "format=format_name",
"-of", "default=noprint_wrappers=1",
vidFname],
[], // envp
SpawnFlags.LEAVE_DESCRIPTORS_OPEN,
null, // child setup
null, // user data
ffStdout, // out stdout
ffStderr, // out stderr
exitStatus);
static if (GLIB_GE_2_69) {
Spawn.sync (null, // working directory
[conf.ffprobeBinary,
"-v", "quiet",
"-show_entries", "stream=width,height,codec_name,codec_type",
"-show_entries", "format=format_name",
"-of", "default=noprint_wrappers=1",
vidFname],
[], // envp
SpawnFlags.LEAVE_DESCRIPTORS_OPEN,
null, // child setup
null, // user data
ffStdout, // out stdout
ffStderr, // out stderr
&exitStatus);
} else {
Spawn.sync (null, // working directory
[conf.ffprobeBinary,
"-v", "quiet",
"-show_entries", "stream=width,height,codec_name,codec_type",
"-show_entries", "format=format_name",
"-of", "default=noprint_wrappers=1",
vidFname],
[], // envp
SpawnFlags.LEAVE_DESCRIPTORS_OPEN,
null, // child setup
null, // user data
ffStdout, // out stdout
ffStderr, // out stderr
exitStatus);
}
} catch (Exception e) {
logError ("Failed to spawn ffprobe: %s", e.to!string);
gres.addHint (cpt, "metainfo-screenshot-but-no-media", ["fname": vidFname.baseName, "msg": e.to!string]);

View File

@ -1,7 +1,12 @@
glib_ge_2_29 = 'false'
if glib_dep.version().version_compare('>=2.69')
glib_ge_2_29 = 'true'
endif
conf_data = configuration_data()
conf_data.set('datadir', join_paths(get_option('prefix'), get_option('datadir'), 'appstream'))
conf_data.set('asgen_version', asgen_version)
conf_data.set('glib_ge_2_29', glib_ge_2_29)
configure_file(input : 'defines.d.in',
output: 'defines.d',
configuration: conf_data