| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Sybil; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
55480
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
5
|
1
|
|
|
1
|
|
12
|
use v5.12; |
|
|
1
|
|
|
|
|
3
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.4'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
243
|
use App::Cmd::Setup -app; |
|
|
1
|
|
|
|
|
29546
|
|
|
|
1
|
|
|
|
|
10
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
885
|
use Capture::Tiny ':all'; |
|
|
1
|
|
|
|
|
20815
|
|
|
|
1
|
|
|
|
|
232
|
|
|
12
|
1
|
|
|
1
|
|
319
|
use File::Copy; |
|
|
1
|
|
|
|
|
1775
|
|
|
|
1
|
|
|
|
|
50
|
|
|
13
|
1
|
|
|
1
|
|
337
|
use File::Slurp; |
|
|
1
|
|
|
|
|
9594
|
|
|
|
1
|
|
|
|
|
77
|
|
|
14
|
1
|
|
|
1
|
|
8
|
use File::Spec; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
740
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _build { |
|
17
|
0
|
|
|
0
|
|
|
my ($self, $target, @opts) = @_; |
|
18
|
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
system 'bazel', 'build', '-c', 'opt', ":$target", @opts; |
|
20
|
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
if ($? == -1) { |
|
22
|
0
|
|
|
|
|
|
say STDERR 'Build failed'; |
|
23
|
0
|
|
|
|
|
|
return undef; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
return 1; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _build_linux { |
|
30
|
0
|
|
|
0
|
|
|
my ($self, $project, $version) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# TODO autodetect build rule |
|
33
|
0
|
|
|
|
|
|
my $target = "$project-linux"; |
|
34
|
0
|
0
|
|
|
|
|
$self->_build($target) or return undef; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# TODO improve result name detection |
|
37
|
0
|
|
|
|
|
|
my $file = "$project-$version-linux.tgz"; |
|
38
|
0
|
0
|
|
|
|
|
unless (copy("bazel-bin/$target.tgz", $file)) { |
|
39
|
0
|
|
|
|
|
|
say STDERR "Copy bazel-bin/$target.tgz to $file failed: $!"; |
|
40
|
0
|
|
|
|
|
|
return undef; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
say STDERR 'Build complete'; |
|
44
|
0
|
|
|
|
|
|
return 1; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _build_windows { |
|
48
|
0
|
|
|
0
|
|
|
my ($self, $project, $version) = @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
my @options = |
|
51
|
|
|
|
|
|
|
('--crosstool_top', '@mxebzl//tools/windows:toolchain', '--cpu', 'win64'); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# TODO autodetect build rule |
|
54
|
0
|
|
|
|
|
|
my $target = "$project-windows"; |
|
55
|
0
|
0
|
|
|
|
|
$self->_build($target, @options) or return undef; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# TODO improve result name detection |
|
58
|
0
|
|
|
|
|
|
my $file = "$project-$version-windows.zip"; |
|
59
|
0
|
0
|
|
|
|
|
unless (copy("bazel-bin/$target.zip", $file)) { |
|
60
|
0
|
|
|
|
|
|
say STDERR "Copy bazel-bin/$target.zip to $file failed: $!"; |
|
61
|
0
|
|
|
|
|
|
return undef; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
say STDERR 'Build complete'; |
|
65
|
0
|
|
|
|
|
|
return 1; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub build_all_targets { |
|
69
|
0
|
|
|
0
|
0
|
|
my ($self, $project, $version) = @_; |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
$self->_build_linux($project, $version) or return undef; |
|
72
|
0
|
0
|
|
|
|
|
$self->_build_windows($project, $version) or return undef; |
|
73
|
0
|
|
|
|
|
|
return 1; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _get_project_from_path { |
|
77
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my @dirs = File::Spec->splitdir(File::Spec->rel2abs(File::Spec->curdir)); |
|
80
|
0
|
|
|
|
|
|
return $dirs[-1]; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub project { |
|
84
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
0
|
|
|
|
$self->{project} ||= $self->_get_project_from_path(); |
|
87
|
0
|
|
|
|
|
|
return $self->{project}; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _get_version_from_git { |
|
91
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $version = capture_stdout { |
|
94
|
0
|
|
|
0
|
|
|
system 'git', 'describe', '--dirty', '--tags'; |
|
95
|
0
|
|
|
|
|
|
}; |
|
96
|
0
|
|
|
|
|
|
chomp $version; |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
return $version; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub version { |
|
102
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
|
0
|
|
|
|
$self->{version} ||= $self->_get_version_from_git(); |
|
105
|
0
|
|
|
|
|
|
return $self->{version}; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub targets { |
|
109
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return qw(linux windows); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub output_file { |
|
115
|
0
|
|
|
0
|
0
|
|
my ($self, $version, $target) = @_; |
|
116
|
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
return $self->project . "-$version-$target." . ($target =~ /^win/ ? 'zip' : 'tgz'); |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub has_build { |
|
121
|
0
|
|
|
0
|
0
|
|
my ($self, $version) = @_; |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
foreach my $target ($self->targets) { |
|
124
|
0
|
|
|
|
|
|
my $file = $self->output_file($version, $target); |
|
125
|
0
|
0
|
|
|
|
|
unless (-e $file) { |
|
126
|
0
|
|
|
|
|
|
say STDERR "Missing build artifact $file"; |
|
127
|
0
|
|
|
|
|
|
return undef; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
return 1; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
|
0
|
0
|
|
sub local_config { return '.sybilrc'; } |
|
135
|
0
|
|
|
0
|
0
|
|
sub global_config { return File::Spec->catfile($ENV{HOME}, '.sybilrc'); } |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub _write_token { |
|
138
|
0
|
|
|
0
|
|
|
my ($self, $token) = @_; |
|
139
|
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
write_file($self->global_config, $token); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub _read_token { |
|
144
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
|
145
|
|
|
|
|
|
|
|
|
146
|
0
|
0
|
|
|
|
|
if (-f $self->local_config) { |
|
|
|
0
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
return read_file($self->local_config); |
|
148
|
|
|
|
|
|
|
} elsif (-f $self->global_config) { |
|
149
|
0
|
|
|
|
|
|
return read_file($self->global_config); |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
return undef; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub github_token { |
|
156
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
0
|
|
|
|
$self->{token} ||= $self->_read_token(); |
|
159
|
0
|
|
|
|
|
|
return $self->{token}; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1; |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
__END__ |