Skip to content

Commit

Permalink
Basic infrastructure for filtering the command-line arguments for pro…
Browse files Browse the repository at this point in the history
…grams from

the new-build hash input to reduce redundant recompilation.

See haskell#4247.
  • Loading branch information
merijn committed Mar 28, 2018
1 parent 457ebb8 commit 0a4fd6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 8 additions & 3 deletions Cabal/Distribution/Simple/Program/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ data Program = Program {
-- | A function to do any additional configuration after we have
-- located the program (and perhaps identified its version). For example
-- it could add args, or environment vars.
programPostConf :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram
programPostConf :: Verbosity -> ConfiguredProgram -> IO ConfiguredProgram,
-- | A function that filters any arguments that don't impact the output
-- from a commandline. Used to limit the volatility of dependency hashes
-- when using new-build.
programFilterArgs :: Maybe Version -> [String] -> [String]
}
instance Show Program where
show (Program name _ _ _) = "Program: " ++ name
show (Program name _ _ _ _) = "Program: " ++ name

type ProgArg = String

Expand Down Expand Up @@ -161,7 +165,8 @@ simpleProgram name = Program {
programName = name,
programFindLocation = \v p -> findProgramOnSearchPath v p name,
programFindVersion = \_ _ -> return Nothing,
programPostConf = \_ p -> return p
programPostConf = \_ p -> return p,
programFilterArgs = const id
}

-- | Make a simple 'ConfiguredProgram'.
Expand Down
10 changes: 9 additions & 1 deletion cabal-install/Distribution/Client/ProjectPlanning.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3522,13 +3522,21 @@ packageHashConfigInputs
pkgHashStripLibs = elabStripLibs,
pkgHashStripExes = elabStripExes,
pkgHashDebugInfo = elabDebugInfo,
pkgHashProgramArgs = elabProgramArgs,
pkgHashProgramArgs = Map.mapWithKey lookupFilter elabProgramArgs,
pkgHashExtraLibDirs = elabExtraLibDirs,
pkgHashExtraFrameworkDirs = elabExtraFrameworkDirs,
pkgHashExtraIncludeDirs = elabExtraIncludeDirs,
pkgHashProgPrefix = elabProgPrefix,
pkgHashProgSuffix = elabProgSuffix
}
where
lookupFilter :: String -> [String] -> [String]
lookupFilter n = case lookupKnownProgram n pkgConfigCompilerProgs of
Just p -> programFilterArgs p (getVersion p)
Nothing -> id

getVersion :: Program -> Maybe Version
getVersion p = lookupProgram p pkgConfigCompilerProgs >>= programVersion


-- | Given the 'InstalledPackageIndex' for a nix-style package store, and an
Expand Down

0 comments on commit 0a4fd6a

Please sign in to comment.