Skip to content

Commit

Permalink
Rerun bootstrapping, and use a consistent encoding method in proto-le…
Browse files Browse the repository at this point in the history
…ns-protoc. (google#290)

Previously we were always using reflected encodings in proto-lens-protoc.
After recent changes, the generated encodings are good enough that we can
use them to decode DescriptorProto.  So, this change makes us use the generated
encodings (for better testing) when the flag is set.
  • Loading branch information
judah authored and blackgnezdo committed Dec 18, 2018
1 parent 85e9dd1 commit a68ca35
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions app/protoc-gen-haskell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ import Data.Monoid ((<>))
import qualified Data.Set as Set
import qualified Data.Text as T
import Data.Text (Text, pack)
import Data.ProtoLens (defMessage)
import Data.ProtoLens (defMessage, decodeMessage, encodeMessage)
-- Force the use of the Reflected API when decoding DescriptorProto
-- so that we can run the test suite against the Generated API.
-- TODO: switch back to Data.ProtoLens.Encoding once the Generated encoding is
-- good enough.
import Data.ProtoLens.Encoding.Bytes (runParser, runBuilder)
import Data.ProtoLens.Encoding.Reflected (parseMessage, buildMessage)
import Lens.Family2
import Proto.Google.Protobuf.Compiler.Plugin
( CodeGeneratorRequest
Expand Down Expand Up @@ -51,9 +49,9 @@ main :: IO ()
main = do
contents <- B.getContents
progName <- getProgName
case runParser parseMessage contents of
case decodeMessage contents of
Left e -> IO.hPutStrLn stderr e >> exitWith (ExitFailure 1)
Right x -> B.putStr $ runBuilder $ buildMessage $ makeResponse progName x
Right x -> B.putStr $ encodeMessage $ makeResponse progName x

makeResponse :: String -> CodeGeneratorRequest -> CodeGeneratorResponse
makeResponse prog request = let
Expand Down

0 comments on commit a68ca35

Please sign in to comment.