on master help sign in
Add library profiling support #3973
335fa91Chris Done
Stackage/BuildConstraints.hs+11−6
@@ -88,12 +88,13 @@ data BuildConstraints = BuildConstraints
88 }
88 }
89
89
90data PackageConstraints = PackageConstraints
90data PackageConstraints = PackageConstraints
91− { pcVersionRange :: VersionRange
91+ { pcVersionRange :: VersionRange
92− , pcMaintainer :: Maybe Maintainer
92+ , pcMaintainer :: Maybe Maintainer
93− , pcTests :: TestState
93+ , pcTests :: TestState
94− , pcHaddocks :: TestState
94+ , pcHaddocks :: TestState
95− , pcBuildBenchmarks :: Bool
95+ , pcBuildBenchmarks :: Bool
96− , pcFlagOverrides :: Map FlagName Bool
96+ , pcFlagOverrides :: Map FlagName Bool
97+ , pcEnableLibProfile :: Bool
97 }
98 }
98 deriving (Show, Eq)
99 deriving (Show, Eq)
99instance ToJSON PackageConstraints where
100instance ToJSON PackageConstraints where
@@ -115,6 +116,7 @@ instance FromJSON PackageConstraints where
115 pcBuildBenchmarks <- o .: "build-benchmarks"
116 pcBuildBenchmarks <- o .: "build-benchmarks"
116 pcFlagOverrides <- Map.mapKeysWith const mkFlagName <$> o .: "flags"
117 pcFlagOverrides <- Map.mapKeysWith const mkFlagName <$> o .: "flags"
117 pcMaintainer <- o .:? "maintainer"
118 pcMaintainer <- o .:? "maintainer"
119+ pcEnableLibProfile <- fmap (fromMaybe False) (o .:? "library-profiling")
118 return PackageConstraints {..}
120 return PackageConstraints {..}
119
121
120-- | The proposed plan from the requirements provided by contributors.
122-- | The proposed plan from the requirements provided by contributors.
@@ -152,6 +154,7 @@ data ConstraintFile = ConstraintFile
152 , cfSkippedBenchmarks :: Set PackageName
154 , cfSkippedBenchmarks :: Set PackageName
153 , cfPackages :: Map Maintainer (Vector Dependency)
155 , cfPackages :: Map Maintainer (Vector Dependency)
154 , cfGithubUsers :: Map Text (Set Text)
156 , cfGithubUsers :: Map Text (Set Text)
157+ , cfSkippedLibProfiling :: Set PackageName
155 }
158 }
156
159
157instance FromJSON ConstraintFile where
160instance FromJSON ConstraintFile where
@@ -162,6 +165,7 @@ instance FromJSON ConstraintFile where
162 cfExpectedTestFailures <- getPackages o "expected-test-failures"
165 cfExpectedTestFailures <- getPackages o "expected-test-failures"
163 cfExpectedHaddockFailures <- getPackages o "expected-haddock-failures"
166 cfExpectedHaddockFailures <- getPackages o "expected-haddock-failures"
164 cfSkippedBenchmarks <- getPackages o "skipped-benchmarks"
167 cfSkippedBenchmarks <- getPackages o "skipped-benchmarks"
168+ cfSkippedLibProfiling <- getPackages o "skipped-profiling"
165 cfPackages <- o .: "packages"
169 cfPackages <- o .: "packages"
166 >>= mapM (mapM toDep)
170 >>= mapM (mapM toDep)
167 . Map.mapKeysWith const Maintainer
171 . Map.mapKeysWith const Maintainer
@@ -196,6 +200,7 @@ toBC ConstraintFile {..} = do
196 mpair = lookup name revmap
200 mpair = lookup name revmap
197 pcMaintainer = fmap fst mpair
201 pcMaintainer = fmap fst mpair
198 pcVersionRange = maybe anyVersion snd mpair
202 pcVersionRange = maybe anyVersion snd mpair
203+ pcEnableLibProfile = not (name `member` cfSkippedLibProfiling)
199 pcTests
204 pcTests
200 | name `member` cfSkippedTests = Don'tBuild
205 | name `member` cfSkippedTests = Don'tBuild
201 | name `member` cfExpectedTestFailures = ExpectFailure
206 | name `member` cfExpectedTestFailures = ExpectFailure
Stackage/CompleteBuild.hs+4−2
@@ -27,8 +27,9 @@ import System.IO (BufferMode (LineBuffering), hSetBuffering)
27
27
28-- | Flags passed in from the command line.
28-- | Flags passed in from the command line.
29data BuildFlags = BuildFlags
29data BuildFlags = BuildFlags
30− { bfEnableTests :: !Bool
30+ { bfEnableTests :: !Bool
31− , bfDoUpload :: !Bool
31+ , bfDoUpload :: !Bool
32+ , bfEnableLibProfile :: !Bool
32 } deriving (Show)
33 } deriving (Show)
33
34
34data BuildType = Nightly | LTS BumpType
35data BuildType = Nightly | LTS BumpType
@@ -180,6 +181,7 @@ completeBuild buildType buildFlags = withManager tlsManagerSettings $ \man -> do
180 , pbJobs = 8
181 , pbJobs = 8
181 , pbGlobalInstall = False
182 , pbGlobalInstall = False
182 , pbEnableTests = bfEnableTests buildFlags
183 , pbEnableTests = bfEnableTests buildFlags
184+ , pbEnableLibProfiling = bfEnableLibProfile buildFlags
183 }
185 }
184 performBuild pb >>= mapM_ putStrLn
186 performBuild pb >>= mapM_ putStrLn
185
187
Stackage/PerformBuild.hs+3
@@ -62,6 +62,7 @@ data PerformBuild = PerformBuild
62 , pbGlobalInstall :: Bool
62 , pbGlobalInstall :: Bool
63 -- ^ Register packages in the global database
63 -- ^ Register packages in the global database
64 , pbEnableTests :: Bool
64 , pbEnableTests :: Bool
65+ , pbEnableLibProfiling :: Bool
65 }
66 }
66
67
67data PackageInfo = PackageInfo
68data PackageInfo = PackageInfo
@@ -299,6 +300,8 @@ singleBuild pb@PerformBuild {..} SingleBuild {..} =
299 tell' $ "--datadir=" ++ fpToText (pbDataDir pb)
300 tell' $ "--datadir=" ++ fpToText (pbDataDir pb)
300 tell' $ "--docdir=" ++ fpToText (pbDocDir pb)
301 tell' $ "--docdir=" ++ fpToText (pbDocDir pb)
301 tell' $ "--flags=" ++ flags
302 tell' $ "--flags=" ++ flags
303+ when (pbEnableLibProfiling && pcEnableLibProfile) $
304+ tell' "--enable-library-profiling"
302 where
305 where
303 tell' x = tell (x:)
306 tell' x = tell (x:)
304
307
Stackage/UpdateBuildPlan.hs+1
@@ -33,6 +33,7 @@ updateBuildConstraints BuildPlan {..} =
33 , pcHaddocks = maybe ExpectSuccess pcHaddocks moldPC
33 , pcHaddocks = maybe ExpectSuccess pcHaddocks moldPC
34 , pcBuildBenchmarks = maybe True pcBuildBenchmarks moldPC
34 , pcBuildBenchmarks = maybe True pcBuildBenchmarks moldPC
35 , pcFlagOverrides = maybe mempty pcFlagOverrides moldPC
35 , pcFlagOverrides = maybe mempty pcFlagOverrides moldPC
36+ , pcEnableLibProfile = maybe False pcEnableLibProfile moldPC
36 }
37 }
37 where
38 where
38 moldBP = lookup name bpPackages
39 moldBP = lookup name bpPackages
app/stackage.hs+4−1
@@ -66,4 +66,7 @@ main =
66 not
66 not
67 (switch
67 (switch
68 (long "skip-upload" <>
68 (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")