diff --git a/src/tools/msvc/builddoc.bat b/src/tools/msvc/builddoc.bat index dc76c7e0484..024706989e9 100755 --- a/src/tools/msvc/builddoc.bat +++ b/src/tools/msvc/builddoc.bat @@ -1,66 +1,7 @@ @echo off -REM Adjust path for your docbook installation in buildenv.pl REM src/tools/msvc/builddoc.bat - -SETLOCAL -SET STARTDIR=%CD% -SET OPENJADE=openjade-1.3.1 -SET DSSSL=docbook-dsssl-1.79 - -IF EXIST ..\msvc IF EXIST ..\..\..\src cd ..\..\.. -IF NOT EXIST doc\src\sgml\version.sgml goto noversion - -IF NOT EXIST src\tools\msvc\buildenv.pl goto nobuildenv -perl -e "require 'src/tools/msvc/buildenv.pl'; while(($k,$v) = each %ENV) { print qq[\@SET $k=$v\n]; }" > bldenv.bat -CALL bldenv.bat -del bldenv.bat -:nobuildenv - -IF NOT EXIST %DOCROOT%\%OPENJADE% SET NF=OpenJade -IF NOT EXIST %DOCROOT%\docbook SET NF=docbook -IF NOT EXIST %DOCROOT%\%DSSSL% set NF=docbook-dssl - -IF NOT "%NF%" == "" GOTO notfound - -IF "%1" == "renamefiles" GOTO renamefiles - -cmd /v /c src\tools\msvc\builddoc renamefiles -cd doc\src\sgml - -SET SGML_CATALOG_FILES=%DOCROOT%\%OPENJADE%\dsssl\catalog;%DOCROOT%\docbook\docbook.cat -perl %DOCROOT%\%DSSSL%\bin\collateindex.pl -f -g -o bookindex.sgml -N -perl mk_feature_tables.pl YES ..\..\..\src\backend\catalog\sql_feature_packages.txt ..\..\..\src\backend\catalog\sql_features.txt > features-supported.sgml -perl mk_feature_tables.pl NO ..\..\..\src\backend\catalog\sql_feature_packages.txt ..\..\..\src\backend\catalog\sql_features.txt > features-unsupported.sgml -perl make-errcodes-table.pl ..\..\..\src\backend\utils\errcodes.txt > errcodes-table.sgml - -echo Running first build... -%DOCROOT%\%OPENJADE%\bin\openjade -V draft-mode -wall -wno-unused-param -wno-empty -D . -c %DOCROOT%\%DSSSL%\catalog -d stylesheet.dsl -i output-html -t sgml postgres.sgml 2>&1 | findstr /V "DTDDECL catalog entries are not supported" -echo Running collateindex... -perl %DOCROOT%\%DSSSL%\bin\collateindex.pl -f -g -i bookindex -o bookindex.sgml HTML.index -echo Running second build... -%DOCROOT%\%OPENJADE%\bin\openjade -V draft-mode -wall -wno-unused-param -wno-empty -D . -c %DOCROOT%\%DSSSL%\catalog -d stylesheet.dsl -i output-html -t sgml postgres.sgml 2>&1 | findstr /V "DTDDECL catalog entries are not supported" - -cd %STARTDIR% -echo Docs build complete. -exit /b - - -:renamefiles -REM Rename ISO entity files -CD %DOCROOT%\docbook -FOR %%f in (ISO*) do ( - set foo=%%f - IF NOT "!foo:~-4!" == ".gml" ren !foo! !foo:~0,3!-!foo:~3!.gml -) -exit /b - -:notfound -echo Could not find directory for %NF%. -cd %STARTDIR% -goto :eof - -:noversion -echo Could not find version.sgml. Please run mkvcbuild.pl first! -cd %STARTDIR% -goto :eof +REM all the logic for this now belongs in builddoc.pl. This file really +REM only exists so you don't have to type "perl builddoc.pl" +REM Resist any temptation to add any logic here. +@perl builddoc.pl %* diff --git a/src/tools/msvc/builddoc.pl b/src/tools/msvc/builddoc.pl new file mode 100644 index 00000000000..deaf659e774 --- /dev/null +++ b/src/tools/msvc/builddoc.pl @@ -0,0 +1,122 @@ +# -*-perl-*- hey - emacs - this is a perl file + +# Adjust path for your docbook installation in buildenv.pl + +# src/tools/msvc/builddoc.pl +# translated from an earlier .bat file + +use strict; +use File::Copy; +use Cwd qw(abs_path getcwd); + + +my $startdir = getcwd(); + +my $openjade = 'openjade-1.3.1'; +my $dsssl = 'docbook-dsssl-1.79'; + +chdir '../../..' if (-d '../msvc' && -d '../../../src'); + +noversion() unless -e 'doc/src/sgml/version.sgml'; + +require 'src/tools/msvc/buildenv.pl' if -e 'src/tools/msvc/buildenv.pl'; + +my $docroot = $ENV{DOCROOT}; +die "bad DOCROOT '$docroot'" unless ($docroot && -d $docroot); + +my @notfound; +foreach my $dir ('docbook', $openjade, $dsssl) +{ + push(@notfound,$dir) unless -d "$docroot/$dir"; +} +missing() if @notfound; + +my $arg = shift; +renamefiles(); + + +chdir 'doc/src/sgml'; + +$ENV{SGML_CATALOG_FILES} = "$docroot/$openjade/dsssl/catalog;" . + "$docroot/docbook/docbook.cat"; + +my $cmd; + +# openjade exits below with a harmless non-zero status, so we +# can't die on "failure" + +$cmd = +"perl mk_feature_tables.pl YES " . + "../../../src/backend/catalog/sql_feature_packages.txt " . + "../../../src/backend/catalog/sql_features.txt " . + "> features-supported.sgml"; +system($cmd); die "features_supported" if $?; +$cmd = +"perl mk_feature_tables.pl NO " . + "\"../../../src/backend/catalog/sql_feature_packages.txt\" " . + "\"../../../src/backend/catalog/sql_features.txt\" " . + "> features-unsupported.sgml"; +system($cmd); die "features_unsupported" if $?; +$cmd = +"perl generate-errcodes-table.pl \"../../../src/backend/utils/errcodes.txt\" " . + "> errcodes-table.sgml"; +system($cmd); die "errcodes-table" if $?; + +print "Running first build...\n"; +$cmd = +"\"$docroot/$openjade/bin/openjade\" -V html-index -wall " . + "-wno-unused-param -wno-empty -D . -c \"$docroot/$dsssl/catalog\" " . + "-d stylesheet.dsl -i output-html -t sgml postgres.sgml 2>&1 " . + "| findstr /V \"DTDDECL catalog entries are not supported\" "; +system($cmd); # die "openjade" if $?; +print "Running collateindex...\n"; +$cmd = +"perl \"$docroot/$dsssl/bin/collateindex.pl\" -f -g -i bookindex " . + "-o bookindex.sgml HTML.index"; +system($cmd); die "collateindex" if $?; +mkdir "html"; +print "Running second build...\n"; +$cmd = +"\"$docroot/$openjade/bin/openjade\" -wall -wno-unused-param -wno-empty " . + "-D . -c \"$docroot/$dsssl/catalog\" -d stylesheet.dsl -t sgml " . + "-i output-html -i include-index postgres.sgml 2>&1 " . + "| findstr /V \"DTDDECL catalog entries are not supported\" "; + +system($cmd); # die "openjade" if $?; + +copy "stylesheet.css", "html/stylesheet.css"; + +print "Docs build complete.\n"; + +exit; + +######################################################## + +sub renamefiles +{ + # Rename ISO entity files + my $savedir = getcwd(); + chdir "$docroot/docbook"; + foreach my $f (glob('ISO*')) + { + next if $f =~ /\.gml$/i; + my $nf = $f; + $nf =~ s/ISO(.*)/ISO-$1.gml/; + move $f, $nf; + } + chdir $savedir; + +} + +sub missing +{ + print STDERR "could not find $docroot/$_\n" foreach (@notfound); + exit 1; +} + +sub noversion +{ + print STDERR "Could not find version.sgml. ", + "Please run mkvcbuild.pl first!\n"; + exit 1; +}