-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Add bindgen build zephyr-sys #76337
Add bindgen build zephyr-sys #76337
Commits on Aug 27, 2024
-
rust: Create zephyr-sys for low-level bindings
With a lot of work done by Mario Jaun <mario.jaun@zuehlke.com>. Use the rust-bindgen tool to extract bindings from the Zephyr header files. The tool is run with the exact configuration of the current build, and therefore the bindings will match the current target. The ifdefs and such are not translated into the Rust code, and this must be generated live for each build. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for aaf40b5 - Browse repository at this point
Copy the full SHA aaf40b5View commit details -
rust: Use zephyr-sys to get bindings
Instead of trying to manually generate the bindings, use those generated by bindgen in the zephyr-sys crate. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 9f71cc7 - Browse repository at this point
Copy the full SHA 9f71cc7View commit details -
rust: Convert k_str_out to bindgen one
Remove the manual k_str_out wrapper, and use the one generated by bindgen. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 1d9d675 - Browse repository at this point
Copy the full SHA 1d9d675View commit details -
include: Add dummy field for Rust as well as CPP
For CPP builds, a few structs that end up empty in some configurations will generate compile errors. With the Rust tools, bindgen ends up producing empty structsw for these as well. Although the code compiles, it generates warnings. For now, add CONFIG_RUST to the ifdef checks so that these structs don't end up empty with Rust either. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 2046760 - Browse repository at this point
Copy the full SHA 2046760View commit details -
cmake: rust: Compile the bindgen wrapper
When compiling Rust programs, the bindgen utility generates a wrapper file to expand inline functions, as these otherwise cannot be accessed from rust. Pass a consistent name to the cargo build, and add it to our source build so that this wrapper get compiled. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for b1d3ec3 - Browse repository at this point
Copy the full SHA b1d3ec3View commit details -
rust: zephyr-sys: Use absolute path for wrapper
Change the header passed into bindgen to be an absolute path. This will cause the generated wrapper to refer to this file also using an absolute path. As such, remove the explicit include path added as part of the build. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 865cf5e - Browse repository at this point
Copy the full SHA 865cf5eView commit details -
doc: rust: Add docs on bindings
Add documentation on the bindings between Rust and C, and the bindgen tool used to generate them. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 2c3432a - Browse repository at this point
Copy the full SHA 2c3432aView commit details -
rust: Export zephyr-sys as zephyr::raw
Re-export all of the bindgen generated bindings in the zephyr-sys crate into `zephyr::raw`. This keeps things easier, as users of `zephyr` only need to worry about the single `zephyr` crate. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for f26c50e - Browse repository at this point
Copy the full SHA f26c50eView commit details
Commits on Aug 28, 2024
-
cmake: rust: Fix typo on variable name
Fix `WRAPPER_FiLE` to `WRAPPER_FILE`. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for fd2061b - Browse repository at this point
Copy the full SHA fd2061bView commit details -
rust: Suppress warning about improper C types
Zephyr takes advantage of a gcc/clang extension that allows structs that have no elements. Rust is perfectly happy with this (it is quite common in Rust code), but generates a warning when a struct containing no elements is passed to C code. For now, suppress this warning on the generated bindings. This has the disadvantage of suppressing it entirely, which might possibly detect other cases of invalid structs. However, the bindings are auto-generated from C structs so should always be valid. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for e825732 - Browse repository at this point
Copy the full SHA e825732View commit details -
Revert "include: Add dummy field for Rust as well as CPP"
This reverts commit 2046760. Put these back so we get the zero element structures when using just rust and not CPP. A subsequent patch will suppress the warning. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 90b90c2 - Browse repository at this point
Copy the full SHA 90b90c2View commit details -
rust: Workaround gcc/clang differences with soft fp
GCC automatically defines a `__SOFTFP__` define on targets that are using software floating point. The clang compiler does not do this by default, so check this, and define it. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 23dad4d - Browse repository at this point
Copy the full SHA 23dad4dView commit details -
rust: zephyr-sys: Fixup clang targets for RISCV
Rustc for RISCV encodes optional features on the CPU available as part of the target tuple. Clang, on the other hand does not. In order to be able to use libclang with bindgen on RISCV, we need to simplify the target tuples a bit. Do this by just matching 'riscv32' or 'riscv64' and then passing in a generic tuple. We aren't generating any code, and the structs should always match between the targets. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 3373f4e - Browse repository at this point
Copy the full SHA 3373f4eView commit details -
.gitignore: Ignore Rust 'target' directories
Although the Cmake rules to build Rust applications keeps the target directory inside of the build directory, some IDE tools may generate a target directory while editing the code. Ignore these so they never get checked in. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 7a95c12 - Browse repository at this point
Copy the full SHA 7a95c12View commit details
Commits on Aug 29, 2024
-
cmake: rust: Add header dependencies to cargo
With bindgen needing to read the headers, make sure CMake knows about this. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for eb68555 - Browse repository at this point
Copy the full SHA eb68555View commit details
Commits on Sep 5, 2024
-
doc: develop: rust: Various cleanups to docs
Minor fixes to the documentation from review feedback. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 6cd9a68 - Browse repository at this point
Copy the full SHA 6cd9a68View commit details -
cmake: rust: Remove redundant call
Remove a redundant call that does exactly what the previous function call accomplishes. Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 2966c8f - Browse repository at this point
Copy the full SHA 2966c8fView commit details -
Fix a mispelled word "al" -> "all". Signed-off-by: David Brown <david.brown@linaro.org>
Configuration menu - View commit details
-
Copy full SHA for 7a8dbb1 - Browse repository at this point
Copy the full SHA 7a8dbb1View commit details