aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-12-23 21:38:56 +0930
committermat <git@matdoes.dev>2025-12-23 06:39:01 -0530
commit0fdcff1909b28c5f61587ff5031c67e2880b84fc (patch)
tree9a80012d7e74305dcbd458934d57d1f9a9de86ae
parent82e3d46ca319badcbc584cf902aeebcbd30948b9 (diff)
downloadazalea-drasl-0fdcff1909b28c5f61587ff5031c67e2880b84fc.tar.xz
don't write unnecessarily from azalea-client's build script
-rw-r--r--azalea-client/build.rs26
-rw-r--r--azalea/src/bot.rs4
2 files changed, 18 insertions, 12 deletions
diff --git a/azalea-client/build.rs b/azalea-client/build.rs
index 49ef62db..156f73a6 100644
--- a/azalea-client/build.rs
+++ b/azalea-client/build.rs
@@ -1,11 +1,12 @@
use std::{
- fs::{self, File},
- io::Write,
+ fmt::Write,
+ fs::{self},
+ path::Path,
};
fn main() {
// Tell Cargo that if the given file changes, to rerun this build script.
- println!("cargo::rerun-if-changed=tests");
+ println!("cargo::rerun-if-changed=tests/simulation");
let Ok(paths) = fs::read_dir("tests/simulation") else {
return;
@@ -29,15 +30,20 @@ fn main() {
modules.push(mod_name);
}
- let Ok(mut mod_rs) = File::create("tests/simulation/mod.rs") else {
- return;
- };
- let _ = writeln!(
- mod_rs,
- "// This file is @generated by `azalea-client/build.rs`.\n"
- );
+ let mut mod_rs = String::new();
+
+ mod_rs.push_str("// This file is @generated by `azalea-client/build.rs`.\n\n");
modules.sort();
for mod_name in modules {
let _ = writeln!(mod_rs, "mod {mod_name};");
}
+
+ let mod_rs_path = Path::new("tests/simulation/mod.rs");
+
+ let existing_mod_rs = fs::read_to_string(mod_rs_path).unwrap_or_default();
+ if mod_rs == existing_mod_rs {
+ // this would cause the build script to run again
+ return;
+ }
+ let _ = fs::write(mod_rs_path, mod_rs);
}
diff --git a/azalea/src/bot.rs b/azalea/src/bot.rs
index 8410f0b1..33293466 100644
--- a/azalea/src/bot.rs
+++ b/azalea/src/bot.rs
@@ -86,8 +86,8 @@ fn stop_jumping(mut query: Query<(&mut Jumping, &mut Bot)>) {
}
}
-/// A trait that adds a few additional functions to [`Client`] that help with
-/// making bots.
+/// A trait that adds a few additional functions to
+/// [`Client`](azalea_client::Client) that help with making bots.
pub trait BotClientExt {
/// Queue a jump for the next tick.
fn jump(&self);