-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.R
More file actions
executable file
·162 lines (81 loc) · 2.28 KB
/
build.R
File metadata and controls
executable file
·162 lines (81 loc) · 2.28 KB
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
#!/usr/bin/env Rscript
require(docopt, quietly = TRUE, warn.conflicts = FALSE)
require(methods, quietly = TRUE, warn.conflicts = FALSE)
docs <- list()
"
Name:
build: a hacky build script.
Usage:
build profile [--previous=<num>] [--time=<time>]
build redocument
build install
build parse
build test
Tasks:
redocument - roxygenise (roxygenate surely?) the documentation. Currently
fixes an issue I'm having where Rcpp's dependencies is stripped from the NS on rebuild.
parse - test that the code parses. Faster than rebuilding.
install - build the package and redocument.
test - run the tests.
Options:
--previous=<num> the maximum number of previous releases to examine [default: Inf]
--time=<time> the total time to run benchmarks for, in seconds [default: 600]
" -> docs $ master
tasks <- local({
self <- list()
sh <- function (...) {
system(paste0(...))
}
self $ redocument <- function () {
devtools :: document(roclets = c('rd', 'collate', 'namespace'))
namespace <- file.path(getwd(), 'NAMESPACE')
write('useDynLib(kea)', file = namespace, append = TRUE)
write('importFrom(Rcpp, sourceCpp)', file = namespace, append = TRUE)
}
self $ parse <- function () {
r_paths <- list.files(getwd(),
pattern = '[.]R$|[.]r',
recursive = TRUE,
full.names = TRUE
)
sapply(r_paths, function (fpath) {
tryCatch(
parse(fpath, keep.source = FALSE),
error = function (err) {
write(paste('could not parse', fpath), stderr())
}
)
})
invisible(NULL)
}
self $ install <- function () {
sh('R CMD INSTALL ', getwd())
self $ redocument()
}
self $ profile <- function (previous, time) {
profile <- file.path(getwd(), 'inst/profile_all_versions.R')
sh(profile, ' --previous=', previous, ' --time=', time)
}
self $ test <- function () {
devtools::check(document = FALSE)
}
self
})
main <- function (args) {
if (args $ redocument) {
tasks $ redocument()
}
if (args $ parse) {
tasks $ parse()
}
if (args $ install) {
tasks $ install()
}
if (args $ profile) {
tasks $ profile(args $ `--previous`, args $ `--time`)
}
if (args $ test) {
tasks $ test()
}
}
main(docopt(docs $ master))