public static string GetPackageFlags (string packages, 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) {
if (report == null)
throw;
report.Error (-27, "Couldn't run pkg-config: " + e.Message);
return null;
}
if (p.StandardOutput == null) {
if (report == null)
throw new ApplicationException ("Specified package did not return any information");
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) {
if (report == null)
throw new ApplicationException (pkgout);
report.Error (-27, "Error running pkg-config. Check the above output.");
p.Close ();
return null;
}
p.Close ();
return pkgout;
}