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

waylandpp implementation #7

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e686e2b
Waylandpp
jwinarske Apr 7, 2020
665302e
platform task runner
jwinarske Apr 11, 2020
fc19ae7
Channel handlers plumbed in
jwinarske Apr 13, 2020
a7bea2e
Add basic platform and plugin handlers
jwinarske Apr 14, 2020
ad7f2e5
Update README.md
jwinarske Apr 14, 2020
e59eae3
Create LICENSE
jwinarske Apr 14, 2020
282393a
remove finding gl lib, not needed
jwinarske Apr 14, 2020
ed1dbba
we don't need gl3
jwinarske Apr 14, 2020
4677982
install target to set rpath
jwinarske Apr 14, 2020
cb73726
egl includes folder
jwinarske Apr 27, 2020
e4f4819
build for Yocto
jwinarske Apr 29, 2020
fe454c8
* AOT support *
jwinarske May 2, 2020
fb9c41c
Merge pull request #1 from jwinarske/aot
jwinarske May 3, 2020
6d77476
clang-format
jwinarske May 3, 2020
86992d8
channel support
jwinarske May 15, 2020
2cc05f4
Create FUNDING.yml
jwinarske May 21, 2020
112ee44
update
jwinarske Jun 9, 2021
a1bce66
update README.md
jwinarske Jun 9, 2021
02532ee
update for desktop build
jwinarske Jun 9, 2021
139d586
glesv3, size for gallery, update readme
jwinarske Jun 9, 2021
478f2a4
update README.md
jwinarske Jun 9, 2021
67ebfca
wayland_display: ensure `has_*` are initialized
xobs Jun 17, 2021
ccbca33
wayland_display: don't segfault when no seat management
xobs Jun 17, 2021
a7af881
wayland_display: use EGL_OPENGL_ES_API
xobs Jun 17, 2021
9b0fedb
Merge pull request #2 from xobs/imx8-fixes
jwinarske Jun 17, 2021
17d0d57
enable wider range of support
jwinarske Jun 21, 2021
2d598ce
Update README.md
jwinarske Sep 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: [jwinarske] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ Icon?

*.sublime-workspace
cmake-*/

.vscode
138 changes: 93 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,111 @@ cmake_minimum_required(VERSION 3.5.2)

project(flutter_wayland)

set(FLUTTER_ENGINE_SHA b9523318caa1a99ffde8adaf331212eb879cabc9)

set(FLUTTER_EMBEDDER_ARTIFACTS_ZIP ${CMAKE_BINARY_DIR}/flutter_embedder_${FLUTTER_ENGINE_SHA}.zip)
set(FLUTTER_ARTIFACTS_ZIP ${CMAKE_BINARY_DIR}/flutter_artifact_${FLUTTER_ENGINE_SHA}.zip)
set(FLUTTER_BUCKET_BASE "https://storage.googleapis.com/flutter_infra/flutter")

# Download and setup the Flutter Engine.
if(NOT EXISTS ${FLUTTER_EMBEDDER_ARTIFACTS_ZIP})
file(DOWNLOAD
${FLUTTER_BUCKET_BASE}/${FLUTTER_ENGINE_SHA}/linux-x64/linux-x64-embedder
${FLUTTER_EMBEDDER_ARTIFACTS_ZIP}
SHOW_PROGRESS
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${FLUTTER_EMBEDDER_ARTIFACTS_ZIP}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()
if(NOT FLUTTER_ENGINE_LIBRARY AND NOT CMAKE_CROSSCOMPILING)

if(NOT FLUTTER_ENGINE_SHA)

if(NOT CHANNEL)
set(CHANNEL "dev" CACHE STRING "Choose the channel, options are: master, dev, beta, stable" FORCE)
message(STATUS "Flutter Channel not set, defaulting to dev")
endif()

message(STATUS "Flutter Channel ........ ${CHANNEL}")

include(FetchContent)

FetchContent_Declare(engine-version
URL https://raw.githubusercontent.com/flutter/flutter/${CHANNEL}/bin/internal/engine.version
DOWNLOAD_NAME engine.version
DOWNLOAD_NO_EXTRACT TRUE
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}
)

FetchContent_GetProperties(engine-version)
if(NOT engine-version_POPULATED)
FetchContent_Populate(engine-version)
file(READ ${CMAKE_BINARY_DIR}/engine.version FLUTTER_ENGINE_SHA)
string(REPLACE "\n" "" FLUTTER_ENGINE_SHA ${FLUTTER_ENGINE_SHA})
else()
MESSAGE(FATAL "Unable to determine engine-version, please override FLUTTER_ENGINE_SHA")
endif()

