~ubuntu-branches/ubuntu/wily/acl2/wily

« back to all changes in this revision

Viewing changes to books/centaur/vl/kit/server.lisp

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2015-01-16 10:35:45 UTC
  • mfrom: (3.3.26 sid)
  • Revision ID: package-import@ubuntu.com-20150116103545-prehe9thgo79o8w8
Tags: 7.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
; VL Verilog Toolkit
 
2
; Copyright (C) 2008-2014 Centaur Technology
 
3
;
 
4
; Contact:
 
5
;   Centaur Technology Formal Verification Group
 
6
;   7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA.
 
7
;   http://www.centtech.com/
 
8
;
 
9
; License: (An MIT/X11-style license)
 
10
;
 
11
;   Permission is hereby granted, free of charge, to any person obtaining a
 
12
;   copy of this software and associated documentation files (the "Software"),
 
13
;   to deal in the Software without restriction, including without limitation
 
14
;   the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
15
;   and/or sell copies of the Software, and to permit persons to whom the
 
16
;   Software is furnished to do so, subject to the following conditions:
 
17
;
 
18
;   The above copyright notice and this permission notice shall be included in
 
19
;   all copies or substantial portions of the Software.
 
20
;
 
21
;   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
22
;   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
23
;   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
24
;   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
25
;   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
26
;   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
27
;   DEALINGS IN THE SOFTWARE.
 
28
;
 
29
; Original author: Jared Davis <jared@centtech.com>
 
30
 
 
31
(in-package "VL")
 
32
(include-book "shell")
 
33
(include-book "../server/server")
 
34
(include-book "../util/gc")
 
35
(include-book "centaur/getopt/top" :dir :system)
 
36
 
 
37
(make-event
 
38
 (let ((public-dir (oslib::catpath *browser-dir* "public")))
 
39
   `(defoptions vl-server-opts
 
40
      :parents (vl-server)
 
41
      :short "Options for running @('vl server')."
 
42
      :tag :vl-server-opts
 
43
 
 
44
      ((help    booleanp
 
45
                "Show a brief usage message and exit."
 
46
                :rule-classes :type-prescription
 
47
                :alias #\h)
 
48
 
 
49
       (readme  booleanp
 
50
                "Show a more elaborate README and exit."
 
51
                :rule-classes :type-prescription)
 
52
 
 
53
       (mem     posp
 
54
                :alias #\m
 
55
                :argname "GB"
 
56
                "Default: 6 GB.  How much memory to try to use.  Raising this
 
57
                 may improve performance by avoiding garbage collection.  To
 
58
                 avoid swapping, keep this below (physical_memory - 2 GB)."
 
59
                :default 6
 
60
                :rule-classes :type-prescription)
 
61
 
 
62
       (port    posp
 
63
                :alias #\p
 
64
                "Default: 9999.  What port to run on."
 
65
                :default 9999
 
66
                :rule-classes :type-prescription)
 
67
 
 
68
       (root    stringp
 
69
                :alias #\r
 
70
                "Default: \"./translations\".  Where to find translations.  See the
 
71
                 --readme to understand this."
 
72
                :default "./translations"
 
73
                :rule-classes :type-prescription)
 
74
 
 
75
       (public  stringp
 
76
                :rule-classes :type-prescription
 
77
                ,(cat "Default: \"" public-dir "\".  Where to find the supporting
 
78
                'public' directory from the module browser's code.  You should be
 
79
                able to ignore this unless you're deploying the module browser to
 
80
                a different directory.")
 
81
                :default ,public-dir)))))
 
82
 
 
83
(defconst *vl-server-help* (str::cat "
 
84
vl server:  Runs the VL Server (which supports the Module Browser).
 
85
 
 
86
Usage:    vl server [OPTIONS]
 
87
 
 
88
Options:" *nls* *nls* *vl-server-opts-usage* *nls*))
 
89
 
 
90
(defconsts (*vl-server-readme* state)
 
91
  (b* (((mv contents state) (acl2::read-file-characters "server.readme" state))
 
92
       ((when (stringp contents))
 
93
        (raise contents)
 
94
        (mv "" state)))
 
95
    (mv (implode contents) state)))
 
96
 
 
97
 
 
98
(define vl-server ((cmdargs string-listp) &optional (state 'state))
 
99
  :parents (kit)
 
100
  :short "The @('vl server') command."
 
101
 
 
102
  (b* (((mv errmsg opts extra-args)
 
103
        (parse-vl-server-opts cmdargs))
 
104
       ((when errmsg)
 
105
        (die "~@0~%" errmsg)
 
106
        state)
 
107
       ((when extra-args)
 
108
        (die "Unrecognized arguments: ~x0" extra-args)
 
109
        state)
 
110
 
 
111
       ((vl-server-opts opts) opts)
 
112
 
 
113
       ((when opts.help)
 
114
        (vl-cw-ps-seq (vl-print *vl-server-help*))
 
115
        (exit-ok)
 
116
        state)
 
117
 
 
118
       ((when opts.readme)
 
119
        (vl-cw-ps-seq (vl-print *vl-server-readme*))
 
120
        (exit-ok)
 
121
        state)
 
122
 
 
123
       (max-mem (* (expt 2 30) opts.mem))
 
124
       (1/3-mem (floor max-mem 3))
 
125
       (- (acl2::set-max-mem ;; newline to appease cert.pl's scanner
 
126
           max-mem))
 
127
       (- (set-vl-gc-baseline))
 
128
       (- (set-vl-gc-threshold 1/3-mem))
 
129
       (- (set-vls-root opts.root))
 
130
 
 
131
       ((unless (<= opts.port 65535))
 
132
        (die "Invalid port ~x0~%" opts.port)
 
133
        state)
 
134
 
 
135
       ((mv & hostname state) (acl2::getenv$ "HOSTNAME" state))
 
136
       (- (cw "Starting VL server on ~s0:~x1~%" hostname opts.port))
 
137
 
 
138
       (- (start :port       opts.port
 
139
                 :public-dir opts.public)))
 
140
    (cw "Starting VL Shell for the server.~%")
 
141
    (vl-shell nil)))
 
142
 
 
143