public static string GetPackageFlags (string packages, bool fatal, Report report)
{
ProcessStartInfo pi = new ProcessStartInfo ();
pi.FileName = "pkg-config";
pi.RedirectStandardOutput = true;
pi.UseShellExecute = false;
pi.Arguments = "--libs " + packages;
Process p = null;
try {
p = Process.Start (pi);
} catch (Exception e) {
report.Error (-27, "Couldn't run pkg-config: " + e.Message);
if (fatal)
Environment.Exit (1);
p.Close ();
return null;
}
if (p.StandardOutput == null){
report.Warning (-27, 1, "Specified package did not return any information");
p.Close ();
return null;
}
string pkgout = p.StandardOutput.ReadToEnd ();
p.WaitForExit ();
if (p.ExitCode != 0) {
report.Error (-27, "Error running pkg-config. Check the above output.");
if (fatal)
Environment.Exit (1);
p.Close ();
return null;
}
p.Close ();
return pkgout;
}