source: valtobtest/subversion-1.6.2/packages/windows-innosetup/tools/mk_svndoc.pl @ 3

Last change on this file since 3 was 3, checked in by valtob, 15 years ago

subversion source 1.6.2 as test

File size: 7.5 KB
Line 
1#!perl
2##########################################################################
3# FILE       mk_svndoc
4# PURPOSE    Making MS HTML-help from the Subversion source documentation
5# ====================================================================
6# Copyright (c) 2000-2005 CollabNet.  All rights reserved.
7#
8# This software is licensed as described in the file COPYING, which
9# you should have received as part of this distribution.  The terms
10# are also available at http://subversion.tigris.org/license-1.html.
11# If newer versions of this license are posted there, you may use a
12# newer version instead, at your option.
13#
14# This software consists of voluntary contributions made by many
15# individuals.  For exact contribution history, see the revision
16# history and logs, available at http://subversion.tigris.org/.
17# ====================================================================
18
19##########################################################################
20# INCLUDED LIBRARY FILES
21use strict;
22use File::Basename;
23use Cwd;
24use Win32;
25require 'cmn.pl';
26
27##########################################################################
28# FUNCTION DECLARATIONS
29sub Main;
30sub CheckForProgs;
31sub CopyAndEolU2W;
32sub MkDirP;
33
34##########################################################################
35# CONSTANTS AND GLOBAL VARIABLES
36# Sorces and destinations
37my $g_PathDocRoot=&cmn_ValuePathfile('path_svnbook');
38my $g_PathSubvRoot=&cmn_ValuePathfile('path_subversion');
39my $g_PathMiscIn=&cmn_ValuePathfile('path_setup_in');
40my %g_FilesToCpAndConv=
41    (
42        'COPYING', 'subversion\SubversionLicense.txt',
43        'README', 'subversion\Readme.dist',
44        'doc\user\lj_article.txt', 'doc\lj_article.txt',
45        'doc\programmer\WritingChangeLogs.txt', 'doc\WritingChangeLogs.txt',
46    );
47
48# Programs needed for making the documentation
49my $g_Prog_hhc='';
50my %g_ProgsInPath=
51    (
52        'libxslt is needed for converting the XML-documentaion.',
53            'xsltproc.exe',
54        'iconv is needed by libxslt and libxslt for converting the XML-documentaion.',
55            'iconv.exe',
56        'libxml2 is needed by libxslt for converting the XML-documentaion.',
57            'libxml2.dll'
58    );
59
60##########################################################################
61# PROGRAM ENTRANCE
62Main;
63
64##########################################################################
65# FUNCTION DEFINITIONS
66#-------------------------------------------------------------------------
67# FUNCTION   Main
68# DOES       This is the program's main function
69sub Main
70{
71    my $CntMkHtmBat='';
72    my %Values;
73    my $RootSvnBook=&cmn_ValuePathfile('path_svnbook');
74    my $DocOut=&cmn_ValuePathfile('path_setup_in');
75    my $PathWinIsPack='';
76    my $Pwd='';
77    my $CntVerXml='';
78
79    # Get absolute path of the current PWD's parent
80    $PathWinIsPack=getcwd;
81    $Pwd=basename($PathWinIsPack);
82    $PathWinIsPack =~ s/\//\\/g;
83    $PathWinIsPack =~ s/\\$Pwd$//;
84
85    # Make $DocOut to an absolute path
86    if ($DocOut eq 'in')
87      {
88        $DocOut = "$PathWinIsPack\\in\\doc";
89      }
90
91    #Make the out dir in "$RootSvnBook\src if needed
92    &MkDirP ("$RootSvnBook\\src\\out") unless (-e "$RootSvnBook\\src\\out");
93
94    #Make the in dir for path_setup_in if needed
95    &MkDirP ("$DocOut") unless (-e "$DocOut");
96
97    #Check for needed programs
98    &CheckForProgs;
99    &CopyAndEolU2W;
100
101    #Create the mk_htmlhelp.bat file from ..\templates\\mk_htmlhelp.bat and
102    #collected data, save it to $RootSvnBook\src\out\mk_htmlhelp.bat
103    %Values =
104      (
105        tv_path_hhc => $g_Prog_hhc,
106        tv_bookdest => $DocOut
107      );
108
109    $CntMkHtmBat=&cmn_Template("$PathWinIsPack\\templates\\mk_htmlhelp.bat", \%Values);
110
111    open (FH_HHP, ">" . "$RootSvnBook\\src\\out\\mk_htmlhelp.bat");
112        print FH_HHP $CntMkHtmBat;
113    close (FH_HHP);
114
115    #Copy style sheet and background image to $RootSvnBook\src\out
116    system ("copy /Y ..\\templates\\svn-doc.css $RootSvnBook\\src\\out");
117    system ("copy /Y ..\\images\\svn_bck.png $RootSvnBook\\src\\out");
118
119    # Set the revision number in $RootSvnBook\src\en\book\version.xml
120    chdir "$RootSvnBook\\src\\en";
121    $CntVerXml=`svnversion .`;
122    chomp($CntVerXml);
123
124    open (FH_VERXML, ">" . "$RootSvnBook\\src\\en\\book\\version.xml");
125        print FH_VERXML "<!ENTITY svn.version \"Revision $CntVerXml\">";
126    close (FH_VERXML);
127
128    # Make the chm file
129    chdir "$RootSvnBook\\src\\out";
130    system ("$RootSvnBook\\src\\out\\mk_htmlhelp.bat");
131    chdir $Pwd;
132}
133
134#-------------------------------------------------------------------------
135# FUNCTION   CheckForProgs
136# DOES       Checking if required programs exists
137sub CheckForProgs
138{
139    my @MissingProgs;
140    my @SysPath;
141    my $bMissingProgs=0;
142    my $Prog2CheckDesc='';
143    my $Prog2Check='';
144
145    # Fill the %PATH% in @SysPath
146    @SysPath = split (/;/, $ENV{PATH});
147
148    # Check for the needed programs who should be in the %PATH%
149    while (($Prog2CheckDesc, $Prog2Check) = each %g_ProgsInPath)
150      {
151        my $bProg2CheckExists=0;
152
153        for (@SysPath)
154          {
155            if (-e "$_\\$Prog2Check")
156              {
157                $bProg2CheckExists=1;
158                last;
159              }
160          }
161
162        if (! $bProg2CheckExists)
163          {
164            $bMissingProgs = 1;
165            push @MissingProgs, $Prog2CheckDesc;
166          }
167      }
168
169    # Check for MS HTML help compiler
170    $g_Prog_hhc = &cmn_ValuePathfile('path_hhc');
171    $g_Prog_hhc = "$g_Prog_hhc\\hhc.exe";
172
173    if (! -e $g_Prog_hhc)
174      {
175        $bMissingProgs = 1;
176        push @MissingProgs, 'Microsoft HTML Help Workshop is needed for making the HTML-help file';
177      }
178    $g_Prog_hhc = "\"$g_Prog_hhc\"";
179
180    if ($bMissingProgs)
181      {
182        my $Msg="One or more required programs needed for making the docs are missing:\n\n";
183
184        for (@MissingProgs)
185          {
186            $Msg=$Msg . "  - $_\n";
187          }
188
189          $Msg=$Msg . "\nPlease, check that everything are installed properly as described in\n";
190          $Msg=$Msg . "the documentation in packages\\windows-innosetup\\tools\\readme.txt\n";
191          Win32::MsgBox($Msg, 0+MB_ICONSTOP, 'ERROR: Missing required programs.');
192          exit 1;
193      }
194}
195
196#-------------------------------------------------------------------------
197# FUNCTION   CopyAndEolU2W
198# DOES       Converts Unix eol's to Windows eol's in a file and saves it to
199#            another location.
200sub CopyAndEolU2W
201{
202    my $FileSrc='';
203    my $FileDest='';
204    my $FileCnt='';
205    my $PathWinIsPack='';
206    my $Pwd='';
207
208    # Get absolute path of the current PWD's parent
209    $PathWinIsPack=getcwd;
210    $Pwd=basename($PathWinIsPack);
211    $PathWinIsPack =~ s/\//\\/g;
212    $PathWinIsPack =~ s/\\$Pwd$//;
213
214    while (($FileSrc, $FileDest) = each %g_FilesToCpAndConv)
215      {
216#        $FileSrc = "$g_PathDocRoot\\$FileSrc";
217        $FileSrc = "$g_PathSubvRoot\\$FileSrc";
218        $FileDest = "$PathWinIsPack\\$g_PathMiscIn\\$FileDest";
219        print "Copying and converting EOL's from $FileSrc to $FileDest\n";
220
221        open (FH_SRC, $FileSrc);
222            while (<FH_SRC>)
223              {
224                chomp($_);
225                $_ = "$_\r\n";
226
227                if ($FileCnt)
228                  {
229                    $FileCnt = $FileCnt . $_;
230                  }
231                else
232                  {
233                    $FileCnt = $_;
234                  }
235              }
236         close (FH_SRC);
237
238        #Make the in dir for path_setup_in if needed
239        &MkDirP (dirname($FileDest)) unless (-e dirname($FileDest));
240
241        open (FH_DEST, ">" . $FileDest);
242            print FH_DEST $FileCnt;
243        close (FH_DEST);
244
245        $FileCnt='';
246      }
247}
Note: See TracBrowser for help on using the repository browser.