2
; Copyright (C) 2008-2014 Centaur Technology
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/
9
; License: (An MIT/X11-style license)
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:
18
; The above copyright notice and this permission notice shall be included in
19
; all copies or substantial portions of the Software.
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.
29
; Original author: Jared Davis <jared@centtech.com>
32
(include-book "shell")
33
(include-book "../server/server")
34
(include-book "../util/gc")
35
(include-book "centaur/getopt/top" :dir :system)
38
(let ((public-dir (oslib::catpath *browser-dir* "public")))
39
`(defoptions vl-server-opts
41
:short "Options for running @('vl server')."
45
"Show a brief usage message and exit."
46
:rule-classes :type-prescription
50
"Show a more elaborate README and exit."
51
:rule-classes :type-prescription)
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)."
60
:rule-classes :type-prescription)
64
"Default: 9999. What port to run on."
66
:rule-classes :type-prescription)
70
"Default: \"./translations\". Where to find translations. See the
71
--readme to understand this."
72
:default "./translations"
73
:rule-classes :type-prescription)
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)))))
83
(defconst *vl-server-help* (str::cat "
84
vl server: Runs the VL Server (which supports the Module Browser).
86
Usage: vl server [OPTIONS]
88
Options:" *nls* *nls* *vl-server-opts-usage* *nls*))
90
(defconsts (*vl-server-readme* state)
91
(b* (((mv contents state) (acl2::read-file-characters "server.readme" state))
92
((when (stringp contents))
95
(mv (implode contents) state)))
98
(define vl-server ((cmdargs string-listp) &optional (state 'state))
100
:short "The @('vl server') command."
102
(b* (((mv errmsg opts extra-args)
103
(parse-vl-server-opts cmdargs))
108
(die "Unrecognized arguments: ~x0" extra-args)
111
((vl-server-opts opts) opts)
114
(vl-cw-ps-seq (vl-print *vl-server-help*))
119
(vl-cw-ps-seq (vl-print *vl-server-readme*))
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
127
(- (set-vl-gc-baseline))
128
(- (set-vl-gc-threshold 1/3-mem))
129
(- (set-vls-root opts.root))
131
((unless (<= opts.port 65535))
132
(die "Invalid port ~x0~%" opts.port)
135
((mv & hostname state) (acl2::getenv$ "HOSTNAME" state))
136
(- (cw "Starting VL server on ~s0:~x1~%" hostname opts.port))
138
(- (start :port opts.port
139
:public-dir opts.public)))
140
(cw "Starting VL Shell for the server.~%")