You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/10/26 20:20:44 UTC
[lucy-commits] svn commit: r1189358 -
/incubator/lucy/branches/clownfish_lemon/clownfish/buildlib/Clownfish/Build.pm
Author: marvin
Date: Wed Oct 26 18:20:43 2011
New Revision: 1189358
URL: http://svn.apache.org/viewvc?rev=1189358&view=rev
Log:
Build local copy of lemon.
Up until now, we'd been counting on having lemon installed and available from
the system. Compile a local copy and use that instead.
This commit copies and pastes code out of trunk/perl/buildlib/Lucy/Build.pm.
Modified:
incubator/lucy/branches/clownfish_lemon/clownfish/buildlib/Clownfish/Build.pm
Modified: incubator/lucy/branches/clownfish_lemon/clownfish/buildlib/Clownfish/Build.pm
URL: http://svn.apache.org/viewvc/incubator/lucy/branches/clownfish_lemon/clownfish/buildlib/Clownfish/Build.pm?rev=1189358&r1=1189357&r2=1189358&view=diff
==============================================================================
--- incubator/lucy/branches/clownfish_lemon/clownfish/buildlib/Clownfish/Build.pm (original)
+++ incubator/lucy/branches/clownfish_lemon/clownfish/buildlib/Clownfish/Build.pm Wed Oct 26 18:20:43 2011
@@ -19,10 +19,14 @@ use warnings;
package Clownfish::Build;
use base qw( Module::Build );
-use File::Spec::Functions qw( catfile );
-
-my $PPPORT_H_PATH = catfile(qw( include ppport.h ));
-my $LEMON_EXE_PATH = 'lemon'; # Don't bother compiling lemon for now.
+use File::Spec::Functions qw( catfile updir catdir );
+use Config;
+use Cwd qw( getcwd );
+
+my $base_dir = updir();
+my $PPPORT_H_PATH = catfile(qw( include ppport.h ));
+my $LEMON_DIR = catdir( $base_dir, 'lemon' );
+my $LEMON_EXE_PATH = catfile( $LEMON_DIR, "lemon$Config{_exe}" );
my $CFC_SOURCE_DIR = 'src';
sub extra_ccflags {
@@ -80,6 +84,24 @@ sub new {
);
}
+sub _run_make {
+ my ( $self, %params ) = @_;
+ my @command = @{ $params{args} };
+ my $dir = $params{dir};
+ my $current_directory = getcwd();
+ chdir $dir if $dir;
+ unshift @command, 'CC=' . $self->config('cc');
+ if ( $self->config('cc') =~ /^cl\b/ ) {
+ unshift @command, "-f", "Makefile.MSVC";
+ }
+ elsif ( $^O =~ /mswin/i ) {
+ unshift @command, "-f", "Makefile.MinGW";
+ }
+ unshift @command, "$Config{make}";
+ system(@command) and confess("$Config{make} failed");
+ chdir $current_directory if $dir;
+}
+
# Write ppport.h, which supplies some XS routines not found in older Perls and
# allows us to use more up-to-date XS API while still supporting Perls back to
# 5.8.3.
@@ -96,9 +118,20 @@ sub ACTION_ppport {
}
}
+# Build the Lemon parser generator.
+sub ACTION_lemon {
+ my $self = shift;
+ print "Building the Lemon parser generator...\n\n";
+ $self->_run_make(
+ dir => $LEMON_DIR,
+ args => [],
+ );
+}
+
# Run all .y files through lemon.
sub ACTION_parsers {
my $self = shift;
+ $self->dispatch('lemon');
my $y_files = $self->rscan_dir( $CFC_SOURCE_DIR, qr/\.y$/ );
for my $y_file (@$y_files) {
my $c_file = $y_file;