Skip to contentSkip to conversation

more flutter package improvements

PATCH Superseded Adam Duskett 1 participant 11 messages Jan 13, 2024

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover more flutter package improvements

Changes v1 -> v2:
- Bump flutter-sdk-bin to 3.16.7
- Bump flutter-engine to 3.16.7

Most of these are self-explanitory and simple, however the depot-tools version bump should be explained:

The current depot-tools version is from Jul 13 2023, and there is a bug where when building with PPD enabled, building a Flutter application on my laptop running Fedora 39 or even in the Debian 11 container fails due to permission issues when running rsync such as:

/usr/bin/sed: couldn't open temporary file [...]/output/per-package/flutter-gallery/host/share/flutter/sdk/.vpython-root/0e1e32/lib/python3.8/sed763MrF: Permission denied
make: *** [package/pkg-generic.mk:267: [...]/output/build/flutter-gallery-2.10.2/.stamp_configured] Error 123

After several hours of attempting to find the exact cause of the issue by parsing git logs of the depot_tools repository and cross-referencing bugs on
https://bugs.chromium.org/p/chromium/issues I am unable to determine the exact reason why the problem occurs or the exact commit that fixes the issue.

However, updating depot-tools does indeed fix the issue, and looking at the source code between 4e87f5bf and 8d14454b shows improvements to several bash scripts, such as gclient, vpython3, and spid. All of which could be culprits of this bug. As flutter-engine is the only package that uses host-depot-tools, it is safe to update.

This permission bug is present on PPD and normal builds, but causes a build to crash only on PPD because of rsyncing. On non-ppd builds, the bug only causes some minor annoyance when trying to run make clean because permission denials crop up when trying to remove the .vpython-root directory.

I can't remember, but I * think * the autobuilders don't select PPD yet, which is probably why this bug hasn't caused any autobuild failures yet.

As for everything else:
- Tested on Fedora 39 and Debian 11.
- PPD and Non-PPD.
- Docker and host.

Everything passes and works as expected.

Thanks!

Adam Duskett (10):
package/ivi-homescreen: add standard_method_codec.h to keyboard
manager plugin
package/depot-tools: bump version to

    8d14454ba4a35fd9d2483842b08815a2357ec86f
  package/flutter-engine/Config.in: Drop nptl dependency
  package/flutter-sdk-bin: bump version to 3.16.7
  package/flutter-engine: bump version to 3.16.7
  package/flutter-pi: bump version to
    b816d8cff40e917ed0bc7905ec5f8611c08b5875

package/flutter-pi/Config.in: propagate flutter-engine dependencies package/flutter-gallery: add a configure step package/flutter-gallery: fix build options package/flutter-gallery: clean up install_target_cmds

 package/depot-tools/depot-tools.hash          |  2 +-
 package/depot-tools/depot-tools.mk            |  2 +-
 package/flutter-engine/Config.in              | 10 +++---
 package/flutter-engine/flutter-engine.mk      |  2 +-
 package/flutter-gallery/flutter-gallery.mk    | 24 ++++++++++----
 package/flutter-pi/Config.in                  | 31 +++++++++++++++++--
 package/flutter-pi/flutter-pi.hash            |  2 +-
 package/flutter-pi/flutter-pi.mk              |  2 +-
 package/flutter-sdk-bin/flutter-sdk-bin.hash  |  2 +-
 package/flutter-sdk-bin/flutter-sdk-bin.mk    |  2 +-
 ...rs-to-the-audio-players-and-keyboar.patch} | 26 ++++++++++++++--
 11 files changed, 81 insertions(+), 24 deletions(-)
 rename package/ivi-homescreen/{0001-add-missing-headers-to-the-audio-players-plugin.patch => 0001-add-missing-headers-to-the-audio-players-and-keyboar.patch} (77%)
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

PATCH v2 1/10 package/ivi-homescreen: add standard_method_codec.h to keyboard manager plugin

The keyboard manager plugin is also missing the flutter/standard_method_codec.h header.

- Add shell/plugins/keyboard_manager/keyboard_manager.h to the patch.

- Rename the patch to 0001-add-missing-headers-to-the-audio-players-and-keyboar.patch

Upstream pull request updated as well.

