Skip to content

Commit

Permalink
Fix build of proto-lens-0.3.* on lts-12. (#211)
Browse files Browse the repository at this point in the history
Also update `stack.yaml` to `lts-12.6` rather than a nightly.

The proto-lens-protoc-0.3.1.1 release had an upper bound
on `temporary` that was too restrictive.  Increase it,
and bump the version to `0.3.1.2`.

Also fix warnings and improve CI.  Turns out the Travis script wasn't robust enough and #195 let through
some warnings.  I fixed the script and confirmed it now catches such
issues.

Also bumped the tutorial and bootstrap scripts to the same LTS
as the main build.
  • Loading branch information
judah authored Aug 25, 2018
1 parent ec79d10 commit fca9671
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 16 deletions.
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ matrix:
addons: {apt: {packages: [libgmp-dev]}}
- env: BUILD=stack STACK='stack --resolver=lts-9.6'
addons: {apt: {packages: [libgmp-dev]}}
- env: BUILD=stack STACK=stack # Use the resolver in stack.yaml
- env: BUILD=stack STACK=stack --resolver=11.22'
addons: {apt: {packages: [libgmp-dev]}}
- env: BUILD=stack STACK='stack --resolver=nightly-2018-05-04'
- env: BUILD=stack STACK='stack' # Use the resolver in stack.yaml
addons: {apt: {packages: [libgmp-dev]}}

before_install:
Expand Down Expand Up @@ -56,11 +56,14 @@ install:
script:
# Separate stack's build and test commands, since build by itself hits some
# edge cases around custom Setup.hs script dependencies.
# Also build the tutorial, with proto-lens-* as extra-deps. Note that
# since stack is not hermetic, the extra-deps for the tutorial reuse some
# build outputs from the regular build.
- case "$BUILD" in
stack)
STACK_ARGS=(--haddock --no-haddock-deps --ghc-options="-Wall -Werror");
cd proto-lens-tutorial && $STACK build "${STACK_ARGS[@]}" && cd ..
$STACK build --bench --no-run-benchmarks "${STACK_ARGS[@]}" && $STACK test "${STACK_ARGS[@]}";;
$STACK build --bench --no-run-benchmarks "${STACK_ARGS[@]}" && $STACK test "${STACK_ARGS[@]}";
cd proto-lens-tutorial && $STACK build "${STACK_ARGS[@]}" && cd ..;;
cabal)
./travis-cabal.sh;;
esac
4 changes: 4 additions & 0 deletions proto-lens-protoc/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog for `proto-lens-protoc`

## v0.3.1.2
- Bump the upper bound to `temporary-1.3`.
- Fix warnings.

## v0.3.1.1
- Fix management of generated files between Cabal components (#171).
- Bump the lower bound on `base` to indicate we require `ghc>=8.0`.
Expand Down
2 changes: 1 addition & 1 deletion proto-lens-protoc/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ library:
- lens-labels == 0.2.*
- pretty == 1.1.*
- process >= 1.2 && < 1.7
- temporary == 1.2.*
- temporary >= 1.2 && < 1.4
exposed-modules:
- Data.ProtoLens.Compiler.Combinators
- Data.ProtoLens.Compiler.Definitions
Expand Down
5 changes: 4 additions & 1 deletion proto-lens-protoc/src/Data/ProtoLens/Compiler/Definitions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
-- | This module takes care of collecting all the definitions in a .proto file
-- and assigning Haskell names to all of the defined things (messages, enums
-- and field names).
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
Expand Down Expand Up @@ -39,7 +40,9 @@ import Data.Int (Int32)
import Data.List (mapAccumL)
import qualified Data.Map as Map
import Data.Maybe (fromMaybe)
import Data.Monoid
#if !MIN_VERSION_base(4,11,0)
import Data.Monoid ((<>))
#endif
import qualified Data.Semigroup as Semigroup
import qualified Data.Set as Set
import Data.String (IsString(..))
Expand Down
16 changes: 9 additions & 7 deletions proto-lens-protoc/src/Data/ProtoLens/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ module Data.ProtoLens.Setup
, generateProtos
) where

import Control.DeepSeq (force)
import Control.Monad (filterM, forM_, guard, when)
import Control.Monad (filterM, forM_, when)
import qualified Data.ByteString as BS
import qualified Data.Map as Map
import Data.Maybe (maybeToList)
Expand All @@ -42,7 +41,9 @@ import Distribution.PackageDescription
, exeName
, exposedModules
, extraSrcFiles
#if !MIN_VERSION_Cabal(2,0,0)
, hsSourceDirs
#endif
, libBuildInfo
, otherModules
, testBuildInfo
Expand All @@ -66,7 +67,6 @@ import qualified Distribution.Simple.PackageIndex as PackageIndex
import Distribution.Simple.Setup (fromFlag, copyDest, copyVerbosity)
import Distribution.Simple.Utils
( createDirectoryIfMissingVerbose
, getDirectoryContentsRecursive
, installOrdinaryFile
, matchFileGlob
)
Expand All @@ -78,7 +78,6 @@ import Distribution.Simple
import Distribution.Verbosity (Verbosity)
import System.FilePath
( (</>)
, (<.>)
, equalFilePath
, isRelative
, makeRelative
Expand Down Expand Up @@ -296,6 +295,7 @@ copyProtosToDataDir verb root destDir files = do
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.
Expand Down Expand Up @@ -326,6 +326,7 @@ fudgePackageDesc lbi p = p
: 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
Expand Down Expand Up @@ -398,11 +399,12 @@ findExecutableOrDie name debugMsg = do
-- (e.g., `stack test` vs `stack build`).
collectActiveModules
:: LocalBuildInfo -> [(ComponentLocalBuildInfo, [ModuleName])]
collectActiveModules l = map (\(n, l) -> (l, f n)) $ Map.toList $ allComponents l
collectActiveModules l = map (\(n, c) -> (c, f n)) $ Map.toList $ allComponents l
where
p = localPkgDescr l
f CLibName = maybeToList (library p) >>= \l -> exposedModules l
++ otherModules (libBuildInfo l)
f CLibName = 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
Expand Down
2 changes: 1 addition & 1 deletion proto-lens-tutorial/stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-11.7
resolver: lts-12.7
packages:
- person
- coffee-order
Expand Down
2 changes: 1 addition & 1 deletion stack-bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-9.21
resolver: lts-12.7
packages:
- proto-lens-protoc
# Build the current HEAD proto-lens-protoc against older revisions of proto-lens
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-11.7
resolver: lts-12.7
packages:
- discrimination-ieee754
- lens-labels
Expand Down

0 comments on commit fca9671

Please sign in to comment.