Skip to content

Allow pre-build rules to generate autogen extra sources files#11573

Open
sheaf wants to merge 1 commit intohaskell:masterfrom
sheaf:hooks-extra-sources
Open

Allow pre-build rules to generate autogen extra sources files#11573
sheaf wants to merge 1 commit intohaskell:masterfrom
sheaf:hooks-extra-sources

Conversation

@sheaf
Copy link
Collaborator

@sheaf sheaf commented Mar 4, 2026

This PR fixes #11607, making it possible to write pre-build rules that generate source files other
than Haskell files.

Because there is no counterpart to autogen-modules for non-Haskell source
files, authors of pre-build rules will need to proceed in two steps:

  1. In a per-component pre-configure hook, the files the author desires to generate
    must be added to the relevant fields, e.g. the cSources field of BuildInfo.

    These files must be relative to autogenCompModulesDir.

  2. Pre-build rules generating these files will now be demanded. This avoids
    getting an error message "The following pre-build rules are not demanded
    and will not be run".

Note that include files (such as .h files) are a bit different: any files
listed under includes/autogen-includes are required at configure time.
This gives SetupHooks authors two choices: either list the include files in
autogen-includes but generate them in a pre-configure hook, or don't list them
there and generate them in a pre-build rule, relying on the files getting picked
up from included directories (this may be brittle).


Template Α: This PR modifies behaviour or interface

@sheaf sheaf force-pushed the hooks-extra-sources branch 2 times, most recently from 22fc5c6 to 91b3755 Compare March 12, 2026 12:01
With this commit, the SetupHooks API now considers all extra source
files placed in the autogen directory for the component to be additional
demands on pre-build rules.

For example, a pre-build rule that generates a C or JavaScript source
file (putting it in the appropriate autogen module for the component)
will now be run, while it used to not be run before (as it used to be
considered "not demanded").
@sheaf sheaf force-pushed the hooks-extra-sources branch from 91b3755 to 3b46b10 Compare March 12, 2026 12:03
@sheaf sheaf marked this pull request as ready for review March 12, 2026 12:04
@sheaf sheaf changed the title WIP: improve support for .c/.h files in pre-build rules Allow pre-build rules to generate autogen extra sources files Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow pre-build rules to generate extra source files

1 participant