Skip to content

Commit 8c5c9ed

Browse files
committed
make the codegen crate work with vscode finally
1 parent 67b253d commit 8c5c9ed

File tree

8 files changed

+983
-49
lines changed

8 files changed

+983
-49
lines changed

.vscode/settings.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@
88
"editor.formatOnSaveMode": "file",
99
"editor.defaultFormatter": "rust-lang.rust-analyzer"
1010
},
11+
"rust-analyzer.server.extraEnv": {
12+
"RA_LOG": "warn,rust_analyzer::reload=info"
13+
},
1114
"rust-analyzer.rustc.source": "discover",
1215
"rust-analyzer.linkedProjects": [
13-
// "./crates/bevy_api_gen/Cargo.toml",
16+
"./crates/bevy_api_gen/Cargo.toml",
1417
"Cargo.toml",
1518
],
16-
"rust-analyzer.check.invocationStrategy": "once",
19+
"rust-analyzer.check.invocationStrategy": "per_workspace",
20+
// "rust-analyzer.cargo.buildScripts.invocationStrategy": "per_workspace",
1721
"rust-analyzer.check.overrideCommand": [
1822
"/home/makspll/git/bevy_mod_scripting/check.sh"
1923
],
20-
"rust-analyzer.cargo.buildScripts.overrideCommand": [
21-
"/home/makspll/git/bevy_mod_scripting/check.sh"
22-
],
24+
// "rust-analyzer.cargo.buildScripts.overrideCommand": [
25+
// "/home/makspll/git/bevy_mod_scripting/check.sh"
26+
// ],
2327
"rust-analyzer.showUnlinkedFileNotification": false,
2428
"rust-analyzer.runnables.extraTestBinaryArgs": [
2529
"--show-output",

check.exe

-25.5 KB
Binary file not shown.

check.json

Lines changed: 688 additions & 0 deletions
Large diffs are not rendered by default.

check.ps1

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
#!/usr/bin/env pwsh
2-
Remove-Variable -Name RUSTUP_TOOLCHAIN -ErrorAction SilentlyContinue
3-
$CURRENT_DIR = Split-Path -Leaf -Path (Get-Location)
4-
5-
if ($CURRENT_DIR -eq "bevy_api_gen") {
6-
cargo +nightly-2024-12-15 clippy --all-targets --message-format=json
7-
} else {
8-
cargo clippy --workspace --all-targets --message-format=json --features="lua54 rhai rune bevy/file_watcher bevy/multi_threaded"
9-
}
2+
Set-Location -Path (Split-Path -Parent $MyInvocation.MyCommand.Definition)
3+
cargo xtask check --ide-mode

crates/bevy_api_gen/Cargo.bootstrap.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ edition = "2021"
66

77
[dependencies]
88
mlua = { version = "0.10", features = ["lua54", "vendored", "send", "macros"] }
9+
bevy_mod_scripting_core = { path = "{{WORKSPACE_DIR}}/crates/bevy_mod_scripting_core" }
910
bevy_reflect = { version = "0.15.0", features = [
1011
"bevy",
1112
"glam",

crates/bevy_api_gen/src/bin/main.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,28 @@ fn find_bootstrap_dir() -> PathBuf {
326326

327327
/// Generate bootstrapping crate files
328328
fn write_bootstrap_files(path: &Path) {
329+
const WORKSPACE_DIR_PLACEHOLDER: &str = "{{WORKSPACE_DIR}}";
330+
329331
// write manifest file 'Cargo.toml'
330-
let manifest_content = include_bytes!("../../Cargo.bootstrap.toml");
332+
let mut manifest_content =
333+
String::from_utf8(include_bytes!("../../Cargo.bootstrap.toml").to_vec())
334+
.expect("Could not read manifest template as utf8");
335+
336+
// replace placeholders
337+
let workspace_dir = Path::new(file!())
338+
.ancestors()
339+
.skip(1)
340+
.nth(5)
341+
.expect("Could not find workspace directory");
342+
343+
manifest_content =
344+
manifest_content.replace(WORKSPACE_DIR_PLACEHOLDER, workspace_dir.to_str().unwrap());
345+
331346
let manifest_path = path.join("Cargo.toml");
332347

333348
let mut file = File::create(manifest_path)
334349
.expect("Could not create manifest file for bootstrapping crate.");
335-
file.write_all(manifest_content)
350+
file.write_all(manifest_content.as_bytes())
336351
.expect("Failed writing to manifest file for bootstrapping crate");
337352

338353
// write dummy main function

crates/xtask/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ itertools = "0.14"
1919
cargo_metadata = "*"
2020
serde = { version = "1.0", features = ["derive"] }
2121
serde_json = "1.0"
22+
glob = "0.3"

0 commit comments

Comments
 (0)