aboutsummaryrefslogtreecommitdiff
path: root/win
diff options
context:
space:
mode:
authorlecoanet2005-04-12 08:49:58 +0000
committerlecoanet2005-04-12 08:49:58 +0000
commit7368302709b7726cb85aa45340b7ba5f5945c6a1 (patch)
tree7e23e9f52778216954b37a673842727dfd27dbdb /win
parentd36ba77a9581ae237321bf156663edbafb417949 (diff)
downloadtkzinc-7368302709b7726cb85aa45340b7ba5f5945c6a1.zip
tkzinc-7368302709b7726cb85aa45340b7ba5f5945c6a1.tar.gz
tkzinc-7368302709b7726cb85aa45340b7ba5f5945c6a1.tar.bz2
tkzinc-7368302709b7726cb85aa45340b7ba5f5945c6a1.tar.xz
The script know how to build the Tcl/Perl/Doc and how to wrap
a msi complete package with the help of Wix.
Diffstat (limited to 'win')
-rw-r--r--win/package.tcl332
1 files changed, 280 insertions, 52 deletions
diff --git a/win/package.tcl b/win/package.tcl
index 2351f0b..db35ba1 100644
--- a/win/package.tcl
+++ b/win/package.tcl
@@ -1,47 +1,158 @@
#
# This script is intended to be run in the win sub-directory
-# with: tclsh84 package.tcl
-#
-set packager {C:\Program Files\Caphyon\Advanced Installer\AdvancedInstaller.exe}
+# with: tclsh build.tcl
+# actions include: tcl, perl, doc, wrap, clean. If nothing
+# is specified all actions are performed in order.
-#
-# Make the Tcl library
-#
-catch {exec nmake -f makefile.vc} result
-puts $result
+set todo [lindex $argv 0]
-#
-# Make the Perl library, use for this the
-# buildperl script.
-#
-set wd [pwd]
-cd ..
-catch {exec tclsh buildperl.tcl} result
-puts $result
-cd $wd
+set root [file join [file dirname [info script]] ..]
-#
-# Build a merged pkgIndex.tcl
-#
-set fout [open pkgIndex.tcl w]
-set fin [open [file join .. pkgIndex.tcl]]
-puts -nonewline $fout [read $fin]
-close $fin
-set fin [open [file join .. library pkgIndex.tcl]]
-foreach line [split [read $fin] \n] {
+if { $todo eq "subst" || $todo eq "" } {
+ #
+ # Substitute @variables@ in the .in registred files
+ # producing their expanded equivalent into files
+ # without the .in extension.
+ #
+ puts "Performing configuration variables substitution..."
+
+ set registredFiles {
+ { Perl Makefile.pl } { Perl Zinc.pm }
+ { Python Zinc.py }
+ { . starkit.tcl }
+ { win makefile.vc }
+ }
+
+ #
+ # First get the variable values.
+ #
+ set fid [open [file join $root configure.in]]
+ while { ! [eof $fid] } {
+ set line [gets $fid]
+ if { [regexp {^MAJOR_VERSION=(.*)$} $line dummy major] } {
+ continue
+ }
+ if { [regexp {^MINOR_VERSION=(.*)$} $line dummy minor] } {
+ continue
+ }
+ if { [regexp {^PATCHLEVEL=(.*)$} $line dummy patchlevel] } {
+ continue
+ }
+ if { [regexp {^VERSION=(.*)$} $line dummy version] } {
+ continue
+ }
+ if { [regexp {^PACKAGE=(.*)$} $line dummy package] } {
+ continue
+ }
+ if { [regexp {^Tkzinc_LIB_FILE=(.*)$} $line dummy libFile] } {
+ continue
+ }
+ if { [regexp {^Tkzincstub_LIB_FILE=(.*)$} $line dummy stubLibFile] } {
+ continue
+ }
+ }
+ close $fid
+ set libFile "${package}${major}${minor}.dll"
+ set stubLibFile "${package}stub${major}${minor}.dll"
+
+ #
+ # Then substitute all occurences in known files
+ #
+ foreach t $registredFiles {
+ set fid [open [file join $root [lindex $t 0] [lindex $t 1].in]]
+ set fod [open [file join $root [lindex $t 0] [lindex $t 1]] w]
+
+ while { ! [eof $fid] } {
+ set line [gets $fid]
+ regsub -all {@MAJOR_VERSION@} $line $major line
+ regsub -all {@MINOR_VERSION@} $line $minor line
+ regsub -all {@PATCHLEVEL@} $line $patchlevel line
+ regsub -all {@VERSION@} $line $version line
+ regsub -all {@PACKAGE@} $line $package line
+ regsub -all {@Tkzinc_LIB_FILE@} $line $libFile line
+ regsub -all {@Tkzincstub_LIB_FILE@} $line $stubLibFile line
+ puts $fod $line
+ }
+
+ close $fid
+ close $fod
+ }
+}
+
+if { $todo eq "tcl" || $todo eq "" } {
+ #
+ # Make the Tcl library
+ #
+ set tmpdir buildtcl
+
+ puts "Compiling the tcl variant..."
+
+ if { [catch {exec nmake -f makefile.vc 2>log} result] } {
+ puts $result
+ exit
+ }
+
+ #
+ # Copy the library files, it makes it easier to test in situ.
+ #
+ foreach f [glob -directory [file join $root library] zinc*.tcl] {
+ file copy -force $f $tmpdir
+ }
+ #
+ # Build a merged pkgIndex.tcl
+ #
+ set fout [open [file join $tmpdir pkgIndex.tcl] a]
+ set fin [open [file join $root library pkgIndex.tcl]]
+ foreach line [split [read $fin] \n] {
if {![regexp {^\s*$|^#} $line]} {
- puts $fout $line
+ puts $fout $line
}
+ }
+ close $fin
+ close $fout
+
+ #
+ # Create a demo script ending in .tcl
+ #
+ file copy -force [file join $root demos zinc-widget] [file join $tmpdir zinc-widget.tcl]
}
-close $fin
-close $fout
-#
-# Build a .bat script for the Perl demos.
-#
-set fout [open zinc-demos.bat w]
-set fin [open [file join .. Perl demos zinc-demos]]
-puts $fout {@rem = '--*-Perl-*--
+if { $todo eq "perl" || $todo eq "" } {
+ #
+ # Make the Tkzinc Perl library for windows
+ #
+ puts "Compiling the perl variant..."
+
+ #
+ # Create a perl build directory and copy the relevant
+ # files in it.
+ #
+ set wd [pwd]
+ set buildDir buildperl
+ set make nmake
+
+ puts "Creating temporary build structure for Tkzinc perl variant"
+
+ if { [file exists $buildDir] } {
+ file delete -force $buildDir
+ }
+ file mkdir $buildDir
+
+ foreach f {t Zinc.xs Zinc.pm Makefile.PL demos README Zinc} {
+ file copy -force [file join $root Perl $f] $buildDir
+ }
+ foreach f [glob -nocomplain [file join $root generic *.c] [file join $root generic *.h] \
+ [file join $root win *.c] [file join $root debian changelog] \
+ [file join $root debian copyright]] {
+ file copy -force $f $buildDir
+ }
+
+ #
+ # Build a .bat script for the Perl demos.
+ #
+ set fout [open [file join $buildDir demos zinc-demos.bat] w]
+ set fin [open [file join $buildDir demos zinc-demos]]
+ puts $fout {@rem = '--*-Perl-*--
@echo off
if "%OS%" == "Windows_NT" goto WinNT
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
@@ -53,24 +164,141 @@ if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofperl
@rem ';}
-puts $fout [read $fin]
-puts $fout {__END__
+ puts $fout [read $fin]
+ puts $fout {__END__
:endofperl}
-close $fin
-close $fout
+ close $fin
+ close $fout
-#
-# Create a demo script ending in .tcl
-#
-file copy -force [file join .. demos zinc-widget] zinc-widget.tcl
+ #
+ # Call the perl setup and then make it.
+ #
+ puts "Compiling the perl variant"
-#
-# Wrap up the msi packages
-#
-exec $packager /build Tkzinc.aip
-exec $packager /build Tkzincperl.aip
+ cd $buildDir
+ if { [catch {exec perl Makefile.PL 2>log} result] } {
+ puts $result
+ exit
+ }
+ if { [catch {exec $make 2>log} result] } {
+ puts $result
+ exit
+ }
+ cd $wd
+}
+
+
+proc DocClean { } {
+ #
+ # Need to get rid of some temporary files.
+ #
+ file delete -force log refman.aux refman.idx refman.ind refman.lof
+ file delete -force refman.log refman.out refman.toc texput.log
+ file delete -force idxmake.dvi idxmake.log refman.4ct refman.4dx refman.4ix
+ file delete -force refman.4tc refman.dvi refman.idx refman.ilg refman.ind
+ file delete -force refman.log refman.tmp refman.xref refman.lg refman.idv
+}
+
+if { $todo eq "doc" || $todo eq "" } {
+ #
+ # Make the pdf manual. Run the command
+ # three time to make the crossrefs ok.
+ #
+ puts "Building the documentation..."
+
+ set cwd [pwd]
+ cd [file join $root doc]
+
+ DocClean
+ puts "First pass through pdflatex."
+ if { [catch {exec pdflatex refman.tex 2>log} result] } {
+ puts $result
+ exit
+ }
+ puts "Running makeindex."
+ if { [catch {exec makeindex -o refman.ind refman.idx 2>log} result] } {
+ puts $result
+ exit
+ }
+ puts "Second pass through pdflatex."
+ if { [catch {exec pdflatex refman.tex 2>log} result] } {
+ puts $result
+ exit
+ }
+ puts "Third pass through pdflatex."
+ if { [catch {exec pdflatex refman.tex 2>log} result] } {
+ puts $result
+ exit
+ }
+ DocClean
+ puts "First pass through latex."
+ if { [catch {exec latex refman.tex 2>log} result] } {
+ puts $result
+ exit
+ }
+ puts "Preparing the index."
+ if { [catch {exec tex {\def\filename{{refman}{idx}{4dx}{ind}}} {\input} idxmake.4ht 2>log} result] } {
+ puts $result
+ exit
+ }
+ puts "Running makeindex."
+ if { [catch {exec makeindex -o refman.ind refman.4dx 2>log} result] } {
+ puts $result
+ exit
+ }
+ puts "Second pass through latex."
+ if { [catch {exec latex refman.tex 2>log} result] } {
+ puts $result
+ exit
+ }
+ puts "Third pass through latex."
+ if { [catch {exec latex refman.tex 2>log} result] } {
+ puts $result
+ exit
+ }
+ puts "Buiding html."
+ if { [catch {exec tex4ht refman.tex 2>log} result] } {
+ puts $result
+ exit
+ }
+ if { [catch {exec t4ht refman.tex 2>log} result] } {
+ puts $result
+ exit
+ }
+ DocClean
+
+ cd $cwd
+}
+
+if { $todo eq "wrap" || $todo eq "" } {
+ #
+ # Wrap up the msi package.
+ #
+ puts "Wrapping the msi package..."
+
+ if { [catch {exec candle Tkzinc.wxs 2>log} result] } {
+ puts $result
+ exit
+ }
+ if { [catch {exec light Tkzinc.wixobj 2>log} result] } {
+ puts $result
+ exit
+ }
+}
+
+if { $todo eq "clean" || $todo eq "" } {
+ #
+ # Clean up after messing around
+ #
+ puts "Cleaning up..."
+
+ file delete -force log pkgIndex.tcl zinc-widget.tcl zinc-demos.bat Tkzinc.wixobj
+ file delete -force buildtcl
+ file delete -force buildperl
+ set cwd [pwd]
+ cd [file join $root doc]
+ file delete -force refman.pdf refman.css nayk0a01.png
+ file delete -force [file glob refman*.html]
+ cd $cwd
+}
-#
-# Clean up after messing around
-#
-#file delete -force pkgIndex.tcl zinc-widget.tcl zinc-demos.bat