Alien-SDL2

 view release on metacpan or  search on metacpan

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

      push @{ $cfg->{ld_shared_libs} }, $have_libs->{$_}->[1];
      $shlib_map{$_} = $have_libs->{$_}->[1];
    }
  }

  $self->config_data('config', $cfg);
}

sub can_build_binaries_from_sources {
  # this needs to be overriden in My::Builder::<platform>
  my $self = shift;
  return 0; # no
}

sub build_binaries {
  # this needs to be overriden in My::Builder::<platform>
  my ($self, $build_out, $build_src) = @_;
  die "###ERROR### My::Builder cannot build SDL2 from sources, use rather My::Builder::<platform>";
}

sub get_additional_cflags {
  # this needs to be overriden in My::Builder::<platform>
  my $self = shift;
  return '';
}

sub get_additional_libs {
  # this needs to be overriden in My::Builder::<platform>
  my $self = shift;
  return '';
}

sub get_path {
  # this needs to be overriden in My::Builder::<platform>
  my ( $self, $path ) = @_;
  return $path;
}

sub clean_dir {
  my( $self, $dir ) = @_;
  if (-d $dir) {
    remove_tree($dir);
    make_path($dir);
  }
}

sub escape_path {
  # this needs to be overriden in My::Builder::<platform>
  my( $self, $path ) = @_;
  return $path;
}

sub check_build_done_marker {
  my $self = shift;
  return (-e 'build_done');
}

sub touch_build_done_marker {
  my $self = shift;
  require ExtUtils::Command;
  local @ARGV = ('build_done');
  ExtUtils::Command::touch();
  $self->add_to_cleanup('build_done');
}

sub clean_build_done_marker {
  my $self = shift;
  unlink 'build_done' if (-e 'build_done');
}

sub check_sha1sum {
  my( $self, $file, $sha1sum ) = @_;
  my $sha1 = Digest::SHA->new;
  my $fh;
  open($fh, $file) or die "###ERROR## Cannot check checksum for '$file'\n";
  binmode($fh);
  $sha1->addfile($fh);
  close($fh);
  my $_sha1sum = $sha1->hexdigest;
  warn "###WARN## checksum for file $file is $_sha1sum but we expect $sha1sum\n" if $_sha1sum ne $sha1sum;
  return ($_sha1sum eq $sha1sum) ? 1 : 0
}

# pure perl implementation of patch functionality
sub apply_patch {
  my ($self, $dir_to_be_patched, $patch_file) = @_;
  my ($src, $diff);

  undef local $/;
  open(DAT, $patch_file) or die "###ERROR### Cannot open file: '$patch_file'\n";
  $diff = <DAT>;
  close(DAT);
  $diff =~ s/\r\n/\n/g; #normalise newlines
  $diff =~ s/\ndiff /\nSpLiTmArKeRdiff /g;
  my @patches = split('SpLiTmArKeR', $diff);

  print STDERR "Applying patch file: '$patch_file'\n";
  foreach my $p (@patches) {
    my ($k) = $p =~ /^---\s*([\S]+)/;
    # doing the same like -p1 for 'patch'
    $k =~ s|\\|/|g;
    $k =~ s|^[^/]*/(.*)$|$1|;
    $k = catfile($dir_to_be_patched, $k);
    print STDERR "- gonna patch '$k'\n";

    if (-f $k) {
      open(SRC, "<", $k) or die "###ERROR### Cannot open file: '$k'\n";
      $src  = <SRC>;
      close(SRC);
      $src =~ s/\r\n/\n/g; #normalise newlines
    }
    else {
      $src = "";
    }

    my $out = eval { Text::Patch::patch( $src, $p, { STYLE => "Unified" } ) };
    if ($out) {
      open(OUT, ">", $k) or die "###ERROR### Cannot open file for writing: '$k'\n";
      print(OUT $out);
      close(OUT);
    }

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 0.393 second using v1.00-cache-2.02-grep-82fe00e-cpan-9e6bc14194b )