---
 ...rs-to-the-audio-players-and-keyboar.patch} | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
 rename package/ivi-homescreen/{0001-add-missing-headers-to-the-audio-players-plugin.patch => 0001-add-missing-headers-to-the-audio-players-and-keyboar.patch} (77%)
package/ivi-homescreen/0001-add-missing-headers-to-the-audio-players-and-keyboar.patch renamed from package/ivi-homescreen/0001-add-missing-headers-to-the-audio-players-plugin.patch +24 -2
similarity index 77%
rename from package/ivi-homescreen/0001-add-missing-headers-to-the-audio-players-plugin.patch
rename to package/ivi-homescreen/0001-add-missing-headers-to-the-audio-players-and-keyboar.patch
index c26fdba7f2..0d308b786b 100644
@@ -1,7 +1,8 @@
 From 7e35ea4fbd94a1604907069bb9cc2e2dff4b43c7 Mon Sep 17 00:00:00 2001
 From: Adam Duskett <[email protected]>
 Date: Sat, 6 Jan 2024 14:18:56 -0700
-Subject: [PATCH] add missing headers to the audio-players plugin
+Subject: [PATCH] add missing headers to the audio-players and keyboard_manager
+ plugin
 
 Fixes flutter::StandardMethodCodec not being declared on the following lines:
 plugins/audio_players/audio_players_registry.cc:83
@@ -9,6 +10,7 @@ plugins/audio_players/audio_players_registry.cc:94
 plugins/audio_players/audio_players_registry.cc:152
 plugins/audio_players/audio_player.cc:257
 plugins/audio_players/audio_player.cc:623
+plugins/keyboard_manager/keyboard_manager.cc:25
 
 Upstream: https://github.com/toyota-connected/ivi-homescreen/pull/133
 
@@ -17,7 +19,8 @@ Signed-off-by: Adam Duskett <[email protected]>
  shell/plugins/audio_players/audio_player.cc           | 3 ++-
  shell/plugins/audio_players/audio_players.cc          | 4 +++-
  shell/plugins/audio_players/audio_players_registry.cc | 3 ++-
- 3 files changed, 7 insertions(+), 3 deletions(-)
+ shell/plugins/keyboard_manager/keyboard_manager.h     | 3 ++-
+ 4 files changed, 9 insertions(+), 4 deletions(-)
 
 diff --git a/shell/plugins/audio_players/audio_player.cc b/shell/plugins/audio_players/audio_player.cc
 index 56027eb..a85e9ae 100644
@@ -77,6 +80,25 @@ index 6c9ef33..00c4f45 100644
 -}  // namespace Plugins
 \ No newline at end of file
 +}  // namespace Plugins
+diff --git a/shell/plugins/keyboard_manager/keyboard_manager.h b/shell/plugins/keyboard_manager/keyboard_manager.h
+index 74b4e8d..cae1954 100644
+--- a/shell/plugins/keyboard_manager/keyboard_manager.h
++++ b/shell/plugins/keyboard_manager/keyboard_manager.h
+@@ -17,6 +17,7 @@
+ #pragma once
+ 
+ #include "flutter/fml/macros.h"
++#include <flutter/standard_method_codec.h>
+ 
+ #include <shell/platform/embedder/embedder.h>
+ 
+@@ -45,4 +46,4 @@ class KeyboardManager {
+ 
+  private:
+   static constexpr char kGetKeyboardState[] = "getKeyboardState";
+-};
+\ No newline at end of file
++};
 -- 
 2.43.0
 
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

PATCH v2 2/10 package/depot-tools: bump version to 8d14454ba4a35fd9d2483842b08815a2357ec86f

In reply to Adam Duskett
---
 package/depot-tools/depot-tools.hash | 2 +-
 package/depot-tools/depot-tools.mk   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
package/depot-tools/depot-tools.hash +1 -1
index 2109096901..70218e4658 100644
@@ -1,3 +1,3 @@
 # Locally calculated
