| 1 | package Upp::Reader; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.012004; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 1 | require Exporter; | |||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||
| 9 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||||
| 12 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||||
| 13 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | # This allows declaration use Upp::Reader ':all'; | ||||||||||||||||||||||||||||||||
| 16 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||||||
| 17 | # will save memory. | ||||||||||||||||||||||||||||||||
| 18 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | ) ] ); | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 1 | $VERSION = '0.1'; | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub remove_escapes { | ||||||||||||||||||||||||||||||
|
Subroutine
remove_escapes: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 33 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||
| 34 | 0 | $s =~ s/\\(.)/$1/g; | |||||||||||||||||||||||||||||||
| 35 | 0 | return $s; | |||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub read_upp { | ||||||||||||||||||||||||||||||
|
Subroutine
read_upp: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 39 | 0 | my $filename = shift; | |||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | open my $in, $filename or die "could not open upp file"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | 0 | my $content = join "", <$in>; | |||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | 0 | my ( $file, $options, $link ) = extract($content); | |||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||
| 48 | sub extract | ||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
extract: not called CC=23 SCAR=63.1
Pod
documented
| |||||||||||||||||||||||||||||||||
| 51 | 0 | my $content = shift; | |||||||||||||||||||||||||||||||
| 52 | 0 | my @file; | |||||||||||||||||||||||||||||||
| 53 | my %options; | ||||||||||||||||||||||||||||||||
| 54 | 0 | my %link; | |||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | while ( $content =~ /((?:[^";]+|\"(?:\\.|.)*?\")+?)\s*;/sg ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | #print ">>$1<<\n"; | ||||||||||||||||||||||||||||||||
| 58 | 0 | my $statement = $1; | |||||||||||||||||||||||||||||||
| 59 | 0 | my $first = 1; | |||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ( $statement =~ /\s*([^\s(]+)(?:\((.+?)\))?/gc ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | #print ">>>>>>>$1 $2\n"; | ||||||||||||||||||||||||||||||||
| 63 | 0 | my ( $section, $options ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ( $section eq "options" or $section eq "link" ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$section eq "options" or $section eq "link"
MC/DC0%0/2
$section eq "options" or $section eq "link"
$section eq "options"
$section eq "link"
Truth table0%0/3
A or B
A= $section eq "options"B= $section eq "link"
| |||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if ( $statement =~ /\G\s*\"((?:\\.|.)*?)\"|\s*(.+)/gc ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 66 | 0 | my @configuration = split /\s*\|\s*/, $options; | |||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | if ( $section eq "options" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 68 | 0 | for my $c (@configuration) { | |||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | push @{ $options{$c} }, defined $1 ? remove_escapes($1) : $2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | if ( $section eq "link" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | 0 | for my $c (@configuration) { | |||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | push @{ $link{$c} }, defined $1 ? remove_escapes($1) : $2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||
| 79 | elsif ( $section eq "file" ) { | ||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if ( $statement =~ /\G\s*(.+)/gcs ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 81 | 0 | my $filelist = $1; | |||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | #my @filelist; | ||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | while ( $filelist | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 85 | =~ /((?:[^",]+|\"(?:\\.|.)*?\")+?)\s*,\s*|((?:[^",]+|\"(?:\\.|.)*?\")+?)\s*/gs ) | ||||||||||||||||||||||||||||||||
| 86 | { | ||||||||||||||||||||||||||||||||
| 87 | 0 | my $file_and_options = $1 . $2; | |||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ( $file_and_options =~ /s*\"((?:\\.|.)*?)\"|\s*(.+)/g ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | my $filename = defined $1 ? remove_escapes($1) : $2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 90 | 0 | my %options; | |||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if ( $file_and_options =~ /\s*([^\s(]+)(?:\((.+?)\))?/gc ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | #print ">>>>>>>$1 $2\n"; | ||||||||||||||||||||||||||||||||
| 94 | 0 | my ( $section, $options ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ( $section eq "options" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ( $file_and_options =~ /\G\s*\"((?:\\.|.)*?)\"|\s*(.+)/gc ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 97 | 0 | my @configuration = split /\s*\|\s*/, $options; | |||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ( $section eq "options" ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 99 | 0 | for my $c (@configuration) { | |||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | push @{ $options{$c} }, defined $1 ? remove_escapes($1) : $2; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||
| 106 | 0 | push @file, [ $filename, \%options ]; | |||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | # while (/\s+|\"((?:\\.|.)+?)\")|([^\s]+)/sg) | ||||||||||||||||||||||||||||||||
| 114 | # { | ||||||||||||||||||||||||||||||||
| 115 | # if (defined $2 && $first) | ||||||||||||||||||||||||||||||||
| 116 | # { | ||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||
| 118 | # $first = 1; | ||||||||||||||||||||||||||||||||
| 119 | # } | ||||||||||||||||||||||||||||||||
| 120 | # } | ||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | # for my $k (%options) { | ||||||||||||||||||||||||||||||||
| 125 | # print "$k $options{$k}\n"; | ||||||||||||||||||||||||||||||||
| 126 | # } | ||||||||||||||||||||||||||||||||
| 127 | 0 | return ( \@file, \%options, \%link ); | |||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | sub format_filelist { | ||||||||||||||||||||||||||||||
|
Subroutine
format_filelist: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 131 | 0 | my ($filelist) = @_; | |||||||||||||||||||||||||||||||
| 132 | 0 | my $outstr; | |||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||
| 134 | #print "$f->[0]\n"; | ||||||||||||||||||||||||||||||||
| 135 | 0 | $outstr = join " ", @$filelist; | |||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||
| 137 | 0 | return $outstr; | |||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub add_switch { | ||||||||||||||||||||||||||||||
|
Subroutine
add_switch: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 141 | 0 | my $sw = shift; | |||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return " " . $sw if ($sw); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 143 | 0 | return ""; | |||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | sub make_compilation { | ||||||||||||||||||||||||||||||
|
Subroutine
make_compilation: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 147 | 0 | my ( $filelist, $options, $link, $target, $compiler_exe, $linker_exe, $compiler_flags, $link_flags ) = @_; | |||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||
| 149 | # -Ic:\mingw\include -IC:\mingw\include\c++\3.4.5 -IC:\mingw\include\c++\3.4.5\mingw32\bits | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | 0 | my $commandlist; | |||||||||||||||||||||||||||||||
| 152 | my @objs; | ||||||||||||||||||||||||||||||||
| 153 | 0 | my $o_ext = ".o"; | |||||||||||||||||||||||||||||||
| 154 | 0 | my $o_sw = "-o "; | |||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | if ( $target =~ /^msc/i ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 156 | 0 | $o_ext = ".obj"; | |||||||||||||||||||||||||||||||
| 157 | 0 | $o_sw = "-Fo"; | |||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||
| 159 | 0 | for my $f (@$filelist) { | |||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | #print "$f->[0]\n"; | ||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if ( $f->[0] =~ /^\.cpp|\.c$/ ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 163 | 0 | my $out_filename = $f->[0]; | |||||||||||||||||||||||||||||||
| 164 | 0 | $out_filename =~ s/\.\w+$/$o_ext/; | |||||||||||||||||||||||||||||||
| 165 | $commandlist | ||||||||||||||||||||||||||||||||
| 166 | .= $compiler_exe . " -c " | ||||||||||||||||||||||||||||||||
| 167 | . $f->[0] | ||||||||||||||||||||||||||||||||
| 168 | . " $o_sw" | ||||||||||||||||||||||||||||||||
| 169 | . $out_filename | ||||||||||||||||||||||||||||||||
| 170 | . add_switch( $f->[1]->{$target} ) | ||||||||||||||||||||||||||||||||
| 171 | 0 | . add_switch( join " ", @{ $options->{$target} } ) | |||||||||||||||||||||||||||||||
| 172 | . add_switch($compiler_flags) . "\n"; | ||||||||||||||||||||||||||||||||
| 173 | 0 | push @objs, $out_filename; | |||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||
| 177 | 0 | $commandlist .= $linker_exe; | |||||||||||||||||||||||||||||||
| 178 | 0 | for my $obj (@objs) { | |||||||||||||||||||||||||||||||
| 179 | 0 | $commandlist .= " " . $obj; | |||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||
| 182 | 0 | $commandlist .= add_switch( join "", @{ $link->{$target} } ) . add_switch($link_flags); | |||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | 0 | return $commandlist; | |||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub example1 { | ||||||||||||||||||||||||||||||
|
Subroutine
example1: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 188 | 0 | print Upp::Reader::make_compilation ( | |||||||||||||||||||||||||||||||
| 189 | Upp::Reader::read_upp('D:\m\upp\extractor\extractor.upp'), | ||||||||||||||||||||||||||||||||
| 190 | 'GCC', 'gcc.exe', 'ld.exe', '-DRELEASE', '' | ||||||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||
| 194 | 1 | 1; | |||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||
| 196 | __END__ | ||||||||||||||||||||||||||||||||