1#!/usr/bin/env perl 2# 3# Generate tags for lsquic project 4# 5# If your `ctags' is not Universal Ctags, set UCTAGS environment variable to 6# point to it. 7 8use warnings; 9 10use Getopt::Long; 11 12GetOptions("docs!" => \my $do_docs); 13 14$tmpfile = '.tags.' . $$ . rand; 15$ctags = $ENV{UCTAGS} || 'ctags'; 16$queue_h = '/usr/include/sys/queue.h'; 17 18@dirs = qw(include bin tests src/lshpack src/liblsquic); 19 20system($ctags, '-f', $tmpfile, 21 ('--kinds-c=+p') x !!$do_docs, # Index function prototypes 22 qw(-R -I SLIST_ENTRY+=void -I LIST_ENTRY+=void 23 -I STAILQ_ENTRY+=void -I TAILQ_ENTRY+=void -I CIRCLEQ_ENTRY+=void 24 -I TAILQ_ENTRY+=void -I SLIST_HEAD+=void -I LIST_HEAD+=void 25 -I STAILQ_HEAD+=void -I TAILQ_HEAD+=void -I CIRCLEQ_HEAD+=void 26 -I TAILQ_HEAD+=void), @dirs) 27 and die "ctags failed"; 28 29-f $queue_h 30 and system($ctags, '-f', $tmpfile, '-a', $queue_h) 31 and die "ctags $queue_h failed"; 32 33if ($do_docs) { 34 @rst = glob("docs/*.rst"); 35 if (@rst) { 36 system("$^X tools/gen-rst-tags.pl @rst >> $tmpfile") 37 and die "cannot run tools/gen-rst-tags.pl"; 38 } 39} 40 41END { unlink $tmpfile } 42 43open TMPFILE, "<", $tmpfile 44 or die "cannot open $tmpfile for reading: $!"; 45while (<TMPFILE>) 46{ 47 push @lines, $_; 48 if ( 49 s/^(mini|full|ietf_full|ietf_mini|evanescent)_conn_ci_/ci_/ 50 or s/^(nocopy|hash|error)_di_/di_/ 51 or s/^(gquic)_(be|Q046|Q050)_/pf_/ 52 or s/^ietf_v[0-9][0-9]*_/pf_/ 53 or s/^stock_shi_/shi_/ 54 or s/^iquic_esf_/esf_/ 55 or s/^gquic[0-9]?_esf_/esf_/ 56 or s/^iquic_esfi_/esfi_/ 57 or s/^lsquic_[sh]pi_/pii_/ 58 or s/^(lsquic_cubic|lsquic_bbr)_/cci_/ 59 ) 60 { 61 push @lines, $_; 62 } 63} 64open TMPFILE, ">", $tmpfile 65 or die "cannot open $tmpfile for writing: $!"; 66print TMPFILE sort @lines; 67close TMPFILE; 68rename $tmpfile, 'tags'; 69