Skip to content

Commit

Permalink
Install goldplate through cabal file
Browse files Browse the repository at this point in the history
Stack doesn't understand the new build-tool-depends so removed this for now
  • Loading branch information
jaspervdj committed Oct 22, 2024
1 parent 72cf0cb commit e082be1
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 80 deletions.
19 changes: 8 additions & 11 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,17 @@ jobs:

- uses: actions/checkout@v4

- uses: actions/cache@v3
with:
path: ~/.stack
key: "${{ runner.os }}-${{ matrix.ghc }}-v8-${{ hashFiles('patat.cabal', 'stack.yaml', 'stack.yaml.lock') }}"
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-v8-
- uses: haskell-actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc }}
enable-stack: true
stack-version: 'latest'
stack-no-global: true
stack-setup-ghc: true

- uses: actions/cache@v3
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-v9-${{ hashFiles('patat.cabal') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-v9-
- run: make build
id: build
Expand Down
21 changes: 5 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,7 @@ ARCHIVE_CREATE=tar czf
ARCHIVE_EXTRACT=tar xvzf
endif

ifeq ($(UNAME), darwin)
# We use `?=` to set SOURCE_DATE_EPOCH only if it is not present. Unfortunately
# we can't use `git --date=unix` since only very recent git versions support
# that, so we need to make a round trip through `date`.
SOURCE_DATE_EPOCH?=$(shell git log -1 --format=%cd --date=unix)
else
SOURCE_DATE_EPOCH?=$(shell date '+%s' \
--date="$(shell git log -1 --format=%cd --date=rfc)")
endif

ifeq ($(UNAME), darwin)
COMPRESS_BIN_DEPS=
Expand All @@ -37,8 +29,6 @@ COMPRESS_BIN_DEPS=$(UPX_BINARY)
COMPRESS_BIN=upx
endif

STACK=stack

# Default target.
.PHONY: build
build: $(PATAT_BINARY)
Expand All @@ -60,7 +50,7 @@ $(PATAT_PACKAGE).$(ARCHIVE): $(PATAT_BINARY) extra/patat.1 $(COMPRESS_BIN_DEPS)
$(ARCHIVE_CREATE) $(PATAT_PACKAGE).$(ARCHIVE) $(PATAT_PACKAGE)

$(PATAT_BINARY):
$(STACK) build --copy-bins
cabal install --installdir="$(dir $(PATAT_BINARY))"

# UPX is used to compress the resulting binary. We currently don't use this on
# Mac OS.
Expand All @@ -73,11 +63,11 @@ $(UPX_BINARY):

# Man page.
extra/patat.1: README.md $(PATAT_BINARY)
SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)" patat-make-man >$@
SOURCE_DATE_EPOCH="$(SOURCE_DATE_EPOCH)" cabal exec -- patat-make-man >$@

# Bash completion.
extra/patat.bash-completion:
patat --bash-completion-script patat >$@
extra/patat.bash-completion: $(PATAT_BINARY)
cabal exec -- patat --bash-completion-script patat >$@

.PHONY: completion
completion: extra/patat.bash-completion
Expand All @@ -88,8 +78,7 @@ man: extra/patat.1
# Also check if we can generate the manual.
.PHONY: test
test: man
$(STACK) install goldplate
goldplate --pretty-diff tests
cabal test

.PHONY: clean
clean:
Expand Down
26 changes: 3 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,11 @@ You can also find generic Linux and Mac OS binaries here:

### From source

Installation from source is very easy. You can build from source using `stack
install` or `cabal install`. `patat` is also available from [Hackage].

[Hackage]: https://hackage.haskell.org/package/patat

For people unfamiliar with the Haskell ecosystem, this means you can do either
of the following:

#### Using stack

1. Install [stack] for your platform.
2. Clone this repository.
3. Run `stack setup` (if you're running stack for the first time) and
`stack install`.
4. Make sure `$HOME/.local/bin` is in your `$PATH`.

[stack]: https://docs.haskellstack.org/en/stable/README/

#### Using cabal

1. Install [cabal] for your platform.
2. Run `cabal install patat`.
3. Make sure `$HOME/.cabal/bin` is in your `$PATH`.
`patat` is also available from [Hackage]. You can install it using [cabal] by
running `cabal install patat`.

[cabal]: https://www.haskell.org/cabal/
[Hackage]: https://hackage.haskell.org/package/patat

Running
-------
Expand Down
4 changes: 4 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
packages: *.cabal
package patat
tests: True
flags: +patat-make-man
12 changes: 12 additions & 0 deletions patat.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,15 @@ Test-suite patat-tests
tasty-quickcheck >= 0.10 && < 0.11,
text >= 1.2 && < 2.2,
QuickCheck >= 2.8 && < 2.15

Test-suite patat-goldplate
Main-is: Main.hs
Ghc-options: -Wall
Hs-source-dirs: tests/golden
Type: exitcode-stdio-1.0
Default-language: Haskell2010
Build-tool-depends: patat:patat

Build-depends:
base >= 4.8 && < 5,
goldplate >= 0.2.2.1 && < 0.3
15 changes: 0 additions & 15 deletions stack.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions stack.yaml.lock

This file was deleted.

8 changes: 8 additions & 0 deletions tests/golden/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Goldplate (Options (..), defaultOptions, mainWith)
import System.Exit (exitWith)

main :: IO ()
main = mainWith options >>= exitWith
where
options = defaultOptions
{ oPrettyDiff = True, oPaths = ["tests/golden"] }
2 changes: 1 addition & 1 deletion tests/golden/inputs/syntax-definitions.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
patat:
syntaxDefinitions:
- 'golden/syntax-definitions/impurescript.xml'
- 'syntax-definitions/impurescript.xml'
...

Hello
Expand Down
4 changes: 2 additions & 2 deletions tests/golden.goldplate → tests/golden/spec.goldplate
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"command": "patat",
"input_files": "golden/inputs/*",
"input_files": "inputs/*",
"arguments": ["--dump", "--force", "${GOLDPLATE_INPUT_FILE}"],
"environment": {
"HOME": "/dev/null"
},
"asserts": [
{"exit_code": 0},
{"stdout": "golden/outputs/${GOLDPLATE_INPUT_BASENAME}.dump"}
{"stdout": "outputs/${GOLDPLATE_INPUT_BASENAME}.dump"}
]
}

0 comments on commit e082be1

Please sign in to comment.