Skip to content

Commit 120a0dd

Browse files
committed
Move /target/godot-gen -> /$crate/src/gen (the former breaks IDE static analysis)
A directory /.generated in the repo root seems to _mostly_ work, but on CLion it needs an extra "Cargo sync" in fresh/cleaned projects. This creates extra friction that a crate-local `gen` directory doesn't have. Maybe reconsider this once IDEs handle things better.
1 parent c639f9a commit 120a0dd

File tree

8 files changed

+13
-24
lines changed

8 files changed

+13
-24
lines changed

.github/composite/godot-itest/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ runs:
7676
# Note: no longer fails, as we expect header to be forward-compatible; instead issues a warning
7777
- name: "Copy and compare GDExtension header"
7878
if: inputs.artifact-name == 'godot-linux'
79-
working-directory: target/godot-gen
79+
working-directory: godot-ffi/src/gen
8080
run: |
8181
mv $RUNNER_DIR/godot_bin/gdextension_interface.h gdextension_interface.h.bak
8282
git apply ../../godot-bindings/res/tweaks.patch

godot-bindings/res/tweak.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
diff --git b/target/godot-gen/gdextension_interface.h a/target/godot-gen/gdextension_interface.h
1+
diff --git b/godot-ffi/src/gen/gdextension_interface.h a/godot-ffi/src/gen/gdextension_interface.h
22
index 0b7615f..6db266e 100644
3-
--- b/target/godot-gen/gdextension_interface.h
4-
+++ a/target/godot-gen/gdextension_interface.h
3+
--- b/godot-ffi/src/gen/gdextension_interface.h
4+
+++ a/godot-ffi/src/gen/gdextension_interface.h
55
@@ -139,22 +139,22 @@ typedef enum {
66

77
} GDExtensionVariantOperator;

godot-bindings/src/godot_exe.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,11 @@ use std::process::{Command, Output};
1717

1818
// Note: CARGO_BUILD_TARGET_DIR and CARGO_TARGET_DIR are not set.
1919
// OUT_DIR would be standing to reason, but it's an unspecified path that cannot be referenced by CI.
20-
const GODOT_VERSION_PATH: &str = concat!(
21-
env!("CARGO_MANIFEST_DIR"),
22-
"/../target/godot-gen/godot_version.txt"
23-
);
24-
const JSON_PATH: &str = concat!(
25-
env!("CARGO_MANIFEST_DIR"),
26-
"/../target/godot-gen/extension_api.json"
27-
);
20+
const GODOT_VERSION_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/src/gen/godot_version.txt");
21+
const JSON_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/src/gen/extension_api.json");
2822
const HEADER_PATH: &str = concat!(
2923
env!("CARGO_MANIFEST_DIR"),
30-
"/../target/godot-gen/gdextension_interface.h"
24+
"/src/gen/gdextension_interface.h"
3125
);
3226

3327
pub fn load_gdextension_json(watch: &mut StopWatch) -> String {

godot-core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ custom-godot = ["godot-ffi/custom-godot", "godot-codegen/custom-godot"]
1717

1818
[dependencies]
1919
godot-ffi = { path = "../godot-ffi" }
20-
once_cell = "1.8"
2120

2221
# See https://docs.rs/glam/latest/glam/index.html#feature-gates
2322
glam = { version = "0.22", features = ["debug-glam-assert"] }

godot-core/build.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
use std::path::Path;
88

99
fn main() {
10-
let gen_path = Path::new(concat!(
11-
env!("CARGO_MANIFEST_DIR"),
12-
"/../target/godot-gen/core"
13-
));
10+
// It would be better to generate this in /.generated or /target/godot-gen, however IDEs currently
11+
// struggle with static analysis when symbols are outside the crate directory (April 2023).
12+
let gen_path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/src/gen"));
1413

1514
if gen_path.exists() {
1615
std::fs::remove_dir_all(gen_path).unwrap_or_else(|e| panic!("failed to delete dir: {e}"));

godot-core/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ pub mod engine;
2424
#[allow(unused_imports, dead_code, non_upper_case_globals, non_snake_case, clippy::too_many_arguments, clippy::let_and_return, clippy::new_ret_no_self)]
2525
#[allow(clippy::upper_case_acronyms)] // TODO remove this line once we transform names
2626
#[allow(clippy::wrong_self_convention)] // TODO remove once to_string is const
27-
#[path = "../../target/godot-gen/core/mod.rs"]
2827
mod gen;
2928

3029
#[doc(hidden)]

godot-ffi/build.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ use std::path::Path;
1111
fn main() {
1212
let mut watch = godot_bindings::StopWatch::start();
1313

14-
let gen_path = Path::new(concat!(
15-
env!("CARGO_MANIFEST_DIR"),
16-
"/../target/godot-gen/ffi"
17-
));
14+
// It would be better to generate this in /.generated or /target/godot-gen, however IDEs currently
15+
// struggle with static analysis when symbols are outside the crate directory (April 2023).
16+
let gen_path = Path::new(concat!(env!("CARGO_MANIFEST_DIR"), "/src/gen"));
1817
let header_rs_path = gen_path.join("gdextension_interface.rs");
1918

2019
godot_bindings::clear_dir(gen_path, &mut watch);

godot-ffi/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
deref_nullptr,
1818
clippy::redundant_static_lifetimes
1919
)]
20-
#[path = "../../target/godot-gen/ffi/mod.rs"]
2120
pub(crate) mod gen;
2221

2322
mod godot_ffi;

0 commit comments

Comments
 (0)