Skip to content

Commit

Permalink
Merge branch 'master' into sig-sign-sdist-and-upload-sign
Browse files Browse the repository at this point in the history
* master: (96 commits)
  Revert "Additional helper to get project config dir"
  Additional helper to get project config dir
  Add a few items to ChangeLog.md
  Add stack build options to stack ghci #1186
  Always build exes, due to cabal copy limitation
  Ported stack_and_ghcjs wiki page to doc
  release script: fix compile warnings
  Fix/add documentation for bcWorkDir and workDirRel
  Organize Stack.Types.Config
  Remove unused functions from Stack.Types.Config
  Fix building tests/benches in some circumstances
  Refactor generateHaddockIndex
  Enhance documentation for Stack.Build.Haddock
  Fix haddock generation
  Enhance documentation for System.Process.Read
  Enhance documentation for System.Process.Run
  Refactorings using mapMaybeM, forMaybeM and forMaybeA
  quite a few cosmetic improvements
  Enhance haddocks for Stack.Build.Execute
  Revert "Only install exes when they're built"
  ...
  • Loading branch information
dysinger committed Nov 13, 2015
2 parents 57d787e + f8d0129 commit a1a5960
Show file tree
Hide file tree
Showing 72 changed files with 2,180 additions and 1,569 deletions.
12 changes: 10 additions & 2 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Major changes:

