-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
196 lines (164 loc) · 8.67 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
PACKAGEVERSION=$(shell sh -c 'grep -F "Version: " DESCRIPTION | cut -f2 -d" "')
PACKAGE=$(shell sh -c 'grep -F "Package: " DESCRIPTION | cut -f2 -d" "')
# FIXME: This Makefile only works with this BINDIR!
BINDIR=$(CURDIR)/..
RNODE=iridiacluster
RDIR=~/
INSTALL_FLAGS=--with-keep.source
BUILD_FLAGS=
PACKAGEDIR=$(CURDIR)
PDFLATEX=pdflatex -shell-escape -file-line-error -halt-on-error -interaction=nonstopmode "\input"
RHUB_COMMON_ARGS= path='$(BINDIR)/$(PACKAGE)_$(PACKAGEVERSION).tar.gz', env_vars = c('_R_CHECK_FORCE_SUGGESTS_'='false', R_DEFAULT_SAVE_VERSION='2', R_DEFAULT_SERIALIZE_VERSION='2')
Reval=R --slave -e
Rversion=$(R --version | head -n -1 | grep -m 1 -o -e [0-9] | head -n 1)
ifeq ($(Rversion),2)
NO_BUILD_VIGNETTES='--no-vignettes'
else
NO_BUILD_VIGNETTES='--no-build-vignettes'
endif
define Rsed
R --slave --vanilla -e 'f <- "$(1)"; txt <- sub($(2), $(3), perl=TRUE, readLines(f)); writeLines(txt, f)'
endef
.PHONY : help build check clean install pdf rsync submit cran winbuild vignettes examples releasecheck genoptions gendoc pkgdown version revdepcheck
help:
@echo "quick-install install the package without rebuilding the vignettes or generating the documentation"
@echo "setup install required packages and software to build"
@echo "install install the package"
@echo "build build the package as a tar.gz file"
@echo "check build the package and run 'R CMD check'"
@echo "test run all tests under testthat"
@echo "test TEST=x run test called test-x.R"
@echo "rsync copy the package and install it on $(RNODE)"
@echo "cran build the package and run 'R CMD check --as-cran'"
@echo "winbuild submit the package to the WINDOWS builder service"
@echo "macbuild submit the package to the MacOS builder service"
@echo "examples regenerate the examples used by vignettes"
@echo "vignettes generate PDF of the vignettes"
@echo "submit submit the package to CRAN (read DEVEL-README first)"
setup:
./scripts/setup.sh
@test -f $(PACKAGEDIR)/vignettes/optbib/.git || git submodule update --init
install: build
cd $(BINDIR) && R CMD INSTALL $(INSTALL_FLAGS) $(PACKAGE)_$(PACKAGEVERSION).tar.gz
quick-install:
R CMD INSTALL $(INSTALL_FLAGS) --no-docs $(PACKAGEDIR)
genoptions: R/irace-options.R vignettes/section/irace-options.tex
R/irace-options.R vignettes/section/irace-options.tex: scripts/irace_options.json scripts/generate-options.R
cd scripts && R --slave -f generate-options.R && cd ..
touch R/irace-options.R vignettes/section/irace-options.tex
gendoc:
$(Reval) 'devtools::document()'
pkgdown: gendoc
$(Reval) 'pkgdown::build_site()'
@$(MAKE) clean
build:
@$(MAKE) genoptions
$(MAKE) releasevignette
@if grep -q @ $(PACKAGEDIR)/vignettes/$(PACKAGE)-package.bib; then true; \
else echo "error: vignettes/$(PACKAGE)-package.bib is empty: run 'make vignettes'"; false; fi
cd $(BINDIR) && R CMD build $(BUILD_FLAGS) $(PACKAGEDIR)
@$(MAKE) clean
closeversion:
git push origin :refs/tags/v$(PACKAGEVERSION) # Remove any existing tag
git tag -f -a v$(PACKAGEVERSION) -m "Version $(PACKAGEVERSION)"
git push && git push --tags
vignettes/$(PACKAGE)-package.bib: vignettes/$(PACKAGE)-package.aux
cd $(PACKAGEDIR)/vignettes \
&& aux2bib $(PACKAGE)-package.aux | grep -v '@comment' > tmp-$(PACKAGE)-package.bib \
&& mv tmp-$(PACKAGE)-package.bib $(PACKAGE)-package.bib
releasevignette: gendoc
test -s $(PACKAGEDIR)/vignettes/$(PACKAGE)-package.bib || $(MAKE) nonreleasevignette
@$(call Rsed,$(PACKAGEDIR)/vignettes/$(PACKAGE)-package.Rnw,"^\\\\setboolean{Release}{false}","\\\\setboolean{Release}{true}")
nonreleasevignette:
@$(call Rsed,$(PACKAGEDIR)/vignettes/$(PACKAGE)-package.Rnw,"^\\\\setboolean{Release}{true}","\\\\setboolean{Release}{false}")
$(MAKE) vignettes
$(MAKE) vignettes/$(PACKAGE)-package.bib
releasebuild: BUILD_FLAGS=--compact-vignettes=qpdf
releasebuild: releasevignette
cd $(BINDIR) && R CMD build $(BUILD_FLAGS) $(PACKAGEDIR) && tar -atvf $(PACKAGE)_$(PACKAGEVERSION).tar.gz
# Let's try to compact vignettes further (not needed for R > 3.6.1)
./scripts/recompact.sh $(BINDIR)/$(PACKAGE)_$(PACKAGEVERSION).tar.gz \
$(PACKAGE)/inst/doc/$(PACKAGE)-package.pdf
cran: releasebuild
cd $(BINDIR) && _R_CHECK_FORCE_SUGGESTS_=false _R_CHECK_CRAN_INCOMING_REMOTE_=true _R_CHECK_CRAN_INCOMING_=true R CMD check --as-cran --install-args="$(INSTALL_FLAGS)" $(PACKAGE)_$(PACKAGEVERSION).tar.gz
revdepcheck:
$(Reval) 'devtools::install_github("r-lib/revdepcheck", ref="main", upgrade="never");revdepcheck::revdep_check(bioc=FALSE)'
releasecheck: cran
$(Reval) 'urlchecker::url_check()'
$(MAKE) winbuild
$(MAKE) macbuild
check: build
test -d ./GenericWrapper4AC/build || (cd GenericWrapper4AC && python3 setup.py install --user)
cd $(BINDIR) && (_R_CHECK_FORCE_SUGGESTS_=false NOT_CRAN=true R CMD check --run-donttest --timings --install-args="$(INSTALL_FLAGS)" $(PACKAGE)_$(PACKAGEVERSION).tar.gz; cat $(PACKAGE).Rcheck/$(PACKAGE)-Ex.timings)
# Using testthat nicer output.
test: clean
ifdef TEST
_R_CHECK_FORCE_SUGGESTS_=false NOT_CRAN=true $(Reval) 'devtools::test(filter="$(TEST)", stop_on_failure = TRUE)'
else
_R_CHECK_FORCE_SUGGESTS_=false NOT_CRAN=true $(Reval) 'testthat::test_local(stop_on_failure = TRUE)'
endif
clean:
cd $(PACKAGEDIR) && (./cleanup; make -C src -f Makevars clean)
## FIXME: building the vignettes is a bit complicated and sometimes fails.
# If \setboolean{Release}{false}, entries are taken from optbib and everything
# should work. However, we cannot build the package like this because we cannot
# distribute optbib. So when \setboolean{Release}{true}, we take entries from
# irace-package.bib, to obtain irace-package.bib, we need to build with
# \setboolean{Release}{false}, use aux2bib on the .aux file, then set
# \setboolean{Release}{true}, then rebuild again. Ideally:
#
# make vignettes' or 'make pdf' should build in whatever Release value we have
# and do whatever is necessary to get it working.
#
# make build/check/cran/install/releasebuild should build with Release as true
# and do whatever is necessary to get it working, but avoid doing extra
# work. For example, if irace-package.bib is non-empty, then do not build two
# times with Release false and then with Release true.
#
# make nonreleasevignette should build with Release as false (which is faster and should always work).
#
# It is ok to fail if something is missing or needs to be done and give a nice error. For example, if optbib is missing.
vignettes: vignettes/$(PACKAGE)-package.Rnw vignettes/section/irace-options.tex
# FIXME: How to display the output of the latex and bibtex commands with R CMD?
# FIXME: How to halt on warning?
@test -f $(PACKAGEDIR)/vignettes/optbib/.git || git submodule update --init
cd $(PACKAGEDIR)/vignettes \
&& R CMD Sweave --pdf --compact $(PACKAGE)-package.Rnw \
&& $(RM) $(PACKAGE)-package.tex
# Rscript -e "library(knitr); knit('$(PACKAGE)-package.Rnw', output='$(PACKAGE)-package.tex', quiet = TRUE)" \
# && $(PDFLATEX) $(PACKAGE)-package.tex && bibtex $(PACKAGE)-package && $(PDFLATEX) $(PACKAGE)-package.tex && $(PDFLATEX) $(PACKAGE)-package.tex && $(RM) $(PACKAGE)-package.tex
pdf: build
R CMD Rd2pdf --force --no-preview --batch --output=$(BINDIR)/$(PACKAGE)_$(PACKAGEVERSION).pdf $(PACKAGEDIR)/
rsync:
ifndef RDIR
@echo "ERROR: You must specify a remote dir (e.g., RDIR=~/)"
@exit 1
endif
ifndef RNODE
@echo "ERROR: You must specify a remote node (e.g., RNODE=majorana)"
@exit 1
else
rsync -rlp -CIzc -L --delete --copy-unsafe-links --exclude=.svn --exclude=.git --exclude=web --exclude=/devel-examples/ --progress --relative \
. \
$(RNODE):$(RDIR)/$(PACKAGE)/
ssh $(RNODE) '. ~/.profile && cd $(RDIR)/$(PACKAGE) && make quick-install'
endif
submit:
@echo 'Edit cran-comments.md and run devtools::release() in R'
remotecran: releasebuild
$(Reval) "rhub::check_for_cran($(RHUB_COMMON_ARGS), show_status = TRUE)"
macbuild: releasebuild
$(Reval) "rhub::check(platform='macos-highsierra-release-cran', $(RHUB_COMMON_ARGS))"
winbuild: releasebuild
$(Reval) "devtools::check_win_release()"
$(Reval) "devtools::check_win_devel()"
$(Reval) "rhub::check_on_windows($(RHUB_COMMON_ARGS))"
examples: quick-install
@echo "*** Makefile: Regenerating data for vignettes and examples. This will take time..."
cd devel-examples/vignette-example/ && R --vanilla --slave --file=create-example-file.R
mv -t inst/exdata/ devel-examples/vignette-example/log-ablation.Rdata devel-examples/vignette-example/irace-acotsp.Rdata devel-examples/vignette-example/sann.rda
mv -t vignettes/ devel-examples/vignette-example/*.Rdata devel-examples/vignette-example/irace-acotsp-stdout.txt
$(MAKE) vignettes
$(MAKE) check
covr: build
$(Reval) "Sys.setenv(NOT_CRAN='true');covr::report(covr::package_coverage(type='all'))"