Split off charmony build action
ACTION_charmony is 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
'charmonizer_c' which specifies the Charmonizer C source file.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/0e583c58
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/0e583c58
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/0e583c58
Branch: refs/heads/master
Commit: 0e583c58405ce941e38840f8802a2fcdfdbd7c07
Parents: af707b9
Author: Nick Wellnhofer <[email protected]>
Authored: Fri Nov 2 19:17:12 2012 +0100
Committer: Nick Wellnhofer <[email protected]>
Committed: Sat Nov 3 21:50:55 2012 +0100
----------------------------------------------------------------------
.../compiler/perl/lib/Clownfish/CFC/Perl/Build.pm | 2 +-
.../perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm | 99 +++++++++++++++
clownfish/runtime/perl/buildlib/Clownfish/Build.pm | 56 +--------
perl/.gitignore | 2 +-
perl/buildlib/Lucy/Build.pm | 58 +--------
5 files changed, 106 insertions(+), 111 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/0e583c58/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/0e583c58/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..21db471
--- /dev/null
+++ b/clownfish/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm
@@ -0,0 +1,99 @@
+# 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 File::Spec::Functions qw( catfile curdir );
+
+# Add a custom Module::Build hashref property to pass the following build
+# parameters.
+# charmonizer_c: Charmonizer C file, required
+if ( $Module::Build::VERSION <= 0.30 ) {
+ __PACKAGE__->add_property( charmonizer_params => {} );
+}
+else {
+ __PACKAGE__->add_property(
+ 'charmonizer_params',
+ default => {},
+ );
+}
+
+my $CHARMONIZER_EXE_PATH = catfile( curdir(), "charmonizer$Config{_exe}" );
+my $CHARMONY_H_PATH = 'charmony.h';
+my $CHARMONY_PM_PATH = 'Charmony.pm';
+
+# Compile and run the charmonizer executable, creating the charmony.h and
+# Charmony.pm files.
+sub ACTION_charmony {
+ my $self = shift;
+ my $charmonizer_c = $self->charmonizer_params('charmonizer_c');
+ $self->add_to_cleanup($CHARMONIZER_EXE_PATH);
+ if ( !$self->up_to_date( $charmonizer_c, $CHARMONIZER_EXE_PATH ) ) {
+ print "\nCompiling $CHARMONIZER_EXE_PATH...\n\n";
+ my $cc = $self->config('cc');
+ my $outflag = $cc =~ /cl\b/ ? "/Fe" : "-o ";
+ system("$cc $charmonizer_c $outflag$CHARMONIZER_EXE_PATH")
+ and die "Failed to compile $CHARMONIZER_EXE_PATH";
+ }
+
+ return if $self->up_to_date( $CHARMONIZER_EXE_PATH, [
+ $CHARMONY_H_PATH, $CHARMONY_PM_PATH,
+ ] );
+ print "\nRunning $CHARMONIZER_EXE_PATH...\n\n";
+
+ $self->add_to_cleanup($CHARMONY_H_PATH);
+ $self->add_to_cleanup($CHARMONY_PM_PATH);
+ # Clean up after charmonizer if it doesn't succeed on its own.
+ $self->add_to_cleanup("_charm*");
+
+ # Prepare arguments to charmonizer.
+ my @command = (
+ $CHARMONIZER_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 $CHARMONIZER_EXE_PATH: $!";
+}
+
+sub _quotify {
+ my $string = shift;
+ $string =~ s/\\/\\\\/g;
+ $string =~ s/"/\\"/g;
+ return qq|"$string"|;
+}
+
+1;
+
+__END__
http://git-wip-us.apache.org/repos/asf/lucy/blob/0e583c58/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 7f3cc11..454ac05 100644
--- a/clownfish/runtime/perl/buildlib/Clownfish/Build.pm
+++ b/clownfish/runtime/perl/buildlib/Clownfish/Build.pm
@@ -35,21 +35,15 @@ 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 $COMMON_SOURCE_DIR = catdir( @BASE_PATH, 'common' );
my $CHARMONIZER_C = catfile( $COMMON_SOURCE_DIR, 'charmonizer.c' );
-my $CHARMONIZER_EXE_PATH = "charmonizer$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' );
@@ -80,6 +74,8 @@ sub new {
}
$self->extra_compiler_flags(@$extra_ccflags);
+ $self->charmonizer_params( charmonizer_c => $CHARMONIZER_C );
+
$self->clownfish_params( autogen_header => $self->autogen_header );
return $self;
@@ -103,54 +99,6 @@ sub _run_make {
chdir $current_directory if $dir;
}
-# Compile and run the charmonizer executable, creating the charmony.h and
-# Charmony.pm files.
-sub ACTION_charmony {
- my $self = shift;
- $self->add_to_cleanup($CHARMONIZER_EXE_PATH);
- if ( !$self->up_to_date( $CHARMONIZER_C, $CHARMONIZER_EXE_PATH ) ) {
- print "\nCompiling $CHARMONIZER_EXE_PATH...\n\n";
- my $cc = $self->config('cc');
- my $outflag = $cc =~ /cl\b/ ? "/Fe" : "-o ";
- system("$cc $CHARMONIZER_C $outflag$CHARMONIZER_EXE_PATH")
- and die "Failed to compile $CHARMONIZER_EXE_PATH";
- }
-
- return if $self->up_to_date( $CHARMONIZER_EXE_PATH, [
- $CHARMONY_H_PATH, $CHARMONY_PM_PATH,
- ] );
- print "\nRunning $CHARMONIZER_EXE_PATH...\n\n";
-
- $self->add_to_cleanup($CHARMONY_H_PATH);
- $self->add_to_cleanup($CHARMONY_PM_PATH);
- # Clean up after charmonizer if it doesn't succeed on its own.
- $self->add_to_cleanup("_charm*");
-
- # Prepare arguments to charmonizer.
- my @command = (
- $CHARMONIZER_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 $CHARMONIZER_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;
http://git-wip-us.apache.org/repos/asf/lucy/blob/0e583c58/perl/.gitignore
----------------------------------------------------------------------
diff --git a/perl/.gitignore b/perl/.gitignore
index 0993b89..0c60b68 100644
--- a/perl/.gitignore
+++ b/perl/.gitignore
@@ -6,7 +6,7 @@
/_build/
/autogen/
/blib/
-/charmonize
+/charmonizer
/charmonize.c
/charmony.h
/lib/Lucy.c
http://git-wip-us.apache.org/repos/asf/lucy/blob/0e583c58/perl/buildlib/Lucy/Build.pm
----------------------------------------------------------------------
diff --git a/perl/buildlib/Lucy/Build.pm b/perl/buildlib/Lucy/Build.pm
index 7c8ccd6..52cf3ff 100644
--- a/perl/buildlib/Lucy/Build.pm
+++ b/perl/buildlib/Lucy/Build.pm
@@ -35,24 +35,18 @@ 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 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 = catdir( @BASE_PATH, 'charmonizer' );
my $COMMON_SOURCE_DIR = catdir( @BASE_PATH, 'common' );
my $CHARMONIZER_C = catfile( $COMMON_SOURCE_DIR, 'charmonizer.c' );
-my $CHARMONIZER_EXE_PATH = "charmonizer$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' );
@@ -85,6 +79,8 @@ sub new {
}
$self->extra_compiler_flags(@$extra_ccflags);
+ $self->charmonizer_params( charmonizer_c => $CHARMONIZER_C );
+
$self->clownfish_params( autogen_header => $self->autogen_header );
return $self;
@@ -108,54 +104,6 @@ sub _run_make {
chdir $current_directory if $dir;
}
-# Compile and run the charmonizer executable, creating the charmony.h and
-# Charmony.pm files.
-sub ACTION_charmony {
- my $self = shift;
- $self->add_to_cleanup($CHARMONIZER_EXE_PATH);
- if ( !$self->up_to_date( $CHARMONIZER_C, $CHARMONIZER_EXE_PATH ) ) {
- print "\nCompiling $CHARMONIZER_EXE_PATH...\n\n";
- my $cc = $self->config('cc');
- my $outflag = $cc =~ /cl\b/ ? "/Fe" : "-o ";
- system("$cc $CHARMONIZER_C $outflag$CHARMONIZER_EXE_PATH")
- and die "Failed to compile $CHARMONIZER_EXE_PATH";
- }
-
- return if $self->up_to_date( $CHARMONIZER_EXE_PATH, [
- $CHARMONY_H_PATH, $CHARMONY_PM_PATH,
- ] );
- print "\nRunning $CHARMONIZER_EXE_PATH...\n\n";
-
- $self->add_to_cleanup($CHARMONY_H_PATH);
- $self->add_to_cleanup($CHARMONY_PM_PATH);
- # Clean up after charmonizer if it doesn't succeed on its own.
- $self->add_to_cleanup("_charm*");
-
- # Prepare arguments to charmonizer.
- my @command = (
- $CHARMONIZER_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 $CHARMONIZER_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;