blib/lib/SPVM/Builder/compile.pl

filter: Statementstmt 92.3% 36 / 39 Branchbran 58.3% 7 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 86.2% 50 / 58 CC 1 SCAR 0.0
CC
1
Cov
84%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/SPVM/Builder/link.pl ↑ Summary blib/script/spvmdist »
1 273 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 273 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 273 ▶use MIME::Base64 qw(decode_base64);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 273 ▶use File::Copy 'move';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 273 ▶use File::Path 'mkpath';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 273 ▶use File::Basename 'basename', 'dirname';
Subroutine BEGIN: called CC=1 SCAR=0.0
7 273 ▶use Carp 'confess';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # Get arguments
10 273 my @argv = split("\0", decode_base64($ARGV[0]));
11 273 my ($command_tmp_dir, $output_file, @cc_cmd) = @argv;
12  
13 # Define log file paths
14 273 my $log_stdout = "$command_tmp_dir/stdout.log";
15 273 my $log_stderr = "$command_tmp_dir/stderr.log";
16  
17 # Redirect stdout and stderr to log files
18 273 ▶open(STDOUT, '>', $log_stdout)
Branch: 1 branch
BranchTrueFalseTotal
open STDOUT, ">", $log_stdout or die "Can't open file '${log_stdout}': $!" 273 0 273
19 or die "Can't open file '$log_stdout': $!";
20 273 ▶open(STDERR, '>', $log_stderr)
Branch: 1 branch
BranchTrueFalseTotal
open STDERR, ">", $log_stderr or die "Can't open file '${log_stderr}': $!" 273 0 273
21 or die "Can't open file '$log_stderr': $!";
22  
23 # Use a temporary file for atomic output generation
24 273 my $tmp_output_file = "$output_file.tmp.$$";
25 273 $cc_cmd[-1] .= $tmp_output_file;
26  
27 273 mkpath dirname $output_file;
28  
29 # Execute the command
30 273 my $system_status = system(@cc_cmd);
31  
32 273 ▶if ($system_status == -1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($system_status == -1) { } 0 273 273
elsif ($system_status & 127) { } 0 273 273
33 0 die "Failed to execute compilation command. \$!=$!, \@cc_cmd='@cc_cmd'";
34 }
35 elsif ($system_status & 127) {
36 0 my $signal = $system_status & 127;
37 0 die "Compilation command died with signal. \$signal=$signal, \@cc_cmd='@cc_cmd'";
38 }
39 else {
40 273 my $exit_status = $system_status >> 8;
41 273 ▶ if ($exit_status != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exit_status != 0) 4 269 273
42 4 die "Compilation command failed with exit code. \$exit_status=$exit_status, \@cc_cmd='@cc_cmd'";
43 }
44 }
45  
46 # Atomically replace the target file
47 269 ▶move($tmp_output_file, $output_file)
Branch: 1 branch
BranchTrueFalseTotal
move($tmp_output_file, $output_file) or confess("Can't move '${tmp_output_file}' to '${output_file}':$!") 269 0 269
48 or confess("Can't move '$tmp_output_file' to '$output_file':$!");
« blib/lib/SPVM/Builder/link.pl ↑ Summary blib/script/spvmdist »