Compile core C files for Perl build using make

Create a static library of the core C code using the generated Makefile
and link the result with the compiled XS code.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/2fdf4292
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/2fdf4292
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/2fdf4292

Branch: refs/heads/perl_build_with_make
Commit: 2fdf429219d2a4a7a542d73a9f25b7ded3b37e68
Parents: 0df0a4f
Author: Nick Wellnhofer <[email protected]>
Authored: Sat Nov 8 18:47:33 2014 +0100
Committer: Nick Wellnhofer <[email protected]>
Committed: Sat Nov 8 19:51:56 2014 +0100

----------------------------------------------------------------------
 perl/.gitignore             |  4 ++-
 perl/Build.PL               | 19 ++--------
 perl/buildlib/Lucy/Build.pm | 77 +++-------------------------------------
 3 files changed, 9 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/2fdf4292/perl/.gitignore
----------------------------------------------------------------------
diff --git a/perl/.gitignore b/perl/.gitignore
index bcd7739..ee543fb 100644
--- a/perl/.gitignore
+++ b/perl/.gitignore
@@ -4,15 +4,17 @@
 /Charmony.pm
 /MYMETA.json
 /MYMETA.yml
+/Makefile
 /_build/
 /autogen/
 /blib/
+/charmonize.c
 /charmonizer
 /charmonizer.exe
-/charmonize.c
 /charmony.h
 /lib/Lucy.c
 /lib/Lucy.xs
+/liblucy.*
 /ppport.h
 /typemap
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/2fdf4292/perl/Build.PL
----------------------------------------------------------------------
diff --git a/perl/Build.PL b/perl/Build.PL
index 79f6a31..88bf6b3 100644
--- a/perl/Build.PL
+++ b/perl/Build.PL
@@ -20,15 +20,8 @@ use lib 'buildlib';
 use File::Spec::Functions qw( catdir );
 use Lucy::Build;
 
-my @BASE_PATH        = Lucy::Build->cf_base_path;
-my $MODULES_DIR      = catdir( @BASE_PATH, 'modules' );
-my $SNOWSTEM_SRC_DIR = catdir( $MODULES_DIR, qw( analysis snowstem source ) );
-my $SNOWSTEM_INC_DIR = catdir( $SNOWSTEM_SRC_DIR, 'include' );
-my $SNOWSTOP_SRC_DIR = catdir( $MODULES_DIR, qw( analysis snowstop source ) );
-my $UCD_INC_DIR      = catdir( $MODULES_DIR, qw( unicode ucd ) );
-my $UTF8PROC_SRC_DIR = catdir( $MODULES_DIR, qw( unicode utf8proc ) );
-my $CORE_SOURCE_DIR  = catdir( @BASE_PATH, 'core' );
-my $XS_SOURCE_DIR    = 'xs';
+my @BASE_PATH       = Lucy::Build->cf_base_path;
+my $CORE_SOURCE_DIR = catdir( @BASE_PATH, 'core' );
 
 my @cf_linker_flags = Clownfish::CFC::Perl::Build->cf_linker_flags(
     'Clownfish',
@@ -64,18 +57,10 @@ my $builder = Lucy::Build->new(
     },
     include_dirs => [
         $CORE_SOURCE_DIR,
-        $XS_SOURCE_DIR,
-        $SNOWSTEM_INC_DIR,
-        $UCD_INC_DIR,
-        $UTF8PROC_SRC_DIR,
     ],
     clownfish_params => {
         source => [
             $CORE_SOURCE_DIR,
-            $XS_SOURCE_DIR,
-            $SNOWSTEM_SRC_DIR,
-            $SNOWSTOP_SRC_DIR,
-            $UTF8PROC_SRC_DIR,
         ],
     },
     extra_linker_flags => [ @cf_linker_flags ],

http://git-wip-us.apache.org/repos/asf/lucy/blob/2fdf4292/perl/buildlib/Lucy/Build.pm
----------------------------------------------------------------------
diff --git a/perl/buildlib/Lucy/Build.pm b/perl/buildlib/Lucy/Build.pm
index 10a97d9..eb27d85 100644
--- a/perl/buildlib/Lucy/Build.pm
+++ b/perl/buildlib/Lucy/Build.pm
@@ -32,14 +32,10 @@ use Config;
 use Carp;
 use Cwd qw( getcwd );
 
-my @BASE_PATH = __PACKAGE__->cf_base_path;
-
+my @BASE_PATH         = __PACKAGE__->cf_base_path;
 my $COMMON_SOURCE_DIR = catdir( @BASE_PATH, 'common' );
-my $LEMON_DIR         = catdir( @BASE_PATH, 'lemon' );
-my $LEMON_EXE_PATH = catfile( $LEMON_DIR, "lemon$Config{_exe}" );
-my $CORE_SOURCE_DIR = catdir( @BASE_PATH, 'core' );
-my $LIB_DIR         = 'lib';
-my $IS_CPAN_DIST    = !@BASE_PATH;
+my $LIB_DIR           = 'lib';
+my $IS_CPAN_DIST      = !@BASE_PATH;
 my $CHARMONIZER_C;
 if ($IS_CPAN_DIST) {
     $CHARMONIZER_C = 'charmonizer.c';
@@ -68,6 +64,7 @@ sub new {
         $self->config( optimize => $optimize );
     }
 
+    $self->charmonizer_params( create_makefile => 1 );
     $self->charmonizer_params( charmonizer_c => $CHARMONIZER_C );
 
     $self->clownfish_params( autogen_header => $self->autogen_header );
@@ -75,34 +72,6 @@ sub new {
     return $self;
 }
 
-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;
-}
-
-# 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 => [],
-    );
-}
-
 sub ACTION_copy_clownfish_includes {
     my $self = shift;
 
@@ -191,43 +160,6 @@ sub ACTION_test_valgrind {
     }
 }
 
-# Run all .y files through lemon.
-sub ACTION_parsers {
-    my $self = shift;
-    $self->depends_on('lemon');
-    my $y_files = $self->rscan_dir( $CORE_SOURCE_DIR, qr/\.y$/ );
-    for my $y_file (@$y_files) {
-        my $c_file = $y_file;
-        my $h_file = $y_file;
-        $c_file =~ s/\.y$/.c/ or die "no match";
-        $h_file =~ s/\.y$/.h/ or die "no match";
-        next if $self->up_to_date( $y_file, [ $c_file, $h_file ] );
-        $self->add_to_cleanup( $c_file, $h_file );
-        system( $LEMON_EXE_PATH, '-q', $y_file ) and die "lemon failed";
-    }
-}
-
-sub ACTION_compile_custom_xs {
-    my $self = shift;
-
-    $self->depends_on(qw( parsers charmony ));
-
-    # Add extra compiler flags from Charmonizer.
-    my $charm_cflags = $self->charmony('EXTRA_CFLAGS');
-    if ($charm_cflags) {
-        my $cf_cflags = $self->clownfish_params('cflags');
-        if ($cf_cflags) {
-            $cf_cflags .= " $charm_cflags";
-        }
-        else {
-            $cf_cflags = $charm_cflags;
-        }
-        $self->clownfish_params( cflags => $cf_cflags );
-    }
-
-    $self->SUPER::ACTION_compile_custom_xs;
-}
-
 sub autogen_header {
     my $self = shift;
     return <<"END_AUTOGEN";
@@ -389,7 +321,6 @@ sub ACTION_semiclean {
 
 sub ACTION_clean {
     my $self = shift;
-    $self->_run_make( dir => $LEMON_DIR, args => ['clean'] );
     $self->SUPER::ACTION_clean;
 }
 

Reply via email to