-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
181 lines (124 loc) · 4.74 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
COMMA_RE = ^\([, ]*\)
ENUM_RE = [ ]*MP2_[A-Z_]*[ ]*=[ ]*[0-9][0-9]*
SED_RE = \(\,\)*[ ]*\/\/[ ]*\(.*\)
ALIAS_RE = [ ]*MP2_\(.*\)\: \(.*\)(\(.*\))
ROXY_RE = ^.*\(\#'.*\)$
VERSION := $(shell sed -n '/^Version: /s///p' DESCRIPTION)
TEST := testthat::test_package(\"macpan2\", reporter = \"progress\")
all:
make full-install
make pkg-check
install-deps:
Rscript -e "remotes::install_github('canmod/oor@validity')"
# Use this rule if you are doing R development or want to promote
# dev.cpp to macpan2.cpp before doing R development.
full-install:
make src-update
make enum-update
make enum-meth-update
make engine-doc-update
make doc-update
make pkg-build
make pkg-install
# Use this rule if (1) you are in a development cycle, (2) you
# haven't updated macpan.cpp (but have perhaps modified dev.cpp)
# and (3) do not require a roxygen update.
quick-install: enum-update enum-meth-update
R CMD INSTALL --no-multiarch --install-tests .
quick-doc-install: R/*.R misc/dev/dev.cpp
make engine-doc-update
make doc-update
make quick-install
forced-quick-doc-install:
touch misc/old-r-source/*.R
make doc-update
make quick-install
quick-test-all:
make quick-doc-install
make run-vignette-code
make run-tests
make run-examples
quick-test:
make quick-doc-install
make run-tests
run-starter-readme-code:
Rscript misc/build/run_starter_readme_code.R
run-examples:
Rscript misc/build/run_examples.R
run-tests:
Rscript -e "library(macpan2); $(TEST)"
run-vignette-code:
cd vignettes
Rscript misc/build/run_vignette_code.R
coverage-report:: coverage.html
coverage.html: R/*.R src/macpan2.cpp tests/testthat/*.R
#Rscript -e "covr::report(file = \"coverage.html\")"
# Some evidence that this version might be more portable
Rscript -e "covr::report(covr::package_coverage(quiet = FALSE), file = \"coverage.html\")"
misc/dev/%.run: misc/dev/%.R
cd misc/dev; Rscript ../../$^
misc/**/%.svg: misc/**/%.drawio
draw.io --export $^ --format svg
misc/**/%.png: misc/**/%.drawio
draw.io --export $^ --format png
svg-readme:: misc/readme/*.svg
png-readme:: misc/readme/*.png
readme:: README.md
README.md: README.Rmd misc/readme/*.svg R/*.R NAMESPACE
Rscript -e "rmarkdown::render('README.Rmd')"
echo '<!-- Auto-generated - do not edit by hand -->' > temp
echo '<!-- Edit README.Rmd instead -->' | cat - $@ >> temp && mv temp $@
push-readme:
make README.md
git add man/figures/*.svg
git add man/figures/*.png
git add man/figures/*.drawio
git add README.md README.Rmd
git commit -m "[skip ci] update readme" || true
git push || true
enum-update:: R/enum.R
R/enum.R: misc/dev/dev.cpp misc/build/enum_tail.R
echo "## Auto-generated - do not edit by hand" > $@
echo "valid_func_sigs = c(" >> $@
grep "$(COMMA_RE)$(ENUM_RE)" misc/dev/dev.cpp | sed 's/$(COMMA_RE)$(ENUM_RE)$(SED_RE)/ \1\"\3\"\2/' >> $@
echo ")" >> $@
cat misc/build/enum_tail.R >> $@
echo "valid_funcs = setNames(as.list(valid_funcs), valid_funcs)" >> $@
enum-meth-update:: R/enum_methods.R
R/enum_methods.R: misc/dev/dev.cpp misc/build/method_head.R misc/build/build_from_enum_methods.R
Rscript misc/build/build_from_enum_methods.R
src-update:: src/macpan2.cpp
src/macpan2.cpp: misc/dev/dev.cpp src/Makevars
echo "// Auto-generated - do not edit by hand" > $@
sed "s/#define MP_VERBOSE//" misc/dev/dev.cpp >> $@
engine-doc-update:: R/engine_functions.R
R/engine_functions.R: src/macpan2.cpp
echo "## Auto-generated - do not edit by hand" > $@
echo "" >> $@
grep "$(ROXY_RE)" $^ | sed "s/$(ROXY_RE)/\1/" >> $@
echo "#' @name engine_functions" >> $@
grep "$(COMMA_RE)$(ENUM_RE)" $^ | sed "s/$(COMMA_RE)$(ALIAS_RE)/#' @aliases \3/" >> $@
echo "NULL" >> $@
doc-update: R/*.R misc/dev/dev.cpp misc/old-r-source/*.R
echo "suppressWarnings(roxygen2::roxygenize(\".\",roclets = c(\"collate\", \"rd\", \"namespace\")))" | R --slave
touch doc-update
pkg-build:: ../macpan2_$(VERSION).tar.gz
../macpan2_$(VERSION).tar.gz: .Rbuildignore DESCRIPTION man/*.Rd R/*.R src/*.cpp tests/testthat/test-*.R tests/testthat.R inst/starter_models/**/tmb.R doc-update
cd .. && R CMD build --no-build-vignettes macpan2
touch pkg-build
pkg-check: ../macpan2_$(VERSION).tar.gz pkg-build
cd .. && R CMD check macpan2_$(VERSION).tar.gz
touch pkg-check
pkg-install: ../macpan2_$(VERSION).tar.gz pkg-build
cd .. && R CMD INSTALL --no-multiarch --install-tests macpan2_$(VERSION).tar.gz
compile-dev: misc/dev/dev.cpp
cd misc/dev; echo "TMB::compile(\"dev.cpp\")" | R --slave
inst/starter_models/%/README.md: inst/starter_models/%/README.Rmd
echo "rmarkdown::render(\"$^\")" | R --slave
inst/starter_models/%/README.push: inst/starter_models/%/README.md
@echo Pushing directory: $(dir $^)
git add -u $(dir $^)
git commit -m "[skip ci] work on starter models"
git push
touch $@
all-starters: inst/starter_models/*/README.push