-sha256  8e0bccdd6b1231f58d5453dc14a5e1d195295ac8d466dec34961e951e946b50b  depot-tools-4e87f5bfe244e903f712408ea68dc3c3a6fe2d00-br1.tar.gz
+sha256  5da23d7558975093c6a732f5743c7f224d16dd3f878a6a1b577b1b127a4098cc  depot-tools-8d14454ba4a35fd9d2483842b08815a2357ec86f-br1.tar.gz
 sha256  984523ee987f4e8b72d61df37d8f1189a7077cd4b77e41a397e35593b297a29d  LICENSE
package/depot-tools/depot-tools.mk +1 -1
index e3b840f29a..634258ffbb 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-DEPOT_TOOLS_VERSION = 4e87f5bfe244e903f712408ea68dc3c3a6fe2d00
+DEPOT_TOOLS_VERSION = 8d14454ba4a35fd9d2483842b08815a2357ec86f
 DEPOT_TOOLS_SITE = https://chromium.googlesource.com/chromium/tools/depot_tools
 DEPOT_TOOLS_SITE_METHOD = git
 DEPOT_TOOLS_LICENSE = BSD-3-Clause
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

PATCH v2 3/10 package/flutter-engine/Config.in: Drop nptl dependency

In reply to Adam Duskett

As Yann mentioned in commit 9d8497e79de3ced144877ba6ee38cc5b7181aaeb, a dependency on a glibc toolchain implies a dependency on BR2_TOOLCHAIN_HAS_THREADS_NPTL. As such, remove the dependency from package/flutter-engine/Config.in.

---
 package/flutter-engine/Config.in | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
package/flutter-engine/Config.in +4 -6
index 3c92e40f74..00bcd05cd4 100644
@@ -11,7 +11,6 @@ config BR2_PACKAGE_FLUTTER_ENGINE
 	depends on BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
 	depends on BR2_TOOLCHAIN_USES_GLIBC
 	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5
-	depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # pthreads
 	depends on BR2_INSTALL_LIBSTDCPP
 	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # std::shared_future
 	depends on !BR2_STATIC_LIBS
@@ -68,12 +67,11 @@ comment "flutter-engine needs an OpenGL or OpenGLES backend"
 	depends on BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
 	depends on !BR2_PACKAGE_HAS_LIBGL && !BR2_PACKAGE_HAS_LIBGLES
 
-comment "flutter-engine needs a glibc toolchain w/ wchar, C++, gcc >= 5, dynamic library, host gcc >= 5, NPTL"
+comment "flutter-engine needs a glibc toolchain w/ wchar, C++, gcc >= 5, dynamic library, host gcc >= 5"
 	depends on BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
-	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_TOOLCHAIN_HAS_THREADS_NPTL \
-		|| !BR2_INSTALL_LIBSTDCPP || !BR2_TOOLCHAIN_GCC_AT_LEAST_5 \
-		|| BR2_STATIC_LIBS || !BR2_USE_WCHAR \
-		|| !BR2_HOST_GCC_AT_LEAST_5
+	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
+		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_5 || BR2_STATIC_LIBS \
+		|| !BR2_USE_WCHAR || !BR2_HOST_GCC_AT_LEAST_5
 
 comment "flutter-engine needs a toolchain not affected by GCC bug 64735"
 	depends on BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

PATCH v2 4/10 package/flutter-sdk-bin: bump version to 3.16.7

In reply to Adam Duskett

---
v1 -> v2: Bump to 3.16.7

 package/flutter-sdk-bin/flutter-sdk-bin.hash | 2 +-
 package/flutter-sdk-bin/flutter-sdk-bin.mk   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
package/flutter-sdk-bin/flutter-sdk-bin.hash +1 -1
index f0a855f2c9..84a7300753 100644
@@ -1,3 +1,3 @@
 # Locally calculated
-sha256  57e59fa3a31be7e87b3847cdf782f1323578bbf70a0cd35f3615f01ab429ac29  flutter_linux_3.16.5-stable.tar.xz
+sha256  a10061a15f7a829337c284474b9703635350f8abeec4922534c8363816fd5eb4  flutter_linux_3.16.7-stable.tar.xz
 sha256  a598db94b6290ffbe10b5ecf911057b6a943351c727fdda9e5f2891d68700a20  LICENSE
