diff --git a/compiler/catala_utils/cli.ml b/compiler/catala_utils/cli.ml index a17bc3dc..20b77fa7 100644 --- a/compiler/catala_utils/cli.ml +++ b/compiler/catala_utils/cli.ml @@ -172,7 +172,7 @@ let plugins_dirs = let default = let ( / ) = Filename.concat in [ - Sys.executable_name + Filename.dirname Sys.executable_name / Filename.parent_dir_name / "lib" / "catala" diff --git a/compiler/driver.ml b/compiler/driver.ml index 839771de..e004cbcf 100644 --- a/compiler/driver.ml +++ b/compiler/driver.ml @@ -73,7 +73,15 @@ let driver source_file (options : Cli.options) : int = try `Plugin (Plugin.find s) with Not_found -> Errors.raise_error - "The selected backend (%s) is not supported by Catala" backend) + "The selected backend (%s) is not supported by Catala, nor was a \ + plugin by this name found under %a" + backend + (Format.pp_print_list + ~pp_sep:(fun ppf () -> Format.fprintf ppf "@ or @ ") + (fun ppf dir -> + Format.pp_print_string ppf + (try Unix.readlink dir with _ -> dir))) + options.plugins_dirs) in let prgm = Surface.Parser_driver.parse_top_level_file source_file language diff --git a/compiler/plugin.ml b/compiler/plugin.ml index cac96c3c..e7f9437a 100644 --- a/compiler/plugin.ml +++ b/compiler/plugin.ml @@ -58,12 +58,16 @@ let load_file f = Errors.format_warning "Could not load plugin %S: %s" f (Printexc.to_string e) -let load_dir d = +let rec load_dir d = let dynlink_exts = if Dynlink.is_native then [".cmxs"] else [".cmo"; ".cma"] in Array.iter (fun f -> - if List.exists (Filename.check_suffix f) dynlink_exts then - load_file (Filename.concat d f)) + if f.[0] = '.' then () + else + let f = Filename.concat d f in + if Sys.is_directory f then load_dir f + else if List.exists (Filename.check_suffix f) dynlink_exts then + load_file f) (Sys.readdir d) diff --git a/compiler/plugins/dune b/compiler/plugins/dune index 1b67068e..531a170f 100644 --- a/compiler/plugins/dune +++ b/compiler/plugins/dune @@ -1,18 +1,22 @@ -(executable +(library (name python) - (modes plugin) + (public_name catala.plugins.python) + (synopsis + "Demonstration Catala plugin that reproduces the behaviour of the built-in python backend") (modules python) (libraries catala.driver)) -(executable +(library (name api_web) - (modes plugin) + (public_name catala.plugins.api_web) + (synopsis "Catala plugin for interaction with a web interface") (modules api_web) (libraries catala.driver)) -(executable +(library (name json_schema) - (modes plugin) + (public_name catala.plugins.json_schema) + (synopsis "Catala plugin generating JSON schemas useful to build web-forms") (modules json_schema) (libraries catala.driver))