source: branches/1.3/gui/apps/launcher.tcl @ 4828

Last change on this file since 4828 was 4828, checked in by dkearney, 6 years ago

adding a -simulate flag to rappture command.

rappture -simulate <driverFile>

accepts a driver.xml file and silently runs a simulation, returning a run.xml file.

  • Property svn:executable set to *
File size: 4.9 KB
Line 
1#!/bin/sh
2# -*- mode: Tcl -*-
3# ----------------------------------------------------------------------
4#  RAPPTURE LAUNCHER
5#
6#  This script is invoked by the "rappture" command.  It parses
7#  various input options and selects the proper main program to
8#  run depending on the function (build tool, run tool, tester, etc.).
9#
10#  RUN AS FOLLOWS:
11#    rappture ?-run? ?-tool <toolfile>?
12#    rappture -builder ?-tool <toolfile>?
13#    rappture -tester ?-tool <toolfile>? ?-testdir <directory>?
14#
15#  The default option is "-run", which brings up the GUI used to
16#  run the tool.  If the <toolfile> is not specified, it defaults
17#  to "tool.xml" in the current working directory.
18#
19# ======================================================================
20#  AUTHOR:  Michael McLennan, Purdue University
21#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
22#
23#  See the file "license.terms" for information on usage and
24#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
25# ======================================================================
26set mainscript ""
27set alist ""
28set toolxml ""
29
30# scan through the arguments and look for the function
31while {[llength $argv] > 0} {
32    set opt [lindex $argv 0]
33    set argv [lrange $argv 1 end]
34
35    if {[string index $opt 0] == "-"} {
36        switch -- $opt {
37            -run {
38                package require RapptureGUI
39                set guidir $RapptureGUI::library
40                set mainscript [file join $guidir scripts main.tcl]
41                set reqpkgs Tk
42            }
43            -builder {
44                package require RapptureBuilder
45                set blddir $RapptureBuilder::library
46                set mainscript [file join $blddir scripts main.tcl]
47                set reqpkgs Tk
48            }
49            -tester {
50                package require RapptureTester
51                set testdir $RapptureTester::library
52                set mainscript [file join $testdir scripts main.tcl]
53                set reqpkgs Tk
54            }
55            -tool {
56                set toolxml [lindex $argv 0]
57                set argv [lrange $argv 1 end]
58                if {![file exists $toolxml]} {
59                    puts stderr "file not found: $toolxml"
60                    exit 1
61                }
62                lappend alist -tool $toolxml
63            }
64            -tool - -testdir - -nosim {
65                lappend alist $opt [lindex $argv 0]
66                set argv [lrange $argv 1 end]
67            }
68            -auto {
69                # for the tester in automatic mode -- don't load Tk
70                package require RapptureTester
71                set testdir $RapptureTester::library
72                set mainscript [file join $testdir scripts auto.tcl]
73                set reqpkgs ""
74            }
75            -load {
76                lappend alist $opt
77                while { [llength $argv] > 0 } {
78                    set val [lindex $argv 0]
79                    if { [string index $val 0] == "-" } {
80                        break
81                    }
82                    lappend alist $val
83                    set argv [lrange $argv 1 end]
84                }
85            }
86            -simulate {
87                # accept a driver.xml file and simulate it
88                set driverxml [lindex $argv 0]
89                set argv [lrange $argv 1 end]
90                if {![file exists $driverxml]} {
91                    puts stderr "file not found: $driverxml"
92                    exit 1
93                }
94                package require Rappture
95                set langdir $Rappture::installdir
96                set mainscript [file join $langdir scripts simulate.tcl]
97                set reqpkgs ""
98                set alist "-driver $driverxml"
99                break
100            }
101            default {
102                puts stderr "usage:"
103                puts stderr "  rappture ?-run? ?-tool toolFile? ?-nosim 0/1? ?-load file file ...?"
104                puts stderr "  rappture -builder ?-tool toolFile?"
105                puts stderr "  rappture -tester ?-auto? ?-tool toolFile? ?-testdir directory?"
106                puts stderr "  rappture -simulate driverFile"
107                exit 1
108            }
109        }
110    }
111}
112
113# If no arguments, assume that it's the -run option
114if {$mainscript eq ""} {
115    package require RapptureGUI
116    set guidir $RapptureGUI::library
117    set mainscript [file join $guidir scripts main.tcl]
118    set reqpkgs Tk
119}
120
121# Invoke the main program with the args
122
123# Note: We're sourcing the driver file "main.tcl" rather than exec-ing
124#       wish because we want to see stderr and stdout messages when they
125#       are written, rather than when the program completes.  It also
126#       eliminates one process waiting for the other to complete. If
127#       "exec" is needed, then the following could be replaced with
128#       blt::bgexec.  It doesn't try to redirect stderr into a file.
129set argv $alist
130foreach name $reqpkgs {
131    package require $name
132}
133source  $mainscript
Note: See TracBrowser for help on using the repository browser.