Skip to content

Conversation

@pachadotdev
Copy link
Contributor

this is a new version of #1921

@jennybc I took some time to type with 1 hand and I used the logic you proposed here #1921 (comment)

R/cpp11.R Outdated
Comment on lines 27 to 30
roxygen_ns_append(
sprintf("@useDynLib %s, .registration = TRUE", project_name())
) && roxygen_remind()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that use_src() does exactly this already? Can you help me understand why use_cpp11() needs to do that again?

usethis/R/rcpp.R

Lines 74 to 75 in 93f4410

roxygen_ns_append(glue("@useDynLib {project_name()}, .registration = TRUE")) &&
roxygen_remind()

Comment on lines 8 to 16
skip_if_not_installed("cpp11")

create_local_package()
use_roxygen_md()
use_package_doc()

local_interactive(FALSE)
local_check_installed()
local_mocked_bindings(check_cpp_register_deps = function() invisible())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of skips and mocks, I would expect this to look very much like the same test for use_rcpp():

test_that("use_rcpp() creates files/dirs, edits DESCRIPTION and .gitignore", {
create_local_package()
use_roxygen_md()
# pretend Rcpp is installed
local_check_installed()
use_rcpp("test")
expect_match(desc::desc_get("LinkingTo"), "Rcpp")
expect_match(desc::desc_get("Imports"), "Rcpp")
expect_proj_dir("src")
expect_proj_file("src", "test.cpp")
ignores <- read_utf8(proj_path("src", ".gitignore"))
expect_true(all(c("*.o", "*.so", "*.dll") %in% ignores))
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to reflect this. The test "use_rcpp_armadillo() creates Makevars..." is something I can implement later for cpp11armadillo.

@jennybc
Copy link
Member

jennybc commented Jul 25, 2024

Whew, we got there!

@jennybc jennybc merged commit cc4d09c into r-lib:main Jul 25, 2024
@pachadotdev pachadotdev deleted the cpp11_2 branch July 26, 2024 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants