uuagc-cabal 1.0.0.2 → 1.0.0.3
raw patch · 3 files changed
+32/−35 lines, 3 filesdep ~uulibsetup-changedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: uulib
API changes (from Hackage documentation)
Files
- Setup.hs +1/−0
- src/Distribution/Simple/UUAGC/UUAGC.hs +28/−32
- uuagc-cabal.cabal +3/−3
Setup.hs view
@@ -1,2 +1,3 @@+module Main where import Distribution.Simple main = defaultMain
src/Distribution/Simple/UUAGC/UUAGC.hs view
@@ -63,7 +63,7 @@ defUUAGCOptions = "uuagc_options" -- | File used to store de classes defined in the cabal file.-agClassesFile = ".ag_file_options"+agClassesFile = "ag_file_options" -- | The prefix used for the cabal file optionsw agModule = "x-agmodule"@@ -78,9 +78,7 @@ uuagcUserHook' uuagcPath = hooks where hooks = simpleUserHooks { hookedPreProcessors = ("ag", ag):("lag",ag):knownSuffixHandlers , buildHook = uuagcBuildHook uuagcPath- , postBuild = uuagcPostBuild , sDistHook = uuagcSDistHook uuagcPath- , postSDist = uuagcPostBuild } ag = uuagc' uuagcPath @@ -132,13 +130,14 @@ -- AG Files and theirs file dependencies in order to see if the latters -- are more updated that the formers, and if this is the case to -- update the AG File-updateAGFile :: String+updateAGFile :: FilePath+ -> FilePath -> PackageDescription -> LocalBuildInfo -> (FilePath, String) -> IO ()-updateAGFile uuagcPath pkgDescr lbi (f, sp) = do- fileOpts <- readFileOptions+updateAGFile uuagcPath classesPath pkgDescr lbi (f, sp) = do+ fileOpts <- readFileOptions classesPath let opts = case lookup f fileOpts of Nothing -> [] Just x -> x@@ -192,16 +191,16 @@ getAGClasses :: [(String, String)] -> IO [AGOptionsClass] getAGClasses = mapM (parseClassAG . snd) . filter ((== agClass) . fst) -writeFileOptions :: [(String, [UUAGCOption])] -> IO ()-writeFileOptions opts = do- hClasses <- openFile agClassesFile WriteMode+writeFileOptions :: FilePath -> [(String, [UUAGCOption])] -> IO ()+writeFileOptions classesPath opts = do+ hClasses <- openFile classesPath WriteMode hPutStr hClasses $ show opts hFlush hClasses hClose hClasses -readFileOptions :: IO [(String, [UUAGCOption])]-readFileOptions = do- hClasses <- openFile agClassesFile ReadMode+readFileOptions :: FilePath -> IO [(String, [UUAGCOption])]+readFileOptions classesPath = do+ hClasses <- openFile classesPath ReadMode sClasses <- hGetContents hClasses classes <- readIO sClasses :: IO [(String, [UUAGCOption])] hClose hClasses@@ -218,7 +217,7 @@ ++ show fClass ++ " is not defined." -uuagcSDistHook :: String+uuagcSDistHook :: FilePath -> PackageDescription -> Maybe LocalBuildInfo -> UserHooks@@ -227,29 +226,31 @@ uuagcSDistHook uuagcPath pd mbLbi uh df = do case mbLbi of Nothing -> warn normal "sdist: the local buildinfo was not present. Skipping AG initialization. Dist may fail."- Just lbi -> commonHook uuagcPath pd lbi uh (sDistVerbosity df)+ Just lbi -> let classesPath = buildDir lbi </> agClassesFile+ in commonHook uuagcPath classesPath pd lbi (sDistVerbosity df) originalSDistHook pd mbLbi uh df -- uuagcBuildHook- :: String+ :: FilePath -> PackageDescription -> LocalBuildInfo -> UserHooks -> BuildFlags -> IO () uuagcBuildHook uuagcPath pd lbi uh bf = do- commonHook uuagcPath pd lbi uh (buildVerbosity bf)+ let classesPath = buildDir lbi </> agClassesFile+ commonHook uuagcPath classesPath pd lbi (buildVerbosity bf) originalBuildHook pd lbi uh bf -commonHook :: String+commonHook :: FilePath+ -> FilePath -> PackageDescription -> LocalBuildInfo- -> UserHooks -> Flag Verbosity -> IO ()-commonHook uuagcPath pd lbi uh fl = do+commonHook uuagcPath classesPath pd lbi fl = do+ let verbosity = fromFlagOrDefault normal fl+ createDirectoryIfMissingVerbose verbosity True (buildDir lbi) let lib = library pd exes = executables pd bis = map libBuildInfo (maybeToList lib) ++ map buildInfo exes@@ -257,17 +258,11 @@ options <- getAGFileOptions (bis >>= customFieldsBI) fileOptions <- forM options (\ opt -> let (notFound, opts) = getOptionsFromClass classes $ opt- in do case fl of- Flag v | v >= verbose -> putStrLn ("options for " ++ filename opt ++ ": " ++ show opts)- _ -> return ()+ in do when (verbosity >= verbose) $ putStrLn ("options for " ++ filename opt ++ ": " ++ show opts) forM_ notFound (hPutStrLn stderr) >> return (normalise . filename $ opt, opts))- writeFileOptions fileOptions+ writeFileOptions classesPath fileOptions let agflSP = map (id &&& dropFileName) $ nub $ getAGFileList options- mapM_ (updateAGFile uuagcPath pd lbi) agflSP--uuagcPostBuild _ _ _ _ = do- exists <- doesFileExist agClassesFile- when exists $ removeFile agClassesFile+ mapM_ (updateAGFile uuagcPath classesPath pd lbi) agflSP getAGFileList :: AGFileOptions -> [FilePath] getAGFileList = map (normalise . filename)@@ -279,14 +274,15 @@ -> BuildInfo -> LocalBuildInfo -> PreProcessor-uuagc' uuagcPath build local =+uuagc' uuagcPath build lbi = PreProcessor { platformIndependent = True, runPreProcessor = mkSimplePreProcessor $ \ inFile outFile verbosity -> do info verbosity $ concat [inFile, " has been preprocessed into ", outFile] print $ "processing: " ++ inFile ++ " generating: " ++ outFile -- opts <- getAGFileOptions $ customFieldsBI build- fileOpts <- readFileOptions+ let classesPath = buildDir lbi </> agClassesFile+ fileOpts <- readFileOptions classesPath let opts = case lookup inFile fileOpts of Nothing -> [] Just x -> x
uuagc-cabal.cabal view
@@ -1,7 +1,7 @@-cabal-version: >=1.6+cabal-version: >=1.8 build-type: Simple name: uuagc-cabal-version: 1.0.0.2+version: 1.0.0.3 license: BSD3 license-file: LICENSE maintainer: Arie Middelkoop <ariem@cs.uu.nl>@@ -18,7 +18,7 @@ library build-depends: base >= 4, base < 5, Cabal >= 1.8.0.6, directory >= 1.0.1.1- build-depends: process >= 1.0.1.3, uulib >= 0.9.12, filepath >= 1.1.0.4, mtl >= 2.0.1.0+ build-depends: process >= 1.0.1.3, uulib >= 0.9.14, filepath >= 1.1.0.4, mtl >= 2.0.1.0 hs-source-dirs: src exposed-modules: Distribution.Simple.UUAGC other-modules: Distribution.Simple.UUAGC.UUAGC,