Skip to content

Commit

Permalink
Build with lts-10.3.
Browse files Browse the repository at this point in the history
Needs to disable `-Werror` due to haskell/cabal#4739.  (We could also work
around it by changing the module structure.)
  • Loading branch information
judah committed Jan 15, 2018
1 parent e9bb1d5 commit ee1393c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
27 changes: 14 additions & 13 deletions src/Pier/Build/Components.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import Development.Shake.FilePath hiding (exe)
import Distribution.ModuleName
import Distribution.Simple.Build.Macros (generatePackageVersionMacros)
import Distribution.Package
import Distribution.PackageDescription
import Distribution.PackageDescription hiding (libName)
import qualified Distribution.InstalledPackageInfo as IP
import Distribution.Text
import Distribution.System (buildOS, OS(..))
import Distribution.Version (Version(..))
import Distribution.Version (Version, versionNumbers)
import Distribution.Compiler
import qualified Data.Set as Set
import Data.Set (Set)
Expand Down Expand Up @@ -253,7 +253,7 @@ buildExecutables p = getConfiguredPackage p >>= \case
Left _ -> return Map.empty
Right confd ->
fmap Map.fromList
. mapM (\e -> (exeName e,) <$> buildExecutable confd e)
. mapM (\e -> (display $ exeName e,) <$> buildExecutable confd e)
. filter (buildable . buildInfo)
$ executables (confdDesc confd)

