Build.PL 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. use Config;
  5. use File::Spec;
  6. my %prereqs = qw(
  7. Boost::Geometry::Utils 0.15
  8. Encode::Locale 0
  9. File::Basename 0
  10. File::Spec 0
  11. Getopt::Long 0
  12. Math::Clipper 1.22
  13. Math::ConvexHull::MonotoneChain 0.01
  14. Math::Geometry::Voronoi 1.3
  15. Math::PlanePath 53
  16. Moo 0.091009
  17. Scalar::Util 0
  18. Storable 0
  19. Test::More 0
  20. IO::Scalar 0
  21. Time::HiRes 0
  22. );
  23. my %recommends = qw(
  24. Class::XSAccessor 0
  25. Growl::GNTP 0.15
  26. XML::SAX::ExpatXS 0
  27. );
  28. if (defined $ARGV[0] && $ARGV[0] eq '--gui') {
  29. %prereqs = qw(
  30. Wx 0.9901
  31. );
  32. %recommends = qw(
  33. Wx::GLCanvas 0
  34. OpenGL 0
  35. );
  36. }
  37. my $missing_prereqs = 0;
  38. if ($ENV{SLIC3R_NO_AUTO}) {
  39. foreach my $module (sort keys %prereqs) {
  40. my $version = $prereqs{$module};
  41. next if eval "use $module $version; 1";
  42. $missing_prereqs = 1 if exists $prereqs{$module};
  43. print "Missing prerequisite $module $version\n";
  44. }
  45. foreach my $module (sort keys %recommends) {
  46. my $version = $recommends{$module};
  47. next if eval "use $module $version; 1";
  48. print "Missing optional $module $version\n";
  49. }
  50. } else {
  51. my @try = (
  52. $ENV{CPANM} // (),
  53. File::Spec->catfile($Config{sitebin}, 'cpanm'),
  54. File::Spec->catfile($Config{installscript}, 'cpanm'),
  55. );
  56. my $cpanm;
  57. foreach my $path (@try) {
  58. if (-e $path) { # don't use -x because it fails on Windows
  59. $cpanm = $path;
  60. last;
  61. }
  62. }
  63. if (!$cpanm) {
  64. if ($^O =~ /^(?:darwin|linux)$/ && system(qw(which cpanm)) == 0) {
  65. $cpanm = 'cpanm';
  66. }
  67. }
  68. die <<'EOF'
  69. cpanm was not found. Please install it before running this script.
  70. There are several ways to install cpanm, try one of these:
  71. apt-get install cpanminus
  72. curl -L http://cpanmin.us | perl - --sudo App::cpanminus
  73. cpan App::cpanminus
  74. If it is installed in a non-standard location you can do:
  75. CPANM=/path/to/cpanm perl Build.PL
  76. EOF
  77. if !$cpanm;
  78. # make sure our cpanm is updated (old ones don't support the ~ syntax)
  79. system $cpanm, 'App::cpanminus';
  80. my %modules = (%prereqs, %recommends);
  81. foreach my $module (sort keys %modules) {
  82. my $version = $modules{$module};
  83. my $res = system $cpanm, "$module~$version";
  84. $missing_prereqs = 1 if $res != 0 && exists $prereqs{$module};
  85. }
  86. # temporarily require this dev version until this upstream bug
  87. # is resolved: https://rt.cpan.org/Ticket/Display.html?id=86367
  88. system $cpanm, 'SMUELLER/ExtUtils-ParseXS-3.18_04.tar.gz';
  89. system $cpanm, '--reinstall', './xs';
  90. }
  91. if (eval "use App::Prove; 1" && !$missing_prereqs) {
  92. App::Prove->new->run;
  93. }
  94. exit 1 if $missing_prereqs;
  95. __END__