Refactor source
The changes in this PR are substantial, but only one involves a breaking change (well, sort of a breaking change).
1. Uses the new `run_cargo()` function, replacing `invoke_cargo()` and all its helper functions. This is wrapped in `rlang::try_fetch()` to handle errors instead of processing conditions from `processx::run()` manually. Also had to make a small tweak to `run_cargo()` type checks to allow `wd = NULL`.
2. Introduces new `extendr_options()` wrapper to simplify `rust_source()` api. This returns a list with class `extendr_opts`. To maintain backward compatibility, all options are still passable through `...` and are injected into `extendr_options()` with `rlang::inject()`.
3. Adds extensive type checking of parameters with rlang standalone type checks.
4. Handles the `extendr_fn_options` parameter to `rust_function()` in a greatly simplified way. This eliminates the need for `function_options.R` and with it a big chunk of the `dplyr` calls.
5. The kind-of, sort-of breaking change: As part of (4), `rust_function()` will now error instead of emit a warning if passed unknown macro options. In fact, the function would error anyway at the cargo command because it's invalid Rust code, so the warning was informative, but also mostly irrelevant. This required updating tests in `test-extendr_function_options.R`. Also, I split this into two separate tests: is the macro option known in _release_ version of extendr when `use_dev_extendr = FALSE` and is macro option known in _dev_ version of extendr when `use_dev_extendr = TRUE`.
A few other things to note:
6. Running `devtools::document()` with an updated version of roxygen is now throwing a lot of documentation warnings, mostly about linking to other functions.
7. Not sure what the value of `cache_build` is. It appears that even when caching, the entire directory is re-written anyway, but I may be missing something. Rather than specifying a boolean with that parameter, it maybe makes more sense to let the user specify a path to a project directory. I believe that is what cpp11 does.
8. There are some cargo-ish things that rextendr is doing manually - particularly related to building a project directory and writing Cargo.toml, and I wonder if it would be better to hand as much of that off to `run_cargo()` as possible. Happy to make those changes here if desired.
合并状态:未合并 1 条评论