Skip to content

Commit

Permalink
Prof_dyn
Browse files Browse the repository at this point in the history
  • Loading branch information
mpickering committed Apr 18, 2024
1 parent b216b99 commit 70b5f74
Show file tree
Hide file tree
Showing 68 changed files with 737 additions and 104 deletions.
13 changes: 13 additions & 0 deletions Cabal-syntax/src/Distribution/PackageDescription/FieldGrammar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ buildInfoFieldGrammar =
<*> optionsFieldGrammar
<*> profOptionsFieldGrammar
<*> sharedOptionsFieldGrammar
<*> profSharedOptionsFieldGrammar
<*> pure mempty -- static-options ???
<*> prefixedFields "x-" L.customFieldsBI
<*> monoidalFieldAla "build-depends" formatDependencyList L.targetBuildDepends
Expand Down Expand Up @@ -738,6 +739,18 @@ sharedOptionsFieldGrammar =
extract :: CompilerFlavor -> ALens' BuildInfo [String]
extract flavor = L.sharedOptions . lookupLens flavor

profSharedOptionsFieldGrammar
:: (FieldGrammar c g, Applicative (g BuildInfo), c (List NoCommaFSep Token' String))
=> g BuildInfo (PerCompilerFlavor [String])
profSharedOptionsFieldGrammar =
PerCompilerFlavor
<$> monoidalFieldAla "ghc-prof-shared-options" (alaList' NoCommaFSep Token') (extract GHC)
<*> monoidalFieldAla "ghcjs-prof-shared-options" (alaList' NoCommaFSep Token') (extract GHCJS)
where
extract :: CompilerFlavor -> ALens' BuildInfo [String]
extract flavor = L.sharedOptions . lookupLens flavor


lookupLens :: (Functor f, Monoid v) => CompilerFlavor -> LensLike' f (PerCompilerFlavor v) v
lookupLens k f p@(PerCompilerFlavor ghc ghcjs)
| k == GHC = (\n -> PerCompilerFlavor n ghcjs) <$> f ghc
Expand Down
7 changes: 7 additions & 0 deletions Cabal-syntax/src/Distribution/Types/BuildInfo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Distribution.Types.BuildInfo
, hcOptions
, hcProfOptions
, hcSharedOptions
, hcProfSharedOptions
, hcStaticOptions
) where

Expand Down Expand Up @@ -133,6 +134,7 @@ data BuildInfo = BuildInfo
, options :: PerCompilerFlavor [String]
, profOptions :: PerCompilerFlavor [String]
, sharedOptions :: PerCompilerFlavor [String]
, profSharedOptions :: PerCompilerFlavor [String]
, staticOptions :: PerCompilerFlavor [String]
, customFieldsBI :: [(String, String)]
-- ^ Custom fields starting
Expand Down Expand Up @@ -193,6 +195,7 @@ instance Monoid BuildInfo where
, options = mempty
, profOptions = mempty
, sharedOptions = mempty
, profSharedOptions = mempty
, staticOptions = mempty
, customFieldsBI = []
, targetBuildDepends = []
Expand Down Expand Up @@ -245,6 +248,7 @@ instance Semigroup BuildInfo where
, options = combine options
, profOptions = combine profOptions
, sharedOptions = combine sharedOptions
, profSharedOptions = combine profSharedOptions
, staticOptions = combine staticOptions
, customFieldsBI = combine customFieldsBI
, targetBuildDepends = combineNub targetBuildDepends
Expand Down Expand Up @@ -295,6 +299,9 @@ hcProfOptions = lookupHcOptions profOptions
hcSharedOptions :: CompilerFlavor -> BuildInfo -> [String]
hcSharedOptions = lookupHcOptions sharedOptions

hcProfSharedOptions :: CompilerFlavor -> BuildInfo -> [String]
hcProfSharedOptions = lookupHcOptions profSharedOptions

hcStaticOptions :: CompilerFlavor -> BuildInfo -> [String]
hcStaticOptions = lookupHcOptions staticOptions

Expand Down
6 changes: 6 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/Octree-0.5.expr
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -238,6 +240,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -339,6 +343,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
2 changes: 2 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/anynone.expr
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
2 changes: 2 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/big-version.expr
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
16 changes: 16 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/common-conditional.expr
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -187,6 +189,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -278,6 +282,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -356,6 +362,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -432,6 +440,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -501,6 +511,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -593,6 +605,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -670,6 +684,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
4 changes: 4 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/common.expr
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -186,6 +188,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
16 changes: 16 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/common2.expr
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -205,6 +207,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -285,6 +289,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -386,6 +392,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -462,6 +470,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -562,6 +572,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -639,6 +651,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -716,6 +730,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
4 changes: 4 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/common3.expr
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -186,6 +188,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
4 changes: 4 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/elif.expr
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -172,6 +174,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
10 changes: 10 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/elif2.expr
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -172,6 +174,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -245,6 +249,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -312,6 +318,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down Expand Up @@ -385,6 +393,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
2 changes: 2 additions & 0 deletions Cabal-tests/tests/ParserTests/regressions/encoding-0.8.expr
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ GenericPackageDescription {
[],
sharedOptions =
PerCompilerFlavor [] [],
profSharedOptions =
PerCompilerFlavor [] [],
staticOptions =
PerCompilerFlavor [] [],
customFieldsBI = [],
Expand Down
Loading

0 comments on commit 70b5f74

Please sign in to comment.