Alien-TinyCCx

 view release on metacpan or  search on metacpan

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

sub ACTION_devclean {
	my $self = shift;
	reset_src;
	$self->ACTION_clean;
}

sub ACTION_devrealclean {
	my $self = shift;
	reset_src;
	$self->ACTION_realclean;
}

# This one's an author action, so I assume they have git and have properly
# configured.
sub ACTION_dist {
	my $self = shift;
	reset_src;
	$self->SUPER::ACTION_dist;
}

# This one's an author action, so I assume they have git and have properly
# configured.
sub ACTION_distdir {
	my $self = shift;
	reset_src;
	$self->SUPER::ACTION_distdir;
}

# This one's an author action, so I assume they have git and have properly
# configured.
sub ACTION_disttest {
	my $self = shift;
	reset_src;
	$self->SUPER::ACTION_disttest;
}

sub apply_patches {
	my ($filename, @patches) = @_;
	
	# make the file read-write (and executable, but that doesn't matter)
	chmod 0700, $filename;
	
	open my $in_fh, '<', $filename
		or die "Unable to open $filename for patching!";
	open my $out_fh, '>', "$filename.new"
		or die "Unable to open $filename.new for patching!";
	LINE: while (my $line = <$in_fh>) {
		# Apply each basic test regex, and call the function if it matches
		for (my $i = 0; $i < @patches; $i += 2) {
			if ($line =~ $patches[$i]) {
				my $next_line = $patches[$i+1]->($in_fh, $out_fh, $line);
				next LINE if $next_line;
			}
		}
		print $out_fh $line;
	}
	
	close $in_fh;
	close $out_fh;
	unlink $filename;
	rename "$filename.new" => $filename;
	
	# make sure it's executable; we may be patching ./configure
	chmod 0700, $filename;
}

1;



( run in 0.913 second using v1.01-cache-2.11-cpan-df04353d9ac )