diff --git a/yesod-bin/Keter.hs b/yesod-bin/Keter.hs index 69bfaeac..3cf021e1 100644 --- a/yesod-bin/Keter.hs +++ b/yesod-bin/Keter.hs @@ -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" diff --git a/yesod-bin/main.hs b/yesod-bin/main.hs index ae4bc012..c4292153 100755 --- a/yesod-bin/main.hs +++ b/yesod-bin/main.hs @@ -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