| 1 | package ExtUtils::Builder::Compiler::VMS; | ||
| 2 | $ExtUtils::Builder::Compiler::VMS::VERSION = '0.038'; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use parent 'ExtUtils::Builder::Compiler'; | ||
| 7 | |||
| 8 | use Carp (); | ||
| 9 | |||
| 10 | sub _init { | ||
| 11 | my ($self, %args) = @_; | ||
| 12 | $args{cc} //= ['CC/DECC']; | ||
| 13 | $self->SUPER::_init(%args); | ||
| 14 | return; | ||
| 15 | } | ||
| 16 | |||
| 17 | # The VMS compiler can only have one define and one include qualifier, so we need to juggle here | ||
| 18 | |||
| 19 | sub add_argument { | ||
| 20 | my ($self, %opts) = @_; | ||
| 21 | my @value; | ||
| 22 | for my $elem (@{ delete $opts{value} }) { | ||
| 23 | if ($elem =~ m{ / def [^=]+ =+ (\()? ( [^/\)]* ) (?(1) \) ) }xi) { | ||
| 24 | my @defines = $2 =~ m/ ( \w+ | "[^"]+" ) /gx; | ||
| 25 | push @{ $self->{defines} }, @defines; | ||
| 26 | } | ||
| 27 | elsif ($elem =~ m{ / inc [^=]+ =+ (\()? ( [^/\)]* ) (?(1) \) ) }xi) { | ||
| 28 | $self->add_include_dir([$2]); | ||
| 29 | } | ||
| 30 | else { | ||
| 31 | push @value, $elem; | ||
| 32 | } | ||
| 33 | } | ||
| 34 | $self->SUPER::add_argument(%opts, value => \@value); | ||
| 35 | return; | ||
| 36 | } | ||
| 37 | |||
| 38 | sub compile_flags { | ||
| 39 | my ($self, $from, $to) = @_; | ||
| 40 | |||
| 41 | my @ret; | ||
| 42 | my @include_dirs = map { $_->{value} } @{ $self->{include_dirs} }; | ||
| 43 | my @defines = map { defined $_->{value} ? $_->{value} ne '' ? qq/"$_->{key}=$_->{value}"/ : qq{"$_->{key}"} : Carp::croak("Can't undefine '$_->{key}'") } @{ $self->{defines} }; | ||
| 44 | push @ret, $self->new_argument(ranking => 15, value => [ "/STANDARD=\U$self->{standard}"]) if $self->{standard}; | ||
| 45 | push @ret, $self->new_argument(ranking => 30, value => [ '/include=' . join ',', @include_dirs ]) if @include_dirs; | ||
| 46 | push @ret, $self->new_argument(ranking => 40, value => [ '/define=' . join ',', @defines ]) if @defines; | ||
| 47 | push @ret, $self->new_argument(ranking => 75, value => [ "/obj=$to", $from ]); | ||
| 48 | return @ret; | ||
| 49 | } | ||
| 50 | |||
| 51 | 1; | ||
| 52 | |||
| 53 | #ABSTRACT: Class for compiling with a VMS compiler | ||
| 54 | |||
| 55 | __END__ |