makepp

 view release on metacpan or  search on metacpan

Mpp/CommandParser.pm  view on Meta::CPAN

  UNIVERSAL::isa($rule, 'Mpp::Rule') or die;
  UNIVERSAL::isa($dir, 'Mpp::File') and die;
  bless {
    RULE => $rule,
    DIR => $dir,
  }, $class;
}

=head2 parse_command

  $parser->parse_command($command, $setenv_hash);

Splits the command into words, prints a log message, and calls xparse_command.

=cut

our $ignore_exe;		# Emergency override.
my %is_builtin;
@is_builtin{qw(
  break cd continue echo exit export false kill let pwd return
  set test true ulimit umask unset wait
  case esac fi for done
)} = ();			# Make these exist
sub parse_command {
  my( $self, $command, $setenv_hash ) = @_;

  Mpp::log PARSE => $command, $self->dirinfo, $self->rule
    if $Mpp::log_level;

  my @cmd_words = Mpp::is_windows < 2 ?
    Mpp::Text::unquote_split_on_whitespace $command :
    map { tr/"//d; $_ } Mpp::Text::split_on_whitespace $command; # Don't unquote \, which is Win dir separator, TODO: \" -> "
  unless( $ignore_exe || UNIVERSAL::isa($self->rule->build_check_method, 'Mpp::BuildCheck::ignore_action') ) {
    $self->add_executable_dependency( $cmd_words[0] )
      unless exists $is_builtin{$cmd_words[0]}
  }
  $self->xparse_command( \@cmd_words, $setenv_hash );
}

=head2 add_executable_dependency

Gets called before xparse_command with the first command word as the
argument.
By default, it adds a dependency on the file given by the word, but only if it
contains no shell metacharacters.  It then adds runtime dependencies, if any,
and calls add_more_executable_dependencies (which the subclass can override)
with the directory name of the executable.

Mpp/CommandParser.pm  view on Meta::CPAN

      $firstword =~ s@^.*/@@ and $suffix_hash->{$firstword}
    };
  }
  my @list = ($list ? @$list : (), $predefs ? @$predefs : ());
  return unless @list;
  return '(' . join('|', map { quotemeta } @list) . ')$';
}

=head2 xparse_command

  $parser->xparse_command($command_array, $setenv_hash);

The derived class should override this to set the default signature method,
to parse the $command_array command
and to add the implicit targets and dependencies to $self->rule.
$setenv_hash is a hashref indicating the command-line environment settings.
(Whether its values have shell variables expanded is not yet guaranteed.)

The current plan is that a new object of this class is created for each
command, but that might change in the future.
If it does, then this method is responsible for clearing previous command
information, such as the include paths.

A TRUE return value indicates that some meaningful scanner was successfully
employed.  An undefined return value is interpreted as a failure.  A failure
forces the rule to propagate failure status, without attempting to build the

Mpp/CommandParser.pm  view on Meta::CPAN

dependency if the file doesn't exist and can't be built.
(For example, an optional configuration file.)
This would be easy to implement, but there aren't any scanners that
would use it right now.

=head1 FUTURE WORK

Dependencies on the environment should also be captured by xparse_command.
I don't know if there is a way to do this at all yet, but in principle it
could be added.
The $setenv_hash parameter can be used to avoid adding dependencies on
variables that are set earlier in the action.
For search paths picked up from the environment, it would be a lot more
efficient to capture dependencies in the form
"rebuild unless file X is picked up from directory Y,"
rather than "rebuild if the path changed."
Also, if we could avoid rebuilding if the file is picked up from a different
location but has the same MD5, then that would be cool.

Perhaps there should be a finfo method that just returns
file_info($_[0], $self->dirinfo).

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

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;

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


#
# This is the main command parser, implementing
# Mpp::CommandParser::xparse_command().  See Mpp/CommandParser.pm for its
# inputs and outputs.
#
my %info_string = (user => 'SWIG_INCLUDES',
		   sys => 'SWIG_SYSTEM_INCLUDES');
my $swig_library_path;
sub xparse_command {
  my( $self, $command, $setenv ) = @_;

  my @input_files;              # The files mentioned on the command line.
  my $output_file;
  my @swig_libs;                # Libraries mentioned with -l.
  my $swig_language = 'tcl';	# The language we're translating into.
  my @includes;
  my @defines;
  my @files;
  $cplusplus = $idash = $importall = $includeall = 0;

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

  return $name if $name =~ m@^/@;
  return "../$name";
}

# This can be modified from the outside for site-specific suffixes:
our @verilog_suffixes = qw(v gv vlib vt bvrl vg vgs vgp sv);

my %info_string = (user => 'VERA_INCLUDES',
		   sys => 'VERA_SYSTEM_INCLUDES');
sub xparse_command {
  my( $self, $command, $setenv ) = @_;

  # Use the MD5 signature checking when we can.
  $self->rule->set_signature_class( 'C.v', 1 );

  my @words=@$command;
  my $dir=$self->dir;
  my $file_regexp = $self->input_filename_regexp(
    $command->[0], [map { ".$_" } @verilog_suffixes]
  );

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

    # Because some relative paths in @c_args are interpreted
    # by VCS as being relative to the csrc subdirectory, we model
    # that by having the scanner think that it's in that dir,
    # but munge the @c_args that *aren't* relative to csrc before
    # we get here.
    Mpp::File::mark_as_directory file_info "csrc", $self->dirinfo;
    require Mpp::CommandParser::Gcc;
    my $c_parser=new_no_gcc Mpp::CommandParser::Gcc(
      $self->rule, $self->dir."/csrc"
    );
    $c_parser->xparse_command([$cmd, @c_args], $setenv)
      or return undef;
  }
  return 1;
}

1;

Mpp/Lexer.pm  view on Meta::CPAN

"	    unless $parser_warnings{$rule->source}++;
      }
    }
  }

  1;
}

=head2 parse_command

	$lexer->parse_command($command, $rule, $dir, $setenv_hash, \$found);

Parse $command as if it is executed in directory $dir (relative to
$rule->build_cwd), and update $rule accordingly.
$setenv_hash is the environmental settings that are set by the rule itself,
with shell variables I<not> expanded.

In this base class, calls find_command_parser to determine which command
parser to use.
If the result is FALSE, then do nothing more.  (This can't
happen for an object of the base class, since we always use a
plain Mpp/CommandParser.)
Otherwise, the resulting object's parse_command method is called, and
we return that method's return value.

pod/makepp_build_cache.pod  view on Meta::CPAN

are:

=over 4

=item *

Set the build cache path in the environment variable MAKEPPFLAGS, like
this (first variant for Korn Shell or bash, second for csh):

    export MAKEPPFLAGS=--build-cache=/path/to/build/cache
    setenv MAKEPPFLAGS --build-cache=/path/to/build/cache

Now every build that you run will always use this build cache, and you
don't need to modify anything else.

=item *

Specify the build cache in your makefiles with a line like this:

    BUILD_CACHE := /path/to/build_cache
    build_cache $(BUILD_CACHE)



( run in 0.696 second using v1.01-cache-2.11-cpan-a1d94b6210f )