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/master - Use charmonizer to provide extra cflags in CFC
Date Mon, 04 Feb 2013 00:15:01 GMT
Updated Branches:
  refs/heads/master 58726a9df -> 78715e114


Use charmonizer to provide extra cflags in CFC


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

Branch: refs/heads/master
Commit: dca4a9985a720bc6992077f6b11171448d133415
Parents: 58726a9
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Fri Jan 4 23:06:30 2013 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Feb 4 01:03:35 2013 +0100

----------------------------------------------------------------------
 clownfish/compiler/common/charmonizer.main         |   31 +++++++++
 .../compiler/perl/buildlib/Clownfish/CFC/Build.pm  |   50 ++-------------
 devel/bin/regen_charmonizer.pl                     |    2 +-
 3 files changed, 39 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/dca4a998/clownfish/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/clownfish/compiler/common/charmonizer.main b/clownfish/compiler/common/charmonizer.main
index 4bafac6..d083f57 100644
--- a/clownfish/compiler/common/charmonizer.main
+++ b/clownfish/compiler/common/charmonizer.main
@@ -23,6 +23,35 @@
 #include "Charmonizer/Probe.h"
 #include "Charmonizer/Probe/Integers.h"
 
+static void
+S_add_compiler_flags(struct chaz_CLIArgs *args) {
+    if (chaz_Probe_gcc_version_num()) {
+        if (getenv("LUCY_VALGRIND")) {
+            chaz_CC_add_extra_cflags("-fno-inline-functions");
+        }
+        else if (getenv("LUCY_DEBUG")) {
+            chaz_CC_add_extra_cflags(
+                "-DLUCY_DEBUG -pedantic -Wall -Wextra "
+                "-Wno-variadic-macros "
+            );
+        }
+
+        /* Tell GCC explicitly to run with maximum options. */
+        chaz_CC_add_extra_cflags("-std=gnu99 -D_GNU_SOURCE");
+    }
+    else if (chaz_Probe_compiler_is_msvc()) {
+        /* Compile as C++ under MSVC. */
+        chaz_CC_add_extra_cflags("-TP");
+
+        /* Thwart stupid warnings. */
+        chaz_CC_add_extra_cflags("-D_CRT_SECURE_NO_WARNINGS");
+        chaz_CC_add_extra_cflags("-D_SCL_SECURE_NO_WARNINGS");
+
+        /* Redefine 'for' to fix broken 'for' scoping under MSVC6. */
+        chaz_CC_add_extra_cflags("-Dfor=\"if(0);else for\"");
+    }
+}
+
 int main(int argc, const char **argv) {
     /* Initialize. */
     {
@@ -32,9 +61,11 @@ int main(int argc, const char **argv) {
             chaz_Probe_die_usage();
         }
         chaz_Probe_init(&args);
+        S_add_compiler_flags(&args);
     }
 
     /* Run probe modules. */
+    chaz_BuildEnv_run();
     chaz_DirManip_run();
     chaz_Headers_run();
     chaz_Integers_run();

http://git-wip-us.apache.org/repos/asf/lucy/blob/dca4a998/clownfish/compiler/perl/buildlib/Clownfish/CFC/Build.pm
----------------------------------------------------------------------
diff --git a/clownfish/compiler/perl/buildlib/Clownfish/CFC/Build.pm b/clownfish/compiler/perl/buildlib/Clownfish/CFC/Build.pm
index 7e2d3ce..a3381af 100644
--- a/clownfish/compiler/perl/buildlib/Clownfish/CFC/Build.pm
+++ b/clownfish/compiler/perl/buildlib/Clownfish/CFC/Build.pm
@@ -37,54 +37,11 @@ my $LEMON_DIR = catdir( $base_dir, 'lemon' );
 my $LEMON_EXE_PATH = catfile( $LEMON_DIR, "lemon$Config{_exe}" );
 my $CFC_SOURCE_DIR = catdir( updir(), 'src' );
 
-sub extra_ccflags {
-    my $self          = shift;
-    my @extra_ccflags = qw( -DCFCPERL );
-
-    my $gcc_version 
-        = $ENV{REAL_GCC_VERSION}
-        || $self->config('gccversion')
-        || undef;
-    if ( defined $gcc_version ) {
-        $gcc_version =~ /^(\d+(\.\d+))/
-            or die "Invalid GCC version: $gcc_version";
-        $gcc_version = $1;
-
-        # Tell GCC explicitly to run with maximum options.
-        push @extra_ccflags, qw( -std=gnu99 -D_GNU_SOURCE );
-
-        if ( defined $ENV{LUCY_DEBUG} ) {
-            push @extra_ccflags, qw(
-                -DLUCY_DEBUG -DPERL_GCC_PEDANTIC -pedantic -Wall
-            );
-            push @extra_ccflags, qw( -Wextra )
-                if $gcc_version >= 3.4;    # correct
-            push @extra_ccflags, qw( -Wno-variadic-macros )
-                if $gcc_version > 3.4;    # at least not on gcc 3.4
-        }
-
-        if ( $ENV{LUCY_VALGRIND} ) {
-            push @extra_ccflags, qw( -fno-inline-functions );
-        }
-    }
-
-    # Compile as C++ under MSVC.
-    # Turn off stupid warnings, too.
-    # Redefine 'for' to fix broken 'for' scoping under MSVC6.
-    if ( $self->config('cc') =~ /^cl\b/ ) {
-        push @extra_ccflags, qw( -TP -D_CRT_SECURE_NO_WARNINGS );
-        push @extra_ccflags, '-Dfor="if(0);else for"';
-    }
-
-    return \@extra_ccflags;
-}
-
 sub new {
     my ( $class, %args ) = @_;
     return $class->SUPER::new(
         %args,
         recursive_test_files => 1,
-        extra_compiler_flags => __PACKAGE__->extra_ccflags,
         charmonizer_params   => {
             charmonizer_c => $CHARMONIZER_C,
         },
@@ -175,9 +132,16 @@ sub ACTION_lexers {
 
 sub ACTION_code {
     my $self = shift;
+
     $self->dispatch('charmony');
     $self->dispatch('ppport');
     $self->dispatch('parsers');
+
+    $self->extra_compiler_flags( join ' ',
+        '-DCFCPERL',
+        $self->charmony("EXTRA_CFLAGS")
+    );
+
     $self->SUPER::ACTION_code;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/dca4a998/devel/bin/regen_charmonizer.pl
----------------------------------------------------------------------
diff --git a/devel/bin/regen_charmonizer.pl b/devel/bin/regen_charmonizer.pl
index 9e76ec7..a8c76ad 100755
--- a/devel/bin/regen_charmonizer.pl
+++ b/devel/bin/regen_charmonizer.pl
@@ -29,7 +29,7 @@ my $MELD_EXE = catfile( $CHAZ_DIR, 'buildbin', 'meld.pl' );
 
 # Clownfish compiler.
 {
-    my $probes = "DirManip,Headers,Integers,Strings";
+    my $probes = "BuildEnv,DirManip,Headers,Integers,Strings";
     my $main   = catfile(qw( clownfish compiler common charmonizer.main ));
     my $out    = $main;
     $out =~ s/\.main/.c/ or die "no match";


Mime
View raw message