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-08 13:07:50 +03:00
|
|
|
ASSETS = seating-mascot.051c86a.svg \
|
|
|
|
Seating_Tara_smiling.svg \
|
|
|
|
teaching-mascot.f828959.svg
|
2022-08-03 15:44:48 +03:00
|
|
|
|
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
|
2022-08-08 13:07:50 +03:00
|
|
|
EXAMPLES= HelloWorld/HelloWorld.juvix \
|
|
|
|
Collatz/Collatz.juvix \
|
2022-08-03 15:44:48 +03:00
|
|
|
Fibonacci/Fibonacci.juvix \
|
2022-08-10 14:02:14 +03:00
|
|
|
Hanoi/Hanoi.juvix \
|
|
|
|
PascalsTriangle/PascalsTriangle.juvix \
|
2022-08-08 13:07:50 +03:00
|
|
|
TicTacToe/CLI/TicTacToe.juvix \
|
|
|
|
ValidityPredicates/SimpleFungibleToken.juvix
|
2022-07-15 14:52:16 +03:00
|
|
|
|
2022-08-03 17:14:38 +03:00
|
|
|
EXAMPLE_WEBAPP_OUTPUT=_docs/examples/webapp
|
|
|
|
WEBAPP_EXAMPLES=TicTacToe/Web/TicTacToe.juvix
|
|
|
|
|
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
|
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
clean: clean-runtime
|
2022-08-03 15:44:48 +03:00
|
|
|
@stack clean --full
|
|
|
|
@rm -rf .hie
|
|
|
|
@rm -rf _docs
|
2022-08-15 13:20:38 +03:00
|
|
|
@rm -rf docs/md
|
2022-08-03 15:44:48 +03:00
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
.PHONY: clean-runtime
|
2023-01-05 18:39:40 +03:00
|
|
|
clean-runtime: clean-juvix-build
|
2022-11-03 11:38:09 +03:00
|
|
|
@cd runtime && make clean
|
|
|
|
|
2023-01-05 18:39:40 +03:00
|
|
|
.PHONY: clean-juvix-build
|
|
|
|
clean-juvix-build:
|
|
|
|
@find . -type d -name '.juvix-build' | xargs rm -rf
|
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
repl:
|
|
|
|
@stack ghci Juvix:lib
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
# -- The Juvix Book
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# -- EXAMPLES
|
|
|
|
|
|
|
|
.PHONY: html-examples
|
|
|
|
html-examples: $(EXAMPLES)
|
|
|
|
|
|
|
|
$(EXAMPLES):
|
|
|
|
$(eval OUTPUTDIR=$(EXAMPLEHTMLOUTPUT)/$(dir $@))
|
|
|
|
@mkdir -p ${OUTPUTDIR}
|
2022-08-03 17:14:38 +03:00
|
|
|
@juvix html $(EXAMPLEMILESTONE)/$@ --recursive --output-dir=$(CURDIR)/${OUTPUTDIR} --print-metadata
|
|
|
|
|
|
|
|
.PHONY: webapp-examples
|
|
|
|
webapp-examples: $(WEBAPP_EXAMPLES)
|
|
|
|
|
|
|
|
$(WEBAPP_EXAMPLES):
|
|
|
|
$(eval OUTPUTDIR=$(EXAMPLE_WEBAPP_OUTPUT)/$(dir $@))
|
|
|
|
@mkdir -p ${OUTPUTDIR}
|
2022-09-05 15:38:04 +03:00
|
|
|
@juvix compile -t wasm -r standalone $(EXAMPLEMILESTONE)/$@
|
2022-08-04 11:19:03 +03:00
|
|
|
@cp $(dir $(EXAMPLEMILESTONE)/$@)* ${OUTPUTDIR}
|
2022-08-03 15:44:48 +03:00
|
|
|
|
|
|
|
# -- MDBook
|
2021-10-30 12:51:42 +03:00
|
|
|
|
2022-08-08 13:07:50 +03:00
|
|
|
docs/md/README.md : README.org
|
2022-07-19 19:43:16 +03:00
|
|
|
@mkdir -p docs/md
|
|
|
|
@${ORGTOMDPRG} README.org ${ORGOPTS}
|
|
|
|
|
2022-08-08 13:07:50 +03:00
|
|
|
docs/md/changelog.md : changelog.org
|
2022-07-25 19:42:24 +03:00
|
|
|
@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-08-08 13:07:50 +03:00
|
|
|
.PHONY: markdown-files
|
|
|
|
markdown-files: docs/md/README.md docs/md/changelog.md $(MDFILES)
|
|
|
|
|
2022-05-20 17:16:16 +03:00
|
|
|
.PHONY: markdown-docs
|
2022-08-08 13:07:50 +03:00
|
|
|
markdown-docs: markdown-files
|
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-08-08 13:07:50 +03:00
|
|
|
serve-docs: markdown-files
|
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-11-03 11:38:09 +03:00
|
|
|
.PHONY: format
|
|
|
|
format: clang-format
|
2022-08-03 15:44:48 +03:00
|
|
|
@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-11-03 11:38:09 +03:00
|
|
|
.PHONY: clang-format
|
|
|
|
clang-format:
|
|
|
|
@cd runtime && make format
|
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY: check-ormolu
|
|
|
|
check-ormolu: export ORMOLUMODE = check
|
|
|
|
check-ormolu:
|
2022-12-22 17:28:58 +03:00
|
|
|
@make -s 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-12-22 17:28:58 +03:00
|
|
|
MAKEAUXFLAGS?=-s
|
|
|
|
MAKE=make ${MAKEAUXFLAGS}
|
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
STACKFLAGS?=--jobs $(THREADS)
|
2022-12-22 17:28:58 +03:00
|
|
|
STACKTESTFLAGS?=--ta --hide-successes --ta --ansi-tricks=false
|
|
|
|
SHELLTESTFLAGS?=--color --diff -a --hide-successes
|
2022-05-05 16:12:17 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY: check
|
2023-01-06 19:54:13 +03:00
|
|
|
check: clean
|
2022-12-22 17:28:58 +03:00
|
|
|
@${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-11-03 11:38:09 +03:00
|
|
|
.PHONY: build
|
|
|
|
build: submodules runtime
|
2022-08-03 15:44:48 +03:00
|
|
|
stack build ${STACKFLAGS}
|
2022-03-25 02:50:18 +03:00
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
.PHONY: fast-build
|
|
|
|
fast-build: submodules runtime
|
|
|
|
stack build --fast ${STACKFLAGS}
|
|
|
|
|
|
|
|
.PHONY: runtime
|
|
|
|
runtime:
|
|
|
|
cd runtime && make -j 4
|
|
|
|
|
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-11-03 11:38:09 +03:00
|
|
|
install: runtime submodules
|
2022-08-03 15:44:48 +03:00
|
|
|
@stack install ${STACKFLAGS}
|
2021-10-26 15:44:54 +03:00
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
.PHONY : fast-install
|
|
|
|
fast-install: runtime submodules
|
|
|
|
@stack install --fast ${STACKFLAGS}
|
|
|
|
|
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
|
2022-12-22 17:28:58 +03:00
|
|
|
@stack test ${STACKFLAGS} ${STACKTESTFLAGS}
|
2022-07-15 14:52:16 +03:00
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
.PHONY : fast-test
|
|
|
|
fast-test: fast-build
|
2022-12-22 17:28:58 +03:00
|
|
|
@stack test --fast ${STACKFLAGS} ${STACKTESTFLAGS}
|
2022-11-03 11:38:09 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY : test-skip-slow
|
|
|
|
test-skip-slow:
|
2022-12-22 17:28:58 +03:00
|
|
|
@stack test ${STACKFLAGS} ${STACKTESTFLAGS} --ta '-p "! /slow tests/"'
|
2022-04-05 20:57:21 +03:00
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
.PHONY : fast-test-skip-slow
|
|
|
|
fast-test-skip-slow:
|
2022-12-22 17:28:58 +03:00
|
|
|
@stack test --fast ${STACKFLAGS} ${STACKTESTFLAGS} --ta '-p "! /slow tests/"'
|
2022-11-03 11:38:09 +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)
|
2022-12-22 17:28:58 +03:00
|
|
|
shelltest ${SHELLTESTFLAGS} 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
|
2023-01-05 19:48:26 +03:00
|
|
|
|
|
|
|
.PHONY : bench
|
|
|
|
bench: runtime submodules
|
|
|
|
@stack bench
|