Skip to content

Commit

Permalink
Rename feature custom-godot -> api-custom
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed May 5, 2024
1 parent 24fd253 commit 5d622d8
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/other/deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ deny = [
{ name = "im" },
{ name = "im-rc" },

# Too heavy in default setup. Can be included for custom-godot etc.
# Too heavy in default setup. Can be included for api-custom etc.
{ name = "syn", wrappers = ["bindgen", "gensym"] },
{ name = "serde", wrappers = ["godot-core", "serde_json"] },
]
Expand Down
2 changes: 1 addition & 1 deletion .github/other/patch-prebuilt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ version="$1"

# Add correct feature to `godot` dependency.
if [[ "$version" == "nightly" ]]; then
# Do not use extraFeatures="custom-godot" here. They just want to use nightly Godot with current API.
# Do not use extraFeatures="api-custom" here. They just want to use nightly Godot with current API.
extraFeatures=""
else
# Extract "major.minor" from "major.minor[.patch]".
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/full-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ jobs:
os: macos-12
artifact-name: macos-double-x86-nightly
godot-binary: godot.macos.editor.dev.double.x86_64
rust-extra-args: --features godot/custom-godot,godot/double-precision
rust-extra-args: --features godot/api-custom,godot/double-precision

- name: macos-x86-4.2
os: macos-12
Expand All @@ -247,12 +247,12 @@ jobs:
godot-binary: godot.macos.editor.dev.arm64
with-hot-reload: true

# custom-godot on macOS arm64 not working, due to clang linker issues.
# api-custom on macOS arm64 not working, due to clang linker issues.
# - name: macos-double-arm
# os: macos-latest
# artifact-name: macos-double-arm-nightly
# godot-binary: godot.macos.editor.dev.double.arm64
# rust-extra-args: --features godot/custom-godot,godot/double-precision
# rust-extra-args: --features godot/api-custom,godot/double-precision

- name: macos-arm-4.2
os: macos-latest
Expand All @@ -272,7 +272,7 @@ jobs:
os: windows-latest
artifact-name: windows-double-nightly
godot-binary: godot.windows.editor.dev.double.x86_64.exe
rust-extra-args: --features godot/custom-godot,godot/double-precision
rust-extra-args: --features godot/api-custom,godot/double-precision

- name: windows-4.2
os: windows-latest
Expand Down Expand Up @@ -305,13 +305,13 @@ jobs:
os: ubuntu-20.04
artifact-name: linux-double-nightly
godot-binary: godot.linuxbsd.editor.dev.double.x86_64
rust-extra-args: --features godot/custom-godot,godot/double-precision,godot/codegen-full,godot/lazy-function-tables
rust-extra-args: --features godot/api-custom,godot/double-precision,godot/codegen-full,godot/lazy-function-tables

- name: linux-features-experimental
os: ubuntu-20.04
artifact-name: linux-nightly
godot-binary: godot.linuxbsd.editor.dev.x86_64
rust-extra-args: --features godot/custom-godot,godot/experimental-threads,godot/serde,codegen-full-experimental
rust-extra-args: --features godot/api-custom,godot/experimental-threads,godot/serde,codegen-full-experimental

- name: linux-release
os: ubuntu-20.04
Expand Down Expand Up @@ -354,7 +354,7 @@ jobs:
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
rust-toolchain: nightly
rust-env-rustflags: -Zrandomize-layout -Zsanitizer=address
rust-extra-args: --features godot/custom-godot
rust-extra-args: --features godot/api-custom
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
rust-target: x86_64-unknown-linux-gnu

Expand Down Expand Up @@ -393,7 +393,7 @@ jobs:
rust-env-rustflags: ${{ matrix.rust-env-rustflags }}
rust-target: ${{ matrix.rust-target }}
rust-cache-key: ${{ matrix.rust-cache-key }}
with-llvm: ${{ contains(matrix.name, 'macos') && contains(matrix.rust-extra-args, 'custom-godot') }}
with-llvm: ${{ contains(matrix.name, 'macos') && contains(matrix.rust-extra-args, 'api-custom') }}
godot-check-header: ${{ matrix.godot-check-header }}

