Changeset 10388

Show
Ignore:
Timestamp:
01/30/10 18:47:42 (7 months ago)
Author:
adamk
Message:

Adding the first skeleton for build system differentiation

Location:
trunk/Padre/lib/Padre/Project
Files:
5 added
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Project/Perl.pm

    r10203 r10388  
    66use strict; 
    77use warnings; 
    8 use Padre::Project (); 
     8use Padre::Project             (); 
     9use Padre::Project::Perl::MI   (); 
     10use Padre::Project::Perl::MB   (); 
     11use Padre::Project::Perl::DZ   (); 
     12use Padre::Project::Perl::EUMM (); 
    913 
    1014our $VERSION = '0.55'; 
     
    1620        # Check the file argument 
    1721        my $focus_file = shift; 
    18         unless ( -f $focus_file ) { 
    19                 return; 
    20         } 
     22        return unless -f $focus_file; 
    2123 
    2224        # Search upwards from the file to find the project root 
     
    2426        my @d = File::Spec->splitdir($d); 
    2527        pop @d if $d[-1] eq ''; 
    26         my $dirs = List::Util::first { 
    27                        -f File::Spec->catpath( $v, $_, 'Makefile.PL' ) 
    28                         or -f File::Spec->catpath( $v, $_, 'Build.PL' ) 
    29                         or -f File::Spec->catpath( $v, $_, 'dist.ini' ) 
    30                         or -f File::Spec->catpath( $v, $_, 'padre.yml' ); 
    31         } 
    32         map { File::Spec->catdir( @d[ 0 .. $_ ] ) } reverse( 0 .. $#d ); 
    33         unless ( defined $dirs ) { 
     28        foreach ( reverse 0 .. $#d ) { 
     29                my $dir = File::Spec->catdir( @d[ 0 .. $_ ] ); 
     30 
     31                # Check for Dist::Zilla support 
     32                my $dist_ini = File::Spec->catpath( $v, $dir, 'dist.ini' ); 
     33                if ( -f $dist_ini ) { 
     34                        return Padre::Project::Perl::DZ->new( 
     35                                root     => File::Spec->catpath( $v, $dir ), 
     36                                dist_ini => $dist_ini, 
     37                        ); 
     38                } 
     39 
     40                # Check for Module::Build support 
     41                my $build_pl = File::Spec->catpath( $v, $dir, 'Build.PL' ); 
     42                if ( -f $build_pl ) { 
     43                        return Padre::Project::Perl::MB->new( 
     44                                root     => File::Spec->catpath( $v, $dir ), 
     45                                build_pl => $build_pl, 
     46                        ); 
     47                } 
     48 
     49                # Check for ExtUtils::MakeMaker and Module::Install support 
     50                my $makefile_pl = File::Spec->catpath( $v, $dir, 'Makefile.PL' ); 
     51                if ( -f $makefile_pl ) { 
     52                        # Differentiate between Module::Install and ExtUtils::MakeMaker 
     53                        return Padre::Project::Perl::EUMM->new( 
     54                                root        => File::Spec->catpath( $v, $dir ), 
     55                                makefile_pl => $makefile_pl, 
     56                        ); 
     57                } 
     58 
     59                # Fall back to looking for null projects 
     60                my $padre_yml = File::Spec->catpath( $v, $dir, 'padre.yml' ); 
     61                if ( -f $padre_yml ) { 
     62                        return Padre::Project::Perl->new( 
     63                                root => File::Spec->catpath( $v, $dir ), 
     64                                padre_yml => $padre_yml, 
     65                        ); 
     66                } 
     67 
    3468                return; 
    3569        } 
    36  
    37         # Hand off to the regular constructor 
    38         return $class->new( 
    39                 root => File::Spec->catpath( $v, $dirs ), 
    40         ); 
    4170} 
    4271