ocamlfind
ocamlfind copied to clipboard
ocamlfind doesn't work for wasicaml
three problems:
- wasicaml has a bug and cannot run executables by non-absolute path (-> solve there, https://github.com/remixlabs/wasicaml/pull/58)
/Users/gerd/biz/figly/protoquery/wasicaml/bin/ocamlfind ocamlmklib
ocamlfind: Package `threads' not found
This is due to a bug in findlib: frontend.ml, line 923, change this to:
let type_of_threads =
try package_property [] "threads" "type_of_threads"
with No_such_package _ -> "ignore"
- wasicaml doesn't support
Unix.spawn
, but you can useSys.command
. Alternaterun_command
implementation:
let run_command ?filter verbose cmd args =
let printable_cmd =
cmd ^ " " ^ String.concat " " (List.map escape_if_needed args) in
( match verbose with
| Normal ->
()
| Verbose ->
print_endline ("+ " ^ printable_cmd);
if filter <> None then
print_string
(" (output of this command is filtered by ocamlfind)\n")
| Only_show ->
print_endline printable_cmd
);
flush stdout;
if verbose <> Only_show then (
let temp_file_opt =
match filter with
| None -> None
| Some _ ->
Some(Filename.temp_file "ocamlfind" ".out") in
let cmd1 =
match temp_file_opt with
| None -> cmd
| Some f -> cmd ^ " > " ^ Filename.quote f in
let code =
Sys.command cmd1 in
if code <> 0 then (
if verbose = Verbose then
print_string (cmd ^ " returned with exit code " ^ string_of_int code ^ "\n");
exit code
);
( match filter, temp_file_opt with
| Some filter_fun, Some temp_file ->
let ch = open_in temp_file in
( try
while true do
let line = input_line ch in
match filter_fun line with
None -> () (* Suppress line *)
| Some line' -> print_endline line'
done;
assert false
with
End_of_file ->
close_in ch;
flush stdout
)
| _ -> ()
)
)
;;