- name: "Build and test hot-reload"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/minimal-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ jobs:
os: windows-latest
artifact-name: windows-nightly
godot-binary: godot.windows.editor.dev.x86_64.exe
# rust-extra-args: --features godot/custom-godot
# rust-extra-args: --features godot/api-custom

# Linux

Expand All @@ -154,7 +154,7 @@ jobs:
os: ubuntu-20.04
artifact-name: linux-nightly
godot-binary: godot.linuxbsd.editor.dev.x86_64
rust-extra-args: --features godot/custom-godot,godot/experimental-threads,godot/serde,codegen-full-experimental
rust-extra-args: --features godot/api-custom,godot/experimental-threads,godot/serde,codegen-full-experimental

# Linux compat

Expand All @@ -172,7 +172,7 @@ jobs:
godot-binary: godot.linuxbsd.editor.dev.x86_64.llvm.san
rust-toolchain: nightly
rust-env-rustflags: -Zrandomize-layout -Zsanitizer=address
rust-extra-args: --features godot/custom-godot
rust-extra-args: --features godot/api-custom
# Sanitizers can't build proc-macros and build scripts; with --target, cargo ignores RUSTFLAGS for those two.
rust-target: x86_64-unknown-linux-gnu

Expand Down Expand Up @@ -200,7 +200,7 @@ jobs:
rust-toolchain: ${{ matrix.rust-toolchain || 'stable' }}
rust-env-rustflags: ${{ matrix.rust-env-rustflags }}
rust-target: ${{ matrix.rust-target }}
with-llvm: ${{ contains(matrix.name, 'macos') && contains(matrix.rust-extra-args, 'custom-godot') }}
with-llvm: ${{ contains(matrix.name, 'macos') && contains(matrix.rust-extra-args, 'api-custom') }}
godot-check-header: ${{ matrix.godot-check-header }}

- name: "Build and test hot-reload"
Expand Down
6 changes: 3 additions & 3 deletions godot-bindings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ keywords = ["gamedev", "godot", "engine", "ffi", "sys"]
categories = ["game-engines", "graphics"]

# Since features are additive and we want the user to user prebuilt by default, we need to have `prebuilt-godot` as the
# default feature. However, it's not possible to _disable_ the prebuilt dependency when specifying `godot-custom` (without
# default feature. However, it's not possible to _disable_ the prebuilt dependency when specifying `api-custom` (without
# requiring no-default-features), so we unfortunately still need to depend on prebuilt and just ignore it.
# The artifact generator explicitly excludes that though (to avoid a quasi-circular dependency back to its repo).
[features]
api-4-0 = ["dep:prebuilt-4-0"]
api-4-1 = ["dep:prebuilt-4-1"]
default = ["dep:prebuilt-4-2"]
custom-godot = ["dep:bindgen", "dep:regex", "dep:which"]
custom-godot-extheader = []
api-custom = ["dep:bindgen", "dep:regex", "dep:which"]
api-custom-extheader = []


[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion godot-bindings/src/godot_exe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pub(crate) fn locate_godot_binary() -> PathBuf {
path
} else {
panic!(
"gdext with `custom-godot` feature requires 'godot4' executable or a GODOT4_BIN \
"gdext with `api-custom` feature requires 'godot4' executable or a GODOT4_BIN \
environment variable (with the path to the executable)."
)
}
Expand Down
14 changes: 7 additions & 7 deletions godot-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ use prebuilt_4_1 as godot4_prebuilt;
#[cfg(not(any(
feature = "api-4-0", //
feature = "api-4-1", //
feature = "custom-godot", //
feature = "api-custom", //
)))]
use prebuilt_4_2 as godot4_prebuilt;

