Skip to content

Commit 5ee667f

Browse files
committed
change build script logic for update_pregenerated_bindings
generate to OUT_DIR as usual, copy from there to the crate root to update the pregenerated bindings also remove `fs::create_dir(&out_path)`, this was left over from target-specific bindings
1 parent 98d6a1c commit 5ee667f

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

sdl2-sys/build.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,11 @@ fn copy_pregenerated_bindings() {
593593
for path in paths {
594594
let from = crate_path.join(path);
595595
let to = out_path.join(path);
596+
597+
// Copy from OUT_DIR to the crate root when updating the pregenerated bindings
598+
#[cfg(update_pregenerated_bindings)]
599+
let (from, to) = (to, from);
600+
596601
if let Err(err) = fs::copy(&from, &to) {
597602
panic!(
598603
"unable to copy {} to {}: {err}",
@@ -609,16 +614,7 @@ fn copy_pregenerated_bindings() {
609614
fn generate_bindings(target: &str, host: &str, headers_paths: &[String]) {
610615
let target_os = get_os_from_triple(target).unwrap();
611616

612-
#[cfg(not(update_pregenerated_bindings))]
613617
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
614-
#[cfg(update_pregenerated_bindings)]
615-
let out_path = PathBuf::from(".");
616-
617-
#[cfg(update_pregenerated_bindings)]
618-
match fs::create_dir(&out_path) {
619-
Err(err) if err.kind() == io::ErrorKind::AlreadyExists => {}
620-
res => res.expect("unable to create bindings dir"),
621-
}
622618

623619
let mut all_bindings = bindgen::builder()
624620
// enable no_std-friendly output by only using core definitions

0 commit comments

Comments
 (0)