Bug 1954903 - Allow to use system gbm libs instead of bundled r=stransky,mjf

Introduce "--with-system-gbm" option, allowing to build Firefox against
system gbm library and to find system gbm header files. Also unify all
gbm includes to match both system and bundled paths.

Differential Revision: https://phabricator.services.mozilla.com/D242098
This commit is contained in:
Jan Grulich
2025-04-14 16:37:02 +00:00
parent da6fff4dba
commit db0912c6b2
14 changed files with 59 additions and 19 deletions

View File

@@ -564,6 +564,13 @@ def write_mozbuild(
mb.write(' CXXFLAGS += CONFIG["MOZ_GTK3_CFLAGS"]\n')
except KeyError:
pass
try:
if relsrcdir in write_mozbuild_variables["INCLUDE_SYSTEM_GBM_HANDLING"]:
mb.write('CXXFLAGS += CONFIG["MOZ_GBM_CFLAGS"]\n')
mb.write('if not CONFIG["MOZ_SYSTEM_GBM"]:\n')
mb.write(' LOCAL_INCLUDES += [ "/third_party/gbm/gbm/" ]\n')
except KeyError:
pass
try:
if (
relsrcdir

View File

@@ -1256,6 +1256,11 @@ if CONFIG["OS_TARGET"] == "Android":
"vr/gvr/capi/include/gvr.h",
]
if CONFIG["MOZ_SYSTEM_GBM"]:
system_headers += [
"gbm.h",
]
if CONFIG["MOZ_JACK"]:
system_headers += [
"jack/jack.h",

View File

@@ -17,6 +17,10 @@
"third_party/libwebrtc/modules/portal/portal_gn",
"third_party/libwebrtc/modules/video_capture/video_capture_internal_impl_gn"
],
"INCLUDE_SYSTEM_GBM_HANDLING": [
"third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn",
"third_party/libwebrtc/modules/portal/portal_gn"
],
"INCLUDE_SYSTEM_DAV1D_HANDLING": [
"third_party/libwebrtc/modules/video_coding/codecs/av1/dav1d_decoder_gn",
"third_party/libwebrtc/modules/video_coding/codecs/av1/libaom_av1_encoder_gn"

View File

@@ -10,7 +10,7 @@
#include "mozilla/webgpu/WebGPUParent.h"
#include "mozilla/widget/DMABufSurface.h"
#include "mozilla/widget/DMABufLibWrapper.h"
#include "gbm/gbm.h"
#include <gbm.h>
namespace mozilla::webgpu {

4
third_party/gbm/gbm/moz.build vendored Normal file
View File

@@ -0,0 +1,4 @@
EXPORTS += [
'gbm.h',
]

View File

@@ -4,13 +4,10 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
SOURCES += [
'mozgbm.cpp',
]
if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk":
CXXFLAGS += CONFIG['MOZ_GTK3_CFLAGS']
LOCAL_INCLUDES += ['/third_party/gbm']
if CONFIG["MOZ_SYSTEM_GBM"]:
OS_LIBS += CONFIG["MOZ_GBM_LIBS"]
else:
SOURCES += ['mozgbm.cpp']
LOCAL_INCLUDES += ['/third_party/gbm/gbm']
FINAL_LIBRARY = 'xul'

View File

@@ -8,7 +8,7 @@
#include "mozilla/Types.h"
#include "prlink.h"
#include <gbm/gbm.h>
#include <gbm.h>
#define GET_FUNC(func, lib) \
func##_fn = \

View File

@@ -1,4 +0,0 @@
EXPORTS.gbm = [
'gbm/gbm.h',
]

View File

@@ -678,6 +678,24 @@ def v4l2(target, toolkit_gtk):
set_config("MOZ_ENABLE_V4L2", True, when=v4l2)
set_define("MOZ_ENABLE_V4L2", True, when=v4l2)
# System gbm support (for screencast support using PipeWire)
# =============================================================
with only_when(compile_environment):
system_lib_option(
"--with-system-gbm",
nargs="?",
help="Use system gbm",
when=use_pkg_config,
)
pipewire_headers = pkg_check_modules(
"MOZ_GBM",
"gbm",
when="--with-system-gbm",
)
set_config("MOZ_SYSTEM_GBM", True, when="--with-system-gbm")
# GL Provider
# ==============================================================
option("--with-gl-provider", nargs=1, help="Set GL provider backend type")

View File

@@ -11,12 +11,12 @@
#include "DMABufLibWrapper.h"
#include "DMABufFormats.h"
#include "gbm/gbm.h"
#ifdef MOZ_WAYLAND
# include "nsWaylandDisplay.h"
# include "mozilla/widget/mozwayland.h"
# include "mozilla/widget/linux-dmabuf-unstable-v1-client-protocol.h"
#endif
#include <gbm.h>
#include "mozilla/gfx/Logging.h" // for gfxCriticalNote

View File

@@ -8,9 +8,9 @@
#ifndef __MOZ_DMABUF_LIB_WRAPPER_H__
#define __MOZ_DMABUF_LIB_WRAPPER_H__
#include "gbm/gbm.h"
#include "mozilla/StaticMutex.h"
#include "mozilla/widget/DMABufFormats.h"
#include <gbm.h>
#include <mutex>
#undef LOGDMABUF

View File

@@ -12,6 +12,7 @@
# include "nsWaylandDisplay.h"
#endif
#include <gbm.h>
#include <fcntl.h>
#include <getopt.h>
#include <signal.h>
@@ -33,7 +34,6 @@
#endif
#include <sys/ioctl.h>
#include "gbm/gbm.h"
#include "mozilla/widget/va_drmcommon.h"
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/FileHandleWrapper.h"

View File

@@ -20,7 +20,6 @@ with Files("*nsGtkKeyUtils*"):
BUG_COMPONENT = ("Core", "DOM: UI Events & Focus Handling")
DIRS += [
"/third_party/gbm/",
"/third_party/gbm/libgbm",
]
@@ -168,6 +167,15 @@ LOCAL_INCLUDES += [
"/widget/x11",
]
CXXFLAGS += CONFIG["MOZ_GBM_CFLAGS"]
if not CONFIG["MOZ_SYSTEM_GBM"]:
LOCAL_INCLUDES += [
"/third_party/gbm/gbm/",
]
DIRS += [
"/third_party/gbm/gbm/",
]
DEFINES["CAIRO_GFX"] = True
DEFINES["MOZ_APP_NAME"] = '"%s"' % CONFIG["MOZ_APP_NAME"]

View File

@@ -11,7 +11,6 @@
#include "DMABufLibWrapper.h"
#include "mozilla/widget/mozwayland.h"
#include "gbm/gbm.h"
#include "mozilla/widget/fractional-scale-v1-client-protocol.h"
#include "mozilla/widget/idle-inhibit-unstable-v1-client-protocol.h"
#include "mozilla/widget/kde-appmenu-client-protocol.h"
@@ -24,6 +23,8 @@
#include "mozilla/widget/xdg-output-unstable-v1-client-protocol.h"
#include "mozilla/widget/color-management-v1-client-protocol.h"
#include <gbm.h>
namespace mozilla::widget {
constexpr const int sColorTransfersNum =