rollbar-hs/Makefile
joneshf 79f82a54ac
Move to a nix-based setup
With nix, we get more reproducable builds.
Everything that goes into making the build can be specified.
The dependencies we need for development/CI can be made the same.

And, we ought to be able to parameterize the build better.
When we want to check if things compile on 8.4.x,
we can change the compiler to that version in one place.

Assuming this works out, it should make for a lower amount of overall work.
2018-08-09 08:09:26 -07:00

62 lines
1.1 KiB
Makefile

CABAL ?= cabal
CABAL_FLAGS ?=
DIST ?= dist
GHCID ?= ghcid
GHCID_FLAGS ?= --ghc-options=-fno-code
HPACK ?= hpack
NIX_SHELL ?= nix-shell
NIX_SHELL_FLAGS ?=
PROJECT_NAME := rollbar-hs
CABAL_FILE := $(PROJECT_NAME).cabal
CONFIGURE := $(DIST)/setup-config
DOC_TEST := $(DIST)/build/doc-test/doc-test
.DEFAULT_GOAL := build
$(CABAL_FILE): package.yaml
$(HPACK)
$(CONFIGURE): $(CABAL_FILE)
$(CABAL) $(CABAL_FLAGS) configure --enable-tests
.PHONY: build
build $(DOC_TEST): $(CONFIGURE) default.nix
$(CABAL) $(CABAL_FLAGS) build
.PHONY: check
check: $(CABAL_FILE)
$(CABAL) $(CABAL_FLAGS) check
.PHONY: clean
clean:
rm -f $(CABAL_FILE)
rm -f default.nix
rm -fr $(DIST)
default.nix: $(CABAL_FILE)
cabal2nix . > $@
.PHONY: sdist
sdist: check
$(CABAL) $(CABAL_FLAGS) sdist
.PHONY: shell
shell:
$(NIX_SHELL) --pure $(NIX_SHELL_FLAGS)
.PHONY: test
test: test-doc-test
.PHONY: test-doc-test
test-doc-test: $(DOC_TEST)
$<
.PHONY: upload-hackage
upload-hackage: sdist
@ $(CABAL) $(CABAL_FLAGS) upload $(DIST)/$(PROJECT_NAME)-*.tar.gz
.PHONY: watch
watch: $(CONFIGURE)
$(GHCID) --command "cabal repl lib:$(PROJECT_NAME) $(GHCID_FLAGS)"