2015-02-04 00:12:51 +00:00
|
|
|
#!/usr/bin/env runhaskell
|
|
|
|
{-# LANGUAGE RecordWildCards #-}
|
2010-04-02 15:16:22 +00:00
|
|
|
import Distribution.Simple
|
2015-02-04 00:12:51 +00:00
|
|
|
import Distribution.Simple.Setup
|
|
|
|
import Distribution.Simple.Install
|
2017-03-01 07:26:17 +00:00
|
|
|
import Distribution.Simple.Program
|
2015-04-15 11:13:00 +00:00
|
|
|
import Distribution.Simple.Register
|
2015-02-04 00:12:51 +00:00
|
|
|
import Distribution.Simple.InstallDirs as ID
|
2015-01-16 14:46:58 +00:00
|
|
|
import Distribution.Simple.LocalBuildInfo
|
2015-02-04 00:12:51 +00:00
|
|
|
import Distribution.PackageDescription
|
2015-01-16 14:46:58 +00:00
|
|
|
|
2015-02-04 00:12:51 +00:00
|
|
|
import Control.Arrow
|
2015-01-16 14:46:58 +00:00
|
|
|
import Control.Applicative
|
2015-02-04 00:12:51 +00:00
|
|
|
import Control.Monad
|
|
|
|
import Data.List
|
|
|
|
import Data.Maybe
|
2015-01-16 14:46:58 +00:00
|
|
|
import Data.Version
|
2015-02-04 00:12:51 +00:00
|
|
|
import Data.Monoid
|
2015-01-16 14:46:58 +00:00
|
|
|
import System.Process
|
|
|
|
import System.Exit
|
2015-02-04 00:12:51 +00:00
|
|
|
import System.FilePath
|
2015-01-16 14:46:58 +00:00
|
|
|
|
2015-02-04 00:12:51 +00:00
|
|
|
import SetupCompat
|
2015-01-16 14:46:58 +00:00
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = defaultMainWithHooks $ simpleUserHooks {
|
2015-02-04 00:12:51 +00:00
|
|
|
confHook = \(gpd, hbi) cf ->
|
2015-02-08 13:17:53 +00:00
|
|
|
xBuildDependsLike <$> (confHook simpleUserHooks) (gpd, hbi) cf
|
2017-03-01 07:26:17 +00:00
|
|
|
, hookedPrograms = [ simpleProgram "shelltest" ]
|
2015-02-04 00:12:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
xBuildDependsLike :: LocalBuildInfo -> LocalBuildInfo
|
|
|
|
xBuildDependsLike lbi =
|
|
|
|
let
|
|
|
|
cc = componentsConfigs lbi
|
|
|
|
pd = localPkgDescr lbi
|
|
|
|
deps = dependsMap lbi
|
|
|
|
in setComponentsConfigs lbi
|
|
|
|
[ (cn, updateClbi deps comp clbi, cdeps)
|
|
|
|
| (cn, clbi, cdeps) <- cc
|
|
|
|
, let comp = getComponent pd cn
|
|
|
|
]
|
|
|
|
|
|
|
|
where
|
2015-02-08 13:17:53 +00:00
|
|
|
updateClbi deps comp clbi = setUnionDeps (otherDeps deps comp) clbi
|
2015-02-04 00:12:51 +00:00
|
|
|
|
|
|
|
dependsMap ::
|
2015-02-08 13:17:53 +00:00
|
|
|
LocalBuildInfo -> [(ComponentName, Deps)]
|
2015-02-04 00:12:51 +00:00
|
|
|
dependsMap lbi =
|
2015-02-08 13:17:53 +00:00
|
|
|
second getDeps <$> allComponentsInBuildOrder lbi
|
2015-02-04 00:12:51 +00:00
|
|
|
|
2015-02-08 13:17:53 +00:00
|
|
|
otherDeps :: [(ComponentName, Deps)] -> Component -> Deps
|
|
|
|
otherDeps deps comp = fromMaybe noDeps $
|
2015-02-04 00:12:51 +00:00
|
|
|
flip lookup deps =<< read <$> lookup "x-build-depends-like" fields
|
|
|
|
where
|
|
|
|
fields = customFieldsBI (componentBuildInfo comp)
|