-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
105 lines (84 loc) · 2.92 KB
/
Makefile
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
96
97
98
99
100
101
102
103
104
105
# Makefile
.PHONY: doc test coverage
APP_NAME=`awk '/^name:/ {print $$2}' pubspec.yaml`
APP_VERSION=`awk '/^version:/ {print $$2}' pubspec.yaml`
#----------------------------------------------------------------
help:
@echo "Targets for ${APP_NAME} ${APP_VERSION}:"
@echo
@echo " format format Dart files (runs \"dart format\")"
@echo
@echo " test run tests (runs \"dart run test\")"
@echo " coverage generate coverage report from the tests"
@echo
@echo " doc generate Dart documentation (runs \"dart doc\")"
@if uname -s | grep -q -i Darwin ; then \
echo " doc-open opens generated Dart documentation (macOS only)"; \
fi
@echo
@echo " pana check before publishing (runs \"dart run pana\")"
@echo
@echo " clean deletes generated files"
@echo
#================================================================
# Development targets
format:
dart format lib test example
#================================================================
# Testing
test:
dart run test
# genhtml is required to convert the coverage data into a HTML report.
# For some reason, HomeBrew installs it but does not create a symbolic link
# in the /opt/homebrew/bin directory. So the executable must be accessed
# by a full path. Of course, this depends on where HomeBrew is installed.
GENHTML=${HOMEBREW_CELLAR}/lcov/2.0/bin/genhtml
coverage:
dart run coverage:test_with_coverage -f -b
@echo
@if [ ! -x "${GENHTML}" ]; then \
echo "Error: executable not found: ${GENHTML}" >&2 ; \
echo " genhtml is from lcov <https://github.com/linux-test-project/lcov>" >&2 ; \
echo " If you have HomeBrew, it can be installed with \"brew install lcov\"." >&2 ; \
echo ; \
exit 3 ; \
fi
"${GENHTML}" coverage/lcov.info -o coverage/html
@echo '--------'
@echo "View coverage report by opening: coverage/html/index.html"
#================================================================
# Documentation
#----------------------------------------------------------------
# Doc
#
# "doc" always deletes the generated documentation directory first
# since any existing files in it are not removed by the "dart doc"
# command.
doc:
rm -rf doc/api
dart doc
#----------------------------------------------------------------
# Convenient command to view generated documentation
doc-open:
@if [ -e doc/api/index.html ]; then \
if uname -s | grep -q -i Darwin ; then \
open doc/api/index.html; \
else \
echo "doc-open: cannot run: only works on macOS"; \
fi ; \
else \
echo "doc-open: Dart doc not generated (run \"make doc\" first)"; \
fi
#================================================================
# Publishing
pana:
dart run pana
#================================================================
# Generation
clean:
@rm -f -r doc/api
@if [ -d coverage-suite ]; then \
find coverage-suite -type l -name \*.dart -exec rm {} \; ; \
rmdir coverage-suite ; \
fi
#EOF