Add some Rust library building infrastructure#16833
Conversation
|
Rebased to track #16274 |
MrKevinWeiss
left a comment
There was a problem hiding this comment.
From the Kconfig perspective, I don't think we need to expose the APPLICATION_RUST_MODULE if we just manually turn off the MODULE_RUST_RIOTMODULES_STANDALONE in the app.test.config.
If the one-liner is too much, we could think about adding a flag to the kconfig.mk similar to the RIOT_CONFIG_DEVELHELP, however, I don't know how scalable this solution would be as we are injecting some make dependency resolution aspects into kconfig.
diff
diff --git a/boards/microbit-v2/Kconfig b/boards/microbit-v2/Kconfig
index 5b6d68fe28..44eacaf949 100644
--- a/boards/microbit-v2/Kconfig
+++ b/boards/microbit-v2/Kconfig
@@ -19,6 +19,7 @@ config BOARD_MICROBIT_V2
select HAS_VDD_LC_FILTER_REG1
select HAVE_SAUL_GPIO
+ select HAVE_LSM303AGR
source "$(RIOTBOARD)/common/microbit/Kconfig"
source "$(RIOTBOARD)/common/nrf52/Kconfig"
diff --git a/drivers/Kconfig b/drivers/Kconfig
index e93c467c7a..3efeedec0f 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -106,6 +106,7 @@ rsource "lpd8808/Kconfig"
rsource "lpsxxx/Kconfig"
rsource "lsm6dsl/Kconfig"
rsource "lsm303dlhc/Kconfig"
+rsource "lsm303agr/Kconfig"
rsource "ltc4150/Kconfig"
rsource "mag3110/Kconfig"
rsource "mhz19/Kconfig"
diff --git a/drivers/lsm303agr/Kconfig b/drivers/lsm303agr/Kconfig
new file mode 100644
index 0000000000..089158ac31
--- /dev/null
+++ b/drivers/lsm303agr/Kconfig
@@ -0,0 +1,20 @@
+# Copyright (c) 2022 HAW Hamburg
+#
+# This file is subject to the terms and conditions of the GNU Lesser
+# General Public License v2.1. See the file LICENSE in the top level
+# directory for more details.
+#
+
+config MODULE_LSM303AGR
+ bool
+ prompt "LSM303AGR 3D accelerometer/magnetometer" if !(MODULE_SAUL_DEFAULT && HAVE_LSM303AGR)
+ default y if (MODULE_SAUL_DEFAULT && HAVE_LSM303AGR)
+ depends on HAS_PERIPH_I2C
+ depends on TEST_KCONFIG
+ select MODULE_RUST_RIOTMODULES
+ select MODULE_PERIPH_I2C
+
+config HAVE_LSM303AGR
+ bool
+ help
+ Indicates that a lsm303agr sensor is present.
diff --git a/examples/rust-hello-world/app.config.test b/examples/rust-hello-world/app.config.test
new file mode 100644
index 0000000000..35e6e62250
--- /dev/null
+++ b/examples/rust-hello-world/app.config.test
@@ -0,0 +1,2 @@
+CONFIG_MODULE_RUST_RIOTMODULES=y
+CONFIG_MODULE_RUST_RIOTMODULES_STANDALONE=n
diff --git a/sys/Kconfig b/sys/Kconfig
index 37943f299b..2b1e75d678 100644
--- a/sys/Kconfig
+++ b/sys/Kconfig
@@ -79,6 +79,7 @@ rsource "progress_bar/Kconfig"
rsource "ps/Kconfig"
rsource "random/Kconfig"
rsource "rtc_utils/Kconfig"
+rsource "rust_riotmodules/Kconfig"
rsource "saul_reg/Kconfig"
rsource "schedstatistics/Kconfig"
rsource "sema/Kconfig"
diff --git a/sys/rust_riotmodules/Kconfig b/sys/rust_riotmodules/Kconfig
new file mode 100644
index 0000000000..a289a26506
--- /dev/null
+++ b/sys/rust_riotmodules/Kconfig
@@ -0,0 +1,19 @@
+# Copyright (c) 2022 HAW Hamburg
+#
+# This file is subject to the terms and conditions of the GNU Lesser
+# General Public License v2.1. See the file LICENSE in the top level
+# directory for more details.
+#
+
+menuconfig MODULE_RUST_RIOTMODULES
+ bool "RUST RIOT modules"
+ depends on TEST_KCONFIG
+ depends on HAS_RUST_TARGET
+ help
+ This module is used when some module asking to have its code built
+ through rust_riotmodules
+
+config MODULE_RUST_RIOTMODULES_STANDALONE
+ bool "RUST RIOT modules are standalone"
+ default y
+ depends on MODULE_RUST_RIOTMODULES|
Thanks, distributed over fixups to give it a try. Ad the one-liner, would it help to express this as rust_riotmodules depending on either rust_application (preferred) or rust_riotmodules_standalone, but the former is only provided by the applications that have a main module? |
This two-line addition is currently necessary for all Kconfig builds of Rust applications that use Rust modules; alternatives are being explored[1] [1]: RIOT-OS#16833 (comment)
|
The test run of |
Some of this *should* be committed (like rust-gcoap following the best pracitce of using the rust_lib_catchall module), but I'd rather have a useful Rust module. This two-line addition is currently necessary for all Kconfig builds of Rust applications that use Rust modules; alternatives are being explored[1] [1]: RIOT-OS#16833 (comment)
|
All test failures are unrelated, and have now promising PRs to resolve them (#18210, #18255, #18236). @maribu wrote:
Is that something you'd turn into an ACK? Does it extend to the lsm303agr driver (which is a candidate for a separate PR and primarily in here to give a good example), or would you rather have that removed when squashing / removing the REMOVEME commits? |
|
@kaspar030, are you happy with the adjustment? Rerunning tests given the failed one looks like a glitch (being unrelated and not having failed in other recent runs) |
|
Please squash! |
|
Thanks! Squashed.
In removing the "REMOVE ME" commits, I split one of them (the one that
made the rust-gcoap example use other Rust modules) off and kept half of
it as the now most recent commit: With how the rust_riotmodules
developed since those lines were written, it's now best to just use the
riot_rustmodules crate all the time (the usual no-op has no deployment
impact), as to tolerate any Rust-written RIOT modules that might be
activated as they come in (eg. if saul_default gains support for a
board's sensor).
While murdock is working this off, I'll run another round of self-review
whether everything that's in the commits is still in the righ place, and
still makes sense.
|
|
Updated again to fix some commit wordings, and documentation typos or misreferences. |
Co-authored-by: Marian Buschsieweke <[email protected]>
It is enabled by saul_default on microbit-v2. Co-authored-by: Marian Buschsieweke <[email protected]>
Taken and simplified from shell test.
Of all the library crates, this is the only root crate, and responsible for pinning good versions.
|
Builds and tests passed [edit: I hope the link is right -- I lost the original link, reconstructed the URL, and that was the commit that was tested]. I missed squashing after the latest fixup I mentioned in #16833 (comment) (e4279bd). Squashing that in and skipping builds/tests due to the pre- and post-squash having identical tree hashes. |
|
Nice! |
Contribution description
Building on #16274 this adds a single module that can encapsulate arbitrarily many Rust-based modules.
It's
heavily WIP, and will be rebased, but the core idea is something that I already want to have discussable:Note that Rust-only modules have little options to be usable, as otherwise they won't be called into:
extern int module_setup(void);to wherever in the init system they need to be called initially. (Personally I'd discourage that in favor of XFA.)Testing procedure
It's not a full test, but it's a good one:
$ make BOARD=microbit-v2 -C examples/saul all flash termTBDIt's all a bit rough so far...but these items are still open:
Issues/PRs references
This is based on #16274,
and will be rebased onto that. Only look at the commits not on that other PR, currently it's the last one only.[edit: testing procedure]