* GHCJS can now be used with stackage snapshots.
* GHCJS can now be used with stackage snapshots via the new `compiler` field.
* Windows installers are now available:
[download them here](https://github.com/commercialhaskell/stack/blob/release/doc/install_and_upgrade.md#windows) [#613](https://github.com/commercialhaskell/stack/issues/613)

Expand All @@ -13,11 +13,19 @@ Other enhancements:
* Added a `stack config set resolver RESOLVER` command. Part of work on [#115](https://github.com/commercialhaskell/stack/issues/115)
* `stack setup` can now install GHCJS on windows. See [#1145](https://github.com/commercialhaskell/stack/issues/1145) and [#749](https://github.com/commercialhaskell/stack/issues/749)
* `stack hpc report` command added, which generates reports for HPC tix files
* `stack ghci` now accepts all the flags accepted by `stack build`. See [#1186](https://github.com/commercialhaskell/stack/issues/1186)
* `stack ghci` builds the project before launching GHCi. If the build fails, optimistically launch GHCi anyway. Use `stack ghci --no-build` option to disable [#1065](https://github.com/commercialhaskell/stack/issues/1065)
* `stack ghci` now detects and warns about various circumstances where it is liable to fail. See [#1270](https://github.com/commercialhaskell/stack/issues/1270)
* Added `require-docker-version` configuration option
* Packages will now usually be built along with their tests and benchmarks. See [#1166](https://github.com/commercialhaskell/stack/issues/1166)

Bug fixes:

* Haddocks not copied for dependencies [#1105](https://github.com/commercialhaskell/stack/issues/1105)
* Fix: Haddocks not copied for dependencies [#1105](https://github.com/commercialhaskell/stack/issues/1105)
* Fix: Global options did not work consistently after subcommand [#519](https://github.com/commercialhaskell/stack/issues/519)
* Fix: 'stack ghci' doesn't notice that a module got deleted [#1180](https://github.com/commercialhaskell/stack/issues/1180)
* Rebuild when cabal file is changed
* Fix: Paths in GHC warnings not canonicalized, nor those for packages in subdirectories or outside the project root [#1259](https://github.com/commercialhaskell/stack/issues/1259)

## v0.1.6.0

Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015, stack
Copyright (c) 2015, Stack contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -15,7 +15,7 @@ modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DISCLAIMED. IN NO EVENT SHALL STACK CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## The Haskell Tool Stack

[![Build Status](https://travis-ci.org/commercialhaskell/stack.svg?branch=master)](https://travis-ci.org/commercialhaskell/stack)
[![Windows build status](https://ci.appveyor.com/api/projects/status/github/commercialhaskell/stack)](https://ci.appveyor.com/project/snoyberg/stack)
[![Windows build status](https://ci.appveyor.com/api/projects/status/c1c7uvmw6x1dupcl?svg=true)](https://ci.appveyor.com/project/snoyberg/stack)
[![Release](https://img.shields.io/github/release/commercialhaskell/stack.svg)](https://github.com/commercialhaskell/stack/releases)

`stack` is a cross-platform program for developing Haskell
Expand Down
5 changes: 3 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cache:
- "c:\\sr" # stack root, short paths == less problems
# Disabled cache in hope of improving reliability of AppVeyor builds
#cache:
#- "c:\\sr" # stack root, short paths == less problems

build: off

Expand Down
2 changes: 1 addition & 1 deletion doc/GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ understand why rebuilding may occur at different points.
Let's look at a subset of the `stack --help` output:

```
build Build the project(s) in this directory/configuration
build Build the package(s) in this directory/configuration
install Shortcut for 'build --copy-bins'
test Shortcut for 'build --test'
bench Shortcut for 'build --bench'
Expand Down
4 changes: 1 addition & 3 deletions doc/dependency_visualization.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
You can use stack to visualize the dependencies between your projects and optionally also external dependencies.
You can use stack to visualize the dependencies between your packages and optionally also external dependencies.

As an example, let's look at `wreq`:

Expand Down Expand Up @@ -39,5 +39,3 @@ and pass in options to `dot` or use another graph layout engine like `twopi`:
$ stack dot --external --prune base,lens,wreq-examples,http-client,aeson,tls,http-client-tls,exceptions | twopi -Groot=wreq -Goverlap=false -Tpng -o wreq_pruned.png
```
[![wreq_pruned](https://cloud.githubusercontent.com/assets/591567/8495538/9fae1184-216e-11e5-9931-99e6147f8aed.png)](https://cloud.githubusercontent.com/assets/591567/8495538/9fae1184-216e-11e5-9931-99e6147f8aed.png)


4 changes: 4 additions & 0 deletions doc/docker_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ otherwise noted.
# When the Docker Engine is remote (accessed by tcp), defaults to false.
set-user: true

# Require the version of the Docker client to be within the specified
# Cabal-style version range (e.g., ">= 1.6.0 && < 1.9.0")
require-docker-version: "any"

Image Repositories
-------------------------------------------------------------------------------

Expand Down
4 changes: 4 additions & 0 deletions doc/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,7 @@ collect2: error: ld returned 1 exit status
/home/philip/.stack/programs/x86_64-linux/ghc-7.10.1/bin/runghc-7.10.1 -package=Cabal-1.22.2.0 -clear-package-db -global-package-db /home/philip/tmp/Setup.hs --builddir=dist-stack/x86_64-linux/Cabal-1.22.2.0/ build
Process exited with code: ExitFailure 1
```
#### Where does the output from `--ghc-options=-ddump-splices` (and other `-ddump*` options) go?
These are written to `*.dump-*` files inside the package's `.stack-work` directory.
10 changes: 5 additions & 5 deletions doc/nonstandard_project_init.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Introduction
The purpose of this page is to collect information about issues that arise when users either have an existing cabal project or another nonstandard setup such as a private hackage database.
The purpose of this page is to collect information about issues that arise when users either have an existing cabal project or another nonstandard setup such as a private hackage database.

# Using a Cabal File
New users may be confused by the fact that you must add dependencies to the projects cabal file, even in the case when you have already listed the package in the `stack.yaml`. In most cases, dependencies for your project that are in the Stackage snapshot need *only* be added to the cabal file. stack makes heavy use of Cabal the library under the hood. In general, your stack packages should also end up being valid cabal-install packages.
New users may be confused by the fact that you must add dependencies to the package's cabal file, even in the case when you have already listed the package in the `stack.yaml`. In most cases, dependencies for your package that are in the Stackage snapshot need *only* be added to the cabal file. stack makes heavy use of Cabal the library under the hood. In general, your stack packages should also end up being valid cabal-install packages.

## Issues Referenced
- https://github.com/commercialhaskell/stack/issues/105

# Passing Flags to Cabal

Any build command, `bench`, `install`, `haddock`, `test`, etc. takes a `--flag` option which passes flags to cabal. Another way to do this is using the flags field in a `stack.yaml`, with the option to specify flags on a per project basis.
Any build command, `bench`, `install`, `haddock`, `test`, etc. takes a `--flag` option which passes flags to cabal. Another way to do this is using the flags field in a `stack.yaml`, with the option to specify flags on a per package basis.

As an example, in a `stack.yaml` for multi-package project with packages `foo`, `bar`, `baz`:

Expand All @@ -25,7 +25,7 @@ flags:

It is also possible to pass the same flag to multiple packages, i.e. `stack build --flag *:necessary`

Currently one needs to list all of your modules that interpret flags in the `other-modules` section of a cabal file. `cabal-install` has a different behavior currently and doesn't require that the modules be listed. This may change in a future release.
Currently one needs to list all of your modules that interpret flags in the `other-modules` section of a cabal file. `cabal-install` has a different behavior currently and doesn't require that the modules be listed. This may change in a future release.


## Issues Referenced
Expand Down Expand Up @@ -87,7 +87,7 @@ Currently WIP?
- https://github.com/commercialhaskell/stack/issues/137

# Intra-package Targets
stack supports intra-package targets, similar to `cabal build COMPONENTS` for situations when you don't want to build every target inside your package.
stack supports intra-package targets, similar to `cabal build COMPONENTS` for situations when you don't want to build every target inside your package.

Example:
```
Expand Down
2 changes: 1 addition & 1 deletion doc/shell_autocompletion.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Note: if you installed a package for you Linux distribution, the bash completion
file was automatically installed (you may need the `bash-completion` package to
have it take effect).

The following adds support for shell tab completion for standard Stack arguments, although completion for filenames and executables etc. within stack is still lacking (see [issue 82](https://github.com/commercialhaskell/stack/issues/832)).
The following adds support for shell tab completion for standard Stack arguments, although completion for filenames and executables etc. within stack is still lacking (see [issue 823](https://github.com/commercialhaskell/stack/issues/832)).

### for bash users

Expand Down
75 changes: 75 additions & 0 deletions doc/stack_and_ghcjs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Stack & GHCJS

To set up and use GHCJS with stack, you should place GHCJS `resolver` in your project's `stack.yaml` (see instructions for [old base](#ghcjs-old-base) and [`master` - a.k.a. improved base](#ghcjs-master-aka-improved-base)). Once this has been done, Stack will use GHCJS for most commands, with the exception of `ghc`, `runghc` and `ide`. (Support for `ghc` and `runghc` will likely be added before the next release - see [#1054](https://github.com/commercialhaskell/stack/issues/1054)).

After creating a `stack.yaml`, which specifies that ghcjs is to be used (see below), you can have Stack automatically set up and boot GHCJS. Stack must be newer than `0.1.6`:

```
$ stack setup
```

(this will take a long time)

## Using a stackage snapshot

The configurations below use a compiler resolver, which means that you can't use packages from a stackage snapshot. The latest development version (which will probably be released as `0.1.7`) also supports using GHCJS with a stackage snapshot, via a `compiler` field. To use the latest development version, do the following:

```
$ stack upgrade --git
```

For example, the old-base configuration looks like this:

```yaml
resolver: lts-3.10
compiler: ghcjs-0.1.0.20150924_ghc-7.10.2
compiler-check: match-exact
```
You can also build existing stack projects which target GHC and instead build them with GHCJS. To do this, invoke stack like this: `stack build --compiler ghcjs-0.1.0.20150924_ghc-7.10.2`

## Example Configurations

### GHCJS (old base)

You can use this resolver for GHCJS (old base) in your `stack.yaml`:

```yaml
resolver: ghcjs-0.1.0.20150924_ghc-7.10.2
compiler-check: match-exact
```

### GHCJS `master` (a.k.a. improved base)

To use the master branch, a.k.a improved base, add the following to your `stack.yaml`:

```yaml
resolver: ghcjs-0.2.0.20151001_ghc-7.10.2
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.0.20151001_ghc-7.10.2:
url: "https://github.com/fizruk/ghcjs/releases/download/v0.2.0.20151001/ghcjs-0.2.0.20151001.tar.gz"
```

or for the 2015-10-29 master branch
```yaml
resolver: ghcjs-0.2.0.20151029_ghc-7.10.2
compiler-check: match-exact
setup-info:
ghcjs:
source:
ghcjs-0.2.0.20151029_ghc-7.10.2:
url: "https://github.com/nrolland/ghcjs/releases/download/v0.2.0.20151029/ghcjs-0.2.0.20151029.tar.gz"
```

### Custom installed GHCJS (development branch)

In order to use a GHCJS installed on your path, just add the following to your `stack.yaml`:

```yaml
resolver: ghcjs-0.2.0_ghc-7.10.2
```

(Or, `ghcjs-0.1.0_ghc-7.10.2` if you are working with an older version)
34 changes: 25 additions & 9 deletions doc/yaml_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Non-project config options may go in the global config (`/etc/stack/config.yaml`

### docker

See [Docker configuration](Docker#configuration).
See [Docker configuration](https://github.com/commercialhaskell/stack/blob/release/doc/docker_integration.md).

### connection-count

Expand Down Expand Up @@ -222,6 +222,23 @@ Specifies how the compiler version in the resolver is matched against concrete v
* `match-exact`: the entire version number must match precisely
* `newer-minor`: the third component can be increased, e.g. if your resolver is `ghc-7.10.1`, then 7.10.2 will also be allowed. This was the default up through stack 0.1.3

### compiler

(Since 0.1.7)

Overrides the compiler version in the resolver. Note that the `compiler-check`
flag also applies to the version numbers. This uses the same syntax as compiler
resolvers like `ghc-7.10.2` or `ghcjs-0.1.0.20150924_ghc-7.10.2` (version used
for the 'old-base' version of GHCJS). While it's useful to override the
compiler for a variety of reasons, the main usecase is to use GHCJS with a
stackage snapshot, like this:

```yaml
resolver: lts-3.10
compiler: ghcjs-0.1.0.20150924_ghc-7.10.2
compiler-check: match-exact
```

### ghc-options

(Since 0.1.4)
Expand Down Expand Up @@ -306,15 +323,14 @@ modify-code-page: false

(Since 0.1.6)

Decide whether a custom `Setup.hs` script should be run with an explicit list
of dependencies based on the dependencies of the package itself, or simply
provided the global package database. This option is most often needed when
overriding packages in the global database, see [issue #1110](https://github.com/commercialhaskell/stack/issues/1110).

Setting the list explicitly can help when a Setup.hs depends on packages in the
local package database. For more information on that case, see [issue #897](https://github.com/commercialhaskell/stack/issues/897).
Decide whether a custom `Setup.hs` script should be run with an explicit list of
dependencies, based on the dependencies of the package itself. It associates the
name of a local package with a boolean. When it's `true`, the `Setup.hs` script
is built with an explicit list of packages. When it's `false` (default), the
`Setup.hs` script is built without access to the local DB, but can access any
package in the snapshot / global DB.

Note that in the future, this should all disappear once Cabal provides full
Note that in the future, this will be unnecessary, once Cabal provides full
support for explicit Setup.hs dependencies.

```yaml
Expand Down
2 changes: 0 additions & 2 deletions etc/scripts/release.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import System.Environment
import System.Directory
import System.IO.Error
import System.Process
import System.Exit

import qualified Codec.Archive.Tar as Tar
import qualified Codec.Archive.Zip as Zip
Expand Down Expand Up @@ -62,7 +61,6 @@ main =
gProjectRoot = "" -- Set to real value velow.
global0 = foldl (flip id) Global{..} flags
-- Need to get paths after options since the '--arch' argument can effect them.
localInstallRoot' <- getStackPath global0 "local-install-root"
projectRoot' <- getStackPath global0 "project-root"
let global = global0
{ gProjectRoot = projectRoot' }
Expand Down
1 change: 1 addition & 0 deletions src/Control/Concurrent/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Stack.Types

data ActionType
= ATBuild
| ATBuildFinal
| ATFinal
deriving (Show, Eq, Ord)
data ActionId = ActionId !PackageIdentifier !ActionType
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Attoparsec/Args.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ data EscapingMode

-- | Parse arguments using 'argsParser'.
parseArgs :: EscapingMode -> Text -> Either String [String]
parseArgs mode t = P.parseOnly (argsParser mode) t
parseArgs mode = P.parseOnly (argsParser mode)

-- | A basic argument parser. It supports space-separated text, and
-- string quotation with identity escaping: \x -> x.
Expand Down
26 changes: 14 additions & 12 deletions src/Data/Binary/VersionTagged.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,53 +25,55 @@ import Data.Binary (Binary (..))
import Data.Binary.Get (ByteOffset)
import Data.Binary.Tagged (HasStructuralInfo, HasSemanticVersion)
import qualified Data.Binary.Tagged as BinaryTagged
import Data.Monoid ((<>))
import Data.Typeable (Typeable)
import Control.Exception.Enclosed (tryAnyDeep)
import System.FilePath (takeDirectory)
import System.Directory (createDirectoryIfMissing)
import Path
import Path.IO (createTree)
import qualified Data.Text as T

type BinarySchema a = (Binary a, NFData a, HasStructuralInfo a, HasSemanticVersion a)

-- | Write to the given file, with a binary-tagged tag.
taggedEncodeFile :: (BinarySchema a, MonadIO m)
=> FilePath
=> Path Abs File
-> a
-> m ()
taggedEncodeFile fp x = liftIO $ do
createDirectoryIfMissing True $ takeDirectory fp
BinaryTagged.taggedEncodeFile fp x
createTree (parent fp)
BinaryTagged.taggedEncodeFile (toFilePath fp) x

-- | Read from the given file. If the read fails, run the given action and
-- write that back to the file. Always starts the file off with the version
-- tag.
taggedDecodeOrLoad :: (BinarySchema a, MonadIO m, MonadLogger m)
=> FilePath
=> Path Abs File
-> m a
-> m a
taggedDecodeOrLoad fp mx = do
$logDebug $ T.pack $ "Trying to decode " ++ fp
let fpt = T.pack (toFilePath fp)
$logDebug $ "Trying to decode " <> fpt
eres <- decodeFileOrFailDeep fp
case eres of
Left _ -> do
$logDebug $ T.pack $ "Failure decoding " ++ fp
$logDebug $ "Failure decoding " <> fpt
x <- mx
taggedEncodeFile fp x
return x
Right x -> do
$logDebug $ T.pack $ "Success decoding " ++ fp
$logDebug $ "Success decoding " <> fpt
return x

-- | Ensure that there are no lurking exceptions deep inside the parsed
-- value... because that happens unfortunately. See
-- https://github.com/commercialhaskell/stack/issues/554
decodeFileOrFailDeep :: (BinarySchema a, MonadIO m, MonadThrow n)
=> FilePath
=> Path loc File
-> m (n a)
decodeFileOrFailDeep fp = liftIO $ fmap (either throwM return) $ tryAnyDeep $ do
eres <- BinaryTagged.taggedDecodeFileOrFail fp
eres <- BinaryTagged.taggedDecodeFileOrFail (toFilePath fp)
case eres of
Left (offset, str) -> throwM $ DecodeFileFailure fp offset str
Left (offset, str) -> throwM $ DecodeFileFailure (toFilePath fp) offset str
Right x -> return x

data DecodeFileFailure = DecodeFileFailure FilePath ByteOffset String
Expand Down
Loading

0 comments on commit a1a5960

Please sign in to comment.