forked from kaz-yos/tableone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (86 loc) · 3.81 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
## Makefile for generating R packages.
## original by 2011 Andrew Redd
## https://gist.github.com/halpo/1374344
## Modified by kaz-yos for a different directory structure.
## To be put in the package directory.
## The build and check output files are put in the package directory.
## These files as well as Makefile have to be .Rbuildignore.
## writing rules
## https://www.gnu.org/software/make/manual/html_node/Rules.html#Rules
## Extract the package name and version from the DESCRIPTION file.
PKG_NAME=$(shell grep -i ^package: DESCRIPTION | cut -d : -d \ -f 2)
PKG_VERSION=$(shell grep -i ^version: DESCRIPTION | cut -d : -d \ -f 2)
## Define files to check for updates
R_FILES := $(wildcard R/*.R)
TST_FILES := $(wildcard tests/testthat/*.R)
SRC_FILES := $(wildcard src/*) $(addprefix src/, $(COPY_SRC))
VIG_FILES := $(wildcard vignettes/*)
PKG_FILES := DESCRIPTION NAMESPACE NEWS $(R_FILES) $(TST_FILES) $(SRC_FILES) $(VIG_FILES)
## .PHONY to allow non-file targets (file targets should not be here)
## https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: test winbuild vignettes readme pkgdown build check check_devtools revdep install clean
### Define targets
## test just runs testthat scripts. No dependencies.
test: NAMESPACE
Rscript -e "options(width = 120); devtools::test()" | tee test-all.txt
## winbuild always build regardless of file update status
## Links to results e-mailed (no useful output locally)
winbuild:
Rscript -e "devtools::check_win_devel()"
Rscript -e "devtools::check_win_release()"
## Build vignettes in inst/doc
vignettes:
Rscript -e "devtools::build_vignettes()"
## Build README.md
readme: README.Rmd
Rscript -e "rmarkdown::render('README.Rmd', output_format = 'md_document', output_file = 'README.md')"
## Build website
## https://pkgdown.r-lib.org
pkgdown: vignettes readme NAMESPACE
Rscript -e "pkgdown::build_site()"
## build depends on the *.tar.gz file, i.e., its own product.
## *.tar.gz file is defined seprately to prevent build execution on every invocation.
build: $(PKG_NAME)_$(PKG_VERSION).tar.gz
## (file target) The *.tar.gz file depends on package files including NAMESPACE,
## and build *.tar.gz file from these.
$(PKG_NAME)_$(PKG_VERSION).tar.gz: $(PKG_FILES)
Rscript -e "devtools::build(pkg = '.', path = '.', manual = TRUE)"
## (file target) NAMESPACE depends on *.R files, and excecute roxygen2 on these.
## methods::is() is not automatically loaded by roxygen2 version 4
NAMESPACE: $(R_FILES)
Rscript -e "devtools::document('.')"
## check requires the *.tar.gz file, and execute strict tests on it.
check: $(PKG_NAME)_$(PKG_VERSION).tar.gz
R CMD check --as-cran ./$(PKG_NAME)_$(PKG_VERSION).tar.gz | tee cran-check.txt
check_devtools: $(PKG_NAME)_$(PKG_VERSION).tar.gz
Rscript -e "options(width = 120); devtools::check(pkg = '.', check_dir = '.', manual = TRUE)" | tee cran-check.txt
## revdep requires the *.tar.gz file, and execute strict tests on it.
## https://github.com/r-lib/revdepcheck
revdep: $(PKG_NAME)_$(PKG_VERSION).tar.gz
Rscript -e "devtools::revdep()"
Rscript -e "options(width = 120); revdepcheck::revdep_check(num_workers = 6); revdepcheck::revdep_summary()" | tee revdep_check.txt
revdep_clean:
Rscript -e "revdepcheck::revdep_reset()"
## install requires the *.tar.gz file, and execute installation using it.
install: $(PKG_NAME)_$(PKG_VERSION).tar.gz
Rscript -e "devtools::install('.')"
## clean has no dependency, and execute removal of make output files.
clean: revdep_clean
-rm -f $(PKG_NAME)_$(PKG_VERSION).tar.gz
-rm -r -f $(PKG_NAME).Rcheck
-rm -r -f man/*.Rd
-rm -r -f NAMESPACE
## Define a target "list" that just prints the names of files.
.PHONY: list
list:
@echo "R files:"
@echo $(R_FILES)
@echo
@echo "Test files:"
@echo $(TST_FILES)
@echo
@echo "Source files:"
@echo $(SRC_FILES)
@echo
@echo "Vignettes:"
@echo $(VIG_FILES)