blob: cac7091556bd4933986d365f9db7697d72ad25d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// created on 6/8/2004 at 5:44 AM
using System;
using System.Diagnostics;
using MonoDevelop.Core;
namespace MonoDevelop.Prj2Make
{
public sealed class PkgConfigInvoker
{
public static string GetPkgConfigVersion()
{
string pkgout = null;
pkgout = RunPkgConfig("--version");
if(pkgout != null)
{
return pkgout;
}
return null;
}
public static string GetPkgVariableValue(string strPkg, string strVarName)
{
string pkgout = null;
pkgout = RunPkgConfig(String.Format("--variable={0} {1}",
strVarName, strPkg));
if(pkgout != null)
{
return pkgout;
}
return null;
}
public static string GetPkgConfigModuleVersion(string strPkg)
{
string pkgout = null;
pkgout = RunPkgConfig(String.Format("--modversion {0}", strPkg));
if(pkgout != null)
{
return pkgout;
}
return null;
}
public static string RunPkgConfig(string strArgLine)
{
string pkgout;
ProcessStartInfo pi = new ProcessStartInfo ();
pi.FileName = "pkg-config";
pi.RedirectStandardOutput = true;
pi.UseShellExecute = false;
pi.Arguments = strArgLine;
Process p = null;
try
{
p = Process.Start (pi);
}
catch (Exception e)
{
Console.WriteLine("Couldn't run pkg-config: " + e.Message);
Environment.Exit (1);
}
if (p.StandardOutput == null)
{
LoggingService.LogDebug ("Specified package did not return any information");
}
pkgout = p.StandardOutput.ReadToEnd ();
p.WaitForExit ();
if (p.ExitCode != 0)
{
LoggingService.LogDebug ("pkg-config command failed: pkg-config " + strArgLine);
return null;
}
if (pkgout != null)
{
p.Close ();
return pkgout;
}
p.Close ();
return null;
}
}
}
|