Added option to use system libwayland
Chromium includes wayland source code and uses it instead of system libwayland. In most case, there isn't any problem since wayland is open source but sometime system libwayland isn't compatible with open source. e.g. there is a case libwayland-egl.so is symlink to libMali.so and it said "wl_egl_window should be opaque for user. the definition should under libMali.so" In this case, it seems wl_egl_window type is not compatible between open source and libMali.so. So this patch give an option to use system libwayland instead. Change-Id: I624f29f8aabb538cd2cd4f303417a4eca2fe34f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5626537 Reviewed-by: Kramer Ge <fangzhoug@chromium.org> Reviewed-by: Thomas Anderson <thomasanderson@chromium.org> Commit-Queue: Wanchang Ryu <wanchang.ryu@lge.com> Reviewed-by: Maksim Sisov <msisov@igalia.com> Reviewed-by: Colin Blundell <blundell@chromium.org> Cr-Commit-Position: refs/heads/main@{#1325993}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
0bd61a8a3d
commit
ccd442f964
build_overrides
gpu/vulkan
third_party
@ -8,7 +8,7 @@ import("//build_overrides/wayland.gni")
|
||||
vulkan_use_x11 = ozone_platform_x11
|
||||
vulkan_use_wayland = ozone_platform_wayland
|
||||
|
||||
if (vulkan_use_wayland) {
|
||||
if (vulkan_use_wayland && !use_system_libwayland) {
|
||||
vulkan_wayland_include_dirs = [
|
||||
"$wayland_gn_dir/src/src",
|
||||
"$wayland_gn_dir/include/src",
|
||||
|
@ -6,5 +6,12 @@ import("//build/config/ozone.gni")
|
||||
|
||||
wayland_gn_dir = "//third_party/wayland"
|
||||
|
||||
if (ozone_platform_wayland) {
|
||||
# This defines use_system_libwayland
|
||||
import("$wayland_gn_dir/features.gni")
|
||||
} else {
|
||||
use_system_libwayland = false
|
||||
}
|
||||
|
||||
# Path to Wayland sources
|
||||
wayland_dir = "$wayland_gn_dir/src"
|
||||
|
@ -23,7 +23,7 @@ if (enable_vulkan) {
|
||||
if (use_vulkan_xcb) {
|
||||
defines += [ "USE_VULKAN_XCB" ]
|
||||
}
|
||||
if (ozone_platform_wayland) {
|
||||
if (ozone_platform_wayland && !use_system_libwayland) {
|
||||
configs = [ "//third_party/wayland:wayland_config" ]
|
||||
}
|
||||
}
|
||||
|
295
third_party/wayland/BUILD.gn
vendored
295
third_party/wayland/BUILD.gn
vendored
@ -3,165 +3,210 @@
|
||||
# found in the LICENSE file.
|
||||
import("//build/config/linux/pkg_config.gni")
|
||||
import("//build/config/sysroot.gni")
|
||||
import("//third_party/wayland/features.gni")
|
||||
import("//third_party/wayland/wayland_protocol.gni")
|
||||
import("//tools/generate_stubs/rules.gni")
|
||||
|
||||
assert(is_linux || is_chromeos)
|
||||
|
||||
wayland_protocol("wayland_protocol_c") {
|
||||
sources = [ "src/protocol/wayland.xml" ]
|
||||
generator_type = "protocol-marshalling"
|
||||
}
|
||||
if (!use_system_libwayland) {
|
||||
wayland_protocol("wayland_protocol_c") {
|
||||
sources = [ "src/protocol/wayland.xml" ]
|
||||
generator_type = "protocol-marshalling"
|
||||
}
|
||||
|
||||
config("wayland_config") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"include/src",
|
||||
"src/cursor",
|
||||
"src/egl",
|
||||
"src/src",
|
||||
]
|
||||
config("wayland_config") {
|
||||
include_dirs = [
|
||||
"include",
|
||||
"include/src",
|
||||
"src/cursor",
|
||||
"src/egl",
|
||||
"src/src",
|
||||
]
|
||||
|
||||
# Client/Server headers are automatically generated. Though, we still need
|
||||
# to pass the path where these headers are located.
|
||||
include_dirs += [ "$root_gen_dir/third_party/wayland/src/protocol" ]
|
||||
}
|
||||
# Client/Server headers are automatically generated. Though, we still need
|
||||
# to pass the path where these headers are located.
|
||||
include_dirs += [ "$root_gen_dir/third_party/wayland/src/protocol" ]
|
||||
}
|
||||
|
||||
# Only used within this file. Should not be in a public_config entry and leak
|
||||
# out. No relations to the "wayland_private" target below.
|
||||
# TODO(thomasanderson): Remove this once
|
||||
# https://patchwork.freedesktop.org/patch/242086/ lands.
|
||||
config("wayland_build_workaround_private_config") {
|
||||
cflags = [ "-Wno-macro-redefined" ]
|
||||
}
|
||||
# Only used within this file. Should not be in a public_config entry and leak
|
||||
# out. No relations to the "wayland_private" target below.
|
||||
# TODO(thomasanderson): Remove this once
|
||||
# https://patchwork.freedesktop.org/patch/242086/ lands.
|
||||
config("wayland_build_workaround_private_config") {
|
||||
cflags = [ "-Wno-macro-redefined" ]
|
||||
}
|
||||
|
||||
wayland_protocol("wayland_server_protocol") {
|
||||
sources = [ "src/protocol/wayland.xml" ]
|
||||
generator_type = "protocol-server"
|
||||
}
|
||||
wayland_protocol("wayland_server_protocol") {
|
||||
sources = [ "src/protocol/wayland.xml" ]
|
||||
generator_type = "protocol-server"
|
||||
}
|
||||
|
||||
wayland_protocol("wayland_client_protocol") {
|
||||
sources = [ "src/protocol/wayland.xml" ]
|
||||
generator_type = "protocol-client"
|
||||
}
|
||||
wayland_protocol("wayland_client_protocol") {
|
||||
sources = [ "src/protocol/wayland.xml" ]
|
||||
generator_type = "protocol-client"
|
||||
}
|
||||
|
||||
source_set("wayland_util") {
|
||||
sources = [
|
||||
"src/src/wayland-private.h",
|
||||
"src/src/wayland-util.c",
|
||||
"src/src/wayland-util.h",
|
||||
]
|
||||
source_set("wayland_util") {
|
||||
sources = [
|
||||
"src/src/wayland-private.h",
|
||||
"src/src/wayland-util.c",
|
||||
"src/src/wayland-util.h",
|
||||
]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
|
||||
static_library("wayland_private") {
|
||||
sources = [
|
||||
"src/src/connection.c",
|
||||
"src/src/wayland-os.c",
|
||||
"src/src/wayland-os.h",
|
||||
]
|
||||
static_library("wayland_private") {
|
||||
sources = [
|
||||
"src/src/connection.c",
|
||||
"src/src/wayland-os.c",
|
||||
"src/src/wayland-os.h",
|
||||
]
|
||||
|
||||
deps = [ ":wayland_util" ]
|
||||
deps = [ ":wayland_util" ]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [
|
||||
":wayland_build_workaround_private_config",
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
"//build/config/linux/libffi",
|
||||
]
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [
|
||||
":wayland_build_workaround_private_config",
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
"//build/config/linux/libffi",
|
||||
]
|
||||
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
|
||||
static_library("wayland_server") {
|
||||
sources = [
|
||||
"src/src/event-loop.c",
|
||||
"src/src/wayland-server.c",
|
||||
"src/src/wayland-shm.c",
|
||||
]
|
||||
static_library("wayland_server") {
|
||||
sources = [
|
||||
"src/src/event-loop.c",
|
||||
"src/src/wayland-server.c",
|
||||
"src/src/wayland-shm.c",
|
||||
]
|
||||
|
||||
include_dirs = [ "include/" ]
|
||||
include_dirs = [ "include/" ]
|
||||
|
||||
deps = [
|
||||
":wayland_private",
|
||||
":wayland_protocol_c",
|
||||
":wayland_util",
|
||||
]
|
||||
deps = [
|
||||
":wayland_private",
|
||||
":wayland_protocol_c",
|
||||
":wayland_util",
|
||||
]
|
||||
|
||||
public_deps = [ ":wayland_server_protocol" ]
|
||||
public_deps = [ ":wayland_server_protocol" ]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [
|
||||
":wayland_build_workaround_private_config",
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
"//build/config/linux/libffi",
|
||||
]
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [
|
||||
":wayland_build_workaround_private_config",
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
"//build/config/linux/libffi",
|
||||
]
|
||||
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
|
||||
static_library("wayland_client") {
|
||||
sources = [ "src/src/wayland-client.c" ]
|
||||
static_library("wayland_client") {
|
||||
sources = [ "src/src/wayland-client.c" ]
|
||||
|
||||
deps = [
|
||||
":wayland_client_protocol",
|
||||
":wayland_private",
|
||||
":wayland_protocol_c",
|
||||
":wayland_util",
|
||||
]
|
||||
deps = [
|
||||
":wayland_client_protocol",
|
||||
":wayland_private",
|
||||
":wayland_protocol_c",
|
||||
":wayland_util",
|
||||
]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [
|
||||
":wayland_build_workaround_private_config",
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
"//build/config/linux/libffi",
|
||||
]
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [
|
||||
":wayland_build_workaround_private_config",
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
"//build/config/linux/libffi",
|
||||
]
|
||||
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
|
||||
static_library("wayland_egl") {
|
||||
sources = [
|
||||
"src/egl/wayland-egl-backend.h",
|
||||
"src/egl/wayland-egl-core.h",
|
||||
"src/egl/wayland-egl.c",
|
||||
"src/egl/wayland-egl.h",
|
||||
]
|
||||
static_library("wayland_egl") {
|
||||
sources = [
|
||||
"src/egl/wayland-egl-backend.h",
|
||||
"src/egl/wayland-egl-core.h",
|
||||
"src/egl/wayland-egl.c",
|
||||
"src/egl/wayland-egl.h",
|
||||
]
|
||||
|
||||
deps = [
|
||||
":wayland_client_protocol",
|
||||
":wayland_util",
|
||||
]
|
||||
deps = [
|
||||
":wayland_client_protocol",
|
||||
":wayland_util",
|
||||
]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
public_configs = [ ":wayland_config" ]
|
||||
}
|
||||
|
||||
static_library("wayland_cursor") {
|
||||
sources = [
|
||||
"src/cursor/cursor-data.h",
|
||||
"src/cursor/os-compatibility.c",
|
||||
"src/cursor/os-compatibility.h",
|
||||
"src/cursor/wayland-cursor.c",
|
||||
"src/cursor/wayland-cursor.h",
|
||||
"src/cursor/xcursor.c",
|
||||
"src/cursor/xcursor.h",
|
||||
]
|
||||
static_library("wayland_cursor") {
|
||||
sources = [
|
||||
"src/cursor/cursor-data.h",
|
||||
"src/cursor/os-compatibility.c",
|
||||
"src/cursor/os-compatibility.h",
|
||||
"src/cursor/wayland-cursor.c",
|
||||
"src/cursor/wayland-cursor.h",
|
||||
"src/cursor/xcursor.c",
|
||||
"src/cursor/xcursor.h",
|
||||
]
|
||||
|
||||
deps = [ ":wayland_client_protocol" ]
|
||||
deps = [ ":wayland_client_protocol" ]
|
||||
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
":wayland_build_workaround_private_config",
|
||||
":wayland_config",
|
||||
]
|
||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||
configs += [
|
||||
"//build/config/compiler:no_chromium_code",
|
||||
":wayland_build_workaround_private_config",
|
||||
":wayland_config",
|
||||
]
|
||||
}
|
||||
} else {
|
||||
# use_system_libwayland
|
||||
import("wayland_version.gni")
|
||||
pkg_config("wayland_server_config") {
|
||||
packages = [ "wayland-server" ]
|
||||
extra_args = [ "wayland-server >= $wayland_version" ]
|
||||
}
|
||||
|
||||
group("wayland_server") {
|
||||
public_configs = [ ":wayland_server_config" ]
|
||||
}
|
||||
|
||||
group("wayland_util") {
|
||||
public_configs = [ ":wayland_client_config" ]
|
||||
}
|
||||
|
||||
pkg_config("wayland_client_config") {
|
||||
packages = [ "wayland-client" ]
|
||||
extra_args = [ "wayland-client >= $wayland_version" ]
|
||||
}
|
||||
|
||||
pkg_config("wayland_cursor_config") {
|
||||
packages = [ "wayland-cursor" ]
|
||||
extra_args = [ "wayland-cursor >= $wayland_version" ]
|
||||
}
|
||||
|
||||
pkg_config("wayland_egl_config") {
|
||||
packages = [ "wayland-egl" ]
|
||||
extra_args = [ "wayland-egl >= $wayland_egl_version" ]
|
||||
}
|
||||
|
||||
group("wayland_client") {
|
||||
public_configs = [ ":wayland_client_config" ]
|
||||
}
|
||||
|
||||
group("wayland_cursor") {
|
||||
public_configs = [ ":wayland_cursor_config" ]
|
||||
}
|
||||
|
||||
group("wayland_egl") {
|
||||
public_configs = [ ":wayland_egl_config" ]
|
||||
}
|
||||
}
|
||||
|
||||
config("wayland_scanner_config") {
|
||||
|
9
third_party/wayland/features.gni
vendored
Normal file
9
third_party/wayland/features.gni
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Copyright 2024 The Chromium Authors
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
declare_args() {
|
||||
# Controls whether the build should use the version of Wayland
|
||||
# library shipped with the system or Chromium third_party.
|
||||
use_system_libwayland = false
|
||||
}
|
38
third_party/wayland/generate_configs.py
vendored
38
third_party/wayland/generate_configs.py
vendored
@ -6,6 +6,7 @@
|
||||
"""Creates config files for building libwayland."""
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
@ -43,6 +44,41 @@ def CopyFileToDestination(file, src_dir, dest_dir):
|
||||
shutil.copy(os.path.join(src_dir, file), dest_dir)
|
||||
print("Copied %s to %s from %s" % (file, dest_dir, src_dir))
|
||||
|
||||
def GetProjectVersionFromMeson(filename):
|
||||
with open(filename) as f:
|
||||
return re.search(
|
||||
'project\(.*?version\s?:\s?\'(?P<version>[\d\.]+)\'.*?\)',
|
||||
f.read(), re.DOTALL).group("version")
|
||||
return None
|
||||
|
||||
def GetPackageVersionFromMeson(filename, module):
|
||||
with open(filename) as f:
|
||||
result = re.search(
|
||||
f'pkgconfig\.generate\(.*?name\s?:\s?\'{module}\'.*?\)',
|
||||
f.read(), re.DOTALL)
|
||||
if result:
|
||||
return re.search('version\s?:\s\'(?P<version>[\d\.]+)',
|
||||
result.group(0)).group('version')
|
||||
return None
|
||||
|
||||
def UpdateWaylandVersionGni():
|
||||
versions = {
|
||||
'wayland': GetProjectVersionFromMeson('src/meson.build'),
|
||||
'wayland_egl': GetPackageVersionFromMeson('src/egl/meson.build',
|
||||
'wayland-egl')
|
||||
}
|
||||
with open('wayland_version.gni', 'w') as f:
|
||||
f.write("# DO NOT MODIFY THIS FILE DIRECTLY!\n"
|
||||
"# IT IS GENERATED BY generate_configs.py\n"
|
||||
"# The version information is used when use_system_libwayland\n"
|
||||
"# is true to check system wayland package version meets\n"
|
||||
"# at least the version of third-party/wayland so that it won't\n"
|
||||
"# make any compile error with chromium\n")
|
||||
for pkg, version in versions.items():
|
||||
if not version:
|
||||
raise Exception(f"Failed to get {pkg} version")
|
||||
f.write(f"{pkg}_version = \"{version}\"\n")
|
||||
print("Updated wayland_version.gni")
|
||||
|
||||
def main():
|
||||
# Creates a directory that will be used by meson to generate build configs.
|
||||
@ -54,6 +90,8 @@ def main():
|
||||
CopyFileToDestination('config.h', temp_dir, GetAbsPath('include'))
|
||||
# Copies wayland-version.h to //third_party/wayland/include/src
|
||||
CopyFileToDestination('wayland-version.h', temp_dir + '/src', GetAbsPath('include/src'))
|
||||
# Update wayland_version.gni from meson.build file
|
||||
UpdateWaylandVersionGni()
|
||||
|
||||
# Removes the directory we used for meson config.
|
||||
shutil.rmtree(temp_dir)
|
||||
|
8
third_party/wayland/wayland_version.gni
vendored
Normal file
8
third_party/wayland/wayland_version.gni
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# DO NOT MODIFY THIS FILE DIRECTLY!
|
||||
# IT IS GENERATED BY generate_configs.py
|
||||
# The version information is used when use_system_libwayland
|
||||
# is true to check system wayland package version meets
|
||||
# atleast the version of third-party/wayland so that it won't
|
||||
# make any compile error with chromium
|
||||
wayland_version = "1.21.0"
|
||||
wayland_egl_version = "18.1.0"
|
5
third_party/weston/BUILD.gn
vendored
5
third_party/weston/BUILD.gn
vendored
@ -7,6 +7,7 @@ import("//build/config/linux/pkg_config.gni")
|
||||
import("//build/config/python.gni")
|
||||
import("//build/config/ui.gni")
|
||||
import("//build/toolchain/toolchain.gni")
|
||||
import("//third_party/wayland/features.gni")
|
||||
import("//third_party/wayland/wayland_protocol.gni")
|
||||
|
||||
wayland_protocol("text_cursor_position_protocol") {
|
||||
@ -72,7 +73,9 @@ config("weston_config") {
|
||||
|
||||
ldflags = [ "-Wl,-rpath=\$ORIGIN" ]
|
||||
|
||||
configs = [ "//third_party/wayland:wayland_config" ]
|
||||
if (!use_system_libwayland) {
|
||||
configs = [ "//third_party/wayland:wayland_config" ]
|
||||
}
|
||||
}
|
||||
|
||||
pkg_config("pixman") {
|
||||
|
Reference in New Issue
Block a user