Skip to content
This repository has been archived by the owner on Feb 3, 2020. It is now read-only.

Commit

Permalink
Add support for "hide" yesodweb/wai#579
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Dec 11, 2016
1 parent f0ae3bf commit 9a2d0bf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.14.5

* Add support for the `hide` field [yesodweb/wai#579](https://github.com/yesodweb/wai/issues/579)

## 0.14.4.1

* A few missing fixes
Expand Down
5 changes: 5 additions & 0 deletions Stackage/BuildConstraints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Control.Monad.Writer.Strict (execWriter, tell)
import Data.Aeson
import Data.Aeson.Internal ((<?>), JSONPathElement (Key))
import qualified Data.Map as Map
import qualified Data.Set as Set
import Data.Yaml (decodeEither', decodeFileEither)
import Distribution.Package (Dependency (..))
import qualified Distribution.System
Expand Down Expand Up @@ -125,6 +126,8 @@ data ConstraintFile = ConstraintFile
, cfGhcMajorVersion :: Maybe (Int, Int)
, cfTreatAsNonCore :: Set PackageName
, cfTellMeWhenItsReleased :: Map PackageName Version
, cfHide :: Set PackageName
-- ^ Packages which should be hidden after registering
}

instance FromJSON ConstraintFile where
Expand All @@ -148,6 +151,7 @@ instance FromJSON ConstraintFile where
cfTreatAsNonCore <- getPackages o "treat-as-non-core" <|> return mempty
cfTellMeWhenItsReleased <- (fmap mconcat $ o .: "tell-me-when-its-released" >>= mapM toNameVerMap)
<?> Key "tell-me-when-its-released"
cfHide <- Set.map PackageName <$> o .:? "hide" .!= mempty
return ConstraintFile {..}
where
goFlagMap = Map.mapKeysWith const FlagName
Expand Down Expand Up @@ -222,6 +226,7 @@ toBC ConstraintFile {..} = do
pcFlagOverrides = fromMaybe mempty $ lookup name cfPackageFlags
pcConfigureArgs = fromMaybe mempty $ lookup name cfConfigureArgs
pcSkipBuild = name `member` cfSkippedBuilds
pcHide = name `member` cfHide

bcGithubUsers = cfGithubUsers
bcBuildToolOverrides = cfBuildToolOverrides
Expand Down
15 changes: 13 additions & 2 deletions Stackage/PerformBuild.hs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,14 @@ singleBuild pb@PerformBuild {..} registeredPackages SingleBuild {..} = do
Nothing -> rest
Just db -> ("-package-db=" ++ pack db) : rest)

ghcPkgArgs :: [Text] -> [Text]
ghcPkgArgs rest =
"--package-db=clear"
: "--package-db=global"
: (case pbDatabase pb of
Nothing -> rest
Just db -> ("--package-db=" ++ pack db) : rest)

configArgs = ($ []) $ execWriter $ do
tell' "--package-db=clear"
tell' "--package-db=global"
Expand Down Expand Up @@ -497,16 +505,19 @@ singleBuild pb@PerformBuild {..} registeredPackages SingleBuild {..} = do
]
return True
| otherwise -> return False
when toBuild $ withConfiged $ \_childDir cabal -> do
when toBuild $ withConfiged $ \childDir cabal -> do
deletePreviousResults pb pident

log' $ "Building " ++ namever
cabal ["build"]

log' $ "Copying/registering " ++ namever
cabal ["copy"]
withMVar sbRegisterMutex $ const $
withMVar sbRegisterMutex $ const $ do
cabal ["register"]
when pcHide $ do
log' $ "Hiding " ++ namever
runIn childDir getOutH "ghc-pkg" $ ghcPkgArgs ["hide", namever]

savePreviousResult pb Build pident True

Expand Down
4 changes: 4 additions & 0 deletions Stackage/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ data PackageConstraints = PackageConstraints
-- ^ Don't even bother building this library, useful when dealing with
-- OS-specific packages. See:
-- https://github.com/fpco/stackage-curator/issues/3
, pcHide :: !Bool
-- ^ Hide this package after registering, useful for avoiding
-- module name conflicts
}
deriving (Show, Eq)
instance ToJSON PackageConstraints where
Expand Down Expand Up @@ -291,6 +294,7 @@ instance FromJSON PackageConstraints where
pcEnableLibProfile <- fmap (fromMaybe True) (o .:? "library-profiling")
pcSkipBuild <- o .:? "skip-build" .!= False
pcConfigureArgs <- o .:? "configure-args" .!= mempty
pcHide <- o .:? "hide" .!= False
return PackageConstraints {..}

data TestState = ExpectSuccess
Expand Down
1 change: 1 addition & 0 deletions Stackage/UpdateBuildPlan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ updateBuildConstraints BuildPlan {..} =
, pcFlagOverrides = maybe mempty pcFlagOverrides moldPC
, pcEnableLibProfile = maybe True pcEnableLibProfile moldPC
, pcSkipBuild = maybe False pcSkipBuild moldPC
, pcHide = maybe False pcHide moldPC
}
where
moldBP = lookup name bpPackages
Expand Down
2 changes: 1 addition & 1 deletion stackage-curator.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: stackage-curator
version: 0.14.4.1
version: 0.14.5
synopsis: Tools for curating Stackage bundles
description: Please see <http://www.stackage.org/package/stackage-curator> for a description and documentation.
homepage: https://github.com/fpco/stackage-curator
Expand Down

0 comments on commit 9a2d0bf

Please sign in to comment.