Skip to content

Commit

Permalink
Merge branch 'extendr:main' into read_cargo_metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kbvernon authored Nov 3, 2024
2 parents bcb0455 + a8d7434 commit 9e342f0
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 50 deletions.
11 changes: 0 additions & 11 deletions .github/workflows/test_pkg_gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,6 @@ jobs:
file.path("tests", "testthat", "test-hello.R")
)
# test NOT_CRAN envvar
brio::write_lines(
c(
"if [ \"$NOT_CRAN\" != \"true\" ]; then",
" exit 1",
"fi"
),
file.path("configure")
)
Sys.chmod("configure", "0755")
# TODO: allow warnings on oldrel (cf., https://stat.ethz.ch/pipermail/r-package-devel/2023q2/009229.html)
if (.Platform$OS.type == "windows" && getRversion() < "4.3.0") {
error_on <- "error"
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# rextendr (development version)

* `Makevars` now prints linked static libraries at compile time <https://github.com/extendr/rextendr/pull/393>
* `use_extendr()` sets the `DESCRIPTION`'s `SystemRequirements` field according to CRAN policy to `Cargo (Rust's package manager), rustc` (#329)
* Introduces new functions `use_cran_defaults()` and `vendor_pkgs()` to ease the publication of extendr-powered packages on CRAN. See the new article _CRAN compliant extendr packages_ on how to use these (#320).
* `rust_sitrep()` now better communicates the status of the Rust toolchain and available targets. It also guides the user through necessary installation steps to fix Rust setup (#318).
Expand Down
36 changes: 0 additions & 36 deletions R/cran-compliance.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,6 @@ use_cran_defaults <- function(path = ".", quiet = FALSE, overwrite = NULL, lib_n
)
}

# create tools directory if it does not exist
if (!dir.exists("tools")) {
dir.create("tools")
}

# add msrv.R template
use_rextendr_template(
"cran/msrv.R",
save_as = file.path("tools", "msrv.R"),
quiet = quiet,
overwrite = overwrite
)

# add configure and configure.win templates
use_rextendr_template(
"cran/configure",
save_as = "configure",
quiet = quiet,
overwrite = overwrite,
data = list(lib_name = lib_name)
)

# configure needs to be made executable
# ignore for Windows
if (.Platform[["OS.type"]] == "unix") {
Sys.chmod("configure", "0755")
}

use_rextendr_template(
"cran/configure.win",
save_as = "configure.win",
quiet = quiet,
overwrite = overwrite,
data = list(lib_name = lib_name)
)

# use CRAN specific Makevars templates
use_rextendr_template(
"cran/Makevars",
Expand Down
37 changes: 37 additions & 0 deletions R/use_extendr.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,43 @@ use_extendr <- function(path = ".",
data = list(pkg_name = pkg_name)
)

# create tools directory if it does not exist
if (!dir.exists("tools")) {
dir.create("tools")
}

# add msrv.R template
use_rextendr_template(
"cran/msrv.R",
save_as = file.path("tools", "msrv.R"),
quiet = quiet,
overwrite = overwrite
)

# add configure and configure.win templates
use_rextendr_template(
"cran/configure",
save_as = "configure",
quiet = quiet,
overwrite = overwrite,
data = list(lib_name = lib_name)
)

# configure needs to be made executable
# ignore for Windows
if (.Platform[["OS.type"]] == "unix") {
Sys.chmod("configure", "0755")
}

use_rextendr_template(
"cran/configure.win",
save_as = "configure.win",
quiet = quiet,
overwrite = overwrite,
data = list(lib_name = lib_name)
)


if (!isTRUE(quiet)) {
cli::cli_alert_success("Finished configuring {.pkg extendr} for package {.pkg {pkg_name}}.")
cli::cli_ul(
Expand Down
3 changes: 3 additions & 0 deletions inst/templates/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ LIBDIR = $(TARGET_DIR)/release
STATLIB = $(LIBDIR)/lib{{{lib_name}}}.a
PKG_LIBS = -L$(LIBDIR) -l{{{lib_name}}}

# Print linked static libraries at compile time
export RUSTFLAGS=--print=native-static-libs

all: C_clean

$(SHLIB): $(STATLIB)
Expand Down
3 changes: 3 additions & 0 deletions inst/templates/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ LIBDIR = $(TARGET_DIR)/$(TARGET)/release
STATLIB = $(LIBDIR)/lib{{{lib_name}}}.a
PKG_LIBS = -L$(LIBDIR) -l{{{lib_name}}} -lws2_32 -ladvapi32 -luserenv -lbcrypt -lntdll

# Print linked static libraries at compile time
export RUSTFLAGS=--print=native-static-libs

all: C_clean

$(SHLIB): $(STATLIB)
Expand Down
3 changes: 3 additions & 0 deletions inst/templates/cran/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ LIBDIR = $(TARGET_DIR)/release
STATLIB = $(LIBDIR)/lib{{{lib_name}}}.a
PKG_LIBS = -L$(LIBDIR) -l{{{lib_name}}}

# Print linked static libraries at compile time
export RUSTFLAGS=--print=native-static-libs

all: C_clean

$(SHLIB): $(STATLIB)
Expand Down
3 changes: 3 additions & 0 deletions inst/templates/cran/Makevars.win
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ LIBDIR = $(TARGET_DIR)/$(TARGET)/release
STATLIB = $(LIBDIR)/lib{{{lib_name}}}.a
PKG_LIBS = -L$(LIBDIR) -l{{{lib_name}}} -lws2_32 -ladvapi32 -luserenv -lbcrypt -lntdll

# Print linked static libraries at compile time
export RUSTFLAGS=--print=native-static-libs

all: C_clean

$(SHLIB): $(STATLIB)
Expand Down
12 changes: 9 additions & 3 deletions tests/testthat/_snaps/use_cran_defaults.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
v Writing 'src/rust/src/lib.rs'
v Writing 'src/testpkg-win.def'
v Writing 'R/extendr-wrappers.R'
v Writing 'tools/msrv.R'
v Writing 'configure'
v Writing 'configure.win'
v Finished configuring extendr for package testpkg.
* Please run `rextendr::document()` for changes to take effect.

Expand All @@ -25,9 +28,6 @@
Code
use_cran_defaults()
Message
v Writing 'tools/msrv.R'
v Writing 'configure'
v Writing 'configure.win'
> File 'src/Makevars' already exists. Skip writing the file.
> File 'src/Makevars.win' already exists. Skip writing the file.
v Adding "^src/rust/vendor$" to '.Rbuildignore'.
Expand All @@ -43,6 +43,9 @@
STATLIB = $(LIBDIR)/libtestpkg.a
PKG_LIBS = -L$(LIBDIR) -ltestpkg
# Print linked static libraries at compile time
export RUSTFLAGS=--print=native-static-libs
all: C_clean
$(SHLIB): $(STATLIB)
Expand Down Expand Up @@ -81,6 +84,9 @@
STATLIB = $(LIBDIR)/libtestpkg.a
PKG_LIBS = -L$(LIBDIR) -ltestpkg -lws2_32 -ladvapi32 -luserenv -lbcrypt -lntdll
# Print linked static libraries at compile time
export RUSTFLAGS=--print=native-static-libs
all: C_clean
$(SHLIB): $(STATLIB)
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/_snaps/use_extendr.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
v Writing 'src/rust/src/lib.rs'
v Writing 'src/testpkg-win.def'
v Writing 'R/extendr-wrappers.R'
v Writing 'tools/msrv.R'
v Writing 'configure'
v Writing 'configure.win'
v Finished configuring extendr for package testpkg.
* Please run `rextendr::document()` for changes to take effect.

Expand Down Expand Up @@ -48,6 +51,9 @@
STATLIB = $(LIBDIR)/libtestpkg.a
PKG_LIBS = -L$(LIBDIR) -ltestpkg
# Print linked static libraries at compile time
export RUSTFLAGS=--print=native-static-libs
all: C_clean
$(SHLIB): $(STATLIB)
Expand Down Expand Up @@ -86,6 +92,9 @@
STATLIB = $(LIBDIR)/libtestpkg.a
PKG_LIBS = -L$(LIBDIR) -ltestpkg -lws2_32 -ladvapi32 -luserenv -lbcrypt -lntdll
# Print linked static libraries at compile time
export RUSTFLAGS=--print=native-static-libs
all: C_clean
$(SHLIB): $(STATLIB)
Expand Down Expand Up @@ -212,6 +221,9 @@
> File 'src/rust/src/lib.rs' already exists. Skip writing the file.
> File 'src/testpkg.wrap-win.def' already exists. Skip writing the file.
> File 'R/extendr-wrappers.R' already exists. Skip writing the file.
> File 'tools/msrv.R' already exists. Skip writing the file.
> File 'configure' already exists. Skip writing the file.
> File 'configure.win' already exists. Skip writing the file.
v Finished configuring extendr for package testpkg.wrap.
* Please run `rextendr::document()` for changes to take effect.

Expand All @@ -229,6 +241,9 @@
v Writing 'src/rust/src/lib.rs'
v Writing 'src/testpkg-win.def'
> File 'R/extendr-wrappers.R' already exists. Skip writing the file.
v Writing 'tools/msrv.R'
v Writing 'configure'
v Writing 'configure.win'
v Finished configuring extendr for package testpkg.
* Please run `rextendr::document()` for changes to take effect.

Expand Down Expand Up @@ -260,6 +275,9 @@
STATLIB = $(LIBDIR)/libbar.a
PKG_LIBS = -L$(LIBDIR) -lbar
# Print linked static libraries at compile time
export RUSTFLAGS=--print=native-static-libs
all: C_clean
$(SHLIB): $(STATLIB)
Expand Down

0 comments on commit 9e342f0

Please sign in to comment.