aboutsummaryrefslogtreecommitdiff
path: root/src/CabalHelper/Compiletime/Program
diff options
context:
space:
mode:
authorDaniel Gröber <dxld@darkboxed.org>2019-08-06 02:41:02 +0200
committerDaniel Gröber (dxld) <dxld@darkboxed.org>2019-09-17 17:48:26 +0200
commitaad828c48f26ea6febaabf37632b0e45868db895 (patch)
tree365ecc552992717c4e42d651fed8e8aee876f88f /src/CabalHelper/Compiletime/Program
parent25e12596dce80ce2cf3928bbe0b2eac339da8c96 (diff)
Add exported interface for running build-tools
Diffstat (limited to 'src/CabalHelper/Compiletime/Program')
-rw-r--r--src/CabalHelper/Compiletime/Program/CabalInstall.hs33
-rw-r--r--src/CabalHelper/Compiletime/Program/Stack.hs2
2 files changed, 33 insertions, 2 deletions
diff --git a/src/CabalHelper/Compiletime/Program/CabalInstall.hs b/src/CabalHelper/Compiletime/Program/CabalInstall.hs
index 686743b..cce4364 100644
--- a/src/CabalHelper/Compiletime/Program/CabalInstall.hs
+++ b/src/CabalHelper/Compiletime/Program/CabalInstall.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE DataKinds, MultiWayIf, TupleSections #-}
+{-# LANGUAGE DataKinds, MultiWayIf, TupleSections, GADTs #-}
-- cabal-helper: Simple interface to Cabal's configuration state
-- Copyright (C) 2018 Daniel Gröber <cabal-helper@dxld.at>
@@ -312,3 +312,34 @@ cpCompNameToChComponentName cn =
(CP.CompNameExe name) -> ChExeName $ Text.unpack name
(CP.CompNameTest name) -> ChTestName $ Text.unpack name
(CP.CompNameBench name) -> ChBenchName $ Text.unpack name
+
+data CabalInstallCommand
+ = CIConfigure
+ | CIBuild
+
+doCabalInstallCmd
+ :: (QueryEnvI c ('Cabal cpt) -> CallProcessWithCwdAndEnv a)
+ -> QueryEnvI c ('Cabal cpt)
+ -> Maybe FilePath -> CabalInstallCommand -> [String] -> IO a
+doCabalInstallCmd procfn qe mcwd cmd args = do
+ case (cmd, projTypeOfQueryEnv qe) of
+ (CIConfigure, SCabal SCV1) ->
+ run "v1-configure" cabalProjArgs cabalUnitArgs []
+ (CIBuild, SCabal SCV1) ->
+ run "v1-build" cabalProjArgs [] []
+ (_, SCabal SCV2) ->
+ run "v2-build" cabalProjArgs cabalUnitArgs []
+ where
+ Programs{..} = qePrograms qe
+ run cmdarg before aftercmd after = procfn qe mcwd [] cabalProgram $
+ before ++ [cmdarg] ++ aftercmd ++ args ++ after
+
+readCabalInstallCmd
+ :: QueryEnvI c ('Cabal cpt)
+ -> Maybe FilePath -> CabalInstallCommand -> [String] -> IO String
+callCabalInstallCmd
+ :: QueryEnvI c ('Cabal cpt)
+ -> Maybe FilePath -> CabalInstallCommand -> [String] -> IO ()
+
+readCabalInstallCmd = doCabalInstallCmd (\qe -> qeReadProcess qe "")
+callCabalInstallCmd = doCabalInstallCmd qeCallProcess
diff --git a/src/CabalHelper/Compiletime/Program/Stack.hs b/src/CabalHelper/Compiletime/Program/Stack.hs
index 264050a..6f3365f 100644
--- a/src/CabalHelper/Compiletime/Program/Stack.hs
+++ b/src/CabalHelper/Compiletime/Program/Stack.hs
@@ -126,7 +126,7 @@ doStackCmd :: (QueryEnvI c 'Stack -> CallProcessWithCwdAndEnv a)
doStackCmd procfn qe mcwd args =
let Programs{..} = qePrograms qe in
procfn qe mcwd stackEnv stackProgram $
- stackArgsBefore ++ args ++ stackArgsAfter
+ stackProjArgs ++ args ++ stackUnitArgs
readStackCmd :: QueryEnvI c 'Stack -> Maybe FilePath -> [String] -> IO String
callStackCmd :: QueryEnvI c 'Stack -> Maybe FilePath -> [String] -> IO ()