Skip to content

Commit

Permalink
Define PD_INTERNAL as true
Browse files Browse the repository at this point in the history
  • Loading branch information
alisomay committed Nov 28, 2024
1 parent ff04728 commit dd88160
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 16 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ const PD_FLOATSIZE: &str = "64";
const WISH: &str = "\"\\\"wish86.exe\\\"\"";

fn main() {
// Get the target endianness from Cargo
let target_endian = std::env::var("CARGO_CFG_TARGET_ENDIAN").unwrap();
// Prepare the endianness defines
let endian_define = match target_endian.as_str() {
"little" => vec!["-DLITTLE_ENDIAN=1234", "-DBYTE_ORDER=LITTLE_ENDIAN"],
"big" => vec!["-DBIG_ENDIAN=4321", "-DBYTE_ORDER=BIG_ENDIAN"],
_ => panic!("Unknown target endian: {}", target_endian),
};

// Directories
let project_dir = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));

Expand Down Expand Up @@ -240,12 +249,17 @@ fn main() {
.clang_arg(format!("-I{}", libpd_wrapper_dir.to_str().unwrap()))
.clang_arg(format!("-I{}", pd_source.to_str().unwrap()))
.clang_arg(format!("-DPD_FLOATSIZE={PD_FLOATSIZE}"))
.clang_arg("-DPD_INTERNAL=0") // Undefine PD_INTERNAL because it is not needed for bindings and cmake complains about it.
.clang_arg("-std=c11")
.clang_arg("-DPD_INTERNAL=1")
.opaque_type("atomic_int")
// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()));

// Add the endianness defines
for arg in endian_define {
bindings_builder = bindings_builder.clang_arg(arg);
}

#[cfg(target_os = "windows")]
let bindings = bindings_builder
.clang_arg(format!("-DWISH={}", WISH))
Expand Down
6 changes: 5 additions & 1 deletion wrapper.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Headers in pure data submodule
// Headers from c++11

#if !defined(__STDC_NO_ATOMICS__)
#include <stdatomic.h>
#endif

// #include "libpd/pure-data/src/d_soundfile.h"
// #include "libpd/pure-data/src/g_all_guis.h"
Expand Down

0 comments on commit dd88160

Please sign in to comment.