Skip to content

Commit

Permalink
Merge branch 'main' into test-parallel-requests
Browse files Browse the repository at this point in the history
  • Loading branch information
mies authored Sep 3, 2024
2 parents b8f5f33 + 38db22c commit 519f7cb
Show file tree
Hide file tree
Showing 31 changed files with 155 additions and 49 deletions.
2 changes: 0 additions & 2 deletions .cargo/config

This file was deleted.

2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package fp-bindgen-xtask --"
26 changes: 26 additions & 0 deletions .github/workflows/audit_rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: Audit Rust code

on:
push:
branches: ["**"]
paths:
- "**/Cargo.toml"
- "**/Cargo.lock"
- "**/deny.toml"
schedule:
- cron: "43 1 * * *"
workflow_dispatch:

jobs:
rust_audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive

- uses: EmbarkStudios/cargo-deny-action@v1
with:
credentials: https://fiberplanebot:${{ secrets.PRIVATE_GITHUB_TOKEN }}@github.com/
17 changes: 8 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install latest stable compiler
id: toolchain
uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
override: true
components: clippy
toolchain: "1.77"
components: clippy, rustfmt

- name: Cache multiple paths
id: cache
Expand All @@ -45,10 +42,12 @@ jobs:
fi
- name: Lint code
uses: actions-rs/clippy-check@v1
uses: giraffate/clippy-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --all-features
github_token: ${{ secrets.GITHUB_TOKEN }}
filter_mode: nofilter
fail_on_error: true
clippy_flags: --all-features

- name: Check format
run: cargo fmt -- --check
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format of this file is based on
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## unreleased

