source: branches/1.4/gui/apps/launcher.tcl @ 4862

Last change on this file since 4862 was 4862, checked in by ldelgass, 10 years ago

merge r4849 from 1.3 branch (remove -simulate flag

  • Property svn:executable set to *
File size: 4.2 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            default {
87                puts stderr "usage:"
88                puts stderr "  rappture ?-run? ?-tool toolFile? ?-nosim 0/1? ?-load file file ...?"
89                puts stderr "  rappture -builder ?-tool toolFile?"
90                puts stderr "  rappture -tester ?-auto? ?-tool toolFile? ?-testdir directory?"
91                exit 1
92            }
93        }
94    }
95}
96
97# If no arguments, assume that it's the -run option
98if {$mainscript eq ""} {
99    package require RapptureGUI
100    set guidir $RapptureGUI::library
101    set mainscript [file join $guidir scripts main.tcl]
102    set reqpkgs Tk
103}
104
105# Invoke the main program with the args
106
107# Note: We're sourcing the driver file "main.tcl" rather than exec-ing
108#       wish because we want to see stderr and stdout messages when they
109#       are written, rather than when the program completes.  It also
110#       eliminates one process waiting for the other to complete. If
111#       "exec" is needed, then the following could be replaced with
112#       blt::bgexec.  It doesn't try to redirect stderr into a file.
113set argv $alist
114foreach name $reqpkgs {
115    package require $name
116}
117source  $mainscript
Note: See TracBrowser for help on using the repository browser.