Skip to content

Commit 1ed6c75

Browse files
committed
Reformat source using air
1 parent 8e3d708 commit 1ed6c75

File tree

4 files changed

+93
-44
lines changed

4 files changed

+93
-44
lines changed

R/build.R

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
#'
1515
#' @importFrom pkgdepends new_pkg_download_proposal
1616
#' @export
17-
build <- function(packages,
18-
out_dir = ".",
19-
remotes = NULL,
20-
dependencies = FALSE,
21-
compress = TRUE) {
17+
build <- function(
18+
packages,
19+
out_dir = ".",
20+
remotes = NULL,
21+
dependencies = FALSE,
22+
compress = TRUE
23+
) {
2224
tmp_dir <- tempfile()
2325
on.exit(unlink(tmp_dir, recursive = TRUE))
2426
dir.create(tmp_dir)
@@ -110,8 +112,11 @@ wasm_build <- function(pkg, tarball_path, contrib_bin, compress) {
110112
desc <- packageDescription(pkg, lib.loc = tmp_dir, fields = "Built")
111113
if (!is.na(desc)) {
112114
stop(paste0(
113-
"Unable to build Wasm package: '", pkg,
114-
"'. Source tarball at '", tarball_path, "' is a binary."
115+
"Unable to build Wasm package: '",
116+
pkg,
117+
"'. Source tarball at '",
118+
tarball_path,
119+
"' is a binary."
115120
))
116121
}
117122

@@ -193,11 +198,20 @@ wasm_build <- function(pkg, tarball_path, contrib_bin, compress) {
193198
# Build the package
194199
status <- withr::with_dir(
195200
tmp_dir,
196-
system2(host_r_bin,
201+
system2(
202+
host_r_bin,
197203
args = c(
198-
"CMD", "INSTALL", "--build", paste0("--library=", lib_dir), pkg,
199-
"--no-docs", "--no-html", "--no-test-load", "--no-staged-install",
200-
"--no-byte-compile", configure_flag
204+
"CMD",
205+
"INSTALL",
206+
"--build",
207+
paste0("--library=", lib_dir),
208+
pkg,
209+
"--no-docs",
210+
"--no-html",
211+
"--no-test-load",
212+
"--no-staged-install",
213+
"--no-byte-compile",
214+
configure_flag
201215
),
202216
env = webr_env
203217
)

R/lib.R

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ make_library <- function(repo_dir = "./repo", lib_dir = "./lib", strip = NULL) {
2020
fs::dir_create(lib_dir)
2121
r_version <- R_system_version(getOption("rwasm.webr_version"))
2222
contrib_bin <- fs::path(
23-
repo_dir, "bin", "emscripten", "contrib",
23+
repo_dir,
24+
"bin",
25+
"emscripten",
26+
"contrib",
2427
paste0(r_version$major, ".", r_version$minor)
2528
)
2629

@@ -63,7 +66,10 @@ make_library <- function(repo_dir = "./repo", lib_dir = "./lib", strip = NULL) {
6366
make_vfs_repo <- function(repo_dir = "./repo", compress = FALSE) {
6467
r_version <- R_system_version(getOption("rwasm.webr_version"))
6568
contrib_bin <- fs::path(
66-
repo_dir, "bin", "emscripten", "contrib",
69+
repo_dir,
70+
"bin",
71+
"emscripten",
72+
"contrib",
6773
paste0(r_version$major, ".", r_version$minor)
6874
)
6975

@@ -114,11 +120,13 @@ make_vfs_repo <- function(repo_dir = "./repo", compress = FALSE) {
114120
#' @inheritDotParams make_library strip
115121
#'
116122
#' @export
117-
make_vfs_library <- function(out_dir = "./vfs",
118-
out_name = "library.data",
119-
repo_dir = "./repo",
120-
compress = FALSE,
121-
...) {
123+
make_vfs_library <- function(
124+
out_dir = "./vfs",
125+
out_name = "library.data",
126+
repo_dir = "./repo",
127+
compress = FALSE,
128+
...
129+
) {
122130
lib_dir <- fs::path(tempfile())
123131
lib_abs <- fs::path_abs(lib_dir)
124132
on.exit(unlink(lib_dir, recursive = TRUE), add = TRUE)
@@ -153,10 +161,12 @@ make_vfs_library <- function(out_dir = "./vfs",
153161
#' @param compress Logical. If `TRUE`, a compressed version of the filesystem
154162
#' data is included in the output. Defaults to `FALSE`.
155163
#' @export
156-
file_packager <- function(in_dir,
157-
out_dir = "./vfs",
158-
out_name = NULL,
159-
compress = FALSE) {
164+
file_packager <- function(
165+
in_dir,
166+
out_dir = "./vfs",
167+
out_name = NULL,
168+
compress = FALSE
169+
) {
160170
fs::dir_create(out_dir)
161171

162172
if (is.null(out_name)) {
@@ -168,7 +178,9 @@ file_packager <- function(in_dir,
168178
message(paste("Packaging:", data_file))
169179

170180
file_packager <- fs::path(
171-
getOption("rwasm.emscripten_root"), "tools", "file_packager"
181+
getOption("rwasm.emscripten_root"),
182+
"tools",
183+
"file_packager"
172184
)
173185

174186
# Pack the contents of in_dir with Emscripten's `file_packager`
@@ -178,8 +190,11 @@ file_packager <- function(in_dir,
178190
system2(
179191
file_packager,
180192
args = c(
181-
data_file, "--preload", sprintf("'%s@/'", in_dir),
182-
"--separate-metadata", sprintf("--js-output='%s'", js_file)
193+
data_file,
194+
"--preload",
195+
sprintf("'%s@/'", in_dir),
196+
"--separate-metadata",
197+
sprintf("--js-output='%s'", js_file)
183198
),
184199
stdout = TRUE,
185200
stderr = TRUE

R/repo.R

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ add_repo <- function(repos = ppm_config$cran_mirror, skip = FALSE, ...) {
3131
mutate(
3232
sources = as.list(sprintf(
3333
"%s/%s_%s.tar.gz",
34-
.data$Repository, .data$package, .data$version
34+
.data$Repository,
35+
.data$package,
36+
.data$version
3537
)),
3638
target = sprintf(
37-
"src/contrib/%s_%s.tar.gz", .data$package, .data$version
39+
"src/contrib/%s_%s.tar.gz",
40+
.data$package,
41+
.data$version
3842
),
3943
ref = .data$package,
4044
status = "OK"
@@ -87,11 +91,13 @@ add_list <- function(list_file, ...) {
8791
#' @importFrom dplyr rows_update select
8892
#' @importFrom pkgdepends new_pkg_download_proposal
8993
#' @export
90-
add_pkg <- function(packages,
91-
repo_dir = "./repo",
92-
remotes = NA,
93-
dependencies = FALSE,
94-
compress = TRUE) {
94+
add_pkg <- function(
95+
packages,
96+
repo_dir = "./repo",
97+
remotes = NA,
98+
dependencies = FALSE,
99+
compress = TRUE
100+
) {
95101
# Set up pkgdepends configuration
96102
config <- ppm_config
97103
config$dependencies <- dependencies
@@ -116,7 +122,10 @@ rm_pkg <- function(packages, repo_dir = "./repo") {
116122
r_version <- R_system_version(getOption("rwasm.webr_version"))
117123
contrib_src <- fs::path(repo_dir, "src", "contrib")
118124
contrib_bin <- fs::path(
119-
repo_dir, "bin", "emscripten", "contrib",
125+
repo_dir,
126+
"bin",
127+
"emscripten",
128+
"contrib",
120129
paste0(r_version$major, ".", r_version$minor)
121130
)
122131

@@ -137,7 +146,10 @@ write_packages <- function(repo_dir = "./repo") {
137146
r_version <- R_system_version(getOption("rwasm.webr_version"))
138147
contrib_src <- fs::path(repo_dir, "src", "contrib")
139148
contrib_bin <- fs::path(
140-
repo_dir, "bin", "emscripten", "contrib",
149+
repo_dir,
150+
"bin",
151+
"emscripten",
152+
"contrib",
141153
paste0(r_version$major, ".", r_version$minor)
142154
)
143155
update_packages(contrib_src, contrib_bin)
@@ -184,18 +196,23 @@ prefer_remotes <- function(package_info, remotes = NA) {
184196
}
185197

186198
# Build packages and update a CRAN-like repo on disk
187-
update_repo <- function(package_info,
188-
remotes = NA,
189-
repo_dir = "./repo",
190-
compress = TRUE) {
199+
update_repo <- function(
200+
package_info,
201+
remotes = NA,
202+
repo_dir = "./repo",
203+
compress = TRUE
204+
) {
191205
r_version <- R_system_version(getOption("rwasm.webr_version"))
192206

193207
writeLines(sprintf("Processing %d package(s).", nrow(package_info)))
194208

195209
# Create contrib paths
196210
contrib_src <- fs::path(repo_dir, "src", "contrib")
197211
contrib_bin <- fs::path(
198-
repo_dir, "bin", "emscripten", "contrib",
212+
repo_dir,
213+
"bin",
214+
"emscripten",
215+
"contrib",
199216
paste0(r_version$major, ".", r_version$minor)
200217
)
201218
fs::dir_create(contrib_src)
@@ -283,10 +300,12 @@ update_repo <- function(package_info,
283300
}
284301

285302
update_packages <- function(contrib_src, contrib_bin) {
286-
if (any(c(
287-
grepl(".tar.gz", fs::dir_ls(contrib_src)),
288-
grepl(".tgz", fs::dir_ls(contrib_bin))
289-
))) {
303+
if (
304+
any(c(
305+
grepl(".tar.gz", fs::dir_ls(contrib_src)),
306+
grepl(".tgz", fs::dir_ls(contrib_bin))
307+
))
308+
) {
290309
tools::write_PACKAGES(contrib_src, verbose = TRUE)
291310
tools::write_PACKAGES(contrib_bin, verbose = TRUE, type = "mac.binary")
292311
invisible(TRUE)

R/tar.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ add_tar_index <- function(file, strip = 0) {
3030
# Check if our tar is compatible
3131
if (!any(file_ext == c("tgz", "gz", "tar"))) {
3232
stop(paste0(
33-
"Can't make index for \"", file,
33+
"Can't make index for \"",
34+
file,
3435
"\". Only uncompressed or `gzip` compressed tar files can be indexed."
3536
))
3637
}

0 commit comments

Comments
 (0)