Discard catala option --build-dir that is not useful in the end

This commit is contained in:
Louis Gesbert 2023-09-27 11:17:26 +02:00
parent 50fad76df3
commit ade51234e8
5 changed files with 17 additions and 44 deletions

View File

@ -411,14 +411,6 @@ module Flags = struct
deterministic output from the Catala compiler, since provers can \
have some randomness in them."
let build_dirs =
value
& opt_all string ["."; "_build"]
& info ["build-dir"] ~docv:"DIR"
~env:(Cmd.Env.info "CATALA_BUILD_DIR")
~doc:
"Directory where compiled modules are expected to be found (this option does not affect catala outputs)"
end
(* Retrieve current version from dune *)

View File

@ -119,7 +119,6 @@ module Flags : sig
val closure_conversion : bool Term.t
val include_dirs : raw_file list Term.t
val disable_counterexamples : bool Term.t
val build_dirs : raw_file list Term.t
end
(** {2 Command-line application} *)

View File

@ -611,12 +611,11 @@ module Commands = struct
result)
results
let interpret_dcalc options includes optimize check_invariants build_dirs ex_scope =
let build_dirs = List.map options.Cli.path_rewrite build_dirs in
let interpret_dcalc options includes optimize check_invariants ex_scope =
let prg, ctx, _ =
Passes.dcalc options ~includes ~optimize ~check_invariants
in
Interpreter.load_runtime_modules ~build_dirs prg;
Interpreter.load_runtime_modules prg;
print_interpretation_results options Interpreter.interpret_program_dcalc prg
(get_scope_uid ctx ex_scope)
@ -633,7 +632,6 @@ module Commands = struct
$ Cli.Flags.include_dirs
$ Cli.Flags.optimize
$ Cli.Flags.check_invariants
$ Cli.Flags.build_dirs
$ Cli.Flags.ex_scope)
let lcalc
@ -687,14 +685,12 @@ module Commands = struct
check_invariants
avoid_exceptions
closure_conversion
build_dirs
ex_scope =
let build_dirs = List.map options.Cli.path_rewrite build_dirs in
let prg, ctx, _ =
Passes.lcalc options ~includes ~optimize ~check_invariants
~avoid_exceptions ~closure_conversion
in
Interpreter.load_runtime_modules ~build_dirs prg;
Interpreter.load_runtime_modules prg;
print_interpretation_results options Interpreter.interpret_program_lcalc prg
(get_scope_uid ctx ex_scope)
@ -713,7 +709,6 @@ module Commands = struct
$ Cli.Flags.check_invariants
$ Cli.Flags.avoid_exceptions
$ Cli.Flags.closure_conversion
$ Cli.Flags.build_dirs
$ Cli.Flags.ex_scope)
let ocaml

View File

@ -940,35 +940,24 @@ let interpret_program_dcalc p s : (Uid.MarkedString.info * ('a, 'm) gexpr) list
reflect that. *)
let evaluate_expr ctx lang e = delcustom (evaluate_expr ctx lang (addcustom e))
let load_runtime_modules ~build_dirs prg =
let load_runtime_modules prg =
let load m =
let obj_base =
let obj_file =
Dynlink.adapt_filename File.(Pos.get_file (ModuleName.pos m) /../ ModuleName.to_string m ^ ".cmo")
in
let possible_files = List.map File.(fun d -> d / obj_base) build_dirs in
match List.filter Sys.file_exists possible_files with
| [] ->
if not (Sys.file_exists obj_file) then
Message.raise_spanned_error
~span_msg:(fun ppf -> Format.pp_print_string ppf "Module defined here")
(ModuleName.pos m)
"Compiled OCaml object %a not found. Make sure it has been suitably compiled, and use @{<blue>--build-dir@} if necessary." File.format obj_base
| [f] ->
(try Dynlink.loadfile f
with Dynlink.Error dl_err ->
Message.raise_error
"Error loading compiled module from %a:@;\
<1 2>@[<hov>%a@]" File.format f
Format.pp_print_text
(Dynlink.error_message dl_err))
| fs ->
Message.raise_spanned_error
~span_msg:(fun ppf -> Format.pp_print_string ppf "Module defined here")
(ModuleName.pos m)
"@[<v>Multiple compiled OCaml objects for %a found:@,- %a@]"
ModuleName.format m
(Format.pp_print_list ~pp_sep:(fun ppf () -> Format.fprintf ppf "@,- ")
File.format)
fs
"Compiled OCaml object %a not found. Make sure it has been suitably compiled." File.format obj_file
else
try Dynlink.loadfile obj_file
with Dynlink.Error dl_err ->
Message.raise_error
"Error loading compiled module from %a:@;\
<1 2>@[<hov>%a@]" File.format obj_file
Format.pp_print_text
(Dynlink.error_message dl_err)
in
let rec aux loaded decl_ctx =
ModuleName.Map.fold (fun mname sub_decl_ctx loaded ->

View File

@ -72,8 +72,6 @@ val interpret_program_lcalc :
providing for each argument a thunked empty default. Returns a list of all
the computed values for the scope variables of the executed scope. *)
val load_runtime_modules : build_dirs:File.t list -> _ program -> unit
val load_runtime_modules : _ program -> unit
(** Dynlink the runtime modules required by the given program, in order to make
them callable by the interpreter.
The specified build dirs are used as prefixes to the catala files defining the modules: with {[["."; "_build"]]}, this means that the compiled artifact of [foo/bar.catala_en] will be searched in [foo/bar.cmxs] and [_build/foo/bar.cmxs] *)
them callable by the interpreter. *)