on master help sign in
Merge branch 'develop' into eac@readme-fix-local-deploy-commands
commit67ea0cca01061cd4ad617b10ca44c4b355df95a5 authorAli Abrar <aliabrar@gmail.com> dateWed 2 Oct 2019, 12:13 (7 years ago) parentb3243cb5b47749
4 files changed+14−9
lib/command/src/Obelisk/Command/Run.hs+9 skeleton/backend/src/Backend.hs−2 skeleton/common/src/Common/Route.hs+4−6 skeleton/frontend/src/Frontend.hs+1−1
lib/command/src/Obelisk/Command/Run.hs+9
@@ -14,6 +14,7 @@ import qualified Data.List as L
1414import qualified Data.List.NonEmpty as NE
1515import Data.Maybe
1616import qualified Data.Text as T
17+import Distribution.Compiler (CompilerFlavor(..))
1718import Distribution.PackageDescription.Parsec (parseGenericPackageDescription)
1819import Distribution.Parsec.ParseResult (runParseResult)
1920import Distribution.Pretty
@@ -48,6 +49,8 @@ data CabalPackageInfo = CabalPackageInfo
4849 -- ^ List of globally enable extensions of the library component
4950 , _cabalPackageInfo_defaultLanguage :: Maybe Language
5051 -- ^ List of globally set languages of the library component
52+ , _cabalPackageInfo_compilerOptions :: [(CompilerFlavor, [String])]
53+ -- ^ List of compiler-specific options (e.g., the "ghc-options" field of the cabal file)
5154 }
5255
5356-- NOTE: `run` is not polymorphic like the rest because we use StaticPtr to invoke it.
@@ -143,6 +146,7 @@ parseCabalPackage dir = do
143146 defaultExtensions $ libBuildInfo lib
144147 , _cabalPackageInfo_defaultLanguage =
145148 defaultLanguage $ libBuildInfo lib
149+ , _cabalPackageInfo_compilerOptions = options $ libBuildInfo lib
146150 }
147151 Left (_, errors) -> do
148152 putLog Error $ T.pack $ "Failed to parse " <> cabalFp <> ":"
@@ -178,8 +182,13 @@ withGhciScript pkgs f = do
178182 extensionsLine = if extensions == mempty
179183 then ""
180184 else ":set " <> intercalate " " ((("-X" <>) . prettyShow) <$> extensions)
185+ ghcOptions = concat $ mapMaybe (\case (GHC, xs) -> Just xs; _ -> Nothing) $
186+ packageInfos >>= _cabalPackageInfo_compilerOptions
181187 dotGhci = unlines $
182188 [ ":set -i" <> intercalate ":" (packageInfos >>= rootedSourceDirs)
189+ , case ghcOptions of
190+ [] -> ""
191+ xs -> ":set " <> intercalate " " xs
183192 , extensionsLine
184193 , ":set " <> intercalate " " (("-X" <>) . prettyShow <$> language)
185194 , ":load Backend Frontend"
skeleton/backend/src/Backend.hs−2
@@ -1,6 +1,4 @@
1−{-# LANGUAGE EmptyCase #-}
21{-# LANGUAGE FlexibleContexts #-}
3−{-# LANGUAGE LambdaCase #-}
42{-# LANGUAGE RankNTypes #-}
53{-# LANGUAGE TypeFamilies #-}
64module Backend where
skeleton/common/src/Common/Route.hs+4−6
@@ -1,15 +1,13 @@
11{-# LANGUAGE EmptyCase #-}
22{-# LANGUAGE FlexibleContexts #-}
3+{-# LANGUAGE FlexibleInstances #-}
34{-# LANGUAGE GADTs #-}
4−{-# LANGUAGE LambdaCase #-}
5−{-# LANGUAGE RankNTypes #-}
6−{-# LANGUAGE TemplateHaskell #-}
75{-# LANGUAGE KindSignatures #-}
8−{-# LANGUAGE EmptyCase #-}
6+{-# LANGUAGE LambdaCase #-}
97{-# LANGUAGE MultiParamTypeClasses #-}
10−{-# LANGUAGE FlexibleInstances #-}
118{-# LANGUAGE OverloadedStrings #-}
12−
9+{-# LANGUAGE RankNTypes #-}
10+{-# LANGUAGE TemplateHaskell #-}
1311module Common.Route where
1412
1513{- -- You will probably want these imports for composing Encoders.
skeleton/frontend/src/Frontend.hs+1−1
@@ -22,7 +22,7 @@ frontend = Frontend
2222 el "p" $ text $ T.pack commonStuff
2323 elAttr "img" ("src" =: static @"obelisk.jpg") blank
2424 el "div" $ do
25− exampleConfig <- getConfig "common/example"
25+ exampleConfig <- getConfig "common/example"
2626 case exampleConfig of
2727 Nothing -> text "No config file found in config/common/example"
2828 Just s -> text (T.decodeUtf8 s)