summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/build/config/linux
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /third_party/libwebrtc/build/config/linux
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/build/config/linux')
-rw-r--r--third_party/libwebrtc/build/config/linux/BUILD.gn79
-rw-r--r--third_party/libwebrtc/build/config/linux/OWNERS1
-rw-r--r--third_party/libwebrtc/build/config/linux/atk/BUILD.gn35
-rw-r--r--third_party/libwebrtc/build/config/linux/atspi2/BUILD.gn29
-rw-r--r--third_party/libwebrtc/build/config/linux/dbus/BUILD.gn14
-rw-r--r--third_party/libwebrtc/build/config/linux/dri/BUILD.gn18
-rw-r--r--third_party/libwebrtc/build/config/linux/gtk/BUILD.gn69
-rw-r--r--third_party/libwebrtc/build/config/linux/gtk/gtk.gni10
-rw-r--r--third_party/libwebrtc/build/config/linux/libdrm/BUILD.gn31
-rw-r--r--third_party/libwebrtc/build/config/linux/libffi/BUILD.gn18
-rw-r--r--third_party/libwebrtc/build/config/linux/libva/BUILD.gn17
-rw-r--r--third_party/libwebrtc/build/config/linux/nss/BUILD.gn22
-rw-r--r--third_party/libwebrtc/build/config/linux/pangocairo/BUILD.gn19
-rw-r--r--third_party/libwebrtc/build/config/linux/pangocairo/pangocairo.gni10
-rwxr-xr-xthird_party/libwebrtc/build/config/linux/pkg-config.py248
-rw-r--r--third_party/libwebrtc/build/config/linux/pkg_config.gni128
16 files changed, 748 insertions, 0 deletions
diff --git a/third_party/libwebrtc/build/config/linux/BUILD.gn b/third_party/libwebrtc/build/config/linux/BUILD.gn
new file mode 100644
index 0000000000..c036e4ae94
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/BUILD.gn
@@ -0,0 +1,79 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("../../../webrtc.gni")
+
+import("//build/config/c++/c++.gni")
+import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/linux/pkg_config.gni")
+import("//build/config/ui.gni")
+
+group("linux") {
+ visibility = [ "//:optimize_gn_gen" ]
+}
+
+# This is included by reference in the //build/config/compiler config that
+# is applied to all targets. It is here to separate out the logic that is
+# Linux-only. This is not applied to Android, but is applied to ChromeOS.
+config("compiler") {
+ if (target_cpu == "arm64") {
+ import("//build/config/arm.gni")
+ cflags = []
+ asmflags = []
+ if (arm_control_flow_integrity == "standard") {
+ cflags += [ "-mbranch-protection=standard" ]
+ asmflags += [ "-mbranch-protection=standard" ]
+ }
+ }
+}
+
+# This is included by reference in the //build/config/compiler:runtime_library
+# config that is applied to all targets. It is here to separate out the logic
+# that is Linux-only. Please see that target for advice on what should go in
+# :runtime_library vs. :compiler.
+config("runtime_library") {
+ # Set here because OS_CHROMEOS cannot be autodetected in build_config.h like
+ # OS_LINUX and the like.
+ if (is_chromeos) {
+ defines = [ "OS_CHROMEOS" ]
+ }
+
+ if ((!(is_chromeos_ash || is_chromeos_lacros) ||
+ default_toolchain != "//build/toolchain/cros:target") &&
+ (!use_custom_libcxx || target_cpu == "mipsel") && !build_with_mozilla) {
+ libs = [ "atomic" ]
+ }
+}
+
+config("libcap") {
+ libs = [ "cap" ]
+}
+
+config("libresolv") {
+ libs = [ "resolv" ]
+}
+
+if (false && use_glib) {
+ pkg_config("glib") {
+ packages = [
+ "glib-2.0",
+ "gmodule-2.0",
+ "gobject-2.0",
+ "gthread-2.0",
+ ]
+ defines = [
+ "GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40",
+ "GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40",
+ ]
+ }
+}
+
+# Ensures all exported symbols are added to the dynamic symbol table. This is
+# necessary to expose Chrome's custom operator new() and operator delete() (and
+# other memory-related symbols) to libraries. Otherwise, they might
+# (de)allocate memory on a different heap, which would spell trouble if pointers
+# to heap-allocated memory are passed over shared library boundaries.
+config("export_dynamic") {
+ ldflags = [ "-rdynamic" ]
+}
diff --git a/third_party/libwebrtc/build/config/linux/OWNERS b/third_party/libwebrtc/build/config/linux/OWNERS
new file mode 100644
index 0000000000..280ba478dc
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/OWNERS
@@ -0,0 +1 @@
+thomasanderson@chromium.org
diff --git a/third_party/libwebrtc/build/config/linux/atk/BUILD.gn b/third_party/libwebrtc/build/config/linux/atk/BUILD.gn
new file mode 100644
index 0000000000..92baff2a9b
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/atk/BUILD.gn
@@ -0,0 +1,35 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/features.gni")
+import("//build/config/linux/pkg_config.gni")
+import("//build/config/ui.gni")
+
+# CrOS doesn't install GTK or any gnome packages.
+assert(!is_chromeos)
+
+# These packages should _only_ be expected when building for a target.
+assert(current_toolchain == default_toolchain)
+
+if (use_atk) {
+ assert(use_glib, "use_atk=true requires that use_glib=true")
+}
+
+pkg_config("atk") {
+ packages = [
+ "atk",
+ "atk-bridge-2.0",
+ ]
+ atk_lib_dir = exec_script(pkg_config_script,
+ pkg_config_args + [
+ "--libdir",
+ "atk",
+ ],
+ "string")
+ defines = [
+ "ATK_LIB_DIR=\"$atk_lib_dir\"",
+ "USE_ATK_BRIDGE",
+ ]
+}
diff --git a/third_party/libwebrtc/build/config/linux/atspi2/BUILD.gn b/third_party/libwebrtc/build/config/linux/atspi2/BUILD.gn
new file mode 100644
index 0000000000..988a995681
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/atspi2/BUILD.gn
@@ -0,0 +1,29 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/linux/pkg_config.gni")
+import("//build/config/ui.gni")
+
+# These packages should _only_ be expected when building for a target.
+assert(current_toolchain == default_toolchain)
+
+if (use_atk) {
+ pkg_config("atspi2") {
+ packages = [ "atspi-2" ]
+ atspi_version = exec_script(pkg_config_script,
+ pkg_config_args + [
+ "atspi-2",
+ "--version-as-components",
+ ],
+ "value")
+ atspi_major_version = atspi_version[0]
+ atspi_minor_version = atspi_version[1]
+ atspi_micro_version = atspi_version[2]
+ defines = [
+ "ATSPI_MAJOR_VERSION=$atspi_major_version",
+ "ATSPI_MINOR_VERSION=$atspi_minor_version",
+ "ATSPI_MICRO_VERSION=$atspi_micro_version",
+ ]
+ }
+}
diff --git a/third_party/libwebrtc/build/config/linux/dbus/BUILD.gn b/third_party/libwebrtc/build/config/linux/dbus/BUILD.gn
new file mode 100644
index 0000000000..f11cf7101c
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/dbus/BUILD.gn
@@ -0,0 +1,14 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/features.gni")
+import("//build/config/linux/pkg_config.gni")
+
+assert(use_dbus)
+
+# Note: if your target also depends on //dbus, you don't need to add this
+# config (it will get added automatically if you depend on //dbus).
+pkg_config("dbus") {
+ packages = [ "dbus-1" ]
+}
diff --git a/third_party/libwebrtc/build/config/linux/dri/BUILD.gn b/third_party/libwebrtc/build/config/linux/dri/BUILD.gn
new file mode 100644
index 0000000000..cad883b76d
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/dri/BUILD.gn
@@ -0,0 +1,18 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/linux/pkg_config.gni")
+
+assert(is_linux, "This file should only be referenced on Linux")
+
+pkg_config("dri") {
+ packages = [ "dri" ]
+ dri_driver_dir = exec_script(pkg_config_script,
+ pkg_config_args + [
+ "--dridriverdir",
+ "dri",
+ ],
+ "string")
+ defines = [ "DRI_DRIVER_DIR=\"$dri_driver_dir\"" ]
+}
diff --git a/third_party/libwebrtc/build/config/linux/gtk/BUILD.gn b/third_party/libwebrtc/build/config/linux/gtk/BUILD.gn
new file mode 100644
index 0000000000..6590023971
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/gtk/BUILD.gn
@@ -0,0 +1,69 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/linux/gtk/gtk.gni")
+import("//build/config/linux/pkg_config.gni")
+
+assert(is_linux, "This file should only be referenced on Linux")
+
+declare_args() {
+ # The (major) version of GTK to build against. A different version may be
+ # loaded at runtime.
+ gtk_version = 3
+}
+
+# GN doesn't check visibility for configs so we give this an obviously internal
+# name to discourage random targets from accidentally depending on this and
+# bypassing the GTK target's visibility.
+pkg_config("gtk_internal_config") {
+ # Gtk requires gmodule, but it does not list it as a dependency in some
+ # misconfigured systems.
+ packages = [
+ "gmodule-2.0",
+ "gthread-2.0",
+ ]
+ if (gtk_version == 3) {
+ packages += [ "gtk+-3.0" ]
+ } else {
+ assert(gtk_version == 4)
+ packages += [ "gtk4" ]
+ }
+}
+
+group("gtk") {
+ visibility = [
+ # This is the only target that can depend on GTK. Do not add more targets
+ # to this list.
+ "//ui/gtk:gtk_stubs",
+
+ # These are allow-listed for WebRTC builds.
+ "//examples:peerconnection_client",
+ "//remoting/host:common",
+ "//remoting/host:remoting_me2me_host_static",
+ "//remoting/host/file_transfer",
+ "//remoting/host/it2me:common",
+ "//remoting/host/it2me:remote_assistance_host",
+ "//remoting/host/linux",
+ "//remoting/host/remote_open_url:common",
+ "//remoting/test:it2me_standalone_host_main",
+ "//webrtc/examples:peerconnection_client",
+ ]
+
+ public_configs = [ ":gtk_internal_config" ]
+}
+
+# Depend on "gtkprint" to get this.
+pkg_config("gtkprint_internal_config") {
+ if (gtk_version == 3) {
+ packages = [ "gtk+-unix-print-3.0" ]
+ } else {
+ assert(gtk_version == 4)
+ packages = [ "gtk4-unix-print" ]
+ }
+}
+
+group("gtkprint") {
+ visibility = [ "//ui/gtk:*" ]
+ public_configs = [ ":gtkprint_internal_config" ]
+}
diff --git a/third_party/libwebrtc/build/config/linux/gtk/gtk.gni b/third_party/libwebrtc/build/config/linux/gtk/gtk.gni
new file mode 100644
index 0000000000..70cb823154
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/gtk/gtk.gni
@@ -0,0 +1,10 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/ui.gni")
+
+declare_args() {
+ # Whether or not we should use libgtk.
+ use_gtk = (is_linux || is_bsd) && !is_chromecast
+}
diff --git a/third_party/libwebrtc/build/config/linux/libdrm/BUILD.gn b/third_party/libwebrtc/build/config/linux/libdrm/BUILD.gn
new file mode 100644
index 0000000000..79695cbc60
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/libdrm/BUILD.gn
@@ -0,0 +1,31 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import("//build/config/chromecast_build.gni")
+import("//build/config/chromeos/args.gni")
+import("//build/config/linux/pkg_config.gni")
+
+assert(is_linux || is_chromeos)
+
+declare_args() {
+ # Controls whether the build should use the version of libdrm library shipped
+ # with the system. In release builds of desktop Linux and Chrome OS we use the
+ # system version. Some Chromecast devices use this as well.
+ use_system_libdrm = is_chromeos_device || ((is_linux || is_bsd) && !is_chromecast)
+}
+
+if (use_system_libdrm) {
+ pkg_config("libdrm_config") {
+ packages = [ "libdrm" ]
+ }
+ group("libdrm") {
+ public_configs = [ ":libdrm_config" ]
+ }
+} else {
+ group("libdrm") {
+ public_deps = [ "//third_party/libdrm" ]
+ }
+ config("libdrm_exynos_include_config") {
+ include_dirs = [ "//third_party/libdrm/src/exynos" ]
+ }
+}
diff --git a/third_party/libwebrtc/build/config/linux/libffi/BUILD.gn b/third_party/libwebrtc/build/config/linux/libffi/BUILD.gn
new file mode 100644
index 0000000000..fb4fa18bf7
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/libffi/BUILD.gn
@@ -0,0 +1,18 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/linux/pkg_config.gni")
+
+if (default_toolchain == "//build/toolchain/cros:target") {
+ pkg_config("libffi") {
+ packages = [ "libffi" ]
+ }
+} else {
+ # On Linux, statically link libffi. This is necessary to prevent a situation
+ # where the runtime version of libffi is different from the build-time version
+ # from the sysroot.
+ config("libffi") {
+ libs = [ ":libffi_pic.a" ]
+ }
+}
diff --git a/third_party/libwebrtc/build/config/linux/libva/BUILD.gn b/third_party/libwebrtc/build/config/linux/libva/BUILD.gn
new file mode 100644
index 0000000000..ada5d665fb
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/libva/BUILD.gn
@@ -0,0 +1,17 @@
+# Copyright 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/linux/pkg_config.gni")
+
+assert(is_linux || is_chromeos, "This file should only be referenced on Linux")
+
+pkg_config("libva") {
+ packages = [ "libva" ]
+
+ # Do not use exec_script to check the version here. It is done with a
+ # static_assert instead.
+
+ # vaapi decoders use dlopen pre-sandbox anyway to improve startup times.
+ ignore_libs = true
+}
diff --git a/third_party/libwebrtc/build/config/linux/nss/BUILD.gn b/third_party/libwebrtc/build/config/linux/nss/BUILD.gn
new file mode 100644
index 0000000000..8c27938b76
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/nss/BUILD.gn
@@ -0,0 +1,22 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/linux/pkg_config.gni")
+
+if (is_linux || is_chromeos) {
+ # This is a dependency on NSS with no libssl. On Linux we use a built-in SSL
+ # library but the system NSS libraries. Non-Linux platforms using NSS use the
+ # hermetic one in //third_party/nss.
+ #
+ # Generally you should depend on //crypto:platform instead of using this
+ # config since that will properly pick up NSS or OpenSSL depending on
+ # platform and build config.
+ pkg_config("system_nss_no_ssl_config") {
+ packages = [ "nss" ]
+ extra_args = [
+ "-v",
+ "-lssl3",
+ ]
+ }
+}
diff --git a/third_party/libwebrtc/build/config/linux/pangocairo/BUILD.gn b/third_party/libwebrtc/build/config/linux/pangocairo/BUILD.gn
new file mode 100644
index 0000000000..ddcc754bbd
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/pangocairo/BUILD.gn
@@ -0,0 +1,19 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/linux/pangocairo/pangocairo.gni")
+import("//build/config/linux/pkg_config.gni")
+
+if (use_pangocairo) {
+ pkg_config("pangocairo") {
+ packages = [ "pangocairo" ]
+
+ # We don't want pkgconfig for pangocairo to explicitly request FreeType to get
+ # linked, because we control which FreeType to link to.
+ extra_args = [
+ "-v",
+ "freetype",
+ ]
+ }
+}
diff --git a/third_party/libwebrtc/build/config/linux/pangocairo/pangocairo.gni b/third_party/libwebrtc/build/config/linux/pangocairo/pangocairo.gni
new file mode 100644
index 0000000000..6bc75294cd
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/pangocairo/pangocairo.gni
@@ -0,0 +1,10 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/chromeos/ui_mode.gni")
+import("//build/config/ui.gni")
+
+declare_args() {
+ use_pangocairo = is_linux && !is_chromecast
+}
diff --git a/third_party/libwebrtc/build/config/linux/pkg-config.py b/third_party/libwebrtc/build/config/linux/pkg-config.py
new file mode 100755
index 0000000000..5adf70cc3b
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/pkg-config.py
@@ -0,0 +1,248 @@
+#!/usr/bin/env python
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from __future__ import print_function
+
+import json
+import os
+import subprocess
+import sys
+import re
+from optparse import OptionParser
+
+# This script runs pkg-config, optionally filtering out some results, and
+# returns the result.
+#
+# The result will be [ <includes>, <cflags>, <libs>, <lib_dirs>, <ldflags> ]
+# where each member is itself a list of strings.
+#
+# You can filter out matches using "-v <regexp>" where all results from
+# pkgconfig matching the given regular expression will be ignored. You can
+# specify more than one regular expression my specifying "-v" more than once.
+#
+# You can specify a sysroot using "-s <sysroot>" where sysroot is the absolute
+# system path to the sysroot used for compiling. This script will attempt to
+# generate correct paths for the sysroot.
+#
+# When using a sysroot, you must also specify the architecture via
+# "-a <arch>" where arch is either "x86" or "x64".
+#
+# CrOS systemroots place pkgconfig files at <systemroot>/usr/share/pkgconfig
+# and one of <systemroot>/usr/lib/pkgconfig or <systemroot>/usr/lib64/pkgconfig
+# depending on whether the systemroot is for a 32 or 64 bit architecture. They
+# specify the 'lib' or 'lib64' of the pkgconfig path by defining the
+# 'system_libdir' variable in the args.gn file. pkg_config.gni communicates this
+# variable to this script with the "--system_libdir <system_libdir>" flag. If no
+# flag is provided, then pkgconfig files are assumed to come from
+# <systemroot>/usr/lib/pkgconfig.
+#
+# Additionally, you can specify the option --atleast-version. This will skip
+# the normal outputting of a dictionary and instead print true or false,
+# depending on the return value of pkg-config for the given package.
+
+
+def SetConfigPath(options):
+ """Set the PKG_CONFIG_LIBDIR environment variable.
+
+ This takes into account any sysroot and architecture specification from the
+ options on the given command line.
+ """
+
+ sysroot = options.sysroot
+ assert sysroot
+
+ # Compute the library path name based on the architecture.
+ arch = options.arch
+ if sysroot and not arch:
+ print("You must specify an architecture via -a if using a sysroot.")
+ sys.exit(1)
+
+ libdir = sysroot + '/usr/' + options.system_libdir + '/pkgconfig'
+ libdir += ':' + sysroot + '/usr/share/pkgconfig'
+ os.environ['PKG_CONFIG_LIBDIR'] = libdir
+ return libdir
+
+
+def GetPkgConfigPrefixToStrip(options, args):
+ """Returns the prefix from pkg-config where packages are installed.
+
+ This returned prefix is the one that should be stripped from the beginning of
+ directory names to take into account sysroots.
+ """
+ # Some sysroots, like the Chromium OS ones, may generate paths that are not
+ # relative to the sysroot. For example,
+ # /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all
+ # paths relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr)
+ # instead of relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr).
+ # To support this correctly, it's necessary to extract the prefix to strip
+ # from pkg-config's |prefix| variable.
+ prefix = subprocess.check_output([options.pkg_config,
+ "--variable=prefix"] + args, env=os.environ).decode('utf-8')
+ if prefix[-4] == '/usr':
+ return prefix[4:]
+ return prefix
+
+
+def MatchesAnyRegexp(flag, list_of_regexps):
+ """Returns true if the first argument matches any regular expression in the
+ given list."""
+ for regexp in list_of_regexps:
+ if regexp.search(flag) != None:
+ return True
+ return False
+
+
+def RewritePath(path, strip_prefix, sysroot):
+ """Rewrites a path by stripping the prefix and prepending the sysroot."""
+ if os.path.isabs(path) and not path.startswith(sysroot):
+ if path.startswith(strip_prefix):
+ path = path[len(strip_prefix):]
+ path = path.lstrip('/')
+ return os.path.join(sysroot, path)
+ else:
+ return path
+
+
+def main():
+ # If this is run on non-Linux platforms, just return nothing and indicate
+ # success. This allows us to "kind of emulate" a Linux build from other
+ # platforms.
+ if "linux" not in sys.platform:
+ print("[[],[],[],[],[]]")
+ return 0
+
+ parser = OptionParser()
+ parser.add_option('-d', '--debug', action='store_true')
+ parser.add_option('-p', action='store', dest='pkg_config', type='string',
+ default='pkg-config')
+ parser.add_option('-v', action='append', dest='strip_out', type='string')
+ parser.add_option('-s', action='store', dest='sysroot', type='string')
+ parser.add_option('-a', action='store', dest='arch', type='string')
+ parser.add_option('--system_libdir', action='store', dest='system_libdir',
+ type='string', default='lib')
+ parser.add_option('--atleast-version', action='store',
+ dest='atleast_version', type='string')
+ parser.add_option('--libdir', action='store_true', dest='libdir')
+ parser.add_option('--dridriverdir', action='store_true', dest='dridriverdir')
+ parser.add_option('--version-as-components', action='store_true',
+ dest='version_as_components')
+ (options, args) = parser.parse_args()
+
+ # Make a list of regular expressions to strip out.
+ strip_out = []
+ if options.strip_out != None:
+ for regexp in options.strip_out:
+ strip_out.append(re.compile(regexp))
+
+ if options.sysroot:
+ libdir = SetConfigPath(options)
+ if options.debug:
+ sys.stderr.write('PKG_CONFIG_LIBDIR=%s\n' % libdir)
+ prefix = GetPkgConfigPrefixToStrip(options, args)
+ else:
+ prefix = ''
+
+ if options.atleast_version:
+ # When asking for the return value, just run pkg-config and print the return
+ # value, no need to do other work.
+ if not subprocess.call([options.pkg_config,
+ "--atleast-version=" + options.atleast_version] +
+ args):
+ print("true")
+ else:
+ print("false")
+ return 0
+
+ if options.version_as_components:
+ cmd = [options.pkg_config, "--modversion"] + args
+ try:
+ version_string = subprocess.check_output(cmd).decode('utf-8')
+ except:
+ sys.stderr.write('Error from pkg-config.\n')
+ return 1
+ print(json.dumps(list(map(int, version_string.strip().split(".")))))
+ return 0
+
+
+ if options.libdir:
+ cmd = [options.pkg_config, "--variable=libdir"] + args
+ if options.debug:
+ sys.stderr.write('Running: %s\n' % cmd)
+ try:
+ libdir = subprocess.check_output(cmd).decode('utf-8')
+ except:
+ print("Error from pkg-config.")
+ return 1
+ sys.stdout.write(libdir.strip())
+ return 0
+
+ if options.dridriverdir:
+ cmd = [options.pkg_config, "--variable=dridriverdir"] + args
+ if options.debug:
+ sys.stderr.write('Running: %s\n' % cmd)
+ try:
+ dridriverdir = subprocess.check_output(cmd).decode('utf-8')
+ except:
+ print("Error from pkg-config.")
+ return 1
+ sys.stdout.write(dridriverdir.strip())
+ return
+
+ cmd = [options.pkg_config, "--cflags", "--libs"] + args
+ if options.debug:
+ sys.stderr.write('Running: %s\n' % ' '.join(cmd))
+
+ try:
+ flag_string = subprocess.check_output(cmd).decode('utf-8')
+ except:
+ sys.stderr.write('Could not run pkg-config.\n')
+ return 1
+
+ # For now just split on spaces to get the args out. This will break if
+ # pkgconfig returns quoted things with spaces in them, but that doesn't seem
+ # to happen in practice.
+ all_flags = flag_string.strip().split(' ')
+
+
+ sysroot = options.sysroot
+ if not sysroot:
+ sysroot = ''
+
+ includes = []
+ cflags = []
+ libs = []
+ lib_dirs = []
+
+ for flag in all_flags[:]:
+ if len(flag) == 0 or MatchesAnyRegexp(flag, strip_out):
+ continue;
+
+ if flag[:2] == '-l':
+ libs.append(RewritePath(flag[2:], prefix, sysroot))
+ elif flag[:2] == '-L':
+ lib_dirs.append(RewritePath(flag[2:], prefix, sysroot))
+ elif flag[:2] == '-I':
+ includes.append(RewritePath(flag[2:], prefix, sysroot))
+ elif flag[:3] == '-Wl':
+ # Don't allow libraries to control ld flags. These should be specified
+ # only in build files.
+ pass
+ elif flag == '-pthread':
+ # Many libs specify "-pthread" which we don't need since we always include
+ # this anyway. Removing it here prevents a bunch of duplicate inclusions
+ # on the command line.
+ pass
+ else:
+ cflags.append(flag)
+
+ # Output a GN array, the first one is the cflags, the second are the libs. The
+ # JSON formatter prints GN compatible lists when everything is a list of
+ # strings.
+ print(json.dumps([includes, cflags, libs, lib_dirs]))
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/third_party/libwebrtc/build/config/linux/pkg_config.gni b/third_party/libwebrtc/build/config/linux/pkg_config.gni
new file mode 100644
index 0000000000..f3b40755bd
--- /dev/null
+++ b/third_party/libwebrtc/build/config/linux/pkg_config.gni
@@ -0,0 +1,128 @@
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//build/config/sysroot.gni")
+
+# Defines a config specifying the result of running pkg-config for the given
+# packages. Put the package names you want to query in the "packages" variable
+# inside the template invocation.
+#
+# You can also add defines via the "defines" variable. This can be useful to
+# add this to the config to pass defines that the library expects to get by
+# users of its headers.
+#
+# Example:
+# pkg_config("mything") {
+# packages = [ "mything1", "mything2" ]
+# defines = [ "ENABLE_AWESOME" ]
+# }
+#
+# You can also use "extra args" to filter out results (see pkg-config.py):
+# extra_args = [ "-v, "foo" ]
+# To ignore libs and ldflags (only cflags/defines will be set, which is useful
+# when doing manual dynamic linking), set:
+# ignore_libs = true
+
+declare_args() {
+ # A pkg-config wrapper to call instead of trying to find and call the right
+ # pkg-config directly. Wrappers like this are common in cross-compilation
+ # environments.
+ # Leaving it blank defaults to searching PATH for 'pkg-config' and relying on
+ # the sysroot mechanism to find the right .pc files.
+ pkg_config = ""
+
+ # A optional pkg-config wrapper to use for tools built on the host.
+ host_pkg_config = ""
+
+ # CrOS systemroots place pkgconfig files at <systemroot>/usr/share/pkgconfig
+ # and one of <systemroot>/usr/lib/pkgconfig or <systemroot>/usr/lib64/pkgconfig
+ # depending on whether the systemroot is for a 32 or 64 bit architecture.
+ #
+ # When build under GYP, CrOS board builds specify the 'system_libdir' variable
+ # as part of the GYP_DEFINES provided by the CrOS emerge build or simple
+ # chrome build scheme. This variable permits controlling this for GN builds
+ # in similar fashion by setting the `system_libdir` variable in the build's
+ # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture.
+ system_libdir = "lib"
+}
+
+pkg_config_script = "//build/config/linux/pkg-config.py"
+
+# Define the args we pass to the pkg-config script for other build files that
+# need to invoke it manually.
+pkg_config_args = []
+
+if (sysroot != "") {
+ # Pass the sysroot if we're using one (it requires the CPU arch also).
+ pkg_config_args += [
+ "-s",
+ rebase_path(sysroot),
+ "-a",
+ target_cpu,
+ ]
+}
+
+if (pkg_config != "") {
+ pkg_config_args += [
+ "-p",
+ pkg_config,
+ ]
+}
+
+# Only use the custom libdir when building with the target sysroot.
+if (target_sysroot != "" && sysroot == target_sysroot) {
+ pkg_config_args += [
+ "--system_libdir",
+ system_libdir,
+ ]
+}
+
+if (host_pkg_config != "") {
+ host_pkg_config_args = [
+ "-p",
+ host_pkg_config,
+ ]
+} else {
+ host_pkg_config_args = pkg_config_args
+}
+
+template("pkg_config") {
+ assert(defined(invoker.packages),
+ "Variable |packages| must be defined to be a list in pkg_config.")
+ config(target_name) {
+ if (host_toolchain == current_toolchain) {
+ args = host_pkg_config_args + invoker.packages
+ } else {
+ args = pkg_config_args + invoker.packages
+ }
+ if (defined(invoker.extra_args)) {
+ args += invoker.extra_args
+ }
+
+ pkgresult = exec_script(pkg_config_script, args, "value")
+ cflags = pkgresult[1]
+
+ foreach(include, pkgresult[0]) {
+ if (use_sysroot) {
+ # We want the system include paths to use -isystem instead of -I to
+ # suppress warnings in those headers.
+ include_relativized = rebase_path(include, root_build_dir)
+ cflags += [ "-isystem$include_relativized" ]
+ } else {
+ cflags += [ "-I$include" ]
+ }
+ }
+
+ if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) {
+ libs = pkgresult[2]
+ lib_dirs = pkgresult[3]
+ }
+
+ forward_variables_from(invoker,
+ [
+ "defines",
+ "visibility",
+ ])
+ }
+}