on master help sign in
Add library profiling support #3973

* Implements --enable-library-profiling in the executable * Adds pbEnableLibProfiling * Adds ability to skip profiling on some packages, e.g. skipped-profiling: - transformers-compat

commit335fa913850d4139d1c4c467311890c3925f3574 authorChris Done <chrisdone@gmail.com> dateWed 31 Dec 2014, 22:14 (12 years ago) parent1f28245
5 files changed+23−9
Stackage/BuildConstraints.hs+11−6 Stackage/CompleteBuild.hs+4−2 Stackage/PerformBuild.hs+3 Stackage/UpdateBuildPlan.hs+1 app/stackage.hs+4−1
Stackage/BuildConstraints.hs+11−6
@@ -88,12 +88,13 @@ data BuildConstraints = BuildConstraints
8888 }
8989
9090data PackageConstraints = PackageConstraints
91− { pcVersionRange :: VersionRange
92− , pcMaintainer :: Maybe Maintainer
93− , pcTests :: TestState
94− , pcHaddocks :: TestState
95− , pcBuildBenchmarks :: Bool
96− , pcFlagOverrides :: Map FlagName Bool
91+ { pcVersionRange :: VersionRange
92+ , pcMaintainer :: Maybe Maintainer
93+ , pcTests :: TestState
94+ , pcHaddocks :: TestState
95+ , pcBuildBenchmarks :: Bool
96+ , pcFlagOverrides :: Map FlagName Bool
97+ , pcEnableLibProfile :: Bool
9798 }
9899 deriving (Show, Eq)
99100instance ToJSON PackageConstraints where
@@ -115,6 +116,7 @@ instance FromJSON PackageConstraints where
115116 pcBuildBenchmarks <- o .: "build-benchmarks"
116117 pcFlagOverrides <- Map.mapKeysWith const mkFlagName <$> o .: "flags"
117118 pcMaintainer <- o .:? "maintainer"
119+ pcEnableLibProfile <- fmap (fromMaybe False) (o .:? "library-profiling")
118120 return PackageConstraints {..}
119121
120122-- | The proposed plan from the requirements provided by contributors.
@@ -152,6 +154,7 @@ data ConstraintFile = ConstraintFile
152154 , cfSkippedBenchmarks :: Set PackageName
153155 , cfPackages :: Map Maintainer (Vector Dependency)
154156 , cfGithubUsers :: Map Text (Set Text)
157+ , cfSkippedLibProfiling :: Set PackageName
155158 }
156159
157160instance FromJSON ConstraintFile where
@@ -162,6 +165,7 @@ instance FromJSON ConstraintFile where
162165 cfExpectedTestFailures <- getPackages o "expected-test-failures"
163166 cfExpectedHaddockFailures <- getPackages o "expected-haddock-failures"
164167 cfSkippedBenchmarks <- getPackages o "skipped-benchmarks"
168+ cfSkippedLibProfiling <- getPackages o "skipped-profiling"
165169 cfPackages <- o .: "packages"
166170 >>= mapM (mapM toDep)
167171 . Map.mapKeysWith const Maintainer
@@ -196,6 +200,7 @@ toBC ConstraintFile {..} = do
196200 mpair = lookup name revmap
197201 pcMaintainer = fmap fst mpair
198202 pcVersionRange = maybe anyVersion snd mpair
203+ pcEnableLibProfile = not (name `member` cfSkippedLibProfiling)
199204 pcTests
200205 | name `member` cfSkippedTests = Don'tBuild
201206 | name `member` cfExpectedTestFailures = ExpectFailure
Stackage/CompleteBuild.hs+4−2
@@ -27,8 +27,9 @@ import System.IO (BufferMode (LineBuffering), hSetBuffering)
2727
2828-- | Flags passed in from the command line.
2929data BuildFlags = BuildFlags
30− { bfEnableTests :: !Bool
31− , bfDoUpload :: !Bool
30+ { bfEnableTests :: !Bool
31+ , bfDoUpload :: !Bool
32+ , bfEnableLibProfile :: !Bool
3233 } deriving (Show)
3334
3435data BuildType = Nightly | LTS BumpType
@@ -180,6 +181,7 @@ completeBuild buildType buildFlags = withManager tlsManagerSettings $ \man -> do
180181 , pbJobs = 8
181182 , pbGlobalInstall = False
182183 , pbEnableTests = bfEnableTests buildFlags
184+ , pbEnableLibProfiling = bfEnableLibProfile buildFlags
183185 }
184186 performBuild pb >>= mapM_ putStrLn
185187
Stackage/PerformBuild.hs+3
@@ -62,6 +62,7 @@ data PerformBuild = PerformBuild
6262 , pbGlobalInstall :: Bool
6363 -- ^ Register packages in the global database
6464 , pbEnableTests :: Bool
65+ , pbEnableLibProfiling :: Bool
6566 }
6667
6768data PackageInfo = PackageInfo
@@ -299,6 +300,8 @@ singleBuild pb@PerformBuild {..} SingleBuild {..} =
299300 tell' $ "--datadir=" ++ fpToText (pbDataDir pb)
300301 tell' $ "--docdir=" ++ fpToText (pbDocDir pb)
301302 tell' $ "--flags=" ++ flags
303+ when (pbEnableLibProfiling && pcEnableLibProfile) $
304+ tell' "--enable-library-profiling"
302305 where
303306 tell' x = tell (x:)
304307
Stackage/UpdateBuildPlan.hs+1
@@ -33,6 +33,7 @@ updateBuildConstraints BuildPlan {..} =
3333 , pcHaddocks = maybe ExpectSuccess pcHaddocks moldPC
3434 , pcBuildBenchmarks = maybe True pcBuildBenchmarks moldPC
3535 , pcFlagOverrides = maybe mempty pcFlagOverrides moldPC
36+ , pcEnableLibProfile = maybe False pcEnableLibProfile moldPC
3637 }
3738 where
3839 moldBP = lookup name bpPackages
app/stackage.hs+4−1
@@ -66,4 +66,7 @@ main =
6666 not
6767 (switch
6868 (long "skip-upload" <>
69− help "Skip uploading bundle, docs, etc."))
69+ help "Skip uploading bundle, docs, etc.")) <*>
70+ switch
71+ (long "enable-library-profiling" <>
72+ help "Enable profiling when building")