All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH vRFC 0/3] Initial flutter packages
@ 2023-07-20 23:36 Adam Duskett
  2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 1/3] package/python-httplib2: add host variant Adam Duskett
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Adam Duskett @ 2023-07-20 23:36 UTC (permalink / raw)
  To: buildroot
  Cc: Adam Duskett, Asaf Kahlon, Thomas Petazzoni, Michael Trimarchi,
	Angelo Compagnucci

Preface: Thank you for all the help, thoughts and insight for this initial
RFC of the flutter-engine library. There are many other flutter packages that
need to be ported, but this is the largest hurdle to overcome.

There are many issues with the flutter-engine package:

- The release tarballs from https://github.com/flutter/engine are in no state
  to compile. They are only for the use of gclient to download a source
  directory structure suitable to build the Flutter engine! If you download,
  extract and attempt to run `./tools/gn --no-goma --no-prebuilt-dart-sdk`, you
  receive the error message:
  `No such file or directory: 'flutter/flutter/third_party/gn/gn.'

  But wait! Wasn't the gn binary just called? No, that's a wrapper in the
  Flutter source tree that formats arguments to call the real gn binary.
  The real gn is not provided in the tarball but is downloaded via gclient
  (among many other supporting repositories.)

  Even worse, the flutter repository depends on the .git dirs being present.
  (https://github.com/meta-flutter/meta-flutter/issues/271) This dependency
  means it is not possible to create a reproducible tarball from the downloaded
  sources, which is why there is no .hash file provided.

  I have asked the flutter project to release full tarballs suitable for
  compiling here: https://github.com/flutter/flutter/issues/130734

- The clang toolchain wrapper does not work properly, resulting in the immediate
  errors of:
    -Wl,-z,now: 'linker' input unused
    -Wl,-z,relro: 'linker' input unused
  The solution is to use clang.br_real and clang++.br_real.

- If using per_package builds, flutter-engine tries to use the host /usr/bin/ld
  instead of the one provided by the compiler, resulting in linking errors.
  As such, if BR2_PER_PACKAGE_DIRECTORIES is enabled, we search for the ld
  provided by the compiler in the host directory and set the path accordingly.

- libtessellator.so (built by flutter) requires three files:
  crtbeginS.o crtendS.o libgcc.a. However, the toolchain path isn't referenced
  when linking. The solution is to copy those three files to the staging lib
  directory before building.

Tested with:
  - Debian 11 and 12
  - Ubuntu 18.04, 20.04, and 22.04
  - Fedora 38
  - Per package directory enabled and disabled
  - x86_64, arm64

Adam Duskett (3):
  package/python-httplib2: add host variant
  package/depot-tools: new package
  package/flutter-engine: new package

 DEVELOPERS                                    |   4 +
 package/Config.in                             |   1 +
 package/Config.in.host                        |   1 +
 .../0001-Disable-ninjalog-upload.patch        |  35 +++
 package/depot-tools/Config.in.host            |  10 +
 package/depot-tools/depot-tools.hash          |   3 +
 package/depot-tools/depot-tools.mk            |  33 ++
 .../0001-disable-pre-canned-sysroot.patch     |  32 ++
 .../0002-remove-explicit-x11-dependency.patch |  33 ++
 .../0003-disable-undefined-version.patch      |  32 ++
 ...onfig.py-do-not-prepend-sysroot-path.patch |  34 +++
 package/flutter-engine/Config.in              |  93 ++++++
 package/flutter-engine/flutter-engine.mk      | 286 ++++++++++++++++++
 package/flutter-engine/gclient                |  16 +
 package/python-httplib2/python-httplib2.mk    |   1 +
 15 files changed, 614 insertions(+)
 create mode 100644 package/depot-tools/0001-Disable-ninjalog-upload.patch
 create mode 100644 package/depot-tools/Config.in.host
 create mode 100644 package/depot-tools/depot-tools.hash
 create mode 100644 package/depot-tools/depot-tools.mk
 create mode 100644 package/flutter-engine/0001-disable-pre-canned-sysroot.patch
 create mode 100644 package/flutter-engine/0002-remove-explicit-x11-dependency.patch
 create mode 100644 package/flutter-engine/0003-disable-undefined-version.patch
 create mode 100644 package/flutter-engine/0004-pkg-config.py-do-not-prepend-sysroot-path.patch
 create mode 100644 package/flutter-engine/Config.in
 create mode 100644 package/flutter-engine/flutter-engine.mk
 create mode 100644 package/flutter-engine/gclient

-- 
2.41.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH vRFC 1/3] package/python-httplib2: add host variant
  2023-07-20 23:36 [Buildroot] [PATCH vRFC 0/3] Initial flutter packages Adam Duskett
@ 2023-07-20 23:36 ` Adam Duskett
  2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 2/3] package/depot-tools: new package Adam Duskett
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Adam Duskett @ 2023-07-20 23:36 UTC (permalink / raw)
  To: buildroot
  Cc: Adam Duskett, Asaf Kahlon, Thomas Petazzoni, Michael Trimarchi,
	Angelo Compagnucci

This is needed for host-depot-tools

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
 package/python-httplib2/python-httplib2.mk | 1 +
 1 file changed, 1 insertion(+)

diff --git a/package/python-httplib2/python-httplib2.mk b/package/python-httplib2/python-httplib2.mk
index 1093ecab39..2f4eb98356 100644
--- a/package/python-httplib2/python-httplib2.mk
+++ b/package/python-httplib2/python-httplib2.mk
@@ -14,3 +14,4 @@ PYTHON_HTTPLIB2_CPE_ID_VENDOR = httplib2_project
 PYTHON_HTTPLIB2_CPE_ID_PRODUCT = httplib2
 
 $(eval $(python-package))
+$(eval $(host-python-package))
-- 
2.41.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH vRFC 2/3] package/depot-tools: new package
  2023-07-20 23:36 [Buildroot] [PATCH vRFC 0/3] Initial flutter packages Adam Duskett
  2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 1/3] package/python-httplib2: add host variant Adam Duskett
@ 2023-07-20 23:36 ` Adam Duskett
  2023-07-23 19:52   ` Yann E. MORIN
  2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 3/3] package/flutter-engine: " Adam Duskett
  2023-07-20 23:37 ` [Buildroot] [PATCH vRFC 0/3] Initial flutter packages Adam Duskett
  3 siblings, 1 reply; 8+ messages in thread
From: Adam Duskett @ 2023-07-20 23:36 UTC (permalink / raw)
  To: buildroot
  Cc: Adam Duskett, Asaf Kahlon, Thomas Petazzoni, Michael Trimarchi,
	Angelo Compagnucci

Chromium and Chromium OS use a package of scripts called
depot_tools to manage checkouts and code reviews. This package
also includes the gclient utility.

gclient is a Python script to manage a workspace of modular dependencies that
are each checked out independently from different subversion or git
repositories. Features include:

  - Dependencies can be specified on a per-OS basis.
  - Dependencies can be specified relative to their parent dependency.
  - Variables can be used to abstract concepts.
  - Hooks can be specified to be run after a checkout.
  - .gclient and DEPS are Python scripts. You can hack in easily or add
     additional configuration data.

.gclient file: It's the primary file. It is, in fact, a Python script. It
specifies the following variables:

  - solutions: an array of dictionaries specifying the projects that will be
               fetched.
  - hooks: additional hooks to be run when this meta checkout is synced.
  - target_os: an optional array of (target) operating systems to fetch
               OS-specific dependencies for.
  - cache_dir: Primarily for bots, multiple working sets use a single git
               cache.

gclient is necessary for checking out the flutter-engine source code, as the
release tarballs provided on the flutter-engine github are in no state to
compile. Google expects the use of gclient to download a source directory
structure suitable to build the Flutter engine.

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
 DEVELOPERS                                    |  3 ++
 package/Config.in.host                        |  1 +
 .../0001-Disable-ninjalog-upload.patch        | 35 +++++++++++++++++++
 package/depot-tools/Config.in.host            | 10 ++++++
 package/depot-tools/depot-tools.hash          |  3 ++
 package/depot-tools/depot-tools.mk            | 33 +++++++++++++++++
 6 files changed, 85 insertions(+)
 create mode 100644 package/depot-tools/0001-Disable-ninjalog-upload.patch
 create mode 100644 package/depot-tools/Config.in.host
 create mode 100644 package/depot-tools/depot-tools.hash
 create mode 100644 package/depot-tools/depot-tools.mk

diff --git a/DEVELOPERS b/DEVELOPERS
index 43058cedf9..38db2dd345 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -26,6 +26,9 @@
 #   infrastructure, and will be CC'ed on all patches that add or
 #   modify packages that use this infrastructure.
 
+N:	Adam Duskett <adam.duskett@amarulasolutions.com>
+F:	package/depot-tools
+
 N:	Adam Heinrich <adam@adamh.cz>
 F:	package/jack1/
 
diff --git a/package/Config.in.host b/package/Config.in.host
index 9addc88522..6eb5d5be1d 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -18,6 +18,7 @@ menu "Host utilities"
 	source "package/cryptsetup/Config.in.host"
 	source "package/dbus-python/Config.in.host"
 	source "package/delve/Config.in.host"
+	source "package/depot-tools/Config.in.host"
 	source "package/dfu-util/Config.in.host"
 	source "package/dos2unix/Config.in.host"
 	source "package/dosfstools/Config.in.host"
diff --git a/package/depot-tools/0001-Disable-ninjalog-upload.patch b/package/depot-tools/0001-Disable-ninjalog-upload.patch
new file mode 100644
index 0000000000..55fd78247f
--- /dev/null
+++ b/package/depot-tools/0001-Disable-ninjalog-upload.patch
@@ -0,0 +1,35 @@
+From eeea6ad620b88a81a4b05d49f32a375b4bbcef36 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <aduskett@gmail.com>
+Date: Thu, 13 Jul 2023 15:50:25 -0700
+Subject: [PATCH] Disable ninjalog upload
+
+Google doesn't need the ninja logs.
+
+Upstream: buildroot-specific.
+Signed-off-by: Adam Duskett <aduskett@gmail.com>
+---
+ autoninja | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/autoninja b/autoninja
+index 06d45d1..354a2f1 100755
+--- a/autoninja
++++ b/autoninja
+@@ -30,12 +30,12 @@ if eval "$command"; then
+   fi
+ 
+   # Collect ninjalog from googler.
+-  python3 "$(dirname -- "$0")/ninjalog_uploader_wrapper.py" --cmd $command
++  # python3 "$(dirname -- "$0")/ninjalog_uploader_wrapper.py" --cmd $command
+   exit
+ fi
+ 
+ # Collect ninjalog from googler.
+-python3 "$(dirname -- "$0")/ninjalog_uploader_wrapper.py" --cmd $command
++# python3 "$(dirname -- "$0")/ninjalog_uploader_wrapper.py" --cmd $command
+ 
+ # Return an error code of 1 so that if a developer types:
+ # "autoninja chrome && chrome" then chrome won't run if the build fails.
+-- 
+2.41.0
+
diff --git a/package/depot-tools/Config.in.host b/package/depot-tools/Config.in.host
new file mode 100644
index 0000000000..935331dedb
--- /dev/null
+++ b/package/depot-tools/Config.in.host
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_HOST_DEPOT_TOOLS
+	bool "host depot-tools"
+	select BR2_PACKAGE_HOST_PYTHON3
+	select BR2_PACKAGE_HOST_PYTHON3_SSL
+	select BR2_PACKAGE_HOST_PYTHON_SIX
+	help
+	  Chromium and Chromium OS use a package of scripts called
+	  depot_tools to manage checkouts and code reviews.
+
+	  https://www.chromium.org/developers/how-tos/install-depot-tools/
diff --git a/package/depot-tools/depot-tools.hash b/package/depot-tools/depot-tools.hash
new file mode 100644
index 0000000000..2109096901
--- /dev/null
+++ b/package/depot-tools/depot-tools.hash
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256  8e0bccdd6b1231f58d5453dc14a5e1d195295ac8d466dec34961e951e946b50b  depot-tools-4e87f5bfe244e903f712408ea68dc3c3a6fe2d00-br1.tar.gz
+sha256  984523ee987f4e8b72d61df37d8f1189a7077cd4b77e41a397e35593b297a29d  LICENSE
diff --git a/package/depot-tools/depot-tools.mk b/package/depot-tools/depot-tools.mk
new file mode 100644
index 0000000000..906340016c
--- /dev/null
+++ b/package/depot-tools/depot-tools.mk
@@ -0,0 +1,33 @@
+################################################################################
+#
+# depot-tools
+#
+################################################################################
+
+DEPOT_TOOLS_VERSION = 4e87f5bfe244e903f712408ea68dc3c3a6fe2d00
+DEPOT_TOOLS_SITE = https://chromium.googlesource.com/chromium/tools/depot_tools
+DEPOT_TOOLS_SITE_METHOD = git
+DEPOT_TOOLS_LICENSE = Chromium
+DEPOT_TOOLS_LICENSE_FILES = LICENSE
+DEPOT_TOOLS_CPE_ID_VENDOR = google
+HOST_DEPOT_TOOLS_DEPENDENCIES = \
+	host-python3 \
+	host-python-httplib2 \
+	host-python-pyparsing \
+	host-python-six
+
+define HOST_DEPOT_TOOLS_INSTALL_CMDS
+	mkdir -p $(HOST_DIR)/share/depot_tools
+	cp -dprf $(@D)/* $(HOST_DIR)/share/depot_tools/
+endef
+
+# Helper wrapper to make using gclient easier.
+DEPOT_TOOLS_GCLIENT=\
+	PATH=$(BR_PATH):$(HOST_DIR)/share/depot_tools \
+	LD_LIBRARY_PATH=$(HOST_DIR)/lib \
+	PYTHONPATH=$(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR) \
+	DEPOT_TOOLS_UPDATE=0 \
+	PYTHONDONTWRITEBYTECODE=1 \
+	$(HOST_DIR)/share/depot_tools/gclient.py
+
+$(eval $(host-generic-package))
-- 
2.41.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [Buildroot] [PATCH vRFC 3/3] package/flutter-engine: new package
  2023-07-20 23:36 [Buildroot] [PATCH vRFC 0/3] Initial flutter packages Adam Duskett
  2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 1/3] package/python-httplib2: add host variant Adam Duskett
  2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 2/3] package/depot-tools: new package Adam Duskett
@ 2023-07-20 23:36 ` Adam Duskett
  2023-07-23 21:26   ` Yann E. MORIN
  2023-07-20 23:37 ` [Buildroot] [PATCH vRFC 0/3] Initial flutter packages Adam Duskett
  3 siblings, 1 reply; 8+ messages in thread
