diff --git a/.github/issue_template.md b/.github/issue_template.md index 044cd341..0000ceff 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -12,6 +12,5 @@ _Please provide the output from the command below, using markdown codeblock synt ```bash rustc --version -protoc --version flutter doctor ``` diff --git a/.github/workflows/build_test.yaml b/.github/workflows/build_test.yaml index 9eba8857..9ed323e4 100644 --- a/.github/workflows/build_test.yaml +++ b/.github/workflows/build_test.yaml @@ -57,11 +57,6 @@ jobs: - name: Setup Rust toolchain uses: dtolnay/rust-toolchain@stable - - name: Setup Protobuf compiler - uses: arduino/setup-protoc@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Setup Ninja and GTK3 toolchain (Only Linux target) if: matrix.target == 'linux' run: | diff --git a/.github/workflows/quality_control.yaml b/.github/workflows/quality_control.yaml index 416278dc..bfc00153 100644 --- a/.github/workflows/quality_control.yaml +++ b/.github/workflows/quality_control.yaml @@ -34,11 +34,6 @@ jobs: - name: Setup Rust toolchain uses: dtolnay/rust-toolchain@stable - - name: Setup Protobuf compiler - uses: arduino/setup-protoc@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Install Clippy run: rustup component add clippy diff --git a/documentation/docs/installing-components.md b/documentation/docs/installing-components.md index 9ad3f275..bb65cc8d 100644 --- a/documentation/docs/installing-components.md +++ b/documentation/docs/installing-components.md @@ -1,15 +1,12 @@ # Installing Components -To get started, you need to have [Flutter SDK](https://docs.flutter.dev/get-started/install), [Rust toolchain](https://www.rust-lang.org/tools/install), and [Protobuf compiler](https://grpc.io/docs/protoc-installation/) installed on your system. +To get started, you need to have [Flutter SDK](https://docs.flutter.dev/get-started/install) and [Rust toolchain](https://www.rust-lang.org/tools/install) installed on your system. -> If you're working on Linux, do not install Flutter from `snap`. Flutter from `snap` comes with its own binary linker called `ld`, which is fundamentally incompatible with Rust. Instead, follow the manual installation method as written in the Flutter docs. - -After the installation, verify your system's readiness with the following commands. Make sure you have installed all the subcomponents that Flutter suggests. If there are no issues in the output, you are good to go onto the next step! +Once you're done with the installations, verify your system's readiness with the following commands. Make sure you have installed all the subcomponents that Flutter suggests. If there are no issues in the output, you are good to go onto the next step! ```bash rustc --version -protoc --version flutter doctor ``` -> For those who aren't familiar, Protobuf is a popular, language-neutral, binary serialization format for structured messages, made by Google. +> If you're working on Linux, do not install Flutter from `snap`. Flutter from `snap` comes with its own binary linker called `ld`, which is fundamentally incompatible with Rust. Instead, follow the manual installation method as written in the Flutter docs. diff --git a/flutter_ffi_plugin/bin/rinf.dart b/flutter_ffi_plugin/bin/rinf.dart index f8788570..648fe169 100755 --- a/flutter_ffi_plugin/bin/rinf.dart +++ b/flutter_ffi_plugin/bin/rinf.dart @@ -191,16 +191,14 @@ utilizing the capabilities of the [Rinf](https://pub.dev/packages/rinf) framework. To run and build this app, you need to have -[Flutter SDK](https://docs.flutter.dev/get-started/install), -[Rust toolchain](https://www.rust-lang.org/tools/install), -and [Protobuf compiler](https://grpc.io/docs/protoc-installation) +[Flutter SDK](https://docs.flutter.dev/get-started/install) +and [Rust toolchain](https://www.rust-lang.org/tools/install) installed on your system. You can check that your system is ready with the commands below. Note that all the Flutter subcomponents should be installed. ```bash rustc --version -protoc --version flutter doctor ``` diff --git a/flutter_ffi_plugin/example/README.md b/flutter_ffi_plugin/example/README.md index cc16e03d..102b701d 100755 --- a/flutter_ffi_plugin/example/README.md +++ b/flutter_ffi_plugin/example/README.md @@ -9,16 +9,14 @@ utilizing the capabilities of the [Rinf](https://pub.dev/packages/rinf) framework. To run and build this app, you need to have -[Flutter SDK](https://docs.flutter.dev/get-started/install), -[Rust toolchain](https://www.rust-lang.org/tools/install), -and [Protobuf compiler](https://grpc.io/docs/protoc-installation) +[Flutter SDK](https://docs.flutter.dev/get-started/install) +and [Rust toolchain](https://www.rust-lang.org/tools/install) installed on your system. You can check that your system is ready with the commands below. Note that all the Flutter subcomponents should be installed. ```bash rustc --version -protoc --version flutter doctor ``` diff --git a/rust_crate/Cargo.toml b/rust_crate/Cargo.toml index df44b7fd..dff827ba 100644 --- a/rust_crate/Cargo.toml +++ b/rust_crate/Cargo.toml @@ -10,6 +10,8 @@ documentation = "https://rinf.cunarist.com" [target.'cfg(not(target_family = "wasm"))'.dependencies] os-thread-local = "0.1.3" backtrace = "0.3.69" +protoc-prebuilt = "0.2.0" +home = "0.5.9" [target.'cfg(target_family = "wasm")'.dependencies] js-sys = "0.3.65" diff --git a/rust_crate/src/main.rs b/rust_crate/src/main.rs index 2dd67032..a1b882d9 100644 --- a/rust_crate/src/main.rs +++ b/rust_crate/src/main.rs @@ -1,7 +1,24 @@ -use std::env; -use std::process::Command; - +#[cfg(not(target_family = "wasm"))] fn main() { + use std::env; + use std::fs; + use std::process::Command; + + // Install and remember Protobuf compiler's path + let home_path = home::home_dir().unwrap(); + let out_path = home_path.join(".local").join("bin"); + println!("{:?}", out_path); + fs::create_dir_all(&out_path).unwrap(); + env::set_var("OUT_DIR", out_path.to_str().unwrap()); + let (protoc_path, _) = protoc_prebuilt::init("22.0").unwrap(); + println!("{:?}", protoc_path.parent().unwrap().to_path_buf()); + let mut path_var = match env::var_os("PATH") { + Some(val) => env::split_paths(&val).collect::>(), + None => Vec::new(), + }; + path_var.push(protoc_path.parent().unwrap().to_path_buf()); + env::set_var("PATH", env::join_paths(path_var).unwrap()); + // Get command-line arguments excluding the program name let dart_command_args: Vec = env::args().skip(1).collect(); @@ -18,3 +35,8 @@ fn main() { // Execute the command let _ = command.status(); } + +#[cfg(target_family = "wasm")] +fn main() { + // Separate dummy function to make the linter happy +}