makepp

 view release on metacpan or  search on metacpan

Mpp/CommandParser/Gcc.pm  view on Meta::CPAN

our @ISA = 'Mpp::CommandParser';

use Mpp::Text;
use Mpp::File;

*factory = \&Mpp::Subs::p_gcc_compilation;

sub new {
  my $self = &Mpp::CommandParser::new;
  require Mpp::Scanner::C;
  $self->{SCANNER} = new Mpp::Scanner::C($self->rule, $self->dir);
  $self;
}

sub new_no_gcc {
  my $self = &new;
  undef $self->{xNO_GCC};
  $self;
}

sub set_default_signature_method {
  my( $self, $leave_comments ) = @_;
  $self->rule->set_signature_class( $leave_comments ? 'md5' : 'C', 1 );
}

# The subclass can override these. Don't start doing any actual scanning here,
# because the signature method isn't necessarily set yet.
*parse_opt = $Mpp::Text::N[0]; # Ignore unknown option.
sub parse_arg {
  #my( undef, $arg, undef, $files ) = @_;

  push @{$_[3]}, $_[1]
    if is_cpp_source_name $_[1];
}


my( $no_link, $leave_comments, $nostdinc, $static );


my %opt =
  (c => \$no_link,
   E => \$no_link,
   S => \$no_link,
   C => \$leave_comments,
   nostdinc => \$nostdinc,
   static => \$static);

my %info_string = (user => 'INCLUDES',
		   sys => 'SYSTEM_INCLUDES',
		   lib => 'LIBS');
my @static_suffix_list = qw(.a);
my @suffix_list = qw(.la .so .sa .a .sl);
sub tags {
  my $scanner = $_[0]{SCANNER};
  $scanner->should_find( 'user' );
  $scanner->info_string( \%info_string );
  $scanner->add_include_suffix_list( lib => $_[1] == 1 ? \@static_suffix_list : \@suffix_list )
    if $_[1];
}
sub xparse_command {
  my( $self, $command, $setenv ) = @_;

  my $dir = $self->dir;
  my $scanner = $self->{SCANNER};
  my $conditional = $scanner->{CONDITIONAL};

  my @prefiles;
  my @files;
  my $idash; # saw -I-
  my @incdirs;
  my @idirafter;
  my $iprefix = '';
  my @libs;
  my @obj_files;
  my @cpp_opts;
  my $file_regexp = $self->input_filename_regexp($command->[0]);
  my $real_lib;

  $no_link = $leave_comments = $nostdinc = $static = 0;
  my( $cmd, @words ) = @$command;
  $cmd =~ s@.*/@@ || Mpp::is_windows > 1 && $cmd =~ s/.*\\//;
  my $icc = $cmd =~ /^ic[cl](?:\.exe)?$/;
  local $_;
  while( defined( $_ = shift @words )) {
    if( !s/^-// ) {
      if( /\.(?:[ls]?[oa]|s(?:l|o\.[\d.]+)|obj|dll)$/ ) { # object file?
	if( /[\*\?\[]/ ) {		# wildcard?
 # TBD: Why is this disabled?  Probably because zglob finds more than the Shell will.  Need chdir & glob.
 if(0) {
	  require Mpp::Glob;
	  push @obj_files,
	    Mpp::Glob::zglob($_, $self->dirinfo);
 }
	} else {
	  push @obj_files, $_;
	}
      } elsif($file_regexp && /$file_regexp/) {
        push @files, $_;
      } else {
	$self->parse_arg( $_, \@words, \@files );
      }
    } elsif( $opt{$_} ) {
      ${$opt{$_}} = 1;
    } elsif( s/^I// ) {
      $_ ||= shift @words;
      if( $_ eq '-' ) {
	$idash = 1;
	$scanner->add_include_dir( user => $_ )
	  for splice @incdirs;
      } else {
	push @incdirs, $_;
      }
    } elsif( s/^i(?:quot(e)|syste(m)|dirafte(r)|(nclude|macros)|prefi(x)|withprefix(before)?)// ) {
      my $val = $_ || shift @words; # yes, value can be glued :-{
      if( $1 || $2 ) {		# -iquote, -isystem
	$scanner->add_include_dir( $2 ? 'sys' : 'user', $val );
      } elsif( $3 ) { 		# -idirafter
	push @idirafter, $val;
      } elsif( $4 ) {		# -include or -imacros
	push @prefiles, $val;
      } elsif( $5 ) { 		# -iprefix



( run in 0.698 second using v1.01-cache-2.11-cpan-39bf76dae61 )