diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 96392b64bc..e84ba88a9e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -37,9 +37,6 @@ jobs: - uses: dart-lang/setup-dart@v1 - - name: Install ffigen - run: dart pub global activate ffigen ^6.0.1 - - name: Install dart dependencies (single block) working-directory: ./frb_example/pure_dart/dart run: dart pub get @@ -335,8 +332,6 @@ jobs: - uses: actions/checkout@v2 - uses: dart-lang/setup-dart@v1 - - name: Install ffigen - run: dart pub global activate ffigen ^6.0.1 - name: Install llvm dependency (Linux) run: sudo apt update && sudo apt-get install -y libclang-dev - name: Build codegen @@ -403,8 +398,6 @@ jobs: components: rustfmt, clippy - uses: dart-lang/setup-dart@v1 - - name: Install ffigen - run: dart pub global activate ffigen ^6.0.1 - name: Install llvm dependency (Linux) run: sudo apt update && sudo apt-get install -y libclang-dev @@ -563,18 +556,29 @@ jobs: runs-on: ${{ matrix.os.image }} steps: + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1 - - - name: Install dart global dependency - run: dart pub global activate ffigen ^6.0.1 - # needed by `ffigen`, see https://github.com/dart-lang/ffigen#installing-llvm - name: Install llvm dependency (Linux) if: ${{ matrix.os.family == 'linux' }} run: sudo apt update && sudo apt-get install -y libclang-dev + - name: Install dart dependencies (single block) + working-directory: ./frb_example/pure_dart/dart + run: dart pub get + + - name: Install dart dependencies (multi blocks) + working-directory: ./frb_example/pure_dart_multi/dart + run: dart pub get + + - name: Install Flutter dependencies + working-directory: ./frb_example/with_flutter + run: flutter pub get + # NOTE in windows, need "\\" instead of "/" - name: Run codegen to pure_dart example (non-windows) if: ${{ matrix.os.family != 'windows' }} diff --git a/.github/workflows/post_release.yaml b/.github/workflows/post_release.yaml index 2defe63b8a..d3105bb675 100644 --- a/.github/workflows/post_release.yaml +++ b/.github/workflows/post_release.yaml @@ -43,9 +43,6 @@ jobs: - uses: dart-lang/setup-dart@v1 - - name: Install ffigen - run: dart pub global activate ffigen ^6.0.1 - - name: Install dart dependencies (single block) working-directory: ./frb_example/pure_dart/dart run: dart pub get @@ -171,16 +168,15 @@ jobs: runs-on: ${{ matrix.os.image }} steps: + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + - uses: actions/checkout@v2 - name: Install released version of codegen run: cargo install flutter_rust_bridge_codegen - - uses: dart-lang/setup-dart@v1 - - - name: Install dart global dependency - run: dart pub global activate ffigen ^6.0.1 - # needed by `ffigen`, see https://github.com/dart-lang/ffigen#installing-llvm - name: Install llvm dependency (Linux) if: ${{ matrix.os.family == 'linux' }} diff --git a/book/src/integrate/deps.md b/book/src/integrate/deps.md index 4207b4a06d..bcac1aef1a 100644 --- a/book/src/integrate/deps.md +++ b/book/src/integrate/deps.md @@ -8,17 +8,31 @@ These depdencies are required only in build-time: - [`flutter_rust_bridge_codegen`](https://lib.rs/crates/flutter_rust_bridge_codegen), the core codegen for Rust-Dart glue code - [`ffigen`](https://pub.dev/packages/ffigen), to generate Dart code from C headers -- [`cargo-xcode`](https://lib.rs/crates/cargo-xcode), to generate Xcode projects for iOS and MacOS -- A working installation of LLVM, see [Installing LLVM](https://pub.dev/packages/ffigen#installing-llvm) +- A working installation of LLVM, see [Installing LLVM](https://pub.dev/packages/ffigen#installing-llvm), used by `ffigen` +- (Optional) [`cargo-xcode`](https://lib.rs/crates/cargo-xcode), if you want to generate Xcode projects for iOS and MacOS An easy way to install most of these dependencies is to run: -```bash -cargo install flutter_rust_bridge_codegen -dart pub global activate ffigen -# if building for iOS or MacOS -cargo install cargo-xcode -``` +- dart project + + ```bash + cargo install flutter_rust_bridge_codegen + dart pub add --dev ffigen && dart pub add ffi + # if building for iOS or MacOS + cargo install cargo-xcode + ``` + +- flutter project + + ```bash + cargo install flutter_rust_bridge_codegen + flutter pub add --dev ffigen && flutter pub add ffi + # if building for iOS or MacOS + cargo install cargo-xcode + ``` + +Alternatively, each of these dependencies may provide prebuilt binaries. Check with +your package manager and review them individually. ## Dart dependencies @@ -51,6 +65,3 @@ Add these lines to `Cargo.toml`: +flutter_rust_bridge = "1" ``` -> **Note** \ -> If you wish to return a `Result`, keep in mind that this library can only run codegen -> for [`anyhow::Result`](https://docs.rs/anyhow/latest/anyhow/type.Result.html). diff --git a/book/src/setup_codegen.md b/book/src/setup_codegen.md deleted file mode 100644 index d3f8ed90fc..0000000000 --- a/book/src/setup_codegen.md +++ /dev/null @@ -1,11 +0,0 @@ -- [`flutter_rust_bridge_codegen`](https://lib.rs/crates/flutter_rust_bridge_codegen), the core codegen for Rust-Dart glue code -- [`ffigen`](https://pub.dev/packages/ffigen), to generate Dart code from C headers -- [`just`](https://github.com/casey/just), a modern command runner alternative to Make -- A working installation of LLVM, see [Installing LLVM](https://pub.dev/packages/ffigen#installing-llvm) - -An easy way to install the first three dependencies is to run these commands: - -```shell -cargo install flutter_rust_bridge_codegen just -dart pub global activate ffigen -``` diff --git a/book/src/template/generate_install.md b/book/src/template/generate_install.md index 48e444a2b9..06d18fbc05 100644 --- a/book/src/template/generate_install.md +++ b/book/src/template/generate_install.md @@ -1,18 +1,3 @@ # Installing codegen -First, you will need the following programs, preferably visible from your path: - -- [`flutter_rust_bridge_codegen`](https://lib.rs/crates/flutter_rust_bridge_codegen), the core codegen for Rust-Dart glue code -- [`ffigen`](https://pub.dev/packages/ffigen), to generate Dart code from C headers -- [`just`](https://github.com/casey/just), a modern command runner alternative to Make -- A working installation of LLVM, see [Installing LLVM](https://pub.dev/packages/ffigen#installing-llvm) - -An easy way to install the first three dependencies is to run these commands: - -```shell -cargo install flutter_rust_bridge_codegen just -dart pub global activate ffigen -``` - -Alternatively, each of these dependencies may provide prebuilt binaries. Check with -your package manager and review them individually. +More informations in the [Installing dependencies](../integrate/deps.md) section. diff --git a/book/src/tutorial_with_flutter.md b/book/src/tutorial_with_flutter.md index 2c8b65bb38..92c3b765a3 100644 --- a/book/src/tutorial_with_flutter.md +++ b/book/src/tutorial_with_flutter.md @@ -2,6 +2,7 @@ In this tutorial, let us draw a [Mandelbrot set](https://en.wikipedia.org/wiki/Mandelbrot_set) (a well-known infinite-resolution "image" generated by a simple math formula). The image is plotted in Flutter UI, generated by Rust algorithm, and communicated via this library. +
(Click to see: What is a Mandelbrot set) @@ -27,16 +28,7 @@ git clone https://github.com/fzyzcjy/flutter_rust_bridge && cd flutter_rust_brid This step is optional, since I have generated the source code already (in quickstart). Even if you do it, you should not see anything changed. -Firstly, you may need to install dependencies of this library: - -* Install `ffigen`: `dart pub global activate ffigen`, and [install LLVM](https://pub.dev/packages/ffigen#installing-llvm) which is required by `ffigen`. -* Install the codegen program: `cargo install flutter_rust_bridge_codegen` (or other probably faster methods described [here](quickstart.md)). - -Then, run the code generator: - -```shell -flutter_rust_bridge_codegen --rust-input frb_example/with_flutter/rust/src/api.rs --dart-output frb_example/with_flutter/lib/bridge_generated.dart --c-output frb_example/with_flutter/ios/Runner/bridge_generated.h -``` +As soon as you make any modification to `api.rs`, you need to run codegen again. More informations about requirements for code generation can be seen in the [Installing dependencies](integrate/deps.md) section. ## Run app diff --git a/frb_codegen/src/commands.rs b/frb_codegen/src/commands.rs index 6ebe013dae..b3e526d563 100644 --- a/frb_codegen/src/commands.rs +++ b/frb_codegen/src/commands.rs @@ -1,13 +1,12 @@ -use std::collections::HashMap; use std::fmt::Write; use std::path::Path; -use std::path::PathBuf; use std::process::Command; use std::process::Output; use crate::error::{Error, Result}; +use crate::utils::PackageManager; +use crate::utils::{ensure_dependencies, guess_toolchain, DartToolchain}; use log::{debug, info, warn}; -use serde::Deserialize; #[must_use] fn call_shell(cmd: &str) -> Output { @@ -18,11 +17,32 @@ fn call_shell(cmd: &str) -> Output { execute_command("sh", &["-c", cmd], None) } -pub fn ensure_tools_available() -> Result { - let output = call_shell("dart pub global list"); - let output = String::from_utf8_lossy(&output.stdout); - if !output.contains("ffigen") { - return Err(Error::MissingExe(String::from("ffigen"))); +pub fn ensure_tools_available(dart_root: &str) -> Result { + let toolchain = guess_toolchain(dart_root).unwrap(); + if toolchain == DartToolchain::Dart && !call_shell("dart --version").status.success() { + return Err(Error::MissingExe("dart".to_string())); + } else if toolchain == DartToolchain::Flutter + && !call_shell("flutter --version").status.success() + { + return Err(Error::MissingExe("flutter".to_string())); + } + + let ffi = ensure_dependencies(dart_root, "ffi", PackageManager::Dependencies).unwrap(); + if ffi.is_none() { + return Err(Error::MissingDep { + name: "ffi".into(), + context: PackageManager::Dependencies, + version: "^2.0.1".into(), + }); + } + + let ffigen = ensure_dependencies(dart_root, "ffigen", PackageManager::DevDependencies).unwrap(); + if ffigen.is_none() { + return Err(Error::MissingDep { + name: "ffigen".into(), + context: PackageManager::DevDependencies, + version: "^6.0.1".into(), + }); } Ok(()) @@ -39,7 +59,10 @@ pub(crate) struct BindgenRustToDartArg<'a> { pub llvm_compiler_opts: &'a str, } -pub(crate) fn bindgen_rust_to_dart(arg: BindgenRustToDartArg) -> anyhow::Result<()> { +pub(crate) fn bindgen_rust_to_dart( + arg: BindgenRustToDartArg, + dart_root: &str, +) -> anyhow::Result<()> { cbindgen( arg.rust_crate_dir, arg.c_output_path, @@ -52,6 +75,7 @@ pub(crate) fn bindgen_rust_to_dart(arg: BindgenRustToDartArg) -> anyhow::Result< arg.dart_class_name, arg.llvm_install_path, arg.llvm_compiler_opts, + dart_root, ) } @@ -161,6 +185,7 @@ fn ffigen( dart_class_name: &str, llvm_path: &[String], llvm_compiler_opts: &str, + dart_root: &str, ) -> anyhow::Result<()> { debug!( "execute ffigen c_path={} dart_path={} llvm_path={:?}", @@ -208,9 +233,15 @@ fn ffigen( std::io::Write::write_all(&mut config_file, config.as_bytes())?; debug!("ffigen config_file: {:?}", config_file); - // NOTE please install ffigen globally first: `dart pub global activate ffigen` + let cmd = format!( + "{} run", + guess_toolchain(dart_root).unwrap().as_run_command() + ); let res = call_shell(&format!( - "dart pub global run ffigen --config \"{}\"", + "cd {}{}{} ffigen --config \"{}\"", + dart_root, + if cfg!(windows) { "; " } else { " && " }, + cmd, config_file.path().to_string_lossy() )); if !res.status.success() { @@ -280,90 +311,3 @@ pub fn build_runner(dart_root: &str) -> Result { } Ok(()) } - -fn guess_toolchain(dart_root: &str) -> anyhow::Result { - debug!("Guessing toolchain the runner is run into"); - let lock_file = PathBuf::from(dart_root).join("pubspec.lock"); - if !lock_file.exists() { - return Err(anyhow::Error::msg(format!( - "missing pubspec.lock in {}", - dart_root - ))); - } - let lock_file = std::fs::read_to_string(lock_file) - .map_err(|_| anyhow::Error::msg(format!("unable to read pubspec.lock in {}", dart_root)))?; - let lock_file: PubspecLock = serde_yaml::from_str(&lock_file).map_err(|_| { - anyhow::Error::msg(format!("unable to parse pubspec.lock in {}", dart_root)) - })?; - if lock_file.packages.contains_key("flutter") { - return Ok(DartToolchain::Flutter); - } - Ok(DartToolchain::Dart) -} - -#[derive(Debug, PartialEq)] -enum DartToolchain { - Dart, - Flutter, -} - -impl DartToolchain { - fn as_run_command(&self) -> &'static str { - match self { - DartToolchain::Dart => "dart", - DartToolchain::Flutter => "flutter pub", - } - } -} - -#[derive(Debug, Deserialize)] -struct PubspecLock { - pub packages: HashMap, -} - -#[cfg(test)] -mod tests { - use std::path::{Path, PathBuf}; - - use crate::commands::{guess_toolchain, DartToolchain}; - use lazy_static::lazy_static; - - lazy_static! { - static ref FRB_EXAMPLES_FOLDER: PathBuf = { - PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("..") - .join("frb_example") - }; - } - - fn guess_toolchain_base(path: &Path, expect_toolchain: DartToolchain) { - let toolchain = guess_toolchain(&path.to_string_lossy()).expect(&format!( - "can get toolchain from {}", - path.to_string_lossy() - )); - assert_eq!(toolchain, expect_toolchain); - } - - #[test] - fn guess_dart_toolchain() { - guess_toolchain_base( - FRB_EXAMPLES_FOLDER.join("pure_dart").join("dart").as_path(), - DartToolchain::Dart, - ); - guess_toolchain_base( - FRB_EXAMPLES_FOLDER - .join("pure_dart_multi") - .join("dart") - .as_path(), - DartToolchain::Dart, - ); - } - - #[test] - fn guess_flutter_toolchain() { - guess_toolchain_base( - FRB_EXAMPLES_FOLDER.join("with_flutter").as_path(), - DartToolchain::Flutter, - ); - } -} diff --git a/frb_codegen/src/config.rs b/frb_codegen/src/config.rs index 5feaacd626..4227e5d518 100644 --- a/frb_codegen/src/config.rs +++ b/frb_codegen/src/config.rs @@ -416,4 +416,10 @@ impl Opts { .to_owned(), ) } + + pub fn dart_root_or_default(&self) -> String { + self.dart_root + .clone() + .unwrap_or_else(|| env!("CARGO_MANIFEST_DIR").to_string()) + } } diff --git a/frb_codegen/src/error.rs b/frb_codegen/src/error.rs index 9a8607d377..cbda74bce2 100644 --- a/frb_codegen/src/error.rs +++ b/frb_codegen/src/error.rs @@ -1,5 +1,7 @@ use thiserror::Error; +use crate::utils::PackageManager; + pub type Result = std::result::Result<(), Error>; #[derive(Error, Debug)] @@ -19,6 +21,18 @@ pub enum Error { MissingExe(String), #[error("{0}")] StringError(String), + #[error("please add {name} to your {context}. (version {version})")] + MissingDep { + name: String, + context: PackageManager, + version: String, + }, + #[error("please update version of {name} in your {context}. (version {version})")] + InvalidDep { + name: String, + context: PackageManager, + version: String, + }, } impl Error { diff --git a/frb_codegen/src/lib.rs b/frb_codegen/src/lib.rs index edda146fb9..c15f5bd19c 100644 --- a/frb_codegen/src/lib.rs +++ b/frb_codegen/src/lib.rs @@ -32,7 +32,8 @@ mod utils; use error::*; pub fn frb_codegen(config: &config::Opts, all_symbols: &[String]) -> anyhow::Result<()> { - ensure_tools_available()?; + let dart_root = config.dart_root_or_default(); + ensure_tools_available(&dart_root)?; info!("Picked config: {:?}", config); @@ -68,20 +69,23 @@ pub fn frb_codegen(config: &config::Opts, all_symbols: &[String]) -> anyhow::Res &config.rust_output_path, DUMMY_WIRE_CODE_FOR_BINDGEN, || { - commands::bindgen_rust_to_dart(BindgenRustToDartArg { - rust_crate_dir: &config.rust_crate_dir, - c_output_path: temp_bindgen_c_output_file - .path() - .as_os_str() - .to_str() - .unwrap(), - dart_output_path: temp_dart_wire_file.path().as_os_str().to_str().unwrap(), - dart_class_name: &config.dart_wire_class_name(), - c_struct_names: ir_file.get_c_struct_names(), - exclude_symbols, - llvm_install_path: &config.llvm_path[..], - llvm_compiler_opts: &config.llvm_compiler_opts, - }) + commands::bindgen_rust_to_dart( + BindgenRustToDartArg { + rust_crate_dir: &config.rust_crate_dir, + c_output_path: temp_bindgen_c_output_file + .path() + .as_os_str() + .to_str() + .unwrap(), + dart_output_path: temp_dart_wire_file.path().as_os_str().to_str().unwrap(), + dart_class_name: &config.dart_wire_class_name(), + c_struct_names: ir_file.get_c_struct_names(), + exclude_symbols, + llvm_install_path: &config.llvm_path[..], + llvm_compiler_opts: &config.llvm_compiler_opts, + }, + &dart_root, + ) }, )?; @@ -138,9 +142,8 @@ pub fn frb_codegen(config: &config::Opts, all_symbols: &[String]) -> anyhow::Res )?; } - let dart_root = &config.dart_root; if needs_freezed && config.build_runner { - let dart_root = dart_root.as_ref().ok_or_else(|| { + let dart_root = config.dart_root.as_ref().ok_or_else(|| { Error::str( "build_runner configured to run, but Dart root could not be inferred. Please specify --dart-root, or disable build_runner with --no-build-runner.", diff --git a/frb_codegen/src/utils.rs b/frb_codegen/src/utils.rs index 89a7a48689..3002888b83 100644 --- a/frb_codegen/src/utils.rs +++ b/frb_codegen/src/utils.rs @@ -1,8 +1,14 @@ -use std::collections::HashSet; +use std::collections::{HashMap, HashSet}; +use std::convert::TryFrom; use std::fmt::Display; use std::fs; use std::hash::Hash; -use std::path::Path; +use std::path::{Path, PathBuf}; +use std::str::FromStr; + +use cargo_metadata::{Version, VersionReq}; +use log::debug; +use serde::Deserialize; pub fn mod_from_rust_path(code_path: &str, crate_path: &str) -> String { Path::new(code_path) @@ -83,3 +89,196 @@ impl Display for BlockIndex { write!(f, "{}", self.0) } } + +#[derive(Debug, PartialEq)] +pub(crate) enum DartToolchain { + Dart, + Flutter, +} + +impl DartToolchain { + pub(crate) fn as_run_command(&self) -> &'static str { + match self { + DartToolchain::Dart => "dart", + DartToolchain::Flutter => "flutter pub", + } + } +} + +#[derive(Debug, Deserialize)] +struct PubspecLock { + pub packages: HashMap, +} + +#[derive(Debug, Deserialize)] +#[serde(untagged)] +pub enum PackageVersion { + Inline(String), + Multiline { version: Option }, +} + +impl PackageVersion { + pub(crate) fn version(&self) -> Option { + match self { + PackageVersion::Inline(v) => Some(v.clone()), + PackageVersion::Multiline { version } => version.clone(), + } + } +} + +#[derive(Debug)] +pub enum PackageVersionKind { + Exact(Version), + Range(VersionReq), +} + +impl TryFrom<&PackageVersion> for PackageVersionKind { + type Error = anyhow::Error; + fn try_from(version: &PackageVersion) -> Result { + if let Some(ref version) = version.version() { + return Self::from_str(version); + } + Err(anyhow::anyhow!("no version found")) + } +} + +impl FromStr for PackageVersionKind { + type Err = anyhow::Error; + + fn from_str(s: &str) -> Result { + let range: [char; 4] = ['>', '<', '=', '^']; + if s.contains(range) { + let version_req = VersionReq::parse(s)?; + Ok(PackageVersionKind::Range(version_req)) + } else { + let version = Version::parse(s)?; + Ok(PackageVersionKind::Exact(version)) + } + } +} + +impl ToString for PackageVersionKind { + fn to_string(&self) -> String { + match self { + PackageVersionKind::Exact(v) => v.to_string(), + PackageVersionKind::Range(v) => v.to_string(), + } + } +} + +#[derive(Debug, PartialEq)] +pub enum PackageManager { + Dependencies, + DevDependencies, +} + +impl std::fmt::Display for PackageManager { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + PackageManager::Dependencies => write!(f, "dependencies"), + PackageManager::DevDependencies => write!(f, "dev_dependencies"), + } + } +} + +#[derive(Debug, Deserialize)] +struct Pubspec { + pub dependencies: Option>, + pub dev_dependencies: Option>, +} + +#[inline] +fn read_file(at: &str, filename: &str) -> anyhow::Result { + let file = PathBuf::from(at).join(filename); + if !file.exists() { + return Err(anyhow::Error::msg(format!( + "missing {} in {}", + filename, at + ))); + } + let content = std::fs::read_to_string(file) + .map_err(|_| anyhow::Error::msg(format!("unable to read {} in {}", filename, at)))?; + Ok(content) +} + +pub(crate) fn guess_toolchain(dart_root: &str) -> anyhow::Result { + debug!("Guessing toolchain the runner is run into"); + let lock_file = read_file(dart_root, "pubspec.lock")?; + let lock_file: PubspecLock = serde_yaml::from_str(&lock_file).map_err(|_| { + anyhow::Error::msg(format!("unable to parse pubspec.lock in {}", dart_root)) + })?; + if lock_file.packages.contains_key("flutter") { + return Ok(DartToolchain::Flutter); + } + Ok(DartToolchain::Dart) +} + +pub(crate) fn ensure_dependencies( + dart_root: &str, + package: &str, + manager: PackageManager, +) -> anyhow::Result> { + debug!( + "Checking presence of {} in {} at {}", + package, manager, dart_root + ); + let manifest_file = read_file(dart_root, "pubspec.yaml")?; + let manifest_file: Pubspec = serde_yaml::from_str(&manifest_file).map_err(|_| { + anyhow::Error::msg(format!("unable to parse pubspec.yaml in {}", dart_root)) + })?; + let deps = if manager == PackageManager::DevDependencies { + manifest_file.dev_dependencies.unwrap_or_default() + } else { + manifest_file.dependencies.unwrap_or_default() + }; + let version = deps.get(package); + let version = version.map(|v| PackageVersionKind::try_from(v).unwrap()); + Ok(version) +} + +#[cfg(test)] +mod tests { + use std::path::{Path, PathBuf}; + + use super::{guess_toolchain, DartToolchain}; + use lazy_static::lazy_static; + + lazy_static! { + static ref FRB_EXAMPLES_FOLDER: PathBuf = { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("..") + .join("frb_example") + }; + } + + fn guess_toolchain_base(path: &Path, expect_toolchain: DartToolchain) { + let toolchain = guess_toolchain(&path.to_string_lossy()).expect(&format!( + "can get toolchain from {}", + path.to_string_lossy() + )); + assert_eq!(toolchain, expect_toolchain); + } + + #[test] + fn guess_dart_toolchain() { + guess_toolchain_base( + FRB_EXAMPLES_FOLDER.join("pure_dart").join("dart").as_path(), + DartToolchain::Dart, + ); + guess_toolchain_base( + FRB_EXAMPLES_FOLDER + .join("pure_dart_multi") + .join("dart") + .as_path(), + DartToolchain::Dart, + ); + } + + #[test] + fn guess_flutter_toolchain() { + guess_toolchain_base( + FRB_EXAMPLES_FOLDER.join("with_flutter").as_path(), + DartToolchain::Flutter, + ); + } +} diff --git a/frb_example/pure_dart/dart/pubspec.lock b/frb_example/pure_dart/dart/pubspec.lock index 3e60e85614..f48e461611 100644 --- a/frb_example/pure_dart/dart/pubspec.lock +++ b/frb_example/pure_dart/dart/pubspec.lock @@ -99,6 +99,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.5" code_builder: dependency: transitive description: @@ -141,6 +148,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.2.3" + ffi: + dependency: "direct main" + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + ffigen: + dependency: "direct dev" + description: + name: ffigen + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.1" file: dependency: transitive description: @@ -309,6 +330,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" shelf: dependency: transitive description: diff --git a/frb_example/pure_dart/dart/pubspec.yaml b/frb_example/pure_dart/dart/pubspec.yaml index dab16b2ff6..27e1a7993b 100644 --- a/frb_example/pure_dart/dart/pubspec.yaml +++ b/frb_example/pure_dart/dart/pubspec.yaml @@ -12,6 +12,8 @@ dependencies: test: ^1.21.4 vm_service: ^9.0.0 freezed_annotation: ^2.1.0 + ffi: ^2.0.1 dev_dependencies: build_runner: ^2.2.0 freezed: ^2.1.0+1 + ffigen: ^6.0.1 diff --git a/frb_example/pure_dart_multi/dart/pubspec.lock b/frb_example/pure_dart_multi/dart/pubspec.lock index 810346b3df..00798cc513 100644 --- a/frb_example/pure_dart_multi/dart/pubspec.lock +++ b/frb_example/pure_dart_multi/dart/pubspec.lock @@ -99,6 +99,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.5" code_builder: dependency: transitive description: @@ -141,6 +148,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.2.3" + ffi: + dependency: "direct main" + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + ffigen: + dependency: "direct dev" + description: + name: ffigen + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.1" file: dependency: transitive description: @@ -309,6 +330,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" shelf: dependency: transitive description: diff --git a/frb_example/pure_dart_multi/dart/pubspec.yaml b/frb_example/pure_dart_multi/dart/pubspec.yaml index 536224f63e..f632107bca 100644 --- a/frb_example/pure_dart_multi/dart/pubspec.yaml +++ b/frb_example/pure_dart_multi/dart/pubspec.yaml @@ -12,6 +12,8 @@ dependencies: test: ^1.18.2 vm_service: ^7.3.0 freezed_annotation: ^2.0.1 + ffi: ^2.0.1 dev_dependencies: build_runner: ^2.1.11 freezed: ^2.0.2 + ffigen: ^6.0.1 diff --git a/frb_example/with_flutter/pubspec.lock b/frb_example/with_flutter/pubspec.lock index 8726533ca8..a8f3228d0d 100644 --- a/frb_example/with_flutter/pubspec.lock +++ b/frb_example/with_flutter/pubspec.lock @@ -120,6 +120,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" + cli_util: + dependency: transitive + description: + name: cli_util + url: "https://pub.dartlang.org" + source: hosted + version: "0.3.5" clock: dependency: transitive description: @@ -176,6 +183,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + ffi: + dependency: "direct main" + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" + ffigen: + dependency: "direct dev" + description: + name: ffigen + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.1" file: dependency: transitive description: @@ -390,6 +411,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + quiver: + dependency: transitive + description: + name: quiver + url: "https://pub.dartlang.org" + source: hosted + version: "3.1.0" shelf: dependency: transitive description: diff --git a/frb_example/with_flutter/pubspec.yaml b/frb_example/with_flutter/pubspec.yaml index 509367d961..50904c11f5 100644 --- a/frb_example/with_flutter/pubspec.yaml +++ b/frb_example/with_flutter/pubspec.yaml @@ -37,6 +37,7 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.5 freezed_annotation: ^2.1.0 + ffi: ^2.0.1 dev_dependencies: flutter_test: @@ -52,6 +53,7 @@ dev_dependencies: flutter_lints: ^1.0.0 freezed: ^2.1.0+1 build_runner: ^2.2.0 + ffigen: ^6.0.1 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/justfile b/justfile index 57534ac8fa..2d6bf4e628 100644 --- a/justfile +++ b/justfile @@ -36,6 +36,10 @@ lint: dart format --fix -l {{line_length}} {{frb_pure}} dart format --fix -l {{line_length}} {{frb_pure_multi}} dart format --fix -l {{line_length}} {{frb_flutter}} + cd {{frb_pure}}/rust && cargo fmt + cd {{frb_pure_multi}}/rust && cargo fmt + cd {{frb_flutter}}/rust && cargo fmt + cd frb_codegen && cargo fmt alias t := test test: test-pure test-integration @@ -63,6 +67,7 @@ check: cd {{frb_pure_multi}}/rust && cargo clippy cd {{frb_flutter}} && flutter pub get && flutter analyze cd {{frb_flutter}}/rust && cargo clippy + cd frb_codegen && cargo clippy refresh_all: (cd frb_rust && cargo clippy -- -D warnings)