From: Adam Duskett @ 2023-07-20 23:36 UTC (permalink / raw)
  To: buildroot
  Cc: Adam Duskett, Asaf Kahlon, Thomas Petazzoni, Michael Trimarchi,
	Angelo Compagnucci

There are many issues with this package:

- The release tarballs from https://github.com/flutter/engine are in no state
  to compile. They are only for the use of gclient to download a source
  directory structure suitable to build the Flutter engine! If you download,
  extract and attempt to run `./tools/gn --no-goma --no-prebuilt-dart-sdk`, you
  receive the error message:
  `No such file or directory: 'flutter/flutter/third_party/gn/gn.'

  But wait! Wasn't the gn binary just called? No, that's a wrapper in the
  Flutter source tree that formats arguments to call the real gn binary.
  The real gn is not provided in the tarball but is downloaded via gclient
  (among many other supporting repositories.)

  Even worse, the flutter repository depends on the .git dirs being present.
  (https://github.com/meta-flutter/meta-flutter/issues/271) This dependency
  means it is not possible to create a reproducible tarball from the downloaded
  sources, which is why there is no .hash file provided.

  I have asked the flutter project to release full tarballs suitable for
  compiling here: https://github.com/flutter/flutter/issues/130734

- The clang toolchain wrapper does not work properly, resulting in the immediate
  errors of:
    -Wl,-z,now: 'linker' input unused
    -Wl,-z,relro: 'linker' input unused
  The solution is to use clang.br_real and clang++.br_real.

- If using per_package builds, flutter-engine tries to use the host /usr/bin/ld
  instead of the one provided by the compiler, resulting in linking errors.
  As such, if BR2_PER_PACKAGE_DIRECTORIES is enabled, we search for the ld
  provided by the compiler in the host directory and set the path accordingly.

- libtessellator.so (built by flutter) requires three files:
  crtbeginS.o crtendS.o libgcc.a. However, the toolchain path isn't referenced
  when linking. The solution is to copy those three files to the staging lib
  directory before building.

Tested with:
  - Debian 11 and 12
  - Ubuntu 18.04, 20.04, and 22.04
  - Fedora 38
  - Per package directory enabled and disabled
  - x86_64, arm64

Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
---
 DEVELOPERS                                    |   1 +
 package/Config.in                             |   1 +
 .../0001-disable-pre-canned-sysroot.patch     |  32 ++
 .../0002-remove-explicit-x11-dependency.patch |  33 ++
 .../0003-disable-undefined-version.patch      |  32 ++
 ...onfig.py-do-not-prepend-sysroot-path.patch |  34 +++
 package/flutter-engine/Config.in              |  93 ++++++
 package/flutter-engine/flutter-engine.mk      | 286 ++++++++++++++++++
 package/flutter-engine/gclient                |  16 +
 9 files changed, 528 insertions(+)
 create mode 100644 package/flutter-engine/0001-disable-pre-canned-sysroot.patch
 create mode 100644 package/flutter-engine/0002-remove-explicit-x11-dependency.patch
 create mode 100644 package/flutter-engine/0003-disable-undefined-version.patch
 create mode 100644 package/flutter-engine/0004-pkg-config.py-do-not-prepend-sysroot-path.patch
 create mode 100644 package/flutter-engine/Config.in
 create mode 100644 package/flutter-engine/flutter-engine.mk
 create mode 100644 package/flutter-engine/gclient

diff --git a/DEVELOPERS b/DEVELOPERS
index 38db2dd345..603bebca1c 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -28,6 +28,7 @@
 
 N:	Adam Duskett <adam.duskett@amarulasolutions.com>
 F:	package/depot-tools
+F:	package/flutter-engine
 
 N:	Adam Heinrich <adam@adamh.cz>
 F:	package/jack1/
diff --git a/package/Config.in b/package/Config.in
index 601922aad5..8c36fe486f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -342,6 +342,7 @@ comment "Graphic libraries"
 	source "package/fbset/Config.in"
 	source "package/fbterm/Config.in"
 	source "package/fbv/Config.in"
+	source "package/flutter-engine/Config.in"
 	source "package/freerdp/Config.in"
 	source "package/graphicsmagick/Config.in"
 	source "package/imagemagick/Config.in"
diff --git a/package/flutter-engine/0001-disable-pre-canned-sysroot.patch b/package/flutter-engine/0001-disable-pre-canned-sysroot.patch
new file mode 100644
index 0000000000..c4064a77c9
--- /dev/null
+++ b/package/flutter-engine/0001-disable-pre-canned-sysroot.patch
@@ -0,0 +1,32 @@
+From 49a14e693124dc34f2cccbfb755d01a1198aa6bf Mon Sep 17 00:00:00 2001
+From: Adam Duskett <adam.duskett@amarulasolutions.com>
+Date: Wed, 19 Jul 2023 15:24:22 -0700
+Subject: [PATCH] disable pre-canned sysroot
+
+Override should be enabled if a custom sysroot using --target-sysroot is
+specified. If --target-sysroot is not set, then it should default to the
+pre-canned sysroot.
+
+Upstream: https://github.com/flutter/flutter/issues/123073
+Signed-off-by: Joel Winarske <joel.winarsk@gmail.com>
+Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
+---
+ build/config/sysroot.gni | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni
+index 7987e519d..1de694263 100644
+--- a/build/config/sysroot.gni
++++ b/build/config/sysroot.gni
+@@ -14,7 +14,7 @@ declare_args() {
+ 
+   # Whether to use the default sysroot when building for Linux, if an explicit
+   # sysroot isn't set.
+-  use_default_linux_sysroot = true
++  use_default_linux_sysroot = false
+ }
+ 
+ if (current_toolchain == default_toolchain && target_sysroot != "") {
+-- 
+2.41.0
+
diff --git a/package/flutter-engine/0002-remove-explicit-x11-dependency.patch b/package/flutter-engine/0002-remove-explicit-x11-dependency.patch
new file mode 100644
index 0000000000..1345d4a3dd
--- /dev/null
+++ b/package/flutter-engine/0002-remove-explicit-x11-dependency.patch
@@ -0,0 +1,33 @@
+From b1a5db9318ca33a03f2700758d5debad907d21b6 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <adam.duskett@amarulasolutions.com>
+Date: Wed, 19 Jul 2023 15:26:40 -0700
+Subject: [PATCH] remove explicit x11 dependency
+
+This is redundant, as the gtk pkg-config query will reference x11 if that's how
+it was built.
+
+Upstream: https://github.com/flutter/flutter/issues/123073
+Signed-off-by: Joel Winarske <joel.winarske@gmail.com>
+Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
+---
+ flutter/shell/platform/linux/config/BUILD.gn | 4 ----
+ 1 file changed, 4 deletions(-)
+
+diff --git a/flutter/shell/platform/linux/config/BUILD.gn b/flutter/shell/platform/linux/config/BUILD.gn
+index da0ac056b..70c7a0ea1 100644
+--- a/flutter/shell/platform/linux/config/BUILD.gn
++++ b/flutter/shell/platform/linux/config/BUILD.gn
+@@ -5,10 +5,6 @@
+ import("//build/config/linux/pkg_config.gni")
+ import("//flutter/shell/platform/glfw/config.gni")
+ 
+-pkg_config("x11") {
+-  packages = [ "x11" ]
+-}
+-
+ pkg_config("gtk") {
+   packages = [ "gtk+-3.0" ]
+ }
+-- 
+2.41.0
+
diff --git a/package/flutter-engine/0003-disable-undefined-version.patch b/package/flutter-engine/0003-disable-undefined-version.patch
new file mode 100644
index 0000000000..468ec4daf9
--- /dev/null
+++ b/package/flutter-engine/0003-disable-undefined-version.patch
@@ -0,0 +1,32 @@
+From 9512040259f3970dd5ca08fd9ebcfd42e7539997 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <aduskett@gmail.com>
+Date: Tue, 18 Jul 2023 15:21:51 -0700
+Subject: [PATCH] Disable undefined-version
+
+This isn't a valid flag for ld, and flutter compiles just fine with the
+no-undefined-version flag.
+
+Upstream: Buildroot specific
+Signed-off-by: Adam Duskett <aduskett@gmail.com>
+---
+ build/config/compiler/BUILD.gn | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
+index 4c9a1ee2b..53fe4a3d5 100644
+--- a/build/config/compiler/BUILD.gn
++++ b/build/config/compiler/BUILD.gn
+@@ -354,8 +354,8 @@ config("compiler") {
+ 
+   # TODO(crbug.com/1374347): Cleanup undefined symbol errors caught by
+   # --no-undefined-version.
+-  if (is_clang && !is_win && !is_mac && !is_ios && !is_wasm) {
+-    ldflags += [ "-Wl,--undefined-version" ]
++  if (!is_clang && !is_win && !is_mac && !is_ios && !is_wasm) {
++    ldflags += [ "-Wl,--no-undefined-version" ]
+   }
+ 
+   # C++ compiler flags setup.
+-- 
+2.41.0
+
diff --git a/package/flutter-engine/0004-pkg-config.py-do-not-prepend-sysroot-path.patch b/package/flutter-engine/0004-pkg-config.py-do-not-prepend-sysroot-path.patch
new file mode 100644
index 0000000000..94da49fdf8
--- /dev/null
+++ b/package/flutter-engine/0004-pkg-config.py-do-not-prepend-sysroot-path.patch
@@ -0,0 +1,34 @@
+From 51e8fed854fd9d373bb9b20d7ed8e7cf6ef12312 Mon Sep 17 00:00:00 2001
+From: Adam Duskett <aduskett@gmail.com>
+Date: Wed, 19 Jul 2023 11:48:59 -0700
+Subject: [PATCH] pkg-config.py: do not prepend sysroot path
+
+The pkg-config script provided by Buildroot already includes the sysroot
+path, causing the pkg-config.py script to double prepend the sysroot path.
+
+IE: output/host/.../sysroot/output/host/.../sysroot
+
+Upstream: Buildroot specific
+Signed-off-by: Adam Duskett <aduskett@gmail.com>
+---
+ build/config/linux/pkg-config.py | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/build/config/linux/pkg-config.py b/build/config/linux/pkg-config.py
+index b4a6aff17..44ffdcaea 100644
+--- a/build/config/linux/pkg-config.py
++++ b/build/config/linux/pkg-config.py
+@@ -207,9 +207,7 @@ def main():
+   all_flags = flag_string.strip().split(' ')
+ 
+ 
+-  sysroot = options.sysroot
+-  if not sysroot:
+-    sysroot = ''
++  sysroot = ''
+ 
+   includes = []
+   cflags = []
+-- 
+2.41.0
+
diff --git a/package/flutter-engine/Config.in b/package/flutter-engine/Config.in
new file mode 100644
index 0000000000..fe72191e77
--- /dev/null
+++ b/package/flutter-engine/Config.in
@@ -0,0 +1,93 @@
+config BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
+	bool
+	default y if BR2_aarch64
+	default y if BR2_arm && !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5
+	default y if BR2_i386
+	default y if BR2_x86_64
+
+config BR2_PACKAGE_FLUTTER_ENGINE
+	bool "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
+	depends on BR2_USE_WCHAR # std::wstring
+	depends on BR2_HOST_GCC_AT_LEAST_5
+	depends on BR2_PACKAGE_HAS_LIBGL || BR2_PACKAGE_HAS_LIBGLES
+	select BR2_PACKAGE_HOST_DEPOT_TOOLS
+	select BR2_PACKAGE_FREETYPE
+	select BR2_PACKAGE_ZLIB
+	help
+	  Flutter is Google's SDK for crafting beautiful, fast user
+	  experience for mobile, web, and desktop from a single
+	  codebase. Flutter works with existing code, is used by
+	  developers and organizations around the world, and is
+	  free and open source.
+
+	  The Flutter Engine is a portable runtime for hosting
+	  Flutter applications. It implements Flutter's core
+	  libraries, including animation and graphics, file and
+	  network I/O, accessibility support, plugin architecture,
+	  and a Dart runtime and compile toolchain. Most developers
+	  will interact with Flutter via the Flutter Framework,
+	  which provides a modern, reactive framework, and a rich
+	  set of platform, layout and foundation widgets.
+
+	  https://github.com/flutter/engine
+
+if BR2_PACKAGE_FLUTTER_ENGINE
+
+choice
+	prompt "Runtime mode"
+	default BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_RELEASE
+	help
+	  Select the runtime mode.
+
+config BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_RELEASE
+	bool "release"
+	help
+	  This build mode is ideal for developers who are looking to
+	  release a high-performance, production-ready application.
+
+config BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_PROFILE
+	bool "profile"
+	help
+	  Profile mode is used for performance profiling and
+	  optimization. This build mode is similar to the development
+	  mode, but it includes more aggressive inlining and
+	  optimization.
+
+config BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_DEBUG
+	bool "debug"
+	help
+	  Includes additional error checking to catch errors at
+	  runtime. This build mode is ideal for developers who are
+	  in the process of writing and testing their applications.
+
+endchoice
+
+config BR2_PACKAGE_FLUTTER_ENGINE_ARTIFACTS
+	bool "build the development artifacts"
+	help
+	  Build the development artifacts used for compiling
+	  flutter applications. This significantly increases the time
+	  to compile.
+
+endif #if BR2_PACKAGE_FLUTTER_ENGINE
+
+comment "flutter-engine needs an OpenGL backend"
+	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"
+	depends on BR2_PACKAGE_FLUTTER_ENGINE_ARM_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
+
+comment "flutter-engine needs a toolchain not affected by GCC bug 64735"
+	depends on BR2_PACKAGE_LLVM_ARCH_SUPPORTS
+	depends on BR2_TOOLCHAIN_HAS_GCC_BUG_64735
diff --git a/package/flutter-engine/flutter-engine.mk b/package/flutter-engine/flutter-engine.mk
new file mode 100644
index 0000000000..aa392a31d8
--- /dev/null
+++ b/package/flutter-engine/flutter-engine.mk
@@ -0,0 +1,286 @@
+################################################################################
+#
+# flutter-engine
+#
+################################################################################
+
+# Flutter-engine has a release on the GitHub page. However, that release is
+# only for Google. Its intended purpose is for the gclient tool provided by
+# Google in their depot-tools package. To use the source code, we must use
+# gclient to download the flutter-engine source code along with several other
+# projects. Unfortunately, the Buildroot download system does not have the
+# capability of using gclient, and considering this package is the only
+# package that uses gclient, we side-step the entire download process and
+# perform the following steps if a tarball does not exist already:
+#
+#  - Copy the pre-made gclient config file to a temporary download
+#    directory.
+#  - Run gclient sync to generate a source directory with the proper
+#    flutter-engine source code in the correct places.
+#  - Run mk_tar_gz to create a tarball.
+#  - Copy the tarball to $(FLUTTER_ENGINE_DL_DIR)
+#    directory to create a reproducible tarball.
+#
+# There is no hash provided, as the gn binary (used for configuration) relies
+# on the .git directories, so there is no way to make reproducible tarballs.
+FLUTTER_ENGINE_VERSION = 3.10.6
+
+# There is nothing for Buildroot to download. This is handled by gclient.
+FLUTTER_ENGINE_SITE =
+FLUTTER_ENGINE_SOURCE =
+FLUTTER_ENGINE_LICENSE = BSD-3-Clause
+FLUTTER_ENGINE_LICENSE_FILES = LICENSE
+FLUTTER_ENGINE_TARBALL_PATH = $(FLUTTER_ENGINE_DL_DIR)/flutter-$(FLUTTER_ENGINE_VERSION).tar.gz
+FLUTTER_ENGINE_INSTALL_STAGING = YES
+FLUTTER_ENGINE_DOWNLOAD_DEPENDENCIES = host-depot-tools
+FLUTTER_ENGINE_DEPENDENCIES = \
+	host-clang \
+	host-ninja \
+	host-pkgconf \
+	freetype \
+	zlib
+
+# Dispatch all architectures of flutter
+ifeq ($(BR2_i386),y)
+FLUTTER_ENGINE_TARGET_ARCH = x86
+FLUTTER_ENGINE_TARGET_TRIPPLE = x86-linux
+else ifeq ($(BR2_x86_64),y)
+FLUTTER_ENGINE_TARGET_ARCH = x64
+FLUTTER_ENGINE_TARGET_TRIPPLE = x86_64-linux
+else ifeq ($(BR2_arm)$(BR2_armeb),y)
+FLUTTER_ENGINE_TARGET_ARCH = arm
+FLUTTER_ENGINE_TARGET_TRIPPLE = arm-linux
+else ifeq ($(BR2_aarch64),y)
+FLUTTER_ENGINE_TARGET_ARCH = arm64
+FLUTTER_ENGINE_TARGET_TRIPPLE = aarch64-linux
+endif
+
+ifeq ($(BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_RELEASE),y)
+FLUTTER_ENGINE_RUNTIME_MODE=release
+else ifeq ($(BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_PROFILE),y)
+FLUTTER_ENGINE_RUNTIME=profile
+else
+FLUTTER_ENGINE_RUNTIME=debug
+endif
+
+FLUTTER_ENGINE_BUILD_DIR = \
+	$(@D)/out/linux_$(FLUTTER_ENGINE_RUNTIME_MODE)_$(FLUTTER_ENGINE_TARGET_ARCH)
+
+FLUTTER_ENGINE_INSTALL_FILES = libflutter_engine.so libflutter_linux_gtk.so
+
+FLUTTER_ENGINE_CONF_OPTS = \
+	--clang \
+	--depot-tools $(HOST_DIR)/share/depot_tools \
+	--embedder-for-target \
+	--linux-cpu $(FLUTTER_ENGINE_TARGET_ARCH) \
+	--no-build-embedder-examples \
+	--no-clang-static-analyzer \
+	--no-enable-unittests \
+	--no-goma \
+	--no-prebuilt-dart-sdk \
+	--runtime-mode $(FLUTTER_ENGINE_RUNTIME_MODE) \
+	--target-os linux \
+	--target-sysroot $(STAGING_DIR) \
+	--target-toolchain $(HOST_DIR) \
+	--target-triple $(FLUTTER_ENGINE_TARGET_TRIPPLE)
+
+ifeq ($(BR2_arm)$(BR2_armeb),y)
+FLUTTER_ENGINE_CONF_OPTS += \
+	--arm-float-abi $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
+endif
+
+ifeq ($(BR2_PACKAGE_FLUTTER_ENGINE_ARTIFACTS),y)
+FLUTTER_ENGINE_CONF_OPTS += --build-engine-artifacts
+else
+FLUTTER_ENGINE_CONF_OPTS += --no-build-engine-artifacts
+endif
+
+ifeq ($(BR2_OPTIMIZE_0),y)
+FLUTTER_ENGINE_CONF_OPTS += --unoptimized
+endif
+
+ifeq ($(BR2_ENABLE_LTO),y)
+FLUTTER_ENGINE_CONF_OPTS += --lto
+else
+FLUTTER_ENGINE_CONF_OPTS += --no-lto
+endif
+
+ifeq ($(BR2_STRIP_strip),y)
+FLUTTER_ENGINE_CONF_OPTS += --stripped
+else
+FLUTTER_ENGINE_CONF_OPTS += --no-stripped
+endif
+
+ifeq ($(BR2_PACKAGE_FONTCONFIG),y)
+FLUTTER_ENGINE_DEPENDENCIES += fontconfig
+FLUTTER_ENGINE_CONF_OPTS += --enable-fontconfig
+endif
+
+ifeq ($(BR2_PACKAGE_HAS_LIBGL),y)
+FLUTTER_ENGINE_DEPENDENCIES += libgl
+endif
+
+ifeq ($(BR2_PACKAGE_HAS_LIBGLES),y)
+FLUTTER_ENGINE_DEPENDENCIES += libgles
+endif
+
+ifeq ($(BR2_PACKAGE_MESA3D),y)
+FLUTTER_ENGINE_DEPENDENCIES += mesa3d
+endif
+
+ifeq ($(BR2_PACKAGE_MESA3D_VULKAN_DRIVER),y)
+FLUTTER_ENGINE_CONF_OPTS += --enable-vulkan
+endif
+
+ifneq ($(BR2_PACKAGE_XORG7)$(BR2_PACKAGE_LIBXCB),yy)
+define FLUTTER_ENGINE_VULKAN_X11_SUPPORT_FIXUP
+	$(SED) "s%vulkan_use_x11.*%vulkan_use_x11 = false%g" -i \
+		$(@D)/build_overrides/vulkan_headers.gni
+endef
+FLUTTER_ENGINE_PRE_CONFIGURE_HOOKS += FLUTTER_ENGINE_VULKAN_X11_SUPPORT_FIXUP
+else
+FLUTTER_ENGINE_DEPENDENCIES += libxcb
+endif
+
+ifneq ($(BR2_PACKAGE_WAYLAND),y)
+define FLUTTER_ENGINE_VULKAN_WAYLAND_SUPPORT_FIXUP
+	$(SED) "s%vulkan_use_wayland.*%vulkan_use_wayland = false%g" \
+		$(@D)/build_overrides/vulkan_headers.gni
+endef
+FLUTTER_ENGINE_PRE_CONFIGURE_HOOKS += FLUTTER_ENGINE_VULKAN_WAYLAND_SUPPORT_FIXUP
+else
+FLUTTER_ENGINE_DEPENDENCIES += wayland
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGTK3),y)
+FLUTTER_ENGINE_DEPENDENCIES += libgtk3
+else
+FLUTTER_ENGINE_CONF_OPTS += --disable-desktop-embeddings
+endif
+
+ifeq ($(BR2_PACKAGE_LIBGLFW),y)
+FLUTTER_ENGINE_DEPENDENCIES += libglfw
+FLUTTER_ENGINE_CONF_OPTS += --build-glfw-shell
+else
+FLUTTER_ENGINE_CONF_OPTS += --no-build-glfw-shell
+endif
+
+# The clang toolchain wrapper causes a lot of the following errors:
+# error: -Wl,-z,now: 'linker' input unused [-Werror,-Wunused-command-line-argument]
+# error: -Wl,-z,relro: 'linker' input unused [-Werror,-Wunused-command-line-argument]
+# Excplicitly use the real clang binaries for cc and cxx.
+ifeq ($(BR2_CCACHE),y)
+define FLUTTER_ENGINE_COMPILER_PATH_FIXUP
+	$(SED) "s%cc =.*%cc = \"\$${toolchain_bin}/ccache clang.br_real\""%g \
+		$(@D)/build/toolchain/custom/BUILD.gn
+
+	$(SED) "s%cxx =.*%cxx = \"\$${toolchain_bin}/ccache clang++.br_real\""%g \
+		$(@D)/build/toolchain/custom/BUILD.gn
+endef
+else
+define FLUTTER_ENGINE_COMPILER_PATH_FIXUP
+	$(SED) "s%cc =.*%cc = \"\$${toolchain_bin}/clang.br_real\""%g \
+		$(@D)/build/toolchain/custom/BUILD.gn
+
+	$(SED) "s%cxx =.*%cxx = \"\$${toolchain_bin}/clang++.br_real\""%g \
+		$(@D)/build/toolchain/custom/BUILD.gn
+endef
+endif
+FLUTTER_ENGINE_PRE_CONFIGURE_HOOKS += FLUTTER_ENGINE_COMPILER_PATH_FIXUP
+
+# If using per_package builds, flutter-engine tries to use the /usr/bin/ld instead of
+# the one provided by the compiler, resulting in linking errors.
+ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
+define FLUTTER_ENGINE_GET_PATH
+	(ld_bin_path=$$(dirname $$(realpath $$(find $(PER_PACKAGE_DIR)/flutter-engine -name ld -type f))); \
+		echo $${ld_bin_path}:$(BR_PATH):$(HOST_DIR)/share/depot_tools; \
+	)
+endef
+else
+define FLUTTER_ENGINE_GET_PATH
+		echo $(BR_PATH):$(HOST_DIR)/share/depot_tools
+endef
+endif
+
+# Generate a tarball if one does not already exist.
+define FLUTTER_ENGINE_GENERATE_TARBALL
+	(if [ ! -e $(FLUTTER_ENGINE_TARBALL_PATH) ]; then \
+		. ./support/download/helpers && \
+		rm -rf $(@D)/dl-tmp && mkdir -p $(@D)/dl-tmp && \
+		$(INSTALL) -D -m 0755 $(FLUTTER_ENGINE_PKGDIR)/gclient \
+			$(@D)/dl-tmp/.gclient && \
+		$(SED) "s%!FLUTTER_VERSION!%$(FLUTTER_ENGINE_VERSION)%g" \
+			$(@D)/dl-tmp/.gclient && \
+		cd $(@D)/dl-tmp && \
+		$(DEPOT_TOOLS_GCLIENT) \
+			sync \
+			--delete_unversioned_trees \
+			-j$(PARALLEL_JOBS) \
+			--no-history \
+			--reset \
+			--shallow && \
+		mkdir -p $(FLUTTER_ENGINE_DL_DIR); \
+		cd $(@D)/dl-tmp && \
+		mk_tar_gz \
+		$(@D)/dl-tmp/src \
+		flutter-$(FLUTTER_ENGINE_VERSION) \
+		"$$(git -C $(@D)/dl-tmp/src log -1 --pretty=format:%ci)" \
+		$(FLUTTER_ENGINE_TARBALL_PATH) && \
+		rm -rf $(@D)/dl-tmp; \
+	fi \
+	)
+endef
+FLUTTER_ENGINE_POST_DOWNLOAD_HOOKS += FLUTTER_ENGINE_GENERATE_TARBALL
+
+define FLUTTER_ENGINE_EXTRACT_CMDS
+	gzip -d -c $(FLUTTER_ENGINE_TARBALL_PATH) | tar --strip-components 1 -C $(@D) -xf -
+endef
+
+define FLUTTER_ENGINE_CONFIGURE_CMDS
+  # libtessellator requires these three files, but the toolchain path isn't
+  # referenced when linking. Copy them to the staging lib directory before
+  # building.
+	$(Q)$(foreach i,crtbeginS.o crtendS.o libgcc.a,
+		$(Q)if [ ! -e $(STAGING_DIR)/usr/lib/$(i) ]; then \
+			file_path=$$(find $(HOST_DIR) -type f -name $(i)); \
+			$(INSTALL) -D -m 0755 $${file_path} $(STAGING_DIR)/usr/lib/$(i); \
+		fi \
+	)
+	(cd $(@D)/ && \
+		rm -rf $(FLUTTER_ENGINE_BUILD_DIR) && \
+		PATH=$(shell $(call FLUTTER_ENGINE_GET_PATH)) \
+		./flutter/tools/gn $(FLUTTER_ENGINE_CONF_OPTS) \
+	)
+endef
+
+define FLUTTER_ENGINE_BUILD_CMDS
+	(cd $(@D); \
+		PATH=$(shell $(call FLUTTER_ENGINE_GET_PATH)) \
+		PYTHONNOUSERSITE=y \
+		$(HOST_DIR)/bin/ninja \
+			-j $(PARALLEL_JOBS) \
+			-C $(FLUTTER_ENGINE_BUILD_DIR) \
+	)
+endef
+
+define FLUTTER_ENGINE_INSTALL_STAGING_CMDS
+	$(foreach i,$(FLUTTER_ENGINE_INSTALL_STAGING_FILES),
+		$(Q)if [ -e $(FLUTTER_ENGINE_BUILD_DIR)/$(i) ]; then \
+			$(INSTALL) -D -m 0755 $(FLUTTER_ENGINE_BUILD_DIR)/$(i) \
+				$(STAGING_DIR)/usr/lib/$(i); \
+		fi \
+	)
+	$(INSTALL) -D -m 0755 $(FLUTTER_ENGINE_BUILD_DIR)/flutter_embedder.h \
+		$(STAGING_DIR)/usr/include/flutter_embedder.h
+endef
+
+define FLUTTER_ENGINE_INSTALL_TARGET_CMDS
+	$(foreach i,$(FLUTTER_ENGINE_INSTALL_FILES),
+		$(Q)if [ -e $(FLUTTER_ENGINE_BUILD_DIR)/$(i) ]; then \
+			$(INSTALL) -D -m 0755 $(FLUTTER_ENGINE_BUILD_DIR)/$(i) \
+				$(TARGET_DIR)/usr/lib/$(i); \
+		fi \
+	)
+endef
+
+$(eval $(generic-package))
diff --git a/package/flutter-engine/gclient b/package/flutter-engine/gclient
new file mode 100644
index 0000000000..168e9a368d
--- /dev/null
+++ b/package/flutter-engine/gclient
@@ -0,0 +1,16 @@
+# This file is taken from the output of meta-flutter/lib/gn.py
+
+solutions = [{
+    "managed": False,
+    "name": "src/flutter",
+    "url": "https://github.com/flutter/engine.git@!FLUTTER_VERSION!",
+    "custom_vars": {
+        "download_android_deps": False,
+        "download_windows_deps": False,
+        "download_linux_deps": False
+    },
+    "custom_deps": {
+        "src/third_party/dart/third_party/pkg/tools":
+        "https://dart.googlesource.com/tools.git@unified_analytics-v1.1.0"
+    }
+}]
-- 
2.41.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [Buildroot] [PATCH vRFC 0/3] Initial flutter packages
  2023-07-20 23:36 [Buildroot] [PATCH vRFC 0/3] Initial flutter packages Adam Duskett
                   ` (2 preceding siblings ...)
  2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 3/3] package/flutter-engine: " Adam Duskett
