docs/cmdline-opts: invoke managen using a relative path
... no need to use an absolute path, that makes the build unncessarily fail if invoked using a different mount point. managen now takes options to find the input files. Update test1478 to provide the dir arguments to managen Closes #13281
This commit is contained in:
parent
a3b084b913
commit
bcc2e90e45
@ -36,7 +36,8 @@ GN_0 = @echo " GENERATE" $@;
|
|||||||
GN_1 =
|
GN_1 =
|
||||||
GN_ = $(GN_0)
|
GN_ = $(GN_0)
|
||||||
|
|
||||||
MANAGEN=$(abs_top_srcdir)/scripts/managen
|
MANAGEN=$(top_srcdir)/scripts/managen
|
||||||
|
INCDIR=$(top_srcdir)/include
|
||||||
|
|
||||||
if BUILD_DOCS
|
if BUILD_DOCS
|
||||||
CLEANFILES = $(MANPAGE) $(ASCIIPAGE)
|
CLEANFILES = $(MANPAGE) $(ASCIIPAGE)
|
||||||
@ -47,10 +48,10 @@ all: $(MANPAGE) $(ASCIIPAGE)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
$(MANPAGE): $(DPAGES) $(SUPPORT) mainpage.idx Makefile.inc $(MANAGEN)
|
$(MANPAGE): $(DPAGES) $(SUPPORT) mainpage.idx Makefile.inc $(MANAGEN)
|
||||||
$(GEN)(rm -f $(MANPAGE) && (cd $(srcdir) && @PERL@ $(MANAGEN) mainpage $(DPAGES)) > manpage.tmp.$$$$ && mv manpage.tmp.$$$$ $(MANPAGE))
|
$(GEN)(rm -f $(MANPAGE) && @PERL@ $(MANAGEN) -d $(srcdir) -I $(INCDIR) mainpage $(DPAGES) > manpage.tmp.$$$$ && mv manpage.tmp.$$$$ $(MANPAGE))
|
||||||
|
|
||||||
$(ASCIIPAGE): $(DPAGES) $(SUPPORT) mainpage.idx Makefile.inc $(MANAGEN)
|
$(ASCIIPAGE): $(DPAGES) $(SUPPORT) mainpage.idx Makefile.inc $(MANAGEN)
|
||||||
$(GEN)(rm -f $(ASCIIPAGE) && (cd $(srcdir) && @PERL@ $(MANAGEN) ascii $(DPAGES)) > asciipage.tmp.$$$$ && mv asciipage.tmp.$$$$ $(ASCIIPAGE))
|
$(GEN)(rm -f $(ASCIIPAGE) && @PERL@ $(MANAGEN) -d $(srcdir) -I $(INCDIR) ascii $(DPAGES) > asciipage.tmp.$$$$ && mv asciipage.tmp.$$$$ $(ASCIIPAGE))
|
||||||
|
|
||||||
listhelp:
|
listhelp:
|
||||||
$(MANAGEN) listhelp $(DPAGES) > $(top_builddir)/src/tool_listhelp.c
|
$(MANAGEN) listhelp $(DPAGES) > $(top_builddir)/src/tool_listhelp.c
|
||||||
|
|||||||
@ -59,15 +59,6 @@ my $year = strftime "%Y", @ts;
|
|||||||
my $version = "unknown";
|
my $version = "unknown";
|
||||||
my $globals;
|
my $globals;
|
||||||
|
|
||||||
open(INC, "<../../include/curl/curlver.h");
|
|
||||||
while(<INC>) {
|
|
||||||
if($_ =~ /^#define LIBCURL_VERSION \"([0-9.]*)/) {
|
|
||||||
$version = $1;
|
|
||||||
last;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
close(INC);
|
|
||||||
|
|
||||||
# get the long name version, return the man page string
|
# get the long name version, return the man page string
|
||||||
sub manpageify {
|
sub manpageify {
|
||||||
my ($k)=@_;
|
my ($k)=@_;
|
||||||
@ -448,10 +439,10 @@ sub render {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub single {
|
sub single {
|
||||||
my ($manpage, $f, $standalone)=@_;
|
my ($dir, $manpage, $f, $standalone)=@_;
|
||||||
my $fh;
|
my $fh;
|
||||||
open($fh, "<:crlf", "$f") ||
|
open($fh, "<:crlf", "$dir/$f") ||
|
||||||
return 1;
|
die "could not find $dir/$f";
|
||||||
my $short;
|
my $short;
|
||||||
my $long;
|
my $long;
|
||||||
my $tags;
|
my $tags;
|
||||||
@ -781,8 +772,10 @@ sub single {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub getshortlong {
|
sub getshortlong {
|
||||||
my ($f)=@_;
|
my ($dir, $f)=@_;
|
||||||
open(F, "<:crlf", "$f");
|
$f =~ s/^.*\///;
|
||||||
|
open(F, "<:crlf", "$dir/$f") ||
|
||||||
|
die "could not find $dir/$f";
|
||||||
my $short;
|
my $short;
|
||||||
my $long;
|
my $long;
|
||||||
my $help;
|
my $help;
|
||||||
@ -833,16 +826,17 @@ sub getshortlong {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub indexoptions {
|
sub indexoptions {
|
||||||
my (@files) = @_;
|
my ($dir, @files) = @_;
|
||||||
foreach my $f (@files) {
|
foreach my $f (@files) {
|
||||||
getshortlong($f);
|
getshortlong($dir, $f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub header {
|
sub header {
|
||||||
my ($manpage, $f)=@_;
|
my ($dir, $manpage, $f)=@_;
|
||||||
my $fh;
|
my $fh;
|
||||||
open($fh, "<:crlf", "$f");
|
open($fh, "<:crlf", "$dir/$f") ||
|
||||||
|
die "could not find $dir/$f";
|
||||||
my @d = render($manpage, $fh, $f, 1);
|
my @d = render($manpage, $fh, $f, 1);
|
||||||
close($fh);
|
close($fh);
|
||||||
printdesc($manpage, 0, @d);
|
printdesc($manpage, 0, @d);
|
||||||
@ -952,13 +946,13 @@ sub listcats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub listglobals {
|
sub listglobals {
|
||||||
my (@files) = @_;
|
my ($dir, @files) = @_;
|
||||||
my @globalopts;
|
my @globalopts;
|
||||||
|
|
||||||
# Find all global options and output them
|
# Find all global options and output them
|
||||||
foreach my $f (sort @files) {
|
foreach my $f (sort @files) {
|
||||||
open(F, "<:crlf", "$f") ||
|
open(F, "<:crlf", "$dir/$f") ||
|
||||||
next;
|
die "could not read $dir/$f";
|
||||||
my $long;
|
my $long;
|
||||||
my $start = 0;
|
my $start = 0;
|
||||||
while(<F>) {
|
while(<F>) {
|
||||||
@ -999,12 +993,12 @@ sub sortnames {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub mainpage {
|
sub mainpage {
|
||||||
my ($manpage, @files) = @_;
|
my ($dir, $manpage, @files) = @_;
|
||||||
# $manpage is 1 for nroff, 0 for ASCII
|
# $manpage is 1 for nroff, 0 for ASCII
|
||||||
my $ret;
|
my $ret;
|
||||||
my $fh;
|
my $fh;
|
||||||
open($fh, "<:crlf", "mainpage.idx") ||
|
open($fh, "<:crlf", "$dir/mainpage.idx") ||
|
||||||
return 1;
|
die "no $dir/mainpage.idx file";
|
||||||
|
|
||||||
print <<HEADER
|
print <<HEADER
|
||||||
.\\" **************************************************************************
|
.\\" **************************************************************************
|
||||||
@ -1047,12 +1041,12 @@ HEADER
|
|||||||
if(/^%options/) {
|
if(/^%options/) {
|
||||||
# output docs for all options
|
# output docs for all options
|
||||||
foreach my $f (sort sortnames @files) {
|
foreach my $f (sort sortnames @files) {
|
||||||
$ret += single($manpage, $f, 0);
|
$ret += single($dir, $manpage, $f, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# render the file
|
# render the file
|
||||||
header($manpage, $f);
|
header($dir, $manpage, $f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close($fh);
|
close($fh);
|
||||||
@ -1080,15 +1074,15 @@ sub showprotocols {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub getargs {
|
sub getargs {
|
||||||
my ($f, @s) = @_;
|
my ($dir, $f, @s) = @_;
|
||||||
if($f eq "mainpage") {
|
if($f eq "mainpage") {
|
||||||
listglobals(@s);
|
listglobals($dir, @s);
|
||||||
mainpage(1, @s);
|
mainpage($dir, 1, @s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
elsif($f eq "ascii") {
|
elsif($f eq "ascii") {
|
||||||
listglobals(@s);
|
listglobals($dir, @s);
|
||||||
mainpage(0, @s);
|
mainpage($dir, 0, @s);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
elsif($f eq "listhelp") {
|
elsif($f eq "listhelp") {
|
||||||
@ -1108,15 +1102,42 @@ sub getargs {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print "Usage: managen <mainpage/ascii/listhelp/single FILE/protos/listcats> [files]\n";
|
print "Usage: managen ".
|
||||||
|
"[-d dir] <mainpage/ascii/listhelp/single FILE/protos/listcats> [files]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
|
|
||||||
|
my $dir = ".";
|
||||||
|
my $include = "../../include";
|
||||||
my $cmd = shift @ARGV;
|
my $cmd = shift @ARGV;
|
||||||
|
|
||||||
|
check:
|
||||||
|
if($cmd eq "-d") {
|
||||||
|
# specifies source directory
|
||||||
|
$dir = shift @ARGV;
|
||||||
|
$cmd = shift @ARGV;
|
||||||
|
goto check;
|
||||||
|
}
|
||||||
|
elsif($cmd eq "-I") {
|
||||||
|
# include path root
|
||||||
|
$include = shift @ARGV;
|
||||||
|
$cmd = shift @ARGV;
|
||||||
|
goto check;
|
||||||
|
}
|
||||||
|
|
||||||
my @files = @ARGV; # the rest are the files
|
my @files = @ARGV; # the rest are the files
|
||||||
|
|
||||||
# learn all existing options
|
open(INC, "<$include/curl/curlver.h");
|
||||||
indexoptions(@files);
|
while(<INC>) {
|
||||||
|
if($_ =~ /^#define LIBCURL_VERSION \"([0-9.]*)/) {
|
||||||
|
$version = $1;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close(INC);
|
||||||
|
|
||||||
getargs($cmd, @files);
|
# learn all existing options
|
||||||
|
indexoptions($dir, @files);
|
||||||
|
|
||||||
|
getargs($dir, $cmd, @files);
|
||||||
|
|||||||
@ -19,7 +19,7 @@ src/tool_listhelp.c is in sync with docs/cmdline-opts
|
|||||||
</name>
|
</name>
|
||||||
|
|
||||||
<command type="perl">
|
<command type="perl">
|
||||||
%SRCDIR/../scripts/managen listhelp %SRCDIR/../docs/cmdline-opts/*.md
|
%SRCDIR/../scripts/managen -d %SRCDIR/../docs/cmdline-opts -I %SRCDIR/../include listhelp %SRCDIR/../docs/cmdline-opts/*.md
|
||||||
</command>
|
</command>
|
||||||
</client>
|
</client>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user