package/flutter-sdk-bin/flutter-sdk-bin.mk +1 -1
index 5e5042bea8..760a603eb8 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-FLUTTER_SDK_BIN_VERSION = 3.16.5
+FLUTTER_SDK_BIN_VERSION = 3.16.7
 FLUTTER_SDK_BIN_SITE = https://storage.googleapis.com/flutter_infra_release/releases/stable/linux
 FLUTTER_SDK_BIN_SOURCE = flutter_linux_$(FLUTTER_SDK_BIN_VERSION)-stable.tar.xz
 FLUTTER_SDK_BIN_LICENSE = BSD-3-Clause
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

PATCH v2 5/10 package/flutter-engine: bump version to 3.16.7

In reply to Adam Duskett

---
v1 ->. v2: bump to 3.16.7

 package/flutter-engine/flutter-engine.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/flutter-engine/flutter-engine.mk +1 -1
index e972612097..cefaed5212 100644
@@ -21,7 +21,7 @@
 #
 # There is no hash provided, as the gn binary (used for configuration) relies
 # on the .git directories. As such, a reproducible tarball is not possible.
-FLUTTER_ENGINE_VERSION = 3.16.5
+FLUTTER_ENGINE_VERSION = 3.16.7
 
 # There is nothing for Buildroot to download. This is handled by gclient.
 FLUTTER_ENGINE_SITE =
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

PATCH v2 6/10 package/flutter-pi: bump version to b816d8cff40e917ed0bc7905ec5f8611c08b5875

In reply to Adam Duskett
---
 package/flutter-pi/flutter-pi.hash | 2 +-
 package/flutter-pi/flutter-pi.mk   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
package/flutter-pi/flutter-pi.hash +1 -1
index 6c5371d18a..f5e72d384c 100644
@@ -1,3 +1,3 @@
 # Locally calculated
-sha256  cf10ca9e26beea036ccf218e6a900de5f1f2000e00c03e7a48898c2a0c99f591  flutter-pi-f34d7bdbda713ba607b9625541ddfa314d9999a0-br1.tar.gz
+sha256  3952cc3471c9424908354a01dfa5ce3ceae376ed0749d94200dedecbe7610c1f  flutter-pi-b816d8cff40e917ed0bc7905ec5f8611c08b5875-br1.tar.gz
 sha256  b34df9d3e1b4e5d1ba70b1740ec74b69f1189b44efd0c96b898b074ef8db1c70  LICENSE
package/flutter-pi/flutter-pi.mk +1 -1
index ab640d704a..cb4f5d093f 100644
@@ -4,7 +4,7 @@
 #
 ################################################################################
 
-FLUTTER_PI_VERSION = f34d7bdbda713ba607b9625541ddfa314d9999a0
+FLUTTER_PI_VERSION = b816d8cff40e917ed0bc7905ec5f8611c08b5875
 FLUTTER_PI_SITE = https://github.com/ardera/flutter-pi.git
 FLUTTER_PI_SITE_METHOD = git
 FLUTTER_PI_LICENSE = MIT
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw

PATCH v2 7/10 package/flutter-pi/Config.in: propagate flutter-engine dependencies

In reply to Adam Duskett

As discussed with Yann, it is better to make the dependencies of flutter-pi verbose, even if flutter-engine and host-flutter-sdk-bin have eleven dependencies combined. This change clears up any ambiguity a user may have regarding the dependencies the flutter-pi package relies upon and why.

---
 package/flutter-pi/Config.in | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
package/flutter-pi/Config.in +28 -3
index 4bbdc3cc77..bb0e3702c1 100644
@@ -1,9 +1,20 @@
 menuconfig BR2_PACKAGE_FLUTTER_PI
 	bool "flutter-pi"
-	depends on BR2_PACKAGE_FLUTTER_ENGINE
+	depends on BR2_PACKAGE_HOST_FLUTTER_SDK_BIN_ARCH_SUPPORTS
+	depends on BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
+	depends on BR2_HOST_GCC_AT_LEAST_5 # flutter-engine
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_5 # flutter-engine
+	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # flutter-engine
+	depends on BR2_TOOLCHAIN_USES_GLIBC # flutter-engine
+	depends on BR2_INSTALL_LIBSTDCPP # flutter-engine
+	depends on !BR2_STATIC_LIBS # flutter-engine, wayland
+	depends on BR2_USE_WCHAR # flutter-engine
+	depends on BR2_PACKAGE_HAS_LIBGL || BR2_PACKAGE_HAS_LIBGLES # flutter-engine
 	depends on BR2_PACKAGE_HAS_LIBGBM
 	depends on BR2_PACKAGE_SYSTEMD # Event loop and dbus support
 	depends on BR2_PACKAGE_HAS_UDEV # libinput
+	select BR2_PACKAGE_HOST_FLUTTER_SDK_BIN
+	select BR2_PACKAGE_FLUTTER_ENGINE
 	select BR2_PACKAGE_LIBDRM
 	select BR2_PACKAGE_LIBINPUT
 	select BR2_PACKAGE_LIBXKBCOMMON
@@ -80,8 +91,22 @@ config BR2_PACKAGE_FLUTTER_PI_TEXT_INPUT_PLUGIN
 
 endif
 
-comment "flutter-pi needs flutter-engine"
-	depends on !BR2_PACKAGE_FLUTTER_ENGINE
+comment "flutter-pi needs a glibc toolchain w/ wchar, C++, gcc >= 5, dynamic library, host gcc >= 5"
+	depends on BR2_PACKAGE_HOST_FLUTTER_SDK_BIN_ARCH_SUPPORTS
+	depends on BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
+	depends on !BR2_TOOLCHAIN_USES_GLIBC || !BR2_INSTALL_LIBSTDCPP \
+		|| !BR2_TOOLCHAIN_GCC_AT_LEAST_5 || BR2_STATIC_LIBS \
+		|| !BR2_USE_WCHAR || !BR2_HOST_GCC_AT_LEAST_5
+
+comment "flutter-pi needs a toolchain not affected by GCC bug 64735"
+	depends on BR2_PACKAGE_HOST_FLUTTER_SDK_BIN_ARCH_SUPPORTS
+	depends on BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_HAS_GCC_BUG_64735
+
+comment "flutter-pi needs an OpenGL or OpenGLES backend"
+	depends on BR2_PACKAGE_HOST_FLUTTER_SDK_BIN_ARCH_SUPPORTS
+	depends on BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
+	depends on !BR2_PACKAGE_HAS_LIBGL && !BR2_PACKAGE_HAS_LIBGLES
 
 comment "flutter-pi needs GBM, systemd, and udev"
 	depends on !BR2_PACKAGE_HAS_LIBGBM || \
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#8 lore raw

PATCH v2 8/10 package/flutter-gallery: add a configure step

In reply to Adam Duskett

To make the next patch easier to understand, add a configure step to the flutter-gallery.mk file. The $(HOST_FLUTTER_SDK_BIN_FLUTTER) build bundle command is placed in the configure step because it generates several files needed for the flutter_gen_snapshot tool to generate the target .so file.

---
 package/flutter-gallery/flutter-gallery.mk | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
package/flutter-gallery/flutter-gallery.mk +8 -3
index 57a476b1ab..50ddd9ffba 100644
@@ -14,12 +14,17 @@ FLUTTER_GALLERY_DEPENDENCIES = \
 
 FLUTTER_GALLERY_INSTALL_DIR = $(TARGET_DIR)/usr/share/flutter/gallery/$(FLUTTER_ENGINE_RUNTIME_MODE)
 
-define FLUTTER_GALLERY_BUILD_CMDS
+define FLUTTER_GALLERY_CONFIGURE_CMDS
 	cd $(@D) && \
 		FLUTTER_RUNTIME_MODES=$(FLUTTER_ENGINE_RUNTIME_MODE) \
 		$(HOST_FLUTTER_SDK_BIN_FLUTTER) clean && \
-		$(HOST_FLUTTER_SDK_BIN_FLUTTER) packages get && \
-		$(HOST_FLUTTER_SDK_BIN_FLUTTER) build bundle && \
+		$(HOST_FLUTTER_SDK_BIN_FLUTTER) pub get && \
+		$(HOST_FLUTTER_SDK_BIN_FLUTTER) build bundle
+endef
+
+define FLUTTER_GALLERY_BUILD_CMDS
+	cd $(@D) && \
+		FLUTTER_RUNTIME_MODES=$(FLUTTER_ENGINE_RUNTIME_MODE) \
 		$(HOST_FLUTTER_SDK_BIN_DART_BIN) package:gallery/main.dart && \
 		$(HOST_FLUTTER_SDK_BIN_ENV) $(FLUTTER_ENGINE_GEN_SNAPSHOT) \
 			--deterministic \
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#9 lore raw

