Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Define MSRV #1314

Closed
wants to merge 23 commits into from
Closed
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
39 changes: 24 additions & 15 deletions .github/workflows/ci.yaml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -478,36 +478,45 @@ jobs:

- run: just ci_codegen

# -------------- MSRV & specific version testing --------------
msrv:
name: MSRV & specific version testing
name: test MSRV and specific problematic versions
runs-on: ubuntu-latest # as of now, there is no real reason to test on multiple OSs
strategy:
matrix:
rust_version:
- nightly # latest nightly
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: also add latest stable

- nightly-2023-06-28 # pre https://github.com/rust-lang/rust/issues/113152
- nightly-2023-07-26 # post https://github.com/rust-lang/rust/issues/113152
- nightly # latest nightly
# TODO(@fzyzcjy, @gutenfries): add MSRV here, as well as other locked versions as needed
#
# DO NOT EDIT BELOW THIS LINE
#
- nightly-2022-07-15 ### nightly MSRV (DO NOT EDIT THIS LINE):
- 1.64 ### stable MSRV (DO NOT EDIT THIS LINE):
#
# DO NOT EDIT ABOVE THIS LINE
#

steps:
- uses: actions/checkout@v2

- uses: dtolnay/rust-toolchain@stable
# cache cargo and rustup to reduce future build times as much as possible
- name: cache
uses: actions/cache@v3
with:
path: |
~/.cargo
~/.rustup
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-

# Check cache, then insdtall if not found
- if: steps.cache.outputs.cache-hit != 'true'
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust_version }}
components: rustfmt, clippy

