File Coverage

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

linestmtbrancondsubcode
1# Copyright (C) 2001-2009, Parrot Foundation.
2
3 - 11
=head1 NAME

config/auto/inline.pm - Inline Compiler Support

=head1 DESCRIPTION

Determines whether the compiler supports C<inline>.

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