Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Builder enhancements - proper disabling SDL submodules based on detec…

…ted missing libs/headers
  • Loading branch information...
commit 1dae658325625ec0d386d7c1850e527ebc10d448 1 parent d492581
@kmx kmx authored
Showing with 30 additions and 34 deletions.
  1. +7 −4 Build.PL
  2. +23 −30 inc/My/Builder.pm
View
11 Build.PL
@@ -377,7 +377,8 @@ my %subsystems =
### external libraries
# <library name> = symbolic library name
# <define> = value that will be used as -D<value> option when compiling XS code
-# <header> = header related to the library that will be used for avalability detection
+# <header> = header related to the library that will be used for avalability detection,
+# could be a sigle value or an array of values
# <lib> = value that will be used as -l<value> option when linking XS code
my %libraries = (
SDL => {
@@ -452,7 +453,7 @@ my %libraries = (
},
GL => {
define => 'HAVE_GL',
- header => 'GL/gl.h',
+ header => [ 'GL/gl.h', 'GL/glext.h' ],
lib => ($^O eq 'MSWin32') ? 'opengl32' : 'GL', # xxx not nice
},
GLU => {
@@ -494,10 +495,14 @@ my $build = $package->new(
meta_add =>
{
},
+ create_readme => 1,
dist_abstract => 'SDL bindings to Perl',
dist_author => 'Kartik Thakore <KTHAKORE@cpan.org>',
);
+### Alien::SDL quick check
+warn "###WARNING### Alien::SDL seems to be broken" unless Alien::SDL->config('prefix');
+
### see which subsystems can be built -- do we have headers for them?
print "Gonna autodetect available libraries ...\n";
my $build_systems = $build->find_subsystems( \%subsystems, \%libraries );
@@ -511,7 +516,6 @@ $build->config_data('sdl_ld_shlib_map', Alien::SDL->config('ld_shlib_map'));
### something that was originally special to MacOS/Darwin
# somebody MacOS/Darwin friendly should review whether it is still necessary
-# xxx TODO xxx
$build->special_build_settings();
### get some info into M::B notes
@@ -521,7 +525,6 @@ $build->notes('libraries', \%libraries);
$build->notes('build_systems', $build_systems);
$build->notes('sdl_cflags', Alien::SDL->config('cflags'));
$build->notes('sdl_libs', Alien::SDL->config('libs'));
-$build->set_build_opts(); # creates notes('defines') and notes('links')
$build->set_file_flags(); # creates notes('file_flags')
# now we're ready to go!
View
53 inc/My/Builder.pm
@@ -50,6 +50,8 @@ sub process_xs
my $properties = $self->{properties};
my $file_args = $self->notes( 'file_flags' )->{$file};
+ return unless defined($file_args);
+
my @old_values = @$properties{ keys %$file_args };
@$properties{ keys %$file_args } = values %$file_args;
@@ -65,71 +67,62 @@ sub find_subsystems
my %enabled;
while ( my ($name, $subsystem) = each %$subsystems )
{
+ my $param;
for my $library (@{ $subsystem->{libraries} })
{
my $lib = $libraries->{$library}
or croak "Unknown library '$library' for '$name'\n";
- unless (defined($found{$lib->{header}})) {
- $found{$lib->{header}} = Alien::SDL->check_header($lib->{header}) ? 1 : 0;
+ my $h = ref($lib->{header}) eq 'ARRAY' ? $lib->{header} : [ $lib->{header} ];
+ my $need_check = 0;
+ foreach (@$h) {
+ $need_check = 1 unless $found{$_};
+ }
+ if ( !$need_check || Alien::SDL->check_header(@$h)) {
+ $found{$_} = 1 foreach (@$h);
+ $param->{libs}->{$library} = 1;
+ push @{ $param->{defines} }, "-D$libraries->{$library}{define}";
+ push @{ $param->{links} }, "-l$libraries->{$library}{lib}";
+ }
+ else {
+ $param = undef;
+ print "###WARNING### Disabling subsystem '$name'\n";
+ last;
}
- $enabled{$name}{$library} = 1 if $found{$lib->{header}};
}
+ $enabled{$name} = $param if $param;
}
return \%enabled;
}
-# set the define flags and flags for the libraries we have
-sub set_build_opts
-{
- my $self = shift;
- my $libraries = $self->notes('libraries');
- my $build_systems = $self->notes('build_systems');
- my %defines;
- my %links;
-
- while (my ($subsystem, $buildable) = each %$build_systems)
- {
- for my $build (grep { $buildable->{ $_ } } keys %$buildable)
- {
- push @{ $defines{$subsystem} }, "-D$libraries->{$build}{define}";
- push @{ $links{$subsystem} }, "-l$libraries->{$build}{lib}";
- }
- }
-
- $self->notes('defines' => \%defines);
- $self->notes('links' => \%links);
-}
-
# save this all in a format process_xs() can understand
sub set_file_flags
{
my $self = shift;
my %file_flags;
+ my %build_systems = %{$self->notes('build_systems')};
- while (my ($subsystem, $buildable) = each %{$self->notes('build_systems')} )
+ while (my ($subsystem, $param) = each %build_systems )
{
my $sub_file = $self->notes('subsystems')->{$subsystem}{file}{to};
$file_flags{$sub_file} = {
extra_compiler_flags =>
[
(split(' ', $self->notes('sdl_cflags'))),
- @{$self->notes('defines')->{$subsystem}},
+ @{$param->{defines}},
( defined $Config{usethreads} ? ('-DUSE_THREADS', '-fPIC') : ('-fPIC' )),
],
extra_linker_flags =>
[
(split(' ', $self->notes('sdl_libs'))),
- @{$self->notes('links')->{$subsystem}},
+ @{$param->{links}},
],
},
}
-
$self->notes('file_flags' => \%file_flags);
}
# override the following functions in My::Builder::<platform> if necessary
# both special to MacOS/Darwin, somebody should review whether it is still necessary
-# xxx TODO xxx
sub special_build_settings { }
sub build_bundle { }

0 comments on commit 1dae658

Please sign in to comment.
Something went wrong with that request. Please try again.