Bump version suffix to 2.16.0 beta2
[ganeti-github.git] / cabal / CabalDependenciesMacros.hs
1 module Main where
2
3 import Control.Applicative
4 import qualified Data.Set as Set
5 import qualified Distribution.Simple.Build.Macros as Macros
6 import Distribution.Simple.Configure (maybeGetPersistBuildConfig)
7 import Distribution.Simple.LocalBuildInfo (externalPackageDeps)
8 import Distribution.PackageDescription (packageDescription)
9 import Distribution.PackageDescription.Parse (readPackageDescription)
10 import Distribution.Text (display)
11 import Distribution.Verbosity (normal)
12 import System.Environment (getArgs)
13
14
15 main :: IO ()
16 main = do
17 -- Get paths from program arguments.
18 (cabalPath, depsPath, macrosPath) <- do
19 args <- getArgs
20 case args of
21 [c, d, m] -> return (c, d, m)
22 _ -> error "Expected 3 arguments: cabalPath depsPath macrosPath"
23
24 -- Read the cabal file.
25 pkgDesc <- packageDescription <$> readPackageDescription normal cabalPath
26
27 -- Read the setup-config.
28 m'conf <- maybeGetPersistBuildConfig "dist"
29 case m'conf of
30 Nothing -> error "could not read dist/setup-config"
31 Just conf -> do
32
33 -- Write package dependencies.
34 let deps = map (display . fst) $ externalPackageDeps conf
35 writeFile depsPath (unwords $ map ("-package-id " ++) deps)
36
37 -- Write package MIN_VERSION_* macros.
38 writeFile macrosPath $ Macros.generate pkgDesc conf