From 004b75b1ec48d6c929e77806141192fd9b9ed1e3 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 20 Oct 2021 15:39:35 -0700 Subject: [PATCH 01/23] Initial commit of flutter plugin --- flutter_wasm/.gitignore | 29 +++ flutter_wasm/.metadata | 10 + flutter_wasm/CHANGELOG.md | 3 + flutter_wasm/LICENSE | 1 + flutter_wasm/README.md | 15 ++ flutter_wasm/analysis_options.yaml | 4 + flutter_wasm/android/.gitignore | 8 + flutter_wasm/android/build.gradle | 126 +++++++++++ flutter_wasm/android/settings.gradle | 1 + .../android/src/main/AndroidManifest.xml | 3 + .../dart/flutter_wasm/FlutterWasmPlugin.kt | 11 + flutter_wasm/example/.gitignore | 46 ++++ flutter_wasm/example/.metadata | 10 + flutter_wasm/example/README.md | 16 ++ flutter_wasm/example/analysis_options.yaml | 29 +++ flutter_wasm/example/android/.gitignore | 13 ++ flutter_wasm/example/android/app/build.gradle | 68 ++++++ .../android/app/src/debug/AndroidManifest.xml | 7 + .../android/app/src/main/AndroidManifest.xml | 32 +++ .../flutter_wasm_example/MainActivity.kt | 6 + .../res/drawable-v21/launch_background.xml | 12 + .../main/res/drawable/launch_background.xml | 12 + .../src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 544 bytes .../src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 442 bytes .../src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 721 bytes .../main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 1031 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 1443 bytes .../app/src/main/res/values-night/styles.xml | 18 ++ .../app/src/main/res/values/styles.xml | 18 ++ .../app/src/profile/AndroidManifest.xml | 7 + flutter_wasm/example/android/build.gradle | 29 +++ .../example/android/gradle.properties | 3 + .../gradle/wrapper/gradle-wrapper.properties | 6 + flutter_wasm/example/android/settings.gradle | 11 + flutter_wasm/example/lib/main.dart | 52 +++++ flutter_wasm/example/pubspec.lock | 205 ++++++++++++++++++ flutter_wasm/example/pubspec.yaml | 22 ++ flutter_wasm/example/test/widget_test.dart | 27 +++ flutter_wasm/lib/flutter_wasm.dart | 1 + flutter_wasm/pubspec.yaml | 28 +++ flutter_wasm/test/flutter_wasm_test.dart | 23 ++ 41 files changed, 912 insertions(+) create mode 100644 flutter_wasm/.gitignore create mode 100644 flutter_wasm/.metadata create mode 100644 flutter_wasm/CHANGELOG.md create mode 100644 flutter_wasm/LICENSE create mode 100644 flutter_wasm/README.md create mode 100644 flutter_wasm/analysis_options.yaml create mode 100644 flutter_wasm/android/.gitignore create mode 100644 flutter_wasm/android/build.gradle create mode 100644 flutter_wasm/android/settings.gradle create mode 100644 flutter_wasm/android/src/main/AndroidManifest.xml create mode 100644 flutter_wasm/android/src/main/kotlin/dev/dart/flutter_wasm/FlutterWasmPlugin.kt create mode 100644 flutter_wasm/example/.gitignore create mode 100644 flutter_wasm/example/.metadata create mode 100644 flutter_wasm/example/README.md create mode 100644 flutter_wasm/example/analysis_options.yaml create mode 100644 flutter_wasm/example/android/.gitignore create mode 100644 flutter_wasm/example/android/app/build.gradle create mode 100644 flutter_wasm/example/android/app/src/debug/AndroidManifest.xml create mode 100644 flutter_wasm/example/android/app/src/main/AndroidManifest.xml create mode 100644 flutter_wasm/example/android/app/src/main/kotlin/com/example/flutter_wasm_example/MainActivity.kt create mode 100644 flutter_wasm/example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 flutter_wasm/example/android/app/src/main/res/drawable/launch_background.xml create mode 100644 flutter_wasm/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 flutter_wasm/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 flutter_wasm/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 flutter_wasm/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 flutter_wasm/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 flutter_wasm/example/android/app/src/main/res/values-night/styles.xml create mode 100644 flutter_wasm/example/android/app/src/main/res/values/styles.xml create mode 100644 flutter_wasm/example/android/app/src/profile/AndroidManifest.xml create mode 100644 flutter_wasm/example/android/build.gradle create mode 100644 flutter_wasm/example/android/gradle.properties create mode 100644 flutter_wasm/example/android/gradle/wrapper/gradle-wrapper.properties create mode 100644 flutter_wasm/example/android/settings.gradle create mode 100644 flutter_wasm/example/lib/main.dart create mode 100644 flutter_wasm/example/pubspec.lock create mode 100644 flutter_wasm/example/pubspec.yaml create mode 100644 flutter_wasm/example/test/widget_test.dart create mode 100644 flutter_wasm/lib/flutter_wasm.dart create mode 100644 flutter_wasm/pubspec.yaml create mode 100644 flutter_wasm/test/flutter_wasm_test.dart diff --git a/flutter_wasm/.gitignore b/flutter_wasm/.gitignore new file mode 100644 index 0000000..9be145f --- /dev/null +++ b/flutter_wasm/.gitignore @@ -0,0 +1,29 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. +/pubspec.lock +**/doc/api/ +.dart_tool/ +.packages +build/ diff --git a/flutter_wasm/.metadata b/flutter_wasm/.metadata new file mode 100644 index 0000000..64df19a --- /dev/null +++ b/flutter_wasm/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: d5396898bed65dacfb355fb6e52ec7ccf76746d9 + channel: unknown + +project_type: plugin diff --git a/flutter_wasm/CHANGELOG.md b/flutter_wasm/CHANGELOG.md new file mode 100644 index 0000000..41cc7d8 --- /dev/null +++ b/flutter_wasm/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 + +* TODO: Describe initial release. diff --git a/flutter_wasm/LICENSE b/flutter_wasm/LICENSE new file mode 100644 index 0000000..ba75c69 --- /dev/null +++ b/flutter_wasm/LICENSE @@ -0,0 +1 @@ +TODO: Add your license here. diff --git a/flutter_wasm/README.md b/flutter_wasm/README.md new file mode 100644 index 0000000..8d87c4b --- /dev/null +++ b/flutter_wasm/README.md @@ -0,0 +1,15 @@ +# flutter_wasm + +A new flutter plugin project. + +## Getting Started + +This project is a starting point for a Flutter +[plug-in package](https://flutter.dev/developing-packages/), +a specialized package that includes platform-specific implementation code for +Android and/or iOS. + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. + diff --git a/flutter_wasm/analysis_options.yaml b/flutter_wasm/analysis_options.yaml new file mode 100644 index 0000000..a5744c1 --- /dev/null +++ b/flutter_wasm/analysis_options.yaml @@ -0,0 +1,4 @@ +include: package:flutter_lints/flutter.yaml + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/flutter_wasm/android/.gitignore b/flutter_wasm/android/.gitignore new file mode 100644 index 0000000..c6cbe56 --- /dev/null +++ b/flutter_wasm/android/.gitignore @@ -0,0 +1,8 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures diff --git a/flutter_wasm/android/build.gradle b/flutter_wasm/android/build.gradle new file mode 100644 index 0000000..c1ffb79 --- /dev/null +++ b/flutter_wasm/android/build.gradle @@ -0,0 +1,126 @@ +group 'dev.dart.flutter_wasm' +version '1.0-SNAPSHOT' + +import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform + +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +rootProject.allprojects { + repositories { + google() + mavenCentral() + } +} + +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' + +android { + compileSdkVersion 30 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + minSdkVersion 16 + } + + def hostOs = DefaultNativePlatform.currentOperatingSystem.getName().toLowerCase() + def hostArch = DefaultNativePlatform.currentArchitecture.getName().replaceAll('-', '_') + def ndkBinDir = "${android.ndkDirectory}/toolchains/llvm/prebuilt/${hostOs}-${hostArch}/bin" + def projectProperties = new Properties() + projectProperties.load(project.rootProject.file('local.properties').newDataInputStream()) + def flutterDir = projectProperties.getProperty('flutter.sdk') + def platformVersion = -1 + fileTree("${android.ndkDirectory}/platforms").visit { FileVisitDetails details -> + if (details.isDirectory() && details.name.startsWith("android-")) { + platformVersion = Math.max(platformVersion, details.name.substring(8) as int) + } + } + if (platformVersion < 0) { + throw new Exception("Can't find any valid platforms in ${android.ndkDirectory}/platforms") + } + + tasks.register('wasm-pub-get') { + doLast { + exec { + workingDir '..' + commandLine "${flutterDir}/bin/flutter", 'pub', 'get' + } + } + } + + def architectures = [ + ['arm64-v8a', 'aarch64-linux-android', 'aarch64-linux-android', 'aarch64-linux-android', 'arch-arm64'], + ['x86', 'i686-linux-android', 'i686-linux-android', 'i686-linux-android', 'arch-x86'], + + // TODO: Enable these when they're supported by Wasmer. See: + // https://github.com/wasmerio/wasmer/issues/1652 + // https://github.com/wasmerio/wasmer/issues/2099 + // ['armeabi-v7a', 'armv7a-linux-androideabi', 'arm-linux-androideabi', 'armv7-linux-androideabi', 'arch-arm'], + // ['x86_64', 'x86_64-linux-android', 'x86_64-linux-android', 'x86_64-linux-android', 'arch-x86_64'], + ] + for (arch in architectures) { + def abi = arch[0] + def clangPrefix = "${arch[1]}${platformVersion}" + def arPrefix = arch[2] + def rustTriple = arch[3] + def sysroot = arch[4] + def sysrootDir = "${android.ndkDirectory}/platforms/android-${platformVersion}/${sysroot}" + def outDir = "${rootDir}/../build/app/intermediates/stripped_native_libs/debug/out/lib/${abi}/" + + tasks.register("wasm-lib-${abi}") { + // Specify inputs and outputs so that incremental build works properly. + inputs.property('platformVersion', platformVersion) + inputs.property('abi', abi) + outputs.file("${outDir}/libwasmer.so") + + dependsOn('wasm-pub-get') + + doLast { + exec { + workingDir '..' + commandLine "${flutterDir}/bin/flutter", 'pub', 'run', 'wasm:setup', + '--sysroot', sysrootDir, + '--target', rustTriple, + '--clang', "${ndkBinDir}/${clangPrefix}-clang", + '--clangpp', "${ndkBinDir}/${clangPrefix}-clang++", + '--ar', "${ndkBinDir}/${arPrefix}-ar", + '-o', outDir + } + } + } + } + + tasks.withType(JavaCompile) { compileTask -> + for (arch in architectures) { + def abi = arch[0] + compileTask.dependsOn("wasm-lib-${abi}") + } + } +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/flutter_wasm/android/settings.gradle b/flutter_wasm/android/settings.gradle new file mode 100644 index 0000000..b63c7d2 --- /dev/null +++ b/flutter_wasm/android/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'flutter_wasm' diff --git a/flutter_wasm/android/src/main/AndroidManifest.xml b/flutter_wasm/android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..4a91b0b --- /dev/null +++ b/flutter_wasm/android/src/main/AndroidManifest.xml @@ -0,0 +1,3 @@ + + diff --git a/flutter_wasm/android/src/main/kotlin/dev/dart/flutter_wasm/FlutterWasmPlugin.kt b/flutter_wasm/android/src/main/kotlin/dev/dart/flutter_wasm/FlutterWasmPlugin.kt new file mode 100644 index 0000000..1e8f38f --- /dev/null +++ b/flutter_wasm/android/src/main/kotlin/dev/dart/flutter_wasm/FlutterWasmPlugin.kt @@ -0,0 +1,11 @@ +package dev.dart.flutter_wasm + +import androidx.annotation.NonNull + +import io.flutter.embedding.engine.plugins.FlutterPlugin + +/** FlutterWasmPlugin */ +class FlutterWasmPlugin: FlutterPlugin { + override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {} + override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {} +} diff --git a/flutter_wasm/example/.gitignore b/flutter_wasm/example/.gitignore new file mode 100644 index 0000000..0fa6b67 --- /dev/null +++ b/flutter_wasm/example/.gitignore @@ -0,0 +1,46 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.buildlog/ +.history +.svn/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins +.flutter-plugins-dependencies +.packages +.pub-cache/ +.pub/ +/build/ + +# Web related +lib/generated_plugin_registrant.dart + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/flutter_wasm/example/.metadata b/flutter_wasm/example/.metadata new file mode 100644 index 0000000..7adad5d --- /dev/null +++ b/flutter_wasm/example/.metadata @@ -0,0 +1,10 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: d5396898bed65dacfb355fb6e52ec7ccf76746d9 + channel: unknown + +project_type: app diff --git a/flutter_wasm/example/README.md b/flutter_wasm/example/README.md new file mode 100644 index 0000000..ab51efe --- /dev/null +++ b/flutter_wasm/example/README.md @@ -0,0 +1,16 @@ +# flutter_wasm_example + +Demonstrates how to use the flutter_wasm plugin. + +## Getting Started + +This project is a starting point for a Flutter application. + +A few resources to get you started if this is your first Flutter project: + +- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) +- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) + +For help getting started with Flutter, view our +[online documentation](https://flutter.dev/docs), which offers tutorials, +samples, guidance on mobile development, and a full API reference. diff --git a/flutter_wasm/example/analysis_options.yaml b/flutter_wasm/example/analysis_options.yaml new file mode 100644 index 0000000..61b6c4d --- /dev/null +++ b/flutter_wasm/example/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + # avoid_print: false # Uncomment to disable the `avoid_print` rule + # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options diff --git a/flutter_wasm/example/android/.gitignore b/flutter_wasm/example/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/flutter_wasm/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/flutter_wasm/example/android/app/build.gradle b/flutter_wasm/example/android/app/build.gradle new file mode 100644 index 0000000..72c888d --- /dev/null +++ b/flutter_wasm/example/android/app/build.gradle @@ -0,0 +1,68 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +if (flutterVersionCode == null) { + flutterVersionCode = '1' +} + +def flutterVersionName = localProperties.getProperty('flutter.versionName') +if (flutterVersionName == null) { + flutterVersionName = '1.0' +} + +apply plugin: 'com.android.application' +apply plugin: 'kotlin-android' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 30 + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + kotlinOptions { + jvmTarget = '1.8' + } + + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "dev.dart.flutter_wasm_example" + minSdkVersion 16 + targetSdkVersion 30 + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/flutter_wasm/example/android/app/src/debug/AndroidManifest.xml b/flutter_wasm/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..57969cf --- /dev/null +++ b/flutter_wasm/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter_wasm/example/android/app/src/main/AndroidManifest.xml b/flutter_wasm/example/android/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a302f7b --- /dev/null +++ b/flutter_wasm/example/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + diff --git a/flutter_wasm/example/android/app/src/main/kotlin/com/example/flutter_wasm_example/MainActivity.kt b/flutter_wasm/example/android/app/src/main/kotlin/com/example/flutter_wasm_example/MainActivity.kt new file mode 100644 index 0000000..9dbea80 --- /dev/null +++ b/flutter_wasm/example/android/app/src/main/kotlin/com/example/flutter_wasm_example/MainActivity.kt @@ -0,0 +1,6 @@ +package dev.dart.flutter_wasm_example + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() { +} diff --git a/flutter_wasm/example/android/app/src/main/res/drawable-v21/launch_background.xml b/flutter_wasm/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/flutter_wasm/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter_wasm/example/android/app/src/main/res/drawable/launch_background.xml b/flutter_wasm/example/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 0000000..304732f --- /dev/null +++ b/flutter_wasm/example/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/flutter_wasm/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/flutter_wasm/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..db77bb4b7b0906d62b1847e87f15cdcacf6a4f29 GIT binary patch literal 544 zcmeAS@N?(olHy`uVBq!ia0vp^9w5xY3?!3`olAj~WQl7;NpOBzNqJ&XDuZK6ep0G} zXKrG8YEWuoN@d~6R2!h8bpbvhu0Wd6uZuB!w&u2PAxD2eNXD>P5D~Wn-+_Wa#27Xc zC?Zj|6r#X(-D3u$NCt}(Ms06KgJ4FxJVv{GM)!I~&n8Bnc94O7-Hd)cjDZswgC;Qs zO=b+9!WcT8F?0rF7!Uys2bs@gozCP?z~o%U|N3vA*22NaGQG zlg@K`O_XuxvZ&Ks^m&R!`&1=spLvfx7oGDKDwpwW`#iqdw@AL`7MR}m`rwr|mZgU`8P7SBkL78fFf!WnuYWm$5Z0 zNXhDbCv&49sM544K|?c)WrFfiZvCi9h0O)B3Pgg&ebxsLQ05GG~ AQ2+n{ literal 0 HcmV?d00001 diff --git a/flutter_wasm/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/flutter_wasm/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..17987b79bb8a35cc66c3c1fd44f5a5526c1b78be GIT binary patch literal 442 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA3?vioaBc-sk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xx&nMcT!A!W`0S9QKQy;}1Cl^CgaH=;G9cpY;r$Q>i*pfB zP2drbID<_#qf;rPZx^FqH)F_D#*k@@q03KywUtLX8Ua?`H+NMzkczFPK3lFz@i_kW%1NOn0|D2I9n9wzH8m|-tHjsw|9>@K=iMBhxvkv6m8Y-l zytQ?X=U+MF$@3 zt`~i=@j|6y)RWMK--}M|=T`o&^Ni>IoWKHEbBXz7?A@mgWoL>!*SXo`SZH-*HSdS+ yn*9;$7;m`l>wYBC5bq;=U}IMqLzqbYCidGC!)_gkIk_C@Uy!y&wkt5C($~2D>~)O*cj@FGjOCM)M>_ixfudOh)?xMu#Fs z#}Y=@YDTwOM)x{K_j*Q;dPdJ?Mz0n|pLRx{4n|)f>SXlmV)XB04CrSJn#dS5nK2lM zrZ9#~WelCp7&e13Y$jvaEXHskn$2V!!DN-nWS__6T*l;H&Fopn?A6HZ-6WRLFP=R` zqG+CE#d4|IbyAI+rJJ`&x9*T`+a=p|0O(+s{UBcyZdkhj=yS1>AirP+0R;mf2uMgM zC}@~JfByORAh4SyRgi&!(cja>F(l*O+nd+@4m$|6K6KDn_&uvCpV23&>G9HJp{xgg zoq1^2_p9@|WEo z*X_Uko@K)qYYv~>43eQGMdbiGbo>E~Q& zrYBH{QP^@Sti!`2)uG{irBBq@y*$B zi#&(U-*=fp74j)RyIw49+0MRPMRU)+a2r*PJ$L5roHt2$UjExCTZSbq%V!HeS7J$N zdG@vOZB4v_lF7Plrx+hxo7(fCV&}fHq)$ literal 0 HcmV?d00001 diff --git a/flutter_wasm/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/flutter_wasm/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..d5f1c8d34e7a88e3f88bea192c3a370d44689c3c GIT binary patch literal 1031 zcmeAS@N?(olHy`uVBq!ia0vp^6F``Q8Ax83A=Cw=BuiW)N`mv#O3D+9QW+dm@{>{( zJaZG%Q-e|yQz{EjrrIztFa`(sgt!6~Yi|1%a`XoT0ojZ}lNrNjb9xjc(B0U1_% zz5^97Xt*%oq$rQy4?0GKNfJ44uvxI)gC`h-NZ|&0-7(qS@?b!5r36oQ}zyZrNO3 zMO=Or+<~>+A&uN&E!^Sl+>xE!QC-|oJv`ApDhqC^EWD|@=#J`=d#Xzxs4ah}w&Jnc z$|q_opQ^2TrnVZ0o~wh<3t%W&flvYGe#$xqda2bR_R zvPYgMcHgjZ5nSA^lJr%;<&0do;O^tDDh~=pIxA#coaCY>&N%M2^tq^U%3DB@ynvKo}b?yu-bFc-u0JHzced$sg7S3zqI(2 z#Km{dPr7I=pQ5>FuK#)QwK?Y`E`B?nP+}U)I#c1+FM*1kNvWG|a(TpksZQ3B@sD~b zpQ2)*V*TdwjFOtHvV|;OsiDqHi=6%)o4b!)x$)%9pGTsE z-JL={-Ffv+T87W(Xpooq<`r*VzWQcgBN$$`u}f>-ZQI1BB8ykN*=e4rIsJx9>z}*o zo~|9I;xof literal 0 HcmV?d00001 diff --git a/flutter_wasm/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/flutter_wasm/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000000000000000000000000000000000000..4d6372eebdb28e45604e46eeda8dd24651419bc0 GIT binary patch literal 1443 zcmb`G{WsKk6vsdJTdFg%tJav9_E4vzrOaqkWF|A724Nly!y+?N9`YV6wZ}5(X(D_N(?!*n3`|_r0Hc?=PQw&*vnU?QTFY zB_MsH|!j$PP;I}?dppoE_gA(4uc!jV&0!l7_;&p2^pxNo>PEcNJv za5_RT$o2Mf!<+r?&EbHH6nMoTsDOa;mN(wv8RNsHpG)`^ymG-S5By8=l9iVXzN_eG%Xg2@Xeq76tTZ*dGh~Lo9vl;Zfs+W#BydUw zCkZ$o1LqWQO$FC9aKlLl*7x9^0q%0}$OMlp@Kk_jHXOjofdePND+j!A{q!8~Jn+s3 z?~~w@4?egS02}8NuulUA=L~QQfm;MzCGd)XhiftT;+zFO&JVyp2mBww?;QByS_1w! zrQlx%{^cMj0|Bo1FjwY@Q8?Hx0cIPF*@-ZRFpPc#bBw{5@tD(5%sClzIfl8WU~V#u zm5Q;_F!wa$BSpqhN>W@2De?TKWR*!ujY;Yylk_X5#~V!L*Gw~;$%4Q8~Mad z@`-kG?yb$a9cHIApZDVZ^U6Xkp<*4rU82O7%}0jjHlK{id@?-wpN*fCHXyXh(bLt* zPc}H-x0e4E&nQ>y%B-(EL=9}RyC%MyX=upHuFhAk&MLbsF0LP-q`XnH78@fT+pKPW zu72MW`|?8ht^tz$iC}ZwLp4tB;Q49K!QCF3@!iB1qOI=?w z7In!}F~ij(18UYUjnbmC!qKhPo%24?8U1x{7o(+?^Zu0Hx81|FuS?bJ0jgBhEMzf< zCgUq7r2OCB(`XkKcN-TL>u5y#dD6D!)5W?`O5)V^>jb)P)GBdy%t$uUMpf$SNV31$ zb||OojAbvMP?T@$h_ZiFLFVHDmbyMhJF|-_)HX3%m=CDI+ID$0^C>kzxprBW)hw(v zr!Gmda);ICoQyhV_oP5+C%?jcG8v+D@9f?Dk*!BxY}dazmrT@64UrP3hlslANK)bq z$67n83eh}OeW&SV@HG95P|bjfqJ7gw$e+`Hxo!4cx`jdK1bJ>YDSpGKLPZ^1cv$ek zIB?0S<#tX?SJCLWdMd{-ME?$hc7A$zBOdIJ)4!KcAwb=VMov)nK;9z>x~rfT1>dS+ zZ6#`2v@`jgbqq)P22H)Tx2CpmM^o1$B+xT6`(v%5xJ(?j#>Q$+rx_R|7TzDZe{J6q zG1*EcU%tE?!kO%^M;3aM6JN*LAKUVb^xz8-Pxo#jR5(-KBeLJvA@-gxNHx0M-ZJLl z;#JwQoh~9V?`UVo#}{6ka@II>++D@%KqGpMdlQ}?9E*wFcf5(#XQnP$Dk5~%iX^>f z%$y;?M0BLp{O3a(-4A?ewryHrrD%cx#Q^%KY1H zNre$ve+vceSLZcNY4U(RBX&)oZn*Py()h)XkE?PL$!bNb{N5FVI2Y%LKEm%yvpyTP z(1P?z~7YxD~Rf<(a@_y` literal 0 HcmV?d00001 diff --git a/flutter_wasm/example/android/app/src/main/res/values-night/styles.xml b/flutter_wasm/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..449a9f9 --- /dev/null +++ b/flutter_wasm/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter_wasm/example/android/app/src/main/res/values/styles.xml b/flutter_wasm/example/android/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..d74aa35 --- /dev/null +++ b/flutter_wasm/example/android/app/src/main/res/values/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/flutter_wasm/example/android/app/src/profile/AndroidManifest.xml b/flutter_wasm/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..57969cf --- /dev/null +++ b/flutter_wasm/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/flutter_wasm/example/android/build.gradle b/flutter_wasm/example/android/build.gradle new file mode 100644 index 0000000..ed45c65 --- /dev/null +++ b/flutter_wasm/example/android/build.gradle @@ -0,0 +1,29 @@ +buildscript { + ext.kotlin_version = '1.3.50' + repositories { + google() + mavenCentral() + } + + dependencies { + classpath 'com.android.tools.build:gradle:4.1.0' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/flutter_wasm/example/android/gradle.properties b/flutter_wasm/example/android/gradle.properties new file mode 100644 index 0000000..94adc3a --- /dev/null +++ b/flutter_wasm/example/android/gradle.properties @@ -0,0 +1,3 @@ +org.gradle.jvmargs=-Xmx1536M +android.useAndroidX=true +android.enableJetifier=true diff --git a/flutter_wasm/example/android/gradle/wrapper/gradle-wrapper.properties b/flutter_wasm/example/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..bc6a58a --- /dev/null +++ b/flutter_wasm/example/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/flutter_wasm/example/android/settings.gradle b/flutter_wasm/example/android/settings.gradle new file mode 100644 index 0000000..44e62bc --- /dev/null +++ b/flutter_wasm/example/android/settings.gradle @@ -0,0 +1,11 @@ +include ':app' + +def localPropertiesFile = new File(rootProject.projectDir, "local.properties") +def properties = new Properties() + +assert localPropertiesFile.exists() +localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + +def flutterSdkPath = properties.getProperty("flutter.sdk") +assert flutterSdkPath != null, "flutter.sdk not set in local.properties" +apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" diff --git a/flutter_wasm/example/lib/main.dart b/flutter_wasm/example/lib/main.dart new file mode 100644 index 0000000..c3760a9 --- /dev/null +++ b/flutter_wasm/example/lib/main.dart @@ -0,0 +1,52 @@ +import 'package:flutter/material.dart'; +import 'dart:async'; +import 'dart:typed_data'; + +import 'package:flutter/services.dart'; +import 'package:flutter_wasm/flutter_wasm.dart'; + +// int64_t square(int64_t n) { return n * n; } +final _data = Uint8List.fromList([ + 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x60, // + 0x01, 0x7e, 0x01, 0x7e, 0x03, 0x02, 0x01, 0x00, 0x04, 0x05, 0x01, 0x70, + 0x01, 0x01, 0x01, 0x05, 0x03, 0x01, 0x00, 0x02, 0x06, 0x08, 0x01, 0x7f, + 0x01, 0x41, 0x80, 0x88, 0x04, 0x0b, 0x07, 0x13, 0x02, 0x06, 0x6d, 0x65, + 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x06, 0x73, 0x71, 0x75, 0x61, 0x72, + 0x65, 0x00, 0x00, 0x0a, 0x09, 0x01, 0x07, 0x00, 0x20, 0x00, 0x20, 0x00, + 0x7e, 0x0b, +]); + +final _inst = WasmModule(_data).builder().build(); +final wasmSquare = _inst.lookupFunction('square'); + +void main() { + runApp(const MyApp()); +} + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + @override + void initState() { + super.initState(); + } + + @override + Widget build(BuildContext context) { + return MaterialApp( + home: Scaffold( + appBar: AppBar( + title: const Text('Wasm example app'), + ), + body: Center( + child: Text('12^2 == ${wasmSquare(12)}'), + ), + ), + ); + } +} diff --git a/flutter_wasm/example/pubspec.lock b/flutter_wasm/example/pubspec.lock new file mode 100644 index 0000000..7bf2035 --- /dev/null +++ b/flutter_wasm/example/pubspec.lock @@ -0,0 +1,205 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + args: + dependency: transitive + description: + name: args + url: "https://pub.dartlang.org" + source: hosted + version: "2.3.0" + async: + dependency: transitive + description: + name: async + url: "https://pub.dartlang.org" + source: hosted + version: "2.8.2" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + charcode: + dependency: transitive + description: + name: charcode + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.1" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + collection: + dependency: transitive + description: + name: collection + url: "https://pub.dartlang.org" + source: hosted + version: "1.15.0" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + ffi: + dependency: transitive + description: + name: ffi + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.2" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_wasm: + dependency: "direct main" + description: + path: ".." + relative: true + source: path + version: "0.0.1" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" + matcher: + dependency: transitive + description: + name: matcher + url: "https://pub.dartlang.org" + source: hosted + version: "0.12.11" + meta: + dependency: transitive + description: + name: meta + url: "https://pub.dartlang.org" + source: hosted + version: "1.7.0" + package_config: + dependency: transitive + description: + name: package_config + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.2" + path: + dependency: transitive + description: + name: path + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + url: "https://pub.dartlang.org" + source: hosted + version: "1.8.1" + stack_trace: + dependency: transitive + description: + name: stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "1.10.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + url: "https://pub.dartlang.org" + source: hosted + version: "1.2.0" + test_api: + dependency: transitive + description: + name: test_api + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.3" + typed_data: + dependency: transitive + description: + name: typed_data + url: "https://pub.dartlang.org" + source: hosted + version: "1.3.0" + vector_math: + dependency: transitive + description: + name: vector_math + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + wasm: + dependency: transitive + description: + path: wasm + ref: HEAD + resolved-ref: "544b12bcfd8f2dd360e464d5384a0f63861c6db4" + url: "git@github.com:dart-lang/wasm.git" + source: git + version: "0.2.0-dev" +sdks: + dart: ">=2.15.0-96.0.dev <3.0.0" + flutter: ">=2.5.0" diff --git a/flutter_wasm/example/pubspec.yaml b/flutter_wasm/example/pubspec.yaml new file mode 100644 index 0000000..b057859 --- /dev/null +++ b/flutter_wasm/example/pubspec.yaml @@ -0,0 +1,22 @@ +name: flutter_wasm_example +description: Demonstrates how to use the flutter_wasm plugin. +publish_to: 'none' + +environment: + sdk: ">=2.15.0-96.0.dev <3.0.0" + +dependencies: + flutter: + sdk: flutter + flutter_wasm: + path: ../ + cupertino_icons: ^1.0.2 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^1.0.0 + +flutter: + uses-material-design: true + diff --git a/flutter_wasm/example/test/widget_test.dart b/flutter_wasm/example/test/widget_test.dart new file mode 100644 index 0000000..1ceccef --- /dev/null +++ b/flutter_wasm/example/test/widget_test.dart @@ -0,0 +1,27 @@ +// This is a basic Flutter widget test. +// +// To perform an interaction with a widget in your test, use the WidgetTester +// utility that Flutter provides. For example, you can send tap and scroll +// gestures. You can also use WidgetTester to find child widgets in the widget +// tree, read text, and verify that the values of widget properties are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:flutter_wasm_example/main.dart'; + +void main() { + testWidgets('Verify Platform version', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(const MyApp()); + + // Verify that platform version is retrieved. + expect( + find.byWidgetPredicate( + (Widget widget) => widget is Text && + widget.data!.startsWith('Running on:'), + ), + findsOneWidget, + ); + }); +} diff --git a/flutter_wasm/lib/flutter_wasm.dart b/flutter_wasm/lib/flutter_wasm.dart new file mode 100644 index 0000000..d33320a --- /dev/null +++ b/flutter_wasm/lib/flutter_wasm.dart @@ -0,0 +1 @@ +export 'package:wasm/wasm.dart'; diff --git a/flutter_wasm/pubspec.yaml b/flutter_wasm/pubspec.yaml new file mode 100644 index 0000000..3f08922 --- /dev/null +++ b/flutter_wasm/pubspec.yaml @@ -0,0 +1,28 @@ +name: flutter_wasm +description: Flutter support for package:wasm +version: 0.0.1 +homepage: + +environment: + sdk: ">=2.15.0-96.0.dev <3.0.0" + flutter: ">=2.5.0" + +dependencies: + flutter: + sdk: flutter + wasm: + git: + url: git@github.com:dart-lang/wasm.git + path: wasm + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^1.0.0 + +flutter: + plugin: + platforms: + android: + package: dev.dart.flutter_wasm + pluginClass: FlutterWasmPlugin diff --git a/flutter_wasm/test/flutter_wasm_test.dart b/flutter_wasm/test/flutter_wasm_test.dart new file mode 100644 index 0000000..e7f571a --- /dev/null +++ b/flutter_wasm/test/flutter_wasm_test.dart @@ -0,0 +1,23 @@ +import 'package:flutter/services.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:flutter_wasm/flutter_wasm.dart'; + +void main() { + const MethodChannel channel = MethodChannel('flutter_wasm'); + + TestWidgetsFlutterBinding.ensureInitialized(); + + setUp(() { + channel.setMockMethodCallHandler((MethodCall methodCall) async { + return '42'; + }); + }); + + tearDown(() { + channel.setMockMethodCallHandler(null); + }); + + test('getPlatformVersion', () async { + expect(await FlutterWasm.platformVersion, '42'); + }); +} From 468d50a80bdabc5b5902b283db7768ef450f46b7 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Tue, 26 Oct 2021 13:26:02 -0700 Subject: [PATCH 02/23] Clean up --- README.md | 2 +- flutter_wasm/CHANGELOG.md | 2 +- flutter_wasm/LICENSE | 1 - flutter_wasm/README.md | 27 ++++++++----- flutter_wasm/analysis_options.yaml | 4 -- flutter_wasm/android/build.gradle | 8 ++-- .../dart/flutter_wasm/FlutterWasmPlugin.kt | 4 ++ flutter_wasm/example/analysis_options.yaml | 29 -------------- .../flutter_wasm_example/MainActivity.kt | 4 ++ flutter_wasm/example/pubspec.lock | 2 +- flutter_wasm/example/pubspec.yaml | 4 ++ flutter_wasm/example/test/widget_test.dart | 15 +++----- flutter_wasm/lib/flutter_wasm.dart | 4 ++ flutter_wasm/test/flutter_wasm_test.dart | 38 ++++++++++++------- 14 files changed, 71 insertions(+), 73 deletions(-) delete mode 100644 flutter_wasm/LICENSE delete mode 100644 flutter_wasm/analysis_options.yaml delete mode 100644 flutter_wasm/example/analysis_options.yaml diff --git a/README.md b/README.md index 57224a6..ac26073 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,6 @@ These packages provide utilities for loading and running WASM modules. Runs WASM modules in Dart native. -## flutter_wasm (coming soon) +## [flutter_wasm](https://github.com/dart-lang/wasm/blob/main/flutter_wasm/README.md) Runs WASM modules in Flutter. diff --git a/flutter_wasm/CHANGELOG.md b/flutter_wasm/CHANGELOG.md index 41cc7d8..e52cf09 100644 --- a/flutter_wasm/CHANGELOG.md +++ b/flutter_wasm/CHANGELOG.md @@ -1,3 +1,3 @@ ## 0.0.1 -* TODO: Describe initial release. +- Initial version diff --git a/flutter_wasm/LICENSE b/flutter_wasm/LICENSE deleted file mode 100644 index ba75c69..0000000 --- a/flutter_wasm/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/flutter_wasm/README.md b/flutter_wasm/README.md index 8d87c4b..3a2be10 100644 --- a/flutter_wasm/README.md +++ b/flutter_wasm/README.md @@ -1,15 +1,22 @@ -# flutter_wasm +Provides utilities for loading and running WASM modules in Flutter apps. +Currently only Android is supported. -A new flutter plugin project. +This is a wrapper around [package:wasm](https://github.com/dart-lang/wasm/blob/main/wasm/README.md). +See that package for more information and documentation. The basic +usage is mostly the same as in that package. The main thing this plugin does is +run `wasm:setup` for your target device during app compilation. -## Getting Started +## Usage -This project is a starting point for a Flutter -[plug-in package](https://flutter.dev/developing-packages/), -a specialized package that includes platform-specific implementation code for -Android and/or iOS. +1. Add a dependency to *both* package `wasm` and `flutter_wasm` in +`pubspec.yaml` and run `flutter pub get`. [#52](https://github.com/dart-lang/wasm/issues/52) -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +1. Next run `flutter run wasm:setup` to build the Wasmer runtime for your host +machine. This does not build the runtime for your target device. It will take a +few minutes. +1. Load your wasm code in your app. See the [example app](https://github.com/dart-lang/wasm/blob/main/flutter_wasm/example/lib/main.dart). + +1. Run your app using `flutter run`. If you see an error at runtime saying +"libwasmer.so not found", just try rebuiling. The first build sometimes fails. +[#51](https://github.com/dart-lang/wasm/issues/51) diff --git a/flutter_wasm/analysis_options.yaml b/flutter_wasm/analysis_options.yaml deleted file mode 100644 index a5744c1..0000000 --- a/flutter_wasm/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/flutter_wasm/android/build.gradle b/flutter_wasm/android/build.gradle index c1ffb79..d4b5aed 100644 --- a/flutter_wasm/android/build.gradle +++ b/flutter_wasm/android/build.gradle @@ -1,3 +1,7 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + group 'dev.dart.flutter_wasm' version '1.0-SNAPSHOT' @@ -75,9 +79,7 @@ android { ['arm64-v8a', 'aarch64-linux-android', 'aarch64-linux-android', 'aarch64-linux-android', 'arch-arm64'], ['x86', 'i686-linux-android', 'i686-linux-android', 'i686-linux-android', 'arch-x86'], - // TODO: Enable these when they're supported by Wasmer. See: - // https://github.com/wasmerio/wasmer/issues/1652 - // https://github.com/wasmerio/wasmer/issues/2099 + // TODO(#53,#54): Enable these when they're supported by Wasmer. // ['armeabi-v7a', 'armv7a-linux-androideabi', 'arm-linux-androideabi', 'armv7-linux-androideabi', 'arch-arm'], // ['x86_64', 'x86_64-linux-android', 'x86_64-linux-android', 'x86_64-linux-android', 'arch-x86_64'], ] diff --git a/flutter_wasm/android/src/main/kotlin/dev/dart/flutter_wasm/FlutterWasmPlugin.kt b/flutter_wasm/android/src/main/kotlin/dev/dart/flutter_wasm/FlutterWasmPlugin.kt index 1e8f38f..6795d5a 100644 --- a/flutter_wasm/android/src/main/kotlin/dev/dart/flutter_wasm/FlutterWasmPlugin.kt +++ b/flutter_wasm/android/src/main/kotlin/dev/dart/flutter_wasm/FlutterWasmPlugin.kt @@ -1,3 +1,7 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + package dev.dart.flutter_wasm import androidx.annotation.NonNull diff --git a/flutter_wasm/example/analysis_options.yaml b/flutter_wasm/example/analysis_options.yaml deleted file mode 100644 index 61b6c4d..0000000 --- a/flutter_wasm/example/analysis_options.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml - -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/flutter_wasm/example/android/app/src/main/kotlin/com/example/flutter_wasm_example/MainActivity.kt b/flutter_wasm/example/android/app/src/main/kotlin/com/example/flutter_wasm_example/MainActivity.kt index 9dbea80..1dac50d 100644 --- a/flutter_wasm/example/android/app/src/main/kotlin/com/example/flutter_wasm_example/MainActivity.kt +++ b/flutter_wasm/example/android/app/src/main/kotlin/com/example/flutter_wasm_example/MainActivity.kt @@ -1,3 +1,7 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + package dev.dart.flutter_wasm_example import io.flutter.embedding.android.FlutterActivity diff --git a/flutter_wasm/example/pubspec.lock b/flutter_wasm/example/pubspec.lock index 7bf2035..ff74cf3 100644 --- a/flutter_wasm/example/pubspec.lock +++ b/flutter_wasm/example/pubspec.lock @@ -192,7 +192,7 @@ packages: source: hosted version: "2.1.0" wasm: - dependency: transitive + dependency: "direct main" description: path: wasm ref: HEAD diff --git a/flutter_wasm/example/pubspec.yaml b/flutter_wasm/example/pubspec.yaml index b057859..2eff394 100644 --- a/flutter_wasm/example/pubspec.yaml +++ b/flutter_wasm/example/pubspec.yaml @@ -10,6 +10,10 @@ dependencies: sdk: flutter flutter_wasm: path: ../ + wasm: + git: + url: git@github.com:dart-lang/wasm.git + path: wasm cupertino_icons: ^1.0.2 dev_dependencies: diff --git a/flutter_wasm/example/test/widget_test.dart b/flutter_wasm/example/test/widget_test.dart index 1ceccef..ff3e0f8 100644 --- a/flutter_wasm/example/test/widget_test.dart +++ b/flutter_wasm/example/test/widget_test.dart @@ -1,9 +1,6 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -11,15 +8,15 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_wasm_example/main.dart'; void main() { - testWidgets('Verify Platform version', (WidgetTester tester) async { + testWidgets('Verify wasm runs', (WidgetTester tester) async { // Build our app and trigger a frame. await tester.pumpWidget(const MyApp()); - // Verify that platform version is retrieved. + // Verify that the wasm code runs. expect( find.byWidgetPredicate( (Widget widget) => widget is Text && - widget.data!.startsWith('Running on:'), + widget.data!.startsWith('12^2 == 144'), ), findsOneWidget, ); diff --git a/flutter_wasm/lib/flutter_wasm.dart b/flutter_wasm/lib/flutter_wasm.dart index d33320a..c48ee40 100644 --- a/flutter_wasm/lib/flutter_wasm.dart +++ b/flutter_wasm/lib/flutter_wasm.dart @@ -1 +1,5 @@ +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + export 'package:wasm/wasm.dart'; diff --git a/flutter_wasm/test/flutter_wasm_test.dart b/flutter_wasm/test/flutter_wasm_test.dart index e7f571a..13c2df9 100644 --- a/flutter_wasm/test/flutter_wasm_test.dart +++ b/flutter_wasm/test/flutter_wasm_test.dart @@ -1,23 +1,33 @@ -import 'package:flutter/services.dart'; +// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test that we can load a wasm module, find a function, and call it. Most of +// the wasm tests are found in package:wasm. This plugin just exports that code. +import 'dart:typed_data'; + import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_wasm/flutter_wasm.dart'; void main() { - const MethodChannel channel = MethodChannel('flutter_wasm'); + test('basics', () { + // int64_t square(int64_t n) { return n * n; } + var data = Uint8List.fromList([ + 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x60, // + 0x01, 0x7e, 0x01, 0x7e, 0x03, 0x02, 0x01, 0x00, 0x04, 0x05, 0x01, 0x70, + 0x01, 0x01, 0x01, 0x05, 0x03, 0x01, 0x00, 0x02, 0x06, 0x08, 0x01, 0x7f, + 0x01, 0x41, 0x80, 0x88, 0x04, 0x0b, 0x07, 0x13, 0x02, 0x06, 0x6d, 0x65, + 0x6d, 0x6f, 0x72, 0x79, 0x02, 0x00, 0x06, 0x73, 0x71, 0x75, 0x61, 0x72, + 0x65, 0x00, 0x00, 0x0a, 0x09, 0x01, 0x07, 0x00, 0x20, 0x00, 0x20, 0x00, + 0x7e, 0x0b, + ]); - TestWidgetsFlutterBinding.ensureInitialized(); + var inst = WasmModule(data).builder().build(); + var fn = inst.lookupFunction('square'); + var n = fn(1234) as int; - setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) async { - return '42'; - }); - }); - - tearDown(() { - channel.setMockMethodCallHandler(null); - }); + expect(n, 1234 * 1234); - test('getPlatformVersion', () async { - expect(await FlutterWasm.platformVersion, '42'); + expect(inst.lookupFunction('not_a_function'), isNull); }); } From cbeccd8abab1c40f0cad21e117d80cb3e8c8b664 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 27 Oct 2021 11:46:18 -0700 Subject: [PATCH 03/23] Add analysis github action for flutter_wasm --- .github/workflows/test-package.yml | 27 ++++++++++++++++++++++ flutter_wasm/example/lib/main.dart | 8 +++---- flutter_wasm/example/pubspec.yaml | 4 ++-- flutter_wasm/example/test/widget_test.dart | 4 ++-- flutter_wasm/pubspec.yaml | 7 +++--- 5 files changed, 38 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index a48cd8b..b614274 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -82,3 +82,30 @@ jobs: - run: dart pub upgrade - run: dart run wasm:setup - run: dart test + + flutter_analyze: + runs-on: ubuntu-latest + strategy: + matrix: + sdk: [ dev ] + defaults: + run: + working-directory: flutter_wasm + steps: + - uses: actions/checkout@v2.3.4 + - uses: dart-lang/setup-dart@v1.0 + with: + sdk: ${{ matrix.sdk }} + - uses: actions/cache@v2.1.6 + with: + path: | + ~/.pub-cache/hosted/ + .dart_tool/ + key: ${{ runner.os }}-${{ matrix.sdk }} + - id: install + run: dart pub upgrade + - run: dart format --output=none --set-exit-if-changed . + if: always() && steps.install.outcome == 'success' + - run: dart analyze --fatal-infos + if: always() && steps.install.outcome == 'success' + diff --git a/flutter_wasm/example/lib/main.dart b/flutter_wasm/example/lib/main.dart index c3760a9..d7f2237 100644 --- a/flutter_wasm/example/lib/main.dart +++ b/flutter_wasm/example/lib/main.dart @@ -1,8 +1,6 @@ -import 'package:flutter/material.dart'; -import 'dart:async'; import 'dart:typed_data'; -import 'package:flutter/services.dart'; +import 'package:flutter/material.dart'; import 'package:flutter_wasm/flutter_wasm.dart'; // int64_t square(int64_t n) { return n * n; } @@ -17,7 +15,7 @@ final _data = Uint8List.fromList([ ]); final _inst = WasmModule(_data).builder().build(); -final wasmSquare = _inst.lookupFunction('square'); +final _wasmSquare = _inst.lookupFunction('square'); void main() { runApp(const MyApp()); @@ -44,7 +42,7 @@ class _MyAppState extends State { title: const Text('Wasm example app'), ), body: Center( - child: Text('12^2 == ${wasmSquare(12)}'), + child: Text('12^2 == ${_wasmSquare(12)}'), ), ), ); diff --git a/flutter_wasm/example/pubspec.yaml b/flutter_wasm/example/pubspec.yaml index 2eff394..709959e 100644 --- a/flutter_wasm/example/pubspec.yaml +++ b/flutter_wasm/example/pubspec.yaml @@ -6,6 +6,7 @@ environment: sdk: ">=2.15.0-96.0.dev <3.0.0" dependencies: + cupertino_icons: ^1.0.2 flutter: sdk: flutter flutter_wasm: @@ -14,12 +15,11 @@ dependencies: git: url: git@github.com:dart-lang/wasm.git path: wasm - cupertino_icons: ^1.0.2 dev_dependencies: + flutter_lints: ^1.0.0 flutter_test: sdk: flutter - flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/flutter_wasm/example/test/widget_test.dart b/flutter_wasm/example/test/widget_test.dart index ff3e0f8..8e7c033 100644 --- a/flutter_wasm/example/test/widget_test.dart +++ b/flutter_wasm/example/test/widget_test.dart @@ -15,8 +15,8 @@ void main() { // Verify that the wasm code runs. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data!.startsWith('12^2 == 144'), + (Widget widget) => + widget is Text && widget.data!.startsWith('12^2 == 144'), ), findsOneWidget, ); diff --git a/flutter_wasm/pubspec.yaml b/flutter_wasm/pubspec.yaml index 3f08922..b11f722 100644 --- a/flutter_wasm/pubspec.yaml +++ b/flutter_wasm/pubspec.yaml @@ -1,7 +1,8 @@ name: flutter_wasm -description: Flutter support for package:wasm version: 0.0.1 -homepage: +description: Flutter support for package:wasm +repository: https://github.com/dart-lang/wasm +publish_to: none environment: sdk: ">=2.15.0-96.0.dev <3.0.0" @@ -16,9 +17,9 @@ dependencies: path: wasm dev_dependencies: + flutter_lints: ^1.0.0 flutter_test: sdk: flutter - flutter_lints: ^1.0.0 flutter: plugin: From c541b8b24e1033e7035ee411c9c6ce2b0b2d2ddf Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 27 Oct 2021 11:58:23 -0700 Subject: [PATCH 04/23] Add flutter tests, and use flutter for flutter_analyze --- .github/workflows/test-package.yml | 52 +++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index b614274..ab4757b 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -92,16 +92,13 @@ jobs: run: working-directory: flutter_wasm steps: - - uses: actions/checkout@v2.3.4 - - uses: dart-lang/setup-dart@v1.0 + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 with: - sdk: ${{ matrix.sdk }} - - uses: actions/cache@v2.1.6 + java-version: '12.x' + - uses: subosito/flutter-action@v1.5.3 with: - path: | - ~/.pub-cache/hosted/ - .dart_tool/ - key: ${{ runner.os }}-${{ matrix.sdk }} + flutter-version: '2.5.0' - id: install run: dart pub upgrade - run: dart format --output=none --set-exit-if-changed . @@ -109,3 +106,42 @@ jobs: - run: dart analyze --fatal-infos if: always() && steps.install.outcome == 'success' + flutter_test: + runs-on: ubuntu-latest + strategy: + matrix: + sdk: [ dev ] + defaults: + run: + working-directory: flutter_wasm + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: '12.x' + - uses: subosito/flutter-action@v1.5.3 + with: + flutter-version: '2.5.0' + - run: flutter pub get + - run: flutter test + + flutter_example_test: + runs-on: ubuntu-latest + strategy: + matrix: + sdk: [ dev ] + defaults: + run: + working-directory: flutter_wasm/example + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v1 + with: + java-version: '12.x' + - uses: subosito/flutter-action@v1.5.3 + with: + flutter-version: '2.5.0' + - run: flutter pub get + - run: flutter test + - run: flutter build apk + - run: flutter build appbundle From 50a8f4e42debdb9281e5956c34193a41f0a671b3 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 27 Oct 2021 12:13:38 -0700 Subject: [PATCH 05/23] Loosen Dart SDK requirements --- flutter_wasm/example/pubspec.yaml | 3 ++- flutter_wasm/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/flutter_wasm/example/pubspec.yaml b/flutter_wasm/example/pubspec.yaml index 709959e..082d9d1 100644 --- a/flutter_wasm/example/pubspec.yaml +++ b/flutter_wasm/example/pubspec.yaml @@ -3,7 +3,8 @@ description: Demonstrates how to use the flutter_wasm plugin. publish_to: 'none' environment: - sdk: ">=2.15.0-96.0.dev <3.0.0" + sdk: '>=2.12.0 <3.0.0' + flutter: ">=2.5.0" dependencies: cupertino_icons: ^1.0.2 diff --git a/flutter_wasm/pubspec.yaml b/flutter_wasm/pubspec.yaml index b11f722..955a30b 100644 --- a/flutter_wasm/pubspec.yaml +++ b/flutter_wasm/pubspec.yaml @@ -5,7 +5,7 @@ repository: https://github.com/dart-lang/wasm publish_to: none environment: - sdk: ">=2.15.0-96.0.dev <3.0.0" + sdk: '>=2.12.0 <3.0.0' flutter: ">=2.5.0" dependencies: From c206b6c1f1516ca8e9d95ee6a0b9388bb113ae7e Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 27 Oct 2021 12:31:07 -0700 Subject: [PATCH 06/23] Comments --- .github/workflows/test-package.yml | 9 --------- flutter_wasm/example/pubspec.yaml | 2 +- flutter_wasm/pubspec.yaml | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index ab4757b..64e48f9 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -85,9 +85,6 @@ jobs: flutter_analyze: runs-on: ubuntu-latest - strategy: - matrix: - sdk: [ dev ] defaults: run: working-directory: flutter_wasm @@ -108,9 +105,6 @@ jobs: flutter_test: runs-on: ubuntu-latest - strategy: - matrix: - sdk: [ dev ] defaults: run: working-directory: flutter_wasm @@ -127,9 +121,6 @@ jobs: flutter_example_test: runs-on: ubuntu-latest - strategy: - matrix: - sdk: [ dev ] defaults: run: working-directory: flutter_wasm/example diff --git a/flutter_wasm/example/pubspec.yaml b/flutter_wasm/example/pubspec.yaml index 082d9d1..740421f 100644 --- a/flutter_wasm/example/pubspec.yaml +++ b/flutter_wasm/example/pubspec.yaml @@ -3,7 +3,7 @@ description: Demonstrates how to use the flutter_wasm plugin. publish_to: 'none' environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.14.0 <3.0.0' flutter: ">=2.5.0" dependencies: diff --git a/flutter_wasm/pubspec.yaml b/flutter_wasm/pubspec.yaml index 955a30b..af1d86b 100644 --- a/flutter_wasm/pubspec.yaml +++ b/flutter_wasm/pubspec.yaml @@ -5,7 +5,7 @@ repository: https://github.com/dart-lang/wasm publish_to: none environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.14.0 <3.0.0' flutter: ">=2.5.0" dependencies: From de811dbbc196668459244898fe223c18fd4da65f Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 27 Oct 2021 14:02:41 -0700 Subject: [PATCH 07/23] Switch from SSH to HTTPS git deps` --- flutter_wasm/example/pubspec.yaml | 2 +- flutter_wasm/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flutter_wasm/example/pubspec.yaml b/flutter_wasm/example/pubspec.yaml index 740421f..49c90dd 100644 --- a/flutter_wasm/example/pubspec.yaml +++ b/flutter_wasm/example/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: path: ../ wasm: git: - url: git@github.com:dart-lang/wasm.git + url: https://github.com/dart-lang/wasm.git path: wasm dev_dependencies: diff --git a/flutter_wasm/pubspec.yaml b/flutter_wasm/pubspec.yaml index af1d86b..6214cfe 100644 --- a/flutter_wasm/pubspec.yaml +++ b/flutter_wasm/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: sdk: flutter wasm: git: - url: git@github.com:dart-lang/wasm.git + url: https://github.com/dart-lang/wasm.git path: wasm dev_dependencies: From bcc772294a136cf146bfe70307b12ea096f93b03 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Wed, 27 Oct 2021 14:21:50 -0700 Subject: [PATCH 08/23] Relative path --- flutter_wasm/example/pubspec.lock | 10 ++++------ flutter_wasm/example/pubspec.yaml | 4 +--- flutter_wasm/pubspec.yaml | 4 +--- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/flutter_wasm/example/pubspec.lock b/flutter_wasm/example/pubspec.lock index ff74cf3..c366628 100644 --- a/flutter_wasm/example/pubspec.lock +++ b/flutter_wasm/example/pubspec.lock @@ -194,12 +194,10 @@ packages: wasm: dependency: "direct main" description: - path: wasm - ref: HEAD - resolved-ref: "544b12bcfd8f2dd360e464d5384a0f63861c6db4" - url: "git@github.com:dart-lang/wasm.git" - source: git + path: "../../wasm" + relative: true + source: path version: "0.2.0-dev" sdks: - dart: ">=2.15.0-96.0.dev <3.0.0" + dart: ">=2.14.0 <3.0.0" flutter: ">=2.5.0" diff --git a/flutter_wasm/example/pubspec.yaml b/flutter_wasm/example/pubspec.yaml index 49c90dd..37f3462 100644 --- a/flutter_wasm/example/pubspec.yaml +++ b/flutter_wasm/example/pubspec.yaml @@ -13,9 +13,7 @@ dependencies: flutter_wasm: path: ../ wasm: - git: - url: https://github.com/dart-lang/wasm.git - path: wasm + path: ../../wasm dev_dependencies: flutter_lints: ^1.0.0 diff --git a/flutter_wasm/pubspec.yaml b/flutter_wasm/pubspec.yaml index 6214cfe..84b4f58 100644 --- a/flutter_wasm/pubspec.yaml +++ b/flutter_wasm/pubspec.yaml @@ -12,9 +12,7 @@ dependencies: flutter: sdk: flutter wasm: - git: - url: https://github.com/dart-lang/wasm.git - path: wasm + path: ../wasm dev_dependencies: flutter_lints: ^1.0.0 From 8326511b2f99b3e139ad19323c0f9f8b737a8236 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 11:04:20 -0700 Subject: [PATCH 09/23] Switch to flutter for analyze action --- .github/workflows/test-package.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 64e48f9..1da85dd 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -97,10 +97,10 @@ jobs: with: flutter-version: '2.5.0' - id: install - run: dart pub upgrade - - run: dart format --output=none --set-exit-if-changed . + run: flutter pub upgrade + - run: flutter format --output=none --set-exit-if-changed . if: always() && steps.install.outcome == 'success' - - run: dart analyze --fatal-infos + - run: flutter analyze --fatal-infos if: always() && steps.install.outcome == 'success' flutter_test: From ab64e3606b7a622ad705fe288b94bb151e458823 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Thu, 28 Oct 2021 12:23:01 -0700 Subject: [PATCH 10/23] also in example! --- .github/workflows/test-package.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 1da85dd..8fff6fc 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -97,7 +97,9 @@ jobs: with: flutter-version: '2.5.0' - id: install - run: flutter pub upgrade + run: | + flutter pub upgrade + flutter pub upgrade --directory example - run: flutter format --output=none --set-exit-if-changed . if: always() && steps.install.outcome == 'success' - run: flutter analyze --fatal-infos From 5a35279a904d00aeaf7fabf5cc49ebc4bee72f0a Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 12:45:08 -0700 Subject: [PATCH 11/23] Run setup script --- .github/workflows/test-package.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 8fff6fc..d6a804d 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -118,7 +118,8 @@ jobs: - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' - - run: flutter pub get + - run: flutter pub upgrade + - run: flutter pub run wasm:setup - run: flutter test flutter_example_test: @@ -134,7 +135,8 @@ jobs: - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' - - run: flutter pub get + - run: flutter pub upgrade + - run: flutter pub run wasm:setup - run: flutter test - run: flutter build apk - run: flutter build appbundle From ccf6b52d1c7d1fcaa2a0d7e7039b1a0048ad38e4 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 12:55:20 -0700 Subject: [PATCH 12/23] Install NDK --- .github/workflows/test-package.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index d6a804d..dee91d0 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -135,6 +135,9 @@ jobs: - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' + - uses: nttld/setup-ndk@v1 + with: + ndk-version: r21e - run: flutter pub upgrade - run: flutter pub run wasm:setup - run: flutter test From 31c71dc2a2518f87ff1eab328761a7f93b111cc0 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 13:07:52 -0700 Subject: [PATCH 13/23] Try the android SDK instead --- .github/workflows/test-package.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index dee91d0..2dc9c73 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -135,9 +135,7 @@ jobs: - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' - - uses: nttld/setup-ndk@v1 - with: - ndk-version: r21e + - uses: android-actions/setup-android@v2 - run: flutter pub upgrade - run: flutter pub run wasm:setup - run: flutter test From f56652e4d33805a855e0333dcdf3a3ea5c432184 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 13:23:20 -0700 Subject: [PATCH 14/23] Both NDK and SDK? --- .github/workflows/test-package.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 2dc9c73..8e534d1 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -132,10 +132,13 @@ jobs: - uses: actions/setup-java@v1 with: java-version: '12.x' + - uses: android-actions/setup-android@v2 + - uses: nttld/setup-ndk@v1 + with: + ndk-version: r21e - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' - - uses: android-actions/setup-android@v2 - run: flutter pub upgrade - run: flutter pub run wasm:setup - run: flutter test From b03424474d0cd6e522674e71afb8cd2480a435d2 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 14:39:25 -0700 Subject: [PATCH 15/23] Trying newer versions of tools --- .github/workflows/test-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 8e534d1..12c94a0 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -132,8 +132,8 @@ jobs: - uses: actions/setup-java@v1 with: java-version: '12.x' - - uses: android-actions/setup-android@v2 - - uses: nttld/setup-ndk@v1 + - uses: android-actions/setup-android@v2.0.2 + - uses: nttld/setup-ndk@v1.0.6 with: ndk-version: r21e - uses: subosito/flutter-action@v1.5.3 From e0d1f01f0257ceb1adb322b9e05aa73c6ab2ba6f Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 14:54:34 -0700 Subject: [PATCH 16/23] Trying a different NDK install action --- .github/workflows/test-package.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 12c94a0..ae54059 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -133,9 +133,16 @@ jobs: with: java-version: '12.x' - uses: android-actions/setup-android@v2.0.2 - - uses: nttld/setup-ndk@v1.0.6 - with: - ndk-version: r21e + - uses: ravinderjangra/android-ndk-toolchain-setup@0.2 + with: + api: '21' + arch: 'x86' + install-location: 'toolchains' + - uses: ravinderjangra/android-ndk-toolchain-setup@0.2 + with: + api: '21' + arch: 'arm64-v8a' + install-location: 'toolchains' - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' From 0d73f377af478f2bae88dbb2efd44c4b693fa2e3 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 14:56:12 -0700 Subject: [PATCH 17/23] Fix yaml --- .github/workflows/test-package.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index ae54059..e849631 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -134,15 +134,15 @@ jobs: java-version: '12.x' - uses: android-actions/setup-android@v2.0.2 - uses: ravinderjangra/android-ndk-toolchain-setup@0.2 - with: - api: '21' - arch: 'x86' - install-location: 'toolchains' + with: + api: '21' + arch: 'x86' + install-location: 'toolchains' - uses: ravinderjangra/android-ndk-toolchain-setup@0.2 - with: - api: '21' - arch: 'arm64-v8a' - install-location: 'toolchains' + with: + api: '21' + arch: 'arm64-v8a' + install-location: 'toolchains' - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' From 980a6c57659ef193fa8ab21a69802ecbc46cb32f Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 15:05:03 -0700 Subject: [PATCH 18/23] Fix arch --- .github/workflows/test-package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index e849631..9fe0ac0 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -141,7 +141,7 @@ jobs: - uses: ravinderjangra/android-ndk-toolchain-setup@0.2 with: api: '21' - arch: 'arm64-v8a' + arch: 'arm64' install-location: 'toolchains' - uses: subosito/flutter-action@v1.5.3 with: From c1662f03f1ad8d2958c2c0ef2ce6df9940c602fb Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 15:09:33 -0700 Subject: [PATCH 19/23] Force install --- .github/workflows/test-package.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 9fe0ac0..46de528 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -138,11 +138,13 @@ jobs: api: '21' arch: 'x86' install-location: 'toolchains' + force: true - uses: ravinderjangra/android-ndk-toolchain-setup@0.2 with: api: '21' arch: 'arm64' install-location: 'toolchains' + force: true - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' From d3fec90090e9d5d5439b7ed72225803a9d312667 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Thu, 28 Oct 2021 15:39:08 -0700 Subject: [PATCH 20/23] Try adding ndkVersion --- flutter_wasm/android/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/flutter_wasm/android/build.gradle b/flutter_wasm/android/build.gradle index d4b5aed..2f89d97 100644 --- a/flutter_wasm/android/build.gradle +++ b/flutter_wasm/android/build.gradle @@ -32,6 +32,7 @@ apply plugin: 'kotlin-android' android { compileSdkVersion 30 + ndkVersion '21.1.6352462' compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 From e62d439009b7fdf067096ec22c2a49b9b98244e8 Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Fri, 29 Oct 2021 11:07:44 -0700 Subject: [PATCH 21/23] Try add-to-path flag --- .github/workflows/test-package.yml | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 46de528..83c74e2 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -133,18 +133,10 @@ jobs: with: java-version: '12.x' - uses: android-actions/setup-android@v2.0.2 - - uses: ravinderjangra/android-ndk-toolchain-setup@0.2 + - uses: nttld/setup-ndk@v1 with: - api: '21' - arch: 'x86' - install-location: 'toolchains' - force: true - - uses: ravinderjangra/android-ndk-toolchain-setup@0.2 - with: - api: '21' - arch: 'arm64' - install-location: 'toolchains' - force: true + ndk-version: r21e + add-to-path: true - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' From 8ba697cd62bc6dd8662d4a746a89a01649157e8a Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Fri, 29 Oct 2021 11:51:36 -0700 Subject: [PATCH 22/23] Add NDK to local.properties --- .github/workflows/test-package.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-package.yml b/.github/workflows/test-package.yml index 83c74e2..7eed76e 100644 --- a/.github/workflows/test-package.yml +++ b/.github/workflows/test-package.yml @@ -137,6 +137,7 @@ jobs: with: ndk-version: r21e add-to-path: true + - run: echo "ndk.dir=$(dirname $(which ndk-build))" >> android/local.properties - uses: subosito/flutter-action@v1.5.3 with: flutter-version: '2.5.0' From 2681e014b571562970ff45cc7c6b76a035e30fcb Mon Sep 17 00:00:00 2001 From: Liam Appelbe Date: Fri, 29 Oct 2021 13:15:46 -0700 Subject: [PATCH 23/23] Remove probably unnecessary flag from gradle file --- flutter_wasm/android/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/flutter_wasm/android/build.gradle b/flutter_wasm/android/build.gradle index 2f89d97..d4b5aed 100644 --- a/flutter_wasm/android/build.gradle +++ b/flutter_wasm/android/build.gradle @@ -32,7 +32,6 @@ apply plugin: 'kotlin-android' android { compileSdkVersion 30 - ndkVersion '21.1.6352462' compileOptions { sourceCompatibility JavaVersion.VERSION_1_8