diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning.hs b/cabal-install/src/Distribution/Client/ProjectPlanning.hs index 5cb04eaf56b..ef68cc81d9c 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning.hs @@ -163,6 +163,7 @@ import Distribution.Types.GivenComponent ( GivenComponent (GivenComponent) ) import Distribution.Types.LibraryName +import qualified Distribution.Types.LocalBuildConfig as LBC import Distribution.Types.PackageVersionConstraint import Distribution.Types.PkgconfigDependency import Distribution.Types.UnqualComponentName @@ -2224,14 +2225,28 @@ elaborateInstallPlan elabPkgDescriptionOverride = descOverride - elabVanillaLib = perPkgOptionFlag pkgid True packageConfigVanillaLib -- TODO: [required feature]: also needs to be handled recursively - elabSharedLib = pkgid `Set.member` pkgsUseSharedLibrary - elabStaticLib = perPkgOptionFlag pkgid False packageConfigStaticLib - elabDynExe = perPkgOptionFlag pkgid False packageConfigDynExe - elabFullyStaticExe = perPkgOptionFlag pkgid False packageConfigFullyStaticExe - elabGHCiLib = perPkgOptionFlag pkgid False packageConfigGHCiLib -- TODO: [required feature] needs to default to enabled on windows still - elabProfExe = perPkgOptionFlag pkgid False packageConfigProf - elabProfLib = pkgid `Set.member` pkgsUseProfilingLibrary + elabBuildOptions = + LBC.BuildOptions + { withVanillaLib = perPkgOptionFlag pkgid True packageConfigVanillaLib -- TODO: [required feature]: also needs to be handled recursively + , withSharedLib = pkgid `Set.member` pkgsUseSharedLibrary + , withStaticLib = perPkgOptionFlag pkgid False packageConfigStaticLib + , withDynExe = perPkgOptionFlag pkgid False packageConfigDynExe + , withFullyStaticExe = perPkgOptionFlag pkgid False packageConfigFullyStaticExe + , withGHCiLib = perPkgOptionFlag pkgid False packageConfigGHCiLib -- TODO: [required feature] needs to default to enabled on windows still + , withProfExe = perPkgOptionFlag pkgid False packageConfigProf + , withProfLib = pkgid `Set.member` pkgsUseProfilingLibrary + , exeCoverage = perPkgOptionFlag pkgid False packageConfigCoverage + , libCoverage = perPkgOptionFlag pkgid False packageConfigCoverage + , withOptimization = perPkgOptionFlag pkgid NormalOptimisation packageConfigOptimization + , splitObjs = perPkgOptionFlag pkgid False packageConfigSplitObjs + , splitSections = perPkgOptionFlag pkgid False packageConfigSplitSections + , stripLibs = perPkgOptionFlag pkgid False packageConfigStripLibs + , stripExes = perPkgOptionFlag pkgid False packageConfigStripExes + , withDebugInfo = perPkgOptionFlag pkgid NoDebugInfo packageConfigDebugInfo + , relocatable = perPkgOptionFlag pkgid False packageConfigRelocatable + , withProfLibDetail = elabProfExeDetail + , withProfExeDetail = elabProfLibDetail + } ( elabProfExeDetail , elabProfLibDetail @@ -2241,14 +2256,7 @@ elaborateInstallPlan ProfDetailDefault packageConfigProfDetail packageConfigProfLibDetail - elabCoverage = perPkgOptionFlag pkgid False packageConfigCoverage - - elabOptimization = perPkgOptionFlag pkgid NormalOptimisation packageConfigOptimization - elabSplitObjs = perPkgOptionFlag pkgid False packageConfigSplitObjs - elabSplitSections = perPkgOptionFlag pkgid False packageConfigSplitSections - elabStripLibs = perPkgOptionFlag pkgid False packageConfigStripLibs - elabStripExes = perPkgOptionFlag pkgid False packageConfigStripExes - elabDebugInfo = perPkgOptionFlag pkgid NoDebugInfo packageConfigDebugInfo + elabDumpBuildInfo = perPkgOptionFlag pkgid NoDumpBuildInfo packageConfigDumpBuildInfo -- Combine the configured compiler prog settings with the user-supplied @@ -4144,31 +4152,34 @@ setupHsConfigureFlags configHcFlavor = toFlag (compilerFlavor pkgConfigCompiler) configHcPath = mempty -- we use configProgramPaths instead configHcPkg = mempty -- we use configProgramPaths instead - configVanillaLib = toFlag elabVanillaLib - configSharedLib = toFlag elabSharedLib - configStaticLib = toFlag elabStaticLib + configVanillaLib = toFlag $ LBC.withVanillaLib elabBuildOptions + configSharedLib = toFlag $ LBC.withSharedLib elabBuildOptions + configStaticLib = toFlag $ LBC.withStaticLib elabBuildOptions - configDynExe = toFlag elabDynExe - configFullyStaticExe = toFlag elabFullyStaticExe - configGHCiLib = toFlag elabGHCiLib - configProfExe = mempty - configProfLib = toFlag elabProfLib - configProf = toFlag elabProfExe + configDynExe = toFlag $ LBC.withDynExe elabBuildOptions + configFullyStaticExe = toFlag $ LBC.withFullyStaticExe elabBuildOptions + configGHCiLib = toFlag $ LBC.withGHCiLib elabBuildOptions + configProfExe = toFlag $ LBC.withProfExe elabBuildOptions + configProfLib = toFlag $ LBC.withProfLib elabBuildOptions + configProf = toFlag $ LBC.withProfExe elabBuildOptions -- configProfDetail is for exe+lib, but overridden by configProfLibDetail -- so we specify both so we can specify independently - configProfDetail = toFlag elabProfExeDetail - configProfLibDetail = toFlag elabProfLibDetail + configProfDetail = toFlag $ LBC.withProfExeDetail elabBuildOptions + configProfLibDetail = toFlag $ LBC.withProfLibDetail elabBuildOptions - configCoverage = toFlag elabCoverage + configCoverage = toFlag $ LBC.exeCoverage elabBuildOptions configLibCoverage = mempty - configOptimization = toFlag elabOptimization - configSplitSections = toFlag elabSplitSections - configSplitObjs = toFlag elabSplitObjs - configStripExes = toFlag elabStripExes - configStripLibs = toFlag elabStripLibs - configDebugInfo = toFlag elabDebugInfo + configRelocatable = toFlag $ LBC.relocatable elabBuildOptions + -- TODO: [research required] ??? + + configOptimization = toFlag $ LBC.withOptimization elabBuildOptions + configSplitSections = toFlag $ LBC.splitSections elabBuildOptions + configSplitObjs = toFlag $ LBC.splitObjs elabBuildOptions + configStripExes = toFlag $ LBC.stripExes elabBuildOptions + configStripLibs = toFlag $ LBC.stripLibs elabBuildOptions + configDebugInfo = toFlag $ LBC.withDebugInfo elabBuildOptions configDumpBuildInfo = toFlag elabDumpBuildInfo configConfigurationsFlags = elabFlagAssignment @@ -4224,7 +4235,6 @@ setupHsConfigureFlags configExactConfiguration = toFlag True configFlagError = mempty -- TODO: [research required] appears not to be implemented - configRelocatable = mempty -- TODO: [research required] ??? configScratchDir = mempty -- never use configUserInstall = mempty -- don't rely on defaults configPrograms_ = mempty -- never use, shouldn't exist @@ -4556,22 +4566,22 @@ packageHashConfigInputs shared@ElaboratedSharedConfig{..} pkg = , pkgHashPlatform = pkgConfigPlatform , pkgHashFlagAssignment = elabFlagAssignment , pkgHashConfigureScriptArgs = elabConfigureScriptArgs - , pkgHashVanillaLib = elabVanillaLib - , pkgHashSharedLib = elabSharedLib - , pkgHashDynExe = elabDynExe - , pkgHashFullyStaticExe = elabFullyStaticExe - , pkgHashGHCiLib = elabGHCiLib - , pkgHashProfLib = elabProfLib - , pkgHashProfExe = elabProfExe - , pkgHashProfLibDetail = elabProfLibDetail - , pkgHashProfExeDetail = elabProfExeDetail - , pkgHashCoverage = elabCoverage - , pkgHashOptimization = elabOptimization - , pkgHashSplitSections = elabSplitSections - , pkgHashSplitObjs = elabSplitObjs - , pkgHashStripLibs = elabStripLibs - , pkgHashStripExes = elabStripExes - , pkgHashDebugInfo = elabDebugInfo + , pkgHashVanillaLib = withVanillaLib + , pkgHashSharedLib = withSharedLib + , pkgHashDynExe = withDynExe + , pkgHashFullyStaticExe = withFullyStaticExe + , pkgHashGHCiLib = withGHCiLib + , pkgHashProfLib = withProfLib + , pkgHashProfExe = withProfExe + , pkgHashProfLibDetail = withProfLibDetail + , pkgHashProfExeDetail = withProfExeDetail + , pkgHashCoverage = exeCoverage + , pkgHashOptimization = withOptimization + , pkgHashSplitSections = splitSections + , pkgHashSplitObjs = splitObjs + , pkgHashStripLibs = stripLibs + , pkgHashStripExes = stripExes + , pkgHashDebugInfo = withDebugInfo , pkgHashProgramArgs = elabProgramArgs , pkgHashExtraLibDirs = elabExtraLibDirs , pkgHashExtraLibDirsStatic = elabExtraLibDirsStatic @@ -4600,6 +4610,7 @@ packageHashConfigInputs shared@ElaboratedSharedConfig{..} pkg = } where ElaboratedConfiguredPackage{..} = normaliseConfiguredPackage shared pkg + LBC.BuildOptions{..} = elabBuildOptions -- | Given the 'InstalledPackageIndex' for a nix-style package store, and an -- 'ElaboratedInstallPlan', replace configured source packages by installed diff --git a/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs b/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs index 28af81774eb..96de8adea45 100644 --- a/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs +++ b/cabal-install/src/Distribution/Client/ProjectPlanning/Types.hs @@ -3,6 +3,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE TypeFamilies #-} -- | Types used while planning how to build everything in a project. @@ -103,6 +104,7 @@ import Distribution.Simple.Setup ) import Distribution.System import Distribution.Types.ComponentRequestedSpec +import qualified Distribution.Types.LocalBuildConfig as LBC import Distribution.Types.PackageDescription (PackageDescription (..)) import Distribution.Types.PkgconfigVersion import Distribution.Verbosity (normal) @@ -264,23 +266,7 @@ data ElaboratedConfiguredPackage = ElaboratedConfiguredPackage , elabInplaceRegisterPackageDBStack :: PackageDBStack , elabPkgDescriptionOverride :: Maybe CabalFileText , -- TODO: make per-component variants of these flags - elabVanillaLib :: Bool - , elabSharedLib :: Bool - , elabStaticLib :: Bool - , elabDynExe :: Bool - , elabFullyStaticExe :: Bool - , elabGHCiLib :: Bool - , elabProfLib :: Bool - , elabProfExe :: Bool - , elabProfLibDetail :: ProfDetailLevel - , elabProfExeDetail :: ProfDetailLevel - , elabCoverage :: Bool - , elabOptimization :: OptimisationLevel - , elabSplitObjs :: Bool - , elabSplitSections :: Bool - , elabStripLibs :: Bool - , elabStripExes :: Bool - , elabDebugInfo :: DebugInfoLevel + elabBuildOptions :: LBC.BuildOptions , elabDumpBuildInfo :: DumpBuildInfo , elabProgramPaths :: Map String FilePath , elabProgramArgs :: Map String [String] @@ -542,7 +528,7 @@ elabDistDirParams shared elab = ElabPackage _ -> Nothing , distParamCompilerId = compilerId (pkgConfigCompiler shared) , distParamPlatform = pkgConfigPlatform shared - , distParamOptimization = elabOptimization elab + , distParamOptimization = LBC.withOptimization $ elabBuildOptions elab } -- | The full set of dependencies which dictate what order we diff --git a/cabal-install/src/Distribution/Client/Run.hs b/cabal-install/src/Distribution/Client/Run.hs index 851d5705ca3..6784e3bfe18 100644 --- a/cabal-install/src/Distribution/Client/Run.hs +++ b/cabal-install/src/Distribution/Client/Run.hs @@ -32,8 +32,8 @@ import Distribution.Simple.Compiler (CompilerFlavor (..), compilerFlavor) import Distribution.Simple.LocalBuildInfo ( ComponentName (..) , LocalBuildInfo (..) - , depLibraryPaths , buildDir + , depLibraryPaths ) import Distribution.Simple.Utils ( addLibraryPath