Merge pull request #1054 from chreekat/keter-build-args

Add build-args to keter subcommand
This commit is contained in:
Michael Snoyman 2015-08-11 18:54:45 +03:00
commit 128165c19c
2 changed files with 13 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import System.Process
import Control.Monad
import System.Directory hiding (findFiles)
import Data.Maybe (mapMaybe)
import Data.Monoid
import System.FilePath ((</>))
import qualified Codec.Archive.Tar as Tar
import Control.Exception
@ -27,8 +28,9 @@ run a b = do
keter :: String -- ^ cabal command
-> Bool -- ^ no build?
-> Bool -- ^ no copy to?
-> [String] -- ^ build args
-> IO ()
keter cabal noBuild noCopyTo = do
keter cabal noBuild noCopyTo buildArgs = do
ketercfg <- keterConfig
mvalue <- decodeFile ketercfg
value <-
@ -76,8 +78,11 @@ keter cabal noBuild noCopyTo = do
then do run "stack" ["clean"]
createDirectoryIfMissing True "./dist/bin"
run "stack"
(words "--local-bin-path ./dist/bin build --copy-bins")
else mapM_ (\x -> run cabal [x]) ["clean", "configure", "build"]
((words "--local-bin-path ./dist/bin build --copy-bins")
<> buildArgs)
else do run cabal ["clean"]
run cabal ["configure"]
run cabal ("build" : buildArgs)
_ <- try' $ removeDirectoryRecursive "static/tmp"

View File

@ -70,6 +70,7 @@ data Command = Init { _initBare :: Bool, _initName :: Maybe String, _initDatabas
| Keter
{ _keterNoRebuild :: Bool
, _keterNoCopyTo :: Bool
, _keterBuildArgs :: [String]
}
| Version
deriving (Show, Eq)
@ -106,7 +107,7 @@ main = do
Configure -> cabal ["configure"]
Build es -> touch' >> cabal ("build":es)
Touch -> touch'
Keter{..} -> keter (cabalCommand o) _keterNoRebuild _keterNoCopyTo
Keter{..} -> keter (cabalCommand o) _keterNoRebuild _keterNoCopyTo _keterBuildArgs
Version -> putStrLn ("yesod-bin version: " ++ showVersion Paths_yesod_bin.version)
AddHandler{..} -> addHandler addHandlerRoute addHandlerPattern addHandlerMethods
Test -> cabalTest cabal
@ -189,6 +190,9 @@ keterOptions :: Parser Command
keterOptions = Keter
<$> switch ( long "nobuild" <> short 'n' <> help "Skip rebuilding" )
<*> switch ( long "nocopyto" <> help "Ignore copy-to directive in keter config file" )
<*> optStrToList ( long "build-args" <> help "Build arguments" )
where
optStrToList m = option (words <$> str) $ value [] <> m
defaultRescan :: Int
defaultRescan = 10