Skip to content

Commit

Permalink
Provide stack copy, deprecate stack install #569
Browse files Browse the repository at this point in the history
  • Loading branch information
snoyberg committed Jul 15, 2015
1 parent c5b9856 commit 8c07cc4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ executePlan menv bopts baseConfigOpts locals sourceMap plan = do
unless (Map.null destToInstalled) $ $logInfo ""
forM_ (Map.toList destToInstalled) $ \(dest, executables) -> do
$logInfo $ T.concat
[ "Installed executables to "
[ "Copied executables to "
, T.pack dest
, ":"]
forM_ executables $ \exe -> $logInfo $ T.append "- " exe
Expand Down
28 changes: 21 additions & 7 deletions src/main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ main = withInterpreterArgs stackProgName $ \args isInterpreter ->
"Build the project(s) in this directory/configuration"
(buildCmd DoNothing)
(buildOptsParser Build)
addCommand "copy"
"Build executables and copy to a user path"
copyCmd
(buildOptsParser Build)
addCommand "install"
"Build executables and install to a user path"
"DEPRECATED: Use stack copy instead"
installCmd
(buildOptsParser Build)
addCommand "test"
Expand Down Expand Up @@ -486,22 +490,32 @@ cleanCmd :: () -> GlobalOpts -> IO ()
cleanCmd () go = withBuildConfig go ThrowException clean

-- | Helper for build and install commands
buildCmdHelper :: NoBuildConfigStrategy -> FinalAction -> BuildOpts -> GlobalOpts -> IO ()
buildCmdHelper strat finalAction opts go
buildCmdHelper :: StackT EnvConfig IO () -- ^ do before build
-> NoBuildConfigStrategy -> FinalAction -> BuildOpts -> GlobalOpts -> IO ()
buildCmdHelper beforeBuild strat finalAction opts go
| boptsFileWatch opts = fileWatch inner
| otherwise = inner $ const $ return ()
where
inner setLocalFiles =
withBuildConfig go strat $
inner setLocalFiles = withBuildConfig go strat $ do
beforeBuild
Stack.Build.build setLocalFiles opts { boptsFinalAction = finalAction }

-- | Build the project.
buildCmd :: FinalAction -> BuildOpts -> GlobalOpts -> IO ()
buildCmd = buildCmdHelper ThrowException
buildCmd = buildCmdHelper (return ()) ThrowException

-- | Install
installCmd :: BuildOpts -> GlobalOpts -> IO ()
installCmd opts = buildCmdHelper ExecStrategy DoNothing opts { boptsInstallExes = True }
installCmd opts =
buildCmdHelper warning ExecStrategy DoNothing opts { boptsInstallExes = True }
where
warning = do
$logWarn "NOTE: stack is not a package manager"
$logWarn "The install command is only used to copy executables to a destination directory, not manage them"
$logWarn "You probably want to use 'stack copy' for clarity"

copyCmd :: BuildOpts -> GlobalOpts -> IO ()
copyCmd opts = buildCmdHelper (return ()) ExecStrategy DoNothing opts { boptsInstallExes = True }

-- | Unpack packages to the filesystem
unpackCmd :: [String] -> GlobalOpts -> IO ()
Expand Down

0 comments on commit 8c07cc4

Please sign in to comment.