endif()

message(STATUS "Engine SHA1 ............ ${FLUTTER_ENGINE_SHA}")

# Download and setup the Flutter Engine.

if(NOT EXISTS ${FLUTTER_ARTIFACTS_ZIP})
file(DOWNLOAD
${FLUTTER_BUCKET_BASE}/${FLUTTER_ENGINE_SHA}/linux-x64/artifacts.zip
${FLUTTER_ARTIFACTS_ZIP}
SHOW_PROGRESS
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${FLUTTER_ARTIFACTS_ZIP}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set(FLUTTER_EMBEDDER_ARTIFACTS_ZIP ${CMAKE_BINARY_DIR}/flutter_embedder_${FLUTTER_ENGINE_SHA}.zip)
set(FLUTTER_BUCKET_BASE "https://storage.googleapis.com/flutter_infra/flutter")

if(NOT EXISTS ${FLUTTER_EMBEDDER_ARTIFACTS_ZIP})
file(DOWNLOAD
${FLUTTER_BUCKET_BASE}/${FLUTTER_ENGINE_SHA}/linux-x64/linux-x64-embedder
${FLUTTER_EMBEDDER_ARTIFACTS_ZIP}
SHOW_PROGRESS
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${FLUTTER_EMBEDDER_ARTIFACTS_ZIP}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
endif()

set(FLUTTER_ENGINE_LIBRARY ${CMAKE_BINARY_DIR}/libflutter_engine.so)
else()
message(STATUS "Engine ................. ${FLUTTER_ENGINE_LIBRARY}")
endif()

find_package(PkgConfig)
pkg_check_modules(WAYLAND_CLIENT REQUIRED wayland-client)
pkg_check_modules(WAYLAND_EGL REQUIRED wayland-egl)
pkg_check_modules(EGL REQUIRED egl)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS FALSE)

include(FindPkgConfig)
pkg_check_modules(WAYLANDPP REQUIRED
wayland-client-extra++>=0.2.7
wayland-client++>=0.2.7
wayland-client-unstable++>=0.2.7
wayland-cursor++>=0.2.7
wayland-egl++>=0.2.7
wayland-client++>=0.2.7
)

pkg_check_modules(EGL REQUIRED egl)
pkg_check_modules(XKBCOMMON REQUIRED xkbcommon)
pkg_check_modules(RAPIDJSON REQUIRED "RapidJSON>=1.1.0")


# Executable
file(GLOB_RECURSE FLUTTER_WAYLAND_SRC
"src/*.cc"
"src/*.h"
set(FLUTTER_WAYLAND_SRC
flutter/standard_codec.cc
src/wayland_display.cc
src/keyboard.cc
src/platform_channel.cc
src/utils.cc
src/main.cc
)

link_directories(${CMAKE_BINARY_DIR})

add_executable(flutter_wayland ${FLUTTER_WAYLAND_SRC})

target_link_libraries(flutter_wayland
${WAYLAND_CLIENT_LIBRARIES}
${WAYLAND_EGL_LIBRARIES}
${EGL_LIBRARIES}
flutter_engine
target_link_libraries(flutter_wayland dl
${FLUTTER_ENGINE_LIBRARY}
${XKBCOMMON_LINK_LIBRARIES}
${RAPIDJSON_LINK_LIBRARIES}
${WAYLANDPP_LINK_LIBRARIES}
${EGL_LDFLAGS}
)

link_directories()
target_include_directories(flutter_wayland
PRIVATE
${WAYLAND_CLIENT_INCLUDE_DIRS}
${WAYLAND_EGL_INCLUDE_DIRS}
${EGL_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${CMAKE_BINARY_DIR}
${WAYLANDPP_INCLUDE_DIRS}
${EGL_INCLUDE_DIRS}
${XKBCOMMON_INCLUDE_DIRS}
${RAPIDJSON_INCLUDE_DIRS}
)

target_compile_options(flutter_wayland PUBLIC ${EGL_CFLAGS})

install(TARGETS flutter_wayland RUNTIME DESTINATION bin)
29 changes: 29 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2020, Joel Winarske
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
103 changes: 78 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,97 @@
Flutter Wayland
============
# Flutter Wayland

A Flutter Embedder that talks to Wayland.
A Flutter Embedder that talks to Wayland

![Running in Weston](assets/image.png)
** ARCHIVED REPO **

Build Setup Instructions
------------------------
I recommend use of https://github.com/toyota-connected/ivi-homescreen/ which is re-write of this proof of concept app.

* Install the following packages (on Debian Stretch): `weston`, `libwayland-dev`, `cmake` and `ninja`.
* From the source root `mkdir build` and move into the directory.
* `cmake -G Ninja ../`. This should check you development environment for required packages, download the Flutter engine artifacts and unpack the same in the build directory.
* `ninja` to build the embedder.
* Run the embedder using `./flutter_wayland`. Make sure `weston` is running. See the instructions on running Flutter applications below.
![Running in Weston](assets/fedora_34.png)

Running Flutter Applications
----------------------------
#### Build Setup Instructions

* Ubuntu 18/20 deps: `sudo apt-get install cmake lib-wayland++ libgl1-mesa-dev libegl1-mesa-dev libgles2-mesa-dev libxkbcommon-dev rapidjson-dev clang`
* Fedora 33/34 deps: `sudo dnf install wayland-devel libxkbcommon-devel rapidjson-devel pugixml-devel waylandpp-devel clang`

```
mkdir build && cd build
CXX=/usr/bin/clang++ CC=/usr/bin/clang cmake ..
make -j VERBOSE=1
```

#### Enable Wayland on Ubuntu 16/18

* log out
* select gear icon
* select `Ubuntu on Wayland`
* login as usual

## Running Flutter Application

```
Flutter Wayland Embedder

========================
Usage: `flutter_wayland <asset_path> <flutter_flags>`

Usage: `flutter_wayland <asset_bundle_path> <flutter_flags>`

This utility runs an instance of a Flutter application and renders using
Wayland core protocols.

The Flutter tools can be obtained at https://flutter.io/

asset_bundle_path: The Flutter application code needs to be snapshotted using
the Flutter tools and the assets packaged in the appropriate
location. This can be done for any Flutter application by
running `flutter build bundle` while in the directory of a
valid Flutter project. This should package all the code and
assets in the "build/flutter_assets" directory. Specify this
directory as the first argument to this utility.
app_path: This either points to asset bundle path, or
an Ahead Of Time (AOT) shared library (.so).

asset_path: The Flutter application code needs to be snapshotted using
the Flutter tools and the assets packaged in the appropriate
location. This can be done for any Flutter application by
running `flutter build bundle` while in the directory of a
valid Flutter project. This should package all the code and
assets in the "build/flutter_assets" directory. Specify this
directory as the first argument to this utility.

flutter_flags: Typically empty. These extra flags are passed directly to the
Flutter engine. To see all supported flags, run
`flutter_tester --help` using the test binary included in the
Flutter tools.
```

#### Building Gallery Application
```
cd ~/development
export PATH=`pwd`/flutter/bin:$PATH
flutter doctor -v
git clone https://github.com/flutter/gallery.git
cd gallery
flutter channel dev
flutter upgrade
flutter build bundle
```
#### Running Gallery Application
```
cd flutter_wayland/build
cp ~/development/flutter/bin/cache/artifacts/engine/linux-x64/icudtl.dat .
./flutter_wayland /home/joel/development/gallery/build/flutter_assets
```
Note: the flutter engine and gallery channel must match, or you will see something like this:

flutter_flags: Typically empty. These extra flags are passed directly to the
Flutter engine. To see all supported flags, run
`flutter_tester --help` using the test binary included in the
Flutter tools.
```
[ERROR:flutter/shell/common/shell.cc(103)] Dart Error: Can't load Kernel binary: Invalid SDK hash.
[ERROR:flutter/runtime/dart_isolate.cc(171)] Could not prepare isolate.
[ERROR:flutter/runtime/runtime_controller.cc(415)] Could not create root isolate.
[ERROR:flutter/shell/common/shell.cc(588)] Could not launch engine with configuration.
```

A run without errors might look like this:

```
$ ./flutter_wayland /home/joel/development/gallery/build/flutter_assets
LOG: /mnt/raid10/flutter_wayland/src/main.cc:65: Arg: /home/joel/development/gallery/build/flutter_assets
Pointer Present
Keyboard Present
assets_path: /home/joel/development/gallery/build/flutter_assets
load_aot: 0
flutter: Observatory listening on http://127.0.0.1:36061/E9T-fNgSjiU=/
LOG: /mnt/raid10/flutter_wayland/src/platform_channel.cc:108: PlatformChannel: SystemChrome.setApplicationSwitcherDescription
```
Binary file added assets/fedora_34.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/ubuntu_wayland_18.0.4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading