diff --git a/doc/dune-files.rst b/doc/dune-files.rst index 2f49c637a72..d0d113bf3d2 100644 --- a/doc/dune-files.rst +++ b/doc/dune-files.rst @@ -1811,15 +1811,15 @@ present, and which libraries it will load. - ``(optional)`` will not declare the plugin if the libraries are not available The loading of the plugin is done using the facilities generated by -:ref:`generate_module` +:ref:`generate_sites_module` -.. _generate_module: +.. _generate_sites_module: -generate_module (since 2.8) ---------------------------- +generate_sites_module (since 2.8) +--------------------------------- Dune proposes some facilities for dealing with :ref:`sites` in a program. The -``generate_module`` stanza will generate code for looking up the correct locations +``generate_sites_module`` stanza will generate code for looking up the correct locations of the sites directories and for loading plugins. It works after installation with or without the relocation mode, inside dune rules, when using dune exec. For promotion it works only if the generated modules are only in the executable (or @@ -1827,7 +1827,7 @@ library statically linked) promoted; generated modules in plugins will not work. .. code:: lisp - (generate_module + (generate_sites_module (module ) ) diff --git a/doc/sites.rst b/doc/sites.rst index 41fd8fbb11c..f867138fcf1 100644 --- a/doc/sites.rst +++ b/doc/sites.rst @@ -73,7 +73,7 @@ Getting the locations of a site at runtime ------------------------------------------ The executable ``mygui`` will be able to get the locations of the ``themes`` -site using the :ref:`generate module stanza` +site using the :ref:`generate sites module stanza` .. code:: scheme @@ -82,7 +82,7 @@ site using the :ref:`generate module stanza` (modules mygui mysites) (libraries dune-site)) - (generate_module + (generate_sites_module (name mysites) (sites mygui)) @@ -227,7 +227,7 @@ Main executable (C) (name c_register) (modules c_register)) - (generate_module + (generate_sites_module (module sites) (plugins (c plugins))) diff --git a/otherlibs/site/src/plugins/plugins.mli b/otherlibs/site/src/plugins/plugins.mli index 902ea8236e6..637421164cc 100644 --- a/otherlibs/site/src/plugins/plugins.mli +++ b/otherlibs/site/src/plugins/plugins.mli @@ -1,6 +1,6 @@ module type S = sig (** The signature of the modules present in the module generated by the stanza - generate_module *) + generate_sites_module *) val paths : string list diff --git a/otherlibs/site/test/run.t b/otherlibs/site/test/run.t index 365d6b898f4..2ee1ffa7355 100644 --- a/otherlibs/site/test/run.t +++ b/otherlibs/site/test/run.t @@ -27,7 +27,7 @@ Test embedding of sites locations information > (library > (public_name a) > (libraries dune-site)) - > (generate_module (module sites) (sites a)) + > (generate_sites_module (module sites) (sites a)) > EOF $ cat >a/a.ml < (library > (public_name b) > (libraries c.register dune-site)) - > (generate_module (module sites) (sites b)) + > (generate_sites_module (module sites) (sites b)) > (plugin (name c-plugins-b) (libraries b) (site (c plugins))) > (install (section (site (b data))) (files info.txt)) > EOF @@ -65,7 +65,7 @@ Test embedding of sites locations information > (public_name d) > (libraries c.register dune-site non-existent-library) > (optional)) - > (generate_module (module sites) (sites d)) + > (generate_sites_module (module sites) (sites d)) > (plugin (name c-plugins-d) (libraries d) (site (c plugins)) (optional)) > (install (section (site (d data))) (files info.txt)) > EOF @@ -96,7 +96,7 @@ Test embedding of sites locations information > (public_name c.register) > (name c_register) > (modules c_register)) - > (generate_module (module sites) (sourceroot) (plugins (c plugins))) + > (generate_sites_module (module sites) (sourceroot) (plugins (c plugins))) > (rule > (targets out.log) > (deps (package c)) diff --git a/src/dune_rules/dir_contents.ml b/src/dune_rules/dir_contents.ml index ad44fc2748e..56f160d15ab 100644 --- a/src/dune_rules/dir_contents.ml +++ b/src/dune_rules/dir_contents.ml @@ -148,8 +148,8 @@ end = struct | Copy_files def -> Simple_rules.copy_files sctx def ~src_dir ~dir ~expander |> Path.Set.to_list |> List.map ~f:Path.basename - | Generate_module def -> - [ Generate_module_rules.setup_rules sctx ~dir def ] + | Generate_sites_module def -> + [ Generate_sites_module_rules.setup_rules sctx ~dir def ] | Library { buildable; _ } | Executables { buildable; _ } -> (* Manually add files generated by the (select ...) dependencies *) diff --git a/src/dune_rules/dune_file.ml b/src/dune_rules/dune_file.ml index b81fa873463..e2cd91d0a45 100644 --- a/src/dune_rules/dune_file.ml +++ b/src/dune_rules/dune_file.ml @@ -2035,7 +2035,7 @@ module Deprecated_library_name = struct { Library_redirect.loc; project; old_name; new_public_name }) end -module Generate_module = struct +module Generate_sites_module = struct type t = { loc : Loc.t ; module_ : Module_name.t @@ -2076,7 +2076,7 @@ type Stanza.t += | Library_redirect of Library_redirect.Local.t | Deprecated_library_name of Deprecated_library_name.t | Cram of Cram_stanza.t - | Generate_module of Generate_module.t + | Generate_sites_module of Generate_sites_module.t | Plugin of Plugin.t module Stanzas = struct @@ -2179,10 +2179,10 @@ module Stanzas = struct , let+ () = Dune_lang.Syntax.since Stanza.syntax (2, 7) and+ t = Cram_stanza.decode in [ Cram t ] ) - ; ( "generate_module" + ; ( "generate_sites_module" , let+ () = Dune_lang.Syntax.since Section.dune_site_syntax (0, 1) - and+ t = Generate_module.decode in - [ Generate_module t ] ) + and+ t = Generate_sites_module.decode in + [ Generate_sites_module t ] ) ; ( "plugin" , let+ () = Dune_lang.Syntax.since Section.dune_site_syntax (0, 1) and+ t = Plugin.decode in diff --git a/src/dune_rules/dune_file.mli b/src/dune_rules/dune_file.mli index 13343a18623..ac026d39247 100644 --- a/src/dune_rules/dune_file.mli +++ b/src/dune_rules/dune_file.mli @@ -390,7 +390,7 @@ module Deprecated_library_name : sig end (** Stanza which generate a module for getting information from dune *) -module Generate_module : sig +module Generate_sites_module : sig type t = { loc : Loc.t ; module_ : Module_name.t (** name of the module to generate *) @@ -419,7 +419,7 @@ type Stanza.t += | Library_redirect of Library_redirect.Local.t | Deprecated_library_name of Deprecated_library_name.t | Cram of Cram_stanza.t - | Generate_module of Generate_module.t + | Generate_sites_module of Generate_sites_module.t | Plugin of Plugin.t val stanza_package : Stanza.t -> Package.t option diff --git a/src/dune_rules/generate_module_rules.ml b/src/dune_rules/generate_sites_module_rules.ml similarity index 97% rename from src/dune_rules/generate_module_rules.ml rename to src/dune_rules/generate_sites_module_rules.ml index 7f55771074e..fb9a8f7aeff 100644 --- a/src/dune_rules/generate_module_rules.ml +++ b/src/dune_rules/generate_sites_module_rules.ml @@ -56,7 +56,7 @@ let plugins_code sctx buf pkg sites = pr buf " module %s : %s.S = %s.Make(struct let paths = Sites.%s end)" (String.capitalize site) plugins plugins site) -let setup_rules sctx ~dir (def : Dune_file.Generate_module.t) = +let setup_rules sctx ~dir (def : Dune_file.Generate_sites_module.t) = let buf = Buffer.create 1024 in if def.sourceroot then sourceroot_code buf; if def.relocatable then relocatable_code buf; diff --git a/src/dune_rules/generate_module_rules.mli b/src/dune_rules/generate_sites_module_rules.mli similarity index 55% rename from src/dune_rules/generate_module_rules.mli rename to src/dune_rules/generate_sites_module_rules.mli index defff5e9ba9..fd062e00158 100644 --- a/src/dune_rules/generate_module_rules.mli +++ b/src/dune_rules/generate_sites_module_rules.mli @@ -4,4 +4,7 @@ open! Stdune (** create the rule and return the produced file *) val setup_rules : - Super_context.t -> dir:Path.Build.t -> Dune_file.Generate_module.t -> string + Super_context.t + -> dir:Path.Build.t + -> Dune_file.Generate_sites_module.t + -> string