@ 2023-07-20 23:37 ` Adam Duskett
  3 siblings, 0 replies; 8+ messages in thread
From: Adam Duskett @ 2023-07-20 23:37 UTC (permalink / raw)
  To: buildroot
  Cc: Angelo Compagnucci, Michael Trimarchi, Asaf Kahlon, Thomas Petazzoni


[-- Attachment #1.1: Type: text/plain, Size: 4922 bytes --]

Sorry about sending this patchset twice, I forgot to sign up for the
mailing list under my Amarula email address. :)

Adam Duskett

Senior Embedded Systems Developer

M. +1208-515-8102

adam.duskett@amarulasolutions.com

__________________________________


Amarula Solutions BV

Joop Geesinkweg 125, 1114 AB, Amsterdam, NL

T. +31 (0)85 111 9170
info@amarulasolutions.com

www.amarulasolutions.com



On Thu, Jul 20, 2023 at 4:36 PM Adam Duskett <
adam.duskett@amarulasolutions.com> wrote:

> Preface: Thank you for all the help, thoughts and insight for this initial
> RFC of the flutter-engine library. There are many other flutter packages
> that
> need to be ported, but this is the largest hurdle to overcome.
>
> There are many issues with the flutter-engine package:
>
> - The release tarballs from https://github.com/flutter/engine are in no
> state
>   to compile. They are only for the use of gclient to download a source
>   directory structure suitable to build the Flutter engine! If you
> download,
>   extract and attempt to run `./tools/gn --no-goma
> --no-prebuilt-dart-sdk`, you
>   receive the error message:
>   `No such file or directory: 'flutter/flutter/third_party/gn/gn.'
>
>   But wait! Wasn't the gn binary just called? No, that's a wrapper in the
>   Flutter source tree that formats arguments to call the real gn binary.
>   The real gn is not provided in the tarball but is downloaded via gclient
>   (among many other supporting repositories.)
>
>   Even worse, the flutter repository depends on the .git dirs being
> present.
>   (https://github.com/meta-flutter/meta-flutter/issues/271) This
> dependency
>   means it is not possible to create a reproducible tarball from the
> downloaded
>   sources, which is why there is no .hash file provided.
>
>   I have asked the flutter project to release full tarballs suitable for
>   compiling here: https://github.com/flutter/flutter/issues/130734
>
> - The clang toolchain wrapper does not work properly, resulting in the
> immediate
>   errors of:
>     -Wl,-z,now: 'linker' input unused
>     -Wl,-z,relro: 'linker' input unused
>   The solution is to use clang.br_real and clang++.br_real.
>
> - If using per_package builds, flutter-engine tries to use the host
> /usr/bin/ld
>   instead of the one provided by the compiler, resulting in linking errors.
>   As such, if BR2_PER_PACKAGE_DIRECTORIES is enabled, we search for the ld
>   provided by the compiler in the host directory and set the path
> accordingly.
>
> - libtessellator.so (built by flutter) requires three files:
>   crtbeginS.o crtendS.o libgcc.a. However, the toolchain path isn't
> referenced
>   when linking. The solution is to copy those three files to the staging
> lib
>   directory before building.
>
> Tested with:
>   - Debian 11 and 12
>   - Ubuntu 18.04, 20.04, and 22.04
>   - Fedora 38
>   - Per package directory enabled and disabled
>   - x86_64, arm64
>
> Adam Duskett (3):
>   package/python-httplib2: add host variant
>   package/depot-tools: new package
>   package/flutter-engine: new package
>
>  DEVELOPERS                                    |   4 +
>  package/Config.in                             |   1 +
>  package/Config.in.host                        |   1 +
>  .../0001-Disable-ninjalog-upload.patch        |  35 +++
>  package/depot-tools/Config.in.host            |  10 +
>  package/depot-tools/depot-tools.hash          |   3 +
>  package/depot-tools/depot-tools.mk            |  33 ++
>  .../0001-disable-pre-canned-sysroot.patch     |  32 ++
>  .../0002-remove-explicit-x11-dependency.patch |  33 ++
>  .../0003-disable-undefined-version.patch      |  32 ++
>  ...onfig.py-do-not-prepend-sysroot-path.patch |  34 +++
>  package/flutter-engine/Config.in              |  93 ++++++
>  package/flutter-engine/flutter-engine.mk      | 286 ++++++++++++++++++
>  package/flutter-engine/gclient                |  16 +
>  package/python-httplib2/python-httplib2.mk    |   1 +
>  15 files changed, 614 insertions(+)
>  create mode 100644 package/depot-tools/0001-Disable-ninjalog-upload.patch
>  create mode 100644 package/depot-tools/Config.in.host
>  create mode 100644 package/depot-tools/depot-tools.hash
>  create mode 100644 package/depot-tools/depot-tools.mk
>  create mode 100644
> package/flutter-engine/0001-disable-pre-canned-sysroot.patch
>  create mode 100644
> package/flutter-engine/0002-remove-explicit-x11-dependency.patch
>  create mode 100644
> package/flutter-engine/0003-disable-undefined-version.patch
>  create mode 100644
> package/flutter-engine/0004-pkg-config.py-do-not-prepend-sysroot-path.patch
>  create mode 100644 package/flutter-engine/Config.in
>  create mode 100644 package/flutter-engine/flutter-engine.mk
>  create mode 100644 package/flutter-engine/gclient
>
> --
> 2.41.0
>
>

[-- Attachment #1.2: Type: text/html, Size: 9360 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Buildroot] [PATCH vRFC 2/3] package/depot-tools: new package
  2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 2/3] package/depot-tools: new package Adam Duskett
@ 2023-07-23 19:52   ` Yann E. MORIN
  0 siblings, 0 replies; 8+ messages in thread
From: Yann E. MORIN @ 2023-07-23 19:52 UTC (permalink / raw)
  To: Adam Duskett
  Cc: Angelo Compagnucci, Michael Trimarchi, Thomas Petazzoni,
	Asaf Kahlon, buildroot

Adam, All,

On 2023-07-20 16:36 -0700, Adam Duskett spake thusly:
> Chromium and Chromium OS use a package of scripts called
> depot_tools to manage checkouts and code reviews. This package
> also includes the gclient utility.
> 
> gclient is a Python script to manage a workspace of modular dependencies that
> are each checked out independently from different subversion or git
> repositories. Features include:
> 
>   - Dependencies can be specified on a per-OS basis.
>   - Dependencies can be specified relative to their parent dependency.
>   - Variables can be used to abstract concepts.
>   - Hooks can be specified to be run after a checkout.
>   - .gclient and DEPS are Python scripts. You can hack in easily or add
>      additional configuration data.
> 
> .gclient file: It's the primary file. It is, in fact, a Python script. It
> specifies the following variables:
> 
>   - solutions: an array of dictionaries specifying the projects that will be
>                fetched.
>   - hooks: additional hooks to be run when this meta checkout is synced.
>   - target_os: an optional array of (target) operating systems to fetch
>                OS-specific dependencies for.
>   - cache_dir: Primarily for bots, multiple working sets use a single git
>                cache.
> 
> gclient is necessary for checking out the flutter-engine source code, as the
> release tarballs provided on the flutter-engine github are in no state to
> compile. Google expects the use of gclient to download a source directory
> structure suitable to build the Flutter engine.

Thanks for this very detailed commit log.

> Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
[--SNIP--]
> diff --git a/package/depot-tools/0001-Disable-ninjalog-upload.patch b/package/depot-tools/0001-Disable-ninjalog-upload.patch
> new file mode 100644
> index 0000000000..55fd78247f
> --- /dev/null
> +++ b/package/depot-tools/0001-Disable-ninjalog-upload.patch
> @@ -0,0 +1,35 @@
> +From eeea6ad620b88a81a4b05d49f32a375b4bbcef36 Mon Sep 17 00:00:00 2001
> +From: Adam Duskett <aduskett@gmail.com>
> +Date: Thu, 13 Jul 2023 15:50:25 -0700
> +Subject: [PATCH] Disable ninjalog upload
> +
> +Google doesn't need the ninja logs.
> +
> +Upstream: buildroot-specific.
> +Signed-off-by: Adam Duskett <aduskett@gmail.com>
> +---
> + autoninja | 4 ++--
> + 1 file changed, 2 insertions(+), 2 deletions(-)
> +
> +diff --git a/autoninja b/autoninja
> +index 06d45d1..354a2f1 100755
> +--- a/autoninja
> ++++ b/autoninja
> +@@ -30,12 +30,12 @@ if eval "$command"; then
> +   fi
> + 
> +   # Collect ninjalog from googler.
> +-  python3 "$(dirname -- "$0")/ninjalog_uploader_wrapper.py" --cmd $command
> ++  # python3 "$(dirname -- "$0")/ninjalog_uploader_wrapper.py" --cmd $command

Don't comment lines out, just remove them (with the associated comment
while at it).

> +   exit
> + fi
> + 
> + # Collect ninjalog from googler.
> +-python3 "$(dirname -- "$0")/ninjalog_uploader_wrapper.py" --cmd $command
> ++# python3 "$(dirname -- "$0")/ninjalog_uploader_wrapper.py" --cmd $command

Ditto.

[--SNIP--]
> diff --git a/package/depot-tools/depot-tools.mk b/package/depot-tools/depot-tools.mk
> new file mode 100644
> index 0000000000..906340016c
> --- /dev/null
> +++ b/package/depot-tools/depot-tools.mk
> @@ -0,0 +1,33 @@
> +################################################################################
> +#
> +# depot-tools
> +#
> +################################################################################
> +
> +DEPOT_TOOLS_VERSION = 4e87f5bfe244e903f712408ea68dc3c3a6fe2d00
> +DEPOT_TOOLS_SITE = https://chromium.googlesource.com/chromium/tools/depot_tools
> +DEPOT_TOOLS_SITE_METHOD = git
> +DEPOT_TOOLS_LICENSE = Chromium

The license in the LICENSE file looks suspiciously like it is in fact a
BSD-3-Clause:
    https://spdx.org/licenses/BSD-3-Clause.html

> +DEPOT_TOOLS_LICENSE_FILES = LICENSE
> +DEPOT_TOOLS_CPE_ID_VENDOR = google
> +HOST_DEPOT_TOOLS_DEPENDENCIES = \
> +	host-python3 \
> +	host-python-httplib2 \
> +	host-python-pyparsing \
> +	host-python-six
> +
> +define HOST_DEPOT_TOOLS_INSTALL_CMDS
> +	mkdir -p $(HOST_DIR)/share/depot_tools
> +	cp -dprf $(@D)/* $(HOST_DIR)/share/depot_tools/
> +endef
> +
> +# Helper wrapper to make using gclient easier.
> +DEPOT_TOOLS_GCLIENT=\

Spaces on both sides of the equal sign.

> +	PATH=$(BR_PATH):$(HOST_DIR)/share/depot_tools \
> +	LD_LIBRARY_PATH=$(HOST_DIR)/lib \

Ick. Why do we need to set LD_LIBRARY_PATH?

> +	PYTHONPATH=$(HOST_DIR)/lib/python$(PYTHON3_VERSION_MAJOR) \

PYTHONPATH=$(PYTHON3_PATH)

Why do we need to force it?

> +	DEPOT_TOOLS_UPDATE=0 \
> +	PYTHONDONTWRITEBYTECODE=1 \

Why do we need PYTHONDONTWRITEBYTECODE=1? I have it in my environment to
avoid littering repositories, indeed, but why do we need to force it for
gclient?

Regards,
Yann E. MORIN.

> +	$(HOST_DIR)/share/depot_tools/gclient.py
> +
> +$(eval $(host-generic-package))
> -- 
> 2.41.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Buildroot] [PATCH vRFC 3/3] package/flutter-engine: new package
  2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 3/3] package/flutter-engine: " Adam Duskett
@ 2023-07-23 21:26   ` Yann E. MORIN
  2023-07-25 15:38     ` Adam Duskett
  0 siblings, 1 reply; 8+ messages in thread
From: Yann E. MORIN @ 2023-07-23 21:26 UTC (permalink / raw)
  To: Adam Duskett
  Cc: Angelo Compagnucci, Michael Trimarchi, Thomas Petazzoni,
	Asaf Kahlon, buildroot

Adam, All,

On 2023-07-20 16:36 -0700, Adam Duskett spake thusly:
> There are many issues with this package:
> 
> - The release tarballs from https://github.com/flutter/engine are in no state
>   to compile. They are only for the use of gclient to download a source
>   directory structure suitable to build the Flutter engine! If you download,
>   extract and attempt to run `./tools/gn --no-goma --no-prebuilt-dart-sdk`, you
>   receive the error message:
>   `No such file or directory: 'flutter/flutter/third_party/gn/gn.'
> 
>   But wait! Wasn't the gn binary just called? No, that's a wrapper in the
>   Flutter source tree that formats arguments to call the real gn binary.
>   The real gn is not provided in the tarball but is downloaded via gclient
>   (among many other supporting repositories.)
> 
>   Even worse, the flutter repository depends on the .git dirs being present.

s/flutter repository/flutter buildsystem/  maybe?

>   (https://github.com/meta-flutter/meta-flutter/issues/271) This dependency
>   means it is not possible to create a reproducible tarball from the downloaded
>   sources, which is why there is no .hash file provided.
> 
>   I have asked the flutter project to release full tarballs suitable for
>   compiling here: https://github.com/flutter/flutter/issues/130734
> 
> - The clang toolchain wrapper does not work properly, resulting in the immediate
>   errors of:
>     -Wl,-z,now: 'linker' input unused
>     -Wl,-z,relro: 'linker' input unused

Those two are us adding them because of BR2_RELRO_FULL (-Wl,-z,relro
alone would be due to BR2_RELRO_PARTIAL).

It does recognise that they are linker options, but why are they
rejected? Do you have more context to provide?

>   The solution is to use clang.br_real and clang++.br_real.

Most probably not, because you lose a lot of the options set by
Buildroot (optimisation ,target CPU, etc...). The real solution is to
understand why -Wl-z-relro/now are rejected, and if they really are not
needed, to find a way to tell the toolchain wrapper not set them for
clang tools.

> - If using per_package builds, flutter-engine tries to use the host /usr/bin/ld
>   instead of the one provided by the compiler, resulting in linking errors.
>   As such, if BR2_PER_PACKAGE_DIRECTORIES is enabled, we search for the ld
>   provided by the compiler in the host directory and set the path accordingly.

Can this be related to the above -Wl issue?

> - libtessellator.so (built by flutter) requires three files:
>   crtbeginS.o crtendS.o libgcc.a. However, the toolchain path isn't referenced
>   when linking. The solution is to copy those three files to the staging lib
>   directory before building.
> 
> Tested with:
>   - Debian 11 and 12
>   - Ubuntu 18.04, 20.04, and 22.04
>   - Fedora 38
>   - Per package directory enabled and disabled
>   - x86_64, arm64
> 
> Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
> ---
[--SNIP--]
> diff --git a/package/flutter-engine/0001-disable-pre-canned-sysroot.patch b/package/flutter-engine/0001-disable-pre-canned-sysroot.patch
> new file mode 100644
> index 0000000000..c4064a77c9
> --- /dev/null
> +++ b/package/flutter-engine/0001-disable-pre-canned-sysroot.patch
> @@ -0,0 +1,32 @@
> +From 49a14e693124dc34f2cccbfb755d01a1198aa6bf Mon Sep 17 00:00:00 2001
> +From: Adam Duskett <adam.duskett@amarulasolutions.com>

You're not the author; Joel Winarske is. That's also the authorship
there is in the upstream issue you referenced.

[--SNIP--]
> diff --git a/package/flutter-engine/0002-remove-explicit-x11-dependency.patch b/package/flutter-engine/0002-remove-explicit-x11-dependency.patch
> new file mode 100644
> index 0000000000..1345d4a3dd
> --- /dev/null
> +++ b/package/flutter-engine/0002-remove-explicit-x11-dependency.patch
> @@ -0,0 +1,33 @@
> +From b1a5db9318ca33a03f2700758d5debad907d21b6 Mon Sep 17 00:00:00 2001
> +From: Adam Duskett <adam.duskett@amarulasolutions.com>

Ditto

> +Date: Wed, 19 Jul 2023 15:26:40 -0700
> +Subject: [PATCH] remove explicit x11 dependency
> +
> +This is redundant, as the gtk pkg-config query will reference x11 if that's how

Not so much redundant, but rather superfluous and may conflict with the
actual rendering system used in gtk3 (e.g. wayland).

> diff --git a/package/flutter-engine/0003-disable-undefined-version.patch b/package/flutter-engine/0003-disable-undefined-version.patch
> new file mode 100644
> index 0000000000..468ec4daf9
> --- /dev/null
> +++ b/package/flutter-engine/0003-disable-undefined-version.patch
> @@ -0,0 +1,32 @@
> +From 9512040259f3970dd5ca08fd9ebcfd42e7539997 Mon Sep 17 00:00:00 2001
> +From: Adam Duskett <aduskett@gmail.com>
> +Date: Tue, 18 Jul 2023 15:21:51 -0700
> +Subject: [PATCH] Disable undefined-version
> +
> +This isn't a valid flag for ld, and flutter compiles just fine with the
> +no-undefined-version flag.

Without that option, the linker will just ignore a symbol with an
undefined version. With the option, a smbol with an undefined version
turns into an error.

So indeed, without the option, the check is relaxed so it is not
surprising the build does not fail.

[--SNIP--]
> diff --git a/package/flutter-engine/Config.in b/package/flutter-engine/Config.in
> new file mode 100644
> index 0000000000..fe72191e77
> --- /dev/null
> +++ b/package/flutter-engine/Config.in
> @@ -0,0 +1,93 @@
> +config BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
> +	bool
> +	default y if BR2_aarch64
> +	default y if BR2_arm && !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5
> +	default y if BR2_i386
> +	default y if BR2_x86_64

Since it uses clang, i'd also add: BR2_PACKAGE_LLVM_ARCH_SUPPORTS, but
this is a bit fuzzy for me what option we should add, if any...

> +
> +config BR2_PACKAGE_FLUTTER_ENGINE
> +	bool "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
> +	depends on BR2_USE_WCHAR # std::wstring
> +	depends on BR2_HOST_GCC_AT_LEAST_5
> +	depends on BR2_PACKAGE_HAS_LIBGL || BR2_PACKAGE_HAS_LIBGLES
> +	select BR2_PACKAGE_HOST_DEPOT_TOOLS
> +	select BR2_PACKAGE_FREETYPE
> +	select BR2_PACKAGE_ZLIB
> +	help
> +	  Flutter is Google's SDK for crafting beautiful, fast user
> +	  experience for mobile, web, and desktop from a single
> +	  codebase. Flutter works with existing code, is used by
> +	  developers and organizations around the world, and is
> +	  free and open source.
> +
> +	  The Flutter Engine is a portable runtime for hosting
> +	  Flutter applications. It implements Flutter's core
> +	  libraries, including animation and graphics, file and
> +	  network I/O, accessibility support, plugin architecture,
> +	  and a Dart runtime and compile toolchain. Most developers
> +	  will interact with Flutter via the Flutter Framework,
> +	  which provides a modern, reactive framework, and a rich
> +	  set of platform, layout and foundation widgets.
> +
> +	  https://github.com/flutter/engine
> +
> +if BR2_PACKAGE_FLUTTER_ENGINE
> +
> +choice
> +	prompt "Runtime mode"
> +	default BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_RELEASE

Mabye:
    default BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_DEBUG if BR2_ENABLE_RUNTIME_DEBUG
    default BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_RELEASE

Which brings up the question: do we need the profile mode in Buildroot,
or can we settle with just Release vs. Debug?

If so, then no need for this choice; just test BR2_ENABLE_RUNTIME_DEBUG
in flutter.mk

[--SNIP--]
> diff --git a/package/flutter-engine/flutter-engine.mk b/package/flutter-engine/flutter-engine.mk
> new file mode 100644
> index 0000000000..aa392a31d8
> --- /dev/null
> +++ b/package/flutter-engine/flutter-engine.mk
> @@ -0,0 +1,286 @@
> +################################################################################
> +#
> +# flutter-engine
> +#
> +################################################################################
> +
> +# Flutter-engine has a release on the GitHub page. However, that release is
> +# only for Google. Its intended purpose is for the gclient tool provided by
> +# Google in their depot-tools package. To use the source code, we must use
> +# gclient to download the flutter-engine source code along with several other
> +# projects. Unfortunately, the Buildroot download system does not have the
> +# capability of using gclient, and considering this package is the only
> +# package that uses gclient, we side-step the entire download process and
> +# perform the following steps if a tarball does not exist already:
> +#
> +#  - Copy the pre-made gclient config file to a temporary download
> +#    directory.
> +#  - Run gclient sync to generate a source directory with the proper
> +#    flutter-engine source code in the correct places.
> +#  - Run mk_tar_gz to create a tarball.
> +#  - Copy the tarball to $(FLUTTER_ENGINE_DL_DIR)
> +#    directory to create a reproducible tarball.
> +#
> +# There is no hash provided, as the gn binary (used for configuration) relies
> +# on the .git directories, so there is no way to make reproducible tarballs.
> +FLUTTER_ENGINE_VERSION = 3.10.6
> +
> +# There is nothing for Buildroot to download. This is handled by gclient.
> +FLUTTER_ENGINE_SITE =
> +FLUTTER_ENGINE_SOURCE =
> +FLUTTER_ENGINE_LICENSE = BSD-3-Clause
> +FLUTTER_ENGINE_LICENSE_FILES = LICENSE
> +FLUTTER_ENGINE_TARBALL_PATH = $(FLUTTER_ENGINE_DL_DIR)/flutter-$(FLUTTER_ENGINE_VERSION).tar.gz
> +FLUTTER_ENGINE_INSTALL_STAGING = YES
> +FLUTTER_ENGINE_DOWNLOAD_DEPENDENCIES = host-depot-tools
> +FLUTTER_ENGINE_DEPENDENCIES = \
> +	host-clang \
> +	host-ninja \
> +	host-pkgconf \
> +	freetype \
> +	zlib
> +
> +# Dispatch all architectures of flutter
> +ifeq ($(BR2_i386),y)
> +FLUTTER_ENGINE_TARGET_ARCH = x86
> +FLUTTER_ENGINE_TARGET_TRIPPLE = x86-linux
> +else ifeq ($(BR2_x86_64),y)
> +FLUTTER_ENGINE_TARGET_ARCH = x64
> +FLUTTER_ENGINE_TARGET_TRIPPLE = x86_64-linux
> +else ifeq ($(BR2_arm)$(BR2_armeb),y)
> +FLUTTER_ENGINE_TARGET_ARCH = arm
> +FLUTTER_ENGINE_TARGET_TRIPPLE = arm-linux
> +else ifeq ($(BR2_aarch64),y)
> +FLUTTER_ENGINE_TARGET_ARCH = arm64
> +FLUTTER_ENGINE_TARGET_TRIPPLE = aarch64-linux
> +endif
> +
> +ifeq ($(BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_RELEASE),y)
> +FLUTTER_ENGINE_RUNTIME_MODE=release
> +else ifeq ($(BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_PROFILE),y)
> +FLUTTER_ENGINE_RUNTIME=profile
> +else
> +FLUTTER_ENGINE_RUNTIME=debug
> +endif
> +
> +FLUTTER_ENGINE_BUILD_DIR = \
> +	$(@D)/out/linux_$(FLUTTER_ENGINE_RUNTIME_MODE)_$(FLUTTER_ENGINE_TARGET_ARCH)
> +
> +FLUTTER_ENGINE_INSTALL_FILES = libflutter_engine.so libflutter_linux_gtk.so
> +
> +FLUTTER_ENGINE_CONF_OPTS = \
> +	--clang \
> +	--depot-tools $(HOST_DIR)/share/depot_tools \
> +	--embedder-for-target \
> +	--linux-cpu $(FLUTTER_ENGINE_TARGET_ARCH) \
> +	--no-build-embedder-examples \
> +	--no-clang-static-analyzer \
> +	--no-enable-unittests \
> +	--no-goma \
> +	--no-prebuilt-dart-sdk \
> +	--runtime-mode $(FLUTTER_ENGINE_RUNTIME_MODE) \
> +	--target-os linux \
> +	--target-sysroot $(STAGING_DIR) \
> +	--target-toolchain $(HOST_DIR) \
> +	--target-triple $(FLUTTER_ENGINE_TARGET_TRIPPLE)
> +
> +ifeq ($(BR2_arm)$(BR2_armeb),y)
> +FLUTTER_ENGINE_CONF_OPTS += \
> +	--arm-float-abi $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
> +endif
> +
> +ifeq ($(BR2_PACKAGE_FLUTTER_ENGINE_ARTIFACTS),y)
> +FLUTTER_ENGINE_CONF_OPTS += --build-engine-artifacts
> +else
> +FLUTTER_ENGINE_CONF_OPTS += --no-build-engine-artifacts
> +endif
> +
> +ifeq ($(BR2_OPTIMIZE_0),y)
> +FLUTTER_ENGINE_CONF_OPTS += --unoptimized
> +endif
> +
> +ifeq ($(BR2_ENABLE_LTO),y)
> +FLUTTER_ENGINE_CONF_OPTS += --lto
> +else
> +FLUTTER_ENGINE_CONF_OPTS += --no-lto
> +endif
> +
> +ifeq ($(BR2_STRIP_strip),y)
> +FLUTTER_ENGINE_CONF_OPTS += --stripped
> +else
> +FLUTTER_ENGINE_CONF_OPTS += --no-stripped
> +endif
> +
> +ifeq ($(BR2_PACKAGE_FONTCONFIG),y)
> +FLUTTER_ENGINE_DEPENDENCIES += fontconfig
> +FLUTTER_ENGINE_CONF_OPTS += --enable-fontconfig

    else
    FLUTTER_ENGINE_CONF_OPTS += --disable-fontconfig

> +endif
> +
> +ifeq ($(BR2_PACKAGE_HAS_LIBGL),y)
> +FLUTTER_ENGINE_DEPENDENCIES += libgl
> +endif
> +
> +ifeq ($(BR2_PACKAGE_HAS_LIBGLES),y)
> +FLUTTER_ENGINE_DEPENDENCIES += libgles
> +endif
> +
> +ifeq ($(BR2_PACKAGE_MESA3D),y)
> +FLUTTER_ENGINE_DEPENDENCIES += mesa3d
> +endif
> +
> +ifeq ($(BR2_PACKAGE_MESA3D_VULKAN_DRIVER),y)
> +FLUTTER_ENGINE_CONF_OPTS += --enable-vulkan

    else
    FLUTTER_ENGINE_CONF_OPTS += --diable-vulkan

> +endif
> +
> +ifneq ($(BR2_PACKAGE_XORG7)$(BR2_PACKAGE_LIBXCB),yy)

Prefer positive logic:

    ifeq ($(BR2_PACKAGE_XORG7)$(BR2_PACKAGE_LIBXCB),yy)
    FLUTTER_ENGINE_DEPENDENCIES += libxcb
    else
    [the hack]
    endif

> +define FLUTTER_ENGINE_VULKAN_X11_SUPPORT_FIXUP
> +	$(SED) "s%vulkan_use_x11.*%vulkan_use_x11 = false%g" -i \
> +		$(@D)/build_overrides/vulkan_headers.gni
> +endef
> +FLUTTER_ENGINE_PRE_CONFIGURE_HOOKS += FLUTTER_ENGINE_VULKAN_X11_SUPPORT_FIXUP
> +else
> +FLUTTER_ENGINE_DEPENDENCIES += libxcb
> +endif
> +
> +ifneq ($(BR2_PACKAGE_WAYLAND),y)

Ditto, positive logic please.

> +define FLUTTER_ENGINE_VULKAN_WAYLAND_SUPPORT_FIXUP
> +	$(SED) "s%vulkan_use_wayland.*%vulkan_use_wayland = false%g" \
> +		$(@D)/build_overrides/vulkan_headers.gni
> +endef
> +FLUTTER_ENGINE_PRE_CONFIGURE_HOOKS += FLUTTER_ENGINE_VULKAN_WAYLAND_SUPPORT_FIXUP
> +else
> +FLUTTER_ENGINE_DEPENDENCIES += wayland
> +endif
> +
> +ifeq ($(BR2_PACKAGE_LIBGTK3),y)
> +FLUTTER_ENGINE_DEPENDENCIES += libgtk3
> +else
> +FLUTTER_ENGINE_CONF_OPTS += --disable-desktop-embeddings
> +endif
> +
> +ifeq ($(BR2_PACKAGE_LIBGLFW),y)
> +FLUTTER_ENGINE_DEPENDENCIES += libglfw
> +FLUTTER_ENGINE_CONF_OPTS += --build-glfw-shell
> +else
> +FLUTTER_ENGINE_CONF_OPTS += --no-build-glfw-shell
> +endif
> +
> +# The clang toolchain wrapper causes a lot of the following errors:
> +# error: -Wl,-z,now: 'linker' input unused [-Werror,-Wunused-command-line-argument]
> +# error: -Wl,-z,relro: 'linker' input unused [-Werror,-Wunused-command-line-argument]

Ah, that's because linker options are passed when we are not linking but
just compiling. And that's an error because of -Werror!

Can we disable -Werror instead of skipping the wrappers?

> +# Excplicitly use the real clang binaries for cc and cxx.
> +ifeq ($(BR2_CCACHE),y)
> +define FLUTTER_ENGINE_COMPILER_PATH_FIXUP
> +	$(SED) "s%cc =.*%cc = \"\$${toolchain_bin}/ccache clang.br_real\""%g \
> +		$(@D)/build/toolchain/custom/BUILD.gn
> +
> +	$(SED) "s%cxx =.*%cxx = \"\$${toolchain_bin}/ccache clang++.br_real\""%g \
> +		$(@D)/build/toolchain/custom/BUILD.gn
> +endef
> +else
> +define FLUTTER_ENGINE_COMPILER_PATH_FIXUP
> +	$(SED) "s%cc =.*%cc = \"\$${toolchain_bin}/clang.br_real\""%g \
> +		$(@D)/build/toolchain/custom/BUILD.gn
> +
> +	$(SED) "s%cxx =.*%cxx = \"\$${toolchain_bin}/clang++.br_real\""%g \
> +		$(@D)/build/toolchain/custom/BUILD.gn
> +endef
> +endif
> +FLUTTER_ENGINE_PRE_CONFIGURE_HOOKS += FLUTTER_ENGINE_COMPILER_PATH_FIXUP
> +
> +# If using per_package builds, flutter-engine tries to use the /usr/bin/ld instead of
> +# the one provided by the compiler, resulting in linking errors.
> +ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
> +define FLUTTER_ENGINE_GET_PATH
> +	(ld_bin_path=$$(dirname $$(realpath $$(find $(PER_PACKAGE_DIR)/flutter-engine -name ld -type f))); \
> +		echo $${ld_bin_path}:$(BR_PATH):$(HOST_DIR)/share/depot_tools; \
> +	)
> +endef
> +else
> +define FLUTTER_ENGINE_GET_PATH
> +		echo $(BR_PATH):$(HOST_DIR)/share/depot_tools
> +endef
> +endif
> +
> +# Generate a tarball if one does not already exist.
> +define FLUTTER_ENGINE_GENERATE_TARBALL
> +	(if [ ! -e $(FLUTTER_ENGINE_TARBALL_PATH) ]; then \

Don't use a subshell here (parenthesis are toally unneeded and
superfluous).

> +		. ./support/download/helpers && \
> +		rm -rf $(@D)/dl-tmp && mkdir -p $(@D)/dl-tmp && \
> +		$(INSTALL) -D -m 0755 $(FLUTTER_ENGINE_PKGDIR)/gclient \

This is not gclient, this is .gclient, but having a source fiel that is
a dot-file in the tree is not nice. Can we just name it dot-gclient
instead:

    $(FLUTTER_ENGINE_PKGDIR)/dot-gclient

> +			$(@D)/dl-tmp/.gclient && \
> +		$(SED) "s%!FLUTTER_VERSION!%$(FLUTTER_ENGINE_VERSION)%g" \
> +			$(@D)/dl-tmp/.gclient && \
> +		cd $(@D)/dl-tmp && \
> +		$(DEPOT_TOOLS_GCLIENT) \
> +			sync \
> +			--delete_unversioned_trees \
> +			-j$(PARALLEL_JOBS) \
> +			--no-history \
> +			--reset \
> +			--shallow && \
> +		mkdir -p $(FLUTTER_ENGINE_DL_DIR); \
> +		cd $(@D)/dl-tmp && \
> +		mk_tar_gz \
> +		$(@D)/dl-tmp/src \
> +		flutter-$(FLUTTER_ENGINE_VERSION) \
> +		"$$(git -C $(@D)/dl-tmp/src log -1 --pretty=format:%ci)" \
> +		$(FLUTTER_ENGINE_TARBALL_PATH) && \
> +		rm -rf $(@D)/dl-tmp; \
> +	fi \
> +	)

I think this big if-block should go into a helper script (yeah, yeah., I
may have written something using make code in my earlier suggestion, but
that was not smart of me...)

So:
    define FLUTTER_ENGINE_GENERATE_TARBALL
        $(FLUTTER_PKGDIR)/gen-tarball \
            --version $(FLUTTER_ENGINE_VERSION) \
            --tarball $(FLUTTER_ENGINE_TARBALL_PATH) \
            --dot-gclient $(FLUTTER_ENGINE_PKGDIR)/dot-gclient \
            --scratch-dir $(@D)/dl-tmp
    endef

And then a sequence of complex script shell is easier to write, to
review, and to maintain.

> +endef
> +FLUTTER_ENGINE_POST_DOWNLOAD_HOOKS += FLUTTER_ENGINE_GENERATE_TARBALL
> +
> +define FLUTTER_ENGINE_EXTRACT_CMDS
> +	gzip -d -c $(FLUTTER_ENGINE_TARBALL_PATH) | tar --strip-components 1 -C $(@D) -xf -
> +endef
> +
> +define FLUTTER_ENGINE_CONFIGURE_CMDS
> +  # libtessellator requires these three files, but the toolchain path isn't
> +  # referenced when linking. Copy them to the staging lib directory before
> +  # building.
> +	$(Q)$(foreach i,crtbeginS.o crtendS.o libgcc.a,
> +		$(Q)if [ ! -e $(STAGING_DIR)/usr/lib/$(i) ]; then \
> +			file_path=$$(find $(HOST_DIR) -type f -name $(i)); \

This is going to be a bit more complex than that, because of multi-lib
or multi-arch external toolchains. See the mess it is to find the
sysroot in toolchain/helpers.mk

But seriously though, why are they not brought in? Did you try to run
the linking command manually in debug mode (--verbose if calling ld
directly, of -Wl.--verbose if using gcc to link)?

Is it using ld to do the link, or is it using gcc?

Is ld binutils', or is it lld? This might also have a link as to why
-Wl,-z,now and -Wl,-z,relro are not supported...

> +			$(INSTALL) -D -m 0755 $${file_path} $(STAGING_DIR)/usr/lib/$(i); \
> +		fi \
> +	)
> +	(cd $(@D)/ && \
> +		rm -rf $(FLUTTER_ENGINE_BUILD_DIR) && \
> +		PATH=$(shell $(call FLUTTER_ENGINE_GET_PATH)) \
> +		./flutter/tools/gn $(FLUTTER_ENGINE_CONF_OPTS) \
> +	)
> +endef
> +
> +define FLUTTER_ENGINE_BUILD_CMDS
> +	(cd $(@D); \
> +		PATH=$(shell $(call FLUTTER_ENGINE_GET_PATH)) \
> +		PYTHONNOUSERSITE=y \
> +		$(HOST_DIR)/bin/ninja \
> +			-j $(PARALLEL_JOBS) \
> +			-C $(FLUTTER_ENGINE_BUILD_DIR) \
> +	)
> +endef
> +
> +define FLUTTER_ENGINE_INSTALL_STAGING_CMDS
> +	$(foreach i,$(FLUTTER_ENGINE_INSTALL_STAGING_FILES),

Err... FLUTTER_ENGINE_INSTALL_STAGING_FILES is set nowhere?

Regards,
Yann E. MORIN.

> +		$(Q)if [ -e $(FLUTTER_ENGINE_BUILD_DIR)/$(i) ]; then \
> +			$(INSTALL) -D -m 0755 $(FLUTTER_ENGINE_BUILD_DIR)/$(i) \
> +				$(STAGING_DIR)/usr/lib/$(i); \
> +		fi \
> +	)
> +	$(INSTALL) -D -m 0755 $(FLUTTER_ENGINE_BUILD_DIR)/flutter_embedder.h \
> +		$(STAGING_DIR)/usr/include/flutter_embedder.h
> +endef
> +
> +define FLUTTER_ENGINE_INSTALL_TARGET_CMDS
> +	$(foreach i,$(FLUTTER_ENGINE_INSTALL_FILES),
> +		$(Q)if [ -e $(FLUTTER_ENGINE_BUILD_DIR)/$(i) ]; then \
> +			$(INSTALL) -D -m 0755 $(FLUTTER_ENGINE_BUILD_DIR)/$(i) \
> +				$(TARGET_DIR)/usr/lib/$(i); \
> +		fi \
> +	)
> +endef
> +
> +$(eval $(generic-package))
> diff --git a/package/flutter-engine/gclient b/package/flutter-engine/gclient
> new file mode 100644
> index 0000000000..168e9a368d
> --- /dev/null
> +++ b/package/flutter-engine/gclient
> @@ -0,0 +1,16 @@
> +# This file is taken from the output of meta-flutter/lib/gn.py
> +
> +solutions = [{
> +    "managed": False,
> +    "name": "src/flutter",
> +    "url": "https://github.com/flutter/engine.git@!FLUTTER_VERSION!",
> +    "custom_vars": {
> +        "download_android_deps": False,
> +        "download_windows_deps": False,
> +        "download_linux_deps": False
> +    },
> +    "custom_deps": {
> +        "src/third_party/dart/third_party/pkg/tools":
> +        "https://dart.googlesource.com/tools.git@unified_analytics-v1.1.0"
> +    }
> +}]
> -- 
> 2.41.0
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Buildroot] [PATCH vRFC 3/3] package/flutter-engine: new package
  2023-07-23 21:26   ` Yann E. MORIN
@ 2023-07-25 15:38     ` Adam Duskett
  0 siblings, 0 replies; 8+ messages in thread
