Framework
Pike 7.7 has support for building an Objective-C framework for use with Darwin. This framework allows Pike to be embedded in any Objective-C application. __Creating the framework__ after successfully building pike from 7.7 CVS, enter the build directory (build/platform_name) and run "make framework". successful completion of this should leave Pike.framework in the current directory. the framework is designed to be located within a "Cocoa" application's Frameworks directory (@executable_dir/../Frameworks), so if you want to install the framework within a standard location, like /Library/Frameworks, you'll need to use the install_name_tool utility to change that location. A small sample program is included in comments at the end of src/OCPikeInterpreter.m. __Building a Universal Framework__ The framework built by "make framework" places any platform specific modules in the Resources/~~platform~~ directory, and the master is able to accomodate this. Therefore, the only file that needs to be made Universal is Pike.framework/Versions/Current/Pike. Use the "lipo" tool to make a fat binary of this file from versions of the file compiled for the desired platforms (currently, this should be Power_Macintosh and i386). Assuming you have made frameworks for both platforms, the following commands should yield a Universal framework in the build/Frameworks directory: {code} cd build mkdir Frameworks cp -rf darwin-8.9.1-i386/Pike.framework Frameworks cp -rf darwin-8.9.1-power-macintosh/Pike.framework/Versions/Current/Resources/Power_Macintosh Frameworks/Pike.framework/Versions/Current/Resources lipo darwin-8.9.1-i386/Pike.framework/Versions/Current/Pike darwin-8.9.1-power-macintosh/Pike.framework/Versions/Current/Resources/Pike -output Frameworks/Pike.framework/Versions/Current/Pike {code} __Using the framework__ Once a pike framework has been built, using it is similar to using any other framework. Because the framework is built with the anticipation it will be used in an embedded form, make sure that you've installed Pike.framework in ../Frameworks from where you run this code. As noted above, install_name_tool can be used to make this a different location, such as /Library/Frameworks. If using the framework embedded within a loadable bundle (such as a preference pane or screensaver), you should use install_name_tool to change the load location to begin with @loader_path (magic identifier indicating the path to the bundle requesting the load) instead of @executable_path (magic identifier indicating the path of the current executable). {code} install_name_tool -change @executable_path/../Frameworks/Pike.framework/Pike @loader_path/../Frameworks/Pike.framework/Pike path/to/bundle/executable gcc -arch ppc -FTestBundle.saver/Contents/Frameworks -c BWTestBundle.m -o BWTestBundle.o MACOSX_DEPLOYMENT_TARGET="10.4" gcc -arch ppc BWTestBundle.o -bundle -o TestBundle -FTestBundle.saver/Contents/Frameworks -framework Pike -framework Foundation -undefined dynamic_lookup -framework ScreenSaver {code} {code} gcc -F../Frameworks -c test.m -o test.o gcc test.o -o test -F../Frameworks -framework Pike -framework Foundation ./test {code} {code} #import Powered by PikeWiki2 |
|||
gotpike.org | Copyright © 2004 - 2009 | Pike is a trademark of Department of Computer and Information Science, Linköping University |