Contributing to rzig
Source:CONTRIBUTING.md
rzig generates the native boundary between R and Zig, so a change can affect every package that uses it. The repository therefore checks each change at several levels, and a pull request is expected to pass all of them.
Setting up
- R 4.6 or newer with the build tools of your platform.
- Zig 0.16.0 and 0.17.0 (both series are supported;
rzig::install_zig()installs a verified release). - The R packages in
SuggestsofDESCRIPTION.
Where things live
-
src/is the Zig framework.sh tools/sync_fixture.shandsh tools/sync_r_package_assets.shcopy it into the test fixture, the example package andinst/zig/framework;zig build genregenerates the generated Zig files. Editsrc/, never the copies. -
R/is the R package: scanning, rendering, checks, the build and the helpers.inst/templatesandinst/zigare the templates thatuse_rzig()copies into packages. -
tests/fixtures/rzigtestis an R package that exercises the boundary;examples/rzigcausalis an example package built in CI.
Checks before a pull request
zig build test # Zig unit tests, with Zig 0.16 and 0.17
zig build lint # the one-error-exit and jump-resume rules
sh tools/sync_fixture.sh --check
# with Zig 0.16, whose format is the format of record
zig fmt --check build.zig src tools tests/fixtures/rzigtest/src/rzig examples/rzigcausal/src/rzig
devtools::test() # with NOT_CRAN=true; builds packages when Zig is present
devtools::check()The fixture tests run in an installed copy of tests/fixtures/rzigtest (see .github/workflows/ci.yml for the commands), and Rscript tools/gctorture_run.R tests/gctorture-callbacks.R runs the boundary under gctorture().
Rules for the boundary
- Zig code returns errors; only
src/boundary.zigraises R errors, after every Zig resource has been released (zig build lintenforces it). - R code runs only on the thread that entered R, and R’s jumps out of R code that Zig calls are stopped before the Zig frames (
src/rcall.zig). - Every R API symbol that
src/c/abi.zigdeclares must be part of R’s API (Rscript tools/check_api_symbols.R). - A change that affects packages gets a NEWS entry, and a change of a template keeps
update_rzig()working (Rscript tools/known_template_hashes.R).