Skip to content

Commit

Permalink
Windows super hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Thakore committed Aug 20, 2009
1 parent 5c44eb3 commit a10ede2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 118 deletions.
143 changes: 26 additions & 117 deletions make/lib/SDL/Build/MSWin32.pm
Expand Up @@ -29,140 +29,49 @@
#

package SDL::Build::MSWin32;

use strict;
use warnings;
use Data::Dumper;
use Carp;
use base 'SDL::Build';
use File::Spec::Functions;

sub fetch_includes
{

warn "Environment variable INCLUDE is empty\n" unless $ENV{INCLUDE};
return map { $_ => 1 } grep { $_ } split( ';', $ENV{INCLUDE} ) if $ENV{INCLUDE};
return '-I.';
}

sub find_header
{
for my $key (qw( LIBS PATH ))
{
#this needs to be carp because some users will have SDL libs in same folder
carp "Environment variable $key is empty\n" unless $ENV{$key};
carp "This will probably fail the compile \nSet $key manually or try building anyway\n" unless $ENV{$key};
}

my ( $self, $header, $includes ) = @_;
( my $dll = $header ) =~ s/\.h/\.dll/;

my $include_dir;

for my $inc_dir ( keys %$includes )
{
next unless -e catfile( $inc_dir, $header );
$include_dir = $inc_dir;
}

return unless $include_dir;

for my $lib_path ( map { split(';', ( $ENV{$_} || '' )) }
qw( LIB LIBS PATH ) )
{
return ( $include_dir, $header ) if -e catfile( $lib_path, $dll );
}
}

sub link_flags
{
return 'SDL.lib';
}

sub compile_flags
{
return;
}

sub subsystems
{
my $self = shift;
my $subsystems = $self->SUPER::subsystems();
my $gl_ss_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_subsystems';

$subsystems->{OpenGL}{libraries} = $self->$gl_ss_method();
return $subsystems;
}

sub libraries
{
my $self = shift;
my $libraries = $self->SUPER::libraries();
my $gl_lib_method = $self->gl_vendor( $ENV{SDL_GL_VENDOR} ) . '_libraries';

$libraries->{OpenGL}{define} .= ' -D' . $self->$gl_lib_method();
return $libraries;
}

sub gl_vendor
{
my ( $self, $vendor ) = @_;

return 'ms_gl' unless defined $vendor;
return 'mesa_gl' if $vendor eq 'MESA';
return 'ms_gl' if $vendor eq 'MS';
croak "Unrecognized GL vendor '$vendor'\n";

}

sub ms_gl_subsystems
{
return [qw( OpenGL GLU )];
}

sub mesa_gl_subsystems
{
return [qw( mesagl mesaglu osmesa )];
}

sub ms_gl_libraries
{
define => 'OPENGL_VENDOR_MS';
}

sub mesa_gl_libraries
sub opengl_headers
{
define => 'OPENGL_VENDOR_MESA';
return GL => 'SDL_opengl.h';
}

sub link_c
sub fetch_includes
{
my $self = shift;
my ( $blib, $rib ) = @_;

# until ExtUtils::ParseXS is patched, avoid warnings from cl.exe
$_[-1] =~ s{\\}{/}g;

$rib =~ s{^src[\\/]}{};
$rib =~ s{[\\/]}{::}g;

local $self->{properties}{module_name} = $rib;
$self->SUPER::link_c( @_ );
return (

$ENV{SDL_INST_DIR}.'/include' => $ENV{SDL_INST_DIR}.'/lib',
$ENV{SDL_INST_DIR}.'/include/gl' => $ENV{SDL_INST_DIR}.'/lib',
$ENV{SDL_INST_DIR}.'/include/GL' => $ENV{SDL_INST_DIR}.'/lib',
$ENV{SDL_INST_DIR}.'/include/SDL' => $ENV{SDL_INST_DIR}.'/lib',
$ENV{SDL_INST_DIR}.'/include/smpeg' => $ENV{SDL_INST_DIR}.'/lib',
);
}

sub sdl_libs
{
my $self = shift;
my $sdl_inst_dir = shift;
#Todo: his needs to be fixed hash references are a mess
#sub build_links
#{

# my $self = shift;
# my $links = $self->SUPER::build_links(@_);
#
# for my $subsystem (values %$links)
# {
# push @{ $subsystem{ libs } }, '-lpthreads';
# }

# return \%links;
#}

}

sub alt_link_flags
{
my $self = shift;
my $sdl_dir = shift;

return $self->SUPER::alt_link_flags($sdl_dir).' -lmingw32 -mwindows -lSDLmain -lSDL.dll';
return $self->SUPER::alt_link_flags($sdl_dir).' -mwindows -lSDLmain -lSDL.dll';
}

sub alt_compile_flags
Expand Down
2 changes: 2 additions & 0 deletions make/lib/SDL/Utility.pm
Expand Up @@ -18,6 +18,8 @@ use SDL::Build;
#
sub sdl_con_found
{
return 0 if($^O eq 'MSWin32');

`sdl-config --libs`;
return 1 unless ($? >> 8) and return 0;

Expand Down
22 changes: 21 additions & 1 deletion src/SDL.xs
Expand Up @@ -97,7 +97,27 @@ static int sdl_perl_use_smpeg_audio = 0;
#define HAVE_TLS_CONTEXT
#endif

#include "src/defines.h"
/* For windows */
#ifndef SDL_PERL_DEFINES_H
#define SDL_PERL_DEFINES_H

#ifdef HAVE_TLS_CONTEXT
PerlInterpreter *parent_perl = NULL;
extern PerlInterpreter *parent_perl;
#define GET_TLS_CONTEXT parent_perl = PERL_GET_CONTEXT;
#define ENTER_TLS_CONTEXT \
PerlInterpreter *current_perl = PERL_GET_CONTEXT; \
PERL_SET_CONTEXT(parent_perl); { \
PerlInterpreter *my_perl = parent_perl;
#define LEAVE_TLS_CONTEXT \
} PERL_SET_CONTEXT(current_perl);
#else
#define GET_TLS_CONTEXT /* TLS context not enabled */
#define ENTER_TLS_CONTEXT /* TLS context not enabled */
#define LEAVE_TLS_CONTEXT /* TLS context not enabled */
#endif

#endif

Uint32
sdl_perl_timer_callback ( Uint32 interval, void* param )
Expand Down

0 comments on commit a10ede2

Please sign in to comment.