Checks each step of the RZig workflow in a package and reports what is present, what is missing and what would make the installation fail:
Arguments
- path
Path to the package root.
- build
If
TRUE, also compile and install the package withbuild_zig()when every other check passes.- lib
With
build = TRUE, the library to install into; seebuild_zig().
Value
An object of class rzig_status: a data frame with the columns
step, ok and detail, one row per check, with the attributes
path, package and, with build = TRUE, build (the
rzig_build object).
Details
DESCRIPTION: the package name and a valid version.
Scaffold: the files written by
use_rzig(), framework sources that match the installed rzig, and executableconfigureandcleanupscripts. Build files that differ from the rzig templates (configure, the Makevars,entry.c,build.zig,build.zig.zon,tools/) are noted, since a package may extend them.Zig source:
src/rzig/src/main.zigwith the registration block and the panic handler of rzig.Exports: the exported functions found by
scan_exports(), with every argument and return type that the boundary rejects, more than 32 arguments, misuse ofrzig.Mut([]f64), error sets other thanrzig.Error, and R functions of the same name elsewhere inR/. An export that masks a function of base R (for examplelog) is noted.Bindings: whether the files written by
document()match the exports.Zig compiler: a compiler of a supported release series (
find_zig()).C toolchain: the C compiler of R,
makeand the R headers.Build (only with
build = TRUE): the result ofbuild_zig().
Every check except the build runs in R without compiling anything.
Examples
package_path <- tempfile("rzig-status-", tmpdir = tempdir())
dir.create(package_path)
writeLines(c("Package: examplepkg", "Version: 0.0.1"),
file.path(package_path, "DESCRIPTION"))
use_rzig(package_path)
#> Generated RZig bindings for examplepkg: 1 exported function
#> Created RZig scaffold for package examplepkg
rzig_status(package_path)
#> RZig status of package examplepkg
#> [ok] DESCRIPTION package examplepkg
#> R CMD check also requires Title, Description, License,
#> Authors@R
#> SystemRequirements does not name Zig; state the
#> supported series, for example "Zig 0.16.x or 0.17.x"
#> [ok] Scaffold build files and framework sources present
#> [ok] Zig source src/rzig/src/main.zig
#> [ok] Exports 1 function: hello_zig
#> [ok] Bindings generated files match the exports
#> [ok] Zig compiler /home/runner/work/_temp/0beafb3f-08c9-475d-9a85-dbeb3ad24ddb/zig-x86_64-linux-0.16.0/zig
#> (version 0.16.0)
#> [ok] C toolchain C compiler gcc
main <- file.path(package_path, "src", "rzig", "src", "main.zig")
cat("/// @export\npub fn half(x: f32) f32 {\n return x / 2;\n}\n",
file = main, append = TRUE)
rzig_status(package_path)
#> RZig status of package examplepkg
#> [ok] DESCRIPTION package examplepkg
#> R CMD check also requires Title, Description, License,
#> Authors@R
#> SystemRequirements does not name Zig; state the
#> supported series, for example "Zig 0.16.x or 0.17.x"
#> [ok] Scaffold build files and framework sources present
#> [ok] Zig source src/rzig/src/main.zig
#> [--] Exports `half`, argument `x`: type f32 is not supported; use f64
#> `half`: return type f32 is not supported
#> [--] Bindings out of date: manifest.zig, R/rzig-wrappers.R, NAMESPACE,
#> man/half.Rd; run document()
#> [ok] Zig compiler /home/runner/work/_temp/0beafb3f-08c9-475d-9a85-dbeb3ad24ddb/zig-x86_64-linux-0.16.0/zig
#> (version 0.16.0)
#> [ok] C toolchain C compiler gcc
#> 2 of 7 checks failed: Exports, Bindings
unlink(package_path, recursive = TRUE)