2013-06-22 16:18:43 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Config;
|
|
|
|
use File::Spec;
|
|
|
|
|
|
|
|
my %prereqs = qw(
|
2014-11-26 22:30:25 +01:00
|
|
|
Devel::CheckLib 0
|
2015-06-13 11:41:55 +02:00
|
|
|
Encode 0
|
|
|
|
Encode::Locale 1.05
|
2013-10-28 11:14:53 +01:00
|
|
|
ExtUtils::MakeMaker 6.80
|
2013-11-19 15:54:00 +01:00
|
|
|
ExtUtils::ParseXS 3.22
|
2013-06-22 16:18:43 +02:00
|
|
|
File::Basename 0
|
|
|
|
File::Spec 0
|
|
|
|
Getopt::Long 0
|
2013-12-28 16:01:27 +01:00
|
|
|
Module::Build::WithXSpp 0.14
|
2013-09-12 11:09:03 +02:00
|
|
|
Moo 1.003001
|
2014-07-26 17:07:43 +02:00
|
|
|
POSIX 0
|
2013-06-22 16:18:43 +02:00
|
|
|
Scalar::Util 0
|
|
|
|
Test::More 0
|
2014-06-13 23:27:52 +02:00
|
|
|
Thread::Semaphore 0
|
2013-06-22 16:18:43 +02:00
|
|
|
IO::Scalar 0
|
2014-12-13 00:01:24 +01:00
|
|
|
threads 1.96
|
2013-06-22 16:18:43 +02:00
|
|
|
Time::HiRes 0
|
2015-06-02 16:10:15 +02:00
|
|
|
Unicode::Normalize 0
|
2011-10-02 11:57:47 +02:00
|
|
|
);
|
2013-06-22 16:18:43 +02:00
|
|
|
my %recommends = qw(
|
|
|
|
Class::XSAccessor 0
|
|
|
|
XML::SAX::ExpatXS 0
|
2015-01-09 14:02:49 +01:00
|
|
|
Test::Harness 0
|
2013-06-23 11:20:03 +02:00
|
|
|
);
|
2013-09-17 21:52:10 +02:00
|
|
|
|
2014-04-10 15:43:31 +02:00
|
|
|
my $sudo = grep { $_ eq '--sudo' } @ARGV;
|
2014-01-11 21:46:22 +01:00
|
|
|
my $gui = grep { $_ eq '--gui' } @ARGV;
|
|
|
|
my $xs_only = grep { $_ eq '--xs' } @ARGV;
|
2013-09-17 21:52:10 +02:00
|
|
|
if ($gui) {
|
2013-07-06 11:37:24 +02:00
|
|
|
%prereqs = qw(
|
2014-10-28 23:39:11 +01:00
|
|
|
Class::Accessor 0
|
2013-08-25 16:10:53 +02:00
|
|
|
Wx 0.9918
|
2015-01-18 16:52:55 +01:00
|
|
|
Socket 2.016
|
2013-07-06 11:37:24 +02:00
|
|
|
);
|
|
|
|
%recommends = qw(
|
2013-11-20 15:37:40 +01:00
|
|
|
Growl::GNTP 0.15
|
2013-07-06 02:44:32 +02:00
|
|
|
Wx::GLCanvas 0
|
2016-11-04 23:23:01 +01:00
|
|
|
OpenGL <0.70
|
2015-01-18 16:52:55 +01:00
|
|
|
LWP::UserAgent 0
|
|
|
|
Net::Bonjour 0
|
2013-07-06 11:37:24 +02:00
|
|
|
);
|
2015-01-04 23:53:59 +01:00
|
|
|
if ($^O eq 'MSWin32') {
|
2015-01-08 22:51:21 +01:00
|
|
|
$recommends{"Win32::TieRegistry"} = 0;
|
2015-02-01 14:07:32 +01:00
|
|
|
|
2015-01-18 16:52:55 +01:00
|
|
|
# we need an up-to-date Win32::API because older aren't thread-safe (GH #2517)
|
|
|
|
$prereqs{'Win32::API'} = 0.79;
|
2015-01-04 23:53:59 +01:00
|
|
|
}
|
2014-01-11 21:46:22 +01:00
|
|
|
} elsif ($xs_only) {
|
|
|
|
%prereqs = %recommends = ();
|
2013-07-06 02:44:32 +02:00
|
|
|
}
|
2013-06-23 11:20:03 +02:00
|
|
|
|
2013-11-10 14:31:51 +01:00
|
|
|
my @missing_prereqs = ();
|
2013-06-24 16:32:03 +02: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 14:32:55 +01:00
|
|
|
push @missing_prereqs, $module if exists $prereqs{$module};
|
2013-06-24 16:32:03 +02:00
|
|
|
print "Missing prerequisite $module $version\n";
|
2013-06-23 11:20:03 +02:00
|
|
|
}
|
2013-06-24 16:32:03 +02: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 11:20:03 +02:00
|
|
|
}
|
2013-06-24 16:39:31 +02: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 11:20:03 +02:00
|
|
|
}
|
2013-06-24 16:39:31 +02:00
|
|
|
if (!$cpanm) {
|
|
|
|
if ($^O =~ /^(?:darwin|linux)$/ && system(qw(which cpanm)) == 0) {
|
|
|
|
$cpanm = 'cpanm';
|
|
|
|
}
|
2013-06-23 11:20:03 +02:00
|
|
|
}
|
2013-06-24 16:39:31 +02:00
|
|
|
die <<'EOF'
|
2013-06-22 16:18:43 +02: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 16:39:31 +02:00
|
|
|
if !$cpanm;
|
2014-04-10 15:43:31 +02:00
|
|
|
my @cpanm_args = ();
|
|
|
|
push @cpanm_args, "--sudo" if $sudo;
|
|
|
|
|
2013-07-06 02:44:32 +02:00
|
|
|
# make sure our cpanm is updated (old ones don't support the ~ syntax)
|
2014-04-10 15:43:31 +02:00
|
|
|
system $cpanm, @cpanm_args, 'App::cpanminus';
|
2013-07-06 02:44:32 +02:00
|
|
|
|
2013-08-24 11:59:51 +02:00
|
|
|
# install the Windows-compatible Math::Libm
|
2013-08-24 12:01:56 +02:00
|
|
|
if ($^O eq 'MSWin32' && !eval "use Math::Libm; 1") {
|
2014-04-10 15:43:31 +02:00
|
|
|
system $cpanm, @cpanm_args, 'https://github.com/alexrj/Math-Libm/tarball/master';
|
2013-08-24 11:59:51 +02:00
|
|
|
}
|
|
|
|
|
2013-06-24 16:39:31 +02:00
|
|
|
my %modules = (%prereqs, %recommends);
|
|
|
|
foreach my $module (sort keys %modules) {
|
|
|
|
my $version = $modules{$module};
|
2014-12-29 01:10:34 +01:00
|
|
|
my @cmd = ($cpanm, @cpanm_args);
|
2015-06-20 15:56:54 +02:00
|
|
|
|
|
|
|
# temporary workaround for upstream bug in test
|
|
|
|
push @cmd, '--notest'
|
|
|
|
if $module =~ /^(?:OpenGL|Math::PlanePath|Test::Harness)$/;
|
|
|
|
|
2014-12-29 01:10:34 +01:00
|
|
|
push @cmd, "$module~$version";
|
2013-11-12 13:35:36 +01:00
|
|
|
if ($module eq 'XML::SAX::ExpatXS' && $^O eq 'MSWin32') {
|
2013-11-19 01:22:31 +01: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 13:35:36 +01:00
|
|
|
}
|
|
|
|
my $res = system @cmd;
|
2013-08-24 12:12:46 +02:00
|
|
|
if ($res != 0) {
|
|
|
|
if (exists $prereqs{$module}) {
|
2013-11-10 14:31:51 +01:00
|
|
|
push @missing_prereqs, $module;
|
2013-08-24 12:12:46 +02:00
|
|
|
} else {
|
|
|
|
printf "Don't worry, this module is optional.\n";
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 21:14:55 +02:00
|
|
|
}
|
2013-07-06 22:00:54 +02:00
|
|
|
|
2013-09-17 21:52:10 +02:00
|
|
|
if (!$gui) {
|
|
|
|
# clean xs directory before reinstalling, to make sure Build is called
|
|
|
|
# with current perl binary
|
|
|
|
if (-e './xs/Build') {
|
|
|
|
if ($^O eq 'MSWin32') {
|
2014-01-11 21:46:22 +01:00
|
|
|
system '.\xs\Build', 'distclean';
|
2013-09-17 21:52:10 +02:00
|
|
|
} else {
|
|
|
|
system './xs/Build', 'distclean';
|
|
|
|
}
|
2013-08-24 11:59:51 +02:00
|
|
|
}
|
2014-05-26 12:50:59 +02:00
|
|
|
my $res = system $cpanm, @cpanm_args, '--reinstall', '--verbose', './xs';
|
2013-11-11 16:40:48 +01:00
|
|
|
if ($res != 0) {
|
|
|
|
die "The XS/C++ code failed to compile, aborting\n";
|
|
|
|
}
|
2013-08-24 11:59:51 +02:00
|
|
|
}
|
2013-06-22 16:18:43 +02:00
|
|
|
}
|
2012-05-17 17:40:12 +03:00
|
|
|
|
2013-11-10 14:31:51 +01:00
|
|
|
if (@missing_prereqs) {
|
|
|
|
printf "The following prerequisites failed to install: %s\n", join(', ', @missing_prereqs);
|
2013-09-16 10:18:42 +02:00
|
|
|
exit 1;
|
2013-11-10 14:31:51 +01:00
|
|
|
} elsif (!$gui) {
|
2013-11-11 10:28:27 +01:00
|
|
|
eval "use App::Prove; 1" or die "Failed to load App::Prove";
|
2013-11-10 14:31:51 +01:00
|
|
|
my $res = App::Prove->new->run ? 0 : 1;
|
|
|
|
if ($res == 0) {
|
2013-09-16 10:18:42 +02: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 14:31:51 +01:00
|
|
|
} else {
|
|
|
|
print "Some tests failed. Please report the failure to the author!\n";
|
2013-09-16 10:18:42 +02:00
|
|
|
}
|
2013-09-19 10:42:49 +02:00
|
|
|
exit $res;
|
2012-05-17 17:40:12 +03:00
|
|
|
}
|
2011-10-02 11:57:47 +02:00
|
|
|
|
2013-06-22 16:18:43 +02:00
|
|
|
__END__
|