Skip to content

Commit

Permalink
Merge branch 'master' into issue_76_spatial_randomisation
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnlaffan committed Jun 18, 2016
2 parents 32b0b1a + 64da31a commit c36ae19
Show file tree
Hide file tree
Showing 2 changed files with 109 additions and 83 deletions.
165 changes: 95 additions & 70 deletions etc/pp/README.txt → etc/pp/README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,96 @@
Heavy.pm.patch needs to be applied to
C:\strawberry\perl\vendor\lib\PAR\Heavy.pm
It causes DLLs to be extracted with their original names instead of CRCs.
Needed for GTK modules to work properly.

Also need to add the following lines before the open is attempted.
This avoids duplicate DLL file names in modules ending in XS.

near line 153, before the line:
open $fh, '>', $filename or die $!

### DIRTY HACK
if (-e $filename && not $filename =~ /Glib|Gtk2|Gnome|Pango|Cairo/) {
$filename .= $member->crc32String; # kludge workaround
}


To get the Biodiverse icon to properly show the PAR libs need to be updated to use the Biodiverse icon.
Other solutions using Win32::EXE result in a slew of warnings when first running the program.


Adapt this code as needed (from http://www.zewaren.net/site/?q=node/116).
It is for a makefile, but seemed to have no effect when run independently using dmake.
Running each command in sequence did work, though (tweaking as appropriate).


PERL_DIR = C:\strawberry_51613_x64\perl
PAR_PACKER_SRC = C:\strawberry_51613_x64\cpan\build\PAR-Packer-1.018-XUXam8

all:
copy /Y C:\shawn\svn\biodiverse_trunk\bin\Biodiverse_icon.ico $(PAR_PACKER_SRC)\myldr\winres\pp.ico
#copy /Y medias\jambon.rc $(PAR_PACKER_SRC)\myldr\winres\pp.rc
del $(PAR_PACKER_SRC)\myldr\ppresource.coff
cd /D $(PAR_PACKER_SRC)\myldr\ && perl Makefile.PL
cd /D $(PAR_PACKER_SRC)\myldr\ && dmake boot.exe
cd /D $(PAR_PACKER_SRC)\myldr\ && dmake Static.pm
attrib -R $(PERL_DIR)\site\lib\PAR\StrippedPARL\Static.pm
copy /Y $(PAR_PACKER_SRC)\myldr\Static.pm $(PERL_DIR)\site\lib\PAR\StrippedPARL\Static.pm




Old info below. The patches are redundant for current versions, and the build script has been updated to copy relevant files across.


Makefile.PL.patch needs to be applied to PAR-Packer-1.013
This patch doesn't change the behaviour. It is just needed to make it build
under x86_64.
Derived from http://www.nntp.perl.org/group/perl.par/2012/03/msg5310.html
(It has been fixed upstream in PAR-Packer-1.014.)

NOTE: The order is important. PAR-Packer needs to be (re)built/installed
after Heavy.pm has been modified, since it gets embedded in some
binaries.

= The above is only relevant if you are not using the PPMs in ..\ppm\ppm516*

Run "..\etc\pp\build.bat" when you are in the bin directory to generate
BiodiverseGUI.exe.

The following DLLs from Strawberry Perl need
to be distributed with BiodiverseGUI.exe:

libstdc++-6.dll
libexpat-1__.dll

On 32-bit, libgcc_s_sjlj-1.dll, additionally needs to be distributed.

The win_gtk_builds\etc\win(32|64)\c tree also needs to be distributed as
"gtk".
## Packing Gtk2 libs ##

The Heavy.pm.patch needs to be applied to PAR\Heavy.pm

Source is https://rt.cpan.org/Ticket/Attachment/1135201/597366/Heavy.pm.patch

This patch means DLLs will be extracted with their original names instead of CRCs,
and is needed for GTK modules to work properly. This is not a perfect approach,
hence the next step.

The following lines also need to inserted before the open is attempted.
This avoids duplicate DLL file names for non-Gtk modules, as otherwise those
with the same ending would all refer to the same file,
e.g. List::BinarySearch::XS, YAML::XS and URI::Escape::XS would
all try to use XS.dll.

Insert the code between START HACK and END HACK near line 153
(should make a patch file for this).

```perl
($filename) = $filename =~ /^([\x20-\xff]+)$/;

### START HACK
if (-e $filename && not $filename =~ /Glib|Gtk2|Gnome|Pango|Cairo/) {
$filename .= $member->crc32String; # kludge workaround
}
### END HACK

open $fh, '>', $filename or die $!;
```

## Icon ##

The PAR libs need to be updated to use the Biodiverse icon.
Other solutions using Win32::EXE result in a slew of warnings
when first running the program.

Before building PAR, copy the Biodiverse icon file into the PAR build folders
as $(PAR_PACKER_SRC)\myldr\winres\pp.ico


### Alternate icon approach ###

Adapt this code as needed (from http://www.zewaren.net/site/?q=node/116).
It is for a makefile, but seemed to have no effect when run independently using dmake.
Running each command in sequence did work, though (tweaking as appropriate).


PERL_DIR = C:\strawberry_51613_x64\perl
PAR_PACKER_SRC = C:\strawberry_51613_x64\cpan\build\PAR-Packer-1.018-XUXam8

all:
copy /Y C:\shawn\svn\biodiverse_trunk\bin\Biodiverse_icon.ico $(PAR_PACKER_SRC)\myldr\winres\pp.ico
#copy /Y medias\jambon.rc $(PAR_PACKER_SRC)\myldr\winres\pp.rc
del $(PAR_PACKER_SRC)\myldr\ppresource.coff
cd /D $(PAR_PACKER_SRC)\myldr\ && perl Makefile.PL
cd /D $(PAR_PACKER_SRC)\myldr\ && dmake boot.exe
cd /D $(PAR_PACKER_SRC)\myldr\ && dmake Static.pm
attrib -R $(PERL_DIR)\site\lib\PAR\StrippedPARL\Static.pm
copy /Y $(PAR_PACKER_SRC)\myldr\Static.pm $(PERL_DIR)\site\lib\PAR\StrippedPARL\Static.pm



## Redundant ##

Old info below.

The patches are redundant for current versions, and the build script has been updated to copy relevant files across.


Makefile.PL.patch needs to be applied to PAR-Packer-1.013
This patch doesn't change the behaviour. It is just needed to make it build
under x86_64.
Derived from http://www.nntp.perl.org/group/perl.par/2012/03/msg5310.html
(It has been fixed upstream in PAR-Packer-1.014.)

NOTE: The order is important. PAR-Packer needs to be (re)built/installed
after Heavy.pm has been modified, since it gets embedded in some
binaries.

= The above is only relevant if you are not using the PPMs in ..\ppm\ppm516*

Run "..\etc\pp\build.bat" when you are in the bin directory to generate
BiodiverseGUI.exe.

The following DLLs from Strawberry Perl need
to be distributed with BiodiverseGUI.exe:

libstdc++-6.dll
libexpat-1__.dll

On 32-bit, libgcc_s_sjlj-1.dll, additionally needs to be distributed.

The win_gtk_builds\etc\win(32|64)\c tree also needs to be distributed as
"gtk".
The "include" directory can be omitted.
27 changes: 14 additions & 13 deletions lib/Biodiverse/Indices/Phylogenetic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -630,36 +630,37 @@ sub calc_pe_central_lists {
my $self = shift;
my %args = @_;

my %wt_list = %{$args{PE_WTLIST}}; # need a copy since we will delete from it
my $base_wt_list = $args{PE_WTLIST};
my $c_list = $args{PHYLO_C_LIST}; # those only in nbr set 2
my $a_list = $args{PHYLO_A_LIST};
my $b_list = $args{PHYLO_B_LIST};
my (%local_range_list_c, %global_range_list_c);

my $local_range_list = $args{PE_LOCAL_RANGELIST};
my $global_range_list = $args{PE_RANGELIST};

my %results;

# avoid copies and slices if there are no nodes found only in nbr set 2
if (scalar keys %$c_list) {
# remove the PE component found only in nbr set 2
# (assuming c_list is shorter than a+b, so this will be the faster approach)
delete @wt_list{keys %$c_list};

my (%wt_list, %local_range_list_c, %global_range_list_c);
# Keep any node found in nbr set 1
@wt_list{keys %$a_list} = @{$base_wt_list}{keys %$a_list};
@wt_list{keys %$b_list} = @{$base_wt_list}{keys %$b_list};

my @keepers = keys %wt_list;
@local_range_list_c{@keepers} = @{$local_range_list}{@keepers};
@global_range_list_c{@keepers} = @{$global_range_list}{@keepers};

$results{PEC_WTLIST} = \%wt_list;
$results{PEC_LOCAL_RANGELIST} = \%local_range_list_c;
$results{PEC_RANGELIST} = \%global_range_list_c;
}
else {
%local_range_list_c = %$local_range_list;
%global_range_list_c = %$global_range_list;
$results{PEC_WTLIST} = $base_wt_list;
$results{PEC_LOCAL_RANGELIST} = $local_range_list;
$results{PEC_RANGELIST} = $global_range_list;
}

my %results = (
PEC_WTLIST => \%wt_list,
PEC_LOCAL_RANGELIST => \%local_range_list_c,
PEC_RANGELIST => \%global_range_list_c,
);

return wantarray ? %results : \%results;
}
Expand Down

0 comments on commit c36ae19

Please sign in to comment.