2023-05-19 18:33:56 +03:00
|
|
|
SHELL := /bin/bash
|
2021-10-26 15:44:54 +03:00
|
|
|
PWD=$(CURDIR)
|
|
|
|
PREFIX="$(PWD)/.stack-work/prefix"
|
|
|
|
UNAME := $(shell uname)
|
2022-07-15 14:52:16 +03:00
|
|
|
EXAMPLEMILESTONE=examples/milestone
|
2023-04-14 12:16:05 +03:00
|
|
|
EXAMPLEHTMLOUTPUT=docs/examples/html
|
2023-01-19 15:28:21 +03:00
|
|
|
EXAMPLES= Collatz/Collatz.juvix \
|
|
|
|
Fibonacci/Fibonacci.juvix \
|
|
|
|
Hanoi/Hanoi.juvix \
|
|
|
|
HelloWorld/HelloWorld.juvix \
|
|
|
|
PascalsTriangle/PascalsTriangle.juvix \
|
|
|
|
TicTacToe/CLI/TicTacToe.juvix \
|
2023-04-27 11:56:31 +03:00
|
|
|
Bank/Bank.juvix \
|
2023-04-12 11:07:01 +03:00
|
|
|
Tutorial/Tutorial.juvix
|
2022-07-15 14:52:16 +03:00
|
|
|
|
2023-01-23 22:33:55 +03:00
|
|
|
DEMO_EXAMPLE=examples/demo/Demo.juvix
|
2022-08-03 17:14:38 +03:00
|
|
|
|
2023-02-22 17:27:40 +03:00
|
|
|
MAKEAUXFLAGS?=-s
|
|
|
|
MAKE=make ${MAKEAUXFLAGS}
|
2023-03-21 22:01:48 +03:00
|
|
|
METAFILES:=README.md \
|
2023-05-19 18:33:56 +03:00
|
|
|
CHANGELOG.md \
|
|
|
|
CONTRIBUTING.md \
|
|
|
|
LICENSE.md
|
2022-05-20 17:16:16 +03:00
|
|
|
|
2023-04-05 16:13:57 +03:00
|
|
|
STACKFLAGS?=--jobs $(THREADS)
|
2023-11-16 18:19:52 +03:00
|
|
|
STACKTESTFLAGS?=--ta --hide-successes --ta --ansi-tricks=false --ta "+RTS -N -RTS"
|
2023-04-05 16:13:57 +03:00
|
|
|
SMOKEFLAGS?=--color --diff=git
|
|
|
|
STACK?=stack
|
|
|
|
|
|
|
|
JUVIXBIN?=juvix
|
|
|
|
|
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
|
|
|
|
2023-07-27 18:57:20 +03:00
|
|
|
all: build
|
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
clean: clean-runtime
|
2023-04-05 16:13:57 +03:00
|
|
|
@${STACK} clean --full
|
2022-08-03 15:44:48 +03:00
|
|
|
@rm -rf .hie
|
|
|
|
|
2023-03-21 18:45:21 +03:00
|
|
|
.PHONY: clean-hard
|
|
|
|
clean-hard: clean
|
|
|
|
@git clean -fdx
|
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
.PHONY: clean-runtime
|
2023-01-05 18:39:40 +03:00
|
|
|
clean-runtime: clean-juvix-build
|
2023-02-22 17:27:40 +03:00
|
|
|
@cd runtime && ${MAKE} clean
|
2022-11-03 11:38:09 +03:00
|
|
|
|
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:
|
2023-04-05 16:13:57 +03:00
|
|
|
@${STACK} ghci Juvix:lib ${STACKFLAGS}
|
2022-08-03 15:44:48 +03:00
|
|
|
|
2023-04-21 20:05:24 +03:00
|
|
|
# -- EXAMPLES HTML OUTPUT
|
2022-08-03 15:44:48 +03:00
|
|
|
|
|
|
|
.PHONY: html-examples
|
|
|
|
html-examples: $(EXAMPLES)
|
|
|
|
|
|
|
|
$(EXAMPLES):
|
|
|
|
$(eval OUTPUTDIR=$(EXAMPLEHTMLOUTPUT)/$(dir $@))
|
|
|
|
@mkdir -p ${OUTPUTDIR}
|
2023-04-05 16:13:57 +03:00
|
|
|
@${JUVIXBIN} html $(EXAMPLEMILESTONE)/$@ --output-dir=$(CURDIR)/${OUTPUTDIR}
|
2023-01-23 22:33:55 +03:00
|
|
|
|
|
|
|
.PHONY: demo-example
|
|
|
|
demo-example:
|
|
|
|
$(eval OUTPUTDIR=$(EXAMPLEHTMLOUTPUT)/Demo)
|
|
|
|
@mkdir -p ${OUTPUTDIR}
|
2023-04-05 16:13:57 +03:00
|
|
|
@${JUVIXBIN} html $(DEMO_EXAMPLE) --output-dir=$(CURDIR)/${OUTPUTDIR}
|
2022-08-03 17:14:38 +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
|
|
|
|
2023-04-05 16:13:57 +03:00
|
|
|
ORMOLU?=${STACK} exec -- ormolu
|
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
|
|
|
|
2023-03-21 22:01:48 +03:00
|
|
|
.PHONY: ormolu
|
|
|
|
ormolu:
|
2023-01-27 14:45:38 +03:00
|
|
|
@${ORMOLU} ${ORMOLUFLAGS} \
|
2024-07-19 11:38:39 +03:00
|
|
|
--mode ${ORMOLUMODE} \
|
2022-08-03 15:44:48 +03:00
|
|
|
$(ORMOLUFILES)
|
2022-05-05 17:21:04 +03:00
|
|
|
|
2023-03-21 22:01:48 +03:00
|
|
|
.PHONY: format
|
|
|
|
format:
|
|
|
|
@${MAKE} clang-format
|
|
|
|
@${MAKE} ormolu
|
|
|
|
|
2022-11-03 11:38:09 +03:00
|
|
|
.PHONY: clang-format
|
|
|
|
clang-format:
|
Update CI to install Smoke, Github actions, and Makefile fixes (#1735)
This PR adds some maintenance at different levels to the CI config, the
Make file, and formatting.
- Most of the actions used by the CI related to haskell, ormolu, hlint
and pre-commit have been updated because Github requires NodeJS 16. This
change removes all the old warnings related to nodeJs.
In the case of ormolu, the new version makes us format some files that
were not formatted before, similarly with hlint.
- The CI has been updated to use the latest version of the Smoke testing
framework, which introduced installation of the dependencies for Linux
(libicu66) and macOS (icu4c) in the CI. In the case of macOS, the CI
uses a binary for smoke. For Linux, we use stack to build smoke from the
source. The source here is in a fork of [the official Smoke
repo](https://github.com/SamirTalwar/smoke). Such includes some
features/changes that are not yet in the official repo.
- The Makefile runs the ormolu and hlint targets using as a path for the
binaries the environment variables ORMOLU and HLINT. Thus, export those
variables in your environment before running `make check,` `make format`
or `make hlint`. Otherwise, the Makefile will use the binaries provided
by `stack`.
Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-01-24 13:50:23 +03:00
|
|
|
@cd runtime && ${MAKE} format
|
2022-11-03 11:38:09 +03:00
|
|
|
|
2023-11-08 18:54:35 +03:00
|
|
|
JUVIX_PACKAGES_IN_REPO=$(shell find \
|
|
|
|
./examples \
|
2023-05-19 18:33:56 +03:00
|
|
|
./tests/positive \
|
|
|
|
./tests/negative \
|
|
|
|
-type d \( -name ".juvix-build" -o -name "FancyPaths" \) -prune -o \
|
2023-11-08 18:54:35 +03:00
|
|
|
-type f -name 'Package.juvix' -print \
|
|
|
|
| awk -F'/Package.juvix' '{print $$1}' | sort -u)
|
2023-05-19 18:33:56 +03:00
|
|
|
|
2023-08-24 12:20:09 +03:00
|
|
|
JUVIXFORMATFLAGS?=--in-place
|
2024-07-22 18:14:37 +03:00
|
|
|
JUVIXTYPECHECKFLAGS?=--log-level warn
|
2023-03-29 16:51:04 +03:00
|
|
|
|
2023-04-12 11:07:01 +03:00
|
|
|
.PHONY: format-juvix-files
|
|
|
|
format-juvix-files:
|
2023-11-08 18:54:35 +03:00
|
|
|
@for p in $(JUVIX_PACKAGES_IN_REPO); do \
|
|
|
|
${JUVIXBIN} format $(JUVIXFORMATFLAGS) "$$p" > /dev/null 2>&1; \
|
2023-05-19 18:33:56 +03:00
|
|
|
exit_code=$$?; \
|
|
|
|
if [ $$exit_code -eq 0 ]; then \
|
2023-11-08 18:54:35 +03:00
|
|
|
echo "[OK] $$p is formatted"; \
|
|
|
|
elif [[ $$exit_code -ne 0 && "$$p" == *"tests/"* ]]; then \
|
|
|
|
echo "[CONTINUE] $$p is in tests directory."; \
|
2023-07-10 20:57:55 +03:00
|
|
|
else \
|
2023-11-08 18:54:35 +03:00
|
|
|
echo "[FAIL] $$p formatting failed" && exit 1; \
|
2023-07-10 20:57:55 +03:00
|
|
|
fi; \
|
|
|
|
done;
|
2023-03-29 16:51:04 +03:00
|
|
|
|
2023-04-12 11:07:01 +03:00
|
|
|
.PHONY: check-format-juvix-files
|
|
|
|
check-format-juvix-files:
|
2023-05-19 18:33:56 +03:00
|
|
|
@JUVIXFORMATFLAGS=--check ${MAKE} format-juvix-files
|
2023-04-12 11:07:01 +03:00
|
|
|
|
2023-05-19 18:33:56 +03:00
|
|
|
JUVIXEXAMPLEFILES=$(shell find ./examples \
|
|
|
|
-type d \( -name ".juvix-build" \) -prune -o \
|
|
|
|
-name "*.juvix" -print)
|
2023-03-29 16:51:04 +03:00
|
|
|
|
|
|
|
.PHONY: typecheck-juvix-examples
|
|
|
|
typecheck-juvix-examples:
|
|
|
|
@for file in $(JUVIXEXAMPLEFILES); do \
|
2023-04-05 16:13:57 +03:00
|
|
|
${JUVIXBIN} typecheck "$$file" $(JUVIXTYPECHECKFLAGS); \
|
2023-05-19 18:33:56 +03:00
|
|
|
exit_code=$$?; \
|
|
|
|
if [ $$exit_code -eq 0 ]; then \
|
|
|
|
echo "[OK] $$file typechecks"; \
|
|
|
|
else \
|
2023-07-10 20:57:55 +03:00
|
|
|
echo "[FAIL] Typecking failed for $$file" && exit 1; \
|
|
|
|
fi; \
|
2023-03-29 16:51:04 +03:00
|
|
|
done
|
2023-03-21 22:01:48 +03:00
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
.PHONY: check-ormolu
|
|
|
|
check-ormolu: export ORMOLUMODE = check
|
|
|
|
check-ormolu:
|
2023-03-21 22:01:48 +03:00
|
|
|
@${MAKE} ormolu
|
Update CI to install Smoke, Github actions, and Makefile fixes (#1735)
This PR adds some maintenance at different levels to the CI config, the
Make file, and formatting.
- Most of the actions used by the CI related to haskell, ormolu, hlint
and pre-commit have been updated because Github requires NodeJS 16. This
change removes all the old warnings related to nodeJs.
In the case of ormolu, the new version makes us format some files that
were not formatted before, similarly with hlint.
- The CI has been updated to use the latest version of the Smoke testing
framework, which introduced installation of the dependencies for Linux
(libicu66) and macOS (icu4c) in the CI. In the case of macOS, the CI
uses a binary for smoke. For Linux, we use stack to build smoke from the
source. The source here is in a fork of [the official Smoke
repo](https://github.com/SamirTalwar/smoke). Such includes some
features/changes that are not yet in the official repo.
- The Makefile runs the ormolu and hlint targets using as a path for the
binaries the environment variables ORMOLU and HLINT. Thus, export those
variables in your environment before running `make check,` `make format`
or `make hlint`. Otherwise, the Makefile will use the binaries provided
by `stack`.
Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-01-24 13:50:23 +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
|
|
|
|
2023-01-30 14:06:18 +03:00
|
|
|
.PHONY: check-only
|
|
|
|
check-only:
|
2023-04-05 16:13:57 +03:00
|
|
|
@${MAKE} build \
|
|
|
|
&& ${MAKE} install \
|
|
|
|
&& ${MAKE} test \
|
|
|
|
&& ${MAKE} smoke \
|
2023-05-19 18:33:56 +03:00
|
|
|
&& ${MAKE} check-format-juvix-files \
|
2023-04-05 16:13:57 +03:00
|
|
|
&& ${MAKE} typecheck-juvix-examples \
|
|
|
|
&& ${MAKE} check-ormolu \
|
|
|
|
&& export SKIP=ormolu,format-juvix-examples,typecheck-juvix-examples \
|
|
|
|
&& ${MAKE} pre-commit
|
2022-03-25 02:50:18 +03:00
|
|
|
|
2023-01-30 14:06:18 +03:00
|
|
|
.PHONY: check
|
|
|
|
check: clean
|
|
|
|
@${MAKE} check-only
|
|
|
|
|
2023-04-05 16:13:57 +03:00
|
|
|
.PHONY : bench
|
|
|
|
bench: runtime submodules
|
|
|
|
@${STACK} bench ${STACKFLAGS}
|
|
|
|
|
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
|
2023-04-05 16:13:57 +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
|
2023-04-05 16:13:57 +03:00
|
|
|
@${STACK} build --fast ${STACKFLAGS}
|
2022-11-03 11:38:09 +03:00
|
|
|
|
|
|
|
.PHONY: runtime
|
|
|
|
runtime:
|
2024-05-22 13:26:51 +03:00
|
|
|
cd runtime && make
|
2022-11-03 11:38:09 +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-11-03 11:38:09 +03:00
|
|
|
install: runtime submodules
|
2023-04-05 16:13:57 +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
|
2023-04-05 16:13:57 +03:00
|
|
|
@${STACK} install --fast ${STACKFLAGS}
|
2022-11-03 11:38:09 +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
|
2023-03-21 18:45:21 +03:00
|
|
|
test: build runtime submodules
|
2023-04-05 16:13:57 +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
|
2023-04-05 16:13:57 +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:
|
2023-04-05 16:13:57 +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:
|
2023-04-05 16:13:57 +03:00
|
|
|
@${STACK} test --fast ${STACKFLAGS} ${STACKTESTFLAGS} --ta '-p "! /slow tests/"'
|
2022-11-03 11:38:09 +03:00
|
|
|
|
2023-01-10 14:49:56 +03:00
|
|
|
SMOKE := $(shell command -v smoke 2> /dev/null)
|
2023-11-23 01:21:29 +03:00
|
|
|
SHA256SUM := $(shell command -v sha256sum 2> /dev/null)
|
2022-04-04 16:55:15 +03:00
|
|
|
|
2023-01-24 18:15:24 +03:00
|
|
|
.PHONY : smoke-only
|
|
|
|
smoke-only:
|
2023-03-14 18:24:07 +03:00
|
|
|
@$(if $(SMOKE),, $(error "Smoke not found, please install it from https://github.com/jonaprieto/smoke"))
|
2023-11-23 01:21:29 +03:00
|
|
|
@$(if $(SHA256SUM),, $(error "sha256sum not found, please install the GNU coreutils package (e.g {apt, brew} install coreutils)"))
|
Update CI to install Smoke, Github actions, and Makefile fixes (#1735)
This PR adds some maintenance at different levels to the CI config, the
Make file, and formatting.
- Most of the actions used by the CI related to haskell, ormolu, hlint
and pre-commit have been updated because Github requires NodeJS 16. This
change removes all the old warnings related to nodeJs.
In the case of ormolu, the new version makes us format some files that
were not formatted before, similarly with hlint.
- The CI has been updated to use the latest version of the Smoke testing
framework, which introduced installation of the dependencies for Linux
(libicu66) and macOS (icu4c) in the CI. In the case of macOS, the CI
uses a binary for smoke. For Linux, we use stack to build smoke from the
source. The source here is in a fork of [the official Smoke
repo](https://github.com/SamirTalwar/smoke). Such includes some
features/changes that are not yet in the official repo.
- The Makefile runs the ormolu and hlint targets using as a path for the
binaries the environment variables ORMOLU and HLINT. Thus, export those
variables in your environment before running `make check,` `make format`
or `make hlint`. Otherwise, the Makefile will use the binaries provided
by `stack`.
Co-authored-by: Paul Cadman <git@paulcadman.dev>
2023-01-24 13:50:23 +03:00
|
|
|
@smoke $(shell find tests -name '*.smoke.yaml')
|
2022-04-04 16:55:15 +03:00
|
|
|
|
2023-01-24 18:15:24 +03:00
|
|
|
.PHONY : smoke
|
|
|
|
smoke: install submodules
|
|
|
|
@${MAKE} smoke-only
|
|
|
|
|
2022-08-03 15:44:48 +03:00
|
|
|
# -- Release
|
2022-05-04 15:06:29 +03:00
|
|
|
|
2023-04-05 16:13:57 +03:00
|
|
|
.PHONY : changelog
|
|
|
|
changelog :
|
2022-08-03 15:44:48 +03:00
|
|
|
@github_changelog_generator
|
2023-12-01 20:39:39 +03:00
|
|
|
|
|
|
|
HYPERFINEBIN := $(shell command -v hyperfine 2> /dev/null)
|
|
|
|
|
|
|
|
.PHONY : hyperfine-benchmarks
|
|
|
|
hyperfine-benchmarks:
|
|
|
|
@$(if $(HYPERFINEBIN),, $(error "hyperfine not found, please install it using cargo or from https://github.com/sharkdp/hyperfine"))
|
|
|
|
cd bench/hyperfine && ${MAKE}
|