Skip to content

Commit

Permalink
feature: added non-api feature that would
Browse files Browse the repository at this point in the history
allo non-api items to be part of the
generated bindings. These bindings
are not cached.
  • Loading branch information
CGMossa committed May 9, 2024
1 parent 1fa9052 commit 633f5a0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ default = ["runtime"]
# Turn on the 'use-bindgen' feature to generate bindings on the fly for your platform.
use-bindgen = ["bindgen", "clang"]

# retain non-API bindings from R (requires build-time generation of bindings)
non-api = ["use-bindgen"]

runtime = ["clang/runtime", "bindgen/runtime"]

# Enables generation of layout-tests in bindgen
layout_tests = ["use-bindgen"]

Expand Down
10 changes: 7 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
// Several non-APIs are required for extendr-engine, so we explicitly allow
// these here. If extendr-engine (or other crate) requires more non-APIs,
Expand All @@ -392,8 +392,7 @@ fn get_non_api() -> std::collections::HashSet<String> {
];

// 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))
Expand All @@ -402,6 +401,11 @@ fn get_non_api() -> std::collections::HashSet<String> {
std::collections::HashSet::from_iter(non_api)
}

#[cfg(all(feature = "use-bindgen", feature = "non-api"))]
fn get_non_api() -> std::collections::HashSet<String> {
Default::default()
}

#[cfg(feature = "use-bindgen")]
/// Generate bindings by calling bindgen.
fn generate_bindings(r_paths: &InstallationPaths, version_info: &RVersionInfo) {
Expand Down

0 comments on commit 633f5a0

Please sign in to comment.