Skip to content

Better code style in build.rs #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2025
Merged

Conversation

krant
Copy link
Contributor

@krant krant commented Jul 1, 2025

  • No more unwraps in build.rs
  • More idiomatic directory traversal (without for)
  • Fix warnings from cargo clippy --features ts-gen on Rust 1.88

@lukipuki
Copy link
Collaborator

lukipuki commented Jul 1, 2025

Note that the build is currently broken because of bluez-async: https://discord.com/channels/867578229534359593/1148012739575418932/1389540482761101402
We need to fix it ASAP.

@krant
Copy link
Contributor Author

krant commented Jul 1, 2025

My guess we should change cargo +1.76.0 here to cargo +1.85.0.

@lukipuki
Copy link
Collaborator

lukipuki commented Jul 1, 2025

My guess we should change cargo +1.76.0 here to cargo +1.85.0.

This is not the right way to do it, we set rust-version = "1.76" in Cargo.toml, we should use the same version in CI to verify the crate builds with 1.76.

@krant
Copy link
Contributor Author

krant commented Jul 1, 2025

But it looks bluetooth crates ecosystem moved on to Rust 2024. Shouldn't we set rust-version = "1.85" then?

@lukipuki
Copy link
Collaborator

lukipuki commented Jul 1, 2025

I don't think we should (it could break someone's build) if there's better solutions: #57

@krant
Copy link
Contributor Author

krant commented Jul 1, 2025

Looks good! Let's merge #57 so I could rebase my PR on top.

@lukipuki
Copy link
Collaborator

lukipuki commented Jul 1, 2025

Looks good! Let's merge #57 so I could rebase my PR on top.

Done

build.rs Outdated
Comment on lines 32 to 33
.map(|x| x.path().to_owned())
.filter(|x| x.extension() == Some(std::ffi::OsStr::new("proto")))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(|x| x.path().to_owned())
.filter(|x| x.extension() == Some(std::ffi::OsStr::new("proto")))
.map(|x| x.into_path())
.filter(|x| x.extension().is_some_and(|ext| ext == "proto"))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, done

build.rs Outdated
let protobufs_dir = "src/protobufs/";
let gen_dir = "src/generated/";
let src_dir = "src/protobufs/";
let out_dir = "src/generated/";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out_dir is not a good name, it already has a meaning inside of build.rs:
https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-crates

I'd keep the original gen_dir.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, done

@lukipuki lukipuki merged commit a0c78fd into meshtastic:main Jul 1, 2025
3 checks passed
@krant krant deleted the build_rs branch July 1, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants