Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* Replaces internal `invoke_cargo()` with `run_cargo()` in `rust_source()`
* Simplifies handling of macro options in `rust_function(extendr_fn_options = list())`
* Unknown macro options in dev and release now throw errors instead of warnings
* `vendor_pkgs()` now has a `clean` argument to remove the `src/rust/vendor` directory after creating the `vendor.tar.xz` file. (#479)
* `Makevars`(.win) now uses the `vendor/`, if it exists, before unzipping the tarball. (#479)

# rextendr 0.4.2

Expand Down
8 changes: 6 additions & 2 deletions R/cran-compliance.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# the vendored dependencies using [`vendor_pkgs()`].
#'
#' @inheritParams use_extendr
#'
#' @param clean `logical(1)` indicating whether the `vendor/` directory should be removed after
#' creating the `vendor.tar.xz` file. Defaults to `FALSE`.
#'
#' @returns
#'
#' - `vendor_pkgs()` returns a data.frame with two columns `crate` and `version`
Expand All @@ -16,7 +20,7 @@
#' vendor_pkgs()
#' }
#' @export
vendor_pkgs <- function(path = ".", quiet = FALSE, overwrite = NULL) {
vendor_pkgs <- function(path = ".", quiet = FALSE, overwrite = NULL, clean = FALSE) {
stderr_line_callback <- function(x, proc) {
if (!cli::ansi_grepl("To use vendored sources", x) && cli::ansi_nzchar(x)) {
cli::cat_bullet(stringi::stri_trim_left(x))
Expand Down Expand Up @@ -119,7 +123,7 @@ vendor_pkgs <- function(path = ".", quiet = FALSE, overwrite = NULL) {
}

# clean up vendor directory
if (dir.exists(file.path(src_dir, "vendor"))) {
if (clean && dir.exists(file.path(src_dir, "vendor"))) {
cli::cli_alert_info("Removing {.path src/rust/vendor} directory")
unlink(file.path(src_dir, "vendor"), recursive = TRUE)
}
Expand Down
10 changes: 8 additions & 2 deletions inst/templates/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ VENDOR_DIR = $(CURDIR)/vendor
# CRAN note: Cargo and Rustc versions are reported during
# configure via tools/msrv.R.
#
# vendor.tar.xz, if present, is unzipped and used for offline compilation.
# If a vendor directory exists, it is used for offline compilation. Otherwise if
# vendor.tar.xz exists, it is unzipped and used for offline compilation.
$(STATLIB):

if [ -f ./rust/vendor.tar.xz ]; then \
if [ -d ./vendor ]; then \
echo "=== Using offline vendor directory ==="; \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
elif [ -f ./rust/vendor.tar.xz ]; then \
echo "=== Using offline vendor tarball ==="; \
tar xf rust/vendor.tar.xz && \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
Expand Down
9 changes: 8 additions & 1 deletion inst/templates/Makevars.win.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ $(STATLIB):
mkdir -p $(TARGET_DIR)/libgcc_mock
touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a

if [ -f ./rust/vendor.tar.xz ]; then \
# If a vendor directory exists, it is used for offline compilation. Otherwise if
# vendor.tar.xz exists, it is unzipped and used for offline compilation.
if [ -d ./vendor ]; then \
echo "=== Using offline vendor directory ==="; \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
elif [ -f ./rust/vendor.tar.xz ]; then \
echo "=== Using offline vendor tarball ==="; \
tar xf rust/vendor.tar.xz && \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
Expand Down
5 changes: 4 additions & 1 deletion man/vendor_pkgs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 24 additions & 5 deletions tests/testthat/_snaps/use_extendr.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,16 @@
# CRAN note: Cargo and Rustc versions are reported during
# configure via tools/msrv.R.
#
# vendor.tar.xz, if present, is unzipped and used for offline compilation.
# If a vendor directory exists, it is used for offline compilation. Otherwise if
# vendor.tar.xz exists, it is unzipped and used for offline compilation.
$(STATLIB):

if [ -f ./rust/vendor.tar.xz ]; then \
if [ -d ./vendor ]; then \
echo "=== Using offline vendor directory ==="; \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
elif [ -f ./rust/vendor.tar.xz ]; then \
echo "=== Using offline vendor tarball ==="; \
tar xf rust/vendor.tar.xz && \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
Expand Down Expand Up @@ -273,7 +279,14 @@
mkdir -p $(TARGET_DIR)/libgcc_mock
touch $(TARGET_DIR)/libgcc_mock/libgcc_eh.a

if [ -f ./rust/vendor.tar.xz ]; then \
# If a vendor directory exists, it is used for offline compilation. Otherwise if
# vendor.tar.xz exists, it is unzipped and used for offline compilation.
if [ -d ./vendor ]; then \
echo "=== Using offline vendor directory ==="; \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
elif [ -f ./rust/vendor.tar.xz ]; then \
echo "=== Using offline vendor tarball ==="; \
tar xf rust/vendor.tar.xz && \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
Expand Down Expand Up @@ -442,10 +455,16 @@
# CRAN note: Cargo and Rustc versions are reported during
# configure via tools/msrv.R.
#
# vendor.tar.xz, if present, is unzipped and used for offline compilation.
# If a vendor directory exists, it is used for offline compilation. Otherwise if
# vendor.tar.xz exists, it is unzipped and used for offline compilation.
$(STATLIB):

if [ -f ./rust/vendor.tar.xz ]; then \
if [ -d ./vendor ]; then \
echo "=== Using offline vendor directory ==="; \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
elif [ -f ./rust/vendor.tar.xz ]; then \
echo "=== Using offline vendor tarball ==="; \
tar xf rust/vendor.tar.xz && \
mkdir -p $(CARGOTMP) && \
cp rust/vendor-config.toml $(CARGOTMP)/config.toml; \
Expand Down
Loading