Added SDLPerl.app bundle to the now fixed Darwin build system
cthulhuology [Fri, 7 Aug 2009 20:59:14 +0000 (16:59 -0400)]
Added .spl filetype for launching SDLPerl.app scripts!

CHANGELOG
MacOSX/Info.plist
MacOSX/SDLPerl.icns [moved from MacOSX/SDL Perl.icns with 100% similarity]
MacOSX/launcher.m
make/lib/SDL/Build.pm
make/lib/SDL/Build/Darwin.pm
src/OpenGL.xs
test/testcolor.spl [new file with mode: 0644]

index c88c1ca..b8d5929 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,13 @@
 Revision history for Perl extension SDL_perl.
 
+* Aug 7 2009   David J. Goehrig <dgoehrig@cpan.org>
+       - fixed Darwin build breakage
+       - added support for Mac Ports policies
+       - updated the name of the bundle
+       - added Darwin action ./Build bundle to create SDLPerl.app
+       - fixed SDLPerl.app compilation
+       - added .spl file type for SDLPerl applications!
+
 * Aug 5 2009    Kartik Thakore   <thakore.kartik@gmail.com>
        - fixed build after Module::Build breakage
        - fixed openGL header problems
index 2d4aa04..29efd98 100644 (file)
@@ -3,16 +3,16 @@
 <plist version="1.0">
 <dict>
        <key>CFBundleDisplayName</key>
-       <string>SDL Perl</string>
+       <string>SDLPerl</string>
        <key>CFBundleDocumentTypes</key>
        <array>
                <dict>
                        <key>CFBundleTypeExtensions</key>
                        <array>
-                               <string>sdlpl</string>
+                               <string>spl</string>
                        </array>
                        <key>CFBundleTypeIconFile</key>
-                       <string>SDL Perl.icns</string>
+                       <string>SDLPerl.icns</string>
                        <key>CFBundleTypeName</key>
                        <string>SDL Perl Script</string>
                        <key>CFBundleTypeRole</key>
                </dict>
        </array>
        <key>CFBundleExecutable</key>
-       <string>SDL Perl</string>
+       <string>SDLPerl</string>
        <key>CFBundleGetInfoString</key>
        <string>Multimedia for Perl</string>
        <key>CFBundleIconFile</key>
-       <string>SDL Perl.icns</string>
+       <string>SDLPerl.icns</string>
        <key>CFBundleIdentifier</key>
        <string>org.perl.sdl</string>
        <key>CFBundleName</key>
-       <string>SDL Perl</string>
+       <string>SDLPerl</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
similarity index 100%
rename from MacOSX/SDL Perl.icns
rename to MacOSX/SDLPerl.icns
index 749f664..59ccff5 100644 (file)
@@ -186,6 +186,7 @@ main( int argc, char** argv)
        [NSApp setMainMenu: [[NSMenu alloc] init]];
        
        sdlplmain = [[SDLPerlMain alloc] init];
+       [sdlplmain retain];
        [NSApp setDelegate: sdlplmain];
 
        [NSApp run];
index 37354a7..3cade52 100644 (file)
@@ -249,9 +249,11 @@ sub process_support_files {
 }
 
 # Override to create a MacOS Bundle
-sub build_bundle
+sub ACTION_bundle
 {
-       return;
+       my ($self) = @_;
+       $self->depends_on('build');
+       $self->get_arch($^O)->build_bundle();
 }
 
 # Override Install method for darwin
@@ -259,7 +261,6 @@ sub ACTION_install {
   my ($self) = @_;
   require ExtUtils::Install;
   $self->depends_on('build');
-  $self->get_arch($^O)->build_bundle();
   ExtUtils::Install::install($self->install_map, 1, 0, $self->{args}{uninst}||0);
 }
 
index 1f090da..2dd2222 100644 (file)
@@ -56,8 +56,7 @@ sub fetch_includes
        '/System/Library/Frameworks/libvorbisfile.framework/Headers' => '../../lib',
        '/System/Library/Frameworks/libvorbisenc.framework/Headers'  => '../../lib',
        '../../include'                                              => '../../lib',
-       '/System/Library/Frameworks/OpenGL.framework/Headers'        =>
-               '/System/Library/Frameworks/OpenGL.framework/Libraries',
+       '/System/Library/Frameworks/OpenGL.framework/Headers'        => '/System/Library/Frameworks/OpenGL.framework/Libraries',
        );
 }
 
