From c27896089a37b125972539cce0622cc022c24780 Mon Sep 17 00:00:00 2001 From: Mossa Date: Thu, 9 May 2024 21:39:15 +0200 Subject: [PATCH 1/8] feature: added `non-api` feature that would allo non-api items to be part of the generated bindings. These bindings are not cached. --- Cargo.toml | 4 ++++ build.rs | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 060681ac..4db0ba7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,11 @@ default = ["runtime"] # Turn on the 'use-bindgen' feature to generate bindings on the fly for your platform. use-bindgen = ["bindgen", "regex"] +# retain non-API bindings from R (requires build-time generation of bindings) +non-api = ["use-bindgen"] + runtime = ["bindgen/runtime"] + # Enables generation of layout-tests in bindgen layout_tests = ["use-bindgen"] diff --git a/build.rs b/build.rs index 84edc4d7..02e384c2 100644 --- a/build.rs +++ b/build.rs @@ -377,7 +377,7 @@ fn set_r_version_vars(ver: &RVersionInfo) { println!("cargo:r_version_devel={}", ver.devel); // Becomes DEP_R_R_VERSION_DEVEL for clients } -#[cfg(feature = "use-bindgen")] +#[cfg(all(feature = "use-bindgen", not(feature = "non-api")))] fn get_non_api() -> std::collections::HashSet { // Several non-APIs are required for extendr-engine, so we explicitly allow // these here. If extendr-engine (or other crate) requires more non-APIs, @@ -392,8 +392,7 @@ fn get_non_api() -> std::collections::HashSet { ]; // nonAPI.txt is generated by - // - // Rscript -e 'cat(tools:::nonAPI, "\n")' | uniq | sort + // Rscript -e 'cat(tools:::nonAPI, sep = "\n")' | tr -d '\r' | sort -u | tee ./nonAPI.txt let non_api = include_str!("./nonAPI.txt") .lines() .filter(|e| !REQUIRED_NON_API.contains(e)) @@ -402,6 +401,11 @@ fn get_non_api() -> std::collections::HashSet { std::collections::HashSet::from_iter(non_api) } +#[cfg(all(feature = "use-bindgen", feature = "non-api"))] +fn get_non_api() -> std::collections::HashSet { + Default::default() +} + #[cfg(feature = "use-bindgen")] /// Generate bindings by calling bindgen. fn generate_bindings(r_paths: &InstallationPaths, version_info: &RVersionInfo) { From e10b76f89dbcbb5fdd3cc72f45b54e31ac91f9d1 Mon Sep 17 00:00:00 2001 From: Mossa Date: Fri, 10 May 2024 22:37:48 +0200 Subject: [PATCH 2/8] [generate bindings] From d4d77bf46b27d064fab5ee346f6dc9f52b547ad8 Mon Sep 17 00:00:00 2001 From: Mossa Date: Fri, 10 May 2024 22:38:11 +0200 Subject: [PATCH 3/8] [generate bindings] From 7951e58f86574fcade61788f9ec1068ab1dbdb42 Mon Sep 17 00:00:00 2001 From: Mossa Date: Sat, 11 May 2024 08:05:18 +0200 Subject: [PATCH 4/8] an empty blocklist result in all items being blocked --- build.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/build.rs b/build.rs index 02e384c2..33303da4 100644 --- a/build.rs +++ b/build.rs @@ -401,21 +401,21 @@ fn get_non_api() -> std::collections::HashSet { std::collections::HashSet::from_iter(non_api) } -#[cfg(all(feature = "use-bindgen", feature = "non-api"))] -fn get_non_api() -> std::collections::HashSet { - Default::default() -} - #[cfg(feature = "use-bindgen")] /// Generate bindings by calling bindgen. fn generate_bindings(r_paths: &InstallationPaths, version_info: &RVersionInfo) { - let blocklist = get_non_api().into_iter().collect::>().join("|"); - // The bindgen::Builder is the main entry point // to bindgen, and lets you build up options for // the resulting bindings. - let mut bindgen_builder = bindgen::Builder::default() - .blocklist_item(blocklist) + let mut bindgen_builder = bindgen::Builder::default(); + + #[cfg(all(feature = "use-bindgen", not(feature = "non-api")))] + { + let blocklist = get_non_api().into_iter().collect::>().join("|"); + bindgen_builder = bindgen_builder.blocklist_item(blocklist); + } + + bindgen_builder = bindgen_builder .emit_diagnostics() .translate_enum_integer_types(true) .merge_extern_blocks(true) From de131e55e0a4717cdc0d1604ccc3857e39f7bc04 Mon Sep 17 00:00:00 2001 From: Mossa Date: Sat, 11 May 2024 08:07:25 +0200 Subject: [PATCH 5/8] ci: add `non-api` option to tests --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 82661284..29488823 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -220,6 +220,7 @@ jobs: run: | . ./ci-cargo.ps1 ci-cargo test -vv --features use-bindgen,layout_tests $(if ($env:RUST_TARGET -ne '') {"--target=$env:RUST_TARGET"} ) '--' --nocapture -ActionName "Running bindgen tests for target: $env:RUST_TARGET" + ci-cargo test -vv --features use-bindgen,non-api,layout_tests $(if ($env:RUST_TARGET -ne '') {"--target=$env:RUST_TARGET"} ) '--' --nocapture -ActionName "Running bindgen tests for target: $env:RUST_TARGET" (with non-API) env: RUST_TARGET: ${{ matrix.config.target }} From 0de398411afd010253cc7b0a1dbd81cf5b1752e6 Mon Sep 17 00:00:00 2001 From: Mossa Date: Sat, 11 May 2024 08:07:31 +0200 Subject: [PATCH 6/8] [generate bindings] From 524f7d83b7e03673ba56b6d01a75412f259a444e Mon Sep 17 00:00:00 2001 From: Mossa Date: Sat, 11 May 2024 08:13:12 +0200 Subject: [PATCH 7/8] ci: fix [generate bindings] --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29488823..f4c9eaf6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -220,7 +220,7 @@ jobs: run: | . ./ci-cargo.ps1 ci-cargo test -vv --features use-bindgen,layout_tests $(if ($env:RUST_TARGET -ne '') {"--target=$env:RUST_TARGET"} ) '--' --nocapture -ActionName "Running bindgen tests for target: $env:RUST_TARGET" - ci-cargo test -vv --features use-bindgen,non-api,layout_tests $(if ($env:RUST_TARGET -ne '') {"--target=$env:RUST_TARGET"} ) '--' --nocapture -ActionName "Running bindgen tests for target: $env:RUST_TARGET" (with non-API) + ci-cargo test -vv --features use-bindgen,non-api,layout_tests $(if ($env:RUST_TARGET -ne '') {"--target=$env:RUST_TARGET"} ) '--' --nocapture -ActionName "Running bindgen tests for target: $env:RUST_TARGET (with non-API)" env: RUST_TARGET: ${{ matrix.config.target }} From 30e62026f6ca9b3eced4785f6a4678bf364dfb85 Mon Sep 17 00:00:00 2001 From: CGMossa Date: Sat, 11 May 2024 06:18:52 +0000 Subject: [PATCH 8/8] Update bindings [skip ci] --- bindings/bindings-windows-x86_64-R4.5-devel.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/bindings-windows-x86_64-R4.5-devel.rs b/bindings/bindings-windows-x86_64-R4.5-devel.rs index 24cca814..0abda463 100644 --- a/bindings/bindings-windows-x86_64-R4.5-devel.rs +++ b/bindings/bindings-windows-x86_64-R4.5-devel.rs @@ -54,8 +54,8 @@ pub const R_MINOR: &[u8; 4] = b"5.0\0"; pub const R_STATUS: &[u8; 29] = b"Under development (unstable)\0"; pub const R_YEAR: &[u8; 5] = b"2024\0"; pub const R_MONTH: &[u8; 3] = b"05\0"; -pub const R_DAY: &[u8; 3] = b"08\0"; -pub const R_SVN_REVISION: u32 = 86528; +pub const R_DAY: &[u8; 3] = b"10\0"; +pub const R_SVN_REVISION: u32 = 86529; pub const R_GE_definitions: u32 = 13; pub const R_GE_deviceClip: u32 = 14; pub const R_GE_group: u32 = 15;