File tree Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -285,13 +285,15 @@ let run
285285 close_ic () );
286286 Debug. stop_profiling ()
287287
288- let info =
288+ let info name =
289289 Info. make
290- ~name: " js_of_ocaml "
290+ ~name
291291 ~doc: " Js_of_ocaml compiler"
292292 ~description:
293293 " Js_of_ocaml is a compiler from OCaml bytecode to Javascript. It makes it possible \
294294 to run pure OCaml programs in JavaScript environments like web browsers and \
295295 Node.js."
296296
297- let command = Cmdliner.Term. (pure run $ Arg. options), info
297+ let command_main = Cmdliner.Term. (pure run $ Arg. options), info " js_of_ocaml"
298+
299+ let command = Cmdliner.Term. (pure run $ Arg. options), info " compile"
Original file line number Diff line number Diff line change 1919val run : Arg .t -> unit
2020
2121val command : unit Cmdliner.Term .t * Cmdliner.Term .info
22+
23+ val command_main : unit Cmdliner.Term .t * Cmdliner.Term .info
Original file line number Diff line number Diff line change @@ -24,12 +24,37 @@ open Js_of_ocaml_compiler
2424let _ =
2525 Sys. catch_break true ;
2626 Timer. init Sys. time;
27+ let argv = Jsoo_cmdline. normalize_argv ~warn: (warn " %s" ) Sys. argv in
28+ let argv =
29+ let like_arg x = String. length x > 0 && Char. equal x.[0 ] '-' in
30+ let like_command x =
31+ String. length x > 0
32+ && (not (Char. equal x.[0 ] '-' ))
33+ && String. for_all x ~f: (function
34+ | 'a' .. 'z' | 'A' .. 'Z' | '-' -> true
35+ | _ -> false )
36+ in
37+ match Array. to_list argv with
38+ | exe :: maybe_command :: rest ->
39+ if like_command maybe_command || like_arg maybe_command
40+ then argv
41+ else
42+ (* Keep compatibility with js_of_ocaml < 3.6.0 *)
43+ Array. of_list
44+ (exe :: Cmdliner.Term. name (snd Compile. command) :: maybe_command :: rest)
45+ | _ -> argv
46+ in
2747 try
2848 Cmdliner.Term. eval_choice
2949 ~catch: false
30- ~argv: (Jsoo_cmdline. normalize_argv ~warn: (warn " %s" ) Sys. argv)
31- Compile. command
32- [ Link. command; Build_fs. command; Build_runtime. command; Print_runtime. command ]
50+ ~argv
51+ Compile. command_main
52+ [ Link. command
53+ ; Build_fs. command
54+ ; Build_runtime. command
55+ ; Print_runtime. command
56+ ; Compile. command
57+ ]
3358 with
3459 | (Match_failure _ | Assert_failure _ | Not_found ) as exc ->
3560 let backtrace = Printexc. get_backtrace () in
You can’t perform that action at this time.
0 commit comments