@@ -75,23 +74,29 @@ sub build_c_source
 
 sub build_install_base
 {
-       return "SDL Perl.app/Contents/Resources";       
+       return "SDLPerl.app/Contents/Resources";        
 }
 
 sub build_bundle
 {
-       $bundle_contents="SDL Perl.app/Contents";
+       $bundle_contents="SDLPerl.app/Contents";
        system "mkdir -p \"$bundle_contents\"";
        mkdir "$bundle_contents/MacOS",0755;
-       $libs = `sdl-config --libs`;
+       $cflags = `sdl-config --cflags`;
+       chomp($cflags);
+       $cflags .= ' ' . `perl -MExtUtils::Embed -e ccopts`;
+       chomp($cflags);
+       $libs = `sdl-config  --libs`;
+       chomp($libs);
+       $libs .= ' ' . `perl -MExtUtils::Embed -e ldopts`;
        chomp($libs);
        $libs =~ s/-lSDLmain//g;
-       system "gcc $libs -framework Cocoa `perl -MExtUtils::Embed -e ldopts` MacOSX/launcher.o -o \"$bundle_contents/MacOS/SDL Perl\"";
-
+       print STDERR "gcc $cflags MacOSX/launcher.m $libs -framework Cocoa -o \"$bundle_contents/MacOS/SDLPerl\"";
+       print STDERR `gcc $cflags MacOSX/launcher.m $libs -framework Cocoa -o \"$bundle_contents/MacOS/SDLPerl\"`;
        mkdir "$bundle_contents/Resources",0755;
        system "echo \"APPL????\" > \"$bundle_contents/PkgInfo\"";
        system "cp MacOSX/Info.plist \"$bundle_contents/\"";
-       system "cp \"MacOSX/SDL Perl.icns\" \"$bundle_contents/Resources\"";
+       system "cp \"MacOSX/SDLPerl.icns\" \"$bundle_contents/Resources\"";
 }
 
 1;
index 13b3e58..47f22c2 100644 (file)
 
 #include <SDL.h>
 
+#ifdef PERL_DARWIN
+#include <gl.h>
+#include <glu.h>
+#else
 #include <GL/gl.h>
 #include <GL/glu.h>
+#endif
+
 
 #ifdef USE_THREADS
 #define HAVE_TLS_CONTEXT
diff --git a/test/testcolor.spl b/test/testcolor.spl
new file mode 100644 (file)
index 0000000..9865b62
--- /dev/null
@@ -0,0 +1,63 @@
+#!/usr/bin/env perl
+#
+
+use SDL;
+use SDL::App;
+use SDL::Event;
+
+use vars qw/ $app /;
+
+print STDERR <<USAGE;
+       Right click on any pixel to get its color values
+       Left click on any pixel to set its value to the last selected
+USAGE
+
+$app = new SDL::App -width => 320, -height => 240, -depth => 8;
+
+my %colors = (
+       red => (new SDL::Color -r => 255, -g => 0, -b => 0 ),
+       green => (new SDL::Color -r => 0, -g => 255, -b => 0),
+       blue => (new SDL::Color -r => 0, -g => 0, -b => 255),
+       yellow => (new SDL::Color -r => 255, -g => 255, -b => 0),
+       purple => (new SDL::Color -r => 255, -g => 0, -b => 255),
+       white => (new SDL::Color -r => 255, -g => 255, -b => 255)
+);
+
+
+$x = 0; $y = 0;
+$rect = new SDL::Rect -x => $x, -y => $y, 
+       -w => $app->width / scalar(keys %colors), -h => $app->height();
+
+print "Sorted colors:\n";
+
+for ( sort keys %colors ) {
+       print "$_ " . join (",",$colors{$_}->r(), $colors{$_}->g(), 
+               $colors{$_}->b()) . "\n";
+}
+
+for ( sort keys %colors ) {
+       $rect->x($x);
+       $x += $rect->width();
+       $app->fill($rect,$colors{$_});
+}
+
+$app->sync();
+
+$last = new SDL::Color -r => 128, -g => 128, -b => 128;
+
+$app->sync();
+$app->loop( {
+       SDL_QUIT() => sub { exit(0); },
+       SDL_KEYDOWN() => sub { $app->fullscreen(); },
+       SDL_MOUSEBUTTONDOWN() => sub { 
+               my $e = shift; 
+               if ($e->button == 3) {
+                       $last = $app->pixel($e->button_x(),$e->button_y());
+                       print STDERR "X: ", $e->button_x(), " Y: ", $e->button_y(), 
+                               " R: ", $last->r(), " G: ", $last->g(), 
+                               " B: ", $last->b(), "\n";
+               } else {
+                       $app->pixel($e->button_x(),$e->button_y(),$last);
+               }
+       },
+});