diff options
| author | Daniel Gröber <dxld@darkboxed.org> | 2018-08-26 19:24:03 +0200 | 
|---|---|---|
| committer | Daniel Gröber <dxld@darkboxed.org> | 2018-08-26 19:24:03 +0200 | 
| commit | fbdc40affeeb41c3aaf357cceab9829a6c00e36b (patch) | |
| tree | d4aef97b9397129b7bc29294686e1f62ac3a466f /src/CabalHelper/Compiletime/Types.hs | |
| parent | 095b631701a5eb85544b1c720d0b575b4106ef4a (diff) | |
Remove wrapper, integrate functionality into the library
The use of a wrapper executable to compile the real helper was a design mistake
originally intended to isolate the calling application from a dependency on the
Cabal library completely. This isolation turned out to be rather tedious and
thus was ignored soon, the wrapper remained though.
Due to the way cabal-install installs components of a package into seperate
install trees when using new-install finding the wrapper exe reliably has become
pretty much impossible without huge effort. Hence we remove it and integrate the
functionality into the library instead.
Diffstat (limited to 'src/CabalHelper/Compiletime/Types.hs')
| -rw-r--r-- | src/CabalHelper/Compiletime/Types.hs | 56 | 
1 files changed, 43 insertions, 13 deletions
| diff --git a/src/CabalHelper/Compiletime/Types.hs b/src/CabalHelper/Compiletime/Types.hs index 77c3255..10fe916 100644 --- a/src/CabalHelper/Compiletime/Types.hs +++ b/src/CabalHelper/Compiletime/Types.hs @@ -14,7 +14,8 @@  -- You should have received a copy of the GNU General Public License  -- along with this program.  If not, see <http://www.gnu.org/licenses/>. -{-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DefaultSignatures #-} +{-# LANGUAGE DeriveGeneric, DeriveDataTypeable, DefaultSignatures, +  KindSignatures, ImplicitParams, ConstraintKinds #-}  {-|  Module      : CabalHelper.Compiletime.Types @@ -25,18 +26,47 @@ License     : GPL-3  module CabalHelper.Compiletime.Types where  import Data.Version +import Data.Typeable +import GHC.Generics -data Options = Options { -          oHelp          :: Bool -        , oVerbose       :: Bool -        , oGhcProgram    :: FilePath -        , oGhcPkgProgram :: FilePath -        , oCabalProgram  :: FilePath -        , oCabalVersion  :: Maybe Version -        , oCabalPkgDb    :: Maybe PackageDbDir -} +type Env = (?opts :: CompileOptions) -newtype PackageDbDir = PackageDbDir { unPackageDbDir :: FilePath } +-- | Paths or names of various programs we need. +data Programs = Programs { +      -- | The path to the @cabal@ program. +      cabalProgram  :: FilePath, + +      -- | The path to the @ghc@ program. +      ghcProgram    :: FilePath, + +      -- | The path to the @ghc-pkg@ program. If +      -- not changed it will be derived from the path to 'ghcProgram'. +      ghcPkgProgram :: FilePath +    } deriving (Eq, Ord, Show, Read, Generic, Typeable) + +-- | Default all programs to their unqualified names, i.e. they will be searched +-- for on @PATH@. +defaultPrograms :: Programs +defaultPrograms = Programs "cabal" "ghc" "ghc-pkg" + +data CompileOptions = CompileOptions +    { oVerbose       :: Bool +    , oCabalPkgDb    :: Maybe PackageDbDir +    , oCabalVersion  :: Maybe Version +    , oPrograms      :: Programs +    } -defaultOptions :: Options -defaultOptions = Options False False "ghc" "ghc-pkg" "cabal" Nothing Nothing +oCabalProgram :: Env => FilePath +oCabalProgram = cabalProgram $ oPrograms ?opts + +oGhcProgram :: Env => FilePath +oGhcProgram = ghcProgram $ oPrograms ?opts + +oGhcPkgProgram :: Env => FilePath +oGhcPkgProgram = ghcPkgProgram $ oPrograms ?opts + +defaultCompileOptions :: CompileOptions +defaultCompileOptions = +    CompileOptions False Nothing Nothing defaultPrograms + +newtype PackageDbDir = PackageDbDir { unPackageDbDir :: FilePath } | 
