From e2b33b5af6dbca28c54c1d4c5897f3e32eb9140d Mon Sep 17 00:00:00 2001 From: Hiroaki Yutani Date: Sat, 12 Feb 2022 19:49:20 +0900 Subject: [PATCH] Further tweak --- build.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 74cc6fe90..aa50f3123 100644 --- a/build.rs +++ b/build.rs @@ -417,7 +417,7 @@ fn generate_bindings(r_paths: &InstallationPaths, version_info: &RVersionInfo) { // // #define FOO(x) (x + 1) // - let re = regex::Regex::new(r#"^\s*#\s*define\s+([^\s\(]+)(\s*\(|\s+[0-9"])"#).unwrap(); + let re = regex::Regex::new(r#"^\s*#\s*define\s+([^\s\(]+)(\s*\(|\s+-?[0-9"])"#).unwrap(); for include_file in include_files { let file = std::fs::File::open(include_file).unwrap(); @@ -428,6 +428,10 @@ fn generate_bindings(r_paths: &InstallationPaths, version_info: &RVersionInfo) { } } + // Cannot detect when the #define-ed constats are aliased in another #define + // c.f. https://github.com/wch/r-source/blob/9f284035b7e503aebe4a804579e9e80a541311bb/src/include/R_ext/GraphicsEngine.h#L93 + allowlist.insert("R_GE_version".to_string()); + let allowlist_pattern = allowlist.into_iter().collect::>().join("|"); // The bindgen::Builder is the main entry point