C-Scan-Constants

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

    } elsif ($ModPerl::CScan::VERSION < 0.75) {
        print STDERR "ModPerl::CScan too old ($ModPerl::CScan::VERSION < 0.75),  using bundled copy.\n";
        $g_use_bundled_cscan = 1;
    }


    my $libmodp_dir = File::Spec->catfile('lib', 'ModPerl');
    if ($g_use_bundled_cscan) {
        if ( ! -d $libmodp_dir ) {
            mkdir($libmodp_dir) or
                die "Could not create $libmodp_dir to relocate bundled CScan.pm: $!"
        }
        copy(File::Spec->catfile('contrib',$libmodp_dir,'CScan.pm'),
	     File::Spec->catfile($libmodp_dir,'CScan.pm')) or
            die "Could not copy bundled ModPerl::CScan to lib directory: $!";
    }
}

# Bail out now if we can't find gcc in the build config.  Note that this
# may not be enough to assure later use of the C preprocessor will
# actually be successful, so we should also probably test gcc now for

lib/C/Scan/Constants.pm  view on Meta::CPAN

}

# _get_constant_data_blobs_from()
#
# Internal function.
#
# Returns a two blobs of data from the supplied file:
#   ($defines,   <-- #define macros with no args
#    $typedefs)  <-- #typedef enum constants
sub _get_constant_data_blobs_from {
    my $file_to_relocate = shift;

    if ( ! -f $file_to_relocate ) {
        croak "$file_to_relocate does not appear to be accessible";
    }

    # Create a temp directory here.
    my $temp_scan_dir = tempdir( 'c_scan_const_XXXXX',
                                 DIR     => File::Spec->tmpdir(),
                                 CLEANUP => 1 )
        or die "Internal error: failed to create temp dir";

    # copy the file into it
    my $scan_file_basename = ( File::Spec->splitpath($file_to_relocate) )[2];
    my $relocated_file = File::Spec->catpath( '',
                                              $temp_scan_dir,
                                              $scan_file_basename );
    copy($file_to_relocate, $relocated_file)
        or croak "Could not copy $file_to_relocate to $relocated_file";

    # scan the file
    my $c_header_file = ModPerl::CScan->new( filename => $relocated_file );
    
    if ( !defined( $c_header_file ) ) {
        croak "Could not create ModPerl::CScan obj for $relocated_file";
    }

    # Ugly hack to fix ActivePerl config bomb, i.e. expectation that "cppstdin"
    # is the cpp we'll be using.  This assumes MinGW is installed, which we
    # attempted to enforce in the Makefile.PL.  It probably assumes more than
    # should be safely assumed about the return data structure from Data::Flow,
    # but it seems to work.
    if ( $^O =~ /MSWin/i ) {
        my $cur_cppstdin = $c_header_file->get('Cpp')->{cppstdin};
	my $cur_cc = $Config{cc};

lib/C/Scan/Constants.pm  view on Meta::CPAN

#    my $defs5    = $c_header_file->get("defines_no_args_full");
#    my $defs6    = $c_header_file->get("Defines");
##################################################################
    my $typedefs = $c_header_file->get("typedef_texts");


### For debugging only ######################################################
### NOTE: need to send STDERR somewhere other than /dev/null for these to
###       work as intended.
###
#    warn sprintf("[$file_to_relocate] defines_no_args = %s", Dumper($defs));
#    warn sprintf("[$file_to_relocate] defines_maybe = %s", Dumper($defs2));
#    warn sprintf("[$file_to_relocate] defines_full = %s", Dumper($defs3));
#    warn sprintf("[$file_to_relocate] defines_args = %s", Dumper($defs4));
#    warn sprintf("[$file_to_relocate] defines_no_args_full = %s", Dumper($defs5));
#    warn sprintf("[$file_to_relocate] Defines = %s", Dumper($defs6));
#    warn sprintf("[$file_to_relocate] enums = %s", Dumper($typedefs));
#############################################################################

    # Restore STDERR and close the temp filehandle for neatness.
    close STDERR;
    open STDERR, ">&", $OLDERR;
	close $OLDERR;

    # Return the file object returned from ModPerl::CScan->new()
    # Note: these may be empty (hashref, arrayref)
    return ($defs, $typedefs);



( run in 0.719 second using v1.01-cache-2.11-cpan-71847e10f99 )