Skip to content

Commit fbbbed8

Browse files
authored
refactor(c/sedona-proj,c/sedona-tg): Remove build-time generated headers (#149)
1 parent e55738c commit fbbbed8

File tree

11 files changed

+186
-1617
lines changed

11 files changed

+186
-1617
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

c/sedona-proj/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ edition.workspace = true
2727
rust-version.workspace = true
2828

2929
[build-dependencies]
30-
bindgen = "0.71.0"
3130
cc = { version = "1" }
3231

3332
[dev-dependencies]

c/sedona-proj/README.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

c/sedona-proj/build.rs

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -14,66 +14,9 @@
1414
// KIND, either express or implied. See the License for the
1515
// specific language governing permissions and limitations
1616
// under the License.
17-
use std::{env, path::PathBuf};
18-
19-
// Since relative path differs between build.rs and a file under `src/`, use the
20-
// absolute path.
21-
fn get_absolute_path(path: String) -> PathBuf {
22-
std::path::absolute(PathBuf::from(path)).expect("Failed to get absolute path")
23-
}
24-
25-
fn configure_bindings_path(prebuilt_bindings_path: String) -> (PathBuf, bool) {
26-
// If SEDONA_PROJ_BINDINGS_OUTPUT_PATH is set, honor the explicit output
27-
// path to regenerate bindings.
28-
if let Ok(output_path) = env::var("SEDONA_PROJ_BINDINGS_OUTPUT_PATH") {
29-
let output_path = get_absolute_path(output_path);
30-
if let Some(output_dir) = output_path.parent() {
31-
std::fs::create_dir_all(output_dir).expect("Failed to create parent dirs");
32-
}
33-
return (output_path, true);
34-
}
35-
36-
// If a prebuilt bindings exists, use it and skip bindgen.
37-
let prebuilt_bindings_path = get_absolute_path(prebuilt_bindings_path);
38-
if prebuilt_bindings_path.exists() {
39-
return (prebuilt_bindings_path, false);
40-
}
41-
42-
let output_dir = env::var("OUT_DIR").unwrap();
43-
let output_path = PathBuf::from(output_dir).join("bindings.rs");
44-
45-
(output_path, true)
46-
}
4717

4818
fn main() {
4919
println!("cargo:rerun-if-changed=src/proj_dyn.c");
50-
println!("cargo:rerun-if-env-changed=SEDONA_PROJ_BINDINGS_OUTPUT_PATH");
5120

5221
cc::Build::new().file("src/proj_dyn.c").compile("proj_dyn");
53-
54-
let target_triple = std::env::var("TARGET").unwrap();
55-
let prebuilt_bindings_path = format!("src/bindings/{target_triple}.rs");
56-
57-
let (bindings_path, generate_bindings) = configure_bindings_path(prebuilt_bindings_path);
58-
59-
println!(
60-
"cargo::rustc-env=BINDINGS_PATH={}",
61-
bindings_path.to_string_lossy()
62-
);
63-
64-
if !generate_bindings {
65-
return;
66-
}
67-
68-
let bindings = bindgen::Builder::default()
69-
.header("src/proj_dyn.h")
70-
.generate_comments(false)
71-
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
72-
.generate()
73-
.expect("Unable to generate bindings");
74-
75-
// Write the bindings to the $OUT_DIR/bindings.rs file.
76-
bindings
77-
.write_to_file(&bindings_path)
78-
.expect("Couldn't write bindings!");
7922
}

0 commit comments

Comments
 (0)