-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
39 lines (28 loc) · 1.22 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
MAKEFILES = $(shell find . -mindepth 2 -maxdepth 2 -name Makefile)
MDIRS = $(filter-out ./sys/,$(dir $(MAKEFILES)))
RSCRIPTS = $(wildcard *[^_].r)
RSCRIPTS_T = $(shell grep -l testthat $(RSCRIPTS) /dev/null)
RSCRIPTS_NO_T = $(filter-out $(RSCRIPTS_T),$(RSCRIPTS))
DEPS=$(shell ./dependencies.sh)
R_PKG=modules,$(shell Rscript -e 'cat(sub("package:", "", grep("^package:", search(), value=TRUE)), sep=",")')
Rscript = Rscript --no-save --no-restore --slave --default-packages=$(R_PKG)
.PHONY: prepare test install-deps
define \n
endef
prepare::
@$(foreach DIR,$(MDIRS),make -C $(DIR) prepare$(\n))
test::
@$(foreach DIR,$(MDIRS),make -C $(DIR) test$(\n))
$(if $(RSCRIPTS_NO_T), @echo "*** NO TESTS FOUND FOR: $(RSCRIPTS_NO_T) ***", )
@$(foreach R,$(RSCRIPTS_T),echo $(R); $(Rscript) $(R)$(\n))
install-deps: dependencies.txt
R -e "req = read.table('dependencies.txt', header=FALSE)[[1]]" \
-e "new = setdiff(req, installed.packages()[,'Package'])" \
-e "cat(new, \"\\n\")" \
-e "BiocManager::install(new)"
DESCRIPTION: DESCRIPTION.in dependencies.txt
sed "s/^/\ \ \ \ /" $(word 2,$^) | sed 's/$$/,/' | sed -e "/@@@/r /dev/stdin" -e "/@@@/d" $< > $@
dependencies.txt: dependencies.sh
bash $< > $@
print-%:
@echo $* = $($*)