From: Adam Duskett @ 2023-07-25 15:38 UTC (permalink / raw)
  To: Yann E. MORIN
  Cc: Angelo Compagnucci, Michael Trimarchi, Thomas Petazzoni,
	Asaf Kahlon, buildroot


[-- Attachment #1.1: Type: text/plain, Size: 25388 bytes --]

Hello Yann;

Adam Duskett

Senior Embedded Systems Developer

M. +1208-515-8102

adam.duskett@amarulasolutions.com

__________________________________


Amarula Solutions BV

Joop Geesinkweg 125, 1114 AB, Amsterdam, NL

T. +31 (0)85 111 9170
info@amarulasolutions.com

www.amarulasolutions.com



On Sun, Jul 23, 2023 at 2:26 PM Yann E. MORIN <yann.morin.1998@free.fr>
wrote:

> Adam, All,
>
> On 2023-07-20 16:36 -0700, Adam Duskett spake thusly:
> > There are many issues with this package:
> >
> > - The release tarballs from https://github.com/flutter/engine are in no
> state
> >   to compile. They are only for the use of gclient to download a source
> >   directory structure suitable to build the Flutter engine! If you
> download,
> >   extract and attempt to run `./tools/gn --no-goma
> --no-prebuilt-dart-sdk`, you
> >   receive the error message:
> >   `No such file or directory: 'flutter/flutter/third_party/gn/gn.'
> >
> >   But wait! Wasn't the gn binary just called? No, that's a wrapper in the
> >   Flutter source tree that formats arguments to call the real gn binary.
> >   The real gn is not provided in the tarball but is downloaded via
> gclient
> >   (among many other supporting repositories.)
> >
> >   Even worse, the flutter repository depends on the .git dirs being
> present.
>
> s/flutter repository/flutter buildsystem/  maybe?
>
> >   (https://github.com/meta-flutter/meta-flutter/issues/271) This
> dependency
> >   means it is not possible to create a reproducible tarball from the
> downloaded
> >   sources, which is why there is no .hash file provided.
> >
> >   I have asked the flutter project to release full tarballs suitable for
> >   compiling here: https://github.com/flutter/flutter/issues/130734
> >
> > - The clang toolchain wrapper does not work properly, resulting in the
> immediate
> >   errors of:
> >     -Wl,-z,now: 'linker' input unused
> >     -Wl,-z,relro: 'linker' input unused
>
> Those two are us adding them because of BR2_RELRO_FULL (-Wl,-z,relro
> alone would be due to BR2_RELRO_PARTIAL).
>
> It does recognise that they are linker options, but why are they
> rejected? Do you have more context to provide?
>
> >   The solution is to use clang.br_real and clang++.br_real.
>
> Most probably not, because you lose a lot of the options set by
> Buildroot (optimisation ,target CPU, etc...). The real solution is to
> understand why -Wl-z-relro/now are rejected, and if they really are not
> needed, to find a way to tell the toolchain wrapper not set them for
> clang tools.
>
> > - If using per_package builds, flutter-engine tries to use the host
> /usr/bin/ld
> >   instead of the one provided by the compiler, resulting in linking
> errors.
> >   As such, if BR2_PER_PACKAGE_DIRECTORIES is enabled, we search for the
> ld
> >   provided by the compiler in the host directory and set the path
> accordingly.
>
> Can this be related to the above -Wl issue?
>
> > - libtessellator.so (built by flutter) requires three files:
> >   crtbeginS.o crtendS.o libgcc.a. However, the toolchain path isn't
> referenced
> >   when linking. The solution is to copy those three files to the staging
> lib
> >   directory before building.
> >
> > Tested with:
> >   - Debian 11 and 12
> >   - Ubuntu 18.04, 20.04, and 22.04
> >   - Fedora 38
> >   - Per package directory enabled and disabled
> >   - x86_64, arm64
> >
> > Signed-off-by: Adam Duskett <adam.duskett@amarulasolutions.com>
> > ---
> [--SNIP--]
> > diff --git
> a/package/flutter-engine/0001-disable-pre-canned-sysroot.patch
> b/package/flutter-engine/0001-disable-pre-canned-sysroot.patch
> > new file mode 100644
> > index 0000000000..c4064a77c9
> > --- /dev/null
> > +++ b/package/flutter-engine/0001-disable-pre-canned-sysroot.patch
> > @@ -0,0 +1,32 @@
> > +From 49a14e693124dc34f2cccbfb755d01a1198aa6bf Mon Sep 17 00:00:00 2001
> > +From: Adam Duskett <adam.duskett@amarulasolutions.com>
>
> You're not the author; Joel Winarske is. That's also the authorship
> there is in the upstream issue you referenced.
>
> [--SNIP--]
> > diff --git
> a/package/flutter-engine/0002-remove-explicit-x11-dependency.patch
> b/package/flutter-engine/0002-remove-explicit-x11-dependency.patch
> > new file mode 100644
> > index 0000000000..1345d4a3dd
> > --- /dev/null
> > +++ b/package/flutter-engine/0002-remove-explicit-x11-dependency.patch
> > @@ -0,0 +1,33 @@
> > +From b1a5db9318ca33a03f2700758d5debad907d21b6 Mon Sep 17 00:00:00 2001
> > +From: Adam Duskett <adam.duskett@amarulasolutions.com>
>
> Ditto
>

Yeah, my bad. I'll fix immediatly.


> > +Date: Wed, 19 Jul 2023 15:26:40 -0700
> > +Subject: [PATCH] remove explicit x11 dependency
> > +
> > +This is redundant, as the gtk pkg-config query will reference x11 if
> that's how
>
> Not so much redundant, but rather superfluous and may conflict with the
> actual rendering system used in gtk3 (e.g. wayland).
>
> > diff --git a/package/flutter-engine/0003-disable-undefined-version.patch
> b/package/flutter-engine/0003-disable-undefined-version.patch
> > new file mode 100644
> > index 0000000000..468ec4daf9
> > --- /dev/null
> > +++ b/package/flutter-engine/0003-disable-undefined-version.patch
> > @@ -0,0 +1,32 @@
> > +From 9512040259f3970dd5ca08fd9ebcfd42e7539997 Mon Sep 17 00:00:00 2001
> > +From: Adam Duskett <aduskett@gmail.com>
> > +Date: Tue, 18 Jul 2023 15:21:51 -0700
> > +Subject: [PATCH] Disable undefined-version
> > +
> > +This isn't a valid flag for ld, and flutter compiles just fine with the
> > +no-undefined-version flag.
>
> Without that option, the linker will just ignore a symbol with an
> undefined version. With the option, a smbol with an undefined version
> turns into an error.
>
> So indeed, without the option, the check is relaxed so it is not
> surprising the build does not fail.
>
> The option doesn't exist for ld afaik. If that option isn't changed ld
returns with something
along the lines of "no such option: no-undefined-version."


> [--SNIP--]
> > diff --git a/package/flutter-engine/Config.in
> b/package/flutter-engine/Config.in
> > new file mode 100644
> > index 0000000000..fe72191e77
> > --- /dev/null
> > +++ b/package/flutter-engine/Config.in
> > @@ -0,0 +1,93 @@
> > +config BR2_PACKAGE_FLUTTER_ENGINE_ARCH_SUPPORTS
> > +     bool
> > +     default y if BR2_aarch64
> > +     default y if BR2_arm && !BR2_ARM_CPU_ARMV4 && !BR2_ARM_CPU_ARMV5
> > +     default y if BR2_i386
> > +     default y if BR2_x86_64
>
> Since it uses clang, i'd also add: BR2_PACKAGE_LLVM_ARCH_SUPPORTS, but
> this is a bit fuzzy for me what option we should add, if any...
>
> > +
> > +config BR2_PACKAGE_FLUTTER_ENGINE
> > +     bool "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
> > +     depends on BR2_USE_WCHAR # std::wstring
> > +     depends on BR2_HOST_GCC_AT_LEAST_5
> > +     depends on BR2_PACKAGE_HAS_LIBGL || BR2_PACKAGE_HAS_LIBGLES
> > +     select BR2_PACKAGE_HOST_DEPOT_TOOLS
> > +     select BR2_PACKAGE_FREETYPE
> > +     select BR2_PACKAGE_ZLIB
> > +     help
> > +       Flutter is Google's SDK for crafting beautiful, fast user
> > +       experience for mobile, web, and desktop from a single
> > +       codebase. Flutter works with existing code, is used by
> > +       developers and organizations around the world, and is
> > +       free and open source.
> > +
> > +       The Flutter Engine is a portable runtime for hosting
> > +       Flutter applications. It implements Flutter's core
> > +       libraries, including animation and graphics, file and
> > +       network I/O, accessibility support, plugin architecture,
> > +       and a Dart runtime and compile toolchain. Most developers
> > +       will interact with Flutter via the Flutter Framework,
> > +       which provides a modern, reactive framework, and a rich
> > +       set of platform, layout and foundation widgets.
> > +
> > +       https://github.com/flutter/engine
> > +
> > +if BR2_PACKAGE_FLUTTER_ENGINE
> > +
> > +choice
> > +     prompt "Runtime mode"
> > +     default BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_RELEASE
>
> Mabye:
>     default BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_DEBUG if
> BR2_ENABLE_RUNTIME_DEBUG
>     default BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_RELEASE
>
> Which brings up the question: do we need the profile mode in Buildroot,
> or can we settle with just Release vs. Debug?
>
> If so, then no need for this choice; just test BR2_ENABLE_RUNTIME_DEBUG
> in flutter.mk
>
> There are many reasons why one would want to enable debugging specifically
for their application.


> [--SNIP--]
> > diff --git a/package/flutter-engine/flutter-engine.mk
> b/package/flutter-engine/flutter-engine.mk
> > new file mode 100644
> > index 0000000000..aa392a31d8
> > --- /dev/null
> > +++ b/package/flutter-engine/flutter-engine.mk
> > @@ -0,0 +1,286 @@
> >
> +################################################################################
> > +#
> > +# flutter-engine
> > +#
> >
> +################################################################################
> > +
> > +# Flutter-engine has a release on the GitHub page. However, that
> release is
> > +# only for Google. Its intended purpose is for the gclient tool
> provided by
> > +# Google in their depot-tools package. To use the source code, we must
> use
> > +# gclient to download the flutter-engine source code along with several
> other
> > +# projects. Unfortunately, the Buildroot download system does not have
> the
> > +# capability of using gclient, and considering this package is the only
> > +# package that uses gclient, we side-step the entire download process
> and
> > +# perform the following steps if a tarball does not exist already:
> > +#
> > +#  - Copy the pre-made gclient config file to a temporary download
> > +#    directory.
> > +#  - Run gclient sync to generate a source directory with the proper
> > +#    flutter-engine source code in the correct places.
> > +#  - Run mk_tar_gz to create a tarball.
> > +#  - Copy the tarball to $(FLUTTER_ENGINE_DL_DIR)
> > +#    directory to create a reproducible tarball.
> > +#
> > +# There is no hash provided, as the gn binary (used for configuration)
> relies
> > +# on the .git directories, so there is no way to make reproducible
> tarballs.
> > +FLUTTER_ENGINE_VERSION = 3.10.6
> > +
> > +# There is nothing for Buildroot to download. This is handled by
> gclient.
> > +FLUTTER_ENGINE_SITE =
> > +FLUTTER_ENGINE_SOURCE =
> > +FLUTTER_ENGINE_LICENSE = BSD-3-Clause
> > +FLUTTER_ENGINE_LICENSE_FILES = LICENSE
> > +FLUTTER_ENGINE_TARBALL_PATH =
> $(FLUTTER_ENGINE_DL_DIR)/flutter-$(FLUTTER_ENGINE_VERSION).tar.gz
> > +FLUTTER_ENGINE_INSTALL_STAGING = YES
> > +FLUTTER_ENGINE_DOWNLOAD_DEPENDENCIES = host-depot-tools
> > +FLUTTER_ENGINE_DEPENDENCIES = \
> > +     host-clang \
> > +     host-ninja \
> > +     host-pkgconf \
> > +     freetype \
> > +     zlib
> > +
> > +# Dispatch all architectures of flutter
> > +ifeq ($(BR2_i386),y)
> > +FLUTTER_ENGINE_TARGET_ARCH = x86
> > +FLUTTER_ENGINE_TARGET_TRIPPLE = x86-linux
> > +else ifeq ($(BR2_x86_64),y)
> > +FLUTTER_ENGINE_TARGET_ARCH = x64
> > +FLUTTER_ENGINE_TARGET_TRIPPLE = x86_64-linux
> > +else ifeq ($(BR2_arm)$(BR2_armeb),y)
> > +FLUTTER_ENGINE_TARGET_ARCH = arm
> > +FLUTTER_ENGINE_TARGET_TRIPPLE = arm-linux
> > +else ifeq ($(BR2_aarch64),y)
> > +FLUTTER_ENGINE_TARGET_ARCH = arm64
> > +FLUTTER_ENGINE_TARGET_TRIPPLE = aarch64-linux
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_RELEASE),y)
> > +FLUTTER_ENGINE_RUNTIME_MODE=release
> > +else ifeq ($(BR2_PACKAGE_FLUTTER_ENGINE_RUNTIME_PROFILE),y)
> > +FLUTTER_ENGINE_RUNTIME=profile
> > +else
> > +FLUTTER_ENGINE_RUNTIME=debug
> > +endif
> > +
> > +FLUTTER_ENGINE_BUILD_DIR = \
> > +
>  $(@D)/out/linux_$(FLUTTER_ENGINE_RUNTIME_MODE)_$(FLUTTER_ENGINE_TARGET_ARCH)
> > +
> > +FLUTTER_ENGINE_INSTALL_FILES = libflutter_engine.so
> libflutter_linux_gtk.so
> > +
> > +FLUTTER_ENGINE_CONF_OPTS = \
> > +     --clang \
> > +     --depot-tools $(HOST_DIR)/share/depot_tools \
> > +     --embedder-for-target \
> > +     --linux-cpu $(FLUTTER_ENGINE_TARGET_ARCH) \
> > +     --no-build-embedder-examples \
> > +     --no-clang-static-analyzer \
> > +     --no-enable-unittests \
> > +     --no-goma \
> > +     --no-prebuilt-dart-sdk \
> > +     --runtime-mode $(FLUTTER_ENGINE_RUNTIME_MODE) \
> > +     --target-os linux \
> > +     --target-sysroot $(STAGING_DIR) \
> > +     --target-toolchain $(HOST_DIR) \
> > +     --target-triple $(FLUTTER_ENGINE_TARGET_TRIPPLE)
> > +
> > +ifeq ($(BR2_arm)$(BR2_armeb),y)
> > +FLUTTER_ENGINE_CONF_OPTS += \
> > +     --arm-float-abi $(call qstrip,$(BR2_GCC_TARGET_FLOAT_ABI))
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_FLUTTER_ENGINE_ARTIFACTS),y)
> > +FLUTTER_ENGINE_CONF_OPTS += --build-engine-artifacts
> > +else
> > +FLUTTER_ENGINE_CONF_OPTS += --no-build-engine-artifacts
> > +endif
> > +
> > +ifeq ($(BR2_OPTIMIZE_0),y)
> > +FLUTTER_ENGINE_CONF_OPTS += --unoptimized
> > +endif
> > +
> > +ifeq ($(BR2_ENABLE_LTO),y)
> > +FLUTTER_ENGINE_CONF_OPTS += --lto
> > +else
> > +FLUTTER_ENGINE_CONF_OPTS += --no-lto
> > +endif
> > +
> > +ifeq ($(BR2_STRIP_strip),y)
> > +FLUTTER_ENGINE_CONF_OPTS += --stripped
> > +else
> > +FLUTTER_ENGINE_CONF_OPTS += --no-stripped
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_FONTCONFIG),y)
> > +FLUTTER_ENGINE_DEPENDENCIES += fontconfig
> > +FLUTTER_ENGINE_CONF_OPTS += --enable-fontconfig
>
>     else
>     FLUTTER_ENGINE_CONF_OPTS += --disable-fontconfig
>
> No, this option does not exist.


> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_HAS_LIBGL),y)
> > +FLUTTER_ENGINE_DEPENDENCIES += libgl
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_HAS_LIBGLES),y)
> > +FLUTTER_ENGINE_DEPENDENCIES += libgles
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_MESA3D),y)
> > +FLUTTER_ENGINE_DEPENDENCIES += mesa3d
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_MESA3D_VULKAN_DRIVER),y)
> > +FLUTTER_ENGINE_CONF_OPTS += --enable-vulkan
>
>     else
>     FLUTTER_ENGINE_CONF_OPTS += --diable-vulkan
>
> No, this option also does not exist.

> > +endif
> > +
> > +ifneq ($(BR2_PACKAGE_XORG7)$(BR2_PACKAGE_LIBXCB),yy)
>
> Prefer positive logic:
>
>     ifeq ($(BR2_PACKAGE_XORG7)$(BR2_PACKAGE_LIBXCB),yy)
>     FLUTTER_ENGINE_DEPENDENCIES += libxcb
>     else
>     [the hack]
>     endif
>
> Works for me.


> > +define FLUTTER_ENGINE_VULKAN_X11_SUPPORT_FIXUP
> > +     $(SED) "s%vulkan_use_x11.*%vulkan_use_x11 = false%g" -i \
> > +             $(@D)/build_overrides/vulkan_headers.gni
> > +endef
> > +FLUTTER_ENGINE_PRE_CONFIGURE_HOOKS +=
> FLUTTER_ENGINE_VULKAN_X11_SUPPORT_FIXUP
> > +else
> > +FLUTTER_ENGINE_DEPENDENCIES += libxcb
> > +endif
> > +
> > +ifneq ($(BR2_PACKAGE_WAYLAND),y)
>
> Ditto, positive logic please.
>
> Sounds good.


> > +define FLUTTER_ENGINE_VULKAN_WAYLAND_SUPPORT_FIXUP
> > +     $(SED) "s%vulkan_use_wayland.*%vulkan_use_wayland = false%g" \
> > +             $(@D)/build_overrides/vulkan_headers.gni
> > +endef
> > +FLUTTER_ENGINE_PRE_CONFIGURE_HOOKS +=
> FLUTTER_ENGINE_VULKAN_WAYLAND_SUPPORT_FIXUP
> > +else
> > +FLUTTER_ENGINE_DEPENDENCIES += wayland
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_LIBGTK3),y)
> > +FLUTTER_ENGINE_DEPENDENCIES += libgtk3
> > +else
> > +FLUTTER_ENGINE_CONF_OPTS += --disable-desktop-embeddings
> > +endif
> > +
> > +ifeq ($(BR2_PACKAGE_LIBGLFW),y)
> > +FLUTTER_ENGINE_DEPENDENCIES += libglfw
> > +FLUTTER_ENGINE_CONF_OPTS += --build-glfw-shell
> > +else
> > +FLUTTER_ENGINE_CONF_OPTS += --no-build-glfw-shell
> > +endif
> > +
> > +# The clang toolchain wrapper causes a lot of the following errors:
> > +# error: -Wl,-z,now: 'linker' input unused
> [-Werror,-Wunused-command-line-argument]
> > +# error: -Wl,-z,relro: 'linker' input unused
> [-Werror,-Wunused-command-line-argument]
>
> Ah, that's because linker options are passed when we are not linking but
> just compiling. And that's an error because of -Werror!
>
> Can we disable -Werror instead of skipping the wrappers?
>
> Maybe? I looked for quite a while but couldn't find where wError is being
set.


> > +# Excplicitly use the real clang binaries for cc and cxx.
> > +ifeq ($(BR2_CCACHE),y)
> > +define FLUTTER_ENGINE_COMPILER_PATH_FIXUP
> > +     $(SED) "s%cc =.*%cc = \"\$${toolchain_bin}/ccache
> clang.br_real\""%g \
> > +             $(@D)/build/toolchain/custom/BUILD.gn
> > +
> > +     $(SED) "s%cxx =.*%cxx = \"\$${toolchain_bin}/ccache
> clang++.br_real\""%g \
> > +             $(@D)/build/toolchain/custom/BUILD.gn
> > +endef
> > +else
> > +define FLUTTER_ENGINE_COMPILER_PATH_FIXUP
> > +     $(SED) "s%cc =.*%cc = \"\$${toolchain_bin}/clang.br_real\""%g \
> > +             $(@D)/build/toolchain/custom/BUILD.gn
> > +
> > +     $(SED) "s%cxx =.*%cxx = \"\$${toolchain_bin}/clang++.br_real\""%g \
> > +             $(@D)/build/toolchain/custom/BUILD.gn
> > +endef
> > +endif
> > +FLUTTER_ENGINE_PRE_CONFIGURE_HOOKS += FLUTTER_ENGINE_COMPILER_PATH_FIXUP
> > +
> > +# If using per_package builds, flutter-engine tries to use the
> /usr/bin/ld instead of
> > +# the one provided by the compiler, resulting in linking errors.
> > +ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
> > +define FLUTTER_ENGINE_GET_PATH
> > +     (ld_bin_path=$$(dirname $$(realpath $$(find
> $(PER_PACKAGE_DIR)/flutter-engine -name ld -type f))); \
> > +             echo
> $${ld_bin_path}:$(BR_PATH):$(HOST_DIR)/share/depot_tools; \
> > +     )
> > +endef
> > +else
> > +define FLUTTER_ENGINE_GET_PATH
> > +             echo $(BR_PATH):$(HOST_DIR)/share/depot_tools
> > +endef
> > +endif
> > +
> > +# Generate a tarball if one does not already exist.
> > +define FLUTTER_ENGINE_GENERATE_TARBALL
> > +     (if [ ! -e $(FLUTTER_ENGINE_TARBALL_PATH) ]; then \
>
> Don't use a subshell here (parenthesis are toally unneeded and
> superfluous).
>
> Sounds good

> > +             . ./support/download/helpers && \
> > +             rm -rf $(@D)/dl-tmp && mkdir -p $(@D)/dl-tmp && \
> > +             $(INSTALL) -D -m 0755 $(FLUTTER_ENGINE_PKGDIR)/gclient \
>
> This is not gclient, this is .gclient, but having a source fiel that is
> a dot-file in the tree is not nice. Can we just name it dot-gclient
> instead:
>
> Sure

>     $(FLUTTER_ENGINE_PKGDIR)/dot-gclient
>
> > +                     $(@D)/dl-tmp/.gclient && \
> > +             $(SED) "s%!FLUTTER_VERSION!%$(FLUTTER_ENGINE_VERSION)%g" \
> > +                     $(@D)/dl-tmp/.gclient && \
> > +             cd $(@D)/dl-tmp && \
> > +             $(DEPOT_TOOLS_GCLIENT) \
> > +                     sync \
> > +                     --delete_unversioned_trees \
> > +                     -j$(PARALLEL_JOBS) \
> > +                     --no-history \
> > +                     --reset \
> > +                     --shallow && \
> > +             mkdir -p $(FLUTTER_ENGINE_DL_DIR); \
> > +             cd $(@D)/dl-tmp && \
> > +             mk_tar_gz \
> > +             $(@D)/dl-tmp/src \
> > +             flutter-$(FLUTTER_ENGINE_VERSION) \
> > +             "$$(git -C $(@D)/dl-tmp/src log -1 --pretty=format:%ci)" \
> > +             $(FLUTTER_ENGINE_TARBALL_PATH) && \
> > +             rm -rf $(@D)/dl-tmp; \
> > +     fi \
> > +     )
>
> I think this big if-block should go into a helper script (yeah, yeah., I
> may have written something using make code in my earlier suggestion, but
> that was not smart of me...)
>
> So:
>     define FLUTTER_ENGINE_GENERATE_TARBALL
>         $(FLUTTER_PKGDIR)/gen-tarball \
>             --version $(FLUTTER_ENGINE_VERSION) \
>             --tarball $(FLUTTER_ENGINE_TARBALL_PATH) \
>             --dot-gclient $(FLUTTER_ENGINE_PKGDIR)/dot-gclient \
>             --scratch-dir $(@D)/dl-tmp
>     endef
>
> And then a sequence of complex script shell is easier to write, to
> review, and to maintain.
>

I had a script originally, and then you suggested to use the Makefile! Gah!
Make up your mind! :^)

> > +endef
> > +FLUTTER_ENGINE_POST_DOWNLOAD_HOOKS += FLUTTER_ENGINE_GENERATE_TARBALL
> > +
> > +define FLUTTER_ENGINE_EXTRACT_CMDS
> > +     gzip -d -c $(FLUTTER_ENGINE_TARBALL_PATH) | tar --strip-components
> 1 -C $(@D) -xf -
> > +endef
> > +
> > +define FLUTTER_ENGINE_CONFIGURE_CMDS
> > +  # libtessellator requires these three files, but the toolchain path
> isn't
> > +  # referenced when linking. Copy them to the staging lib directory
> before
> > +  # building.
> > +     $(Q)$(foreach i,crtbeginS.o crtendS.o libgcc.a,
> > +             $(Q)if [ ! -e $(STAGING_DIR)/usr/lib/$(i) ]; then \
> > +                     file_path=$$(find $(HOST_DIR) -type f -name $(i));
> \
>
> This is going to be a bit more complex than that, because of multi-lib
> or multi-arch external toolchains. See the mess it is to find the
> sysroot in toolchain/helpers.mk
>
> But seriously though, why are they not brought in? Did you try to run
> the linking command manually in debug mode (--verbose if calling ld
> directly, of -Wl.--verbose if using gcc to link)?
>
> Is it using ld to do the link, or is it using gcc?
>
> Is ld binutils', or is it lld? This might also have a link as to why
> -Wl,-z,now and -Wl,-z,relro are not supported...
>

I'll do more research into this and get back to you.

> > +                     $(INSTALL) -D -m 0755 $${file_path}
> $(STAGING_DIR)/usr/lib/$(i); \
> > +             fi \
> > +     )
> > +     (cd $(@D)/ && \
> > +             rm -rf $(FLUTTER_ENGINE_BUILD_DIR) && \
> > +             PATH=$(shell $(call FLUTTER_ENGINE_GET_PATH)) \
> > +             ./flutter/tools/gn $(FLUTTER_ENGINE_CONF_OPTS) \
> > +     )
> > +endef
> > +
> > +define FLUTTER_ENGINE_BUILD_CMDS
> > +     (cd $(@D); \
> > +             PATH=$(shell $(call FLUTTER_ENGINE_GET_PATH)) \
> > +             PYTHONNOUSERSITE=y \
> > +             $(HOST_DIR)/bin/ninja \
> > +                     -j $(PARALLEL_JOBS) \
> > +                     -C $(FLUTTER_ENGINE_BUILD_DIR) \
> > +     )
> > +endef
> > +
> > +define FLUTTER_ENGINE_INSTALL_STAGING_CMDS
> > +     $(foreach i,$(FLUTTER_ENGINE_INSTALL_STAGING_FILES),
>
> Err... FLUTTER_ENGINE_INSTALL_STAGING_FILES is set nowhere?
>
> Yeah, should just be  FLUTTER_ENGINE_INSTALL_FILES

> Regards,
> Yann E. MORIN.
>
> > +             $(Q)if [ -e $(FLUTTER_ENGINE_BUILD_DIR)/$(i) ]; then \
> > +                     $(INSTALL) -D -m 0755
> $(FLUTTER_ENGINE_BUILD_DIR)/$(i) \
> > +                             $(STAGING_DIR)/usr/lib/$(i); \
> > +             fi \
> > +     )
> > +     $(INSTALL) -D -m 0755
> $(FLUTTER_ENGINE_BUILD_DIR)/flutter_embedder.h \
> > +             $(STAGING_DIR)/usr/include/flutter_embedder.h
> > +endef
> > +
> > +define FLUTTER_ENGINE_INSTALL_TARGET_CMDS
> > +     $(foreach i,$(FLUTTER_ENGINE_INSTALL_FILES),
> > +             $(Q)if [ -e $(FLUTTER_ENGINE_BUILD_DIR)/$(i) ]; then \
> > +                     $(INSTALL) -D -m 0755
> $(FLUTTER_ENGINE_BUILD_DIR)/$(i) \
> > +                             $(TARGET_DIR)/usr/lib/$(i); \
> > +             fi \
> > +     )
> > +endef
> > +
> > +$(eval $(generic-package))
> > diff --git a/package/flutter-engine/gclient
> b/package/flutter-engine/gclient
> > new file mode 100644
> > index 0000000000..168e9a368d
> > --- /dev/null
> > +++ b/package/flutter-engine/gclient
> > @@ -0,0 +1,16 @@
> > +# This file is taken from the output of meta-flutter/lib/gn.py
> > +
> > +solutions = [{
> > +    "managed": False,
> > +    "name": "src/flutter",
> > +    "url": "https://github.com/flutter/engine.git@!FLUTTER_VERSION!",
> > +    "custom_vars": {
> > +        "download_android_deps": False,
> > +        "download_windows_deps": False,
> > +        "download_linux_deps": False
> > +    },
> > +    "custom_deps": {
> > +        "src/third_party/dart/third_party/pkg/tools":
> > +        "
> https://dart.googlesource.com/tools.git@unified_analytics-v1.1.0"
> > +    }
> > +}]
> > --
> > 2.41.0
> >
> > _______________________________________________
> > buildroot mailing list
> > buildroot@buildroot.org
> > https://lists.buildroot.org/mailman/listinfo/buildroot
>
> --
>
> .-----------------.--------------------.------------------.--------------------.
> |  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
> conspiracy: |
> | +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
>      |
> | +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is
> no  |
> | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
>  conspiracy.  |
>
> '------------------------------^-------^------------------^--------------------'
>

[-- Attachment #1.2: Type: text/html, Size: 35920 bytes --]

[-- Attachment #2: Type: text/plain, Size: 150 bytes --]

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-07-25 15:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20 23:36 [Buildroot] [PATCH vRFC 0/3] Initial flutter packages Adam Duskett
2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 1/3] package/python-httplib2: add host variant Adam Duskett
2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 2/3] package/depot-tools: new package Adam Duskett
2023-07-23 19:52   ` Yann E. MORIN
2023-07-20 23:36 ` [Buildroot] [PATCH vRFC 3/3] package/flutter-engine: " Adam Duskett
2023-07-23 21:26   ` Yann E. MORIN
2023-07-25 15:38     ` Adam Duskett
2023-07-20 23:37 ` [Buildroot] [PATCH vRFC 0/3] Initial flutter packages Adam Duskett

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.