[banshee] [darwin] package Monobjc as an experiment



commit ab81b89147c8a328186cc72cd664e6f5e8433432
Author: Aaron Bockover <abockover novell com>
Date:   Thu Feb 25 16:19:51 2010 -0500

    [darwin] package Monobjc as an experiment
    
    I have no idea if I want to use this, but it looks pretty complete and
    interesting. Basic testing shows some things working - GTK and the CFRunLoop
    seem to integrate nicely together, and I could get volume/mount notifications
    from NSWorkspace in GTK ... so that's one step closer to hardware support.
    
    This thing was a nightmare to build and integrate though. Jeesh.

 build/bundle/packages.py                           |    1 +
 build/bundle/packages/monobjc.py                   |   61 ++++++++++++++++++++
 .../packages/patches/monobjc/PkgConfigGenerator.cs |   39 +++++++++++++
 .../monobjc/nant-disable-native-enable-debug.patch |   29 +++++++++
 .../monobjc/remove-executable-path-dllimport.patch |   61 ++++++++++++++++++++
 5 files changed, 191 insertions(+), 0 deletions(-)
---
diff --git a/build/bundle/packages.py b/build/bundle/packages.py
index d52f6df..9e157af 100644
--- a/build/bundle/packages.py
+++ b/build/bundle/packages.py
@@ -78,6 +78,7 @@ class BansheePackages:
 
 		if isinstance (self, DarwinProfile):
 			self.packages.extend ([
+				'packages/monobjc.py',
 				'packages/ige-mac-integration.py'
 			])
 
