Reexport all of the AOS essentials in a single `aos` crate
This improves the usability of aos for Rust as it allows for
clearly delineated modules and a better IDE workflow since
pulling one dependency will bring all the utilities one generally
needs.
Change-Id: I5d39d9510cee4b3867077ce46a4a45041192f3ee
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/BUILD b/aos/BUILD
index 38f3cf6..42a108a 100644
--- a/aos/BUILD
+++ b/aos/BUILD
@@ -806,3 +806,19 @@
"//aos/testing:tmpdir",
],
)
+
+rust_library(
+ name = "aos_rs",
+ srcs = ["aos.rs"],
+ crate_name = "aos",
+ visibility = ["//visibility:public"],
+ deps = [
+ ":configuration_rs",
+ ":flatbuffers_rs",
+ ":init_rs",
+ ":uuid_rs",
+ "//aos/events:event_loop_runtime",
+ "//aos/events:shm_event_loop_rs",
+ "//aos/events:simulated_event_loop_rs",
+ ],
+)
diff --git a/aos/aos.rs b/aos/aos.rs
new file mode 100644
index 0000000..3a13c4d
--- /dev/null
+++ b/aos/aos.rs
@@ -0,0 +1,14 @@
+//! All of AOS into a single, easy to use library.
+
+pub use aos_configuration as configuration;
+pub use aos_init as init;
+pub use aos_uuid as uuid;
+
+pub use aos_flatbuffers as flatbuffers;
+
+/// The essentials for working with the AOS event loop.
+pub mod events {
+ pub use aos_events_event_loop_runtime as event_loop_runtime;
+ pub use aos_events_shm_event_loop as shm_event_loop;
+ pub use aos_events_simulated_event_loop as simulated_event_loop;
+}
diff --git a/aos/events/BUILD b/aos/events/BUILD
index 2793195..75b3bb9 100644
--- a/aos/events/BUILD
+++ b/aos/events/BUILD
@@ -243,16 +243,11 @@
# it pretty much impossible to figure out what happened.
env = {"RUST_TEST_NOCAPTURE": "1"},
deps = [
- ":event_loop_runtime",
":ping_lib_rs",
":ping_rust_fbs",
":pong_lib_rs",
":pong_rust_fbs",
- ":simulated_event_loop_rs",
- "//aos:configuration_rs",
- "//aos:configuration_rust_fbs",
- "//aos:flatbuffers_rs",
- "//aos:test_init_rs",
+ "//aos/testing:aos_rs",
"@com_github_google_flatbuffers//rust",
"@crate_index//:futures",
"@rules_rust//tools/runfiles",
@@ -270,10 +265,7 @@
deps = [
":ping_lib_rs",
":shm_event_loop_rs",
- "//aos:configuration_rs",
- "//aos:configuration_rust_fbs",
- "//aos:flatbuffers_rs",
- "//aos:init_rs",
+ "//aos:aos_rs",
"@crate_index//:clap",
],
)
@@ -285,9 +277,9 @@
],
crate_name = "ping_lib",
deps = [
- ":event_loop_runtime",
":ping_rust_fbs",
":pong_rust_fbs",
+ "//aos:aos_rs",
"@com_github_google_flatbuffers//rust",
"@crate_index//:futures",
],
@@ -304,10 +296,7 @@
deps = [
":pong_lib_rs",
":shm_event_loop_rs",
- "//aos:configuration_rs",
- "//aos:configuration_rust_fbs",
- "//aos:flatbuffers_rs",
- "//aos:init_rs",
+ "//aos:aos_rs",
"@crate_index//:clap",
],
)
@@ -319,9 +308,9 @@
],
crate_name = "pong_lib",
deps = [
- ":event_loop_runtime",
":ping_rust_fbs",
":pong_rust_fbs",
+ "//aos:aos_rs",
"@com_github_google_flatbuffers//rust",
"@crate_index//:futures",
],
diff --git a/aos/events/ping.rs b/aos/events/ping.rs
index 09da114..c58b21b 100644
--- a/aos/events/ping.rs
+++ b/aos/events/ping.rs
@@ -1,6 +1,6 @@
-use aos_configuration as config;
-use aos_events_shm_event_loop::ShmEventLoop;
-use aos_init::WithCppFlags;
+use aos::configuration;
+use aos::events::shm_event_loop::ShmEventLoop;
+use aos::init::WithCppFlags;
use clap::Parser;
use ping_lib::PingTask;
use std::path::Path;
@@ -16,8 +16,8 @@
fn main() {
let app = App::parse_with_cpp_flags();
- aos_init::init();
- let config = config::read_config_from(Path::new("pingpong_config.json")).unwrap();
+ aos::init::init();
+ let config = configuration::read_config_from(Path::new("pingpong_config.json")).unwrap();
let ping = PingTask::new();
ShmEventLoop::new(&config).run_with(|runtime| {
runtime.set_realtime_priority(5);
diff --git a/aos/events/ping_lib.rs b/aos/events/ping_lib.rs
index 96d7132..9303a3b 100644
--- a/aos/events/ping_lib.rs
+++ b/aos/events/ping_lib.rs
@@ -1,4 +1,4 @@
-use aos_events_event_loop_runtime::{EventLoopRuntime, Sender, Watcher};
+use aos::events::event_loop_runtime::{EventLoopRuntime, Sender, Watcher};
use core::cell::Cell;
use core::time::Duration;
use futures::never::Never;
diff --git a/aos/events/pingpong_test.rs b/aos/events/pingpong_test.rs
index a20f66f..2a71cd0 100644
--- a/aos/events/pingpong_test.rs
+++ b/aos/events/pingpong_test.rs
@@ -2,10 +2,10 @@
mod tests {
use std::{cell::Cell, time::Duration};
- use aos_configuration::read_config_from;
- use aos_events_event_loop_runtime::{EventLoopRuntimeHolder, Watcher};
- use aos_events_simulated_event_loop::{SimulatedEventLoopFactory, SimulatedEventLoopHolder};
- use aos_test_init::test_init;
+ use aos::configuration::read_config_from;
+ use aos::events::event_loop_runtime::{EventLoopRuntimeHolder, Watcher};
+ use aos::events::simulated_event_loop::{SimulatedEventLoopFactory, SimulatedEventLoopHolder};
+ use aos::testing::init::test_init;
use ping_lib::PingTask;
use ping_rust_fbs::aos::examples as ping;
use pong_rust_fbs::aos::examples as pong;
diff --git a/aos/events/pong.rs b/aos/events/pong.rs
index 833cba2..d20eac6 100644
--- a/aos/events/pong.rs
+++ b/aos/events/pong.rs
@@ -1,6 +1,6 @@
-use aos_configuration as config;
-use aos_events_shm_event_loop::ShmEventLoop;
-use aos_init::WithCppFlags;
+use aos::configuration;
+use aos::events::shm_event_loop::ShmEventLoop;
+use aos::init::WithCppFlags;
use clap::Parser;
use std::path::Path;
@@ -13,8 +13,8 @@
fn main() {
let _app = App::parse_with_cpp_flags();
- aos_init::init();
- let config = config::read_config_from(Path::new("pingpong_config.json")).unwrap();
+ aos::init::init();
+ let config = configuration::read_config_from(Path::new("pingpong_config.json")).unwrap();
ShmEventLoop::new(&config).run_with(|runtime| {
let task = pong(*runtime);
runtime.set_realtime_priority(5);
diff --git a/aos/events/pong_lib.rs b/aos/events/pong_lib.rs
index fc1c162..6451b7b 100644
--- a/aos/events/pong_lib.rs
+++ b/aos/events/pong_lib.rs
@@ -1,4 +1,4 @@
-use aos_events_event_loop_runtime::{EventLoopRuntime, Sender, Watcher};
+use aos::events::event_loop_runtime::{EventLoopRuntime, Sender, Watcher};
use futures::never::Never;
use std::borrow::Borrow;
diff --git a/aos/testing/BUILD b/aos/testing/BUILD
index 02459e4..eb9e2b2 100644
--- a/aos/testing/BUILD
+++ b/aos/testing/BUILD
@@ -1,3 +1,5 @@
+load("//tools/rust:defs.bzl", "rust_library")
+
cc_library(
name = "googletest",
testonly = True,
@@ -131,3 +133,17 @@
"@com_google_absl//absl/strings",
],
)
+
+rust_library(
+ name = "aos_rs",
+ testonly = True,
+ srcs = ["aos.rs"],
+ crate_name = "aos",
+ gen_docs = False,
+ gen_doctests = False,
+ visibility = ["//visibility:public"],
+ deps = [
+ "//aos:aos_rs",
+ "//aos:test_init_rs",
+ ],
+)
diff --git a/aos/testing/aos.rs b/aos/testing/aos.rs
new file mode 100644
index 0000000..6c7795d
--- /dev/null
+++ b/aos/testing/aos.rs
@@ -0,0 +1,7 @@
+// Reexport all of the [`aos`] crate
+pub use aos::*;
+
+/// Utilities for testing an AOS application.
+pub mod testing {
+ pub use aos_test_init as init;
+}