lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [2/2] git commit: refs/heads/cfc_charmony - Split off Charmonizer build ACTIONs
Date Fri, 02 Nov 2012 21:24:31 GMT
Split off Charmonizer build ACTIONs

Charmonizer build ACTIONs are split off into
Clownfish::CFC::Perl::Build::Charmonic. Now, the hierarchy of the Build
classes is:

* Module::Build
  * Clownfish::CFC::Perl::Build::Charmonic
    * Clownfish::CFC::Perl::Build
      * Clownfish::Build
      * Lucy::Build

Clownfish::CFC::Perl::Build::Charmonic adds a Module::Build hashref
property named 'charmonizer_params'. For now, its only entry is
'source_dir' which specifies the Charmonizer source directory.


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

Branch: refs/heads/cfc_charmony
Commit: 68bbc8b4fc3557aee3999583c10978a3f49bb44a
Parents: c123ce0
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Fri Nov 2 19:17:12 2012 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Fri Nov 2 21:44:30 2012 +0100

----------------------------------------------------------------------
 .../compiler/perl/lib/Clownfish/CFC/Perl/Build.pm  |    2 +-
 .../perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm |  155 +++++++++++++++
 clownfish/runtime/perl/buildlib/Clownfish/Build.pm |   86 +--------
 perl/buildlib/Lucy/Build.pm                        |   88 +--------
 4 files changed, 161 insertions(+), 170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/68bbc8b4/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
index d53519c..45fb38c 100644
--- a/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
@@ -17,7 +17,7 @@ use strict;
 use warnings;
 
 package Clownfish::CFC::Perl::Build;
-use base qw( Module::Build );
+use base qw( Clownfish::CFC::Perl::Build::Charmonic );
 our $VERSION = '0.01';
 
 use File::Spec::Functions qw( catdir catfile curdir updir abs2rel rel2abs );

http://git-wip-us.apache.org/repos/asf/lucy/blob/68bbc8b4/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm
new file mode 100644
index 0000000..09eeb5b
--- /dev/null
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm
@@ -0,0 +1,155 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+use strict;
+use warnings;
+
+package Clownfish::CFC::Perl::Build::Charmonic;
+
+use base qw( Module::Build );
+
+our $VERSION = '0.003000';
+$VERSION = eval $VERSION;
+
+use Carp;
+use Config;
+use Cwd qw( getcwd );
+use Env qw( @PATH );
+use File::Spec::Functions qw( rel2abs );
+
+BEGIN { unshift @PATH, rel2abs( getcwd() ) }
+
+# Add a custom Module::Build hashref property to pass the following build
+# parameters.
+# source_dir: Charmonizer source directory, required
+if ( $Module::Build::VERSION <= 0.30 ) {
+    __PACKAGE__->add_property( charmonizer_params => {} );
+}
+else {
+    __PACKAGE__->add_property(
+        'charmonizer_params',
+        default => {},
+    );
+}
+
+my $CHARMONIZE_EXE_PATH = "charmonize$Config{_exe}";
+my $CHARMONY_H_PATH     = 'charmony.h';
+my $CHARMONY_PM_PATH    = 'Charmony.pm';
+
+sub _charmonizer_run_make {
+    my ( $self, %params ) = @_;
+    my @command           = @{ $params{args} };
+    my $dir               = $self->charmonizer_params('source_dir');
+    my $cc                = $self->config('cc');
+    my $current_directory = getcwd();
+    chdir $dir;
+    unshift @command, "CC=$cc";
+    if ( $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;
+}
+
+# Build the charmonize executable.
+sub ACTION_build_charmonize {
+    my $self = shift;
+    print "Building $CHARMONIZE_EXE_PATH...\n\n";
+    my $meld_c = rel2abs("charmonize.c");
+    $self->add_to_cleanup($meld_c);
+    $self->add_to_cleanup($CHARMONIZE_EXE_PATH);
+    my $charmonize_main = 'charmonize.c';
+    $self->_charmonizer_run_make(
+        args => [ "meld", "PERL=$^X", "FILES=$charmonize_main", "OUT=$meld_c" ],
+    );
+    if ( !$self->up_to_date( $meld_c, $CHARMONIZE_EXE_PATH ) ) {
+        my $cc = $Config{cc};
+        my $outflag = $cc =~ /cl\b/ ? "/Fe" : "-o ";
+        system("$cc $meld_c $outflag$CHARMONIZE_EXE_PATH")
+            and die "Failed to compile $CHARMONIZE_EXE_PATH";
+    }
+}
+
+# Run the charmonize executable, creating the charmony.h and Charmony.pm
+# files.
+sub ACTION_run_charmonize {
+    my $self = shift;
+    $self->dispatch('build_charmonize');
+    return if $self->up_to_date( $CHARMONIZE_EXE_PATH, [
+        $CHARMONY_H_PATH, $CHARMONY_PM_PATH,
+    ] );
+    print "\nRunning $CHARMONIZE_EXE_PATH...\n\n";
+
+    $self->add_to_cleanup($CHARMONY_H_PATH);
+    $self->add_to_cleanup($CHARMONY_PM_PATH);
+    # Clean up after charmonize if it doesn't succeed on its own.
+    $self->add_to_cleanup("_charm*");
+
+    # Prepare arguments to charmonize.
+    my @command = (
+        $CHARMONIZE_EXE_PATH,
+        '--cc=' . _quotify( $self->config('cc') ),
+        '--enable-c',
+        '--enable-perl',
+        '--',
+        $self->config('ccflags'),
+        @{ $self->extra_compiler_flags },
+    );
+    if ( $ENV{CHARM_VALGRIND} ) {
+        unshift @command, "valgrind", "--leak-check=yes";
+    }
+    print join( " ", @command ), $/;
+
+    system(@command) and die "Failed to run $CHARMONIZE_EXE_PATH: $!";
+}
+
+sub _quotify {
+    my $string = shift;
+    $string =~ s/\\/\\\\/g;
+    $string =~ s/"/\\"/g;
+    return qq|"$string"|;
+}
+
+# Build the charmonizer tests.
+sub ACTION_charmonizer_tests {
+    my $self = shift;
+    $self->dispatch('run_charmonize');
+    print "Building Charmonizer Tests...\n\n";
+    my $flags = join( " ",
+        $self->config('ccflags'),
+        @{ $self->extra_compiler_flags },
+        '-I' . rel2abs( getcwd() ),
+    );
+    $flags =~ s/"/\\"/g;
+    $self->_charmonizer_run_make(
+        args => [ "DEFS=$flags", "tests" ],
+    );
+}
+
+sub ACTION_clean {
+    my $self = shift;
+    $self->_charmonizer_run_make(
+        args => ['clean']
+    );
+    $self->SUPER::ACTION_clean;
+}
+
+1;
+
+__END__

http://git-wip-us.apache.org/repos/asf/lucy/blob/68bbc8b4/clownfish/runtime/perl/buildlib/Clownfish/Build.pm
----------------------------------------------------------------------
diff --git a/clownfish/runtime/perl/buildlib/Clownfish/Build.pm b/clownfish/runtime/perl/buildlib/Clownfish/Build.pm
index bf374d4..0593dff 100644
--- a/clownfish/runtime/perl/buildlib/Clownfish/Build.pm
+++ b/clownfish/runtime/perl/buildlib/Clownfish/Build.pm
@@ -35,19 +35,13 @@ use File::Spec::Functions qw( catdir catfile updir rel2abs );
 use File::Path qw( rmtree );
 use File::Copy qw( move );
 use Config;
-use Env qw( @PATH );
 use Carp;
 use Cwd qw( getcwd );
 
-BEGIN { unshift @PATH, rel2abs( getcwd() ) }
-
 my @BASE_PATH = __PACKAGE__->cf_base_path;
 
 my $CHARMONIZER_ORIG_DIR
     = rel2abs( catdir( @BASE_PATH, updir(), updir(), 'charmonizer' ) );
-my $CHARMONIZE_EXE_PATH  = "charmonize$Config{_exe}";
-my $CHARMONY_H_PATH      = 'charmony.h';
-my $CHARMONY_PM_PATH     = 'Charmony.pm';
 my $CORE_SOURCE_DIR = catdir( @BASE_PATH, 'core' );
 my $CFC_DIR = catdir( @BASE_PATH, updir(), 'compiler', 'perl' );
 my $CFC_BUILD  = catfile( $CFC_DIR, 'Build' );
@@ -78,6 +72,8 @@ sub new {
     }
     $self->extra_compiler_flags(@$extra_ccflags);
 
+    $self->charmonizer_params( source_dir => $CHARMONIZER_ORIG_DIR );
+
     $self->clownfish_params( autogen_header => $self->autogen_header );
 
     return $self;
@@ -101,83 +97,6 @@ sub _run_make {
     chdir $current_directory if $dir;
 }
 
-# Build the charmonize executable.
-sub ACTION_build_charmonize {
-    my $self = shift;
-    print "Building $CHARMONIZE_EXE_PATH...\n\n";
-    my $meld_c = rel2abs("charmonize.c");
-    $self->add_to_cleanup($meld_c);
-    $self->add_to_cleanup($CHARMONIZE_EXE_PATH);
-    my $charmonize_main = catfile( $CHARMONIZER_ORIG_DIR, 'charmonize.c' );
-    $self->_run_make(
-        dir  => $CHARMONIZER_ORIG_DIR,
-        args => [ "meld", "PERL=$^X", "FILES=$charmonize_main", "OUT=$meld_c" ],
-    );
-    if ( !$self->up_to_date( $meld_c, $CHARMONIZE_EXE_PATH ) ) {
-        my $cc = $Config{cc};
-        my $outflag = $cc =~ /cl\b/ ? "/Fe" : "-o ";
-        system("$cc $meld_c $outflag$CHARMONIZE_EXE_PATH")
-            and die "Failed to compile $CHARMONIZE_EXE_PATH";
-    }
-}
-
-# Run the charmonize executable, creating the charmony.h and Charmony.pm
-# files.
-sub ACTION_run_charmonize {
-    my $self = shift;
-    $self->dispatch('build_charmonize');
-    return if $self->up_to_date( $CHARMONIZE_EXE_PATH, [
-        $CHARMONY_H_PATH, $CHARMONY_PM_PATH,
-    ] );
-    print "\nRunning $CHARMONIZE_EXE_PATH...\n\n";
-
-    $self->add_to_cleanup($CHARMONY_H_PATH);
-    $self->add_to_cleanup($CHARMONY_PM_PATH);
-    # Clean up after charmonize if it doesn't succeed on its own.
-    $self->add_to_cleanup("_charm*");
-
-    # Prepare arguments to charmonize.
-    my @command = (
-        $CHARMONIZE_EXE_PATH,
-        '--cc=' . _quotify( $self->config('cc') ),
-        '--enable-c',
-        '--enable-perl',
-        '--',
-        $self->config('ccflags'),
-        @{ $self->extra_compiler_flags },
-    );
-    if ( $ENV{CHARM_VALGRIND} ) {
-        unshift @command, "valgrind", "--leak-check=yes";
-    }
-    print join( " ", @command ), $/;
-
-    system(@command) and die "Failed to run $CHARMONIZE_EXE_PATH: $!";
-}
-
-sub _quotify {
-    my $string = shift;
-    $string =~ s/\\/\\\\/g;
-    $string =~ s/"/\\"/g;
-    return qq|"$string"|;
-}
-
-# Build the charmonizer tests.
-sub ACTION_charmonizer_tests {
-    my $self = shift;
-    $self->dispatch('run_charmonize');
-    print "Building Charmonizer Tests...\n\n";
-    my $flags = join( " ",
-        $self->config('ccflags'),
-        @{ $self->extra_compiler_flags },
-        '-I' . rel2abs( getcwd() ),
-    );
-    $flags =~ s/"/\\"/g;
-    $self->_run_make(
-        dir  => $CHARMONIZER_ORIG_DIR,
-        args => [ "DEFS=$flags", "tests" ],
-    );
-}
-
 sub ACTION_cfc {
     my $self    = shift;
     my $old_dir = getcwd();
@@ -366,7 +285,6 @@ sub _clean_prereq_builds {
             and die "Clownfish clean failed";
         chdir $old_dir;
     }
-    $self->_run_make( dir => $CHARMONIZER_ORIG_DIR, args => ['clean'] );
 }
 
 sub ACTION_clean {

http://git-wip-us.apache.org/repos/asf/lucy/blob/68bbc8b4/perl/buildlib/Lucy/Build.pm
----------------------------------------------------------------------
diff --git a/perl/buildlib/Lucy/Build.pm b/perl/buildlib/Lucy/Build.pm
index abcdae2..7a674cd 100644
--- a/perl/buildlib/Lucy/Build.pm
+++ b/perl/buildlib/Lucy/Build.pm
@@ -35,22 +35,16 @@ no lib 'clownfish/compiler/perl/lib';
 our $VERSION = '0.003000';
 $VERSION = eval $VERSION;
 
-use File::Spec::Functions qw( catdir catfile updir rel2abs );
+use File::Spec::Functions qw( catdir catfile );
 use File::Path qw( rmtree );
 use File::Copy qw( move );
 use Config;
-use Env qw( @PATH );
 use Carp;
 use Cwd qw( getcwd );
 
-BEGIN { unshift @PATH, rel2abs( getcwd() ) }
-
 my @BASE_PATH = __PACKAGE__->cf_base_path;
 
 my $CHARMONIZER_ORIG_DIR = catdir( @BASE_PATH, 'charmonizer' );
-my $CHARMONIZE_EXE_PATH  = "charmonize$Config{_exe}";
-my $CHARMONY_H_PATH      = 'charmony.h';
-my $CHARMONY_PM_PATH     = 'Charmony.pm';
 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' );
@@ -83,6 +77,8 @@ sub new {
     }
     $self->extra_compiler_flags(@$extra_ccflags);
 
+    $self->charmonizer_params( source_dir => $CHARMONIZER_ORIG_DIR );
+
     $self->clownfish_params( autogen_header => $self->autogen_header );
 
     return $self;
@@ -106,83 +102,6 @@ sub _run_make {
     chdir $current_directory if $dir;
 }
 
-# Build the charmonize executable.
-sub ACTION_build_charmonize {
-    my $self = shift;
-    print "Building $CHARMONIZE_EXE_PATH...\n\n";
-    my $meld_c = rel2abs("charmonize.c");
-    $self->add_to_cleanup($meld_c);
-    $self->add_to_cleanup($CHARMONIZE_EXE_PATH);
-    my $charmonize_main = catfile( $CHARMONIZER_ORIG_DIR, 'charmonize.c' );
-    $self->_run_make(
-        dir  => $CHARMONIZER_ORIG_DIR,
-        args => [ "meld", "PERL=$^X", "FILES=$charmonize_main", "OUT=$meld_c" ],
-    );
-    if ( !$self->up_to_date( $meld_c, $CHARMONIZE_EXE_PATH ) ) {
-        my $cc = $Config{cc};
-        my $outflag = $cc =~ /cl\b/ ? "/Fe" : "-o ";
-        system("$cc $meld_c $outflag$CHARMONIZE_EXE_PATH")
-            and die "Failed to compile $CHARMONIZE_EXE_PATH";
-    }
-}
-
-# Run the charmonize executable, creating the charmony.h and Charmony.pm
-# files.
-sub ACTION_run_charmonize {
-    my $self = shift;
-    $self->dispatch('build_charmonize');
-    return if $self->up_to_date( $CHARMONIZE_EXE_PATH, [
-        $CHARMONY_H_PATH, $CHARMONY_PM_PATH,
-    ] );
-    print "\nRunning $CHARMONIZE_EXE_PATH...\n\n";
-
-    $self->add_to_cleanup($CHARMONY_H_PATH);
-    $self->add_to_cleanup($CHARMONY_PM_PATH);
-    # Clean up after charmonize if it doesn't succeed on its own.
-    $self->add_to_cleanup("_charm*");
-
-    # Prepare arguments to charmonize.
-    my @command = (
-        $CHARMONIZE_EXE_PATH,
-        '--cc=' . _quotify( $self->config('cc') ),
-        '--enable-c',
-        '--enable-perl',
-        '--',
-        $self->config('ccflags'),
-        @{ $self->extra_compiler_flags },
-    );
-    if ( $ENV{CHARM_VALGRIND} ) {
-        unshift @command, "valgrind", "--leak-check=yes";
-    }
-    print join( " ", @command ), $/;
-
-    system(@command) and die "Failed to run $CHARMONIZE_EXE_PATH: $!";
-}
-
-sub _quotify {
-    my $string = shift;
-    $string =~ s/\\/\\\\/g;
-    $string =~ s/"/\\"/g;
-    return qq|"$string"|;
-}
-
-# Build the charmonizer tests.
-sub ACTION_charmonizer_tests {
-    my $self = shift;
-    $self->dispatch('run_charmonize');
-    print "Building Charmonizer Tests...\n\n";
-    my $flags = join( " ",
-        $self->config('ccflags'),
-        @{ $self->extra_compiler_flags },
-        '-I' . rel2abs( getcwd() ),
-    );
-    $flags =~ s/"/\\"/g;
-    $self->_run_make(
-        dir  => $CHARMONIZER_ORIG_DIR,
-        args => [ "DEFS=$flags", "tests" ],
-    );
-}
-
 # Build the Lemon parser generator.
 sub ACTION_lemon {
     my $self = shift;
@@ -535,7 +454,6 @@ sub _clean_prereq_builds {
             and die "Clownfish clean failed";
         chdir $old_dir;
     }
-    $self->_run_make( dir => $CHARMONIZER_ORIG_DIR, args => ['clean'] );
     $self->_run_make( dir => $LEMON_DIR,            args => ['clean'] );
 }
 


Mime
View raw message