[Mono-devel-list] Getting Tao.OpenGl building with Mono and GTK# with gtkglext-sharp
Jackson Harper
jackson at ximian.com
Wed Jul 7 23:03:53 EDT 2004
The ilasm and monodis patches have been in CVS for a couple of days :-).
Jackson
On Wed, 2004-07-07 at 18:18, Steven Brown wrote:
> Hello, I've been poking on the Tao framework in Mono's CVS trying to get
> it to build with only Mono instead of depending on Microsoft's tools,
> and running in Linux with GTK#. Almost everything works with a couple
> patches to Tao and Mono, and I can successfully do OpenGL with GTK#.
> Patches are included here and I'll give some instructions below. I'm
> not sure who's the contact now for Tao since it moved into Mono's CVS;
> should discussion go to mono-devel, the GTK# list, or ..?
>
>
> First you need to patch Tao's PostProcess project so it can read monodis
> -generated il code as well as ildasm il. The attached patch
> 'tao-monodis-regex-swb.patch' does this. (Tao's PostProcess
> disassembles Tao dlls, does a regex to replace some il code in the
> IlasmAttribute and a couple other changes, and reassembles the dll. See
> their FAQ).
>
> To build the Tao.OpenGl project, compile the pre-processed dll:
>
> mcs /d:LINUX /clscheck- /unsafe /t:library /out:Tao.OpenGl.dll *.cs
>
> Build the PostProcessor:
>
> mcs /t:exe /out:Tao.PostProcess.exe *.cs
>
> Disassemble the pre-processed dll:
>
> monodis Tao.OpenGl.dll --output=Tao.OpenGl.il
>
> Run the PostProcessor:
>
> mono PostProcess.exe Tao.OpenGl.il Tao.OpenGl.pp.il /R /Y
>
> Re-assemble the post-processed il. You will need the attached patches
> 'mcs-ilasm-NumberHelper-float.swb.patch' and
> 'mono-monodis-typing-swb.patch', as Mono's ilasm doesn't recognize
> floats like "1e+150", and monodis forgets to wrap it in a float64()
> cast. There is still one bug left (but it's being looked at by jackson)
> that prevents Mono's ilasm from finishing this step, so you'll need to
> run it with Microsoft's ilasm for now:
>
> ilasm /dll /output:Tao.OpenGl.dll Tao.OpenGl.pp.il
>
>
> You can then use the resulting Tao.OpenGl.dll with gtkglext-sharp and
> GTK# to get OpenGL in GTK#. Nifty. :) Almost completely independent of
> Microsoft tools, now. If you use gtkglext-sharp, you'll also need the
> two attached .config files to tell it what libraries to use on Linux.
>
>
> I'll add these patches to bugzilla if it looks like they'll fall off the
> list. These instructions should also really be CVSed into a README in
> the Tao module until it gets autoconfed. What I'd like to see is the
> GTK# project absorb gtkglext-sharp as one of the optional dlls it
> builds, as I think its extension of GTK widgets to support OpenGL is a
> big win for GTK#, and it would prevent gtkglext-sharp from being lost to
> bitrot. I'll probably need to ask the GTK# list about that, but what do
> y'all think about that idea? It was the best solution to OpenGL with
> GTK# I could find.
>
>
> ______________________________________________________________________
> Change the regex that matches ends of attributes, as Mono fully qualifies the
> names. E.g.:
>
> MS: // end of class DelegateCallingConventionCdeclAttribute
> Mono: // end of class Tao.OpenGl.DelegateCallingConventionCdeclAttribute
>
> Change the regex that cuts the body of the IlasmAttribute to be compatible with
> monodis-genereated il. Checks for a line with no starting hex rather than
> expecting 'Code size' which should be a tad more generic.
>
> This will fix PostProcess.exe spinning on monodis generated il. It should
> remain compatible with Microsoft ildasm generated il.
>
> - Steven Brown <swbrown at ucsd.edu>
>
>
> Index: Framework/Projects/Tao.PostProcess/ReleaseBuildProcessor.cs
> ===================================================================
> RCS file: /mono/tao/Framework/Projects/Tao.PostProcess/ReleaseBuildProcessor.cs,v
> retrieving revision 1.2
> diff -u -r1.2 ReleaseBuildProcessor.cs
> --- Framework/Projects/Tao.PostProcess/ReleaseBuildProcessor.cs 6 Jun 2004 19:51:38 -0000 1.2
> +++ Framework/Projects/Tao.PostProcess/ReleaseBuildProcessor.cs 30 Jun 2004 05:11:48 -0000
> @@ -112,7 +112,7 @@
> private string ModifyIlasmCalls(string fileContent) {
> int callStartPosition = -1;
> int callEndPosition = -1;
> - Regex callStart = new Regex(@"((?<Method> \.custom instance void Tao\..*?\.IlasmAttribute::\.ctor\(string\) = \((?<Body> .*?) \/\/ Code size .*? )} \/\/ end of)", RegexOptions.Compiled | RegexOptions.Singleline);
> + Regex callStart = new Regex(@"((?<Method> \.custom instance void (class )?Tao\..*?\.IlasmAttribute::\.ctor\(string\)\s*=\s*\((?<Body>.*?)(?<LineWithNoHex>\n\s*[^0-9A-Fa-f\s]).*?)}\s*\/\/ end of)", RegexOptions.Compiled | RegexOptions.Singleline);
>
> Match callStartMatch = callStart.Match(fileContent);
> while(callStartMatch.Success) {
> @@ -235,7 +235,7 @@
> /// </remarks>
> protected override string InjectMsil(string fileContent) {
> Regex attributeStart = new Regex(@"\.class .*? IlasmAttribute", RegexOptions.Compiled);
> - Regex attributeEnd = new Regex(@"// end of class IlasmAttribute", RegexOptions.Compiled);
> + Regex attributeEnd = new Regex(@"// end of class .*IlasmAttribute", RegexOptions.Compiled);
> fileContent = RemoveAttribute(attributeStart, attributeEnd, fileContent);
> fileContent = ModifyIlasmCalls(fileContent);
>
> @@ -258,7 +258,7 @@
> /// </remarks>
> protected override string ModifyCdeclDelegates(string fileContent) {
> Regex attributeStart = new Regex(@"\.class .*? DelegateCallingConventionCdeclAttribute", RegexOptions.Compiled);
> - Regex attributeEnd = new Regex(@"// end of class DelegateCallingConventionCdeclAttribute", RegexOptions.Compiled);
> + Regex attributeEnd = new Regex(@"// end of class .*DelegateCallingConventionCdeclAttribute", RegexOptions.Compiled);
> fileContent = RemoveAttribute(attributeStart, attributeEnd, fileContent);
> fileContent = ModifyCdeclDelegateCalls(fileContent);
>
>
> ______________________________________________________________________
> Literal float tokens as generated by monodis like "1e+150" fail to be parsed by
> ilasm as NumberHelper only checks for a '.' to consider a number a float.
> Quick hack fix of having it also check for an 'e' or 'E'.
>
> - Steven Brown <swbrown at ucsd.edu>
>
>
> Index: ilasm/scanner/NumberHelper.cs
> ===================================================================
> RCS file: /mono/mcs/ilasm/scanner/NumberHelper.cs,v
> retrieving revision 1.8
> diff -u -r1.8 NumberHelper.cs
> --- ilasm/scanner/NumberHelper.cs 10 Jun 2004 21:01:19 -0000 1.8
> +++ ilasm/scanner/NumberHelper.cs 29 Jun 2004 06:00:00 -0000
> @@ -118,7 +118,7 @@
> }
>
> try {
> - if (num.IndexOf ('.') != -1) {
> + if (num.IndexOf ('.') != -1 || num.IndexOf('e') != -1 || num.IndexOf('E') != -1) {
> double d = Double.Parse (num, nstyles, NumberFormatInfo.InvariantInfo);
> result.token = Token.FLOAT64;
> result.val = d;
>
> ______________________________________________________________________
> float64 cast for literals as done by ildasm was missing in monodis. Might not
> matter, but makes the output similiar.
>
> I assume the same is true for float32, so it was also changed.
>
> - Steven Brown <swbrown at ucsd.edu>
>
>
> Index: mono/dis/get.c
> ===================================================================
> RCS file: /mono/mono/mono/dis/get.c,v
> retrieving revision 1.82
> diff -u -r1.82 get.c
> --- mono/dis/get.c 25 Jun 2004 18:54:50 -0000 1.82
> +++ mono/dis/get.c 29 Jun 2004 06:13:14 -0000
> @@ -1621,12 +1621,12 @@
> case MONO_TYPE_R4: {
> float r;
> readr4 (ptr, &r);
> - return g_strdup_printf ("%g", (double) r);
> + return g_strdup_printf ("float32(%g)", (double) r);
> }
> case MONO_TYPE_R8: {
> double r;
> readr8 (ptr, &r);
> - return g_strdup_printf ("%g", r);
> + return g_strdup_printf ("float64(%g)", r);
> }
> case MONO_TYPE_STRING: {
> int i, j, e;
>
> ______________________________________________________________________
> <configuration>
> <dllmap dll="libgtkglext-win32-1.0-0.dll" target="libgtkglext-x11-1.0.so.0"/>
> <dllmap dll="libgdkglext-win32-1.0-0.dll" target="libgdkglext-x11-1.0.so.0"/>
> </configuration>
>
> ______________________________________________________________________
> <configuration>
> <dllmap dll="libgtkglext-win32-1.0-0.dll" target="libgtkglext-x11-1.0.so.0"/>
> <dllmap dll="libgdkglext-win32-1.0-0.dll" target="libgdkglext-x11-1.0.so.0"/>
> </configuration>
More information about the Mono-devel-list
mailing list