Alien-IUP

 view release on metacpan or  search on metacpan

inc/My/Builder.pm  view on Meta::CPAN

      print STDERR "OUTPUT:\n", $output, "\n";
    }
    elsif ($limit>0) {
      print STDERR "OUTPUT: (only last $limit chars)\n", $output, "\n";
    }
  }
  return $success;
}

sub run_output_std {
  my ($self, @cmd) = @_;
  print STDERR "CMD: " . join(' ',@cmd) . "\n";
  my $rv = run3(\@cmd, undef, undef, undef, { return_if_system_error => 1 } );
  my $success = ($rv == 1 && $? == 0) ? 1 : 0;
  print STDERR "- finished successfully\n" if ($success);
  return $success;
}

sub run_stdout2str {
  my ($self, @cmd) = @_;
  my $output;
  my $rv = run3(\@cmd, \undef, \$output, \undef, { return_if_system_error => 1 } );
  $output =~ s/[\r\n]*$//;
  return $output;
}

sub run_bothout2str {
  my ($self, @cmd) = @_;
  my $output;
  my $rv = run3(\@cmd, \undef, \$output, \$output, { return_if_system_error => 1 } );
  $output =~ s/[\r\n]*$//;
  return $output;
}

sub run_custom {
  my ($self, @cmd) = @_;
  my $rv;
  if ($self->notes('build_msgs')) {
    $rv = $self->run_output_std(@cmd);
  }
  else {
    $rv = $self->run_output_on_error($self->notes('build_msgs_limit'), @cmd);
  }
  warn "###WARN### error during run_custom()" unless $rv;
  return $rv;
}

sub find_file {
  my ($self, $dir, $re) = @_;
  my @files;
  $re ||= qr/.*/;
  {
    no warnings 'File::Find'; #hide warning "Can't opendir(...): Permission denied
    find({ wanted => sub { push @files, rel2abs($_) if /$re/ }, follow => 1, no_chdir => 1 , follow_skip => 2}, $dir);
  };
  return @files;
}

sub sort_libs {
  my ($self, @unsorted) = @_;
  my @wanted_order = qw/iupcontrols iup_pplot iup_plot iupcd iupgl iupglcontrols iup_mglplot iupim iupimglib iupole iupweb iuptuio iupwin iupmot iupgtk iup cdgl cdpdf cdwin cdx11 cdgdk cd ftgl freetype6 freetype freetype-6 pdflib im_fftw im_jp2 im_pr...
  my @sorted;
  my %u;

  for (my $i=0; $i<scalar(@unsorted); $i++) {
    $u{$unsorted[$i]} = $i;
  }
  for (@wanted_order) {
    if (defined $u{$_}) {
      push(@sorted, $_);
      $unsorted[$u{$_}] = undef;
    }
  }
  for (@unsorted) {
    push(@sorted, $_) if defined $_;
  }

  return @sorted;
}

sub touchfile {
  my $self = shift;
  my $t    = time;
  foreach my $file (@_) {
    open(FILE,">>$file") || die "Cannot write $file:$!";
    close(FILE);
    utime($t,$t,$file);
  }
}

sub detect_sys_libs {
  die;
};

sub pkg_config {
  my ($self, $pkc, $nul) = @_;
  if ($nul && $pkc && `$pkc --version 2>$nul`) {
    warn "Checking system libraries zlib, freetype2\n";
    (my $syszlib_ver        = `$pkc zlib --modversion 2>$nul`     ) =~ s/\s*$//;
    (my $syszlib_lflags     = `$pkc zlib --libs 2>$nul`           ) =~ s/\s*$//;
    (my $syszlib_cflags     = `$pkc zlib --cflags 2>$nul`         ) =~ s/\s*$//;
    (my $sysfreetype_ver    = `$pkc freetype2 --modversion 2>$nul`) =~ s/\s*$//;
    (my $sysfreetype_lflags = `$pkc freetype2 --libs 2>$nul`      ) =~ s/\s*$//;
    (my $sysfreetype_cflags = `$pkc freetype2 --cflags 2>$nul`    ) =~ s/\s*$//;
    $self->config_data('syszlib_ver',        $syszlib_ver       );
    $self->config_data('syszlib_lflags',     $syszlib_lflags    );
    $self->config_data('syszlib_cflags',     $syszlib_cflags    );
    $self->config_data('sysfreetype_ver',    $sysfreetype_ver   );
    $self->config_data('sysfreetype_lflags', $sysfreetype_lflags);
    $self->config_data('sysfreetype_cflags', $sysfreetype_cflags);
    warn "FOUND: zlib-$syszlib_ver LF=$syszlib_lflags\n"             if $syszlib_lflags;
    warn "FOUND: freetype-$sysfreetype_ver LF=$sysfreetype_lflags\n" if $sysfreetype_lflags;
  }
};

1;



( run in 1.627 second using v1.01-cache-2.11-cpan-2398b32b56e )