source: branches/1.5/pkgs/cf/mkindex.tcl @ 5901

Last change on this file since 5901 was 5901, checked in by gah, 9 years ago

first pass on new build

File size: 2.3 KB
Line 
1# ----------------------------------------------------------------------
2#  mkindex.tcl
3#
4#  This utility freshens up the tclIndex file in a scripts directory.
5#    USAGE:  tclsh mkindex.tcl ?<directory> <directory> ...?
6#
7# ======================================================================
8#  AUTHOR:  Michael McLennan, Purdue University
9#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
10#
11#  See the file "license.terms" for information on usage and
12#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13# ======================================================================
14package require Itcl  ;# include itcl constructs in the index
15
16proc auto_mkindex { srcdir outfile patterns } {
17    global errorCode errorInfo
18
19    if {[interp issafe]} {
20        error "can't generate index within safe interpreter"
21    }
22
23    set fid [open $outfile w]
24
25    set oldDir [pwd]
26    cd $srcdir
27    set srcdir [pwd]
28
29    append index "# Tcl autoload index file, version 2.0\n"
30    append index "# This file is generated by the \"auto_mkindex\" command\n"
31    append index "# and sourced to set up indexing information for one or\n"
32    append index "# more commands.  Typically each line is a command that\n"
33    append index "# sets an element in the auto_index array, where the\n"
34    append index "# element name is the name of a command and the value is\n"
35    append index "# a script that loads the command.\n\n"
36    if {$patterns == ""} {
37        set patterns *.tcl
38    }
39    auto_mkindex_parser::init
40    foreach file [eval glob $patterns] {
41        if {[catch {auto_mkindex_parser::mkindex $file} msg] == 0} {
42            append index $msg
43        } else {
44            set code $errorCode
45            set info $errorInfo
46            cd $oldDir
47            error $msg $info $code
48        }
49    }
50    auto_mkindex_parser::cleanup
51    puts -nonewline $fid $index
52    close $fid
53    cd $oldDir
54}
55
56set outfile "tclIndex"
57set srcdir  "."
58set args {}
59for {set i 0} { $i < [llength $argv] } { incr i } {
60    set arg [lindex $argv $i]
61    if { $arg == "--outfile" } {
62        incr i
63        set outfile [lindex $argv $i]
64        continue
65    } elseif { $arg == "--srcdir" } {
66        incr i
67        set srcdir [lindex $argv $i]
68        continue
69    }
70    lappend args $arg
71}
72
73auto_mkindex $srcdir $outfile $args
74if { ![file exists $outfile] } {
75    exit 1
76}
77exit 0
Note: See TracBrowser for help on using the repository browser.