os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tools/genWinImage.tcl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 # genWinImage.tcl --
     2 #
     3 #	This script generates the Windows installer.
     4 #
     5 # Copyright (c) 1999 by Scriptics Corporation.
     6 # All rights reserved.
     7 # 
     8 # RCS: @(#) $Id: genWinImage.tcl,v 1.5 2000/04/25 22:29:21 hobbs Exp $
     9 
    10 
    11 # This file is insensitive to the directory from which it is invoked.
    12 
    13 namespace eval genWinImage {
    14     # toolsDir --
    15     #
    16     # This variable points to the platform specific tools directory.
    17 
    18     variable toolsDir
    19 
    20     # tclBuildDir --
    21     #
    22     # This variable points to the directory containing the Tcl built tree.
    23 
    24     variable tclBuildDir
    25 
    26     # tkBuildDir --
    27     #
    28     # This variable points to the directory containing the Tk built tree.
    29 
    30     variable tkBuildDir
    31 
    32     # our script name at runtime
    33     variable script [info script]
    34 }
    35 
    36 # genWinImage::init --
    37 #
    38 #	This is the main entry point.
    39 #
    40 # Arguments:
    41 #	None.
    42 #
    43 # Results:
    44 #	None.
    45 
    46 proc genWinImage::init {} {
    47     global tcl_platform argv argv0
    48     variable tclBuildDir
    49     variable tkBuildDir
    50     variable toolsDir
    51     variable script
    52  
    53     puts "\n--- $script started: \
    54 	    [clock format [clock seconds] -format "%Y%m%d-%H:%M"] --\n"
    55 
    56     if {$tcl_platform(platform) != "windows"} {
    57 	puts stderr "ERROR: Cannot build TCL.EXE on Unix systems"
    58 	exit 1
    59     }
    60 
    61     if {[llength $argv] != 3} {
    62 	puts stderr "usage: $argv0 <tclBuildDir> <tkBuildDir> <toolsDir>"
    63 	exit 0
    64     }
    65 
    66     set tclBuildDir [lindex $argv 0]
    67     set tkBuildDir [lindex $argv 1]
    68     set toolsDir [lindex $argv 2]
    69 
    70     generateInstallers
    71  
    72     puts "\n--- $script finished: \
    73 	    [clock format [clock seconds] -format "%Y%m%d-%H:%M"] --\n\n"
    74 }
    75 
    76 # genWinImage::makeTextFile --
    77 #
    78 #	Convert the input file into a CRLF terminated text file.
    79 #
    80 # Arguments:
    81 #	infile		The input file to convert.
    82 #	outfile		The location where the text file should be stored.
    83 #
    84 # Results:
    85 #	None.
    86 
    87 proc genWinImage::makeTextFile {infile outfile} {
    88     set f [open $infile r]
    89     set text [read $f]
    90     close $f
    91     set f [open $outfile w]
    92     fconfigure $f -translation crlf
    93     puts -nonewline $f $text
    94     close $f
    95 }
    96 
    97 # genWinImage::generateInstallers --
    98 #
    99 #	Perform substitutions on the pro.wse.in file and then
   100 #	invoke the WSE script twice; once for CD and once for web.
   101 #
   102 # Arguments:
   103 #	None.
   104 #
   105 # Results:
   106 #	Leaves proweb.exe and procd.exe sitting in the curent directory.
   107 
   108 proc genWinImage::generateInstallers {} {
   109     variable toolsDir
   110     variable tclBuildDir
   111     variable tkBuildDir
   112 
   113     # Now read the "pro/srcs/install/pro.wse.in" file, have Tcl make
   114     # appropriate substitutions, write out the resulting file in a
   115     # current-working-directory.  Use this new file to perform installation
   116     # image creation.  Note that we have to use this technique to set
   117     # the value of _WISE_ because wise32 won't use a /d switch for this
   118     # variable.
   119 
   120     set __TCLBASEDIR__ [file native $tclBuildDir]
   121     set __TKBASEDIR__ [file native $tkBuildDir]
   122     set __WISE__ [file native [file join $toolsDir wise]]
   123 
   124     set f [open [file join $__TCLBASEDIR__ generic/tcl.h] r]
   125     set s [read $f]
   126     close $f
   127     regexp {TCL_PATCH_LEVEL\s*\"([^\"]*)\"} $s dummy __TCL_PATCH_LEVEL__
   128     
   129     set f [open tcl.wse.in r]
   130     set s [read $f]
   131     close $f
   132     set s [subst -nocommands -nobackslashes $s]
   133     set f [open tcl.wse w]
   134     puts $f $s
   135     close $f
   136 
   137     # Ensure the text files are CRLF terminated
   138 
   139     makeTextFile [file join $tclBuildDir win/README.binary] \
   140 	    [file join $tclBuildDir win/readme.txt]
   141     makeTextFile [file join $tclBuildDir license.terms] \
   142 	    [file join $tclBuildDir license.txt]
   143 
   144     set wise32ProgFilePath [file native [file join $__WISE__ wise32.exe]]
   145 
   146     # Run the Wise installer to create the Windows install images.
   147 
   148     if {[catch {exec [file native $wise32ProgFilePath] /c tcl.wse} errMsg]} {
   149 	puts stderr "ERROR: $errMsg"
   150     } else {
   151 	puts "\"TCL.EXE\" created."
   152     }
   153 
   154     return
   155 }
   156 
   157 genWinImage::init