forked from open-mpi/ompi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-owner.pl
executable file
·178 lines (147 loc) · 4.26 KB
/
check-owner.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env perl
#
# Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2015 Los Alamos National Security, LLC. All rights reserved.
# $COPYRIGHT$
#
# Simple script to traverse the OMPI source tree that looks for
# owner.txt files, and generates <project>_mca_owner.md files.
#
use strict;
use Cwd;
use File::Find;
use Getopt::Long;
use Data::Dumper;
my $num_warnings = 0;
my $num_errors = 0;
###########################################################################
my $VERBOSE = 0;
my $HELP = 0;
GetOptions(
"help|h" => \$HELP,
"verbose|v" => \$VERBOSE,
) or die "unable to parse options, aborted";
if ($HELP) {
print <<EOF;
%0 [options]
--help | h This help message
--verbose | v Be verbose in output
EOF
exit(0);
}
###########################################################################
sub verbose {
print @_
if ($VERBOSE);
}
sub DebugDump {
my $d = new Data::Dumper([@_]);
$d->Purity(1)->Indent(1);
my $s = $d->Dump;
print $s;
}
sub isTopDir {
my ($d) = @_;
# master
if (-f "$d/Makefile.ompi-rules") {
return 1;
}
# v1.8
if (-f "$d/Makefile.man-page-rules") {
return 1;
}
return 0;
}
###########################################################################
# Find the top-level OMPI source tree dir
my $start = cwd();
my $top = $start;
while (!isTopDir($top)) {
chdir("..");
$top = cwd();
die "Can't find top-level Open MPI directory"
if ($top eq "/");
}
chdir($start);
###########################################################################
my @owner_files;
# Helper: Search for all owner files
sub match_files {
# Don't process sym links
return
if (-l $_);
# Don't recurse down "special" directories
if (-d $_ &&
((/^\.deps$/) || (/^\.libs$/) ||
(/^\.svn$/) || (/^\.hg$/) || (/^\.git$/))) {
$File::Find::prune = 1;
return;
}
# $File::Find::name is the path relative to the starting point.
# $_ contains the file's basename. The code automatically changes
# to the processed directory, so we want to open / close $_.
verbose("--> $File::Find::name\n");
my $relative = $File::Find::name;
$relative =~ s/^$top//;
$relative =~ s/^\///;
my $short = $_;
if ($short =~ "owner.txt") {
push(@owner_files, {
full => $File::Find::name,
short => $short,
relative => $relative,
});
verbose(" Found owner file: $short\n");
}
}
# Find all owner files
print "Searching for owner files...\n";
my $startrel = $start;
if ($top ne $start) {
$startrel =~ s/^$top//;
$startrel =~ s/^\///;
}
find(\&match_files, ".");
###########################################################################
# Index all help files
my $help_topics;
my $help_file_refs;
print "Indexing owner files (from entire source tree)...\n";
my $old_lib = "";
my $filename;
foreach my $info (@owner_files) {
verbose("Indexing owner: $info->{full}\n");
open(OWNERFILE, $info->{full}) || die "Could not open file $info->{full}\n";
my $owner="unknown";
my $status="unknown";
my $label="unknown";
while (<OWNERFILE>) {
next if /^#/;
chop;
if (/^owner/) {
($label,$owner) = split(/:/);
$owner =~ s/\s//ge; # get rid of white space, may need something better
}
if (/^status/) {
($label,$status) = split(/:/);
$status =~ s/\s//ge;
}
}
my @components = split(/\//,$info->{full});
shift(@components);
my $lib = shift(@components);
if ($lib ne $old_lib) {
$filename = $lib."_mca_owner.md";
printf("hey, found a new lib %s filename %s\n",$lib,$filename);
open(MDFILE, ">$filename") || die "Could not open file $filename\n";
printf(MDFILE "| Framework | Component | Owner | Status |\n");
printf(MDFILE "| --- | --- | --- | --- |\n");
$old_lib = $lib;
}
shift(@components);
my $frame = shift(@components);
my $comp = shift(@components);
printf("For lib %s framework %s component %s owner %s status %s\n", $lib, $frame, $comp, $owner, $status);
printf(MDFILE "| $frame | $comp | $owner | $status |\n");
close (OWNERFILE);
}