Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Other enhancements:
excludes the key being set and includes an `!include` directive.
* Stack's `config set snapshot` command now works with other snapshot values
in addition to snapshot synonymns.
* Add Stack's `config compiler-tools` command to create (when applicable) the
compiler tools directory for the specified compiler version (implies Stack's
`config build-files` command).

Bug fixes:

Expand Down Expand Up @@ -197,7 +200,7 @@ Other enhancements:
documentation.
* `stack sdist` and `stack upload` report the version of Cabal (the library)
being used to check packages.
* Add the `stack config build-files` command to generate (when applicable) a
* Add Stack's `config build-files` command to generate (when applicable) a
Cabal file from a package description in the Hpack format and/or a lock file
for Stack's project-level configuration, without taking any other build steps.

Expand Down
16 changes: 16 additions & 0 deletions doc/commands/config_command.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Available commands:
build-files Generate (when applicable) a Cabal file from a
package description in the Hpack format and/or a lock
file for Stack's project-level configuration.
compiler-tools-bin Create (when applicable) the compiler tools
directory for the specified compiler version (implies
'config build-files').
env Print environment variables for use in a shell.
set Set a key in a configuration file to value.
~~~
Expand All @@ -32,6 +35,19 @@ stack config build-files

without taking any other build steps.

## The `stack config compiler-tools` command

:octicons-tag-24: UNRELEASED

~~~text
stack config compiler-tools
~~~

`stack config compiler-tools` creates (when applicable) the
[compiler tools directory](../topics/stack_root.md#compiler-tools-directory-optional)
for the specified compiler version. Implies Stack's
[`config build-files` command](#the-stack-config-build-files-command).

## The `stack config env` command

~~~text
Expand Down
6 changes: 4 additions & 2 deletions doc/topics/stack_environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ root directory.

## The compiler tools directory

When the directory is required, Stack creates, in the
When the directory is required or requested, Stack creates, in the
[Stack root](stack_root.md#compiler-tools-directory-optional), a compiler tools
directory for the specified compiler version. Command
[`stack path --compiler-tools-bin`](../commands/path_command.md) to see that
Expand All @@ -62,7 +62,9 @@ directory.
compiler's executable file, put a copy of the alternative tool (or a link to
it) in the
[compiler tools directory](stack_root.md#compiler-tools-directory-optional)
for the specified compiler version.
for the specified compiler version. If that directory does not exist, it can
be created with Stack's
[`config compiler-tools` command](../commands/config_command.md#the-stack-config-compiler-tools-command).

## The compiler binary's directory

Expand Down
7 changes: 4 additions & 3 deletions doc/topics/stack_root.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,17 @@ that, in turn, contains a `bin` directory (the compiler tools directory for that
compiler version).

If the compiler tools directory for a specified compiler version does not exist,
and Stack needs that directory, then Stack will create it.
and Stack needs that directory, then Stack will create it. The directory can
also be created using Stack's
[`config compiler-tools` command](../commands/config_command.md#the-stack-config-compiler-tools-command)

In the [Stack environment](stack_environment.md#the-compiler-tools-directory),
the compiler tools directory for the specified compiler version is on the PATH.

For further information see:

* The [Stack environment](stack_environment.md#the-compiler-tools-directory);
* Stack's [`path --compiler-tools-bin` command](../commands/path_command.md);
and
* Stack's [`path --compiler-tools-bin` command](../commands/path_command.md); and
* Stack's
[`build --copy-compiler-tool` command](../commands/build_command.md#-no-copy-compiler-tool-flag).

Expand Down
11 changes: 9 additions & 2 deletions src/Stack/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ import Stack.Build ( buildCmd )
import Stack.BuildInfo ( hpackVersion, versionString' )
import Stack.Clean ( CleanCommand (..), cleanCmd )
import Stack.ConfigCmd
( cfgCmdBuildFiles, cfgCmdBuildFilesName, cfgCmdEnv
, cfgCmdEnvName, cfgCmdName, cfgCmdSet, cfgCmdSetName
( cfgCmdBuildFiles, cfgCmdBuildFilesName, cfgCmdCompilerTools
, cfgCmdCompilerToolsName, cfgCmdEnv, cfgCmdEnvName
, cfgCmdName, cfgCmdSet, cfgCmdSetName
)
import Stack.Constants
( globalFooter, osIsWindows, relFileStack, relFileStackDotExe
Expand Down Expand Up @@ -257,6 +258,12 @@ commandLineHandler currentDir progName mExecutablePath isInterpreter =
-- cfgCmdBuildFiles itself yields nothing of interest.
(withConfig YesReexec . withBuildConfig . cfgCmdBuildFiles)
(pure ())
addCommand'
cfgCmdCompilerToolsName
"Create (when applicable) the compiler tools directory for the \
\specified compiler version (implies 'config build-files')."
(withConfig YesReexec . withDefaultEnvConfig . cfgCmdCompilerTools)
(pure ())
)

docker = addSubCommands'
Expand Down
13 changes: 12 additions & 1 deletion src/Stack/ConfigCmd.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ module Stack.ConfigCmd
, cfgCmdEnvName
, cfgCmdBuildFiles
, cfgCmdBuildFilesName
, cfgCmdCompilerTools
, cfgCmdCompilerToolsName
, cfgCmdName
, yamlContainsInclude
) where
Expand All @@ -33,6 +35,7 @@ import qualified Data.Text as T
import qualified Data.Yaml as Yaml
import Pantry ( loadSnapshot )
import Path ( parent )
import Path.IO ( ensureDir )
import qualified RIO.Map as Map
import RIO.NonEmpty ( nonEmpty )
import qualified RIO.NonEmpty as NE
Expand All @@ -49,7 +52,7 @@ import Stack.Types.ConfigMonoid
)
import Stack.Types.ConfigSetOpts
( CommandScope (..), ConfigCmdSet (..) ,configCmdSetScope )
import Stack.Types.EnvConfig ( EnvConfig )
import Stack.Types.EnvConfig ( EnvConfig, bindirCompilerTools )
import Stack.Types.EnvSettings ( EnvSettings (..) )
import Stack.Types.GHCVariant ( HasGHCVariant )
import Stack.Types.Snapshot ( AbstractSnapshot )
Expand Down Expand Up @@ -337,6 +340,10 @@ cfgCmdEnvName = "env"
cfgCmdBuildFilesName :: String
cfgCmdBuildFilesName = "build-files"

-- | The name of Stack's @config@ command's @compiler-tools-bin@ subcommand.
cfgCmdCompilerToolsName :: String
cfgCmdCompilerToolsName = "compiler-tools"

data EnvVarAction = EVASet !Text | EVAUnset
deriving Show

Expand Down Expand Up @@ -370,3 +377,7 @@ cfgCmdEnv es = do
-- 'Stack.Config.withBuildConfig' that yields the desired actions.
cfgCmdBuildFiles :: () -> RIO BuildConfig ()
cfgCmdBuildFiles () = pure ()

-- | This function takes no settings.
cfgCmdCompilerTools :: () -> RIO EnvConfig ()
cfgCmdCompilerTools () = bindirCompilerTools >>= ensureDir
2 changes: 1 addition & 1 deletion src/Stack/Path.hs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ pathsFromEnvConfig =
, "compiler-bin"
, WithoutHaddocks $ T.pack . toFilePathNoTrailingSep . parent . (.compiler)
)
, ( "Directory containing binaries specific to a particular compiler"
, ( "The compiler tools directory for the specified compiler version."
, "compiler-tools-bin"
, WithoutHaddocks $ T.pack . toFilePathNoTrailingSep . (.toolsDir)
)
Expand Down
Loading