Skip to content

Commit

Permalink
tools: separate crowtty bin from libuv dep, fix CI (#342)
Browse files Browse the repository at this point in the history
The `crowtty` CLI requires `libuv` on Linux systems in order to interact
with serial devices. This is why the x86_64 build is now failing on CI,
since the bootimage builder depends on `crowtty` in order to run it on
the QEMU virtual serial port, but building crowtty requires `libuv`.
See:
#341 (comment)

This commit separates the `crowtty` binary from the `libcrowtty`
library, so that only the CLI binary depends on `libuv`. Hopefully this
fixes the x86_64 CI build.

Fixes #341
  • Loading branch information
hawkw authored Oct 8, 2024
1 parent 6d1b851 commit 1a00f53
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 51 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
- check
- clippy
- build-bins
- build-x86_64
- test
- test-host-miri
- docs
Expand Down
27 changes: 19 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ default-members = [
# tools
# note that this skips `manganese` by default, so that we don't build its
# dependency features when running `cargo check --all-features` and similar.
"tools/crowtty",
"tools/libcrowtty",
"tools/dumbloader",
"tools/f3repl",
"tools/x86_64-bootimager",
Expand Down
3 changes: 3 additions & 0 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ part of the MnemOS environment.
CrowTTY multiplexes and de-multiplexes [`sermux`] frames sent and recieved
over a UART connection from a target, and decodes
[`mnemos-trace-proto`]-formatted diagnostic data.
* [`libcrowtty/] - The core of `crowtty`, factored out as a library so that it
can be included in other tools.
* [`dumbloader/`] - An image loader type thing for Cortex-M, I think? We're not
really using this thing anymore, and I'm not entirely sure what it does.
* [`f3repl/`] - A Forth repl for [`forth3`].
Expand All @@ -25,6 +27,7 @@ part of the MnemOS environment.
[`source/`]: ../source/
[`platforms/`]: ../platforms/
[`crowtty/`]: ./crowtty/
[`libcrowtty/`]: ./libcrowtty/
[`dumbloader/`]: ./dumbloader/
[`f3repl/`]: ./f3repl/
[`manganese/`]: ./manganese/
Expand Down
32 changes: 4 additions & 28 deletions tools/crowtty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ readme = "./README.md"
license = "MIT OR Apache-2.0"
edition = "2021"

### See `main.rs::serial` comments for why these duplicate dependencies exit

### See `connection::serial` comments for why these duplicate dependencies exit

[dependencies.serialport_regular]
package = "serialport"
Expand All @@ -27,38 +28,13 @@ rev = "7fec572529ec35b82bd4e3636d897fe2f1c2233f"

###

[dependencies.cobs]
version = "0.2"
[dependencies.libcrowtty]
path = "../libcrowtty"

[dependencies.clap]
version = "4.0"
features = ["derive", "env"]

[dependencies.serde]
version = "1.0"
features = ["derive"]

[dependencies.postcard]
version = "1"
features = ["alloc"]

[dependencies.owo-colors]
version = "3.5"
features = ["supports-colors"]

[dependencies.tracing-serde-structured]
git = "https://github.com/hawkw/tracing-serde-structured"
branch = "eliza/span-fields"
default-features = true

[dependencies.sermux-proto]
path = "../../source/sermux-proto"
features = ["use-std"]

[dependencies.mnemos-trace-proto]
path = "../../source/trace-proto"
features = ["std"]

[dependencies.tracing]
version = "0.1.37"
default-features = false
Expand Down
9 changes: 5 additions & 4 deletions tools/crowtty/src/connection.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use libcrowtty::LogTag;
use std::path::PathBuf;
use std::{
fmt,
io::{self, Read, Write},
net::{IpAddr, Ipv4Addr, SocketAddr, TcpStream},
path::PathBuf,
time::Duration,
};

Expand Down Expand Up @@ -78,10 +79,10 @@ impl Read for Connection {
}

impl Connection {
pub fn log_tag(&self) -> crate::LogTag {
pub fn log_tag(&self) -> LogTag {
match self {
Self::Serial(_) => crate::LogTag::serial(),
Self::Tcp(_) => crate::LogTag::tcp(),
Self::Serial(_) => LogTag::serial(),
Self::Tcp(_) => LogTag::tcp(),
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions tools/crowtty/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use clap::Parser;
use crowtty::{connection::Connect, Crowtty};
use connection::Connect;
use miette::{Context, IntoDiagnostic};
use tracing::level_filters::LevelFilter;

mod connection;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Args {
Expand All @@ -14,7 +16,7 @@ struct Args {
verbose: bool,

#[clap(flatten)]
settings: crowtty::Settings,
settings: libcrowtty::Settings,

/// a comma-separated list of `tracing` targets and levels to enable.
///
Expand Down Expand Up @@ -51,7 +53,7 @@ fn main() -> miette::Result<()> {
.connect()
.into_diagnostic()
.with_context(|| format!("failed to connect to {connect}"))?;
Crowtty::new(conn.log_tag().verbose(verbose))
libcrowtty::Crowtty::new(conn.log_tag().verbose(verbose))
.settings(settings)
.trace_filter(trace_filter)
.run(conn)
Expand Down
61 changes: 61 additions & 0 deletions tools/libcrowtty/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
cargo-features = ["per-package-target", "profile-rustflags"]

[package]
name = "libcrowtty"
version = "0.1.0"
description = """
The library parts of crowtty.
crowtty is a host tool, aimed at speaking the sermux protocol with a
simulator or physical target. It allows for receiving tracing messages,
as well as mapping multiplexed "ports" as TCP sockets on the host.
"""
repository = "https://github.com/tosc-rs/mnemos"
homepage = "https://mnemos.dev"
readme = "./README.md"
license = "MIT OR Apache-2.0"
edition = "2021"

[dependencies.cobs]
version = "0.2"

[dependencies.clap]
version = "4.0"
features = ["derive", "env"]

[dependencies.serde]
version = "1.0"
features = ["derive"]

[dependencies.postcard]
version = "1"
features = ["alloc"]

[dependencies.owo-colors]
version = "3.5"
features = ["supports-colors"]

[dependencies.tracing-serde-structured]
git = "https://github.com/hawkw/tracing-serde-structured"
branch = "eliza/span-fields"
default-features = true

[dependencies.sermux-proto]
path = "../../source/sermux-proto"
features = ["use-std"]

[dependencies.mnemos-trace-proto]
path = "../../source/trace-proto"
features = ["std"]

[dependencies.tracing]
version = "0.1.37"
default-features = false

[dependencies.tracing-subscriber]
version = "0.3.17"
default-features = false
features = ["std"]

[dependencies.miette]
workspace = true
15 changes: 15 additions & 0 deletions tools/libcrowtty/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `libcrowtty`: the library parts of crowtty

[`crowtty`] is a host tool, aimed at speaking the sermux protocol with a simulator
or physical target. It allows for receiving tracing messages, as well as mapping
multiplexed "ports" as TCP sockets on the host. It is the primary way of
connecting to hardware platforms that speak the
sermux-proto over a physical serial port.

This crate contains the generic, library bits of `crowtty`, without the
command-line application, or code for connecting to serial TTY devices (which
requires `libuv` on Linux). It's factored out primarily so that it can be used
by the [`x86_64-bootimager`] tool to connect to QEMU virtual serial devices.

[crowtty]: ../crowtty/
[`x86_64-bootimager`]: ../x86_64-bootimager
6 changes: 6 additions & 0 deletions tools/libcrowtty/oranda.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"components": {
"mdbook": false,
"changelog": false
}
}
File renamed without changes.
1 change: 0 additions & 1 deletion tools/crowtty/src/lib.rs → tools/libcrowtty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use std::{
};
use tracing::level_filters::LevelFilter;

pub mod connection;
mod keyboard;
mod trace;

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tools/x86_64-bootimager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
anyhow = "1"
camino = "1"
crowtty = { path = "../crowtty" }
libcrowtty = { path = "../libcrowtty" }
heck = "0.5"
# cargo_metadata = "0.18.1"
miette = { workspace = true, features = ["fancy"] }
Expand Down
10 changes: 5 additions & 5 deletions tools/x86_64-bootimager/src/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Options {
pub crowtty_verbose: bool,

#[clap(flatten)]
pub crowtty_opts: crowtty::Settings,
pub crowtty_opts: libcrowtty::Settings,

/// Tracing filter to set when connecting Crowtty to the QEMU virtual serial
/// port.
Expand Down Expand Up @@ -125,7 +125,7 @@ impl Options {
.into_diagnostic()
.context("failed to spawn QEMU child process")?;

let tag = crowtty::LogTag::serial().verbose(self.crowtty_verbose);
let tag = libcrowtty::LogTag::serial().verbose(self.crowtty_verbose);
let crowtty_thread = if crowtty_enabled {
let stdin = qemu.stdin.take().expect("QEMU should have piped stdin");
let stdout = qemu.stdout.take().expect("QEMU should have piped stdout");
Expand Down Expand Up @@ -182,8 +182,8 @@ impl Options {
}

fn run_crowtty(
tag: crowtty::LogTag,
crowtty_opts: crowtty::Settings,
tag: libcrowtty::LogTag,
crowtty_opts: libcrowtty::Settings,
trace_filter: tracing_subscriber::filter::Targets,
boot_log: BootLogLevel,
stdin: std::process::ChildStdin,
Expand Down Expand Up @@ -253,7 +253,7 @@ fn run_crowtty(
stdout
};

crowtty::Crowtty::new(tag)
libcrowtty::Crowtty::new(tag)
.settings(crowtty_opts)
.trace_filter(trace_filter)
.run(QemuStdio { stdin, stdout })
Expand Down

0 comments on commit 1a00f53

Please sign in to comment.