File Coverage

File:config/auto/inline.pm
Coverage:91.0%

linestmtbrancondsubcode
1# Copyright (C) 2001-2009, Parrot Foundation.
2# $Id: inline.pm 37201 2009-03-08 12:07:48Z fperrad $
3
4 - 12
=head1 NAME

config/auto/inline.pm - Inline Compiler Support

=head1 DESCRIPTION

Determines whether the compiler supports C<inline>.

=cut
13
14package auto::inline;
15
16
81
81
81
use strict;
17
81
81
81
use warnings;
18
19
81
81
81
use base qw(Parrot::Configure::Step);
20
21
81
81
81
use Parrot::Configure::Utils ':auto';
22
23
24sub _init {
25
86
    my $self = shift;
26
86
    my %data;
27
86
    $data{description} = q{Does your compiler support inline};
28
86
    $data{result} = q{};
29
86
    return \%data;
30}
31
32sub runstep {
33
82
    my ( $self, $conf ) = @_;
34
35
82
    my $inline = $conf->options->get(qw(inline));
36
82
    if ( defined $inline ) {
37
1
        $conf->data->set( inline => $inline );
38
1
        return 1;
39    }
40
41
81
    my $test = $self->_first_probe_for_inline($conf);
42
81
    unless ($test) {
43
0
        $test = $self->_second_probe_for_inline($conf, $test);
44    }
45
46
81
    $self->_evaluate_inline($conf, $test);
47
81
    return 1;
48}
49
50sub _first_probe_for_inline {
51
81
    my $self = shift;
52
81
    my $conf = shift;
53
81
    my $test;
54
81
    $conf->cc_gen('config/auto/inline/test1_c.in');
55
81
81
    eval { $conf->cc_build(); };
56
81
    if ( !$@ ) {
57
81
        $test = $conf->cc_run();
58
81
        chomp $test if $test;
59    }
60
81
    $conf->cc_clean();
61
81
    return $test;
62}
63
64sub _second_probe_for_inline {
65
1
    my $self = shift;
66
1
    my $conf = shift;
67
1
    my $test = shift;
68
1
    if ( !$test ) {
69
1
        $conf->cc_gen('config/auto/inline/test2_c.in');
70
1
1
        eval { $conf->cc_build(); };
71
1
        if ( !$@ ) {
72
1
            $test = $conf->cc_run();
73
1
            chomp $test if $test;
74        }
75
1
        $conf->cc_clean();
76    }
77
1
    return $test;
78}
79
80sub _evaluate_inline {
81
85
    my ($self, $conf, $test) = @_;
82
85
    my $verbose = $conf->options->get(qw(verbose));
83
85
    if ($test) {
84
84
        print " ($test) " if $verbose;
85
84
        $self->set_result('yes');
86    }
87    else {
88
1
        print " no " if $verbose;
89
1
        $self->set_result('no');
90
1
        $test = '';
91    }
92
85
    $conf->data->set( inline => $test );
93
85
    return 1;
94}
95
961;
97
98# Local Variables:
99# mode: cperl
100# cperl-indent-level: 4
101# fill-column: 100
102# End:
103# vim: expandtab shiftwidth=4: