Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Yocto support #30

Closed
jmarijan opened this issue Mar 16, 2021 · 19 comments
Closed

Add Yocto support #30

jmarijan opened this issue Mar 16, 2021 · 19 comments
Labels
enhancement New feature or request yocto Topics of Yocto

Comments

@jmarijan
Copy link

Do you have a plan to add a Yocto support for flutter-embedded-linux?

Yocto Layer for the Flutter already exists :
https://github.com/jwinarske/meta-flutter

It has support for some of the engines, such as flutter-pi.

@HidenoriMatsubayashi
Copy link
Contributor

Thank you for your question. Yes, I'm going to add the Yocto support for the example.

@HidenoriMatsubayashi HidenoriMatsubayashi added the enhancement New feature or request label Mar 16, 2021
@HidenoriMatsubayashi HidenoriMatsubayashi changed the title [Question] Yocto support Add Yocto support Mar 16, 2021
@jmarijan
Copy link
Author

jmarijan commented Mar 17, 2021

Thank you for your response. Looking forward to it.

In meanwhile, I am trying to create a recipe for your repo on my own. I am using dunfell version of Yocto.
There is a problem regarding EGL/egl.h library. While cross-compiling your repo on Yocto, following error is received:

`| tmp/work/aarch64-mx8mn-fslc-linux/flutter-embedded-linux/1.0-r0/git/src/flutter/shell/platform/linux_embedded/surface/context_egl.h:92:26: error: no matching function for call to 'eglCreateWindowSurface'
| EGLSurface surface = eglCreateWindowSurface(
| ^~~~~~~~~~~~~~~~~~~~~~

|tmp/work/aarch64-mx8mn-fslc-linux/flutter-embedded-linux/1.0-r0/git/src/flutter/shell/platform/linux_embedded/surface/linuxes_surface_gl_drm.h:48:36: note: in instantiation of member function 'flutter::ContextEgl<gbm_device, gbm_surface, gbm_surface>::CreateOffscreenSurface' requested here
| offscreen_surface_ = context_->CreateOffscreenSurface(window);
| ^

| tmp/work/aarch64-mx8mn-fslc-linux/flutter-embedded-linux/1.0-r0/recipe-sysroot/usr/include/EGL/egl.h:155:31: note: candidate function not viable: cannot convert argument of incomplete type 'gbm_surface *' to 'EGLNativeWindowType' (aka 'wl_egl_window *') for 3rd argument
| EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
`

In my opinion, your EGL/egl.h and EGL/egl.h library which Yocto fetches from source (https://archive.mesa3d.org/; version 20.0.2) are different.
Can you please tell me which version of EGL/egl.h library is in use on your project?

@psstoyanov
Copy link

@jmarijan , I believe EGLStream is already marked as pending for implementation in #1

@HidenoriMatsubayashi
Copy link
Contributor

HidenoriMatsubayashi commented Mar 18, 2021

@jmarijan
Did you add WL_EGL_PLATFORM define? NativeWindowType is different depends on the platforms. You need to specify it properly.

EGLSurface eglCreateWindowSurface(EGLDisplay display, 
    EGLConfig config, NativeWindowType native_window, EGLint const * attrib_list);

See: https://www.khronos.org/registry/EGL/api/EGL/eglplatform.h

#elif defined(WL_EGL_PLATFORM)

typedef struct wl_display     *EGLNativeDisplayType;
typedef struct wl_egl_pixmap  *EGLNativePixmapType;
typedef struct wl_egl_window  *EGLNativeWindowType;

#elif defined(__GBM__)

typedef struct gbm_device  *EGLNativeDisplayType;
typedef struct gbm_bo      *EGLNativePixmapType;
typedef void               *EGLNativeWindowType;

#elif defined(__ANDROID__) || defined(ANDROID)

@HidenoriMatsubayashi HidenoriMatsubayashi added the yocto Topics of Yocto label Mar 19, 2021
@ghost
Copy link

ghost commented Mar 22, 2021

@HidenoriMatsubayashi
Start working on this issue.

@jwinarske
Copy link

jwinarske commented Apr 8, 2021

https://github.com/jwinarske/meta-flutter/blob/dunfell/recipes-graphics/flutter-embedded-linux/flutter-embedded-linux_git.bb
It builds but I need to sort out the install paths when I have a spare moment, and add some package config flags for the build variants.

@HidenoriMatsubayashi I understand you were asking around Toyota. I own the Toyota Flutter Embedder.

@HidenoriMatsubayashi
Copy link
Contributor

@jwinarske
Thank you for commenting and creating flutter-embedded-linux_git.bb. Actually, @TomohideMorimoto who is one of our member is creating a Yocto meta file for Flutter Engine and this embedder.

Yes, I talked a little with Toyota's members a few weeks ago. Are you one of them? Toyota's Flutter Embedder is focusing AGL, right? I'm interested in Flutter use in AGL and Toyota. Do you have any plans to open source? Especially, I'm interested in what to do with plugins such as video player and webview.

@jwinarske
Copy link

@jwinarske
Thank you for commenting and creating flutter-embedded-linux_git.bb. Actually, @TomohideMorimoto who is one of our member is creating a Yocto meta file for Flutter Engine and this embedder.

Yes, I talked a little with Toyota's members a few weeks ago. Are you one of them? Toyota's Flutter Embedder is focusing AGL, right? I'm interested in Flutter use in AGL and Toyota. Do you have any plans to open source? Especially, I'm interested in what to do with plugins such as video player and webview.

Open source plans are out of my hands. If/when it does, it will happen through AGL (Yocto based). The flutter-engine recipe won' change much beyond this one, if at all.

As far as plugins go I prefer manually loading a shared module, oppose to statically linking the plugin code. If the plugin is in the filesystem, then it gets loaded, otherwise returns not implemented on the channel. It keeps a clean demarcation between random plugin authors and application owners. So having a plugin that can be built for GTK Linux or standalone plugin (shared module with known API including version) would meet the requirement. Otherwise trying to cross compile a plugin using Flutter tools would require binary repository package changes not standard between organizations. So alignment on plugins is a need.

@HidenoriMatsubayashi
Copy link
Contributor

I see. Thank you for sharing!

@LefixBlue LefixBlue mentioned this issue Apr 13, 2021
6 tasks
@jwinarske
Copy link

Updated recipes here. Each example app is a separate recipe. Patches are specific to dunfell (libweston-8). I renamed the bins so they can be installed at the same time.

There is currently an issue with XDG protocol hanging. Seems you're missing a surface commit, which also indicates you're building with older Wayland Protocol and Weston.

@HidenoriMatsubayashi
Copy link
Contributor

@jwinarske

There is currently an issue with XDG protocol hanging. Seems you're missing a surface commit, which also indicates you're building with older Wayland Protocol and Weston.

Could you give me some more information? Do you mean that wl_surface_commit should be called every time?

@topolittle
Copy link

I get the following error:
ninja: error: '/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml'
That's because the path to the xml file is hardcoded to the host in the cmake build file.
The following patch resolves this error.

From f7f5e4e69adae518824dfcfe1002129d2cb19f3a Mon Sep 17 00:00:00 2001
From: Stephane Gilbert stephane.gilbert@exfo.com
Date: Mon, 19 Apr 2021 14:05:38 -0400
Subject: [PATCH] Fix: xdg-shell.xml not found


cmake/build.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/build.cmake b/cmake/build.cmake
index 8abc9b7..ac66080 100644
--- a/cmake/build.cmake
+++ b/cmake/build.cmake
@@ -35,7 +35,7 @@ elseif(${BACKEND_TYPE} STREQUAL "X11")
src/flutter/shell/platform/linux_embedded/window/native_window_x11.cc)
else()
find_program(WaylandScannerExec NAMES wayland-scanner)

  • get_filename_component(_infile /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml ABSOLUTE)
  • get_filename_component(_infile $ENV{PKG_CONFIG_SYSROOT_DIR}/usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml ABSOLUTE)
    set(_client_header ${CMAKE_CURRENT_SOURCE_DIR}/src/wayland/protocol/xdg-shell-client-protocol.h)
    set(_code ${CMAKE_CURRENT_SOURCE_DIR}/src/wayland/protocol/xdg-shell-protocol.c)
    set_source_files_properties(${_client_header} GENERATED)
    --
    2.30.2

