Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: CI
on:
pull_request:
push:
branches: [main]

env:
# disable incremental compilation.
#
# incremental compilation is useful as part of an edit-build-test-edit cycle,
# as it lets the compiler avoid recompiling code that hasn't changed. however,
# on CI, we're not making small edits; we're almost always building the entire
# project from scratch. thus, incremental compilation on CI actually
# introduces *additional* overhead to support making future builds
# faster...but no future builds will ever occur in any given CI environment.
#
# see https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
# for details.
CARGO_INCREMENTAL: 0
# allow more retries for network requests in cargo (downloading crates) and
# rustup (installing toolchains). this should help to reduce flaky CI failures
# from transient network timeouts or other issues.
CARGO_NET_RETRY: 10
RUSTUP_MAX_RETRIES: 10

jobs:
check-idol:
name: Check idol codegen
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- "stable"
# the current pinned Rust toolchain in the Hubris repo:
# https://github.com/oxidecomputer/hubris/blob/master/rust-toolchain.toml
#
# when updating Hubris' Rust toolchain, make sure to update this, too!
# TODO(eliza): it would be nice to determine this automatically...
- "nightly-2022-11-01"
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: Swatinem/rust-cache@v1
- run: cargo check -p idol

check-runtime:
name: Check idol-runtime
runs-on: ubuntu-latest
strategy:
matrix:
rust:
# the current pinned Rust toolchain in the Hubris repo:
# https://github.com/oxidecomputer/hubris/blob/master/rust-toolchain.toml
#
# when updating Hubris' Rust toolchain, make sure to update this, too!
# TODO(eliza): it would be nice to determine this automatically...
- "nightly-2022-11-01"
target:
- "thumbv6m-none-eabi"
- "thumbv7em-none-eabihf"
- "thumbv8m.main-none-eabihf"
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- uses: Swatinem/rust-cache@v1
- run: cargo check -p idol-runtime --target ${{ matrix.target }}

rustfmt:
name: rustfmt
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- "stable"
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- uses: Swatinem/rust-cache@v1
- run: cargo fmt --check
9 changes: 9 additions & 0 deletions .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: license-check
on: pull_request
jobs:
license:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Check License Header
uses: apache/skywalking-eyes/header@501a28d2fb4a9b962661987e50cf0219631b32ff
4 changes: 4 additions & 0 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#![no_std]

//! Runtime support types for code generated by the Idol compiler.
Expand Down
4 changes: 4 additions & 0 deletions src/bin/servertest.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use std::io::Read;

fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
Expand Down
4 changes: 4 additions & 0 deletions src/counters.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use crate::syntax;
use proc_macro2::TokenStream;
use quote::quote;
Expand Down
20 changes: 14 additions & 6 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ impl Generator {
Ok(tokens)
}


pub fn generate_server_constants(&self, iface: &syntax::Interface) -> TokenStream {
pub fn generate_server_constants(
&self,
iface: &syntax::Interface,
) -> TokenStream {
// Generate message sizing constants for each message.
let mut msgsize_names = Vec::with_capacity(iface.ops.len());
let consts = iface.ops.iter().map(|(name, op)| {
Expand Down Expand Up @@ -202,7 +204,10 @@ impl Generator {
}
}

pub fn generate_server_conversions(&self, iface: &syntax::Interface) -> TokenStream {
pub fn generate_server_conversions(
&self,
iface: &syntax::Interface,
) -> TokenStream {
let conversions = iface.ops.iter().map(|(name, op)| {
// Define args struct.
let attrs = match op.encoding {
Expand Down Expand Up @@ -296,7 +301,7 @@ impl Generator {
} else {
quote! {}
};

let read_fn = {
let read_fn = format_ident!("read_{}_msg", name);
match op.encoding {
Expand Down Expand Up @@ -361,7 +366,10 @@ impl Generator {
}
}

pub fn generate_server_op_impl(&self, iface: &syntax::Interface) -> TokenStream {
pub fn generate_server_op_impl(
&self,
iface: &syntax::Interface,
) -> TokenStream {
let op_enum = iface.name.as_op_enum();
let max_reply_size_cases = iface.ops.keys().map(|opname| {
let reply_size = opname.as_reply_size();
Expand Down Expand Up @@ -743,7 +751,7 @@ fn generate_trait_def(
quote! { Result<#ok, idol_runtime::RequestError<#err_ty>> }
},
syntax::Reply::Simple(t) => {
quote! {
quote! {
Result<#t, idol_runtime::RequestError<core::convert::Infallible>>
}
},
Expand Down