From: Rico Tzschichholz Date: Mon, 5 Feb 2024 14:53:27 +0000 (+0100) Subject: vala: Add CodeContext.pkg_config_variable() helper X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=8e13e12e0512d1f240ae2acbdec7a4752361e832;p=thirdparty%2Fvala.git vala: Add CodeContext.pkg_config_variable() helper --- diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala index 7f34f4b09..7610890fd 100644 --- a/vala/valacodecontext.vala +++ b/vala/valacodecontext.vala @@ -941,4 +941,23 @@ public class Vala.CodeContext { return output; } + + public string? pkg_config_variable (string package_name, string variable_name) { + string pc = pkg_config_command + " --variable="+ variable_name + " " + package_name; + string? output = null; + int exit_status; + + try { + Process.spawn_command_line_sync (pc, out output, null, out exit_status); + if (exit_status != 0) { + Report.error (null, "%s exited with status %d", pkg_config_command, exit_status); + return null; + } + } catch (SpawnError e) { + Report.error (null, e.message); + output = null; + } + + return output; + } }