diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..48a3496 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "gdextension-api" +version = "0.3.0" diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..63cceaa --- /dev/null +++ b/build.rs @@ -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); +} diff --git a/src/lib.rs b/src/lib.rs index a530bb3..043a00d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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) }