Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) godot-rust; Bromeon and contributors.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

/// Build script to expose the crate's manifest directory to dependent crates.
///
/// This allows dependent crates to locate platform-specific prebuilt bindings
/// during cross-compilation, where cfg attributes are evaluated for the host
/// platform instead of the target platform.
///
/// Dependent crates can access this via the `DEP_GDEXTENSION_API_ROOT` environment variable.
fn main() {
// Export the manifest directory so dependent crates can find our files
let manifest_dir =
std::env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR should be set by Cargo");

println!("cargo:root={}", manifest_dir);
}
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ pub const GODOT_VERSION_STRING: &str = "4.5";

/// Returns the contents of the header file `gdextension_interface.h`.
pub const fn load_gdextension_header_h() -> CowStr {
CowStr::Borrowed(include_str!("../../4.5/res/gdextension_interface.h"))
CowStr::Borrowed(include_str!("../res/gdextension_interface.h"))
}

/// Returns the contents of the header file `gdextension_interface.rs`, generated for the corresponding platform.
pub const fn load_gdextension_header_rs() -> CowStr {
#[cfg(windows)]
let s = include_str!("../../4.5/res/gdextension_interface_windows.rs");
let s = include_str!("../res/gdextension_interface_windows.rs");

#[cfg(target_os = "macos")]
let s = include_str!("../../4.5/res/gdextension_interface_macos.rs");
let s = include_str!("../res/gdextension_interface_macos.rs");

#[cfg(all(unix, not(target_os = "macos")))]
let s = include_str!("../../4.5/res/gdextension_interface_linux.rs");
let s = include_str!("../res/gdextension_interface_linux.rs");

CowStr::Borrowed(s)
}
Expand Down