Skip to content

Commit fcadc37

Browse files
authored
Merge pull request #1100 from TitanNano/jovan/not_itest_default_feature
Move `itest` default feature `codegen-full` into build script
2 parents 1add2d0 + 9265f9e commit fcadc37

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

godot-codegen/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ use std::path::{Path, PathBuf};
4343

4444
pub type SubmitFn = dyn FnMut(PathBuf, TokenStream);
4545

46+
#[cfg(not(feature = "codegen-full"))]
47+
pub const IS_CODEGEN_FULL: bool = false;
48+
49+
/// Used by itest to determine true codegen status; see itest/build.rs.
50+
#[cfg(feature = "codegen-full")]
51+
pub const IS_CODEGEN_FULL: bool = true;
52+
4653
fn write_file(path: &Path, contents: String) {
4754
let dir = path.parent().unwrap();
4855
let _ = std::fs::create_dir_all(dir);

itest/rust/Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ publish = false
1010
crate-type = ["cdylib"]
1111

1212
[features]
13-
default = ["codegen-full"]
13+
# Default feature MUST be empty for workflow reasons, even if it differs from the default feature set in upstream `godot` crate.
14+
default = []
1415
codegen-full = ["godot/__codegen-full"]
1516
codegen-full-experimental = ["codegen-full", "godot/experimental-godot-api"]
1617
experimental-threads = ["godot/experimental-threads"]
@@ -28,6 +29,7 @@ serde_json = { version = "1.0", optional = true }
2829
[build-dependencies]
2930
godot-bindings = { path = "../../godot-bindings" } # emit_godot_version_cfg
3031
repo-tweak = { path = "../repo-tweak" }
32+
godot-codegen = { path = "../../godot-codegen" } # IS_CODEGEN_FULL
3133

3234
# Minimum versions compatible with -Zminimal-versions
3335
proc-macro2 = "1.0.80" # Literal::c_string() added in 1.0.80.

itest/rust/build.rs

+9
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,15 @@ fn main() {
269269
rustfmt_if_needed(vec![rust_file]);
270270

271271
godot_bindings::emit_godot_version_cfg();
272+
273+
// The godot crate has a __codegen-full default feature that enables the godot-codegen/codegen-full feature. When compiling the entire
274+
// workspace itest also gets compiled with full codegen due to feature unification. This causes compiler errors since the
275+
// itest/codegen-full feature does not automatically get enabled in such a situation.
276+
//
277+
// By conditionally emitting the feature config we can auto enable the feature for itest as well.
278+
if godot_codegen::IS_CODEGEN_FULL {
279+
println!("cargo::rustc-cfg=feature=\"codegen-full\"");
280+
}
272281
}
273282

274283
// TODO remove, or remove code duplication with codegen

0 commit comments

Comments
 (0)