diff --git a/Cabal/Distribution/Backpack/ComponentsGraph.hs b/Cabal/Distribution/Backpack/ComponentsGraph.hs index aab90dd6e0e..4ee8ff06d9a 100644 --- a/Cabal/Distribution/Backpack/ComponentsGraph.hs +++ b/Cabal/Distribution/Backpack/ComponentsGraph.hs @@ -12,7 +12,7 @@ import Prelude () import Distribution.Compat.Prelude import Distribution.Package -import Distribution.PackageDescription as PD hiding (Flag) +import Distribution.PackageDescription import Distribution.Simple.BuildToolDepends import Distribution.Simple.LocalBuildInfo import Distribution.Types.ComponentRequestedSpec diff --git a/Cabal/Distribution/Backpack/Configure.hs b/Cabal/Distribution/Backpack/Configure.hs index 78e393137b2..62f5e5462ce 100644 --- a/Cabal/Distribution/Backpack/Configure.hs +++ b/Cabal/Distribution/Backpack/Configure.hs @@ -27,14 +27,14 @@ import Distribution.Backpack.ReadyComponent import Distribution.Backpack.ComponentsGraph import Distribution.Backpack.Id -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.Simple.Compiler import Distribution.Package import qualified Distribution.InstalledPackageInfo as Installed import Distribution.InstalledPackageInfo (InstalledPackageInfo ,emptyInstalledPackageInfo) import qualified Distribution.Simple.PackageIndex as PackageIndex import Distribution.Simple.PackageIndex (InstalledPackageIndex) -import Distribution.PackageDescription as PD hiding (Flag) +import Distribution.PackageDescription import Distribution.ModuleName import Distribution.Simple.Setup as Setup import Distribution.Simple.LocalBuildInfo diff --git a/Cabal/Distribution/Backpack/ConfiguredComponent.hs b/Cabal/Distribution/Backpack/ConfiguredComponent.hs index aabe1898a47..a2c0c3c47e9 100644 --- a/Cabal/Distribution/Backpack/ConfiguredComponent.hs +++ b/Cabal/Distribution/Backpack/ConfiguredComponent.hs @@ -35,7 +35,7 @@ import Distribution.Types.LibraryName import Distribution.Types.UnqualComponentName import Distribution.Types.ComponentInclude import Distribution.Package -import Distribution.PackageDescription as PD hiding (Flag) +import Distribution.PackageDescription import Distribution.Simple.BuildToolDepends import Distribution.Simple.Setup as Setup import Distribution.Simple.LocalBuildInfo diff --git a/Cabal/Distribution/Backpack/Id.hs b/Cabal/Distribution/Backpack/Id.hs index b5e14a60ba5..53b99784f3c 100644 --- a/Cabal/Distribution/Backpack/Id.hs +++ b/Cabal/Distribution/Backpack/Id.hs @@ -11,8 +11,8 @@ import Prelude () import Distribution.Compat.Prelude import Distribution.Types.UnqualComponentName -import Distribution.Simple.Compiler hiding (Flag) -import Distribution.PackageDescription as PD hiding (Flag) +import Distribution.Simple.Compiler +import Distribution.PackageDescription import Distribution.Simple.Setup as Setup import qualified Distribution.Simple.InstallDirs as InstallDirs import Distribution.Simple.LocalBuildInfo diff --git a/Cabal/Distribution/Backpack/LinkedComponent.hs b/Cabal/Distribution/Backpack/LinkedComponent.hs index 1ead8f0c7e9..584fc5d713f 100644 --- a/Cabal/Distribution/Backpack/LinkedComponent.hs +++ b/Cabal/Distribution/Backpack/LinkedComponent.hs @@ -35,7 +35,7 @@ import Distribution.Types.ComponentInclude import Distribution.Types.ComponentId import Distribution.Types.PackageId import Distribution.Package -import Distribution.PackageDescription as PD hiding (Flag) +import Distribution.PackageDescription import Distribution.ModuleName import Distribution.Simple.LocalBuildInfo import Distribution.Verbosity diff --git a/Cabal/Distribution/Fields/ConfVar.hs b/Cabal/Distribution/Fields/ConfVar.hs index 879841cd19d..68601cd53e9 100644 --- a/Cabal/Distribution/Fields/ConfVar.hs +++ b/Cabal/Distribution/Fields/ConfVar.hs @@ -1,14 +1,14 @@ {-# LANGUAGE OverloadedStrings #-} module Distribution.Fields.ConfVar (parseConditionConfVar) where -import Distribution.Compat.CharParsing (char, integral) +import Distribution.Compat.CharParsing (char, integral) import Distribution.Compat.Prelude -import Distribution.Parsec (Parsec (..), runParsecParser, Position (..)) -import Distribution.Parsec.FieldLineStream (fieldLineStreamFromBS) -import Distribution.Fields.Field (SectionArg (..)) +import Distribution.Fields.Field (SectionArg (..)) import Distribution.Fields.ParseResult +import Distribution.Parsec (Parsec (..), Position (..), runParsecParser) +import Distribution.Parsec.FieldLineStream (fieldLineStreamFromBS) import Distribution.Types.Condition -import Distribution.Types.ConfVar (ConfVar (..)) +import Distribution.Types.ConfVar (ConfVar (..)) import Distribution.Version (anyVersion, earlierVersion, intersectVersionRanges, laterVersion, majorBoundVersion, mkVersion, noVersion, orEarlierVersion, orLaterVersion, thisVersion, unionVersionRanges, @@ -52,7 +52,7 @@ parser = condOr boolLiteral = Lit <$> boolLiteral' osCond = Var . OS <$ string "os" <*> parens fromParsec - flagCond = Var . Flag <$ string "flag" <*> parens fromParsec + flagCond = Var . PackageFlag <$ string "flag" <*> parens fromParsec archCond = Var . Arch <$ string "arch" <*> parens fromParsec implCond = Var <$ string "impl" <*> parens implCond' diff --git a/Cabal/Distribution/PackageDescription.hs b/Cabal/Distribution/PackageDescription.hs index b8b1304d402..6376c8ca4a0 100644 --- a/Cabal/Distribution/PackageDescription.hs +++ b/Cabal/Distribution/PackageDescription.hs @@ -91,7 +91,7 @@ module Distribution.PackageDescription ( -- * package configuration GenericPackageDescription(..), - Flag(..), emptyFlag, + PackageFlag(..), emptyFlag, FlagName, mkFlagName, unFlagName, FlagAssignment, mkFlagAssignment, unFlagAssignment, nullFlagAssignment, showFlagValue, diff --git a/Cabal/Distribution/PackageDescription/Check.hs b/Cabal/Distribution/PackageDescription/Check.hs index 72336652e37..687246c3c89 100644 --- a/Cabal/Distribution/PackageDescription/Check.hs +++ b/Cabal/Distribution/PackageDescription/Check.hs @@ -1500,12 +1500,12 @@ checkUnusedFlags gpd used :: Set.Set FlagName used = mconcat - [ toSetOf (L.condLibrary . traverse . traverseCondTreeV . L._Flag) gpd - , toSetOf (L.condSubLibraries . traverse . _2 . traverseCondTreeV . L._Flag) gpd - , toSetOf (L.condForeignLibs . traverse . _2 . traverseCondTreeV . L._Flag) gpd - , toSetOf (L.condExecutables . traverse . _2 . traverseCondTreeV . L._Flag) gpd - , toSetOf (L.condTestSuites . traverse . _2 . traverseCondTreeV . L._Flag) gpd - , toSetOf (L.condBenchmarks . traverse . _2 . traverseCondTreeV . L._Flag) gpd + [ toSetOf (L.condLibrary . traverse . traverseCondTreeV . L._PackageFlag) gpd + , toSetOf (L.condSubLibraries . traverse . _2 . traverseCondTreeV . L._PackageFlag) gpd + , toSetOf (L.condForeignLibs . traverse . _2 . traverseCondTreeV . L._PackageFlag) gpd + , toSetOf (L.condExecutables . traverse . _2 . traverseCondTreeV . L._PackageFlag) gpd + , toSetOf (L.condTestSuites . traverse . _2 . traverseCondTreeV . L._PackageFlag) gpd + , toSetOf (L.condBenchmarks . traverse . _2 . traverseCondTreeV . L._PackageFlag) gpd ] checkUnicodeXFields :: GenericPackageDescription -> [PackageCheck] @@ -1650,14 +1650,14 @@ checkDevelopmentOnlyFlags pkg = -- We've basically got three-values logic here: True, False or unknown -- hence this pattern to propagate the unknown cases properly. - definitelyFalse (Var (Flag n)) = maybe False not (Map.lookup n manualFlags) + definitelyFalse (Var (PackageFlag n)) = maybe False not (Map.lookup n manualFlags) definitelyFalse (Var _) = False definitelyFalse (Lit b) = not b definitelyFalse (CNot c) = definitelyTrue c definitelyFalse (COr c1 c2) = definitelyFalse c1 && definitelyFalse c2 definitelyFalse (CAnd c1 c2) = definitelyFalse c1 || definitelyFalse c2 - definitelyTrue (Var (Flag n)) = fromMaybe False (Map.lookup n manualFlags) + definitelyTrue (Var (PackageFlag n)) = fromMaybe False (Map.lookup n manualFlags) definitelyTrue (Var _) = False definitelyTrue (Lit b) = b definitelyTrue (CNot c) = definitelyFalse c diff --git a/Cabal/Distribution/PackageDescription/Configuration.hs b/Cabal/Distribution/PackageDescription/Configuration.hs index 2c55f17daad..0231277e6dc 100644 --- a/Cabal/Distribution/PackageDescription/Configuration.hs +++ b/Cabal/Distribution/PackageDescription/Configuration.hs @@ -88,7 +88,7 @@ simplifyWithSysParams os arch cinfo cond = (cond', flags) Just compat -> Right (any matchImpl compat) where matchImpl (CompilerId c v) = comp == c && v `withinRange` vr - interp (Flag f) = Left f + interp (PackageFlag f) = Left f -- TODO: Add instances and check -- @@ -125,7 +125,7 @@ parseCondition = condOr boolLiteral = fmap Lit parsec archIdent = fmap Arch parsec osIdent = fmap OS parsec - flagIdent = fmap (Flag . mkFlagName . lowercase) (munch1 isIdentChar) + flagIdent = fmap (PackageFlag . mkFlagName . lowercase) (munch1 isIdentChar) isIdentChar c = isAlphaNum c || c == '_' || c == '-' oper s = sp >> string s >> sp sp = spaces @@ -327,7 +327,7 @@ fromDepMapUnion :: DepMapUnion -> [Dependency] fromDepMapUnion m = [ Dependency p vr cs | (p,(vr,cs)) <- Map.toList (unDepMapUnion m) ] freeVars :: CondTree ConfVar c a -> [FlagName] -freeVars t = [ f | Flag f <- freeVars' t ] +freeVars t = [ f | PackageFlag f <- freeVars' t ] where freeVars' (CondNode _ _ ifs) = concatMap compfv ifs compfv (CondBranch c ct mct) = condfv c ++ freeVars' ct ++ maybe [] freeVars' mct @@ -478,7 +478,7 @@ finalizePD userflags enabled satisfyDep ++ map (\(name,tree) -> mapTreeData (SubComp name . CTest) tree) tests0 ++ map (\(name,tree) -> mapTreeData (SubComp name . CBench) tree) bms0 - flagChoices = map (\(MkFlag n _ d manual) -> (n, d2c manual n d)) flags + flagChoices = map (\(MkPackageFlag n _ d manual) -> (n, d2c manual n d)) flags d2c manual n b = case lookupFlagAssignment n userflags of Just val -> [val] Nothing diff --git a/Cabal/Distribution/PackageDescription/FieldGrammar.hs b/Cabal/Distribution/PackageDescription/FieldGrammar.hs index 5bb8455ae0d..65acced3fac 100644 --- a/Cabal/Distribution/PackageDescription/FieldGrammar.hs +++ b/Cabal/Distribution/PackageDescription/FieldGrammar.hs @@ -505,14 +505,14 @@ lookupLens k f p@(PerCompilerFlavor ghc ghcjs) ------------------------------------------------------------------------------- flagFieldGrammar - :: (FieldGrammar g, Applicative (g Flag)) - => FlagName -> g Flag Flag -flagFieldGrammar name = MkFlag name + :: (FieldGrammar g, Applicative (g PackageFlag)) + => FlagName -> g PackageFlag PackageFlag +flagFieldGrammar name = MkPackageFlag name <$> freeTextFieldDef "description" L.flagDescription <*> booleanFieldDef "default" L.flagDefault True <*> booleanFieldDef "manual" L.flagManual False -{-# SPECIALIZE flagFieldGrammar :: FlagName -> ParsecFieldGrammar' Flag #-} -{-# SPECIALIZE flagFieldGrammar :: FlagName -> PrettyFieldGrammar' Flag #-} +{-# SPECIALIZE flagFieldGrammar :: FlagName -> ParsecFieldGrammar' PackageFlag #-} +{-# SPECIALIZE flagFieldGrammar :: FlagName -> PrettyFieldGrammar' PackageFlag #-} ------------------------------------------------------------------------------- -- SourceRepo diff --git a/Cabal/Distribution/PackageDescription/PrettyPrint.hs b/Cabal/Distribution/PackageDescription/PrettyPrint.hs index 68144093014..a81faf64658 100644 --- a/Cabal/Distribution/PackageDescription/PrettyPrint.hs +++ b/Cabal/Distribution/PackageDescription/PrettyPrint.hs @@ -100,11 +100,11 @@ ppSetupBInfo v (Just sbi) | otherwise = pure $ PrettySection () "custom-setup" [] $ prettyFieldGrammar v (setupBInfoFieldGrammar False) sbi -ppGenPackageFlags :: CabalSpecVersion -> [Flag] -> [PrettyField ()] +ppGenPackageFlags :: CabalSpecVersion -> [PackageFlag] -> [PrettyField ()] ppGenPackageFlags = map . ppFlag -ppFlag :: CabalSpecVersion -> Flag -> PrettyField () -ppFlag v flag@(MkFlag name _ _ _) = PrettySection () "flag" [ppFlagName name] $ +ppFlag :: CabalSpecVersion -> PackageFlag -> PrettyField () +ppFlag v flag@(MkPackageFlag name _ _ _) = PrettySection () "flag" [ppFlagName name] $ prettyFieldGrammar v (flagFieldGrammar name) flag ppCondTree2 :: CabalSpecVersion -> PrettyFieldGrammar' s -> CondTree ConfVar [Dependency] s -> [PrettyField ()] @@ -176,10 +176,10 @@ ppCondition (COr c1 c2) = parens (hsep [ppCondition c1, text "| ppCondition (CAnd c1 c2) = parens (hsep [ppCondition c1, text "&&" <+> ppCondition c2]) ppConfVar :: ConfVar -> Doc -ppConfVar (OS os) = text "os" <<>> parens (pretty os) -ppConfVar (Arch arch) = text "arch" <<>> parens (pretty arch) -ppConfVar (Flag name) = text "flag" <<>> parens (ppFlagName name) -ppConfVar (Impl c v) = text "impl" <<>> parens (pretty c <+> pretty v) +ppConfVar (OS os) = text "os" <<>> parens (pretty os) +ppConfVar (Arch arch) = text "arch" <<>> parens (pretty arch) +ppConfVar (PackageFlag name) = text "flag" <<>> parens (ppFlagName name) +ppConfVar (Impl c v) = text "impl" <<>> parens (pretty c <+> pretty v) ppFlagName :: FlagName -> Doc ppFlagName = text . unFlagName diff --git a/Cabal/Distribution/Simple.hs b/Cabal/Distribution/Simple.hs index 68baecec36c..0d2f34746a6 100644 --- a/Cabal/Distribution/Simple.hs +++ b/Cabal/Distribution/Simple.hs @@ -61,10 +61,10 @@ import Prelude () import Distribution.Compat.Prelude -- local -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.Simple.Compiler import Distribution.Simple.UserHooks import Distribution.Package -import Distribution.PackageDescription hiding (Flag) +import Distribution.PackageDescription import Distribution.PackageDescription.Configuration import Distribution.Simple.Program import Distribution.Simple.Program.Db diff --git a/Cabal/Distribution/Simple/Build.hs b/Cabal/Distribution/Simple/Build.hs index e6916b8e9a6..593c2afce60 100644 --- a/Cabal/Distribution/Simple/Build.hs +++ b/Cabal/Distribution/Simple/Build.hs @@ -57,8 +57,8 @@ import Distribution.Simple.Build.Macros (generateCabalMacrosHeader) import Distribution.Simple.Build.PathsModule (generatePathsModule) import qualified Distribution.Simple.Program.HcPkg as HcPkg -import Distribution.Simple.Compiler hiding (Flag) -import Distribution.PackageDescription hiding (Flag) +import Distribution.Simple.Compiler +import Distribution.PackageDescription import qualified Distribution.InstalledPackageInfo as IPI import Distribution.InstalledPackageInfo (InstalledPackageInfo) import qualified Distribution.ModuleName as ModuleName diff --git a/Cabal/Distribution/Simple/Compiler.hs b/Cabal/Distribution/Simple/Compiler.hs index 03e6b1e25cc..976c6438b9f 100644 --- a/Cabal/Distribution/Simple/Compiler.hs +++ b/Cabal/Distribution/Simple/Compiler.hs @@ -47,7 +47,7 @@ module Distribution.Simple.Compiler ( flagToDebugInfoLevel, -- * Support for language extensions - Flag, + CompilerFlag, languageToFlags, unsupportedLanguages, extensionsToFlags, @@ -93,9 +93,9 @@ data Compiler = Compiler { compilerCompat :: [CompilerId], -- ^ Other implementations that this compiler claims to be -- compatible with. - compilerLanguages :: [(Language, Flag)], + compilerLanguages :: [(Language, CompilerFlag)], -- ^ Supported language standards. - compilerExtensions :: [(Extension, Maybe Flag)], + compilerExtensions :: [(Extension, Maybe CompilerFlag)], -- ^ Supported extensions. compilerProperties :: Map String String -- ^ A key-value map for properties not covered by the above fields. @@ -279,12 +279,12 @@ unsupportedLanguages comp langs = [ lang | lang <- langs , isNothing (languageToFlag comp lang) ] -languageToFlags :: Compiler -> Maybe Language -> [Flag] +languageToFlags :: Compiler -> Maybe Language -> [CompilerFlag] languageToFlags comp = filter (not . null) . catMaybes . map (languageToFlag comp) . maybe [Haskell98] (\x->[x]) -languageToFlag :: Compiler -> Language -> Maybe Flag +languageToFlag :: Compiler -> Language -> Maybe CompilerFlag languageToFlag comp ext = lookup ext (compilerLanguages comp) @@ -294,16 +294,16 @@ unsupportedExtensions comp exts = [ ext | ext <- exts , isNothing (extensionToFlag' comp ext) ] -type Flag = String +type CompilerFlag = String -- |For the given compiler, return the flags for the supported extensions. -extensionsToFlags :: Compiler -> [Extension] -> [Flag] +extensionsToFlags :: Compiler -> [Extension] -> [CompilerFlag] extensionsToFlags comp = nub . filter (not . null) . catMaybes . map (extensionToFlag comp) -- | Looks up the flag for a given extension, for a given compiler. -- Ignores the subtlety of extensions which lack associated flags. -extensionToFlag :: Compiler -> Extension -> Maybe Flag +extensionToFlag :: Compiler -> Extension -> Maybe CompilerFlag extensionToFlag comp ext = join (extensionToFlag' comp ext) -- | Looks up the flag for a given extension, for a given compiler. @@ -315,7 +315,7 @@ extensionToFlag comp ext = join (extensionToFlag' comp ext) -- the inner layer indicates whether it has a flag. -- When building strings, it is often more convenient to use 'extensionToFlag', -- which ignores the difference. -extensionToFlag' :: Compiler -> Extension -> Maybe (Maybe Flag) +extensionToFlag' :: Compiler -> Extension -> Maybe (Maybe CompilerFlag) extensionToFlag' comp ext = lookup ext (compilerExtensions comp) -- | Does this compiler support parallel --make mode? diff --git a/Cabal/Distribution/Simple/Configure.hs b/Cabal/Distribution/Simple/Configure.hs index 8abdc6485b2..9e3a111570c 100644 --- a/Cabal/Distribution/Simple/Configure.hs +++ b/Cabal/Distribution/Simple/Configure.hs @@ -60,15 +60,15 @@ import Distribution.Compat.Prelude import Distribution.Compiler import Distribution.Types.IncludeRenaming import Distribution.Utils.NubList -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.Simple.Compiler import Distribution.Simple.PreProcess import Distribution.Package -import qualified Distribution.InstalledPackageInfo as Installed +import qualified Distribution.InstalledPackageInfo as IPI import Distribution.InstalledPackageInfo (InstalledPackageInfo) import qualified Distribution.Simple.PackageIndex as PackageIndex import Distribution.Simple.PackageIndex (InstalledPackageIndex) -import Distribution.PackageDescription as PD hiding (Flag) -import Distribution.Types.PackageDescription as PD +import Distribution.PackageDescription +import Distribution.Types.PackageDescription import Distribution.PackageDescription.PrettyPrint import Distribution.PackageDescription.Configuration import Distribution.PackageDescription.Check hiding (doesFileExist) @@ -902,7 +902,7 @@ getInternalPackages pkg_descr0 = -- | Returns true if a dependency is satisfiable. This function may -- report a dependency satisfiable even when it is not, but not vice --- versa. This is to be passed to finalizePD. +-- versa. This is to be passed to finalize dependencySatisfiable :: Bool -- ^ use external internal deps? -> Bool -- ^ exact configuration? @@ -977,7 +977,7 @@ dependencySatisfiable -- library yet, so we just return a bool and later report a generic error. visible lib = maybe False -- Does not even exist (wasn't in the depsMap) - (\ipi -> Installed.libVisibility ipi == LibraryVisibilityPublic + (\ipi -> IPI.libVisibility ipi == LibraryVisibilityPublic -- If the override is enabled, the visibility does -- not matter (it's handled externally) || allow_private_deps @@ -986,7 +986,7 @@ dependencySatisfiable -- This is only triggered when passing a component -- of the same package as --dependency, such as in: -- cabal-testsuite/PackageTests/ConfigureComponent/SubLib/setup-explicit.test.hs - || pkgName (Installed.sourcePackageId ipi) == pn) + || pkgName (IPI.sourcePackageId ipi) == pn) maybeIPI where maybeIPI = Map.lookup (depName, CLibName lib) requiredDepsMap @@ -1040,7 +1040,7 @@ configureFinalizedPackage verbosity cfg enabled addExtraIncludeLibDirs pkg_descr = let extraBi = mempty { extraLibDirs = configExtraLibDirs cfg , extraFrameworkDirs = configExtraFrameworkDirs cfg - , PD.includeDirs = configExtraIncludeDirs cfg} + , includeDirs = configExtraIncludeDirs cfg} modifyLib l = l{ libBuildInfo = libBuildInfo l `mappend` extraBi } modifyExecutable e = e{ buildInfo = buildInfo e @@ -1072,13 +1072,13 @@ checkCompilerProblems verbosity comp pkg_descr enabled = do ++ "package flags. To use this feature you must use " ++ "GHC 7.9 or later." - when (any (not.null.PD.reexportedModules) (PD.allLibraries pkg_descr) + when (any (not.null.reexportedModules) (allLibraries pkg_descr) && not (reexportedModulesSupported comp)) $ die' verbosity $ "Your compiler does not support module re-exports. To use " ++ "this feature you must use GHC 7.9 or later." - when (any (not.null.PD.signatures) (PD.allLibraries pkg_descr) + when (any (not.null.signatures) (allLibraries pkg_descr) && not (backpackSupported comp)) $ die' verbosity $ "Your compiler does not support Backpack. To use " @@ -1684,11 +1684,11 @@ ccLdOptionsBuildInfo cflags ldflags = (extraLibs', ldflags') = partition ("-l" `isPrefixOf`) ldflags (extraLibDirs', ldflags'') = partition ("-L" `isPrefixOf`) ldflags' in mempty { - PD.includeDirs = map (drop 2) includeDirs', - PD.extraLibs = map (drop 2) extraLibs', - PD.extraLibDirs = map (drop 2) extraLibDirs', - PD.ccOptions = cflags', - PD.ldOptions = ldflags'' + includeDirs = map (drop 2) includeDirs', + extraLibs = map (drop 2) extraLibs', + extraLibDirs = map (drop 2) extraLibDirs', + ccOptions = cflags', + ldOptions = ldflags'' } -- ----------------------------------------------------------------------------- @@ -1734,8 +1734,8 @@ checkForeignDeps pkg lbi verbosity = missingHdr <- findOffendingHdr explainErrors missingHdr missingLibs) where - allHeaders = collectField PD.includes - allLibs = collectField PD.extraLibs + allHeaders = collectField includes + allLibs = collectField extraLibs ifBuildsWith headers args success failure = do checkDuplicateHeaders @@ -1755,7 +1755,7 @@ checkForeignDeps pkg lbi verbosity = -- including file. As such we need to take drastic measures -- and delete the offending file in the source directory. checkDuplicateHeaders = do - let relIncDirs = filter (not . isAbsolute) (collectField PD.includeDirs) + let relIncDirs = filter (not . isAbsolute) (collectField includeDirs) isHeader = isSuffixOf ".h" genHeaders <- forM relIncDirs $ \dir -> fmap (dir ) . filter isHeader <$> @@ -1808,42 +1808,42 @@ checkForeignDeps pkg lbi verbosity = ++ [ "-I" ++ buildDir lbi "autogen" ] -- `configure' may generate headers in the build directory ++ [ "-I" ++ buildDir lbi dir - | dir <- ordNub (collectField PD.includeDirs) + | dir <- ordNub (collectField includeDirs) , not (isAbsolute dir)] -- we might also reference headers from the -- packages directory. ++ [ "-I" ++ baseDir lbi dir - | dir <- ordNub (collectField PD.includeDirs) + | dir <- ordNub (collectField includeDirs) , not (isAbsolute dir)] - ++ [ "-I" ++ dir | dir <- ordNub (collectField PD.includeDirs) + ++ [ "-I" ++ dir | dir <- ordNub (collectField includeDirs) , isAbsolute dir] ++ ["-I" ++ baseDir lbi] - ++ collectField PD.cppOptions - ++ collectField PD.ccOptions + ++ collectField cppOptions + ++ collectField ccOptions ++ [ "-I" ++ dir | dir <- ordNub [ dir | dep <- deps - , dir <- Installed.includeDirs dep ] + , dir <- IPI.includeDirs dep ] -- dedupe include dirs of dependencies -- to prevent quadratic blow-up ] ++ [ opt | dep <- deps - , opt <- Installed.ccOptions dep ] + , opt <- IPI.ccOptions dep ] commonCcArgs = commonCppArgs - ++ collectField PD.ccOptions + ++ collectField ccOptions ++ [ opt | dep <- deps - , opt <- Installed.ccOptions dep ] + , opt <- IPI.ccOptions dep ] commonLdArgs = [ "-L" ++ dir - | dir <- ordNub (collectField PD.extraLibDirs) ] - ++ collectField PD.ldOptions + | dir <- ordNub (collectField extraLibDirs) ] + ++ collectField ldOptions ++ [ "-L" ++ dir | dir <- ordNub [ dir | dep <- deps - , dir <- Installed.libraryDirs dep ] + , dir <- IPI.libraryDirs dep ] ] --TODO: do we also need dependent packages' ld options? makeLdArgs libs = [ "-l"++lib | lib <- libs ] ++ commonLdArgs @@ -2012,8 +2012,8 @@ checkRelocatable verbosity pkg lbi traverse_ (doCheck pkgr) ipkgs where doCheck pkgr ipkg - | maybe False (== pkgr) (Installed.pkgRoot ipkg) - = forM_ (Installed.libraryDirs ipkg) $ \libdir -> do + | maybe False (== pkgr) (IPI.pkgRoot ipkg) + = forM_ (IPI.libraryDirs ipkg) $ \libdir -> do -- When @prefix@ is not under @pkgroot@, -- @shortRelativePath prefix pkgroot@ will return a path with -- @..@s and following check will fail without @canonicalizePath@. diff --git a/Cabal/Distribution/Simple/Doctest.hs b/Cabal/Distribution/Simple/Doctest.hs index 9d75a3a37ac..7dcb3c5274e 100644 --- a/Cabal/Distribution/Simple/Doctest.hs +++ b/Cabal/Distribution/Simple/Doctest.hs @@ -25,8 +25,8 @@ import qualified Distribution.Simple.GHC as GHC import qualified Distribution.Simple.GHCJS as GHCJS -- local -import Distribution.PackageDescription as PD hiding (Flag) -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.PackageDescription +import Distribution.Simple.Compiler import Distribution.Simple.Program.GHC import Distribution.Simple.Program import Distribution.Simple.PreProcess diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs index 67990b951ec..9898d697ab0 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -99,7 +99,7 @@ import qualified Distribution.Simple.Program.Strip as Strip import Distribution.Simple.Program.GHC import Distribution.Simple.Setup import qualified Distribution.Simple.Setup as Cabal -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.Simple.Compiler import Distribution.Version import Distribution.System import Distribution.Verbosity diff --git a/Cabal/Distribution/Simple/GHC/Internal.hs b/Cabal/Distribution/Simple/GHC/Internal.hs index 243524ce246..b62288c9370 100644 --- a/Cabal/Distribution/Simple/GHC/Internal.hs +++ b/Cabal/Distribution/Simple/GHC/Internal.hs @@ -51,12 +51,11 @@ import Distribution.Compat.Prelude import Distribution.Simple.GHC.ImplInfo import Distribution.Types.ComponentLocalBuildInfo import Distribution.Backpack -import Distribution.InstalledPackageInfo -import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo -import Distribution.PackageDescription as PD hiding (Flag) +import qualified Distribution.InstalledPackageInfo as IPI +import Distribution.PackageDescription import Distribution.Compat.Exception import Distribution.Lex -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.Simple.Compiler import Distribution.Simple.Program.GHC import Distribution.Simple.Setup import qualified Distribution.ModuleName as ModuleName @@ -281,10 +280,10 @@ componentCcGhcOptions verbosity _implInfo lbi bi clbi odir filename = ,autogenPackageModulesDir lbi ,odir] -- includes relative to the package - ++ PD.includeDirs bi + ++ includeDirs bi -- potential includes generated by `configure' -- in the build directory - ++ [buildDir lbi dir | dir <- PD.includeDirs bi], + ++ [buildDir lbi dir | dir <- includeDirs bi], ghcOptHideAllPackages= toFlag True, ghcOptPackageDBs = withPackageDB lbi, ghcOptPackages = toNubListR $ mkGhcOptPackages clbi, @@ -296,7 +295,7 @@ componentCcGhcOptions verbosity _implInfo lbi bi clbi odir filename = MinimalDebugInfo -> ["-g1"] NormalDebugInfo -> ["-g"] MaximalDebugInfo -> ["-g3"]) ++ - PD.ccOptions bi, + ccOptions bi, ghcOptObjDir = toFlag odir } @@ -317,10 +316,10 @@ componentCxxGhcOptions verbosity _implInfo lbi bi clbi odir filename = ,autogenPackageModulesDir lbi ,odir] -- includes relative to the package - ++ PD.includeDirs bi + ++ includeDirs bi -- potential includes generated by `configure' -- in the build directory - ++ [buildDir lbi dir | dir <- PD.includeDirs bi], + ++ [buildDir lbi dir | dir <- includeDirs bi], ghcOptHideAllPackages= toFlag True, ghcOptPackageDBs = withPackageDB lbi, ghcOptPackages = toNubListR $ mkGhcOptPackages clbi, @@ -332,7 +331,7 @@ componentCxxGhcOptions verbosity _implInfo lbi bi clbi odir filename = MinimalDebugInfo -> ["-g1"] NormalDebugInfo -> ["-g"] MaximalDebugInfo -> ["-g3"]) ++ - PD.cxxOptions bi, + cxxOptions bi, ghcOptObjDir = toFlag odir } @@ -353,10 +352,10 @@ componentAsmGhcOptions verbosity _implInfo lbi bi clbi odir filename = ,autogenPackageModulesDir lbi ,odir] -- includes relative to the package - ++ PD.includeDirs bi + ++ includeDirs bi -- potential includes generated by `configure' -- in the build directory - ++ [buildDir lbi dir | dir <- PD.includeDirs bi], + ++ [buildDir lbi dir | dir <- includeDirs bi], ghcOptHideAllPackages= toFlag True, ghcOptPackageDBs = withPackageDB lbi, ghcOptPackages = toNubListR $ mkGhcOptPackages clbi, @@ -368,7 +367,7 @@ componentAsmGhcOptions verbosity _implInfo lbi bi clbi odir filename = MinimalDebugInfo -> ["-g1"] NormalDebugInfo -> ["-g"] MaximalDebugInfo -> ["-g3"]) ++ - PD.asmOptions bi, + asmOptions bi, ghcOptObjDir = toFlag odir } @@ -412,14 +411,14 @@ componentGhcOptions verbosity implInfo lbi bi clbi odir = ,autogenPackageModulesDir lbi ,odir] -- includes relative to the package - ++ PD.includeDirs bi + ++ includeDirs bi -- potential includes generated by `configure' -- in the build directory - ++ [buildDir lbi dir | dir <- PD.includeDirs bi], + ++ [buildDir lbi dir | dir <- includeDirs bi], ghcOptCppOptions = cppOptions bi, ghcOptCppIncludes = toNubListR $ [autogenComponentModulesDir lbi clbi cppHeaderName], - ghcOptFfiIncludes = toNubListR $ PD.includes bi, + ghcOptFfiIncludes = toNubListR $ includes bi, ghcOptObjDir = toFlag odir, ghcOptHiDir = toFlag odir, ghcOptStubDir = toFlag odir, @@ -461,10 +460,10 @@ componentCmmGhcOptions verbosity _implInfo lbi bi clbi odir filename = ,autogenPackageModulesDir lbi ,odir] -- includes relative to the package - ++ PD.includeDirs bi + ++ includeDirs bi -- potential includes generated by `configure' -- in the build directory - ++ [buildDir lbi dir | dir <- PD.includeDirs bi], + ++ [buildDir lbi dir | dir <- includeDirs bi], ghcOptCppOptions = cppOptions bi, ghcOptCppIncludes = toNubListR $ [autogenComponentModulesDir lbi clbi cppHeaderName], @@ -527,21 +526,15 @@ mkGhcOptPackages :: ComponentLocalBuildInfo -> [(OpenUnitId, ModuleRenaming)] mkGhcOptPackages = componentIncludes -substTopDir :: FilePath -> InstalledPackageInfo -> InstalledPackageInfo +substTopDir :: FilePath -> IPI.InstalledPackageInfo -> IPI.InstalledPackageInfo substTopDir topDir ipo = ipo { - InstalledPackageInfo.importDirs - = map f (InstalledPackageInfo.importDirs ipo), - InstalledPackageInfo.libraryDirs - = map f (InstalledPackageInfo.libraryDirs ipo), - InstalledPackageInfo.includeDirs - = map f (InstalledPackageInfo.includeDirs ipo), - InstalledPackageInfo.frameworkDirs - = map f (InstalledPackageInfo.frameworkDirs ipo), - InstalledPackageInfo.haddockInterfaces - = map f (InstalledPackageInfo.haddockInterfaces ipo), - InstalledPackageInfo.haddockHTMLs - = map f (InstalledPackageInfo.haddockHTMLs ipo) + IPI.importDirs = map f (IPI.importDirs ipo), + IPI.libraryDirs = map f (IPI.libraryDirs ipo), + IPI.includeDirs = map f (IPI.includeDirs ipo), + IPI.frameworkDirs = map f (IPI.frameworkDirs ipo), + IPI.haddockInterfaces = map f (IPI.haddockInterfaces ipo), + IPI.haddockHTMLs = map f (IPI.haddockHTMLs ipo) } where f ('$':'t':'o':'p':'d':'i':'r':rest) = topDir ++ rest f x = x diff --git a/Cabal/Distribution/Simple/GHCJS.hs b/Cabal/Distribution/Simple/GHCJS.hs index dfa2881bbb9..20493735ff2 100644 --- a/Cabal/Distribution/Simple/GHCJS.hs +++ b/Cabal/Distribution/Simple/GHCJS.hs @@ -63,7 +63,7 @@ import qualified Distribution.Simple.Program.Strip as Strip import Distribution.Simple.Program.GHC import Distribution.Simple.Setup import qualified Distribution.Simple.Setup as Cabal -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.Simple.Compiler import Distribution.CabalSpecVersion import Distribution.Version import Distribution.System diff --git a/Cabal/Distribution/Simple/Haddock.hs b/Cabal/Distribution/Simple/Haddock.hs index 7ad7d41c2e8..119455c6385 100644 --- a/Cabal/Distribution/Simple/Haddock.hs +++ b/Cabal/Distribution/Simple/Haddock.hs @@ -42,8 +42,8 @@ import Distribution.Types.TargetInfo import Distribution.Types.ExposedModule import Distribution.Package import qualified Distribution.ModuleName as ModuleName -import Distribution.PackageDescription as PD hiding (Flag) -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.PackageDescription +import Distribution.Simple.Compiler import Distribution.Simple.Glob import Distribution.Simple.Program.GHC import Distribution.Simple.Program.ResponseFile @@ -365,7 +365,7 @@ fromPackageDescription haddockTarget pkg_descr = mempty , argTitle = Flag $ showPkg ++ subtitle } where - desc = PD.description pkg_descr + desc = description pkg_descr showPkg = prettyShow (packageId pkg_descr) subtitle | ShortText.null (synopsis pkg_descr) = "" diff --git a/Cabal/Distribution/Simple/HaskellSuite.hs b/Cabal/Distribution/Simple/HaskellSuite.hs index 787b3edb0ea..567a3428149 100644 --- a/Cabal/Distribution/Simple/HaskellSuite.hs +++ b/Cabal/Distribution/Simple/HaskellSuite.hs @@ -12,7 +12,7 @@ import qualified Data.Map as Map (empty) import qualified Data.List.NonEmpty as NE import Distribution.Simple.Program -import Distribution.Simple.Compiler as Compiler +import Distribution.Simple.Compiler import Distribution.Simple.Utils import Distribution.Simple.BuildPaths import Distribution.Verbosity @@ -79,7 +79,7 @@ configure verbosity mbHcPath hcPkgPath progdb0 = do let comp = Compiler { compilerId = CompilerId (HaskellSuite compName) compVersion, - compilerAbiTag = Compiler.NoAbiTag, + compilerAbiTag = NoAbiTag, compilerCompat = [], compilerLanguages = languages, compilerExtensions = extensions, @@ -106,7 +106,7 @@ getCompilerVersion verbosity prog = do simpleParsec versionStr return (name, version) -getExtensions :: Verbosity -> ConfiguredProgram -> IO [(Extension, Maybe Compiler.Flag)] +getExtensions :: Verbosity -> ConfiguredProgram -> IO [(Extension, Maybe CompilerFlag)] getExtensions verbosity prog = do extStrs <- lines `fmap` @@ -114,7 +114,7 @@ getExtensions verbosity prog = do return [ (ext, Just $ "-X" ++ prettyShow ext) | Just ext <- map simpleParsec extStrs ] -getLanguages :: Verbosity -> ConfiguredProgram -> IO [(Language, Compiler.Flag)] +getLanguages :: Verbosity -> ConfiguredProgram -> IO [(Language, CompilerFlag)] getLanguages verbosity prog = do langStrs <- lines `fmap` diff --git a/Cabal/Distribution/Simple/Program/GHC.hs b/Cabal/Distribution/Simple/Program/GHC.hs index cdb9b014b19..8559f751285 100644 --- a/Cabal/Distribution/Simple/Program/GHC.hs +++ b/Cabal/Distribution/Simple/Program/GHC.hs @@ -27,10 +27,9 @@ import Distribution.Compat.Prelude import Distribution.Backpack import Distribution.Compat.Semigroup (First'(..), Last'(..), Option'(..)) import Distribution.Simple.GHC.ImplInfo -import Distribution.PackageDescription hiding (Flag) +import Distribution.PackageDescription import Distribution.ModuleName -import Distribution.Simple.Compiler hiding (Flag) -import qualified Distribution.Simple.Compiler as Compiler (Flag) +import Distribution.Simple.Compiler import Distribution.Simple.Flag import Distribution.Simple.Program.Types import Distribution.Simple.Program.Run @@ -457,7 +456,7 @@ data GhcOptions = GhcOptions { -- | A GHC version-dependent mapping of extensions to flags. This must be -- set to be able to make use of the 'ghcOptExtensions'. - ghcOptExtensionMap :: Map Extension (Maybe Compiler.Flag), + ghcOptExtensionMap :: Map Extension (Maybe CompilerFlag), ---------------- -- Compilation diff --git a/Cabal/Distribution/Simple/Setup.hs b/Cabal/Distribution/Simple/Setup.hs index c047b9aaa16..93783d4b006 100644 --- a/Cabal/Distribution/Simple/Setup.hs +++ b/Cabal/Distribution/Simple/Setup.hs @@ -88,10 +88,10 @@ import Distribution.Pretty import qualified Distribution.Compat.CharParsing as P import qualified Text.PrettyPrint as Disp import Distribution.ModuleName -import Distribution.PackageDescription hiding (Flag) +import Distribution.PackageDescription import Distribution.Simple.Command hiding (boolOpt, boolOpt') import qualified Distribution.Simple.Command as Command -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.Simple.Compiler import Distribution.Simple.Flag import Distribution.Simple.Utils import Distribution.Simple.Program diff --git a/Cabal/Distribution/Simple/SrcDist.hs b/Cabal/Distribution/Simple/SrcDist.hs index 6ad2257dd41..60bf9414aeb 100644 --- a/Cabal/Distribution/Simple/SrcDist.hs +++ b/Cabal/Distribution/Simple/SrcDist.hs @@ -47,7 +47,7 @@ module Distribution.Simple.SrcDist ( import Prelude () import Distribution.Compat.Prelude -import Distribution.PackageDescription hiding (Flag) +import Distribution.PackageDescription import Distribution.PackageDescription.Check hiding (doesFileExist) import Distribution.Package import Distribution.ModuleName diff --git a/Cabal/Distribution/Simple/UHC.hs b/Cabal/Distribution/Simple/UHC.hs index b155b4816cf..403d723604b 100644 --- a/Cabal/Distribution/Simple/UHC.hs +++ b/Cabal/Distribution/Simple/UHC.hs @@ -29,7 +29,7 @@ import Distribution.InstalledPackageInfo import Distribution.Package hiding (installedUnitId) import Distribution.PackageDescription import Distribution.Simple.BuildPaths -import Distribution.Simple.Compiler as C +import Distribution.Simple.Compiler import Distribution.Simple.LocalBuildInfo import Distribution.Simple.PackageIndex import Distribution.Simple.Program @@ -60,7 +60,7 @@ configure verbosity hcPath _hcPkgPath progdb = do let comp = Compiler { compilerId = CompilerId UHC uhcVersion, - compilerAbiTag = C.NoAbiTag, + compilerAbiTag = NoAbiTag, compilerCompat = [], compilerLanguages = uhcLanguages, compilerExtensions = uhcLanguageExtensions, @@ -69,11 +69,11 @@ configure verbosity hcPath _hcPkgPath progdb = do compPlatform = Nothing return (comp, compPlatform, progdb') -uhcLanguages :: [(Language, C.Flag)] +uhcLanguages :: [(Language, CompilerFlag)] uhcLanguages = [(Haskell98, "")] -- | The flags for the supported extensions. -uhcLanguageExtensions :: [(Extension, Maybe C.Flag)] +uhcLanguageExtensions :: [(Extension, Maybe CompilerFlag)] uhcLanguageExtensions = let doFlag (f, (enable, disable)) = [(EnableExtension f, enable), (DisableExtension f, disable)] diff --git a/Cabal/Distribution/Types/ConfVar.hs b/Cabal/Distribution/Types/ConfVar.hs index 67882d04b3f..39e5e04d326 100644 --- a/Cabal/Distribution/Types/ConfVar.hs +++ b/Cabal/Distribution/Types/ConfVar.hs @@ -15,7 +15,7 @@ import Distribution.System -- | A @ConfVar@ represents the variable type used. data ConfVar = OS OS | Arch Arch - | Flag FlagName + | PackageFlag FlagName | Impl CompilerFlavor VersionRange deriving (Eq, Show, Typeable, Data, Generic) diff --git a/Cabal/Distribution/Types/Flag.hs b/Cabal/Distribution/Types/Flag.hs index 588a3c88ccb..f9779aacd8d 100644 --- a/Cabal/Distribution/Types/Flag.hs +++ b/Cabal/Distribution/Types/Flag.hs @@ -2,7 +2,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Distribution.Types.Flag ( - Flag(..), + PackageFlag(..), emptyFlag, FlagName, mkFlagName, @@ -38,7 +38,7 @@ import qualified Distribution.Compat.CharParsing as P -- | A flag can represent a feature to be included, or a way of linking -- a target against its dependencies, or in fact whatever you can think of. -data Flag = MkFlag +data PackageFlag = MkPackageFlag { flagName :: FlagName , flagDescription :: String , flagDefault :: Bool @@ -46,14 +46,13 @@ data Flag = MkFlag } deriving (Show, Eq, Typeable, Data, Generic) -instance Binary Flag -instance Structured Flag +instance Binary PackageFlag +instance Structured PackageFlag +instance NFData PackageFlag where rnf = genericRnf -instance NFData Flag where rnf = genericRnf - --- | A 'Flag' initialized with default parameters. -emptyFlag :: FlagName -> Flag -emptyFlag name = MkFlag +-- | A 'PackageFlag' initialized with default parameters. +emptyFlag :: FlagName -> PackageFlag +emptyFlag name = MkPackageFlag { flagName = name , flagDescription = "" , flagDefault = True @@ -119,6 +118,8 @@ instance Described FlagName where -- discovered during configuration. For example @--flags=foo --flags=-bar@ -- becomes @[("foo", True), ("bar", False)]@ -- +-- TODO: Why we record the multiplicity of the flag? +-- newtype FlagAssignment = FlagAssignment { getFlagAssignment :: Map.Map FlagName (Int, Bool) } deriving (Binary, Generic, NFData, Typeable) diff --git a/Cabal/Distribution/Types/GenericPackageDescription.hs b/Cabal/Distribution/Types/GenericPackageDescription.hs index adbadf9ecec..96fa0620d65 100644 --- a/Cabal/Distribution/Types/GenericPackageDescription.hs +++ b/Cabal/Distribution/Types/GenericPackageDescription.hs @@ -45,7 +45,7 @@ data GenericPackageDescription = -- -- Perfectly, PackageIndex should have sum type, so we don't need to -- have dummy GPDs. - , genPackageFlags :: [Flag] + , genPackageFlags :: [PackageFlag] , condLibrary :: Maybe (CondTree ConfVar [Dependency] Library) , condSubLibraries :: [( UnqualComponentName , CondTree ConfVar [Dependency] Library )] diff --git a/Cabal/Distribution/Types/GenericPackageDescription/Lens.hs b/Cabal/Distribution/Types/GenericPackageDescription/Lens.hs index 05b73138d98..012d7365e54 100644 --- a/Cabal/Distribution/Types/GenericPackageDescription/Lens.hs +++ b/Cabal/Distribution/Types/GenericPackageDescription/Lens.hs @@ -1,7 +1,7 @@ {-# LANGUAGE Rank2Types #-} module Distribution.Types.GenericPackageDescription.Lens ( GenericPackageDescription, - Flag, + PackageFlag, FlagName, ConfVar (..), module Distribution.Types.GenericPackageDescription.Lens, @@ -22,7 +22,7 @@ import Distribution.Types.PackageDescription (PackageDescription) import Distribution.Types.Benchmark (Benchmark) import Distribution.Types.ForeignLib (ForeignLib) import Distribution.Types.GenericPackageDescription (GenericPackageDescription(GenericPackageDescription) ) -import Distribution.Types.Flag (Flag(MkFlag), FlagName) +import Distribution.Types.Flag (PackageFlag(MkPackageFlag), FlagName) import Distribution.Types.ConfVar (ConfVar (..)) import Distribution.Types.Library (Library) import Distribution.Types.TestSuite (TestSuite) @@ -43,7 +43,7 @@ gpdScannedVersion :: Lens' GenericPackageDescription (Maybe Version) gpdScannedVersion f s = fmap (\x -> s { T.gpdScannedVersion = x }) (f (T.gpdScannedVersion s)) {-# INLINE gpdScannedVersion #-} -genPackageFlags :: Lens' GenericPackageDescription [Flag] +genPackageFlags :: Lens' GenericPackageDescription [PackageFlag] genPackageFlags f s = fmap (\x -> s { T.genPackageFlags = x }) (f (T.genPackageFlags s)) {-# INLINE genPackageFlags #-} @@ -94,20 +94,20 @@ allCondTrees f (GenericPackageDescription p v a1 x1 x2 x3 x4 x5 x6) = -- Flag ------------------------------------------------------------------------------- -flagName :: Lens' Flag FlagName -flagName f (MkFlag x1 x2 x3 x4) = fmap (\y1 -> MkFlag y1 x2 x3 x4) (f x1) +flagName :: Lens' PackageFlag FlagName +flagName f (MkPackageFlag x1 x2 x3 x4) = fmap (\y1 -> MkPackageFlag y1 x2 x3 x4) (f x1) {-# INLINE flagName #-} -flagDescription :: Lens' Flag String -flagDescription f (MkFlag x1 x2 x3 x4) = fmap (\y1 -> MkFlag x1 y1 x3 x4) (f x2) +flagDescription :: Lens' PackageFlag String +flagDescription f (MkPackageFlag x1 x2 x3 x4) = fmap (\y1 -> MkPackageFlag x1 y1 x3 x4) (f x2) {-# INLINE flagDescription #-} -flagDefault :: Lens' Flag Bool -flagDefault f (MkFlag x1 x2 x3 x4) = fmap (\y1 -> MkFlag x1 x2 y1 x4) (f x3) +flagDefault :: Lens' PackageFlag Bool +flagDefault f (MkPackageFlag x1 x2 x3 x4) = fmap (\y1 -> MkPackageFlag x1 x2 y1 x4) (f x3) {-# INLINE flagDefault #-} -flagManual :: Lens' Flag Bool -flagManual f (MkFlag x1 x2 x3 x4) = fmap (\y1 -> MkFlag x1 x2 x3 y1) (f x4) +flagManual :: Lens' PackageFlag Bool +flagManual f (MkPackageFlag x1 x2 x3 x4) = fmap (\y1 -> MkPackageFlag x1 x2 x3 y1) (f x4) {-# INLINE flagManual #-} ------------------------------------------------------------------------------- @@ -122,9 +122,9 @@ _Arch :: Traversal' ConfVar Arch _Arch f (Arch arch) = Arch <$> f arch _Arch _ x = pure x -_Flag :: Traversal' ConfVar FlagName -_Flag f (Flag flag) = Flag <$> f flag -_Flag _ x = pure x +_PackageFlag :: Traversal' ConfVar FlagName +_PackageFlag f (PackageFlag flag) = PackageFlag <$> f flag +_PackageFlag _ x = pure x _Impl :: Traversal' ConfVar (CompilerFlavor, VersionRange) _Impl f (Impl cf vr) = uncurry Impl <$> f (cf, vr) diff --git a/Cabal/tests/Instances/TreeDiff.hs b/Cabal/tests/Instances/TreeDiff.hs index 05f49469961..36158010695 100644 --- a/Cabal/tests/Instances/TreeDiff.hs +++ b/Cabal/tests/Instances/TreeDiff.hs @@ -65,7 +65,6 @@ instance ToExpr ExeDependency where toExpr = defaultExprViaShow instance ToExpr Executable instance ToExpr ExecutableScope where toExpr = defaultExprViaShow instance ToExpr ExposedModule where toExpr = defaultExprViaShow -instance ToExpr Flag instance ToExpr FlagName where toExpr = defaultExprViaShow instance ToExpr ForeignLib instance ToExpr ForeignLibOption @@ -85,6 +84,7 @@ instance ToExpr ModuleRenaming instance ToExpr OpenModule instance ToExpr OpenUnitId instance ToExpr PackageDescription +instance ToExpr PackageFlag instance ToExpr PackageIdentifier instance ToExpr PackageName where toExpr = defaultExprViaShow instance ToExpr PkgconfigDependency where toExpr = defaultExprViaShow diff --git a/Cabal/tests/ParserTests/regressions/common-conditional.expr b/Cabal/tests/ParserTests/regressions/common-conditional.expr index a52558abc43..f6e194e31f4 100644 --- a/Cabal/tests/ParserTests/regressions/common-conditional.expr +++ b/Cabal/tests/ParserTests/regressions/common-conditional.expr @@ -5,7 +5,7 @@ GenericPackageDescription condLibrary = Just CondNode {condTreeComponents = [CondBranch - {condBranchCondition = `Var (Flag (FlagName "foo"))`, + {condBranchCondition = `Var (PackageFlag (FlagName "foo"))`, condBranchIfFalse = Nothing, condBranchIfTrue = CondNode {condTreeComponents = [CondBranch @@ -295,7 +295,7 @@ GenericPackageDescription `mkVersion []`), testName = `UnqualComponentName ""`}}}, CondBranch - {condBranchCondition = `Var (Flag (FlagName "foo"))`, + {condBranchCondition = `Var (PackageFlag (FlagName "foo"))`, condBranchIfFalse = Nothing, condBranchIfTrue = CondNode {condTreeComponents = [CondBranch @@ -586,7 +586,7 @@ GenericPackageDescription testInterface = TestSuiteExeV10 `mkVersion [1,0]` "Tests.hs", testName = `UnqualComponentName ""`}}], - genPackageFlags = [MkFlag + genPackageFlags = [MkPackageFlag {flagDefault = True, flagDescription = "", flagManual = True, diff --git a/Cabal/tests/ParserTests/regressions/libpq1.expr b/Cabal/tests/ParserTests/regressions/libpq1.expr index f51621bf120..75cb8d915dc 100644 --- a/Cabal/tests/ParserTests/regressions/libpq1.expr +++ b/Cabal/tests/ParserTests/regressions/libpq1.expr @@ -167,7 +167,7 @@ GenericPackageDescription reexportedModules = [], signatures = []}}}, CondBranch - {condBranchCondition = `Var (Flag (FlagName "use-pkg-config"))`, + {condBranchCondition = `Var (PackageFlag (FlagName "use-pkg-config"))`, condBranchIfFalse = Just CondNode {condTreeComponents = [CondBranch @@ -567,7 +567,7 @@ GenericPackageDescription signatures = []}}, condSubLibraries = [], condTestSuites = [], - genPackageFlags = [MkFlag + genPackageFlags = [MkPackageFlag {flagDefault = False, flagDescription = "", flagManual = True, diff --git a/Cabal/tests/ParserTests/regressions/libpq2.expr b/Cabal/tests/ParserTests/regressions/libpq2.expr index 21755a0d68c..1e8e8f53a69 100644 --- a/Cabal/tests/ParserTests/regressions/libpq2.expr +++ b/Cabal/tests/ParserTests/regressions/libpq2.expr @@ -167,7 +167,7 @@ GenericPackageDescription reexportedModules = [], signatures = []}}}, CondBranch - {condBranchCondition = `Var (Flag (FlagName "use-pkg-config"))`, + {condBranchCondition = `Var (PackageFlag (FlagName "use-pkg-config"))`, condBranchIfFalse = Just CondNode {condTreeComponents = [CondBranch @@ -567,7 +567,7 @@ GenericPackageDescription signatures = []}}, condSubLibraries = [], condTestSuites = [], - genPackageFlags = [MkFlag + genPackageFlags = [MkPackageFlag {flagDefault = False, flagDescription = "", flagManual = True, diff --git a/Cabal/tests/ParserTests/regressions/nothing-unicode.expr b/Cabal/tests/ParserTests/regressions/nothing-unicode.expr index 1c7e818ce81..3c0a595251c 100644 --- a/Cabal/tests/ParserTests/regressions/nothing-unicode.expr +++ b/Cabal/tests/ParserTests/regressions/nothing-unicode.expr @@ -5,7 +5,7 @@ GenericPackageDescription condLibrary = Just CondNode {condTreeComponents = [CondBranch - {condBranchCondition = `CNot (Var (Flag (FlagName "\\28961")))`, + {condBranchCondition = `CNot (Var (PackageFlag (FlagName "\\28961")))`, condBranchIfFalse = Nothing, condBranchIfTrue = CondNode {condTreeComponents = [], @@ -123,7 +123,7 @@ GenericPackageDescription signatures = []}}, condSubLibraries = [], condTestSuites = [], - genPackageFlags = [MkFlag + genPackageFlags = [MkPackageFlag {flagDefault = True, flagDescription = "\28961", flagManual = False, diff --git a/Cabal/tests/ParserTests/regressions/shake.expr b/Cabal/tests/ParserTests/regressions/shake.expr index 9ea01afab8e..5fb1a3777eb 100644 --- a/Cabal/tests/ParserTests/regressions/shake.expr +++ b/Cabal/tests/ParserTests/regressions/shake.expr @@ -67,7 +67,7 @@ GenericPackageDescription exeScope = ExecutablePublic, modulePath = ""}}}, CondBranch - {condBranchCondition = `Var (Flag (FlagName "portable"))`, + {condBranchCondition = `Var (PackageFlag (FlagName "portable"))`, condBranchIfFalse = Just CondNode {condTreeComponents = [CondBranch @@ -667,7 +667,7 @@ GenericPackageDescription condLibrary = Just CondNode {condTreeComponents = [CondBranch - {condBranchCondition = `Var (Flag (FlagName "portable"))`, + {condBranchCondition = `Var (PackageFlag (FlagName "portable"))`, condBranchIfFalse = Just CondNode {condTreeComponents = [CondBranch @@ -1395,7 +1395,7 @@ GenericPackageDescription `mkVersion []`), testName = `UnqualComponentName ""`}}}, CondBranch - {condBranchCondition = `Var (Flag (FlagName "portable"))`, + {condBranchCondition = `Var (PackageFlag (FlagName "portable"))`, condBranchIfFalse = Just CondNode {condTreeComponents = [CondBranch @@ -2046,7 +2046,7 @@ GenericPackageDescription testInterface = TestSuiteExeV10 `mkVersion [1,0]` "Test.hs", testName = `UnqualComponentName ""`}}], - genPackageFlags = [MkFlag + genPackageFlags = [MkPackageFlag {flagDefault = False, flagDescription = "Obtain FileTime using portable functions", flagManual = True, diff --git a/cabal-install/Distribution/Client/Install.hs b/cabal-install/Distribution/Client/Install.hs index 21cde7f1061..56349c9afed 100644 --- a/cabal-install/Distribution/Client/Install.hs +++ b/cabal-install/Distribution/Client/Install.hs @@ -155,7 +155,7 @@ import Distribution.Types.PackageVersionConstraint import Distribution.Types.MungedPackageId import qualified Distribution.PackageDescription as PackageDescription import Distribution.PackageDescription - ( PackageDescription, GenericPackageDescription(..), Flag(..) + ( PackageDescription, GenericPackageDescription(..), PackageFlag(..) , FlagAssignment, mkFlagAssignment, unFlagAssignment , showFlagValue, diffFlagAssignment, nullFlagAssignment ) import Distribution.PackageDescription.Configuration @@ -713,7 +713,7 @@ printPlan dryRun verbosity plan sourcePkgDb = case plan of (packageIndex sourcePkgDb) (packageName pkg) - toFlagAssignment :: [Flag] -> FlagAssignment + toFlagAssignment :: [PackageFlag] -> FlagAssignment toFlagAssignment = mkFlagAssignment . map (\ f -> (flagName f, flagDefault f)) nonDefaultFlags :: ConfiguredPackage loc -> FlagAssignment diff --git a/cabal-install/Distribution/Client/List.hs b/cabal-install/Distribution/Client/List.hs index f261546859e..6a87172bdb7 100644 --- a/cabal-install/Distribution/Client/List.hs +++ b/cabal-install/Distribution/Client/List.hs @@ -23,7 +23,7 @@ import Distribution.License (License) import qualified Distribution.InstalledPackageInfo as Installed import qualified Distribution.PackageDescription as Source import Distribution.PackageDescription - ( Flag(..), unFlagName ) + ( PackageFlag(..), unFlagName ) import Distribution.PackageDescription.Configuration ( flattenPackageDescription ) import Distribution.Pretty (pretty) @@ -295,7 +295,7 @@ data PackageDisplayInfo = PackageDisplayInfo { author :: ShortText, maintainer :: ShortText, dependencies :: [ExtDependency], - flags :: [Flag], + flags :: [PackageFlag], hasLib :: Bool, hasExe :: Bool, executables :: [UnqualComponentName], diff --git a/cabal-install/Distribution/Client/ProjectPlanning.hs b/cabal-install/Distribution/Client/ProjectPlanning.hs index 351c7d45d01..59c7eadb6d0 100644 --- a/cabal-install/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/Distribution/Client/ProjectPlanning.hs @@ -126,7 +126,7 @@ import qualified Distribution.PackageDescription as Cabal import qualified Distribution.PackageDescription as PD import qualified Distribution.PackageDescription.Configuration as PD import Distribution.Simple.PackageIndex (InstalledPackageIndex) -import Distribution.Simple.Compiler hiding (Flag) +import Distribution.Simple.Compiler import qualified Distribution.Simple.GHC as GHC --TODO: [code cleanup] eliminate import qualified Distribution.Simple.GHCJS as GHCJS --TODO: [code cleanup] eliminate import Distribution.Simple.Program diff --git a/cabal-install/Distribution/Solver/Modular/IndexConversion.hs b/cabal-install/Distribution/Solver/Modular/IndexConversion.hs index 59e2f850d6a..bc84228ce7e 100644 --- a/cabal-install/Distribution/Solver/Modular/IndexConversion.hs +++ b/cabal-install/Distribution/Solver/Modular/IndexConversion.hs @@ -9,8 +9,8 @@ import Data.Maybe (mapMaybe, fromMaybe, maybeToList) import Data.Monoid as Mon import qualified Data.Set as S +import qualified Distribution.InstalledPackageInfo as IPI import Distribution.Compiler -import Distribution.InstalledPackageInfo as IPI import Distribution.Package -- from Cabal import Distribution.Simple.BuildToolDepends -- from Cabal import Distribution.Types.ExeDependency -- from Cabal @@ -20,8 +20,8 @@ import Distribution.Types.UnqualComponentName -- from Cabal import Distribution.Types.CondTree -- from Cabal import Distribution.Types.MungedPackageId -- from Cabal import Distribution.Types.MungedPackageName -- from Cabal -import Distribution.PackageDescription as PD -- from Cabal -import Distribution.PackageDescription.Configuration as PDC +import Distribution.PackageDescription -- from Cabal +import Distribution.PackageDescription.Configuration import qualified Distribution.Simple.PackageIndex as SI import Distribution.System import Distribution.Types.ForeignLib @@ -81,14 +81,14 @@ convIPI' (ShadowPkgs sip) idx = shadow x = x -- | Extract/recover the the package ID from an installed package info, and convert it to a solver's I. -convId :: InstalledPackageInfo -> (PN, I) +convId :: IPI.InstalledPackageInfo -> (PN, I) convId ipi = (pn, I ver $ Inst $ IPI.installedUnitId ipi) where MungedPackageId mpn ver = mungedId ipi -- HACK. See Note [Index conversion with internal libraries] pn = encodeCompatPackageName mpn -- | Convert a single installed package into the solver-specific format. -convIP :: SI.InstalledPackageIndex -> InstalledPackageInfo -> (PN, I, PInfo) +convIP :: SI.InstalledPackageIndex -> IPI.InstalledPackageInfo -> (PN, I, PInfo) convIP idx ipi = case mapM (convIPId (DependencyReason pn M.empty S.empty) comp idx) (IPI.depends ipi) of Nothing -> (pn, i, PInfo [] M.empty M.empty (Just Broken)) @@ -99,7 +99,7 @@ convIP idx ipi = (pn, i) = convId ipi -- 'sourceLibName' is unreliable, but for now we only really use this for -- primary libs anyways - comp = componentNameToComponent $ CLibName $ sourceLibName ipi + comp = componentNameToComponent $ CLibName $ IPI.sourceLibName ipi -- TODO: Installed packages should also store their encapsulations! -- Note [Index conversion with internal libraries] @@ -186,7 +186,7 @@ convGPD os arch cinfo constraints strfl solveExes pn CondTree ConfVar [Dependency] a -> FlaggedDeps PN conv comp getInfo dr = convCondTree M.empty dr pkg os arch cinfo pn fds comp getInfo ipns solveExes . - PDC.addBuildableCondition getInfo + addBuildableCondition getInfo initDR = DependencyReason pn M.empty S.empty @@ -264,7 +264,7 @@ isBuildableComponent os arch cinfo constraints getInfo tree = | otherwise = Lit False where matchImpl (CompilerId cf' cv) = cf == cf' && checkVR cvr cv - simplifyCondition (Var (Flag f)) + simplifyCondition (Var (PackageFlag f)) | Just b <- L.lookup f flagAssignment = Lit b simplifyCondition (Var v) = Var v simplifyCondition (Lit b) = Lit b @@ -298,9 +298,9 @@ prefix f fds = [f (concat fds)] -- | Convert flag information. Automatic flags are now considered weak -- unless strong flags have been selected explicitly. -flagInfo :: StrongFlags -> [PD.Flag] -> FlagInfo +flagInfo :: StrongFlags -> [PackageFlag] -> FlagInfo flagInfo (StrongFlags strfl) = - M.fromList . L.map (\ (MkFlag fn _ b m) -> (fn, FInfo b (flagType m) (weak m))) + M.fromList . L.map (\ (MkPackageFlag fn _ b m) -> (fn, FInfo b (flagType m) (weak m))) where weak m = WeakOrTrivial $ not (strfl || m) flagType m = if m then Manual else Automatic @@ -334,9 +334,9 @@ convCondTree flags dr pkg os arch cinfo pn fds comp getInfo ipns solveExes@(Solv mergeSimpleDeps $ L.map (\d -> D.Simple (convLibDep dr d) comp) (mapMaybe (filterIPNs ipns) ds) -- unconditional package dependencies - ++ L.map (\e -> D.Simple (LDep dr (Ext e)) comp) (PD.allExtensions bi) -- unconditional extension dependencies - ++ L.map (\l -> D.Simple (LDep dr (Lang l)) comp) (PD.allLanguages bi) -- unconditional language dependencies - ++ L.map (\(PkgconfigDependency pkn vr) -> D.Simple (LDep dr (Pkg pkn vr)) comp) (PD.pkgconfigDepends bi) -- unconditional pkg-config dependencies + ++ L.map (\e -> D.Simple (LDep dr (Ext e)) comp) (allExtensions bi) -- unconditional extension dependencies + ++ L.map (\l -> D.Simple (LDep dr (Lang l)) comp) (allLanguages bi) -- unconditional language dependencies + ++ L.map (\(PkgconfigDependency pkn vr) -> D.Simple (LDep dr (Pkg pkn vr)) comp) (pkgconfigDepends bi) -- unconditional pkg-config dependencies ++ concatMap (convBranch flags dr pkg os arch cinfo pn fds comp getInfo ipns solveExes) branches -- build-tools dependencies -- NB: Only include these dependencies if SolveExecutables @@ -472,7 +472,7 @@ convBranch flags dr pkg os arch cinfo pn fds comp getInfo ipns solveExes (CondBr go (CNot c) t f = go c f t go (CAnd c d) t f = go c (go d t f) f go (COr c d) t f = go c t (go d t f) - go (Var (Flag fn)) t f = \flags' -> + go (Var (PackageFlag fn)) t f = \flags' -> case M.lookup fn flags' of Just True -> t flags' Just False -> f flags' @@ -549,4 +549,4 @@ convExeDep dr (ExeDependency pn exe vr) = LDep dr $ Dep (PkgComponent pn (Expose convSetupBuildInfo :: PN -> SetupBuildInfo -> FlaggedDeps PN convSetupBuildInfo pn nfo = L.map (\d -> D.Simple (convLibDep (DependencyReason pn M.empty S.empty) d) ComponentSetup) - (PD.setupDepends nfo) + (setupDepends nfo) diff --git a/cabal-install/solver-dsl/UnitTests/Distribution/Solver/Modular/DSL.hs b/cabal-install/solver-dsl/UnitTests/Distribution/Solver/Modular/DSL.hs index 9fb4fb7c195..1697793ae28 100644 --- a/cabal-install/solver-dsl/UnitTests/Distribution/Solver/Modular/DSL.hs +++ b/cabal-install/solver-dsl/UnitTests/Distribution/Solver/Modular/DSL.hs @@ -332,15 +332,15 @@ exAvSrcPkg :: ExampleAvailable -> UnresolvedSourcePackage exAvSrcPkg ex = let pkgId = exAvPkgId ex - flags :: [C.Flag] + flags :: [C.PackageFlag] flags = - let declaredFlags :: Map ExampleFlagName C.Flag + let declaredFlags :: Map ExampleFlagName C.PackageFlag declaredFlags = Map.fromListWith (\f1 f2 -> error $ "duplicate flag declarations: " ++ show [f1, f2]) [(exFlagName flag, mkFlag flag) | flag <- exAvFlags ex] - usedFlags :: Map ExampleFlagName C.Flag + usedFlags :: Map ExampleFlagName C.PackageFlag usedFlags = Map.fromList [(fn, mkDefaultFlag fn) | fn <- names] where names = concatMap extractFlags $ CD.flatDeps (exAvDeps ex) @@ -557,7 +557,7 @@ exAvSrcPkg ex = mkFlagged :: (ExampleFlagName, Dependencies, Dependencies) -> DependencyComponent C.BuildInfo mkFlagged (f, a, b) = - C.CondBranch (C.Var (C.Flag (C.mkFlagName f))) + C.CondBranch (C.Var (C.PackageFlag (C.mkFlagName f))) (mkBuildInfoTree a) (Just (mkBuildInfoTree b)) @@ -604,8 +604,8 @@ mkVersionRange v1 v2 = C.intersectVersionRanges (C.orLaterVersion $ mkSimpleVersion v1) (C.earlierVersion $ mkSimpleVersion v2) -mkFlag :: ExFlag -> C.Flag -mkFlag flag = C.MkFlag { +mkFlag :: ExFlag -> C.PackageFlag +mkFlag flag = C.MkPackageFlag { C.flagName = C.mkFlagName $ exFlagName flag , C.flagDescription = "" , C.flagDefault = exFlagDefault flag @@ -615,8 +615,8 @@ mkFlag flag = C.MkFlag { Automatic -> False } -mkDefaultFlag :: ExampleFlagName -> C.Flag -mkDefaultFlag flag = C.MkFlag { +mkDefaultFlag :: ExampleFlagName -> C.PackageFlag +mkDefaultFlag flag = C.MkPackageFlag { C.flagName = C.mkFlagName flag , C.flagDescription = "" , C.flagDefault = True diff --git a/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs b/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs index ea69806a751..f54f4e23886 100644 --- a/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs +++ b/cabal-install/tests/UnitTests/Distribution/Client/ProjectConfig.hs @@ -18,7 +18,7 @@ import Distribution.Deprecated.Text as Text import qualified Distribution.Deprecated.ReadP as Parse import Distribution.Package -import Distribution.PackageDescription hiding (Flag, SourceRepo) +import Distribution.PackageDescription import Distribution.Compiler import Distribution.Version import Distribution.Simple.Compiler diff --git a/changelog.d/issue-6710 b/changelog.d/issue-6710 new file mode 100644 index 00000000000..28c3932bcc9 --- /dev/null +++ b/changelog.d/issue-6710 @@ -0,0 +1,2 @@ +synopsis: Rename Flag to CompilerFlag and PackageFlag +issues: #6710