configuration-tools 0.2.4.1 → 0.2.5
raw patch · 4 files changed
+75/−20 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Configuration.Utils.Setup: mkPkgInfoModules :: UserHooks -> UserHooks
Files
- CHANGELOG.md +9/−2
- configuration-tools.cabal +2/−2
- constraints +1/−1
- src/Configuration/Utils/Setup.hs +63/−15
CHANGELOG.md view
@@ -1,3 +1,10 @@+0.2.5+=====++* `Configuration.Utils.Setup`: export `mkPkgInfoModules` function + that modifies a given `UserHooks` record to generate an `PkgInfo`+ module during configuration.+ 0.2.4.1 ======= @@ -6,10 +13,10 @@ 0.2.4 ===== -* Configuration.Utils.Setup: fixed generation of 'PkgInfo' module for+* Configuration.Utils.Setup: fixed generation of `PkgInfo` module for package configurations with explict flags. -* Improved documentation for 'Maybe' values.+* Improved documentation for `Maybe` values. 0.2.3 =====
configuration-tools.cabal view
@@ -3,7 +3,7 @@ -- ------------------------------------------------------ -- Name: configuration-tools-Version: 0.2.4.1+Version: 0.2.5 Synopsis: Tools for specifying and parsing configurations description: Tools for specifying and parsing configurations@@ -54,7 +54,7 @@ source-repository this type: git location: https://github.com/alephcloud/hs-configuration-tools.git- tag: 0.2.4.1+ tag: 0.2.5 Library hs-source-dirs: src
constraints view
@@ -11,7 +11,7 @@ bytestring ==0.10.4.0, comonad ==4.2, conduit ==1.1.6,- configuration-tools ==0.2.4.1,+ configuration-tools ==0.2.5, containers ==0.5.5.1, contravariant ==0.6, deepseq ==1.3.0.2,
src/Configuration/Utils/Setup.hs view
@@ -26,7 +26,7 @@ -- -- = Usage as Setup Script ----- There are two ways how this module can be used:+-- There are three ways how this module can be used: -- -- 1. Copy the code of this module into a file called @Setup.hs@ in the root -- directory of your package.@@ -38,7 +38,18 @@ -- > -- > import Configuration.Utils.Setup ----- With both methods the field @Build-Type@ in the package description (cabal) file+-- 3. For usage within a more complex @Setup.hs@ script you shall import this+-- module qualified and use the 'mkPkgInfoModules' function. For example:+--+-- > module Main (main) where+-- >+-- > import qualified Configuration.Utils.Setup as ConfTools+-- >+-- > main :: IO ()+-- > main = defaultMainWithHooks (ConfTools.mkPkgInfoModules simpleUserHooks)+-- >+--+-- With all methods the field @Build-Type@ in the package description (cabal) file -- must be set to @Custom@: -- -- > Build-Type: Custom@@ -90,7 +101,10 @@ -- [@--license@] -- prints the text of the lincense of the application and exits. ---module Configuration.Utils.Setup (main) where+module Configuration.Utils.Setup+( main+, mkPkgInfoModules+) where import Distribution.PackageDescription import Distribution.Simple@@ -116,18 +130,52 @@ import System.Directory (doesFileExist, doesDirectoryExist, createDirectoryIfMissing) import System.Exit (ExitCode(ExitSuccess)) +-- | Include this function when your setup doesn't contain any+-- extra functionality.+-- main :: IO ()-main = defaultMainWithHooks simpleUserHooks- { postConf = mkPkgInfoModules+main = defaultMainWithHooks (mkPkgInfoModules simpleUserHooks)++-- | Modifies the given record of hooks by adding functionality that+-- creates a package info module for each component of the cabal package.+--+-- This function is intended for usage in more complex @Setup.hs@ scripts.+-- If your setup doesn't contain any other function you can just import+-- the 'main' function from this module.+--+-- The modules are created in the /autogen/ build directory where also the+-- @Path_@ module is created by cabal's simple build setup. This is usually the+-- directory @.\/dist\/build\/autogen@.+--+-- For a library component the module is named just @PkgInfo@. For all other+-- components the module is named @PkgInfo_COMPONENT_NAME@ where+-- @COMPONENT_NAME@ is the name of the component with @-@ characters replaced by+-- @_@.+--+mkPkgInfoModules+ :: UserHooks+ -> UserHooks+mkPkgInfoModules hooks = hooks+ { postConf = mkPkgInfoModulesPostConf (postConf hooks) }++mkPkgInfoModulesPostConf+ :: (Args -> ConfigFlags -> PackageDescription -> LocalBuildInfo -> IO ())+ -> Args+ -> ConfigFlags+ -> PackageDescription+ -> LocalBuildInfo+ -> IO ()+mkPkgInfoModulesPostConf hook args flags pkgDesc bInfo = do+ mkModules+ hook args flags pkgDesc bInfo where- mkPkgInfoModules _ _ pkgDesc bInfo = mapM_ (f . \(a,_,_) -> a) $ componentsConfigs bInfo- where- f cname = case cname of- CLibName -> updatePkgInfoModule Nothing pkgDesc bInfo- CExeName s -> updatePkgInfoModule (Just s) pkgDesc bInfo- CTestName s -> updatePkgInfoModule (Just s) pkgDesc bInfo- CBenchName s -> updatePkgInfoModule (Just s) pkgDesc bInfo+ mkModules = mapM_ (f . \(a,_,_) -> a) $ componentsConfigs bInfo+ f cname = case cname of+ CLibName -> updatePkgInfoModule Nothing pkgDesc bInfo+ CExeName s -> updatePkgInfoModule (Just s) pkgDesc bInfo+ CTestName s -> updatePkgInfoModule (Just s) pkgDesc bInfo+ CBenchName s -> updatePkgInfoModule (Just s) pkgDesc bInfo pkgInfoModuleName :: Maybe String -> String pkgInfoModuleName Nothing = "PkgInfo"@@ -147,9 +195,9 @@ getVCS = doesDirectoryExist ".hg" >>= \x0 -> if x0 then return (Just Mercurial)- else doesDirectoryExist ".git" >>= \x1 -> if x1- then return (Just Git)- else return Nothing+ else doesDirectoryExist ".git" >>= \x1 -> return $ if x1+ then Just Git+ else Nothing flagNameStr :: FlagName -> String flagNameStr (FlagName s) = s