PATCH v2 9/10 package/flutter-gallery: fix build options

In reply to Adam Duskett

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.

---
 package/flutter-gallery/flutter-gallery.mk | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
package/flutter-gallery/flutter-gallery.mk +7 -2
index 50ddd9ffba..e23dc399da 100644
@@ -24,10 +24,15 @@ endef
 
 define FLUTTER_GALLERY_BUILD_CMDS
 	cd $(@D) && \
-		FLUTTER_RUNTIME_MODES=$(FLUTTER_ENGINE_RUNTIME_MODE) \
-		$(HOST_FLUTTER_SDK_BIN_DART_BIN) package:gallery/main.dart && \
+		$(HOST_FLUTTER_SDK_BIN_DART_BIN) \
+			-Dflutter.dart_plugin_registrant=file://$(@D)/.dart_tool/flutter_build/dart_plugin_registrant.dart \
+			--source file://$(@D)/.dart_tool/flutter_build/dart_plugin_registrant.dart \
+			--source package:flutter/src/dart_plugin_registrant.dart \
+			--native-assets $(@D)/.dart_tool/flutter_build/*/native_assets.yaml \
+			package:gallery/main.dart && \
 		$(HOST_FLUTTER_SDK_BIN_ENV) $(FLUTTER_ENGINE_GEN_SNAPSHOT) \
 			--deterministic \
+			--obfuscate \
 			--snapshot_kind=app-aot-elf \
 			--elf=libapp.so \
 			.dart_tool/flutter_build/*/app.dill
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#10 lore raw

PATCH v2 10/10 package/flutter-gallery: clean up install_target_cmds

In reply to Adam Duskett

Remove and create the kernel_blob.bin file in the flutter_assets directory:

When Flutter compiles the source code, it creates the kernel_blob.bin file, a Dart Kernel Bytecode of the application.

If kernel_blob.bin exists inside the flutter_assets directory, then the application source code can be extracted with nothing more than apktool. Not only is this a security risk, it's also redundant and a waste of space.

Removing the kernel_blob.bin file generated for flutter-gallery saves 86M! Because this package is a reference package, and some applications may check if the kernel_blob.bin file exists, we also touch a blank kernel_blob.bin file.

Do not use relative symlinks:
Users may not install their applications in the /usr/share/flutter/${package_name} directory. Because this is a reference application, using exact symlinks to icudtl.dat and libflutter_engine.so is preferable.

---
 package/flutter-gallery/flutter-gallery.mk | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
package/flutter-gallery/flutter-gallery.mk +4 -2
index e23dc399da..6b0954cb32 100644
@@ -45,10 +45,12 @@ define FLUTTER_GALLERY_INSTALL_TARGET_CMDS
 	$(INSTALL) -D -m 0755 $(@D)/libapp.so \
 		$(FLUTTER_GALLERY_INSTALL_DIR)/lib/libapp.so
 
-	ln -sf ../../../$(FLUTTER_ENGINE_RUNTIME_MODE)/data/icudtl.dat \
+	ln -sf /usr/share/flutter/$(FLUTTER_ENGINE_RUNTIME_MODE)/data/icudtl.dat \
 	$(FLUTTER_GALLERY_INSTALL_DIR)/data/
 
-	ln -sf ../../../../../lib/libflutter_engine.so $(FLUTTER_GALLERY_INSTALL_DIR)/lib/
+	ln -sf /usr/lib/libflutter_engine.so $(FLUTTER_GALLERY_INSTALL_DIR)/lib/
+	$(RM) $(FLUTTER_GALLERY_INSTALL_DIR)/data/flutter_assets/kernel_blob.bin
+	touch $(FLUTTER_GALLERY_INSTALL_DIR)/data/flutter_assets/kernel_blob.bin
 endef
 
 $(eval $(generic-package))
Signature · 6 lines
2.43.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot