[Bps-public-commit] r9860 - in bpsbuilder/BPB: . lib/BPB

sunnavy at bestpractical.com sunnavy at bestpractical.com
Sun Dec 9 10:55:15 EST 2007


Author: sunnavy
Date: Sun Dec  9 10:55:15 2007
New Revision: 9860

Added:
   bpsbuilder/BPB/lib/BPB/Build.pm
Modified:
   bpsbuilder/BPB/   (props changed)
   bpsbuilder/BPB/lib/BPB.pm

Log:
 r25377 at sun-navys-macbook:  sunnavy | 2007-12-09 15:39:46 +0800
 added Build.pm


Modified: bpsbuilder/BPB/lib/BPB.pm
==============================================================================
--- bpsbuilder/BPB/lib/BPB.pm	(original)
+++ bpsbuilder/BPB/lib/BPB.pm	Sun Dec  9 10:55:15 2007
@@ -8,11 +8,12 @@
 
 use base qw/Class::Accessor::Fast/;
 
-__PACKAGE__->mk_accessors(qw/config backend source/);
+__PACKAGE__->mk_accessors(qw/config backend source build/);
 
 use BPB::Config;
 use BPB::Backend;
 use BPB::Source;
+use BPB::Build;
 
 =head2 new
 
@@ -38,11 +39,19 @@
         BPB::Config->new( config => delete $args{config}, name => $args{name} )
     );
     $self->backend(
-        BPB::Backend->new( %{ $self->config->name->{backend} }, name
-        => $args{name} ) );
+        BPB::Backend->new(
+            %{ $self->config->name->{backend} },
+            name => $args{name}
+        )
+    );
     $self->source(
-        BPB::Source->new( %{ $self->config->name->{source}}, source =>
-            $args{source} ) ) if $args{source};
+        BPB::Source->new(
+            %{ $self->config->name->{source} },
+            source => $args{source}
+        )
+    ) if $args{source};
+
+    $self->build( BPB::Build->new( %{ $self->config->name->{build} } ) );
 
     return $self;
 }

Added: bpsbuilder/BPB/lib/BPB/Build.pm
==============================================================================
--- (empty file)
+++ bpsbuilder/BPB/lib/BPB/Build.pm	Sun Dec  9 10:55:15 2007
@@ -0,0 +1,126 @@
+package BPB::Build;
+
+use warnings;
+use strict;
+use Carp;
+
+use base qw/Class::Accessor::Fast/;
+
+__PACKAGE__->mk_accessors(qw/install_directory perl build_directory skip_test/);
+
+use File::Spec;
+
+use Data::Dumper;
+
+sub new {
+    my $class = shift;
+    my $self  = {@_};
+    bless $self, $class;
+}
+
+sub run {
+    my $self = shift;
+    my %args = @_;
+
+    for ( keys %args ) {
+        $self->$_( $args{$_} ) if $args{$_};
+    }
+
+    croak 'need build_directory option' unless $self->build_directory;
+
+    mkdir $self->install_directory unless -e $self->install_directory;
+
+    chdir $self->build_directory;
+
+    # first, install deps, then install main
+    my $order =
+      BPB::Config::LoadFile( File::Spec->catfile( 'bpb', 'order.yml' ) );
+
+    for (@$order) {
+        s/::/-/g;
+        $self->_install( File::Spec->catfile( 'deps', $_ ) );
+        chdir $self->build_directory;
+    }
+
+    $self->_install('main');
+}
+
+sub _install {
+    my $self = shift;
+    my $dir  = shift;
+    chdir $dir;
+
+    my @commands;
+    if ( -f 'Build.PL' ) {
+        push @commands,
+          $self->perl . " Build.PL --install_base=" . $self->install_directory;
+        unless ( $self->skip_test ) {
+            push @commands, "./Build test";
+        }
+        push @commands, "./Build install";
+    }
+    elsif ( -f 'Makefile.PL' ) {
+        push @commands,
+          $self->perl . " Makefile.PL INSTALL_BASE=" . $self->install_directory;
+        unless ( $self->skip_test ) {
+            push @commands, 'make test';
+        }
+
+        push @commands, "make install";
+    }
+    else {
+        warn "I have no idea how to build this distribution";
+    }
+
+    $self->_run($_) for @commands;
+}
+
+sub _run {
+    my $self = shift;
+    my $cmd  = shift;
+    system($cmd);
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+BPB::Build - 
+
+=head1 DESCRIPTION
+
+
+
+=head1 INTERFACE
+
+
+
+=head1 DEPENDENCIES
+
+
+None.
+
+
+=head1 INCOMPATIBILITIES
+
+None reported.
+
+
+=head1 BUGS AND LIMITATIONS
+
+No bugs have been reported.
+
+=head1 AUTHOR
+
+sunnavy  C<< <sunnavy at bestpractical.com> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright 2007 Best Practical Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+



More information about the Bps-public-commit mailing list