Commit fe9bdc8c authored by Merijn Verstraaten's avatar Merijn Verstraaten
Browse files

Apply program flag normalisation to local packages too.

Move package flag normalisation code for the new-build hash into it's own
`normaliseConfiguredPackage` function and reuse it to detect whether the
configuration of a local package has changed and needs to be rebuild.
parent 419c65e0
......@@ -98,6 +98,7 @@ import Data.List (isPrefixOf)
import Control.Monad
import Control.Exception
import Data.Function (on)
import Data.Maybe
import System.FilePath
......@@ -251,7 +252,7 @@ rebuildTargetsDryRun distDirLayout@DistDirLayout{..} shared =
return (BuildStatusUpToDate buildResult)
where
packageFileMonitor =
newPackageFileMonitor distDirLayout (elabDistDirParams shared pkg)
newPackageFileMonitor shared distDirLayout (elabDistDirParams shared pkg)
-- | A specialised traversal over the packages in an install plan.
......@@ -330,11 +331,20 @@ data PackageFileMonitor = PackageFileMonitor {
--
type BuildResultMisc = (DocsResult, TestsResult)
newPackageFileMonitor :: DistDirLayout -> DistDirParams -> PackageFileMonitor
newPackageFileMonitor DistDirLayout{distPackageCacheFile} dparams =
newPackageFileMonitor :: ElaboratedSharedConfig
-> DistDirLayout
-> DistDirParams
-> PackageFileMonitor
newPackageFileMonitor shared
DistDirLayout{distPackageCacheFile}
dparams =
PackageFileMonitor {
pkgFileMonitorConfig =
newFileMonitor (distPackageCacheFile dparams "config"),
FileMonitor {
fileMonitorCacheFile = distPackageCacheFile dparams "config",
fileMonitorKeyValid = (==) `on` normaliseConfiguredPackage shared,
fileMonitorCheckIfOnlyValueChanged = False
},
pkgFileMonitorBuild =
FileMonitor {
......@@ -1244,7 +1254,7 @@ buildInplaceUnpackedPackage verbosity
isParallelBuild = buildSettingNumJobs >= 2
packageFileMonitor = newPackageFileMonitor distDirLayout dparams
packageFileMonitor = newPackageFileMonitor pkgshared distDirLayout dparams
whenReConfigure action = case buildStatus of
BuildStatusConfigure _ -> action
......
......@@ -3559,10 +3559,7 @@ packageHashInputs _ pkg =
packageHashConfigInputs :: ElaboratedSharedConfig
-> ElaboratedConfiguredPackage
-> PackageHashConfigInputs
packageHashConfigInputs
ElaboratedSharedConfig{..}
ElaboratedConfiguredPackage{..} =
packageHashConfigInputs shared@ElaboratedSharedConfig{..} pkg =
PackageHashConfigInputs {
pkgHashCompilerId = compilerId pkgConfigCompiler,
pkgHashPlatform = pkgConfigPlatform,
......@@ -3583,7 +3580,7 @@ packageHashConfigInputs
pkgHashStripLibs = elabStripLibs,
pkgHashStripExes = elabStripExes,
pkgHashDebugInfo = elabDebugInfo,
pkgHashProgramArgs = Map.mapWithKey lookupFilter elabProgramArgs,
pkgHashProgramArgs = elabProgramArgs,
pkgHashExtraLibDirs = elabExtraLibDirs,
pkgHashExtraFrameworkDirs = elabExtraFrameworkDirs,
pkgHashExtraIncludeDirs = elabExtraIncludeDirs,
......@@ -3591,16 +3588,7 @@ packageHashConfigInputs
pkgHashProgSuffix = elabProgSuffix
}
where
knownProgramDb = addKnownPrograms builtinPrograms pkgConfigCompilerProgs
lookupFilter :: String -> [String] -> [String]
lookupFilter n flags = case lookupKnownProgram n knownProgramDb of
Just p -> programNormaliseArgs p (getVersion p) elabPkgDescription flags
Nothing -> flags
getVersion :: Program -> Maybe Version
getVersion p = lookupProgram p knownProgramDb >>= programVersion
ElaboratedConfiguredPackage{..} = normaliseConfiguredPackage shared pkg
-- | Given the 'InstalledPackageIndex' for a nix-style package store, and an
-- 'ElaboratedInstallPlan', replace configured source packages by installed
......
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE TypeFamilies #-}
-- | Types used while planning how to build everything in a project.
......@@ -11,6 +12,7 @@ module Distribution.Client.ProjectPlanning.Types (
-- * Elaborated install plan types
ElaboratedInstallPlan,
normaliseConfiguredPackage,
ElaboratedConfiguredPackage(..),
elabDistDirParams,
......@@ -83,7 +85,7 @@ import Distribution.InstalledPackageInfo (InstalledPackageInfo)
import Distribution.Simple.Compiler
import Distribution.Simple.Build.PathsModule (pkgPathEnvVar)
import qualified Distribution.Simple.BuildTarget as Cabal
import Distribution.Simple.Program.Db
import Distribution.Simple.Program
import Distribution.ModuleName (ModuleName)
import Distribution.Simple.LocalBuildInfo (ComponentName(..))
import qualified Distribution.Simple.InstallDirs as InstallDirs
......@@ -98,6 +100,7 @@ import Distribution.Compat.Graph (IsNode(..))
import Distribution.Simple.Utils (ordNub)
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe (catMaybes)
import Data.Set (Set)
import qualified Data.ByteString.Lazy as LBS
......@@ -310,6 +313,25 @@ data ElaboratedConfiguredPackage
}
deriving (Eq, Show, Generic, Typeable)
normaliseConfiguredPackage :: ElaboratedSharedConfig
-> ElaboratedConfiguredPackage
-> ElaboratedConfiguredPackage
normaliseConfiguredPackage ElaboratedSharedConfig{pkgConfigCompilerProgs} pkg =
pkg { elabProgramArgs = Map.mapWithKey lookupFilter (elabProgramArgs pkg) }
where
knownProgramDb = addKnownPrograms builtinPrograms pkgConfigCompilerProgs
pkgDesc :: PackageDescription
pkgDesc = elabPkgDescription pkg
lookupFilter :: String -> [String] -> [String]
lookupFilter n args = case lookupKnownProgram n knownProgramDb of
Just p -> programNormaliseArgs p (getVersion p) pkgDesc args
Nothing -> args
getVersion :: Program -> Maybe Version
getVersion p = lookupProgram p knownProgramDb >>= programVersion
-- | The package/component contains/is a library and so must be registered
elabRequiresRegistration :: ElaboratedConfiguredPackage -> Bool
elabRequiresRegistration elab =
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment