Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ordNub for extra stanzas #8499

Merged
merged 5 commits into from Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 6 additions & 23 deletions Cabal/src/Distribution/Simple/Build.hs
Expand Up @@ -89,7 +89,6 @@ import Distribution.Version (thisVersion)
import Distribution.Compat.Graph (IsNode(..))

import Control.Monad
import qualified Data.Set as Set
import qualified Data.ByteString.Lazy as LBS
import System.FilePath ( (</>), (<.>), takeDirectory )
import System.Directory ( getCurrentDirectory, removeFile, doesFileExist )
Expand Down Expand Up @@ -434,52 +433,36 @@ generateCode codeGens nm pdesc bi lbi clbi verbosity = do
-- information.
addExtraCSources :: BuildInfo -> [FilePath] -> BuildInfo
addExtraCSources bi extras = bi { cSources = new }
where new = Set.toList $ old `Set.union` exs
old = Set.fromList $ cSources bi
exs = Set.fromList extras

where new = ordNub (extras ++ cSources bi)

-- | Add extra C++ sources generated by preprocessing to build
-- information.
addExtraCxxSources :: BuildInfo -> [FilePath] -> BuildInfo
addExtraCxxSources bi extras = bi { cxxSources = new }
where new = Set.toList $ old `Set.union` exs
old = Set.fromList $ cxxSources bi
exs = Set.fromList extras

where new = ordNub (extras ++ cxxSources bi)

-- | Add extra C-- sources generated by preprocessing to build
-- information.
addExtraCmmSources :: BuildInfo -> [FilePath] -> BuildInfo
addExtraCmmSources bi extras = bi { cmmSources = new }
where new = Set.toList $ old `Set.union` exs
old = Set.fromList $ cmmSources bi
exs = Set.fromList extras

where new = ordNub (extras ++ cmmSources bi)

-- | Add extra ASM sources generated by preprocessing to build
-- information.
addExtraAsmSources :: BuildInfo -> [FilePath] -> BuildInfo
addExtraAsmSources bi extras = bi { asmSources = new }
where new = Set.toList $ old `Set.union` exs
old = Set.fromList $ asmSources bi
exs = Set.fromList extras
where new = ordNub (extras ++ asmSources bi)

-- | Add extra HS modules generated by preprocessing to build
-- information.
addExtraOtherModules :: BuildInfo -> [ModuleName.ModuleName] -> BuildInfo
addExtraOtherModules bi extras = bi { otherModules = new }
where new = Set.toList $ old `Set.union` exs
old = Set.fromList $ otherModules bi
exs = Set.fromList extras
where new = ordNub (extras ++ otherModules bi)

-- | Add extra source dir for generated modules.
addSrcDir :: BuildInfo -> FilePath -> BuildInfo
addSrcDir bi extra = bi { hsSourceDirs = new }
where new = Set.toList $ old `Set.union` ex
old = Set.fromList $ hsSourceDirs bi
ex = Set.fromList [unsafeMakeSymbolicPath extra] -- TODO
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happened to the TODO?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

got lost, but I'm not sure what it meant to begin with?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, neither do I, unfortunately. I hoped you fixed it somehow :D

Copy link
Collaborator

Choose a reason for hiding this comment

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

What it meant I have a guess: maybe the author of TODO wished there was no "unsafe"?


where new = ordNub (unsafeMakeSymbolicPath extra : hsSourceDirs bi)

replComponent :: ReplOptions
-> Verbosity
Expand Down
7 changes: 7 additions & 0 deletions changelog.d/pr-8499
@@ -0,0 +1,7 @@
synopsis: orders extra stanzas
packages: Cabal
prs: #8499
issues: #8458
description: {
Ensure thatt extra-src-dirs, extra sources, and extra other modules all are added using ordNub rather than incidentally alphabetized.
}