# cache rust toolchains to reduce build time
# automaticly updates cache if Cargo.lock changes, ie, if nightly-latest changes
- uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ runner.os }}-rust-${{ matrix.rust_version }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-${{ matrix.rust_version }}-
${{ runner.os }}-rust-
${{ runner.os }}-

- uses: subosito/flutter-action@v2
with:
Expand Down
fzyzcjy marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ launch.json
.local-chromium
Makefile
*.log
.vscode
.vscode
*.bak
14 changes: 7 additions & 7 deletions Cargo.toml
gutenfries marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[workspace]
members = [
"frb_codegen",
"frb_rust",
"frb_macros",
"frb_example/pure_dart/rust",
"frb_example/pure_dart_multi/rust",
"frb_example/with_flutter/rust",
"frb_codegen",
"frb_rust",
"frb_macros",
"frb_example/pure_dart/rust",
"frb_example/pure_dart_multi/rust",
"frb_example/with_flutter/rust",
]

[workspace.package]
Expand All @@ -31,4 +31,4 @@ flutter_rust_bridge_codegen = { path = "frb_codegen", version = "1" }

[profile.release.package.flutter_rust_bridge_codegen]
strip = "debuginfo"
debug = 1 # preserves some debug information
debug = 1 # preserves some debug information
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[![CI](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/ci.yaml/badge.svg)](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/ci.yaml)
[![Example](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/post_release.yaml/badge.svg)](https://github.com/fzyzcjy/flutter_rust_bridge/actions/workflows/post_release.yaml)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/6afbdad19e7245adbf9e9771777be3d7)](https://app.codacy.com/gh/fzyzcjy/flutter_rust_bridge?utm_source=github.com&utm_medium=referral&utm_content=fzyzcjy/flutter_rust_bridge&utm_campaign=Badge_Grade_Settings)
[![Minimum Supported Stable Rust Version](https://img.shields.io/badge/stable_msrv-1.64+-green.svg)](/.stable_msrv)
[![Minimum Supported Nightly Rust Version](https://img.shields.io/badge/nightly_msrv-nightly--2022--07--15+-orange.svg)](/.nightly_msrv)

![Logo](https://github.com/fzyzcjy/flutter_rust_bridge/raw/master/book/logo.png)

Expand All @@ -28,7 +30,7 @@ Check out [the user guide](https://fzyzcjy.github.io/flutter_rust_bridge/) for [

## 📎 P.S. Achieve ~60 FPS, no matter how janky the Flutter app was due to build/layout

Here is my another open-source library :) https://github.com/fzyzcjy/flutter_smooth.
Here is my another open-source library :) <https://github.com/fzyzcjy/flutter_smooth>.

## ✨ Contributors

Expand Down
19 changes: 19 additions & 0 deletions book/src/msrv.md
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we need to add a link to it from our book index

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# MSRV

The MSRV (Minimum Supported Rust Version) is the oldest version of Rust that
this crate is guaranteed to work with.

The MSRV(s) for `flutter_rust_bridge` are as follows:

| Channel | MSRV |
| ------- | ---- |
| stable | <!-- stable msrv --> `1.64+` |
| nightly | <!-- nightly msrv --> `nightly-2022-07-15+` |
Comment on lines +10 to +11
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It seems that we are repeating ourself for 3 times:

  1. the one in ci (we test our code with MSRV version)
  2. the one in readme.md (the badge)
  3. the doc here

is it possible we somehow add a very quick sanity check for them, to ensure that they are always in sync? e.g. some quick python/shell/whatever script to extract MSRV from these 3 places, and check they are equal. Then we can add them to CI, so nobody will accidencially make MSRV not-in-sync


EDIT: Oh I see, they are already auto generated from shell. Then what about this:

  1. refactor the shell script into "determine MSRV automatically" and "given MSRV, write them into these few places". because in the future someone may want to manually write MSRV.
  2. in these few places, maybe we can add comments saying e.g. <!-- MSRV IS AUTOMATICALLY WRITTEN BY xxxxxxxx.sh, PLEASE DO NOT MODIFY BY HAND, BUT USE THAT SCRIPT-->


These versions are CI tested and _guaranteed_ to compile,
given there are no external error factors.

The MSRV is subject to change without prior notice in major/minor releases of `flutter_rust_bridge`,
but we do our best to keep it as low as possible.

The MSRV is also stated in the [`README.md`](/README.md).
19 changes: 19 additions & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
msrv = "1.64"

# https://doc.rust-lang.org/nightly/clippy/lint_configuration.html#avoid-breaking-exported-api
avoid-breaking-exported-api = true

# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
disallowed-methods = [
"std::time::Instant::now", # use `instant` crate instead for wasm/web compatibility
"std::time::Duration::elapsed", # use `instant` crate instead for wasm/web compatibility
"std::time::SystemTime::now", # use `instant` or `time` crates instead for wasm/web compatibility
"std::thread::spawn", # Cannot spawn threads on wasm
# TODO(@fzyzcjy): add methods here as needed
gutenfries marked this conversation as resolved.
Show resolved Hide resolved

]

# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_types
disallowed-types = [
# TODO(@fzyzcjy): add types here as needed
gutenfries marked this conversation as resolved.
Show resolved Hide resolved
]
20 changes: 11 additions & 9 deletions frb_codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
cargo-features = ["workspace-inheritance"]
fzyzcjy marked this conversation as resolved.
Show resolved Hide resolved

[package]
name = "flutter_rust_bridge_codegen"
categories.workspace = true
description.workspace = true
edition.workspace = true
keywords.workspace = true
license.workspace = true
name = "flutter_rust_bridge_codegen"
repository.workspace = true
version.workspace = true

Expand All @@ -17,25 +19,25 @@ name = "flutter_rust_bridge_codegen"
path = "src/main.rs"

[dependencies]
anyhow = {workspace = true}
thiserror = {workspace = true}
anyhow = { workspace = true }
thiserror = { workspace = true }
cargo_metadata = "0.14.1"
convert_case = "0.5.0"
delegate = "0.8.0"
enum_dispatch = "0.3.8"
itertools = "0.10.3"
lazy_static = {workspace = true}
lazy_static = { workspace = true }
log = "0.4"
fern = { version = "0.6.0", features = ["date-based","colored"] }
fern = { version = "0.6.0", features = ["date-based", "colored"] }
atty = "0.2.14"
chrono = "0.4"
pathdiff = "0.2.1"
quote = "1.0"
regex = "1.5.4"
serde = {version = "1.0", features = ["derive"]}
serde = { version = "1.0", features = ["derive"] }
serde_yaml = "0.8"
strum_macros = "0.24.3"
syn = {version = "2.0.26", features = ["full", "extra-traits"]}
syn = { version = "2.0.26", features = ["full", "extra-traits"] }
tempfile = "3.2.0"
toml = "0.5.8"
topological-sort = "0.2.2"
Expand All @@ -50,8 +52,8 @@ semver = "1.0.12"
bin-dir = "{bin}{binary-ext}"

[package.metadata.binstall.overrides]
i686-pc-windows-msvc = {pkg-fmt = "zip"}
x86_64-pc-windows-msvc = {pkg-fmt = "zip"}
i686-pc-windows-msvc = { pkg-fmt = "zip" }
x86_64-pc-windows-msvc = { pkg-fmt = "zip" }

[features]
default = ["chrono", "serde", "uuid", "anyhow/backtrace"]
Expand Down
12 changes: 7 additions & 5 deletions frb_example/pure_dart/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "flutter_rust_bridge_example_single_block_test"
version = "1.0.0"
Expand All @@ -12,18 +14,18 @@ wasm-start = ["flutter_rust_bridge/wasm-start"]

[build-dependencies]
flutter_rust_bridge_codegen = { workspace = true, features = [
"chrono",
"uuid",
"chrono",
"uuid",
] }

[dependencies]
anyhow = { workspace = true, features = ["backtrace"] }
lazy_static = { workspace = true }
chrono = { workspace = true }
flutter_rust_bridge = { workspace = true, features = [
"chrono",
"uuid",
"worker-max",
"chrono",
"uuid",
"worker-max",
] }
uuid = { workspace = true }
log = "0.4"
Expand Down
2 changes: 2 additions & 0 deletions frb_example/pure_dart/rust/Cargo.toml.release
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "flutter_rust_bridge_example_single_block_test"
version = "1.0.0"
Expand Down
2 changes: 2 additions & 0 deletions frb_example/pure_dart/rust/external/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "flutter_rust_bridge_example_external"
version = "0.1.0"
Expand Down
2 changes: 2 additions & 0 deletions frb_example/pure_dart_multi/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "flutter_rust_bridge_example_multi_blocks_test"
version = "1.0.0"
Expand Down
2 changes: 2 additions & 0 deletions frb_example/pure_dart_multi/rust/Cargo.toml.release
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "flutter_rust_bridge_example_multi_blocks_test"
version = "1.0.0"
Expand Down
14 changes: 8 additions & 6 deletions frb_example/with_flutter/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "flutter_rust_bridge_example"
version = "0.1.0"
Expand All @@ -9,13 +11,13 @@ crate-type = ["cdylib"]

[build-dependencies]
flutter_rust_bridge_codegen = { workspace = true, features = [
"chrono",
"uuid",
"chrono",
"uuid",
] }

[dependencies]
anyhow = { workspace = true, features = ["backtrace"] }
flutter_rust_bridge = { workspace = true, features = ["chrono"]}
num = "0.4" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
image = "0.24.3" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
crossbeam = "0.8" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
flutter_rust_bridge = { workspace = true, features = ["chrono"] }
num = "0.4" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
image = "0.24.3" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
crossbeam = "0.8" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
4 changes: 3 additions & 1 deletion frb_example/with_flutter/rust/Cargo.toml.release
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "flutter_rust_bridge_example"
version = "0.1.0"
Expand All @@ -12,4 +14,4 @@ anyhow = { workspace = true, features = ["backtrace"] }
flutter_rust_bridge = { version = "1" }
num = "0.4" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
image = "0.24.3" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
crossbeam = "0.8" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
crossbeam = "0.8" # unrelated to Flutter Rust Bridge. Used only to draw beautiful photos.
2 changes: 2 additions & 0 deletions frb_macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "flutter_rust_bridge_macros"
version.workspace = true
Expand Down
20 changes: 11 additions & 9 deletions frb_rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cargo-features = ["workspace-inheritance"]

[package]
name = "flutter_rust_bridge"
version.workspace = true
Expand Down Expand Up @@ -31,15 +33,15 @@ console_error_panic_hook = { version = "0.1.7", optional = true }
wasm-bindgen = { version = "0.2.81" }
js-sys = { version = "0.3.60" }
web-sys = { version = "0.3.58", features = [
"DedicatedWorkerGlobalScope",
"MessageEvent",
"MessagePort",
"ErrorEvent",
"Blob",
"BlobPropertyBag",
"Worker",
"Url",
"BroadcastChannel",
"DedicatedWorkerGlobalScope",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be great if the old format could be kept, because someone else in the future may also automatically change the format via IDE automatically, then the code blame history will be a mess... but that's not a super big problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what toml formatter does the project use?

If it is Taplo, perhaps a configuration file may be helpful (https://taplo.tamasfe.dev/configuration/file.html)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, there is no format yet. I am just following flutter's convention: when there is no (auto) formatter, try to not change the code due to format.

However, feel free to configure a formatter (e.g. Taplo)! Just ensure that

  • it is checked in CI (along with other formatters, like Dart and Rust formatter)
  • it is run automatically when just precommit (trivial to do if you put is as a sibling to the existing Dart format etc)
  • it has nice support and is popular, e.g. has VSCode and Intellij IDEA bulit-in support or plugin support

"MessageEvent",
"MessagePort",
"ErrorEvent",
"Blob",
"BlobPropertyBag",
"Worker",
"Url",
"BroadcastChannel",
] }

[build-dependencies]
Expand Down
7 changes: 7 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ ci_codegen:
just generate_all
just check_no_git_diff

msrv:
bash tools/find_msrv.sh
bash tools/find_nightly_msrv.sh
Comment on lines +198 to +199
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it seems that the files are renamed


# ============================ misc ============================

clean:
Expand Down Expand Up @@ -310,6 +314,9 @@ _install_crate name="cargo-lipo":
else
echo "Already installed the correct version of $PACKAGE_NAME."
fi



# ============================ to be migrated ============================

# TODO - @Desdaemon
Expand Down
1 change: 1 addition & 0 deletions tools/.nightly_msrv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nightly-2022-07-15
1 change: 1 addition & 0 deletions tools/.stable_msrv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.64
Loading
Loading