proto-lens-setup 0.4.0.2 → 0.4.0.3
raw patch · 3 files changed
+24/−82 lines, 3 filesdep ~Cabaldep ~basedep ~proto-lens-protocPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Cabal, base, proto-lens-protoc
API changes (from Hackage documentation)
Files
- Changelog.md +5/−0
- proto-lens-setup.cabal +6/−6
- src/Data/ProtoLens/Setup.hs +13/−76
Changelog.md view
@@ -1,5 +1,10 @@ # Changelog for `proto-lens-setup` +## v0.4.0.3+- Bump lower bounds to base-4.10 (ghc-8.2) and Cabal-2.0.+- Support dependencies on base-4.13 (ghc-8.8) and Cabal-3.0.+- Bump upper bounds to proto-lens-0.6.+ ## v0.4.0.2 - Bump upper bounds to support `proto-lens-0.5.*`.
proto-lens-setup.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: b0a3becc6c52cfe6b90d049ade629a7c65d5f007dcde7b994cecde873cba0d0e+-- hash: ad9f898b6f6c451500331aaaa794dbff14323dd382cd8d57269848e6dcbcdc28 name: proto-lens-setup-version: 0.4.0.2+version: 0.4.0.3 synopsis: Cabal support for codegen with proto-lens. description: This package provides Cabal support for the @proto-lens@ package. It automatically generates Haskell source files from protocol buffer@@ -70,15 +70,15 @@ hs-source-dirs: src build-depends:- Cabal >=1.22 && <2.5- , base >=4.9 && <4.13+ Cabal >=2.0 && <3.1+ , base >=4.10 && <4.14 , bytestring ==0.10.* , containers >=0.5 && <0.7 , deepseq ==1.4.* , directory >=1.2 && <1.4 , filepath >=1.4 && <1.6 , process >=1.2 && <1.7- , proto-lens-protoc >=0.4 && <0.6+ , proto-lens-protoc >=0.4 && <0.7 , temporary >=1.2 && <1.4 , text ==1.2.* default-language: Haskell2010
src/Data/ProtoLens/Setup.hs view
@@ -29,7 +29,6 @@ import qualified Data.Map as Map import Data.Maybe (maybeToList) import qualified Data.Set as Set-import qualified Data.Text as T import Distribution.ModuleName (ModuleName) import qualified Distribution.ModuleName as ModuleName import qualified Distribution.InstalledPackageInfo as InstalledPackageInfo@@ -41,9 +40,6 @@ , exeName , exposedModules , extraSrcFiles-#if !MIN_VERSION_Cabal(2,0,0)- , hsSourceDirs-#endif #if MIN_VERSION_Cabal(2,4,0) , specVersion #endif@@ -53,7 +49,7 @@ , testBuildInfo , testName )-import qualified Distribution.Simple.BuildPaths as BuildPaths+import Distribution.Simple.BuildPaths (autogenComponentModulesDir) import Distribution.Simple.InstallDirs (datadir) import Distribution.Simple.LocalBuildInfo ( LocalBuildInfo(..)@@ -61,9 +57,10 @@ , ComponentName(..) , ComponentLocalBuildInfo , componentPackageDeps-#if MIN_VERSION_Cabal(2,0,0) , allComponentsInBuildOrder , componentNameMap+#if MIN_VERSION_Cabal(3,0,0)+ , LibraryName(..) #endif ) import qualified Distribution.Simple.PackageIndex as PackageIndex@@ -92,6 +89,7 @@ ) import System.FilePath ( (</>)+ , (<.>) , equalFilePath , isRelative , makeRelative@@ -110,7 +108,7 @@ import System.IO.Temp (withSystemTempDirectory) import System.Process (callProcess) -import qualified Data.ProtoLens.Compiler.Plugin as Plugin+import Data.ProtoLens.Compiler.ModuleName (protoModuleName) -- | This behaves the same as 'Distribution.Simple.defaultMain', but -- auto-generates Haskell files from .proto files which are:@@ -205,16 +203,6 @@ { buildHook = \p l h f -> generate l >> buildHook hooks p l h f , haddockHook = \p l h f -> generate l >> haddockHook hooks p l h f , replHook = \p l h f args -> generate l >> replHook hooks p l h f args-#if !MIN_VERSION_Cabal(2,0,0)- -- Older versions of Cabal don't support the autogen-modules field.- -- Work around it by manually generating the modules and putting them- -- in a place where `cabal sdist` will pick them up.- , sDistHook = \p maybe_l h f -> case maybe_l of- Nothing -> error "Can't run protoc; run 'cabal configure' first."- Just l -> do- generate l- sDistHook hooks (fudgePackageDesc l p) maybe_l h f-#endif , postCopy = \a flags pkg lbi -> do let verb = fromFlag $ copyVerbosity flags let destDir = datadir (absoluteInstallDirs pkg lbi@@ -254,7 +242,7 @@ -- directory. let activeModules = collectActiveModules l let allModules = Set.fromList . concat . map snd $ activeModules- let usedInComponent f = ModuleName.fromString (Plugin.moduleNameStr "Proto" f)+ let usedInComponent f = ModuleName.fromString (protoModuleName f) `Set.member` allModules generateProtosWithImports (root : importDirs) tmpDir -- Applying 'root </>' does nothing if the path is already@@ -263,7 +251,7 @@ -- Copy each active component's files over to its autogen directory, but -- only if they've changed since last time. forM_ activeModules $ \(compBI, mods) -> forM_ mods $ \m -> do- let f = T.unpack (Plugin.outputFilePath $ ModuleName.toFilePath m)+ let f = ModuleName.toFilePath m <.> ".hs" let sourcePath = tmpDir </> f sourceExists <- doesFileExist sourcePath when sourceExists $ do@@ -316,39 +304,6 @@ protoLensImportsPrefix :: FilePath protoLensImportsPrefix = "proto-lens-imports" -#if !MIN_VERSION_Cabal(2,0,0)--- | Add the autogen directory to the hs-source-dirs of all the targets in the--- .cabal file. Used to fool 'sdist' by pointing it to the generated source--- files.-fudgePackageDesc :: LocalBuildInfo -> PackageDescription -> PackageDescription-fudgePackageDesc lbi p = p- { library =- (\lib -> lib { libBuildInfo = fudgeBuildInfo CLibName $ libBuildInfo lib })- <$> library p- , executables =- (\exe -> exe { buildInfo = fudgeBuildInfo (CExeName $ exeName exe)- $ buildInfo exe })- <$> executables p- , testSuites =- (\test -> test { testBuildInfo = fudgeBuildInfo (CTestName $ testName test)- $ testBuildInfo test })- <$> testSuites p- , benchmarks =- (\bench -> bench { benchmarkBuildInfo =- fudgeBuildInfo (CBenchName $ benchmarkName bench)- $ benchmarkBuildInfo bench })- <$> benchmarks p- }- where- comps = allComponents lbi- fudgeBuildInfo n bi- | Just compLBI <- Map.lookup n comps- = bi { hsSourceDirs = autogenComponentModulesDir lbi compLBI- : hsSourceDirs bi }- | otherwise = bi -- Could happen if a component isn't active; try- -- anyway and see whether Cabal complains later on.-#endif- -- | Returns whether the @root@ is a parent folder of @f@. isSubdirectoryOf :: FilePath -> FilePath -> Bool isSubdirectoryOf root f@@ -423,15 +378,18 @@ collectActiveModules l = map (\(n, c) -> (c, f n)) $ Map.toList $ allComponents l where p = localPkgDescr l- f CLibName = maybeToList (library p) >>=+#if MIN_VERSION_Cabal(3,0,0)+ f (CLibName LMainLibName)+#else+ f CLibName+#endif+ = maybeToList (library p) >>= \lib -> exposedModules lib ++ otherModules (libBuildInfo lib) f (CExeName n) = otherModules . buildInfo $ exes Map.! n f (CTestName n) = otherModules . testBuildInfo $ tests Map.! n f (CBenchName n) = otherModules . benchmarkBuildInfo $ benchs Map.! n-#if MIN_VERSION_Cabal(2,0,0) f _ = [] -- TODO: other lib kinds; for now just suppress the warning-#endif exes = Map.fromList [(exeName e, e) | e <- executables p] tests = Map.fromList [(testName e, e) | e <- testSuites p] benchs = Map.fromList [(benchmarkName e, e) | e <- benchmarks p]@@ -441,22 +399,14 @@ -- | List all the packages that this one depends on. collectDeps :: LocalBuildInfo -> [InstalledPackageInfo.InstalledPackageInfo]-#if MIN_VERSION_Cabal(2,0,0) collectDeps l = do c <- allComponentsInBuildOrder l (i,_) <- componentPackageDeps c Just p <- [PackageIndex.lookupUnitId (installedPkgs l) i] return p-#else-collectDeps l = do- (_, c ,_) <- componentsConfigs l- (_, i) <- componentPackageDeps c- PackageIndex.lookupSourcePackageId (installedPkgs l) i-#endif -- | All the components that will be built by this Cabal command. allComponents :: LocalBuildInfo -> Map.Map ComponentName ComponentLocalBuildInfo-#if MIN_VERSION_Cabal(2,0,0) allComponents l = fmap requireOne $ componentNameMap l where -- TODO: this doesn't support Backpack, which can have more than one@@ -464,16 +414,3 @@ requireOne [x] = x requireOne xs = error $ "Data.ProtoLens.Setup.allComponents: expected one " ++ "component per name, got " ++ show xs--#else-allComponents l = Map.fromList [(c, b) | (c, b, _) <- componentsConfigs l]-#endif---- | Get the component-level "autogen" directory where we're putting the--- generated .hs files. (For Cabal-1.0, use the shared 'BuildPaths.autogenModulesDir'.)-autogenComponentModulesDir :: LocalBuildInfo -> ComponentLocalBuildInfo -> FilePath-#if MIN_VERSION_Cabal(2,0,0)-autogenComponentModulesDir = BuildPaths.autogenComponentModulesDir-#else-autogenComponentModulesDir lbi _ = BuildPaths.autogenModulesDir lbi-#endif