- Add ability to add `publish` to the generated Cargo.toml file (#208)
- Fix generating publish value as a toml bool (#209)

## [3.0.0] - 2023-04-28

### Added
Expand Down
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
exclude = [
"examples/example-plugin",
"examples/example-rust-wasmer2-runtime",
Expand All @@ -19,7 +20,7 @@ fp-bindgen-macros = { version = "3.0.0", path = "macros" }
[workspace.package]
version = "3.0.0"
authors = ["Fiberplane <[email protected]>"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
homepage = "https://github.com/fiberplane/fp-bindgen/"
repository = "https://github.com/fiberplane/fp-bindgen/"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# fp-bindgen

[![Crates.io](https://img.shields.io/crates/v/fp-bindgen.svg)](https://crates.io/crates/fp-bindgen)
[![Discord Shield](https://discordapp.com/api/guilds/950489382626951178/widget.png?style=shield)](https://discord.gg/fAt2xgMSGS)
[![Discord Shield](https://discordapp.com/api/guilds/950489382626951178/widget.png?style=shield)](https://discord.gg/MJr7pYzZQ4)

Bindings generator for full-stack WASM plugins.

Expand Down
49 changes: 49 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[advisories]
ignore = []
yanked = "deny"

[licenses]
allow = [
"0BSD",
"Apache-2.0 WITH LLVM-exception",
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"CC0-1.0",
"ISC",
"MIT",
"MPL-2.0",
"OpenSSL",
"Unicode-DFS-2016",
"Unlicense",
"WTFPL",
"Zlib",
]
confidence-threshold = 0.8
exceptions = []

[[licenses.clarify]]
crate = "ring"
expression = "MIT AND ISC AND OpenSSL"
license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]

[licenses.private]
ignore = true

[bans]
multiple-versions = "allow"
wildcards = "allow"
highlight = "all"
workspace-default-features = "allow"
external-default-features = "allow"

deny = []

[sources]
unknown-registry = "deny"
unknown-git = "deny"
allow-registry = ["https://github.com/rust-lang/crates.io-index"]
allow-git = []

[sources.allow-org]
github = ["fiberplane", "autometrics-dev"]
1 change: 1 addition & 0 deletions examples/example-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ authors = ["Fiberplane <[email protected]>"]
edition = "2018"
name = "example-plugin"
version = "0.1.0"
publish = false

[lib]
crate-type = ["cdylib"]
Expand Down
15 changes: 8 additions & 7 deletions examples/example-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ authors = ["Fiberplane <[email protected]>"]
edition = "2018"
name = "example-protocol"
version = "0.1.0"
publish = false

[dependencies]
bytes = {version = "1", features = ["serde"]}
fp-bindgen = {path = "../../fp-bindgen", features = [
bytes = { version = "1", features = ["serde"] }
fp-bindgen = { path = "../../fp-bindgen", features = [
"bytes-compat",
"http-compat",
"serde-bytes-compat",
"time-compat",
"generators",
]}
] }
http = "0.2"
once_cell = "1"
pretty_assertions = "0.7"
redux-example = {path = "../redux-example"}
serde = {version = "1.0", features = ["derive"]}
pretty_assertions = "1"
redux-example = { path = "../redux-example" }
serde = { version = "1.0", features = ["derive"] }
serde_bytes = "0.11"
time = {version = "0.3", features = ["macros", "serde-human-readable"]}
time = { version = "0.3", features = ["macros", "serde-human-readable"] }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unused)]
#![allow(clippy::let_and_return, unused)]
use super::types::*;
use fp_bindgen_support::{
common::{abi::WasmAbi, mem::FatPtr},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unused)]
#![allow(clippy::let_and_return, unused)]
use super::types::*;
use fp_bindgen_support::{
common::{abi::WasmAbi, mem::FatPtr},
Expand Down
1 change: 1 addition & 0 deletions examples/example-rust-wasmer2-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
edition = "2021"
name = "example-rust-wasmer2-runtime"
version = "0.1.0"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
1 change: 1 addition & 0 deletions examples/redux-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ authors = ["Fiberplane <[email protected]>"]
edition = "2018"
name = "redux-example"
version = "0.1.0"
publish = false

[dependencies]
fp-bindgen = {path = "../../fp-bindgen"}
Expand Down
2 changes: 1 addition & 1 deletion fp-bindgen-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description = "Support crate for fp-bindgen"
homepage = { workspace = true }
repository = { workspace = true }
readme = "README.md"
version = { workspace = true }
version = "3.0.0"
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions fp-bindgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repository = { workspace = true }
readme = "../README.md"
keywords = ["WebAssembly", "WASM", "bindgen"]
categories = ["development-tools::ffi", "wasm"]
version = { workspace = true }
version = "3.0.0"
authors = { workspace = true }
edition = { workspace = true }
license = { workspace = true }
Expand All @@ -22,7 +22,7 @@ default = [
"rmpv-compat",
"serde-bytes-compat",
"serde-json-compat",
"time-compat"
"time-compat",
]
http-compat = ["http"]
rmpv-compat = ["rmpv"]
Expand Down
4 changes: 4 additions & 0 deletions fp-bindgen/src/casing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::convert::TryFrom;
pub enum Casing {
Original,
CamelCase,
LowerCase,
PascalCase,
SnakeCase,
ScreamingSnakeCase,
Expand All @@ -15,6 +16,7 @@ impl Casing {
match self {
Self::Original => None,
Self::CamelCase => Some("camelCase"),
Self::LowerCase => Some("lowercase"),
Self::PascalCase => Some("PascalCase"),
Self::SnakeCase => Some("snake_case"),
Self::ScreamingSnakeCase => Some("SCREAMING_SNAKE_CASE"),
Expand All @@ -25,6 +27,7 @@ impl Casing {
match self {
Self::Original => string.to_owned(),
Self::CamelCase => string.to_camel_case(),
Self::LowerCase => string.to_lowercase(),
Self::PascalCase => string.to_pascal_case(),
Self::SnakeCase => string.to_snake_case(),
Self::ScreamingSnakeCase => string.to_screaming_snake_case(),
Expand All @@ -44,6 +47,7 @@ impl TryFrom<&str> for Casing {
fn try_from(value: &str) -> Result<Self, Self::Error> {
match value {
"camelCase" => Ok(Self::CamelCase),
"lowercase" => Ok(Self::LowerCase),
"PascalCase" => Ok(Self::PascalCase),
"snake_case" => Ok(Self::SnakeCase),
"SCREAMING_SNAKE_CASE" => Ok(Self::ScreamingSnakeCase),
Expand Down
2 changes: 1 addition & 1 deletion fp-bindgen/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Ord for Function {

impl PartialOrd for Function {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.name.partial_cmp(&other.name)
Some(self.cmp(other))
}
}

Expand Down
19 changes: 18 additions & 1 deletion fp-bindgen/src/generators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ pub struct RustPluginConfig {

/// The license of the generated crate.
pub license: Option<RustPluginConfigValue>,

/// Whether the crate is marked as published or not (note: this should
/// the string value "true" or "false")
pub publish: Option<RustPluginConfigValue>,
}

impl RustPluginConfig {
Expand All @@ -81,6 +85,7 @@ impl RustPluginConfig {
description: None,
readme: None,
license: None,
publish: None,
},
}
}
Expand All @@ -92,6 +97,7 @@ pub enum RustPluginConfigValue {
String(String),
Vec(Vec<String>),
Workspace,
Bool(bool),
}

impl From<&str> for RustPluginConfigValue {
Expand All @@ -118,6 +124,12 @@ impl From<Vec<String>> for RustPluginConfigValue {
}
}

impl From<bool> for RustPluginConfigValue {
fn from(value: bool) -> Self {
Self::Bool(value)
}
}

pub struct RustPluginConfigBuilder {
config: RustPluginConfig,
}
Expand Down Expand Up @@ -178,6 +190,11 @@ impl RustPluginConfigBuilder {
self
}

pub fn publish(mut self, value: bool) -> Self {
self.config.publish = Some(value.into());
self
}

pub fn dependency(mut self, name: impl Into<String>, dependency: CargoDependency) -> Self {
self.config.dependencies.insert(name.into(), dependency);
self
Expand Down Expand Up @@ -235,7 +252,7 @@ impl TsRuntimeConfig {

/// Sets the `msgpack_module` setting.
pub fn with_msgpack_module(mut self, msgpack_module: &str) -> Self {
self.msgpack_module = msgpack_module.to_owned();
msgpack_module.clone_into(&mut self.msgpack_module);
self
}

Expand Down
4 changes: 3 additions & 1 deletion fp-bindgen/src/generators/rust_plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn generate_cargo_file(
format!(
"[package]
{}{}{}edition = \"2018\"
{}{}{}
{}{}{}{}
[dependencies]
{}
",
Expand All @@ -112,6 +112,7 @@ fn generate_cargo_file(
format_cargo_key("description", config.description),
format_cargo_key("readme", config.readme),
format_cargo_key("license", config.license),
format_cargo_key("publish", config.publish),
dependencies
.iter()
.map(|(name, value)| format!("{name} = {value}"))
Expand Down Expand Up @@ -591,6 +592,7 @@ fn format_cargo_key(key: &str, value: Option<RustPluginConfigValue>) -> String {
inline.insert("workspace", true.into());
toml_edit::value(inline)
}
RustPluginConfigValue::Bool(value) => toml_edit::value(value),
};

let mut doc = toml_edit::Document::new();
Expand Down
2 changes: 1 addition & 1 deletion fp-bindgen/src/generators/rust_wasmer2_runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pub(crate) fn format_function_bindings(
new_func: String,
create_import_object_func: String,
) -> String {
rustfmt_wrapper::rustfmt(format!(r#"#![allow(unused)]
rustfmt_wrapper::rustfmt(format!(r#"#![allow(clippy::let_and_return, unused)]
use super::types::*;
use fp_bindgen_support::{{
common::{{mem::FatPtr, abi::WasmAbi}},
Expand Down
2 changes: 1 addition & 1 deletion fp-bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# fp-bindgen
[![Crates.io](https://img.shields.io/crates/v/fp-bindgen.svg)](https://crates.io/crates/fp-bindgen)
[![Discord Shield](https://discordapp.com/api/guilds/950489382626951178/widget.png?style=shield)](https://discord.gg/fAt2xgMSGS)
[![Discord Shield](https://discordapp.com/api/guilds/950489382626951178/widget.png?style=shield)](https://discord.gg/MJr7pYzZQ4)
Bindings generator for full-stack WASM plugins.
Expand Down
Loading

0 comments on commit 519f7cb

Please sign in to comment.