a821aee2d2
As the flutter-gallery package is a reference package for users wishing to use Flutter for their UX with Buildroot, this package must have the correct build options. Indeed, this package currently starts and runs, but only because of the 0001-remove-GetStorage.patch. Through testing, flutter-gallery fails to run during the following scenario: - The xdg-user-dirs package is ported and present. - flutter-gallery depends on xdg-user-dirs. - The 0001-remove-GetStorage.patch file is removed. After extensive testing and comparing the current build arguments against what the meta-flutter repository for Yocto passes to all of the applications that inherit flutter-app, it is clear that handling the dart_plugin_registrant.dart file is missing from the dart arguments in the flutter-gallery build step. As the documentation for the dart_plugin_registrant.dart file is nonexistent in any official documentation. However, there is a comment from an issue on the official dart-lang/sdk page on Github that explains what this file is (and refers to the Dark SDK source code instead of official documentation.) From https://github.com/dart-lang/sdk/issues/52506#issuecomment-1562806787: ``` The dart_plugin_registrant.dart is a very special file. It's neither included in the Dart app nor any dependent packages. Rather it's an artificially created file by the flutter tools. It contains logic to run plugin registration logic. A flutter build will eventually compile the Dart application where it will add <dir>/.dart_tool/flutter_build/dart_plugin_registrant.dart as an extra source file (see here). Additionally it will also inject that uri as a constant into Dart source code via a -Dflutter.dart_plugin_registrant=<uri>. Once the app runs it will access the package:flutter/src/dart_plugin_registrant.dart:dartPluginRegistrantLibrary constant and use it to look up the library object and then invoke the plugin registration logic. ``` Now that what the dart_plugin_registrant.dart does is understood, we need to pass the following to the dart binary during the flutter-gallery build step: -Dflutter.dart_plugin_registrant=file://[...]/dart_plugin_registrant.dart: Injects a file containing the logic to run the plugin registration logic as a constant into the flutter-application source code. --source file://$(@D)/.dart_tool/flutter_build/dart_plugin_registrant.dart: Adds the dart_plugin_registrant.dart file as a source file to compile. --source package:flutter/src/dart_plugin_registrant.dart: Binds the plugin implementation to the platform interface based on the configuration of the app's pubpec.yaml, and the plugin's pubspec.yaml. The native_assets.yaml file provides the native-assets mapping for @Native external functions. The flutter-gallery package has no functions marked as @Native; however, calling "flutter build bundle" creates a blank template "native_assets.yaml" file, which is safe to include in the build. This line, while not necessary for flutter-gallery, may be helpful for other users who use @Native external functions in their applications, and this example makes porting other applications quicker and easier. Finally, there is a known issue when using the dart_plugin_registrant.dart file outlined here: https://github.com/flutter/flutter/issues/137972. To summarize: If a user fails to pass the --obfuscate flag to gen_snapshsot when using the dart_plugin_registrant.dart file, their application may fail to start. One such application is Gallery, which I have independently verified. As such, pass the --obfuscate flag to gen_snapshot to ensure that flutter-gallery properly starts when building with the additional dart_plugin_registrant.dart arguments above. However, I acknowledge that the obfuscate flag hides function and class names in compiled Dart code, and there are some cases when a user should avoid using the flag. For example, when using the runtimeType API: https://api.flutter.dev/flutter/dart-core/Object/runtimeType.html. However, this is not the case with flutter-gallery, and the --obfuscate flag is needed. Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com> [yann.morin.1998@free.fr: restore FLUTTER_RUNTIME_MODES] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> |
||
---|---|---|
arch | ||
board | ||
boot | ||
configs | ||
docs | ||
fs | ||
linux | ||
package | ||
support | ||
system | ||
toolchain | ||
utils | ||
.checkpackageignore | ||
.clang-format | ||
.defconfig | ||
.editorconfig | ||
.flake8 | ||
.gitignore | ||
.gitlab-ci.yml | ||
.shellcheckrc | ||
CHANGES | ||
Config.in | ||
Config.in.legacy | ||
COPYING | ||
DEVELOPERS | ||
Makefile | ||
Makefile.legacy | ||
README |
Buildroot is a simple, efficient and easy-to-use tool to generate embedded Linux systems through cross-compilation. The documentation can be found in docs/manual. You can generate a text document with 'make manual-text' and read output/docs/manual/manual.text. Online documentation can be found at http://buildroot.org/docs.html To build and use the buildroot stuff, do the following: 1) run 'make menuconfig' 2) select the target architecture and the packages you wish to compile 3) run 'make' 4) wait while it compiles 5) find the kernel, bootloader, root filesystem, etc. in output/images You do not need to be root to build or run buildroot. Have fun! Buildroot comes with a basic configuration for a number of boards. Run 'make list-defconfigs' to view the list of provided configurations. Please feed suggestions, bug reports, insults, and bribes back to the buildroot mailing list: buildroot@buildroot.org You can also find us on #buildroot on OFTC IRC. If you would like to contribute patches, please read https://buildroot.org/manual.html#submitting-patches