Skip to content

Commit

Permalink
CPAN Release 0.27
Browse files Browse the repository at this point in the history
- Add CppGuess support.
- Probably a temporary solution.
  • Loading branch information
ingydotnet committed Dec 21, 2014
1 parent c02d961 commit 43cf473
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -21,6 +21,8 @@ perl:
install:
- cpanm --quiet --notest
Devel::Cover::Report::Coveralls
ExtUtils::CppGuess
File::Share
Inline
Inline::C

Expand Down
1 change: 1 addition & 0 deletions About
Expand Up @@ -68,6 +68,7 @@ This repoository contains the following top level files and directories:
.git/ - Git repository data.
lib/ - All the source code libraries (modules).
note/ - Random note files. To-Do lists, specs, etc.
share/ - Shared files for the release package.

Resources
---------
Expand Down
6 changes: 6 additions & 0 deletions Changes
@@ -1,4 +1,10 @@
---
version: 0.27
date: Sun Dec 21 00:28:22 EST 2014
changes:
- Add CppGuess support.
- Probably a temporary solution.
---
version: 0.26
date: Thu Dec 18 18:04:08 PST 2014
changes:
Expand Down
3 changes: 2 additions & 1 deletion Meta
@@ -1,7 +1,7 @@
=meta: 0.0.1

name: Inline-Module
version: 0.26
version: 0.27
abstract: Support for Inline-based CPAN Extension Modules
homepage: https://metacpan.org/release/Inline-Module

Expand All @@ -17,6 +17,7 @@ author:

requires:
perl: 5.8.1
ExtUtils::CppGuess: 0 # For Inline::CPP. For now.
File::Share: 0
Inline: 0
Inline::C: 0
Expand Down
11 changes: 8 additions & 3 deletions lib/Inline/Module.pm
@@ -1,6 +1,6 @@
use strict; use warnings;
package Inline::Module;
our $VERSION = '0.26';
our $VERSION = '0.27';
our $API_VERSION = 'v2';

use Carp 'croak';
Expand Down Expand Up @@ -285,11 +285,14 @@ sub included_modules {
'Inline::C::Parser::RegExp';
}
if (grep /:CPP$/, @$ilsm) {
push @$include,
push @$include, (
'Inline::C',
'Inline::CPP::Config',
'Inline::CPP::Parser::RecDescent',
'Parse::RecDescent';
'Parse::RecDescent',
'ExtUtils::CppGuess',
'Capture::Tiny',
);
}
return $include;
}
Expand Down Expand Up @@ -392,6 +395,8 @@ bootstrap $module;
sub write_module {
my ($class, $dest, $module, $code) = @_;

$code =~ s/\n+__END__\n.*//s;

my $filepath = $module;
$filepath =~ s!::!/!g;
$filepath = "$dest/$filepath.pm";
Expand Down
70 changes: 41 additions & 29 deletions share/CPPConfig.pm
Expand Up @@ -4,48 +4,60 @@ use strict; use warnings;
package Inline::CPP::Config;

use Config;
# use ExtUtils::CppGuess;
use ExtUtils::CppGuess;

our ($compiler, $libs, $iostream_fn, $cpp_flavor_defs) = cpp_guess();
our ($compiler, $libs, $iostream_fn, $cpp_flavor_defs) = guess();

my $cpp_info;
BEGIN {
my $default_headers = <<'.';
sub guess {
my ($compiler, $libs, $iostream_fn, $cpp_flavor_defs);
$iostream_fn = 'iostream';
$cpp_flavor_defs = <<'.';
#define __INLINE_CPP_STANDARD_HEADERS 1
#define __INLINE_CPP_NAMESPACE_STD 1
.
my @default_info = (
'g++ -xc++',
'-lstdc++',
'iostream',
$default_headers,
);
$cpp_info = {
'cygwin' => [ @default_info ],
'darwin' => [ @default_info ],
'linux' => [ @default_info ],
'MSWin32' => [ @default_info ],
};
}

sub throw;
sub cpp_guess {
my $key = $Config::Config{osname};
if (my $config = $cpp_info->{$key}) {
$config->[0] .= ' -D_FILE_OFFSET_BITS=64',
if $Config::Config{ccflags} =~ /-D_FILE_OFFSET_BITS=64/;
return @$config;
if ($Config::Config{osname} eq 'freebsd'
&& $Config::Config{osvers} =~ /^(\d+)/
&& $1 >= 10
) {
$compiler = 'clang++';
$libs = '-lc++';
}

throw "Unsupported OS/Compiler for Inline::Module+Inline::CPP '$key'";
else {
my $guesser = ExtUtils::CppGuess->new;
my %configuration = $guesser->module_build_options;
if( $guesser->is_gcc ) {
$compiler = 'g++';
}
elsif ( $guesser->is_msvc ) {
$compiler = 'cl';
}

$compiler .= $configuration{extra_compiler_flags};
$libs = $configuration{extra_linker_flags};

($compiler, $libs) = map {
_trim_whitespace($_)
} ($compiler, $libs);
}
return ($compiler, $libs, $iostream_fn, $cpp_flavor_defs);
}

sub throw {
die "@_" unless
my $os = $^O;
my $msg = "Unsupported OS/Compiler for Inline::Module+Inline::CPP '$os'";
die $msg unless
$ENV{PERL5_MINISMOKEBOX} ||
$ENV{PERL_CR_SMOKER_CURRENT};
eval 'use lib "inc"; use Inline::Module; 1' or die $@;
Inline::Module->smoke_system_info_dump();
Inline::Module->smoke_system_info_dump($msg);
}

sub _trim_whitespace {
my $string = shift;
$string =~ s/^\s+|\s+$//g;
$string =~ s/\s+/ /g;
return $string;
}

1;

0 comments on commit 43cf473

Please sign in to comment.