| File: | config/gen/config_h.pm |
| Coverage: | 93.6% |
| line | stmt | bran | cond | sub | code |
|---|---|---|---|---|---|
| 1 | # Copyright (C) 2001-2007, Parrot Foundation. | ||||
| 2 | |||||
| 3 - 14 | =head1 NAME config/gen/config_h.pm - Configuration Header =head1 DESCRIPTION Generates F<include/parrot/config.h> with platform-specific configuration values, F<include/parrot/has_header.h> with platform-specific header information, and F<include/parrot/feature.h> with information on optional features. =cut | ||||
| 15 | |||||
| 16 | package gen::config_h; | ||||
| 17 | |||||
| 18 | 2 2 2 | use strict; | |||
| 19 | 2 2 2 | use warnings; | |||
| 20 | |||||
| 21 | 2 2 2 | use base qw(Parrot::Configure::Step); | |||
| 22 | |||||
| 23 | 2 2 2 | use Parrot::Configure::Utils ':gen'; | |||
| 24 | |||||
| 25 | |||||
| 26 | sub _init { | ||||
| 27 | 3 | my $self = shift; | |||
| 28 | 3 | my %data; | |||
| 29 | 3 | $data{description} = q{Generate C headers}; | |||
| 30 | 3 | $data{result} = q{}; | |||
| 31 | 3 | $data{templates} = { | |||
| 32 | config_h => 'config/gen/config_h/config_h.in', | ||||
| 33 | feature_h => 'config/gen/config_h/feature_h.in', | ||||
| 34 | has_header_h => 'config/gen/config_h/has_header_h.in', | ||||
| 35 | }; | ||||
| 36 | 3 | return \%data; | |||
| 37 | } | ||||
| 38 | |||||
| 39 | sub runstep { | ||||
| 40 | 1 | my ( $self, $conf ) = @_; | |||
| 41 | |||||
| 42 | 1 | $conf->genfile($self->{templates}->{config_h}, 'include/parrot/config.h', | |||
| 43 | ignore_pattern => 'PARROT_CONFIG_DATE', | ||||
| 44 | conditioned_lines => 1 | ||||
| 45 | ); | ||||
| 46 | |||||
| 47 | 1 | $conf->genfile($self->{templates}->{feature_h}, 'include/parrot/feature.h', | |||
| 48 | ignore_pattern => 'PARROT_CONFIG_DATE', | ||||
| 49 | feature_file => 1 | ||||
| 50 | ); | ||||
| 51 | |||||
| 52 | 1 | my @sorted_keys = sort $conf->data->keys(); | |||
| 53 | |||||
| 54 | 92 | $conf->data->set( TEMP_header => | |||
| 55 | 359 | join "\n", map { $conf->data->get($_) | |||
| 56 | ? "#define PARROT_HAS_HEADER_" . uc(substr $_, 2) . " 1" | ||||
| 57 | : "#undef PARROT_HAS_HEADER_" . uc(substr $_, 2) } | ||||
| 58 | 1 | grep { /^i_\w+/ } | |||
| 59 | @sorted_keys | ||||
| 60 | ); | ||||
| 61 | |||||
| 62 | 20 | $conf->data->set( TEMP_has_config => | |||
| 63 | 359 | join "\n", map { "#define PARROT_" . uc($_) . " 1" } | |||
| 64 | 1 | grep { /^HAS_\w+/ && $conf->data->get($_) } | |||
| 65 | @sorted_keys | ||||
| 66 | ); | ||||
| 67 | |||||
| 68 | 0 | $conf->data->set( TEMP_d_config => | |||
| 69 | 359 | join "\n", map { "#define PARROT_" . uc(substr $_, 2) . " " . $conf->data->get($_) } | |||
| 70 | 1 | grep { /^D_\w+/ } | |||
| 71 | @sorted_keys | ||||
| 72 | ); | ||||
| 73 | |||||
| 74 | 0 | $conf->data->set( TEMP_cli_define => | |||
| 75 | 1 | join "\n", map { "#define PARROT_DEF_" . uc($_) . " 1" } | |||
| 76 | split /,/, $conf->options->get('define') || '' | ||||
| 77 | ); | ||||
| 78 | |||||
| 79 | 1 | $conf->genfile($self->{templates}->{has_header_h}, 'include/parrot/has_header.h'); | |||
| 80 | |||||
| 81 | 1 | return 1; | |||
| 82 | } | ||||
| 83 | |||||
| 84 | 1; | ||||
| 85 | |||||
| 86 | # Local Variables: | ||||
| 87 | # mode: cperl | ||||
| 88 | # cperl-indent-level: 4 | ||||
| 89 | # fill-column: 100 | ||||
| 90 | # End: | ||||
| 91 | # vim: expandtab shiftwidth=4: | ||||