xref: /aosp_15_r20/external/webrtc/modules/portal/BUILD.gn (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1# Copyright (c) 2022 The WebRTC project authors. All Rights Reserved.
2#
3# Use of this source code is governed by a BSD-style license
4# that can be found in the LICENSE file in the root of the source
5# tree. An additional intellectual property rights grant can be found
6# in the file PATENTS.  All contributing project authors may
7# be found in the AUTHORS file in the root of the source tree.
8
9import("//build/config/linux/pkg_config.gni")
10import("//tools/generate_stubs/rules.gni")
11import("../../webrtc.gni")
12
13if ((is_linux || is_chromeos) && rtc_use_pipewire) {
14  pkg_config("gio") {
15    packages = [
16      "gio-2.0",
17      "gio-unix-2.0",
18    ]
19  }
20
21  pkg_config("pipewire") {
22    packages = [ "libpipewire-0.3" ]
23    if (!rtc_link_pipewire) {
24      ignore_libs = true
25    }
26  }
27
28  pkg_config("gbm") {
29    packages = [ "gbm" ]
30  }
31  pkg_config("egl") {
32    packages = [ "egl" ]
33  }
34  pkg_config("epoxy") {
35    packages = [ "epoxy" ]
36    ignore_libs = true
37  }
38  pkg_config("libdrm") {
39    packages = [ "libdrm" ]
40  }
41
42  if (!rtc_link_pipewire) {
43    # When libpipewire is not directly linked, use stubs to allow for dlopening of
44    # the binary.
45    generate_stubs("pipewire_stubs") {
46      configs = [
47        "../../:common_config",
48        ":pipewire",
49      ]
50      deps = [ "../../rtc_base" ]
51      extra_header = "pipewire_stub_header.fragment"
52      logging_function = "RTC_LOG(LS_VERBOSE)"
53      logging_include = "rtc_base/logging.h"
54      output_name = "pipewire_stubs"
55      path_from_source = "modules/portal"
56      sigs = [ "pipewire.sigs" ]
57      if (!build_with_chromium) {
58        macro_include = "rtc_base/system/no_cfi_icall.h"
59        macro_deps = [ "../../rtc_base/system:no_cfi_icall" ]
60      }
61    }
62  }
63
64  config("pipewire_base") {
65    configs = [
66      ":gio",
67      ":pipewire",
68    ]
69  }
70
71  config("pipewire_all") {
72    configs = [
73      ":pipewire_base",
74      ":gbm",
75      ":egl",
76      ":epoxy",
77      ":libdrm",
78    ]
79  }
80
81  config("pipewire_config") {
82    defines = [ "WEBRTC_USE_PIPEWIRE" ]
83
84    # Chromecast build config overrides `WEBRTC_USE_PIPEWIRE` even when
85    # `rtc_use_pipewire` is not set, which causes pipewire_config to not be
86    # included in targets. More details in: webrtc:13898
87    if (is_linux && !is_castos) {
88      defines += [ "WEBRTC_USE_GIO" ]
89    }
90  }
91
92  rtc_library("portal") {
93    sources = [
94      "pipewire_utils.cc",
95      "pipewire_utils.h",
96      "portal_request_response.h",
97      "scoped_glib.cc",
98      "scoped_glib.h",
99      "xdg_desktop_portal_utils.cc",
100      "xdg_desktop_portal_utils.h",
101      "xdg_session_details.h",
102    ]
103
104    configs += [
105      ":gio",
106      ":pipewire",
107      ":pipewire_config",
108    ]
109
110    deps = [
111      "../../rtc_base:checks",
112      "../../rtc_base:logging",
113      "../../rtc_base:sanitizer",
114    ]
115    absl_deps = [ "//third_party/abseil-cpp/absl/strings" ]
116
117    if (!rtc_link_pipewire) {
118      defines = [ "WEBRTC_DLOPEN_PIPEWIRE" ]
119
120      deps += [ ":pipewire_stubs" ]
121    }
122  }
123}
124