Expand All @@ -263,7 +263,7 @@ buildExecutableNamed p e = getConfiguredPackage p >>= \case
Left pid -> error $ "Built-in package " ++ display pid
++ " has no executables"
Right confd
| Just exe <- find ((== e) . exeName) (executables $ confdDesc confd)
| Just exe <- find ((== e) . display . exeName) (executables $ confdDesc confd)
-> buildExecutable confd exe
| otherwise -> error $ "Package " ++ display (packageId confd)
++ " has no executable named " ++ e
Expand All @@ -273,6 +273,7 @@ buildExecutable
-> Executable
-> Action BuiltExecutable
buildExecutable confd exe = do
let name = display $ exeName exe
let desc = confdDesc confd
let packageSourceDir = confdSourceDir confd
let bi = buildInfo exe
Expand All @@ -281,7 +282,7 @@ buildExecutable confd exe = do
conf <- askConfig
let ghc = configGhc conf
let outputPrefix = display (packageName $ package desc)
</> "exe" </> exeName exe
</> "exe" </> name
let cIncludeDirs = transitiveIncludeDirs transDeps
<> Set.map (packageSourceDir />)
(Set.fromList $ ifNullDirs $ includeDirs bi)
Expand All @@ -296,13 +297,13 @@ buildExecutable confd exe = do
moduleBootFiles <- catMaybes <$> mapM findBootFile otherModuleFiles
let cFiles = map (packageSourceDir />) $ cSources bi
cIncludes <- collectCIncludes desc bi (packageSourceDir />)
bin <- runCommand (output $ exeName exe)
bin <- runCommand (output $ name)
$ message (display (package desc) ++ ": building executable "
++ exeName exe)
++ name)
<> inputList moduleBootFiles
<> inputList cIncludes
<> ghcCommand ghc deps bi confd
[ "-o", pathOut (exeName exe)
[ "-o", pathOut name
, "-hidir", outputPrefix </> "hi"
, "-odir", outputPrefix </> "o"
, "-dynamic"
Expand Down Expand Up @@ -459,8 +460,7 @@ genPathsModule m pkg datas = do
[ "{-# LANGUAGE CPP #-}"
, "module " ++ display m ++ " (getDataFileName, getDataDir, version) where"
, "import Data.Version (Version(..))"
, "version :: Version"
, "version = Version " ++ show (versionBranch
, "version = Version " ++ show (versionNumbers
$ pkgVersion pkg)
++ ""
++ " []" -- tags are deprecated
Expand Down Expand Up @@ -495,7 +495,7 @@ search ghc bi cIncludeDirs m srcDir
let yFile = srcDir /> toFilePath m <.> ext
exists yFile
let relOutput = toFilePath m <.> "hs"
happy <- lift $ buildExecutableNamed (PackageName "happy") "happy"
happy <- lift $ buildExecutableNamed (mkPackageName "happy") "happy"
lift . runCommand (output relOutput)
$ progExe happy
["-o", pathOut relOutput, pathIn yFile]
Expand All @@ -521,7 +521,8 @@ search ghc bi cIncludeDirs m srcDir
let xFile = srcDir /> toFilePath m <.> ext
exists xFile
let relOutput = toFilePath m <.> "hs"
alex <- lift $ buildExecutableNamed (PackageName "alex") "alex"
-- TODO: mkPackageName doesn't exist in older ones
alex <- lift $ buildExecutableNamed (mkPackageName "alex") "alex"
lift . runCommand (output relOutput)
$ progExe alex
["-o", pathOut relOutput, pathIn xFile]
Expand Down Expand Up @@ -582,7 +583,7 @@ collectPlainDataFiles desc dir = do
(dataFiles desc)

cppVersion :: Version -> String
cppVersion v = case versionBranch v of
cppVersion v = case versionNumbers v of
(v1:v2:_) -> show v1 ++ if v2 < 10 then '0':show v2 else show v2
_ -> error $ "cppVersion: " ++ display v

Expand Down
6 changes: 4 additions & 2 deletions src/Pier/Build/Package.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Distribution.Version (withinRange)
import Distribution.PackageDescription
import Distribution.PackageDescription.Parse
import Distribution.Compiler
import Distribution.Types.CondTree (CondBranch(..))

import Pier.Build.Stackage
import Pier.Core.Command
Expand Down Expand Up @@ -70,7 +71,7 @@ parseCabalFileInDir dir = do
cabalFile <- findCabalFile dir
cabalContents <- readArtifact cabalFile
-- TODO: better error message when parse fails; and maybe warnings too?
case parsePackageDescription cabalContents of
case parseGenericPackageDescription cabalContents of
ParseFailed err -> error $ show err
ParseOk _ pkg -> return pkg

Expand Down Expand Up @@ -106,7 +107,8 @@ resolve plan flags node
= sconcat
$ condTreeData node :|
[ resolve plan flags t
| (cond,ifTrue,ifFalse) <- condTreeComponents node
| CondBranch cond ifTrue ifFalse
<- condTreeComponents node
, Just t <- [if isTrue plan flags cond
then Just ifTrue
else ifFalse]]
Expand Down
22 changes: 20 additions & 2 deletions src/Pier/Orphans.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-- | All-purpose module for defining orphan instances.
{-# LANGUAGE CPP #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Pier.Orphans () where
Expand All @@ -11,6 +12,9 @@ import Distribution.PackageDescription
import Distribution.Package
import qualified Distribution.Text as Cabal

import Distribution.Version
import Distribution.Utils.ShortText

instance Hashable a => Hashable (Set.Set a) where
hashWithSalt k = hashWithSalt k . Set.toList

Expand All @@ -19,15 +23,29 @@ instance Hashable PackageId
instance Hashable PackageName
instance Hashable ComponentId
instance Hashable UnitId
instance Hashable ShortText
instance Hashable Version

instance FromJSON Version where
parseJSON = withText "Version" simpleParser

instance FromJSONKey Version where
fromJSONKey = cabalKeyTextParser

instance FromJSON PackageName where
parseJSON = withText "PackageName" simpleParser

instance FromJSONKey PackageName where
fromJSONKey = cabalKeyTextParser

instance FromJSON PackageIdentifier where
parseJSON = withText "PackageIdentifier" simpleParser

deriving instance FromJSONKey PackageName

simpleParser :: Cabal.Text a => T.Text -> Parser a
simpleParser t = case Cabal.simpleParse (T.unpack t) of
Just v -> pure v
Nothing -> fail $ "Unable to parse PackageIdentifier: "
++ show t

cabalKeyTextParser :: Cabal.Text a => FromJSONKeyFunction a
cabalKeyTextParser = FromJSONKeyTextParser simpleParser
4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
resolver: lts-9.6
resolver: lts-10.3

packages:
- '.'

ghc-options:
"$locals": -Wall -Werror
"$locals": -Wall

extra-deps:
- shake-0.16

0 comments on commit ee1393c

Please sign in to comment.