Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions compiler/compileArg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type t =
; source_map : (string option * Source_map.t) option
; runtime_files : string list
; runtime_only : bool
; output_file : string option
; output_file : [`Name of string | `Stdout] * bool
; input_file : string option
; params : (string * string) list
; static_env : (string * string) list
Expand All @@ -43,7 +43,8 @@ type t =
include_dir : string list
; fs_files : string list
; fs_output : string option
; fs_external : bool }
; fs_external : bool
; keep_unit_names : bool }

let options =
let toplevel_section = "OPTIONS (TOPLEVEL)" in
Expand All @@ -67,6 +68,10 @@ let options =
in
Arg.(required & pos ~rev:true 0 (some string) None & info [] ~docv:"PROGRAM" ~doc)
in
let keep_unit_names =
let doc = "Keep unit name" in
Arg.(value & flag & info ["keep-unit-names"] ~doc)
in
let profile =
let doc = "Set optimization profile : [$(docv)]." in
let profile = List.map Driver.profiles ~f:(fun (i, p) -> string_of_int i, p) in
Expand Down Expand Up @@ -191,7 +196,8 @@ let options =
sourcemap_root
output_file
input_file
js_files =
js_files
keep_unit_names =
let chop_extension s =
try Filename.chop_extension s with Invalid_argument _ -> s
in
Expand All @@ -213,17 +219,21 @@ let options =
in
let output_file =
match output_file with
| Some _ -> output_file
| None -> Option.map input_file ~f:(fun s -> chop_extension s ^ ".js")
| Some "-" -> `Stdout, true
| Some s -> `Name s, true
| None -> (
match input_file with
| Some s -> `Name (chop_extension s ^ ".js"), false
| None -> `Stdout, false)
in
let source_map =
if ((not no_sourcemap) && sourcemap) || sourcemap_inline_in_js
then
let file, sm_output_file =
match output_file with
| Some file when sourcemap_inline_in_js -> file, None
| Some file -> file, Some (chop_extension file ^ ".map")
| None -> "STDIN", None
| `Name file, _ when sourcemap_inline_in_js -> file, None
| `Name file, _ -> file, Some (chop_extension file ^ ".map")
| `Stdout, _ -> "STDIN", None
in
Some
( sm_output_file
Expand Down Expand Up @@ -268,7 +278,8 @@ let options =
; nocmis
; output_file
; input_file
; source_map }
; source_map
; keep_unit_names }
in
let t =
Term.(
Expand Down Expand Up @@ -296,7 +307,8 @@ let options =
$ sourcemap_root
$ output_file
$ input_file
$ js_files)
$ js_files
$ keep_unit_names)
in
Term.ret t

Expand Down
5 changes: 3 additions & 2 deletions compiler/compileArg.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type t =
; source_map : (string option * Source_map.t) option
; runtime_files : string list
; runtime_only : bool
; output_file : string option
; output_file : [`Name of string | `Stdout] * bool
; input_file : string option
; params : (string * string) list
; static_env : (string * string) list
Expand All @@ -41,7 +41,8 @@ type t =
include_dir : string list
; fs_files : string list
; fs_output : string option
; fs_external : bool }
; fs_external : bool
; keep_unit_names : bool }

val options : t Cmdliner.Term.t

Expand Down
1 change: 1 addition & 0 deletions compiler/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
(libraries
js_of_ocaml-compiler
cmdliner
compiler-libs.common
(select empty-findlib.ml from
;; Only link js_of_ocaml-compiler.findlib-support if it exists
(js_of_ocaml-compiler.findlib-support -> empty-findlib.ml.in)
Expand Down
Loading