From 07a89303aacbeec6386e357287b6fd9fcca77d94 Mon Sep 17 00:00:00 2001 From: Julian Date: Tue, 15 Sep 2026 17:13:31 -0600 Subject: [PATCH] WIP native assets migration --- .github/workflows/check_and_lint.yml | 38 +- .../workflows/test_example_plugin_build.yml | 56 +- .gitignore | 27 +- .metadata | 18 +- .pubignore | 27 + CHANGELOG.md | 13 + README.md | 75 +- analysis_options.yaml | 8 +- android/.gitignore | 9 - android/build.gradle | 56 -- android/settings.gradle | 1 - android/src/main/AndroidManifest.xml | 3 - build_pod.sh | 58 -- build_tool/README.md | 2 - build_tool/analysis_options.yaml | 31 - build_tool/bin/build_tool.dart | 5 - build_tool/lib/build_tool.dart | 5 - build_tool/lib/src/android_environment.dart | 192 ---- build_tool/lib/src/artifacts_provider.dart | 263 ----- build_tool/lib/src/build_cmake.dart | 37 - build_tool/lib/src/build_gradle.dart | 46 - build_tool/lib/src/build_pod.dart | 86 -- build_tool/lib/src/build_tool.dart | 273 ------ build_tool/lib/src/builder.dart | 206 ---- build_tool/lib/src/cargo.dart | 45 - build_tool/lib/src/crate_hash.dart | 121 --- build_tool/lib/src/environment.dart | 65 -- build_tool/lib/src/logging.dart | 49 - build_tool/lib/src/options.dart | 306 ------ build_tool/lib/src/precompile_binaries.dart | 202 ---- build_tool/lib/src/rustup.dart | 146 --- build_tool/lib/src/target.dart | 144 --- build_tool/lib/src/util.dart | 169 ---- build_tool/lib/src/verify_binaries.dart | 81 -- build_tool/pubspec.lock | 453 --------- build_tool/pubspec.yaml | 30 - build_tool/test/builder_test.dart | 28 - build_tool/test/cargo_test.dart | 28 - build_tool/test/options_test.dart | 75 -- build_tool/test/rustup_test.dart | 66 -- cargokit/.github/workflows/check_and_lint.yml | 26 - .../workflows/test_example_plugin_build.yml | 86 -- cargokit/.gitignore | 4 - cargokit/LICENSE | 39 - cargokit/README | 8 - cargokit/build_pod.sh | 58 -- cargokit/build_tool/README.md | 2 - cargokit/build_tool/analysis_options.yaml | 31 - cargokit/build_tool/bin/build_tool.dart | 5 - cargokit/build_tool/lib/build_tool.dart | 5 - .../lib/src/android_environment.dart | 192 ---- .../lib/src/artifacts_provider.dart | 263 ----- cargokit/build_tool/lib/src/build_cmake.dart | 37 - cargokit/build_tool/lib/src/build_gradle.dart | 46 - cargokit/build_tool/lib/src/build_pod.dart | 86 -- cargokit/build_tool/lib/src/build_tool.dart | 273 ------ cargokit/build_tool/lib/src/builder.dart | 206 ---- cargokit/build_tool/lib/src/cargo.dart | 45 - cargokit/build_tool/lib/src/crate_hash.dart | 121 --- cargokit/build_tool/lib/src/environment.dart | 65 -- cargokit/build_tool/lib/src/logging.dart | 49 - cargokit/build_tool/lib/src/options.dart | 306 ------ .../lib/src/precompile_binaries.dart | 202 ---- cargokit/build_tool/lib/src/rustup.dart | 146 --- cargokit/build_tool/lib/src/target.dart | 144 --- cargokit/build_tool/lib/src/util.dart | 169 ---- .../build_tool/lib/src/verify_binaries.dart | 81 -- cargokit/build_tool/pubspec.lock | 453 --------- cargokit/build_tool/pubspec.yaml | 30 - cargokit/build_tool/test/builder_test.dart | 28 - cargokit/build_tool/test/cargo_test.dart | 28 - cargokit/build_tool/test/options_test.dart | 75 -- cargokit/build_tool/test/rustup_test.dart | 66 -- cargokit/cmake/cargokit.cmake | 99 -- cargokit/cmake/resolve_symlinks.ps1 | 34 - cargokit/docs/architecture.md | 104 -- cargokit/docs/precompiled_binaries.md | 95 -- cargokit/gradle/plugin.gradle | 239 ----- cargokit/run_build_tool.cmd | 91 -- cargokit/run_build_tool.sh | 99 -- cmake/cargokit.cmake | 99 -- cmake/resolve_symlinks.ps1 | 34 - docs/architecture.md | 104 -- docs/precompiled_binaries.md | 95 -- example/android/app/build.gradle.kts | 15 +- example/android/gradle.properties | 4 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle.kts | 4 +- example/linux/flutter/generated_plugins.cmake | 2 - example/pubspec.lock | 138 +-- .../windows/flutter/generated_plugins.cmake | 2 - flutter_rust_bridge.yaml | 1 - gradle/plugin.gradle | 239 ----- hook/build.dart | 137 +++ hook/cargo_dependencies.dart | 46 + ios/Classes/dummy_file.c | 1 - ios/Classes/frb_generated.h | 896 ------------------ ios/xelis_flutter.podspec | 45 - lib/src/api/api.dart | 4 +- lib/src/api/logger.dart | 3 +- lib/src/api/models/address_book_dtos.dart | 3 +- lib/src/api/models/wallet_dtos.dart | 6 +- lib/src/api/models/wallet_dtos.freezed.dart | 135 ++- lib/src/api/models/xswd_dtos.dart | 4 +- lib/src/api/models/xswd_dtos.freezed.dart | 79 +- lib/src/api/network.dart | 3 +- lib/src/api/precomputed_tables.dart | 4 +- lib/src/api/precomputed_tables.freezed.dart | 27 +- lib/src/api/progress_report.dart | 4 +- lib/src/api/progress_report.freezed.dart | 30 +- lib/src/api/seed_search_engine.dart | 3 +- lib/src/api/table_generation.dart | 3 +- lib/src/api/utils.dart | 3 +- lib/src/api/wallet.dart | 3 +- lib/src/api/xswd/imp.dart | 3 +- lib/src/frb_generated.dart | 25 +- lib/src/frb_generated.io.dart | 22 +- lib/src/frb_generated.web.dart | 8 +- lib/src/lib.dart | 3 +- linux/CMakeLists.txt | 19 - macos/Classes/dummy_file.c | 1 - macos/xelis_flutter.podspec | 44 - pubspec.lock | 185 ++-- pubspec.yaml | 85 +- run_build_tool.cmd | 91 -- run_build_tool.sh | 99 -- rust/Cargo.lock | 763 +-------------- rust/Cargo.toml | 13 +- rust/rust-toolchain.toml | 28 +- rust/src/frb_generated.rs | 347 ++++--- .../.gradle/8.9/checksums/checksums.lock | Bin 17 -> 0 bytes .../8.9/dependencies-accessors/gc.properties | 0 .../executionHistory/executionHistory.lock | Bin 17 -> 0 bytes .../.gradle/8.9/fileChanges/last-build.bin | Bin 1 -> 0 bytes .../.gradle/8.9/fileHashes/fileHashes.lock | Bin 17 -> 0 bytes .../android/.gradle/8.9/gc.properties | 0 .../buildOutputCleanup.lock | Bin 17 -> 0 bytes .../buildOutputCleanup/cache.properties | 2 - .../android/.gradle/vcs-1/gc.properties | 0 tool/analysis_options.yaml | 3 + tool/generate_bindings.dart | 110 ++- tool/pubspec.yaml | 16 + tool/test/cargo_dependencies_test.dart | 105 ++ windows/.gitignore | 17 - windows/CMakeLists.txt | 20 - 145 files changed, 1163 insertions(+), 10703 deletions(-) create mode 100644 .pubignore delete mode 100644 android/.gitignore delete mode 100644 android/build.gradle delete mode 100644 android/settings.gradle delete mode 100644 android/src/main/AndroidManifest.xml delete mode 100755 build_pod.sh delete mode 100644 build_tool/README.md delete mode 100644 build_tool/analysis_options.yaml delete mode 100644 build_tool/bin/build_tool.dart delete mode 100644 build_tool/lib/build_tool.dart delete mode 100644 build_tool/lib/src/android_environment.dart delete mode 100644 build_tool/lib/src/artifacts_provider.dart delete mode 100644 build_tool/lib/src/build_cmake.dart delete mode 100644 build_tool/lib/src/build_gradle.dart delete mode 100644 build_tool/lib/src/build_pod.dart delete mode 100644 build_tool/lib/src/build_tool.dart delete mode 100644 build_tool/lib/src/builder.dart delete mode 100644 build_tool/lib/src/cargo.dart delete mode 100644 build_tool/lib/src/crate_hash.dart delete mode 100644 build_tool/lib/src/environment.dart delete mode 100644 build_tool/lib/src/logging.dart delete mode 100644 build_tool/lib/src/options.dart delete mode 100644 build_tool/lib/src/precompile_binaries.dart delete mode 100644 build_tool/lib/src/rustup.dart delete mode 100644 build_tool/lib/src/target.dart delete mode 100644 build_tool/lib/src/util.dart delete mode 100644 build_tool/lib/src/verify_binaries.dart delete mode 100644 build_tool/pubspec.lock delete mode 100644 build_tool/pubspec.yaml delete mode 100644 build_tool/test/builder_test.dart delete mode 100644 build_tool/test/cargo_test.dart delete mode 100644 build_tool/test/options_test.dart delete mode 100644 build_tool/test/rustup_test.dart delete mode 100644 cargokit/.github/workflows/check_and_lint.yml delete mode 100644 cargokit/.github/workflows/test_example_plugin_build.yml delete mode 100644 cargokit/.gitignore delete mode 100644 cargokit/LICENSE delete mode 100644 cargokit/README delete mode 100755 cargokit/build_pod.sh delete mode 100644 cargokit/build_tool/README.md delete mode 100644 cargokit/build_tool/analysis_options.yaml delete mode 100644 cargokit/build_tool/bin/build_tool.dart delete mode 100644 cargokit/build_tool/lib/build_tool.dart delete mode 100644 cargokit/build_tool/lib/src/android_environment.dart delete mode 100644 cargokit/build_tool/lib/src/artifacts_provider.dart delete mode 100644 cargokit/build_tool/lib/src/build_cmake.dart delete mode 100644 cargokit/build_tool/lib/src/build_gradle.dart delete mode 100644 cargokit/build_tool/lib/src/build_pod.dart delete mode 100644 cargokit/build_tool/lib/src/build_tool.dart delete mode 100644 cargokit/build_tool/lib/src/builder.dart delete mode 100644 cargokit/build_tool/lib/src/cargo.dart delete mode 100644 cargokit/build_tool/lib/src/crate_hash.dart delete mode 100644 cargokit/build_tool/lib/src/environment.dart delete mode 100644 cargokit/build_tool/lib/src/logging.dart delete mode 100644 cargokit/build_tool/lib/src/options.dart delete mode 100644 cargokit/build_tool/lib/src/precompile_binaries.dart delete mode 100644 cargokit/build_tool/lib/src/rustup.dart delete mode 100644 cargokit/build_tool/lib/src/target.dart delete mode 100644 cargokit/build_tool/lib/src/util.dart delete mode 100644 cargokit/build_tool/lib/src/verify_binaries.dart delete mode 100644 cargokit/build_tool/pubspec.lock delete mode 100644 cargokit/build_tool/pubspec.yaml delete mode 100644 cargokit/build_tool/test/builder_test.dart delete mode 100644 cargokit/build_tool/test/cargo_test.dart delete mode 100644 cargokit/build_tool/test/options_test.dart delete mode 100644 cargokit/build_tool/test/rustup_test.dart delete mode 100644 cargokit/cmake/cargokit.cmake delete mode 100644 cargokit/cmake/resolve_symlinks.ps1 delete mode 100644 cargokit/docs/architecture.md delete mode 100644 cargokit/docs/precompiled_binaries.md delete mode 100644 cargokit/gradle/plugin.gradle delete mode 100644 cargokit/run_build_tool.cmd delete mode 100755 cargokit/run_build_tool.sh delete mode 100644 cmake/cargokit.cmake delete mode 100644 cmake/resolve_symlinks.ps1 delete mode 100644 docs/architecture.md delete mode 100644 docs/precompiled_binaries.md delete mode 100644 gradle/plugin.gradle create mode 100644 hook/build.dart create mode 100644 hook/cargo_dependencies.dart delete mode 100644 ios/Classes/dummy_file.c delete mode 100644 ios/Classes/frb_generated.h delete mode 100644 ios/xelis_flutter.podspec delete mode 100644 linux/CMakeLists.txt delete mode 100644 macos/Classes/dummy_file.c delete mode 100644 macos/xelis_flutter.podspec delete mode 100644 run_build_tool.cmd delete mode 100755 run_build_tool.sh delete mode 100644 rust_builder/android/.gradle/8.9/checksums/checksums.lock delete mode 100644 rust_builder/android/.gradle/8.9/dependencies-accessors/gc.properties delete mode 100644 rust_builder/android/.gradle/8.9/executionHistory/executionHistory.lock delete mode 100644 rust_builder/android/.gradle/8.9/fileChanges/last-build.bin delete mode 100644 rust_builder/android/.gradle/8.9/fileHashes/fileHashes.lock delete mode 100644 rust_builder/android/.gradle/8.9/gc.properties delete mode 100644 rust_builder/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock delete mode 100644 rust_builder/android/.gradle/buildOutputCleanup/cache.properties delete mode 100644 rust_builder/android/.gradle/vcs-1/gc.properties create mode 100644 tool/analysis_options.yaml create mode 100644 tool/pubspec.yaml create mode 100644 tool/test/cargo_dependencies_test.dart delete mode 100644 windows/.gitignore delete mode 100644 windows/CMakeLists.txt diff --git a/.github/workflows/check_and_lint.yml b/.github/workflows/check_and_lint.yml index 714de05..839cd13 100644 --- a/.github/workflows/check_and_lint.yml +++ b/.github/workflows/check_and_lint.yml @@ -6,23 +6,35 @@ on: name: Check and Lint +permissions: + contents: read + jobs: Flutter: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: subosito/flutter-action@v2 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2.23.0 with: channel: "stable" - - name: Pub Get - run: dart pub get --no-precompile - working-directory: build_tool - - name: Dart Format - run: dart format . --output=none --set-exit-if-changed - working-directory: build_tool - - name: Analyze + - name: Pub Get (package) + run: flutter pub get + - name: Pub Get (example) + run: flutter pub get + working-directory: example + - name: Pub Get (tool) + run: dart pub get + working-directory: tool + - name: Dart Format (hook + tool) + run: dart format hook tool --output=none --set-exit-if-changed + - name: Analyze (package) + run: flutter analyze + - name: Analyze (example) + run: flutter analyze + working-directory: example + - name: Analyze (tool) run: dart analyze - working-directory: build_tool - - name: Test - run: flutter test - working-directory: build_tool + working-directory: tool + - name: Test Cargo dependency parser + run: dart test + working-directory: tool diff --git a/.github/workflows/test_example_plugin_build.yml b/.github/workflows/test_example_plugin_build.yml index 59b8215..a6097a6 100644 --- a/.github/workflows/test_example_plugin_build.yml +++ b/.github/workflows/test_example_plugin_build.yml @@ -6,6 +6,9 @@ on: name: Test Example Plugin +permissions: + contents: read + jobs: Build: runs-on: ${{ matrix.os }} @@ -20,23 +23,29 @@ jobs: - debug - release steps: - - uses: actions/checkout@v4 - - uses: subosito/flutter-action@v2 + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2.23.0 with: channel: "stable" - - name: Cache Cargo - uses: actions/cache@v4 + - name: Cache Cargo registry + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 with: path: | ~/.cargo/registry ~/.cargo/git - rust/target key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} restore-keys: | ${{ runner.os }}-cargo- + - name: Cache Rust toolchain + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.rustup/toolchains + ~/.rustup/update-hashes + key: ${{ runner.os }}-rustup-${{ hashFiles('rust/rust-toolchain.toml') }} - name: Install Linux dependencies if: matrix.os == 'ubuntu-latest' - run: sudo apt-get update && sudo apt-get install -y libclang-dev llvm libgtk-3-dev ninja-build cmake + run: sudo apt-get update && sudo apt-get install -y libgtk-3-dev ninja-build cmake - name: Pub Get run: flutter pub get working-directory: example @@ -59,3 +68,38 @@ jobs: - name: Build Android (${{ matrix.build_mode }}) run: flutter build apk --${{ matrix.build_mode }} -v working-directory: example + + # Keeps the advertised minimum Flutter version honest: the package claims + # Flutter 3.47.2+, so build the example with that exact release too. + Build-Minimum-Flutter: + runs-on: macos-latest + steps: + - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0 + - uses: subosito/flutter-action@1a449444c387b1966244ae4d4f8c696479add0b2 # v2.23.0 + with: + flutter-version: "3.47.2" + - name: Cache Cargo registry + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: ${{ runner.os }}-cargo-${{ hashFiles('rust/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + - name: Cache Rust toolchain + uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0 + with: + path: | + ~/.rustup/toolchains + ~/.rustup/update-hashes + key: ${{ runner.os }}-rustup-${{ hashFiles('rust/rust-toolchain.toml') }} + - name: Pub Get + run: flutter pub get + working-directory: example + - name: Build macOS (debug) + run: flutter build macos --debug -v + working-directory: example + - name: Build Android (debug) + run: flutter build apk --debug -v + working-directory: example diff --git a/.gitignore b/.gitignore index 950c423..3208314 100644 --- a/.gitignore +++ b/.gitignore @@ -27,27 +27,14 @@ migrate_working_dir/ **/doc/api/ .dart_tool/ build/ -rust/src/bin -android/src/main/jniLibs/ -rust/default/ -ios/include/ -ios/libs/ -macos/include/ -macos/libs/ lib/git_versions.dart temp/ -scripts/windows/vcpkg/ -scripts/linux/xelis_flutter_bins/ -scripts/ios/xelis_flutter_bins/ -scripts/android/xelis_flutter_bins/ -scripts/windows/xelis_flutter_bins/ -scripts/macos/xelis_flutter_bins/ -scripts/android/cache/ -scripts/android/build/openssl/ - -linux/bin/ +# Rust target -.dart_tool -*.iml -!pubspec.lock \ No newline at end of file +rust/src/bin +rust/default/ + +!pubspec.lock +# The maintainer tool in tool/ is a throwaway package; its lockfile is not tracked. +/tool/pubspec.lock diff --git a/.metadata b/.metadata index 04e8799..8b03ef7 100644 --- a/.metadata +++ b/.metadata @@ -7,7 +7,7 @@ version: revision: "c519ee916eaeb88923e67befb89c0f1dabfa83e6" channel: "stable" -project_type: plugin +project_type: package # Tracks metadata for the flutter migrate command migration: @@ -15,21 +15,6 @@ migration: - platform: root create_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 base_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - - platform: android - create_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - base_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - - platform: ios - create_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - base_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - - platform: linux - create_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - base_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - - platform: macos - create_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - base_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - - platform: windows - create_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 - base_revision: c519ee916eaeb88923e67befb89c0f1dabfa83e6 # User provided section @@ -39,4 +24,3 @@ migration: # Files that are not part of the templates will be ignored by default. unmanaged_files: - 'lib/main.dart' - - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/.pubignore b/.pubignore new file mode 100644 index 0000000..9ee323c --- /dev/null +++ b/.pubignore @@ -0,0 +1,27 @@ +# pub uses this file INSTEAD of .gitignore for this directory, so it repeats +# the relevant .gitignore rules and adds pub-only exclusions. +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ +migrate_working_dir/ +*.iml +*.ipr +*.iws +.idea/ +.vscode/ +**/doc/api/ +.dart_tool/ +build/ +lib/git_versions.dart +temp/ +target +rust/src/bin +rust/default/ +# Maintainer-only Dart package; not part of the published package. +/tool/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 79470c7..a24b78a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# 0.4.0 + +- **Breaking:** the native build moved from Cargokit (podspec / CMake / Gradle FFI plugin) to Flutter native assets: `hook/build.dart` via `flutter_rust_bridge_hooks` and `native_toolchain_rust`. Consumers now need Flutter 3.47.2+ (Dart 3.13+), rustup, and Android NDK r27+ (Windows hosts also need the Visual Studio C++ build tools); nothing else changes on the consumer side (no CocoaPods/CMake/Gradle configuration). +- Removed the `android/`, `ios/`, `macos/`, `linux/`, `windows/`, and `cargokit/` plugin scaffolding; the package is a Dart package with a build hook (`.metadata` now says `package`). +- Bumped `flutter_rust_bridge` to 2.13.0 and regenerated the bindings; bumped `freezed` to 4.0.1 and regenerated the `*.freezed.dart` parts (Dart 3.13 no longer accepts `final` on constructor parameters, which freezed 3 emitted). +- `rust/rust-toolchain.toml` pins Rust 1.91.0 and lists every cross-compilation target; rustup downloads the toolchain (minimal profile) and targets automatically on the first build (roughly 1.9 GB on disk once installed). +- Build behaviour: Rust is always compiled with the release profile (also in Flutter debug builds); artifacts live under the app's `.dart_tool/hooks_runner/`, one Cargo target directory per build configuration (target platform/architecture, debug and release separately), and `flutter clean` removes them (on Windows hosts the Cargo target directory is placed under `%TEMP%\frb_native_assets_` and is not removed by `flutter clean`); the hook re-runs when Rust sources, `Cargo.toml`, `Cargo.lock` or `rust-toolchain.toml` change. +- The hook runs `cargo build --locked`, links the Android library against the app's `minSdk` API level (as Cargokit did), and forces 16 KB page alignment for 64-bit Android ABIs regardless of the NDK version. +- `flutter test` in a dependent app now runs the hook too and installs the host library under `build/native_assets//`; on macOS and Linux host tests that call into Rust need `FRB_DART_LOAD_EXTERNAL_LIBRARY_NATIVE_LIB_DIR=build/native_assets//` (see README), on Windows it is found automatically. +- The bindings regeneration script is its own Dart package under `tool/`: `cd tool && dart run generate_bindings.dart` (maintainers need `rustup component add rustfmt --toolchain 1.91.0`, since the toolchain now uses the minimal profile). It reads the codegen version from the `flutter_rust_bridge` pin in `pubspec.yaml`; the unused `[build-dependencies]` entry for `flutter_rust_bridge_codegen` was removed from `rust/Cargo.toml`. +- `native_toolchain_rust`, which spawns rustup/cargo on consumer machines, is pinned exactly (1.0.6); the shared `hooks` protocol package stays a range (`^2.1.0`) so apps can combine this package with other native-assets packages. +- Removed the unused `path_provider`, `ffi`, and `plugin_platform_interface` dependencies. Apps that used one of them only through this package must now depend on it directly. + # 0.2.0 - Unified API with Genesix reference bindings post-hard-fork diff --git a/README.md b/README.md index d274303..f8213ef 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,70 @@ - - -## NEEDS UPDATING - # Xelis Wallet FFI Bindings for Flutter -This repo is setup to be a shoe-in library in flutter applications, allowing easy access to the native Rust wallet methods from `xelis-blockchain` without the need for any rewrites. This is enabled by the `flutter_rust_bridge_codegen` tool, as well as the automated build & dependency conventions used within this repository. +This repo is set up to be a drop-in library for Flutter applications, allowing easy access to the native Rust wallet methods from `xelis-blockchain` without the need for any rewrites. This is enabled by the `flutter_rust_bridge_codegen` tool, as well as the automated build & dependency conventions used within this repository. The continued adoption of Genesix features and dev QOL needs for apps are the primary points of focus for this library, helping to facilitate Xelis integration and adoption for the community. ## Compatibility -![Rust](https://img.shields.io/badge/rust-1.91%2B-orange.svg) -![Xelis Dart SDK](https://img.shields.io/badge/xelis__dart__sdk-0.30.9%2B-blue.svg) +![Flutter](https://img.shields.io/badge/flutter-3.47.2%2B-blue.svg) +![Rust](https://img.shields.io/badge/rust-1.91.0-orange.svg) ## Getting started -To make use of `xelis-flutter-ffi`, simply add a git dependency to your flutter app's `pubspec.yaml`, like this: + +### Requirements + +Every machine that builds an app depending on this package needs: + +- **Flutter 3.47.2 or newer** (Dart 3.13+). The Rust crate is compiled and bundled by Flutter native assets (build hooks). +- **[rustup](https://rustup.rs).** The first build downloads the pinned toolchain (Rust 1.91.0, minimal profile) and every cross-compilation target listed in `rust/rust-toolchain.toml`; installed, that is roughly 1.9 GB on disk, about 1.4 GB of it for the cross-compilation targets. The list covers all platforms Flutter can target so that a single checkout builds everywhere. + Cargo must be able to find `rustc`: with a standard rustup install (`~/.cargo/bin` on `PATH`) nothing needs to be done; with Homebrew's rustup add `$(brew --prefix rustup)/bin` to `PATH`, otherwise the build fails with `could not execute process rustc -vV`. + Builds started from Xcode (Product > Run / Archive) do not see your shell's `PATH`; they get the system one from `/etc/paths`. Homebrew puts only `rustup` itself in `/opt/homebrew/bin` and keeps the `cargo`/`rustc` proxies in its keg, which is on no `PATH`, so the build fails there even though it works in a terminal. Link the proxies into `/usr/local/bin` (always on the system `PATH`) once: + + ```bash + sudo mkdir -p /usr/local/bin && sudo ln -s "$(brew --prefix rustup)"/bin/* /usr/local/bin/ + ``` +- **Windows hosts:** Visual Studio Build Tools with the "Desktop development with C++" workload. The Rust `*-pc-windows-msvc` host toolchain needs its `link.exe`, also for Android-only builds. +- **Android only:** NDK r27 or newer (the NDK Flutter installs by default satisfies this). The library is linked against your app's `minSdk` API level and, for 64-bit ABIs, with 16 KB page alignment regardless of the NDK version. + +### Adding the dependency + +Add a git dependency to your Flutter app's `pubspec.yaml`: ```yaml xelis_flutter: git: url: https://github.com/xelis-project/xelis-flutter-ffi.git - ref: v0.1.0 # release tags will be attributed to specific xelis-blockchain releases going forward + ref: v0.4.0 # use a release tag; releases track specific xelis-blockchain versions ``` -When either `flutter run` or `flutter build` are called, this library will handle all dependency building and/or Podspec operations for you, without the need for any extra setup. +When `flutter run`, `flutter build`, or `flutter test` is invoked, Flutter runs this package's `hook/build.dart`, which compiles the Rust crate for the target platform with Cargo and bundles the resulting library into the app. No CocoaPods, CMake, or Gradle configuration is required on your side. + +### Build behaviour worth knowing + +- The Rust crate is always compiled with Cargo's release profile, also for Flutter debug builds (build hooks have no notion of the Flutter build mode). The first build of each target architecture takes several minutes; later builds are incremental and the hook only re-runs when Rust sources, `Cargo.toml`, `Cargo.lock`, or `rust-toolchain.toml` change. +- Build artifacts live under the app's `.dart_tool/hooks_runner/`, one Cargo target directory per build configuration (target platform and architecture, and debug and release builds separately), so the first release build after debug builds compiles the crate again. `flutter clean` deletes them all, so the next build starts from scratch. On Windows hosts, `flutter_rust_bridge_hooks` keeps paths short by placing the Cargo target directory under `%TEMP%\frb_native_assets_` instead; `flutter clean` does not remove those, delete them manually to reclaim disk space. +- The hook runs `cargo build --locked`: a `Cargo.toml` change without a matching `Cargo.lock` update fails the build instead of silently re-resolving dependencies. +- Build hooks run with a filtered environment. Flutter passes through `PATH`, `HOME`, `TMPDIR`/`TEMP`, `ANDROID_HOME`, `ANDROID_NDK*`, and a few OS variables, but not `RUSTUP_HOME`, `CARGO_HOME`, `RUSTFLAGS`, or `CARGO_*`. Non-default rustup/cargo locations configured through those variables are therefore not seen by the build, and the toolchain is installed under `~/.rustup`. +- `flutter test` also runs the hook and installs the host library under `build/native_assets//`. On Windows that directory is on `PATH` during the test run, so the bindings load it. On macOS and Linux the bindings look the library up by name and will not find it there; point them at it: `FRB_DART_LOAD_EXTERNAL_LIBRARY_NATIVE_LIB_DIR=build/native_assets/macos/ flutter test` (use `linux/` on Linux). Tests that never touch Rust are unaffected apart from the hook's compile time. -The FFI bindings are updated and included in the repo; there is no need to regenerate them on your end unless you modify the files in `rust/`. +## Regenerating the bindings -To regenerate bindings after changing the Rust API, make sure LLVM/Clang is installed and run: +The FFI bindings are committed; there is no need to regenerate them unless you modify the files in `rust/`. Regeneration needs LLVM/Clang (libclang) and `cargo` on `PATH`, plus `rustfmt` for the pinned toolchain, which the minimal profile in `rust/rust-toolchain.toml` does not install: ```bash -dart run tool/generate_bindings.dart +rustup component add rustfmt --toolchain 1.91.0 ``` -The script detects LLVM through `llvm-config`. If it is installed in a custom location, set `LLVM_PATH` or pass the path directly to `flutter_rust_bridge_codegen` with `--llvm-path`. +Without it the generator still succeeds but writes an unformatted `rust/src/frb_generated.rs`, which shows up as a large spurious diff. + +```bash +cd tool +dart run generate_bindings.dart +``` + +The script locates the package root (the parent of `tool/`), installs the `flutter_rust_bridge_codegen` version matching the `flutter_rust_bridge` pin in `pubspec.yaml` (built with `cargo install --locked`) into the package root's `.dart_tool/frb_bin` on first use, then regenerates the package's `lib/src/` and `rust/src/frb_generated.rs`. It is a separate Dart package on purpose: running it does not trigger this package's build hook, so it keeps working when a Rust API change has made the previously generated `frb_generated.rs` uncompilable. + +The script detects LLVM through `llvm-config`. If LLVM is installed in a custom location, set `LLVM_PATH` or pass the path directly to `flutter_rust_bridge_codegen` with `--llvm-path`. + ## Usage In your app's `main` entry point, be sure to initialize the RustLib. This will enable the use of imported bindings anywhere in your app. @@ -60,6 +81,7 @@ Here is an example of using the api crate through FFI to create a Xelis Wallet i ```dart import 'package:xelis_flutter/src/api/wallet.dart' as x_wallet; import 'package:xelis_flutter/src/api/network.dart' as x_network; +import 'package:xelis_flutter/src/api/precomputed_tables.dart' as x_tables; Future createXelisWallet() async { final String name = "example-wallet"; @@ -72,7 +94,8 @@ Future createXelisWallet() async { password: password, network: x_network.Network.mainnet, precomputedTablesPath: directory, // precomputed tables will be written to this location - l1Low: true, // will generate lightweight precomputed tables, use false for full-sized tables + // lightweight precomputed tables; see PrecomputedTableType for the other variants + precomputedTableType: const x_tables.PrecomputedTableType.l1Low(), ); final mnemonic = await wallet.getSeed(); diff --git a/analysis_options.yaml b/analysis_options.yaml index 534f26d..ad5cf72 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,12 +1,8 @@ analyzer: exclude: - build/** - - android/** - - ios/** - - web/** - - windows/** - - macos/** - - linux/** + # Separate Dart package (maintainer script); analyzed on its own in CI. + - tool/** include: package:flutter_lints/flutter.yaml # Additional information about this file can be found at diff --git a/android/.gitignore b/android/.gitignore deleted file mode 100644 index 161bdcd..0000000 --- a/android/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -*.iml -.gradle -/local.properties -/.idea/workspace.xml -/.idea/libraries -.DS_Store -/build -/captures -.cxx diff --git a/android/build.gradle b/android/build.gradle deleted file mode 100644 index 0f08302..0000000 --- a/android/build.gradle +++ /dev/null @@ -1,56 +0,0 @@ -// The Android Gradle Plugin builds the native code with the Android NDK. - -group 'com.flutter_rust_bridge.xelis_flutter' -version '1.0' - -buildscript { - repositories { - google() - mavenCentral() - } - - dependencies { - // The Android Gradle Plugin knows how to build native code with the NDK. - classpath 'com.android.tools.build:gradle:7.3.0' - } -} - -rootProject.allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: 'com.android.library' - -android { - if (project.android.hasProperty("namespace")) { - namespace 'com.flutter_rust_bridge.xelis_flutter' - } - - // Bumping the plugin compileSdkVersion requires all clients of this plugin - // to bump the version in their app. - compileSdkVersion 33 - - // Use the NDK version - // declared in /android/app/build.gradle file of the Flutter project. - // Replace it with a version number if this plugin requires a specfic NDK version. - // (e.g. ndkVersion "23.1.7779620") - ndkVersion android.ndkVersion - - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - defaultConfig { - minSdkVersion 19 - } -} - -apply from: "../cargokit/gradle/plugin.gradle" -cargokit { - manifestDir = "../rust" - libname = "xelis_flutter" -} diff --git a/android/settings.gradle b/android/settings.gradle deleted file mode 100644 index 1c98a8b..0000000 --- a/android/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'xelis_flutter' diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml deleted file mode 100644 index 489df87..0000000 --- a/android/src/main/AndroidManifest.xml +++ /dev/null @@ -1,3 +0,0 @@ - - diff --git a/build_pod.sh b/build_pod.sh deleted file mode 100755 index ed0e0d9..0000000 --- a/build_pod.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -set -e - -BASEDIR=$(dirname "$0") - -# Workaround for https://github.com/dart-lang/pub/issues/4010 -BASEDIR=$(cd "$BASEDIR" ; pwd -P) - -# Remove XCode SDK from path. Otherwise this breaks tool compilation when building iOS project -NEW_PATH=`echo $PATH | tr ":" "\n" | grep -v "Contents/Developer/" | tr "\n" ":"` - -export PATH=${NEW_PATH%?} # remove trailing : - -env - -# Platform name (macosx, iphoneos, iphonesimulator) -export CARGOKIT_DARWIN_PLATFORM_NAME=$PLATFORM_NAME - -# Arctive architectures (arm64, armv7, x86_64), space separated. -export CARGOKIT_DARWIN_ARCHS=$ARCHS - -# Current build configuration (Debug, Release) -export CARGOKIT_CONFIGURATION=$CONFIGURATION - -# Path to directory containing Cargo.toml. -export CARGOKIT_MANIFEST_DIR=$PODS_TARGET_SRCROOT/$1 - -# Temporary directory for build artifacts. -export CARGOKIT_TARGET_TEMP_DIR=$TARGET_TEMP_DIR - -# Output directory for final artifacts. -export CARGOKIT_OUTPUT_DIR=$PODS_CONFIGURATION_BUILD_DIR/$PRODUCT_NAME - -# Directory to store built tool artifacts. -export CARGOKIT_TOOL_TEMP_DIR=$TARGET_TEMP_DIR/build_tool - -# Directory inside root project. Not necessarily the top level directory of root project. -export CARGOKIT_ROOT_PROJECT_DIR=$SRCROOT - -FLUTTER_EXPORT_BUILD_ENVIRONMENT=( - "$PODS_ROOT/../Flutter/ephemeral/flutter_export_environment.sh" # macOS - "$PODS_ROOT/../Flutter/flutter_export_environment.sh" # iOS -) - -for path in "${FLUTTER_EXPORT_BUILD_ENVIRONMENT[@]}" -do - if [[ -f "$path" ]]; then - source "$path" - fi -done - -sh "$BASEDIR/run_build_tool.sh" build-pod "$@" - -# Make a symlink from built framework to phony file, which will be used as input to -# build script. This should force rebuild (podspec currently doesn't support alwaysOutOfDate -# attribute on custom build phase) -ln -fs "$OBJROOT/XCBuildData/build.db" "${BUILT_PRODUCTS_DIR}/cargokit_phony" -ln -fs "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" "${BUILT_PRODUCTS_DIR}/cargokit_phony_out" diff --git a/build_tool/README.md b/build_tool/README.md deleted file mode 100644 index 3816eca..0000000 --- a/build_tool/README.md +++ /dev/null @@ -1,2 +0,0 @@ -A sample command-line application with an entrypoint in `bin/`, library code -in `lib/`, and example unit test in `test/`. diff --git a/build_tool/analysis_options.yaml b/build_tool/analysis_options.yaml deleted file mode 100644 index a1aad5b..0000000 --- a/build_tool/analysis_options.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -linter: - rules: - - prefer_relative_imports - - directives_ordering - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/build_tool/bin/build_tool.dart b/build_tool/bin/build_tool.dart deleted file mode 100644 index f27ec75..0000000 --- a/build_tool/bin/build_tool.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:build_tool/build_tool.dart' as build_tool; - -void main(List arguments) { - build_tool.runMain(arguments); -} diff --git a/build_tool/lib/build_tool.dart b/build_tool/lib/build_tool.dart deleted file mode 100644 index b329c01..0000000 --- a/build_tool/lib/build_tool.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'src/build_tool.dart' as build_tool; - -Future runMain(List args) async { - return build_tool.runMain(args); -} diff --git a/build_tool/lib/src/android_environment.dart b/build_tool/lib/src/android_environment.dart deleted file mode 100644 index 9342964..0000000 --- a/build_tool/lib/src/android_environment.dart +++ /dev/null @@ -1,192 +0,0 @@ -import 'dart:io'; -import 'dart:isolate'; -import 'dart:math' as math; - -import 'package:collection/collection.dart'; -import 'package:path/path.dart' as path; -import 'package:version/version.dart'; - -import 'target.dart'; -import 'util.dart'; - -class AndroidEnvironment { - AndroidEnvironment({ - required this.sdkPath, - required this.ndkVersion, - required this.minSdkVersion, - required this.targetTempDir, - required this.target, - }); - - static void clangLinkerWrapper(List args) { - final clang = Platform.environment['_CARGOKIT_NDK_LINK_CLANG']; - if (clang == null) { - throw Exception( - "cargo-ndk rustc linker: didn't find _CARGOKIT_NDK_LINK_CLANG env var"); - } - final target = Platform.environment['_CARGOKIT_NDK_LINK_TARGET']; - if (target == null) { - throw Exception( - "cargo-ndk rustc linker: didn't find _CARGOKIT_NDK_LINK_TARGET env var"); - } - - runCommand(clang, [ - target, - ...args, - ]); - } - - /// Full path to Android SDK. - final String sdkPath; - - /// Full version of Android NDK. - final String ndkVersion; - - /// Minimum supported SDK version. - final int minSdkVersion; - - /// Target directory for build artifacts. - final String targetTempDir; - - /// Target being built. - final Target target; - - bool ndkIsInstalled() { - final ndkPath = path.join(sdkPath, 'ndk', ndkVersion); - final ndkPackageXml = File(path.join(ndkPath, 'package.xml')); - return ndkPackageXml.existsSync(); - } - - void installNdk({ - required String javaHome, - }) { - final sdkManagerExtension = Platform.isWindows ? '.bat' : ''; - final sdkManager = path.join( - sdkPath, - 'cmdline-tools', - 'latest', - 'bin', - 'sdkmanager$sdkManagerExtension', - ); - - log.info('Installing NDK $ndkVersion'); - runCommand(sdkManager, [ - '--install', - 'ndk;$ndkVersion', - ], environment: { - 'JAVA_HOME': javaHome, - }); - } - - Future> buildEnvironment() async { - final hostArch = Platform.isMacOS - ? "darwin-x86_64" - : (Platform.isLinux ? "linux-x86_64" : "windows-x86_64"); - - final ndkPath = path.join(sdkPath, 'ndk', ndkVersion); - final toolchainPath = path.join( - ndkPath, - 'toolchains', - 'llvm', - 'prebuilt', - hostArch, - 'bin', - ); - - final minSdkVersion = - math.max(target.androidMinSdkVersion!, this.minSdkVersion); - - final exe = Platform.isWindows ? '.exe' : ''; - - final arKey = 'AR_${target.rust}'; - final arValue = ['${target.rust}-ar', 'llvm-ar', 'llvm-ar.exe'] - .map((e) => path.join(toolchainPath, e)) - .firstWhereOrNull((element) => File(element).existsSync()); - if (arValue == null) { - throw Exception('Failed to find ar for $target in $toolchainPath'); - } - - final targetArg = '--target=${target.rust}$minSdkVersion'; - - final ccKey = 'CC_${target.rust}'; - final ccValue = path.join(toolchainPath, 'clang$exe'); - final cfFlagsKey = 'CFLAGS_${target.rust}'; - final cFlagsValue = targetArg; - - final cxxKey = 'CXX_${target.rust}'; - final cxxValue = path.join(toolchainPath, 'clang++$exe'); - final cxxFlagsKey = 'CXXFLAGS_${target.rust}'; - final cxxFlagsValue = targetArg; - - final linkerKey = - 'cargo_target_${target.rust.replaceAll('-', '_')}_linker'.toUpperCase(); - - final ranlibKey = 'RANLIB_${target.rust}'; - final ranlibValue = path.join(toolchainPath, 'llvm-ranlib$exe'); - - final ndkVersionParsed = Version.parse(ndkVersion); - final rustFlagsKey = 'CARGO_ENCODED_RUSTFLAGS'; - final rustFlagsValue = _libGccWorkaround(targetTempDir, ndkVersionParsed); - - final runRustTool = - Platform.isWindows ? 'run_build_tool.cmd' : 'run_build_tool.sh'; - - final packagePath = (await Isolate.resolvePackageUri( - Uri.parse('package:build_tool/buildtool.dart')))! - .toFilePath(); - final selfPath = path.canonicalize(path.join( - packagePath, - '..', - '..', - '..', - runRustTool, - )); - - // Make sure that run_build_tool is working properly even initially launched directly - // through dart run. - final toolTempDir = - Platform.environment['CARGOKIT_TOOL_TEMP_DIR'] ?? targetTempDir; - - return { - arKey: arValue, - ccKey: ccValue, - cfFlagsKey: cFlagsValue, - cxxKey: cxxValue, - cxxFlagsKey: cxxFlagsValue, - ranlibKey: ranlibValue, - rustFlagsKey: rustFlagsValue, - linkerKey: selfPath, - // Recognized by main() so we know when we're acting as a wrapper - '_CARGOKIT_NDK_LINK_TARGET': targetArg, - '_CARGOKIT_NDK_LINK_CLANG': ccValue, - 'CARGOKIT_TOOL_TEMP_DIR': toolTempDir, - }; - } - - // Workaround for libgcc missing in NDK23, inspired by cargo-ndk - String _libGccWorkaround(String buildDir, Version ndkVersion) { - final workaroundDir = path.join( - buildDir, - 'cargokit', - 'libgcc_workaround', - '${ndkVersion.major}', - ); - Directory(workaroundDir).createSync(recursive: true); - if (ndkVersion.major >= 23) { - File(path.join(workaroundDir, 'libgcc.a')) - .writeAsStringSync('INPUT(-lunwind)'); - } else { - // Other way around, untested, forward libgcc.a from libunwind once Rust - // gets updated for NDK23+. - File(path.join(workaroundDir, 'libunwind.a')) - .writeAsStringSync('INPUT(-lgcc)'); - } - - var rustFlags = Platform.environment['CARGO_ENCODED_RUSTFLAGS'] ?? ''; - if (rustFlags.isNotEmpty) { - rustFlags = '$rustFlags\x1f'; - } - rustFlags = '$rustFlags-L\x1f$workaroundDir'; - return rustFlags; - } -} diff --git a/build_tool/lib/src/artifacts_provider.dart b/build_tool/lib/src/artifacts_provider.dart deleted file mode 100644 index ef655a9..0000000 --- a/build_tool/lib/src/artifacts_provider.dart +++ /dev/null @@ -1,263 +0,0 @@ -import 'dart:io'; - -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:http/http.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'builder.dart'; -import 'crate_hash.dart'; -import 'options.dart'; -import 'precompile_binaries.dart'; -import 'rustup.dart'; -import 'target.dart'; - -class Artifact { - /// File system location of the artifact. - final String path; - - /// Actual file name that the artifact should have in destination folder. - final String finalFileName; - - AritifactType get type { - if (finalFileName.endsWith('.dll') || - finalFileName.endsWith('.dll.lib') || - finalFileName.endsWith('.pdb') || - finalFileName.endsWith('.so') || - finalFileName.endsWith('.dylib')) { - return AritifactType.dylib; - } else if (finalFileName.endsWith('.lib') || finalFileName.endsWith('.a')) { - return AritifactType.staticlib; - } else { - throw Exception('Unknown artifact type for $finalFileName'); - } - } - - Artifact({ - required this.path, - required this.finalFileName, - }); -} - -final _log = Logger('artifacts_provider'); - -class ArtifactProvider { - ArtifactProvider({ - required this.environment, - required this.userOptions, - }); - - final BuildEnvironment environment; - final CargokitUserOptions userOptions; - - Future>> getArtifacts(List targets) async { - final result = await _getPrecompiledArtifacts(targets); - - final pendingTargets = List.of(targets); - pendingTargets.removeWhere((element) => result.containsKey(element)); - - if (pendingTargets.isEmpty) { - return result; - } - - final rustup = Rustup(); - for (final target in targets) { - final builder = RustBuilder(target: target, environment: environment); - builder.prepare(rustup); - _log.info('Building ${environment.crateInfo.packageName} for $target'); - final targetDir = await builder.build(); - // For local build accept both static and dynamic libraries. - final artifactNames = { - ...getArtifactNames( - target: target, - libraryName: environment.crateInfo.packageName, - aritifactType: AritifactType.dylib, - remote: false, - ), - ...getArtifactNames( - target: target, - libraryName: environment.crateInfo.packageName, - aritifactType: AritifactType.staticlib, - remote: false, - ) - }; - final artifacts = artifactNames - .map((artifactName) => Artifact( - path: path.join(targetDir, artifactName), - finalFileName: artifactName, - )) - .where((element) => File(element.path).existsSync()) - .toList(); - result[target] = artifacts; - } - return result; - } - - Future>> _getPrecompiledArtifacts( - List targets) async { - if (userOptions.usePrecompiledBinaries == false) { - _log.info('Precompiled binaries are disabled'); - return {}; - } - if (environment.crateOptions.precompiledBinaries == null) { - _log.fine('Precompiled binaries not enabled for this crate'); - return {}; - } - - final start = Stopwatch()..start(); - final crateHash = CrateHash.compute(environment.manifestDir, - tempStorage: environment.targetTempDir); - _log.fine( - 'Computed crate hash $crateHash in ${start.elapsedMilliseconds}ms'); - - final downloadedArtifactsDir = - path.join(environment.targetTempDir, 'precompiled', crateHash); - Directory(downloadedArtifactsDir).createSync(recursive: true); - - final res = >{}; - - for (final target in targets) { - final requiredArtifacts = getArtifactNames( - target: target, - libraryName: environment.crateInfo.packageName, - remote: true, - ); - final artifactsForTarget = []; - - for (final artifact in requiredArtifacts) { - final fileName = PrecompileBinaries.fileName(target, artifact); - final downloadedPath = path.join(downloadedArtifactsDir, fileName); - if (!File(downloadedPath).existsSync()) { - final signatureFileName = - PrecompileBinaries.signatureFileName(target, artifact); - await _tryDownloadArtifacts( - crateHash: crateHash, - fileName: fileName, - signatureFileName: signatureFileName, - finalPath: downloadedPath, - ); - } - if (File(downloadedPath).existsSync()) { - artifactsForTarget.add(Artifact( - path: downloadedPath, - finalFileName: artifact, - )); - } else { - break; - } - } - - // Only provide complete set of artifacts. - if (artifactsForTarget.length == requiredArtifacts.length) { - _log.fine('Found precompiled artifacts for $target'); - res[target] = artifactsForTarget; - } - } - - return res; - } - - static Future _get(Uri url, {Map? headers}) async { - int attempt = 0; - const maxAttempts = 10; - while (true) { - try { - return await get(url, headers: headers); - } on SocketException catch (e) { - // Try to detect reset by peer error and retry. - if (attempt++ < maxAttempts && - (e.osError?.errorCode == 54 || e.osError?.errorCode == 10054)) { - _log.severe( - 'Failed to download $url: $e, attempt $attempt of $maxAttempts, will retry...'); - await Future.delayed(Duration(seconds: 1)); - continue; - } else { - rethrow; - } - } - } - } - - Future _tryDownloadArtifacts({ - required String crateHash, - required String fileName, - required String signatureFileName, - required String finalPath, - }) async { - final precompiledBinaries = environment.crateOptions.precompiledBinaries!; - final prefix = precompiledBinaries.uriPrefix; - final url = Uri.parse('$prefix$crateHash/$fileName'); - final signatureUrl = Uri.parse('$prefix$crateHash/$signatureFileName'); - _log.fine('Downloading signature from $signatureUrl'); - final signature = await _get(signatureUrl); - if (signature.statusCode == 404) { - _log.warning( - 'Precompiled binaries not available for crate hash $crateHash ($fileName)'); - return; - } - if (signature.statusCode != 200) { - _log.severe( - 'Failed to download signature $signatureUrl: status ${signature.statusCode}'); - return; - } - _log.fine('Downloading binary from $url'); - final res = await _get(url); - if (res.statusCode != 200) { - _log.severe('Failed to download binary $url: status ${res.statusCode}'); - return; - } - if (verify( - precompiledBinaries.publicKey, res.bodyBytes, signature.bodyBytes)) { - File(finalPath).writeAsBytesSync(res.bodyBytes); - } else { - _log.shout('Signature verification failed! Ignoring binary.'); - } - } -} - -enum AritifactType { - staticlib, - dylib, -} - -AritifactType artifactTypeForTarget(Target target) { - if (target.darwinPlatform != null) { - return AritifactType.staticlib; - } else { - return AritifactType.dylib; - } -} - -List getArtifactNames({ - required Target target, - required String libraryName, - required bool remote, - AritifactType? aritifactType, -}) { - aritifactType ??= artifactTypeForTarget(target); - if (target.darwinArch != null) { - if (aritifactType == AritifactType.staticlib) { - return ['lib$libraryName.a']; - } else { - return ['lib$libraryName.dylib']; - } - } else if (target.rust.contains('-windows-')) { - if (aritifactType == AritifactType.staticlib) { - return ['$libraryName.lib']; - } else { - return [ - '$libraryName.dll', - '$libraryName.dll.lib', - if (!remote) '$libraryName.pdb' - ]; - } - } else if (target.rust.contains('-linux-')) { - if (aritifactType == AritifactType.staticlib) { - return ['lib$libraryName.a']; - } else { - return ['lib$libraryName.so']; - } - } else { - throw Exception("Unsupported target: ${target.rust}"); - } -} diff --git a/build_tool/lib/src/build_cmake.dart b/build_tool/lib/src/build_cmake.dart deleted file mode 100644 index 9154371..0000000 --- a/build_tool/lib/src/build_cmake.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'dart:io'; - -import 'package:path/path.dart' as path; - -import 'artifacts_provider.dart'; -import 'builder.dart'; -import 'environment.dart'; -import 'options.dart'; -import 'target.dart'; - -class BuildCMake { - final CargokitUserOptions userOptions; - - BuildCMake({required this.userOptions}); - - Future build() async { - final targetPlatform = Environment.targetPlatform; - final target = Target.forFlutterName(Environment.targetPlatform); - if (target == null) { - throw Exception("Unknown target platform: $targetPlatform"); - } - - final environment = BuildEnvironment.fromEnvironment(isAndroid: false); - final provider = - ArtifactProvider(environment: environment, userOptions: userOptions); - final artifacts = await provider.getArtifacts([target]); - - final libs = artifacts[target]!; - - for (final lib in libs) { - if (lib.type == AritifactType.dylib) { - File(lib.path) - .copySync(path.join(Environment.outputDir, lib.finalFileName)); - } - } - } -} diff --git a/build_tool/lib/src/build_gradle.dart b/build_tool/lib/src/build_gradle.dart deleted file mode 100644 index 469c8b2..0000000 --- a/build_tool/lib/src/build_gradle.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'dart:io'; - -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'artifacts_provider.dart'; -import 'builder.dart'; -import 'environment.dart'; -import 'options.dart'; -import 'target.dart'; - -final log = Logger('build_gradle'); - -class BuildGradle { - BuildGradle({required this.userOptions}); - - final CargokitUserOptions userOptions; - - Future build() async { - final targets = Environment.targetPlatforms.map((arch) { - final target = Target.forFlutterName(arch); - if (target == null) { - throw Exception( - "Unknown darwin target or platform: $arch, ${Environment.darwinPlatformName}"); - } - return target; - }).toList(); - - final environment = BuildEnvironment.fromEnvironment(isAndroid: true); - final provider = - ArtifactProvider(environment: environment, userOptions: userOptions); - final artifacts = await provider.getArtifacts(targets); - - for (final target in targets) { - final libs = artifacts[target]!; - final outputDir = path.join(Environment.outputDir, target.android!); - Directory(outputDir).createSync(recursive: true); - - for (final lib in libs) { - if (lib.type == AritifactType.dylib) { - File(lib.path).copySync(path.join(outputDir, lib.finalFileName)); - } - } - } - } -} diff --git a/build_tool/lib/src/build_pod.dart b/build_tool/lib/src/build_pod.dart deleted file mode 100644 index f01401e..0000000 --- a/build_tool/lib/src/build_pod.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'dart:io'; - -import 'package:path/path.dart' as path; - -import 'artifacts_provider.dart'; -import 'builder.dart'; -import 'environment.dart'; -import 'options.dart'; -import 'target.dart'; -import 'util.dart'; - -class BuildPod { - BuildPod({required this.userOptions}); - - final CargokitUserOptions userOptions; - - Future build() async { - final targets = Environment.darwinArchs.map((arch) { - final target = Target.forDarwin( - platformName: Environment.darwinPlatformName, darwinAarch: arch); - if (target == null) { - throw Exception( - "Unknown darwin target or platform: $arch, ${Environment.darwinPlatformName}"); - } - return target; - }).toList(); - - final environment = BuildEnvironment.fromEnvironment(isAndroid: false); - final provider = - ArtifactProvider(environment: environment, userOptions: userOptions); - final artifacts = await provider.getArtifacts(targets); - - void performLipo(String targetFile, Iterable sourceFiles) { - runCommand("lipo", [ - '-create', - ...sourceFiles, - '-output', - targetFile, - ]); - } - - final outputDir = Environment.outputDir; - - Directory(outputDir).createSync(recursive: true); - - final staticLibs = artifacts.values - .expand((element) => element) - .where((element) => element.type == AritifactType.staticlib) - .toList(); - final dynamicLibs = artifacts.values - .expand((element) => element) - .where((element) => element.type == AritifactType.dylib) - .toList(); - - final libName = environment.crateInfo.packageName; - - // If there is static lib, use it and link it with pod - if (staticLibs.isNotEmpty) { - final finalTargetFile = path.join(outputDir, "lib$libName.a"); - performLipo(finalTargetFile, staticLibs.map((e) => e.path)); - } else { - // Otherwise try to replace bundle dylib with our dylib - final bundlePaths = [ - '$libName.framework/Versions/A/$libName', - '$libName.framework/$libName', - ]; - - for (final bundlePath in bundlePaths) { - final targetFile = path.join(outputDir, bundlePath); - if (File(targetFile).existsSync()) { - performLipo(targetFile, dynamicLibs.map((e) => e.path)); - - // Replace absolute id with @rpath one so that it works properly - // when moved to Frameworks. - runCommand("install_name_tool", [ - '-id', - '@rpath/$bundlePath', - targetFile, - ]); - return; - } - } - throw Exception('Unable to find bundle for dynamic library'); - } - } -} diff --git a/build_tool/lib/src/build_tool.dart b/build_tool/lib/src/build_tool.dart deleted file mode 100644 index 6415f23..0000000 --- a/build_tool/lib/src/build_tool.dart +++ /dev/null @@ -1,273 +0,0 @@ -import 'dart:io'; - -import 'package:args/command_runner.dart'; -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:github/github.dart'; -import 'package:hex/hex.dart'; -import 'package:logging/logging.dart'; - -import 'android_environment.dart'; -import 'build_cmake.dart'; -import 'build_gradle.dart'; -import 'build_pod.dart'; -import 'logging.dart'; -import 'options.dart'; -import 'precompile_binaries.dart'; -import 'target.dart'; -import 'util.dart'; -import 'verify_binaries.dart'; - -final log = Logger('build_tool'); - -abstract class BuildCommand extends Command { - Future runBuildCommand(CargokitUserOptions options); - - @override - Future run() async { - final options = CargokitUserOptions.load(); - - if (options.verboseLogging || - Platform.environment['CARGOKIT_VERBOSE'] == '1') { - enableVerboseLogging(); - } - - await runBuildCommand(options); - } -} - -class BuildPodCommand extends BuildCommand { - @override - final name = 'build-pod'; - - @override - final description = 'Build cocoa pod library'; - - @override - Future runBuildCommand(CargokitUserOptions options) async { - final build = BuildPod(userOptions: options); - await build.build(); - } -} - -class BuildGradleCommand extends BuildCommand { - @override - final name = 'build-gradle'; - - @override - final description = 'Build android library'; - - @override - Future runBuildCommand(CargokitUserOptions options) async { - final build = BuildGradle(userOptions: options); - await build.build(); - } -} - -class BuildCMakeCommand extends BuildCommand { - @override - final name = 'build-cmake'; - - @override - final description = 'Build CMake library'; - - @override - Future runBuildCommand(CargokitUserOptions options) async { - final build = BuildCMake(userOptions: options); - await build.build(); - } -} - -class GenKeyCommand extends Command { - @override - final name = 'gen-key'; - - @override - final description = 'Generate key pair for signing precompiled binaries'; - - @override - void run() { - final kp = generateKey(); - final private = HEX.encode(kp.privateKey.bytes); - final public = HEX.encode(kp.publicKey.bytes); - print("Private Key: $private"); - print("Public Key: $public"); - } -} - -class PrecompileBinariesCommand extends Command { - PrecompileBinariesCommand() { - argParser - ..addOption( - 'repository', - mandatory: true, - help: 'Github repository slug in format owner/name', - ) - ..addOption( - 'manifest-dir', - mandatory: true, - help: 'Directory containing Cargo.toml', - ) - ..addMultiOption('target', - help: 'Rust target triple of artifact to build.\n' - 'Can be specified multiple times or omitted in which case\n' - 'all targets for current platform will be built.') - ..addOption( - 'android-sdk-location', - help: 'Location of Android SDK (if available)', - ) - ..addOption( - 'android-ndk-version', - help: 'Android NDK version (if available)', - ) - ..addOption( - 'android-min-sdk-version', - help: 'Android minimum rquired version (if available)', - ) - ..addOption( - 'temp-dir', - help: 'Directory to store temporary build artifacts', - ) - ..addOption( - 'glibc-version', - help: 'GLIBC version to use for linux builds', - ) - ..addFlag( - "verbose", - abbr: "v", - defaultsTo: false, - help: "Enable verbose logging", - ); - } - - @override - final name = 'precompile-binaries'; - - @override - final description = 'Prebuild and upload binaries\n' - 'Private key must be passed through PRIVATE_KEY environment variable. ' - 'Use gen_key through generate priave key.\n' - 'Github token must be passed as GITHUB_TOKEN environment variable.\n'; - - @override - Future run() async { - final verbose = argResults!['verbose'] as bool; - if (verbose) { - enableVerboseLogging(); - } - - final privateKeyString = Platform.environment['PRIVATE_KEY']; - if (privateKeyString == null) { - throw ArgumentError('Missing PRIVATE_KEY environment variable'); - } - final githubToken = Platform.environment['GITHUB_TOKEN']; - if (githubToken == null) { - throw ArgumentError('Missing GITHUB_TOKEN environment variable'); - } - final privateKey = HEX.decode(privateKeyString); - if (privateKey.length != 64) { - throw ArgumentError('Private key must be 64 bytes long'); - } - final manifestDir = argResults!['manifest-dir'] as String; - if (!Directory(manifestDir).existsSync()) { - throw ArgumentError('Manifest directory does not exist: $manifestDir'); - } - String? androidMinSdkVersionString = - argResults!['android-min-sdk-version'] as String?; - int? androidMinSdkVersion; - if (androidMinSdkVersionString != null) { - androidMinSdkVersion = int.tryParse(androidMinSdkVersionString); - if (androidMinSdkVersion == null) { - throw ArgumentError( - 'Invalid android-min-sdk-version: $androidMinSdkVersionString'); - } - } - final targetStrigns = argResults!['target'] as List; - final targets = targetStrigns.map((target) { - final res = Target.forRustTriple(target); - if (res == null) { - throw ArgumentError('Invalid target: $target'); - } - return res; - }).toList(growable: false); - final precompileBinaries = PrecompileBinaries( - privateKey: PrivateKey(privateKey), - githubToken: githubToken, - manifestDir: manifestDir, - repositorySlug: RepositorySlug.full(argResults!['repository'] as String), - targets: targets, - androidSdkLocation: argResults!['android-sdk-location'] as String?, - androidNdkVersion: argResults!['android-ndk-version'] as String?, - androidMinSdkVersion: androidMinSdkVersion, - tempDir: argResults!['temp-dir'] as String?, - glibcVersion: argResults!['glibc-version'] as String?, - ); - - await precompileBinaries.run(); - } -} - -class VerifyBinariesCommand extends Command { - VerifyBinariesCommand() { - argParser.addOption( - 'manifest-dir', - mandatory: true, - help: 'Directory containing Cargo.toml', - ); - } - - @override - final name = "verify-binaries"; - - @override - final description = 'Verifies published binaries\n' - 'Checks whether there is a binary published for each targets\n' - 'and checks the signature.'; - - @override - Future run() async { - final manifestDir = argResults!['manifest-dir'] as String; - final verifyBinaries = VerifyBinaries( - manifestDir: manifestDir, - ); - await verifyBinaries.run(); - } -} - -Future runMain(List args) async { - try { - // Init logging before options are loaded - initLogging(); - - if (Platform.environment['_CARGOKIT_NDK_LINK_TARGET'] != null) { - return AndroidEnvironment.clangLinkerWrapper(args); - } - - final runner = CommandRunner('build_tool', 'Cargokit built_tool') - ..addCommand(BuildPodCommand()) - ..addCommand(BuildGradleCommand()) - ..addCommand(BuildCMakeCommand()) - ..addCommand(GenKeyCommand()) - ..addCommand(PrecompileBinariesCommand()) - ..addCommand(VerifyBinariesCommand()); - - await runner.run(args); - } on ArgumentError catch (e) { - stderr.writeln(e.toString()); - exit(1); - } catch (e, s) { - log.severe(kDoubleSeparator); - log.severe('Cargokit BuildTool failed with error:'); - log.severe(kSeparator); - log.severe(e); - // This tells user to install Rust, there's no need to pollute the log with - // stack trace. - if (e is! RustupNotFoundException) { - log.severe(kSeparator); - log.severe(s); - log.severe(kSeparator); - log.severe('BuildTool arguments: $args'); - } - log.severe(kDoubleSeparator); - exit(1); - } -} diff --git a/build_tool/lib/src/builder.dart b/build_tool/lib/src/builder.dart deleted file mode 100644 index 894a9ec..0000000 --- a/build_tool/lib/src/builder.dart +++ /dev/null @@ -1,206 +0,0 @@ -import 'package:collection/collection.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'android_environment.dart'; -import 'cargo.dart'; -import 'environment.dart'; -import 'options.dart'; -import 'rustup.dart'; -import 'target.dart'; -import 'util.dart'; - -final _log = Logger('builder'); - -enum BuildConfiguration { - debug, - release, - profile, -} - -extension on BuildConfiguration { - bool get isDebug => this == BuildConfiguration.debug; - String get rustName => switch (this) { - BuildConfiguration.debug => 'debug', - BuildConfiguration.release => 'release', - BuildConfiguration.profile => 'release', - }; -} - -class BuildException implements Exception { - final String message; - - BuildException(this.message); - - @override - String toString() { - return 'BuildException: $message'; - } -} - -class BuildEnvironment { - final BuildConfiguration configuration; - final CargokitCrateOptions crateOptions; - final String targetTempDir; - final String manifestDir; - final CrateInfo crateInfo; - - final bool isAndroid; - final String? androidSdkPath; - final String? androidNdkVersion; - final int? androidMinSdkVersion; - final String? javaHome; - - final String? glibcVersion; - - BuildEnvironment({ - required this.configuration, - required this.crateOptions, - required this.targetTempDir, - required this.manifestDir, - required this.crateInfo, - required this.isAndroid, - this.androidSdkPath, - this.androidNdkVersion, - this.androidMinSdkVersion, - this.javaHome, - this.glibcVersion, - }); - - static BuildConfiguration parseBuildConfiguration(String value) { - // XCode configuration adds the flavor to configuration name. - final firstSegment = value.split('-').first; - final buildConfiguration = BuildConfiguration.values.firstWhereOrNull( - (e) => e.name == firstSegment, - ); - if (buildConfiguration == null) { - _log.warning('Unknown build configuraiton $value, will assume release'); - return BuildConfiguration.release; - } - return buildConfiguration; - } - - static BuildEnvironment fromEnvironment({ - required bool isAndroid, - }) { - final buildConfiguration = - parseBuildConfiguration(Environment.configuration); - final manifestDir = Environment.manifestDir; - final crateOptions = CargokitCrateOptions.load( - manifestDir: manifestDir, - ); - final crateInfo = CrateInfo.load(manifestDir); - return BuildEnvironment( - configuration: buildConfiguration, - crateOptions: crateOptions, - targetTempDir: Environment.targetTempDir, - manifestDir: manifestDir, - crateInfo: crateInfo, - isAndroid: isAndroid, - androidSdkPath: isAndroid ? Environment.sdkPath : null, - androidNdkVersion: isAndroid ? Environment.ndkVersion : null, - androidMinSdkVersion: - isAndroid ? int.parse(Environment.minSdkVersion) : null, - javaHome: isAndroid ? Environment.javaHome : null, - ); - } -} - -class RustBuilder { - final Target target; - final BuildEnvironment environment; - - RustBuilder({ - required this.target, - required this.environment, - }); - - void prepare( - Rustup rustup, - ) { - final toolchain = _toolchain; - if (rustup.installedTargets(toolchain) == null) { - rustup.installToolchain(toolchain); - } - if (toolchain == 'nightly') { - rustup.installRustSrcForNightly(); - } - if (!rustup.installedTargets(toolchain)!.contains(target.rust)) { - rustup.installTarget(target.rust, toolchain: toolchain); - } - if (environment.glibcVersion != null) { - rustup.installZigBuild(toolchain); - } - } - - CargoBuildOptions? get _buildOptions => - environment.crateOptions.cargo[environment.configuration]; - - String get _toolchain => _buildOptions?.toolchain.name ?? 'stable'; - - /// Returns the path of directory containing build artifacts. - Future build() async { - final extraArgs = _buildOptions?.flags ?? []; - final manifestPath = path.join(environment.manifestDir, 'Cargo.toml'); - runCommand( - 'rustup', - [ - 'run', - _toolchain, - 'cargo', - (target.android == null && environment.glibcVersion != null) - ? 'zigbuild' - : 'build', - ...extraArgs, - '--manifest-path', - manifestPath, - '-p', - environment.crateInfo.packageName, - if (!environment.configuration.isDebug) '--release', - '--target', - target.rust + - ((target.android == null && environment.glibcVersion != null) - ? '.${environment.glibcVersion!}' - : ""), - '--target-dir', - environment.targetTempDir, - ], - environment: await _buildEnvironment(), - ); - return path.join( - environment.targetTempDir, - target.rust, - environment.configuration.rustName, - ); - } - - Future> _buildEnvironment() async { - if (target.android == null) { - return {}; - } else { - final sdkPath = environment.androidSdkPath; - final ndkVersion = environment.androidNdkVersion; - final minSdkVersion = environment.androidMinSdkVersion; - if (sdkPath == null) { - throw BuildException('androidSdkPath is not set'); - } - if (ndkVersion == null) { - throw BuildException('androidNdkVersion is not set'); - } - if (minSdkVersion == null) { - throw BuildException('androidMinSdkVersion is not set'); - } - final env = AndroidEnvironment( - sdkPath: sdkPath, - ndkVersion: ndkVersion, - minSdkVersion: minSdkVersion, - targetTempDir: environment.targetTempDir, - target: target, - ); - if (!env.ndkIsInstalled() && environment.javaHome != null) { - env.installNdk(javaHome: environment.javaHome!); - } - return env.buildEnvironment(); - } - } -} diff --git a/build_tool/lib/src/cargo.dart b/build_tool/lib/src/cargo.dart deleted file mode 100644 index 0d4483f..0000000 --- a/build_tool/lib/src/cargo.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'dart:io'; - -import 'package:path/path.dart' as path; -import 'package:toml/toml.dart'; - -class ManifestException { - ManifestException(this.message, {required this.fileName}); - - final String? fileName; - final String message; - - @override - String toString() { - if (fileName != null) { - return 'Failed to parse package manifest at $fileName: $message'; - } else { - return 'Failed to parse package manifest: $message'; - } - } -} - -class CrateInfo { - CrateInfo({required this.packageName}); - - final String packageName; - - static CrateInfo parseManifest(String manifest, {final String? fileName}) { - final toml = TomlDocument.parse(manifest); - final package = toml.toMap()['package']; - if (package == null) { - throw ManifestException('Missing package section', fileName: fileName); - } - final name = package['name']; - if (name == null) { - throw ManifestException('Missing package name', fileName: fileName); - } - return CrateInfo(packageName: name); - } - - static CrateInfo load(String manifestDir) { - final manifestFile = File(path.join(manifestDir, 'Cargo.toml')); - final manifest = manifestFile.readAsStringSync(); - return parseManifest(manifest, fileName: manifestFile.path); - } -} diff --git a/build_tool/lib/src/crate_hash.dart b/build_tool/lib/src/crate_hash.dart deleted file mode 100644 index e58c37f..0000000 --- a/build_tool/lib/src/crate_hash.dart +++ /dev/null @@ -1,121 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:collection/collection.dart'; -import 'package:convert/convert.dart'; -import 'package:crypto/crypto.dart'; -import 'package:path/path.dart' as path; - -class CrateHash { - /// Computes a hash uniquely identifying crate content. This takes into account - /// content all all .rs files inside the src directory, as well as Cargo.toml, - /// Cargo.lock, build.rs and cargokit.yaml. - /// - /// If [tempStorage] is provided, computed hash is stored in a file in that directory - /// and reused on subsequent calls if the crate content hasn't changed. - static String compute(String manifestDir, {String? tempStorage}) { - return CrateHash._( - manifestDir: manifestDir, - tempStorage: tempStorage, - )._compute(); - } - - CrateHash._({ - required this.manifestDir, - required this.tempStorage, - }); - - String _compute() { - final files = getFiles(); - final tempStorage = this.tempStorage; - if (tempStorage != null) { - final quickHash = _computeQuickHash(files); - final quickHashFolder = Directory(path.join(tempStorage, 'crate_hash')); - quickHashFolder.createSync(recursive: true); - final quickHashFile = File(path.join(quickHashFolder.path, quickHash)); - if (quickHashFile.existsSync()) { - return quickHashFile.readAsStringSync(); - } - final hash = _computeHash(files); - quickHashFile.writeAsStringSync(hash); - return hash; - } else { - return _computeHash(files); - } - } - - /// Computes a quick hash based on files stat (without reading contents). This - /// is used to cache the real hash, which is slower to compute since it involves - /// reading every single file. - String _computeQuickHash(List files) { - final output = AccumulatorSink(); - final input = sha256.startChunkedConversion(output); - - final data = ByteData(8); - for (final file in files) { - input.add(utf8.encode(file.path)); - final stat = file.statSync(); - data.setUint64(0, stat.size); - input.add(data.buffer.asUint8List()); - data.setUint64(0, stat.modified.millisecondsSinceEpoch); - input.add(data.buffer.asUint8List()); - } - - input.close(); - return base64Url.encode(output.events.single.bytes); - } - - String _computeHash(List files) { - final output = AccumulatorSink(); - final input = sha256.startChunkedConversion(output); - - void addTextFile(File file) { - // text Files are hashed by lines in case we're dealing with github checkout - // that auto-converts line endings. - final splitter = LineSplitter(); - if (file.existsSync()) { - final data = file.readAsStringSync(); - final lines = splitter.convert(data); - for (final line in lines) { - input.add(utf8.encode(line)); - } - } - } - - for (final file in files) { - addTextFile(file); - } - - input.close(); - final res = output.events.single; - - // Truncate to 128bits. - final hash = res.bytes.sublist(0, 16); - return hex.encode(hash); - } - - List getFiles() { - final src = Directory(path.join(manifestDir, 'src')); - final files = src - .listSync(recursive: true, followLinks: false) - .whereType() - .toList(); - files.sortBy((element) => element.path); - void addFile(String relative) { - final file = File(path.join(manifestDir, relative)); - if (file.existsSync()) { - files.add(file); - } - } - - addFile('Cargo.toml'); - addFile('Cargo.lock'); - addFile('build.rs'); - addFile('cargokit.yaml'); - return files; - } - - final String manifestDir; - final String? tempStorage; -} diff --git a/build_tool/lib/src/environment.dart b/build_tool/lib/src/environment.dart deleted file mode 100644 index 1d267ed..0000000 --- a/build_tool/lib/src/environment.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'dart:io'; - -extension on String { - String resolveSymlink() => File(this).resolveSymbolicLinksSync(); -} - -class Environment { - /// Current build configuration (debug or release). - static String get configuration => - _getEnv("CARGOKIT_CONFIGURATION").toLowerCase(); - - static bool get isDebug => configuration == 'debug'; - static bool get isRelease => configuration == 'release'; - - /// Temporary directory where Rust build artifacts are placed. - static String get targetTempDir => _getEnv("CARGOKIT_TARGET_TEMP_DIR"); - - /// Final output directory where the build artifacts are placed. - static String get outputDir => _getEnvPath('CARGOKIT_OUTPUT_DIR'); - - /// Path to the crate manifest (containing Cargo.toml). - static String get manifestDir => _getEnvPath('CARGOKIT_MANIFEST_DIR'); - - /// Directory inside root project. Not necessarily root folder. Symlinks are - /// not resolved on purpose. - static String get rootProjectDir => _getEnv('CARGOKIT_ROOT_PROJECT_DIR'); - - // Pod - - /// Platform name (macosx, iphoneos, iphonesimulator). - static String get darwinPlatformName => - _getEnv("CARGOKIT_DARWIN_PLATFORM_NAME"); - - /// List of architectures to build for (arm64, armv7, x86_64). - static List get darwinArchs => - _getEnv("CARGOKIT_DARWIN_ARCHS").split(' '); - - // Gradle - static String get minSdkVersion => _getEnv("CARGOKIT_MIN_SDK_VERSION"); - static String get ndkVersion => _getEnv("CARGOKIT_NDK_VERSION"); - static String get sdkPath => _getEnvPath("CARGOKIT_SDK_DIR"); - static String get javaHome => _getEnvPath("CARGOKIT_JAVA_HOME"); - static List get targetPlatforms => - _getEnv("CARGOKIT_TARGET_PLATFORMS").split(','); - - // CMAKE - static String get targetPlatform => _getEnv("CARGOKIT_TARGET_PLATFORM"); - - static String _getEnv(String key) { - final res = Platform.environment[key]; - if (res == null) { - throw Exception("Missing environment variable $key"); - } - return res; - } - - static String _getEnvPath(String key) { - final res = _getEnv(key); - if (Directory(res).existsSync()) { - return res.resolveSymlink(); - } else { - return res; - } - } -} diff --git a/build_tool/lib/src/logging.dart b/build_tool/lib/src/logging.dart deleted file mode 100644 index 06392b9..0000000 --- a/build_tool/lib/src/logging.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'dart:io'; - -import 'package:logging/logging.dart'; - -const String kSeparator = "--"; -const String kDoubleSeparator = "=="; - -bool _lastMessageWasSeparator = false; - -void _log(LogRecord rec) { - final prefix = '${rec.level.name}: '; - final out = rec.level == Level.SEVERE ? stderr : stdout; - if (rec.message == kSeparator) { - if (!_lastMessageWasSeparator) { - out.write(prefix); - out.writeln('-' * 80); - _lastMessageWasSeparator = true; - } - return; - } else if (rec.message == kDoubleSeparator) { - out.write(prefix); - out.writeln('=' * 80); - _lastMessageWasSeparator = true; - return; - } - out.write(prefix); - out.writeln(rec.message); - _lastMessageWasSeparator = false; -} - -void initLogging() { - Logger.root.level = Level.INFO; - Logger.root.onRecord.listen((LogRecord rec) { - final lines = rec.message.split('\n'); - for (final line in lines) { - if (line.isNotEmpty || lines.length == 1 || line != lines.last) { - _log(LogRecord( - rec.level, - line, - rec.loggerName, - )); - } - } - }); -} - -void enableVerboseLogging() { - Logger.root.level = Level.ALL; -} diff --git a/build_tool/lib/src/options.dart b/build_tool/lib/src/options.dart deleted file mode 100644 index 7937dca..0000000 --- a/build_tool/lib/src/options.dart +++ /dev/null @@ -1,306 +0,0 @@ -import 'dart:io'; - -import 'package:collection/collection.dart'; -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:hex/hex.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; -import 'package:source_span/source_span.dart'; -import 'package:yaml/yaml.dart'; - -import 'builder.dart'; -import 'environment.dart'; -import 'rustup.dart'; - -final _log = Logger('options'); - -/// A class for exceptions that have source span information attached. -class SourceSpanException implements Exception { - // This is a getter so that subclasses can override it. - /// A message describing the exception. - String get message => _message; - final String _message; - - // This is a getter so that subclasses can override it. - /// The span associated with this exception. - /// - /// This may be `null` if the source location can't be determined. - SourceSpan? get span => _span; - final SourceSpan? _span; - - SourceSpanException(this._message, this._span); - - /// Returns a string representation of `this`. - /// - /// [color] may either be a [String], a [bool], or `null`. If it's a string, - /// it indicates an ANSI terminal color escape that should be used to - /// highlight the span's text. If it's `true`, it indicates that the text - /// should be highlighted using the default color. If it's `false` or `null`, - /// it indicates that the text shouldn't be highlighted. - @override - String toString({Object? color}) { - if (span == null) return message; - return 'Error on ${span!.message(message, color: color)}'; - } -} - -enum Toolchain { - stable, - beta, - nightly, -} - -class CargoBuildOptions { - final Toolchain toolchain; - final List flags; - - CargoBuildOptions({ - required this.toolchain, - required this.flags, - }); - - static Toolchain _toolchainFromNode(YamlNode node) { - if (node case YamlScalar(value: String name)) { - final toolchain = - Toolchain.values.firstWhereOrNull((element) => element.name == name); - if (toolchain != null) { - return toolchain; - } - } - throw SourceSpanException( - 'Unknown toolchain. Must be one of ${Toolchain.values.map((e) => e.name)}.', - node.span); - } - - static CargoBuildOptions parse(YamlNode node) { - if (node is! YamlMap) { - throw SourceSpanException('Cargo options must be a map', node.span); - } - Toolchain toolchain = Toolchain.stable; - List flags = []; - for (final MapEntry(:key, :value) in node.nodes.entries) { - if (key case YamlScalar(value: 'toolchain')) { - toolchain = _toolchainFromNode(value); - } else if (key case YamlScalar(value: 'extra_flags')) { - if (value case YamlList(nodes: List list)) { - if (list.every((element) { - if (element case YamlScalar(value: String _)) { - return true; - } - return false; - })) { - flags = list.map((e) => e.value as String).toList(); - continue; - } - } - throw SourceSpanException( - 'Extra flags must be a list of strings', value.span); - } else { - throw SourceSpanException( - 'Unknown cargo option type. Must be "toolchain" or "extra_flags".', - key.span); - } - } - return CargoBuildOptions(toolchain: toolchain, flags: flags); - } -} - -extension on YamlMap { - /// Map that extracts keys so that we can do map case check on them. - Map get valueMap => - nodes.map((key, value) => MapEntry(key.value, value)); -} - -class PrecompiledBinaries { - final String uriPrefix; - final PublicKey publicKey; - - PrecompiledBinaries({ - required this.uriPrefix, - required this.publicKey, - }); - - static PublicKey _publicKeyFromHex(String key, SourceSpan? span) { - final bytes = HEX.decode(key); - if (bytes.length != 32) { - throw SourceSpanException( - 'Invalid public key. Must be 32 bytes long.', span); - } - return PublicKey(bytes); - } - - static PrecompiledBinaries parse(YamlNode node) { - if (node case YamlMap(valueMap: Map map)) { - if (map - case { - 'url_prefix': YamlNode urlPrefixNode, - 'public_key': YamlNode publicKeyNode, - }) { - final urlPrefix = switch (urlPrefixNode) { - YamlScalar(value: String urlPrefix) => urlPrefix, - _ => throw SourceSpanException( - 'Invalid URL prefix value.', urlPrefixNode.span), - }; - final publicKey = switch (publicKeyNode) { - YamlScalar(value: String publicKey) => - _publicKeyFromHex(publicKey, publicKeyNode.span), - _ => throw SourceSpanException( - 'Invalid public key value.', publicKeyNode.span), - }; - return PrecompiledBinaries( - uriPrefix: urlPrefix, - publicKey: publicKey, - ); - } - } - throw SourceSpanException( - 'Invalid precompiled binaries value. ' - 'Expected Map with "url_prefix" and "public_key".', - node.span); - } -} - -/// Cargokit options specified for Rust crate. -class CargokitCrateOptions { - CargokitCrateOptions({ - this.cargo = const {}, - this.precompiledBinaries, - }); - - final Map cargo; - final PrecompiledBinaries? precompiledBinaries; - - static CargokitCrateOptions parse(YamlNode node) { - if (node is! YamlMap) { - throw SourceSpanException('Cargokit options must be a map', node.span); - } - final options = {}; - PrecompiledBinaries? precompiledBinaries; - - for (final entry in node.nodes.entries) { - if (entry - case MapEntry( - key: YamlScalar(value: 'cargo'), - value: YamlNode node, - )) { - if (node is! YamlMap) { - throw SourceSpanException('Cargo options must be a map', node.span); - } - for (final MapEntry(:YamlNode key, :value) in node.nodes.entries) { - if (key case YamlScalar(value: String name)) { - final configuration = BuildConfiguration.values - .firstWhereOrNull((element) => element.name == name); - if (configuration != null) { - options[configuration] = CargoBuildOptions.parse(value); - continue; - } - } - throw SourceSpanException( - 'Unknown build configuration. Must be one of ${BuildConfiguration.values.map((e) => e.name)}.', - key.span); - } - } else if (entry.key case YamlScalar(value: 'precompiled_binaries')) { - precompiledBinaries = PrecompiledBinaries.parse(entry.value); - } else { - throw SourceSpanException( - 'Unknown cargokit option type. Must be "cargo" or "precompiled_binaries".', - entry.key.span); - } - } - return CargokitCrateOptions( - cargo: options, - precompiledBinaries: precompiledBinaries, - ); - } - - static CargokitCrateOptions load({ - required String manifestDir, - }) { - final uri = Uri.file(path.join(manifestDir, "cargokit.yaml")); - final file = File.fromUri(uri); - if (file.existsSync()) { - final contents = loadYamlNode(file.readAsStringSync(), sourceUrl: uri); - return parse(contents); - } else { - return CargokitCrateOptions(); - } - } -} - -class CargokitUserOptions { - // When Rustup is installed always build locally unless user opts into - // using precompiled binaries. - static bool defaultUsePrecompiledBinaries() { - return Rustup.executablePath() == null; - } - - CargokitUserOptions({ - required this.usePrecompiledBinaries, - required this.verboseLogging, - }); - - CargokitUserOptions._() - : usePrecompiledBinaries = defaultUsePrecompiledBinaries(), - verboseLogging = false; - - static CargokitUserOptions parse(YamlNode node) { - if (node is! YamlMap) { - throw SourceSpanException('Cargokit options must be a map', node.span); - } - bool usePrecompiledBinaries = defaultUsePrecompiledBinaries(); - bool verboseLogging = false; - - for (final entry in node.nodes.entries) { - if (entry.key case YamlScalar(value: 'use_precompiled_binaries')) { - if (entry.value case YamlScalar(value: bool value)) { - usePrecompiledBinaries = value; - continue; - } - throw SourceSpanException( - 'Invalid value for "use_precompiled_binaries". Must be a boolean.', - entry.value.span); - } else if (entry.key case YamlScalar(value: 'verbose_logging')) { - if (entry.value case YamlScalar(value: bool value)) { - verboseLogging = value; - continue; - } - throw SourceSpanException( - 'Invalid value for "verbose_logging". Must be a boolean.', - entry.value.span); - } else { - throw SourceSpanException( - 'Unknown cargokit option type. Must be "use_precompiled_binaries" or "verbose_logging".', - entry.key.span); - } - } - return CargokitUserOptions( - usePrecompiledBinaries: usePrecompiledBinaries, - verboseLogging: verboseLogging, - ); - } - - static CargokitUserOptions load() { - String fileName = "cargokit_options.yaml"; - var userProjectDir = Directory(Environment.rootProjectDir); - - while (userProjectDir.parent.path != userProjectDir.path) { - final configFile = File(path.join(userProjectDir.path, fileName)); - if (configFile.existsSync()) { - final contents = loadYamlNode( - configFile.readAsStringSync(), - sourceUrl: configFile.uri, - ); - final res = parse(contents); - if (res.verboseLogging) { - _log.info('Found user options file at ${configFile.path}'); - } - return res; - } - userProjectDir = userProjectDir.parent; - } - return CargokitUserOptions._(); - } - - final bool usePrecompiledBinaries; - final bool verboseLogging; -} diff --git a/build_tool/lib/src/precompile_binaries.dart b/build_tool/lib/src/precompile_binaries.dart deleted file mode 100644 index 201874b..0000000 --- a/build_tool/lib/src/precompile_binaries.dart +++ /dev/null @@ -1,202 +0,0 @@ -import 'dart:io'; - -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:github/github.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'artifacts_provider.dart'; -import 'builder.dart'; -import 'cargo.dart'; -import 'crate_hash.dart'; -import 'options.dart'; -import 'rustup.dart'; -import 'target.dart'; - -final _log = Logger('precompile_binaries'); - -class PrecompileBinaries { - PrecompileBinaries({ - required this.privateKey, - required this.githubToken, - required this.repositorySlug, - required this.manifestDir, - required this.targets, - this.androidSdkLocation, - this.androidNdkVersion, - this.androidMinSdkVersion, - this.tempDir, - this.glibcVersion, - }); - - final PrivateKey privateKey; - final String githubToken; - final RepositorySlug repositorySlug; - final String manifestDir; - final List targets; - final String? androidSdkLocation; - final String? androidNdkVersion; - final int? androidMinSdkVersion; - final String? tempDir; - final String? glibcVersion; - - static String fileName(Target target, String name) { - return '${target.rust}_$name'; - } - - static String signatureFileName(Target target, String name) { - return '${target.rust}_$name.sig'; - } - - Future run() async { - final crateInfo = CrateInfo.load(manifestDir); - - final targets = List.of(this.targets); - if (targets.isEmpty) { - targets.addAll([ - ...Target.buildableTargets(), - if (androidSdkLocation != null) ...Target.androidTargets(), - ]); - } - - _log.info('Precompiling binaries for $targets'); - - final hash = CrateHash.compute(manifestDir); - _log.info('Computed crate hash: $hash'); - - final String tagName = 'precompiled_$hash'; - - final github = GitHub(auth: Authentication.withToken(githubToken)); - final repo = github.repositories; - final release = await _getOrCreateRelease( - repo: repo, - tagName: tagName, - packageName: crateInfo.packageName, - hash: hash, - ); - - final tempDir = this.tempDir != null - ? Directory(this.tempDir!) - : Directory.systemTemp.createTempSync('precompiled_'); - - tempDir.createSync(recursive: true); - - final crateOptions = CargokitCrateOptions.load( - manifestDir: manifestDir, - ); - - final buildEnvironment = BuildEnvironment( - configuration: BuildConfiguration.release, - crateOptions: crateOptions, - targetTempDir: tempDir.path, - manifestDir: manifestDir, - crateInfo: crateInfo, - isAndroid: androidSdkLocation != null, - androidSdkPath: androidSdkLocation, - androidNdkVersion: androidNdkVersion, - androidMinSdkVersion: androidMinSdkVersion, - glibcVersion: glibcVersion, - ); - - final rustup = Rustup(); - - for (final target in targets) { - final artifactNames = getArtifactNames( - target: target, - libraryName: crateInfo.packageName, - remote: true, - ); - - if (artifactNames.every((name) { - final fileName = PrecompileBinaries.fileName(target, name); - return (release.assets ?? []).any((e) => e.name == fileName); - })) { - _log.info("All artifacts for $target already exist - skipping"); - continue; - } - - _log.info('Building for $target'); - - final builder = - RustBuilder(target: target, environment: buildEnvironment); - builder.prepare(rustup); - final res = await builder.build(); - - final assets = []; - for (final name in artifactNames) { - final file = File(path.join(res, name)); - if (!file.existsSync()) { - throw Exception('Missing artifact: ${file.path}'); - } - - final data = file.readAsBytesSync(); - final create = CreateReleaseAsset( - name: PrecompileBinaries.fileName(target, name), - contentType: "application/octet-stream", - assetData: data, - ); - final signature = sign(privateKey, data); - final signatureCreate = CreateReleaseAsset( - name: signatureFileName(target, name), - contentType: "application/octet-stream", - assetData: signature, - ); - bool verified = verify(public(privateKey), data, signature); - if (!verified) { - throw Exception('Signature verification failed'); - } - assets.add(create); - assets.add(signatureCreate); - } - _log.info('Uploading assets: ${assets.map((e) => e.name)}'); - for (final asset in assets) { - // This seems to be failing on CI so do it one by one - int retryCount = 0; - while (true) { - try { - await repo.uploadReleaseAssets(release, [asset]); - break; - } on Exception catch (e) { - if (retryCount == 10) { - rethrow; - } - ++retryCount; - _log.shout( - 'Upload failed (attempt $retryCount, will retry): ${e.toString()}'); - await Future.delayed(Duration(seconds: 2)); - } - } - } - } - - _log.info('Cleaning up'); - tempDir.deleteSync(recursive: true); - } - - Future _getOrCreateRelease({ - required RepositoriesService repo, - required String tagName, - required String packageName, - required String hash, - }) async { - Release release; - try { - _log.info('Fetching release $tagName'); - release = await repo.getReleaseByTagName(repositorySlug, tagName); - } on ReleaseNotFound { - _log.info('Release not found - creating release $tagName'); - release = await repo.createRelease( - repositorySlug, - CreateRelease.from( - tagName: tagName, - name: 'Precompiled binaries ${hash.substring(0, 8)}', - targetCommitish: null, - isDraft: false, - isPrerelease: false, - body: 'Precompiled binaries for crate $packageName, ' - 'crate hash $hash.', - )); - } - return release; - } -} diff --git a/build_tool/lib/src/rustup.dart b/build_tool/lib/src/rustup.dart deleted file mode 100644 index 715b6d0..0000000 --- a/build_tool/lib/src/rustup.dart +++ /dev/null @@ -1,146 +0,0 @@ -import 'dart:io'; - -import 'package:collection/collection.dart'; -import 'package:path/path.dart' as path; - -import 'util.dart'; - -class _Toolchain { - _Toolchain( - this.name, - this.targets, - ); - - final String name; - final List targets; -} - -class Rustup { - List? installedTargets(String toolchain) { - final targets = _installedTargets(toolchain); - return targets != null ? List.unmodifiable(targets) : null; - } - - void installToolchain(String toolchain) { - log.info("Installing Rust toolchain: $toolchain"); - runCommand("rustup", ['toolchain', 'install', toolchain]); - _installedToolchains - .add(_Toolchain(toolchain, _getInstalledTargets(toolchain))); - } - - void installTarget( - String target, { - required String toolchain, - }) { - log.info("Installing Rust target: $target"); - runCommand("rustup", ['target', 'add', '--toolchain', toolchain, target]); - _installedTargets(toolchain)?.add(target); - } - - bool _didInstallZigBuild = false; - - void installZigBuild(String toolchain) { - if (_didInstallZigBuild) { - return; - } - - log.info("Installing Zig build"); - runCommand("rustup", [ - 'run', - toolchain, - 'cargo', - 'install', - '--locked', - 'cargo-zigbuild', - ]); - _didInstallZigBuild = true; - } - - final List<_Toolchain> _installedToolchains; - - Rustup() : _installedToolchains = _getInstalledToolchains(); - - List? _installedTargets(String toolchain) => _installedToolchains - .firstWhereOrNull( - (e) => e.name == toolchain || e.name.startsWith('$toolchain-')) - ?.targets; - - static List<_Toolchain> _getInstalledToolchains() { - String extractToolchainName(String line) { - // ignore (default) after toolchain name - final parts = line.split(' '); - return parts[0]; - } - - final res = runCommand("rustup", ['toolchain', 'list']); - - // To list all non-custom toolchains, we need to filter out lines that - // don't start with "stable", "beta", or "nightly". - Pattern nonCustom = RegExp(r"^(stable|beta|nightly)"); - final lines = res.stdout - .toString() - .split('\n') - .where((e) => e.isNotEmpty && e.startsWith(nonCustom)) - .map(extractToolchainName) - .toList(growable: true); - - return lines - .map( - (name) => _Toolchain( - name, - _getInstalledTargets(name), - ), - ) - .toList(growable: true); - } - - static List _getInstalledTargets(String toolchain) { - final res = runCommand("rustup", [ - 'target', - 'list', - '--toolchain', - toolchain, - '--installed', - ]); - final lines = res.stdout - .toString() - .split('\n') - .where((e) => e.isNotEmpty) - .toList(growable: true); - return lines; - } - - bool _didInstallRustSrcForNightly = false; - - void installRustSrcForNightly() { - if (_didInstallRustSrcForNightly) { - return; - } - // Useful for -Z build-std - runCommand( - "rustup", - ['component', 'add', 'rust-src', '--toolchain', 'nightly'], - ); - _didInstallRustSrcForNightly = true; - } - - static String? executablePath() { - final envPath = Platform.environment['PATH']; - final envPathSeparator = Platform.isWindows ? ';' : ':'; - final home = Platform.isWindows - ? Platform.environment['USERPROFILE'] - : Platform.environment['HOME']; - final paths = [ - if (home != null) path.join(home, '.cargo', 'bin'), - if (envPath != null) ...envPath.split(envPathSeparator), - ]; - for (final p in paths) { - final rustup = Platform.isWindows ? 'rustup.exe' : 'rustup'; - final rustupPath = path.join(p, rustup); - if (File(rustupPath).existsSync()) { - return rustupPath; - } - } - return null; - } -} diff --git a/build_tool/lib/src/target.dart b/build_tool/lib/src/target.dart deleted file mode 100644 index a5c25fc..0000000 --- a/build_tool/lib/src/target.dart +++ /dev/null @@ -1,144 +0,0 @@ -import 'dart:io'; - -import 'package:collection/collection.dart'; - -import 'util.dart'; - -class Target { - Target({ - required this.rust, - this.flutter, - this.android, - this.androidMinSdkVersion, - this.darwinPlatform, - this.darwinArch, - }); - - static final all = [ - Target( - rust: 'armv7-linux-androideabi', - flutter: 'android-arm', - android: 'armeabi-v7a', - androidMinSdkVersion: 16, - ), - Target( - rust: 'aarch64-linux-android', - flutter: 'android-arm64', - android: 'arm64-v8a', - androidMinSdkVersion: 21, - ), - Target( - rust: 'i686-linux-android', - flutter: 'android-x86', - android: 'x86', - androidMinSdkVersion: 16, - ), - Target( - rust: 'x86_64-linux-android', - flutter: 'android-x64', - android: 'x86_64', - androidMinSdkVersion: 21, - ), - Target( - rust: 'x86_64-pc-windows-msvc', - flutter: 'windows-x64', - ), - Target( - rust: 'aarch64-pc-windows-msvc', - flutter: 'windows-arm64', - ), - Target( - rust: 'x86_64-unknown-linux-gnu', - flutter: 'linux-x64', - ), - Target( - rust: 'aarch64-unknown-linux-gnu', - flutter: 'linux-arm64', - ), - Target(rust: 'riscv64gc-unknown-linux-gnu', flutter: 'linux-riscv64'), - Target( - rust: 'x86_64-apple-darwin', - darwinPlatform: 'macosx', - darwinArch: 'x86_64', - ), - Target( - rust: 'aarch64-apple-darwin', - darwinPlatform: 'macosx', - darwinArch: 'arm64', - ), - Target( - rust: 'aarch64-apple-ios', - darwinPlatform: 'iphoneos', - darwinArch: 'arm64', - ), - Target( - rust: 'aarch64-apple-ios-sim', - darwinPlatform: 'iphonesimulator', - darwinArch: 'arm64', - ), - Target( - rust: 'x86_64-apple-ios', - darwinPlatform: 'iphonesimulator', - darwinArch: 'x86_64', - ), - ]; - - static Target? forFlutterName(String flutterName) { - return all.firstWhereOrNull((element) => element.flutter == flutterName); - } - - static Target? forDarwin({ - required String platformName, - required String darwinAarch, - }) { - return all.firstWhereOrNull((element) => // - element.darwinPlatform == platformName && - element.darwinArch == darwinAarch); - } - - static Target? forRustTriple(String triple) { - return all.firstWhereOrNull((element) => element.rust == triple); - } - - static List androidTargets() { - return all - .where((element) => element.android != null) - .toList(growable: false); - } - - /// Returns buildable targets on current host platform ignoring Android targets. - static List buildableTargets() { - if (Platform.isLinux) { - // Right now we don't support cross-compiling on Linux. So we just return - // the host target. - final arch = (runCommand('arch', []).stdout as String).trim(); - if (arch == 'aarch64') { - return [Target.forRustTriple('aarch64-unknown-linux-gnu')!]; - } else if (arch == 'riscv64') { - return [Target.forRustTriple('riscv64gc-unknown-linux-gnu')!]; - } else { - return [Target.forRustTriple('x86_64-unknown-linux-gnu')!]; - } - } - return all.where((target) { - if (Platform.isWindows) { - return target.rust.contains('-windows-'); - } else if (Platform.isMacOS) { - return target.darwinPlatform != null; - } - return false; - }).toList(growable: false); - } - - @override - String toString() { - return rust; - } - - final String? flutter; - final String rust; - final String? android; - final int? androidMinSdkVersion; - final String? darwinPlatform; - final String? darwinArch; -} diff --git a/build_tool/lib/src/util.dart b/build_tool/lib/src/util.dart deleted file mode 100644 index d8e3019..0000000 --- a/build_tool/lib/src/util.dart +++ /dev/null @@ -1,169 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'logging.dart'; -import 'rustup.dart'; - -final log = Logger("process"); - -class CommandFailedException implements Exception { - final String executable; - final List arguments; - final ProcessResult result; - - CommandFailedException({ - required this.executable, - required this.arguments, - required this.result, - }); - - @override - String toString() { - final stdout = result.stdout.toString().trim(); - final stderr = result.stderr.toString().trim(); - return [ - "External Command: $executable ${arguments.map((e) => '"$e"').join(' ')}", - "Returned Exit Code: ${result.exitCode}", - kSeparator, - "STDOUT:", - if (stdout.isNotEmpty) stdout, - kSeparator, - "STDERR:", - if (stderr.isNotEmpty) stderr, - ].join('\n'); - } -} - -class TestRunCommandArgs { - final String executable; - final List arguments; - final String? workingDirectory; - final Map? environment; - final bool includeParentEnvironment; - final bool runInShell; - final Encoding? stdoutEncoding; - final Encoding? stderrEncoding; - - TestRunCommandArgs({ - required this.executable, - required this.arguments, - this.workingDirectory, - this.environment, - this.includeParentEnvironment = true, - this.runInShell = false, - this.stdoutEncoding, - this.stderrEncoding, - }); -} - -class TestRunCommandResult { - TestRunCommandResult({ - this.pid = 1, - this.exitCode = 0, - this.stdout = '', - this.stderr = '', - }); - - final int pid; - final int exitCode; - final String stdout; - final String stderr; -} - -TestRunCommandResult Function(TestRunCommandArgs args)? testRunCommandOverride; - -ProcessResult runCommand( - String executable, - List arguments, { - String? workingDirectory, - Map? environment, - bool includeParentEnvironment = true, - bool runInShell = false, - Encoding? stdoutEncoding = systemEncoding, - Encoding? stderrEncoding = systemEncoding, -}) { - if (testRunCommandOverride != null) { - final result = testRunCommandOverride!(TestRunCommandArgs( - executable: executable, - arguments: arguments, - workingDirectory: workingDirectory, - environment: environment, - includeParentEnvironment: includeParentEnvironment, - runInShell: runInShell, - stdoutEncoding: stdoutEncoding, - stderrEncoding: stderrEncoding, - )); - return ProcessResult( - result.pid, - result.exitCode, - result.stdout, - result.stderr, - ); - } - log.finer('Running command $executable ${arguments.join(' ')}'); - final res = Process.runSync( - _resolveExecutable(executable), - arguments, - workingDirectory: workingDirectory, - environment: environment, - includeParentEnvironment: includeParentEnvironment, - runInShell: runInShell, - stderrEncoding: stderrEncoding, - stdoutEncoding: stdoutEncoding, - ); - if (res.exitCode != 0) { - throw CommandFailedException( - executable: executable, - arguments: arguments, - result: res, - ); - } else { - return res; - } -} - -class RustupNotFoundException implements Exception { - @override - String toString() { - return [ - ' ', - 'rustup not found in PATH.', - ' ', - 'Maybe you need to install Rust? It only takes a minute:', - ' ', - if (Platform.isWindows) 'https://www.rust-lang.org/tools/install', - if (hasHomebrewRustInPath()) ...[ - '\$ brew unlink rust # Unlink homebrew Rust from PATH', - ], - if (!Platform.isWindows) - "\$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh", - ' ', - ].join('\n'); - } - - static bool hasHomebrewRustInPath() { - if (!Platform.isMacOS) { - return false; - } - final envPath = Platform.environment['PATH'] ?? ''; - final paths = envPath.split(':'); - return paths.any((p) { - return p.contains('homebrew') && File(path.join(p, 'rustc')).existsSync(); - }); - } -} - -String _resolveExecutable(String executable) { - if (executable == 'rustup') { - final resolved = Rustup.executablePath(); - if (resolved != null) { - return resolved; - } - throw RustupNotFoundException(); - } else { - return executable; - } -} diff --git a/build_tool/lib/src/verify_binaries.dart b/build_tool/lib/src/verify_binaries.dart deleted file mode 100644 index 0094c64..0000000 --- a/build_tool/lib/src/verify_binaries.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'dart:io'; - -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:http/http.dart'; - -import 'artifacts_provider.dart'; -import 'cargo.dart'; -import 'crate_hash.dart'; -import 'options.dart'; -import 'precompile_binaries.dart'; -import 'target.dart'; - -class VerifyBinaries { - VerifyBinaries({ - required this.manifestDir, - }); - - final String manifestDir; - - Future run() async { - final crateInfo = CrateInfo.load(manifestDir); - - final config = CargokitCrateOptions.load(manifestDir: manifestDir); - final precompiledBinaries = config.precompiledBinaries; - if (precompiledBinaries == null) { - stdout.writeln('Crate does not support precompiled binaries.'); - } else { - final crateHash = CrateHash.compute(manifestDir); - stdout.writeln('Crate hash: $crateHash'); - - for (final target in Target.all) { - final message = 'Checking ${target.rust}...'; - stdout.write(message.padRight(40)); - stdout.flush(); - - final artifacts = getArtifactNames( - target: target, - libraryName: crateInfo.packageName, - remote: true, - ); - - final prefix = precompiledBinaries.uriPrefix; - - bool ok = true; - - for (final artifact in artifacts) { - final fileName = PrecompileBinaries.fileName(target, artifact); - final signatureFileName = - PrecompileBinaries.signatureFileName(target, artifact); - - final url = Uri.parse('$prefix$crateHash/$fileName'); - final signatureUrl = - Uri.parse('$prefix$crateHash/$signatureFileName'); - - final signature = await get(signatureUrl); - if (signature.statusCode != 200) { - stdout.writeln('MISSING'); - ok = false; - break; - } - final asset = await get(url); - if (asset.statusCode != 200) { - stdout.writeln('MISSING'); - ok = false; - break; - } - - if (!verify(precompiledBinaries.publicKey, asset.bodyBytes, - signature.bodyBytes)) { - stdout.writeln('INVALID SIGNATURE'); - ok = false; - } - } - - if (ok) { - stdout.writeln('OK'); - } - } - } - } -} diff --git a/build_tool/pubspec.lock b/build_tool/pubspec.lock deleted file mode 100644 index 343bdd3..0000000 --- a/build_tool/pubspec.lock +++ /dev/null @@ -1,453 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - _fe_analyzer_shared: - dependency: transitive - description: - name: _fe_analyzer_shared - sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 - url: "https://pub.dev" - source: hosted - version: "64.0.0" - adaptive_number: - dependency: transitive - description: - name: adaptive_number - sha256: "3a567544e9b5c9c803006f51140ad544aedc79604fd4f3f2c1380003f97c1d77" - url: "https://pub.dev" - source: hosted - version: "1.0.0" - analyzer: - dependency: transitive - description: - name: analyzer - sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" - url: "https://pub.dev" - source: hosted - version: "6.2.0" - args: - dependency: "direct main" - description: - name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 - url: "https://pub.dev" - source: hosted - version: "2.4.2" - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - collection: - dependency: "direct main" - description: - name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" - source: hosted - version: "1.18.0" - convert: - dependency: "direct main" - description: - name: convert - sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" - url: "https://pub.dev" - source: hosted - version: "3.1.1" - coverage: - dependency: transitive - description: - name: coverage - sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097" - url: "https://pub.dev" - source: hosted - version: "1.6.3" - crypto: - dependency: "direct main" - description: - name: crypto - sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab - url: "https://pub.dev" - source: hosted - version: "3.0.3" - ed25519_edwards: - dependency: "direct main" - description: - name: ed25519_edwards - sha256: "6ce0112d131327ec6d42beede1e5dfd526069b18ad45dcf654f15074ad9276cd" - url: "https://pub.dev" - source: hosted - version: "0.3.1" - file: - dependency: transitive - description: - name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" - url: "https://pub.dev" - source: hosted - version: "6.1.4" - fixnum: - dependency: transitive - description: - name: fixnum - sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - frontend_server_client: - dependency: transitive - description: - name: frontend_server_client - sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" - url: "https://pub.dev" - source: hosted - version: "3.2.0" - github: - dependency: "direct main" - description: - name: github - sha256: "9966bc13bf612342e916b0a343e95e5f046c88f602a14476440e9b75d2295411" - url: "https://pub.dev" - source: hosted - version: "9.17.0" - glob: - dependency: transitive - description: - name: glob - sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" - url: "https://pub.dev" - source: hosted - version: "2.1.2" - hex: - dependency: "direct main" - description: - name: hex - sha256: "4e7cd54e4b59ba026432a6be2dd9d96e4c5205725194997193bf871703b82c4a" - url: "https://pub.dev" - source: hosted - version: "0.2.0" - http: - dependency: "direct main" - description: - name: http - sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" - url: "https://pub.dev" - source: hosted - version: "3.2.1" - http_parser: - dependency: transitive - description: - name: http_parser - sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" - url: "https://pub.dev" - source: hosted - version: "4.0.2" - io: - dependency: transitive - description: - name: io - sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" - url: "https://pub.dev" - source: hosted - version: "1.0.4" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" - json_annotation: - dependency: transitive - description: - name: json_annotation - sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 - url: "https://pub.dev" - source: hosted - version: "4.8.1" - lints: - dependency: "direct dev" - description: - name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - logging: - dependency: "direct main" - description: - name: logging - sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - matcher: - dependency: transitive - description: - name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" - url: "https://pub.dev" - source: hosted - version: "0.12.16" - meta: - dependency: transitive - description: - name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" - source: hosted - version: "1.9.1" - mime: - dependency: transitive - description: - name: mime - sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e - url: "https://pub.dev" - source: hosted - version: "1.0.4" - node_preamble: - dependency: transitive - description: - name: node_preamble - sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" - url: "https://pub.dev" - source: hosted - version: "2.0.2" - package_config: - dependency: transitive - description: - name: package_config - sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" - url: "https://pub.dev" - source: hosted - version: "2.1.0" - path: - dependency: "direct main" - description: - name: path - sha256: "2ad4cddff7f5cc0e2d13069f2a3f7a73ca18f66abd6f5ecf215219cdb3638edb" - url: "https://pub.dev" - source: hosted - version: "1.8.0" - petitparser: - dependency: transitive - description: - name: petitparser - sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 - url: "https://pub.dev" - source: hosted - version: "5.4.0" - pool: - dependency: transitive - description: - name: pool - sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" - url: "https://pub.dev" - source: hosted - version: "1.5.1" - pub_semver: - dependency: transitive - description: - name: pub_semver - sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - shelf: - dependency: transitive - description: - name: shelf - sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 - url: "https://pub.dev" - source: hosted - version: "1.4.1" - shelf_packages_handler: - dependency: transitive - description: - name: shelf_packages_handler - sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" - url: "https://pub.dev" - source: hosted - version: "3.0.2" - shelf_static: - dependency: transitive - description: - name: shelf_static - sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e - url: "https://pub.dev" - source: hosted - version: "1.1.2" - shelf_web_socket: - dependency: transitive - description: - name: shelf_web_socket - sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" - url: "https://pub.dev" - source: hosted - version: "1.0.4" - source_map_stack_trace: - dependency: transitive - description: - name: source_map_stack_trace - sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - source_maps: - dependency: transitive - description: - name: source_maps - sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" - url: "https://pub.dev" - source: hosted - version: "0.10.12" - source_span: - dependency: "direct main" - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" - source: hosted - version: "2.1.2" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test: - dependency: "direct dev" - description: - name: test - sha256: "9b0dd8e36af4a5b1569029949d50a52cb2a2a2fdaa20cebb96e6603b9ae241f9" - url: "https://pub.dev" - source: hosted - version: "1.24.6" - test_api: - dependency: transitive - description: - name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" - url: "https://pub.dev" - source: hosted - version: "0.6.1" - test_core: - dependency: transitive - description: - name: test_core - sha256: "4bef837e56375537055fdbbbf6dd458b1859881f4c7e6da936158f77d61ab265" - url: "https://pub.dev" - source: hosted - version: "0.5.6" - toml: - dependency: "direct main" - description: - name: toml - sha256: "157c5dca5160fced243f3ce984117f729c788bb5e475504f3dbcda881accee44" - url: "https://pub.dev" - source: hosted - version: "0.14.0" - typed_data: - dependency: transitive - description: - name: typed_data - sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c - url: "https://pub.dev" - source: hosted - version: "1.3.2" - version: - dependency: "direct main" - description: - name: version - sha256: "2307e23a45b43f96469eeab946208ed63293e8afca9c28cd8b5241ff31c55f55" - url: "https://pub.dev" - source: hosted - version: "3.0.0" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: "0fae432c85c4ea880b33b497d32824b97795b04cdaa74d270219572a1f50268d" - url: "https://pub.dev" - source: hosted - version: "11.9.0" - watcher: - dependency: transitive - description: - name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - web_socket_channel: - dependency: transitive - description: - name: web_socket_channel - sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b - url: "https://pub.dev" - source: hosted - version: "2.4.0" - webkit_inspection_protocol: - dependency: transitive - description: - name: webkit_inspection_protocol - sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - yaml: - dependency: "direct main" - description: - name: yaml - sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" - url: "https://pub.dev" - source: hosted - version: "3.1.2" -sdks: - dart: ">=3.0.0 <4.0.0" diff --git a/build_tool/pubspec.yaml b/build_tool/pubspec.yaml deleted file mode 100644 index e01aa0a..0000000 --- a/build_tool/pubspec.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: build_tool -description: Cargokit build_tool. Facilitates the build of Rust crate during Flutter application build. -publish_to: none -version: 1.0.0 - -environment: - sdk: ">=3.0.0 <4.0.0" - -# Add regular dependencies here. -dependencies: - # these are pinned on purpose because the bundle_tool_runner doesn't have - # pubspec.lock. See run_build_tool.sh - logging: 1.2.0 - path: 1.8.0 - version: 3.0.0 - collection: 1.18.0 - ed25519_edwards: 0.3.1 - hex: 0.2.0 - yaml: 3.1.2 - source_span: 1.10.0 - github: 9.17.0 - args: 2.4.2 - crypto: 3.0.3 - convert: 3.1.1 - http: 1.1.0 - toml: 0.14.0 - -dev_dependencies: - lints: ^2.1.0 - test: ^1.24.0 diff --git a/build_tool/test/builder_test.dart b/build_tool/test/builder_test.dart deleted file mode 100644 index e92852e..0000000 --- a/build_tool/test/builder_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:build_tool/src/builder.dart'; -import 'package:test/test.dart'; - -void main() { - test('parseBuildConfiguration', () { - var b = BuildEnvironment.parseBuildConfiguration('debug'); - expect(b, BuildConfiguration.debug); - - b = BuildEnvironment.parseBuildConfiguration('profile'); - expect(b, BuildConfiguration.profile); - - b = BuildEnvironment.parseBuildConfiguration('release'); - expect(b, BuildConfiguration.release); - - b = BuildEnvironment.parseBuildConfiguration('debug-dev'); - expect(b, BuildConfiguration.debug); - - b = BuildEnvironment.parseBuildConfiguration('profile'); - expect(b, BuildConfiguration.profile); - - b = BuildEnvironment.parseBuildConfiguration('profile-prod'); - expect(b, BuildConfiguration.profile); - - // fallback to release - b = BuildEnvironment.parseBuildConfiguration('unknown'); - expect(b, BuildConfiguration.release); - }); -} diff --git a/build_tool/test/cargo_test.dart b/build_tool/test/cargo_test.dart deleted file mode 100644 index 00afe29..0000000 --- a/build_tool/test/cargo_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:build_tool/src/cargo.dart'; -import 'package:test/test.dart'; - -final _cargoToml = """ -[workspace] - -[profile.release] -lto = true -panic = "abort" -opt-level = "z" -# strip = "symbols" - -[package] -name = "super_native_extensions" -version = "0.1.0" -edition = "2021" -resolver = "2" - -[lib] -crate-type = ["cdylib", "staticlib"] -"""; - -void main() { - test('parseCargoToml', () { - final info = CrateInfo.parseManifest(_cargoToml); - expect(info.packageName, 'super_native_extensions'); - }); -} diff --git a/build_tool/test/options_test.dart b/build_tool/test/options_test.dart deleted file mode 100644 index 25a85b6..0000000 --- a/build_tool/test/options_test.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'package:build_tool/src/builder.dart'; -import 'package:build_tool/src/options.dart'; -import 'package:hex/hex.dart'; -import 'package:test/test.dart'; -import 'package:yaml/yaml.dart'; - -void main() { - test('parseCargoBuildOptions', () { - final yaml = """ -toolchain: nightly -extra_flags: - - -Z - # Comment here - - build-std=panic_abort,std -"""; - final node = loadYamlNode(yaml); - final options = CargoBuildOptions.parse(node); - expect(options.toolchain, Toolchain.nightly); - expect(options.flags, ['-Z', 'build-std=panic_abort,std']); - }); - - test('parsePrecompiledBinaries', () { - final yaml = """ -url_prefix: https://url-prefix -public_key: a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445 -"""; - final precompiledBinaries = PrecompiledBinaries.parse(loadYamlNode(yaml)); - final key = HEX.decode( - 'a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445'); - expect(precompiledBinaries.uriPrefix, 'https://url-prefix'); - expect(precompiledBinaries.publicKey.bytes, key); - }); - - test('parseCargokitOptions', () { - const yaml = ''' -cargo: - # For smalles binaries rebuilt the standard library with panic=abort - debug: - toolchain: nightly - extra_flags: - - -Z - # Comment here - - build-std=panic_abort,std - release: - toolchain: beta - -precompiled_binaries: - url_prefix: https://url-prefix - public_key: a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445 -'''; - final options = CargokitCrateOptions.parse(loadYamlNode(yaml)); - expect(options.precompiledBinaries?.uriPrefix, 'https://url-prefix'); - final key = HEX.decode( - 'a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445'); - expect(options.precompiledBinaries?.publicKey.bytes, key); - - final debugOptions = options.cargo[BuildConfiguration.debug]!; - expect(debugOptions.toolchain, Toolchain.nightly); - expect(debugOptions.flags, ['-Z', 'build-std=panic_abort,std']); - - final releaseOptions = options.cargo[BuildConfiguration.release]!; - expect(releaseOptions.toolchain, Toolchain.beta); - expect(releaseOptions.flags, []); - }); - - test('parseCargokitUserOptions', () { - const yaml = ''' -use_precompiled_binaries: false -verbose_logging: true -'''; - final options = CargokitUserOptions.parse(loadYamlNode(yaml)); - expect(options.usePrecompiledBinaries, false); - expect(options.verboseLogging, true); - }); -} diff --git a/build_tool/test/rustup_test.dart b/build_tool/test/rustup_test.dart deleted file mode 100644 index af95303..0000000 --- a/build_tool/test/rustup_test.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'package:build_tool/src/rustup.dart'; -import 'package:build_tool/src/util.dart'; -import 'package:test/test.dart'; - -void main() { - test('rustup with no toolchains', () { - bool didListToolchains = false; - bool didInstallStable = false; - bool didListTargets = false; - testRunCommandOverride = (args) { - expect(args.executable, 'rustup'); - switch (args.arguments) { - case ['toolchain', 'list']: - didListToolchains = true; - return TestRunCommandResult(stdout: 'no installed toolchains\n'); - case ['toolchain', 'install', 'stable']: - didInstallStable = true; - return TestRunCommandResult(); - case ['target', 'list', '--toolchain', 'stable', '--installed']: - didListTargets = true; - return TestRunCommandResult( - stdout: 'x86_64-unknown-linux-gnu\nx86_64-apple-darwin\n'); - default: - throw Exception('Unexpected call: ${args.arguments}'); - } - }; - final rustup = Rustup(); - rustup.installToolchain('stable'); - expect(didInstallStable, true); - expect(didListToolchains, true); - expect(didListTargets, true); - expect(rustup.installedTargets('stable'), [ - 'x86_64-unknown-linux-gnu', - 'x86_64-apple-darwin', - ]); - testRunCommandOverride = null; - }); - - test('rustup with esp toolchain', () { - final targetsQueried = []; - testRunCommandOverride = (args) { - expect(args.executable, 'rustup'); - switch (args.arguments) { - case ['toolchain', 'list']: - return TestRunCommandResult( - stdout: 'stable-aarch64-apple-darwin (default)\n' - 'nightly-aarch64-apple-darwin\n' - 'esp\n'); - case ['target', 'list', '--toolchain', String toolchain, '--installed']: - targetsQueried.add(toolchain); - return TestRunCommandResult(stdout: '$toolchain:target\n'); - default: - throw Exception('Unexpected call: ${args.arguments}'); - } - }; - final rustup = Rustup(); - expect(targetsQueried, [ - 'stable-aarch64-apple-darwin', - 'nightly-aarch64-apple-darwin', - ]); - expect(rustup.installedTargets('stable'), - ['stable-aarch64-apple-darwin:target']); - expect(rustup.installedTargets('nightly'), - ['nightly-aarch64-apple-darwin:target']); - }); -} diff --git a/cargokit/.github/workflows/check_and_lint.yml b/cargokit/.github/workflows/check_and_lint.yml deleted file mode 100644 index d8979f0..0000000 --- a/cargokit/.github/workflows/check_and_lint.yml +++ /dev/null @@ -1,26 +0,0 @@ -on: - pull_request: - push: - branches: - - main - -name: Check and Lint - -jobs: - Flutter: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # 4.1.0 - - uses: subosito/flutter-action@44ac965b96f18d999802d4b807e3256d5a3f9fa1 # 2.16.0 - - name: Pub Get - run: dart pub get --no-precompile - working-directory: build_tool - - name: Dart Format - run: dart format . --output=none --set-exit-if-changed - working-directory: build_tool - - name: Analyze - run: dart analyze - working-directory: build_tool - - name: Test - run: flutter test - working-directory: build_tool diff --git a/cargokit/.github/workflows/test_example_plugin_build.yml b/cargokit/.github/workflows/test_example_plugin_build.yml deleted file mode 100644 index 83cc47c..0000000 --- a/cargokit/.github/workflows/test_example_plugin_build.yml +++ /dev/null @@ -1,86 +0,0 @@ -on: - pull_request: - push: - branches: - - main - -name: Test Example Plugin - -jobs: - Build: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - macOS-latest - - windows-latest - build_mode: - - debug - - profile - - release - env: - EXAMPLE_DIR: "a b/hello_rust_ffi_plugin/example" - CARGOKIT_VERBOSE: 1 - steps: - - name: Extract branch name - shell: bash - run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT - id: extract_branch - - name: Setup Repository - shell: bash - run: | - mkdir "a b" # Space is intentional - cd "a b" - git config --global user.email "you@example.com" - git config --global user.name "Your Name" - # "advanced" branch has extra iOS flavor and uses rust nightly for release builds - git clone -b advanced https://github.com/irondash/hello_rust_ffi_plugin - cd hello_rust_ffi_plugin - git subtree pull --prefix cargokit https://github.com/${{ github.event.pull_request.head.repo.full_name || github.repository }} ${{ steps.extract_branch.outputs.branch }} --squash - - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - name: Install GTK - if: (matrix.os == 'ubuntu-latest') - run: sudo apt-get update && sudo apt-get install libgtk-3-dev - - name: Install ninja-build - if: (matrix.os == 'ubuntu-latest') - run: sudo apt-get update && sudo apt-get install ninja-build - - name: Build Linux (${{ matrix.build_mode }}) - if: matrix.os == 'ubuntu-latest' - shell: bash - working-directory: ${{ env.EXAMPLE_DIR }} - run: flutter build linux --${{ matrix.build_mode }} -v - - name: Build macOS (${{ matrix.build_mode }}) - if: matrix.os == 'macos-latest' - shell: bash - working-directory: ${{ env.EXAMPLE_DIR }} - run: flutter build macos --${{ matrix.build_mode }} -v - - name: Build iOS (${{ matrix.build_mode }}) - if: matrix.os == 'macos-latest' - shell: bash - working-directory: ${{ env.EXAMPLE_DIR }} - run: flutter build ios --${{ matrix.build_mode }} --no-codesign -v - - name: Build iOS (${{ matrix.build_mode }}) - flavor1 - if: matrix.os == 'macos-latest' - shell: bash - working-directory: ${{ env.EXAMPLE_DIR }} - run: flutter build ios --flavor flavor1 --${{ matrix.build_mode }} --no-codesign -v - - name: Build Windows (${{ matrix.build_mode }}) - if: matrix.os == 'windows-latest' - shell: bash - working-directory: ${{ env.EXAMPLE_DIR }} - run: flutter build windows --${{ matrix.build_mode }} -v - - name: Build Android (${{ matrix.build_mode }}) - shell: bash - working-directory: ${{ env.EXAMPLE_DIR }} - run: | - if [[ $(sysctl hw.optional.arm64) == *"hw.optional.arm64: 1"* ]]; then - export JAVA_HOME=$JAVA_HOME_17_arm64 - else - export JAVA_HOME=$JAVA_HOME_17_X64 - fi - flutter build apk --${{ matrix.build_mode }} -v - diff --git a/cargokit/.gitignore b/cargokit/.gitignore deleted file mode 100644 index cf7bb86..0000000 --- a/cargokit/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -target -.dart_tool -*.iml -!pubspec.lock diff --git a/cargokit/LICENSE b/cargokit/LICENSE deleted file mode 100644 index 54a7d58..0000000 --- a/cargokit/LICENSE +++ /dev/null @@ -1,39 +0,0 @@ -Copyright 2022 Matej Knopp - -================================================================================ - -MIT LICENSE - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS -OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -================================================================================ - -APACHE LICENSE, VERSION 2.0 - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - diff --git a/cargokit/README b/cargokit/README deleted file mode 100644 index 8ae4a07..0000000 --- a/cargokit/README +++ /dev/null @@ -1,8 +0,0 @@ -Experimental repository to provide glue for seamlessly integrating cargo build -with flutter plugins and packages. - -See https://matejknopp.com/post/flutter_plugin_in_rust_with_no_prebuilt_binaries/ -for a tutorial on how to use Cargokit. - -Example plugin available at https://github.com/irondash/hello_rust_ffi_plugin. - diff --git a/cargokit/build_pod.sh b/cargokit/build_pod.sh deleted file mode 100755 index ed0e0d9..0000000 --- a/cargokit/build_pod.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -set -e - -BASEDIR=$(dirname "$0") - -# Workaround for https://github.com/dart-lang/pub/issues/4010 -BASEDIR=$(cd "$BASEDIR" ; pwd -P) - -# Remove XCode SDK from path. Otherwise this breaks tool compilation when building iOS project -NEW_PATH=`echo $PATH | tr ":" "\n" | grep -v "Contents/Developer/" | tr "\n" ":"` - -export PATH=${NEW_PATH%?} # remove trailing : - -env - -# Platform name (macosx, iphoneos, iphonesimulator) -export CARGOKIT_DARWIN_PLATFORM_NAME=$PLATFORM_NAME - -# Arctive architectures (arm64, armv7, x86_64), space separated. -export CARGOKIT_DARWIN_ARCHS=$ARCHS - -# Current build configuration (Debug, Release) -export CARGOKIT_CONFIGURATION=$CONFIGURATION - -# Path to directory containing Cargo.toml. -export CARGOKIT_MANIFEST_DIR=$PODS_TARGET_SRCROOT/$1 - -# Temporary directory for build artifacts. -export CARGOKIT_TARGET_TEMP_DIR=$TARGET_TEMP_DIR - -# Output directory for final artifacts. -export CARGOKIT_OUTPUT_DIR=$PODS_CONFIGURATION_BUILD_DIR/$PRODUCT_NAME - -# Directory to store built tool artifacts. -export CARGOKIT_TOOL_TEMP_DIR=$TARGET_TEMP_DIR/build_tool - -# Directory inside root project. Not necessarily the top level directory of root project. -export CARGOKIT_ROOT_PROJECT_DIR=$SRCROOT - -FLUTTER_EXPORT_BUILD_ENVIRONMENT=( - "$PODS_ROOT/../Flutter/ephemeral/flutter_export_environment.sh" # macOS - "$PODS_ROOT/../Flutter/flutter_export_environment.sh" # iOS -) - -for path in "${FLUTTER_EXPORT_BUILD_ENVIRONMENT[@]}" -do - if [[ -f "$path" ]]; then - source "$path" - fi -done - -sh "$BASEDIR/run_build_tool.sh" build-pod "$@" - -# Make a symlink from built framework to phony file, which will be used as input to -# build script. This should force rebuild (podspec currently doesn't support alwaysOutOfDate -# attribute on custom build phase) -ln -fs "$OBJROOT/XCBuildData/build.db" "${BUILT_PRODUCTS_DIR}/cargokit_phony" -ln -fs "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" "${BUILT_PRODUCTS_DIR}/cargokit_phony_out" diff --git a/cargokit/build_tool/README.md b/cargokit/build_tool/README.md deleted file mode 100644 index 3816eca..0000000 --- a/cargokit/build_tool/README.md +++ /dev/null @@ -1,2 +0,0 @@ -A sample command-line application with an entrypoint in `bin/`, library code -in `lib/`, and example unit test in `test/`. diff --git a/cargokit/build_tool/analysis_options.yaml b/cargokit/build_tool/analysis_options.yaml deleted file mode 100644 index a1aad5b..0000000 --- a/cargokit/build_tool/analysis_options.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -linter: - rules: - - prefer_relative_imports - - directives_ordering - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options diff --git a/cargokit/build_tool/bin/build_tool.dart b/cargokit/build_tool/bin/build_tool.dart deleted file mode 100644 index f27ec75..0000000 --- a/cargokit/build_tool/bin/build_tool.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'package:build_tool/build_tool.dart' as build_tool; - -void main(List arguments) { - build_tool.runMain(arguments); -} diff --git a/cargokit/build_tool/lib/build_tool.dart b/cargokit/build_tool/lib/build_tool.dart deleted file mode 100644 index b329c01..0000000 --- a/cargokit/build_tool/lib/build_tool.dart +++ /dev/null @@ -1,5 +0,0 @@ -import 'src/build_tool.dart' as build_tool; - -Future runMain(List args) async { - return build_tool.runMain(args); -} diff --git a/cargokit/build_tool/lib/src/android_environment.dart b/cargokit/build_tool/lib/src/android_environment.dart deleted file mode 100644 index 9342964..0000000 --- a/cargokit/build_tool/lib/src/android_environment.dart +++ /dev/null @@ -1,192 +0,0 @@ -import 'dart:io'; -import 'dart:isolate'; -import 'dart:math' as math; - -import 'package:collection/collection.dart'; -import 'package:path/path.dart' as path; -import 'package:version/version.dart'; - -import 'target.dart'; -import 'util.dart'; - -class AndroidEnvironment { - AndroidEnvironment({ - required this.sdkPath, - required this.ndkVersion, - required this.minSdkVersion, - required this.targetTempDir, - required this.target, - }); - - static void clangLinkerWrapper(List args) { - final clang = Platform.environment['_CARGOKIT_NDK_LINK_CLANG']; - if (clang == null) { - throw Exception( - "cargo-ndk rustc linker: didn't find _CARGOKIT_NDK_LINK_CLANG env var"); - } - final target = Platform.environment['_CARGOKIT_NDK_LINK_TARGET']; - if (target == null) { - throw Exception( - "cargo-ndk rustc linker: didn't find _CARGOKIT_NDK_LINK_TARGET env var"); - } - - runCommand(clang, [ - target, - ...args, - ]); - } - - /// Full path to Android SDK. - final String sdkPath; - - /// Full version of Android NDK. - final String ndkVersion; - - /// Minimum supported SDK version. - final int minSdkVersion; - - /// Target directory for build artifacts. - final String targetTempDir; - - /// Target being built. - final Target target; - - bool ndkIsInstalled() { - final ndkPath = path.join(sdkPath, 'ndk', ndkVersion); - final ndkPackageXml = File(path.join(ndkPath, 'package.xml')); - return ndkPackageXml.existsSync(); - } - - void installNdk({ - required String javaHome, - }) { - final sdkManagerExtension = Platform.isWindows ? '.bat' : ''; - final sdkManager = path.join( - sdkPath, - 'cmdline-tools', - 'latest', - 'bin', - 'sdkmanager$sdkManagerExtension', - ); - - log.info('Installing NDK $ndkVersion'); - runCommand(sdkManager, [ - '--install', - 'ndk;$ndkVersion', - ], environment: { - 'JAVA_HOME': javaHome, - }); - } - - Future> buildEnvironment() async { - final hostArch = Platform.isMacOS - ? "darwin-x86_64" - : (Platform.isLinux ? "linux-x86_64" : "windows-x86_64"); - - final ndkPath = path.join(sdkPath, 'ndk', ndkVersion); - final toolchainPath = path.join( - ndkPath, - 'toolchains', - 'llvm', - 'prebuilt', - hostArch, - 'bin', - ); - - final minSdkVersion = - math.max(target.androidMinSdkVersion!, this.minSdkVersion); - - final exe = Platform.isWindows ? '.exe' : ''; - - final arKey = 'AR_${target.rust}'; - final arValue = ['${target.rust}-ar', 'llvm-ar', 'llvm-ar.exe'] - .map((e) => path.join(toolchainPath, e)) - .firstWhereOrNull((element) => File(element).existsSync()); - if (arValue == null) { - throw Exception('Failed to find ar for $target in $toolchainPath'); - } - - final targetArg = '--target=${target.rust}$minSdkVersion'; - - final ccKey = 'CC_${target.rust}'; - final ccValue = path.join(toolchainPath, 'clang$exe'); - final cfFlagsKey = 'CFLAGS_${target.rust}'; - final cFlagsValue = targetArg; - - final cxxKey = 'CXX_${target.rust}'; - final cxxValue = path.join(toolchainPath, 'clang++$exe'); - final cxxFlagsKey = 'CXXFLAGS_${target.rust}'; - final cxxFlagsValue = targetArg; - - final linkerKey = - 'cargo_target_${target.rust.replaceAll('-', '_')}_linker'.toUpperCase(); - - final ranlibKey = 'RANLIB_${target.rust}'; - final ranlibValue = path.join(toolchainPath, 'llvm-ranlib$exe'); - - final ndkVersionParsed = Version.parse(ndkVersion); - final rustFlagsKey = 'CARGO_ENCODED_RUSTFLAGS'; - final rustFlagsValue = _libGccWorkaround(targetTempDir, ndkVersionParsed); - - final runRustTool = - Platform.isWindows ? 'run_build_tool.cmd' : 'run_build_tool.sh'; - - final packagePath = (await Isolate.resolvePackageUri( - Uri.parse('package:build_tool/buildtool.dart')))! - .toFilePath(); - final selfPath = path.canonicalize(path.join( - packagePath, - '..', - '..', - '..', - runRustTool, - )); - - // Make sure that run_build_tool is working properly even initially launched directly - // through dart run. - final toolTempDir = - Platform.environment['CARGOKIT_TOOL_TEMP_DIR'] ?? targetTempDir; - - return { - arKey: arValue, - ccKey: ccValue, - cfFlagsKey: cFlagsValue, - cxxKey: cxxValue, - cxxFlagsKey: cxxFlagsValue, - ranlibKey: ranlibValue, - rustFlagsKey: rustFlagsValue, - linkerKey: selfPath, - // Recognized by main() so we know when we're acting as a wrapper - '_CARGOKIT_NDK_LINK_TARGET': targetArg, - '_CARGOKIT_NDK_LINK_CLANG': ccValue, - 'CARGOKIT_TOOL_TEMP_DIR': toolTempDir, - }; - } - - // Workaround for libgcc missing in NDK23, inspired by cargo-ndk - String _libGccWorkaround(String buildDir, Version ndkVersion) { - final workaroundDir = path.join( - buildDir, - 'cargokit', - 'libgcc_workaround', - '${ndkVersion.major}', - ); - Directory(workaroundDir).createSync(recursive: true); - if (ndkVersion.major >= 23) { - File(path.join(workaroundDir, 'libgcc.a')) - .writeAsStringSync('INPUT(-lunwind)'); - } else { - // Other way around, untested, forward libgcc.a from libunwind once Rust - // gets updated for NDK23+. - File(path.join(workaroundDir, 'libunwind.a')) - .writeAsStringSync('INPUT(-lgcc)'); - } - - var rustFlags = Platform.environment['CARGO_ENCODED_RUSTFLAGS'] ?? ''; - if (rustFlags.isNotEmpty) { - rustFlags = '$rustFlags\x1f'; - } - rustFlags = '$rustFlags-L\x1f$workaroundDir'; - return rustFlags; - } -} diff --git a/cargokit/build_tool/lib/src/artifacts_provider.dart b/cargokit/build_tool/lib/src/artifacts_provider.dart deleted file mode 100644 index ef655a9..0000000 --- a/cargokit/build_tool/lib/src/artifacts_provider.dart +++ /dev/null @@ -1,263 +0,0 @@ -import 'dart:io'; - -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:http/http.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'builder.dart'; -import 'crate_hash.dart'; -import 'options.dart'; -import 'precompile_binaries.dart'; -import 'rustup.dart'; -import 'target.dart'; - -class Artifact { - /// File system location of the artifact. - final String path; - - /// Actual file name that the artifact should have in destination folder. - final String finalFileName; - - AritifactType get type { - if (finalFileName.endsWith('.dll') || - finalFileName.endsWith('.dll.lib') || - finalFileName.endsWith('.pdb') || - finalFileName.endsWith('.so') || - finalFileName.endsWith('.dylib')) { - return AritifactType.dylib; - } else if (finalFileName.endsWith('.lib') || finalFileName.endsWith('.a')) { - return AritifactType.staticlib; - } else { - throw Exception('Unknown artifact type for $finalFileName'); - } - } - - Artifact({ - required this.path, - required this.finalFileName, - }); -} - -final _log = Logger('artifacts_provider'); - -class ArtifactProvider { - ArtifactProvider({ - required this.environment, - required this.userOptions, - }); - - final BuildEnvironment environment; - final CargokitUserOptions userOptions; - - Future>> getArtifacts(List targets) async { - final result = await _getPrecompiledArtifacts(targets); - - final pendingTargets = List.of(targets); - pendingTargets.removeWhere((element) => result.containsKey(element)); - - if (pendingTargets.isEmpty) { - return result; - } - - final rustup = Rustup(); - for (final target in targets) { - final builder = RustBuilder(target: target, environment: environment); - builder.prepare(rustup); - _log.info('Building ${environment.crateInfo.packageName} for $target'); - final targetDir = await builder.build(); - // For local build accept both static and dynamic libraries. - final artifactNames = { - ...getArtifactNames( - target: target, - libraryName: environment.crateInfo.packageName, - aritifactType: AritifactType.dylib, - remote: false, - ), - ...getArtifactNames( - target: target, - libraryName: environment.crateInfo.packageName, - aritifactType: AritifactType.staticlib, - remote: false, - ) - }; - final artifacts = artifactNames - .map((artifactName) => Artifact( - path: path.join(targetDir, artifactName), - finalFileName: artifactName, - )) - .where((element) => File(element.path).existsSync()) - .toList(); - result[target] = artifacts; - } - return result; - } - - Future>> _getPrecompiledArtifacts( - List targets) async { - if (userOptions.usePrecompiledBinaries == false) { - _log.info('Precompiled binaries are disabled'); - return {}; - } - if (environment.crateOptions.precompiledBinaries == null) { - _log.fine('Precompiled binaries not enabled for this crate'); - return {}; - } - - final start = Stopwatch()..start(); - final crateHash = CrateHash.compute(environment.manifestDir, - tempStorage: environment.targetTempDir); - _log.fine( - 'Computed crate hash $crateHash in ${start.elapsedMilliseconds}ms'); - - final downloadedArtifactsDir = - path.join(environment.targetTempDir, 'precompiled', crateHash); - Directory(downloadedArtifactsDir).createSync(recursive: true); - - final res = >{}; - - for (final target in targets) { - final requiredArtifacts = getArtifactNames( - target: target, - libraryName: environment.crateInfo.packageName, - remote: true, - ); - final artifactsForTarget = []; - - for (final artifact in requiredArtifacts) { - final fileName = PrecompileBinaries.fileName(target, artifact); - final downloadedPath = path.join(downloadedArtifactsDir, fileName); - if (!File(downloadedPath).existsSync()) { - final signatureFileName = - PrecompileBinaries.signatureFileName(target, artifact); - await _tryDownloadArtifacts( - crateHash: crateHash, - fileName: fileName, - signatureFileName: signatureFileName, - finalPath: downloadedPath, - ); - } - if (File(downloadedPath).existsSync()) { - artifactsForTarget.add(Artifact( - path: downloadedPath, - finalFileName: artifact, - )); - } else { - break; - } - } - - // Only provide complete set of artifacts. - if (artifactsForTarget.length == requiredArtifacts.length) { - _log.fine('Found precompiled artifacts for $target'); - res[target] = artifactsForTarget; - } - } - - return res; - } - - static Future _get(Uri url, {Map? headers}) async { - int attempt = 0; - const maxAttempts = 10; - while (true) { - try { - return await get(url, headers: headers); - } on SocketException catch (e) { - // Try to detect reset by peer error and retry. - if (attempt++ < maxAttempts && - (e.osError?.errorCode == 54 || e.osError?.errorCode == 10054)) { - _log.severe( - 'Failed to download $url: $e, attempt $attempt of $maxAttempts, will retry...'); - await Future.delayed(Duration(seconds: 1)); - continue; - } else { - rethrow; - } - } - } - } - - Future _tryDownloadArtifacts({ - required String crateHash, - required String fileName, - required String signatureFileName, - required String finalPath, - }) async { - final precompiledBinaries = environment.crateOptions.precompiledBinaries!; - final prefix = precompiledBinaries.uriPrefix; - final url = Uri.parse('$prefix$crateHash/$fileName'); - final signatureUrl = Uri.parse('$prefix$crateHash/$signatureFileName'); - _log.fine('Downloading signature from $signatureUrl'); - final signature = await _get(signatureUrl); - if (signature.statusCode == 404) { - _log.warning( - 'Precompiled binaries not available for crate hash $crateHash ($fileName)'); - return; - } - if (signature.statusCode != 200) { - _log.severe( - 'Failed to download signature $signatureUrl: status ${signature.statusCode}'); - return; - } - _log.fine('Downloading binary from $url'); - final res = await _get(url); - if (res.statusCode != 200) { - _log.severe('Failed to download binary $url: status ${res.statusCode}'); - return; - } - if (verify( - precompiledBinaries.publicKey, res.bodyBytes, signature.bodyBytes)) { - File(finalPath).writeAsBytesSync(res.bodyBytes); - } else { - _log.shout('Signature verification failed! Ignoring binary.'); - } - } -} - -enum AritifactType { - staticlib, - dylib, -} - -AritifactType artifactTypeForTarget(Target target) { - if (target.darwinPlatform != null) { - return AritifactType.staticlib; - } else { - return AritifactType.dylib; - } -} - -List getArtifactNames({ - required Target target, - required String libraryName, - required bool remote, - AritifactType? aritifactType, -}) { - aritifactType ??= artifactTypeForTarget(target); - if (target.darwinArch != null) { - if (aritifactType == AritifactType.staticlib) { - return ['lib$libraryName.a']; - } else { - return ['lib$libraryName.dylib']; - } - } else if (target.rust.contains('-windows-')) { - if (aritifactType == AritifactType.staticlib) { - return ['$libraryName.lib']; - } else { - return [ - '$libraryName.dll', - '$libraryName.dll.lib', - if (!remote) '$libraryName.pdb' - ]; - } - } else if (target.rust.contains('-linux-')) { - if (aritifactType == AritifactType.staticlib) { - return ['lib$libraryName.a']; - } else { - return ['lib$libraryName.so']; - } - } else { - throw Exception("Unsupported target: ${target.rust}"); - } -} diff --git a/cargokit/build_tool/lib/src/build_cmake.dart b/cargokit/build_tool/lib/src/build_cmake.dart deleted file mode 100644 index 9154371..0000000 --- a/cargokit/build_tool/lib/src/build_cmake.dart +++ /dev/null @@ -1,37 +0,0 @@ -import 'dart:io'; - -import 'package:path/path.dart' as path; - -import 'artifacts_provider.dart'; -import 'builder.dart'; -import 'environment.dart'; -import 'options.dart'; -import 'target.dart'; - -class BuildCMake { - final CargokitUserOptions userOptions; - - BuildCMake({required this.userOptions}); - - Future build() async { - final targetPlatform = Environment.targetPlatform; - final target = Target.forFlutterName(Environment.targetPlatform); - if (target == null) { - throw Exception("Unknown target platform: $targetPlatform"); - } - - final environment = BuildEnvironment.fromEnvironment(isAndroid: false); - final provider = - ArtifactProvider(environment: environment, userOptions: userOptions); - final artifacts = await provider.getArtifacts([target]); - - final libs = artifacts[target]!; - - for (final lib in libs) { - if (lib.type == AritifactType.dylib) { - File(lib.path) - .copySync(path.join(Environment.outputDir, lib.finalFileName)); - } - } - } -} diff --git a/cargokit/build_tool/lib/src/build_gradle.dart b/cargokit/build_tool/lib/src/build_gradle.dart deleted file mode 100644 index 469c8b2..0000000 --- a/cargokit/build_tool/lib/src/build_gradle.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'dart:io'; - -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'artifacts_provider.dart'; -import 'builder.dart'; -import 'environment.dart'; -import 'options.dart'; -import 'target.dart'; - -final log = Logger('build_gradle'); - -class BuildGradle { - BuildGradle({required this.userOptions}); - - final CargokitUserOptions userOptions; - - Future build() async { - final targets = Environment.targetPlatforms.map((arch) { - final target = Target.forFlutterName(arch); - if (target == null) { - throw Exception( - "Unknown darwin target or platform: $arch, ${Environment.darwinPlatformName}"); - } - return target; - }).toList(); - - final environment = BuildEnvironment.fromEnvironment(isAndroid: true); - final provider = - ArtifactProvider(environment: environment, userOptions: userOptions); - final artifacts = await provider.getArtifacts(targets); - - for (final target in targets) { - final libs = artifacts[target]!; - final outputDir = path.join(Environment.outputDir, target.android!); - Directory(outputDir).createSync(recursive: true); - - for (final lib in libs) { - if (lib.type == AritifactType.dylib) { - File(lib.path).copySync(path.join(outputDir, lib.finalFileName)); - } - } - } - } -} diff --git a/cargokit/build_tool/lib/src/build_pod.dart b/cargokit/build_tool/lib/src/build_pod.dart deleted file mode 100644 index f01401e..0000000 --- a/cargokit/build_tool/lib/src/build_pod.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'dart:io'; - -import 'package:path/path.dart' as path; - -import 'artifacts_provider.dart'; -import 'builder.dart'; -import 'environment.dart'; -import 'options.dart'; -import 'target.dart'; -import 'util.dart'; - -class BuildPod { - BuildPod({required this.userOptions}); - - final CargokitUserOptions userOptions; - - Future build() async { - final targets = Environment.darwinArchs.map((arch) { - final target = Target.forDarwin( - platformName: Environment.darwinPlatformName, darwinAarch: arch); - if (target == null) { - throw Exception( - "Unknown darwin target or platform: $arch, ${Environment.darwinPlatformName}"); - } - return target; - }).toList(); - - final environment = BuildEnvironment.fromEnvironment(isAndroid: false); - final provider = - ArtifactProvider(environment: environment, userOptions: userOptions); - final artifacts = await provider.getArtifacts(targets); - - void performLipo(String targetFile, Iterable sourceFiles) { - runCommand("lipo", [ - '-create', - ...sourceFiles, - '-output', - targetFile, - ]); - } - - final outputDir = Environment.outputDir; - - Directory(outputDir).createSync(recursive: true); - - final staticLibs = artifacts.values - .expand((element) => element) - .where((element) => element.type == AritifactType.staticlib) - .toList(); - final dynamicLibs = artifacts.values - .expand((element) => element) - .where((element) => element.type == AritifactType.dylib) - .toList(); - - final libName = environment.crateInfo.packageName; - - // If there is static lib, use it and link it with pod - if (staticLibs.isNotEmpty) { - final finalTargetFile = path.join(outputDir, "lib$libName.a"); - performLipo(finalTargetFile, staticLibs.map((e) => e.path)); - } else { - // Otherwise try to replace bundle dylib with our dylib - final bundlePaths = [ - '$libName.framework/Versions/A/$libName', - '$libName.framework/$libName', - ]; - - for (final bundlePath in bundlePaths) { - final targetFile = path.join(outputDir, bundlePath); - if (File(targetFile).existsSync()) { - performLipo(targetFile, dynamicLibs.map((e) => e.path)); - - // Replace absolute id with @rpath one so that it works properly - // when moved to Frameworks. - runCommand("install_name_tool", [ - '-id', - '@rpath/$bundlePath', - targetFile, - ]); - return; - } - } - throw Exception('Unable to find bundle for dynamic library'); - } - } -} diff --git a/cargokit/build_tool/lib/src/build_tool.dart b/cargokit/build_tool/lib/src/build_tool.dart deleted file mode 100644 index 6415f23..0000000 --- a/cargokit/build_tool/lib/src/build_tool.dart +++ /dev/null @@ -1,273 +0,0 @@ -import 'dart:io'; - -import 'package:args/command_runner.dart'; -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:github/github.dart'; -import 'package:hex/hex.dart'; -import 'package:logging/logging.dart'; - -import 'android_environment.dart'; -import 'build_cmake.dart'; -import 'build_gradle.dart'; -import 'build_pod.dart'; -import 'logging.dart'; -import 'options.dart'; -import 'precompile_binaries.dart'; -import 'target.dart'; -import 'util.dart'; -import 'verify_binaries.dart'; - -final log = Logger('build_tool'); - -abstract class BuildCommand extends Command { - Future runBuildCommand(CargokitUserOptions options); - - @override - Future run() async { - final options = CargokitUserOptions.load(); - - if (options.verboseLogging || - Platform.environment['CARGOKIT_VERBOSE'] == '1') { - enableVerboseLogging(); - } - - await runBuildCommand(options); - } -} - -class BuildPodCommand extends BuildCommand { - @override - final name = 'build-pod'; - - @override - final description = 'Build cocoa pod library'; - - @override - Future runBuildCommand(CargokitUserOptions options) async { - final build = BuildPod(userOptions: options); - await build.build(); - } -} - -class BuildGradleCommand extends BuildCommand { - @override - final name = 'build-gradle'; - - @override - final description = 'Build android library'; - - @override - Future runBuildCommand(CargokitUserOptions options) async { - final build = BuildGradle(userOptions: options); - await build.build(); - } -} - -class BuildCMakeCommand extends BuildCommand { - @override - final name = 'build-cmake'; - - @override - final description = 'Build CMake library'; - - @override - Future runBuildCommand(CargokitUserOptions options) async { - final build = BuildCMake(userOptions: options); - await build.build(); - } -} - -class GenKeyCommand extends Command { - @override - final name = 'gen-key'; - - @override - final description = 'Generate key pair for signing precompiled binaries'; - - @override - void run() { - final kp = generateKey(); - final private = HEX.encode(kp.privateKey.bytes); - final public = HEX.encode(kp.publicKey.bytes); - print("Private Key: $private"); - print("Public Key: $public"); - } -} - -class PrecompileBinariesCommand extends Command { - PrecompileBinariesCommand() { - argParser - ..addOption( - 'repository', - mandatory: true, - help: 'Github repository slug in format owner/name', - ) - ..addOption( - 'manifest-dir', - mandatory: true, - help: 'Directory containing Cargo.toml', - ) - ..addMultiOption('target', - help: 'Rust target triple of artifact to build.\n' - 'Can be specified multiple times or omitted in which case\n' - 'all targets for current platform will be built.') - ..addOption( - 'android-sdk-location', - help: 'Location of Android SDK (if available)', - ) - ..addOption( - 'android-ndk-version', - help: 'Android NDK version (if available)', - ) - ..addOption( - 'android-min-sdk-version', - help: 'Android minimum rquired version (if available)', - ) - ..addOption( - 'temp-dir', - help: 'Directory to store temporary build artifacts', - ) - ..addOption( - 'glibc-version', - help: 'GLIBC version to use for linux builds', - ) - ..addFlag( - "verbose", - abbr: "v", - defaultsTo: false, - help: "Enable verbose logging", - ); - } - - @override - final name = 'precompile-binaries'; - - @override - final description = 'Prebuild and upload binaries\n' - 'Private key must be passed through PRIVATE_KEY environment variable. ' - 'Use gen_key through generate priave key.\n' - 'Github token must be passed as GITHUB_TOKEN environment variable.\n'; - - @override - Future run() async { - final verbose = argResults!['verbose'] as bool; - if (verbose) { - enableVerboseLogging(); - } - - final privateKeyString = Platform.environment['PRIVATE_KEY']; - if (privateKeyString == null) { - throw ArgumentError('Missing PRIVATE_KEY environment variable'); - } - final githubToken = Platform.environment['GITHUB_TOKEN']; - if (githubToken == null) { - throw ArgumentError('Missing GITHUB_TOKEN environment variable'); - } - final privateKey = HEX.decode(privateKeyString); - if (privateKey.length != 64) { - throw ArgumentError('Private key must be 64 bytes long'); - } - final manifestDir = argResults!['manifest-dir'] as String; - if (!Directory(manifestDir).existsSync()) { - throw ArgumentError('Manifest directory does not exist: $manifestDir'); - } - String? androidMinSdkVersionString = - argResults!['android-min-sdk-version'] as String?; - int? androidMinSdkVersion; - if (androidMinSdkVersionString != null) { - androidMinSdkVersion = int.tryParse(androidMinSdkVersionString); - if (androidMinSdkVersion == null) { - throw ArgumentError( - 'Invalid android-min-sdk-version: $androidMinSdkVersionString'); - } - } - final targetStrigns = argResults!['target'] as List; - final targets = targetStrigns.map((target) { - final res = Target.forRustTriple(target); - if (res == null) { - throw ArgumentError('Invalid target: $target'); - } - return res; - }).toList(growable: false); - final precompileBinaries = PrecompileBinaries( - privateKey: PrivateKey(privateKey), - githubToken: githubToken, - manifestDir: manifestDir, - repositorySlug: RepositorySlug.full(argResults!['repository'] as String), - targets: targets, - androidSdkLocation: argResults!['android-sdk-location'] as String?, - androidNdkVersion: argResults!['android-ndk-version'] as String?, - androidMinSdkVersion: androidMinSdkVersion, - tempDir: argResults!['temp-dir'] as String?, - glibcVersion: argResults!['glibc-version'] as String?, - ); - - await precompileBinaries.run(); - } -} - -class VerifyBinariesCommand extends Command { - VerifyBinariesCommand() { - argParser.addOption( - 'manifest-dir', - mandatory: true, - help: 'Directory containing Cargo.toml', - ); - } - - @override - final name = "verify-binaries"; - - @override - final description = 'Verifies published binaries\n' - 'Checks whether there is a binary published for each targets\n' - 'and checks the signature.'; - - @override - Future run() async { - final manifestDir = argResults!['manifest-dir'] as String; - final verifyBinaries = VerifyBinaries( - manifestDir: manifestDir, - ); - await verifyBinaries.run(); - } -} - -Future runMain(List args) async { - try { - // Init logging before options are loaded - initLogging(); - - if (Platform.environment['_CARGOKIT_NDK_LINK_TARGET'] != null) { - return AndroidEnvironment.clangLinkerWrapper(args); - } - - final runner = CommandRunner('build_tool', 'Cargokit built_tool') - ..addCommand(BuildPodCommand()) - ..addCommand(BuildGradleCommand()) - ..addCommand(BuildCMakeCommand()) - ..addCommand(GenKeyCommand()) - ..addCommand(PrecompileBinariesCommand()) - ..addCommand(VerifyBinariesCommand()); - - await runner.run(args); - } on ArgumentError catch (e) { - stderr.writeln(e.toString()); - exit(1); - } catch (e, s) { - log.severe(kDoubleSeparator); - log.severe('Cargokit BuildTool failed with error:'); - log.severe(kSeparator); - log.severe(e); - // This tells user to install Rust, there's no need to pollute the log with - // stack trace. - if (e is! RustupNotFoundException) { - log.severe(kSeparator); - log.severe(s); - log.severe(kSeparator); - log.severe('BuildTool arguments: $args'); - } - log.severe(kDoubleSeparator); - exit(1); - } -} diff --git a/cargokit/build_tool/lib/src/builder.dart b/cargokit/build_tool/lib/src/builder.dart deleted file mode 100644 index 894a9ec..0000000 --- a/cargokit/build_tool/lib/src/builder.dart +++ /dev/null @@ -1,206 +0,0 @@ -import 'package:collection/collection.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'android_environment.dart'; -import 'cargo.dart'; -import 'environment.dart'; -import 'options.dart'; -import 'rustup.dart'; -import 'target.dart'; -import 'util.dart'; - -final _log = Logger('builder'); - -enum BuildConfiguration { - debug, - release, - profile, -} - -extension on BuildConfiguration { - bool get isDebug => this == BuildConfiguration.debug; - String get rustName => switch (this) { - BuildConfiguration.debug => 'debug', - BuildConfiguration.release => 'release', - BuildConfiguration.profile => 'release', - }; -} - -class BuildException implements Exception { - final String message; - - BuildException(this.message); - - @override - String toString() { - return 'BuildException: $message'; - } -} - -class BuildEnvironment { - final BuildConfiguration configuration; - final CargokitCrateOptions crateOptions; - final String targetTempDir; - final String manifestDir; - final CrateInfo crateInfo; - - final bool isAndroid; - final String? androidSdkPath; - final String? androidNdkVersion; - final int? androidMinSdkVersion; - final String? javaHome; - - final String? glibcVersion; - - BuildEnvironment({ - required this.configuration, - required this.crateOptions, - required this.targetTempDir, - required this.manifestDir, - required this.crateInfo, - required this.isAndroid, - this.androidSdkPath, - this.androidNdkVersion, - this.androidMinSdkVersion, - this.javaHome, - this.glibcVersion, - }); - - static BuildConfiguration parseBuildConfiguration(String value) { - // XCode configuration adds the flavor to configuration name. - final firstSegment = value.split('-').first; - final buildConfiguration = BuildConfiguration.values.firstWhereOrNull( - (e) => e.name == firstSegment, - ); - if (buildConfiguration == null) { - _log.warning('Unknown build configuraiton $value, will assume release'); - return BuildConfiguration.release; - } - return buildConfiguration; - } - - static BuildEnvironment fromEnvironment({ - required bool isAndroid, - }) { - final buildConfiguration = - parseBuildConfiguration(Environment.configuration); - final manifestDir = Environment.manifestDir; - final crateOptions = CargokitCrateOptions.load( - manifestDir: manifestDir, - ); - final crateInfo = CrateInfo.load(manifestDir); - return BuildEnvironment( - configuration: buildConfiguration, - crateOptions: crateOptions, - targetTempDir: Environment.targetTempDir, - manifestDir: manifestDir, - crateInfo: crateInfo, - isAndroid: isAndroid, - androidSdkPath: isAndroid ? Environment.sdkPath : null, - androidNdkVersion: isAndroid ? Environment.ndkVersion : null, - androidMinSdkVersion: - isAndroid ? int.parse(Environment.minSdkVersion) : null, - javaHome: isAndroid ? Environment.javaHome : null, - ); - } -} - -class RustBuilder { - final Target target; - final BuildEnvironment environment; - - RustBuilder({ - required this.target, - required this.environment, - }); - - void prepare( - Rustup rustup, - ) { - final toolchain = _toolchain; - if (rustup.installedTargets(toolchain) == null) { - rustup.installToolchain(toolchain); - } - if (toolchain == 'nightly') { - rustup.installRustSrcForNightly(); - } - if (!rustup.installedTargets(toolchain)!.contains(target.rust)) { - rustup.installTarget(target.rust, toolchain: toolchain); - } - if (environment.glibcVersion != null) { - rustup.installZigBuild(toolchain); - } - } - - CargoBuildOptions? get _buildOptions => - environment.crateOptions.cargo[environment.configuration]; - - String get _toolchain => _buildOptions?.toolchain.name ?? 'stable'; - - /// Returns the path of directory containing build artifacts. - Future build() async { - final extraArgs = _buildOptions?.flags ?? []; - final manifestPath = path.join(environment.manifestDir, 'Cargo.toml'); - runCommand( - 'rustup', - [ - 'run', - _toolchain, - 'cargo', - (target.android == null && environment.glibcVersion != null) - ? 'zigbuild' - : 'build', - ...extraArgs, - '--manifest-path', - manifestPath, - '-p', - environment.crateInfo.packageName, - if (!environment.configuration.isDebug) '--release', - '--target', - target.rust + - ((target.android == null && environment.glibcVersion != null) - ? '.${environment.glibcVersion!}' - : ""), - '--target-dir', - environment.targetTempDir, - ], - environment: await _buildEnvironment(), - ); - return path.join( - environment.targetTempDir, - target.rust, - environment.configuration.rustName, - ); - } - - Future> _buildEnvironment() async { - if (target.android == null) { - return {}; - } else { - final sdkPath = environment.androidSdkPath; - final ndkVersion = environment.androidNdkVersion; - final minSdkVersion = environment.androidMinSdkVersion; - if (sdkPath == null) { - throw BuildException('androidSdkPath is not set'); - } - if (ndkVersion == null) { - throw BuildException('androidNdkVersion is not set'); - } - if (minSdkVersion == null) { - throw BuildException('androidMinSdkVersion is not set'); - } - final env = AndroidEnvironment( - sdkPath: sdkPath, - ndkVersion: ndkVersion, - minSdkVersion: minSdkVersion, - targetTempDir: environment.targetTempDir, - target: target, - ); - if (!env.ndkIsInstalled() && environment.javaHome != null) { - env.installNdk(javaHome: environment.javaHome!); - } - return env.buildEnvironment(); - } - } -} diff --git a/cargokit/build_tool/lib/src/cargo.dart b/cargokit/build_tool/lib/src/cargo.dart deleted file mode 100644 index 0d4483f..0000000 --- a/cargokit/build_tool/lib/src/cargo.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'dart:io'; - -import 'package:path/path.dart' as path; -import 'package:toml/toml.dart'; - -class ManifestException { - ManifestException(this.message, {required this.fileName}); - - final String? fileName; - final String message; - - @override - String toString() { - if (fileName != null) { - return 'Failed to parse package manifest at $fileName: $message'; - } else { - return 'Failed to parse package manifest: $message'; - } - } -} - -class CrateInfo { - CrateInfo({required this.packageName}); - - final String packageName; - - static CrateInfo parseManifest(String manifest, {final String? fileName}) { - final toml = TomlDocument.parse(manifest); - final package = toml.toMap()['package']; - if (package == null) { - throw ManifestException('Missing package section', fileName: fileName); - } - final name = package['name']; - if (name == null) { - throw ManifestException('Missing package name', fileName: fileName); - } - return CrateInfo(packageName: name); - } - - static CrateInfo load(String manifestDir) { - final manifestFile = File(path.join(manifestDir, 'Cargo.toml')); - final manifest = manifestFile.readAsStringSync(); - return parseManifest(manifest, fileName: manifestFile.path); - } -} diff --git a/cargokit/build_tool/lib/src/crate_hash.dart b/cargokit/build_tool/lib/src/crate_hash.dart deleted file mode 100644 index e58c37f..0000000 --- a/cargokit/build_tool/lib/src/crate_hash.dart +++ /dev/null @@ -1,121 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:collection/collection.dart'; -import 'package:convert/convert.dart'; -import 'package:crypto/crypto.dart'; -import 'package:path/path.dart' as path; - -class CrateHash { - /// Computes a hash uniquely identifying crate content. This takes into account - /// content all all .rs files inside the src directory, as well as Cargo.toml, - /// Cargo.lock, build.rs and cargokit.yaml. - /// - /// If [tempStorage] is provided, computed hash is stored in a file in that directory - /// and reused on subsequent calls if the crate content hasn't changed. - static String compute(String manifestDir, {String? tempStorage}) { - return CrateHash._( - manifestDir: manifestDir, - tempStorage: tempStorage, - )._compute(); - } - - CrateHash._({ - required this.manifestDir, - required this.tempStorage, - }); - - String _compute() { - final files = getFiles(); - final tempStorage = this.tempStorage; - if (tempStorage != null) { - final quickHash = _computeQuickHash(files); - final quickHashFolder = Directory(path.join(tempStorage, 'crate_hash')); - quickHashFolder.createSync(recursive: true); - final quickHashFile = File(path.join(quickHashFolder.path, quickHash)); - if (quickHashFile.existsSync()) { - return quickHashFile.readAsStringSync(); - } - final hash = _computeHash(files); - quickHashFile.writeAsStringSync(hash); - return hash; - } else { - return _computeHash(files); - } - } - - /// Computes a quick hash based on files stat (without reading contents). This - /// is used to cache the real hash, which is slower to compute since it involves - /// reading every single file. - String _computeQuickHash(List files) { - final output = AccumulatorSink(); - final input = sha256.startChunkedConversion(output); - - final data = ByteData(8); - for (final file in files) { - input.add(utf8.encode(file.path)); - final stat = file.statSync(); - data.setUint64(0, stat.size); - input.add(data.buffer.asUint8List()); - data.setUint64(0, stat.modified.millisecondsSinceEpoch); - input.add(data.buffer.asUint8List()); - } - - input.close(); - return base64Url.encode(output.events.single.bytes); - } - - String _computeHash(List files) { - final output = AccumulatorSink(); - final input = sha256.startChunkedConversion(output); - - void addTextFile(File file) { - // text Files are hashed by lines in case we're dealing with github checkout - // that auto-converts line endings. - final splitter = LineSplitter(); - if (file.existsSync()) { - final data = file.readAsStringSync(); - final lines = splitter.convert(data); - for (final line in lines) { - input.add(utf8.encode(line)); - } - } - } - - for (final file in files) { - addTextFile(file); - } - - input.close(); - final res = output.events.single; - - // Truncate to 128bits. - final hash = res.bytes.sublist(0, 16); - return hex.encode(hash); - } - - List getFiles() { - final src = Directory(path.join(manifestDir, 'src')); - final files = src - .listSync(recursive: true, followLinks: false) - .whereType() - .toList(); - files.sortBy((element) => element.path); - void addFile(String relative) { - final file = File(path.join(manifestDir, relative)); - if (file.existsSync()) { - files.add(file); - } - } - - addFile('Cargo.toml'); - addFile('Cargo.lock'); - addFile('build.rs'); - addFile('cargokit.yaml'); - return files; - } - - final String manifestDir; - final String? tempStorage; -} diff --git a/cargokit/build_tool/lib/src/environment.dart b/cargokit/build_tool/lib/src/environment.dart deleted file mode 100644 index 1d267ed..0000000 --- a/cargokit/build_tool/lib/src/environment.dart +++ /dev/null @@ -1,65 +0,0 @@ -import 'dart:io'; - -extension on String { - String resolveSymlink() => File(this).resolveSymbolicLinksSync(); -} - -class Environment { - /// Current build configuration (debug or release). - static String get configuration => - _getEnv("CARGOKIT_CONFIGURATION").toLowerCase(); - - static bool get isDebug => configuration == 'debug'; - static bool get isRelease => configuration == 'release'; - - /// Temporary directory where Rust build artifacts are placed. - static String get targetTempDir => _getEnv("CARGOKIT_TARGET_TEMP_DIR"); - - /// Final output directory where the build artifacts are placed. - static String get outputDir => _getEnvPath('CARGOKIT_OUTPUT_DIR'); - - /// Path to the crate manifest (containing Cargo.toml). - static String get manifestDir => _getEnvPath('CARGOKIT_MANIFEST_DIR'); - - /// Directory inside root project. Not necessarily root folder. Symlinks are - /// not resolved on purpose. - static String get rootProjectDir => _getEnv('CARGOKIT_ROOT_PROJECT_DIR'); - - // Pod - - /// Platform name (macosx, iphoneos, iphonesimulator). - static String get darwinPlatformName => - _getEnv("CARGOKIT_DARWIN_PLATFORM_NAME"); - - /// List of architectures to build for (arm64, armv7, x86_64). - static List get darwinArchs => - _getEnv("CARGOKIT_DARWIN_ARCHS").split(' '); - - // Gradle - static String get minSdkVersion => _getEnv("CARGOKIT_MIN_SDK_VERSION"); - static String get ndkVersion => _getEnv("CARGOKIT_NDK_VERSION"); - static String get sdkPath => _getEnvPath("CARGOKIT_SDK_DIR"); - static String get javaHome => _getEnvPath("CARGOKIT_JAVA_HOME"); - static List get targetPlatforms => - _getEnv("CARGOKIT_TARGET_PLATFORMS").split(','); - - // CMAKE - static String get targetPlatform => _getEnv("CARGOKIT_TARGET_PLATFORM"); - - static String _getEnv(String key) { - final res = Platform.environment[key]; - if (res == null) { - throw Exception("Missing environment variable $key"); - } - return res; - } - - static String _getEnvPath(String key) { - final res = _getEnv(key); - if (Directory(res).existsSync()) { - return res.resolveSymlink(); - } else { - return res; - } - } -} diff --git a/cargokit/build_tool/lib/src/logging.dart b/cargokit/build_tool/lib/src/logging.dart deleted file mode 100644 index 06392b9..0000000 --- a/cargokit/build_tool/lib/src/logging.dart +++ /dev/null @@ -1,49 +0,0 @@ -import 'dart:io'; - -import 'package:logging/logging.dart'; - -const String kSeparator = "--"; -const String kDoubleSeparator = "=="; - -bool _lastMessageWasSeparator = false; - -void _log(LogRecord rec) { - final prefix = '${rec.level.name}: '; - final out = rec.level == Level.SEVERE ? stderr : stdout; - if (rec.message == kSeparator) { - if (!_lastMessageWasSeparator) { - out.write(prefix); - out.writeln('-' * 80); - _lastMessageWasSeparator = true; - } - return; - } else if (rec.message == kDoubleSeparator) { - out.write(prefix); - out.writeln('=' * 80); - _lastMessageWasSeparator = true; - return; - } - out.write(prefix); - out.writeln(rec.message); - _lastMessageWasSeparator = false; -} - -void initLogging() { - Logger.root.level = Level.INFO; - Logger.root.onRecord.listen((LogRecord rec) { - final lines = rec.message.split('\n'); - for (final line in lines) { - if (line.isNotEmpty || lines.length == 1 || line != lines.last) { - _log(LogRecord( - rec.level, - line, - rec.loggerName, - )); - } - } - }); -} - -void enableVerboseLogging() { - Logger.root.level = Level.ALL; -} diff --git a/cargokit/build_tool/lib/src/options.dart b/cargokit/build_tool/lib/src/options.dart deleted file mode 100644 index 7937dca..0000000 --- a/cargokit/build_tool/lib/src/options.dart +++ /dev/null @@ -1,306 +0,0 @@ -import 'dart:io'; - -import 'package:collection/collection.dart'; -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:hex/hex.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; -import 'package:source_span/source_span.dart'; -import 'package:yaml/yaml.dart'; - -import 'builder.dart'; -import 'environment.dart'; -import 'rustup.dart'; - -final _log = Logger('options'); - -/// A class for exceptions that have source span information attached. -class SourceSpanException implements Exception { - // This is a getter so that subclasses can override it. - /// A message describing the exception. - String get message => _message; - final String _message; - - // This is a getter so that subclasses can override it. - /// The span associated with this exception. - /// - /// This may be `null` if the source location can't be determined. - SourceSpan? get span => _span; - final SourceSpan? _span; - - SourceSpanException(this._message, this._span); - - /// Returns a string representation of `this`. - /// - /// [color] may either be a [String], a [bool], or `null`. If it's a string, - /// it indicates an ANSI terminal color escape that should be used to - /// highlight the span's text. If it's `true`, it indicates that the text - /// should be highlighted using the default color. If it's `false` or `null`, - /// it indicates that the text shouldn't be highlighted. - @override - String toString({Object? color}) { - if (span == null) return message; - return 'Error on ${span!.message(message, color: color)}'; - } -} - -enum Toolchain { - stable, - beta, - nightly, -} - -class CargoBuildOptions { - final Toolchain toolchain; - final List flags; - - CargoBuildOptions({ - required this.toolchain, - required this.flags, - }); - - static Toolchain _toolchainFromNode(YamlNode node) { - if (node case YamlScalar(value: String name)) { - final toolchain = - Toolchain.values.firstWhereOrNull((element) => element.name == name); - if (toolchain != null) { - return toolchain; - } - } - throw SourceSpanException( - 'Unknown toolchain. Must be one of ${Toolchain.values.map((e) => e.name)}.', - node.span); - } - - static CargoBuildOptions parse(YamlNode node) { - if (node is! YamlMap) { - throw SourceSpanException('Cargo options must be a map', node.span); - } - Toolchain toolchain = Toolchain.stable; - List flags = []; - for (final MapEntry(:key, :value) in node.nodes.entries) { - if (key case YamlScalar(value: 'toolchain')) { - toolchain = _toolchainFromNode(value); - } else if (key case YamlScalar(value: 'extra_flags')) { - if (value case YamlList(nodes: List list)) { - if (list.every((element) { - if (element case YamlScalar(value: String _)) { - return true; - } - return false; - })) { - flags = list.map((e) => e.value as String).toList(); - continue; - } - } - throw SourceSpanException( - 'Extra flags must be a list of strings', value.span); - } else { - throw SourceSpanException( - 'Unknown cargo option type. Must be "toolchain" or "extra_flags".', - key.span); - } - } - return CargoBuildOptions(toolchain: toolchain, flags: flags); - } -} - -extension on YamlMap { - /// Map that extracts keys so that we can do map case check on them. - Map get valueMap => - nodes.map((key, value) => MapEntry(key.value, value)); -} - -class PrecompiledBinaries { - final String uriPrefix; - final PublicKey publicKey; - - PrecompiledBinaries({ - required this.uriPrefix, - required this.publicKey, - }); - - static PublicKey _publicKeyFromHex(String key, SourceSpan? span) { - final bytes = HEX.decode(key); - if (bytes.length != 32) { - throw SourceSpanException( - 'Invalid public key. Must be 32 bytes long.', span); - } - return PublicKey(bytes); - } - - static PrecompiledBinaries parse(YamlNode node) { - if (node case YamlMap(valueMap: Map map)) { - if (map - case { - 'url_prefix': YamlNode urlPrefixNode, - 'public_key': YamlNode publicKeyNode, - }) { - final urlPrefix = switch (urlPrefixNode) { - YamlScalar(value: String urlPrefix) => urlPrefix, - _ => throw SourceSpanException( - 'Invalid URL prefix value.', urlPrefixNode.span), - }; - final publicKey = switch (publicKeyNode) { - YamlScalar(value: String publicKey) => - _publicKeyFromHex(publicKey, publicKeyNode.span), - _ => throw SourceSpanException( - 'Invalid public key value.', publicKeyNode.span), - }; - return PrecompiledBinaries( - uriPrefix: urlPrefix, - publicKey: publicKey, - ); - } - } - throw SourceSpanException( - 'Invalid precompiled binaries value. ' - 'Expected Map with "url_prefix" and "public_key".', - node.span); - } -} - -/// Cargokit options specified for Rust crate. -class CargokitCrateOptions { - CargokitCrateOptions({ - this.cargo = const {}, - this.precompiledBinaries, - }); - - final Map cargo; - final PrecompiledBinaries? precompiledBinaries; - - static CargokitCrateOptions parse(YamlNode node) { - if (node is! YamlMap) { - throw SourceSpanException('Cargokit options must be a map', node.span); - } - final options = {}; - PrecompiledBinaries? precompiledBinaries; - - for (final entry in node.nodes.entries) { - if (entry - case MapEntry( - key: YamlScalar(value: 'cargo'), - value: YamlNode node, - )) { - if (node is! YamlMap) { - throw SourceSpanException('Cargo options must be a map', node.span); - } - for (final MapEntry(:YamlNode key, :value) in node.nodes.entries) { - if (key case YamlScalar(value: String name)) { - final configuration = BuildConfiguration.values - .firstWhereOrNull((element) => element.name == name); - if (configuration != null) { - options[configuration] = CargoBuildOptions.parse(value); - continue; - } - } - throw SourceSpanException( - 'Unknown build configuration. Must be one of ${BuildConfiguration.values.map((e) => e.name)}.', - key.span); - } - } else if (entry.key case YamlScalar(value: 'precompiled_binaries')) { - precompiledBinaries = PrecompiledBinaries.parse(entry.value); - } else { - throw SourceSpanException( - 'Unknown cargokit option type. Must be "cargo" or "precompiled_binaries".', - entry.key.span); - } - } - return CargokitCrateOptions( - cargo: options, - precompiledBinaries: precompiledBinaries, - ); - } - - static CargokitCrateOptions load({ - required String manifestDir, - }) { - final uri = Uri.file(path.join(manifestDir, "cargokit.yaml")); - final file = File.fromUri(uri); - if (file.existsSync()) { - final contents = loadYamlNode(file.readAsStringSync(), sourceUrl: uri); - return parse(contents); - } else { - return CargokitCrateOptions(); - } - } -} - -class CargokitUserOptions { - // When Rustup is installed always build locally unless user opts into - // using precompiled binaries. - static bool defaultUsePrecompiledBinaries() { - return Rustup.executablePath() == null; - } - - CargokitUserOptions({ - required this.usePrecompiledBinaries, - required this.verboseLogging, - }); - - CargokitUserOptions._() - : usePrecompiledBinaries = defaultUsePrecompiledBinaries(), - verboseLogging = false; - - static CargokitUserOptions parse(YamlNode node) { - if (node is! YamlMap) { - throw SourceSpanException('Cargokit options must be a map', node.span); - } - bool usePrecompiledBinaries = defaultUsePrecompiledBinaries(); - bool verboseLogging = false; - - for (final entry in node.nodes.entries) { - if (entry.key case YamlScalar(value: 'use_precompiled_binaries')) { - if (entry.value case YamlScalar(value: bool value)) { - usePrecompiledBinaries = value; - continue; - } - throw SourceSpanException( - 'Invalid value for "use_precompiled_binaries". Must be a boolean.', - entry.value.span); - } else if (entry.key case YamlScalar(value: 'verbose_logging')) { - if (entry.value case YamlScalar(value: bool value)) { - verboseLogging = value; - continue; - } - throw SourceSpanException( - 'Invalid value for "verbose_logging". Must be a boolean.', - entry.value.span); - } else { - throw SourceSpanException( - 'Unknown cargokit option type. Must be "use_precompiled_binaries" or "verbose_logging".', - entry.key.span); - } - } - return CargokitUserOptions( - usePrecompiledBinaries: usePrecompiledBinaries, - verboseLogging: verboseLogging, - ); - } - - static CargokitUserOptions load() { - String fileName = "cargokit_options.yaml"; - var userProjectDir = Directory(Environment.rootProjectDir); - - while (userProjectDir.parent.path != userProjectDir.path) { - final configFile = File(path.join(userProjectDir.path, fileName)); - if (configFile.existsSync()) { - final contents = loadYamlNode( - configFile.readAsStringSync(), - sourceUrl: configFile.uri, - ); - final res = parse(contents); - if (res.verboseLogging) { - _log.info('Found user options file at ${configFile.path}'); - } - return res; - } - userProjectDir = userProjectDir.parent; - } - return CargokitUserOptions._(); - } - - final bool usePrecompiledBinaries; - final bool verboseLogging; -} diff --git a/cargokit/build_tool/lib/src/precompile_binaries.dart b/cargokit/build_tool/lib/src/precompile_binaries.dart deleted file mode 100644 index 201874b..0000000 --- a/cargokit/build_tool/lib/src/precompile_binaries.dart +++ /dev/null @@ -1,202 +0,0 @@ -import 'dart:io'; - -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:github/github.dart'; -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'artifacts_provider.dart'; -import 'builder.dart'; -import 'cargo.dart'; -import 'crate_hash.dart'; -import 'options.dart'; -import 'rustup.dart'; -import 'target.dart'; - -final _log = Logger('precompile_binaries'); - -class PrecompileBinaries { - PrecompileBinaries({ - required this.privateKey, - required this.githubToken, - required this.repositorySlug, - required this.manifestDir, - required this.targets, - this.androidSdkLocation, - this.androidNdkVersion, - this.androidMinSdkVersion, - this.tempDir, - this.glibcVersion, - }); - - final PrivateKey privateKey; - final String githubToken; - final RepositorySlug repositorySlug; - final String manifestDir; - final List targets; - final String? androidSdkLocation; - final String? androidNdkVersion; - final int? androidMinSdkVersion; - final String? tempDir; - final String? glibcVersion; - - static String fileName(Target target, String name) { - return '${target.rust}_$name'; - } - - static String signatureFileName(Target target, String name) { - return '${target.rust}_$name.sig'; - } - - Future run() async { - final crateInfo = CrateInfo.load(manifestDir); - - final targets = List.of(this.targets); - if (targets.isEmpty) { - targets.addAll([ - ...Target.buildableTargets(), - if (androidSdkLocation != null) ...Target.androidTargets(), - ]); - } - - _log.info('Precompiling binaries for $targets'); - - final hash = CrateHash.compute(manifestDir); - _log.info('Computed crate hash: $hash'); - - final String tagName = 'precompiled_$hash'; - - final github = GitHub(auth: Authentication.withToken(githubToken)); - final repo = github.repositories; - final release = await _getOrCreateRelease( - repo: repo, - tagName: tagName, - packageName: crateInfo.packageName, - hash: hash, - ); - - final tempDir = this.tempDir != null - ? Directory(this.tempDir!) - : Directory.systemTemp.createTempSync('precompiled_'); - - tempDir.createSync(recursive: true); - - final crateOptions = CargokitCrateOptions.load( - manifestDir: manifestDir, - ); - - final buildEnvironment = BuildEnvironment( - configuration: BuildConfiguration.release, - crateOptions: crateOptions, - targetTempDir: tempDir.path, - manifestDir: manifestDir, - crateInfo: crateInfo, - isAndroid: androidSdkLocation != null, - androidSdkPath: androidSdkLocation, - androidNdkVersion: androidNdkVersion, - androidMinSdkVersion: androidMinSdkVersion, - glibcVersion: glibcVersion, - ); - - final rustup = Rustup(); - - for (final target in targets) { - final artifactNames = getArtifactNames( - target: target, - libraryName: crateInfo.packageName, - remote: true, - ); - - if (artifactNames.every((name) { - final fileName = PrecompileBinaries.fileName(target, name); - return (release.assets ?? []).any((e) => e.name == fileName); - })) { - _log.info("All artifacts for $target already exist - skipping"); - continue; - } - - _log.info('Building for $target'); - - final builder = - RustBuilder(target: target, environment: buildEnvironment); - builder.prepare(rustup); - final res = await builder.build(); - - final assets = []; - for (final name in artifactNames) { - final file = File(path.join(res, name)); - if (!file.existsSync()) { - throw Exception('Missing artifact: ${file.path}'); - } - - final data = file.readAsBytesSync(); - final create = CreateReleaseAsset( - name: PrecompileBinaries.fileName(target, name), - contentType: "application/octet-stream", - assetData: data, - ); - final signature = sign(privateKey, data); - final signatureCreate = CreateReleaseAsset( - name: signatureFileName(target, name), - contentType: "application/octet-stream", - assetData: signature, - ); - bool verified = verify(public(privateKey), data, signature); - if (!verified) { - throw Exception('Signature verification failed'); - } - assets.add(create); - assets.add(signatureCreate); - } - _log.info('Uploading assets: ${assets.map((e) => e.name)}'); - for (final asset in assets) { - // This seems to be failing on CI so do it one by one - int retryCount = 0; - while (true) { - try { - await repo.uploadReleaseAssets(release, [asset]); - break; - } on Exception catch (e) { - if (retryCount == 10) { - rethrow; - } - ++retryCount; - _log.shout( - 'Upload failed (attempt $retryCount, will retry): ${e.toString()}'); - await Future.delayed(Duration(seconds: 2)); - } - } - } - } - - _log.info('Cleaning up'); - tempDir.deleteSync(recursive: true); - } - - Future _getOrCreateRelease({ - required RepositoriesService repo, - required String tagName, - required String packageName, - required String hash, - }) async { - Release release; - try { - _log.info('Fetching release $tagName'); - release = await repo.getReleaseByTagName(repositorySlug, tagName); - } on ReleaseNotFound { - _log.info('Release not found - creating release $tagName'); - release = await repo.createRelease( - repositorySlug, - CreateRelease.from( - tagName: tagName, - name: 'Precompiled binaries ${hash.substring(0, 8)}', - targetCommitish: null, - isDraft: false, - isPrerelease: false, - body: 'Precompiled binaries for crate $packageName, ' - 'crate hash $hash.', - )); - } - return release; - } -} diff --git a/cargokit/build_tool/lib/src/rustup.dart b/cargokit/build_tool/lib/src/rustup.dart deleted file mode 100644 index 715b6d0..0000000 --- a/cargokit/build_tool/lib/src/rustup.dart +++ /dev/null @@ -1,146 +0,0 @@ -import 'dart:io'; - -import 'package:collection/collection.dart'; -import 'package:path/path.dart' as path; - -import 'util.dart'; - -class _Toolchain { - _Toolchain( - this.name, - this.targets, - ); - - final String name; - final List targets; -} - -class Rustup { - List? installedTargets(String toolchain) { - final targets = _installedTargets(toolchain); - return targets != null ? List.unmodifiable(targets) : null; - } - - void installToolchain(String toolchain) { - log.info("Installing Rust toolchain: $toolchain"); - runCommand("rustup", ['toolchain', 'install', toolchain]); - _installedToolchains - .add(_Toolchain(toolchain, _getInstalledTargets(toolchain))); - } - - void installTarget( - String target, { - required String toolchain, - }) { - log.info("Installing Rust target: $target"); - runCommand("rustup", ['target', 'add', '--toolchain', toolchain, target]); - _installedTargets(toolchain)?.add(target); - } - - bool _didInstallZigBuild = false; - - void installZigBuild(String toolchain) { - if (_didInstallZigBuild) { - return; - } - - log.info("Installing Zig build"); - runCommand("rustup", [ - 'run', - toolchain, - 'cargo', - 'install', - '--locked', - 'cargo-zigbuild', - ]); - _didInstallZigBuild = true; - } - - final List<_Toolchain> _installedToolchains; - - Rustup() : _installedToolchains = _getInstalledToolchains(); - - List? _installedTargets(String toolchain) => _installedToolchains - .firstWhereOrNull( - (e) => e.name == toolchain || e.name.startsWith('$toolchain-')) - ?.targets; - - static List<_Toolchain> _getInstalledToolchains() { - String extractToolchainName(String line) { - // ignore (default) after toolchain name - final parts = line.split(' '); - return parts[0]; - } - - final res = runCommand("rustup", ['toolchain', 'list']); - - // To list all non-custom toolchains, we need to filter out lines that - // don't start with "stable", "beta", or "nightly". - Pattern nonCustom = RegExp(r"^(stable|beta|nightly)"); - final lines = res.stdout - .toString() - .split('\n') - .where((e) => e.isNotEmpty && e.startsWith(nonCustom)) - .map(extractToolchainName) - .toList(growable: true); - - return lines - .map( - (name) => _Toolchain( - name, - _getInstalledTargets(name), - ), - ) - .toList(growable: true); - } - - static List _getInstalledTargets(String toolchain) { - final res = runCommand("rustup", [ - 'target', - 'list', - '--toolchain', - toolchain, - '--installed', - ]); - final lines = res.stdout - .toString() - .split('\n') - .where((e) => e.isNotEmpty) - .toList(growable: true); - return lines; - } - - bool _didInstallRustSrcForNightly = false; - - void installRustSrcForNightly() { - if (_didInstallRustSrcForNightly) { - return; - } - // Useful for -Z build-std - runCommand( - "rustup", - ['component', 'add', 'rust-src', '--toolchain', 'nightly'], - ); - _didInstallRustSrcForNightly = true; - } - - static String? executablePath() { - final envPath = Platform.environment['PATH']; - final envPathSeparator = Platform.isWindows ? ';' : ':'; - final home = Platform.isWindows - ? Platform.environment['USERPROFILE'] - : Platform.environment['HOME']; - final paths = [ - if (home != null) path.join(home, '.cargo', 'bin'), - if (envPath != null) ...envPath.split(envPathSeparator), - ]; - for (final p in paths) { - final rustup = Platform.isWindows ? 'rustup.exe' : 'rustup'; - final rustupPath = path.join(p, rustup); - if (File(rustupPath).existsSync()) { - return rustupPath; - } - } - return null; - } -} diff --git a/cargokit/build_tool/lib/src/target.dart b/cargokit/build_tool/lib/src/target.dart deleted file mode 100644 index a5c25fc..0000000 --- a/cargokit/build_tool/lib/src/target.dart +++ /dev/null @@ -1,144 +0,0 @@ -import 'dart:io'; - -import 'package:collection/collection.dart'; - -import 'util.dart'; - -class Target { - Target({ - required this.rust, - this.flutter, - this.android, - this.androidMinSdkVersion, - this.darwinPlatform, - this.darwinArch, - }); - - static final all = [ - Target( - rust: 'armv7-linux-androideabi', - flutter: 'android-arm', - android: 'armeabi-v7a', - androidMinSdkVersion: 16, - ), - Target( - rust: 'aarch64-linux-android', - flutter: 'android-arm64', - android: 'arm64-v8a', - androidMinSdkVersion: 21, - ), - Target( - rust: 'i686-linux-android', - flutter: 'android-x86', - android: 'x86', - androidMinSdkVersion: 16, - ), - Target( - rust: 'x86_64-linux-android', - flutter: 'android-x64', - android: 'x86_64', - androidMinSdkVersion: 21, - ), - Target( - rust: 'x86_64-pc-windows-msvc', - flutter: 'windows-x64', - ), - Target( - rust: 'aarch64-pc-windows-msvc', - flutter: 'windows-arm64', - ), - Target( - rust: 'x86_64-unknown-linux-gnu', - flutter: 'linux-x64', - ), - Target( - rust: 'aarch64-unknown-linux-gnu', - flutter: 'linux-arm64', - ), - Target(rust: 'riscv64gc-unknown-linux-gnu', flutter: 'linux-riscv64'), - Target( - rust: 'x86_64-apple-darwin', - darwinPlatform: 'macosx', - darwinArch: 'x86_64', - ), - Target( - rust: 'aarch64-apple-darwin', - darwinPlatform: 'macosx', - darwinArch: 'arm64', - ), - Target( - rust: 'aarch64-apple-ios', - darwinPlatform: 'iphoneos', - darwinArch: 'arm64', - ), - Target( - rust: 'aarch64-apple-ios-sim', - darwinPlatform: 'iphonesimulator', - darwinArch: 'arm64', - ), - Target( - rust: 'x86_64-apple-ios', - darwinPlatform: 'iphonesimulator', - darwinArch: 'x86_64', - ), - ]; - - static Target? forFlutterName(String flutterName) { - return all.firstWhereOrNull((element) => element.flutter == flutterName); - } - - static Target? forDarwin({ - required String platformName, - required String darwinAarch, - }) { - return all.firstWhereOrNull((element) => // - element.darwinPlatform == platformName && - element.darwinArch == darwinAarch); - } - - static Target? forRustTriple(String triple) { - return all.firstWhereOrNull((element) => element.rust == triple); - } - - static List androidTargets() { - return all - .where((element) => element.android != null) - .toList(growable: false); - } - - /// Returns buildable targets on current host platform ignoring Android targets. - static List buildableTargets() { - if (Platform.isLinux) { - // Right now we don't support cross-compiling on Linux. So we just return - // the host target. - final arch = (runCommand('arch', []).stdout as String).trim(); - if (arch == 'aarch64') { - return [Target.forRustTriple('aarch64-unknown-linux-gnu')!]; - } else if (arch == 'riscv64') { - return [Target.forRustTriple('riscv64gc-unknown-linux-gnu')!]; - } else { - return [Target.forRustTriple('x86_64-unknown-linux-gnu')!]; - } - } - return all.where((target) { - if (Platform.isWindows) { - return target.rust.contains('-windows-'); - } else if (Platform.isMacOS) { - return target.darwinPlatform != null; - } - return false; - }).toList(growable: false); - } - - @override - String toString() { - return rust; - } - - final String? flutter; - final String rust; - final String? android; - final int? androidMinSdkVersion; - final String? darwinPlatform; - final String? darwinArch; -} diff --git a/cargokit/build_tool/lib/src/util.dart b/cargokit/build_tool/lib/src/util.dart deleted file mode 100644 index d8e3019..0000000 --- a/cargokit/build_tool/lib/src/util.dart +++ /dev/null @@ -1,169 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:logging/logging.dart'; -import 'package:path/path.dart' as path; - -import 'logging.dart'; -import 'rustup.dart'; - -final log = Logger("process"); - -class CommandFailedException implements Exception { - final String executable; - final List arguments; - final ProcessResult result; - - CommandFailedException({ - required this.executable, - required this.arguments, - required this.result, - }); - - @override - String toString() { - final stdout = result.stdout.toString().trim(); - final stderr = result.stderr.toString().trim(); - return [ - "External Command: $executable ${arguments.map((e) => '"$e"').join(' ')}", - "Returned Exit Code: ${result.exitCode}", - kSeparator, - "STDOUT:", - if (stdout.isNotEmpty) stdout, - kSeparator, - "STDERR:", - if (stderr.isNotEmpty) stderr, - ].join('\n'); - } -} - -class TestRunCommandArgs { - final String executable; - final List arguments; - final String? workingDirectory; - final Map? environment; - final bool includeParentEnvironment; - final bool runInShell; - final Encoding? stdoutEncoding; - final Encoding? stderrEncoding; - - TestRunCommandArgs({ - required this.executable, - required this.arguments, - this.workingDirectory, - this.environment, - this.includeParentEnvironment = true, - this.runInShell = false, - this.stdoutEncoding, - this.stderrEncoding, - }); -} - -class TestRunCommandResult { - TestRunCommandResult({ - this.pid = 1, - this.exitCode = 0, - this.stdout = '', - this.stderr = '', - }); - - final int pid; - final int exitCode; - final String stdout; - final String stderr; -} - -TestRunCommandResult Function(TestRunCommandArgs args)? testRunCommandOverride; - -ProcessResult runCommand( - String executable, - List arguments, { - String? workingDirectory, - Map? environment, - bool includeParentEnvironment = true, - bool runInShell = false, - Encoding? stdoutEncoding = systemEncoding, - Encoding? stderrEncoding = systemEncoding, -}) { - if (testRunCommandOverride != null) { - final result = testRunCommandOverride!(TestRunCommandArgs( - executable: executable, - arguments: arguments, - workingDirectory: workingDirectory, - environment: environment, - includeParentEnvironment: includeParentEnvironment, - runInShell: runInShell, - stdoutEncoding: stdoutEncoding, - stderrEncoding: stderrEncoding, - )); - return ProcessResult( - result.pid, - result.exitCode, - result.stdout, - result.stderr, - ); - } - log.finer('Running command $executable ${arguments.join(' ')}'); - final res = Process.runSync( - _resolveExecutable(executable), - arguments, - workingDirectory: workingDirectory, - environment: environment, - includeParentEnvironment: includeParentEnvironment, - runInShell: runInShell, - stderrEncoding: stderrEncoding, - stdoutEncoding: stdoutEncoding, - ); - if (res.exitCode != 0) { - throw CommandFailedException( - executable: executable, - arguments: arguments, - result: res, - ); - } else { - return res; - } -} - -class RustupNotFoundException implements Exception { - @override - String toString() { - return [ - ' ', - 'rustup not found in PATH.', - ' ', - 'Maybe you need to install Rust? It only takes a minute:', - ' ', - if (Platform.isWindows) 'https://www.rust-lang.org/tools/install', - if (hasHomebrewRustInPath()) ...[ - '\$ brew unlink rust # Unlink homebrew Rust from PATH', - ], - if (!Platform.isWindows) - "\$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh", - ' ', - ].join('\n'); - } - - static bool hasHomebrewRustInPath() { - if (!Platform.isMacOS) { - return false; - } - final envPath = Platform.environment['PATH'] ?? ''; - final paths = envPath.split(':'); - return paths.any((p) { - return p.contains('homebrew') && File(path.join(p, 'rustc')).existsSync(); - }); - } -} - -String _resolveExecutable(String executable) { - if (executable == 'rustup') { - final resolved = Rustup.executablePath(); - if (resolved != null) { - return resolved; - } - throw RustupNotFoundException(); - } else { - return executable; - } -} diff --git a/cargokit/build_tool/lib/src/verify_binaries.dart b/cargokit/build_tool/lib/src/verify_binaries.dart deleted file mode 100644 index 0094c64..0000000 --- a/cargokit/build_tool/lib/src/verify_binaries.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'dart:io'; - -import 'package:ed25519_edwards/ed25519_edwards.dart'; -import 'package:http/http.dart'; - -import 'artifacts_provider.dart'; -import 'cargo.dart'; -import 'crate_hash.dart'; -import 'options.dart'; -import 'precompile_binaries.dart'; -import 'target.dart'; - -class VerifyBinaries { - VerifyBinaries({ - required this.manifestDir, - }); - - final String manifestDir; - - Future run() async { - final crateInfo = CrateInfo.load(manifestDir); - - final config = CargokitCrateOptions.load(manifestDir: manifestDir); - final precompiledBinaries = config.precompiledBinaries; - if (precompiledBinaries == null) { - stdout.writeln('Crate does not support precompiled binaries.'); - } else { - final crateHash = CrateHash.compute(manifestDir); - stdout.writeln('Crate hash: $crateHash'); - - for (final target in Target.all) { - final message = 'Checking ${target.rust}...'; - stdout.write(message.padRight(40)); - stdout.flush(); - - final artifacts = getArtifactNames( - target: target, - libraryName: crateInfo.packageName, - remote: true, - ); - - final prefix = precompiledBinaries.uriPrefix; - - bool ok = true; - - for (final artifact in artifacts) { - final fileName = PrecompileBinaries.fileName(target, artifact); - final signatureFileName = - PrecompileBinaries.signatureFileName(target, artifact); - - final url = Uri.parse('$prefix$crateHash/$fileName'); - final signatureUrl = - Uri.parse('$prefix$crateHash/$signatureFileName'); - - final signature = await get(signatureUrl); - if (signature.statusCode != 200) { - stdout.writeln('MISSING'); - ok = false; - break; - } - final asset = await get(url); - if (asset.statusCode != 200) { - stdout.writeln('MISSING'); - ok = false; - break; - } - - if (!verify(precompiledBinaries.publicKey, asset.bodyBytes, - signature.bodyBytes)) { - stdout.writeln('INVALID SIGNATURE'); - ok = false; - } - } - - if (ok) { - stdout.writeln('OK'); - } - } - } - } -} diff --git a/cargokit/build_tool/pubspec.lock b/cargokit/build_tool/pubspec.lock deleted file mode 100644 index 343bdd3..0000000 --- a/cargokit/build_tool/pubspec.lock +++ /dev/null @@ -1,453 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - _fe_analyzer_shared: - dependency: transitive - description: - name: _fe_analyzer_shared - sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 - url: "https://pub.dev" - source: hosted - version: "64.0.0" - adaptive_number: - dependency: transitive - description: - name: adaptive_number - sha256: "3a567544e9b5c9c803006f51140ad544aedc79604fd4f3f2c1380003f97c1d77" - url: "https://pub.dev" - source: hosted - version: "1.0.0" - analyzer: - dependency: transitive - description: - name: analyzer - sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" - url: "https://pub.dev" - source: hosted - version: "6.2.0" - args: - dependency: "direct main" - description: - name: args - sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 - url: "https://pub.dev" - source: hosted - version: "2.4.2" - async: - dependency: transitive - description: - name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" - url: "https://pub.dev" - source: hosted - version: "2.11.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - collection: - dependency: "direct main" - description: - name: collection - sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a - url: "https://pub.dev" - source: hosted - version: "1.18.0" - convert: - dependency: "direct main" - description: - name: convert - sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" - url: "https://pub.dev" - source: hosted - version: "3.1.1" - coverage: - dependency: transitive - description: - name: coverage - sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097" - url: "https://pub.dev" - source: hosted - version: "1.6.3" - crypto: - dependency: "direct main" - description: - name: crypto - sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab - url: "https://pub.dev" - source: hosted - version: "3.0.3" - ed25519_edwards: - dependency: "direct main" - description: - name: ed25519_edwards - sha256: "6ce0112d131327ec6d42beede1e5dfd526069b18ad45dcf654f15074ad9276cd" - url: "https://pub.dev" - source: hosted - version: "0.3.1" - file: - dependency: transitive - description: - name: file - sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d" - url: "https://pub.dev" - source: hosted - version: "6.1.4" - fixnum: - dependency: transitive - description: - name: fixnum - sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - frontend_server_client: - dependency: transitive - description: - name: frontend_server_client - sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" - url: "https://pub.dev" - source: hosted - version: "3.2.0" - github: - dependency: "direct main" - description: - name: github - sha256: "9966bc13bf612342e916b0a343e95e5f046c88f602a14476440e9b75d2295411" - url: "https://pub.dev" - source: hosted - version: "9.17.0" - glob: - dependency: transitive - description: - name: glob - sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" - url: "https://pub.dev" - source: hosted - version: "2.1.2" - hex: - dependency: "direct main" - description: - name: hex - sha256: "4e7cd54e4b59ba026432a6be2dd9d96e4c5205725194997193bf871703b82c4a" - url: "https://pub.dev" - source: hosted - version: "0.2.0" - http: - dependency: "direct main" - description: - name: http - sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - http_multi_server: - dependency: transitive - description: - name: http_multi_server - sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" - url: "https://pub.dev" - source: hosted - version: "3.2.1" - http_parser: - dependency: transitive - description: - name: http_parser - sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" - url: "https://pub.dev" - source: hosted - version: "4.0.2" - io: - dependency: transitive - description: - name: io - sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" - url: "https://pub.dev" - source: hosted - version: "1.0.4" - js: - dependency: transitive - description: - name: js - sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 - url: "https://pub.dev" - source: hosted - version: "0.6.7" - json_annotation: - dependency: transitive - description: - name: json_annotation - sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 - url: "https://pub.dev" - source: hosted - version: "4.8.1" - lints: - dependency: "direct dev" - description: - name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - logging: - dependency: "direct main" - description: - name: logging - sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - matcher: - dependency: transitive - description: - name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" - url: "https://pub.dev" - source: hosted - version: "0.12.16" - meta: - dependency: transitive - description: - name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" - url: "https://pub.dev" - source: hosted - version: "1.9.1" - mime: - dependency: transitive - description: - name: mime - sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e - url: "https://pub.dev" - source: hosted - version: "1.0.4" - node_preamble: - dependency: transitive - description: - name: node_preamble - sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" - url: "https://pub.dev" - source: hosted - version: "2.0.2" - package_config: - dependency: transitive - description: - name: package_config - sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" - url: "https://pub.dev" - source: hosted - version: "2.1.0" - path: - dependency: "direct main" - description: - name: path - sha256: "2ad4cddff7f5cc0e2d13069f2a3f7a73ca18f66abd6f5ecf215219cdb3638edb" - url: "https://pub.dev" - source: hosted - version: "1.8.0" - petitparser: - dependency: transitive - description: - name: petitparser - sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750 - url: "https://pub.dev" - source: hosted - version: "5.4.0" - pool: - dependency: transitive - description: - name: pool - sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" - url: "https://pub.dev" - source: hosted - version: "1.5.1" - pub_semver: - dependency: transitive - description: - name: pub_semver - sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" - url: "https://pub.dev" - source: hosted - version: "2.1.4" - shelf: - dependency: transitive - description: - name: shelf - sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 - url: "https://pub.dev" - source: hosted - version: "1.4.1" - shelf_packages_handler: - dependency: transitive - description: - name: shelf_packages_handler - sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" - url: "https://pub.dev" - source: hosted - version: "3.0.2" - shelf_static: - dependency: transitive - description: - name: shelf_static - sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e - url: "https://pub.dev" - source: hosted - version: "1.1.2" - shelf_web_socket: - dependency: transitive - description: - name: shelf_web_socket - sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" - url: "https://pub.dev" - source: hosted - version: "1.0.4" - source_map_stack_trace: - dependency: transitive - description: - name: source_map_stack_trace - sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" - url: "https://pub.dev" - source: hosted - version: "2.1.1" - source_maps: - dependency: transitive - description: - name: source_maps - sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" - url: "https://pub.dev" - source: hosted - version: "0.10.12" - source_span: - dependency: "direct main" - description: - name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" - url: "https://pub.dev" - source: hosted - version: "1.10.0" - stack_trace: - dependency: transitive - description: - name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" - url: "https://pub.dev" - source: hosted - version: "1.11.1" - stream_channel: - dependency: transitive - description: - name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 - url: "https://pub.dev" - source: hosted - version: "2.1.2" - string_scanner: - dependency: transitive - description: - name: string_scanner - sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 - url: "https://pub.dev" - source: hosted - version: "1.2.1" - test: - dependency: "direct dev" - description: - name: test - sha256: "9b0dd8e36af4a5b1569029949d50a52cb2a2a2fdaa20cebb96e6603b9ae241f9" - url: "https://pub.dev" - source: hosted - version: "1.24.6" - test_api: - dependency: transitive - description: - name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" - url: "https://pub.dev" - source: hosted - version: "0.6.1" - test_core: - dependency: transitive - description: - name: test_core - sha256: "4bef837e56375537055fdbbbf6dd458b1859881f4c7e6da936158f77d61ab265" - url: "https://pub.dev" - source: hosted - version: "0.5.6" - toml: - dependency: "direct main" - description: - name: toml - sha256: "157c5dca5160fced243f3ce984117f729c788bb5e475504f3dbcda881accee44" - url: "https://pub.dev" - source: hosted - version: "0.14.0" - typed_data: - dependency: transitive - description: - name: typed_data - sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c - url: "https://pub.dev" - source: hosted - version: "1.3.2" - version: - dependency: "direct main" - description: - name: version - sha256: "2307e23a45b43f96469eeab946208ed63293e8afca9c28cd8b5241ff31c55f55" - url: "https://pub.dev" - source: hosted - version: "3.0.0" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: "0fae432c85c4ea880b33b497d32824b97795b04cdaa74d270219572a1f50268d" - url: "https://pub.dev" - source: hosted - version: "11.9.0" - watcher: - dependency: transitive - description: - name: watcher - sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" - url: "https://pub.dev" - source: hosted - version: "1.1.0" - web_socket_channel: - dependency: transitive - description: - name: web_socket_channel - sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b - url: "https://pub.dev" - source: hosted - version: "2.4.0" - webkit_inspection_protocol: - dependency: transitive - description: - name: webkit_inspection_protocol - sha256: "67d3a8b6c79e1987d19d848b0892e582dbb0c66c57cc1fef58a177dd2aa2823d" - url: "https://pub.dev" - source: hosted - version: "1.2.0" - yaml: - dependency: "direct main" - description: - name: yaml - sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" - url: "https://pub.dev" - source: hosted - version: "3.1.2" -sdks: - dart: ">=3.0.0 <4.0.0" diff --git a/cargokit/build_tool/pubspec.yaml b/cargokit/build_tool/pubspec.yaml deleted file mode 100644 index e01aa0a..0000000 --- a/cargokit/build_tool/pubspec.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: build_tool -description: Cargokit build_tool. Facilitates the build of Rust crate during Flutter application build. -publish_to: none -version: 1.0.0 - -environment: - sdk: ">=3.0.0 <4.0.0" - -# Add regular dependencies here. -dependencies: - # these are pinned on purpose because the bundle_tool_runner doesn't have - # pubspec.lock. See run_build_tool.sh - logging: 1.2.0 - path: 1.8.0 - version: 3.0.0 - collection: 1.18.0 - ed25519_edwards: 0.3.1 - hex: 0.2.0 - yaml: 3.1.2 - source_span: 1.10.0 - github: 9.17.0 - args: 2.4.2 - crypto: 3.0.3 - convert: 3.1.1 - http: 1.1.0 - toml: 0.14.0 - -dev_dependencies: - lints: ^2.1.0 - test: ^1.24.0 diff --git a/cargokit/build_tool/test/builder_test.dart b/cargokit/build_tool/test/builder_test.dart deleted file mode 100644 index e92852e..0000000 --- a/cargokit/build_tool/test/builder_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:build_tool/src/builder.dart'; -import 'package:test/test.dart'; - -void main() { - test('parseBuildConfiguration', () { - var b = BuildEnvironment.parseBuildConfiguration('debug'); - expect(b, BuildConfiguration.debug); - - b = BuildEnvironment.parseBuildConfiguration('profile'); - expect(b, BuildConfiguration.profile); - - b = BuildEnvironment.parseBuildConfiguration('release'); - expect(b, BuildConfiguration.release); - - b = BuildEnvironment.parseBuildConfiguration('debug-dev'); - expect(b, BuildConfiguration.debug); - - b = BuildEnvironment.parseBuildConfiguration('profile'); - expect(b, BuildConfiguration.profile); - - b = BuildEnvironment.parseBuildConfiguration('profile-prod'); - expect(b, BuildConfiguration.profile); - - // fallback to release - b = BuildEnvironment.parseBuildConfiguration('unknown'); - expect(b, BuildConfiguration.release); - }); -} diff --git a/cargokit/build_tool/test/cargo_test.dart b/cargokit/build_tool/test/cargo_test.dart deleted file mode 100644 index 00afe29..0000000 --- a/cargokit/build_tool/test/cargo_test.dart +++ /dev/null @@ -1,28 +0,0 @@ -import 'package:build_tool/src/cargo.dart'; -import 'package:test/test.dart'; - -final _cargoToml = """ -[workspace] - -[profile.release] -lto = true -panic = "abort" -opt-level = "z" -# strip = "symbols" - -[package] -name = "super_native_extensions" -version = "0.1.0" -edition = "2021" -resolver = "2" - -[lib] -crate-type = ["cdylib", "staticlib"] -"""; - -void main() { - test('parseCargoToml', () { - final info = CrateInfo.parseManifest(_cargoToml); - expect(info.packageName, 'super_native_extensions'); - }); -} diff --git a/cargokit/build_tool/test/options_test.dart b/cargokit/build_tool/test/options_test.dart deleted file mode 100644 index 25a85b6..0000000 --- a/cargokit/build_tool/test/options_test.dart +++ /dev/null @@ -1,75 +0,0 @@ -import 'package:build_tool/src/builder.dart'; -import 'package:build_tool/src/options.dart'; -import 'package:hex/hex.dart'; -import 'package:test/test.dart'; -import 'package:yaml/yaml.dart'; - -void main() { - test('parseCargoBuildOptions', () { - final yaml = """ -toolchain: nightly -extra_flags: - - -Z - # Comment here - - build-std=panic_abort,std -"""; - final node = loadYamlNode(yaml); - final options = CargoBuildOptions.parse(node); - expect(options.toolchain, Toolchain.nightly); - expect(options.flags, ['-Z', 'build-std=panic_abort,std']); - }); - - test('parsePrecompiledBinaries', () { - final yaml = """ -url_prefix: https://url-prefix -public_key: a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445 -"""; - final precompiledBinaries = PrecompiledBinaries.parse(loadYamlNode(yaml)); - final key = HEX.decode( - 'a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445'); - expect(precompiledBinaries.uriPrefix, 'https://url-prefix'); - expect(precompiledBinaries.publicKey.bytes, key); - }); - - test('parseCargokitOptions', () { - const yaml = ''' -cargo: - # For smalles binaries rebuilt the standard library with panic=abort - debug: - toolchain: nightly - extra_flags: - - -Z - # Comment here - - build-std=panic_abort,std - release: - toolchain: beta - -precompiled_binaries: - url_prefix: https://url-prefix - public_key: a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445 -'''; - final options = CargokitCrateOptions.parse(loadYamlNode(yaml)); - expect(options.precompiledBinaries?.uriPrefix, 'https://url-prefix'); - final key = HEX.decode( - 'a4c3433798eb2c36edf2b94dbb4dd899d57496ca373a8982d8a792410b7f6445'); - expect(options.precompiledBinaries?.publicKey.bytes, key); - - final debugOptions = options.cargo[BuildConfiguration.debug]!; - expect(debugOptions.toolchain, Toolchain.nightly); - expect(debugOptions.flags, ['-Z', 'build-std=panic_abort,std']); - - final releaseOptions = options.cargo[BuildConfiguration.release]!; - expect(releaseOptions.toolchain, Toolchain.beta); - expect(releaseOptions.flags, []); - }); - - test('parseCargokitUserOptions', () { - const yaml = ''' -use_precompiled_binaries: false -verbose_logging: true -'''; - final options = CargokitUserOptions.parse(loadYamlNode(yaml)); - expect(options.usePrecompiledBinaries, false); - expect(options.verboseLogging, true); - }); -} diff --git a/cargokit/build_tool/test/rustup_test.dart b/cargokit/build_tool/test/rustup_test.dart deleted file mode 100644 index af95303..0000000 --- a/cargokit/build_tool/test/rustup_test.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'package:build_tool/src/rustup.dart'; -import 'package:build_tool/src/util.dart'; -import 'package:test/test.dart'; - -void main() { - test('rustup with no toolchains', () { - bool didListToolchains = false; - bool didInstallStable = false; - bool didListTargets = false; - testRunCommandOverride = (args) { - expect(args.executable, 'rustup'); - switch (args.arguments) { - case ['toolchain', 'list']: - didListToolchains = true; - return TestRunCommandResult(stdout: 'no installed toolchains\n'); - case ['toolchain', 'install', 'stable']: - didInstallStable = true; - return TestRunCommandResult(); - case ['target', 'list', '--toolchain', 'stable', '--installed']: - didListTargets = true; - return TestRunCommandResult( - stdout: 'x86_64-unknown-linux-gnu\nx86_64-apple-darwin\n'); - default: - throw Exception('Unexpected call: ${args.arguments}'); - } - }; - final rustup = Rustup(); - rustup.installToolchain('stable'); - expect(didInstallStable, true); - expect(didListToolchains, true); - expect(didListTargets, true); - expect(rustup.installedTargets('stable'), [ - 'x86_64-unknown-linux-gnu', - 'x86_64-apple-darwin', - ]); - testRunCommandOverride = null; - }); - - test('rustup with esp toolchain', () { - final targetsQueried = []; - testRunCommandOverride = (args) { - expect(args.executable, 'rustup'); - switch (args.arguments) { - case ['toolchain', 'list']: - return TestRunCommandResult( - stdout: 'stable-aarch64-apple-darwin (default)\n' - 'nightly-aarch64-apple-darwin\n' - 'esp\n'); - case ['target', 'list', '--toolchain', String toolchain, '--installed']: - targetsQueried.add(toolchain); - return TestRunCommandResult(stdout: '$toolchain:target\n'); - default: - throw Exception('Unexpected call: ${args.arguments}'); - } - }; - final rustup = Rustup(); - expect(targetsQueried, [ - 'stable-aarch64-apple-darwin', - 'nightly-aarch64-apple-darwin', - ]); - expect(rustup.installedTargets('stable'), - ['stable-aarch64-apple-darwin:target']); - expect(rustup.installedTargets('nightly'), - ['nightly-aarch64-apple-darwin:target']); - }); -} diff --git a/cargokit/cmake/cargokit.cmake b/cargokit/cmake/cargokit.cmake deleted file mode 100644 index ddd05df..0000000 --- a/cargokit/cmake/cargokit.cmake +++ /dev/null @@ -1,99 +0,0 @@ -SET(cargokit_cmake_root "${CMAKE_CURRENT_LIST_DIR}/..") - -# Workaround for https://github.com/dart-lang/pub/issues/4010 -get_filename_component(cargokit_cmake_root "${cargokit_cmake_root}" REALPATH) - -if(WIN32) - # REALPATH does not properly resolve symlinks on windows :-/ - execute_process(COMMAND powershell -ExecutionPolicy Bypass -File "${CMAKE_CURRENT_LIST_DIR}/resolve_symlinks.ps1" "${cargokit_cmake_root}" OUTPUT_VARIABLE cargokit_cmake_root OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() - -# Arguments -# - target: CMAKE target to which rust library is linked -# - manifest_dir: relative path from current folder to directory containing cargo manifest -# - lib_name: cargo package name -# - any_symbol_name: name of any exported symbol from the library. -# used on windows to force linking with library. -function(apply_cargokit target manifest_dir lib_name any_symbol_name) - - set(CARGOKIT_LIB_NAME "${lib_name}") - set(CARGOKIT_LIB_FULL_NAME "${CMAKE_SHARED_MODULE_PREFIX}${CARGOKIT_LIB_NAME}${CMAKE_SHARED_MODULE_SUFFIX}") - if (CMAKE_CONFIGURATION_TYPES) - set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$") - set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/$/${CARGOKIT_LIB_FULL_NAME}") - else() - set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") - set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/${CARGOKIT_LIB_FULL_NAME}") - endif() - set(CARGOKIT_TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/cargokit_build") - - if (FLUTTER_TARGET_PLATFORM) - set(CARGOKIT_TARGET_PLATFORM "${FLUTTER_TARGET_PLATFORM}") - else() - set(CARGOKIT_TARGET_PLATFORM "windows-x64") - endif() - - set(CARGOKIT_ENV - "CARGOKIT_CMAKE=${CMAKE_COMMAND}" - "CARGOKIT_CONFIGURATION=$" - "CARGOKIT_MANIFEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${manifest_dir}" - "CARGOKIT_TARGET_TEMP_DIR=${CARGOKIT_TEMP_DIR}" - "CARGOKIT_OUTPUT_DIR=${CARGOKIT_OUTPUT_DIR}" - "CARGOKIT_TARGET_PLATFORM=${CARGOKIT_TARGET_PLATFORM}" - "CARGOKIT_TOOL_TEMP_DIR=${CARGOKIT_TEMP_DIR}/tool" - "CARGOKIT_ROOT_PROJECT_DIR=${CMAKE_SOURCE_DIR}" - ) - - if (WIN32) - set(SCRIPT_EXTENSION ".cmd") - set(IMPORT_LIB_EXTENSION ".lib") - else() - set(SCRIPT_EXTENSION ".sh") - set(IMPORT_LIB_EXTENSION "") - execute_process(COMMAND chmod +x "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}") - endif() - - # Using generators in custom command is only supported in CMake 3.20+ - if (CMAKE_CONFIGURATION_TYPES AND ${CMAKE_VERSION} VERSION_LESS "3.20.0") - foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES) - add_custom_command( - OUTPUT - "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}/${CARGOKIT_LIB_FULL_NAME}" - "${CMAKE_CURRENT_BINARY_DIR}/_phony_" - COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV} - "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake - VERBATIM - ) - endforeach() - else() - add_custom_command( - OUTPUT - ${OUTPUT_LIB} - "${CMAKE_CURRENT_BINARY_DIR}/_phony_" - COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV} - "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake - VERBATIM - ) - endif() - - - set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/_phony_" PROPERTIES SYMBOLIC TRUE) - - if (TARGET ${target}) - # If we have actual cmake target provided create target and make existing - # target depend on it - add_custom_target("${target}_cargokit" DEPENDS ${OUTPUT_LIB}) - add_dependencies("${target}" "${target}_cargokit") - target_link_libraries("${target}" PRIVATE "${OUTPUT_LIB}${IMPORT_LIB_EXTENSION}") - if(WIN32) - target_link_options(${target} PRIVATE "/INCLUDE:${any_symbol_name}") - endif() - else() - # Otherwise (FFI) just use ALL to force building always - add_custom_target("${target}_cargokit" ALL DEPENDS ${OUTPUT_LIB}) - endif() - - # Allow adding the output library to plugin bundled libraries - set("${target}_cargokit_lib" ${OUTPUT_LIB} PARENT_SCOPE) - -endfunction() diff --git a/cargokit/cmake/resolve_symlinks.ps1 b/cargokit/cmake/resolve_symlinks.ps1 deleted file mode 100644 index 2ac593a..0000000 --- a/cargokit/cmake/resolve_symlinks.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -function Resolve-Symlinks { - [CmdletBinding()] - [OutputType([string])] - param( - [Parameter(Position = 0, Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] - [string] $Path - ) - - [string] $separator = '/' - [string[]] $parts = $Path.Split($separator) - - [string] $realPath = '' - foreach ($part in $parts) { - if ($realPath -and !$realPath.EndsWith($separator)) { - $realPath += $separator - } - - $realPath += $part.Replace('\', '/') - - # The slash is important when using Get-Item on Drive letters in pwsh. - if (-not($realPath.Contains($separator)) -and $realPath.EndsWith(':')) { - $realPath += '/' - } - - $item = Get-Item $realPath - if ($item.LinkTarget) { - $realPath = $item.LinkTarget.Replace('\', '/') - } - } - $realPath -} - -$path = Resolve-Symlinks -Path $args[0] -Write-Host $path diff --git a/cargokit/docs/architecture.md b/cargokit/docs/architecture.md deleted file mode 100644 index d9bcf4e..0000000 --- a/cargokit/docs/architecture.md +++ /dev/null @@ -1,104 +0,0 @@ -# Cargokit Architecture - -Note: This is mostly relevant for plugins authors that want to see a bit under the hood rather then just following a tutorial. - -In ideal conditions the end-developer using the plugin should not even be aware of Cargokit existence. - -## Integration - -Cargokit is meant to be included in Flutter plugin (or application) that contains the Rust crate to be built during the Flutter build process. - -Cargokit can be either incuded as git submodule or git subtree (required for plugins - as pub does not support submodules for git dependencies). - -For a step by step tutorial on integrating Cargokit with a Flutter plugin see https://matejknopp.com/post/flutter_plugin_in_rust_with_no_prebuilt_binaries/. - -## build_tool - -Build tool is the core of cargokit. It is a Dart command line package that facilitates the build of Rust crate. It is invoked during the Flutter build process to build (or download) Rust artifacts, but it can be also used as a standalone tool. - -It handles the following commands: - -### build-cmake - -This is invoked from `cargokit.cmake` and it is used to build the Rust crate into a dynamic library on Linux and Windows (which use CMake as build system). - -The command takes no additional arguments, everything is controlled during environment variables set by `cargokit.cmake`. - -### build-gradle - -This is invoked from `plugin.gradle` and it is used to build the Rust crate into a dynamic library on Android. The command takes no additional arguments, everything is controlled during environment variables set by `plugin.gradle`. - -The build_tool installs NDK if needed, configures the Rust environment for cross compilation and then invokes `cargo build` with appropriate arguments and environment variables. - -The build-tool also acts a linker driver. - -### build-pod - -This is invoked from plugin's podspec `script_phase` through `build_pod.sh`. Bundle tool will build the Rust crate into a static library that gets linked into the plugin Framework. In this case must have `:execution_position` set to `:before_compile`. - -Cargokit will build binaries for all active architectures from XCode build and lipo them togherer. - -When using Cargokit to integrate Rust code with an application (not a plugin) you can also configure the `Cargo.toml` to just build a dynamic library. When Cargokit finds that the crate only built a dylib and no static lib, it will attempt to replace the Cocoapod framework binary with the dylib. In this case the script `:execution_position` must be set to `:after_compile`. This is *not* recommended for plugins and it's quite experimental. - -### gen-key, precompile-binaries, verify-binaries - -These are used as when providing precompiled binaries for Plugin. See [precompiled_binaries.md](precompiled_binaries.md) for more information. - -## Launching the build_tool during build. - -During Flutter build, the build tool can not be launched directly using `dart run`. Rather it is launched through `run_build_tool.sh` and `run_build_tool.cmd`. Because the `build_tool` is shipped as part of plugin, we generally don't want to write into the plugin directory during build, which would happen if the `build_tool` was simply invoked through `dart run` (For example the `.dart_tool/package_config.json` file would get written inside the `build_tool` directory). - -Instead the `run_build_tool` script creates a minimal Dart command line package in the build directory and references the `build_tool` as package. That way the `.dart_tool/package_config.json` file is created in the temporary build folder and not in the plugin itself. The script also precompiles the Dart code to speed up subsequent invocations. - -## Configuring Cargokit - -### Configuration for the Rust crate - -Cargokit can be configured through a `cargokit.yaml` file, which can be used to control the build of the Rust package and is placed into the Rust crate next to `Cargo.toml`. - -Here is an example `cargokit.yaml` with comments: -```yaml -cargo: - debug: # Configuration of cargo execution during debug builds - toolchain: stable # default - release: # Configuration of cargo execution for release builds - toolchain: nightly # rustup will be invoked with nightly toolchain - extra_flags: # extra arguments passed to cargo build - - -Z - - build-std=panic_abort,std - -# If crate ships with precompiled binaries, they can be configured here. -precompiled_binaries: - # Uri prefix used when downloading precompiled binaries. - url_prefix: https://github.com/superlistapp/super_native_extensions/releases/download/precompiled_ - - # Public key for verifying downloaded precompiled binaries. - public_key: 3a257ef1c7d72d84225ac4658d24812ada50a7a7a8a2138c2a91353389fdc514 -``` - -### Configuration for the application consuming the plugin - -A `cargokit_options.yaml` file can also be placed by developer using plugin to the root of the application package. In which case the file can be used to specify following options: - -```yaml -# Enables verbose logging of Cargokit during build -verbose_logging: true - -# Opts out of using precompiled binaries. If crate has configured -# and deployed precompiled binaries, these will be by default used whenever Rustup -# is not installed. With `use_precompiled_binaries` set to false, the build will -# instead be aborted prompting user to install Rustup. -use_precompiled_binaries: false -``` - -## Detecting Rustup - -When the plugin doesn't come with precompiled libraries (or user opt-out), `build_tool` will need to invoke Rustup during build to ensure that required Rust targets and toolchain are installed for current build and to build the Rust crate. - -Cargokit will attempt to detect Rustup in the default Rustup installation location (`~/.cargo/rustup`) as well as in PATH. This is done so that if user install Rustup but doesn't properly configure PATH, Cargokit will still work. - -If `build_tool` doesn't find Rustup, it will about the build with a message showing instructions to install Rustup specific to current platform. - -On macOS it will also detect a homebrew Rust installation in PATH and will prompt user to call `brew unlink rust` first to remove homebrew Rust installation from PATH, because it may interfere with Rustup. - -Homebrew Rust installation can not be used by Cargokit, because it can only build for host platform. Cargokit needs to be able to cross compile the Rust crate for iOS and Android and thus needs full Rustup installation. diff --git a/cargokit/docs/precompiled_binaries.md b/cargokit/docs/precompiled_binaries.md deleted file mode 100644 index 2026e86..0000000 --- a/cargokit/docs/precompiled_binaries.md +++ /dev/null @@ -1,95 +0,0 @@ -# Precompiled Binaries - -Because Cargokit builds the Rust crate during Flutter build, it is inherently -dependend on the Rust toolchain being installed on the developer's machine. - -To decrease the friction, it is possible for Cargokit to use precompiled binaries instead. - -This is how the process of using precompiled binaries looks from the perspective of the build on developer machine: - -1. Cargokit checks if there is `cargokit_options.yaml` file in the root folder of target application. If there is one, it will be checked for `use_precompiled_binaries` options to see if user opted out of using precompiled binaries. In which case Cargokit will insist on building from source. Cargokit will also build from source if the configuration file is absent, but user has Rustup installed. - -2. Cargokit checks if there is `cargokit.yaml` file placed in the Rust crate. If there is one, it will be checked for `precompiled_binaries` section to see if crate supports precompiled binaries. The configuration section must contain a public key and URL prefix. - -3. Cargokit computes a `crate-hash`. This is a SHA256 hash value computed from all Rust files inside crate, `Cargo.toml`, `Cargo.lock` and `cargokit.yaml`. This uniquely identifies the crate and it is used to find the correct precompiled binaries. - -4. Cargokit will attempt to download the precompiled binaries for target platform and `crate_hash` combination and a signature file for each downloaded binary. If download succeeds, the binary content will be verified against the signature and public key included in `cargokit.yaml` (which is part of Rust crate and thus part of published Flutter package). - -5. If the verification succeeds, the precompiled binaries will be used. Otherwise the binary will be discarded and Cargokit will insist on building from source. - -## Providing precompiled binaries - -Note that this assumes that precompiled binaries will be generated during github actions and deployed as github releases. - -### Use `build_tool` to generate a key-pair: - -``` -dart run build_tool gen-key -``` - -This will print the private key and public key. Store the private key securely. It needs to be provided as a secret to github action. - -The public key should be included in `cargokit.yaml` file in the Rust crate. - -### Provide a `cargokit.yaml` file in the Rust crate - -The file must be placed alongside Cargo.toml. - -```yaml -precompiled_binaries: - # Uri prefix used when downloading precompiled binaries. - url_prefix: https://github.com///releases/download/precompiled_ - - # Public key for verifying downloaded precompiled binaries. - public_key: -``` - -### Configure a github action to build and upload precompiled binaries. - -The github action should be run at every commit to main branch (and possibly other branches). - -The action needs two secrets - private key for signing binaries and GitHub token for uploading binaries as releases. Here is example action that precompiles and uploads binaries for all supported targets. - -```yaml -on: - push: - branches: [ main ] - -name: Precompile Binaries - -jobs: - Precompile: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - macOS-latest - - windows-latest - steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1 - - name: Install GTK - if: (matrix.os == 'ubuntu-latest') - run: sudo apt-get update && sudo apt-get install libgtk-3-dev - - name: Precompile - if: (matrix.os == 'macOS-latest') || (matrix.os == 'windows-latest') - run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=superlistapp/super_native_extensions - working-directory: super_native_extensions/cargokit/build_tool - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - PRIVATE_KEY: ${{ secrets.RELEASE_PRIVATE_KEY }} - - name: Precompile (with Android) - if: (matrix.os == 'ubuntu-latest') - run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=superlistapp/super_native_extensions --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=24.0.8215888 --android-min-sdk-version=23 - working-directory: super_native_extensions/cargokit/build_tool - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - PRIVATE_KEY: ${{ secrets.RELEASE_PRIVATE_KEY }} -``` - -By default the `built_tool precompile-binaries` commands build and uploads the binaries for all targets buildable from current host. This can be overriden using the `--target ` argument. - -Android binaries will be built when `--android-sdk-location` and `--android-ndk-version` arguments are provided. - diff --git a/cargokit/gradle/plugin.gradle b/cargokit/gradle/plugin.gradle deleted file mode 100644 index f0aa6fe..0000000 --- a/cargokit/gradle/plugin.gradle +++ /dev/null @@ -1,239 +0,0 @@ -import java.nio.file.Paths -import org.apache.tools.ant.taskdefs.condition.Os - -CargoKitPlugin.file = buildscript.sourceFile - -apply plugin: CargoKitPlugin - -class CargoKitExtension { - String manifestDir // Relative path to folder containing Cargo.toml - String libname // Library name within Cargo.toml. Must be a cdylib -} - -abstract class CargoKitBuildTask extends DefaultTask { - - @Input - String buildMode - - @Input - String buildDir - - @Input - String outputDir - - @Input - String ndkVersion - - @Input - String sdkDirectory - - @Input - int compileSdkVersion - - @Input - int minSdkVersion - - @Input - String pluginFile - - @Input - List targetPlatforms - - @TaskAction - def build() { - if (project.cargokit.manifestDir == null) { - throw new GradleException("Property 'manifestDir' must be set on cargokit extension") - } - - if (project.cargokit.libname == null) { - throw new GradleException("Property 'libname' must be set on cargokit extension") - } - - def executableName = Os.isFamily(Os.FAMILY_WINDOWS) ? "run_build_tool.cmd" : "run_build_tool.sh" - def path = Paths.get(new File(pluginFile).parent, "..", executableName) - - def manifestDir = Paths.get(project.buildscript.sourceFile.parent, project.cargokit.manifestDir) - def rootProjectDir = project.rootProject.projectDir - - if (!Os.isFamily(Os.FAMILY_WINDOWS)) { - project.exec { - commandLine 'chmod', '+x', path - } - } - - project.exec { - executable path - args "build-gradle" - environment "CARGOKIT_ROOT_PROJECT_DIR", rootProjectDir - environment "CARGOKIT_TOOL_TEMP_DIR", "${buildDir}/build_tool" - environment "CARGOKIT_MANIFEST_DIR", manifestDir - environment "CARGOKIT_CONFIGURATION", buildMode - environment "CARGOKIT_TARGET_TEMP_DIR", buildDir - environment "CARGOKIT_OUTPUT_DIR", outputDir - environment "CARGOKIT_NDK_VERSION", ndkVersion - environment "CARGOKIT_SDK_DIR", sdkDirectory - environment "CARGOKIT_COMPILE_SDK_VERSION", compileSdkVersion - environment "CARGOKIT_MIN_SDK_VERSION", minSdkVersion - environment "CARGOKIT_TARGET_PLATFORMS", targetPlatforms.join(",") - environment "CARGOKIT_JAVA_HOME", System.properties['java.home'] - } - } -} - -class CargoKitPlugin implements Plugin { - - static String file - - private Plugin findFlutterPlugin(Project rootProject) { - _findFlutterPlugin(rootProject.childProjects) - } - - /** - * Try to find the Flutter plugin by class name, supporting both old and new - * Flutter Gradle layouts. - */ - private Plugin _findFlutterPlugin(Map projects) { - for (entry in projects) { - def proj = entry.value - for (plugin in proj.plugins) { - def name = plugin.class.name - if (name == "com.flutter.gradle.FlutterPlugin" || - name == "FlutterPlugin") { - return plugin - } - } - def nested = _findFlutterPlugin(proj.childProjects) - if (nested != null) { - return nested - } - } - return null - } - - @Override - void apply(Project project) { - // Always create the extension so users can configure it even if plugin resolution fails - project.extensions.create("cargokit", CargoKitExtension) - - def flutterPlugin = findFlutterPlugin(project.rootProject) - - // Decide which Android project we treat as the "host" app/library. - Project hostProject = null - if (flutterPlugin != null) { - hostProject = flutterPlugin.project - } else { - // Fallback for newer Flutter / plugin-loader layouts: - // pick the first Android application project (usually :app) - hostProject = project.rootProject.subprojects.find { - it.plugins.hasPlugin("com.android.application") - } - if (hostProject != null) { - println "CargoKit: Flutter plugin not found; using ${hostProject.path} as host Android app." - } - } - - if (hostProject == null) { - println "CargoKit: Flutter plugin not found and no Android application project; CargoKit plugin will not be applied." - return - } - - def androidExt = hostProject.extensions.findByName("android") - if (androidExt == null) { - println "CargoKit: Host project ${hostProject.path} has no Android extension; CargoKit plugin will not be applied." - return - } - - def cargoBuildDir = "${project.buildDir}/build" - - // Determine if the host project is an application or a library. - def isApplication = hostProject.plugins.hasPlugin("com.android.application") - def variants = isApplication ? androidExt.applicationVariants : androidExt.libraryVariants - - variants.all { variant -> - final String buildType = variant.buildType.name - - def cargoOutputDir = "${project.buildDir}/jniLibs/${buildType}" - def jniLibs = project.android.sourceSets.maybeCreate(buildType).jniLibs - jniLibs.srcDir(new File(cargoOutputDir)) - - // Determine target platforms in a way that works across Flutter versions. - List platforms - try { - // Newer API (post 9b878b): static utility - platforms = com.flutter.gradle.FlutterPluginUtils - .getTargetPlatforms(hostProject) - .collect() - } catch (Throwable ignored) { - // Older API: plugin instance exposes getTargetPlatforms() - if (flutterPlugin != null && - flutterPlugin.metaClass.respondsTo(flutterPlugin, "getTargetPlatforms")) { - platforms = flutterPlugin.getTargetPlatforms().collect() - } else { - // Final fallback: assume common Android targets - platforms = ["android-arm", "android-arm64"] - } - } - - // Same behavior as addFlutterDependencies in flutter.gradle - if (buildType == "debug") { - platforms.add("android-x86") - platforms.add("android-x64") - } - - // Delay task creation until the project is fully evaluated. - project.getGradle().afterProject { p -> - if (p != project) return - - def taskName = "cargokitCargoBuild${project.cargokit.libname.capitalize()}${buildType.capitalize()}" - if (project.tasks.findByName(taskName)) { - return - } - - def ndkVersionValue = androidExt.ndkVersion - if (ndkVersionValue == null) { - throw new GradleException( - "Please set 'android.ndkVersion' in '${hostProject.path}/build.gradle'." - ) - } - - // Handle both "android-34" and "34" styles for compileSdkVersion - def compileSdkStr = androidExt.compileSdkVersion?.toString() - if (compileSdkStr == null) { - throw new GradleException( - "android.compileSdkVersion must be set on host project (${hostProject.path})." - ) - } - int compileSdkInt - if (compileSdkStr.startsWith("android-")) { - compileSdkInt = Integer.parseInt(compileSdkStr.substring("android-".length())) - } else { - compileSdkInt = Integer.parseInt(compileSdkStr) - } - - def minSdkInt = androidExt.defaultConfig.minSdkVersion.apiLevel as int - - def task = project.tasks.create(taskName, CargoKitBuildTask) { - buildMode = variant.buildType.name - buildDir = cargoBuildDir - outputDir = cargoOutputDir - ndkVersion = ndkVersionValue - sdkDirectory = androidExt.sdkDirectory - minSdkVersion = minSdkInt - compileSdkVersion = compileSdkInt - targetPlatforms = platforms - pluginFile = CargoKitPlugin.file - } - - def onTask = { newTask -> - if (newTask.name == "merge${buildType.capitalize()}NativeLibs") { - newTask.dependsOn task - // Fix Gradle 7.4.2+ not picking up JNI library changes - newTask.outputs.upToDateWhen { false } - } - } - project.tasks.each onTask - project.tasks.whenTaskAdded onTask - } - } - } -} diff --git a/cargokit/run_build_tool.cmd b/cargokit/run_build_tool.cmd deleted file mode 100644 index c45d0aa..0000000 --- a/cargokit/run_build_tool.cmd +++ /dev/null @@ -1,91 +0,0 @@ -@echo off -setlocal - -setlocal ENABLEDELAYEDEXPANSION - -SET BASEDIR=%~dp0 - -if not exist "%CARGOKIT_TOOL_TEMP_DIR%" ( - mkdir "%CARGOKIT_TOOL_TEMP_DIR%" -) -cd /D "%CARGOKIT_TOOL_TEMP_DIR%" - -SET BUILD_TOOL_PKG_DIR=%BASEDIR%build_tool -SET DART=%FLUTTER_ROOT%\bin\cache\dart-sdk\bin\dart - -set BUILD_TOOL_PKG_DIR_POSIX=%BUILD_TOOL_PKG_DIR:\=/% - -( - echo name: build_tool_runner - echo version: 1.0.0 - echo publish_to: none - echo. - echo environment: - echo sdk: '^>=3.0.0 ^<4.0.0' - echo. - echo dependencies: - echo build_tool: - echo path: %BUILD_TOOL_PKG_DIR_POSIX% -) >pubspec.yaml - -if not exist bin ( - mkdir bin -) - -( - echo import 'package:build_tool/build_tool.dart' as build_tool; - echo void main^(List^ args^) ^{ - echo build_tool.runMain^(args^); - echo ^} -) >bin\build_tool_runner.dart - -SET PRECOMPILED=bin\build_tool_runner.dill - -REM To detect changes in package we compare output of DIR /s (recursive) -set PREV_PACKAGE_INFO=.dart_tool\package_info.prev -set CUR_PACKAGE_INFO=.dart_tool\package_info.cur - -DIR "%BUILD_TOOL_PKG_DIR%" /s > "%CUR_PACKAGE_INFO%_orig" - -REM Last line in dir output is free space on harddrive. That is bound to -REM change between invocation so we need to remove it -( - Set "Line=" - For /F "UseBackQ Delims=" %%A In ("%CUR_PACKAGE_INFO%_orig") Do ( - SetLocal EnableDelayedExpansion - If Defined Line Echo !Line! - EndLocal - Set "Line=%%A") -) >"%CUR_PACKAGE_INFO%" -DEL "%CUR_PACKAGE_INFO%_orig" - -REM Compare current directory listing with previous -FC /B "%CUR_PACKAGE_INFO%" "%PREV_PACKAGE_INFO%" > nul 2>&1 - -If %ERRORLEVEL% neq 0 ( - REM Changed - copy current to previous and remove precompiled kernel - if exist "%PREV_PACKAGE_INFO%" ( - DEL "%PREV_PACKAGE_INFO%" - ) - MOVE /Y "%CUR_PACKAGE_INFO%" "%PREV_PACKAGE_INFO%" - if exist "%PRECOMPILED%" ( - DEL "%PRECOMPILED%" - ) -) - -REM There is no CUR_PACKAGE_INFO it was renamed in previous step to %PREV_PACKAGE_INFO% -REM which means we need to do pub get and precompile -if not exist "%PRECOMPILED%" ( - echo Running pub get in "%cd%" - "%DART%" pub get --no-precompile - "%DART%" compile kernel bin/build_tool_runner.dart -) - -"%DART%" "%PRECOMPILED%" %* - -REM 253 means invalid snapshot version. -If %ERRORLEVEL% equ 253 ( - "%DART%" pub get --no-precompile - "%DART%" compile kernel bin/build_tool_runner.dart - "%DART%" "%PRECOMPILED%" %* -) diff --git a/cargokit/run_build_tool.sh b/cargokit/run_build_tool.sh deleted file mode 100755 index 24b0ed8..0000000 --- a/cargokit/run_build_tool.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash - -set -e - -BASEDIR=$(dirname "$0") - -mkdir -p "$CARGOKIT_TOOL_TEMP_DIR" - -cd "$CARGOKIT_TOOL_TEMP_DIR" - -# Write a very simple bin package in temp folder that depends on build_tool package -# from Cargokit. This is done to ensure that we don't pollute Cargokit folder -# with .dart_tool contents. - -BUILD_TOOL_PKG_DIR="$BASEDIR/build_tool" - -if [[ -z $FLUTTER_ROOT ]]; then # not defined - DART=dart -else - DART="$FLUTTER_ROOT/bin/cache/dart-sdk/bin/dart" -fi - -cat << EOF > "pubspec.yaml" -name: build_tool_runner -version: 1.0.0 -publish_to: none - -environment: - sdk: '>=3.0.0 <4.0.0' - -dependencies: - build_tool: - path: "$BUILD_TOOL_PKG_DIR" -EOF - -mkdir -p "bin" - -cat << EOF > "bin/build_tool_runner.dart" -import 'package:build_tool/build_tool.dart' as build_tool; -void main(List args) { - build_tool.runMain(args); -} -EOF - -# Create alias for `shasum` if it does not exist and `sha1sum` exists -if ! [ -x "$(command -v shasum)" ] && [ -x "$(command -v sha1sum)" ]; then - shopt -s expand_aliases - alias shasum="sha1sum" -fi - -# Dart run will not cache any package that has a path dependency, which -# is the case for our build_tool_runner. So instead we precompile the package -# ourselves. -# To invalidate the cached kernel we use the hash of ls -LR of the build_tool -# package directory. This should be good enough, as the build_tool package -# itself is not meant to have any path dependencies. - -if [[ "$OSTYPE" == "darwin"* ]]; then - PACKAGE_HASH=$(ls -lTR "$BUILD_TOOL_PKG_DIR" | shasum) -else - PACKAGE_HASH=$(ls -lR --full-time "$BUILD_TOOL_PKG_DIR" | shasum) -fi - -PACKAGE_HASH_FILE=".package_hash" - -if [ -f "$PACKAGE_HASH_FILE" ]; then - EXISTING_HASH=$(cat "$PACKAGE_HASH_FILE") - if [ "$PACKAGE_HASH" != "$EXISTING_HASH" ]; then - rm "$PACKAGE_HASH_FILE" - fi -fi - -# Run pub get if needed. -if [ ! -f "$PACKAGE_HASH_FILE" ]; then - "$DART" pub get --no-precompile - "$DART" compile kernel bin/build_tool_runner.dart - echo "$PACKAGE_HASH" > "$PACKAGE_HASH_FILE" -fi - -# Rebuild the tool if it was deleted by Android Studio -if [ ! -f "bin/build_tool_runner.dill" ]; then - "$DART" compile kernel bin/build_tool_runner.dart -fi - -set +e - -"$DART" bin/build_tool_runner.dill "$@" - -exit_code=$? - -# 253 means invalid snapshot version. -if [ $exit_code == 253 ]; then - "$DART" pub get --no-precompile - "$DART" compile kernel bin/build_tool_runner.dart - "$DART" bin/build_tool_runner.dill "$@" - exit_code=$? -fi - -exit $exit_code diff --git a/cmake/cargokit.cmake b/cmake/cargokit.cmake deleted file mode 100644 index ddd05df..0000000 --- a/cmake/cargokit.cmake +++ /dev/null @@ -1,99 +0,0 @@ -SET(cargokit_cmake_root "${CMAKE_CURRENT_LIST_DIR}/..") - -# Workaround for https://github.com/dart-lang/pub/issues/4010 -get_filename_component(cargokit_cmake_root "${cargokit_cmake_root}" REALPATH) - -if(WIN32) - # REALPATH does not properly resolve symlinks on windows :-/ - execute_process(COMMAND powershell -ExecutionPolicy Bypass -File "${CMAKE_CURRENT_LIST_DIR}/resolve_symlinks.ps1" "${cargokit_cmake_root}" OUTPUT_VARIABLE cargokit_cmake_root OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() - -# Arguments -# - target: CMAKE target to which rust library is linked -# - manifest_dir: relative path from current folder to directory containing cargo manifest -# - lib_name: cargo package name -# - any_symbol_name: name of any exported symbol from the library. -# used on windows to force linking with library. -function(apply_cargokit target manifest_dir lib_name any_symbol_name) - - set(CARGOKIT_LIB_NAME "${lib_name}") - set(CARGOKIT_LIB_FULL_NAME "${CMAKE_SHARED_MODULE_PREFIX}${CARGOKIT_LIB_NAME}${CMAKE_SHARED_MODULE_SUFFIX}") - if (CMAKE_CONFIGURATION_TYPES) - set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$") - set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/$/${CARGOKIT_LIB_FULL_NAME}") - else() - set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") - set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/${CARGOKIT_LIB_FULL_NAME}") - endif() - set(CARGOKIT_TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/cargokit_build") - - if (FLUTTER_TARGET_PLATFORM) - set(CARGOKIT_TARGET_PLATFORM "${FLUTTER_TARGET_PLATFORM}") - else() - set(CARGOKIT_TARGET_PLATFORM "windows-x64") - endif() - - set(CARGOKIT_ENV - "CARGOKIT_CMAKE=${CMAKE_COMMAND}" - "CARGOKIT_CONFIGURATION=$" - "CARGOKIT_MANIFEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${manifest_dir}" - "CARGOKIT_TARGET_TEMP_DIR=${CARGOKIT_TEMP_DIR}" - "CARGOKIT_OUTPUT_DIR=${CARGOKIT_OUTPUT_DIR}" - "CARGOKIT_TARGET_PLATFORM=${CARGOKIT_TARGET_PLATFORM}" - "CARGOKIT_TOOL_TEMP_DIR=${CARGOKIT_TEMP_DIR}/tool" - "CARGOKIT_ROOT_PROJECT_DIR=${CMAKE_SOURCE_DIR}" - ) - - if (WIN32) - set(SCRIPT_EXTENSION ".cmd") - set(IMPORT_LIB_EXTENSION ".lib") - else() - set(SCRIPT_EXTENSION ".sh") - set(IMPORT_LIB_EXTENSION "") - execute_process(COMMAND chmod +x "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}") - endif() - - # Using generators in custom command is only supported in CMake 3.20+ - if (CMAKE_CONFIGURATION_TYPES AND ${CMAKE_VERSION} VERSION_LESS "3.20.0") - foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES) - add_custom_command( - OUTPUT - "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}/${CARGOKIT_LIB_FULL_NAME}" - "${CMAKE_CURRENT_BINARY_DIR}/_phony_" - COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV} - "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake - VERBATIM - ) - endforeach() - else() - add_custom_command( - OUTPUT - ${OUTPUT_LIB} - "${CMAKE_CURRENT_BINARY_DIR}/_phony_" - COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV} - "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake - VERBATIM - ) - endif() - - - set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/_phony_" PROPERTIES SYMBOLIC TRUE) - - if (TARGET ${target}) - # If we have actual cmake target provided create target and make existing - # target depend on it - add_custom_target("${target}_cargokit" DEPENDS ${OUTPUT_LIB}) - add_dependencies("${target}" "${target}_cargokit") - target_link_libraries("${target}" PRIVATE "${OUTPUT_LIB}${IMPORT_LIB_EXTENSION}") - if(WIN32) - target_link_options(${target} PRIVATE "/INCLUDE:${any_symbol_name}") - endif() - else() - # Otherwise (FFI) just use ALL to force building always - add_custom_target("${target}_cargokit" ALL DEPENDS ${OUTPUT_LIB}) - endif() - - # Allow adding the output library to plugin bundled libraries - set("${target}_cargokit_lib" ${OUTPUT_LIB} PARENT_SCOPE) - -endfunction() diff --git a/cmake/resolve_symlinks.ps1 b/cmake/resolve_symlinks.ps1 deleted file mode 100644 index 2ac593a..0000000 --- a/cmake/resolve_symlinks.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -function Resolve-Symlinks { - [CmdletBinding()] - [OutputType([string])] - param( - [Parameter(Position = 0, Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] - [string] $Path - ) - - [string] $separator = '/' - [string[]] $parts = $Path.Split($separator) - - [string] $realPath = '' - foreach ($part in $parts) { - if ($realPath -and !$realPath.EndsWith($separator)) { - $realPath += $separator - } - - $realPath += $part.Replace('\', '/') - - # The slash is important when using Get-Item on Drive letters in pwsh. - if (-not($realPath.Contains($separator)) -and $realPath.EndsWith(':')) { - $realPath += '/' - } - - $item = Get-Item $realPath - if ($item.LinkTarget) { - $realPath = $item.LinkTarget.Replace('\', '/') - } - } - $realPath -} - -$path = Resolve-Symlinks -Path $args[0] -Write-Host $path diff --git a/docs/architecture.md b/docs/architecture.md deleted file mode 100644 index d9bcf4e..0000000 --- a/docs/architecture.md +++ /dev/null @@ -1,104 +0,0 @@ -# Cargokit Architecture - -Note: This is mostly relevant for plugins authors that want to see a bit under the hood rather then just following a tutorial. - -In ideal conditions the end-developer using the plugin should not even be aware of Cargokit existence. - -## Integration - -Cargokit is meant to be included in Flutter plugin (or application) that contains the Rust crate to be built during the Flutter build process. - -Cargokit can be either incuded as git submodule or git subtree (required for plugins - as pub does not support submodules for git dependencies). - -For a step by step tutorial on integrating Cargokit with a Flutter plugin see https://matejknopp.com/post/flutter_plugin_in_rust_with_no_prebuilt_binaries/. - -## build_tool - -Build tool is the core of cargokit. It is a Dart command line package that facilitates the build of Rust crate. It is invoked during the Flutter build process to build (or download) Rust artifacts, but it can be also used as a standalone tool. - -It handles the following commands: - -### build-cmake - -This is invoked from `cargokit.cmake` and it is used to build the Rust crate into a dynamic library on Linux and Windows (which use CMake as build system). - -The command takes no additional arguments, everything is controlled during environment variables set by `cargokit.cmake`. - -### build-gradle - -This is invoked from `plugin.gradle` and it is used to build the Rust crate into a dynamic library on Android. The command takes no additional arguments, everything is controlled during environment variables set by `plugin.gradle`. - -The build_tool installs NDK if needed, configures the Rust environment for cross compilation and then invokes `cargo build` with appropriate arguments and environment variables. - -The build-tool also acts a linker driver. - -### build-pod - -This is invoked from plugin's podspec `script_phase` through `build_pod.sh`. Bundle tool will build the Rust crate into a static library that gets linked into the plugin Framework. In this case must have `:execution_position` set to `:before_compile`. - -Cargokit will build binaries for all active architectures from XCode build and lipo them togherer. - -When using Cargokit to integrate Rust code with an application (not a plugin) you can also configure the `Cargo.toml` to just build a dynamic library. When Cargokit finds that the crate only built a dylib and no static lib, it will attempt to replace the Cocoapod framework binary with the dylib. In this case the script `:execution_position` must be set to `:after_compile`. This is *not* recommended for plugins and it's quite experimental. - -### gen-key, precompile-binaries, verify-binaries - -These are used as when providing precompiled binaries for Plugin. See [precompiled_binaries.md](precompiled_binaries.md) for more information. - -## Launching the build_tool during build. - -During Flutter build, the build tool can not be launched directly using `dart run`. Rather it is launched through `run_build_tool.sh` and `run_build_tool.cmd`. Because the `build_tool` is shipped as part of plugin, we generally don't want to write into the plugin directory during build, which would happen if the `build_tool` was simply invoked through `dart run` (For example the `.dart_tool/package_config.json` file would get written inside the `build_tool` directory). - -Instead the `run_build_tool` script creates a minimal Dart command line package in the build directory and references the `build_tool` as package. That way the `.dart_tool/package_config.json` file is created in the temporary build folder and not in the plugin itself. The script also precompiles the Dart code to speed up subsequent invocations. - -## Configuring Cargokit - -### Configuration for the Rust crate - -Cargokit can be configured through a `cargokit.yaml` file, which can be used to control the build of the Rust package and is placed into the Rust crate next to `Cargo.toml`. - -Here is an example `cargokit.yaml` with comments: -```yaml -cargo: - debug: # Configuration of cargo execution during debug builds - toolchain: stable # default - release: # Configuration of cargo execution for release builds - toolchain: nightly # rustup will be invoked with nightly toolchain - extra_flags: # extra arguments passed to cargo build - - -Z - - build-std=panic_abort,std - -# If crate ships with precompiled binaries, they can be configured here. -precompiled_binaries: - # Uri prefix used when downloading precompiled binaries. - url_prefix: https://github.com/superlistapp/super_native_extensions/releases/download/precompiled_ - - # Public key for verifying downloaded precompiled binaries. - public_key: 3a257ef1c7d72d84225ac4658d24812ada50a7a7a8a2138c2a91353389fdc514 -``` - -### Configuration for the application consuming the plugin - -A `cargokit_options.yaml` file can also be placed by developer using plugin to the root of the application package. In which case the file can be used to specify following options: - -```yaml -# Enables verbose logging of Cargokit during build -verbose_logging: true - -# Opts out of using precompiled binaries. If crate has configured -# and deployed precompiled binaries, these will be by default used whenever Rustup -# is not installed. With `use_precompiled_binaries` set to false, the build will -# instead be aborted prompting user to install Rustup. -use_precompiled_binaries: false -``` - -## Detecting Rustup - -When the plugin doesn't come with precompiled libraries (or user opt-out), `build_tool` will need to invoke Rustup during build to ensure that required Rust targets and toolchain are installed for current build and to build the Rust crate. - -Cargokit will attempt to detect Rustup in the default Rustup installation location (`~/.cargo/rustup`) as well as in PATH. This is done so that if user install Rustup but doesn't properly configure PATH, Cargokit will still work. - -If `build_tool` doesn't find Rustup, it will about the build with a message showing instructions to install Rustup specific to current platform. - -On macOS it will also detect a homebrew Rust installation in PATH and will prompt user to call `brew unlink rust` first to remove homebrew Rust installation from PATH, because it may interfere with Rustup. - -Homebrew Rust installation can not be used by Cargokit, because it can only build for host platform. Cargokit needs to be able to cross compile the Rust crate for iOS and Android and thus needs full Rustup installation. diff --git a/docs/precompiled_binaries.md b/docs/precompiled_binaries.md deleted file mode 100644 index 2026e86..0000000 --- a/docs/precompiled_binaries.md +++ /dev/null @@ -1,95 +0,0 @@ -# Precompiled Binaries - -Because Cargokit builds the Rust crate during Flutter build, it is inherently -dependend on the Rust toolchain being installed on the developer's machine. - -To decrease the friction, it is possible for Cargokit to use precompiled binaries instead. - -This is how the process of using precompiled binaries looks from the perspective of the build on developer machine: - -1. Cargokit checks if there is `cargokit_options.yaml` file in the root folder of target application. If there is one, it will be checked for `use_precompiled_binaries` options to see if user opted out of using precompiled binaries. In which case Cargokit will insist on building from source. Cargokit will also build from source if the configuration file is absent, but user has Rustup installed. - -2. Cargokit checks if there is `cargokit.yaml` file placed in the Rust crate. If there is one, it will be checked for `precompiled_binaries` section to see if crate supports precompiled binaries. The configuration section must contain a public key and URL prefix. - -3. Cargokit computes a `crate-hash`. This is a SHA256 hash value computed from all Rust files inside crate, `Cargo.toml`, `Cargo.lock` and `cargokit.yaml`. This uniquely identifies the crate and it is used to find the correct precompiled binaries. - -4. Cargokit will attempt to download the precompiled binaries for target platform and `crate_hash` combination and a signature file for each downloaded binary. If download succeeds, the binary content will be verified against the signature and public key included in `cargokit.yaml` (which is part of Rust crate and thus part of published Flutter package). - -5. If the verification succeeds, the precompiled binaries will be used. Otherwise the binary will be discarded and Cargokit will insist on building from source. - -## Providing precompiled binaries - -Note that this assumes that precompiled binaries will be generated during github actions and deployed as github releases. - -### Use `build_tool` to generate a key-pair: - -``` -dart run build_tool gen-key -``` - -This will print the private key and public key. Store the private key securely. It needs to be provided as a secret to github action. - -The public key should be included in `cargokit.yaml` file in the Rust crate. - -### Provide a `cargokit.yaml` file in the Rust crate - -The file must be placed alongside Cargo.toml. - -```yaml -precompiled_binaries: - # Uri prefix used when downloading precompiled binaries. - url_prefix: https://github.com///releases/download/precompiled_ - - # Public key for verifying downloaded precompiled binaries. - public_key: -``` - -### Configure a github action to build and upload precompiled binaries. - -The github action should be run at every commit to main branch (and possibly other branches). - -The action needs two secrets - private key for signing binaries and GitHub token for uploading binaries as releases. Here is example action that precompiles and uploads binaries for all supported targets. - -```yaml -on: - push: - branches: [ main ] - -name: Precompile Binaries - -jobs: - Precompile: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - - macOS-latest - - windows-latest - steps: - - uses: actions/checkout@v2 - - uses: dart-lang/setup-dart@v1 - - name: Install GTK - if: (matrix.os == 'ubuntu-latest') - run: sudo apt-get update && sudo apt-get install libgtk-3-dev - - name: Precompile - if: (matrix.os == 'macOS-latest') || (matrix.os == 'windows-latest') - run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=superlistapp/super_native_extensions - working-directory: super_native_extensions/cargokit/build_tool - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - PRIVATE_KEY: ${{ secrets.RELEASE_PRIVATE_KEY }} - - name: Precompile (with Android) - if: (matrix.os == 'ubuntu-latest') - run: dart run build_tool precompile-binaries -v --manifest-dir=../../rust --repository=superlistapp/super_native_extensions --android-sdk-location=/usr/local/lib/android/sdk --android-ndk-version=24.0.8215888 --android-min-sdk-version=23 - working-directory: super_native_extensions/cargokit/build_tool - env: - GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }} - PRIVATE_KEY: ${{ secrets.RELEASE_PRIVATE_KEY }} -``` - -By default the `built_tool precompile-binaries` commands build and uploads the binaries for all targets buildable from current host. This can be overriden using the `--target ` argument. - -Android binaries will be built when `--android-sdk-location` and `--android-ndk-version` arguments are provided. - diff --git a/example/android/app/build.gradle.kts b/example/android/app/build.gradle.kts index d7db3ea..cbc7c2b 100644 --- a/example/android/app/build.gradle.kts +++ b/example/android/app/build.gradle.kts @@ -1,6 +1,5 @@ plugins { id("com.android.application") - id("kotlin-android") // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. id("dev.flutter.flutter-gradle-plugin") } @@ -11,12 +10,8 @@ android { ndkVersion = flutter.ndkVersion compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_11.toString() + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } defaultConfig { @@ -39,6 +34,12 @@ android { } } +kotlin { + compilerOptions { + jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 + } +} + flutter { source = "../.." } diff --git a/example/android/gradle.properties b/example/android/gradle.properties index f018a61..578bcd6 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,3 +1,5 @@ org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true -android.enableJetifier=true +# Flutter template settings for AGP 9: keep the classic DSL and the standalone Kotlin plugin +android.newDsl=false +android.builtInKotlin=false diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index afa1e8e..a20f2c4 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.1-all.zip diff --git a/example/android/settings.gradle.kts b/example/android/settings.gradle.kts index a439442..9d5a6fe 100644 --- a/example/android/settings.gradle.kts +++ b/example/android/settings.gradle.kts @@ -18,8 +18,8 @@ pluginManagement { plugins { id("dev.flutter.flutter-plugin-loader") version "1.0.0" - id("com.android.application") version "8.7.0" apply false - id("org.jetbrains.kotlin.android") version "1.8.22" apply false + id("com.android.application") version "9.1.0" apply false + id("org.jetbrains.kotlin.android") version "2.4.0" apply false } include(":app") diff --git a/example/linux/flutter/generated_plugins.cmake b/example/linux/flutter/generated_plugins.cmake index e5b4cac..2e1de87 100644 --- a/example/linux/flutter/generated_plugins.cmake +++ b/example/linux/flutter/generated_plugins.cmake @@ -6,8 +6,6 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST - jni - xelis_flutter ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/example/pubspec.lock b/example/pubspec.lock index ad07236..7d122f4 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -89,14 +89,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.3" - ffi: - dependency: transitive - description: - name: ffi - sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" - url: "https://pub.dev" - source: hosted - version: "2.2.0" file: dependency: transitive description: @@ -127,10 +119,18 @@ packages: dependency: transitive description: name: flutter_rust_bridge - sha256: e87d6b9ee934dcd24a128ccb2bd91905d2d5fe5c06245d6a8f5477d4907a437a + sha256: ec69331e2335ab4d456c0a9fc700892c2c85b72b9c0cb39df3ecfe8833d5d5c8 url: "https://pub.dev" source: hosted - version: "2.12.0" + version: "2.13.0" + flutter_rust_bridge_hooks: + dependency: transitive + description: + name: flutter_rust_bridge_hooks + sha256: "19900fbcaa8ddc2a4f1b13994ef34393eda129ebccc59ceb887a8fd2cf5def3e" + url: "https://pub.dev" + source: hosted + version: "2.13.0" flutter_test: dependency: "direct dev" description: flutter @@ -162,30 +162,6 @@ packages: description: flutter source: sdk version: "0.0.0" - jni: - dependency: transitive - description: - name: jni - sha256: "5bc9a9daac5ccfbd6a758377600b9f7fdce13d93f26e8012a8941014a5d978d1" - url: "https://pub.dev" - source: hosted - version: "1.0.2" - jni_flutter: - dependency: transitive - description: - name: jni_flutter - sha256: "7b717011ea40d04fd47c2731d3d1d36eb99eba3435c2753d62489e8c3c9991d5" - url: "https://pub.dev" - source: hosted - version: "1.0.2" - jni_util: - dependency: transitive - description: - name: jni_util - sha256: "1ba86da04a5f2bf18fde2edb235587e70c5b0fc5bd4ba955f46b00942c3fc35f" - url: "https://pub.dev" - source: hosted - version: "1.0.0" json_annotation: dependency: transitive description: @@ -258,22 +234,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.19.0" - objective_c: + native_toolchain_rust: dependency: transitive description: - name: objective_c - sha256: b7fb95a6d9a4f009edd63dc5ac69f07420b23a16161c6dd8660290b59c602e8e + name: native_toolchain_rust + sha256: "8469a0e32a47a5c84b7fd300de9fd0e8082aac76c37922986324f5082a58350d" url: "https://pub.dev" source: hosted - version: "9.5.0" - package_config: - dependency: transitive - description: - name: package_config - sha256: ffcf4cf3d6c0b74ac43708d9f56625506e8a68aa935abe9d267a7330f320eb5d - url: "https://pub.dev" - source: hosted - version: "3.0.0" + version: "1.0.6" path: dependency: transitive description: @@ -282,54 +250,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" - path_provider: - dependency: transitive - description: - name: path_provider - sha256: a7f4874f987173da295a61c181b8ee71dab59b332a486b391babf26a1b884825 - url: "https://pub.dev" - source: hosted - version: "2.1.6" - path_provider_android: - dependency: transitive - description: - name: path_provider_android - sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd" - url: "https://pub.dev" - source: hosted - version: "2.3.1" - path_provider_foundation: + petitparser: dependency: transitive description: - name: path_provider_foundation - sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699" + name: petitparser + sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675" url: "https://pub.dev" source: hosted - version: "2.6.0" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - sha256: "58c2005f147315b11e9b4a7bc889cd5203e250cba8e3f012dae259b4972b5c16" - url: "https://pub.dev" - source: hosted - version: "2.2.2" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - sha256: "484838772624c3a4b94f1e44a3e19897fee738f2d5c4ce448443b0417f7c9dda" - url: "https://pub.dev" - source: hosted - version: "2.1.3" - path_provider_windows: - dependency: transitive - description: - name: path_provider_windows - sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 - url: "https://pub.dev" - source: hosted - version: "2.3.0" + version: "7.0.2" platform: dependency: transitive description: @@ -338,14 +266,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.6" - plugin_platform_interface: - dependency: transitive - description: - name: plugin_platform_interface - sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" - url: "https://pub.dev" - source: hosted - version: "2.1.8" process: dependency: transitive description: @@ -431,6 +351,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.12" + toml: + dependency: transitive + description: + name: toml + sha256: "35a35f782228656a2af31e8c73d1353cc4ef3d683fd68af1111b44631879c05e" + url: "https://pub.dev" + source: hosted + version: "0.18.0" typed_data: dependency: transitive description: @@ -471,21 +399,13 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0" - xdg_directories: - dependency: transitive - description: - name: xdg_directories - sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" - url: "https://pub.dev" - source: hosted - version: "1.1.0" xelis_flutter: dependency: "direct main" description: path: ".." relative: true source: path - version: "0.2.0" + version: "0.4.0" yaml: dependency: transitive description: @@ -495,5 +415,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.11.0 <4.0.0" - flutter: ">=3.38.4" + dart: ">=3.13.0 <4.0.0" + flutter: ">=3.47.2" diff --git a/example/windows/flutter/generated_plugins.cmake b/example/windows/flutter/generated_plugins.cmake index 0412f2c..b93c4c3 100644 --- a/example/windows/flutter/generated_plugins.cmake +++ b/example/windows/flutter/generated_plugins.cmake @@ -6,8 +6,6 @@ list(APPEND FLUTTER_PLUGIN_LIST ) list(APPEND FLUTTER_FFI_PLUGIN_LIST - jni - xelis_flutter ) set(PLUGIN_BUNDLED_LIBRARIES) diff --git a/flutter_rust_bridge.yaml b/flutter_rust_bridge.yaml index ae6c5bf..7446c23 100644 --- a/flutter_rust_bridge.yaml +++ b/flutter_rust_bridge.yaml @@ -1,7 +1,6 @@ rust_input: crate::api rust_root: rust/ dart_output: lib/src/ -c_output: ios/Classes/frb_generated.h full_dep: true # ffigen searches each location for lib/libclang.so (or the platform diff --git a/gradle/plugin.gradle b/gradle/plugin.gradle deleted file mode 100644 index f0aa6fe..0000000 --- a/gradle/plugin.gradle +++ /dev/null @@ -1,239 +0,0 @@ -import java.nio.file.Paths -import org.apache.tools.ant.taskdefs.condition.Os - -CargoKitPlugin.file = buildscript.sourceFile - -apply plugin: CargoKitPlugin - -class CargoKitExtension { - String manifestDir // Relative path to folder containing Cargo.toml - String libname // Library name within Cargo.toml. Must be a cdylib -} - -abstract class CargoKitBuildTask extends DefaultTask { - - @Input - String buildMode - - @Input - String buildDir - - @Input - String outputDir - - @Input - String ndkVersion - - @Input - String sdkDirectory - - @Input - int compileSdkVersion - - @Input - int minSdkVersion - - @Input - String pluginFile - - @Input - List targetPlatforms - - @TaskAction - def build() { - if (project.cargokit.manifestDir == null) { - throw new GradleException("Property 'manifestDir' must be set on cargokit extension") - } - - if (project.cargokit.libname == null) { - throw new GradleException("Property 'libname' must be set on cargokit extension") - } - - def executableName = Os.isFamily(Os.FAMILY_WINDOWS) ? "run_build_tool.cmd" : "run_build_tool.sh" - def path = Paths.get(new File(pluginFile).parent, "..", executableName) - - def manifestDir = Paths.get(project.buildscript.sourceFile.parent, project.cargokit.manifestDir) - def rootProjectDir = project.rootProject.projectDir - - if (!Os.isFamily(Os.FAMILY_WINDOWS)) { - project.exec { - commandLine 'chmod', '+x', path - } - } - - project.exec { - executable path - args "build-gradle" - environment "CARGOKIT_ROOT_PROJECT_DIR", rootProjectDir - environment "CARGOKIT_TOOL_TEMP_DIR", "${buildDir}/build_tool" - environment "CARGOKIT_MANIFEST_DIR", manifestDir - environment "CARGOKIT_CONFIGURATION", buildMode - environment "CARGOKIT_TARGET_TEMP_DIR", buildDir - environment "CARGOKIT_OUTPUT_DIR", outputDir - environment "CARGOKIT_NDK_VERSION", ndkVersion - environment "CARGOKIT_SDK_DIR", sdkDirectory - environment "CARGOKIT_COMPILE_SDK_VERSION", compileSdkVersion - environment "CARGOKIT_MIN_SDK_VERSION", minSdkVersion - environment "CARGOKIT_TARGET_PLATFORMS", targetPlatforms.join(",") - environment "CARGOKIT_JAVA_HOME", System.properties['java.home'] - } - } -} - -class CargoKitPlugin implements Plugin { - - static String file - - private Plugin findFlutterPlugin(Project rootProject) { - _findFlutterPlugin(rootProject.childProjects) - } - - /** - * Try to find the Flutter plugin by class name, supporting both old and new - * Flutter Gradle layouts. - */ - private Plugin _findFlutterPlugin(Map projects) { - for (entry in projects) { - def proj = entry.value - for (plugin in proj.plugins) { - def name = plugin.class.name - if (name == "com.flutter.gradle.FlutterPlugin" || - name == "FlutterPlugin") { - return plugin - } - } - def nested = _findFlutterPlugin(proj.childProjects) - if (nested != null) { - return nested - } - } - return null - } - - @Override - void apply(Project project) { - // Always create the extension so users can configure it even if plugin resolution fails - project.extensions.create("cargokit", CargoKitExtension) - - def flutterPlugin = findFlutterPlugin(project.rootProject) - - // Decide which Android project we treat as the "host" app/library. - Project hostProject = null - if (flutterPlugin != null) { - hostProject = flutterPlugin.project - } else { - // Fallback for newer Flutter / plugin-loader layouts: - // pick the first Android application project (usually :app) - hostProject = project.rootProject.subprojects.find { - it.plugins.hasPlugin("com.android.application") - } - if (hostProject != null) { - println "CargoKit: Flutter plugin not found; using ${hostProject.path} as host Android app." - } - } - - if (hostProject == null) { - println "CargoKit: Flutter plugin not found and no Android application project; CargoKit plugin will not be applied." - return - } - - def androidExt = hostProject.extensions.findByName("android") - if (androidExt == null) { - println "CargoKit: Host project ${hostProject.path} has no Android extension; CargoKit plugin will not be applied." - return - } - - def cargoBuildDir = "${project.buildDir}/build" - - // Determine if the host project is an application or a library. - def isApplication = hostProject.plugins.hasPlugin("com.android.application") - def variants = isApplication ? androidExt.applicationVariants : androidExt.libraryVariants - - variants.all { variant -> - final String buildType = variant.buildType.name - - def cargoOutputDir = "${project.buildDir}/jniLibs/${buildType}" - def jniLibs = project.android.sourceSets.maybeCreate(buildType).jniLibs - jniLibs.srcDir(new File(cargoOutputDir)) - - // Determine target platforms in a way that works across Flutter versions. - List platforms - try { - // Newer API (post 9b878b): static utility - platforms = com.flutter.gradle.FlutterPluginUtils - .getTargetPlatforms(hostProject) - .collect() - } catch (Throwable ignored) { - // Older API: plugin instance exposes getTargetPlatforms() - if (flutterPlugin != null && - flutterPlugin.metaClass.respondsTo(flutterPlugin, "getTargetPlatforms")) { - platforms = flutterPlugin.getTargetPlatforms().collect() - } else { - // Final fallback: assume common Android targets - platforms = ["android-arm", "android-arm64"] - } - } - - // Same behavior as addFlutterDependencies in flutter.gradle - if (buildType == "debug") { - platforms.add("android-x86") - platforms.add("android-x64") - } - - // Delay task creation until the project is fully evaluated. - project.getGradle().afterProject { p -> - if (p != project) return - - def taskName = "cargokitCargoBuild${project.cargokit.libname.capitalize()}${buildType.capitalize()}" - if (project.tasks.findByName(taskName)) { - return - } - - def ndkVersionValue = androidExt.ndkVersion - if (ndkVersionValue == null) { - throw new GradleException( - "Please set 'android.ndkVersion' in '${hostProject.path}/build.gradle'." - ) - } - - // Handle both "android-34" and "34" styles for compileSdkVersion - def compileSdkStr = androidExt.compileSdkVersion?.toString() - if (compileSdkStr == null) { - throw new GradleException( - "android.compileSdkVersion must be set on host project (${hostProject.path})." - ) - } - int compileSdkInt - if (compileSdkStr.startsWith("android-")) { - compileSdkInt = Integer.parseInt(compileSdkStr.substring("android-".length())) - } else { - compileSdkInt = Integer.parseInt(compileSdkStr) - } - - def minSdkInt = androidExt.defaultConfig.minSdkVersion.apiLevel as int - - def task = project.tasks.create(taskName, CargoKitBuildTask) { - buildMode = variant.buildType.name - buildDir = cargoBuildDir - outputDir = cargoOutputDir - ndkVersion = ndkVersionValue - sdkDirectory = androidExt.sdkDirectory - minSdkVersion = minSdkInt - compileSdkVersion = compileSdkInt - targetPlatforms = platforms - pluginFile = CargoKitPlugin.file - } - - def onTask = { newTask -> - if (newTask.name == "merge${buildType.capitalize()}NativeLibs") { - newTask.dependsOn task - // Fix Gradle 7.4.2+ not picking up JNI library changes - newTask.outputs.upToDateWhen { false } - } - } - project.tasks.each onTask - project.tasks.whenTaskAdded onTask - } - } - } -} diff --git a/hook/build.dart b/hook/build.dart new file mode 100644 index 0000000..5ef1307 --- /dev/null +++ b/hook/build.dart @@ -0,0 +1,137 @@ +import 'dart:io'; + +import 'package:code_assets/code_assets.dart'; +import 'package:flutter_rust_bridge_hooks/flutter_rust_bridge_hooks.dart'; +import 'package:logging/logging.dart'; + +import 'cargo_dependencies.dart'; + +/// Flutter native assets build hook. +/// +/// Flutter runs this for every target platform/architecture during +/// `flutter run` / `flutter build` (and `flutter test`). It compiles the Rust +/// crate in `rust/` with Cargo (via rustup, using the toolchain and targets +/// pinned in `rust/rust-toolchain.toml`) and registers the resulting dynamic +/// library as a code asset so Flutter bundles it with the app. +void main(List args) async { + await build(args, (input, output) async { + // Keep the builder's assets, but replace its dependency list: version 1.0.6 + // splits Cargo's escaped paths on spaces and registers nonexistent files. + final rustOutput = BuildOutputBuilder(); + await FlutterRustBridgeNativeAssetsBuilder( + cratePath: 'rust', + // Dart library (relative to lib/) that owns the generated FFI bindings. + assetName: 'src/frb_generated.io.dart', + // Fail loudly if Cargo.toml and Cargo.lock disagree instead of silently + // re-resolving dependencies on the consumer's machine. + extraCargoBuildArgs: const ['--locked'], + // `input.config.code` throws when a hook run has no code assets (e.g. a + // data-assets-only invocation), so check `buildCodeAssets` first, exactly + // like native_toolchain_rust does before it touches the code config. + extraCargoEnvironmentVariables: input.config.buildCodeAssets + ? { + ..._androidMinSdkToolchain(input.config.code), + ..._androidPageSizeFlags(input.config.code), + } + : const {}, + ).run(input: input, output: rustOutput, logger: _logger()); + + for (final asset in rustOutput.build().assets.code) { + output.assets.code.add(asset); + final library = File.fromUri(asset.file!); + final filename = library.uri.pathSegments.last; + final depInfo = File.fromUri( + library.parent.uri.resolve( + '${filename.substring(0, filename.lastIndexOf('.'))}.d', + ), + ); + output.dependencies.addAll([ + for (final path in parseCargoDependencies(await depInfo.readAsString())) + input.packageRoot.resolveUri(Uri.file(path)), + ]); + } + + // Cargo's dep-info does not list the crate configuration. Register it + // too, so dependency/feature/toolchain changes invalidate the cached build. + output.dependencies.addAll([ + for (final file in ['Cargo.toml', 'Cargo.lock', 'rust-toolchain.toml']) + input.packageRoot.resolve('rust/$file'), + ]); + }); +} + +/// native_toolchain_rust's default logger runs at CONFIG level and dumps the +/// complete process environment (including any proxy URLs) into the build +/// output, which Flutter keeps under `.dart_tool/hooks_runner/**/stdout.txt`. +/// Log at INFO and above only: the cargo invocation and its outcome. +Logger _logger() { + return Logger.detached('xelis_flutter.rust') + ..level = Level.INFO + ..onRecord.listen((record) { + final sink = record.level >= Level.WARNING ? stderr : stdout; + sink.writeln('[${record.level.name}] ${record.message}'); + if (record.error != null) sink.writeln(record.error); + if (record.stackTrace != null) sink.writeln(record.stackTrace); + }); +} + +/// native_toolchain_rust compiles and links Android targets with the NDK's +/// `35-clang` wrappers, i.e. against API level 35, regardless of the +/// app's `minSdk`. That lets the linker accept libc symbols that do not exist +/// on older devices, where `dlopen` would then fail at runtime. Cargokit (the +/// previous build system) linked against `minSdk`; restore that behaviour by +/// pointing CC/CXX/linker at the wrappers for the API level Flutter passes in. +/// Falls back to native_toolchain_rust's defaults if the wrappers are missing. +Map _androidMinSdkToolchain(CodeConfig code) { + if (code.targetOS != OS.android) return const {}; + final cCompiler = code.cCompiler; + if (cCompiler == null) return const {}; + + final rustTriple = switch (code.targetArchitecture) { + Architecture.arm64 => 'aarch64-linux-android', + Architecture.arm => 'armv7-linux-androideabi', + Architecture.x64 => 'x86_64-linux-android', + _ => null, + }; + if (rustTriple == null) return const {}; + // The NDK names its armv7 wrappers differently from the Rust target triple. + final ndkTriple = rustTriple == 'armv7-linux-androideabi' + ? 'armv7a-linux-androideabi' + : rustTriple; + + final api = code.android.targetNdkApi; + final binDir = File.fromUri(cCompiler.compiler).parent.path; + final suffix = Platform.isWindows ? '.cmd' : ''; + final prefix = '$binDir${Platform.pathSeparator}$ndkTriple$api'; + final clang = '$prefix-clang$suffix'; + final clangxx = '$prefix-clang++$suffix'; + if (!File(clang).existsSync() || !File(clangxx).existsSync()) { + return const {}; + } + + final envTriple = rustTriple.replaceAll('-', '_'); + return { + 'CC_$envTriple': clang, + 'CXX_$envTriple': clangxx, + 'CARGO_TARGET_${envTriple.toUpperCase()}_LINKER': clang, + }; +} + +/// 64-bit Android libraries must be 16 KB page aligned (Google Play requires it +/// for apps targeting Android 15+). rustc adds no linker flag for this and the +/// NDK linker only defaults to 16 KB from r28 on, so force it regardless of +/// which NDK Flutter picked. Hooks strip RUSTFLAGS from the environment, so the +/// per-target cargo variable is the only one that applies here. +Map _androidPageSizeFlags(CodeConfig code) { + if (code.targetOS != OS.android) return const {}; + final envTriple = switch (code.targetArchitecture) { + Architecture.arm64 => 'AARCH64_LINUX_ANDROID', + Architecture.x64 => 'X86_64_LINUX_ANDROID', + _ => null, + }; + if (envTriple == null) return const {}; + return { + 'CARGO_TARGET_${envTriple}_RUSTFLAGS': + '-C link-arg=-Wl,-z,max-page-size=16384', + }; +} diff --git a/hook/cargo_dependencies.dart b/hook/cargo_dependencies.dart new file mode 100644 index 0000000..550ee6c --- /dev/null +++ b/hook/cargo_dependencies.dart @@ -0,0 +1,46 @@ +import 'dart:convert'; + +/// Reads the top-level `.d` files written by the pinned Cargo toolchain. +/// +/// Cargo escapes spaces as `\ `, but leaves backslashes, `#`, and `$` literal. +/// These files are not fully Make-escaped, so unescaping other characters +/// would corrupt paths, particularly on Windows. +Iterable parseCargoDependencies(String contents) { + final paths = {}; + for (final line in const LineSplitter().convert(contents)) { + if (line.isEmpty || line.startsWith('#')) continue; + + // A drive letter contains a colon, but only the rule separator is followed + // by an unescaped space. An empty (phony) rule has no dependencies. + final separator = line.indexOf(': '); + if (separator < 0) { + if (line.trim().isEmpty || line.endsWith(':')) continue; + throw FormatException('Invalid Cargo dependency rule', line); + } + + final dependencies = line.substring(separator + 2); + final path = StringBuffer(); + void addPath() { + if (path.isNotEmpty) { + paths.add(path.toString()); + path.clear(); + } + } + + for (var i = 0; i < dependencies.length; i++) { + final character = dependencies.codeUnitAt(i); + if (character == 0x5c && + i + 1 < dependencies.length && + dependencies.codeUnitAt(i + 1) == 0x20) { + path.write(' '); + i++; + } else if (character == 0x20) { + addPath(); + } else { + path.writeCharCode(character); + } + } + addPath(); + } + return paths; +} diff --git a/ios/Classes/dummy_file.c b/ios/Classes/dummy_file.c deleted file mode 100644 index e06dab9..0000000 --- a/ios/Classes/dummy_file.c +++ /dev/null @@ -1 +0,0 @@ -// This is an empty file to force CocoaPods to create a framework. diff --git a/ios/Classes/frb_generated.h b/ios/Classes/frb_generated.h deleted file mode 100644 index 0c1e6d1..0000000 --- a/ios/Classes/frb_generated.h +++ /dev/null @@ -1,896 +0,0 @@ -#include -#include -#include -// EXTRA BEGIN -typedef struct DartCObject *WireSyncRust2DartDco; -typedef struct WireSyncRust2DartSse { - uint8_t *ptr; - int32_t len; -} WireSyncRust2DartSse; - -typedef int64_t DartPort; -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); -void store_dart_post_cobject(DartPostCObjectFnType ptr); -// EXTRA END -typedef struct _Dart_Handle* Dart_Handle; - -typedef struct wire_cst_list_prim_u_8_strict { - uint8_t *ptr; - int32_t len; -} wire_cst_list_prim_u_8_strict; - -typedef struct wire_cst_list_String { - struct wire_cst_list_prim_u_8_strict **ptr; - int32_t len; -} wire_cst_list_String; - -typedef struct wire_cst_transfer { - double float_amount; - struct wire_cst_list_prim_u_8_strict *str_address; - struct wire_cst_list_prim_u_8_strict *asset_hash; - struct wire_cst_list_prim_u_8_strict *extra_data; - bool *encrypt_extra_data; -} wire_cst_transfer; - -typedef struct wire_cst_list_transfer { - struct wire_cst_transfer *ptr; - int32_t len; -} wire_cst_list_transfer; - -typedef struct wire_cst_signature_multisig { - uint8_t id; - struct wire_cst_list_prim_u_8_strict *signature; -} wire_cst_signature_multisig; - -typedef struct wire_cst_list_signature_multisig { - struct wire_cst_signature_multisig *ptr; - int32_t len; -} wire_cst_list_signature_multisig; - -typedef struct wire_cst_history_page_filter { - uintptr_t page; - uintptr_t *limit; - struct wire_cst_list_prim_u_8_strict *asset_hash; - struct wire_cst_list_prim_u_8_strict *address; - struct wire_cst_list_prim_u_8_strict *contract; - uint64_t *min_topoheight; - uint64_t *max_topoheight; - bool accept_incoming; - bool accept_outgoing; - bool accept_coinbase; - bool accept_burn; - bool accept_blob; - uint64_t *min_timestamp; - uint64_t *max_timestamp; -} wire_cst_history_page_filter; - -typedef struct wire_cst_record_string_permission_policy { - struct wire_cst_list_prim_u_8_strict *field0; - int32_t field1; -} wire_cst_record_string_permission_policy; - -typedef struct wire_cst_list_record_string_permission_policy { - struct wire_cst_record_string_permission_policy *ptr; - int32_t len; -} wire_cst_list_record_string_permission_policy; - -typedef struct wire_cst_Report_TableGeneration { - double progress; - struct wire_cst_list_prim_u_8_strict *step; - struct wire_cst_list_prim_u_8_strict *message; -} wire_cst_Report_TableGeneration; - -typedef struct wire_cst_Report_Misc { - struct wire_cst_list_prim_u_8_strict *message; -} wire_cst_Report_Misc; - -typedef union ReportKind { - struct wire_cst_Report_TableGeneration TableGeneration; - struct wire_cst_Report_Misc Misc; -} ReportKind; - -typedef struct wire_cst_report { - int32_t tag; - union ReportKind kind; -} wire_cst_report; - -typedef struct wire_cst_contact_details { - struct wire_cst_list_prim_u_8_strict *name; - struct wire_cst_list_prim_u_8_strict *address; - struct wire_cst_list_prim_u_8_strict *note; -} wire_cst_contact_details; - -typedef struct wire_cst_record_string_contact_details { - struct wire_cst_list_prim_u_8_strict *field0; - struct wire_cst_contact_details field1; -} wire_cst_record_string_contact_details; - -typedef struct wire_cst_list_record_string_contact_details { - struct wire_cst_record_string_contact_details *ptr; - int32_t len; -} wire_cst_list_record_string_contact_details; - -typedef struct wire_cst_address_book_data { - struct wire_cst_list_record_string_contact_details *contacts; -} wire_cst_address_book_data; - -typedef struct wire_cst_PrecomputedTableType_Custom { - uintptr_t field0; -} wire_cst_PrecomputedTableType_Custom; - -typedef union PrecomputedTableTypeKind { - struct wire_cst_PrecomputedTableType_Custom Custom; -} PrecomputedTableTypeKind; - -typedef struct wire_cst_precomputed_table_type { - int32_t tag; - union PrecomputedTableTypeKind kind; -} wire_cst_precomputed_table_type; - -typedef struct wire_cst_XswdRequestType_Permission { - struct wire_cst_list_prim_u_8_strict *field0; -} wire_cst_XswdRequestType_Permission; - -typedef struct wire_cst_XswdRequestType_PrefetchPermissions { - struct wire_cst_list_prim_u_8_strict *field0; -} wire_cst_XswdRequestType_PrefetchPermissions; - -typedef union XswdRequestTypeKind { - struct wire_cst_XswdRequestType_Permission Permission; - struct wire_cst_XswdRequestType_PrefetchPermissions PrefetchPermissions; -} XswdRequestTypeKind; - -typedef struct wire_cst_xswd_request_type { - int32_t tag; - union XswdRequestTypeKind kind; -} wire_cst_xswd_request_type; - -typedef struct wire_cst_app_info { - struct wire_cst_list_prim_u_8_strict *id; - struct wire_cst_list_prim_u_8_strict *name; - struct wire_cst_list_prim_u_8_strict *description; - struct wire_cst_list_prim_u_8_strict *url; - struct wire_cst_list_record_string_permission_policy *permissions; -} wire_cst_app_info; - -typedef struct wire_cst_xswd_request_summary { - struct wire_cst_xswd_request_type event_type; - struct wire_cst_app_info application_info; -} wire_cst_xswd_request_summary; - -typedef struct wire_cst_XelisAssetOwner_Creator { - struct wire_cst_list_prim_u_8_strict *contract; - uint64_t id; -} wire_cst_XelisAssetOwner_Creator; - -typedef struct wire_cst_XelisAssetOwner_Owner { - struct wire_cst_list_prim_u_8_strict *origin; - uint64_t origin_id; - struct wire_cst_list_prim_u_8_strict *owner; -} wire_cst_XelisAssetOwner_Owner; - -typedef union XelisAssetOwnerKind { - struct wire_cst_XelisAssetOwner_Creator Creator; - struct wire_cst_XelisAssetOwner_Owner Owner; -} XelisAssetOwnerKind; - -typedef struct wire_cst_xelis_asset_owner { - int32_t tag; - union XelisAssetOwnerKind kind; -} wire_cst_xelis_asset_owner; - -typedef struct wire_cst_list_app_info { - struct wire_cst_app_info *ptr; - int32_t len; -} wire_cst_list_app_info; - -typedef struct wire_cst_list_contact_details { - struct wire_cst_contact_details *ptr; - int32_t len; -} wire_cst_list_contact_details; - -typedef struct wire_cst_record_string_string { - struct wire_cst_list_prim_u_8_strict *field0; - struct wire_cst_list_prim_u_8_strict *field1; -} wire_cst_record_string_string; - -typedef struct wire_cst_list_record_string_string { - struct wire_cst_record_string_string *ptr; - int32_t len; -} wire_cst_list_record_string_string; - -typedef struct wire_cst_record_string_u_64 { - struct wire_cst_list_prim_u_8_strict *field0; - uint64_t field1; -} wire_cst_record_string_u_64; - -typedef struct wire_cst_list_record_string_u_64 { - struct wire_cst_record_string_u_64 *ptr; - int32_t len; -} wire_cst_list_record_string_u_64; - -typedef struct wire_cst_XelisMaxSupplyMode_Fixed { - uint64_t field0; -} wire_cst_XelisMaxSupplyMode_Fixed; - -typedef struct wire_cst_XelisMaxSupplyMode_Mintable { - uint64_t field0; -} wire_cst_XelisMaxSupplyMode_Mintable; - -typedef union XelisMaxSupplyModeKind { - struct wire_cst_XelisMaxSupplyMode_Fixed Fixed; - struct wire_cst_XelisMaxSupplyMode_Mintable Mintable; -} XelisMaxSupplyModeKind; - -typedef struct wire_cst_xelis_max_supply_mode { - int32_t tag; - union XelisMaxSupplyModeKind kind; -} wire_cst_xelis_max_supply_mode; - -typedef struct wire_cst_xelis_asset_metadata { - struct wire_cst_list_prim_u_8_strict *name; - struct wire_cst_list_prim_u_8_strict *ticker; - uint8_t decimals; - struct wire_cst_xelis_max_supply_mode max_supply; - struct wire_cst_xelis_asset_owner *owner; -} wire_cst_xelis_asset_metadata; - -typedef struct wire_cst_record_string_xelis_asset_metadata { - struct wire_cst_list_prim_u_8_strict *field0; - struct wire_cst_xelis_asset_metadata field1; -} wire_cst_record_string_xelis_asset_metadata; - -typedef struct wire_cst_list_record_string_xelis_asset_metadata { - struct wire_cst_record_string_xelis_asset_metadata *ptr; - int32_t len; -} wire_cst_list_record_string_xelis_asset_metadata; - -typedef struct wire_cst_log_entry { - int32_t level; - struct wire_cst_list_prim_u_8_strict *tag; - struct wire_cst_list_prim_u_8_strict *msg; -} wire_cst_log_entry; - -typedef struct wire_cst_record_auto_owned_rust_opaque_flutter_rust_bridgefor_generated_rust_auto_opaque_inner_transaction_auto_owned_rust_opaque_flutter_rust_bridgefor_generated_rust_auto_opaque_inner_transaction_builder_state { - uintptr_t field0; - uintptr_t field1; -} wire_cst_record_auto_owned_rust_opaque_flutter_rust_bridgefor_generated_rust_auto_opaque_inner_transaction_auto_owned_rust_opaque_flutter_rust_bridgefor_generated_rust_auto_opaque_inner_transaction_builder_state; - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_get_address(uintptr_t that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_get_data(uintptr_t that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_set_address(uintptr_t that, - uintptr_t address); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_set_data(uintptr_t that, - uintptr_t *data); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__seed_search_engine__SearchEngine_check_seed(uintptr_t that, - struct wire_cst_list_String *seed); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__seed_search_engine__SearchEngine_init(uintptr_t language_index); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__seed_search_engine__SearchEngine_search(uintptr_t that, - struct wire_cst_list_prim_u_8_strict *query); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__logger__SendToDartLogger_auto_accessor_get_level(uintptr_t that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__logger__SendToDartLogger_auto_accessor_set_level(uintptr_t that, - uintptr_t level); - -void frbgen_xelis_flutter_wire__crate__api__logger__SendToDartLogger_set_stream_sink(int64_t port_, - struct wire_cst_list_prim_u_8_strict *stream_sink); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_get_fee(uintptr_t that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_get_hash(uintptr_t that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_get_transaction_type(uintptr_t that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_set_fee(uintptr_t that, - uint64_t fee); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_set_hash(uintptr_t that, - struct wire_cst_list_prim_u_8_strict *hash); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_set_transaction_type(uintptr_t that, - uintptr_t transaction_type); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_all_history(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_broadcast_transaction(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *tx_hash); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_change_password(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *old_password, - struct wire_cst_list_prim_u_8_strict *new_password); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_clear_transaction(uintptr_t that, - struct wire_cst_list_prim_u_8_strict *tx_hash); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_close(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_close_application_session(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *id); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_convert_transactions_to_csv(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_burn_all_transaction(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset_hash); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_burn_transaction(int64_t port_, - uintptr_t that, - double float_amount, - struct wire_cst_list_prim_u_8_strict *asset_hash); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_multisig_burn_all_transaction(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset_hash); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_multisig_burn_transaction(int64_t port_, - uintptr_t that, - double float_amount, - struct wire_cst_list_prim_u_8_strict *asset_hash); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_multisig_transfer_all_transaction(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *str_address, - struct wire_cst_list_prim_u_8_strict *asset_hash, - struct wire_cst_list_prim_u_8_strict *extra_data, - bool *encrypt_extra_data); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_multisig_transfers_transaction(int64_t port_, - uintptr_t that, - struct wire_cst_list_transfer *transfers); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_transfer_all_transaction(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *str_address, - struct wire_cst_list_prim_u_8_strict *asset_hash, - struct wire_cst_list_prim_u_8_strict *extra_data, - bool *encrypt_extra_data); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_transfers_transaction(int64_t port_, - uintptr_t that, - struct wire_cst_list_transfer *transfers); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_estimate_fees(int64_t port_, - uintptr_t that, - struct wire_cst_list_transfer *transfers); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_events_stream(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *sink); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_export_transactions_to_csv_file(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *file_path); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_finalize_multisig_transaction(int64_t port_, - uintptr_t that, - struct wire_cst_list_signature_multisig *signatures); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_format_coin(int64_t port_, - uintptr_t that, - uint64_t atomic_amount, - struct wire_cst_list_prim_u_8_strict *asset_hash); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_address_str(uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_all_assets(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_application_permissions(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_balance_by_id(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_balance_by_id_raw(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_balances(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_decimals(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_metadata(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_ticker(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_daemon_info(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_history_count(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_known_assets(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_multisig_state(int64_t port_, - uintptr_t that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_network(uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_nonce(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_seed(int64_t port_, - uintptr_t that, - uintptr_t *language_index); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_tracked_asset_balances_raw(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_tracked_balances(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_xelis_balance(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_xelis_balance_raw(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_has_asset_balance(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_has_xelis_balance(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_history(int64_t port_, - uintptr_t that, - struct wire_cst_history_page_filter *filter); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_init_delete_multisig(int64_t port_, - uintptr_t that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_address_valid_for_multisig(uintptr_t that, - struct wire_cst_list_prim_u_8_strict *address); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_asset_tracked(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_online(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_valid_password(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *password); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_xswd_running(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_modify_application_permissions(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *id, - struct wire_cst_list_record_string_permission_policy *permissions); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_multisig_setup(int64_t port_, - uintptr_t that, - uint8_t threshold, - struct wire_cst_list_String *participants); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_multisig_sign(uintptr_t that, - struct wire_cst_list_prim_u_8_strict *tx_hash); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_offline_mode(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_online_mode(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *daemon_address); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_rescan(int64_t port_, - uintptr_t that, - uint64_t topoheight); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_start_xswd(int64_t port_, - uintptr_t that, - const void *cancel_request_dart_callback, - const void *request_application_dart_callback, - const void *request_permission_dart_callback, - const void *request_prefetch_permissions_dart_callback, - const void *app_disconnect_dart_callback); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_stop_xswd(int64_t port_, - uintptr_t that); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_track_asset(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset); - -void frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_untrack_asset(int64_t port_, - uintptr_t that, - struct wire_cst_list_prim_u_8_strict *asset); - -void frbgen_xelis_flutter_wire__crate__api__progress_report__add_progress_report(int64_t port_, - struct wire_cst_report *report); - -void frbgen_xelis_flutter_wire__crate__api__models__address_book_dtos__address_book_data_get_all_entries(int64_t port_, - struct wire_cst_address_book_data *that); - -void frbgen_xelis_flutter_wire__crate__api__precomputed_tables__are_precomputed_tables_available(int64_t port_, - struct wire_cst_list_prim_u_8_strict *precomputed_tables_path, - struct wire_cst_precomputed_table_type *precomputed_table_type); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__clear_cached_tables(void); - -void frbgen_xelis_flutter_wire__crate__api__xswd__imp__create_app_info(int64_t port_, - uintptr_t state); - -void frbgen_xelis_flutter_wire__crate__api__api__create_log_stream(int64_t port_, - struct wire_cst_list_prim_u_8_strict *s); - -void frbgen_xelis_flutter_wire__crate__api__api__create_progress_report_stream(int64_t port_, - struct wire_cst_list_prim_u_8_strict *stream_sink); - -void frbgen_xelis_flutter_wire__crate__api__wallet__create_xelis_wallet(int64_t port_, - struct wire_cst_list_prim_u_8_strict *name, - struct wire_cst_list_prim_u_8_strict *directory, - struct wire_cst_list_prim_u_8_strict *password, - int32_t network, - struct wire_cst_list_prim_u_8_strict *seed, - struct wire_cst_list_prim_u_8_strict *private_key, - struct wire_cst_list_prim_u_8_strict *precomputed_tables_path, - struct wire_cst_precomputed_table_type *precomputed_table_type); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__drop_wallet(uintptr_t wallet); - -void frbgen_xelis_flutter_wire__crate__api__utils__format_coin(int64_t port_, - uint64_t value, - uint8_t decimals); - -void frbgen_xelis_flutter_wire__crate__api__utils__format_xelis(int64_t port_, uint64_t value); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__get_cached_table(void); - -void frbgen_xelis_flutter_wire__crate__api__wallet__get_current_precomputed_tables_type(int64_t port_); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__utils__get_language_index_from_str(struct wire_cst_list_prim_u_8_strict *input); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__utils__get_mnemonic_words(uintptr_t language_index); - -void frbgen_xelis_flutter_wire__crate__api__logger__init_logger(int64_t port_); - -void frbgen_xelis_flutter_wire__crate__api__api__initialize_crypto_provider(int64_t port_); - -void frbgen_xelis_flutter_wire__crate__api__api__initialize_xelis_config(int64_t port_); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__utils__is_address_valid(struct wire_cst_list_prim_u_8_strict *str_address, - int32_t network); - -void frbgen_xelis_flutter_wire__crate__api__wallet__open_xelis_wallet(int64_t port_, - struct wire_cst_list_prim_u_8_strict *name, - struct wire_cst_list_prim_u_8_strict *directory, - struct wire_cst_list_prim_u_8_strict *password, - int32_t network, - struct wire_cst_list_prim_u_8_strict *precomputed_tables_path, - struct wire_cst_precomputed_table_type *precomputed_table_type); - -void frbgen_xelis_flutter_wire__crate__api__precomputed_tables__precomputed_table_type_index(int64_t port_, - struct wire_cst_precomputed_table_type *that); - -void frbgen_xelis_flutter_wire__crate__api__precomputed_tables__precomputed_table_type_name(int64_t port_, - struct wire_cst_precomputed_table_type *that); - -void frbgen_xelis_flutter_wire__crate__api__precomputed_tables__precomputed_table_type_to_l1_size(int64_t port_, - struct wire_cst_precomputed_table_type *that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__refresh_mt_params(void); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__wallet__set_mt_params(uintptr_t thread_count, - uintptr_t concurrency); - -void frbgen_xelis_flutter_wire__crate__api__api__set_up_rust_logger(int64_t port_); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__utils__split_integrated_address(struct wire_cst_list_prim_u_8_strict *integrated_address); - -void frbgen_xelis_flutter_wire__crate__api__wallet__update_tables(int64_t port_, - struct wire_cst_list_prim_u_8_strict *precomputed_tables_path, - struct wire_cst_precomputed_table_type *precomputed_table_type); - -void frbgen_xelis_flutter_wire__crate__api__xswd__imp__xswd_handler(int64_t port_, - uintptr_t receiver, - const void *cancel_request_dart_callback, - const void *request_application_dart_callback, - const void *request_permission_dart_callback, - const void *request_prefetch_permissions_dart_callback, - const void *app_disconnect_dart_callback); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_app_disconnect(struct wire_cst_xswd_request_summary *that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_application_request(struct wire_cst_xswd_request_summary *that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_cancel_request(struct wire_cst_xswd_request_summary *that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_permission_request(struct wire_cst_xswd_request_summary *that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_prefetch_permissions_request(struct wire_cst_xswd_request_summary *that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_permission_json(struct wire_cst_xswd_request_summary *that); - -WireSyncRust2DartDco frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_prefetch_permissions_json(struct wire_cst_xswd_request_summary *that); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerAddress(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerAddress(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerAppState(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerAppState(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDataElement(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDataElement(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerIntegratedAddress(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerIntegratedAddress(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLevelFilter(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLevelFilter(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerPrecomputedTablesShared(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerPrecomputedTablesShared(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSearchEngine(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSearchEngine(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSendToDartLogger(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSendToDartLogger(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSummaryTransaction(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSummaryTransaction(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransaction(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransaction(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransactionBuilderState(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransactionBuilderState(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransactionTypeBuilder(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransactionTypeBuilder(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerUnboundedReceiverXSWDEvent(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerUnboundedReceiverXSWDEvent(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerXelisWallet(const void *ptr); - -void frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerXelisWallet(const void *ptr); - -uintptr_t *frbgen_xelis_flutter_cst_new_box_autoadd_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDataElement(uintptr_t value); - -uintptr_t *frbgen_xelis_flutter_cst_new_box_autoadd_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerPrecomputedTablesShared(uintptr_t value); - -struct wire_cst_address_book_data *frbgen_xelis_flutter_cst_new_box_autoadd_address_book_data(void); - -bool *frbgen_xelis_flutter_cst_new_box_autoadd_bool(bool value); - -struct wire_cst_history_page_filter *frbgen_xelis_flutter_cst_new_box_autoadd_history_page_filter(void); - -struct wire_cst_precomputed_table_type *frbgen_xelis_flutter_cst_new_box_autoadd_precomputed_table_type(void); - -struct wire_cst_report *frbgen_xelis_flutter_cst_new_box_autoadd_report(void); - -uint64_t *frbgen_xelis_flutter_cst_new_box_autoadd_u_64(uint64_t value); - -uintptr_t *frbgen_xelis_flutter_cst_new_box_autoadd_usize(uintptr_t value); - -struct wire_cst_xelis_asset_owner *frbgen_xelis_flutter_cst_new_box_autoadd_xelis_asset_owner(void); - -struct wire_cst_xswd_request_summary *frbgen_xelis_flutter_cst_new_box_autoadd_xswd_request_summary(void); - -struct wire_cst_list_String *frbgen_xelis_flutter_cst_new_list_String(int32_t len); - -struct wire_cst_list_app_info *frbgen_xelis_flutter_cst_new_list_app_info(int32_t len); - -struct wire_cst_list_contact_details *frbgen_xelis_flutter_cst_new_list_contact_details(int32_t len); - -struct wire_cst_list_prim_u_8_strict *frbgen_xelis_flutter_cst_new_list_prim_u_8_strict(int32_t len); - -struct wire_cst_list_record_string_contact_details *frbgen_xelis_flutter_cst_new_list_record_string_contact_details(int32_t len); - -struct wire_cst_list_record_string_permission_policy *frbgen_xelis_flutter_cst_new_list_record_string_permission_policy(int32_t len); - -struct wire_cst_list_record_string_string *frbgen_xelis_flutter_cst_new_list_record_string_string(int32_t len); - -struct wire_cst_list_record_string_u_64 *frbgen_xelis_flutter_cst_new_list_record_string_u_64(int32_t len); - -struct wire_cst_list_record_string_xelis_asset_metadata *frbgen_xelis_flutter_cst_new_list_record_string_xelis_asset_metadata(int32_t len); - -struct wire_cst_list_signature_multisig *frbgen_xelis_flutter_cst_new_list_signature_multisig(int32_t len); - -struct wire_cst_list_transfer *frbgen_xelis_flutter_cst_new_list_transfer(int32_t len); -static int64_t dummy_method_to_enforce_bundling(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDataElement); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_Auto_Owned_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerPrecomputedTablesShared); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_address_book_data); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_bool); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_history_page_filter); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_precomputed_table_type); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_report); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_u_64); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_usize); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_xelis_asset_owner); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_box_autoadd_xswd_request_summary); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_String); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_app_info); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_contact_details); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_prim_u_8_strict); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_record_string_contact_details); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_record_string_permission_policy); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_record_string_string); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_record_string_u_64); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_record_string_xelis_asset_metadata); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_signature_multisig); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_cst_new_list_transfer); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerAddress); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerAppState); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDataElement); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerIntegratedAddress); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLevelFilter); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerPrecomputedTablesShared); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSearchEngine); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSendToDartLogger); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSummaryTransaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransactionBuilderState); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransactionTypeBuilder); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerUnboundedReceiverXSWDEvent); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_decrement_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerXelisWallet); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerAddress); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerAppState); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerDataElement); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerIntegratedAddress); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerLevelFilter); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerPrecomputedTablesShared); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSearchEngine); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSendToDartLogger); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerSummaryTransaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransactionBuilderState); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerTransactionTypeBuilder); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerUnboundedReceiverXSWDEvent); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_rust_arc_increment_strong_count_RustOpaque_flutter_rust_bridgefor_generatedRustAutoOpaqueInnerXelisWallet); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__api__create_log_stream); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__api__create_progress_report_stream); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__api__initialize_crypto_provider); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__api__initialize_xelis_config); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__api__set_up_rust_logger); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__logger__SendToDartLogger_auto_accessor_get_level); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__logger__SendToDartLogger_auto_accessor_set_level); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__logger__SendToDartLogger_set_stream_sink); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__logger__init_logger); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__address_book_dtos__address_book_data_get_all_entries); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_get_address); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_get_data); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_set_address); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_set_data); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_get_fee); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_get_hash); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_get_transaction_type); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_set_fee); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_set_hash); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_set_transaction_type); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_app_disconnect); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_application_request); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_cancel_request); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_permission_request); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_is_prefetch_permissions_request); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_permission_json); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__models__xswd_dtos__xswd_request_summary_prefetch_permissions_json); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__precomputed_tables__are_precomputed_tables_available); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__precomputed_tables__precomputed_table_type_index); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__precomputed_tables__precomputed_table_type_name); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__precomputed_tables__precomputed_table_type_to_l1_size); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__progress_report__add_progress_report); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__seed_search_engine__SearchEngine_check_seed); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__seed_search_engine__SearchEngine_init); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__seed_search_engine__SearchEngine_search); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__utils__format_coin); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__utils__format_xelis); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__utils__get_language_index_from_str); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__utils__get_mnemonic_words); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__utils__is_address_valid); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__utils__split_integrated_address); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_all_history); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_broadcast_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_change_password); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_clear_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_close); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_close_application_session); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_convert_transactions_to_csv); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_burn_all_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_burn_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_multisig_burn_all_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_multisig_burn_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_multisig_transfer_all_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_multisig_transfers_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_transfer_all_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_create_transfers_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_estimate_fees); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_events_stream); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_export_transactions_to_csv_file); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_finalize_multisig_transaction); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_format_coin); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_address_str); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_all_assets); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_application_permissions); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_balance_by_id); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_balance_by_id_raw); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_balances); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_decimals); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_metadata); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_asset_ticker); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_daemon_info); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_history_count); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_known_assets); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_multisig_state); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_network); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_nonce); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_seed); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_tracked_asset_balances_raw); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_tracked_balances); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_xelis_balance); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_get_xelis_balance_raw); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_has_asset_balance); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_has_xelis_balance); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_history); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_init_delete_multisig); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_address_valid_for_multisig); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_asset_tracked); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_online); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_valid_password); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_is_xswd_running); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_modify_application_permissions); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_multisig_setup); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_multisig_sign); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_offline_mode); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_online_mode); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_rescan); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_start_xswd); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_stop_xswd); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_track_asset); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__XelisWallet_untrack_asset); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__clear_cached_tables); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__create_xelis_wallet); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__drop_wallet); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__get_cached_table); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__get_current_precomputed_tables_type); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__open_xelis_wallet); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__refresh_mt_params); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__set_mt_params); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__wallet__update_tables); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__xswd__imp__create_app_info); - dummy_var ^= ((int64_t) (void*) frbgen_xelis_flutter_wire__crate__api__xswd__imp__xswd_handler); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - return dummy_var; -} diff --git a/ios/xelis_flutter.podspec b/ios/xelis_flutter.podspec deleted file mode 100644 index 94d10b5..0000000 --- a/ios/xelis_flutter.podspec +++ /dev/null @@ -1,45 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint xelis_flutter.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'xelis_flutter' - s.version = '0.0.1' - s.summary = 'A new Flutter FFI plugin project.' - s.description = <<-DESC -A new Flutter FFI plugin project. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - - # This will ensure the source files in Classes/ are included in the native - # builds of apps using this FFI plugin. Podspec does not support relative - # paths, so Classes contains a forwarder C file that relatively imports - # `../src/*` so that the C sources can be shared among all target platforms. - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.dependency 'Flutter' - s.platform = :ios, '11.0' - - # Flutter.framework does not contain a i386 slice. - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } - s.swift_version = '5.0' - - s.script_phase = { - :name => 'Build Rust library', - # First argument is relative path to the `rust` folder, second is name of rust library - :script => 'sh "$PODS_TARGET_SRCROOT/../cargokit/build_pod.sh" ../rust xelis_flutter', - :execution_position => :before_compile, - :input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'], - # Let XCode know that the static library referenced in -force_load below is - # created by this build step. - :output_files => ["${BUILT_PRODUCTS_DIR}/libxelis_flutter.a"], - } - s.pod_target_xcconfig = { - 'DEFINES_MODULE' => 'YES', - # Flutter.framework does not contain a i386 slice. - 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', - 'OTHER_LDFLAGS' => '-force_load ${BUILT_PRODUCTS_DIR}/libxelis_flutter.a -framework Foundation -framework SystemConfiguration -lc++', - } -end \ No newline at end of file diff --git a/lib/src/api/api.dart b/lib/src/api/api.dart index 0b59709..99bae9e 100644 --- a/lib/src/api/api.dart +++ b/lib/src/api/api.dart @@ -1,11 +1,13 @@ // This file is automatically generated, so please do not edit it. -// @generated by `flutter_rust_bridge`@ 2.12.0. +// @generated by `flutter_rust_bridge`@ 2.13.0. // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import import '../frb_generated.dart'; import 'logger.dart'; + import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + import 'progress_report.dart'; /// Initialize xelis_common configuration diff --git a/lib/src/api/logger.dart b/lib/src/api/logger.dart index d64405c..0574bc6 100644 --- a/lib/src/api/logger.dart +++ b/lib/src/api/logger.dart @@ -3,9 +3,10 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + import '../frb_generated.dart'; import '../lib.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; // These functions are ignored because they are not marked as `pub`: `record_to_entry` // These types are ignored because they are neither used by any `pub` functions nor (for structs and enums) marked `#[frb(unignore)]`: `SEND_TO_DART_LOGGER_STREAM_SINK` diff --git a/lib/src/api/models/address_book_dtos.dart b/lib/src/api/models/address_book_dtos.dart index 58e8571..ea2d4ff 100644 --- a/lib/src/api/models/address_book_dtos.dart +++ b/lib/src/api/models/address_book_dtos.dart @@ -3,9 +3,10 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import -import '../../frb_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import '../../frb_generated.dart'; + // These functions are ignored because they are not marked as `pub`: `add_entry` // These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `fmt`, `fmt` // These functions are ignored (category: IgnoreBecauseExplicitAttribute): `from`, `from`, `new`, `new`, `to_data_element` diff --git a/lib/src/api/models/wallet_dtos.dart b/lib/src/api/models/wallet_dtos.dart index 23973c2..b917a17 100644 --- a/lib/src/api/models/wallet_dtos.dart +++ b/lib/src/api/models/wallet_dtos.dart @@ -3,10 +3,12 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import -import '../../frb_generated.dart'; -import '../../lib.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'package:freezed_annotation/freezed_annotation.dart' hide protected; + +import '../../frb_generated.dart'; +import '../../lib.dart'; + part 'wallet_dtos.freezed.dart'; // These functions are ignored because they have generic arguments: `options` diff --git a/lib/src/api/models/wallet_dtos.freezed.dart b/lib/src/api/models/wallet_dtos.freezed.dart index 6d14f4c..3d7a0c4 100644 --- a/lib/src/api/models/wallet_dtos.freezed.dart +++ b/lib/src/api/models/wallet_dtos.freezed.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND // coverage:ignore-file -// ignore_for_file: type=lint +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'wallet_dtos.dart'; @@ -9,6 +9,7 @@ part of 'wallet_dtos.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND // dart format off T _$identity(T value) => value; /// @nodoc @@ -25,16 +26,21 @@ $HistoryPageFilterCopyWith get copyWith => _$HistoryPageFilte @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is HistoryPageFilter&&(identical(other.page, page) || other.page == page)&&(identical(other.limit, limit) || other.limit == limit)&&(identical(other.assetHash, assetHash) || other.assetHash == assetHash)&&(identical(other.address, address) || other.address == address)&&(identical(other.contract, contract) || other.contract == contract)&&(identical(other.minTopoheight, minTopoheight) || other.minTopoheight == minTopoheight)&&(identical(other.maxTopoheight, maxTopoheight) || other.maxTopoheight == maxTopoheight)&&(identical(other.acceptIncoming, acceptIncoming) || other.acceptIncoming == acceptIncoming)&&(identical(other.acceptOutgoing, acceptOutgoing) || other.acceptOutgoing == acceptOutgoing)&&(identical(other.acceptCoinbase, acceptCoinbase) || other.acceptCoinbase == acceptCoinbase)&&(identical(other.acceptBurn, acceptBurn) || other.acceptBurn == acceptBurn)&&(identical(other.acceptBlob, acceptBlob) || other.acceptBlob == acceptBlob)&&(identical(other.minTimestamp, minTimestamp) || other.minTimestamp == minTimestamp)&&(identical(other.maxTimestamp, maxTimestamp) || other.maxTimestamp == maxTimestamp)); + final _this = this as HistoryPageFilter; + return identical(this, other) || (other.runtimeType == runtimeType&&other is HistoryPageFilter&&(identical(other.page, _this.page) || other.page == _this.page)&&(identical(other.limit, _this.limit) || other.limit == _this.limit)&&(identical(other.assetHash, _this.assetHash) || other.assetHash == _this.assetHash)&&(identical(other.address, _this.address) || other.address == _this.address)&&(identical(other.contract, _this.contract) || other.contract == _this.contract)&&(identical(other.minTopoheight, _this.minTopoheight) || other.minTopoheight == _this.minTopoheight)&&(identical(other.maxTopoheight, _this.maxTopoheight) || other.maxTopoheight == _this.maxTopoheight)&&(identical(other.acceptIncoming, _this.acceptIncoming) || other.acceptIncoming == _this.acceptIncoming)&&(identical(other.acceptOutgoing, _this.acceptOutgoing) || other.acceptOutgoing == _this.acceptOutgoing)&&(identical(other.acceptCoinbase, _this.acceptCoinbase) || other.acceptCoinbase == _this.acceptCoinbase)&&(identical(other.acceptBurn, _this.acceptBurn) || other.acceptBurn == _this.acceptBurn)&&(identical(other.acceptBlob, _this.acceptBlob) || other.acceptBlob == _this.acceptBlob)&&(identical(other.minTimestamp, _this.minTimestamp) || other.minTimestamp == _this.minTimestamp)&&(identical(other.maxTimestamp, _this.maxTimestamp) || other.maxTimestamp == _this.maxTimestamp)); } @override -int get hashCode => Object.hash(runtimeType,page,limit,assetHash,address,contract,minTopoheight,maxTopoheight,acceptIncoming,acceptOutgoing,acceptCoinbase,acceptBurn,acceptBlob,minTimestamp,maxTimestamp); +int get hashCode { + final _this = this as HistoryPageFilter; + return Object.hash(runtimeType,_this.page,_this.limit,_this.assetHash,_this.address,_this.contract,_this.minTopoheight,_this.maxTopoheight,_this.acceptIncoming,_this.acceptOutgoing,_this.acceptCoinbase,_this.acceptBurn,_this.acceptBlob,_this.minTimestamp,_this.maxTimestamp); +} @override String toString() { - return 'HistoryPageFilter(page: $page, limit: $limit, assetHash: $assetHash, address: $address, contract: $contract, minTopoheight: $minTopoheight, maxTopoheight: $maxTopoheight, acceptIncoming: $acceptIncoming, acceptOutgoing: $acceptOutgoing, acceptCoinbase: $acceptCoinbase, acceptBurn: $acceptBurn, acceptBlob: $acceptBlob, minTimestamp: $minTimestamp, maxTimestamp: $maxTimestamp)'; + final _this = this as HistoryPageFilter; + return 'HistoryPageFilter(page: ${_this.page}, limit: ${_this.limit}, assetHash: ${_this.assetHash}, address: ${_this.address}, contract: ${_this.contract}, minTopoheight: ${_this.minTopoheight}, maxTopoheight: ${_this.maxTopoheight}, acceptIncoming: ${_this.acceptIncoming}, acceptOutgoing: ${_this.acceptOutgoing}, acceptCoinbase: ${_this.acceptCoinbase}, acceptBurn: ${_this.acceptBurn}, acceptBlob: ${_this.acceptBlob}, minTimestamp: ${_this.minTimestamp}, maxTimestamp: ${_this.maxTimestamp})'; } @@ -63,7 +69,7 @@ class _$HistoryPageFilterCopyWithImpl<$Res> /// Create a copy of HistoryPageFilter /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({Object? page = null,Object? limit = freezed,Object? assetHash = freezed,Object? address = freezed,Object? contract = freezed,Object? minTopoheight = freezed,Object? maxTopoheight = freezed,Object? acceptIncoming = null,Object? acceptOutgoing = null,Object? acceptCoinbase = null,Object? acceptBurn = null,Object? acceptBlob = null,Object? minTimestamp = freezed,Object? maxTimestamp = freezed,}) { - return _then(_self.copyWith( + return _then(HistoryPageFilter( page: null == page ? _self.page : page // ignore: cast_nullable_to_non_nullable as BigInt,limit: freezed == limit ? _self.limit : limit // ignore: cast_nullable_to_non_nullable as BigInt?,assetHash: freezed == assetHash ? _self.assetHash : assetHash // ignore: cast_nullable_to_non_nullable @@ -241,16 +247,18 @@ _$HistoryPageFilterCopyWith<_HistoryPageFilter> get copyWith => __$HistoryPageFi @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _HistoryPageFilter&&(identical(other.page, page) || other.page == page)&&(identical(other.limit, limit) || other.limit == limit)&&(identical(other.assetHash, assetHash) || other.assetHash == assetHash)&&(identical(other.address, address) || other.address == address)&&(identical(other.contract, contract) || other.contract == contract)&&(identical(other.minTopoheight, minTopoheight) || other.minTopoheight == minTopoheight)&&(identical(other.maxTopoheight, maxTopoheight) || other.maxTopoheight == maxTopoheight)&&(identical(other.acceptIncoming, acceptIncoming) || other.acceptIncoming == acceptIncoming)&&(identical(other.acceptOutgoing, acceptOutgoing) || other.acceptOutgoing == acceptOutgoing)&&(identical(other.acceptCoinbase, acceptCoinbase) || other.acceptCoinbase == acceptCoinbase)&&(identical(other.acceptBurn, acceptBurn) || other.acceptBurn == acceptBurn)&&(identical(other.acceptBlob, acceptBlob) || other.acceptBlob == acceptBlob)&&(identical(other.minTimestamp, minTimestamp) || other.minTimestamp == minTimestamp)&&(identical(other.maxTimestamp, maxTimestamp) || other.maxTimestamp == maxTimestamp)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _HistoryPageFilter&&(identical(other.page, page) || other.page == page)&&(identical(other.limit, limit) || other.limit == limit)&&(identical(other.assetHash, assetHash) || other.assetHash == assetHash)&&(identical(other.address, address) || other.address == address)&&(identical(other.contract, contract) || other.contract == contract)&&(identical(other.minTopoheight, minTopoheight) || other.minTopoheight == minTopoheight)&&(identical(other.maxTopoheight, maxTopoheight) || other.maxTopoheight == maxTopoheight)&&(identical(other.acceptIncoming, acceptIncoming) || other.acceptIncoming == acceptIncoming)&&(identical(other.acceptOutgoing, acceptOutgoing) || other.acceptOutgoing == acceptOutgoing)&&(identical(other.acceptCoinbase, acceptCoinbase) || other.acceptCoinbase == acceptCoinbase)&&(identical(other.acceptBurn, acceptBurn) || other.acceptBurn == acceptBurn)&&(identical(other.acceptBlob, acceptBlob) || other.acceptBlob == acceptBlob)&&(identical(other.minTimestamp, minTimestamp) || other.minTimestamp == minTimestamp)&&(identical(other.maxTimestamp, maxTimestamp) || other.maxTimestamp == maxTimestamp)); } @override -int get hashCode => Object.hash(runtimeType,page,limit,assetHash,address,contract,minTopoheight,maxTopoheight,acceptIncoming,acceptOutgoing,acceptCoinbase,acceptBurn,acceptBlob,minTimestamp,maxTimestamp); +int get hashCode { + return Object.hash(runtimeType,page,limit,assetHash,address,contract,minTopoheight,maxTopoheight,acceptIncoming,acceptOutgoing,acceptCoinbase,acceptBurn,acceptBlob,minTimestamp,maxTimestamp); +} @override String toString() { - return 'HistoryPageFilter(page: $page, limit: $limit, assetHash: $assetHash, address: $address, contract: $contract, minTopoheight: $minTopoheight, maxTopoheight: $maxTopoheight, acceptIncoming: $acceptIncoming, acceptOutgoing: $acceptOutgoing, acceptCoinbase: $acceptCoinbase, acceptBurn: $acceptBurn, acceptBlob: $acceptBlob, minTimestamp: $minTimestamp, maxTimestamp: $maxTimestamp)'; + return 'HistoryPageFilter(page: $page, limit: $limit, assetHash: $assetHash, address: $address, contract: $contract, minTopoheight: $minTopoheight, maxTopoheight: $maxTopoheight, acceptIncoming: $acceptIncoming, acceptOutgoing: $acceptOutgoing, acceptCoinbase: $acceptCoinbase, acceptBurn: $acceptBurn, acceptBlob: $acceptBlob, minTimestamp: $minTimestamp, maxTimestamp: $maxTimestamp)'; } @@ -315,16 +323,21 @@ $SignatureMultisigCopyWith get copyWith => _$SignatureMultisi @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is SignatureMultisig&&(identical(other.id, id) || other.id == id)&&(identical(other.signature, signature) || other.signature == signature)); + final _this = this as SignatureMultisig; + return identical(this, other) || (other.runtimeType == runtimeType&&other is SignatureMultisig&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.signature, _this.signature) || other.signature == _this.signature)); } @override -int get hashCode => Object.hash(runtimeType,id,signature); +int get hashCode { + final _this = this as SignatureMultisig; + return Object.hash(runtimeType,_this.id,_this.signature); +} @override String toString() { - return 'SignatureMultisig(id: $id, signature: $signature)'; + final _this = this as SignatureMultisig; + return 'SignatureMultisig(id: ${_this.id}, signature: ${_this.signature})'; } @@ -353,7 +366,7 @@ class _$SignatureMultisigCopyWithImpl<$Res> /// Create a copy of SignatureMultisig /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? signature = null,}) { - return _then(_self.copyWith( + return _then(SignatureMultisig( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as int,signature: null == signature ? _self.signature : signature // ignore: cast_nullable_to_non_nullable as String, @@ -507,16 +520,18 @@ _$SignatureMultisigCopyWith<_SignatureMultisig> get copyWith => __$SignatureMult @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _SignatureMultisig&&(identical(other.id, id) || other.id == id)&&(identical(other.signature, signature) || other.signature == signature)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SignatureMultisig&&(identical(other.id, id) || other.id == id)&&(identical(other.signature, signature) || other.signature == signature)); } @override -int get hashCode => Object.hash(runtimeType,id,signature); +int get hashCode { + return Object.hash(runtimeType,id,signature); +} @override String toString() { - return 'SignatureMultisig(id: $id, signature: $signature)'; + return 'SignatureMultisig(id: $id, signature: $signature)'; } @@ -569,16 +584,21 @@ $TransferCopyWith get copyWith => _$TransferCopyWithImpl(thi @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is Transfer&&(identical(other.floatAmount, floatAmount) || other.floatAmount == floatAmount)&&(identical(other.strAddress, strAddress) || other.strAddress == strAddress)&&(identical(other.assetHash, assetHash) || other.assetHash == assetHash)&&(identical(other.extraData, extraData) || other.extraData == extraData)&&(identical(other.encryptExtraData, encryptExtraData) || other.encryptExtraData == encryptExtraData)); + final _this = this as Transfer; + return identical(this, other) || (other.runtimeType == runtimeType&&other is Transfer&&(identical(other.floatAmount, _this.floatAmount) || other.floatAmount == _this.floatAmount)&&(identical(other.strAddress, _this.strAddress) || other.strAddress == _this.strAddress)&&(identical(other.assetHash, _this.assetHash) || other.assetHash == _this.assetHash)&&(identical(other.extraData, _this.extraData) || other.extraData == _this.extraData)&&(identical(other.encryptExtraData, _this.encryptExtraData) || other.encryptExtraData == _this.encryptExtraData)); } @override -int get hashCode => Object.hash(runtimeType,floatAmount,strAddress,assetHash,extraData,encryptExtraData); +int get hashCode { + final _this = this as Transfer; + return Object.hash(runtimeType,_this.floatAmount,_this.strAddress,_this.assetHash,_this.extraData,_this.encryptExtraData); +} @override String toString() { - return 'Transfer(floatAmount: $floatAmount, strAddress: $strAddress, assetHash: $assetHash, extraData: $extraData, encryptExtraData: $encryptExtraData)'; + final _this = this as Transfer; + return 'Transfer(floatAmount: ${_this.floatAmount}, strAddress: ${_this.strAddress}, assetHash: ${_this.assetHash}, extraData: ${_this.extraData}, encryptExtraData: ${_this.encryptExtraData})'; } @@ -607,7 +627,7 @@ class _$TransferCopyWithImpl<$Res> /// Create a copy of Transfer /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({Object? floatAmount = null,Object? strAddress = null,Object? assetHash = null,Object? extraData = freezed,Object? encryptExtraData = freezed,}) { - return _then(_self.copyWith( + return _then(Transfer( floatAmount: null == floatAmount ? _self.floatAmount : floatAmount // ignore: cast_nullable_to_non_nullable as double,strAddress: null == strAddress ? _self.strAddress : strAddress // ignore: cast_nullable_to_non_nullable as String,assetHash: null == assetHash ? _self.assetHash : assetHash // ignore: cast_nullable_to_non_nullable @@ -767,16 +787,18 @@ _$TransferCopyWith<_Transfer> get copyWith => __$TransferCopyWithImpl<_Transfer> @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _Transfer&&(identical(other.floatAmount, floatAmount) || other.floatAmount == floatAmount)&&(identical(other.strAddress, strAddress) || other.strAddress == strAddress)&&(identical(other.assetHash, assetHash) || other.assetHash == assetHash)&&(identical(other.extraData, extraData) || other.extraData == extraData)&&(identical(other.encryptExtraData, encryptExtraData) || other.encryptExtraData == encryptExtraData)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Transfer&&(identical(other.floatAmount, floatAmount) || other.floatAmount == floatAmount)&&(identical(other.strAddress, strAddress) || other.strAddress == strAddress)&&(identical(other.assetHash, assetHash) || other.assetHash == assetHash)&&(identical(other.extraData, extraData) || other.extraData == extraData)&&(identical(other.encryptExtraData, encryptExtraData) || other.encryptExtraData == encryptExtraData)); } @override -int get hashCode => Object.hash(runtimeType,floatAmount,strAddress,assetHash,extraData,encryptExtraData); +int get hashCode { + return Object.hash(runtimeType,floatAmount,strAddress,assetHash,extraData,encryptExtraData); +} @override String toString() { - return 'Transfer(floatAmount: $floatAmount, strAddress: $strAddress, assetHash: $assetHash, extraData: $extraData, encryptExtraData: $encryptExtraData)'; + return 'Transfer(floatAmount: $floatAmount, strAddress: $strAddress, assetHash: $assetHash, extraData: $extraData, encryptExtraData: $encryptExtraData)'; } @@ -832,16 +854,21 @@ $XelisAssetMetadataCopyWith get copyWith => _$XelisAssetMeta @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetMetadata&&(identical(other.name, name) || other.name == name)&&(identical(other.ticker, ticker) || other.ticker == ticker)&&(identical(other.decimals, decimals) || other.decimals == decimals)&&(identical(other.maxSupply, maxSupply) || other.maxSupply == maxSupply)&&(identical(other.owner, owner) || other.owner == owner)); + final _this = this as XelisAssetMetadata; + return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetMetadata&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.ticker, _this.ticker) || other.ticker == _this.ticker)&&(identical(other.decimals, _this.decimals) || other.decimals == _this.decimals)&&(identical(other.maxSupply, _this.maxSupply) || other.maxSupply == _this.maxSupply)&&(identical(other.owner, _this.owner) || other.owner == _this.owner)); } @override -int get hashCode => Object.hash(runtimeType,name,ticker,decimals,maxSupply,owner); +int get hashCode { + final _this = this as XelisAssetMetadata; + return Object.hash(runtimeType,_this.name,_this.ticker,_this.decimals,_this.maxSupply,_this.owner); +} @override String toString() { - return 'XelisAssetMetadata(name: $name, ticker: $ticker, decimals: $decimals, maxSupply: $maxSupply, owner: $owner)'; + final _this = this as XelisAssetMetadata; + return 'XelisAssetMetadata(name: ${_this.name}, ticker: ${_this.ticker}, decimals: ${_this.decimals}, maxSupply: ${_this.maxSupply}, owner: ${_this.owner})'; } @@ -870,7 +897,7 @@ class _$XelisAssetMetadataCopyWithImpl<$Res> /// Create a copy of XelisAssetMetadata /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({Object? name = null,Object? ticker = null,Object? decimals = null,Object? maxSupply = null,Object? owner = freezed,}) { - return _then(_self.copyWith( + return _then(XelisAssetMetadata( name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as String,ticker: null == ticker ? _self.ticker : ticker // ignore: cast_nullable_to_non_nullable as String,decimals: null == decimals ? _self.decimals : decimals // ignore: cast_nullable_to_non_nullable @@ -1051,16 +1078,18 @@ _$XelisAssetMetadataCopyWith<_XelisAssetMetadata> get copyWith => __$XelisAssetM @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _XelisAssetMetadata&&(identical(other.name, name) || other.name == name)&&(identical(other.ticker, ticker) || other.ticker == ticker)&&(identical(other.decimals, decimals) || other.decimals == decimals)&&(identical(other.maxSupply, maxSupply) || other.maxSupply == maxSupply)&&(identical(other.owner, owner) || other.owner == owner)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _XelisAssetMetadata&&(identical(other.name, name) || other.name == name)&&(identical(other.ticker, ticker) || other.ticker == ticker)&&(identical(other.decimals, decimals) || other.decimals == decimals)&&(identical(other.maxSupply, maxSupply) || other.maxSupply == maxSupply)&&(identical(other.owner, owner) || other.owner == owner)); } @override -int get hashCode => Object.hash(runtimeType,name,ticker,decimals,maxSupply,owner); +int get hashCode { + return Object.hash(runtimeType,name,ticker,decimals,maxSupply,owner); +} @override String toString() { - return 'XelisAssetMetadata(name: $name, ticker: $ticker, decimals: $decimals, maxSupply: $maxSupply, owner: $owner)'; + return 'XelisAssetMetadata(name: $name, ticker: $ticker, decimals: $decimals, maxSupply: $maxSupply, owner: $owner)'; } @@ -1132,7 +1161,7 @@ mixin _$XelisAssetOwner { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetOwner); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetOwner); } @@ -1141,7 +1170,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'XelisAssetOwner()'; + return 'XelisAssetOwner()'; } @@ -1303,7 +1332,7 @@ class XelisAssetOwner_None extends XelisAssetOwner { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetOwner_None); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetOwner_None); } @@ -1312,7 +1341,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'XelisAssetOwner.none()'; + return 'XelisAssetOwner.none()'; } @@ -1341,16 +1370,18 @@ $XelisAssetOwner_CreatorCopyWith get copyWith => _$Xeli @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetOwner_Creator&&(identical(other.contract, contract) || other.contract == contract)&&(identical(other.id, id) || other.id == id)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetOwner_Creator&&(identical(other.contract, contract) || other.contract == contract)&&(identical(other.id, id) || other.id == id)); } @override -int get hashCode => Object.hash(runtimeType,contract,id); +int get hashCode { + return Object.hash(runtimeType,contract,id); +} @override String toString() { - return 'XelisAssetOwner.creator(contract: $contract, id: $id)'; + return 'XelisAssetOwner.creator(contract: $contract, id: $id)'; } @@ -1410,16 +1441,18 @@ $XelisAssetOwner_OwnerCopyWith get copyWith => _$XelisAss @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetOwner_Owner&&(identical(other.origin, origin) || other.origin == origin)&&(identical(other.originId, originId) || other.originId == originId)&&(identical(other.owner, owner) || other.owner == owner)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisAssetOwner_Owner&&(identical(other.origin, origin) || other.origin == origin)&&(identical(other.originId, originId) || other.originId == originId)&&(identical(other.owner, owner) || other.owner == owner)); } @override -int get hashCode => Object.hash(runtimeType,origin,originId,owner); +int get hashCode { + return Object.hash(runtimeType,origin,originId,owner); +} @override String toString() { - return 'XelisAssetOwner.owner(origin: $origin, originId: $originId, owner: $owner)'; + return 'XelisAssetOwner.owner(origin: $origin, originId: $originId, owner: $owner)'; } @@ -1468,7 +1501,7 @@ mixin _$XelisMaxSupplyMode { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisMaxSupplyMode); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisMaxSupplyMode); } @@ -1477,7 +1510,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'XelisMaxSupplyMode()'; + return 'XelisMaxSupplyMode()'; } @@ -1639,7 +1672,7 @@ class XelisMaxSupplyMode_None extends XelisMaxSupplyMode { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisMaxSupplyMode_None); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisMaxSupplyMode_None); } @@ -1648,7 +1681,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'XelisMaxSupplyMode.none()'; + return 'XelisMaxSupplyMode.none()'; } @@ -1676,16 +1709,18 @@ $XelisMaxSupplyMode_FixedCopyWith get copyWith => _$Xe @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisMaxSupplyMode_Fixed&&(identical(other.field0, field0) || other.field0 == field0)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisMaxSupplyMode_Fixed&&(identical(other.field0, field0) || other.field0 == field0)); } @override -int get hashCode => Object.hash(runtimeType,field0); +int get hashCode { + return Object.hash(runtimeType,field0); +} @override String toString() { - return 'XelisMaxSupplyMode.fixed(field0: $field0)'; + return 'XelisMaxSupplyMode.fixed(field0: $field0)'; } @@ -1742,16 +1777,18 @@ $XelisMaxSupplyMode_MintableCopyWith get copyWith = @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisMaxSupplyMode_Mintable&&(identical(other.field0, field0) || other.field0 == field0)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XelisMaxSupplyMode_Mintable&&(identical(other.field0, field0) || other.field0 == field0)); } @override -int get hashCode => Object.hash(runtimeType,field0); +int get hashCode { + return Object.hash(runtimeType,field0); +} @override String toString() { - return 'XelisMaxSupplyMode.mintable(field0: $field0)'; + return 'XelisMaxSupplyMode.mintable(field0: $field0)'; } diff --git a/lib/src/api/models/xswd_dtos.dart b/lib/src/api/models/xswd_dtos.dart index edf4694..cc436d8 100644 --- a/lib/src/api/models/xswd_dtos.dart +++ b/lib/src/api/models/xswd_dtos.dart @@ -3,9 +3,11 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import -import '../../frb_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'package:freezed_annotation/freezed_annotation.dart' hide protected; + +import '../../frb_generated.dart'; + part 'xswd_dtos.freezed.dart'; // These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `clone`, `clone`, `clone`, `clone`, `clone`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt` diff --git a/lib/src/api/models/xswd_dtos.freezed.dart b/lib/src/api/models/xswd_dtos.freezed.dart index 72c4580..7f0b602 100644 --- a/lib/src/api/models/xswd_dtos.freezed.dart +++ b/lib/src/api/models/xswd_dtos.freezed.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND // coverage:ignore-file -// ignore_for_file: type=lint +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'xswd_dtos.dart'; @@ -9,6 +9,7 @@ part of 'xswd_dtos.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND // dart format off T _$identity(T value) => value; /// @nodoc @@ -25,16 +26,21 @@ $AppInfoCopyWith get copyWith => _$AppInfoCopyWithImpl(this as @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is AppInfo&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.url, url) || other.url == url)&&const DeepCollectionEquality().equals(other.permissions, permissions)); + final _this = this as AppInfo; + return identical(this, other) || (other.runtimeType == runtimeType&&other is AppInfo&&(identical(other.id, _this.id) || other.id == _this.id)&&(identical(other.name, _this.name) || other.name == _this.name)&&(identical(other.description, _this.description) || other.description == _this.description)&&(identical(other.url, _this.url) || other.url == _this.url)&&const DeepCollectionEquality().equals(other.permissions, _this.permissions)); } @override -int get hashCode => Object.hash(runtimeType,id,name,description,url,const DeepCollectionEquality().hash(permissions)); +int get hashCode { + final _this = this as AppInfo; + return Object.hash(runtimeType,_this.id,_this.name,_this.description,_this.url,const DeepCollectionEquality().hash(_this.permissions)); +} @override String toString() { - return 'AppInfo(id: $id, name: $name, description: $description, url: $url, permissions: $permissions)'; + final _this = this as AppInfo; + return 'AppInfo(id: ${_this.id}, name: ${_this.name}, description: ${_this.description}, url: ${_this.url}, permissions: ${_this.permissions})'; } @@ -63,7 +69,7 @@ class _$AppInfoCopyWithImpl<$Res> /// Create a copy of AppInfo /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? name = null,Object? description = null,Object? url = freezed,Object? permissions = null,}) { - return _then(_self.copyWith( + return _then(AppInfo( id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable @@ -204,7 +210,7 @@ return $default(_that.id,_that.name,_that.description,_that.url,_that.permission class _AppInfo implements AppInfo { - const _AppInfo({required this.id, required this.name, required this.description, this.url, required final Map permissions}): _permissions = permissions; + const _AppInfo({required this.id, required this.name, required this.description, this.url, required Map permissions}): _permissions = permissions; @override final String id; @@ -229,16 +235,18 @@ _$AppInfoCopyWith<_AppInfo> get copyWith => __$AppInfoCopyWithImpl<_AppInfo>(thi @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _AppInfo&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.url, url) || other.url == url)&&const DeepCollectionEquality().equals(other._permissions, _permissions)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _AppInfo&&(identical(other.id, id) || other.id == id)&&(identical(other.name, name) || other.name == name)&&(identical(other.description, description) || other.description == description)&&(identical(other.url, url) || other.url == url)&&const DeepCollectionEquality().equals(other.permissions, _permissions)); } @override -int get hashCode => Object.hash(runtimeType,id,name,description,url,const DeepCollectionEquality().hash(_permissions)); +int get hashCode { + return Object.hash(runtimeType,id,name,description,url,const DeepCollectionEquality().hash(_permissions)); +} @override String toString() { - return 'AppInfo(id: $id, name: $name, description: $description, url: $url, permissions: $permissions)'; + return 'AppInfo(id: $id, name: $name, description: $description, url: $url, permissions: $permissions)'; } @@ -294,16 +302,21 @@ $XswdRequestSummaryCopyWith get copyWith => _$XswdRequestSum @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestSummary&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.applicationInfo, applicationInfo) || other.applicationInfo == applicationInfo)); + final _this = this as XswdRequestSummary; + return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestSummary&&(identical(other.eventType, _this.eventType) || other.eventType == _this.eventType)&&(identical(other.applicationInfo, _this.applicationInfo) || other.applicationInfo == _this.applicationInfo)); } @override -int get hashCode => Object.hash(runtimeType,eventType,applicationInfo); +int get hashCode { + final _this = this as XswdRequestSummary; + return Object.hash(runtimeType,_this.eventType,_this.applicationInfo); +} @override String toString() { - return 'XswdRequestSummary(eventType: $eventType, applicationInfo: $applicationInfo)'; + final _this = this as XswdRequestSummary; + return 'XswdRequestSummary(eventType: ${_this.eventType}, applicationInfo: ${_this.applicationInfo})'; } @@ -332,7 +345,7 @@ class _$XswdRequestSummaryCopyWithImpl<$Res> /// Create a copy of XswdRequestSummary /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({Object? eventType = null,Object? applicationInfo = null,}) { - return _then(_self.copyWith( + return _then(XswdRequestSummary( eventType: null == eventType ? _self.eventType : eventType // ignore: cast_nullable_to_non_nullable as XswdRequestType,applicationInfo: null == applicationInfo ? _self.applicationInfo : applicationInfo // ignore: cast_nullable_to_non_nullable as AppInfo, @@ -504,16 +517,18 @@ _$XswdRequestSummaryCopyWith<_XswdRequestSummary> get copyWith => __$XswdRequest @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is _XswdRequestSummary&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.applicationInfo, applicationInfo) || other.applicationInfo == applicationInfo)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is _XswdRequestSummary&&(identical(other.eventType, eventType) || other.eventType == eventType)&&(identical(other.applicationInfo, applicationInfo) || other.applicationInfo == applicationInfo)); } @override -int get hashCode => Object.hash(runtimeType,eventType,applicationInfo); +int get hashCode { + return Object.hash(runtimeType,eventType,applicationInfo); +} @override String toString() { - return 'XswdRequestSummary(eventType: $eventType, applicationInfo: $applicationInfo)'; + return 'XswdRequestSummary(eventType: $eventType, applicationInfo: $applicationInfo)'; } @@ -579,7 +594,7 @@ mixin _$XswdRequestType { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType); } @@ -588,7 +603,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'XswdRequestType()'; + return 'XswdRequestType()'; } @@ -762,7 +777,7 @@ class XswdRequestType_Application extends XswdRequestType { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType_Application); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType_Application); } @@ -771,7 +786,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'XswdRequestType.application()'; + return 'XswdRequestType.application()'; } @@ -799,16 +814,18 @@ $XswdRequestType_PermissionCopyWith get copyWith => @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType_Permission&&(identical(other.field0, field0) || other.field0 == field0)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType_Permission&&(identical(other.field0, field0) || other.field0 == field0)); } @override -int get hashCode => Object.hash(runtimeType,field0); +int get hashCode { + return Object.hash(runtimeType,field0); +} @override String toString() { - return 'XswdRequestType.permission(field0: $field0)'; + return 'XswdRequestType.permission(field0: $field0)'; } @@ -865,16 +882,18 @@ $XswdRequestType_PrefetchPermissionsCopyWith Object.hash(runtimeType,field0); +int get hashCode { + return Object.hash(runtimeType,field0); +} @override String toString() { - return 'XswdRequestType.prefetchPermissions(field0: $field0)'; + return 'XswdRequestType.prefetchPermissions(field0: $field0)'; } @@ -926,7 +945,7 @@ class XswdRequestType_CancelRequest extends XswdRequestType { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType_CancelRequest); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType_CancelRequest); } @@ -935,7 +954,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'XswdRequestType.cancelRequest()'; + return 'XswdRequestType.cancelRequest()'; } @@ -958,7 +977,7 @@ class XswdRequestType_AppDisconnect extends XswdRequestType { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType_AppDisconnect); + return identical(this, other) || (other.runtimeType == runtimeType&&other is XswdRequestType_AppDisconnect); } @@ -967,7 +986,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'XswdRequestType.appDisconnect()'; + return 'XswdRequestType.appDisconnect()'; } diff --git a/lib/src/api/network.dart b/lib/src/api/network.dart index 5560fe0..018f6fd 100644 --- a/lib/src/api/network.dart +++ b/lib/src/api/network.dart @@ -3,7 +3,8 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import -import '../frb_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import '../frb_generated.dart'; + enum Network { mainnet, testnet, stagenet } diff --git a/lib/src/api/precomputed_tables.dart b/lib/src/api/precomputed_tables.dart index 5e7e329..4d89e2e 100644 --- a/lib/src/api/precomputed_tables.dart +++ b/lib/src/api/precomputed_tables.dart @@ -3,9 +3,11 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import -import '../frb_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'package:freezed_annotation/freezed_annotation.dart' hide protected; + +import '../frb_generated.dart'; + part 'precomputed_tables.freezed.dart'; // These types are ignored because they are neither used by any `pub` functions nor (for structs and enums) marked `#[frb(unignore)]`: `LogProgressTableGenerationReportFunction` diff --git a/lib/src/api/precomputed_tables.freezed.dart b/lib/src/api/precomputed_tables.freezed.dart index eb4e29b..a7dbacb 100644 --- a/lib/src/api/precomputed_tables.freezed.dart +++ b/lib/src/api/precomputed_tables.freezed.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND // coverage:ignore-file -// ignore_for_file: type=lint +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'precomputed_tables.dart'; @@ -9,6 +9,7 @@ part of 'precomputed_tables.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND // dart format off T _$identity(T value) => value; /// @nodoc @@ -20,7 +21,7 @@ mixin _$PrecomputedTableType { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType); + return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType); } @@ -29,7 +30,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'PrecomputedTableType()'; + return 'PrecomputedTableType()'; } @@ -197,7 +198,7 @@ class PrecomputedTableType_L1Low extends PrecomputedTableType { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType_L1Low); + return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType_L1Low); } @@ -206,7 +207,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'PrecomputedTableType.l1Low()'; + return 'PrecomputedTableType.l1Low()'; } @@ -229,7 +230,7 @@ class PrecomputedTableType_L1Medium extends PrecomputedTableType { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType_L1Medium); + return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType_L1Medium); } @@ -238,7 +239,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'PrecomputedTableType.l1Medium()'; + return 'PrecomputedTableType.l1Medium()'; } @@ -261,7 +262,7 @@ class PrecomputedTableType_L1Full extends PrecomputedTableType { @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType_L1Full); + return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType_L1Full); } @@ -270,7 +271,7 @@ int get hashCode => runtimeType.hashCode; @override String toString() { - return 'PrecomputedTableType.l1Full()'; + return 'PrecomputedTableType.l1Full()'; } @@ -298,16 +299,18 @@ $PrecomputedTableType_CustomCopyWith get copyWith = @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType_Custom&&(identical(other.field0, field0) || other.field0 == field0)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is PrecomputedTableType_Custom&&(identical(other.field0, field0) || other.field0 == field0)); } @override -int get hashCode => Object.hash(runtimeType,field0); +int get hashCode { + return Object.hash(runtimeType,field0); +} @override String toString() { - return 'PrecomputedTableType.custom(field0: $field0)'; + return 'PrecomputedTableType.custom(field0: $field0)'; } diff --git a/lib/src/api/progress_report.dart b/lib/src/api/progress_report.dart index 87d1ec1..c0aff7d 100644 --- a/lib/src/api/progress_report.dart +++ b/lib/src/api/progress_report.dart @@ -3,9 +3,11 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import -import '../frb_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'package:freezed_annotation/freezed_annotation.dart' hide protected; + +import '../frb_generated.dart'; + part 'progress_report.freezed.dart'; // These types are ignored because they are neither used by any `pub` functions nor (for structs and enums) marked `#[frb(unignore)]`: `PROGRESS_REPORT_STREAM_SINK` diff --git a/lib/src/api/progress_report.freezed.dart b/lib/src/api/progress_report.freezed.dart index fd05ddb..027cced 100644 --- a/lib/src/api/progress_report.freezed.dart +++ b/lib/src/api/progress_report.freezed.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND // coverage:ignore-file -// ignore_for_file: type=lint +// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark part of 'progress_report.dart'; @@ -9,6 +9,7 @@ part of 'progress_report.dart'; // FreezedGenerator // ************************************************************************** +// GENERATED CODE - DO NOT MODIFY BY HAND // dart format off T _$identity(T value) => value; /// @nodoc @@ -25,16 +26,21 @@ $ReportCopyWith get copyWith => _$ReportCopyWithImpl(this as Rep @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is Report&&(identical(other.message, message) || other.message == message)); + final _this = this as Report; + return identical(this, other) || (other.runtimeType == runtimeType&&other is Report&&(identical(other.message, _this.message) || other.message == _this.message)); } @override -int get hashCode => Object.hash(runtimeType,message); +int get hashCode { + final _this = this as Report; + return Object.hash(runtimeType,_this.message); +} @override String toString() { - return 'Report(message: $message)'; + final _this = this as Report; + return 'Report(message: ${_this.message})'; } @@ -223,16 +229,18 @@ $Report_TableGenerationCopyWith get copyWith => _$Report @override bool operator ==(Object other) { - return identical(this, other) || (other.runtimeType == runtimeType&&other is Report_TableGeneration&&(identical(other.progress, progress) || other.progress == progress)&&(identical(other.step, step) || other.step == step)&&(identical(other.message, message) || other.message == message)); + return identical(this, other) || (other.runtimeType == runtimeType&&other is Report_TableGeneration&&(identical(other.progress, progress) || other.progress == progress)&&(identical(other.step, step) || other.step == step)&&(identical(other.message, message) || other.message == message)); } @override -int get hashCode => Object.hash(runtimeType,progress,step,message); +int get hashCode { + return Object.hash(runtimeType,progress,step,message); +} @override String toString() { - return 'Report.tableGeneration(progress: $progress, step: $step, message: $message)'; + return 'Report.tableGeneration(progress: $progress, step: $step, message: $message)'; } @@ -291,16 +299,18 @@ $Report_MiscCopyWith get copyWith => _$Report_MiscCopyWithImpl Object.hash(runtimeType,message); +int get hashCode { + return Object.hash(runtimeType,message); +} @override String toString() { - return 'Report.misc(message: $message)'; + return 'Report.misc(message: $message)'; } diff --git a/lib/src/api/seed_search_engine.dart b/lib/src/api/seed_search_engine.dart index 6a69ae7..734e180 100644 --- a/lib/src/api/seed_search_engine.dart +++ b/lib/src/api/seed_search_engine.dart @@ -3,9 +3,10 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import -import '../frb_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import '../frb_generated.dart'; + // Rust type: RustOpaqueNom> abstract class SearchEngine implements RustOpaqueInterface { List checkSeed({required List seed}); diff --git a/lib/src/api/table_generation.dart b/lib/src/api/table_generation.dart index 8fcd8f8..919ba21 100644 --- a/lib/src/api/table_generation.dart +++ b/lib/src/api/table_generation.dart @@ -3,9 +3,10 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + import '../frb_generated.dart'; import 'precomputed_tables.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; // These types are ignored because they are neither used by any `pub` functions nor (for structs and enums) marked `#[frb(unignore)]`: `LogProgressTableGenerationReportFunction` // These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `report` diff --git a/lib/src/api/utils.dart b/lib/src/api/utils.dart index 3a51fbf..4606325 100644 --- a/lib/src/api/utils.dart +++ b/lib/src/api/utils.dart @@ -3,9 +3,10 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + import '../frb_generated.dart'; import 'network.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; // These functions have error during generation (see debug logs or enable `stop_on_error: true` for more details): `from_xelis` diff --git a/lib/src/api/wallet.dart b/lib/src/api/wallet.dart index a9083bc..a35e51d 100644 --- a/lib/src/api/wallet.dart +++ b/lib/src/api/wallet.dart @@ -3,11 +3,12 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + import '../frb_generated.dart'; import 'models/wallet_dtos.dart'; import 'models/xswd_dtos.dart'; import 'network.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; import 'precomputed_tables.dart'; import 'xswd/imp.dart'; diff --git a/lib/src/api/xswd/imp.dart b/lib/src/api/xswd/imp.dart index ea62a49..a57395e 100644 --- a/lib/src/api/xswd/imp.dart +++ b/lib/src/api/xswd/imp.dart @@ -3,9 +3,10 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + import '../../frb_generated.dart'; import '../models/xswd_dtos.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; // These functions are ignored because they are not marked as `pub`: `create_event_summary`, `handle_permission_decision`, `handle_prefetch_permissions_decision`, `xswd_event_name` diff --git a/lib/src/frb_generated.dart b/lib/src/frb_generated.dart index 9371a57..0733843 100644 --- a/lib/src/frb_generated.dart +++ b/lib/src/frb_generated.dart @@ -3,6 +3,11 @@ // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; + import 'api/api.dart'; import 'api/logger.dart'; import 'api/models/address_book_dtos.dart'; @@ -15,13 +20,10 @@ import 'api/seed_search_engine.dart'; import 'api/utils.dart'; import 'api/wallet.dart'; import 'api/xswd/imp.dart'; -import 'dart:async'; -import 'dart:convert'; import 'frb_generated.dart'; import 'frb_generated.io.dart' if (dart.library.js_interop) 'frb_generated.web.dart'; import 'lib.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; /// Main entrypoint of the Rust API class RustLib extends BaseEntrypoint { @@ -73,7 +75,7 @@ class RustLib extends BaseEntrypoint { kDefaultExternalLibraryLoaderConfig; @override - String get codegenVersion => '2.12.0'; + String get codegenVersion => '2.13.0'; @override int get rustContentHash => -747425718; @@ -5041,9 +5043,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { Map dco_decode_Map_String_String_None(dynamic raw) { // Codec=Dco (DartCObject based), see doc to use other codecs return Map.fromEntries( - dco_decode_list_record_string_string( - raw, - ).map((e) => MapEntry(e.$1, e.$2)), + dco_decode_list_record_string_string(raw) + .map((e) => MapEntry(e.$1, e.$2)), ); } @@ -5053,9 +5054,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { ) { // Codec=Dco (DartCObject based), see doc to use other codecs return Map.fromEntries( - dco_decode_list_record_string_contact_details( - raw, - ).map((e) => MapEntry(e.$1, e.$2)), + dco_decode_list_record_string_contact_details(raw) + .map((e) => MapEntry(e.$1, e.$2)), ); } @@ -5065,9 +5065,8 @@ class RustLibApiImpl extends RustLibApiImplPlatform implements RustLibApi { ) { // Codec=Dco (DartCObject based), see doc to use other codecs return Map.fromEntries( - dco_decode_list_record_string_permission_policy( - raw, - ).map((e) => MapEntry(e.$1, e.$2)), + dco_decode_list_record_string_permission_policy(raw) + .map((e) => MapEntry(e.$1, e.$2)), ); } diff --git a/lib/src/frb_generated.io.dart b/lib/src/frb_generated.io.dart index 2a2dc9c..320c759 100644 --- a/lib/src/frb_generated.io.dart +++ b/lib/src/frb_generated.io.dart @@ -3,6 +3,12 @@ // ignore_for_file: unused_import, unused_element, unnecessary_import, duplicate_ignore, invalid_use_of_internal_member, annotate_overrides, non_constant_identifier_names, curly_braces_in_flow_control_structures, prefer_const_literals_to_create_immutables, unused_field +import 'dart:async'; +import 'dart:convert'; +import 'dart:ffi' as ffi; + +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart'; + import 'api/api.dart'; import 'api/logger.dart'; import 'api/models/address_book_dtos.dart'; @@ -15,12 +21,8 @@ import 'api/seed_search_engine.dart'; import 'api/utils.dart'; import 'api/wallet.dart'; import 'api/xswd/imp.dart'; -import 'dart:async'; -import 'dart:convert'; -import 'dart:ffi' as ffi; import 'frb_generated.dart'; import 'lib.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_io.dart'; abstract class RustLibApiImplPlatform extends BaseApiImpl { RustLibApiImplPlatform({ @@ -6304,10 +6306,14 @@ class RustLibWire implements BaseWire { typedef DartPort = ffi.Int64; typedef DartDartPort = int; -typedef DartPostCObjectFnTypeFunction = - ffi.Bool Function(DartPort port_id, ffi.Pointer message); -typedef DartDartPostCObjectFnTypeFunction = - bool Function(DartDartPort port_id, ffi.Pointer message); +typedef DartPostCObjectFnTypeFunction = ffi.Bool Function( + DartPort port_id, + ffi.Pointer message, +); +typedef DartDartPostCObjectFnTypeFunction = bool Function( + DartDartPort port_id, + ffi.Pointer message, +); typedef DartPostCObjectFnType = ffi.Pointer>; diff --git a/lib/src/frb_generated.web.dart b/lib/src/frb_generated.web.dart index cdc2c02..f56a3eb 100644 --- a/lib/src/frb_generated.web.dart +++ b/lib/src/frb_generated.web.dart @@ -6,6 +6,11 @@ // Static analysis wrongly picks the IO variant, thus ignore this // ignore_for_file: argument_type_not_assignable +import 'dart:async'; +import 'dart:convert'; + +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_web.dart'; + import 'api/api.dart'; import 'api/logger.dart'; import 'api/models/address_book_dtos.dart'; @@ -18,11 +23,8 @@ import 'api/seed_search_engine.dart'; import 'api/utils.dart'; import 'api/wallet.dart'; import 'api/xswd/imp.dart'; -import 'dart:async'; -import 'dart:convert'; import 'frb_generated.dart'; import 'lib.dart'; -import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated_web.dart'; abstract class RustLibApiImplPlatform extends BaseApiImpl { RustLibApiImplPlatform({ diff --git a/lib/src/lib.dart b/lib/src/lib.dart index ba5b72d..b24e440 100644 --- a/lib/src/lib.dart +++ b/lib/src/lib.dart @@ -3,9 +3,10 @@ // ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import -import 'frb_generated.dart'; import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'frb_generated.dart'; + // Rust type: RustOpaqueNom> abstract class Address implements RustOpaqueInterface {} diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt deleted file mode 100644 index 200b75a..0000000 --- a/linux/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# The Flutter tooling requires that developers have CMake 3.10 or later -# installed. You should not increase this version, as doing so will cause -# the plugin to fail to compile for some customers of the plugin. -cmake_minimum_required(VERSION 3.10) - -# Project-level configuration. -set(PROJECT_NAME "xelis_flutter") -project(${PROJECT_NAME} LANGUAGES CXX) - -include("../cargokit/cmake/cargokit.cmake") -apply_cargokit(${PROJECT_NAME} ../rust xelis_flutter "") - -# List of absolute paths to libraries that should be bundled with the plugin. -# This list could contain prebuilt libraries, or libraries created by an -# external build triggered from this build file. -set(xelis_flutter_bundled_libraries - "${${PROJECT_NAME}_cargokit_lib}" - PARENT_SCOPE -) diff --git a/macos/Classes/dummy_file.c b/macos/Classes/dummy_file.c deleted file mode 100644 index e06dab9..0000000 --- a/macos/Classes/dummy_file.c +++ /dev/null @@ -1 +0,0 @@ -// This is an empty file to force CocoaPods to create a framework. diff --git a/macos/xelis_flutter.podspec b/macos/xelis_flutter.podspec deleted file mode 100644 index f10860e..0000000 --- a/macos/xelis_flutter.podspec +++ /dev/null @@ -1,44 +0,0 @@ -# -# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. -# Run `pod lib lint xelis_flutter.podspec` to validate before publishing. -# -Pod::Spec.new do |s| - s.name = 'xelis_flutter' - s.version = '0.0.1' - s.summary = 'A new Flutter FFI plugin project.' - s.description = <<-DESC -A new Flutter FFI plugin project. - DESC - s.homepage = 'http://example.com' - s.license = { :file => '../LICENSE' } - s.author = { 'Your Company' => 'email@example.com' } - - # This will ensure the source files in Classes/ are included in the native - # builds of apps using this FFI plugin. Podspec does not support relative - # paths, so Classes contains a forwarder C file that relatively imports - # `../src/*` so that the C sources can be shared among all target platforms. - s.source = { :path => '.' } - s.source_files = 'Classes/**/*' - s.dependency 'FlutterMacOS' - - s.platform = :osx, '10.11' - s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } - s.swift_version = '5.0' - - s.script_phase = { - :name => 'Build Rust library', - # First argument is relative path to the `rust` folder, second is name of rust library - :script => 'sh "$PODS_TARGET_SRCROOT/../cargokit/build_pod.sh" ../rust xelis_flutter', - :execution_position => :before_compile, - :input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'], - # Let XCode know that the static library referenced in -force_load below is - # created by this build step. - :output_files => ["${BUILT_PRODUCTS_DIR}/libxelis_flutter.a"], - } - s.pod_target_xcconfig = { - 'DEFINES_MODULE' => 'YES', - # Flutter.framework does not contain a i386 slice. - 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', - 'OTHER_LDFLAGS' => '-force_load ${BUILT_PRODUCTS_DIR}/libxelis_flutter.a -framework Foundation -framework SystemConfiguration', - } -end \ No newline at end of file diff --git a/pubspec.lock b/pubspec.lock index 27d5354..4d4d2a6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -5,18 +5,26 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "3b19a47f6ea7c2632760777c78174f47f6aec1e05f0cd611380d4593b8af1dbc" + sha256: "1b0e6a07425a3e460666e88bf1c949ccc7bb0116ad562ce94a1eca60fe820725" url: "https://pub.dev" source: hosted - version: "96.0.0" + version: "103.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "0c516bc4ad36a1a75759e54d5047cb9d15cded4459df01aa35a0b5ec7db2c2a0" + sha256: "61c04d0c1bfed555c681ea079519933f071a5a026578ff73c4ff0df2d3462e5e" url: "https://pub.dev" source: hosted - version: "10.2.0" + version: "13.3.0" + analyzer_buffer: + dependency: transitive + description: + name: analyzer_buffer + sha256: f890a2e708e38fbf4238ad2f9fd3d506538acdddb0cd8eb2c3e8c7bd17784b57 + url: "https://pub.dev" + source: hosted + version: "0.3.4" args: dependency: transitive description: @@ -130,7 +138,7 @@ packages: source: hosted version: "1.1.2" code_assets: - dependency: transitive + dependency: "direct main" description: name: code_assets sha256: bf394f466ba9205f1812a0433b392d6af280f155f56651eda7c18cc32ed493b8 @@ -165,10 +173,10 @@ packages: dependency: transitive description: name: dart_style - sha256: "29f7ecc274a86d32920b1d9cfc7502fa87220da41ec60b55f329559d5732e2b2" + sha256: "82ade9fc4273f29ed673e33166944465225b4f7fc5d4aaef48605cc751c18fc1" url: "https://pub.dev" source: hosted - version: "3.1.7" + version: "3.1.13" fake_async: dependency: transitive description: @@ -178,7 +186,7 @@ packages: source: hosted version: "1.3.3" ffi: - dependency: "direct main" + dependency: transitive description: name: ffi sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" @@ -214,6 +222,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_driver: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" flutter_lints: dependency: "direct dev" description: @@ -226,10 +239,18 @@ packages: dependency: "direct main" description: name: flutter_rust_bridge - sha256: e87d6b9ee934dcd24a128ccb2bd91905d2d5fe5c06245d6a8f5477d4907a437a + sha256: ec69331e2335ab4d456c0a9fc700892c2c85b72b9c0cb39df3ecfe8833d5d5c8 + url: "https://pub.dev" + source: hosted + version: "2.13.0" + flutter_rust_bridge_hooks: + dependency: "direct main" + description: + name: flutter_rust_bridge_hooks + sha256: "19900fbcaa8ddc2a4f1b13994ef34393eda129ebccc59ceb887a8fd2cf5def3e" url: "https://pub.dev" source: hosted - version: "2.12.0" + version: "2.13.0" flutter_test: dependency: "direct dev" description: flutter @@ -239,10 +260,10 @@ packages: dependency: "direct dev" description: name: freezed - sha256: f23ea33b3863f119b58ed1b586e881a46bd28715ddcc4dbc33104524e3434131 + sha256: "541a82723c84298f3ca46a6c2186935aa21ad529ad1f1423d67af18040494f51" url: "https://pub.dev" source: hosted - version: "3.2.5" + version: "4.0.1" freezed_annotation: dependency: "direct main" description: @@ -251,6 +272,11 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0" + fuchsia_remote_debug_protocol: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" glob: dependency: transitive description: @@ -268,7 +294,7 @@ packages: source: hosted version: "2.3.2" hooks: - dependency: transitive + dependency: "direct main" description: name: hooks sha256: "03a564c3704524ee0f7fc56fc621e8796cc2eb8c24d1f1a33b34979815b285c4" @@ -291,6 +317,11 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.2" + integration_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" io: dependency: transitive description: @@ -299,30 +330,6 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.5" - jni: - dependency: transitive - description: - name: jni - sha256: "5bc9a9daac5ccfbd6a758377600b9f7fdce13d93f26e8012a8941014a5d978d1" - url: "https://pub.dev" - source: hosted - version: "1.0.2" - jni_flutter: - dependency: transitive - description: - name: jni_flutter - sha256: "7b717011ea40d04fd47c2731d3d1d36eb99eba3435c2753d62489e8c3c9991d5" - url: "https://pub.dev" - source: hosted - version: "1.0.2" - jni_util: - dependency: transitive - description: - name: jni_util - sha256: "1ba86da04a5f2bf18fde2edb235587e70c5b0fc5bd4ba955f46b00942c3fc35f" - url: "https://pub.dev" - source: hosted - version: "1.0.0" json_annotation: dependency: "direct main" description: @@ -372,7 +379,7 @@ packages: source: hosted version: "5.1.1" logging: - dependency: transitive + dependency: "direct main" description: name: logging sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 @@ -411,14 +418,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.0" - objective_c: - dependency: transitive + native_toolchain_rust: + dependency: "direct main" description: - name: objective_c - sha256: b7fb95a6d9a4f009edd63dc5ac69f07420b23a16161c6dd8660290b59c602e8e + name: native_toolchain_rust + sha256: "8469a0e32a47a5c84b7fd300de9fd0e8082aac76c37922986324f5082a58350d" url: "https://pub.dev" source: hosted - version: "9.5.0" + version: "1.0.6" package_config: dependency: transitive description: @@ -435,54 +442,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.1" - path_provider: - dependency: "direct main" - description: - name: path_provider - sha256: a7f4874f987173da295a61c181b8ee71dab59b332a486b391babf26a1b884825 - url: "https://pub.dev" - source: hosted - version: "2.1.6" - path_provider_android: - dependency: transitive - description: - name: path_provider_android - sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd" - url: "https://pub.dev" - source: hosted - version: "2.3.1" - path_provider_foundation: - dependency: transitive - description: - name: path_provider_foundation - sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699" - url: "https://pub.dev" - source: hosted - version: "2.6.0" - path_provider_linux: - dependency: transitive - description: - name: path_provider_linux - sha256: "58c2005f147315b11e9b4a7bc889cd5203e250cba8e3f012dae259b4972b5c16" - url: "https://pub.dev" - source: hosted - version: "2.2.2" - path_provider_platform_interface: - dependency: transitive - description: - name: path_provider_platform_interface - sha256: "484838772624c3a4b94f1e44a3e19897fee738f2d5c4ce448443b0417f7c9dda" - url: "https://pub.dev" - source: hosted - version: "2.1.3" - path_provider_windows: + petitparser: dependency: transitive description: - name: path_provider_windows - sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + name: petitparser + sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675" url: "https://pub.dev" source: hosted - version: "2.3.0" + version: "7.0.2" platform: dependency: transitive description: @@ -491,14 +458,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.6" - plugin_platform_interface: - dependency: "direct main" - description: - name: plugin_platform_interface - sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" - url: "https://pub.dev" - source: hosted - version: "2.1.8" pool: dependency: transitive description: @@ -507,6 +466,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.2" + process: + dependency: transitive + description: + name: process + sha256: "4242ba3508d37e01808bdf71ad1d5bb93a8d671bf2e7450e6b1b353fb0808891" + url: "https://pub.dev" + source: hosted + version: "5.0.6" pub_semver: dependency: transitive description: @@ -616,6 +583,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.1" + sync_http: + dependency: transitive + description: + name: sync_http + sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961" + url: "https://pub.dev" + source: hosted + version: "0.3.1" term_glyph: dependency: transitive description: @@ -632,6 +607,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.7.12" + toml: + dependency: transitive + description: + name: toml + sha256: "35a35f782228656a2af31e8c73d1353cc4ef3d683fd68af1111b44631879c05e" + url: "https://pub.dev" + source: hosted + version: "0.18.0" typed_data: dependency: transitive description: @@ -688,14 +671,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" - xdg_directories: + webdriver: dependency: transitive description: - name: xdg_directories - sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + name: webdriver + sha256: "28b82ec894fed45dd71c23ba62d1af973ed97dd59a4f5790a4d38b0b13e5657e" url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "3.2.0" yaml: dependency: transitive description: @@ -713,5 +696,5 @@ packages: source: hosted version: "2.2.4" sdks: - dart: ">=3.11.0-0 <4.0.0" - flutter: ">=3.38.4" + dart: ">=3.13.0 <4.0.0" + flutter: ">=3.47.2" diff --git a/pubspec.yaml b/pubspec.yaml index 3731bd5..f897c56 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,76 +1,41 @@ name: xelis_flutter -description: "A pre-built suite of FFI bindings to use the native Rust Xelis wallet functions in any Flutter app, by simply adding this plugin as a dependency." -version: 0.2.0 +description: "FFI bindings to the native Rust Xelis wallet for Flutter apps. The Rust crate is compiled by Flutter native assets when you build your app." +version: 0.4.0 homepage: +# The Rust crate in `rust/` is compiled and bundled by Flutter native assets +# (build hooks) through `hook/build.dart`; there is no platform plugin +# scaffolding (no podspec / CMake / Gradle). Requires Flutter 3.47.2+ and rustup. environment: - sdk: ^3.9.0 - flutter: ">=1.17.0" + sdk: ^3.13.0 + flutter: ">=3.47.2" dependencies: flutter: sdk: flutter - plugin_platform_interface: ^2.0.2 - ffi: ^2.1.3 freezed_annotation: ">=2.0.0 <4.0.0" json_annotation: ^4.9.0 - path_provider: ^2.1.5 - flutter_rust_bridge: 2.12.0 + flutter_rust_bridge: 2.13.0 + # Used by hook/build.dart, which runs on every machine that builds a + # dependent app, so these must be regular (not dev) dependencies. + flutter_rust_bridge_hooks: 2.13.0 + # native_toolchain_rust spawns rustup/cargo on every consumer machine, so it is + # pinned exactly and bumped deliberately (together with flutter_rust_bridge_hooks, + # re-running the platform builds). `hooks` is the build-hook protocol package that + # every native-assets package shares, so it stays a range: pinning it exactly would + # make version solving fail for apps that also use a package requiring a newer one. + native_toolchain_rust: 1.0.6 + hooks: ^2.1.0 + code_assets: ^1.2.1 + logging: ^1.3.0 dev_dependencies: - build_runner: ^2.15.1 + build_runner: ^2.15.1 ffigen: ^20.1.1 flutter_lints: ^5.0.0 - freezed: ^3.2.5 - json_serializable: ^6.13.0 + freezed: ^4.0.1 + json_serializable: ^6.13.0 flutter_test: sdk: flutter - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter packages. -flutter: - plugin: - platforms: - android: - ffiPlugin: true - ios: - ffiPlugin: true - linux: - ffiPlugin: true - macos: - ffiPlugin: true - windows: - ffiPlugin: true - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/to/asset-from-package - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/to/resolution-aware-images - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/to/font-from-package + integration_test: + sdk: flutter diff --git a/run_build_tool.cmd b/run_build_tool.cmd deleted file mode 100644 index c45d0aa..0000000 --- a/run_build_tool.cmd +++ /dev/null @@ -1,91 +0,0 @@ -@echo off -setlocal - -setlocal ENABLEDELAYEDEXPANSION - -SET BASEDIR=%~dp0 - -if not exist "%CARGOKIT_TOOL_TEMP_DIR%" ( - mkdir "%CARGOKIT_TOOL_TEMP_DIR%" -) -cd /D "%CARGOKIT_TOOL_TEMP_DIR%" - -SET BUILD_TOOL_PKG_DIR=%BASEDIR%build_tool -SET DART=%FLUTTER_ROOT%\bin\cache\dart-sdk\bin\dart - -set BUILD_TOOL_PKG_DIR_POSIX=%BUILD_TOOL_PKG_DIR:\=/% - -( - echo name: build_tool_runner - echo version: 1.0.0 - echo publish_to: none - echo. - echo environment: - echo sdk: '^>=3.0.0 ^<4.0.0' - echo. - echo dependencies: - echo build_tool: - echo path: %BUILD_TOOL_PKG_DIR_POSIX% -) >pubspec.yaml - -if not exist bin ( - mkdir bin -) - -( - echo import 'package:build_tool/build_tool.dart' as build_tool; - echo void main^(List^ args^) ^{ - echo build_tool.runMain^(args^); - echo ^} -) >bin\build_tool_runner.dart - -SET PRECOMPILED=bin\build_tool_runner.dill - -REM To detect changes in package we compare output of DIR /s (recursive) -set PREV_PACKAGE_INFO=.dart_tool\package_info.prev -set CUR_PACKAGE_INFO=.dart_tool\package_info.cur - -DIR "%BUILD_TOOL_PKG_DIR%" /s > "%CUR_PACKAGE_INFO%_orig" - -REM Last line in dir output is free space on harddrive. That is bound to -REM change between invocation so we need to remove it -( - Set "Line=" - For /F "UseBackQ Delims=" %%A In ("%CUR_PACKAGE_INFO%_orig") Do ( - SetLocal EnableDelayedExpansion - If Defined Line Echo !Line! - EndLocal - Set "Line=%%A") -) >"%CUR_PACKAGE_INFO%" -DEL "%CUR_PACKAGE_INFO%_orig" - -REM Compare current directory listing with previous -FC /B "%CUR_PACKAGE_INFO%" "%PREV_PACKAGE_INFO%" > nul 2>&1 - -If %ERRORLEVEL% neq 0 ( - REM Changed - copy current to previous and remove precompiled kernel - if exist "%PREV_PACKAGE_INFO%" ( - DEL "%PREV_PACKAGE_INFO%" - ) - MOVE /Y "%CUR_PACKAGE_INFO%" "%PREV_PACKAGE_INFO%" - if exist "%PRECOMPILED%" ( - DEL "%PRECOMPILED%" - ) -) - -REM There is no CUR_PACKAGE_INFO it was renamed in previous step to %PREV_PACKAGE_INFO% -REM which means we need to do pub get and precompile -if not exist "%PRECOMPILED%" ( - echo Running pub get in "%cd%" - "%DART%" pub get --no-precompile - "%DART%" compile kernel bin/build_tool_runner.dart -) - -"%DART%" "%PRECOMPILED%" %* - -REM 253 means invalid snapshot version. -If %ERRORLEVEL% equ 253 ( - "%DART%" pub get --no-precompile - "%DART%" compile kernel bin/build_tool_runner.dart - "%DART%" "%PRECOMPILED%" %* -) diff --git a/run_build_tool.sh b/run_build_tool.sh deleted file mode 100755 index 24b0ed8..0000000 --- a/run_build_tool.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash - -set -e - -BASEDIR=$(dirname "$0") - -mkdir -p "$CARGOKIT_TOOL_TEMP_DIR" - -cd "$CARGOKIT_TOOL_TEMP_DIR" - -# Write a very simple bin package in temp folder that depends on build_tool package -# from Cargokit. This is done to ensure that we don't pollute Cargokit folder -# with .dart_tool contents. - -BUILD_TOOL_PKG_DIR="$BASEDIR/build_tool" - -if [[ -z $FLUTTER_ROOT ]]; then # not defined - DART=dart -else - DART="$FLUTTER_ROOT/bin/cache/dart-sdk/bin/dart" -fi - -cat << EOF > "pubspec.yaml" -name: build_tool_runner -version: 1.0.0 -publish_to: none - -environment: - sdk: '>=3.0.0 <4.0.0' - -dependencies: - build_tool: - path: "$BUILD_TOOL_PKG_DIR" -EOF - -mkdir -p "bin" - -cat << EOF > "bin/build_tool_runner.dart" -import 'package:build_tool/build_tool.dart' as build_tool; -void main(List args) { - build_tool.runMain(args); -} -EOF - -# Create alias for `shasum` if it does not exist and `sha1sum` exists -if ! [ -x "$(command -v shasum)" ] && [ -x "$(command -v sha1sum)" ]; then - shopt -s expand_aliases - alias shasum="sha1sum" -fi - -# Dart run will not cache any package that has a path dependency, which -# is the case for our build_tool_runner. So instead we precompile the package -# ourselves. -# To invalidate the cached kernel we use the hash of ls -LR of the build_tool -# package directory. This should be good enough, as the build_tool package -# itself is not meant to have any path dependencies. - -if [[ "$OSTYPE" == "darwin"* ]]; then - PACKAGE_HASH=$(ls -lTR "$BUILD_TOOL_PKG_DIR" | shasum) -else - PACKAGE_HASH=$(ls -lR --full-time "$BUILD_TOOL_PKG_DIR" | shasum) -fi - -PACKAGE_HASH_FILE=".package_hash" - -if [ -f "$PACKAGE_HASH_FILE" ]; then - EXISTING_HASH=$(cat "$PACKAGE_HASH_FILE") - if [ "$PACKAGE_HASH" != "$EXISTING_HASH" ]; then - rm "$PACKAGE_HASH_FILE" - fi -fi - -# Run pub get if needed. -if [ ! -f "$PACKAGE_HASH_FILE" ]; then - "$DART" pub get --no-precompile - "$DART" compile kernel bin/build_tool_runner.dart - echo "$PACKAGE_HASH" > "$PACKAGE_HASH_FILE" -fi - -# Rebuild the tool if it was deleted by Android Studio -if [ ! -f "bin/build_tool_runner.dill" ]; then - "$DART" compile kernel bin/build_tool_runner.dart -fi - -set +e - -"$DART" bin/build_tool_runner.dill "$@" - -exit_code=$? - -# 253 means invalid snapshot version. -if [ $exit_code == 253 ]; then - "$DART" pub get --no-precompile - "$DART" compile kernel bin/build_tool_runner.dart - "$DART" bin/build_tool_runner.dill "$@" - exit_code=$? -fi - -exit $exit_code diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 35be3bd..f77c51f 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -105,7 +105,7 @@ dependencies = [ "actix-utils", "futures-core", "futures-util", - "mio 1.2.2", + "mio", "socket2 0.5.10", "tokio", "tracing", @@ -343,56 +343,6 @@ dependencies = [ "libc", ] -[[package]] -name = "anstream" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" - -[[package]] -name = "anstyle-parse" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" -dependencies = [ - "windows-sys 0.61.2", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" -dependencies = [ - "anstyle", - "once_cell_polyfill", - "windows-sys 0.61.2", -] - [[package]] name = "anyhow" version = "1.0.104" @@ -648,65 +598,6 @@ dependencies = [ "bytes", ] -[[package]] -name = "camino" -version = "1.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb1307f12aa967b5a58416e87b3653360e0fd614a016b6e970db08fecbb1b80d" -dependencies = [ - "serde_core", -] - -[[package]] -name = "cargo-platform" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e35af189006b9c0f00a064685c727031e3ed2d8020f7ba284d78cc2671bd36ea" -dependencies = [ - "serde", -] - -[[package]] -name = "cargo_metadata" -version = "0.14.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa" -dependencies = [ - "camino", - "cargo-platform", - "semver", - "serde", - "serde_json", -] - -[[package]] -name = "cargo_toml" -version = "0.21.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fbd1fe9db3ebf71b89060adaf7b0504c2d6a425cf061313099547e382c2e472" -dependencies = [ - "serde", - "toml 0.8.23", -] - -[[package]] -name = "cbindgen" -version = "0.28.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eadd868a2ce9ca38de7eeafdcec9c7065ef89b42b32f0839278d55f35c54d1ff" -dependencies = [ - "heck 0.4.1", - "indexmap", - "log", - "proc-macro2", - "quote", - "serde", - "serde_json", - "syn 2.0.119", - "tempfile", - "toml 0.8.23", -] - [[package]] name = "cc" version = "1.4.0" @@ -794,69 +685,12 @@ dependencies = [ "inout 0.2.2", ] -[[package]] -name = "clap" -version = "4.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91e0c145792ef73a6ad36d27c75ac09f1832222a3c209689d90f534685ee5b7" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f09628afdcc538b57f3c6341e9c8e9970f18e4a481690a64974d7023bd33548b" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d012d2b9d65aca7f18f4d9878a045bc17899bba951561ba5ec3c2ba1eed9a061" -dependencies = [ - "heck 0.5.0", - "proc-macro2", - "quote", - "syn 3.0.3", -] - -[[package]] -name = "clap_lex" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9" - [[package]] name = "cmov" version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" -[[package]] -name = "colorchoice" -version = "1.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" - -[[package]] -name = "colored" -version = "1.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f741c91823341bebf717d4c71bda820630ce065443b58bd1b7451af008355" -dependencies = [ - "is-terminal", - "lazy_static", - "winapi", -] - [[package]] name = "colored" version = "2.2.0" @@ -867,18 +701,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "console" -version = "0.16.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe5f465a4f6fee88fad41b85d990f84c835335e85b5d9e6e63e0d06d28cba7c" -dependencies = [ - "encode_unicode", - "libc", - "unicode-width", - "windows-sys 0.61.2", -] - [[package]] name = "console_error_panic_hook" version = "0.1.7" @@ -922,12 +744,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d52eff69cd5e647efe296129160853a42795992097e8af39800e1060caeea9b" -[[package]] -name = "convert_case" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a24b1aaf0fd0ce8b45161144d6f42cd91677fd5940fd431183eb023b3a2b8" - [[package]] name = "convert_case" version = "0.10.0" @@ -997,15 +813,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crossbeam-channel" -version = "0.5.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d85363c37faeca707aef026efa9f3b34d077bce547e48f770770625c6013679e" -dependencies = [ - "crossbeam-utils", -] - [[package]] name = "crossbeam-deque" version = "0.8.7" @@ -1151,17 +958,6 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "derive_more" version = "2.1.1" @@ -1177,7 +973,7 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" dependencies = [ - "convert_case 0.10.0", + "convert_case", "proc-macro2", "quote", "rustc_version", @@ -1230,12 +1026,6 @@ version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e5e8f6c15a24b9a3ee5efec809ccd006d3b30e8b3bb63c39af737c7f87daa1d" -[[package]] -name = "encode_unicode" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" - [[package]] name = "encoding_rs" version = "0.8.35" @@ -1245,38 +1035,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "enum-iterator" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fd242f399be1da0a5354aa462d57b4ab2b4ee0683cc552f7c007d2d12d36e94" -dependencies = [ - "enum-iterator-derive", -] - -[[package]] -name = "enum-iterator-derive" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "685adfa4d6f3d765a26bc5dbc936577de9abf756c1feeb3089b01dd395034842" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - -[[package]] -name = "enum_dispatch" -version = "0.3.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa18ce2bc66555b3218614519ac839ddb759a7d6720732f979ef8d13be147ecd" -dependencies = [ - "once_cell", - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "env_filter" version = "0.1.4" @@ -1303,23 +1061,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "fastrand" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" - -[[package]] -name = "fern" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f0c14694cbd524c8720dd69b0e3179344f04ebb5f90f2e4a440c6ea3b2f1ee" -dependencies = [ - "chrono", - "colored 1.9.4", - "log", -] - [[package]] name = "fern" version = "0.7.1" @@ -1327,7 +1068,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4316185f709b23713e41e3195f90edef7fb00c3ed4adc79769cf09cc762a3b29" dependencies = [ "chrono", - "colored 2.2.0", + "colored", "log", ] @@ -1356,16 +1097,6 @@ dependencies = [ "rayon", ] -[[package]] -name = "filetime" -version = "0.2.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" -dependencies = [ - "cfg-if", - "libc", -] - [[package]] name = "find-msvc-tools" version = "0.1.9" @@ -1396,9 +1127,9 @@ dependencies = [ [[package]] name = "flutter_rust_bridge" -version = "2.12.0" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0884853aae8a6517b5b58cf36f55da487f2fe110e1686938eb29b6640aae4a5" +checksum = "24a973d15b8fc7de9fb29cdfbec58a2ac41f6252492d3b882abfdc603e32b34f" dependencies = [ "allo-isolate", "android_logger", @@ -1423,56 +1154,11 @@ dependencies = [ "web-sys", ] -[[package]] -name = "flutter_rust_bridge_codegen" -version = "2.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13823e8157bada9dc828d67cd23e4bcebcfffa9313175dacad0325fc3188940c" -dependencies = [ - "anyhow", - "cargo_metadata", - "cargo_toml", - "cbindgen", - "chrono", - "clap", - "convert_case 0.5.0", - "derivative", - "enum-iterator", - "enum_dispatch", - "fern 0.6.2", - "glob", - "hex", - "include_dir", - "indicatif", - "indicatif-log-bridge", - "itertools 0.10.5", - "lazy_static", - "log", - "notify", - "notify-debouncer-mini", - "paste", - "pathdiff", - "proc-macro2", - "quote", - "regex", - "serde", - "serde_json", - "serde_yaml", - "serial_test", - "sha1 0.10.7", - "strum 0.26.3", - "strum_macros 0.26.4", - "syn 2.0.119", - "tempfile", - "toml 0.5.11", - "topological-sort", -] - [[package]] name = "flutter_rust_bridge_macros" -version = "2.12.0" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b5ce32f35f710ced8c5aa557f023f1a624e737b5460cee2b70fcd3a8df09e1b" +checksum = "901eec2d226107dad1c55b30f7421c4687bebcf70ed43ca44d1b447ca087b238" dependencies = [ "hex", "md-5", @@ -1518,15 +1204,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fsevent-sys" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2" -dependencies = [ - "libc", -] - [[package]] name = "funty" version = "2.0.0" @@ -1694,12 +1371,6 @@ version = "0.32.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7" -[[package]] -name = "glob" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" - [[package]] name = "group" version = "0.14.0" @@ -1764,12 +1435,6 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" -[[package]] -name = "heck" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" - [[package]] name = "heck" version = "0.5.0" @@ -2030,25 +1695,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "include_dir" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "923d117408f1e49d914f1a379a309cffe4f18c05cf4e3d12e613a15fc81bd0dd" -dependencies = [ - "include_dir_macros", -] - -[[package]] -name = "include_dir_macros" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cab85a7ed0bd5f0e76d93846e0147172bed2e2d3f859bcc33a8d9699cad1a75" -dependencies = [ - "proc-macro2", - "quote", -] - [[package]] name = "indexmap" version = "2.14.0" @@ -2061,49 +1707,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "indicatif" -version = "0.18.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9433806cd6b4ec1aba79c021c7e4c58fb4c3b9977c085062e611ac929998fb0c" -dependencies = [ - "console", - "portable-atomic", - "unicode-width", - "unit-prefix", - "web-time", -] - -[[package]] -name = "indicatif-log-bridge" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63703cf9069b85dbe6fe26e1c5230d013dee99d3559cd3d02ba39e099ef7ab02" -dependencies = [ - "indicatif", - "log", -] - -[[package]] -name = "inotify" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff" -dependencies = [ - "bitflags 1.3.2", - "inotify-sys", - "libc", -] - -[[package]] -name = "inotify-sys" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c033f80b2c113cdf91ab7a33faa9cbc014726dcad99880c8609af2a370edf37d" -dependencies = [ - "libc", -] - [[package]] name = "inout" version = "0.1.4" @@ -2137,32 +1740,6 @@ version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" -[[package]] -name = "is-terminal" -version = "0.4.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys 0.61.2", -] - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" - -[[package]] -name = "itertools" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" -dependencies = [ - "either", -] - [[package]] name = "itertools" version = "0.14.0" @@ -2233,26 +1810,6 @@ version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" -[[package]] -name = "kqueue" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "273c0752728918e0ac4976f2b275b6fefb9ecd400585dec929419f3844cd87b5" -dependencies = [ - "kqueue-sys", - "libc", -] - -[[package]] -name = "kqueue-sys" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07293a4e297ac234359b510362495713f75ea345d5307140414f20c69ffeb087" -dependencies = [ - "bitflags 2.13.1", - "libc", -] - [[package]] name = "language-tags" version = "0.3.2" @@ -2281,12 +1838,6 @@ dependencies = [ "serde", ] -[[package]] -name = "linux-raw-sys" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" - [[package]] name = "litemap" version = "0.8.2" @@ -2416,18 +1967,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "mio" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" -dependencies = [ - "libc", - "log", - "wasi", - "windows-sys 0.48.0", -] - [[package]] name = "mio" version = "1.2.2" @@ -2440,36 +1979,6 @@ dependencies = [ "windows-sys 0.61.2", ] -[[package]] -name = "notify" -version = "6.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d" -dependencies = [ - "bitflags 2.13.1", - "crossbeam-channel", - "filetime", - "fsevent-sys", - "inotify", - "kqueue", - "libc", - "log", - "mio 0.8.11", - "walkdir", - "windows-sys 0.48.0", -] - -[[package]] -name = "notify-debouncer-mini" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d40b221972a1fc5ef4d858a2f671fb34c75983eb385463dff3780eeff6a9d43" -dependencies = [ - "crossbeam-channel", - "log", - "notify", -] - [[package]] name = "num-conv" version = "0.2.2" @@ -2519,12 +2028,6 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" -[[package]] -name = "once_cell_polyfill" -version = "1.70.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" - [[package]] name = "oslog" version = "0.2.0" @@ -2629,12 +2132,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" -[[package]] -name = "pathdiff" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" - [[package]] name = "percent-encoding" version = "2.3.2" @@ -2728,7 +2225,7 @@ version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" dependencies = [ - "toml_edit 0.25.13+spec-1.1.0", + "toml_edit", ] [[package]] @@ -3025,19 +2522,6 @@ dependencies = [ "semver", ] -[[package]] -name = "rustix" -version = "1.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" -dependencies = [ - "bitflags 2.13.1", - "errno", - "libc", - "linux-raw-sys", - "windows-sys 0.61.2", -] - [[package]] name = "rustls" version = "0.23.42" @@ -3084,15 +2568,6 @@ version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" -[[package]] -name = "same-file" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" -dependencies = [ - "winapi-util", -] - [[package]] name = "schemars" version = "1.2.2" @@ -3130,10 +2605,6 @@ name = "semver" version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" -dependencies = [ - "serde", - "serde_core", -] [[package]] name = "serde" @@ -3199,15 +2670,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_spanned" -version = "0.6.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" -dependencies = [ - "serde", -] - [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -3220,44 +2682,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_yaml" -version = "0.9.34+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" -dependencies = [ - "indexmap", - "itoa", - "ryu", - "serde", - "unsafe-libyaml", -] - -[[package]] -name = "serial_test" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e56dd856803e253c8f298af3f4d7eb0ae5e23a737252cd90bb4f3b435033b2d" -dependencies = [ - "dashmap", - "futures", - "lazy_static", - "log", - "parking_lot 0.12.5", - "serial_test_derive", -] - -[[package]] -name = "serial_test_derive" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91d129178576168c589c9ec973feedf7d3126c01ac2bf08795109aa35b69fb8f" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.119", -] - [[package]] name = "sha1" version = "0.10.7" @@ -3396,38 +2820,13 @@ dependencies = [ "zeroize", ] -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "strum" -version = "0.26.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" - [[package]] name = "strum" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" dependencies = [ - "strum_macros 0.27.2", -] - -[[package]] -name = "strum_macros" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" -dependencies = [ - "heck 0.5.0", - "proc-macro2", - "quote", - "rustversion", - "syn 2.0.119", + "strum_macros", ] [[package]] @@ -3436,7 +2835,7 @@ version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7695ce3845ea4b33927c055a39dc438a45b059f7c1b3d91d38d10355fb8cbca7" dependencies = [ - "heck 0.5.0", + "heck", "proc-macro2", "quote", "syn 2.0.119", @@ -3448,17 +2847,6 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.119" @@ -3525,19 +2913,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" -[[package]] -name = "tempfile" -version = "3.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" -dependencies = [ - "fastrand", - "getrandom 0.4.3", - "once_cell", - "rustix", - "windows-sys 0.61.2", -] - [[package]] name = "termcolor" version = "1.4.1" @@ -3655,7 +3030,7 @@ checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed" dependencies = [ "bytes", "libc", - "mio 1.2.2", + "mio", "parking_lot 0.12.5", "pin-project-lite", "signal-hook-registry", @@ -3759,36 +3134,6 @@ dependencies = [ "syn 2.0.119", ] -[[package]] -name = "toml" -version = "0.5.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" -dependencies = [ - "serde", -] - -[[package]] -name = "toml" -version = "0.8.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" -dependencies = [ - "serde", - "serde_spanned", - "toml_datetime 0.6.11", - "toml_edit 0.22.27", -] - -[[package]] -name = "toml_datetime" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" -dependencies = [ - "serde", -] - [[package]] name = "toml_datetime" version = "1.1.1+spec-1.1.0" @@ -3798,20 +3143,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "toml_edit" -version = "0.22.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" -dependencies = [ - "indexmap", - "serde", - "serde_spanned", - "toml_datetime 0.6.11", - "toml_write", - "winnow 0.7.15", -] - [[package]] name = "toml_edit" version = "0.25.13+spec-1.1.0" @@ -3819,9 +3150,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b" dependencies = [ "indexmap", - "toml_datetime 1.1.1+spec-1.1.0", + "toml_datetime", "toml_parser", - "winnow 1.0.4", + "winnow", ] [[package]] @@ -3830,21 +3161,9 @@ version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" dependencies = [ - "winnow 1.0.4", + "winnow", ] -[[package]] -name = "toml_write" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" - -[[package]] -name = "topological-sort" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d" - [[package]] name = "tower-service" version = "0.3.3" @@ -3947,24 +3266,12 @@ version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" -[[package]] -name = "unicode-width" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" - [[package]] name = "unicode-xid" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" -[[package]] -name = "unit-prefix" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81e544489bf3d8ef66c953931f56617f423cd4b5494be343d9b9d3dda037b9a3" - [[package]] name = "universal-hash" version = "0.6.1" @@ -3975,12 +3282,6 @@ dependencies = [ "ctutils", ] -[[package]] -name = "unsafe-libyaml" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" - [[package]] name = "untrusted" version = "0.9.0" @@ -4011,28 +3312,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" -[[package]] -name = "utf8parse" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" - [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "walkdir" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" -dependencies = [ - "same-file", - "winapi-util", -] - [[package]] name = "want" version = "0.3.1" @@ -4406,15 +3691,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.7.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" -dependencies = [ - "memchr", -] - [[package]] name = "winnow" version = "1.0.4" @@ -4529,7 +3805,7 @@ dependencies = [ "anyhow", "hex", "indexmap", - "itertools 0.14.0", + "itertools", "lazy_static", "schemars", "serde", @@ -4569,7 +3845,7 @@ dependencies = [ "chacha20 0.9.1", "chacha20poly1305", "curve25519-dalek", - "fern 0.7.1", + "fern", "futures", "futures-util", "getrandom 0.2.17", @@ -4593,7 +3869,7 @@ dependencies = [ "serde_json", "serde_regex", "sha3", - "strum 0.27.2", + "strum", "thiserror 2.0.19", "tokio", "tokio-tungstenite-wasm", @@ -4615,7 +3891,6 @@ dependencies = [ "anyhow", "bytemuck_derive", "flutter_rust_bridge", - "flutter_rust_bridge_codegen", "indexmap", "lazy_static", "log", @@ -4651,7 +3926,7 @@ dependencies = [ "futures", "hex", "indexmap", - "itertools 0.14.0", + "itertools", "linked-hash-table", "log", "lru 0.16.4", @@ -4659,7 +3934,7 @@ dependencies = [ "serde", "serde_json", "sled", - "strum 0.27.2", + "strum", "thiserror 2.0.19", "tokio-tungstenite-wasm", "wasm-bindgen-futures", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 22a6767..712b904 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -4,10 +4,11 @@ version = "0.1.0" edition = "2021" [lib] +name = "xelis_flutter" crate-type = ["lib", "cdylib", "staticlib"] [dependencies] -flutter_rust_bridge = { version = "=2.12.0", features = ["log"] } +flutter_rust_bridge = { version = "=2.13.0", features = ["log"] } anyhow = "1" log = { version = "0.4", features = ["release_max_level_trace"] } parking_lot = "0.12.1" @@ -22,10 +23,6 @@ bytemuck_derive = "=1.8.1" lru = "0.12" indexmap = { version = "2.0.0", features = ["serde"] } -[build-dependencies] -flutter_rust_bridge_codegen = "2.12.0" -anyhow = "1" - [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen = "0.2.92" @@ -35,4 +32,8 @@ rustls = { version = "0.23.29", features = ["ring"], default-features = false } [features] default = ["xelis_wallet/api_server", "log/release_max_level_trace"] -network_handler = ["xelis_wallet/network_handler"] \ No newline at end of file +network_handler = ["xelis_wallet/network_handler"] + +[lints.rust] +# `frb_expand` is a cfg set by flutter_rust_bridge_codegen while it parses the crate. +unexpected_cfgs = { level = "warn", check-cfg = ["cfg(frb_expand)"] } diff --git a/rust/rust-toolchain.toml b/rust/rust-toolchain.toml index d0741b5..ca2a580 100644 --- a/rust/rust-toolchain.toml +++ b/rust/rust-toolchain.toml @@ -1,3 +1,27 @@ [toolchain] -channel = "1.91.0" -components = ["rustfmt", "clippy"] \ No newline at end of file +# native_toolchain_rust requires an exact version (no floating `stable`/`beta`/`nightly`) +# so that consumers get reproducible builds. rustup installs this toolchain and every +# target listed below automatically the first time the crate is built. +channel = "1.91.0" +# Consumers only need rustc, cargo and the std targets below; rustfmt/clippy/docs +# are not installed (maintainers: `rustup component add rustfmt clippy`). +profile = "minimal" +targets = [ + # Android + "aarch64-linux-android", + "armv7-linux-androideabi", + "x86_64-linux-android", + # iOS (device + simulator) + "aarch64-apple-ios", + "aarch64-apple-ios-sim", + "x86_64-apple-ios", + # macOS + "aarch64-apple-darwin", + "x86_64-apple-darwin", + # Linux + "x86_64-unknown-linux-gnu", + "aarch64-unknown-linux-gnu", + # Windows + "x86_64-pc-windows-msvc", + "aarch64-pc-windows-msvc", +] diff --git a/rust/src/frb_generated.rs b/rust/src/frb_generated.rs index 8bcbac1..f46a2df 100644 --- a/rust/src/frb_generated.rs +++ b/rust/src/frb_generated.rs @@ -1,5 +1,5 @@ // This file is automatically generated, so please do not edit it. -// @generated by `flutter_rust_bridge`@ 2.12.0. +// @generated by `flutter_rust_bridge`@ 2.13.0. #![allow( non_camel_case_types, @@ -21,7 +21,8 @@ clippy::explicit_auto_deref, clippy::borrow_deref_ref, clippy::uninlined_format_args, - clippy::needless_borrow + clippy::needless_borrow, + mismatched_lifetime_syntaxes )] // Section: imports @@ -44,7 +45,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_opaque = RustOpaqueNom, default_rust_auto_opaque = RustAutoOpaqueNom, ); -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.12.0"; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.13.0"; pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -747425718; // Section: executor @@ -81,8 +82,8 @@ fn wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_get_ad } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok(api_that_guard.address.clone())?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(api_that_guard.address.clone())?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -115,8 +116,8 @@ fn wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_get_da } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok(api_that_guard.data.clone())?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(api_that_guard.data.clone())?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -151,12 +152,12 @@ fn wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_set_ad } } let mut api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ { api_that_guard.address = api_address; }; })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -191,12 +192,12 @@ fn wire__crate__api__models__wallet_dtos__IntegratedAddress_auto_accessor_set_da } } let mut api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ { api_that_guard.data = api_data; }; })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -236,7 +237,7 @@ fn wire__crate__api__seed_search_engine__SearchEngine_check_seed_impl( &*api_that_guard, api_seed, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) }, @@ -254,10 +255,10 @@ fn wire__crate__api__seed_search_engine__SearchEngine_init_impl( move || { let api_language_index = language_index.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( - crate::api::seed_search_engine::SearchEngine::init(api_language_index), - )?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(crate::api::seed_search_engine::SearchEngine::init( + api_language_index, + ))?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -297,7 +298,7 @@ fn wire__crate__api__seed_search_engine__SearchEngine_search_impl( &*api_that_guard, api_query, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) }, @@ -331,8 +332,8 @@ fn wire__crate__api__logger__SendToDartLogger_auto_accessor_get_level_impl( } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok(api_that_guard.level.clone())?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(api_that_guard.level.clone())?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -367,12 +368,12 @@ fn wire__crate__api__logger__SendToDartLogger_auto_accessor_set_level_impl( } } let mut api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ { api_that_guard.level = api_level; }; })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -393,10 +394,10 @@ fn wire__crate__api__logger__SendToDartLogger_set_stream_sink_impl( let api_stream_sink = stream_sink.cst_decode(); move |context| { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::logger::SendToDartLogger::set_stream_sink(api_stream_sink); })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) } }, @@ -430,8 +431,8 @@ fn wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_get_f } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok(api_that_guard.fee.clone())?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(api_that_guard.fee.clone())?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -464,8 +465,8 @@ fn wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_get_h } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok(api_that_guard.hash.clone())?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(api_that_guard.hash.clone())?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -498,8 +499,8 @@ fn wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_get_t } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok(api_that_guard.transaction_type.clone())?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(api_that_guard.transaction_type.clone())?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -534,12 +535,12 @@ fn wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_set_f } } let mut api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ { api_that_guard.fee = api_fee; }; })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -574,12 +575,12 @@ fn wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_set_h } } let mut api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ { api_that_guard.hash = api_hash; }; })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -614,12 +615,12 @@ fn wire__crate__api__models__wallet_dtos__SummaryTransaction_auto_accessor_set_t } } let mut api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ { api_that_guard.transaction_type = api_transaction_type; }; })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -660,7 +661,7 @@ fn wire__crate__api__wallet__XelisWallet_all_history_impl( let api_that_guard = api_that_guard.unwrap(); let output_ok = crate::api::wallet::XelisWallet::all_history(&*api_that_guard).await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -709,7 +710,7 @@ fn wire__crate__api__wallet__XelisWallet_broadcast_transaction_impl( api_tx_hash, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -761,7 +762,7 @@ fn wire__crate__api__wallet__XelisWallet_change_password_impl( api_new_password, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -804,7 +805,7 @@ fn wire__crate__api__wallet__XelisWallet_clear_transaction_impl( &*api_that_guard, api_tx_hash, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) }, @@ -844,10 +845,10 @@ fn wire__crate__api__wallet__XelisWallet_close_impl( } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::wallet::XelisWallet::close(&*api_that_guard).await; })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -896,7 +897,7 @@ fn wire__crate__api__wallet__XelisWallet_close_application_session_impl( &api_id, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -943,7 +944,7 @@ fn wire__crate__api__wallet__XelisWallet_convert_transactions_to_csv_impl( &*api_that_guard, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -993,7 +994,7 @@ fn wire__crate__api__wallet__XelisWallet_create_burn_all_transaction_impl( api_asset_hash, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1045,7 +1046,7 @@ fn wire__crate__api__wallet__XelisWallet_create_burn_transaction_impl( api_asset_hash, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1095,7 +1096,7 @@ fn wire__crate__api__wallet__XelisWallet_create_multisig_burn_all_transaction_im api_asset_hash, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1148,7 +1149,7 @@ fn wire__crate__api__wallet__XelisWallet_create_multisig_burn_transaction_impl( api_asset_hash, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1166,7 +1167,7 @@ fn wire__crate__api__wallet__XelisWallet_create_multisig_transfer_all_transactio extra_data: impl CstDecode>, encrypt_extra_data: impl CstDecode>, ) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::(flutter_rust_bridge::for_generated::TaskInfo{ debug_name: "XelisWallet_create_multisig_transfer_all_transaction", port: Some(port_), mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal }, move || { let api_that = that.cst_decode();let api_str_address = str_address.cst_decode();let api_asset_hash = asset_hash.cst_decode();let api_extra_data = extra_data.cst_decode();let api_encrypt_extra_data = encrypt_extra_data.cst_decode(); move |context| async move { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::(flutter_rust_bridge::for_generated::TaskInfo{ debug_name: "XelisWallet_create_multisig_transfer_all_transaction", port: Some(port_), mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal }, move || {let api_that = that.cst_decode();let api_str_address = str_address.cst_decode();let api_asset_hash = asset_hash.cst_decode();let api_extra_data = extra_data.cst_decode();let api_encrypt_extra_data = encrypt_extra_data.cst_decode(); move |context| async move { transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>((move || async move { let mut api_that_guard = None; let decode_indices_ = flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new(&api_that, 0, false)]); @@ -1177,7 +1178,7 @@ let decode_indices_ = flutter_rust_bridge::for_generated::lockable_compute_decod } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = crate::api::wallet::XelisWallet::create_multisig_transfer_all_transaction(&*api_that_guard, api_str_address, api_asset_hash, api_extra_data, api_encrypt_extra_data).await?; Ok(output_ok) + let output_ok = crate::api::wallet::XelisWallet::create_multisig_transfer_all_transaction(&*api_that_guard, api_str_address, api_asset_hash, api_extra_data, api_encrypt_extra_data).await?; std::result::Result::Ok(output_ok) })().await) } }) } @@ -1223,7 +1224,7 @@ fn wire__crate__api__wallet__XelisWallet_create_multisig_transfers_transaction_i api_transfers, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1282,7 +1283,7 @@ fn wire__crate__api__wallet__XelisWallet_create_transfer_all_transaction_impl( api_encrypt_extra_data, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1332,7 +1333,7 @@ fn wire__crate__api__wallet__XelisWallet_create_transfers_transaction_impl( api_transfers, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1381,7 +1382,7 @@ fn wire__crate__api__wallet__XelisWallet_estimate_fees_impl( api_transfers, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1425,14 +1426,14 @@ fn wire__crate__api__wallet__XelisWallet_events_stream_impl( } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::wallet::XelisWallet::events_stream( &*api_that_guard, api_sink, ) .await; })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1482,7 +1483,7 @@ fn wire__crate__api__wallet__XelisWallet_export_transactions_to_csv_file_impl( api_file_path, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1532,7 +1533,7 @@ fn wire__crate__api__wallet__XelisWallet_finalize_multisig_transaction_impl( api_signatures, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1584,7 +1585,7 @@ fn wire__crate__api__wallet__XelisWallet_format_coin_impl( api_asset_hash, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1620,10 +1621,10 @@ fn wire__crate__api__wallet__XelisWallet_get_address_str_impl( } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok( - crate::api::wallet::XelisWallet::get_address_str(&*api_that_guard), - )?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(crate::api::wallet::XelisWallet::get_address_str( + &*api_that_guard, + ))?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -1665,7 +1666,7 @@ fn wire__crate__api__wallet__XelisWallet_get_all_assets_impl( let output_ok = crate::api::wallet::XelisWallet::get_all_assets(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1712,7 +1713,7 @@ fn wire__crate__api__wallet__XelisWallet_get_application_permissions_impl( &*api_that_guard, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1761,7 +1762,7 @@ fn wire__crate__api__wallet__XelisWallet_get_asset_balance_by_id_impl( api_asset, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1811,7 +1812,7 @@ fn wire__crate__api__wallet__XelisWallet_get_asset_balance_by_id_raw_impl( api_asset, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1856,7 +1857,7 @@ fn wire__crate__api__wallet__XelisWallet_get_asset_balances_impl( let output_ok = crate::api::wallet::XelisWallet::get_asset_balances(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1905,7 +1906,7 @@ fn wire__crate__api__wallet__XelisWallet_get_asset_decimals_impl( api_asset, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -1954,7 +1955,7 @@ fn wire__crate__api__wallet__XelisWallet_get_asset_metadata_impl( api_asset, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2003,7 +2004,7 @@ fn wire__crate__api__wallet__XelisWallet_get_asset_ticker_impl( api_asset, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2048,7 +2049,7 @@ fn wire__crate__api__wallet__XelisWallet_get_daemon_info_impl( let output_ok = crate::api::wallet::XelisWallet::get_daemon_info(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2093,7 +2094,7 @@ fn wire__crate__api__wallet__XelisWallet_get_history_count_impl( let output_ok = crate::api::wallet::XelisWallet::get_history_count(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2138,7 +2139,7 @@ fn wire__crate__api__wallet__XelisWallet_get_known_assets_impl( let output_ok = crate::api::wallet::XelisWallet::get_known_assets(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2183,7 +2184,7 @@ fn wire__crate__api__wallet__XelisWallet_get_multisig_state_impl( let output_ok = crate::api::wallet::XelisWallet::get_multisig_state(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2219,10 +2220,10 @@ fn wire__crate__api__wallet__XelisWallet_get_network_impl( } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok(crate::api::wallet::XelisWallet::get_network( + let output_ok = Ok::<_, ()>(crate::api::wallet::XelisWallet::get_network( &*api_that_guard, ))?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -2261,10 +2262,10 @@ fn wire__crate__api__wallet__XelisWallet_get_nonce_impl( } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::wallet::XelisWallet::get_nonce(&*api_that_guard).await, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2313,7 +2314,7 @@ fn wire__crate__api__wallet__XelisWallet_get_seed_impl( api_language_index, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2360,7 +2361,7 @@ fn wire__crate__api__wallet__XelisWallet_get_tracked_asset_balances_raw_impl( &*api_that_guard, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2405,7 +2406,7 @@ fn wire__crate__api__wallet__XelisWallet_get_tracked_balances_impl( let output_ok = crate::api::wallet::XelisWallet::get_tracked_balances(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2450,7 +2451,7 @@ fn wire__crate__api__wallet__XelisWallet_get_xelis_balance_impl( let output_ok = crate::api::wallet::XelisWallet::get_xelis_balance(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2496,7 +2497,7 @@ fn wire__crate__api__wallet__XelisWallet_get_xelis_balance_raw_impl( &*api_that_guard, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2545,7 +2546,7 @@ fn wire__crate__api__wallet__XelisWallet_has_asset_balance_impl( api_asset, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2590,7 +2591,7 @@ fn wire__crate__api__wallet__XelisWallet_has_xelis_balance_impl( let output_ok = crate::api::wallet::XelisWallet::has_xelis_balance(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2637,7 +2638,7 @@ fn wire__crate__api__wallet__XelisWallet_history_impl( let output_ok = crate::api::wallet::XelisWallet::history(&*api_that_guard, api_filter) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2682,7 +2683,7 @@ fn wire__crate__api__wallet__XelisWallet_init_delete_multisig_impl( let output_ok = crate::api::wallet::XelisWallet::init_delete_multisig(&*api_that_guard) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2725,7 +2726,7 @@ fn wire__crate__api__wallet__XelisWallet_is_address_valid_for_multisig_impl( &*api_that_guard, api_address, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) }, @@ -2772,7 +2773,7 @@ fn wire__crate__api__wallet__XelisWallet_is_asset_tracked_impl( api_asset, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2814,10 +2815,10 @@ fn wire__crate__api__wallet__XelisWallet_is_online_impl( } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::wallet::XelisWallet::is_online(&*api_that_guard).await, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2866,7 +2867,7 @@ fn wire__crate__api__wallet__XelisWallet_is_valid_password_impl( api_password, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2908,11 +2909,11 @@ fn wire__crate__api__wallet__XelisWallet_is_xswd_running_impl( } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::wallet::XelisWallet::is_xswd_running(&*api_that_guard) .await, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -2967,7 +2968,7 @@ fn wire__crate__api__wallet__XelisWallet_modify_application_permissions_impl( api_permissions, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3019,7 +3020,7 @@ fn wire__crate__api__wallet__XelisWallet_multisig_setup_impl( api_participants, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3062,7 +3063,7 @@ fn wire__crate__api__wallet__XelisWallet_multisig_sign_impl( &*api_that_guard, api_tx_hash, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) }, @@ -3104,7 +3105,7 @@ fn wire__crate__api__wallet__XelisWallet_offline_mode_impl( let api_that_guard = api_that_guard.unwrap(); let output_ok = crate::api::wallet::XelisWallet::offline_mode(&*api_that_guard).await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3153,7 +3154,7 @@ fn wire__crate__api__wallet__XelisWallet_online_mode_impl( api_daemon_address, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3202,7 +3203,7 @@ fn wire__crate__api__wallet__XelisWallet_rescan_impl( api_topoheight, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3221,7 +3222,7 @@ fn wire__crate__api__wallet__XelisWallet_start_xswd_impl( request_prefetch_permissions_dart_callback: impl CstDecode, app_disconnect_dart_callback: impl CstDecode, ) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::(flutter_rust_bridge::for_generated::TaskInfo{ debug_name: "XelisWallet_start_xswd", port: Some(port_), mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal }, move || { let api_that = that.cst_decode();let api_cancel_request_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_unit_AnyhowException(cancel_request_dart_callback.cst_decode());let api_request_application_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_application_dart_callback.cst_decode());let api_request_permission_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_permission_dart_callback.cst_decode());let api_request_prefetch_permissions_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_prefetch_permissions_dart_callback.cst_decode());let api_app_disconnect_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_unit_AnyhowException(app_disconnect_dart_callback.cst_decode()); move |context| async move { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::(flutter_rust_bridge::for_generated::TaskInfo{ debug_name: "XelisWallet_start_xswd", port: Some(port_), mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal }, move || {let api_that = that.cst_decode();let api_cancel_request_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_unit_AnyhowException(cancel_request_dart_callback.cst_decode());let api_request_application_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_application_dart_callback.cst_decode());let api_request_permission_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_permission_dart_callback.cst_decode());let api_request_prefetch_permissions_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_prefetch_permissions_dart_callback.cst_decode());let api_app_disconnect_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_unit_AnyhowException(app_disconnect_dart_callback.cst_decode()); move |context| async move { transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>((move || async move { let mut api_that_guard = None; let decode_indices_ = flutter_rust_bridge::for_generated::lockable_compute_decode_order(vec![flutter_rust_bridge::for_generated::LockableOrderInfo::new(&api_that, 0, false)]); @@ -3232,7 +3233,7 @@ let decode_indices_ = flutter_rust_bridge::for_generated::lockable_compute_decod } } let api_that_guard = api_that_guard.unwrap(); - let output_ok = crate::api::wallet::XelisWallet::start_xswd(&*api_that_guard, api_cancel_request_dart_callback, api_request_application_dart_callback, api_request_permission_dart_callback, api_request_prefetch_permissions_dart_callback, api_app_disconnect_dart_callback).await?; Ok(output_ok) + let output_ok = crate::api::wallet::XelisWallet::start_xswd(&*api_that_guard, api_cancel_request_dart_callback, api_request_application_dart_callback, api_request_permission_dart_callback, api_request_prefetch_permissions_dart_callback, api_app_disconnect_dart_callback).await?; std::result::Result::Ok(output_ok) })().await) } }) } @@ -3272,7 +3273,7 @@ fn wire__crate__api__wallet__XelisWallet_stop_xswd_impl( let api_that_guard = api_that_guard.unwrap(); let output_ok = crate::api::wallet::XelisWallet::stop_xswd(&*api_that_guard).await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3321,7 +3322,7 @@ fn wire__crate__api__wallet__XelisWallet_track_asset_impl( api_asset, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3370,7 +3371,7 @@ fn wire__crate__api__wallet__XelisWallet_untrack_asset_impl( api_asset, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3392,10 +3393,10 @@ fn wire__crate__api__progress_report__add_progress_report_impl( let api_report = report.cst_decode(); move |context| { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::progress_report::add_progress_report(api_report); })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) } }, @@ -3415,12 +3416,12 @@ fn wire__crate__api__models__address_book_dtos__address_book_data_get_all_entrie let api_that = that.cst_decode(); move |context| { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::models::address_book_dtos::AddressBookData::get_all_entries( &api_that, ), )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) } }, @@ -3443,14 +3444,14 @@ fn wire__crate__api__precomputed_tables__are_precomputed_tables_available_impl( move |context| async move { transform_result_dco::<_, _, ()>( (move || async move { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::precomputed_tables::are_precomputed_tables_available( api_precomputed_tables_path, api_precomputed_table_type, ) .await, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3468,10 +3469,10 @@ fn wire__crate__api__wallet__clear_cached_tables_impl( }, move || { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::wallet::clear_cached_tables(); })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -3510,10 +3511,10 @@ fn wire__crate__api__xswd__imp__create_app_info_impl( } } let api_state_guard = api_state_guard.unwrap(); - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::xswd::imp::create_app_info(&*api_state_guard).await, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3539,7 +3540,7 @@ fn wire__crate__api__api__create_log_stream_impl( transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( (move || { let output_ok = crate::api::api::create_log_stream(api_s)?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) } @@ -3568,7 +3569,7 @@ fn wire__crate__api__api__create_progress_report_stream_impl( (move || { let output_ok = crate::api::api::create_progress_report_stream(api_stream_sink)?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) } @@ -3615,7 +3616,7 @@ fn wire__crate__api__wallet__create_xelis_wallet_impl( api_precomputed_table_type, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3635,10 +3636,10 @@ fn wire__crate__api__wallet__drop_wallet_impl( move || { let api_wallet = wallet.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::wallet::drop_wallet(api_wallet); })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -3659,11 +3660,9 @@ fn wire__crate__api__utils__format_coin_impl( let api_decimals = decimals.cst_decode(); move |context| { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok(crate::api::utils::format_coin( - api_value, - api_decimals, - ))?; - Ok(output_ok) + let output_ok = + Ok::<_, ()>(crate::api::utils::format_coin(api_value, api_decimals))?; + std::result::Result::Ok(output_ok) })()) } }, @@ -3683,9 +3682,8 @@ fn wire__crate__api__utils__format_xelis_impl( let api_value = value.cst_decode(); move |context| { transform_result_dco::<_, _, ()>((move || { - let output_ok = - Result::<_, ()>::Ok(crate::api::utils::format_xelis(api_value))?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(crate::api::utils::format_xelis(api_value))?; + std::result::Result::Ok(output_ok) })()) } }, @@ -3701,8 +3699,8 @@ fn wire__crate__api__wallet__get_cached_table_impl( }, move || { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok(crate::api::wallet::get_cached_table())?; - Ok(output_ok) + let output_ok = Ok::<_, ()>(crate::api::wallet::get_cached_table())?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -3721,7 +3719,7 @@ fn wire__crate__api__wallet__get_current_precomputed_tables_type_impl( transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( (move || { let output_ok = crate::api::wallet::get_current_precomputed_tables_type()?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) } @@ -3740,10 +3738,9 @@ fn wire__crate__api__utils__get_language_index_from_str_impl( move || { let api_input = input.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( - crate::api::utils::get_language_index_from_str(&api_input), - )?; - Ok(output_ok) + let output_ok = + Ok::<_, ()>(crate::api::utils::get_language_index_from_str(&api_input))?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -3761,8 +3758,8 @@ fn wire__crate__api__utils__get_mnemonic_words_impl( let api_language_index = language_index.cst_decode(); transform_result_dco::<_, _, ()>((move || { let output_ok = - Result::<_, ()>::Ok(crate::api::utils::get_mnemonic_words(api_language_index))?; - Ok(output_ok) + Ok::<_, ()>(crate::api::utils::get_mnemonic_words(api_language_index))?; + std::result::Result::Ok(output_ok) })()) }, ) @@ -3779,10 +3776,10 @@ fn wire__crate__api__logger__init_logger_impl( move || { move |context| { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::logger::init_logger(); })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) } }, @@ -3802,7 +3799,7 @@ fn wire__crate__api__api__initialize_crypto_provider_impl( transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( (move || { let output_ok = crate::api::api::initialize_crypto_provider()?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) } @@ -3823,7 +3820,7 @@ fn wire__crate__api__api__initialize_xelis_config_impl( transform_result_dco::<_, _, flutter_rust_bridge::for_generated::anyhow::Error>( (move || { let output_ok = crate::api::api::initialize_xelis_config()?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) } @@ -3844,11 +3841,11 @@ fn wire__crate__api__utils__is_address_valid_impl( let api_str_address = str_address.cst_decode(); let api_network = network.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok(crate::api::utils::is_address_valid( + let output_ok = Ok::<_, ()>(crate::api::utils::is_address_valid( api_str_address, api_network, ))?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -3887,7 +3884,7 @@ fn wire__crate__api__wallet__open_xelis_wallet_impl( api_precomputed_table_type, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -3909,10 +3906,10 @@ fn wire__crate__api__precomputed_tables__precomputed_table_type_index_impl( let api_that = that.cst_decode(); move |context| { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::precomputed_tables::PrecomputedTableType::index(&api_that), )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) } }, @@ -3932,10 +3929,10 @@ fn wire__crate__api__precomputed_tables__precomputed_table_type_name_impl( let api_that = that.cst_decode(); move |context| { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::precomputed_tables::PrecomputedTableType::name(&api_that), )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) } }, @@ -3960,7 +3957,7 @@ fn wire__crate__api__precomputed_tables__precomputed_table_type_to_l1_size_impl( crate::api::precomputed_tables::PrecomputedTableType::to_l1_size( &api_that, )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) } @@ -3977,10 +3974,10 @@ fn wire__crate__api__wallet__refresh_mt_params_impl( }, move || { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::wallet::refresh_mt_params(); })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -3999,10 +3996,10 @@ fn wire__crate__api__wallet__set_mt_params_impl( let api_thread_count = thread_count.cst_decode(); let api_concurrency = concurrency.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::wallet::set_mt_params(api_thread_count, api_concurrency); })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -4019,10 +4016,10 @@ fn wire__crate__api__api__set_up_rust_logger_impl( move || { move |context| { transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok({ + let output_ok = Ok::<_, ()>({ crate::api::api::set_up_rust_logger(); })?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) } }, @@ -4043,7 +4040,7 @@ fn wire__crate__api__utils__split_integrated_address_impl( (move || { let output_ok = crate::api::utils::split_integrated_address(api_integrated_address)?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })(), ) }, @@ -4071,7 +4068,7 @@ fn wire__crate__api__wallet__update_tables_impl( api_precomputed_table_type, ) .await?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })() .await, ) @@ -4088,9 +4085,9 @@ fn wire__crate__api__xswd__imp__xswd_handler_impl( request_prefetch_permissions_dart_callback: impl CstDecode, app_disconnect_dart_callback: impl CstDecode, ) { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::(flutter_rust_bridge::for_generated::TaskInfo{ debug_name: "xswd_handler", port: Some(port_), mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal }, move || { let api_receiver = receiver.cst_decode();let api_cancel_request_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_unit_AnyhowException(cancel_request_dart_callback.cst_decode());let api_request_application_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_application_dart_callback.cst_decode());let api_request_permission_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_permission_dart_callback.cst_decode());let api_request_prefetch_permissions_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_prefetch_permissions_dart_callback.cst_decode());let api_app_disconnect_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_unit_AnyhowException(app_disconnect_dart_callback.cst_decode()); move |context| async move { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::(flutter_rust_bridge::for_generated::TaskInfo{ debug_name: "xswd_handler", port: Some(port_), mode: flutter_rust_bridge::for_generated::FfiCallMode::Normal }, move || {let api_receiver = receiver.cst_decode();let api_cancel_request_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_unit_AnyhowException(cancel_request_dart_callback.cst_decode());let api_request_application_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_application_dart_callback.cst_decode());let api_request_permission_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_permission_dart_callback.cst_decode());let api_request_prefetch_permissions_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_user_permission_decision_AnyhowException(request_prefetch_permissions_dart_callback.cst_decode());let api_app_disconnect_dart_callback = decode_DartFn_Inputs_xswd_request_summary_Output_unit_AnyhowException(app_disconnect_dart_callback.cst_decode()); move |context| async move { transform_result_dco::<_, _, ()>((move || async move { - let output_ok = Result::<_,()>::Ok({ crate::api::xswd::imp::xswd_handler(api_receiver, api_cancel_request_dart_callback, api_request_application_dart_callback, api_request_permission_dart_callback, api_request_prefetch_permissions_dart_callback, api_app_disconnect_dart_callback).await; })?; Ok(output_ok) + let output_ok = Ok::<_, ()>({ crate::api::xswd::imp::xswd_handler(api_receiver, api_cancel_request_dart_callback, api_request_application_dart_callback, api_request_permission_dart_callback, api_request_prefetch_permissions_dart_callback, api_app_disconnect_dart_callback).await; })?; std::result::Result::Ok(output_ok) })().await) } }) } @@ -4106,10 +4103,10 @@ fn wire__crate__api__models__xswd_dtos__xswd_request_summary_is_app_disconnect_i move || { let api_that = that.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::models::xswd_dtos::XswdRequestSummary::is_app_disconnect(&api_that), )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -4126,12 +4123,12 @@ fn wire__crate__api__models__xswd_dtos__xswd_request_summary_is_application_requ move || { let api_that = that.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::models::xswd_dtos::XswdRequestSummary::is_application_request( &api_that, ), )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -4148,10 +4145,10 @@ fn wire__crate__api__models__xswd_dtos__xswd_request_summary_is_cancel_request_i move || { let api_that = that.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::models::xswd_dtos::XswdRequestSummary::is_cancel_request(&api_that), )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -4168,12 +4165,12 @@ fn wire__crate__api__models__xswd_dtos__xswd_request_summary_is_permission_reque move || { let api_that = that.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::models::xswd_dtos::XswdRequestSummary::is_permission_request( &api_that, ), )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -4181,9 +4178,9 @@ fn wire__crate__api__models__xswd_dtos__xswd_request_summary_is_permission_reque fn wire__crate__api__models__xswd_dtos__xswd_request_summary_is_prefetch_permissions_request_impl( that: impl CstDecode, ) -> flutter_rust_bridge::for_generated::WireSyncRust2DartDco { - FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::(flutter_rust_bridge::for_generated::TaskInfo{ debug_name: "xswd_request_summary_is_prefetch_permissions_request", port: None, mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync }, move || { let api_that = that.cst_decode(); + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::(flutter_rust_bridge::for_generated::TaskInfo{ debug_name: "xswd_request_summary_is_prefetch_permissions_request", port: None, mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync }, move || {let api_that = that.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_,()>::Ok(crate::api::models::xswd_dtos::XswdRequestSummary::is_prefetch_permissions_request(&api_that))?; Ok(output_ok) + let output_ok = Ok::<_, ()>(crate::api::models::xswd_dtos::XswdRequestSummary::is_prefetch_permissions_request(&api_that))?; std::result::Result::Ok(output_ok) })()) }) } fn wire__crate__api__models__xswd_dtos__xswd_request_summary_permission_json_impl( @@ -4198,10 +4195,10 @@ fn wire__crate__api__models__xswd_dtos__xswd_request_summary_permission_json_imp move || { let api_that = that.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::models::xswd_dtos::XswdRequestSummary::permission_json(&api_that), )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -4218,12 +4215,12 @@ fn wire__crate__api__models__xswd_dtos__xswd_request_summary_prefetch_permission move || { let api_that = that.cst_decode(); transform_result_dco::<_, _, ()>((move || { - let output_ok = Result::<_, ()>::Ok( + let output_ok = Ok::<_, ()>( crate::api::models::xswd_dtos::XswdRequestSummary::prefetch_permissions_json( &api_that, ), )?; - Ok(output_ok) + std::result::Result::Ok(output_ok) })()) }, ) @@ -7179,7 +7176,7 @@ impl SseEncode for crate::api::models::xswd_dtos::XswdRequestType { #[cfg(not(target_family = "wasm"))] mod io { // This file is automatically generated, so please do not edit it. - // @generated by `flutter_rust_bridge`@ 2.12.0. + // @generated by `flutter_rust_bridge`@ 2.13.0. // Section: imports @@ -10265,7 +10262,7 @@ pub use io::*; #[cfg(target_family = "wasm")] mod web { // This file is automatically generated, so please do not edit it. - // @generated by `flutter_rust_bridge`@ 2.12.0. + // @generated by `flutter_rust_bridge`@ 2.13.0. // Section: imports diff --git a/rust_builder/android/.gradle/8.9/checksums/checksums.lock b/rust_builder/android/.gradle/8.9/checksums/checksums.lock deleted file mode 100644 index a8c927fb3da847e583026e72c4e5dca790ec36dd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 TcmZR6#BLZrh56__1}FdkDxU*) diff --git a/rust_builder/android/.gradle/8.9/dependencies-accessors/gc.properties b/rust_builder/android/.gradle/8.9/dependencies-accessors/gc.properties deleted file mode 100644 index e69de29..0000000 diff --git a/rust_builder/android/.gradle/8.9/executionHistory/executionHistory.lock b/rust_builder/android/.gradle/8.9/executionHistory/executionHistory.lock deleted file mode 100644 index a60af63df4ffee8f85dcd0ecb421acad2902593b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 TcmZP$3YNY4)bFPl0~7!NFFpg^ diff --git a/rust_builder/android/.gradle/8.9/fileChanges/last-build.bin b/rust_builder/android/.gradle/8.9/fileChanges/last-build.bin deleted file mode 100644 index f76dd238ade08917e6712764a16a22005a50573d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1 IcmZPo000310RR91 diff --git a/rust_builder/android/.gradle/8.9/fileHashes/fileHashes.lock b/rust_builder/android/.gradle/8.9/fileHashes/fileHashes.lock deleted file mode 100644 index 75b521fb756a19a290d57c54aec72f9bad55df14..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 TcmZQBS}EbGX?kb@0~7!NCxZh# diff --git a/rust_builder/android/.gradle/8.9/gc.properties b/rust_builder/android/.gradle/8.9/gc.properties deleted file mode 100644 index e69de29..0000000 diff --git a/rust_builder/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/rust_builder/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock deleted file mode 100644 index 70236158345463ad2d3a9f8eef9b989605abcae2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17 UcmZQpj%Pl(YLoe61_)pT04yW}$p8QV diff --git a/rust_builder/android/.gradle/buildOutputCleanup/cache.properties b/rust_builder/android/.gradle/buildOutputCleanup/cache.properties deleted file mode 100644 index a1773f8..0000000 --- a/rust_builder/android/.gradle/buildOutputCleanup/cache.properties +++ /dev/null @@ -1,2 +0,0 @@ -#Sun Jan 26 09:15:50 PST 2025 -gradle.version=8.9 diff --git a/rust_builder/android/.gradle/vcs-1/gc.properties b/rust_builder/android/.gradle/vcs-1/gc.properties deleted file mode 100644 index e69de29..0000000 diff --git a/tool/analysis_options.yaml b/tool/analysis_options.yaml new file mode 100644 index 0000000..d3e9ba9 --- /dev/null +++ b/tool/analysis_options.yaml @@ -0,0 +1,3 @@ +# The tool is its own package; without this file the analyzer would inherit +# the parent package's analysis_options.yaml (which excludes tool/**). +include: package:lints/recommended.yaml diff --git a/tool/generate_bindings.dart b/tool/generate_bindings.dart index 450cc9b..cf98db4 100644 --- a/tool/generate_bindings.dart +++ b/tool/generate_bindings.dart @@ -1,18 +1,26 @@ -import 'dart:convert'; import 'dart:io'; +to stdout is the intended UX. +// ignore_for_file: avoid_print + +import 'dart:io'; + import 'package:path/path.dart' as p; -import 'package:toml/toml.dart'; - -/// Get the pinned flutter_rust_bridge_codegen version from Cargo.toml -String getFrbCodegenVersion(String cargoTomlPath) { - final content = File(cargoTomlPath).readAsStringSync(); - final toml = TomlDocument.parse(content).toMap(); - final section = toml['build-dependencies'] as Map?; - final frb = section?['flutter_rust_bridge_codegen']; - - if (frb is String) return frb; - if (frb is Map && frb['version'] != null) return frb['version'] as String; - return '2.7.1'; // fallback + +/// The codegen version must match the `flutter_rust_bridge` runtime pinned in +/// pubspec.yaml (and rust/Cargo.toml), so read the exact pin from there. +String getFrbCodegenVersion(String pubspecPath) { + final content = File(pubspecPath).readAsStringSync(); + final match = RegExp( + r'^\s+flutter_rust_bridge:\s*["\x27]?(\d+\.\d+\.\d+[^\s"\x27#]*)', + multiLine: true, + ).firstMatch(content); + if (match == null) { + throw Exception( + 'pubspec.yaml must pin flutter_rust_bridge to an exact version ' + '(e.g. `flutter_rust_bridge: 2.13.0`); could not read it from $pubspecPath', + ); + } + return match.group(1)!; } String? findLlvmPath() { @@ -32,22 +40,44 @@ String? findLlvmPath() { } } +/// Locates the package root (the directory containing `rust/Cargo.toml` and +/// `flutter_rust_bridge.yaml`). This script lives in `/tool/` and is +/// normally run from that directory, so try the script location first and +/// fall back to the current directory and its parent. +Directory findPackageRoot() { + final candidates = [ + File.fromUri(Platform.script).parent.parent, + Directory.current.parent, + Directory.current, + ]; + for (final dir in candidates) { + if (File(p.join(dir.path, 'rust', 'Cargo.toml')).existsSync() && + File(p.join(dir.path, 'flutter_rust_bridge.yaml')).existsSync()) { + return dir.absolute; + } + } + throw Exception( + 'Could not find the package root (rust/Cargo.toml + ' + 'flutter_rust_bridge.yaml). Run this from the tool/ directory.', + ); +} + Future main() async { print('🔧 Starting Flutter Rust Bridge binding generation...'); try { - final root = Directory.current; - final cargoToml = File(p.join(root.path, 'rust', 'Cargo.toml')); - if (!cargoToml.existsSync()) { - throw Exception('Could not find rust/Cargo.toml at project root.'); - } - - final version = getFrbCodegenVersion(cargoToml.path); + final root = findPackageRoot(); + print('📁 Package root: ${root.path}'); + final version = getFrbCodegenVersion(p.join(root.path, 'pubspec.yaml')); print('📦 flutter_rust_bridge_codegen version: $version'); - // Local binary path - final binRoot = Directory(p.join('.dart_tool', 'frb_bin')); - final binPath = p.join(binRoot.path, 'bin', 'flutter_rust_bridge_codegen'); + // Local binary path (inside the package's .dart_tool, which is gitignored) + final binRoot = Directory(p.join(root.path, '.dart_tool', 'frb_bin')); + final binPath = p.join( + binRoot.path, + 'bin', + 'flutter_rust_bridge_codegen${Platform.isWindows ? '.exe' : ''}', + ); final bin = File(binPath); // Check if installed and version matches @@ -58,18 +88,17 @@ Future main() async { print('📥 Installing flutter_rust_bridge_codegen...'); await binRoot.create(recursive: true); - final installProcess = await Process.start( - 'cargo', - [ - 'install', - 'flutter_rust_bridge_codegen', - '--version', version, - '--root', binRoot.path, - if (bin.existsSync()) - '--force', // Only force if an old version exists - ], - mode: ProcessStartMode.inheritStdio, - ); + final installProcess = await Process.start('cargo', [ + 'install', + 'flutter_rust_bridge_codegen', + '--version', + version, + // Build the generator with its published Cargo.lock for reproducibility. + '--locked', + '--root', + binRoot.path, + if (bin.existsSync()) '--force', // Only force if an old version exists + ], mode: ProcessStartMode.inheritStdio); final exitCode = await installProcess.exitCode; if (exitCode != 0) { @@ -80,12 +109,13 @@ Future main() async { } // Prepare Dart output dir - final dartOutput = Directory(p.join('lib', 'src')); + final dartOutput = Directory(p.join(root.path, 'lib', 'src')); if (!dartOutput.existsSync()) { await dartOutput.create(recursive: true); } - // Run the codegen + // Run the codegen from the package root so it picks up + // flutter_rust_bridge.yaml. print('🚀 Running flutter_rust_bridge_codegen...'); final llvmPath = findLlvmPath(); if (llvmPath != null) { @@ -96,20 +126,22 @@ Future main() async { [ 'generate', '--rust-root', - 'rust', + p.join(root.path, 'rust'), '--rust-input', 'crate::api', '--dart-output', dartOutput.path, if (llvmPath != null) ...['--llvm-path', llvmPath], ], + workingDirectory: root.path, mode: ProcessStartMode.inheritStdio, ); final code = await process.exitCode; if (code != 0) { throw Exception( - 'flutter_rust_bridge_codegen failed with exit code $code'); + 'flutter_rust_bridge_codegen failed with exit code $code', + ); } print('🎉 Bindings generated successfully!'); diff --git a/tool/pubspec.yaml b/tool/pubspec.yaml new file mode 100644 index 0000000..1eb64ed --- /dev/null +++ b/tool/pubspec.yaml @@ -0,0 +1,16 @@ +name: xelis_flutter_tool +description: Maintainer script that installs the pinned flutter_rust_bridge_codegen and regenerates the bindings. Not part of the published package. +publish_to: none + +# Kept as a separate package on purpose: running it with `dart run` must not +# trigger the parent package's build hook (which would compile the Rust crate +# and fail whenever the stale frb_generated.rs no longer compiles). +environment: + sdk: ^3.13.0 + +dependencies: + path: ^1.9.1 + +dev_dependencies: + lints: ^6.0.0 + test: ^1.31.1 diff --git a/tool/test/cargo_dependencies_test.dart b/tool/test/cargo_dependencies_test.dart new file mode 100644 index 0000000..d1bb92d --- /dev/null +++ b/tool/test/cargo_dependencies_test.dart @@ -0,0 +1,105 @@ +import 'package:test/test.dart'; + +import '../../hook/cargo_dependencies.dart'; + +void main() { + group('parseCargoDependencies', () { + test('returns dependencies from each rule without tracking targets', () { + const contents = + '/build/libxelis_flutter.dylib: /source/src/lib.rs ' + '/source/src/api/wallet.rs\n' + '/build/libxelis_flutter.a: /source/Cargo.toml\n' + '/source/src/lib.rs:\n'; + + expect(parseCargoDependencies(contents), [ + '/source/src/lib.rs', + '/source/src/api/wallet.rs', + '/source/Cargo.toml', + ]); + }); + + test('decodes escaped spaces in Unix dependency paths', () { + const contents = + r'/build/my\ app/libxelis_flutter.dylib: ' + r'/source/my\ wallet/src/lib.rs /source/my\ wallet/Cargo.toml'; + + expect(parseCargoDependencies(contents), [ + '/source/my wallet/src/lib.rs', + '/source/my wallet/Cargo.toml', + ]); + }); + + test('preserves Windows separators and ignores the target drive colon', () { + const contents = + r'C:\build\libxelis_flutter.dll: ' + r'C:\source\wallet\src\lib.rs C:\source\wallet\src\api\wallet.rs'; + + expect(parseCargoDependencies(contents), [ + r'C:\source\wallet\src\lib.rs', + r'C:\source\wallet\src\api\wallet.rs', + ]); + }); + + test('decodes spaces while preserving Windows path separators', () { + const contents = + r'C:\my\ app\build\libxelis_flutter.dll: ' + r'C:\source\my\ wallet\src\lib.rs ' + r'C:\source\my\ wallet\Cargo.toml'; + + expect(parseCargoDependencies(contents), [ + r'C:\source\my wallet\src\lib.rs', + r'C:\source\my wallet\Cargo.toml', + ]); + }); + + test('preserves a literal backslash adjacent to an escaped space', () { + const contents = + r'/build/libxelis_flutter.dylib: ' + r'/source/name\\ with\ space.rs /source/name\segment.rs'; + + expect(parseCargoDependencies(contents), [ + r'/source/name\ with space.rs', + r'/source/name\segment.rs', + ]); + }); + + test('preserves literal hashes, dollar signs, and dependency colons', () { + const contents = + r'/build/libxelis_flutter.dylib: ' + r'/source/hash#dollar$/src/lib:generated.rs ' + r'/source/escaped\ #$\ name.rs'; + + expect(parseCargoDependencies(contents), [ + r'/source/hash#dollar$/src/lib:generated.rs', + r'/source/escaped #$ name.rs', + ]); + }); + + test('preserves literal tabs inside dependency paths', () { + const contents = + '/build/libxelis_flutter.dylib: ' + '/source/name\twith-tab.rs /source/src/lib.rs'; + + expect(parseCargoDependencies(contents), [ + '/source/name\twith-tab.rs', + '/source/src/lib.rs', + ]); + }); + + test('accepts CRLF rules and skips empty lines and target-only rules', () { + const contents = + '\r\n' + r'C:\build\libxelis_flutter.dll: C:\source\src\lib.rs' + '\r\n' + r'C:\build\libxelis_flutter.lib: C:\source\Cargo.toml' + '\r\n' + r'C:\source\src\lib.rs:' + '\r\n\r\n'; + + expect(parseCargoDependencies(contents), [ + r'C:\source\src\lib.rs', + r'C:\source\Cargo.toml', + ]); + }); + }); +} diff --git a/windows/.gitignore b/windows/.gitignore deleted file mode 100644 index b3eb2be..0000000 --- a/windows/.gitignore +++ /dev/null @@ -1,17 +0,0 @@ -flutter/ - -# Visual Studio user-specific files. -*.suo -*.user -*.userosscache -*.sln.docstates - -# Visual Studio build-related files. -x64/ -x86/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt deleted file mode 100644 index 5767644..0000000 --- a/windows/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# The Flutter tooling requires that developers have a version of Visual Studio -# installed that includes CMake 3.14 or later. You should not increase this -# version, as doing so will cause the plugin to fail to compile for some -# customers of the plugin. -cmake_minimum_required(VERSION 3.14) - -# Project-level configuration. -set(PROJECT_NAME "xelis_flutter") -project(${PROJECT_NAME} LANGUAGES CXX) - -include("../cargokit/cmake/cargokit.cmake") -apply_cargokit(${PROJECT_NAME} ../rust xelis_flutter "") - -# List of absolute paths to libraries that should be bundled with the plugin. -# This list could contain prebuilt libraries, or libraries created by an -# external build triggered from this build file. -set(xelis_flutter_bundled_libraries - "${${PROJECT_NAME}_cargokit_lib}" - PARENT_SCOPE -)