2013-06-22 14:18:43 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Config;
|
|
|
|
use File::Spec;
|
|
|
|
|
|
|
|
my %prereqs = qw(
|
|
|
|
Boost::Geometry::Utils 0.15
|
|
|
|
Encode::Locale 0
|
2013-10-28 10:14:53 +00:00
|
|
|
ExtUtils::MakeMaker 6.80
|
2013-06-22 14:18:43 +00:00
|
|
|
File::Basename 0
|
|
|
|
File::Spec 0
|
|
|
|
Getopt::Long 0
|
|
|
|
Math::ConvexHull::MonotoneChain 0.01
|
|
|
|
Math::Geometry::Voronoi 1.3
|
|
|
|
Math::PlanePath 53
|
2013-12-28 15:01:27 +00:00
|
|
|
Module::Build::WithXSpp 0.14
|
2013-09-12 09:09:03 +00:00
|
|
|
Moo 1.003001
|
2013-06-22 14:18:43 +00:00
|
|
|
Scalar::Util 0
|
|
|
|
Storable 0
|
2013-11-10 13:31:51 +00:00
|
|
|
Test::Harness 0
|
2013-06-22 14:18:43 +00:00
|
|
|
Test::More 0
|
|
|
|
IO::Scalar 0
|
|
|
|
Time::HiRes 0
|
2011-10-02 09:57:47 +00:00
|
|
|
);
|
2013-06-22 14:18:43 +00:00
|
|
|
my %recommends = qw(
|
|
|
|
Class::XSAccessor 0
|
|
|
|
Growl::GNTP 0.15
|
|
|
|
XML::SAX::ExpatXS 0
|
2013-06-23 09:20:03 +00:00
|
|
|
);
|
2013-09-17 19:52:10 +00:00
|
|
|
|
|
|
|
my $gui = defined $ARGV[0] && $ARGV[0] eq '--gui';
|
|
|
|
if ($gui) {
|
2013-07-06 09:37:24 +00:00
|
|
|
%prereqs = qw(
|
2013-08-25 14:10:53 +00:00
|
|
|
Wx 0.9918
|
2013-07-06 09:37:24 +00:00
|
|
|
);
|
|
|
|
%recommends = qw(
|
2013-07-06 00:44:32 +00:00
|
|
|
Wx::GLCanvas 0
|
|
|
|
OpenGL 0
|
2013-07-06 09:37:24 +00:00
|
|
|
);
|
2013-07-06 00:44:32 +00:00
|
|
|
}
|
2013-06-23 09:20:03 +00:00
|
|
|
|
2013-11-10 13:31:51 +00:00
|
|
|
my @missing_prereqs = ();
|
2013-06-24 14:32:03 +00:00
|
|
|
if ($ENV{SLIC3R_NO_AUTO}) {
|
|
|
|
foreach my $module (sort keys %prereqs) {
|
|
|
|
my $version = $prereqs{$module};
|
|
|
|
next if eval "use $module $version; 1";
|
2013-11-10 13:32:55 +00:00
|
|
|
push @missing_prereqs, $module if exists $prereqs{$module};
|
2013-06-24 14:32:03 +00:00
|
|
|
print "Missing prerequisite $module $version\n";
|
2013-06-23 09:20:03 +00:00
|
|
|
}
|
2013-06-24 14:32:03 +00:00
|
|
|
foreach my $module (sort keys %recommends) {
|
|
|
|
my $version = $recommends{$module};
|
|
|
|
next if eval "use $module $version; 1";
|
|
|
|
print "Missing optional $module $version\n";
|
2013-06-23 09:20:03 +00:00
|
|
|
}
|
2013-06-24 14:39:31 +00:00
|
|
|
} else {
|
|
|
|
my @try = (
|
|
|
|
$ENV{CPANM} // (),
|
|
|
|
File::Spec->catfile($Config{sitebin}, 'cpanm'),
|
|
|
|
File::Spec->catfile($Config{installscript}, 'cpanm'),
|
|
|
|
);
|
|
|
|
|
|
|
|
my $cpanm;
|
|
|
|
foreach my $path (@try) {
|
|
|
|
if (-e $path) { # don't use -x because it fails on Windows
|
|
|
|
$cpanm = $path;
|
|
|
|
last;
|
|
|
|
}
|
2013-06-23 09:20:03 +00:00
|
|
|
}
|
2013-06-24 14:39:31 +00:00
|
|
|
if (!$cpanm) {
|
|
|
|
if ($^O =~ /^(?:darwin|linux)$/ && system(qw(which cpanm)) == 0) {
|
|
|
|
$cpanm = 'cpanm';
|
|
|
|
}
|
2013-06-23 09:20:03 +00:00
|
|
|
}
|
2013-06-24 14:39:31 +00:00
|
|
|
die <<'EOF'
|
2013-06-22 14:18:43 +00:00
|
|
|
cpanm was not found. Please install it before running this script.
|
|
|
|
|
|
|
|
There are several ways to install cpanm, try one of these:
|
|
|
|
|
|
|
|
apt-get install cpanminus
|
|
|
|
curl -L http://cpanmin.us | perl - --sudo App::cpanminus
|
|
|
|
cpan App::cpanminus
|
|
|
|
|
|
|
|
If it is installed in a non-standard location you can do:
|
|
|
|
|
|
|
|
CPANM=/path/to/cpanm perl Build.PL
|
|
|
|
|
|
|
|
EOF
|
2013-06-24 14:39:31 +00:00
|
|
|
if !$cpanm;
|
|
|
|
|
2013-07-06 00:44:32 +00:00
|
|
|
# make sure our cpanm is updated (old ones don't support the ~ syntax)
|
|
|
|
system $cpanm, 'App::cpanminus';
|
|
|
|
|
2013-08-24 09:59:51 +00:00
|
|
|
# install the Windows-compatible Math::Libm
|
2013-08-24 10:01:56 +00:00
|
|
|
if ($^O eq 'MSWin32' && !eval "use Math::Libm; 1") {
|
2013-08-24 09:59:51 +00:00
|
|
|
system $cpanm, 'https://github.com/alexrj/Math-Libm/tarball/master';
|
|
|
|
}
|
|
|
|
|
2013-06-24 14:39:31 +00:00
|
|
|
my %modules = (%prereqs, %recommends);
|
|
|
|
foreach my $module (sort keys %modules) {
|
|
|
|
my $version = $modules{$module};
|
2013-11-12 12:35:36 +00:00
|
|
|
my @cmd = ($cpanm, "$module~$version");
|
|
|
|
if ($module eq 'XML::SAX::ExpatXS' && $^O eq 'MSWin32') {
|
2013-11-19 00:22:31 +00:00
|
|
|
my $mingw = 'C:\dev\CitrusPerl\mingw64';
|
|
|
|
$mingw = 'C:\dev\CitrusPerl\mingw32' if !-d $mingw;
|
|
|
|
if (!-d $mingw) {
|
|
|
|
print "Could not find the MinGW directory at $mingw; skipping XML::SAX::ExpatXS (only needed for faster parsing of AMF files)\n";
|
|
|
|
} else {
|
|
|
|
push @cmd, sprintf('--configure-args="EXPATLIBPATH=%s\lib EXPATINCPATH=%s\include"', $mingw, $mingw);
|
|
|
|
}
|
2013-11-12 12:35:36 +00:00
|
|
|
}
|
|
|
|
my $res = system @cmd;
|
2013-08-24 10:12:46 +00:00
|
|
|
if ($res != 0) {
|
|
|
|
if (exists $prereqs{$module}) {
|
2013-11-10 13:31:51 +00:00
|
|
|
push @missing_prereqs, $module;
|
2013-08-24 10:12:46 +00:00
|
|
|
} else {
|
|
|
|
printf "Don't worry, this module is optional.\n";
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 19:14:55 +00:00
|
|
|
}
|
2013-07-06 20:00:54 +00:00
|
|
|
|
2013-09-17 19:52:10 +00:00
|
|
|
if (!$gui) {
|
|
|
|
# temporarily require this dev version until this upstream bug
|
|
|
|
# is resolved: https://rt.cpan.org/Ticket/Display.html?id=86367
|
|
|
|
system $cpanm, 'SMUELLER/ExtUtils-ParseXS-3.18_04.tar.gz';
|
|
|
|
|
|
|
|
# clean xs directory before reinstalling, to make sure Build is called
|
|
|
|
# with current perl binary
|
|
|
|
if (-e './xs/Build') {
|
|
|
|
if ($^O eq 'MSWin32') {
|
|
|
|
system 'cd', 'xs';
|
|
|
|
system 'Build', 'distclean';
|
|
|
|
system 'cd', '..';
|
|
|
|
} else {
|
|
|
|
system './xs/Build', 'distclean';
|
|
|
|
}
|
2013-08-24 09:59:51 +00:00
|
|
|
}
|
2013-11-11 15:40:48 +00:00
|
|
|
my $res = system $cpanm, '--reinstall', './xs';
|
|
|
|
if ($res != 0) {
|
|
|
|
die "The XS/C++ code failed to compile, aborting\n";
|
|
|
|
}
|
2013-08-24 09:59:51 +00:00
|
|
|
}
|
2013-06-22 14:18:43 +00:00
|
|
|
}
|
2012-05-17 14:40:12 +00:00
|
|
|
|
2013-11-10 13:31:51 +00:00
|
|
|
if (@missing_prereqs) {
|
|
|
|
printf "The following prerequisites failed to install: %s\n", join(', ', @missing_prereqs);
|
2013-09-16 08:18:42 +00:00
|
|
|
exit 1;
|
2013-11-10 13:31:51 +00:00
|
|
|
} elsif (!$gui) {
|
2013-11-11 09:28:27 +00:00
|
|
|
eval "use App::Prove; 1" or die "Failed to load App::Prove";
|
2013-11-10 13:31:51 +00:00
|
|
|
my $res = App::Prove->new->run ? 0 : 1;
|
|
|
|
if ($res == 0) {
|
2013-09-16 08:18:42 +00:00
|
|
|
print "If you also want to use the GUI you can now run `perl Build.PL --gui` to install the required modules.\n";
|
2013-11-10 13:31:51 +00:00
|
|
|
} else {
|
|
|
|
print "Some tests failed. Please report the failure to the author!\n";
|
2013-09-16 08:18:42 +00:00
|
|
|
}
|
2013-09-19 08:42:49 +00:00
|
|
|
exit $res;
|
2012-05-17 14:40:12 +00:00
|
|
|
}
|
2011-10-02 09:57:47 +00:00
|
|
|
|
2013-06-22 14:18:43 +00:00
|
|
|
__END__
|