Once the configure phase passes, there are many compilation errors. It's like clang doesn't find all the required include files.

@HidenoriMatsubayashi
Copy link
Contributor

@TomohideMorimoto Please check your build environment and fix properly.

@topolittle
Copy link

I managed to build flutter-wayland-client under Yocto. Here what I have changed:
There was a missing build dependency. I added wayland-protocol to the DEPENDS variable.
I had to make some change to CmakeList.txt to use the Yocto's cross compiler instead of the native one. Here is the patch for it:

From b447ab6b15a9b906b0990eebbc7068ca410baa79 Mon Sep 17 00:00:00 2001
From: Stephane Gilbert <stephane.gilbert@exfo.com>
Date: Tue, 20 Apr 2021 13:08:51 -0400
Subject: [PATCH] Fix: Wrong clang compiler used in Yocto Setting
 CMAKE_C_COMPILER and CMAKE_CXX_COMPILER in CMakeList overrides the compiler
 binary Bitbake should use to cross-compile E.g.: clang++ vs
 aarch64-poky-linux-clang++

---
 CMakeLists.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9008a04..1a7b44a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.10)
 project("flutter_linuxes" LANGUAGES CXX C)
 
 # Rules of compiler and cpp version.
-set(CMAKE_C_COMPILER clang)
-set(CMAKE_CXX_COMPILER clang++)
+#set(CMAKE_C_COMPILER clang)
+#set(CMAKE_CXX_COMPILER clang++)
 set(CMAKE_CXX_STANDARD 17)
 
 # Build options.
-- 
2.30.2

@HidenoriMatsubayashi
Copy link
Contributor

HidenoriMatsubayashi commented Apr 22, 2021

@topolittle

There was a missing build dependency. I added wayland-protocol to the DEPENDS variable.

I would like to confirm. wayland-protocol isn't explicitly added, but It exists in meta/recipes-graphics/wayland. So, I think it's okay without it. Are you cross-building using the SDK/toolchain generated by Yocto?

@jwinarske
Copy link

A meta-layer is always in a separate source repo, otherwise you clone the same repo twice, and you end up with source in your meta layer. Not a good pattern.

Why not just reference my layer? Not to mention it's going to get some updates.

@HidenoriMatsubayashi
Copy link
Contributor

HidenoriMatsubayashi commented Apr 27, 2021

Thank you for your advice. I'm wondering if we should make a new repo for the yocto recipe. By the way, just wondering, is your activity on here in a position as Toyota or personal?

@jwinarske
Copy link

Personal.

@topolittle
Copy link

Following the commit ae9e975, the above patch I posted to cross-compile in Yocto is no longer required.

@ghost ghost mentioned this issue May 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request yocto Topics of Yocto
Projects
None yet
Development

No branches or pull requests

5 participants