Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-addins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@novell.com>2009-08-21 13:37:12 +0400
committerLluis Sanchez <lluis@novell.com>2009-08-21 13:37:12 +0400
commita982f009d3d2c923b3b3ca0737bb8186a5850825 (patch)
treeb460e335cd2a0b3675f8f1205eeb317cdd0e778e
parent1dad9f043c265f7360aa6940bd50d81fdee137da (diff)
* mautil/Main.cs:
* Mono.Addins.MSBuild/ResolveAddinReferences.cs: Track api changes. * Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs: Applications can now register a test command to be used for testing add-ins. Don't use the pkg-config command, use instead the PcFileCache. * Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs: Updated. svn path=/trunk/mono-addins/; revision=140410
-rw-r--r--Mono.Addins.MSBuild/ChangeLog4
-rw-r--r--Mono.Addins.MSBuild/ResolveAddinReferences.cs6
-rw-r--r--Mono.Addins.Setup/ChangeLog9
-rw-r--r--Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs103
-rw-r--r--Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs95
-rw-r--r--mautil/ChangeLog4
-rw-r--r--mautil/Main.cs5
7 files changed, 153 insertions, 73 deletions
diff --git a/Mono.Addins.MSBuild/ChangeLog b/Mono.Addins.MSBuild/ChangeLog
index e83ea87..8eb23bf 100644
--- a/Mono.Addins.MSBuild/ChangeLog
+++ b/Mono.Addins.MSBuild/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-21 Lluis Sanchez Gual <lluis@novell.com>
+
+ * ResolveAddinReferences.cs: Track api changes.
+
2009-08-20 Lluis Sanchez Gual <lluis@novell.com>
* Makefile.am:
diff --git a/Mono.Addins.MSBuild/ResolveAddinReferences.cs b/Mono.Addins.MSBuild/ResolveAddinReferences.cs
index b51d1b3..99870a6 100644
--- a/Mono.Addins.MSBuild/ResolveAddinReferences.cs
+++ b/Mono.Addins.MSBuild/ResolveAddinReferences.cs
@@ -50,14 +50,14 @@ namespace Mono.Addins.MSBuild
return true;
}
string domain = extensionDomain[0].ItemSpec;
- AddinRegistry registry = SetupService.GetRegistryForApplication (domain);
- if (registry == null) {
+ Application app = SetupService.GetExtensibleApplication (domain);
+ if (app == null) {
Log.LogError ("Extension domain '{0}' not found", domain);
return false;
}
foreach (ITaskItem item in addinReferences) {
- Addin addin = registry.GetAddin (item.ItemSpec);
+ Addin addin = app.Registry.GetAddin (item.ItemSpec);
if (addin == null) {
Log.LogError ("Add-in '{0}' not found", item.ItemSpec);
return false;
diff --git a/Mono.Addins.Setup/ChangeLog b/Mono.Addins.Setup/ChangeLog
index 6bc3c56..c012632 100644
--- a/Mono.Addins.Setup/ChangeLog
+++ b/Mono.Addins.Setup/ChangeLog
@@ -1,3 +1,12 @@
+2009-08-21 Lluis Sanchez Gual <lluis@novell.com>
+
+ * Mono.Addins.Setup/SetupService.cs: Applications can now
+ register a test command to be used for testing add-ins.
+ Don't use the pkg-config command, use instead the
+ PcFileCache.
+
+ * Mono.Addins.Setup/PcFileCache.cs: Updated.
+
2009-08-20 Lluis Sanchez Gual <lluis@novell.com>
* Makefile.am:
diff --git a/Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs b/Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs
index 8e0ad59..300c281 100644
--- a/Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs
+++ b/Mono.Addins.Setup/Mono.Addins.Setup/PcFileCache.cs
@@ -32,7 +32,7 @@ using System.Collections.Generic;
namespace Mono.PkgConfig
{
- internal interface IPcFileCacheContext<TP> where TP:BasePackageInfo, new()
+ internal interface IPcFileCacheContext<TP> where TP:PackageInfo, new()
{
// In the implementation of this method, the host application can extract
// information from the pc file and store it in the PackageInfo object
@@ -46,16 +46,30 @@ namespace Mono.PkgConfig
void ReportError (string message, Exception ex);
}
- internal abstract class BasePcFileCache<TP> where TP:BasePackageInfo, new()
+ internal interface IPcFileCacheContext: IPcFileCacheContext<PackageInfo>
+ {
+ }
+
+ internal abstract class PcFileCache: PcFileCache<PackageInfo>
+ {
+ public PcFileCache (IPcFileCacheContext ctx): base (ctx)
+ {
+ }
+ }
+
+ internal abstract class PcFileCache<TP> where TP:PackageInfo, new()
{
const string CACHE_VERSION = "2";
Dictionary<string, TP> infos = new Dictionary<string, TP> ();
+ Dictionary<string, List<TP>> filesByFolder = new Dictionary<string, List<TP>> ();
+
string cacheFile;
bool hasChanges;
IPcFileCacheContext<TP> ctx;
+ IEnumerable<string> defaultPaths;
- public BasePcFileCache (IPcFileCacheContext<TP> ctx)
+ public PcFileCache (IPcFileCacheContext<TP> ctx)
{
this.ctx = ctx;
try {
@@ -77,9 +91,7 @@ namespace Mono.PkgConfig
// Updates the pkg-config index, using the default search directories
public void Update ()
{
- string pkgConfigPath = Environment.GetEnvironmentVariable ("PKG_CONFIG_PATH");
- string pkgConfigDir = Environment.GetEnvironmentVariable ("PKG_CONFIG_LIBDIR");
- Update (GetPkgconfigPaths (null, pkgConfigPath, pkgConfigDir));
+ Update (GetDefaultPaths ());
}
// Updates the pkg-config index, looking for .pc files in the provided directories
@@ -92,14 +104,42 @@ namespace Mono.PkgConfig
Save ();
}
- public IEnumerable<TP> AllPackages {
- get { return infos.Values; }
+ public IEnumerable<TP> GetPackages ()
+ {
+ return GetPackages (null);
+ }
+
+ public IEnumerable<TP> GetPackages (IEnumerable<string> pkgConfigDirs)
+ {
+ if (pkgConfigDirs == null)
+ pkgConfigDirs = GetDefaultPaths ();
+
+ foreach (string sp in pkgConfigDirs) {
+ List<TP> list;
+ if (filesByFolder.TryGetValue (Path.GetFullPath (sp), out list)) {
+ foreach (TP p in list)
+ yield return p;
+ }
+ }
+ }
+
+ public TP GetPackageInfoByName (string name)
+ {
+ return GetPackageInfoByName (name, null);
+ }
+
+ public TP GetPackageInfoByName (string name, IEnumerable<string> pkgConfigDirs)
+ {
+ foreach (TP p in GetPackages (pkgConfigDirs))
+ if (p.Name == name)
+ return p;
+ return null;
}
// Returns information about a .pc file
public TP GetPackageInfo (string file)
{
- TP info;
+ TP info, oldInfo = null;
file = Path.GetFullPath (file);
DateTime wtime = File.GetLastWriteTime (file);
@@ -108,6 +148,7 @@ namespace Mono.PkgConfig
if (infos.TryGetValue (file, out info)) {
if (info.LastWriteTime == wtime)
return info;
+ oldInfo = info;
}
}
@@ -122,13 +163,42 @@ namespace Mono.PkgConfig
if (!info.IsValidPackage)
info = new TP (); // Create a default empty instance
info.LastWriteTime = wtime;
- infos [file] = info;
+ Add (file, info, oldInfo);
hasChanges = true;
}
return info;
}
+/* void Remove (string file, TP pinfo)
+ {
+ infos.Remove (file);
+ string dir = Path.GetFullPath (Path.GetDirectoryName (file));
+ List<TP> list;
+ if (filesByFolder.TryGetValue (dir, out list))
+ list.Remove (pinfo);
+ }
+ */
+
+ void Add (string file, TP info, TP replacedInfo)
+ {
+ infos [file] = info;
+ string dir = Path.GetFullPath (Path.GetDirectoryName (file));
+ List<TP> list;
+ if (!filesByFolder.TryGetValue (dir, out list)) {
+ list = new List<TP> ();
+ filesByFolder [dir] = list;
+ }
+ if (replacedInfo != null) {
+ int i = list.IndexOf (replacedInfo);
+ if (i != -1) {
+ list [i] = info;
+ return;
+ }
+ }
+ list.Add (info);
+ }
+
FileStream OpenFile (FileAccess access)
{
int retries = 6;
@@ -246,7 +316,7 @@ namespace Mono.PkgConfig
tr.MoveToContent ();
if (!pinfo.IsValidPackage || ctx.IsCustomDataComplete (file, pinfo))
- infos [file] = pinfo;
+ Add (file, pinfo, null);
}
protected virtual void ReadPackageContent (XmlReader tr, TP pinfo)
@@ -279,6 +349,15 @@ namespace Mono.PkgConfig
{
}
+ IEnumerable<string> GetDefaultPaths ()
+ {
+ if (defaultPaths == null) {
+ string pkgConfigPath = Environment.GetEnvironmentVariable ("PKG_CONFIG_PATH");
+ string pkgConfigDir = Environment.GetEnvironmentVariable ("PKG_CONFIG_LIBDIR");
+ defaultPaths = GetPkgconfigPaths (null, pkgConfigPath, pkgConfigDir);
+ }
+ return defaultPaths;
+ }
public IEnumerable<string> GetPkgconfigPaths (string prefix, string pkgConfigPath, string pkgConfigLibdir)
{
@@ -454,7 +533,7 @@ namespace Mono.PkgConfig
}
}
- internal class BasePackageInfo
+ internal class PackageInfo
{
Dictionary<string,string> customData;
diff --git a/Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs b/Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs
index 860b9c1..42c0f32 100644
--- a/Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs
+++ b/Mono.Addins.Setup/Mono.Addins.Setup/SetupService.cs
@@ -371,49 +371,20 @@ namespace Mono.Addins.Setup
Directory.Delete (RepositoryCachePath, true);
}
- public static AddinRegistry GetRegistryForApplication (string name)
+ public static Application GetExtensibleApplication (string name)
{
- string startupDir;
- string regDir;
- try {
- if (System.IO.Path.DirectorySeparatorChar == '\\') {
- // On windows, look for packages in the registry
- RegistryKey fxFolderKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey (@"SOFTWARE\Mono\Mono.Addins\AddinRoots\" + name, false);
- if (fxFolderKey != null) {
- startupDir = fxFolderKey.GetValue ("RootPath") as string;
- regDir = fxFolderKey.GetValue ("RegistryPath") as string;
- fxFolderKey.Close ();
- } else
- return null;
- }
- else {
- // On Unix, look for registry info using pkg-config
- ProcessStartInfo pinfo = new ProcessStartInfo ("pkg-config","--variable=MonoAddinsRoot " + name);
- pinfo.UseShellExecute = false;
- pinfo.RedirectStandardOutput = true;
- pinfo.RedirectStandardError = true;
- Process proc = Process.Start (pinfo);
- startupDir = proc.StandardOutput.ReadLine ();
- proc.WaitForExit ();
- if (proc.ExitCode != 0)
- return null;
-
- pinfo = new ProcessStartInfo ("pkg-config","--variable=MonoAddinsRegistry " + name);
- pinfo.UseShellExecute = false;
- pinfo.RedirectStandardOutput = true;
- proc = Process.Start (pinfo);
- regDir = proc.StandardOutput.ReadLine ();
- proc.WaitForExit ();
- if (proc.ExitCode != 0)
- return null;
- }
- } catch {
- return null;
- }
- return new AddinRegistry (regDir, startupDir);
+ return GetExtensibleApplication (name, null);
}
- static AddinsPcFileCache pcFileCache;
+ public static Application GetExtensibleApplication (string name, IEnumerable<string> searchPaths)
+ {
+ AddinsPcFileCache pcc = GetAddinsPcFileCache (searchPaths);
+ PackageInfo pi = pcc.GetPackageInfoByName (name, searchPaths);
+ if (pi != null)
+ return new Application (pi);
+ else
+ return null;
+ }
public static Application[] GetExtensibleApplications ()
{
@@ -424,6 +395,18 @@ namespace Mono.Addins.Setup
{
List<Application> list = new List<Application> ();
+ AddinsPcFileCache pcc = GetAddinsPcFileCache (searchPaths);
+ foreach (PackageInfo pinfo in pcc.GetPackages (searchPaths)) {
+ if (pinfo.IsValidPackage)
+ list.Add (new Application (pinfo));
+ }
+ return list.ToArray ();
+ }
+
+ static AddinsPcFileCache pcFileCache;
+
+ static AddinsPcFileCache GetAddinsPcFileCache (IEnumerable<string> searchPaths)
+ {
if (pcFileCache == null) {
pcFileCache = new AddinsPcFileCache ();
if (searchPaths != null)
@@ -431,22 +414,18 @@ namespace Mono.Addins.Setup
else
pcFileCache.Update ();
}
- foreach (BasePackageInfo pinfo in pcFileCache.AllPackages) {
- if (pinfo.IsValidPackage)
- list.Add (new Application (pinfo));
- }
- return list.ToArray ();
+ return pcFileCache;
}
}
- class AddinsPcFileCacheContext: IPcFileCacheContext<BasePackageInfo>
+ class AddinsPcFileCacheContext: IPcFileCacheContext
{
- public bool IsCustomDataComplete (string pcfile, BasePackageInfo pkg)
+ public bool IsCustomDataComplete (string pcfile, PackageInfo pkg)
{
return true;
}
- public void StoreCustomData (Mono.PkgConfig.PcFile pcfile, BasePackageInfo pkg)
+ public void StoreCustomData (Mono.PkgConfig.PcFile pcfile, PackageInfo pkg)
{
}
@@ -457,7 +436,7 @@ namespace Mono.Addins.Setup
}
}
- class AddinsPcFileCache: BasePcFileCache<BasePackageInfo>
+ class AddinsPcFileCache: PcFileCache
{
public AddinsPcFileCache (): base (new AddinsPcFileCacheContext ())
{
@@ -471,38 +450,42 @@ namespace Mono.Addins.Setup
}
}
- protected override void ParsePackageInfo (PcFile file, BasePackageInfo pinfo)
+ protected override void ParsePackageInfo (PcFile file, PackageInfo pinfo)
{
string rootPath = file.GetVariable ("MonoAddinsRoot");
string regPath = file.GetVariable ("MonoAddinsRegistry");
+ string testCmd = file.GetVariable ("MonoAddinsTestCommand");
if (string.IsNullOrEmpty (rootPath) || string.IsNullOrEmpty (regPath))
return;
pinfo.SetData ("MonoAddinsRoot", rootPath);
pinfo.SetData ("MonoAddinsRegistry", regPath);
+ pinfo.SetData ("MonoAddinsTestCommand", testCmd);
}
}
public class Application
{
AddinRegistry registry;
- string rootPath;
- string regPath;
- internal Application (BasePackageInfo pinfo)
+ internal Application (PackageInfo pinfo)
{
Name = pinfo.Name;
Description = pinfo.Description;
- rootPath = pinfo.GetData ("MonoAddinsRoot");
- regPath = pinfo.GetData ("MonoAddinsRegistry");
+ StartupPath = pinfo.GetData ("MonoAddinsRoot");
+ RegistryPath = pinfo.GetData ("MonoAddinsRegistry");
+ TestCommand = pinfo.GetData ("MonoAddinsTestCommand");
}
public string Description { get; internal set; }
public string Name { get; internal set; }
+ public string TestCommand { get; internal set; }
+ public string StartupPath { get; internal set; }
+ public string RegistryPath { get; internal set; }
public AddinRegistry Registry {
get {
if (registry == null)
- registry = new AddinRegistry (regPath, rootPath);
+ registry = new AddinRegistry (RegistryPath, StartupPath);
return registry;
}
}
diff --git a/mautil/ChangeLog b/mautil/ChangeLog
index b06003d..6f88c9a 100644
--- a/mautil/ChangeLog
+++ b/mautil/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-21 Lluis Sanchez Gual <lluis@novell.com>
+
+ * Main.cs: Track api changes.
+
2009-08-20 Lluis Sanchez Gual <lluis@novell.com>
* Main.cs: Track api changes.
diff --git a/mautil/Main.cs b/mautil/Main.cs
index 8f5a304..61238fb 100644
--- a/mautil/Main.cs
+++ b/mautil/Main.cs
@@ -73,11 +73,12 @@ namespace mautil
Console.WriteLine ("The --registry and --path options can't be used when --package is specified.");
return 1;
}
- reg = SetupService.GetRegistryForApplication (package);
- if (reg == null) {
+ Application app = SetupService.GetExtensibleApplication (package);
+ if (app == null) {
Console.WriteLine ("The package could not be found or does not provide add-in registry information.");
return 1;
}
+ reg = app.Registry;
}
else {
if (startupPath == null)