From fc9242bd22950d9009bcd3c6ada661b2511c33a6 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 20 Nov 2022 18:44:53 +0100 Subject: [PATCH] [flutter] Update WASM compiler flags, README.md for web --- spine-flutter/README.md | 11 +++++- spine-flutter/example/pubspec.lock | 54 ------------------------------ spine-flutter/src/compile-wasm.sh | 16 ++++++++- 3 files changed, 25 insertions(+), 56 deletions(-) diff --git a/spine-flutter/README.md b/spine-flutter/README.md index 96e0bb1ad..aeb1f0a05 100644 --- a/spine-flutter/README.md +++ b/spine-flutter/README.md @@ -20,7 +20,16 @@ spine-flutter works with data exported from Spine 4.1.xx. spine-flutter supports all Spine features, except two-color tinting and the screen blend mode. +## Supported platforms +The spine-flutter runtime works on desktop, mobile and web. Web deployment requires canvaskit, which will add about 2mb of dependencies to your web deployment. You can compile your app for web with Canvaskit like this: + +``` +flutter build web --web-renderer canvaskit +``` + ## Setup +TBD + ## Example The example in this repository is directly depending on the spine-flutter sources. The sources include C++ code ([spine-cpp](../spine-cpp)) which needs to be compiled. To run the example project, install the [Flutter SDK](https://docs.flutter.dev/get-started/install), then run `flutter doctor`` which will instruct you what other dependencies to install. @@ -29,4 +38,4 @@ Once installed, run the `setup.sh` script in the `spine-flutter` folder. This wi You can then open `spine-flutter` in an IDE or editor of your choice that supports Flutter, like [IntelliJ IDEA/Android Studio](https://docs.flutter.dev/get-started/editor?tab=androidstudio) or [Visual Studio Code](https://docs.flutter.dev/get-started/editor?tab=vscode) to inspect and run the example. Alternatively, you can run the example from the [command line](https://docs.flutter.dev/get-started/test-drive?tab=terminal). -> **Note**: spine-flutter does not work on the web. spine-flutter uses spine-cpp underneath, which requires Dart FFI which is currently not supported on the web. \ No newline at end of file + \ No newline at end of file diff --git a/spine-flutter/example/pubspec.lock b/spine-flutter/example/pubspec.lock index 0a6e03b6c..977fddeee 100644 --- a/spine-flutter/example/pubspec.lock +++ b/spine-flutter/example/pubspec.lock @@ -8,13 +8,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.9.0" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" characters: dependency: transitive description: @@ -22,13 +15,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.1" collection: dependency: transitive description: @@ -50,13 +36,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.5" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" ffi: dependency: transitive description: @@ -76,11 +55,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" http: dependency: transitive description: @@ -116,13 +90,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.12" material_color_utilities: dependency: transitive description: @@ -177,20 +144,6 @@ packages: relative: true source: path version: "0.0.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: @@ -205,13 +158,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.1" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.12" typed_data: dependency: transitive description: diff --git a/spine-flutter/src/compile-wasm.sh b/spine-flutter/src/compile-wasm.sh index f9bc23c29..ac09cc282 100755 --- a/spine-flutter/src/compile-wasm.sh +++ b/spine-flutter/src/compile-wasm.sh @@ -1,5 +1,19 @@ #!/bin/sh dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" pushd $dir > /dev/null -emcc -Ispine-cpp/include --closure 1 -O3 -fno-rtti -fno-exceptions -s MAIN_MODULE=1 -s EXPORT_NAME=libspine_flutter -s MODULARIZE=1 spine_flutter.cpp `find spine-cpp/src -type f` -o ../lib/assets/libspine_flutter.js +mkdir -p ../lib/assets/ +emcc \ + -Ispine-cpp/include \ + --closure 1 -O3 -fno-rtti -fno-exceptions \ + -s MAIN_MODULE=1 \ + -s MODULARIZE=1 \ + -s ALLOW_MEMORY_GROWTH=1 \ + -s ALLOW_TABLE_GROWTH \ + -s MALLOC=emmalloc \ + -s ENVIRONMENT=web \ + --no-entry \ + -s EXPORT_NAME=libspine_flutter \ + spine_flutter.cpp `find spine-cpp/src -type f` \ + -o ../lib/assets/libspine_flutter.js + ls -lah ../lib/assets popd \ No newline at end of file