The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl

# A copy of perldist that does some strawberry-specific actions

use 5.006;
use strict;
use warnings;
use Pod::Usage;
use Getopt::Long           ();
use URI                    ();
use Perl::Dist::Machine    ();
use Perl::Dist::Strawberry ();

use vars qw{$VERSION};
BEGIN {
	$VERSION = '1.11';
}





#####################################################################
# Handle Options

my $PERL_VERSION = undef;
my $CPAN         = undef;
my $OUTPUT       = undef;
my $FORCE        = undef;
my $result       = Getopt::Long::GetOptions(
	"perl_version=s" => \$PERL_VERSION,
	"cpan=s"         => \$CPAN,
	"output=s"       => \$OUTPUT,
	"force"          => \$FORCE,
);

# Get the distribution class name
my $class = 'Perl::Dist::Strawberry';
unless ( $class->isa('Perl::Dist') ) {
	die "$class is not a Perl::Dist subclass";
}

# Generate options and hand off to the class
my %options = (
	# 5.8.8 may not build properly under
	# a directory with spaces in it.
	temp_dir => 'C:\\tmp',
);
if ( defined $PERL_VERSION ) {
	$options{perl_version} = $PERL_VERSION;
}
if ( defined $CPAN ) {
	$options{cpan} = URI->new( $CPAN );
}
if ( defined $OUTPUT ) {
	$options{output} = $OUTPUT;
}
if ( defined $FORCE ) {
	$options{force} = 1;
}

# Create the machine
my $machine = Perl::Dist::Strawberry->default_machine(
	common => \%options,
);
unless ( $machine ) {
	die("Failed to create default machine");
}

my $start = time;
unless ( $machine->run ) {
	die("Failed to run");
}
my $t = time - $start;
print "Completed full generation run in $t seconds\n";

chdir $machine->output;

exit(0);