2021-10-26 15:44:54 +03:00
|
|
|
PWD=$(CURDIR)
|
|
|
|
PREFIX="$(PWD)/.stack-work/prefix"
|
|
|
|
UNAME := $(shell uname)
|
2022-04-04 18:44:08 +03:00
|
|
|
HLINTQUIET :=
|
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
ASSETS = seating-mascot.051c86a.svg \
|
|
|
|
Seating_Tara_smiling.svg \
|
|
|
|
teaching-mascot.f828959.svg
|
|
|
|
|
2022-05-23 17:20:02 +03:00
|
|
|
ORGFILES = $(shell find docs/org -type f -name '*.org')
|
|
|
|
MDFILES:=$(patsubst docs/org/%,docs/md/%,$(ORGFILES:.org=.md))
|
2022-05-20 17:16:16 +03:00
|
|
|
|
2022-07-15 14:52:16 +03:00
|
|
|
EXAMPLEMILESTONE=examples/milestone
|
|
|
|
EXAMPLEHTMLOUTPUT=_docs/examples/html
|
|
|
|
EXAMPLES=ValidityPredicates/SimpleFungibleToken.juvix \
|
2022-08-03 15:44:48 +03:00
|
|
|
MiniTicTacToe/MiniTicTacToe.juvix \
|
|
|
|
Fibonacci/Fibonacci.juvix \
|
|
|
|
Collatz/Collatz.juvix
|
2022-07-15 14:52:16 +03:00
|
|
|
|
2022-05-20 17:16:16 +03:00
|
|
|
ORGTOMDPRG ?=pandoc
|
2022-05-23 17:20:02 +03:00
|
|
|
ORGOPTS=--from org --to markdown_strict -s -o $@
|
2022-05-20 17:16:16 +03:00
|
|
|
|
2021-10-26 15:44:54 +03:00
|
|
|
ifeq ($(UNAME), Darwin)
|
|
|
|
THREADS := $(shell sysctl -n hw.logicalcpu)
|
|
|
|
else ifeq ($(UNAME), Linux)
|
|
|
|
THREADS := $(shell nproc)
|
|
|
|
else
|
|
|
|
THREADS := $(shell echo %NUMBER_OF_PROCESSORS%)
|
|
|
|
endif
|
2021-09-26 19:59:51 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
all: install
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@stack clean --full
|
|
|
|
@rm -rf .hie
|
|
|
|
@rm -rf _docs
|
|
|
|
|
|
|
|
repl:
|
|
|
|
@stack ghci Juvix:lib
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# -- The Juvix Book
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# -- EXAMPLES
|
|
|
|
|
|
|
|
.PHONY: html-examples
|
|
|
|
html-examples: $(EXAMPLES)
|
|
|
|
|
|
|
|
$(EXAMPLES):
|
|
|
|
$(eval OUTPUTDIR=$(EXAMPLEHTMLOUTPUT)/$(dir $@))
|
|
|
|
@mkdir -p ${OUTPUTDIR}
|
|
|
|
@juvix html $(EXAMPLEMILESTONE)/$@ --recursive --output-dir=./../../../${OUTPUTDIR} --print-metadata
|
|
|
|
|
|
|
|
# -- MDBook
|
2021-10-30 12:51:42 +03:00
|
|
|
|
2022-07-19 19:43:16 +03:00
|
|
|
docs/md/README.md :
|
|
|
|
@mkdir -p docs/md
|
|
|
|
@${ORGTOMDPRG} README.org ${ORGOPTS}
|
|
|
|
|
2022-07-25 19:42:24 +03:00
|
|
|
docs/md/changelog.md :
|
|
|
|
@mkdir -p docs/md
|
|
|
|
@${ORGTOMDPRG} changelog.org ${ORGOPTS}
|
|
|
|
|
2022-05-23 17:20:02 +03:00
|
|
|
docs/md/%.md : docs/org/%.org
|
|
|
|
@echo "Processing ... $@"
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
${ORGTOMDPRG} $? ${ORGOPTS}
|
|
|
|
|
2022-05-20 17:16:16 +03:00
|
|
|
.PHONY: markdown-docs
|
2022-07-25 19:42:24 +03:00
|
|
|
markdown-docs: docs/md/README.md docs/md/changelog.md $(MDFILES)
|
2022-07-06 15:23:13 +03:00
|
|
|
@echo "copying assets ..."
|
|
|
|
@mkdir -p docs/md/assets
|
|
|
|
@cp -v $(addprefix assets/,$(ASSETS)) docs/md/assets
|
2022-08-03 15:44:48 +03:00
|
|
|
@mdbook build
|
2022-05-20 17:16:16 +03:00
|
|
|
|
|
|
|
.PHONY: serve-docs
|
2022-05-23 17:20:02 +03:00
|
|
|
serve-docs: $(MDFILES)
|
2022-08-03 15:44:48 +03:00
|
|
|
@mdbook serve --open
|
2021-09-26 19:59:51 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
# -- Codebase Documentation
|
2021-09-26 19:59:51 +03:00
|
|
|
|
2021-12-04 16:17:49 +03:00
|
|
|
.PHONY : haddock
|
|
|
|
haddock :
|
2022-08-03 15:44:48 +03:00
|
|
|
@cabal --docdir=docs/ --htmldir=docs/ haddock --enable-documentation
|
2021-12-04 16:17:49 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# -- Codebase Health
|
|
|
|
# ------------------------------------------------------------------------------
|
2021-09-26 19:59:51 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
ORMOLUFILES = $(shell git ls-files '*.hs' '*.hs-boot' | grep -v '^contrib/')
|
|
|
|
ORMOLUFLAGS?=--no-cabal
|
|
|
|
ORMOLUMODE?=inplace
|
2022-07-08 14:59:45 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
format:
|
|
|
|
@stack exec -- ormolu ${ORMOLUFLAGS} \
|
|
|
|
--ghc-opt -XStandaloneDeriving \
|
|
|
|
--ghc-opt -XUnicodeSyntax \
|
|
|
|
--ghc-opt -XDerivingStrategies \
|
|
|
|
--ghc-opt -XMultiParamTypeClasses \
|
|
|
|
--ghc-opt -XTemplateHaskell \
|
|
|
|
--ghc-opt -XImportQualifiedPost \
|
|
|
|
--mode ${ORMOLUMODE} \
|
|
|
|
$(ORMOLUFILES)
|
2022-05-05 17:21:04 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY: check-ormolu
|
|
|
|
check-ormolu: export ORMOLUMODE = check
|
|
|
|
check-ormolu:
|
|
|
|
make format
|
2022-03-25 02:50:18 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY : hlint
|
|
|
|
hlint :
|
|
|
|
@hlint src app test ${HLINTQUIET}
|
2021-09-26 19:59:51 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
PRECOMMIT := $(shell command -v pre-commit 2> /dev/null)
|
2021-10-26 15:44:54 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY : install-pre-commit
|
|
|
|
install-pre-commit :
|
|
|
|
@$(if $(PRECOMMIT),, pip install pre-commit)
|
2021-10-30 12:51:42 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY : pre-commit
|
|
|
|
pre-commit :
|
|
|
|
@pre-commit run --all-files
|
2022-03-23 13:40:03 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# -- Build-Install-Test-Release
|
|
|
|
# ------------------------------------------------------------------------------
|
2022-05-05 17:21:04 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
STACKFLAGS?=--fast --jobs $(THREADS)
|
2022-05-05 16:12:17 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY: check
|
|
|
|
check:
|
|
|
|
@make build
|
|
|
|
@make install
|
|
|
|
@make test
|
|
|
|
@make test-shell
|
|
|
|
@make format
|
|
|
|
@make pre-commit
|
2022-03-25 02:50:18 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
# -- Build requirements
|
2022-06-09 17:36:07 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY: submodules
|
|
|
|
submodules:
|
|
|
|
@git submodule sync
|
|
|
|
@git submodule update --init --recursive
|
2022-06-09 17:36:07 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY : build
|
|
|
|
build: submodules
|
|
|
|
stack build ${STACKFLAGS}
|
2022-03-25 02:50:18 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
# -- Install
|
2022-04-04 16:55:15 +03:00
|
|
|
|
2022-03-23 14:13:28 +03:00
|
|
|
.PHONY : install
|
2022-08-03 15:44:48 +03:00
|
|
|
install: submodules
|
|
|
|
@stack install ${STACKFLAGS}
|
2021-10-26 15:44:54 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
# -- Testing
|
2022-07-15 14:52:16 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY : test
|
|
|
|
test: build
|
|
|
|
@stack test ${STACKFLAGS}
|
2022-07-15 14:52:16 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY : test-skip-slow
|
|
|
|
test-skip-slow:
|
|
|
|
@stack test ${STACKFLAGS} --ta '-p "! /slow tests/"'
|
2022-04-05 20:57:21 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
SHELLTEST := $(shell command -v shelltest 2> /dev/null)
|
2022-04-04 16:55:15 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY : test-shell
|
|
|
|
test-shell : install
|
|
|
|
@$(if $(SHELLTEST),, stack install shelltestrunner)
|
|
|
|
shelltest --color --diff -a -j8 tests
|
2022-04-04 16:55:15 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
# -- Release
|
2022-05-04 15:06:29 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY : changelog-updates
|
|
|
|
changelog-updates :
|
|
|
|
@github_changelog_generator
|
|
|
|
@pandoc CHANGELOG.md --from markdown --to org -o UPDATES-FOR-CHANGELOG.org
|