Skip to content

Commit

Permalink
A few "stack path" cleanups and additions
Browse files Browse the repository at this point in the history
1) Rename the new "--programs-path" to "--programs"
2) Rename the new "--compiler-path" to "--compiler"
3) Add support for the deprecated "--ghc-paths" option
4) Add "--compiler-bin", yielding bin folder
  • Loading branch information
mgsloan committed Apr 13, 2016
1 parent 1ff3a7e commit 2f7755d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
6 changes: 3 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Behavior changes:
* `stack init` now ignores symlinks when searching for cabal files. It also now
ignores any directory that begins with `.` (as well as `dist` dirs) - before
it would only ignore `.git`, `.stack-work`, and `dist`.
* The `stack path --ghc-paths` option is renamed to `--programs-path`.
`--compiler-path` is added, which points directly at the compiler used in
the current project.
* The stack executable is no longer built with `-rtsopts`. Before, when
`-rtsopts` was enabled, stack would process `+RTS` options even when intended
for some other program, such as when used with `stack exec -- prog +RTS`.
See [#2022](https://github.com/commercialhaskell/stack/issues/2022).
* The `stack path --ghc-paths` option is deprecated and renamed to `--programs`.
`--compiler` is added, which points directly at the compiler used in
the current project. `--compiler-bin` points to the compiler's bin dir.
* For consistency with the `$STACK_ROOT` environment variable, the
`stack path --global-stack-root` flag and the `global-stack-root` field
in the output of `stack path` are being deprecated and replaced with the
Expand Down
11 changes: 6 additions & 5 deletions doc/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,7 @@ modified version of a dependency that hasn't yet been released upstream.

Please note that when adding upstream packages directly to your project it is
important to distinguish _local packages_ from the upstream _dependency
packages_. Otherwise you may have trouble running `stack GHCi`. See
packages_. Otherwise you may have trouble running `stack GHCi`. See
[stack.yaml documentation](yaml_configuration.md#packages) for more details.

## Flags and GHC options
Expand Down Expand Up @@ -1474,8 +1474,9 @@ stack-root: /home/michael/.stack
project-root: /home/michael/wai
config-location: /home/michael/wai/stack.yaml
bin-path: /home/michael/.stack/snapshots/x86_64-linux/lts-2.17/7.8.4/bin:/home/michael/.stack/programs/x86_64-linux/ghc-7.8.4/bin:/home/michael/.stack/programs/x86_64-linux/ghc-7.10.2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
programs-path: /home/michael/.stack/programs/x86_64-linux
compiler-path: /home/michael/.stack/programs/x86_64-linux/ghc-7.8.4/bin/ghc
programs: /home/michael/.stack/programs/x86_64-linux
compiler: /home/michael/.stack/programs/x86_64-linux/ghc-7.8.4/bin/ghc
compiler-bin: /home/michael/.stack/programs/x86_64-linux/ghc-7.8.4/bin
local-bin-path: /home/michael/.local/bin
extra-include-dirs:
extra-library-dirs:
Expand All @@ -1496,7 +1497,7 @@ these keys you're interested in, which can be convenient for scripting. As a
simple example, let's find out which versions of GHC are installed locally:

```
michael@d30748af6d3d:~/wai$ ls $(stack path --programs-path)/*.installed
michael@d30748af6d3d:~/wai$ ls $(stack path --programs)/*.installed
/home/michael/.stack/programs/x86_64-linux/ghc-7.10.2.installed
/home/michael/.stack/programs/x86_64-linux/ghc-7.8.4.installed
```
Expand All @@ -1509,7 +1510,7 @@ what needs to be removed:
1. The stack executable itself
2. The stack root, e.g. `$HOME/.stack` on non-Windows systems.
* See `stack path --stack-root`
* On Windows, you will also need to delete `stack path --programs-paths`
* On Windows, you will also need to delete `stack path --programs`
3. Any local `.stack-work` directories inside a project

## exec
Expand Down
41 changes: 26 additions & 15 deletions src/main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -536,15 +536,14 @@ pathCmd keys go =
localroot <- installationRootLocal
distDir <- distRelativeDir
hpcDir <- hpcReportDir
compilerPath <- getCompilerPath =<< getWhichCompiler
when (T.pack deprecatedStackRootOptionName `elem` keys) $
liftIO $ forM_
[ ""
, "'--" <> deprecatedStackRootOptionName <> "' will be removed in a future release."
, "Please use '--" <> stackRootOptionName <> "' instead."
, ""
]
(hPutStrLn stderr)
compiler <- getCompilerPath =<< getWhichCompiler
let deprecated = filter ((`elem` keys) . fst) deprecatedPathKeys
liftIO $ forM_ deprecated $ \(oldOption, newOption) -> T.hPutStrLn stderr $ T.unlines
[ ""
, "'--" <> oldOption <> "' will be removed in a future release."
, "Please use '--" <> newOption <> "' instead."
, ""
]
forM_
-- filter the chosen paths in flags (keys),
-- or show all of them if no specific paths chosen.
Expand All @@ -571,7 +570,7 @@ pathCmd keys go =
distDir
hpcDir
extra
compilerPath))))
compiler))))

-- | Passed to all the path printers as a source of info.
data PathInfo = PathInfo
Expand All @@ -585,7 +584,7 @@ data PathInfo = PathInfo
, piDistDir :: Path Rel Dir
, piHpcDir :: Path Abs Dir
, piExtraDbs :: [Path Abs Dir]
, piCompilerPath :: Path Abs File
, piCompiler :: Path Abs File
}

-- | The paths of interest to a user. The first tuple string is used
Expand All @@ -612,11 +611,14 @@ paths =
, "bin-path"
, T.pack . intercalate [searchPathSeparator] . eoPath . piEnvOverride )
, ( "Install location for GHC and other core tools"
, "programs-path"
, "programs"
, T.pack . toFilePathNoTrailingSep . configLocalPrograms . bcConfig . piBuildConfig )
, ( "Compiler (e.g. ghc)"
, "compiler-path"
, T.pack . toFilePath . piCompilerPath )
, ( "Compiler binary (e.g. ghc)"
, "compiler"
, T.pack . toFilePath . piCompiler )
, ( "Directory containing the compiler binary (e.g. ghc)"
, "compiler-bin"
, T.pack . toFilePathNoTrailingSep . parent . piCompiler )
, ( "Local bin path where stack installs executables"
, "local-bin-path"
, T.pack . toFilePathNoTrailingSep . configLocalBin . bcConfig . piBuildConfig )
Expand Down Expand Up @@ -656,11 +658,20 @@ paths =
, ( "Where HPC reports and tix files are stored"
, "local-hpc-root"
, T.pack . toFilePathNoTrailingSep . piHpcDir )
, ( "DEPRECATED: Use '--programs' instead"
, "ghc-paths"
, T.pack . toFilePathNoTrailingSep . configLocalPrograms . bcConfig . piBuildConfig )
, ( "DEPRECATED: Use '--" <> stackRootOptionName <> "' instead"
, T.pack deprecatedStackRootOptionName
, T.pack . toFilePathNoTrailingSep . configStackRoot . bcConfig . piBuildConfig )
]

deprecatedPathKeys :: [(Text, Text)]
deprecatedPathKeys =
[ (T.pack deprecatedStackRootOptionName, T.pack stackRootOptionName)
, ("ghc-paths", "programs")
]

data SetupCmdOpts = SetupCmdOpts
{ scoCompilerVersion :: !(Maybe CompilerVersion)
, scoForceReinstall :: !Bool
Expand Down

0 comments on commit 2f7755d

Please sign in to comment.