// This is outside of `godot_version` to allow us to use it even when we don't have the `custom-godot`
// This is outside of `godot_version` to allow us to use it even when we don't have the `api-custom`
// feature enabled.
#[derive(Eq, PartialEq, Debug)]
pub struct GodotVersion {
Expand All @@ -51,7 +51,7 @@ pub struct GodotVersion {
#[cfg(test)]
mod godot_version;

#[cfg(feature = "custom-godot")]
#[cfg(feature = "api-custom")]
#[path = ""]
mod custom {
use super::*;
Expand All @@ -68,7 +68,7 @@ mod custom {
godot_exe::write_gdextension_headers(h_path, rs_path, false, watch);
}

#[cfg(feature = "custom-godot-extheader")]
#[cfg(feature = "api-custom-extheader")]
pub fn write_gdextension_headers_from_c(h_path: &Path, rs_path: &Path, watch: &mut StopWatch) {
godot_exe::write_gdextension_headers(h_path, rs_path, true, watch);
}
Expand All @@ -78,13 +78,13 @@ mod custom {
}
}

#[cfg(feature = "custom-godot")]
#[cfg(feature = "api-custom")]
pub use custom::*;

// ----------------------------------------------------------------------------------------------------------------------------------------------
// Reuse existing files

#[cfg(not(feature = "custom-godot"))]
#[cfg(not(feature = "api-custom"))]
#[path = ""]
mod prebuilt {
use super::*;
Expand Down Expand Up @@ -124,7 +124,7 @@ mod prebuilt {
}
}

#[cfg(not(feature = "custom-godot"))]
#[cfg(not(feature = "api-custom"))]
pub use prebuilt::*;

// ----------------------------------------------------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion godot-codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ codegen-fmt = []
codegen-full = []
codegen-lazy-fptrs = []
double-precision = []
custom-godot = ["godot-bindings/custom-godot"]
api-custom = ["godot-bindings/api-custom"]
experimental-godot-api = []

[dependencies]
Expand Down
2 changes: 1 addition & 1 deletion godot-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ codegen-lazy-fptrs = [
"godot-ffi/codegen-lazy-fptrs",
"godot-codegen/codegen-lazy-fptrs",
]
custom-godot = ["godot-ffi/custom-godot", "godot-codegen/custom-godot"]
api-custom = ["godot-ffi/api-custom", "godot-codegen/api-custom"]
double-precision = ["godot-codegen/double-precision"]
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
experimental-threads = ["godot-ffi/experimental-threads"]
Expand Down
2 changes: 1 addition & 1 deletion godot-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords = ["gamedev", "godot", "engine", "ffi"]
categories = ["game-engines", "graphics"]

[features]
custom-godot = ["godot-bindings/custom-godot"]
api-custom = ["godot-bindings/api-custom"]
codegen-fmt = ["godot-codegen/codegen-fmt"]
codegen-lazy-fptrs = ["godot-codegen/codegen-lazy-fptrs"]
experimental-godot-api = ["godot-codegen/experimental-godot-api"]
Expand Down
2 changes: 1 addition & 1 deletion godot-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ keywords = ["gamedev", "godot", "engine", "derive", "macro"]
categories = ["game-engines", "graphics"]

[features]
custom-godot = ["godot-bindings/custom-godot"]
api-custom = ["godot-bindings/api-custom"]

[lib]
proc-macro = true
Expand Down
15 changes: 8 additions & 7 deletions godot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ categories = ["game-engines", "graphics"]

[features]
default = ["codegen-full"]
custom-godot = ["godot-core/custom-godot"]
api-4-0 = ["godot-core/api-4-0"]
api-4-1 = ["godot-core/api-4-1"]
api-custom = ["godot-core/api-custom"]
custom-godot = []
double-precision = ["godot-core/double-precision"]
formatted = ["godot-core/codegen-fmt"]
serde = ["godot-core/serde"]
lazy-function-tables = ["godot-core/codegen-lazy-fptrs"]
experimental-threads = ["godot-core/experimental-threads"]
experimental-godot-api = ["godot-core/experimental-godot-api"]
experimental-threads = ["godot-core/experimental-threads"]
experimental-wasm = []
api-4-0 = ["godot-core/api-4-0"]
api-4-1 = ["godot-core/api-4-1"]
formatted = ["godot-core/codegen-fmt"]
lazy-function-tables = ["godot-core/codegen-lazy-fptrs"]
serde = ["godot-core/serde"]

# Private features, they are under no stability guarantee
codegen-full = ["godot-core/codegen-full"]
Expand Down
33 changes: 22 additions & 11 deletions godot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,18 +113,26 @@
//! Use `f64` instead of `f32` for the floating-point type [`real`][type@builtin::real]. Requires Godot to be compiled with the
//! scons flag `precision=double`.<br><br>
//!
//! * **`custom-godot`**
//! * **`api-4-{minor}`**
//!
//! Sets the [API level](https://godot-rust.github.io/book/toolchain/compatibility.html) to the specified Godot version, e.g. `api-4-1`.
//! You can use at most one `api-*` feature. By default, a recent stable Godot release is used.
//!
//! The API level determines the lowest possible Godot version under which the extension can run. We support latest patch releases of each
//! Godot minor version, down to `4.0`. From `4.1` onwards, the API is forward-compatible (you can use `api-4-1` under a Godot 4.3 binary).
//! Level `4.0` is not compatible with newer versions.
//!
//! If you want to share your extension with others, we recommend setting the level as low as possible. This can however mean you cannot
//! use newer Godot features. In certain cases, we provide polyfills for newer features on older versions.
//!
//! The gdext-built extension will check compatibility on startup and refuse to load if it detects a mismatch.<br><br>
//!
//! * **`api-custom`**
//!
//! Use a custom Godot build instead of the latest official release. This is useful when you like to use a
//! version compiled yourself, with custom flags.
//!
//! If you simply want to use a different official release, use this pattern instead (here e.g. for version `4.0`):
//! ```toml
//! # Trick Cargo into seeing a different URL; https://github.com/rust-lang/cargo/issues/5478
//! [patch."https://github.com/godot-rust/godot4-prebuilt"]
//! godot4-prebuilt = { git = "https://github.com//godot-rust/godot4-prebuilt", branch = "4.0"}
//! ```
//! <br>
//! This feature is mutually exclusive with `api-4-*` features.<br><br>
//!
//! * **`serde`**
//!
Expand Down Expand Up @@ -187,8 +195,11 @@ compile_error!("Thread safety for lazy function pointers is not yet implemented.
compile_error!("Must opt-in using `experimental-wasm` Cargo feature; keep in mind that this is work in progress");

// See also https://github.com/godotengine/godot/issues/86346.
#[cfg(all(feature = "double-precision", not(feature = "custom-godot")))]
compile_error!("The feature `double-precision` currently requires `custom-godot` due to incompatibilities in the GDExtension API JSON.");
#[cfg(all(feature = "double-precision", not(feature = "api-custom")))]
compile_error!("The feature `double-precision` currently requires `api-custom` due to incompatibilities in the GDExtension API JSON.");

#[cfg(feature = "custom-godot")]
compile_error!("The feature `custom-godot` has been renamed to `api-custom`. See https://github.com/godot-rust/gdext/pull/702.");

const fn _validate_features() {
let mut count = 0;
Expand All @@ -199,7 +210,7 @@ const fn _validate_features() {
if cfg!(feature = "api-4-1") {
count += 1;
}
if cfg!(feature = "custom-godot") {
if cfg!(feature = "api-custom") {
count += 1;
}

Expand Down

0 comments on commit 5d622d8

Please sign in to comment.