Skip to content

Add program prefix and suffix to BuildOptions#11787

Open
sheaf wants to merge 1 commit into
haskell:masterfrom
sheaf:hooks-prefix
Open

Add program prefix and suffix to BuildOptions#11787
sheaf wants to merge 1 commit into
haskell:masterfrom
sheaf:hooks-prefix

Conversation

@sheaf

@sheaf sheaf commented May 5, 2026

Copy link
Copy Markdown
Collaborator

This commits adds two new fields of BuildOptions, namely programPrefix and programSuffix. This allows the installed executable program prefix and suffix to be set by SetupHooks for packages with build-type: Hooks.


Template Α: This PR modifies behaviour or interface

Include the following checklist in your PR:

  • Patches conform to the coding conventions.
  • Any changes that could be relevant to users have been recorded in the changelog.
  • The documentation has been updated, if necessary.
  • Manual QA notes have been included.
  • Tests have been added. (Ask for help if you don’t know how to write them! Ask for an exemption if tests are too complex for too little coverage!)

@sheaf sheaf force-pushed the hooks-prefix branch 2 times, most recently from 24c1c44 to bf07ec8 Compare May 5, 2026 11:39
@sheaf sheaf marked this pull request as ready for review May 5, 2026 11:40
@ulysses4ever

Copy link
Copy Markdown
Collaborator

Should cabal-install be updated to use these fields to handle affixes (prefixes and suffixes)? It handles them today on the higher level, but now, if we can do it on the library level, we add redundancy?

@sheaf

sheaf commented May 6, 2026

Copy link
Copy Markdown
Collaborator Author

Should cabal-install be updated to use these fields to handle affixes (prefixes and suffixes)? It handles them today on the higher level, but now, if we can do it on the library level, we add redundancy?

Which part of the cabal-install codebase are you referring to specifically?

All I could find was this, in Distribution.Client.CmdInstall:

ignoreProgramAffixes :: ConfigFlags -> ConfigFlags
ignoreProgramAffixes configFlags =
  configFlags
    { configProgPrefix = NoFlag
    , configProgSuffix = NoFlag
    }

@ulysses4ever

Copy link
Copy Markdown
Collaborator

I'm talking about these configProgPrefix/configProgSuffix. Are setup hooks not able to leverage those? Or vise versa?

@sheaf

sheaf commented May 6, 2026

Copy link
Copy Markdown
Collaborator Author

I'm talking about these configProgPrefix/configProgSuffix. Are setup hooks not able to leverage those? Or vise versa?

SetupHooks don't use ConfigFlags; ConfigFlags is part of the command-line interface for ./Setup.

@ulysses4ever

Copy link
Copy Markdown
Collaborator

@sheaf my bad. I dived a little deeper to try to substantiate my hunch, and here is the place that bothers me:

progPrefix, progSuffix :: LocalBuildInfo -> PathTemplate
progPrefix (LocalBuildInfo{configFlags = cfg}) =
fromFlag $ configProgPrefix cfg
progSuffix (LocalBuildInfo{configFlags = cfg}) =
fromFlag $ configProgSuffix cfg

Shouldn't these read from the new build options instead? Something like:

progPrefix, progSuffix :: LocalBuildInfo -> PathTemplate
progPrefix lbi@(LocalBuildInfo{configFlags = cfg}) =
  fromMaybe
    (fromFlag $ configProgPrefix cfg)
    (programPrefix lbi)
progSuffix lbi@(LocalBuildInfo{configFlags = cfg}) =
  fromMaybe
    (fromFlag $ configProgSuffix cfg)
    (programSuffix lbi)

@jappeace

jappeace commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Hi, some questions because I'm curious.
Why would you want this?
(Isn't there an issue for this as well?)

Also, wouldn't a test be helpful to assert the prefix and suffix gets passed down in a hook build type situation?

@tdammers tdammers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not actually introduce any code that uses these fields, does it?

@sheaf

sheaf commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

@sheaf my bad. I dived a little deeper to try to substantiate my hunch, and here is the place that bothers me:

progPrefix, progSuffix :: LocalBuildInfo -> PathTemplate
progPrefix (LocalBuildInfo{configFlags = cfg}) =
fromFlag $ configProgPrefix cfg
progSuffix (LocalBuildInfo{configFlags = cfg}) =
fromFlag $ configProgSuffix cfg

Shouldn't these read from the new build options instead? Something like:

progPrefix, progSuffix :: LocalBuildInfo -> PathTemplate
progPrefix lbi@(LocalBuildInfo{configFlags = cfg}) =
  fromMaybe
    (fromFlag $ configProgPrefix cfg)
    (programPrefix lbi)
progSuffix lbi@(LocalBuildInfo{configFlags = cfg}) =
  fromMaybe
    (fromFlag $ configProgSuffix cfg)
    (programSuffix lbi)

Yes, excellent point. The values in ConfigFlags are just for the CLI, once the data makes it into BuildOptions we should always pull from there. I'm fixing this now.

@sheaf sheaf force-pushed the hooks-prefix branch 2 times, most recently from c4daf04 to 3181f38 Compare May 28, 2026 08:36
@sheaf

sheaf commented May 28, 2026

Copy link
Copy Markdown
Collaborator Author

Why would you want this?

This was requested in #11168.

Also, wouldn't a test be helpful to assert the prefix and suffix gets passed down in a hook build type situation?

This does not actually introduce any code that uses these fields, does it?

I added a test now.

@sheaf sheaf force-pushed the hooks-prefix branch 2 times, most recently from 8ca68d3 to eafe997 Compare May 28, 2026 09:49
This commits adds two new fields of `BuildOptions`, namely `programPrefix`
and `programSuffix`. This allows the installed executable program prefix
and suffix to be set by `SetupHooks` for packages with `build-type: Hooks`.

Fixes haskell#11168
@Mikolaj Mikolaj requested a review from jappeace June 4, 2026 17:49
@jappeace

jappeace commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

Thanks 🙏🏽

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants