Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Friendly non linux compilation error#80

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

shahn
Copy link
Contributor

I tried to make it a bit friendlier for someone accidentally building on non-linux by adding a build script to check and only including neli for linux. Also this removes an unused and very outdated dependency as well as updating thiserror to version 2, which has permeated through the ecosystem quite a bit

byte_conv is also unmaintained for 9 years and has an open bug aboutunsoundness.
This doesn't seem to require any code modifications
@shahnshahn changed the titleFriendly non linux compilationFriendly non linux compilation errorDec 22, 2024
Copy link
Collaborator

@fpagliughifpagliughi left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! This should be helpful.

Unfortunately, there is a build error:

error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, but the minimum supported Rust version of `socketcan v3.4.0-pre.0 (/home/fmp/projects/rust/embedded/socketcan)` is 1.70.Switch to the old `cargo:rerun-if-changed=build.rs` syntax (note the single colon).See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script for more information about build script outputs.

I think the string in the println should just have a single colon, ':'

"cargo:rerun-if-changed=build.rs"

Ok(val) if val == "linux" => Ok(()),
_ => Err("Building for anything but Linux is not supported by socketcan".into()),
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works, but I usually force a compile error for an error message that's even more clear:

// build.rs#[cfg(not(target_os = "linux"))]compile_error!("socketcan can only be build for a Linux target");fn main() {}

which gives:

error: socketcan can only be build for a Linux target --> build.rs:4:1  |4 | compile_error!("socketcan can only be build for a Linux target");  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^error: could not compile `buildtgt` (build script) due to 1 previous error

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This does not work for cross compiles, as far as I know. Inside a build script, you cannot rely on #[cfg] for target_os but have to use the cargo environment variable. The reason is that the build script is built for the architecture that you're running the build on because it gets executed there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, yeah, I think you're right. This keeps tripping me up.

@shahnshahnforce-pushed thefriendly_non_linux_compilation branch from897e549 toeb55dabCompareDecember 22, 2024 20:00
@shahn
Copy link
ContributorAuthor

Sorry for the MSRV violation and thanks for catching it. I added a fix. With regards to thecompile_error(), I don't think we can use it in the build script, unfortunately.

@fpagliughifpagliughi merged commitd8f4dbe intosocketcan-rs:masterDec 22, 2024
@shahnshahn deleted the friendly_non_linux_compilation branchDecember 22, 2024 21:32
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@fpagliughifpagliughifpagliughi approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@shahn@fpagliughi

[8]ページ先頭

©2009-2025 Movatter.jp