Re: Darwin Port

Christopher Waters <[email protected]>
Newsgroups gmane.comp.graphics.chromium.devel
Message-ID <[email protected]>
I did some browsing around the Mac documentation, and I came across 
some articles on Umbrella Frameworks, which is another way of saying 
"frameworks within frameworks." The nifty thing about these is that 
when the dynamic linker cannot find a symbol in the base framework, it 
looks in its child frameworks for the symbols.  This takes care of a 
lot of problems the dynamic linker has given me about certain symbols 
it expected to find in libGL.dylib (specifically gll_noop and 
gll_pkey).  In order to implement this, though, we have to create a 
temporary framework file structure.  The following is a list of the 
folders I used to test this out:

/private/tmp/OpenGL.framework
cwaters% ls -lR
  Frameworks -> Versions/Current/Frameworks
  Headers -> Versions/Current/Headers
  Libraries -> Versions/Current/Libraries
  OpenGL -> Versions/Current/OpenGL
  Resources -> Versions/Current/Resources
  Versions

./Versions:
  A
  Current -> A

./Versions/A:
  Frameworks
  Headers -> 
/System/Library/Frameworks/OpenGL.framework/Versions/A/Headers
  Libraries
  OpenGL -> /cr/lib/Darwin/libcrfaker.dylib
  Resources -> 
/System/Library/Frameworks/OpenGL.framework/Versions/A/Resources

./Versions/A/Frameworks:
  NOpenGL.framework -> /System/Library/Frameworks/OpenGL.framework

./Versions/A/Libraries:
  libGL.dylib -> /cr/lib/Darwin/libcrfaker.dylib

After I made all the folders and symbolic links, I preappeneded "/tmp" 
to DYLD_FRAMEWORK_PATH (in app_faker.c)
I wouldn't say it worked sucessfully, since the program itself crashed 
after creating/setting the context, but I would say that it -worked-, 
in the sense that the faker's CGL functions were actually called.

Attached is a diff between the HEAD app_faker.c and the app_faker.c 
with the implementation I wrote for this purpose.

  -Chris Waters



On Jun 23, 2004, at 2:11 PM, Christopher Waters wrote:

> Attached is the "change log" I made.  The tarballed code can be found 
> at: http://www.cse.msstate.edu/~crw7/vis/cr-1.1.tar.gz
> I restarted off of HEAD yesterday morning, so it should be up to date.
>
> I got most of my ideas for all of this (using AGL in spus and CGL in 
> faker; defining SPU before including arch.mk; etc) from Jorge's 
> "Darwin Patch" mails.
> Everything builds fine, but then goes downhill when trying to run the 
> app faker :(
>
> There seems to be some trick in "tricking" the dynamic linker, too... 
> forcing a flat namspace and then inserting the faker library only 
> worked until you tried to call functions in the actual opengl library.
>
>  -Chris Waters
>
> <Darwin_work.rtf>
app_faker.diff (application/octet-stream, 2 KB)
55a56,57
> #elif defined(DARWIN)
> #define OPENGL_CLIENT_LIB "libcrfaker.dylib"
65a68,69
> #elif defined(DARWIN)
> #define SYSTEM_LIB_DIR "/System/Libraries/Frameworks/OpenGL.framework/Libraries"
72a77,78
> #elif defined(DARWIN)
> 	"libGL.dylib"
485a492,543
> #ifdef DARWIN
> #define TEMP_FRAMEWORK_NAME "OpenGL.framework"
> #define SYSTEM_GL_PATH		"/System/Library/Frameworks/OpenGL.framework"
> 
> #define MAKEADD_DIR(n)  ( mkdir((n),0777), add_dir_to_temp_list((n)) )
> 
> static void make_temp_framework( const char *dir ) {
> 	char name[1024];
> 
> 	(void) libgl_names;
> 
> 	crStrcpy( name, dir );
> 	crStrcat( name, "/" TEMP_FRAMEWORK_NAME );
> 	MAKEADD_DIR( name );
> 
> 	crStrcat( name, "/Versions" );
> 	MAKEADD_DIR( name );
> 
> 	crStrcat( name, "/A" );
> 	MAKEADD_DIR( name );
> 
> 	make_temp_link( name, "Current", "A" );
> 
> 	crStrcat( name, "/Frameworks" );
> 	MAKEADD_DIR( name );
> 
> 	crStrcpy( name, dir );
> 	crStrcat( name, "/" TEMP_FRAMEWORK_NAME "/Versions/A/Libraries" );
> 	MAKEADD_DIR( name );
> 
> 	crStrcpy( name, dir );
> 	crStrcat( name, "/" TEMP_FRAMEWORK_NAME );
> 
> 	make_temp_link( name, "Frameworks", "Versions/Current/Frameworks" );
> 	make_temp_link( name, "Headers", "Versions/Current/Headers" );
> 	make_temp_link( name, "Libraries", "Versions/Current/Libraries" );
> 	make_temp_link( name, "OpenGL", "Versions/Current/OpenGL" );
> 	make_temp_link( name, "Resources", "Versions/Current/Resources" );
> 
> 	crStrcat( name, "/Versions/A" );
> 	make_temp_link( name, "Headers", SYSTEM_GL_PATH "/Headers" );
> 	make_temp_link( name, "OpenGL", cr_lib );
> 	make_temp_link( name, "Resources", SYSTEM_GL_PATH "/Resources" );
> 
> 	/* these are the most important parts */
> 	make_temp_link( name, "Frameworks/NOpenGL.framework", SYSTEM_GL_PATH );
> 
> 	crStrcat( name, "/Libraries" );
> 	make_temp_link( name, "libGL.dylib", cr_lib );
> }
> #endif
> 
545a604,606
> #ifdef DARWIN
> 	make_temp_framework( tmpdir );
> #else
566a628
> #endif
569a632,633
> #elif defined(DARWIN)
> 	prefix_env_var( tmpdir, "DYLD_FRAMEWORK_PATH" );
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.