-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (61 loc) · 2.46 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
rscript = Rscript --no-save --no-restore
# Deployment configuration
deploy_remote ?= origin
deploy_branch ?= master
deploy_source ?= develop
.PHONY: all
all: documentation vignettes
.PHONY: deploy
## Deploy the code with documentation to Github
deploy: update-master
git add --force NAMESPACE
git add --force man
git add --force doc
git commit --message Deployment
git push --force ${deploy_remote} ${deploy_branch}
git checkout ${deploy_source}
git checkout DESCRIPTION # To undo Roxygen meddling with file
.PHONY: update-master
update-master:
git checkout ${deploy_source}
-git branch --delete --force ${deploy_branch}
git checkout -b ${deploy_branch}
${MAKE} documentation vignettes
.PHONY: test
## Run unit tests
test:
${rscript} -e "devtools::test()"
test-%:
${rscript} -e "devtools::test(filter = '$*')"
.PHONY: vignettes
## Compile all vignettes and other R Markdown articles
vignettes: knit_all
${rscript} -e "devtools::build_vignettes(clean = FALSE, install = FALSE)"
# Delete intermediate files generated by Rcpp
${RM} {doc,vignettes}/rcpp/convolve.{so,rds} vignettes/convolve.cpp.R
rmd_files=$(wildcard vignettes/*.rmd)
knit_results=$(patsubst vignettes/%.rmd,doc/%.md,${rmd_files})
.PHONY: knit_all
## Compile R markdown articles and move files to the documentation directory
knit_all: ${knit_results} | doc
cp -r vignettes/* doc
doc:
mkdir -p $@
doc/%.md: vignettes/%.rmd | doc
${rscript} -e "rmarkdown::render('$<', output_format = 'md_document', output_file = '$@', output_dir = '$(dir $@)')"
.PHONY: documentation
## Compile the in-line package documentation
documentation:
# Note: this needs to be run twice to generate correct S3 exports; see
# <https://github.com/hadley/devtools/issues/1585>
${rscript} -e "library(devtools); document(); document()"
## Clean up all build files
cleanall:
${RM} -r doc
${RM} -r man
${RM} NAMESPACE
.DEFAULT_GOAL := show-help
# See <https://gist.github.com/klmr/575726c7e05d8780505a> for explanation.
.PHONY: show-help
show-help:
@echo "$$(tput bold)Available rules:$$(tput sgr0)";echo;sed -ne"/^## /{h;s/.*//;:d" -e"H;n;s/^## //;td" -e"s/:.*//;G;s/\\n## /---/;s/\\n/ /g;p;}" ${MAKEFILE_LIST}|LC_ALL='C' sort -f|awk -F --- -v n=$$(tput cols) -v i=19 -v a="$$(tput setaf 6)" -v z="$$(tput sgr0)" '{printf"%s%*s%s ",a,-i,$$1,z;m=split($$2,w," ");l=n-i;for(j=1;j<=m;j++){l-=length(w[j])+1;if(l<= 0){l=n-i-length(w[j])-1;printf"\n%*s ",-i," ";}printf"%s ",w[j];}printf"\n";}'|more $(shell test $(shell uname) == Darwin && echo '-Xr')