You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2014/04/22 22:59:07 UTC

[lucy-commits] [1/6] git commit: Define HAS_BOOL in source, not via compiler flags

Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 3e5e15e58 -> b7d53da9b


Define HAS_BOOL in source, not via compiler flags


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

Branch: refs/heads/master
Commit: 4845706904f1cbe6e64814a644b06a0d57ca18e2
Parents: f42f56e
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Feb 16 22:12:19 2014 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Apr 22 21:15:44 2014 +0200

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC/Perl/Build.pm |  5 -----
 compiler/src/CFCPerl.c                        |  4 ++++
 runtime/common/charmonizer.c                  | 10 ----------
 runtime/common/charmonizer.main               | 10 ----------
 runtime/perl/xs/XSBind.h                      |  2 ++
 5 files changed, 6 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/48457069/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
index 938da21..e632bc8 100644
--- a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
+++ b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
@@ -58,11 +58,6 @@ my $BUILDLIB_DIR = 'buildlib';
 sub new {
     my $self = shift->SUPER::new( @_ );
 
-    # Define HAS_BOOL, so that the Perl headers don't redefine 'bool'.
-    my $extra_ccflags = $self->extra_compiler_flags;
-    push @$extra_ccflags, '-DHAS_BOOL';
-    $self->extra_compiler_flags(@$extra_ccflags);
-
     # TODO: use Charmonizer to determine whether pthreads are userland.
     if ( $Config{osname} =~ /openbsd/i && $Config{usethreads} ) {
         my $extra_ldflags = $self->extra_linker_flags;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/48457069/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerl.c b/compiler/src/CFCPerl.c
index fe2bc3a..02fb96b 100644
--- a/compiler/src/CFCPerl.c
+++ b/compiler/src/CFCPerl.c
@@ -270,9 +270,13 @@ S_write_boot_c(CFCPerl *self) {
         "%s\n"
         "\n"
         "#include \"cfish_parcel.h\"\n"
+        "\n"
+        "/* Avoid conflicts with Clownfish bool type. */\n"
+        "#define HAS_BOOL\n"
         "#include \"EXTERN.h\"\n"
         "#include \"perl.h\"\n"
         "#include \"XSUB.h\"\n"
+        "\n"
         "#include \"boot.h\"\n"
         "#include \"Clownfish/String.h\"\n"
         "#include \"Clownfish/VTable.h\"\n"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/48457069/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index d0a6bc4..0608f15 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -7079,16 +7079,6 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) {
         }
     }
 
-    /* When compiling for Perl bindings, define HAS_BOOL so that the Perl
-     * headers don't redefine 'bool' in conflict with C++.
-     *
-     * TODO: Compile all files that #include Perl headers separately and
-     * remove this directive.
-     */
-    if (args->charmony_pm) {
-        chaz_CFlags_add_define(extra_cflags, "HAS_BOOL", NULL);
-    }
-
     chaz_CFlags_add_define(extra_cflags, "CFP_CFISH", NULL);
     chaz_CFlags_add_define(extra_cflags, "CFP_TESTCFISH", NULL);
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/48457069/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main
index e6b35a7..3babc4a 100644
--- a/runtime/common/charmonizer.main
+++ b/runtime/common/charmonizer.main
@@ -81,16 +81,6 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) {
         }
     }
 
-    /* When compiling for Perl bindings, define HAS_BOOL so that the Perl
-     * headers don't redefine 'bool' in conflict with C++.
-     *
-     * TODO: Compile all files that #include Perl headers separately and
-     * remove this directive.
-     */
-    if (args->charmony_pm) {
-        chaz_CFlags_add_define(extra_cflags, "HAS_BOOL", NULL);
-    }
-
     chaz_CFlags_add_define(extra_cflags, "CFP_CFISH", NULL);
     chaz_CFlags_add_define(extra_cflags, "CFP_TESTCFISH", NULL);
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/48457069/runtime/perl/xs/XSBind.h
----------------------------------------------------------------------
diff --git a/runtime/perl/xs/XSBind.h b/runtime/perl/xs/XSBind.h
index e37058c..5df36f9 100644
--- a/runtime/perl/xs/XSBind.h
+++ b/runtime/perl/xs/XSBind.h
@@ -29,6 +29,8 @@
 #include "Clownfish/VArray.h"
 #include "Clownfish/VTable.h"
 
