| 1 |
#!/usr/bin/env perl |
| 2 |
|
| 3 |
# Copyright (c) MediaTek USA Inc., 2020 |
| 4 |
# |
| 5 |
# This program is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License as published by |
| 7 |
# the Free Software Foundation; either version 2 of the License, or (at |
| 8 |
# your option) any later version. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, but |
| 11 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
# General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU General Public License |
| 16 |
# along with this program; if not, see |
| 17 |
# <http://www.gnu.org/licenses/>. |
| 18 |
# |
| 19 |
# |
| 20 |
# p4annotate |
| 21 |
# |
| 22 |
# This script runs "p4 annotate" for the specified file and formats the result |
| 23 |
# to match the diffcov(1) 'annotate' callback specification: |
| 24 |
# use p4annotate; |
| 25 |
# my $callback = p4annotate->new([--md5] [--log logfile] [--verify]); |
| 26 |
# $callback->annotate(filename); |
| 27 |
# |
| 28 |
# It is implemented so that it can be loaded as a Perl module such that the |
| 29 |
# callback can be executed without incurring an additional process overhead - |
| 30 |
# which appears to be large and hightly variable in our compute farm environment. |
| 31 |
# |
| 32 |
# It can also be called directly, as |
| 33 |
# p4annotate [--md5] [--log logfild] [--verify] filename |
| 34 |
|
| 35 |
use strict; |
| 36 |
use FindBin; |
| 37 |
use lib "$FindBin::RealBin"; |
| 38 |
use p4annotate qw(new); |
| 39 |
use annotateutil qw(call_annotate); |
| 40 |
|
| 41 |
if (-f $ARGV[-1] || '-' ne index($ARGV[-1], 1)) { |
| 42 |
call_annotate('p4annotate', $0, @ARGV); |
| 43 |
} else { |
| 44 |
p4annotate->new($0, @ARGV); |
| 45 |
} |