Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 63 lines (50 sloc) 1.76 KB
#!/usr/bin/env ocaml
#use "topfind"
#require "str"
#require "unix"
#require "ospecl"
let info verbose str =
if verbose then begin
Printf.printf "%s\n" str;
flush stdout
end else ()
let specs_of_file filename =
Topdirs.dir_use Format.std_formatter filename;
Obj.obj (Toploop.getvalue "specs")
let rec execute_spec_files verbose in_chan out_chan =
let send_back event =
output_value out_chan event;
flush out_chan;
while true do
let spec_file = input_line in_chan in
info verbose (Printf.sprintf "rx: %s" spec_file);
let specs = specs_of_file spec_file in
Ospecl.Spec.Exec.execute [send_back] specs
with End_of_file -> ()
let _ =
let usage_message =
let this_file = (Filename.basename Sys.argv.(0)) in
Printf.sprintf "usage: %s [options]
Starts a server which listens on the given port. Clients can connect and send filenames of spec source files which define a single value (specs : Ospecl.Spec.t list). These specs will be executed locally and the execution events sent back to the client.
" this_file
let append_to list_ref value =
list_ref := !list_ref @ [value]
let port = ref 0 in
let include_dirs = ref [] in
let verbose = ref false in
Arg.parse (Arg.align [
("-l", Arg.Set_int port, "PORT to listen on");
("-I", Arg.String (append_to include_dirs), "DIRECTORY to look for .cmo files referenced in the spec files");
("-v", Arg.Set verbose, " print debugging output");
let address = (Unix.ADDR_INET (Unix.inet_addr_of_string "", !port)) in
List.iter Topdirs.dir_directory !include_dirs;
info !verbose (Printf.sprintf "Listening on port %d" !port);
Unix.establish_server (execute_spec_files !verbose) address