Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongbo Zhang committed Jul 10, 2016
1 parent ce4be8e commit d50b8f9
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
9 changes: 2 additions & 7 deletions jscomp/common/js_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ let default_env = ref NodeJS
type path = string

type package_info = env * string

(* | AmdJS of path *)
(* | NodeJS of path *)
(* | Goog *)

type package_name = string
type packages_info = (package_name * package_info list) option
(** we don't force people to use package *)
Expand All @@ -59,7 +54,7 @@ let get_env () = !default_env
let set_env env = default_env := env


(* let npm_package_path = ref None *)



let packages_info : packages_info ref = ref None
Expand Down Expand Up @@ -98,7 +93,7 @@ let set_npm_package_path s =
Ext_pervasives.bad_argf "invalid npm package path: %s" s
in
packages_info := Some (name, (env,path) :: envs)
(* default_env := env , npm_package_path := Some path *)



let get_npm_package_path () =
Expand Down
39 changes: 25 additions & 14 deletions jscomp/common/js_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,59 @@ type env =
| Goog

val cmj_ext : string

val get_env : unit -> env
val set_env : env -> unit


val get_ext : unit -> string

val get_output_dir : string -> string
val get_output_file : string -> string


val set_npm_package_path : string -> unit

(** return [package_name] and [path] *)
val set_npm_package_path : string -> unit
val get_npm_package_path : unit -> (string * string) option

val set_package_name : string -> unit
val get_package_name : unit -> string option

(** corss module inline option *)
val cross_module_inline : bool ref
val set_cross_module_inline : bool -> unit
val get_cross_module_inline : unit -> bool

(** diagnose option *)
val diagnose : bool ref
val get_diagnose : unit -> bool
val set_diagnose : bool -> unit

val set_env : env -> unit

(** generate tds option *)
val default_gen_tds : bool ref

(** options for builtion ppx *)
val no_builtin_ppx_ml : bool ref
val no_builtin_ppx_mli : bool ref

(** check-div-by-zero option *)
val check_div_by_zero : bool ref
val get_check_div_by_zero : unit -> bool

(* It will imply [-noassert] be set too, note from the implmentation point of view,
in the lambda layer, it is impossible to tell whehther it is [assert (3 <> 2)] or
[if (3<>2) then assert false]
*)
val no_any_assert : bool ref
val set_no_any_assert : unit -> unit
val get_no_any_assert : unit -> bool




(** Internal use *)
val runtime_set : String_set.t
val stdlib_set : String_set.t

Expand Down Expand Up @@ -108,15 +131,3 @@ val is_same_file : unit -> bool

val tool_name : string

val check_div_by_zero : bool ref

val get_check_div_by_zero : unit -> bool

(* It will imply [-noassert] be set too, note from the implmentation point of view,
in the lambda layer, it is impossible to tell whehther it is [assert (3 <> 2)] or
[if (3<>2) then assert false]
*)
val no_any_assert : bool ref

val set_no_any_assert : unit -> unit
val get_no_any_assert : unit -> bool
6 changes: 2 additions & 4 deletions jscomp/js_program_loader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ let string_of_module_id (x : Lam_module_ident.t) : string =
*)
let base = String.uncapitalize id.name in
begin match Lam_compile_env.get_goog_package_name x with
| None
| Some "" ->
base
| None -> base
| Some v -> v ^ "." ^ base
end
| AmdJS
Expand All @@ -62,7 +60,7 @@ let string_of_module_id (x : Lam_module_ident.t) : string =
Ext_filename.node_relative_path
(`Dir (Js_config.get_output_dir !Location.input_name)) dep
in
begin match Lam_compile_env.get_npm_package_path x
begin match Lam_compile_env.get_package_path_from_cmj x
with
| Some (package_name, x) ->
let filename = String.uncapitalize id.name in
Expand Down
2 changes: 1 addition & 1 deletion jscomp/lam_compile_env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ let get_goog_package_name ({ kind; _} as id : Lam_module_ident.t) =
~found:(fun x -> x.goog_package)


let get_npm_package_path ( id : Lam_module_ident.t) =
let get_package_path_from_cmj ( id : Lam_module_ident.t) =
query_and_add_if_not_exist id No_env
~not_found:(fun _ -> None)
~found:(fun x -> x.npm_package_path)
Expand Down
2 changes: 1 addition & 1 deletion jscomp/lam_compile_env.mli
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ val reset : unit -> unit

val is_pure : Lam_module_ident.t -> bool
val get_goog_package_name : Lam_module_ident.t -> string option
val get_npm_package_path : Lam_module_ident.t -> (string * string) option
val get_package_path_from_cmj : Lam_module_ident.t -> (string * string) option

(* The second argument is mostly from [runtime] modules
will change the input [hard_dependencies]
Expand Down

0 comments on commit d50b8f9

Please sign in to comment.