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 libuv support as a replacement of systemd + some CMake fixes #420

Merged
merged 10 commits into from
Jun 2, 2024
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode/
/build/
/src/third_party/wayland/protocols/*
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Luke Howard <[email protected]>
Stanislav Shmarov <[email protected]>
Sebastian Urban <[email protected]>
Ómar Högni Guðmarsson <[email protected]>
Athaariq Ardhiansyah <[email protected]>
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ set(CMAKE_CXX_STANDARD 17)
project("flutter_elinux" LANGUAGES CXX C)

# Build options.
option(BACKEND_TYPE "Select WAYLAND, DRM-GBM, DRM-EGLSTREAM, or X11 as the display backend type" WAYLAND)
set(BACKEND_TYPE "WAYLAND" CACHE STRING "Select WAYLAND, DRM-GBM, DRM-EGLSTREAM, or X11 as the display backend type")
set_property(CACHE BACKEND_TYPE PROPERTY STRINGS "WAYLAND" "DRM-GBM" "DRM-EGLSTREAM" "X11")
# Disabled USE_DIRTY_REGION_MANAGEMENT due flicker issue.
# See https://github.com/sony/flutter-embedded-linux/issues/334
option(USE_DIRTY_REGION_MANAGEMENT "Use Flutter dirty region management" OFF)
Expand All @@ -24,8 +25,11 @@ option(FLUTTER_RELEASE "Build Flutter Engine with release mode" OFF)

if(NOT BUILD_ELINUX_SO)
# Load the user project.
set(USER_PROJECT_PATH "examples/flutter-wayland-client" CACHE STRING "")
set(USER_PROJECT_PATH "" CACHE STRING "examples/flutter-wayland-client")
message("User project: ${USER_PROJECT_PATH}")
if(NOT ${BACKEND_TYPE} STREQUAL "WAYLAND")
message(WARNING "BACKEND_TYPE variable is ignored because BUILD_ELINUX_SO is OFF")
endif()
include(${USER_PROJECT_PATH}/cmake/user_config.cmake)
else()
# Set the filename of elinux .so file
Expand Down
16 changes: 11 additions & 5 deletions cmake/build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,24 @@ target_link_libraries(${TARGET}
${LIBINPUT_LIBRARIES}
${LIBUDEV_LIBRARIES}
${LIBSYSTEMD_LIBRARIES}
${LIBUV_LIBRARIES}
${X11_LIBRARIES}
${LIBWESTON_LIBRARIES}
${FLUTTER_EMBEDDER_LIB}
## User libraries
${USER_APP_LIBRARIES}
)

if(${BACKEND_TYPE} MATCHES "DRM-(GBM|EGLSTREAM)")
target_link_libraries(${TARGET}
PRIVATE
Threads::Threads
)
if(${BACKEND_TYPE} MATCHES "^DRM-(GBM|EGLSTREAM)$")
target_link_libraries(${TARGET}
PRIVATE
Threads::Threads
)

# Indicate whether libsystemd must replace libuv
if("${LIBSYSTEMD_FOUND}" STREQUAL "1")
add_definitions(-DUSE_LIBSYSTEMD)
endif()
endif()

set(FLUTTER_EMBEDDER_LIB "${CMAKE_CURRENT_SOURCE_DIR}/build/libflutter_engine.so")
Expand Down
13 changes: 11 additions & 2 deletions cmake/package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,26 @@ pkg_check_modules(EGL REQUIRED egl)
pkg_check_modules(XKBCOMMON REQUIRED xkbcommon)

# depends on backend type.
if(${BACKEND_TYPE} MATCHES "DRM-(GBM|EGLSTREAM)")
if(${BACKEND_TYPE} MATCHES "^DRM-(GBM|EGLSTREAM)$")
# DRM backend
pkg_check_modules(DRM REQUIRED libdrm)
pkg_check_modules(LIBINPUT REQUIRED libinput)
pkg_check_modules(LIBUDEV REQUIRED libudev)
pkg_check_modules(LIBSYSTEMD REQUIRED libsystemd)
pkg_check_modules(LIBSYSTEMD libsystemd)
pkg_check_modules(LIBUV libuv)
if(${BACKEND_TYPE} STREQUAL "DRM-GBM")
pkg_check_modules(GBM REQUIRED gbm)
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
# Check if either systemd or libuv exist
if((NOT "${LIBSYSTEMD_FOUND}" STREQUAL "1") AND (NOT "${LIBUV_FOUND}" STREQUAL "1"))
message(FATAL_ERROR
"${BACKEND_TYPE} backend requires either libsystemd or libuv, but
they're not exist.")
elseif(("${LIBSYSTEMD_FOUND}" STREQUAL "1") AND ("${LIBUV_FOUND}" STREQUAL "1"))
message("!! NOTICE: libsystemd found, libuv won't be used.")
endif()
elseif(${BACKEND_TYPE} STREQUAL "X11")
pkg_check_modules(X11 REQUIRED x11)
else()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ class CustomEncodableValue {

#if defined(FLUTTER_ENABLE_RTTI) && FLUTTER_ENABLE_RTTI
// Passthrough to std::any's type().
const std::type_info& type() const noexcept { return value_.type(); }
const std::type_info& type() const noexcept {
return value_.type();
}
#endif

// This operator exists only to provide a stable ordering for use as a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ class GpuSurfaceTexture {
// The available texture variants.
// Only PixelBufferTexture is currently implemented.
// Other variants are expected to be added in the future.
typedef std::variant<PixelBufferTexture, GpuSurfaceTexture, EGLImageTexture> TextureVariant;
typedef std::variant<PixelBufferTexture, GpuSurfaceTexture, EGLImageTexture>
TextureVariant;

// An object keeping track of external textures.
//
Expand Down
3 changes: 2 additions & 1 deletion src/flutter/shell/platform/common/json_method_codec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ JsonMethodCodec::EncodeErrorEnvelopeInternal(
rapidjson::Document envelope(rapidjson::kArrayType);
auto& allocator = envelope.GetAllocator();
envelope.PushBack(rapidjson::Value(error_code.c_str(), allocator), allocator);
envelope.PushBack(rapidjson::Value(error_message.c_str(), allocator), allocator);
envelope.PushBack(rapidjson::Value(error_message.c_str(), allocator),
allocator);
rapidjson::Value details_value;
if (error_details) {
details_value.CopyFrom(*error_details, allocator);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ typedef struct {
size_t width;
// Height of the EGLImage.
size_t height;
// An optional callback that gets invoked when the |egl_image| can be released.
// An optional callback that gets invoked when the |egl_image| can be
// released.
void (*release_callback)(void* release_context);
// Opaque data passed to |release_callback|.
void* release_context;
Expand Down Expand Up @@ -142,12 +143,12 @@ typedef const FlutterDesktopGpuSurfaceDescriptor* (
size_t height,
void* user_data);

typedef const FlutterDesktopEGLImage* (
*FlutterDesktopEGLImageTextureCallback)(size_t width,
size_t height,
void* egl_display,
void* egl_context,
void* user_data);
typedef const FlutterDesktopEGLImage* (*FlutterDesktopEGLImageTextureCallback)(
size_t width,
size_t height,
void* egl_display,
void* egl_context,
void* user_data);

// An object used to configure pixel buffer textures.
typedef struct {
Expand Down
4 changes: 2 additions & 2 deletions src/flutter/shell/platform/common/text_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <algorithm>

//#include "flutter/fml/logging.h"
// #include "flutter/fml/logging.h"

namespace flutter {

Expand Down Expand Up @@ -66,7 +66,7 @@ class TextRange {
//
// Asserts that the range is of length 0.
size_t position() const {
//FML_DCHECK(base_ == extent_);
// FML_DCHECK(base_ == extent_);
return extent_;
}

Expand Down
Loading
Loading