@@ -3019,25 +3019,36 @@ Autogenerated modules and includes
30193019
30203020.. pkg-section :: None
30213021
3022- Modules that are built automatically at setup, created with a custom
3023- setup script, must appear on :pkg-field: `other-modules ` for the library,
3024- executable, test-suite or benchmark stanzas or also on
3025- :pkg-field: `library:exposed-modules ` for libraries to be used, but are not
3026- really on the package when distributed. This makes commands like sdist fail
3027- because the file is not found.
3028-
3029- These special modules must appear again on the :pkg-field: `autogen-modules `
3030- field of the stanza that is using them, besides :pkg-field: `other-modules ` or
3031- :pkg-field: `library:exposed-modules `. With this there is no need to create
3032- complex build hooks for this poweruser case.
3022+ Autogenerated modules are not included with the package source. Instead, they
3023+ are built automatically at setup or created with a custom setup script and must
3024+ appear twice for a component: once to flag them as being autogenerated in an
3025+ :pkg-field: `autogen-modules ` field, and again to bring them into the component
3026+ with a listing in :pkg-field: `other-modules ` or
3027+ :pkg-field: `library:exposed-modules `.
3028+
3029+ .. note ::
3030+
3031+ Files :file: `Paths_{ pkgname } ` and :file: `PackageInfo_{ pkgname } `,
3032+ autogenerated modules with package :ref: `version <package-version-info >` and
3033+ :ref: `package-related <package-related-info >` information, are typically
3034+ exposed so that they're accessible with the library.
3035+
3036+ Creating a source distribution with ``cabal sdist `` reports any source files
3037+ not found and fails. Listing modules as :pkg-field: `autogen-modules ` exempts
3038+ ``cabal sdist `` from finding files for these modules.
3039+
3040+ .. error ::
3041+
3042+ An autogenerated module cannot also be the :pkg-field: `executable:main-is `
3043+ file. The ``cabal sdist `` command expects to find this file in the source
3044+ tree and autogenerated modules are generated outside the source tree.
30333045
30343046.. pkg-field :: autogen-modules: module list
30353047 :since: 2.0
30363048
3037- .. todo :: document autogen-modules field
3038-
3039- Right now :pkg-field: `executable:main-is ` modules are not supported on
3040- :pkg-field: `autogen-modules `.
3049+ A list of autogenerated modules. Each one of these modules must also be
3050+ listed elsewhere as if they were modules on disk. Autogenerated modules are
3051+ not packaged by the ``cabal sdist `` command.
30413052
30423053::
30433054
@@ -3065,9 +3076,9 @@ Right now :pkg-field:`executable:main-is` modules are not supported on
30653076.. pkg-field :: autogen-includes: filename list
30663077 :since: 3.0
30673078
3068- A list of header files from this package which are autogenerated
3069- (e.g. by a ``configure `` script). Autogenerated header files are not
3070- packaged by `` sdist `` command.
3079+ A list of header files from this package which are autogenerated (e.g. by a
3080+ ``configure `` script). Autogenerated header files are not packaged by
3081+ the `` cabal sdist `` command.
30713082
30723083
30733084.. _accessing-data-files :
@@ -3131,6 +3142,8 @@ hyphens converted into underscores, and ``var`` is either ``bindir``,
31313142the configured data directory for ``pretty-show `` is controlled with the
31323143``pretty_show_datadir `` environment variable.
31333144
3145+ .. _package-version-info :
3146+
31343147Accessing the package version
31353148^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31363149
@@ -3142,6 +3155,8 @@ The auto generated :file:`PackageInfo_{pkgname}` module exports the constant
31423155which is defined as the version of your package as specified in the
31433156``version `` field.
31443157
3158+ .. _package-related-info :
3159+
31453160Accessing package-related information
31463161^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
31473162
0 commit comments