package ocaml_plugin

  1. Overview
  2. Docs

Module Ocaml_plugin.DynloaderSource

Ocaml plugin loader, from ocaml source file. Wrapper around Dynlink module, including on the fly async ocaml compilation.

This is a low level module, casual user should rather use Compiler apart from Make to create a dedicated Plugin loader.

Sourceval default_disabled_warnings : int list

See the labelled argument custom_warnings_spec for what these are for.

Sourceval warnings_spec : disabled_warnings:int list -> string
Sourceval default_warnings_spec : string
Sourcetype t

Mutable type for loading ocaml modules.

Sourcetype dynloader = t
Sourcetype 'a create_arguments = ?in_dir:string -> ?in_dir_perm:Async.Unix.file_perm -> ?include_directories:string list -> ?custom_warnings_spec:string -> ?strict_sequence:bool -> ?cmx_flags:string list -> ?cmxs_flags:string list -> ?trigger_unused_value_warnings_despite_mli:bool -> ?use_cache:Plugin_cache.Config.t -> 'a
Sourcemodule Ppx : sig ... end
Sourcemodule Preprocessor : sig ... end
Sourcemodule Compilation_config : sig ... end
Sourceval create : (?initialize:(directory:string -> unit Async.Deferred.Or_error.t) -> ?compilation_config:Compilation_config.t -> ?ocamlopt_opt:string -> ?ocamldep_opt:string -> unit -> t Async.Deferred.Or_error.t) create_arguments

Currently this library works with native code only. The function create will raise if called in bytecode.

Cleaning the files generated by this Dynloader.t from the begining of his life, and try to remove the directory if it is empty once the files have been removed. Doesn't fail if the directory contains other files, keep them and keep the directory in that case. Once cleaned, you cannot use a dynloader anymore, you should just leave it alone and let it be collected by the GC at some point. Using a cleaned dynloader will result in an error.

Sourcemodule Univ_constr : sig ... end
Sourcemodule type Module_type = sig ... end
Sourceval find_dependencies : t -> string -> string list Async.Deferred.Or_error.t

find_dependencies t file uses ocamldep to compute the list of .ml and .mli files that file depends on transitively, which you can then pass to load_ocaml_src_files. file must be an .ml file, and all the files it depend on must be in the same folder.

Sourcemodule type S = sig ... end
Sourcemodule Make (X : Module_type) : S with type t := X.t
Sourcemodule Side_effect : S with type t := unit

In some cases, we are only interested by the toplevel side effects of dynlinked modules.

Sourcemodule type Side_effect = sig ... end
Sourceval side_effect_univ_constr : (module Side_effect) Univ_constr.t
Sourceval return_plugin : 'a Univ_constr.t -> (unit -> 'a) -> unit
OCaml

Innovation. Community. Security.