Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (79 loc) · 3.11 KB
/
Copy pathMakefile
File metadata and controls
95 lines (79 loc) · 3.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# SPDX-FileCopyrightText: Copyright (c) 2025 Objectionary.com
# SPDX-License-Identifier: MIT
.ONESHELL:
.SHELLFLAGS := -e -o pipefail -c
.PHONY: all test compiled hlint fourmolu ruff coverage bench binary phino clean
SHELL := bash
JNA_VERSION := 5.19.1
JEO_VERSION := 0.15.3
ifeq ($(OS),Windows_NT)
MVNW := $(CURDIR)/benchmark/mvnw.cmd
BIN_EXT := .exe
RELEASE_SPLIT :=
RELEASE_LDOPT :=
else
MVNW := $(CURDIR)/benchmark/mvnw
BIN_EXT :=
ifeq ($(shell uname -s),Darwin)
RELEASE_SPLIT :=
RELEASE_LDOPT := -optl-Wl,-dead_strip
else
RELEASE_SPLIT := -split-sections
RELEASE_LDOPT := -optl-Wl,--gc-sections
endif
endif
all: test hlint fourmolu ruff
.SILENT:
test:
cabal test all --enable-tests --ghc-options=-Werror
.SILENT:
compiled:
cabal run exe:phino -f -compiled -- compile
cabal test all --enable-tests -f compiled --builddir=dist-compiled --ghc-options=-Werror
.SILENT:
hlint:
hlint src app test
.SILENT:
fourmolu:
fourmolu --mode check src app test
.SILENT:
ruff:
ruff check .
ruff format --check .
.SILENT:
coverage:
threshold=$${COVERAGE_THRESHOLD:-80}
cabal test all --enable-tests --enable-coverage --ghc-options=-Werror
excludes=$$(find test -name '*.hs' -exec basename {} .hs \; | paste -sd, -)
hpc-codecov cabal:spec -x "$${excludes}" -x "Paths_phino" --out=coverage.json
coverage=$$(python3 -c "import json; d=json.load(open('coverage.json')); t=sum(len(v) for v in d['coverage'].values()); c=sum(1 for v in d['coverage'].values() for h in v.values() if isinstance(h,int) and h>0); print(int(100*c/t) if t else 0)")
rm -f coverage.json
if [ "$${coverage}" -lt "$${threshold}" ]; then echo "Coverage $${coverage}% is below threshold $${threshold}%"; exit 1; fi
echo "Coverage $${coverage}% meets threshold $${threshold}%"
.SILENT:
bench: benchmark/tmp/native.phi
cabal bench --enable-benchmarks
benchmark/tmp/native.phi: benchmark/tmp/Native.xmir
phino rewrite --input xmir --sweet benchmark/tmp/Native.xmir > benchmark/tmp/native.phi
benchmark/tmp/Native.xmir:
command -v java >/dev/null 2>&1 || { echo "java is required to run benchmarks but was not found in PATH"; exit 1; }
mkdir -p $(CURDIR)/benchmark/tmp/jeo/target/classes/com/sun/jna
curl -sSL --fail --retry 3 https://repo1.maven.org/maven2/net/java/dev/jna/jna/$(JNA_VERSION)/jna-$(JNA_VERSION).jar -o $(CURDIR)/benchmark/tmp/jna.jar
cd $(CURDIR)/benchmark/tmp/jeo/target/classes && jar xf $(CURDIR)/benchmark/tmp/jna.jar com/sun/jna/Native.class
cd $(CURDIR)/benchmark/tmp/jeo && $(MVNW) org.eolang:jeo-maven-plugin:$(JEO_VERSION):disassemble -Djeo.disassemble.sourcesDir=target/classes -Djeo.disassemble.outputDir=xmir -q
mv $(CURDIR)/benchmark/tmp/jeo/xmir/com/sun/jna/Native.xmir $(CURDIR)/benchmark/tmp/Native.xmir
rm -rf $(CURDIR)/benchmark/tmp/jeo
.SILENT:
binary:
cabal build --ghc-options="$(RELEASE_SPLIT) $(RELEASE_LDOPT)"
mkdir -p dist-release
cp "$$(cabal list-bin phino)" dist-release/phino$(BIN_EXT)
strip dist-release/phino$(BIN_EXT)
.SILENT:
phino:
cabal build exe:phino
cp "$$(cabal list-bin phino)" $(CURDIR)/phino$(BIN_EXT)
.SILENT:
clean:
cabal clean
rm -rf .stack-work benchmark/tmp compiled/generated dist-compiled