+/* Avoid conflicts with Clownfish bool type. */
+#define HAS_BOOL
 #include "EXTERN.h"
 #include "perl.h"
 #include "XSUB.h"


[lucy-commits] [6/6] git commit: Bake parcel privacy defines into XS

Posted by nw...@apache.org.
Bake parcel privacy defines into XS

The XS code can now be compiled without any extra compiler flags.


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

Branch: refs/heads/master
Commit: b7d53da9bbbd3bd6cae5e21e45b0e2cac3635e57
Parents: 1757e4e
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Feb 16 23:53:51 2014 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Apr 22 22:57:06 2014 +0200

----------------------------------------------------------------------
 compiler/src/CFCPerl.c | 14 +++++++++++++-
 runtime/perl/Build.PL  |  1 -
 2 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b7d53da9/compiler/src/CFCPerl.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerl.c b/compiler/src/CFCPerl.c
index 02fb96b..d931ea2 100644
--- a/compiler/src/CFCPerl.c
+++ b/compiler/src/CFCPerl.c
@@ -399,12 +399,24 @@ S_add_xs_init(char *xs_init, CFCPerlSub *xsub) {
 
 void
 CFCPerl_write_bindings(CFCPerl *self) {
-    CFCClass **ordered = CFCHierarchy_ordered_classes(self->hierarchy);
+    CFCParcel    **parcels  = CFCParcel_all_parcels();
+    CFCClass     **ordered  = CFCHierarchy_ordered_classes(self->hierarchy);
     CFCPerlClass **registry = CFCPerlClass_registry();
     char *hand_rolled_xs   = CFCUtil_strdup("");
     char *generated_xs     = CFCUtil_strdup("");
     char *xs_init          = CFCUtil_strdup("");
 
+    // Bake the parcel privacy defines into the XS, so it can be compiled
+    // without any extra compiler flags.
+    for (size_t i = 0; parcels[i]; ++i) {
+        if (!CFCParcel_included(parcels[i])) {
+            const char *privacy_sym = CFCParcel_get_privacy_sym(parcels[i]);
+            generated_xs = CFCUtil_cat(generated_xs, "#define ", privacy_sym,
+                                       "\n", NULL);
+        }
+    }
+    generated_xs = CFCUtil_cat(generated_xs, "\n", NULL);
+
     // Pound-includes for generated headers.
     for (size_t i = 0; ordered[i] != NULL; i++) {
         CFCClass *klass = ordered[i];

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b7d53da9/runtime/perl/Build.PL
----------------------------------------------------------------------
diff --git a/runtime/perl/Build.PL b/runtime/perl/Build.PL
index c893e5d..94cf181 100644
--- a/runtime/perl/Build.PL
+++ b/runtime/perl/Build.PL
@@ -57,7 +57,6 @@ my $builder = Clownfish::Build->new(
         ],
         include => [], # Don't use default includes.
     },
-    extra_compiler_flags => '-DCFP_CFISH -DCFP_TESTCFISH',
     add_to_cleanup => [
         qw(
             Clownfish-*


[lucy-commits] [3/6] git commit: Switch to Module::Build->depends_on

Posted by nw...@apache.org.
Switch to Module::Build->depends_on

According to the Module::Build documentation, 'depends_on' is preferred
over 'dispatch' when calling actions from inside another action.

Calling 'dispatch' also has the side effect of localizing the
Module::Build properties hash. This makes it impossible to call an
action which changes some properties and use the changed properties
afterwards. The next commit relies on this feature.


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

Branch: refs/heads/master
Commit: 93b82bed6e9c9acd1595fbad207b7a29580075c2
Parents: 4845706
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Feb 16 22:13:01 2014 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Apr 22 21:17:01 2014 +0200

----------------------------------------------------------------------
 compiler/perl/buildlib/Clownfish/CFC/Build.pm |  6 ++----
 compiler/perl/lib/Clownfish/CFC/Perl/Build.pm | 12 +++++++-----
 runtime/perl/buildlib/Clownfish/Build.pm      |  8 +++-----
 3 files changed, 12 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/93b82bed/compiler/perl/buildlib/Clownfish/CFC/Build.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/buildlib/Clownfish/CFC/Build.pm b/compiler/perl/buildlib/Clownfish/CFC/Build.pm
index b695813..93fa675 100644
--- a/compiler/perl/buildlib/Clownfish/CFC/Build.pm
+++ b/compiler/perl/buildlib/Clownfish/CFC/Build.pm
@@ -95,7 +95,7 @@ sub ACTION_lemon {
 # Run all .y files through lemon.
 sub ACTION_parsers {
     my $self = shift;
-    $self->dispatch('lemon');
+    $self->depends_on('lemon');
     my $y_files = $self->rscan_dir( $CFC_SOURCE_DIR, qr/\.y$/ );
     for my $y_file (@$y_files) {
         my $c_file = $y_file;
@@ -133,9 +133,7 @@ sub ACTION_lexers {
 sub ACTION_code {
     my $self = shift;
 
-    $self->dispatch('charmony');
-    $self->dispatch('ppport');
-    $self->dispatch('parsers');
+    $self->depends_on(qw( charmony ppport parsers ));
 
     my @flags = $self->split_like_shell($self->charmony("EXTRA_CFLAGS"));
     # The flag for the MSVC6 hack contains spaces. Make sure it stays quoted.

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/93b82bed/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
index e632bc8..da22e53 100644
--- a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
+++ b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
@@ -249,7 +249,7 @@ sub _compile_clownfish {
 
 sub ACTION_pod {
     my $self = shift;
-    $self->dispatch("clownfish");
+    $self->depends_on('clownfish');
     $self->_write_pod(@_);
 }
 
@@ -354,7 +354,7 @@ sub ACTION_ppport {
 sub ACTION_compile_custom_xs {
     my $self = shift;
 
-    $self->dispatch('ppport');
+    $self->depends_on('ppport');
 
     require ExtUtils::CBuilder;
     require ExtUtils::ParseXS;
@@ -485,9 +485,11 @@ sub ACTION_compile_custom_xs {
 sub ACTION_code {
     my $self = shift;
 
-    $self->dispatch('clownfish');
-    $self->dispatch('compile_custom_xs');
-    $self->dispatch('copy_clownfish_includes');
+    $self->depends_on(qw(
+        clownfish
+        compile_custom_xs
+        copy_clownfish_includes
+    ));
 
     $self->SUPER::ACTION_code;
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/93b82bed/runtime/perl/buildlib/Clownfish/Build.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build.pm b/runtime/perl/buildlib/Clownfish/Build.pm
index 9a28a55..991ac5a 100644
--- a/runtime/perl/buildlib/Clownfish/Build.pm
+++ b/runtime/perl/buildlib/Clownfish/Build.pm
@@ -97,7 +97,7 @@ sub ACTION_cfc {
 sub ACTION_copy_clownfish_includes {
     my $self = shift;
 
-    $self->dispatch('charmony');
+    $self->depends_on('charmony');
 
     $self->SUPER::ACTION_copy_clownfish_includes;
 
@@ -108,8 +108,7 @@ sub ACTION_copy_clownfish_includes {
 sub ACTION_clownfish {
     my $self = shift;
 
-    $self->dispatch('charmony');
-    $self->dispatch('cfc');
+    $self->depends_on(qw( charmony cfc ));
 
     $self->SUPER::ACTION_clownfish;
 }
@@ -176,8 +175,7 @@ sub ACTION_test_valgrind {
     if ( !$ENV{LUCY_VALGRIND} ) {
         warn "\$ENV{LUCY_VALGRIND} not true -- possible false positives";
     }
-    $self->dispatch('code');
-    $self->dispatch('suppressions');
+    $self->depends_on(qw( code suppressions ));
 
     # Unbuffer STDOUT, grab test file names and suppressions files.
     $|++;


[lucy-commits] [2/6] git commit: MSVC flags shouldn't be needed for XS compilation

Posted by nw...@apache.org.
MSVC flags shouldn't be needed for XS compilation


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

Branch: refs/heads/master
Commit: f42f56eea527824ea69a8ef729799ada61e9419c
Parents: 3e5e15e
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Feb 16 22:11:22 2014 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Apr 22 21:15:44 2014 +0200

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC/Perl/Build.pm | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/f42f56ee/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
index 4ac8e51..938da21 100644
--- a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
+++ b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
@@ -58,16 +58,8 @@ my $BUILDLIB_DIR = 'buildlib';
 sub new {
     my $self = shift->SUPER::new( @_ );
 
-    my $extra_ccflags = $self->extra_compiler_flags;
-    if ( $self->config('cc') =~ /^cl\b/ ) {
-        # Compile as C++ under MSVC.
-        push @$extra_ccflags, qw(
-            -TP -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS
-        );
-        # Redefine 'for' to fix broken 'for' scoping under MSVC6.
-        push @$extra_ccflags, '-Dfor="if(0);else for"';
-    }
     # Define HAS_BOOL, so that the Perl headers don't redefine 'bool'.
+    my $extra_ccflags = $self->extra_compiler_flags;
     push @$extra_ccflags, '-DHAS_BOOL';
     $self->extra_compiler_flags(@$extra_ccflags);
 


[lucy-commits] [5/6] git commit: Set -fvisibility flag via charmonizer

Posted by nw...@apache.org.
Set -fvisibility flag via charmonizer


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

Branch: refs/heads/master
Commit: 1757e4e6c919577fc8690f536cf7aab8a02fe4f3
Parents: 85dad61
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Feb 16 22:14:37 2014 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Apr 22 22:57:06 2014 +0200

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC/Perl/Build.pm | 11 ++---------
 runtime/common/charmonizer.c                  |  3 ++-
 runtime/common/charmonizer.main               |  3 ++-
 3 files changed, 6 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1757e4e6/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
index 8ace1ac..6c94cf4 100644
--- a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
+++ b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
@@ -376,14 +376,7 @@ sub ACTION_compile_custom_xs {
     for my $source_dir (@$source_dirs) {
         push @$c_files, @{ $self->rscan_dir( $source_dir, qr/\.c$/ ) };
     }
-    # Compile with -fvisibility=hidden on GCC >= 4.0
-    my $extra_cflags = $self->clownfish_params('cflags') || '';
-    if ( $self->config('gccversion') && $Config{dlext} ne 'dll' ) {
-        my @version_nums = split( /\./, $self->config('gccversion') );
-        if ( $version_nums[0] >= 4 ) {
-            $extra_cflags .= ' -fvisibility=hidden';
-        }
-    }
+    my $extra_cflags = $self->clownfish_params('cflags');
     for my $c_file (@$c_files) {
         my $o_file   = $c_file;
         my $ccs_file = $c_file;
@@ -419,7 +412,7 @@ sub ACTION_compile_custom_xs {
     unshift @objects, $perl_binding_o_file;
     $self->add_to_cleanup($perl_binding_o_file);
     if ( !$self->up_to_date( $perl_binding_c_file, $perl_binding_o_file ) ) {
-        # Don't use -fvisibility=hidden for XS
+        # Don't use Clownfish compiler flags for XS
         $cbuilder->compile(
             source               => $perl_binding_c_file,
             extra_compiler_flags => $self->extra_compiler_flags,

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1757e4e6/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index 0608f15..0b58d35 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -7081,6 +7081,8 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) {
 
     chaz_CFlags_add_define(extra_cflags, "CFP_CFISH", NULL);
     chaz_CFlags_add_define(extra_cflags, "CFP_TESTCFISH", NULL);
+
+    chaz_CFlags_hide_symbols(extra_cflags);
 }
 
 static int
@@ -7183,7 +7185,6 @@ S_write_makefile(struct chaz_CLIArgs *args) {
     chaz_CFlags_enable_debugging(makefile_cflags);
     chaz_CFlags_disable_strict_aliasing(makefile_cflags);
     chaz_CFlags_compile_shared_library(makefile_cflags);
-    chaz_CFlags_hide_symbols(makefile_cflags);
     if (args->code_coverage) {
         chaz_CFlags_enable_code_coverage(makefile_cflags);
     }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/1757e4e6/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main
index 3babc4a..8b181e7 100644
--- a/runtime/common/charmonizer.main
+++ b/runtime/common/charmonizer.main
@@ -83,6 +83,8 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) {
 
     chaz_CFlags_add_define(extra_cflags, "CFP_CFISH", NULL);
     chaz_CFlags_add_define(extra_cflags, "CFP_TESTCFISH", NULL);
+
+    chaz_CFlags_hide_symbols(extra_cflags);
 }
 
 static int
@@ -185,7 +187,6 @@ S_write_makefile(struct chaz_CLIArgs *args) {
     chaz_CFlags_enable_debugging(makefile_cflags);
     chaz_CFlags_disable_strict_aliasing(makefile_cflags);
     chaz_CFlags_compile_shared_library(makefile_cflags);
-    chaz_CFlags_hide_symbols(makefile_cflags);
     if (args->code_coverage) {
         chaz_CFlags_enable_code_coverage(makefile_cflags);
     }


[lucy-commits] [4/6] git commit: Remove dependency of Clownfish::CFC::Perl::Build on Charmonizer

Posted by nw...@apache.org.
Remove dependency of Clownfish::CFC::Perl::Build on Charmonizer

Add a new field 'cflags' to the 'clownfish_params' Module::Build
property to pass additional compiler flags.


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

Branch: refs/heads/master
Commit: 85dad61a24d2e3476f0251c49b253084a9a0030c
Parents: 93b82be
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sun Feb 16 22:13:42 2014 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Apr 22 22:57:06 2014 +0200

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC/Perl/Build.pm | 11 +++++---
 runtime/perl/buildlib/Clownfish/Build.pm      | 31 ++++++++++++++++++----
 2 files changed, 34 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/85dad61a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
index da22e53..8ace1ac 100644
--- a/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
+++ b/compiler/perl/lib/Clownfish/CFC/Perl/Build.pm
@@ -17,7 +17,7 @@ use strict;
 use warnings;
 
 package Clownfish::CFC::Perl::Build;
-use base qw( Clownfish::CFC::Perl::Build::Charmonic );
+use base qw( Module::Build );
 our $VERSION = '0.01';
 
 use File::Spec::Functions qw( catdir catfile curdir updir abs2rel rel2abs );
@@ -91,7 +91,7 @@ sub new {
 
     my $include_dirs = $self->include_dirs;
     push( @$include_dirs,
-        curdir(), # for ppport.h and charmony.h
+        curdir(), # for ppport.h
         catdir( $AUTOGEN_DIR, 'include' ),
         @$cf_include,
     );
@@ -377,7 +377,7 @@ sub ACTION_compile_custom_xs {
         push @$c_files, @{ $self->rscan_dir( $source_dir, qr/\.c$/ ) };
     }
     # Compile with -fvisibility=hidden on GCC >= 4.0
-    my $extra_cflags = $self->charmony("EXTRA_CFLAGS");
+    my $extra_cflags = $self->clownfish_params('cflags') || '';
     if ( $self->config('gccversion') && $Config{dlext} ne 'dll' ) {
         my @version_nums = split( /\./, $self->config('gccversion') );
         if ( $version_nums[0] >= 4 ) {
@@ -631,6 +631,11 @@ system include directories if needed.
 A string that will be prepended to the files generated by the Clownfish
 compiler.
 
+=head3 cflags
+
+A string with additional compiler flags used to compile the Clownfish .c
+files.
+
 =head1 METHODS
 
 =head2 my @path = Clownfish::CFC::Perl::Build->cf_base_path();

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/85dad61a/runtime/perl/buildlib/Clownfish/Build.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build.pm b/runtime/perl/buildlib/Clownfish/Build.pm
index 991ac5a..2c01db6 100644
--- a/runtime/perl/buildlib/Clownfish/Build.pm
+++ b/runtime/perl/buildlib/Clownfish/Build.pm
@@ -25,7 +25,10 @@ package Clownfish::Build;
 # yet. So we look in 'clownfish/compiler/perl/lib' directly and cleanup @INC
 # afterwards.
 use lib '../../compiler/perl/lib';
-use base qw( Clownfish::CFC::Perl::Build );
+use base qw(
+    Clownfish::CFC::Perl::Build
+    Clownfish::CFC::Perl::Build::Charmonic
+);
 no lib '../../compiler/perl/lib';
 
 our $VERSION = '0.003000';
@@ -97,22 +100,40 @@ sub ACTION_cfc {
 sub ACTION_copy_clownfish_includes {
     my $self = shift;
 
-    $self->depends_on('charmony');
-
     $self->SUPER::ACTION_copy_clownfish_includes;
 
-    $self->cf_copy_include_file( 'charmony.h' );
     $self->cf_copy_include_file( 'XSBind.h' );
 }
 
 sub ACTION_clownfish {
     my $self = shift;
 
-    $self->depends_on(qw( charmony cfc ));
+    $self->depends_on('cfc');
 
     $self->SUPER::ACTION_clownfish;
 }
 
+sub ACTION_compile_custom_xs {
+    my $self = shift;
+
+    $self->depends_on('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 ACTION_suppressions {
     my $self       = shift;
     my $LOCAL_SUPP = 'local.supp';