Skip to content

Commit 0df6396

Browse files
committed
Process the -parameter flag
1 parent 0514f08 commit 0df6396

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/kernel/mconfig.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ let dump_ocaml x =
5454
("pp", Json.option (dump_with_workdir Json.string) x.pp);
5555
("warnings", dump_warnings x.warnings);
5656
("cmi_file", Json.option Json.string x.cmi_file);
57+
("parameters", `List (List.map ~f:Json.string x.parameters));
5758
("as_parameter", `Bool x.as_parameter);
5859
( "zero_alloc_check",
5960
`String (Zero_alloc_annotations.to_string x.zero_alloc_check) )

src/kernel/mocaml.ml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,16 @@ let setup_reader_config config =
5252
as_parameter := ocaml.as_parameter;
5353
zero_alloc_check := ocaml.zero_alloc_check
5454

55+
let init_params params =
56+
List.iter params ~f:(fun s ->
57+
Env.register_parameter (s |> Global_module.Name.create_no_args))
58+
5559
let setup_typer_config config =
5660
setup_reader_config config;
5761
let visible = Mconfig.build_path config in
5862
let hidden = Mconfig.hidden_build_path config in
59-
Load_path.(init ~auto_include:no_auto_include ~visible ~hidden)
63+
Load_path.(init ~auto_include:no_auto_include ~visible ~hidden);
64+
init_params config.ocaml.parameters
6065

6166
(** Switchable implementation of Oprint *)
6267

src/kernel/mtyper.ml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,13 @@ let run config parsetree =
289289
(* Resetting the local store will clear the load_path cache.
290290
Save it now, reset the store and then restore the path. *)
291291
let { Load_path.visible; hidden } = Load_path.get_paths () in
292+
(* Same story with the registered parameters. *)
293+
let parameters = Env.parameters () in
292294
Mocaml.flush_caches ();
293295
Local_store.reset ();
294296
Load_path.reset ();
295-
Load_path.(init ~auto_include:no_auto_include ~visible ~hidden));
297+
Load_path.(init ~auto_include:no_auto_include ~visible ~hidden);
298+
List.iter ~f:Env.register_parameter parameters);
296299
let caught = ref [] in
297300
Msupport.catch_errors Mconfig.(config.ocaml.warnings) caught @@ fun () ->
298301
Typecore.reset_delayed_checks ();

0 commit comments

Comments
 (0)