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

Organize things and rename the package to Rinf #187

Merged
merged 97 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
bb06019
Initial commit
knopp Apr 11, 2022
a7a62c7
Add empty workspace table
knopp Apr 13, 2022
a2c3b9b
Handle Flutter flavors and use ndkVersion from flutter if missing
knopp Aug 5, 2022
4b236a8
Fix compatibility with NDK 23 and newer.
knopp Oct 26, 2022
19762a1
Improvements to gradle build
knopp Nov 4, 2022
ddb6901
Add support for dylib on iOS and macOS
knopp Nov 5, 2022
380bfb4
Rename to cargokit
knopp Nov 11, 2022
811cb86
Symlink cargokit_phony_out
knopp Nov 11, 2022
c0606e8
Use llvm-ar from NDK
knopp Nov 11, 2022
4cb8bd4
Add any_symbol_name argument to apply_cargokit
knopp Nov 11, 2022
5939b92
Improve error reporting.
knopp Nov 12, 2022
2ebfade
fix problem with accessing gradle plugin properties too early
knopp Nov 15, 2022
c4fc1fc
fix regression for static libraries in cocoapods
knopp Nov 15, 2022
9e47f96
put phony file in products dir instead of tmpdir
knopp Nov 16, 2022
4274804
fix: llvm-ar detection on windows
knopp Jan 27, 2023
d32cdf6
fix: nested project interation in Gradle
knopp Mar 1, 2023
bed29e4
fix: add RANLIB environment variable for NDK build
knopp Mar 1, 2023
a677f7c
fix: flutter plugin lookup failing with multiple projects
knopp Mar 30, 2023
5aab533
fix: workaroudn for gradle plugin 7.4.2 not picking up JNI changes
knopp Jul 1, 2023
00dc003
fix: put ~/.cargo/bin to path first
knopp Jul 10, 2023
d12fcef
Update run_rust_tool.sh
temeddix Jul 16, 2023
1fc5489
Update run_rust_tool.cmd
temeddix Jul 16, 2023
1891d5a
chore: make clippy happy
knopp Jul 21, 2023
7ce8af4
feat: automatically install NDK if not found
knopp Jul 21, 2023
6d28ebc
Merge pull request #2 from temeddix/main
knopp Jul 22, 2023
b17d34e
fix: when checking for NDK check for presence of package.xml
knopp Jul 22, 2023
67cf985
feat: improve support for building FFI lib with CMake
knopp Jul 23, 2023
733ab74
feat! do not use ndk wrapper scripts
knopp Aug 7, 2023
04b95ea
fix! only accept cargo from ~/.cargo
knopp Aug 7, 2023
fb68308
fix: misspelled environment variable names
knopp Aug 7, 2023
54ae038
fix: check for cargo
knopp Aug 7, 2023
ea1ee39
Change `build_android` to `build_gradle`
bookshiyi Aug 19, 2023
e3c4cd9
Merge pull request #5 from bookshiyi/main
knopp Aug 22, 2023
0a02600
feat: always run cargo through rustup
knopp Aug 22, 2023
7d53ec6
windows
knopp Aug 22, 2023
dbc916e
Merge pull request #7 from irondash/run_cargo_through_rustup
knopp Aug 22, 2023
1b37dc5
fix: [windows] escape argument paths when calling cargo
knopp Aug 22, 2023
5d6e4df
fix: [macos, linux] escape argument paths when calling cargo
knopp Aug 22, 2023
72b0271
docs: update readme
knopp Aug 23, 2023
1e5585a
feat! add support for precompiling binaries
knopp Aug 28, 2023
53c0fa7
workflow
knopp Aug 28, 2023
ab3e66a
reformat
knopp Aug 28, 2023
c32b456
pub get
knopp Aug 28, 2023
8f96e6d
support for pod/dylib
knopp Aug 28, 2023
9d2b674
fix for old bash
knopp Aug 28, 2023
fdddb61
hash file path for quick hash
knopp Aug 28, 2023
dee4d87
Check whether homebrew Rust is in path and prompt unlinking
knopp Aug 29, 2023
e493969
Build rust library if rustup is present by default.
knopp Aug 29, 2023
79e527a
Initial documentation
knopp Aug 29, 2023
939ad37
update docs
knopp Aug 29, 2023
c8cff46
rename
knopp Aug 29, 2023
eb68ef4
typos
knopp Aug 29, 2023
53b65a5
main branch
knopp Aug 29, 2023
78dc165
prebuilt -> precompiled (consistency)
knopp Aug 30, 2023
dfcea13
rename
knopp Aug 30, 2023
387e07e
crate options in cargokit.yaml
knopp Aug 30, 2023
b190fdf
tweaks
knopp Aug 30, 2023
d72e38e
Merge pull request #11 from irondash/precompiled_binaries
knopp Aug 30, 2023
47b4637
fix typo
knopp Aug 30, 2023
bd8a2b8
feat: infer library name from Cargo.toml
knopp Aug 30, 2023
a082edc
Merge pull request #12 from irondash/infer_library_name
knopp Aug 30, 2023
6df32c4
chore: update pubspec.yaml
knopp Aug 30, 2023
e2c0fc9
chore: add !pubspec.lock to .gitignore
knopp Aug 30, 2023
52b2251
docs: comment typo
knopp Sep 1, 2023
bfd4bcc
fix: [pod] exception when building bundle dylib
knopp Sep 10, 2023
32b6720
Merge pull request #15 from irondash/fix_pod_dylib_bundle_replacement
knopp Sep 10, 2023
be425f7
fix: parsing configuration should ignore flavor
knopp Sep 11, 2023
34cc336
Merge pull request #16 from irondash/build_configuraiton_parse_ignore…
knopp Sep 11, 2023
c1e8fcf
fix: script argument escaping (#18)
knopp Sep 11, 2023
1f644b2
feat: add workaround for pub path resolving bug (#19)
knopp Sep 11, 2023
6d421f9
chore: add CI test for building example plugin (#17)
knopp Sep 11, 2023
98f6e01
feat: allow configuring verbose mode through CARGOKIT_VERBOSE env (#21)
knopp Sep 12, 2023
fa301d5
fix: [android] specify compiler extension on windows (#22)
knopp Sep 12, 2023
62bb5c9
chore: test iOS flavor and nightly for release build (#20)
knopp Sep 12, 2023
0f0359e
fix: install targets for correct toolchain (#26)
knopp Sep 15, 2023
7467b9a
fix: build_pod.sh should setup flutter environment (#29)
knopp Sep 21, 2023
7a5bba8
fix: setup flutter environment for Xcode iOS builds (#30)
knopp Sep 21, 2023
7dbb078
feat: check for invalid snapshot version and recompile kernel (#32)
knopp Sep 25, 2023
15bdc18
fix: symlink creation when building pods (#33)
knopp Oct 11, 2023
0352c1c
Move files
temeddix Oct 17, 2023
2b52dcb
Rename the framework to Rinf
temeddix Oct 17, 2023
ba76168
Rename crate `rifs` to `rinf`
temeddix Oct 17, 2023
c8f5165
Fix various things
temeddix Oct 17, 2023
c2727aa
Fix various things
temeddix Oct 17, 2023
0407d85
Organize small things
temeddix Oct 17, 2023
7c490db
Fix small things
temeddix Oct 17, 2023
7e11cfa
Fix URL
temeddix Oct 17, 2023
29724ed
Fix small problems with automation
temeddix Oct 17, 2023
8a9d6e2
Temporarily remove cargokit
temeddix Oct 17, 2023
9c74263
Add 'flutter_package/cargokit/' from commit '15bdc18ed8e74055d0673f6a…
temeddix Oct 17, 2023
fde721a
Fix cargokit update logic
temeddix Oct 17, 2023
69cc25f
Rename a directory
temeddix Oct 17, 2023
97cdce2
Fix various things
temeddix Oct 17, 2023
feb2169
Fix file permissions
temeddix Oct 17, 2023
6bda82d
Use symlink for common files
temeddix Oct 17, 2023
3d04824
Fix symlinks
temeddix Oct 17, 2023
3e5c643
Restore example app's readme file
temeddix Oct 17, 2023
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
42 changes: 22 additions & 20 deletions .github/workflows/build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install shorthand CLI tool
run: cargo install --path shorthand/

- name: Create a Flutter app for testing
run: flutter create test_app

- name: Setup Ninja and GTK3 toolchain (Only Linux target)
if: matrix.target == 'linux'
run: |
Expand All @@ -80,52 +74,60 @@ jobs:
distribution: "zulu"
java-version: "11"

- name: Install the CLI tool
working-directory: rust_crate/
run: cargo install --path ./

- name: Create a Flutter app for testing
working-directory: flutter_ffi_plugin/
run: flutter create test_app

- name: Fetch Flutter dependencies
working-directory: test_app/
working-directory: flutter_ffi_plugin/test_app/
run: flutter pub get

- name: Add this framework as a dependency
working-directory: test_app/
run: dart pub add "rust_in_flutter:{'path':'../'}"
working-directory: flutter_ffi_plugin/test_app/
run: dart pub add "rinf:{'path':'../'}"

- name: Apply Rust template
working-directory: test_app/
run: rifs template
working-directory: flutter_ffi_plugin/test_app/
run: rinf template

- name: Generate message files
working-directory: test_app/
run: rifs message
working-directory: flutter_ffi_plugin/test_app/
run: rinf message

- name: Build the example app
if: matrix.target == 'linux'
working-directory: test_app/
working-directory: flutter_ffi_plugin/test_app/
run: flutter build linux

- name: Build the example app
if: matrix.target == 'android'
working-directory: test_app/
working-directory: flutter_ffi_plugin/test_app/
run: |
flutter build apk
flutter build appbundle

- name: Build the example app
if: matrix.target == 'windows'
working-directory: test_app/
working-directory: flutter_ffi_plugin/test_app/
run: flutter build windows

- name: Build the example app
if: matrix.target == 'macos'
working-directory: test_app/
working-directory: flutter_ffi_plugin/test_app/
run: flutter build macos

- name: Build the example app
if: matrix.target == 'ios'
working-directory: test_app/
working-directory: flutter_ffi_plugin/test_app/
run: flutter build ios --no-codesign

- name: Build the example app
if: matrix.target == 'web'
working-directory: test_app/
working-directory: flutter_ffi_plugin/test_app/
run: |
rifs wasm --release
rinf wasm --release
flutter build web
14 changes: 7 additions & 7 deletions .github/workflows/formatting_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install shorthand CLI tool
working-directory: shorthand/
run: cargo install --path ./

- name: Install Clippy
run: rustup component add clippy

- name: Install the CLI tool
working-directory: rust_crate/
run: cargo install --path ./

- name: Fetch Flutter dependencies
working-directory: example/
working-directory: flutter_ffi_plugin/example/
run: flutter pub get

- name: Generate message files
working-directory: example/
run: rifs message
working-directory: flutter_ffi_plugin/example/
run: rinf message

- name: Check for any errors
run: |
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ build/
target/

# Others
**/*.lock
*.lock
/documentation/site/
42 changes: 0 additions & 42 deletions .metadata

This file was deleted.

10 changes: 0 additions & 10 deletions .pubignore

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[workspace]
members = ["./example/native/*", "./shorthand"]
members = ["./flutter_ffi_plugin/example/native/*", "./rust_crate"]
resolver = "2"
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Rust-In-Flutter
# Rinf: Rust in Flutter

[![Pub Version](https://img.shields.io/pub/v/rust_in_flutter)](https://pub.dev/packages/rust_in_flutter)
[![Pub Popularity](https://img.shields.io/pub/popularity/rust_in_flutter)](https://pub.dev/packages/rust_in_flutter)
[![Pub Points](https://img.shields.io/pub/points/rust_in_flutter)](https://pub.dev/packages/rust_in_flutter)
[![GitHub Stars](https://img.shields.io/github/stars/cunarist/rust-in-flutter)](https://github.com/cunarist/rust-in-flutter/stargazers)
[![Build Test](https://github.com/cunarist/rust-in-flutter/actions/workflows/build_test.yaml/badge.svg)](https://github.com/cunarist/rust-in-flutter/actions/workflows/build_test.yaml?query=branch%3Amain)
[![GitHub License](https://img.shields.io/github/license/cunarist/rust-in-flutter)](https://github.com/cunarist/rust-in-flutter/blob/main/LICENSE)
[![Pub Version](https://img.shields.io/pub/v/rinf)](https://pub.dev/packages/rinf)
[![Pub Popularity](https://img.shields.io/pub/popularity/rinf)](https://pub.dev/packages/rinf)
[![Pub Points](https://img.shields.io/pub/points/rinf)](https://pub.dev/packages/rinf)
[![GitHub Stars](https://img.shields.io/github/stars/cunarist/rinf)](https://github.com/cunarist/rinf/stargazers)
[![Build Test](https://github.com/cunarist/rinf/actions/workflows/build_test.yaml/badge.svg)](https://github.com/cunarist/rinf/actions/workflows/build_test.yaml?query=branch%3Amain)
[![GitHub License](https://img.shields.io/github/license/cunarist/rinf)](https://github.com/cunarist/rinf/blob/main/LICENSE)

**Rust as your Flutter backend, Flutter as your Rust frontend**

![Preview](https://github.com/cunarist/rust-in-flutter/assets/66480156/ae82aad9-02f9-4a1e-93f9-69907511baf8)
![Preview](https://github.com/cunarist/rinf/assets/66480156/ae82aad9-02f9-4a1e-93f9-69907511baf8)

This is a production-ready framework for creating beautiful and performant cross-platform apps using Flutter and Rust with batteries fully included. Simply add this framework to your app project, and you're all set to write Flutter and Rust together!

## 🎮 Demo

Visit the [demo](https://rif-demo.cunarist.com/) running on the web to experience the smoothness and delightfulness that comes from the combination of Flutter and Rust. You can also dive into the [example code](https://github.com/cunarist/rust-in-flutter/tree/main/example).
Visit the [demo](https://rinf-demo.cunarist.com/) running on the web to experience the smoothness and delightfulness that comes from the combination of Flutter and Rust. You can also dive into the [example code](https://github.com/cunarist/rinf/tree/main/flutter_ffi_plugin/example).

## 🖥️ Platform Support

All platforms available with Flutter are [tested](https://github.com/cunarist/rust-in-flutter/actions/workflows/build_test.yaml?query=branch%3Amain) and supported. Challenging build settings are automatically handled by this framework.
All platforms available with Flutter are [tested](https://github.com/cunarist/rinf/actions/workflows/build_test.yaml?query=branch%3Amain) and supported. Challenging build settings are automatically handled by this framework.

- ✅ Linux: Tested and supported
- ✅ Android: Tested and supported
Expand All @@ -34,7 +34,7 @@ All platforms available with Flutter are [tested](https://github.com/cunarist/ru
- **Minimal**: This is not a bulky framework that requires you to install so many dependencies and use complicated CLI commands. Just focus on your code using your preferred Flutter and Rust libraries.
- **High-level interface**: No messing with sensitive build files, no concerns about memory safety. Stay with Dart and Rust that you're familiar with.
- **Low-level control**: Though the hard things are kept beneath the surface, you are free to modify the underlying logic such as concurrency or debugging features. There is no hidden mechanism that prevents your understanding.
- **Well maintained**: Our [automated workflows](https://github.com/cunarist/rust-in-flutter/actions) including build tests are always kept passing, thanks to the main branch protection rule. Also, the number of external dependencies is kept as low as possible and documentations are thoughtfully organized.
- **Well maintained**: Our [automated workflows](https://github.com/cunarist/rinf/actions) including build tests are always kept passing, thanks to the main branch protection rule. Also, the number of external dependencies is kept as low as possible and documentations are thoughtfully organized.
- **Efficient**: No memory copy when sending native data, no hidden threads and web workers with memory overhead. This is a really thin wrapper around Dart and Rust.
- **Scalable**: You are able to use an arbitrary number of Rust library crates as you want, perhaps including ones that you've already been working on.
- **Logical API**: You declare RESTful messages, not functions for APIs, which provides greater stability. Requesting from Dart and responsing from Rust, as well as streaming from Rust to Dart is possible. Messages are type-safe and flexible because it's powered by the well-known [Protobuf](https://protobuf.dev/) serialization. You also have the ability to send large binary data from Rust to Dart without any memory copy.
Expand All @@ -57,10 +57,10 @@ Rust has garnered a devoted following, being [the most loved programming languag

## 📖 Documentation

Check out the [documentation](https://rif-docs.cunarist.com) for everything you need to know about how to use this thing.
Check out the [documentation](https://rinf-docs.cunarist.com) for everything you need to know about how to use this thing.

## 👥 Contributors

We appreciate your contribution to the development of this project! We're always open to discussions and pull requests, so please do not hesitate to leave your ideas or opinions at our GitHub repository.

[![GitHub contributors (via allcontributors.org)](https://contrib.rocks/image?repo=cunarist/rust-in-flutter)](https://github.com/cunarist/rust-in-flutter/graphs/contributors)
[![GitHub contributors (via allcontributors.org)](https://contrib.rocks/image?repo=cunarist/rinf)](https://github.com/cunarist/rinf/graphs/contributors)
1 change: 0 additions & 1 deletion android/settings.gradle

This file was deleted.

29 changes: 18 additions & 11 deletions automate/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import sys
import re


def exit():
Expand Down Expand Up @@ -40,25 +39,31 @@ def remove_files_in_folder(directory: str, prefix: str):
# Temporarily add `ffi` package
# because `flutter_rust_bridge_codegen` wants it,
# though the generated code doesn't use it.
os.chdir("./flutter_ffi_plugin/")
command = "dart pub add ffi"
os.system(command)
os.chdir("../")

# Delete previous bridge files.
remove_files_in_folder("./example/native/hub/src/bridge", "bridge")
remove_files_in_folder("./lib/src", "bridge")
remove_files_in_folder(
"./flutter_ffi_plugin/example/native/hub/src/bridge", "bridge"
)
remove_files_in_folder("./flutter_ffi_plugin/lib/src", "bridge")

# Generate bridge files.
command = "flutter_rust_bridge_codegen"
command += " --rust-input ./example/native/hub/src/bridge/api.rs"
command += " --rust-output ./example/native/hub/src/bridge/bridge_generated.rs"
command += " --dart-output ./lib/src/bridge_generated.dart"
command += " --dart-decl-output ./lib/src/bridge_definitions.dart"
command += " --rust-input ./flutter_ffi_plugin/example/native/hub/src/bridge/api.rs"
command += " --rust-output ./flutter_ffi_plugin/example/native/hub/src/bridge/bridge_generated.rs"
command += " --dart-output ./flutter_ffi_plugin/lib/src/bridge_generated.dart"
command += (
" --dart-decl-output ./flutter_ffi_plugin/lib/src/bridge_definitions.dart"
)
command += " --class-name Bridge"
command += " --wasm"
os.system(command)

# Remove an unnecessary root import.
filepath = "./example/native/hub/src/lib.rs"
filepath = "./flutter_ffi_plugin/example/native/hub/src/lib.rs"
with open(filepath, mode="r", encoding="utf8") as file:
lines = file.readlines()
for turn, line in enumerate(lines):
Expand All @@ -68,7 +73,7 @@ def remove_files_in_folder(directory: str, prefix: str):
file.write("".join(lines))

# Modify some code.
directory_path = "./lib/src/"
directory_path = "./flutter_ffi_plugin/lib/src/"
search_string = "package:flutter_rust_bridge/flutter_rust_bridge.dart"
replace_string = "bridge_engine/exports.dart"
replace_string_in_files(directory_path, search_string, replace_string)
Expand All @@ -88,7 +93,7 @@ def remove_files_in_folder(directory: str, prefix: str):
replace_string = ""
replace_string_in_files(directory_path, search_string, replace_string)

directory_path = "./example/native/hub/src/bridge"
directory_path = "./flutter_ffi_plugin/example/native/hub/src/bridge"
search_string = "flutter_rust_bridge::"
replace_string = "crate::bridge::bridge_engine::"
replace_string_in_files(directory_path, search_string, replace_string)
Expand All @@ -111,13 +116,15 @@ def remove_files_in_folder(directory: str, prefix: str):
os.system(command)

# Remove temporarily added `ffi` package.
os.chdir("./flutter_ffi_plugin/")
command = "dart pub remove ffi"
os.system(command)
os.chdir("../")

elif sys.argv[1] == "cargokit-update":
print("Updating CargoKit...")
command = "git subtree pull"
command += " --prefix cargokit"
command += " --prefix flutter_ffi_plugin/cargokit"
command += " https://github.com/irondash/cargokit.git"
command += " main"
command += " --squash"
Expand Down
6 changes: 3 additions & 3 deletions documentation/docs/applying-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
First of all, add this framework to your Flutter project.

```bash
flutter pub add rust_in_flutter
flutter pub add rinf
```

Then, simply run this in the command-line from your Flutter project's directory.

```bash
rifs template
rinf template
```

After running the command, you'll have new files and folders as your starter Rust template.
Expand Down Expand Up @@ -48,7 +48,7 @@ After running the command, you'll have new files and folders as your starter Rus
Be aware that the message code in Dart and Rust doesn't exist yet. You need to generate message code from the `.proto` files in the `./messages` folder. To do this, run the following command:

```bash
rifs message
rinf message
```

Don't forget to read the guides in `./native/README.md` first. Various comments are written in the actual code to help you understand the whole structure. Also, you might want to remove `sample_crate` in production.
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/contribution.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

We appreciate your contribution to the development of this project! We're always open to discussions and pull requests, so please do not hesitate to leave your ideas or opinions at our GitHub repository.

[![GitHub contributors (via allcontributors.org)](https://contrib.rocks/image?repo=cunarist/rust-in-flutter)](https://github.com/cunarist/rust-in-flutter/graphs/contributors)
[![GitHub contributors (via allcontributors.org)](https://contrib.rocks/image?repo=cunarist/rinf)](https://github.com/cunarist/rinf/graphs/contributors)
Loading