]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Add CodeContext.pkg_config_variable() helper
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 5 Feb 2024 14:53:27 +0000 (15:53 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 21 Feb 2024 08:51:26 +0000 (09:51 +0100)
vala/valacodecontext.vala

index 7f34f4b09ee4dd4bdcd300dbf4f1cc31624b94a5..7610890fdcd186cf9f3065969d7ed081dca1eade 100644 (file)
@@ -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;
+       }
 }