packages feed

proto-lens-protoc 0.1.0.0 → 0.1.0.1

raw patch · 3 files changed

+48/−10 lines, 3 filesdep ~Cabaldep ~basedep ~process

Dependency ranges changed: Cabal, base, process, proto-lens

Files

proto-lens-protoc.cabal view
@@ -1,5 +1,5 @@ name:                proto-lens-protoc-version:             0.1.0.0+version:             0.1.0.1 synopsis:            Protocol buffer compiler for the proto-lens library. description:   Turn protocol buffer files (.proto) into Haskell files (.hs) which@@ -18,16 +18,16 @@   default-language:  Haskell2010   hs-source-dirs:    src   build-depends:-        Cabal == 1.22.*-      , base == 4.8.*+        Cabal >= 1.22 && < 1.25+      , base >= 4.8 && < 4.10       , bytestring == 0.10.*       , containers == 0.5.*       , data-default-class == 0.0.*       , directory == 1.2.*       , filepath == 1.4.*       , lens-family == 1.2.*-      , process == 1.2.*-      , proto-lens == 0.1.0.0+      , process >= 1.2 && < 1.5+      , proto-lens == 0.1.0.1       , text == 1.2.*   reexported-modules:       -- Modules that are needed by the generated Haskell files:@@ -50,7 +50,7 @@       Generate    build-depends:-        base == 4.8.*+        base >= 4.8 && < 4.10       , bytestring == 0.10.*       , containers == 0.5.*       , data-default-class == 0.0.*@@ -59,7 +59,7 @@       , lens-family == 1.2.*       -- Specify an exact version of `proto-lens`, since it's tied closely       -- to the generated code.-      , proto-lens == 0.1.0.0+      , proto-lens == 0.1.0.1       , text == 1.2.*   hs-source-dirs:      src   default-language:    Haskell2010
src/Data/ProtoLens/Setup.hs view
@@ -19,8 +19,17 @@     , generateProtos     ) where -import Distribution.PackageDescription (extraSrcFiles)+import Distribution.PackageDescription+    ( PackageDescription(..)+    , benchmarkBuildInfo+    , buildInfo+    , extraSrcFiles+    , hsSourceDirs+    , libBuildInfo+    , testBuildInfo+    ) import Distribution.Simple.BuildPaths (autogenModulesDir)+import Distribution.Simple.LocalBuildInfo (LocalBuildInfo) import Distribution.Simple.Program (knownPrograms, ConfiguredProgram(..)) import Distribution.Simple.Program.Types (simpleProgram) import Distribution.Simple.Utils (matchFileGlob)@@ -68,7 +77,11 @@ generatingProtos root hooks = hooks     { buildHook = \p l h f -> generateSources p l >> buildHook hooks p l h f     , haddockHook = \p l h f -> generateSources p l >> haddockHook hooks p l h f-    -- TODO: add a hook for sdist.+    , sDistHook = \p maybe_l h f -> case maybe_l of+            Nothing -> error "Can't run protoc; run 'cabal configure' first."+            Just l -> do+                        generateSources p l+                        sDistHook hooks (fudgePackageDesc l p) maybe_l h f     }   where     generateSources p l = do@@ -78,6 +91,29 @@             $ filter (isSubdirectoryOf root)             $ filter (\f -> takeExtension f == ".proto")                 files++-- | 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 (libBuildInfo lib) })+            <$> library p+    , executables =+        (\exe -> exe { buildInfo = fudgeBuildInfo (buildInfo exe) })+            <$> executables p+    , testSuites =+        (\test -> test { testBuildInfo = fudgeBuildInfo (testBuildInfo test) })+            <$> testSuites p+    , benchmarks =+        (\bench -> bench { benchmarkBuildInfo =+                              fudgeBuildInfo (benchmarkBuildInfo bench) })+            <$> benchmarks p+    }+  where+    fudgeBuildInfo bi =+        bi { hsSourceDirs = autogenModulesDir lbi : hsSourceDirs bi }  -- | Returns whether the @root@ is a parent folder of @f@. isSubdirectoryOf :: FilePath -> FilePath -> Bool
src/Definitions.hs view
@@ -108,7 +108,9 @@ -- nested in other messages), and assign Haskell names to them. collectDefinitions :: FileDescriptorProto -> Env Name collectDefinitions fd = let-    protoPrefix = "." <> (fd ^. package) <> "."+    protoPrefix = case fd ^. package of+        "" -> "."+        p -> "." <> p <> "."     hsPrefix = ""     in Map.fromList $ messageAndEnumDefs protoPrefix hsPrefix                           (fd ^. messageType) (fd ^. enumType)