1 | #!/bin/sh |
---|
2 | # ---------------------------------------------------------------------- |
---|
3 | # RAPPTURE LAUNCHER |
---|
4 | # |
---|
5 | # This script is invoked by the "rappture" command. It parses |
---|
6 | # various input options and selects the proper main program to |
---|
7 | # run depending on the function (build tool, run tool, tester, etc.). |
---|
8 | # |
---|
9 | # RUN AS FOLLOWS: |
---|
10 | # rappture ?-run? ?-tool <toolfile>? |
---|
11 | # rappture -builder ?-tool <toolfile>? |
---|
12 | # rappture -tester ?-tool <toolfile>? ?-testdir <directory>? |
---|
13 | # |
---|
14 | # The default option is "-run", which brings up the GUI used to |
---|
15 | # run the tool. If the <toolfile> is not specified, it defaults |
---|
16 | # to "tool.xml" in the current working directory. |
---|
17 | # |
---|
18 | # ====================================================================== |
---|
19 | # AUTHOR: Michael McLennan, Purdue University |
---|
20 | # Copyright (c) 2004-2011 Purdue Research Foundation |
---|
21 | # |
---|
22 | # See the file "license.terms" for information on usage and |
---|
23 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
24 | # ====================================================================== |
---|
25 | package require RapptureGUI |
---|
26 | set guidir $RapptureGUI::library |
---|
27 | |
---|
28 | package require RapptureBuilder |
---|
29 | set blddir $RapptureBuilder::library |
---|
30 | |
---|
31 | package require RapptureTester |
---|
32 | set testdir $RapptureTester::library |
---|
33 | |
---|
34 | set mainscript [file join $guidir scripts main.tcl] |
---|
35 | set alist "" |
---|
36 | set toolxml "" |
---|
37 | |
---|
38 | # scan through the arguments and look for the function |
---|
39 | while {[llength $argv] > 0} { |
---|
40 | set opt [lindex $argv 0] |
---|
41 | set argv [lrange $argv 1 end] |
---|
42 | |
---|
43 | if {[string index $opt 0] == "-"} { |
---|
44 | switch -- $opt { |
---|
45 | -run { |
---|
46 | set mainscript [file join $guidir scripts main.tcl] |
---|
47 | } |
---|
48 | -builder { |
---|
49 | set mainscript [file join $blddir scripts main.tcl] |
---|
50 | } |
---|
51 | -tester { |
---|
52 | set mainscript [file join $testdir scripts main.tcl] |
---|
53 | } |
---|
54 | -tool { |
---|
55 | set toolxml [lindex $argv 0] |
---|
56 | set argv [lrange $argv 1 end] |
---|
57 | if {![file exists $toolxml]} { |
---|
58 | puts stderr "file not found: $toolxml" |
---|
59 | exit 1 |
---|
60 | } |
---|
61 | lappend alist -tool $toolxml |
---|
62 | } |
---|
63 | -testdir - -nosim { |
---|
64 | lappend alist $opt [lindex $argv 0] |
---|
65 | set argv [lrange $argv 1 end] |
---|
66 | } |
---|
67 | -load { |
---|
68 | lappend alist $opt |
---|
69 | while {1} { |
---|
70 | set val [lindex $argv 0] |
---|
71 | if {[string index $val 0] != "-"} { |
---|
72 | break |
---|
73 | } |
---|
74 | lappend alist $val |
---|
75 | set argv [lrange $argv 1 end] |
---|
76 | } |
---|
77 | } |
---|
78 | default { |
---|
79 | puts stderr "usage:" |
---|
80 | puts stderr " rappture ?-run? ?-tool toolFile? ?-nosim 0/1? ?-load file file ...?" |
---|
81 | puts stderr " rappture -builder ?-tool toolFile?" |
---|
82 | puts stderr " rappture -tester ?-tool toolFile? ?-testdir directory?" |
---|
83 | exit 1 |
---|
84 | } |
---|
85 | } |
---|
86 | } |
---|
87 | } |
---|
88 | |
---|
89 | # if we didn't find a tool.xml file, then look for one here |
---|
90 | if {$toolxml eq ""} { |
---|
91 | if {![file exists tool.xml]} { |
---|
92 | puts stderr "rappture: can't find tool definition file \"tool.xml\"" |
---|
93 | puts stderr " Use the -tool option to specify the location of this file." |
---|
94 | exit 1 |
---|
95 | } |
---|
96 | set alist [linsert $alist 0 -tool tool.xml] |
---|
97 | } |
---|
98 | |
---|
99 | # invoke the main program with the args |
---|
100 | eval exec wish [list $mainscript] $alist |
---|