-
-
Save AlexDaniel/76a4aa8205f854dfaf461f5eb7e2a987 to your computer and use it in GitHub Desktop.
bloatable preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
# Copyright © 2016-2017 | |
# Aleks-Daniel Jakimenko-Aleksejev <alex.jakimenko@gmail.com> | |
# Copyright © 2016 | |
# Daniel Green <ddgreen@gmail.com> | |
# | |
# This program is free software: you can redistribute it and/or modify | |
# it under the terms of the GNU Affero General Public License as published by | |
# the Free Software Foundation, either version 3 of the License, or | |
# (at your option) any later version. | |
# | |
# This program is distributed in the hope that it will be useful, | |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
# GNU Affero General Public License for more details. | |
# | |
# You should have received a copy of the GNU Affero General Public License | |
# along with this program. If not, see <http://www.gnu.org/licenses/>. | |
use lib ‘.’; | |
use Misc; | |
use Whateverable; | |
use IRC::Client; | |
unit class Bloatable does Whateverable; | |
method help($msg) { | |
“Like this: {$msg.server.current-nick}: f583f22,HEAD” | |
} | |
multi method irc-to-me($msg where ?.text) { | |
my $value = self.process: $msg, $msg.text; | |
return without $value; | |
return $value but Reply($msg) | |
} | |
method process($msg, $config) { | |
my $old-dir = $*CWD; | |
my ($commits-status, @commits) = self.get-commits: $config, repo => MOARVM; | |
return $commits-status unless @commits; | |
dd @commits; | |
my %files; | |
my %prev; | |
for @commits -> $commit { | |
my %cur; | |
# convert to real ids so we can look up the builds | |
%cur<full-commit> = self.to-full-commit: $commit, repo => MOARVM; | |
if not defined %cur<full-commit> { | |
%cur<error> = “Cannot find revision $commit”; | |
my @options = <HEAD v6.c releases all>; | |
%cur<error> ~= “ (did you mean “{self.get-short-commit: self.get-similar: $commit, @options, repo => MOARVM}”?)” | |
} elsif not self.build-exists: %cur<full-commit>, :backend<moarvm> { | |
%cur<error> = ‘No build for this commit’ | |
} | |
%cur<short-commit> = self.get-short-commit: $commit; | |
%cur<short-commit> ~= “({self.get-short-commit: %cur<full-commit>})” if $commit eq ‘HEAD’; | |
if %prev { | |
my $filename = “result-{(1 + %files).fmt: ‘%05d’}”; | |
my $result = “Comparing %prev<short-commit> → %cur<short-commit>\n”; | |
if %prev<error> { | |
$result ~= “Skipping because of the error with %prev<short-commit>:\n”; | |
$result ~= %prev<error>; | |
} elsif %cur<error> { | |
$result ~= “Skipping because of the error with %cur<short-commit>:\n”; | |
$result ~= %cur<error>; | |
} else { | |
$result ~= | |
self.run-smth: :backend<moarvm>, %prev<full-commit>, -> $prev-path { | |
!“$prev-path/lib/libmoar.so”.IO.e | |
?? “No libmoar.so file in build %prev<short-commit>” | |
!! self.run-smth: :backend<moarvm>, %cur<full-commit>, -> $cur-path { | |
!“$cur-path/lib/libmoar.so”.IO.e | |
?? “No libmoar.so file in build %cur<short-commit>” | |
!! self.get-output(‘bloaty’, ‘-d’, ‘compileunits’, ‘-n’, ‘50’, | |
“$cur-path/lib/libmoar.so”, ‘--’, “$prev-path/lib/libmoar.so”)<output> | |
} | |
} | |
} | |
%files{$filename} = $result; | |
} | |
%prev = %cur; | |
} | |
if @commits == 1 { | |
return %prev<error> if %prev<error>; | |
return self.run-smth: :backend<moarvm>, %prev<full-commit>, -> $prev-path { | |
!“$prev-path/lib/libmoar.so”.IO.e | |
?? “No libmoar.so file in build %prev<short-commit>” | |
!! “%prev<short-commit>\n” | |
~ self.get-output(‘bloaty’, ‘-d’, ‘compileunits’, ‘-n’, ‘100’, | |
“$prev-path/lib/libmoar.so”)<output> | |
} | |
} else { | |
return ‘’ but FileStore(%files); | |
} | |
LEAVE { | |
chdir $old-dir; | |
} | |
} | |
Bloatable.new.selfrun: ‘bloatable6’, [ /‘bloat’ y?6?/, fuzzy-nick(‘bloatable6’, 2) ] | |
# vim: expandtab shiftwidth=4 ft=perl6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment