Skip to content

Commit

Permalink
Add --build-path
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Sep 29, 2020
1 parent cc03409 commit dc27ad3
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/App/Commands/Options/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import qualified Antiope.Env as AWS
data SyncToArchiveOptions = SyncToArchiveOptions
{ region :: Region
, archiveUri :: Location
, buildPath :: FilePath
, storePath :: FilePath
, storePathHash :: Maybe String
, threads :: Int
Expand All @@ -21,6 +22,7 @@ data SyncToArchiveOptions = SyncToArchiveOptions
data SyncFromArchiveOptions = SyncFromArchiveOptions
{ region :: Region
, archiveUris :: [Location]
, buildPath :: FilePath
, storePath :: FilePath
, storePathHash :: Maybe String
, threads :: Int
Expand Down
14 changes: 10 additions & 4 deletions src/App/Commands/SyncFromArchive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Antiope.Env (mkEnv)
import Antiope.Options.Applicative
import App.Commands.Options.Parser (text)
import App.Commands.Options.Types (SyncFromArchiveOptions (SyncFromArchiveOptions))
import App.Static (cabalDirectory)
import Control.Applicative
import Control.Lens hiding ((<.>))
import Control.Monad (unless, void, when)
Expand All @@ -34,6 +33,7 @@ import Options.Applicative hiding (columns)
import System.Directory (createDirectoryIfMissing, doesDirectoryExist)

import qualified App.Commands.Options.Types as Z
import qualified App.Static as AS
import qualified Control.Concurrent.STM as STM
import qualified Data.ByteString.Char8 as C8
import qualified Data.ByteString.Lazy as LBS
Expand Down Expand Up @@ -81,7 +81,7 @@ runSyncFromArchive opts = do
CIO.putStrLn $ "Threads: " <> tshow threads
CIO.putStrLn $ "AWS Log level: " <> tshow awsLogLevel

mbPlan <- Z.loadPlan
mbPlan <- Z.loadPlan $ opts ^. the @"buildPath"

case mbPlan of
Right planJson -> do
Expand Down Expand Up @@ -213,11 +213,17 @@ optsSyncFromArchive = SyncFromArchiveOptions
<> metavar "S3_URI"
)
)
<*> strOption
( long "build-path"
<> help ("Path to cabal build directory. Defaults to " <> show AS.buildPath)
<> metavar "DIRECTORY"
<> value AS.buildPath
)
<*> strOption
( long "store-path"
<> help "Path to cabal store"
<> help ("Path to cabal store. Defaults to " <> show AS.cabalDirectory)
<> metavar "DIRECTORY"
<> value (cabalDirectory </> "store")
<> value (AS.cabalDirectory </> "store")
)
<*> optional
( strOption
Expand Down
15 changes: 11 additions & 4 deletions src/App/Commands/SyncToArchive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import Antiope.Env (mkEnv)
import Antiope.Options.Applicative
import App.Commands.Options.Parser (text)
import App.Commands.Options.Types (SyncToArchiveOptions (SyncToArchiveOptions))
import App.Static (cabalDirectory)
import Control.Applicative
import Control.Lens hiding ((<.>))
import Control.Monad (filterM, unless, when)
Expand All @@ -33,6 +32,7 @@ import Options.Applicative hiding (columns)
import System.Directory (doesDirectoryExist)

import qualified App.Commands.Options.Types as Z
import qualified App.Static as AS
import qualified Control.Concurrent.STM as STM
import qualified Data.ByteString.Lazy as LBS
import qualified Data.ByteString.Lazy.Char8 as LC8
Expand Down Expand Up @@ -76,7 +76,8 @@ runSyncToArchive opts = do

tEarlyExit <- STM.newTVarIO False

mbPlan <- Z.loadPlan
mbPlan <- Z.loadPlan $ opts ^. the @"buildPath"

case mbPlan of
Right planJson -> do
compilerContextResult <- runExceptT $ Z.mkCompilerContext planJson
Expand Down Expand Up @@ -172,13 +173,19 @@ optsSyncToArchive = SyncToArchiveOptions
( long "archive-uri"
<> help "Archive URI to sync to"
<> metavar "S3_URI"
<> value (Local $ cabalDirectory </> "archive")
<> value (Local $ AS.cabalDirectory </> "archive")
)
<*> strOption
( long "build-path"
<> help ("Path to cabal build directory. Defaults to " <> show AS.buildPath)
<> metavar "DIRECTORY"
<> value AS.buildPath
)
<*> strOption
( long "store-path"
<> help "Path to cabal store"
<> metavar "DIRECTORY"
<> value (cabalDirectory </> "store")
<> value (AS.cabalDirectory </> "store")
)
<*> optional
( strOption
Expand Down
3 changes: 3 additions & 0 deletions src/App/Static.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ import qualified App.Static.Windows as W

cabalDirectory :: FilePath
cabalDirectory = if S.isPosix then P.cabalDirectory else W.cabalDirectory

buildPath :: FilePath
buildPath = "dist-newstyle"
4 changes: 2 additions & 2 deletions src/HaskellWorks/CabalCache/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ getPackages basePath planJson = forM packages (mkPackageInfo basePath compilerId
packages :: [Z.Package]
packages = planJson ^. the @"installPlan"

loadPlan :: IO (Either AppError Z.PlanJson)
loadPlan = (first fromString . eitherDecode) <$> LBS.readFile ("dist-newstyle" </> "cache" </> "plan.json")
loadPlan :: FilePath -> IO (Either AppError Z.PlanJson)
loadPlan buildPath = (first fromString . eitherDecode) <$> LBS.readFile (buildPath </> "cache" </> "plan.json")

-------------------------------------------------------------------------------
mkPackageInfo :: FilePath -> Z.CompilerId -> Z.Package -> IO PackageInfo
Expand Down

0 comments on commit dc27ad3

Please sign in to comment.