-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
174 lines (141 loc) · 4.14 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
R=R
REXEC=$(R) -q -e
MAKE:=$(MAKE) --no-print-directory
package=W4MRUtils
version = $(shell grep -Po "Version: .*" ./DESCRIPTION |cut -d \ -f 2)
use_kind = Imports
sources_files=$(shell ls R/*.R)
test_files=$(shell ls tests/testthat/*.R)
all_R_files=$(sources_files) $(test_files)
package_tgz=$(package)_$(version).tar.gz
man_rd_files=$(shell ls man/*.Rd)
man_html_files=$(man_rd_files:%.Rd=%.html)
vignettes_rd_files=$(shell ls vignettes/*.Rmd)
vignettes_html_files=$(vignettes_rd_files:%.Rmd=%.html)
TARGET = CRAN
# TARGET = BIOC
CHECK = $(REXEC) "devtools::check(pkg = '$(shell pwd)')"
ifeq ($(TARGET),CRAN)
CHECK = $(R) CMD check --as-cran $(package_tgz)
endif
ifeq ($(TARGET),BIOC)
CHECK = $(R) CMD BiocCheck $(package_tgz)
endif
all: clean doc test build check lint install
clean: clean_html clean_namespace
clean_html: clean_man_html clean_vign_html
install: doc test quick_install
test: quick_install quick_test report
build: $(package_tgz)
doc: README.md docfiles
NAMESPACE: simple_document
docfiles: simple_document
$(REXEC) 'pkgdown::build_site()'
simple_document:
@$(REXEC) "devtools::document('.')"
README.md: README.Rmd
$(REXEC) "rmarkdown::render('README.Rmd')"
check: build
@echo "Checking package..."
@-( \
cp $(package_tgz) /tmp/ ; \
cd /tmp/ ; \
$(CHECK) ; \
) ;
@echo "Checked."
$(package_tgz): \
$(all_R_files) \
vignettes/*.Rmd \
man/*.Rd \
README.md \
.Rbuildignore \
inst/extdata/* \
DESCRIPTION \
NAMESPACE
@echo "Building package..."
@$(R) CMD build "."
@echo "Built."
ifneq ("$(NO_REPORT)","")
report:
@echo "[NO_REPORT=$(NO_REPORT)]: reporting cancelled."
else
report: coverage.html
endif
coverage.html: $(all_R_files) $(package_tgz)
@echo "Doing reporting:"
@$(REXEC) 'covr::report(covr::package_coverage(), "coverage.html")'
quick_test: $(all_R_files)
@echo "Running tests..."
@$(REXEC) "devtools::test('.')"
@echo "Finished."
quick_install:
$(REXEC) 'devtools::install(".", dependencies=FALSE, repos=NULL, type="source")'
uninstall:
@$(REXEC) 'if ("$(package)" %in% rownames(installed.packages()))remove.packages("$(package)")'
clean_namespace:
@- rm NAMESPACE
clean_man_html:
@- rm man/*.html
clean_vign_html:
@- rm vignettes/*.html
lint:
@$(REXEC) 'lintr::lint_dir("R")'
remove_%.html:
rm $*
help:
@echo ""
@echo "Les variables en haut du Makefile peuvent être modifiées en fonction"
@echo "de votre configuration."
@echo ""
@echo "Par exemple, si pour appeller R, vous avez besoin de lancer"
@echo " la commande \`/var/R-4.2.3/bin/R\`"
@echo "alors vous pouvez redéfinir la variable R comme suit:"
@echo "R=/var/R-4.2.3/bin/R"
@echo ""
@echo "Les différentes règles les plus intéressantes:"
@echo ""
@echo " - check:"
@echo " Build le package, puis lance les checks."
@echo " Peut-être l'une des commandes les plus" "importantes avec la"
@echo " commande \`make doc\`"
@echo " Pour checker selon les standards du cran ou de bioconductor,"
@echo " vous pouvez le lancer comme tel:"
@echo " - \`TARGET=CRAN make check\`"
@echo " - \`TARGET=BIOC make check\`"
@echo ""
@echo " - doc:"
@echo " Produit tous les fichiers de doc"
@echo " et transforme le README.Rmd en README.md"
@echo ""
@echo " - README.md:"
@echo " Génère ce fichier à partir du .Rmd"
@echo ""
@echo " - install:"
@echo " Génère la documentation, lance les testes unitaires et"
@echo " installe le package en local"
@echo ""
@echo " - test:"
@echo " Lance les testes unitaires,"
@echo " et produit le rapport de couverture de code"
@echo ""
@echo " - build: "
@echo " Créé le .tar.gz du package"
@echo ""
@echo " - uninstall:"
@echo " Désinstalle ce package."
@echo ""
@echo " - lint:"
@echo " Lance le linteur R sur le package"
@echo ""
@echo " - clean:"
@echo " Supprime les fichiers générés par ce makefile"
@echo ""
@echo " - all: (ou juste \`make\`, suivi de rien du tout)"
@echo " Lances les commandes suivantes:"
@echo " - clean"
@echo " - doc"
@echo " - test"
@echo " - build"
@echo " - check"
@echo " - lint"
@echo " - install"