Skip to content

Commit 15b8fbb

Browse files
bors[bot]jrvanwhy
andauthored
Merge #291
291: Add the `libtock2` crate. r=hudson-ayers a=jrvanwhy `libtock2` is the "one stop shop" for using `libtock-rs`. It is intended to be easy to use and will provide everything needed to create a `libtock-rs` process binary. However, in order to be easy to use, it will not support unit testing, as described in the [Overview](https://github.com/tock/libtock-rs/tree/master/doc/Overview.md) doc. `make test` contained several commands that tested `libtock_runtime` specifically. I reworked those commands so they test `libtock2` as well. The new structure uses only exclusion lists to select crates, which means they will never miss newly-added crates. Co-authored-by: Johnathan Van Why <[email protected]>
2 parents 761310d + 0b462e0 commit 15b8fbb

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

.github/workflows/mac-os.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ jobs:
2424
- name: Build and Test
2525
run: |
2626
cd "${GITHUB_WORKSPACE}"
27-
LIBTOCK_PLATFORM=nrf52 cargo build -p libtock_runtime \
27+
LIBTOCK_PLATFORM=nrf52 cargo build -p libtock2 \
2828
--target=thumbv7em-none-eabi

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ exclude = [ "tock" ]
8686
members = [
8787
"codegen",
8888
"core",
89+
"libtock2",
8990
"platform",
9091
"runtime",
9192
"test_runner",

Makefile

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,30 @@ examples:
8686

8787
# Arguments to pass to cargo to exclude libtock_runtime and crates that depend
8888
# on libtock_runtime. Used when we need to build a crate for the host OS, as
89-
# libtock_runtime only suppors running on Tock.
90-
EXCLUDE_RUNTIME := --exclude libtock_runtime
89+
# libtock_runtime only supports running on Tock.
90+
EXCLUDE_RUNTIME := --exclude libtock2 --exclude libtock_runtime
91+
92+
# Arguments to pass to cargo to exclude `std` and crates that depend on it. Used
93+
# when we build a crate for an embedded target, as those targets lack `std`.
94+
EXCLUDE_STD := --exclude libtock_unittest --exclude print_sizes --exclude test_runner
9195

9296
.PHONY: test
9397
test: examples test-qemu-hifive
94-
# TODO: Remove the libtock_runtime build when we have a code example for the
95-
# 2.0 crates.
96-
LIBTOCK_PLATFORM=nrf52 cargo build --release --target=thumbv7em-none-eabi -p libtock_runtime
98+
# TODO: When we have a working embedded test harness, change the libtock2
99+
# builds to --all-targets rather than --examples.
100+
# Build libtock2 on both a RISC-V target and an ARM target. We pick
101+
# opentitan as the RISC-V target because it lacks atomics.
102+
LIBTOCK_PLATFORM=opentitan cargo build --examples --release \
103+
--target=riscv32imc-unknown-none-elf -p libtock2
104+
LIBTOCK_PLATFORM=nrf52 cargo build --examples --release \
105+
--target=thumbv7em-none-eabi -p libtock2
97106
LIBTOCK_PLATFORM=nrf52 PLATFORM=nrf52 cargo fmt --all -- --check
98-
PLATFORM=nrf52 cargo clippy --all-targets --exclude libtock_runtime --workspace
99-
LIBTOCK_PLATFORM=hifive1 cargo clippy --target=riscv32imac-unknown-none-elf -p libtock_runtime
107+
PLATFORM=nrf52 cargo clippy --all-targets $(EXCLUDE_RUNTIME) --workspace
108+
# TODO: Add a clippy invocation for an ARM platform, once the Tock 1.0
109+
# crates are removed. It is omitted because the Tock 1.0 crates don't
110+
# currently pass clippy on ARM.
111+
LIBTOCK_PLATFORM=hifive1 PLATFORM=hifive1 cargo clippy $(EXCLUDE_STD) \
112+
--target=riscv32imac-unknown-none-elf --workspace
100113
PLATFORM=nrf52 cargo miri test $(EXCLUDE_RUNTIME) --workspace
101114
MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-track-raw-pointers" \
102115
PLATFORM=nrf52 cargo miri test $(EXCLUDE_RUNTIME) --workspace

libtock2/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
authors = ["Tock Project Developers <[email protected]>"]
3+
categories = ["embedded", "no-std", "os"]
4+
description = """Tock Rust userspace library collection. Provides all the \
5+
tools needed to create a Tock Rust process binary."""
6+
edition = "2018"
7+
license = "Apache-2.0 OR MIT"
8+
name = "libtock2"
9+
repository = "https://www.github.com/tock/libtock-rs"
10+
version = "0.1.0"
11+
12+
[dependencies]
13+
libtock_platform = { path = "../platform" }
14+
libtock_runtime = { path = "../runtime" }

libtock2/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#![forbid(unsafe_code)]
2+
#![no_std]
3+
4+
pub use libtock_platform as platform;
5+
pub use libtock_runtime as runtime;

0 commit comments

Comments
 (0)