Created
June 29, 2023 17:35
-
-
Save aavogt/0176120f5cefe935d5c92941d8ca37af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(glue) | |
library(stringr) | |
require(rlang) | |
require(rextendr) | |
# drop-in replacement for rextendr::rust_source | |
# use a build directory in the current working directory | |
# if the source file is lib.rs the build is in lib_build | |
# code= needed for https://github.com/extendr/rextendr/issues/234 | |
rust_source <- function(file, code= paste0(readLines(file), collapse="\n"), features="ndarray", ...) { | |
# https://github.com/extendr/rextendr/issues/291 | |
rlang::env_bind(rextendr:::the, build_dir = { | |
b <- file.path(getwd(), glue("{str_remove(file, '.rs')}_build")) | |
if (!dir.exists(b)) { | |
dir.create(b) | |
dir.create(file.path(b, "src")) | |
dir.create(file.path(b, "R")) | |
dir.create(file.path(b, ".cargo")) | |
} | |
b | |
}) | |
rextendr::rust_source(code = code, features=features, | |
env = parent.frame(), ... ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment