diff --git a/example/dart_package/README.md b/example/dart_package/README.md index 8b55e73..8524a5d 100644 --- a/example/dart_package/README.md +++ b/example/dart_package/README.md @@ -25,11 +25,10 @@ start using the package. ## Usage -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. +Run binary console command in root folder: -```dart -const like = 'sample'; +```sh +dart --enable-experiment=native-assets run bin/dart_package_example.dart ``` ## Additional information diff --git a/example/dart_package/hook/build.dart b/example/dart_package/hook/build.dart index f977fb7..f9cecdb 100644 --- a/example/dart_package/hook/build.dart +++ b/example/dart_package/hook/build.dart @@ -5,11 +5,11 @@ import 'package:native_assets_cli/native_assets_cli.dart'; void main(List args) async { try { - await build(args, (BuildConfig buildConfig, BuildOutput output) async { + await build(args, (BuildInput input, BuildOutputBuilder output) async { final builder = RustBuilder( package: 'dart_package', cratePath: 'rust', - buildConfig: buildConfig, + buildInput: input, ); await builder.run(output: output); }); diff --git a/example/dart_package/pubspec.yaml b/example/dart_package/pubspec.yaml index 5404a73..6a674d3 100644 --- a/example/dart_package/pubspec.yaml +++ b/example/dart_package/pubspec.yaml @@ -4,11 +4,12 @@ version: 1.0.0 publish_to: none environment: - sdk: ^3.5.0-90.0.dev + sdk: ^3.5.0 dependencies: - native_toolchain_rust: ^0.1.0-dev.7 - native_assets_cli: ^0.7.2 + native_toolchain_rust: + path: ../../native_toolchain_rust + native_assets_cli: ^0.12.0 dev_dependencies: lints: ^3.0.0 diff --git a/example/flutter_package/example/.metadata b/example/flutter_package/example/.metadata index 59e4e2d..8af9f15 100644 --- a/example/flutter_package/example/.metadata +++ b/example/flutter_package/example/.metadata @@ -4,8 +4,8 @@ # This file should be version controlled and should not be manually edited. version: - revision: "9689f7f89c9821b344321668fd144bdd6b957d41" - channel: "main" + revision: "17025dd88227cd9532c33fa78f5250d548d87e9a" + channel: "stable" project_type: app @@ -13,26 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - base_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 + create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a - platform: android - create_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - base_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - - platform: ios - create_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - base_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - - platform: linux - create_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - base_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - - platform: macos - create_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - base_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - - platform: web - create_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - base_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - - platform: windows - create_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 - base_revision: 9689f7f89c9821b344321668fd144bdd6b957d41 + create_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a + base_revision: 17025dd88227cd9532c33fa78f5250d548d87e9a # User provided section diff --git a/example/flutter_package/example/android/.gitignore b/example/flutter_package/example/android/.gitignore index 6f56801..8f0dea9 100644 --- a/example/flutter_package/example/android/.gitignore +++ b/example/flutter_package/example/android/.gitignore @@ -7,7 +7,8 @@ gradle-wrapper.jar GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. -# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +# See https://flutter.dev/to/reference-keystore key.properties **/*.keystore **/*.jks +app/.cxx diff --git a/example/flutter_package/example/android/app/build.gradle b/example/flutter_package/example/android/app/build.gradle index 2f5eea4..b5511a9 100644 --- a/example/flutter_package/example/android/app/build.gradle +++ b/example/flutter_package/example/android/app/build.gradle @@ -15,11 +15,15 @@ android { targetCompatibility = JavaVersion.VERSION_1_8 } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 + } + defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId = "com.example.example" // You can update the following values to match your application needs. - // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + // For more information, see: https://flutter.dev/to/review-gradle-config. minSdk = flutter.minSdkVersion targetSdk = flutter.targetSdkVersion versionCode = flutter.versionCode diff --git a/example/flutter_package/example/android/gradle/wrapper/gradle-wrapper.properties b/example/flutter_package/example/android/gradle/wrapper/gradle-wrapper.properties index e1ca574..7bb2df6 100644 --- a/example/flutter_package/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/flutter_package/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-7.6.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip diff --git a/example/flutter_package/example/android/settings.gradle b/example/flutter_package/example/android/settings.gradle index 536165d..b9e43bd 100644 --- a/example/flutter_package/example/android/settings.gradle +++ b/example/flutter_package/example/android/settings.gradle @@ -18,8 +18,8 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "7.3.0" apply false - id "org.jetbrains.kotlin.android" version "1.7.10" apply false + id "com.android.application" version "8.1.0" apply false + id "org.jetbrains.kotlin.android" version "1.8.22" apply false } include ":app" diff --git a/example/flutter_package/example/pubspec.lock b/example/flutter_package/example/pubspec.lock index ef67936..3e8b345 100644 --- a/example/flutter_package/example/pubspec.lock +++ b/example/flutter_package/example/pubspec.lock @@ -29,50 +29,42 @@ packages: dependency: transitive description: name: async - sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" url: "https://pub.dev" source: hosted - version: "2.11.0" + version: "2.13.0" boolean_selector: dependency: transitive description: name: boolean_selector - sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" characters: dependency: transitive description: name: characters - sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 url: "https://pub.dev" source: hosted - version: "1.3.0" - cli_config: - dependency: transitive - description: - name: cli_config - sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec - url: "https://pub.dev" - source: hosted - version: "0.2.0" + version: "1.4.0" clock: dependency: transitive description: name: clock - sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b url: "https://pub.dev" source: hosted - version: "1.1.1" + version: "1.1.2" collection: dependency: transitive description: name: collection - sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" url: "https://pub.dev" source: hosted - version: "1.19.0" + version: "1.19.1" convert: dependency: transitive description: @@ -85,10 +77,10 @@ packages: dependency: transitive description: name: coverage - sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76" + sha256: e3493833ea012784c740e341952298f1cc77f1f01b1bbc3eb4eecf6984fb7f43 url: "https://pub.dev" source: hosted - version: "1.7.2" + version: "1.11.1" crypto: dependency: transitive description: @@ -101,10 +93,10 @@ packages: dependency: transitive description: name: fake_async - sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78" + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" url: "https://pub.dev" source: hosted - version: "1.3.1" + version: "1.3.3" file: dependency: transitive description: @@ -198,18 +190,18 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" + sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" url: "https://pub.dev" source: hosted - version: "10.0.5" + version: "10.0.9" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 url: "https://pub.dev" source: hosted - version: "3.0.5" + version: "3.0.9" leak_tracker_testing: dependency: transitive description: @@ -238,10 +230,10 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.17" material_color_utilities: dependency: transitive description: @@ -254,10 +246,10 @@ packages: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.16.0" mime: dependency: transitive description: @@ -270,17 +262,17 @@ packages: dependency: transitive description: name: native_assets_cli - sha256: "3da9bdd4beb2ed059dae7fd93baa62c5f6c3cdf630bbb88334303dfa92d6da26" + sha256: bd4cac2c174be1ec0dd86c1bd2b55ffaad6870f7bcf31b2d5d85d0a5fbc40e82 url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.12.0" native_toolchain_rust: dependency: "direct overridden" description: path: "../../../native_toolchain_rust" relative: true source: path - version: "0.1.0-dev.7" + version: "0.2.0-dev.0" native_toolchain_rust_common: dependency: "direct overridden" description: @@ -308,10 +300,10 @@ packages: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.9.1" petitparser: dependency: transitive description: @@ -358,7 +350,7 @@ packages: path: "../../../rustup" relative: true source: path - version: "0.1.0-dev.6" + version: "0.1.0-dev.8" shelf: dependency: transitive description: @@ -395,7 +387,7 @@ packages: dependency: transitive description: flutter source: sdk - version: "0.0.99" + version: "0.0.0" source_map_stack_trace: dependency: transitive description: @@ -416,66 +408,66 @@ packages: dependency: transitive description: name: source_span - sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.10.1" stack_trace: dependency: transitive description: name: stack_trace - sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" url: "https://pub.dev" source: hosted - version: "1.11.1" + version: "1.12.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" url: "https://pub.dev" source: hosted - version: "2.1.2" + version: "2.1.4" string_scanner: dependency: transitive description: name: string_scanner - sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3" + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" term_glyph: dependency: transitive description: name: term_glyph - sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" url: "https://pub.dev" source: hosted - version: "1.2.1" + version: "1.2.2" test: dependency: transitive description: name: test - sha256: "713a8789d62f3233c46b4a90b174737b2c04cb6ae4500f2aa8b1be8f03f5e67f" + sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" url: "https://pub.dev" source: hosted - version: "1.25.8" + version: "1.25.15" test_api: dependency: transitive description: name: test_api - sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.3" + version: "0.7.4" test_core: dependency: transitive description: name: test_core - sha256: "12391302411737c176b0b5d6491f466b0dd56d4763e347b6714efbaa74d7953d" + sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" url: "https://pub.dev" source: hosted - version: "0.6.5" + version: "0.6.8" toml: dependency: transitive description: @@ -504,10 +496,10 @@ packages: dependency: transitive description: name: vm_service - sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc + sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 url: "https://pub.dev" source: hosted - version: "14.2.4" + version: "15.0.0" watcher: dependency: transitive description: @@ -549,5 +541,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.5.0-90.0.dev <4.0.0" + dart: ">=3.7.0 <4.0.0" flutter: ">=3.18.0-18.0.pre.54" diff --git a/example/flutter_package/hook/build.dart b/example/flutter_package/hook/build.dart index b613765..5b470a9 100644 --- a/example/flutter_package/hook/build.dart +++ b/example/flutter_package/hook/build.dart @@ -5,12 +5,12 @@ import 'package:native_assets_cli/native_assets_cli.dart'; void main(List args) async { try { - await build(args, (BuildConfig buildConfig, BuildOutput output) async { + await build(args, (BuildInput input, BuildOutputBuilder output) async { final builder = RustBuilder( // The ID of native assets consists of package name and crate name. package: 'flutter_package', cratePath: 'rust', - buildConfig: buildConfig, + buildInput: input, extraCargoArgs: ['--features=sum'], ); await builder.run(output: output); diff --git a/example/flutter_package/pubspec.yaml b/example/flutter_package/pubspec.yaml index ecf9a90..7e96fb2 100644 --- a/example/flutter_package/pubspec.yaml +++ b/example/flutter_package/pubspec.yaml @@ -4,14 +4,15 @@ version: 0.0.1 publish_to: none environment: - sdk: '>=3.5.0-90.0.dev <4.0.0' + sdk: '>=3.5.0 <4.0.0' flutter: ">=1.17.0" dependencies: flutter: sdk: flutter - native_toolchain_rust: ^0.1.0-dev.7 - native_assets_cli: ^0.7.2 + native_toolchain_rust: + path: ../../native_toolchain_rust + native_assets_cli: ^0.12.0 dev_dependencies: flutter_test: @@ -22,7 +23,7 @@ dev_dependencies: # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter packages. -flutter: +# flutter: # To add assets to your package, add an assets section, like this: # assets: diff --git a/native_doctor/lib/src/checkers/ndk.dart b/native_doctor/lib/src/checkers/ndk.dart index f317032..9d16982 100644 --- a/native_doctor/lib/src/checkers/ndk.dart +++ b/native_doctor/lib/src/checkers/ndk.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:collection/collection.dart'; -import 'package:native_assets_cli/native_assets_cli.dart'; +import 'package:native_assets_cli/code_assets.dart'; import 'package:native_doctor/src/android_sdk.dart'; import 'package:native_doctor/src/native_doctor.dart'; import 'package:native_doctor/src/toolchain_checker.dart'; diff --git a/native_doctor/lib/src/native_doctor.dart b/native_doctor/lib/src/native_doctor.dart index 650d7d2..8f4db81 100644 --- a/native_doctor/lib/src/native_doctor.dart +++ b/native_doctor/lib/src/native_doctor.dart @@ -3,7 +3,7 @@ import 'dart:io'; import 'package:args/args.dart'; import 'package:collection/collection.dart'; import 'package:logging/logging.dart'; -import 'package:native_assets_cli/native_assets_cli.dart'; +import 'package:native_assets_cli/code_assets.dart'; import 'package:native_doctor/src/checkers/ndk.dart'; import 'package:native_doctor/src/writer.dart'; import 'package:native_doctor/src/checkers/rustup.dart'; diff --git a/native_doctor/pubspec.lock b/native_doctor/pubspec.lock index dbee978..af71015 100644 --- a/native_doctor/pubspec.lock +++ b/native_doctor/pubspec.lock @@ -49,14 +49,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.3" - cli_config: - dependency: transitive - description: - name: cli_config - sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec - url: "https://pub.dev" - source: hosted - version: "0.2.0" collection: dependency: "direct main" description: @@ -189,10 +181,10 @@ packages: dependency: transitive description: name: meta - sha256: "25dfcaf170a0190f47ca6355bdd4552cb8924b430512ff0cafb8db9bd41fe33b" + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.14.0" + version: "1.16.0" mime: dependency: transitive description: @@ -205,10 +197,10 @@ packages: dependency: "direct main" description: name: native_assets_cli - sha256: "3da9bdd4beb2ed059dae7fd93baa62c5f6c3cdf630bbb88334303dfa92d6da26" + sha256: bd4cac2c174be1ec0dd86c1bd2b55ffaad6870f7bcf31b2d5d85d0a5fbc40e82 url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.12.0" native_toolchain_rust_common: dependency: "direct main" description: @@ -286,7 +278,7 @@ packages: path: "../rustup" relative: true source: path - version: "0.1.0-dev.6" + version: "0.1.0-dev.8" shelf: dependency: transitive description: @@ -379,26 +371,26 @@ packages: dependency: "direct dev" description: name: test - sha256: d72b538180efcf8413cd2e4e6fcc7ae99c7712e0909eb9223f9da6e6d0ef715f + sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" url: "https://pub.dev" source: hosted - version: "1.25.4" + version: "1.25.15" test_api: dependency: transitive description: name: test_api - sha256: "2419f20b0c8677b2d67c8ac4d1ac7372d862dc6c460cdbb052b40155408cd794" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.1" + version: "0.7.4" test_core: dependency: transitive description: name: test_core - sha256: "4d070a6bc36c1c4e89f20d353bfd71dc30cdf2bd0e14349090af360a029ab292" + sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" url: "https://pub.dev" source: hosted - version: "0.6.2" + version: "0.6.8" typed_data: dependency: transitive description: @@ -456,4 +448,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.4.0-265.0.dev <4.0.0" + dart: ">=3.7.0 <4.0.0" diff --git a/native_doctor/pubspec.yaml b/native_doctor/pubspec.yaml index da703b3..acf3ef4 100644 --- a/native_doctor/pubspec.yaml +++ b/native_doctor/pubspec.yaml @@ -1,10 +1,10 @@ name: native_doctor description: A tool that analyzes Flutter and Dart project dependencies, find requirements for native toolchains and, if possible, resolves issues. -version: 0.1.0-dev.4 +version: 0.1.0-dev.6 repository: https://github.com/irondash/native_toolchain_rust environment: - sdk: ^3.4.0-265.0.dev + sdk: ^3.5.0 executables: native_doctor: @@ -18,7 +18,7 @@ dependencies: pub_semver: ^2.1.4 yaml: ^3.1.2 pubspec_parse: ^1.2.3 - native_assets_cli: ^0.7.2 + native_assets_cli: ^0.12.0 collection: ^1.18.0 logging: ^1.2.0 path: ^1.9.0 diff --git a/native_toolchain_rust/README.md b/native_toolchain_rust/README.md index c294c4b..3ca6d5f 100644 --- a/native_toolchain_rust/README.md +++ b/native_toolchain_rust/README.md @@ -25,12 +25,12 @@ import 'package:native_assets_cli/native_assets_cli.dart'; void main(List args) async { try { - await build(args, (BuildConfig buildConfig, BuildOutput output) async { + await build(args, (BuildInput input, BuildOutputBuilder output) async { final builder = RustBuilder( // The ID of native assets consists of package name and crate name. package: '', cratePath: 'rust', - buildConfig: buildConfig, + buildInput: input, ); await builder.run(output: output); }); diff --git a/native_toolchain_rust/lib/src/android_environment.dart b/native_toolchain_rust/lib/src/android_environment.dart index 150a734..d55ba74 100644 --- a/native_toolchain_rust/lib/src/android_environment.dart +++ b/native_toolchain_rust/lib/src/android_environment.dart @@ -1,7 +1,7 @@ import 'dart:io'; import 'package:collection/collection.dart'; -import 'package:native_assets_cli/native_assets_cli.dart'; +import 'package:native_assets_cli/code_assets.dart'; import 'package:native_toolchain_rust/rustup.dart'; import 'package:native_toolchain_rust/src/android_linker_wrapper.dart'; import 'package:path/path.dart' as path; diff --git a/native_toolchain_rust/lib/src/android_linker_wrapper.dart b/native_toolchain_rust/lib/src/android_linker_wrapper.dart index aecaf8a..9e56595 100644 --- a/native_toolchain_rust/lib/src/android_linker_wrapper.dart +++ b/native_toolchain_rust/lib/src/android_linker_wrapper.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:native_assets_cli/native_assets_cli.dart'; +import 'package:native_assets_cli/code_assets.dart'; import 'package:native_toolchain_rust/rustup.dart'; import 'package:native_toolchain_rust_common/native_toolchain_rust_common.dart'; import 'package:path/path.dart' as path; diff --git a/native_toolchain_rust/lib/src/builder.dart b/native_toolchain_rust/lib/src/builder.dart index da88fa6..d3838ba 100644 --- a/native_toolchain_rust/lib/src/builder.dart +++ b/native_toolchain_rust/lib/src/builder.dart @@ -1,15 +1,13 @@ import 'dart:io'; import 'package:logging/logging.dart'; -import 'package:native_assets_cli/native_assets_cli.dart'; +import 'package:native_assets_cli/code_assets.dart'; import 'package:native_toolchain_rust/rustup.dart'; import 'package:native_toolchain_rust_common/native_toolchain_rust_common.dart'; import 'package:rustup/rustup.dart'; import 'package:native_toolchain_rust/src/android_environment.dart'; import 'package:native_toolchain_rust/src/crate_manifest.dart'; -import 'package:path/path.dart' as path; - class RustToolchainException implements Exception { RustToolchainException({required this.message}); @@ -75,9 +73,9 @@ class RustToolchain { } Future _checkNativeManifest({ - required BuildConfig buildConfig, + required BuildInput buildInput, }) async { - final manifest = NativeManifest.forPackage(buildConfig.packageRoot); + final manifest = NativeManifest.forPackage(buildInput.packageRoot); if (manifest == null) { throw RustToolchainException( message: '`native_manifest.yaml` expected in package root.\n' @@ -102,11 +100,11 @@ class RustToolchain { } class RustBuilder { - RustBuilder({ + const RustBuilder({ required this.package, this.toolchain, required this.cratePath, - required this.buildConfig, + required this.buildInput, this.extraCargoArgs = const [], this.release = true, this.assetName, @@ -134,8 +132,8 @@ class RustBuilder { /// Path to the Rust crate directory relative to the package root. final String cratePath; - /// Build config provided to the build callback from `native_assets_cli`. - final BuildConfig buildConfig; + /// Build input provider from `native_assets_cli`. + final BuildInput buildInput; /// Dart build files inside hook directory that should be added as /// dependencies. Default value adds `hook/build.dart` as dependency. @@ -158,135 +156,96 @@ class RustBuilder { /// Optional logger for verbose output. final Logger? logger; - Future run({required BuildOutput output}) async { + Future run({required BuildOutputBuilder output}) async { final toolchain = this.toolchain ?? await RustToolchain.withName('stable'); - - final manifestPath = buildConfig.packageRoot + final manifestPath = buildInput.packageRoot .resolve(cratePath) .makeDirectory() .resolve('Cargo.toml'); final manifestInfo = CrateManifestInfo.load(manifestPath); - final outDir = - buildConfig.outputDirectory.resolve('native_toolchain_rust/'); + final outDir = buildInput.outputDirectory.resolve('native_toolchain_rust/'); final dylibName = - buildConfig.targetOS.dylibFileName(manifestInfo.packageName); - - if (buildConfig.dryRun) { - output.addAsset(NativeCodeAsset( - package: package, - name: assetName ?? manifestInfo.packageName, - linkMode: DynamicLoadingBundled(), - os: buildConfig.targetOS, - file: Uri.file(dylibName), - )); - return; - } + buildInput.config.code.targetOS.dylibFileName(manifestInfo.packageName); final target = RustTarget.from( - architecture: buildConfig.targetArchitecture!, - os: buildConfig.targetOS, - iosSdk: buildConfig.targetOS == OS.iOS ? buildConfig.targetIOSSdk : null, + architecture: buildInput.config.code.targetArchitecture, + os: buildInput.config.code.targetOS, + iosSdk: buildInput.config.code.targetOS == OS.iOS + ? buildInput.config.code.iOS.targetSdk + : null, )!; await toolchain._checkTarget(target: target); if (useNativeManifest) { - await toolchain._checkNativeManifest(buildConfig: buildConfig); + await toolchain._checkNativeManifest(buildInput: buildInput); } - final effectiveBuildMode = release ? BuildMode.release : BuildMode.debug; - - if (!buildConfig.dryRun) { - await toolchain.toolchain.rustup.runCommand( - [ - 'run', - toolchain.name, - 'cargo', - 'build', - '--manifest-path', - manifestPath.toFilePath(), - '-p', - manifestInfo.packageName, - if (effectiveBuildMode == BuildMode.release) '--release', - '--verbose', - '--target', - target.triple, - '--target-dir', - outDir.toFilePath(), - ...extraCargoArgs, - ], - environment: await _buildEnvironment( - outDir, - target, - toolchain.toolchain, - ), - logger: logger, - ); - } + await toolchain.toolchain.rustup.runCommand( + [ + 'run', + toolchain.name, + 'cargo', + 'build', + '--manifest-path', + manifestPath.toFilePath(), + '-p', + manifestInfo.packageName, + if (release) '--release', + '--verbose', + '--target', + target.triple, + '--target-dir', + outDir.toFilePath(), + ...extraCargoArgs, + ], + environment: await _buildEnvironment( + outDir, + target, + toolchain.toolchain, + ), + logger: logger, + ); - final effectiveOutDir = outDir - .resolve('${target.triple}/') - .resolve('${effectiveBuildMode.name}/'); + final buildModeName = release ? 'release' : 'debug'; - final asset = NativeCodeAsset( + final effectiveOutDir = + outDir.resolve('${target.triple}/').resolve('$buildModeName/'); + + final asset = CodeAsset( package: package, name: assetName ?? manifestInfo.packageName, - os: buildConfig.targetOS, - architecture: buildConfig.targetArchitecture, + os: buildInput.config.code.targetOS, + architecture: buildInput.config.code.targetArchitecture, linkMode: DynamicLoadingBundled(), file: effectiveOutDir.resolve(dylibName), ); - output.addAsset(asset); - if (!buildConfig.dryRun) { - _addDependencies( - output: output, - effectiveOutDir: effectiveOutDir, - dylibName: dylibName, - ); - } + output.assets.code.add(asset); + for (final source in dartBuildFiles) { output.addDependency( - buildConfig.packageRoot.resolve(source), + buildInput.packageRoot.resolve(source), ); } } - void _addDependencies({ - required BuildOutput output, - required Uri effectiveOutDir, - required String dylibName, - }) { - final dylibPath = effectiveOutDir.resolve(dylibName).toFilePath(); - final depFile = path.setExtension(dylibPath, '.d'); - final lines = File(depFile).readAsLinesSync(); - for (final line in lines) { - final parts = line.split(':'); - if (parts[0] == dylibPath) { - final dependencies = parts[1].trim().split(' '); - for (final dependency in dependencies) { - output.addDependency(Uri.file(dependency)); - } - } - } - } - Future> _buildEnvironment( Uri outDir, RustTarget target, RustupToolchain toolchain, ) async { - if (buildConfig.targetOS == OS.android) { - final ndkInfo = - NdkInfo.forCCompiler(buildConfig.cCompiler.compiler!.toFilePath())!; + if (buildInput.config.code.targetOS == OS.android) { + final ndkInfo = NdkInfo.forCCompiler( + buildInput.config.code.cCompiler!.compiler.toFilePath())!; final env = AndroidEnvironment( ndkInfo: ndkInfo, - minSdkVersion: buildConfig.targetAndroidNdkApi!, + minSdkVersion: buildInput.config.code.android.targetNdkApi, targetTempDir: outDir.toFilePath(), toolchain: toolchain, target: target, ); return env.buildEnvironment(); - } else if (buildConfig.targetOS == OS.iOS) { + } else if ({OS.iOS, OS.macOS}.contains(buildInput.config.code.targetOS)) { final path = Platform.environment['PATH'] ?? ''; // XCode injects paths in PATH that breaks host build for crates with build.rs. // https://github.com/irondash/native_toolchain_rust/issues/17 diff --git a/native_toolchain_rust/pubspec.lock b/native_toolchain_rust/pubspec.lock index 51f3072..a31f857 100644 --- a/native_toolchain_rust/pubspec.lock +++ b/native_toolchain_rust/pubspec.lock @@ -41,14 +41,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" - cli_config: - dependency: transitive - description: - name: cli_config - sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec - url: "https://pub.dev" - source: hosted - version: "0.2.0" collection: dependency: "direct main" description: @@ -173,10 +165,10 @@ packages: dependency: transitive description: name: meta - sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c url: "https://pub.dev" source: hosted - version: "1.12.0" + version: "1.16.0" mime: dependency: transitive description: @@ -189,10 +181,10 @@ packages: dependency: "direct main" description: name: native_assets_cli - sha256: "3da9bdd4beb2ed059dae7fd93baa62c5f6c3cdf630bbb88334303dfa92d6da26" + sha256: bd4cac2c174be1ec0dd86c1bd2b55ffaad6870f7bcf31b2d5d85d0a5fbc40e82 url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.12.0" native_toolchain_rust_common: dependency: "direct main" description: @@ -270,7 +262,7 @@ packages: path: "../rustup" relative: true source: path - version: "0.1.0-dev.6" + version: "0.1.0-dev.8" shelf: dependency: transitive description: @@ -448,4 +440,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.4.0-190.0.dev <4.0.0" + dart: ">=3.7.0 <4.0.0" diff --git a/native_toolchain_rust/pubspec.yaml b/native_toolchain_rust/pubspec.yaml index a53ace4..bcf886f 100644 --- a/native_toolchain_rust/pubspec.yaml +++ b/native_toolchain_rust/pubspec.yaml @@ -1,21 +1,21 @@ name: native_toolchain_rust description: Library to interact with rustup and cargo when building Dart and Flutter native assets written in Rust. -version: 0.1.0-dev.7 +version: 0.2.0-dev.0 homepage: https://github.com/irondash/native_toolchain_rust.git environment: - sdk: ">=3.4.0-190.0.dev <4.0.0" + sdk: ">=3.5.0 <4.0.0" dependencies: native_toolchain_rust_common: ^0.1.0-dev.3 collection: ^1.18.0 logging: ^1.2.0 - native_assets_cli: ^0.7.2 + native_assets_cli: ^0.12.0 path: ^1.9.0 process: ^5.0.2 pub_semver: ^2.1.4 toml: ^0.15.0 - rustup: ^0.1.0-dev.6 + rustup: ^0.1.0-dev.8 dev_dependencies: lints: ^3.0.0 diff --git a/native_toolchain_rust/test/build_test.dart b/native_toolchain_rust/test/build_test.dart index 1a047a4..c8d2350 100644 --- a/native_toolchain_rust/test/build_test.dart +++ b/native_toolchain_rust/test/build_test.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:native_assets_cli/native_assets_cli.dart'; +import 'package:native_assets_cli/code_assets.dart'; import 'package:native_toolchain_rust_common/native_toolchain_rust_common.dart'; import 'package:path/path.dart' as p; import 'package:test/test.dart'; diff --git a/rustup/lib/src/rustup.dart b/rustup/lib/src/rustup.dart index d01dd19..a854e77 100644 --- a/rustup/lib/src/rustup.dart +++ b/rustup/lib/src/rustup.dart @@ -1,9 +1,9 @@ import 'dart:io'; +import 'package:native_assets_cli/code_assets.dart'; import 'package:native_toolchain_rust_common/native_toolchain_rust_common.dart' as common; import 'package:collection/collection.dart'; import 'package:logging/logging.dart'; -import 'package:native_assets_cli/native_assets_cli.dart'; import 'package:path/path.dart' as path; import 'package:pub_semver/pub_semver.dart'; import 'package:rustup/src/mutex.dart'; diff --git a/rustup/pubspec.yaml b/rustup/pubspec.yaml index 26ff1be..aabcb8f 100644 --- a/rustup/pubspec.yaml +++ b/rustup/pubspec.yaml @@ -1,16 +1,16 @@ name: rustup description: "Dart bindings for the rustup CLI tool." -version: 0.1.0-dev.6 +version: 0.1.0-dev.8 homepage: https://github.com/irondash/native_toolchain_rust.git environment: - sdk: ">=3.4.0-190.0.dev <4.0.0" + sdk: ">=3.5.0 <4.0.0" dependencies: native_toolchain_rust_common: ^0.1.0-dev.3 process: ^5.0.2 pub_semver: ^2.1.4 - native_assets_cli: ^0.7.2 + native_assets_cli: ^0.12.0 http: ^1.2.1 logging: ^1.2.0 path: ^1.9.0