Skip to content

Commit

Permalink
Static linking: Fail if Eliom_config.parse_config is called without c…
Browse files Browse the repository at this point in the history
…onfig file
  • Loading branch information
balat committed May 11, 2024
1 parent 262c9c8 commit f757b6a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/lib/eliom_config.server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ let get_config_info () =

let get_config () =
match Eliom_common.global_register_allowed () with
| Some _ -> !Eliommod.config
| Some _ -> (
match !Eliommod.config with
| Some c -> c
| None -> failwith "No config file. Is it a statically linked executable?")
| None ->
raise
(Eliom_common.Eliom_site_information_not_available
Expand Down
6 changes: 3 additions & 3 deletions src/lib/server/eliommod.ml
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ let site_init_ref = ref []
(** Register function for evaluation at site initialisation *)
let register_site_init e = site_init_ref := e :: !site_init_ref

let config = ref []
let config = ref None (* None means no config file (static linking) *)
let config_in_tag = ref "" (* the parent tag of the currently handled tag *)

type module_to_load = Files of string list | Name of string
Expand All @@ -739,10 +739,10 @@ let site_init firstmodule =

let load_eliom_module _sitedata cmo_or_name parent_tag content =
let preload () =
config := content;
config := Some content;
config_in_tag := parent_tag
in
let postload () = config := [] in
let postload () = config := Some [] in
try
match cmo_or_name with
| Files cmo -> Ocsigen_loader.loadfiles preload postload true cmo
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/eliommod.mli
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ val end_init : unit -> unit
val handle_init_exn : exn -> string
val site_init_ref : (unit -> unit) list ref
val register_site_init : (unit -> unit) -> unit
val config : Xml_light_types.xml list ref
val config : Xml_light_types.xml list option ref
val config_in_tag : string ref

type module_to_load = Files of string list | Name of string
Expand Down

0 comments on commit f757b6a

Please sign in to comment.