diff --git a/build/bundle/packages/monobjc.py b/build/bundle/packages/monobjc.py
new file mode 100644
index 0000000..320ee73
--- /dev/null
+++ b/build/bundle/packages/monobjc.py
@@ -0,0 +1,61 @@
+class MonobjcPackage (Package):
+	def __init__ (self):
+		Package.__init__ (self, 'Monobjc', '2.0.479.0', sources = [
+			'http://downloads.monobjc.net/%{name}-%{version}.tar.gz',
+			'patches/monobjc/Makefile',
+			'patches/monobjc/nant-disable-native-enable-debug.patch',
+			'patches/monobjc/remove-executable-path-dllimport.patch',
+			'patches/monobjc/PkgConfigGenerator.cs'
+		])
+
+		self.dylib_compatibility_version = '2.0.0'
+		self.dylib_current_version = '2.4.79'
+
+	def prep (self):
+		# Create and extract into top-level directory
+		# since Monobjc is archived incorrectly
+		self.sh ('mkdir "%{source_dir_name}"')
+		self.cd ('%{source_dir_name}')
+		self.sh ('tar xf "%{sources[0]}"')
+		
+		# Remove the binaries that come with the release
+		self.sh ('rm -rf -- dist')
+
+		# Install a proper Makefile that builds properly
+		self.sh ('cp "%{sources[1]}" src/native/Monobjc/src')
+
+		# Disable native and 1.0 profile builds in nant,
+		# and enable debugging (produce .mdb files)
+		self.sh ('patch -p1 < "%{sources[2]}"')
+
+		# Remove the @executable_path/ prefix from the
+		# DllImport attributes for libmonobjc.2.dylib
+		self.sh ('patch -p1 < "%{sources[3]}"')
+
+	def build (self):
+		# Build the managed libraries
+		self.sh ('nant build-libraries')
+
+		# Build the native library
+		self.pushd ('src/native/Monobjc/src')
+		self.sh ('make COMPATIBILITY_VERSION=%{dylib_compatibility_version} CURRENT_VERSION=%{dylib_current_version}')
+		self.popd ()
+
+		# Build the pkg-config generator
+		self.sh ('gmcs -out:pc-gen.exe "%{sources[4]}"')
+
+	def install (self):
+		# Install assemblies into the GAC, generate a pkg-config file
+		self.sh ('mkdir -p "%{prefix}/share/pkgconfig"')
+		for path in glob.glob ('dist/2.0/*.dll'):
+			basename = os.path.basename (path)
+			pkgconfig = os.path.splitext (basename)[0] + '.pc'
+			self.sh ('gacutil -i -package Monobjc -root "%{prefix}/lib" "' +
+				path + '"')
+			self.sh ('mono pc-gen.exe "%{prefix}/lib/mono/Monobjc/' +
+				basename + '" > "%{prefix}/share/pkgconfig/' + pkgconfig + '"')
+
+		# Install native library into the standard lib dir
+		self.sh ('cp "src/native/Monobjc/src/libmonobjc.2.dylib" "%{prefix}/lib"')
+
+MonobjcPackage ()
diff --git a/build/bundle/packages/patches/monobjc/PkgConfigGenerator.cs b/build/bundle/packages/patches/monobjc/PkgConfigGenerator.cs
new file mode 100644
index 0000000..ed814cb
--- /dev/null
+++ b/build/bundle/packages/patches/monobjc/PkgConfigGenerator.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Reflection;
+using System.Collections.Generic;
+
+public static class PkgConfigGenerator
+{
+    private static List<Assembly> assemblies = new List<Assembly> ();
+
+    public static void Main (string [] args)
+    {
+        var asm = Assembly.LoadFrom (args[0]);
+        var asm_name = asm.GetName ();
+        WalkAssembly (asm);
+
+        Console.WriteLine ("Name: {0}", asm_name.Name);
+        Console.WriteLine ("Description:");
+        Console.WriteLine ("Version: {0}", asm_name.Version);
+        Console.Write ("Libs: ");
+        foreach (var dep in assemblies) {
+            if (dep.GetName ().Name != "mscorlib") {
+                Console.Write ("-r:{0} ", dep.Location);
+            }
+        }
+        Console.WriteLine ();
+    }
+
+    private static void WalkAssembly (Assembly asm)
+    {
+        if (assemblies.Contains (asm)) {
+            return;
+        }
+
+        assemblies.Add (asm);
+
+        foreach (var rname in asm.GetReferencedAssemblies ()) {
+            WalkAssembly (Assembly.Load (rname.FullName));
+        }
+    }
+}
diff --git a/build/bundle/packages/patches/monobjc/nant-disable-native-enable-debug.patch b/build/bundle/packages/patches/monobjc/nant-disable-native-enable-debug.patch
new file mode 100644
index 0000000..082c23a
--- /dev/null
+++ b/build/bundle/packages/patches/monobjc/nant-disable-native-enable-debug.patch
@@ -0,0 +1,29 @@
+diff --git a/Monobjc.build b/Monobjc.build
+index 03546ab..83c350b 100644
+--- a/Monobjc.build
++++ b/Monobjc.build
+@@ -60,12 +60,16 @@
+   ================================================================================ -->
+   <target name="build-libraries" description="Build the two set of libraries" depends="banner, prepare">
+     <!-- Native libraries -->
++    <!--
+     <call target="build-libraries-native"/>
++    -->
+     
+     <!-- Version : 1.0 -->
++    <!--
+     <property name="version" value="1.0"/>
+     <property name="define" value="ENABLE_SHORT_KEY;ENABLE_FAST_PATH"/>
+     <call target="build-libraries-intern"/>
++    -->
+     
+     <!-- Version : 2.0 -->
+     <property name="version" value="2.0"/>
+@@ -513,6 +517,7 @@ public static String FormatVersion(String version) {
+     		output="${output.dir}/${lib.name}.dll"
+     		doc="${output.dir}/${lib.name}.xml"
+     		define="${define}"
++    		debug="true"
+     		keyfile="${keyfile}">
+       <sources>
+         <include name="${build.dir}/GeneratedAssemblyInfo.${version}.${hg.revision}.0.cs"/>
diff --git a/build/bundle/packages/patches/monobjc/remove-executable-path-dllimport.patch b/build/bundle/packages/patches/monobjc/remove-executable-path-dllimport.patch
new file mode 100644
index 0000000..82d9922
--- /dev/null
+++ b/build/bundle/packages/patches/monobjc/remove-executable-path-dllimport.patch
@@ -0,0 +1,61 @@
+diff --git a/src/libraries/Monobjc/Runtime/ObjectiveC20/NativeMethods.cs b/src/libraries/Monobjc/Runtime/ObjectiveC20/NativeMethods.cs
+index 74ce891..c44aa30 100644
+--- a/src/libraries/Monobjc/Runtime/ObjectiveC20/NativeMethods.cs
++++ b/src/libraries/Monobjc/Runtime/ObjectiveC20/NativeMethods.cs
+@@ -197,7 +197,7 @@ namespace Monobjc.Runtime.ObjectiveC20
+         /// <summary>
+         /// <para></para>
+         /// </summary>
+-        [DllImport("@executable_path/libmonobjc.2.dylib", EntryPoint = "hook_thread_lifecycle")]
++        [DllImport("libmonobjc.2.dylib", EntryPoint = "hook_thread_lifecycle")]
+         public static extern int hook_thread_lifecycle();
+ 
+         /// <summary>
+@@ -205,7 +205,7 @@ namespace Monobjc.Runtime.ObjectiveC20
+         /// </summary>
+         /// <param name="callback"></param>
+         /// <returns></returns>
+-        [DllImport("@executable_path/libmonobjc.2.dylib", EntryPoint = "set_dealloc_callback")]
++        [DllImport("libmonobjc.2.dylib", EntryPoint = "set_dealloc_callback")]
+         public static extern bool set_dealloc_callback(RuntimeBridge.DeallocCallback callback);
+ 
+         /// <summary>
+@@ -213,7 +213,7 @@ namespace Monobjc.Runtime.ObjectiveC20
+         /// </summary>
+         /// <param name="cls"></param>
+         /// <returns></returns>
+-        [DllImport("@executable_path/libmonobjc.2.dylib", EntryPoint = "intercept_dealloc_for")]
++        [DllImport("libmonobjc.2.dylib", EntryPoint = "intercept_dealloc_for")]
+         public static extern bool intercept_dealloc_for(IntPtr cls);
+ 
+         /// <summary>
+@@ -221,7 +221,7 @@ namespace Monobjc.Runtime.ObjectiveC20
+         /// </summary>
+         /// <param name="target"></param>
+         /// <returns></returns>
+-        [DllImport("@executable_path/libmonobjc.2.dylib", EntryPoint = "add_object")]
++        [DllImport("libmonobjc.2.dylib", EntryPoint = "add_object")]
+         public static extern bool add_object(IntPtr target);
+ 
+         /// <summary>
+@@ -229,7 +229,7 @@ namespace Monobjc.Runtime.ObjectiveC20
+         /// </summary>
+         /// <param name="target"></param>
+         /// <returns></returns>
+-        [DllImport("@executable_path/libmonobjc.2.dylib", EntryPoint = "contains_object")]
++        [DllImport("libmonobjc.2.dylib", EntryPoint = "contains_object")]
+         public static extern int contains_object(IntPtr target);
+ 
+         /// <summary>
+@@ -237,8 +237,8 @@ namespace Monobjc.Runtime.ObjectiveC20
+         /// </summary>
+         /// <param name="target"></param>
+         /// <returns></returns>
+-        [DllImport("@executable_path/libmonobjc.2.dylib", EntryPoint = "remove_object")]
++        [DllImport("libmonobjc.2.dylib", EntryPoint = "remove_object")]
+         public static extern bool remove_object(IntPtr target);
+ #endif
+     }
+-}
+\ No newline at end of file
++}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]