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

Last change on this file since 3721 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

  • Property svn:executable set to *
File size: 3.5 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# ======================================================================
26package require RapptureGUI
27set guidir $RapptureGUI::library
28
29package require RapptureBuilder
30set blddir $RapptureBuilder::library
31
32package require RapptureTester
33set testdir $RapptureTester::library
34
35set mainscript [file join $guidir scripts main.tcl]
36set alist ""
37set toolxml ""
38
39# scan through the arguments and look for the function
40while {[llength $argv] > 0} {
41    set opt [lindex $argv 0]
42    set argv [lrange $argv 1 end]
43
44    if {[string index $opt 0] == "-"} {
45        switch -- $opt {
46            -run {
47                set mainscript [file join $guidir scripts main.tcl]
48            }
49            -builder {
50                set mainscript [file join $blddir scripts main.tcl]
51            }
52            -tester {
53                set mainscript [file join $testdir scripts main.tcl]
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            -load {
69                lappend alist $opt
70                while { [llength $argv] > 0 } {
71                    set val [lindex $argv 0]
72                    if { [string index $val 0] == "-" } {
73                        break
74                    }
75                    lappend alist $val
76                    set argv [lrange $argv 1 end]
77                }
78            }
79            default {
80                puts stderr "usage:"
81                puts stderr "  rappture ?-run? ?-tool toolFile? ?-nosim 0/1? ?-load file file ...?"
82                puts stderr "  rappture -builder ?-tool toolFile?"
83                puts stderr "  rappture -tester ?-tool toolFile? ?-testdir directory?"
84                exit 1
85            }
86        }
87    }
88}
89
90# Invoke the main program with the args
91
92# Note: We're sourcing the driver file "main.tcl" rather than exec-ing
93#       wish because we want to see stderr and stdout messages when they
94#       are written, rather than when the program completes.  It also
95#       eliminates one process waiting for the other to complete. If
96#       "exec" is needed, then the following could be replaced with
97#       blt::bgexec.  It doesn't try to redirect stderr into a file.
98set argv $alist
99package require Tk
100source  $mainscript
Note: See TracBrowser for help on using the repository browser.