diff -uprN Glib-Object-Introspection-0.009.orig/Makefile.PL Glib-Object-Introspection-0.009/Makefile.PL --- Glib-Object-Introspection-0.009.orig/Makefile.PL 2012-01-20 09:35:00 +0200 +++ Glib-Object-Introspection-0.009/Makefile.PL 2012-06-21 12:28:25 +0200 @@ -21,6 +21,7 @@ use warnings; use ExtUtils::MakeMaker; use File::Spec; use Cwd; +use Config; my %PREREQ_PM = ( 'ExtUtils::Depends' => 0.300, @@ -30,6 +31,7 @@ my %PREREQ_PM = ( my %BUILD_REQ = ( 'gobject-introspection-1.0' => '0.10.0', + 'libffi' => '3.0.0', ); my $dep_success = eval <<__EOE__; @@ -55,6 +57,23 @@ if (!$cfg_success) { exit 0; } +# FIXME: PC files list libffi as private, but needed on Win32 to link with +# G-O-I; is this a Win32 or upstream problem? +if ($^O eq 'MSWin32') { + my %cfg_ffi; + my $cfg_success = eval { + %cfg_ffi = ExtUtils::PkgConfig->find ( + "libffi >= $BUILD_REQ{'libffi'}"); + 1; + }; + if (!$cfg_success) { + warn $@; + exit 0; + } + $cfg{cflags} .= " $cfg_ffi{cflags}"; + $cfg{libs} .= " $cfg_ffi{libs}"; +} + my @xs_files = qw(GObjectIntrospection.xs); my %pm_files = ( @@ -112,42 +131,101 @@ sub compile_test_libraries { 'gidatadir'); my $testsdir = $gidatadir . '/tests'; my %cairo_flags = ExtUtils::PkgConfig->find ('cairo'); - my %gio_flags = ExtUtils::PkgConfig->find ('gio-2.0'); my %glib_flags = ExtUtils::PkgConfig->find ('glib-2.0'); - + my %gobj_flags = ExtUtils::PkgConfig->find ('gobject-2.0'); + my %gio_flags = ExtUtils::PkgConfig->find ('gio-2.0'); + my @commands; # FIXME: Why is --no-as-needed necessary? - !system (qq(gcc -shared -fPIC -Wl,--no-as-needed -g \\ - $cairo_flags{cflags} $cairo_flags{libs} \\ - $gio_flags{cflags} $gio_flags{libs} \\ - $testsdir/regress.c \\ - -o libregress.so 1>/dev/null 2>/dev/null)) - && !system (qq(LD_LIBRARY_PATH=$build_dir \\ - g-ir-scanner \\ - --include=cairo-1.0 --include=Gio-2.0 \\ - --namespace=Regress --nsversion=1.0 \\ - --quiet --warn-all --warn-error \\ - --library=regress \\ - --output=Regress-1.0.gir \\ - $testsdir/regress.h $testsdir/regress.c \\ - 1>/dev/null 2>/dev/null)) - && !system (qq(g-ir-compiler Regress-1.0.gir -o Regress-1.0.typelib \\ - 1>/dev/null 2>/dev/null)) - && !system (qq(gcc -shared -fPIC -g \\ - $glib_flags{cflags} $glib_flags{libs} \\ - $testsdir/gimarshallingtests.c \\ - -o libgimarshallingtests.so 1>/dev/null 2>/dev/null)) - && !system (qq(LD_LIBRARY_PATH=$build_dir \\ - g-ir-scanner \\ - --include=GObject-2.0 \\ - --namespace=GIMarshallingTests \\ - --symbol-prefix=gi_marshalling_tests --nsversion=1.0 \\ - --quiet --warn-all --warn-error \\ - --library=gimarshallingtests \\ - --output=GIMarshallingTests-1.0.gir \\ - $testsdir/gimarshallingtests.h $testsdir/gimarshallingtests.c \\ - 1>/dev/null 2>/dev/null)) - && !system (qq(g-ir-compiler GIMarshallingTests-1.0.gir \\ - -o GIMarshallingTests-1.0.typelib 1>/dev/null 2>/dev/null)) + my $c_flags = qq(-shared -fPIC -Wl,--no-as-needed); + my $gir_cmd = qq(LD_LIBRARY_PATH=$build_dir g-ir-scanner); + my $prefix = q(); + my $pipe = qq(1>/dev/null 2>/dev/null); + + if ($^O eq 'MSWin32') { + my @path = File::Spec->path; + my $found = 0; + + foreach my $base ( map { File::Spec->catfile($_, 'g-ir-scanner') } @path ) { + if ( -f $base ) { + $gir_cmd = qq(python $base); + $found = 1; + last; + } + } + + die 'Cannot find g-ir-scanner' if (!$found); + + $c_flags = qq(-shared); + $pipe = qq(1>NUL 2>NUL); + # XXX: We need the lib prefix for --library argument to G-O-I on Win32, + # else DLL resolution fails - not sure if its a G-O-I bug not fixed + # for MinGW32 ... + $prefix = 'lib'; + } + + push(@commands, + qq(gcc $c_flags -g \\ + $testsdir/regress.c -o libregress.$Config{dlext} \\ + $cairo_flags{cflags} $cairo_flags{libs} \\ + $gio_flags{cflags} $gio_flags{libs} \\ + $pipe)); + push(@commands, + qq($gir_cmd \\ + --include=cairo-1.0 --include=Gio-2.0 \\ + --namespace=Regress --nsversion=1.0 \\ + --quiet --warn-all --warn-error \\ + --library=${prefix}regress \\ + --output=Regress-1.0.gir \\ + $testsdir/regress.h $testsdir/regress.c \\ + $pipe)); + push(@commands, + qq(g-ir-compiler Regress-1.0.gir -o Regress-1.0.typelib \\ + $pipe)); + # FIXME: Need GObject-2.0 on Windows - Win32 or upstream problem? + push(@commands, + qq(gcc $c_flags -g \\ + $testsdir/gimarshallingtests.c -o libgimarshallingtests.$Config{dlext} \\ + $glib_flags{cflags} $glib_flags{libs} \\ + $gobj_flags{cflags} $gobj_flags{libs} \\ + $pipe)); + push(@commands, + qq($gir_cmd \\ + --include=GObject-2.0 \\ + --namespace=GIMarshallingTests \\ + --symbol-prefix=gi_marshalling_tests --nsversion=1.0 \\ + --quiet --warn-all --warn-error \\ + --library=${prefix}gimarshallingtests \\ + --output=GIMarshallingTests-1.0.gir \\ + $testsdir/gimarshallingtests.h $testsdir/gimarshallingtests.c \\ + $pipe)); + push(@commands, + qq(g-ir-compiler GIMarshallingTests-1.0.gir \\ + -o GIMarshallingTests-1.0.typelib $pipe)); + + if ($^O eq 'MSWin32') { + my $path = $ENV{PATH}; + + # XXX: G-O-I defaults to CC=cc + $ENV{CC} = 'gcc' if (!defined $ENV{CC}); + $ENV{PATH} .= ';' . $build_dir; + + foreach my $command (@commands) { + # XXX: Cmd.exe do not support \ as line break ... + $command =~ s/\\\n//mg; + $command =~ s/\s\s+/ /mg; + + system($command) == 0 or die "Failed to execute: $command\n"; + } + + $ENV{PATH} = $path; + } + else { + foreach my $command (@commands) { + system($command) == 0 or die "Failed to execute: $command\n"; + } + } + + 1; }; print $success ? "OK\n" : "not OK\n"; @@ -159,8 +237,15 @@ package MY; # so that "SUPER" works righ sub test { my $inherited = shift->SUPER::test(@_); - # put "build" into LD_LIBRARY_PATH for the tests - $inherited =~ s/(test_dynamic :: pure_all)\n\t/$1\n\tLD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:build /; + if ($^O eq 'MSWin32') { + # put "build" into PATH for the tests + # FIXME: Not sure how to get this to actually work with dmake + $inherited =~ s/(test_dynamic :: pure_all)\n\t/$1\n\tset PATH=%PATH%;build\n\t /; + } + else { + # put "build" into LD_LIBRARY_PATH for the tests + $inherited =~ s/(test_dynamic :: pure_all)\n\t/$1\n\tLD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:build /; + } $inherited; } diff -uprN Glib-Object-Introspection-0.009.orig/t/inc/setup.pl Glib-Object-Introspection-0.009/t/inc/setup.pl --- Glib-Object-Introspection-0.009.orig/t/inc/setup.pl 2012-01-19 06:36:53 +0200 +++ Glib-Object-Introspection-0.009/t/inc/setup.pl 2012-06-20 18:00:39 +0200 @@ -1,14 +1,27 @@ +use Config; use Glib::Object::Introspection; use Test::More; -unless (-e 'build/libregress.so' && -e 'build/libgimarshallingtests.so') { +unless (-e qq(build/libregress.$Config{dlext}) && -e qq(build/libgimarshallingtests.$Config{dlext})) { plan skip_all => 'Need the test libraries'; } -unless (defined $ENV{LD_LIBRARY_PATH} && - $ENV{LD_LIBRARY_PATH} =~ m/\bbuild\b/) -{ - plan skip_all => 'Need "build" in LD_LIBRARY_PATH'; +if ($^O eq 'MSWin32') { + # FIXME: Not sure how to get this to actually work with dmake + if (0) { + unless (defined $ENV{PATH} && + $ENV{PATH} =~ m/\bbuild\b/) + { + plan skip_all => 'Need "build" in PATH'; + } + } +} +else { + unless (defined $ENV{LD_LIBRARY_PATH} && + $ENV{LD_LIBRARY_PATH} =~ m/\bbuild\b/) + { + plan skip_all => 'Need "build" in LD_LIBRARY_PATH'; + } } Glib::Object::Introspection->setup(