summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/webrtc/build/config
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/libwebrtc/webrtc/build/config')
-rw-r--r--third_party/libwebrtc/webrtc/build/config/BUILD.gn389
-rw-r--r--third_party/libwebrtc/webrtc/build/config/BUILDCONFIG.gn714
-rw-r--r--third_party/libwebrtc/webrtc/build/config/OWNERS6
-rw-r--r--third_party/libwebrtc/webrtc/build/config/aix/BUILD.gn50
-rw-r--r--third_party/libwebrtc/webrtc/build/config/allocator.gni53
-rw-r--r--third_party/libwebrtc/webrtc/build/config/android/BUILD.gn239
-rw-r--r--third_party/libwebrtc/webrtc/build/config/android/OWNERS3
-rw-r--r--third_party/libwebrtc/webrtc/build/config/android/config.gni374
-rw-r--r--third_party/libwebrtc/webrtc/build/config/android/internal_rules.gni2894
-rw-r--r--third_party/libwebrtc/webrtc/build/config/android/rules.gni2970
-rw-r--r--third_party/libwebrtc/webrtc/build/config/arm.gni126
-rw-r--r--third_party/libwebrtc/webrtc/build/config/chrome_build.gni22
-rw-r--r--third_party/libwebrtc/webrtc/build/config/chromecast/BUILD.gn85
-rw-r--r--third_party/libwebrtc/webrtc/build/config/chromecast_build.gni36
-rw-r--r--third_party/libwebrtc/webrtc/build/config/clang/BUILD.gn65
-rw-r--r--third_party/libwebrtc/webrtc/build/config/clang/clang.gni13
-rw-r--r--third_party/libwebrtc/webrtc/build/config/compiler/BUILD.gn1766
-rw-r--r--third_party/libwebrtc/webrtc/build/config/compiler/compiler.gni182
-rw-r--r--third_party/libwebrtc/webrtc/build/config/compiler/pgo/BUILD.gn101
-rw-r--r--third_party/libwebrtc/webrtc/build/config/compiler/pgo/pgo.gni17
-rw-r--r--third_party/libwebrtc/webrtc/build/config/crypto.gni23
-rw-r--r--third_party/libwebrtc/webrtc/build/config/dcheck_always_on.gni8
-rw-r--r--third_party/libwebrtc/webrtc/build/config/features.gni73
-rw-r--r--third_party/libwebrtc/webrtc/build/config/freetype/BUILD.gn16
-rw-r--r--third_party/libwebrtc/webrtc/build/config/freetype/OWNERS2
-rw-r--r--third_party/libwebrtc/webrtc/build/config/freetype/freetype.gni14
-rw-r--r--third_party/libwebrtc/webrtc/build/config/fuchsia/BUILD.gn40
-rw-r--r--third_party/libwebrtc/webrtc/build/config/fuchsia/OWNERS1
-rw-r--r--third_party/libwebrtc/webrtc/build/config/fuchsia/config.gni10
-rw-r--r--third_party/libwebrtc/webrtc/build/config/gcc/BUILD.gn151
-rw-r--r--third_party/libwebrtc/webrtc/build/config/get_host_byteorder.py11
-rw-r--r--third_party/libwebrtc/webrtc/build/config/host_byteorder.gni27
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/BUILD.gn155
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/BuildInfo.plist35
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/Host-Info.plist126
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/Module-Info.plist24
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/OWNERS1
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/codesign.py437
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/entitlements.plist12
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/find_signing_identity.py47
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/ios_sdk.gni168
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/rules.gni1509
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/write_framework_hmap.py97
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/write_framework_modulemap.py26
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ios/xctest_shell.mm19
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/BUILD.gn102
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/atk/BUILD.gn47
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/dbus/BUILD.gn14
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/gconf/BUILD.gn19
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/gtk/BUILD.gn39
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/gtk/gtk.gni12
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/gtk2/BUILD.gn44
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/gtk3/BUILD.gn43
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/libffi/BUILD.gn9
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/pangocairo/BUILD.gn16
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/pkg-config.py219
-rw-r--r--third_party/libwebrtc/webrtc/build/config/linux/pkg_config.gni117
-rw-r--r--third_party/libwebrtc/webrtc/build/config/locales.gni187
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/BUILD.gn104
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/BuildInfo.plist26
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/OWNERS4
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/base_rules.gni253
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/compile_ib_files.py57
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/mac_sdk.gni105
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/package_framework.py60
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/plist_util.py254
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/prepare_framework_version.py42
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/rules.gni692
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/sdk_info.py73
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/symbols.gni30
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/write_pkg_info.py47
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mac/xcrun.py28
-rw-r--r--third_party/libwebrtc/webrtc/build/config/mips.gni58
-rw-r--r--third_party/libwebrtc/webrtc/build/config/nacl/BUILD.gn143
-rw-r--r--third_party/libwebrtc/webrtc/build/config/nacl/config.gni52
-rw-r--r--third_party/libwebrtc/webrtc/build/config/nacl/rules.gni185
-rw-r--r--third_party/libwebrtc/webrtc/build/config/pch.gni12
-rw-r--r--third_party/libwebrtc/webrtc/build/config/posix/BUILD.gn43
-rw-r--r--third_party/libwebrtc/webrtc/build/config/posix/sysroot_ld_path.py21
-rw-r--r--third_party/libwebrtc/webrtc/build/config/sanitizers/BUILD.gn579
-rw-r--r--third_party/libwebrtc/webrtc/build/config/sanitizers/OWNERS2
-rw-r--r--third_party/libwebrtc/webrtc/build/config/sanitizers/sanitizers.gni203
-rw-r--r--third_party/libwebrtc/webrtc/build/config/sysroot.gni92
-rw-r--r--third_party/libwebrtc/webrtc/build/config/ui.gni72
-rw-r--r--third_party/libwebrtc/webrtc/build/config/v8_target_cpu.gni61
-rw-r--r--third_party/libwebrtc/webrtc/build/config/win/BUILD.gn438
-rw-r--r--third_party/libwebrtc/webrtc/build/config/win/console_app.gni18
-rw-r--r--third_party/libwebrtc/webrtc/build/config/win/manifest.gni191
-rw-r--r--third_party/libwebrtc/webrtc/build/config/win/visual_studio_version.gni39
-rw-r--r--third_party/libwebrtc/webrtc/build/config/zip.gni55
90 files changed, 18044 insertions, 0 deletions
diff --git a/third_party/libwebrtc/webrtc/build/config/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/BUILD.gn
new file mode 100644
index 0000000000..59524689aa
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/BUILD.gn
@@ -0,0 +1,389 @@
+# 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/allocator.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromecast_build.gni")
+import("//build/config/crypto.gni")
+import("//build/config/dcheck_always_on.gni")
+import("//build/config/features.gni")
+import("//build/config/pch.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/ui.gni")
+import("//build/toolchain/goma.gni")
+
+declare_args() {
+ # When set (the default) enables C++ iterator debugging in debug builds.
+ # Iterator debugging is always off in release builds (technically, this flag
+ # affects the "debug" config, which is always available but applied by
+ # default only in debug builds).
+ #
+ # Iterator debugging is generally useful for catching bugs. But it can
+ # introduce extra locking to check the state of an iterator against the state
+ # of the current object. For iterator- and thread-heavy code, this can
+ # significantly slow execution.
+ enable_iterator_debugging = true
+}
+
+# ==============================================
+# PLEASE DO NOT ADD MORE THINGS TO THIS LIST
+# ==============================================
+#
+# Legacy feature defines applied to all targets.
+#
+# These are applied to every single compile in the build and most of them are
+# only relevant to a few files. This bloats command lines and causes
+# unnecessary recompiles when flags are flipped.
+#
+# To pass defines to source code from the build, use the buildflag system which
+# will write headers containing the defines you need. This isolates the define
+# and means its definition can participate in the build graph, only recompiling
+# things when it actually changes.
+#
+# See //build/buildflag_header.gni for inntructions on generating headers.
+#
+# This will also allow you to scope your build flag to a BUILD.gn file (or a
+# .gni file if you need it from more than one place) rather than making global
+# flags. See //build/config/BUILDCONFIG.gn for advice on where to define
+# build flags.
+config("feature_flags") {
+ # Don't use deprecated V8 APIs anywhere.
+ defines = []
+ defines += [ "V8_DEPRECATION_WARNINGS" ]
+
+ if (dcheck_always_on) {
+ defines += [ "DCHECK_ALWAYS_ON=1" ]
+ }
+ if (use_udev) {
+ # TODO(brettw) should probably be "=1".
+ defines += [ "USE_UDEV" ]
+ }
+ if (use_ash) {
+ defines += [ "USE_ASH=1" ]
+ }
+ if (use_aura) {
+ defines += [ "USE_AURA=1" ]
+ }
+ if (use_pango) {
+ defines += [ "USE_PANGO=1" ]
+ }
+ if (use_cairo) {
+ defines += [ "USE_CAIRO=1" ]
+ }
+ if (use_glib) {
+ defines += [ "USE_GLIB=1" ]
+ }
+ if (use_openssl_certs) {
+ defines += [ "USE_OPENSSL_CERTS=1" ]
+ }
+ if (use_nss_certs) {
+ defines += [ "USE_NSS_CERTS=1" ]
+ }
+ if (use_ozone) {
+ defines += [ "USE_OZONE=1" ]
+ }
+ if (use_x11) {
+ defines += [ "USE_X11=1" ]
+ }
+ if (use_allocator != "tcmalloc") {
+ defines += [ "NO_TCMALLOC" ]
+ }
+ if (is_asan || is_lsan || is_tsan || is_msan) {
+ defines += [
+ "MEMORY_TOOL_REPLACES_ALLOCATOR",
+ "MEMORY_SANITIZER_INITIAL_SIZE",
+ ]
+ }
+ if (is_asan) {
+ defines += [ "ADDRESS_SANITIZER" ]
+ }
+ if (is_lsan) {
+ defines += [ "LEAK_SANITIZER" ]
+ }
+ if (is_tsan) {
+ defines += [
+ "THREAD_SANITIZER",
+ "DYNAMIC_ANNOTATIONS_EXTERNAL_IMPL=1",
+ "WTF_USE_DYNAMIC_ANNOTATIONS_NOIMPL=1",
+ ]
+ }
+ if (is_msan) {
+ defines += [ "MEMORY_SANITIZER" ]
+ }
+ if (is_ubsan || is_ubsan_null || is_ubsan_vptr || is_ubsan_security) {
+ defines += [ "UNDEFINED_SANITIZER" ]
+ }
+ if (!enable_nacl) {
+ defines += [ "DISABLE_NACL" ]
+ }
+ if (safe_browsing_mode == 1) {
+ defines += [ "FULL_SAFE_BROWSING" ]
+ defines += [ "SAFE_BROWSING_CSD" ]
+ defines += [ "SAFE_BROWSING_DB_LOCAL" ]
+ } else if (safe_browsing_mode == 2) {
+ defines += [ "SAFE_BROWSING_DB_REMOTE" ]
+ }
+ if (is_official_build) {
+ defines += [ "OFFICIAL_BUILD" ]
+ }
+ if (is_chrome_branded) {
+ defines += [ "GOOGLE_CHROME_BUILD" ]
+ } else {
+ defines += [ "CHROMIUM_BUILD" ]
+ }
+ if (is_syzyasan) {
+ defines += [
+ "SYZYASAN",
+ "MEMORY_SANITIZER_INITIAL_SIZE",
+ ]
+ }
+ if (!fieldtrial_testing_like_official_build && !is_chrome_branded
+ && !build_with_mozilla) {
+ defines += [ "FIELDTRIAL_TESTING_ENABLED" ]
+ }
+
+ # ==============================================
+ # PLEASE DO NOT ADD MORE THINGS TO THIS LIST
+ # ==============================================
+ #
+ # See the comment at the top.
+}
+
+# Debug/release ----------------------------------------------------------------
+
+config("debug") {
+ defines = [
+ "DYNAMIC_ANNOTATIONS_ENABLED=1",
+ "WTF_USE_DYNAMIC_ANNOTATIONS=1",
+ ]
+
+ if (!build_with_mozilla) {
+ defines += [ "_DEBUG" ]
+ }
+
+ if (is_nacl) {
+ defines += [ "DYNAMIC_ANNOTATIONS_PREFIX=NACL_" ]
+ }
+
+ if (is_win) {
+ if (!enable_iterator_debugging) {
+ # Iterator debugging is enabled by default by the compiler on debug
+ # builds, and we have to tell it to turn it off.
+ defines += [ "_HAS_ITERATOR_DEBUGGING=0" ]
+ }
+ } else if (is_linux && current_cpu == "x64" && enable_iterator_debugging) {
+ # Enable libstdc++ debugging facilities to help catch problems early, see
+ # http://crbug.com/65151 .
+ # TODO(phajdan.jr): Should we enable this for all of POSIX?
+ #defines += [ "_GLIBCXX_DEBUG=1" ]
+ }
+}
+
+config("release") {
+ defines = [ "NDEBUG" ]
+
+ # Sanitizers.
+ if (is_tsan) {
+ defines += [
+ "DYNAMIC_ANNOTATIONS_ENABLED=1",
+ "WTF_USE_DYNAMIC_ANNOTATIONS=1",
+ ]
+ } else {
+ defines += [ "NVALGRIND" ]
+ if (!is_nacl) {
+ # NaCl always enables dynamic annotations. Currently this value is set to
+ # 1 for all .nexes.
+ defines += [ "DYNAMIC_ANNOTATIONS_ENABLED=0" ]
+ }
+ }
+
+ if (is_ios) {
+ # Disable NSAssert and GTMDevAssert (from Google Toolbox for Mac). This
+ # follows XCode's default behavior for Release builds.
+ defines += [ "NS_BLOCK_ASSERTIONS=1" ]
+ }
+}
+
+# Default libraries ------------------------------------------------------------
+
+# This config defines the default libraries applied to all targets.
+config("default_libs") {
+ if (is_win) {
+ # TODO(brettw) this list of defaults should probably be smaller, and
+ # instead the targets that use the less common ones (e.g. wininet or
+ # winspool) should include those explicitly.
+ libs = [
+ "advapi32.lib",
+ "comdlg32.lib",
+ "dbghelp.lib",
+ "delayimp.lib",
+ "dnsapi.lib",
+ "gdi32.lib",
+ "kernel32.lib",
+ "msimg32.lib",
+ "odbc32.lib",
+ "odbccp32.lib",
+ "ole32.lib",
+ "oleaut32.lib",
+ "psapi.lib",
+ "shell32.lib",
+ "shlwapi.lib",
+ "user32.lib",
+ "usp10.lib",
+ "uuid.lib",
+ "version.lib",
+ "wininet.lib",
+ "winmm.lib",
+ "winspool.lib",
+ "ws2_32.lib",
+
+ # Please don't add more stuff here. We should actually be making this
+ # list smaller, since all common things should be covered. If you need
+ # some extra libraries, please just add a libs = [ "foo.lib" ] to your
+ # target that needs it.
+ ]
+ } else if (is_android) {
+ libs = [
+ "dl",
+ "m",
+ ]
+ } else if (is_mac) {
+ # Targets should choose to explicitly link frameworks they require. Since
+ # linking can have run-time side effects, nothing should be listed here.
+ libs = []
+ } else if (is_ios) {
+ # The libraries listed here will be specified for both the target and the
+ # host. Only the common ones should be listed here.
+ libs = [
+ "CoreFoundation.framework",
+ "CoreGraphics.framework",
+ "CoreText.framework",
+ "Foundation.framework",
+ ]
+ } else if (is_linux) {
+ libs = [
+ "dl",
+ "rt",
+ ]
+ }
+}
+
+# Dependencies that all executables and shared libraries should have.
+group("exe_and_shlib_deps") {
+ public_deps = []
+ if (using_sanitizer) {
+ public_deps += [ "//build/config/sanitizers:deps" ]
+ }
+ if (use_custom_libcxx) {
+ public_deps += [ "//buildtools/third_party/libc++:libcxx_proxy" ]
+ }
+ if (use_afl) {
+ public_deps += [ "//third_party/afl" ]
+ }
+}
+
+# Executable configs -----------------------------------------------------------
+
+# Windows linker setup for EXEs and DLLs.
+if (is_win) {
+ _windows_linker_configs = [
+ "//build/config/win:sdk_link",
+ "//build/config/win:common_linker_setup",
+ ]
+}
+
+# This config defines the configs applied to all executables.
+config("executable_config") {
+ configs = []
+
+ if (is_win) {
+ configs += _windows_linker_configs
+
+ # Currently only turn on linker CFI for executables.
+ configs += [ "//build/config/win:cfi_linker" ]
+ } else if (is_mac) {
+ configs += [
+ "//build/config/mac:mac_dynamic_flags",
+ "//build/config/mac:mac_executable_flags",
+ ]
+ } else if (is_ios) {
+ configs += [
+ "//build/config/ios:ios_dynamic_flags",
+ "//build/config/ios:ios_executable_flags",
+ ]
+ } else if (is_linux || is_android || current_os == "aix") {
+ configs += [ "//build/config/gcc:executable_ldconfig" ]
+ if (is_android) {
+ configs += [ "//build/config/android:executable_config" ]
+ } else if (is_chromecast) {
+ configs += [ "//build/config/chromecast:executable_config" ]
+ }
+ }
+
+ # If we're using the prebuilt instrumented libraries with the sanitizers, we
+ # need to add ldflags to every binary to make sure they are picked up.
+ if (prebuilt_instrumented_libraries_available) {
+ configs += [ "//third_party/instrumented_libraries:prebuilt_ldflags" ]
+ }
+ if (use_locally_built_instrumented_libraries) {
+ configs += [ "//third_party/instrumented_libraries:locally_built_ldflags" ]
+ }
+ configs += [ "//build/config/sanitizers:link_executable" ]
+}
+
+# Shared library configs -------------------------------------------------------
+
+# This config defines the configs applied to all shared libraries.
+config("shared_library_config") {
+ configs = []
+
+ if (is_win) {
+ configs += _windows_linker_configs
+ } else if (is_mac) {
+ configs += [ "//build/config/mac:mac_dynamic_flags" ]
+ } else if (is_ios) {
+ configs += [ "//build/config/ios:ios_dynamic_flags" ]
+ } else if (is_chromecast) {
+ configs += [ "//build/config/chromecast:shared_library_config" ]
+ }
+
+ # If we're using the prebuilt instrumented libraries with the sanitizers, we
+ # need to add ldflags to every binary to make sure they are picked up.
+ if (prebuilt_instrumented_libraries_available) {
+ configs += [ "//third_party/instrumented_libraries:prebuilt_ldflags" ]
+ }
+ if (use_locally_built_instrumented_libraries) {
+ configs += [ "//third_party/instrumented_libraries:locally_built_ldflags" ]
+ }
+ configs += [ "//build/config/sanitizers:link_shared_library" ]
+}
+
+# Add this config to your target to enable precompiled headers.
+#
+# Precompiled headers are done on a per-target basis. If you have just a couple
+# of files, the time it takes to precompile (~2 seconds) can actually be longer
+# than the time saved. On a Z620, a 100 file target compiles about 2 seconds
+# faster with precompiled headers, with greater savings for larger targets.
+#
+# Recommend precompiled headers for targets with more than 50 .cc files.
+config("precompiled_headers") {
+ if (enable_precompiled_headers) {
+ if (is_win) {
+ # This is a string rather than a file GN knows about. It has to match
+ # exactly what's in the /FI flag below, and what might appear in the
+ # source code in quotes for an #include directive.
+ precompiled_header = "build/precompile.h"
+
+ # This is a file that GN will compile with the above header. It will be
+ # implicitly added to the sources (potentially multiple times, with one
+ # variant for each language used in the target).
+ precompiled_source = "//build/precompile.cc"
+
+ # Force include the header.
+ cflags = [ "/FI$precompiled_header" ]
+ } else if (is_mac) {
+ precompiled_source = "//build/precompile.h"
+ }
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/BUILDCONFIG.gn b/third_party/libwebrtc/webrtc/build/config/BUILDCONFIG.gn
new file mode 100644
index 0000000000..38771eda5b
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/BUILDCONFIG.gn
@@ -0,0 +1,714 @@
+# 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.
+
+# =============================================================================
+# WHAT IS THIS FILE?
+# =============================================================================
+#
+# This is the master GN build configuration. This file is loaded after the
+# build args (args.gn) for the build directory and after the toplevel ".gn"
+# file (which points to this file as the build configuration).
+#
+# This file will be executed and the resulting context will be used to execute
+# every other file in the build. So variables declared here (that don't start
+# with an underscore) will be implicitly global.
+
+# =============================================================================
+# PLATFORM SELECTION
+# =============================================================================
+#
+# There are two main things to set: "os" and "cpu". The "toolchain" is the name
+# of the GN thing that encodes combinations of these things.
+#
+# Users typically only set the variables "target_os" and "target_cpu" in "gn
+# args", the rest are set up by our build and internal to GN.
+#
+# There are three different types of each of these things: The "host"
+# represents the computer doing the compile and never changes. The "target"
+# represents the main thing we're trying to build. The "current" represents
+# which configuration is currently being defined, which can be either the
+# host, the target, or something completely different (like nacl). GN will
+# run the same build file multiple times for the different required
+# configuration in the same build.
+#
+# This gives the following variables:
+# - host_os, host_cpu, host_toolchain
+# - target_os, target_cpu, default_toolchain
+# - current_os, current_cpu, current_toolchain.
+#
+# Note the default_toolchain isn't symmetrical (you would expect
+# target_toolchain). This is because the "default" toolchain is a GN built-in
+# concept, and "target" is something our build sets up that's symmetrical with
+# its GYP counterpart. Potentially the built-in default_toolchain variable
+# could be renamed in the future.
+#
+# When writing build files, to do something only for the host:
+# if (current_toolchain == host_toolchain) { ...
+
+if (target_os == "") {
+ target_os = host_os
+}
+
+if (target_cpu == "") {
+ if (target_os == "android") {
+ # If we're building for Android, we should assume that we want to
+ # build for ARM by default, not the host_cpu (which is likely x64).
+ # This allows us to not have to specify both target_os and target_cpu
+ # on the command line.
+ target_cpu = "arm"
+ } else {
+ target_cpu = host_cpu
+ }
+}
+
+if (current_cpu == "") {
+ current_cpu = target_cpu
+}
+if (current_os == "") {
+ current_os = target_os
+}
+
+# =============================================================================
+# BUILD FLAGS
+# =============================================================================
+#
+# This block lists input arguments to the build, along with their default
+# values.
+#
+# If a value is specified on the command line, it will overwrite the defaults
+# given in a declare_args block, otherwise the default will be used.
+#
+# YOU SHOULD ALMOST NEVER NEED TO ADD FLAGS TO THIS FILE. GN allows any file in
+# the build to declare build flags. If you need a flag for a single component,
+# you can just declare it in the corresponding BUILD.gn file.
+#
+# - If your feature is a single target, say //components/foo, you can put
+# a declare_args() block in //components/foo/BUILD.gn and use it there.
+# Nobody else in the build needs to see the flag.
+#
+# - Defines based on build variables should be implemented via the generated
+# build flag header system. See //build/buildflag_header.gni. You can put
+# the buildflag_header target in the same file as the build flag itself. You
+# should almost never set "defines" directly.
+#
+# - If your flag toggles a target on and off or toggles between different
+# versions of similar things, write a "group" target that forwards to the
+# right target (or no target) depending on the value of the build flag. This
+# group can be in the same BUILD.gn file as the build flag, and targets can
+# depend unconditionally on the group rather than duplicating flag checks
+# across many targets.
+#
+# - If a semi-random set of build files REALLY needs to know about a define and
+# the above pattern for isolating the build logic in a forwarding group
+# doesn't work, you can put the argument in a .gni file. This should be put
+# in the lowest level of the build that knows about this feature (which should
+# almost always be outside of the //build directory!).
+#
+# Other flag advice:
+#
+# - Use boolean values when possible. If you need a default value that expands
+# to some complex thing in the default case (like the location of the
+# compiler which would be computed by a script), use a default value of -1 or
+# the empty string. Outside of the declare_args block, conditionally expand
+# the default value as necessary.
+#
+# - Use a name like "use_foo" or "is_foo" (whatever is more appropriate for
+# your feature) rather than just "foo".
+#
+# - Write good comments directly above the declaration with no blank line.
+# These comments will appear as documentation in "gn args --list".
+#
+# - Don't call exec_script inside declare_args. This will execute the script
+# even if the value is overridden, which is wasteful. See first bullet.
+
+# Enable to use the Mozilla internal settings.
+declare_args() {
+ build_with_mozilla = true
+}
+
+declare_args() {
+ # Set to enable the official build level of optimization. This has nothing
+ # to do with branding, but enables an additional level of optimization above
+ # release (!is_debug). This might be better expressed as a tri-state
+ # (debug, release, official) but for historical reasons there are two
+ # separate flags.
+ is_official_build = false
+
+ # Whether we're a traditional desktop unix.
+ is_desktop_linux = current_os == "linux"
+
+ # Set to true when compiling with the Clang compiler. Typically this is used
+ # to configure warnings.
+ is_clang =
+ current_os == "mac" || current_os == "ios" || current_os == "chromeos" ||
+ current_os == "fuchsia" || current_os == "freebsd" || current_os == "openbsd" ||
+ (current_os == "linux" && current_cpu != "s390x" &&
+ current_cpu != "s390" && current_cpu != "ppc64" && current_cpu != "ppc")
+
+ # Allows the path to a custom target toolchain to be injected as a single
+ # argument, and set as the default toolchain.
+ custom_toolchain = ""
+
+ # This should not normally be set as a build argument. It's here so that
+ # every toolchain can pass through the "global" value via toolchain_args().
+ host_toolchain = ""
+
+ # DON'T ADD MORE FLAGS HERE. Read the comment above.
+}
+
+declare_args() {
+ # Debug build. Enabling official builds automatically sets is_debug to false.
+ is_debug = !is_official_build
+}
+
+declare_args() {
+ # Component build. Setting to true compiles targets declared as "components"
+ # as shared libraries loaded dynamically. This speeds up development time.
+ # When false, components will be linked statically.
+ #
+ # For more information see
+ # https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.md
+ is_component_build =
+ is_debug && current_os != "ios" && current_os != "fuchsia" && !build_with_mozilla
+}
+
+assert(!(is_debug && is_official_build), "Can't do official debug builds")
+
+# ==============================================================================
+# TOOLCHAIN SETUP
+# ==============================================================================
+#
+# Here we set the default toolchain, as well as the variable host_toolchain
+# which will identify the toolchain corresponding to the local system when
+# doing cross-compiles. When not cross-compiling, this will be the same as the
+# default toolchain.
+#
+# We do this before anything else to make sure we complain about any
+# unsupported os/cpu combinations as early as possible.
+
+if (host_toolchain == "") {
+ # This should only happen in the top-level context.
+ # In a specific toolchain context, the toolchain_args()
+ # block should have propagated a value down.
+ # TODO(dpranke): Add some sort of assert here that verifies that
+ # no toolchain omitted host_toolchain from its toolchain_args().
+
+ if (host_os == "linux") {
+ if (target_os != "linux") {
+ # TODO(dpranke) - is_clang normally applies only to the target
+ # build, and there is no way to indicate that you want to override
+ # it for both the target build *and* the host build. Do we need to
+ # support this?
+ host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
+ } else if (is_clang) {
+ host_toolchain = "//build/toolchain/linux:clang_$host_cpu"
+ } else {
+ host_toolchain = "//build/toolchain/linux:$host_cpu"
+ }
+ } else if (host_os == "mac") {
+ host_toolchain = "//build/toolchain/mac:clang_$host_cpu"
+ } else if (host_os == "win") {
+ # On Windows always use the target CPU for host builds. On the
+ # configurations we support this will always work and it saves build steps.
+ if (is_clang) {
+ host_toolchain = "//build/toolchain/win:clang_$target_cpu"
+ } else {
+ host_toolchain = "//build/toolchain/win:$target_cpu"
+ }
+ } else if (host_os == "aix") {
+ host_toolchain = "//build/toolchain/aix:$host_cpu"
+ } else {
+ host_toolchain = "//build/toolchain/fallback:default"
+ }
+}
+
+_default_toolchain = ""
+
+if (target_os == "android") {
+ assert(host_os == "linux" || host_os == "mac",
+ "Android builds are only supported on Linux and Mac hosts.")
+ if (is_clang) {
+ _default_toolchain = "//build/toolchain/android:android_clang_$target_cpu"
+ } else {
+ _default_toolchain = "//build/toolchain/android:android_$target_cpu"
+ }
+} else if (target_os == "chromeos" || target_os == "linux") {
+ # See comments in build/toolchain/cros/BUILD.gn about board compiles.
+ if (is_clang) {
+ _default_toolchain = "//build/toolchain/linux:clang_$target_cpu"
+ } else {
+ _default_toolchain = "//build/toolchain/linux:$target_cpu"
+ }
+} else if (target_os == "fuchsia") {
+ _default_toolchain = "//build/toolchain/fuchsia:$target_cpu"
+} else if (target_os == "ios") {
+ _default_toolchain = "//build/toolchain/mac:ios_clang_$target_cpu"
+} else if (target_os == "mac") {
+ assert(host_os == "mac", "Mac cross-compiles are unsupported.")
+ _default_toolchain = host_toolchain
+} else if (target_os == "win") {
+ # On Windows we use the same toolchain for host and target by default.
+ assert(target_os == host_os, "Win cross-compiles only work on win hosts.")
+ if (is_clang) {
+ _default_toolchain = "//build/toolchain/win:clang_$target_cpu"
+ } else {
+ _default_toolchain = "//build/toolchain/win:$target_cpu"
+ }
+} else if (target_os == "aix") {
+ _default_toolchain = "//build/toolchain/aix:$target_cpu"
+} else if (target_os == "winrt_81" || target_os == "winrt_81_phone" ||
+ target_os == "winrt_10") {
+ _default_toolchain = "//build/toolchain/win:winrt_$target_cpu"
+} else {
+ _default_toolchain = host_toolchain
+}
+
+# If a custom toolchain has been set in the args, set it as default. Otherwise,
+# set the default toolchain for the platform (if any).
+if (custom_toolchain != "") {
+ set_default_toolchain(custom_toolchain)
+} else if (_default_toolchain != "") {
+ set_default_toolchain(_default_toolchain)
+}
+
+# =============================================================================
+# OS DEFINITIONS
+# =============================================================================
+#
+# We set these various is_FOO booleans for convenience in writing OS-based
+# conditions.
+#
+# - is_android, is_chromeos, is_ios, and is_win should be obvious.
+# - is_mac is set only for desktop Mac. It is not set on iOS.
+# - is_posix is true for mac and any Unix-like system (basically everything
+# except Windows).
+# - is_linux is true for desktop Linux and ChromeOS, but not Android (which is
+# generally too different despite being based on the Linux kernel).
+#
+# Do not add more is_* variants here for random lesser-used Unix systems like
+# aix or one of the BSDs. If you need to check these, just check the
+# current_os value directly.
+
+if (current_os == "win" || current_os == "winrt_81" ||
+ current_os == "winrt_81_phone" || current_os == "winrt_10") {
+ is_android = false
+ is_chromeos = false
+ is_fuchsia = false
+ is_ios = false
+ is_linux = false
+ is_mac = false
+ is_nacl = false
+ is_posix = false
+ is_win = true
+} else if (current_os == "mac") {
+ is_android = false
+ is_chromeos = false
+ is_fuchsia = false
+ is_ios = false
+ is_linux = false
+ is_mac = true
+ is_nacl = false
+ is_posix = true
+ is_win = false
+} else if (current_os == "android") {
+ is_android = true
+ is_chromeos = false
+ is_fuchsia = false
+ is_ios = false
+ is_linux = false
+ is_mac = false
+ is_nacl = false
+ is_posix = true
+ is_win = false
+} else if (current_os == "chromeos") {
+ is_android = false
+ is_chromeos = true
+ is_fuchsia = false
+ is_ios = false
+ is_linux = true
+ is_mac = false
+ is_nacl = false
+ is_posix = true
+ is_win = false
+} else if (current_os == "nacl") {
+ # current_os == "nacl" will be passed by the nacl toolchain definition.
+ # It is not set by default or on the command line. We treat is as a
+ # Posix variant.
+ is_android = false
+ is_chromeos = false
+ is_fuchsia = false
+ is_ios = false
+ is_linux = false
+ is_mac = false
+ is_nacl = true
+ is_posix = true
+ is_win = false
+} else if (current_os == "fuchsia") {
+ is_android = false
+ is_chromeos = false
+ is_fuchsia = true
+ is_ios = false
+ is_linux = false
+ is_mac = false
+ is_nacl = false
+ is_posix = true
+ is_win = false
+} else if (current_os == "ios") {
+ is_android = false
+ is_chromeos = false
+ is_fuchsia = false
+ is_ios = true
+ is_linux = false
+ is_mac = false
+ is_nacl = false
+ is_posix = true
+ is_win = false
+} else if (current_os == "linux") {
+ is_android = false
+ is_chromeos = false
+ is_fuchsia = false
+ is_ios = false
+ is_linux = true
+ is_mac = false
+ is_nacl = false
+ is_posix = true
+ is_win = false
+} else {
+ # AIX, BSDs, Solaris, etc.
+ is_android = false
+ is_chromeos = false
+ is_fuchsia = false
+ is_ios = false
+ is_linux = false
+ is_mac = false
+ is_nacl = false
+ is_posix = true
+ is_win = false
+}
+
+# A list of BSD systems maintained by community
+if (current_os == "dragonfly" || current_os == "freebsd" ||
+ current_os == "netbsd" || current_os == "openbsd") {
+ is_bsd = true
+} else {
+ is_bsd = false
+}
+
+# =============================================================================
+# SOURCES FILTERS
+# =============================================================================
+#
+# These patterns filter out platform-specific files when assigning to the
+# sources variable. The magic variable |sources_assignment_filter| is applied
+# to each assignment or appending to the sources variable and matches are
+# automatically removed.
+#
+# Note that the patterns are NOT regular expressions. Only "*" and "\b" (path
+# boundary = end of string or slash) are supported, and the entire string
+# must match the pattern (so you need "*.cc" to match all .cc files, for
+# example).
+
+# DO NOT ADD MORE PATTERNS TO THIS LIST, see set_sources_assignment_filter call
+# below.
+sources_assignment_filter = []
+if (!is_posix) {
+ sources_assignment_filter += [
+ "*_posix.h",
+ "*_posix.cc",
+ "*_posix_unittest.h",
+ "*_posix_unittest.cc",
+ "*\bposix/*",
+ ]
+}
+
+if (!is_win) {
+ sources_assignment_filter += [
+ "*_win.cc",
+ "*_win.h",
+ "*_win_unittest.cc",
+ "*\bwin/*",
+ "*.def",
+ "*.rc",
+ ]
+}
+if (!is_mac) {
+ sources_assignment_filter += [
+ "*_mac.h",
+ "*_mac.cc",
+ "*_mac.mm",
+ "*_mac_unittest.h",
+ "*_mac_unittest.cc",
+ "*_mac_unittest.mm",
+ "*\bmac/*",
+ "*_cocoa.h",
+ "*_cocoa.cc",
+ "*_cocoa.mm",
+ "*_cocoa_unittest.h",
+ "*_cocoa_unittest.cc",
+ "*_cocoa_unittest.mm",
+ "*\bcocoa/*",
+ ]
+}
+if (!is_ios) {
+ sources_assignment_filter += [
+ "*_ios.h",
+ "*_ios.cc",
+ "*_ios.mm",
+ "*_ios_unittest.h",
+ "*_ios_unittest.cc",
+ "*_ios_unittest.mm",
+ "*\bios/*",
+ ]
+}
+if (!is_mac && !is_ios) {
+ sources_assignment_filter += [ "*.mm" ]
+}
+if (!is_linux && !is_bsd) {
+ sources_assignment_filter += [
+ "*_linux.h",
+ "*_linux.cc",
+ "*_linux_unittest.h",
+ "*_linux_unittest.cc",
+ "*\blinux/*",
+ ]
+}
+if (!is_android) {
+ sources_assignment_filter += [
+ "*_android.h",
+ "*_android.cc",
+ "*_android_unittest.h",
+ "*_android_unittest.cc",
+ "*\bandroid/*",
+ ]
+}
+if (!is_chromeos) {
+ sources_assignment_filter += [
+ "*_chromeos.h",
+ "*_chromeos.cc",
+ "*_chromeos_unittest.h",
+ "*_chromeos_unittest.cc",
+ "*\bchromeos/*",
+ ]
+}
+
+# DO NOT ADD MORE PATTERNS TO THIS LIST, see set_sources_assignment_filter call
+# below.
+
+# Actually save this list.
+#
+# These patterns are executed for every file in the source tree of every run.
+# Therefore, adding more patterns slows down the build for everybody. We should
+# only add automatic patterns for configurations affecting hundreds of files
+# across many projects in the tree.
+#
+# Therefore, we only add rules to this list corresponding to platforms on the
+# Chromium waterfall. This is not for non-officially-supported platforms
+# (FreeBSD, etc.) toolkits, (X11, GTK, etc.), or features. For these cases,
+# write a conditional in the target to remove the file(s) from the list when
+# your platform/toolkit/feature doesn't apply.
+set_sources_assignment_filter(sources_assignment_filter)
+
+# =============================================================================
+# TARGET DEFAULTS
+# =============================================================================
+#
+# Set up the default configuration for every build target of the given type.
+# The values configured here will be automatically set on the scope of the
+# corresponding target. Target definitions can add or remove to the settings
+# here as needed.
+
+# Holds all configs used for running the compiler.
+default_compiler_configs = [
+ "//build/config:feature_flags",
+ "//build/config/compiler:afdo",
+ "//build/config/compiler:compiler",
+ "//build/config/compiler:pthread",
+ "//build/config/compiler:clang_stackrealign",
+ "//build/config/compiler:compiler_arm_fpu",
+ "//build/config/compiler:compiler_arm_thumb",
+ "//build/config/compiler:chromium_code",
+ "//build/config/compiler:default_include_dirs",
+ "//build/config/compiler:default_optimization",
+ "//build/config/compiler:default_stack_frames",
+ "//build/config/compiler:default_symbols",
+ "//build/config/compiler:no_rtti",
+ "//build/config/compiler:runtime_library",
+ "//build/config/sanitizers:default_sanitizer_flags",
+]
+if (is_win) {
+ default_compiler_configs += [
+ "//build/config/win:default_crt",
+ "//build/config/win:lean_and_mean",
+ "//build/config/win:nominmax",
+ "//build/config/win:unicode",
+ "//build/config/win:winver",
+ "//build/config/win:vs_code_analysis",
+ ]
+}
+if (current_os == "winrt_81" || current_os == "winrt_81_phone" ||
+ current_os == "winrt_10") {
+ default_compiler_configs += [ "//build/config/win:target_winrt" ]
+}
+
+if (is_posix) {
+ default_compiler_configs += [ "//build/config/gcc:no_exceptions" ]
+ if (current_os != "aix") {
+ default_compiler_configs +=
+ [ "//build/config/gcc:symbol_visibility_hidden" ]
+ }
+}
+
+if (is_android) {
+ default_compiler_configs +=
+ [ "//build/config/android:default_cygprofile_instrumentation" ]
+}
+
+if (is_clang && !is_nacl) {
+ default_compiler_configs += [
+ "//build/config/clang:find_bad_constructs",
+ "//build/config/clang:extra_warnings",
+ ]
+}
+
+# Debug/release-related defines.
+if (is_debug) {
+ default_compiler_configs += [ "//build/config:debug" ]
+} else {
+ default_compiler_configs += [ "//build/config:release" ]
+}
+
+# Static libraries and source sets use only the compiler ones.
+set_defaults("static_library") {
+ configs = default_compiler_configs
+}
+set_defaults("source_set") {
+ configs = default_compiler_configs
+}
+
+# Compute the set of configs common to all linked targets (shared libraries,
+# loadable modules, executables) to avoid duplication below.
+if (is_win) {
+ # Many targets remove these configs, so they are not contained within
+ # //build/config:executable_config for easy removal.
+ _linker_configs = [
+ "//build/config/win:default_incremental_linking",
+
+ # Default to console-mode apps. Most of our targets are tests and such
+ # that shouldn't use the windows subsystem.
+ "//build/config/win:console",
+ ]
+} else if (is_mac) {
+ _linker_configs = [ "//build/config/mac:strip_all" ]
+} else {
+ _linker_configs = []
+}
+
+# Executable defaults.
+default_executable_configs = default_compiler_configs + [
+ "//build/config:default_libs",
+ "//build/config:executable_config",
+ ] + _linker_configs
+set_defaults("executable") {
+ configs = default_executable_configs
+}
+
+# Shared library and loadable module defaults (also for components in component
+# mode).
+default_shared_library_configs = default_compiler_configs + [
+ "//build/config:default_libs",
+ "//build/config:shared_library_config",
+ ] + _linker_configs
+if (is_android) {
+ # Strip native JNI exports from shared libraries by default. Binaries that
+ # want this can remove this config.
+ default_shared_library_configs +=
+ [ "//build/config/android:hide_all_but_jni_onload" ]
+}
+set_defaults("shared_library") {
+ configs = default_shared_library_configs
+}
+set_defaults("loadable_module") {
+ configs = default_shared_library_configs
+
+ # loadable_modules are generally used by other libs, not just via JNI.
+ if (is_android) {
+ configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
+ }
+}
+
+# ==============================================================================
+# COMPONENT SETUP
+# ==============================================================================
+
+# Defines a component, which equates to a shared_library when
+# is_component_build == true and a static_library otherwise.
+#
+# Use static libraries for the static build rather than source sets because
+# many of of our test binaries link many large dependencies but often don't
+# use large portions of them. The static libraries are much more efficient to
+# link in this situation since only the necessary object files are linked.
+#
+# The invoker can override the type of the target in the non-component-build
+# case by setting static_component_type to either "source_set" or
+# "static_library". If unset, the default will be used.
+template("component") {
+ if (is_component_build) {
+ _component_mode = "shared_library"
+ } else if (defined(invoker.static_component_type)) {
+ assert(invoker.static_component_type == "static_library" ||
+ invoker.static_component_type == "source_set")
+ _component_mode = invoker.static_component_type
+ } else if (is_android || !defined(invoker.sources)) {
+ # When there are no sources defined, use a source set to avoid creating
+ # an empty static library (which generally don't work).
+ #
+ # When we changed components to default from source sets to static
+ # libraries, an Android benchmark regressed slightly
+ # (https://crbug.com/619593). We don't have a good theory on why this might
+ # be since theoretically it should be the same. It could be something as
+ # silly as random code locality luck.
+ #
+ # There seems to be no build-time performance hit to using source sets on
+ # Android (the normal reason for defaulting to static libraries), so we
+ # make the default on Android to be source set.
+ #
+ # If it's been a long time since this was added and you're skeptical,
+ # please feel free to remove the Android exception and see if any
+ # benchmarks obviously regress. If not, it would be great to standardize
+ # with the rest of the platforms.
+ _component_mode = "source_set"
+ } else {
+ _component_mode = "static_library"
+ }
+ target(_component_mode, target_name) {
+ # Explicitly forward visibility, implicitly forward everything else.
+ # Forwarding "*" doesn't recurse into nested scopes (to avoid copying all
+ # globals into each template invocation), so won't pick up file-scoped
+ # variables. Normally this isn't too bad, but visibility is commonly
+ # defined at the file scope. Explicitly forwarding visibility and then
+ # excluding it from the "*" set works around this problem.
+ # See http://crbug.com/594610
+ forward_variables_from(invoker, [ "visibility" ])
+ forward_variables_from(invoker, "*", [ "visibility" ])
+
+ # All shared libraries must have the sanitizer deps to properly link in
+ # asan mode (this target will be empty in other cases).
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ "//build/config:exe_and_shlib_deps" ]
+ }
+}
+
+# Component defaults
+set_defaults("component") {
+ if (is_component_build) {
+ configs = default_shared_library_configs
+ if (is_android) {
+ configs -= [ "//build/config/android:hide_all_but_jni_onload" ]
+ }
+ } else {
+ configs = default_compiler_configs
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/OWNERS b/third_party/libwebrtc/webrtc/build/config/OWNERS
new file mode 100644
index 0000000000..bd53091f46
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/OWNERS
@@ -0,0 +1,6 @@
+brettw@chromium.org
+dpranke@chromium.org
+scottmg@chromium.org
+
+per-file BUILDCONFIG.gn=brettw@chromium.org
+per-file BUILDCONFIG.gn=set noparent
diff --git a/third_party/libwebrtc/webrtc/build/config/aix/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/aix/BUILD.gn
new file mode 100644
index 0000000000..7ab1e7cdd3
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/aix/BUILD.gn
@@ -0,0 +1,50 @@
+# 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/sanitizers/sanitizers.gni")
+import("//build/toolchain/toolchain.gni")
+
+# 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.
+
+config("compiler") {
+ # These flags are shared between the C compiler and linker.
+ defines = [
+ "_LINUX_SOURCE_COMPAT=1",
+ "__STDC_FORMAT_MACROS",
+ "_ALL_SOURCE=1",
+ ]
+
+ cflags = [
+ "-Wall",
+ "-Wno-unused-parameter",
+ "-pthread",
+ "-Wmissing-field-initializers",
+ "-Wno-uninitialized",
+ "-mcpu=power5+",
+ "-mfprnd",
+ "-mno-popcntb",
+ "-maix64",
+ "-fdata-sections",
+ "-ffunction-sections",
+ "-O3",
+
+ # "-Werror"
+ # We need to find a way to fix the TOC warnings if we want to enable this.
+ ]
+
+ cflags_cc = [
+ "-std=gnu++11",
+ "-fno-rtti",
+ "-fno-exceptions",
+ "-Wno-narrowing",
+ "-Wnon-virtual-dtor",
+ ]
+
+ ldflags = [
+ "-pthread",
+ "-maix64",
+ "-Wl,-bbigtoc",
+ ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/allocator.gni b/third_party/libwebrtc/webrtc/build/config/allocator.gni
new file mode 100644
index 0000000000..5ac3ed6704
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/allocator.gni
@@ -0,0 +1,53 @@
+# 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/sanitizers/sanitizers.gni")
+
+# Temporarily disable tcmalloc on arm64 linux to get rid of compilation errors.
+if (is_android || current_cpu == "mipsel" || is_mac || is_ios || is_asan ||
+ is_lsan || is_tsan || is_msan || is_win || is_syzyasan || is_fuchsia ||
+ (is_linux && target_cpu == "arm64")) {
+ _default_allocator = "none"
+} else {
+ _default_allocator = "tcmalloc"
+}
+
+# The debug CRT on Windows has some debug features that are incompatible with
+# the shim. NaCl in particular does seem to link some binaries statically
+# against the debug CRT with "is_nacl=false".
+if ((is_linux || is_android || is_mac ||
+ (is_win && !is_component_build && !is_debug)) && !is_asan && !is_lsan &&
+ !is_tsan && !is_msan) {
+ _default_use_allocator_shim = true
+} else {
+ _default_use_allocator_shim = false
+}
+
+declare_args() {
+ # Memory allocator to use. Set to "none" to use default allocator.
+ use_allocator = _default_allocator
+
+ # Causes all the allocations to be routed via allocator_shim.cc.
+ use_allocator_shim = _default_use_allocator_shim
+}
+
+if (is_nacl) {
+ # Turn off the build flag for NaCL builds to minimize confusion, as NaCL
+ # doesn't support the heap shim.
+ use_allocator_shim = false
+}
+
+assert(use_allocator == "none" || use_allocator == "tcmalloc")
+
+assert(!is_win || use_allocator == "none", "Tcmalloc doesn't work on Windows.")
+assert(!is_mac || use_allocator == "none", "Tcmalloc doesn't work on macOS.")
+
+assert(
+ !use_allocator_shim || is_linux || is_android || is_win || is_mac,
+ "use_allocator_shim is supported only on Linux, Android, Windows and macOS targets")
+
+if (is_win && use_allocator_shim) {
+ assert(!is_component_build,
+ "The allocator shim doesn't work for the component build on Windows.")
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/android/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/android/BUILD.gn
new file mode 100644
index 0000000000..a8ff866fa9
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/android/BUILD.gn
@@ -0,0 +1,239 @@
+# 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/android/config.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+
+assert(is_android)
+
+# 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
+# Android-only.
+config("compiler") {
+ cflags = [
+ "-ffunction-sections",
+ "-fno-short-enums",
+ ]
+ defines = [
+ "ANDROID",
+
+ # The NDK has these things, but doesn't define the constants to say that it
+ # does. Define them here instead.
+ "HAVE_SYS_UIO_H",
+
+ # Forces full rebuilds on NDK rolls.
+ "ANDROID_NDK_VERSION=${android_ndk_version}",
+ ]
+
+ if (is_clang) {
+ if (current_cpu == "mips64el") {
+ cflags += [
+ # Have to force IAS for mips64.
+ "-fintegrated-as",
+ ]
+ }
+ } else {
+ # Clang doesn't support these flags.
+ cflags += [ "-finline-limit=64" ]
+ }
+
+ ldflags = [
+ "-Wl,--no-undefined",
+
+ # Don't allow visible symbols from libgcc or libc++ to be
+ # re-exported.
+ "-Wl,--exclude-libs=libgcc.a",
+ "-Wl,--exclude-libs=libc++_static.a",
+
+ # Don't allow visible symbols from libraries that contain
+ # assembly code with symbols that aren't hidden properly.
+ # http://crbug.com/448386
+ "-Wl,--exclude-libs=libvpx_assembly_arm.a",
+ ]
+
+ if (is_clang) {
+ if (current_cpu == "arm") {
+ abi_target = "arm-linux-androideabi"
+ } else if (current_cpu == "x86") {
+ abi_target = "i686-linux-androideabi"
+ } else if (current_cpu == "arm64") {
+ abi_target = "aarch64-linux-android"
+ } else if (current_cpu == "x64") {
+ # Place holder for x64 support, not tested.
+ # TODO: Enable clang support for Android x64. http://crbug.com/539781
+ abi_target = "x86_64-linux-androideabi"
+ } else if (current_cpu == "mipsel") {
+ abi_target = "mipsel-linux-android"
+ } else if (current_cpu == "mips64el") {
+ # Place holder for mips64 support, not tested.
+ abi_target = "mips64el-linux-androideabi"
+ } else {
+ assert(false, "Architecture not supported")
+ }
+ cflags += [ "--target=$abi_target" ]
+ ldflags += [ "--target=$abi_target" ]
+ }
+
+ # Assign any flags set for the C compiler to asmflags so that they are sent
+ # to the assembler.
+ asmflags = cflags
+}
+
+# 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 Android-only. Please see that target for advice on what should go in
+# :runtime_library vs. :compiler.
+config("runtime_library") {
+ # NOTE: The libc++ header include paths below are specified in cflags_cc
+ # rather than include_dirs because they need to come after include_dirs.
+ # Think of them like system headers, but don't use '-isystem' because the
+ # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit
+ # strange errors. The include ordering here is important; change with
+ # caution.
+ cflags_cc = []
+ if (android_ndk_major_version >= 13) {
+ libcxx_include_path =
+ rebase_path("$android_libcpp_root/include", root_build_dir)
+ libcxxabi_include_path =
+ rebase_path("$android_ndk_root/sources/cxx-stl/llvm-libc++abi/include",
+ root_build_dir)
+
+ if (!is_clang) {
+ # Per the release notes, GCC is not supported in the NDK starting with
+ # r13. It's still present, though, and has conflicting declarations of
+ # float abs(float).
+ cflags_cc += [ "-Wno-attributes" ]
+ }
+ } else {
+ libcxx_include_path =
+ rebase_path("$android_libcpp_root/libcxx/include", root_build_dir)
+ libcxxabi_include_path = rebase_path(
+ "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/include",
+ root_build_dir)
+ }
+ cflags_cc += [
+ "-isystem" + libcxx_include_path,
+ "-isystem" + libcxxabi_include_path,
+ "-isystem" +
+ rebase_path("$android_ndk_root/sources/android/support/include",
+ root_build_dir),
+ ]
+
+ defines = [ "__GNU_SOURCE=1" ] # Necessary for clone().
+ ldflags = [ "-nostdlib" ]
+ lib_dirs = [ android_libcpp_lib_dir ]
+
+ if (!build_with_mozilla) {
+ # The libc++ runtime library (must come first).
+ # ASan needs to dynamically link to libc++ even in static builds so
+ # that it can interpose operator new.
+ if (is_component_build || is_asan) {
+ libs = [ "c++_shared" ]
+ } else {
+ libs = [ "c++_static" ]
+ }
+ libs += [
+ "c++abi",
+ "android_support",
+ ]
+
+ # arm builds of libc++ starting in NDK r12 depend on unwind.
+ if (current_cpu == "arm") {
+ libs += [ "unwind" ]
+ }
+
+ # Manually link the libgcc.a that the cross compiler uses. This is
+ # absolute because the linker will look inside the sysroot if it's not.
+ libs += [
+ rebase_path(android_libgcc_file),
+ "c",
+ ]
+
+ # Clang with libc++ does not require an explicit atomic library reference.
+ if (!is_clang) {
+ libs += [ "atomic" ]
+ }
+
+ if (is_clang) {
+ # Work around incompatibilities between bionic and clang headers.
+ defines += [
+ "__compiler_offsetof=__builtin_offsetof",
+ "nan=__builtin_nan",
+ ]
+
+ if (current_cpu == "x64" || current_cpu == "arm64" ||
+ current_cpu == "mips64el") {
+ # 64-bit targets build with NDK 21, 32-bit targets with NDK 16
+ # (see ./config.gni). When using clang, NDK 21 defines snprintf to
+ # something for a kind of for of _FORTIFY_SOURCE support, see
+ # third_party/android_tools/ndk/platforms/android-21/arch-x86_64/usr/include/stdio.h
+ # Making snprintf a macro breaks base/strings/string_utils.h which
+ # defines base::snprintf(). So define snprintf to itself to force the
+ # NDK to not redefine it. This disables _chk for snprintf, but since
+ # 32-bit versions use NDK 16 which doesn't have any fortify support, that
+ # seems ok. b/32067310 tracks better fortify support with clang.
+ # TODO(thakis): Remove this once b/32067310 is fixed.
+ defines += [ "snprintf=snprintf" ]
+ }
+ }
+
+ # TODO(jdduke) Re-enable on mips after resolving linking
+ # issues with libc++ (crbug.com/456380).
+ if (current_cpu != "mipsel" && current_cpu != "mips64el") {
+ ldflags += [ "-Wl,--warn-shared-textrel" ]
+ }
+ }
+}
+
+config("executable_config") {
+ cflags = [ "-fPIE" ]
+ asmflags = [ "-fPIE" ]
+ ldflags = [ "-pie" ]
+}
+
+config("hide_all_but_jni_onload") {
+ ldflags = [ "-Wl,--version-script=" + rebase_path(
+ "//build/android/android_only_explicit_jni_exports.lst") ]
+}
+
+config("hide_all_but_jni") {
+ ldflags = [ "-Wl,--version-script=" +
+ rebase_path("//build/android/android_only_jni_exports.lst") ]
+}
+
+# Instrumentation -------------------------------------------------------------
+#
+# The BUILDCONFIG file sets the "default_cygprofile_instrumentation" config on
+# targets by default. You can override whether the cygprofile instrumentation is
+# used on a per-target basis:
+#
+# configs -= [ "//build/config/android:default_cygprofile_instrumentation" ]
+# configs += [ "//build/config/android:no_cygprofile_instrumentation" ]
+
+config("default_cygprofile_instrumentation") {
+ if (use_order_profiling) {
+ configs = [ ":cygprofile_instrumentation" ]
+ } else {
+ configs = [ ":no_cygprofile_instrumentation" ]
+ }
+}
+
+config("cygprofile_instrumentation") {
+ defines = [ "CYGPROFILE_INSTRUMENTATION=1" ]
+ cflags = [ "-finstrument-functions" ]
+
+ if (!is_clang) {
+ cflags += [
+ # Allow mmx intrinsics to inline, so that the compiler can expand the intrinsics.
+ "-finstrument-functions-exclude-file-list=mmintrin.h",
+
+ # Avoid errors with current NDK:
+ # "third_party/android_tools/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/include/arm_neon.h:3426:3: error: argument must be a constant"
+ "-finstrument-functions-exclude-file-list=arm_neon.h",
+ ]
+ }
+}
+
+config("no_cygprofile_instrumentation") {
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/android/OWNERS b/third_party/libwebrtc/webrtc/build/config/android/OWNERS
new file mode 100644
index 0000000000..2dd8a67364
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/android/OWNERS
@@ -0,0 +1,3 @@
+agrieve@chromium.org
+
+# COMPONENT: Build
diff --git a/third_party/libwebrtc/webrtc/build/config/android/config.gni b/third_party/libwebrtc/webrtc/build/config/android/config.gni
new file mode 100644
index 0000000000..1d276ffced
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/android/config.gni
@@ -0,0 +1,374 @@
+# 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.
+
+# This file contains common system config stuff for the Android build.
+
+if (is_android) {
+ import("//build_overrides/build.gni")
+
+ has_chrome_android_internal =
+ exec_script("//build/dir_exists.py",
+ [ rebase_path("//clank", root_build_dir) ],
+ "string") == "True"
+
+ # We are using a separate declare_args block for only this argument so that
+ # we can decide if we have to pull in definitions from the internal config
+ # early.
+ declare_args() {
+ # Enables using the internal Chrome for Android repository. The default
+ # value depends on whether the repository is available, and if it's not but
+ # this argument is manually set to True, the generation will fail.
+ # The main purpose of this argument is to avoid having to maintain 2
+ # repositories to support both public only and internal builds.
+ enable_chrome_android_internal = has_chrome_android_internal
+ }
+
+ if (enable_chrome_android_internal) {
+ import("//clank/config.gni")
+ }
+
+ if (!defined(extra_chrome_shared_library_configs)) {
+ extra_chrome_shared_library_configs = []
+ }
+
+ if (!defined(default_android_ndk_root)) {
+ default_android_ndk_root = "//third_party/android_tools/ndk"
+ default_android_ndk_version = "r12b"
+ default_android_ndk_major_version = 12
+ } else {
+ assert(defined(default_android_ndk_version))
+ assert(defined(default_android_ndk_major_version))
+ }
+
+ if (!defined(default_android_sdk_root)) {
+ default_android_sdk_root = "//third_party/android_tools/sdk"
+ default_android_sdk_version = "25"
+ default_android_sdk_build_tools_version = "25.0.2"
+ }
+
+ if (!defined(default_lint_android_sdk_root)) {
+ # Purposefully repeated so that downstream can change
+ # default_android_sdk_root without changing lint version.
+ default_lint_android_sdk_root = "//third_party/android_tools/sdk"
+ default_lint_android_sdk_version = "25"
+ }
+
+ if (!defined(default_extras_android_sdk_root)) {
+ # Purposefully repeated so that downstream can change
+ # default_android_sdk_root without changing where we load the SDK extras
+ # from. (Google Play services, etc.)
+ default_extras_android_sdk_root = "//third_party/android_tools/sdk"
+ }
+
+ if (!defined(default_android_keystore_path)) {
+ default_android_keystore_path =
+ "//build/android/ant/chromium-debug.keystore"
+ default_android_keystore_name = "chromiumdebugkey"
+ default_android_keystore_password = "chromium"
+ }
+
+ # TODO(paulmiller): Remove; superseded by google_play_services_package.
+ if (!defined(google_play_services_library)) {
+ google_play_services_library =
+ "//third_party/android_tools:google_play_services_default_java"
+ }
+
+ # TODO(paulmiller): Remove; superseded by google_play_services_package.
+ if (!defined(google_play_services_resources)) {
+ google_play_services_resources =
+ "//third_party/android_tools:google_play_services_default_resources"
+ }
+
+ # google_play_services_package contains the path where individual client
+ # targets (e.g. google_play_services_base_java) are located.
+ if (!defined(google_play_services_package)) {
+ google_play_services_package = "//third_party/android_tools"
+ }
+
+ webview_public_framework_jar =
+ "//third_party/android_platform/webview/frameworks_7.1.1_r28.jar"
+ if (!defined(webview_framework_jar)) {
+ webview_framework_jar = webview_public_framework_jar
+ }
+
+ declare_args() {
+ android_ndk_root = default_android_ndk_root
+ android_ndk_version = default_android_ndk_version
+ android_ndk_major_version = default_android_ndk_major_version
+
+ android_sdk_root = default_android_sdk_root
+ android_sdk_version = default_android_sdk_version
+ android_sdk_build_tools_version = default_android_sdk_build_tools_version
+
+ lint_android_sdk_root = default_lint_android_sdk_root
+ lint_android_sdk_version = default_lint_android_sdk_version
+
+ # Libc++ library directory. Override to use a custom libc++ binary.
+ android_libcpp_lib_dir = ""
+
+ # Android versionCode for android_apk()s that don't expclitly set one.
+ android_default_version_code = "1"
+
+ # Android versionName for android_apk()s that don't expclitly set one.
+ android_default_version_name = "Developer Build"
+
+ # The path to the keystore to use for signing builds.
+ android_keystore_path = default_android_keystore_path
+
+ # The name of the keystore to use for signing builds.
+ android_keystore_name = default_android_keystore_name
+
+ # The password for the keystore to use for signing builds.
+ android_keystore_password = default_android_keystore_password
+
+ # Set to true to run findbugs on JAR targets.
+ run_findbugs = false
+
+ # Set to true to enable verbose findbugs logging. This does nothing if
+ # run_findbugs is false.
+ findbugs_verbose = false
+
+ # Enables verbose proguard output (summaries and unfiltered output).
+ proguard_verbose = false
+
+ # Java debug on Android. Having this on enables multidexing, and turning it
+ # off will enable proguard.
+ is_java_debug = is_debug
+
+ # Set to true to enable the Errorprone compiler
+ use_errorprone_java_compiler = false
+
+ # Enables EMMA Java code coverage. Instruments classes during build to
+ # produce .ec files during runtime
+ emma_coverage = false
+
+ # EMMA filter string consisting of a list of inclusion/exclusion patterns
+ # separated with whitespace and/or comma. Only has effect if
+ # emma_coverage==true
+ emma_filter = ""
+
+ # Disables process isolation when building _incremental targets.
+ # Required for Android M+ due to SELinux policies (stronger sandboxing).
+ disable_incremental_isolated_processes = false
+
+ # Speeds up incremental compiles by compiling only changed files.
+ enable_incremental_javac = false
+
+ # Adds intrumentation to each function. Writes a file with the order that
+ # functions are called at startup.
+ use_order_profiling = false
+
+ # Builds secondary abi for APKs, supports build 32-bit arch as secondary
+ # abi in 64-bit Monochrome and WebView.
+ build_apk_secondary_abi = true
+
+ # Enables java8 language features (via retrolambda).
+ # work-in-progress (http://crbug.com/642600)
+ use_java8 = false
+
+ # Build incremental targets whenever possible.
+ # Ex. with this arg set to true, the chrome_public_apk target result in
+ # chrome_public_apk_incremental being built.
+ incremental_apk_by_default = false
+ }
+
+ # We need a second declare_args block to make sure we are using the overridden
+ # value of the arguments set above.
+ declare_args() {
+ # Speed up dexing using dx --incremental.
+ enable_incremental_dx = is_java_debug
+ }
+
+ # Neither of these should ever be used for release builds since they are
+ # somewhat experimental and dx --incremental is known to not produce
+ # byte-for-byte identical output.
+ assert(!(enable_incremental_dx && !is_java_debug))
+ assert(!(enable_incremental_javac && !is_java_debug))
+
+ # Host stuff -----------------------------------------------------------------
+
+ # Defines the name the Android build gives to the current host CPU
+ # architecture, which is different than the names GN uses.
+ if (host_cpu == "x64") {
+ android_host_arch = "x86_64"
+ } else if (host_cpu == "x86") {
+ android_host_arch = "x86"
+ } else {
+ assert(false, "Need Android toolchain support for your build CPU arch.")
+ }
+
+ # Defines the name the Android build gives to the current host CPU
+ # architecture, which is different than the names GN uses.
+ if (host_os == "linux") {
+ android_host_os = "linux"
+ } else if (host_os == "mac") {
+ android_host_os = "darwin"
+ } else {
+ assert(false, "Need Android toolchain support for your build OS.")
+ }
+
+ # Directories and files ------------------------------------------------------
+ #
+ # We define may of the dirs strings here for each output architecture (rather
+ # than just the current one) since these are needed by the Android toolchain
+ # file to define toolchains for all possible targets in one pass.
+
+ android_sdk = "${android_sdk_root}/platforms/android-${android_sdk_version}"
+
+ # Path to the Android NDK and SDK.
+ android_ndk_include_dir = "$android_ndk_root/usr/include"
+
+ android_sdk_tools = "${android_sdk_root}/tools"
+ android_sdk_build_tools =
+ "${android_sdk_root}/build-tools/$android_sdk_build_tools_version"
+
+ # Path to the SDK's android.jar
+ android_sdk_jar = "$android_sdk/android.jar"
+
+ zipalign_path = "$android_sdk_build_tools/zipalign"
+
+ # Subdirectories inside android_ndk_root that contain the sysroot for the
+ # associated platform.
+ # If you raise this, reevaluate the snprintf=snprintf in ./BUILD.gn.
+ _android_api_level = 16
+ x86_android_sysroot_subdir =
+ "platforms/android-${_android_api_level}/arch-x86"
+ arm_android_sysroot_subdir =
+ "platforms/android-${_android_api_level}/arch-arm"
+ mips_android_sysroot_subdir =
+ "platforms/android-${_android_api_level}/arch-mips"
+
+ # If you raise this, reevaluate the snprintf=snprintf in ./BUILD.gn.
+ _android64_api_level = 21
+ x86_64_android_sysroot_subdir =
+ "platforms/android-${_android64_api_level}/arch-x86_64"
+ arm64_android_sysroot_subdir =
+ "platforms/android-${_android64_api_level}/arch-arm64"
+ mips64_android_sysroot_subdir =
+ "platforms/android-${_android64_api_level}/arch-mips64"
+
+ # Toolchain root directory for each build. The actual binaries are inside
+ # a "bin" directory inside of these.
+ _android_toolchain_version = "4.9"
+ _android_toolchain_detailed_version = "4.9.x"
+ x86_android_toolchain_root = "$android_ndk_root/toolchains/x86-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
+ arm_android_toolchain_root = "$android_ndk_root/toolchains/arm-linux-androideabi-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
+ mips_android_toolchain_root = "$android_ndk_root/toolchains/mipsel-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
+ x86_64_android_toolchain_root = "$android_ndk_root/toolchains/x86_64-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
+ arm64_android_toolchain_root = "$android_ndk_root/toolchains/aarch64-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
+ mips64_android_toolchain_root = "$android_ndk_root/toolchains/mips64el-linux-android-${_android_toolchain_version}/prebuilt/${android_host_os}-${android_host_arch}"
+
+ # Location of libgcc. This is only needed for the current GN toolchain, so we
+ # only need to define the current one, rather than one for every platform
+ # like the toolchain roots.
+ if (current_cpu == "x86") {
+ android_prebuilt_arch = "android-x86"
+ _binary_prefix = "i686-linux-android"
+ android_toolchain_root = "$x86_android_toolchain_root"
+ android_libgcc_file = "$android_toolchain_root/lib/gcc/i686-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
+ } else if (current_cpu == "arm") {
+ android_prebuilt_arch = "android-arm"
+ _binary_prefix = "arm-linux-androideabi"
+ android_toolchain_root = "$arm_android_toolchain_root"
+ android_libgcc_file = "$android_toolchain_root/lib/gcc/arm-linux-androideabi/${_android_toolchain_detailed_version}/libgcc.a"
+ } else if (current_cpu == "mipsel") {
+ android_prebuilt_arch = "android-mips"
+ _binary_prefix = "mipsel-linux-android"
+ android_toolchain_root = "$mips_android_toolchain_root"
+ android_libgcc_file = "$android_toolchain_root/lib/gcc/mipsel-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
+ } else if (current_cpu == "x64") {
+ android_prebuilt_arch = "android-x86_64"
+ _binary_prefix = "x86_64-linux-android"
+ android_toolchain_root = "$x86_64_android_toolchain_root"
+ android_libgcc_file = "$android_toolchain_root/lib/gcc/x86_64-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
+ } else if (current_cpu == "arm64") {
+ android_prebuilt_arch = "android-arm64"
+ _binary_prefix = "aarch64-linux-android"
+ android_toolchain_root = "$arm64_android_toolchain_root"
+ android_libgcc_file = "$android_toolchain_root/lib/gcc/aarch64-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
+ } else if (current_cpu == "mips64el") {
+ android_prebuilt_arch = "android-mips64"
+ _binary_prefix = "mips64el-linux-android"
+ android_toolchain_root = "$mips64_android_toolchain_root"
+ android_libgcc_file = "$android_toolchain_root/lib/gcc/mips64el-linux-android/${_android_toolchain_detailed_version}/libgcc.a"
+ } else {
+ assert(false, "Need android libgcc support for your target arch.")
+ }
+
+ android_tool_prefix = "$android_toolchain_root/bin/$_binary_prefix-"
+ android_readelf = "${android_tool_prefix}readelf"
+ android_objcopy = "${android_tool_prefix}objcopy"
+ android_gdbserver =
+ "$android_ndk_root/prebuilt/$android_prebuilt_arch/gdbserver/gdbserver"
+
+ # Toolchain stuff ------------------------------------------------------------
+
+ android_libcpp_root = "$android_ndk_root/sources/cxx-stl/llvm-libc++"
+
+ # ABI ------------------------------------------------------------------------
+
+ if (current_cpu == "x86") {
+ android_app_abi = "x86"
+ } else if (current_cpu == "arm") {
+ import("//build/config/arm.gni")
+ if (arm_version < 7) {
+ android_app_abi = "armeabi"
+ } else {
+ android_app_abi = "armeabi-v7a"
+ }
+ } else if (current_cpu == "mipsel") {
+ android_app_abi = "mips"
+ } else if (current_cpu == "x64") {
+ android_app_abi = "x86_64"
+ } else if (current_cpu == "arm64") {
+ android_app_abi = "arm64-v8a"
+ } else if (current_cpu == "mips64el") {
+ android_app_abi = "mips64"
+ } else {
+ assert(false, "Unknown Android ABI: " + current_cpu)
+ }
+
+ if (android_libcpp_lib_dir == "") {
+ android_libcpp_lib_dir = "${android_libcpp_root}/libs/${android_app_abi}"
+ }
+
+ # Secondary ABI -------------------------------------------------------------
+ if (target_cpu == "arm64" || target_cpu == "x64" || target_cpu == "mips64el") {
+ android_64bit_target_cpu = true
+ } else if (target_cpu == "arm" || target_cpu == "x86" ||
+ target_cpu == "mipsel") {
+ android_64bit_target_cpu = false
+ } else {
+ assert(false, "Unknown target CPU: $target_cpu")
+ }
+
+ # Intentionally do not define android_app_secondary_abi_cpu and
+ # android_app_secondary_abi for 32-bit target_cpu, since they are not used.
+ if (target_cpu == "arm64") {
+ android_secondary_abi_cpu = "arm"
+ android_app_secondary_abi = "armeabi-v7a"
+ } else if (target_cpu == "x64") {
+ android_secondary_abi_cpu = "x86"
+ android_app_secondary_abi = "x86"
+ } else if (target_cpu == "mips64el") {
+ android_secondary_abi_cpu = "mipsel"
+ android_app_secondary_abi = "mips"
+ }
+
+ if (defined(android_secondary_abi_cpu)) {
+ if (is_clang) {
+ android_secondary_abi_toolchain =
+ "//build/toolchain/android:android_clang_${android_secondary_abi_cpu}"
+ } else {
+ android_secondary_abi_toolchain =
+ "//build/toolchain/android:android_${android_secondary_abi_cpu}"
+ }
+ }
+}
+
+declare_args() {
+ # Enables used resource whitelist generation. Set for official builds only
+ # as a large amount of build output is generated.
+ enable_resource_whitelist_generation = is_android && is_official_build
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/android/internal_rules.gni b/third_party/libwebrtc/webrtc/build/config/android/internal_rules.gni
new file mode 100644
index 0000000000..a67956961a
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/android/internal_rules.gni
@@ -0,0 +1,2894 @@
+# 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.
+
+# Do not add any imports to non-//build directories here.
+# Some projects (e.g. V8) do not have non-build directories DEPS'ed in.
+import("//build_overrides/build.gni")
+import("//build/config/android/config.gni")
+import("//build/config/dcheck_always_on.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+
+assert(is_android)
+
+# These identify targets that have .build_config files (except for android_apk,
+# java_binary, resource_rewriter, since we never need to depend on these).
+_java_target_whitelist = [
+ "*:*_java",
+ "*:*_javalib",
+ "*:*_java_*", # e.g. java_test_support
+ "*:java",
+ "*:junit",
+ "*:junit_*",
+ "*:*_junit_*",
+ "*:*javatests",
+ "*:*_assets",
+ "*android*:assets",
+ "*:*_apk_*resources",
+ "*android*:resources",
+ "*:*_resources",
+ "*:*_grd",
+ "*:*locale_paks",
+
+ # TODO(agrieve): Rename targets below to match above patterns.
+ "*android_webview/glue:glue",
+ "//chrome/test/android/cast_emulator:cast_emulator",
+]
+
+# Targets that match the whitelist but are not actually java targets.
+_java_target_blacklist = [
+ "//chrome:packed_resources",
+ "*:*_unpack_aar",
+]
+
+_default_proguard_jar_path = "//third_party/proguard/lib/proguard.jar"
+
+# Write the target's .build_config file. This is a json file that contains a
+# dictionary of information about how to build this target (things that
+# require knowledge about this target's dependencies and cannot be calculated
+# at gn-time). There is a special syntax to add a value in that dictionary to
+# an action/action_foreachs args:
+# --python-arg=@FileArg($rebased_build_config_path:key0:key1)
+# At runtime, such an arg will be replaced by the value in the build_config.
+# See build/android/gyp/write_build_config.py and
+# build/android/gyp/util/build_utils.py:ExpandFileArgs
+template("write_build_config") {
+ type = invoker.type
+ _is_prebuilt_binary =
+ defined(invoker.is_prebuilt_binary) && invoker.is_prebuilt_binary
+
+ # Don't need to enforce naming scheme for these targets since we never
+ # consider them in dependency chains.
+ if (!_is_prebuilt_binary && type != "android_apk" && type != "java_binary" &&
+ type != "resource_rewriter" && type != "dist_jar") {
+ set_sources_assignment_filter(_java_target_whitelist)
+ _parent_invoker = invoker.invoker
+ _target_label =
+ get_label_info(":${_parent_invoker.target_name}", "label_no_toolchain")
+ sources = [
+ _target_label,
+ ]
+ if (sources != []) {
+ set_sources_assignment_filter(_java_target_blacklist)
+ sources = []
+ sources = [
+ _target_label,
+ ]
+ if (sources != []) {
+ assert(false, "Invalid java target name: $_target_label")
+ }
+ }
+ sources = []
+ }
+
+ action(target_name) {
+ set_sources_assignment_filter([])
+ build_config = invoker.build_config
+
+ assert(type == "android_apk" || type == "java_library" ||
+ type == "android_resources" || type == "deps_dex" ||
+ type == "dist_jar" || type == "android_assets" ||
+ type == "resource_rewriter" || type == "java_binary" ||
+ type == "group" || type == "java_prebuilt" || type == "junit_binary")
+
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "testonly",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+
+ script = "//build/android/gyp/write_build_config.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ inputs = []
+
+ _deps_configs = []
+ if (defined(invoker.possible_config_deps)) {
+ foreach(_possible_dep, invoker.possible_config_deps) {
+ set_sources_assignment_filter(_java_target_whitelist)
+ _target_label = get_label_info(_possible_dep, "label_no_toolchain")
+ sources = [
+ _target_label,
+ ]
+ if (sources == []) {
+ set_sources_assignment_filter(_java_target_blacklist)
+ sources = []
+ sources = [
+ _target_label,
+ ]
+ if (sources != []) {
+ deps += [ "${_target_label}__build_config" ]
+ _dep_gen_dir = get_label_info(_possible_dep, "target_gen_dir")
+ _dep_name = get_label_info(_possible_dep, "name")
+ _deps_configs += [ "$_dep_gen_dir/$_dep_name.build_config" ]
+ }
+ }
+ sources = []
+ }
+ set_sources_assignment_filter([])
+ }
+ _rebased_deps_configs = rebase_path(_deps_configs, root_build_dir)
+
+ outputs = [
+ build_config,
+ ]
+
+ args = [
+ "--type",
+ type,
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--deps-configs=$_rebased_deps_configs",
+ "--build-config",
+ rebase_path(build_config, root_build_dir),
+ ]
+
+ is_java = type == "java_library" || type == "java_binary" ||
+ type == "java_prebuilt"
+ is_apk = type == "android_apk"
+ is_android_assets = type == "android_assets"
+ is_android_resources = type == "android_resources"
+ is_deps_dex = type == "deps_dex"
+ is_group = type == "group"
+
+ supports_android = is_apk || is_android_assets || is_android_resources ||
+ is_deps_dex || is_group ||
+ (is_java && defined(invoker.supports_android) &&
+ invoker.supports_android)
+ requires_android =
+ is_apk || is_android_assets || is_android_resources || is_deps_dex ||
+ (is_java && defined(invoker.requires_android) &&
+ invoker.requires_android)
+
+ assert(!requires_android || supports_android,
+ "requires_android requires" + " supports_android")
+
+ # Mark these variables as used.
+ assert(is_java || true)
+ assert(is_apk || true)
+ assert(is_android_resources || true)
+ assert(is_deps_dex || true)
+ assert(is_group || true)
+
+ if (is_java || is_apk) {
+ args += [
+ "--jar-path",
+ rebase_path(invoker.jar_path, root_build_dir),
+ ]
+ }
+
+ if (is_java && defined(invoker.java_resources_jar)) {
+ args += [
+ "--java-resources-jar-path",
+ rebase_path(invoker.java_resources_jar, root_build_dir),
+ ]
+ }
+ if (is_apk || is_deps_dex || (is_java && supports_android)) {
+ args += [
+ "--dex-path",
+ rebase_path(invoker.dex_path, root_build_dir),
+ ]
+ }
+ if (supports_android) {
+ args += [ "--supports-android" ]
+ }
+ if (requires_android) {
+ args += [ "--requires-android" ]
+ }
+ if (defined(invoker.bypass_platform_checks) &&
+ invoker.bypass_platform_checks) {
+ args += [ "--bypass-platform-checks" ]
+ }
+
+ if (defined(invoker.apk_under_test)) {
+ deps += [ "${invoker.apk_under_test}__build_config" ]
+ apk_under_test_gen_dir =
+ get_label_info(invoker.apk_under_test, "target_gen_dir")
+ apk_under_test_name = get_label_info(invoker.apk_under_test, "name")
+ apk_under_test_config =
+ "$apk_under_test_gen_dir/$apk_under_test_name.build_config"
+ args += [
+ "--tested-apk-config",
+ rebase_path(apk_under_test_config, root_build_dir),
+ ]
+ }
+
+ if (is_android_assets) {
+ if (defined(invoker.asset_sources)) {
+ _rebased_asset_sources =
+ rebase_path(invoker.asset_sources, root_build_dir)
+ args += [ "--asset-sources=$_rebased_asset_sources" ]
+ }
+ if (defined(invoker.asset_renaming_sources)) {
+ _rebased_asset_renaming_sources =
+ rebase_path(invoker.asset_renaming_sources, root_build_dir)
+ args += [ "--asset-renaming-sources=$_rebased_asset_renaming_sources" ]
+
+ # These are zip paths, so no need to rebase.
+ args += [ "--asset-renaming-destinations=${invoker.asset_renaming_destinations}" ]
+ }
+ if (defined(invoker.disable_compression) && invoker.disable_compression) {
+ args += [ "--disable-asset-compression" ]
+ }
+ }
+
+ if (is_android_resources || is_apk) {
+ assert(defined(invoker.resources_zip))
+ args += [
+ "--resources-zip",
+ rebase_path(invoker.resources_zip, root_build_dir),
+ ]
+ if (defined(invoker.android_manifest)) {
+ inputs += [ invoker.android_manifest ]
+ args += [
+ "--android-manifest",
+ rebase_path(invoker.android_manifest, root_build_dir),
+ ]
+ } else {
+ assert(!is_apk, "apk build configs require an android_manifest")
+ }
+ if (defined(invoker.custom_package)) {
+ args += [
+ "--package-name",
+ invoker.custom_package,
+ ]
+ }
+ if (defined(invoker.r_text)) {
+ args += [
+ "--r-text",
+ rebase_path(invoker.r_text, root_build_dir),
+ ]
+ }
+ }
+
+ if (is_android_resources && defined(invoker.resource_dirs)) {
+ resource_dirs = rebase_path(invoker.resource_dirs, root_build_dir)
+ args += [ "--resource-dirs=$resource_dirs" ]
+ }
+
+ if (is_apk) {
+ if (defined(invoker.shared_libraries_runtime_deps_file)) {
+ # Don't list shared_libraries_runtime_deps_file as an input in order to
+ # avoid having to depend on the runtime_deps target. See comment in
+ # rules.gni for why we do this.
+ args += [
+ "--shared-libraries-runtime-deps",
+ rebase_path(invoker.shared_libraries_runtime_deps_file,
+ root_build_dir),
+ ]
+ }
+
+ if (defined(invoker.secondary_abi_shared_libraries_runtime_deps_file)) {
+ # Don't list secondary_abi_shared_libraries_runtime_deps_file as an
+ # input in order to avoid having to depend on the runtime_deps target.
+ # See comment in rules.gni for why we do this.
+ args += [
+ "--secondary-abi-shared-libraries-runtime-deps",
+ rebase_path(invoker.secondary_abi_shared_libraries_runtime_deps_file,
+ root_build_dir),
+ ]
+ }
+
+ if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) {
+ args += [
+ "--proguard-enabled",
+ "--proguard-info",
+ rebase_path(invoker.proguard_info, root_build_dir),
+ ]
+ }
+
+ if (defined(invoker.apk_path)) {
+ _rebased_apk_path = rebase_path(invoker.apk_path, root_build_dir)
+ _rebased_incremental_apk_path =
+ rebase_path(invoker.incremental_apk_path, root_build_dir)
+ _rebased_incremental_install_script_path =
+ rebase_path(invoker.incremental_install_script_path, root_build_dir)
+ _incremental_allowed =
+ defined(invoker.incremental_allowed) && invoker.incremental_allowed
+ args += [ "--apk-path=$_rebased_apk_path" ]
+ args += [ "--incremental-install-script-path=$_rebased_incremental_install_script_path" ]
+
+ assert(_rebased_incremental_apk_path != "") # Mark as used.
+ if (_incremental_allowed) {
+ args += [ "--incremental-apk-path=$_rebased_incremental_apk_path" ]
+ }
+ }
+ }
+
+ if (defined(invoker.java_sources_file)) {
+ args += [
+ "--java-sources-file",
+ rebase_path(invoker.java_sources_file, root_build_dir),
+ ]
+ }
+ if (defined(invoker.srcjar)) {
+ args += [
+ "--srcjar",
+ rebase_path(invoker.srcjar, root_build_dir),
+ ]
+ }
+ if (defined(invoker.bundled_srcjars)) {
+ _rebased_bundled_srcjars =
+ rebase_path(invoker.bundled_srcjars, root_build_dir)
+ args += [ "--bundled-srcjars=$_rebased_bundled_srcjars" ]
+ }
+ if (defined(invoker.input_jars_paths)) {
+ _rebased_input_jars_paths =
+ rebase_path(invoker.input_jars_paths, root_build_dir)
+ args += [ "--extra-classpath-jars=$_rebased_input_jars_paths" ]
+ }
+ if (defined(invoker.proguard_configs)) {
+ _rebased_proguard_configs =
+ rebase_path(invoker.proguard_configs, root_build_dir)
+ args += [ "--proguard-configs=$_rebased_proguard_configs" ]
+ }
+ if (defined(invoker.gradle_treat_as_prebuilt) &&
+ invoker.gradle_treat_as_prebuilt) {
+ args += [ "--gradle-treat-as-prebuilt" ]
+ }
+ if (defined(invoker.main_class)) {
+ args += [
+ "--main-class",
+ invoker.main_class,
+ ]
+ }
+ if (defined(invoker.alternative_android_sdk_ijar)) {
+ args += [
+ "--bootclasspath",
+ rebase_path(invoker.alternative_android_sdk_ijar, root_build_dir),
+ ]
+ }
+ if (current_toolchain != default_toolchain) {
+ # This has to be a built-time error rather than a GN assert because many
+ # packages have a mix of java and non-java targets. For example, the
+ # following would fail even though nothing depends on :bar(//baz):
+ #
+ # shared_library("foo") {
+ # }
+ #
+ # android_library("bar") {
+ # deps = [ ":foo(//baz)" ]
+ # assert(current_toolchain == default_toolchain)
+ # }
+ _msg = [
+ "Tried to build an Android target in a non-default toolchain.",
+ "target: " + get_label_info(":$target_name", "label_with_toolchain"),
+ "default_toolchain: $default_toolchain",
+ ]
+ args += [ "--fail=$_msg" ]
+ }
+ }
+}
+
+template("copy_ex") {
+ set_sources_assignment_filter([])
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "data",
+ "deps",
+ "inputs",
+ "sources",
+ "testonly",
+ "visibility",
+ ])
+ if (!defined(sources)) {
+ sources = []
+ }
+ script = "//build/android/gyp/copy_ex.py"
+ depfile = "$target_gen_dir/$target_name.d"
+
+ _stamp_file = "$target_gen_dir/$target_name.stamp"
+ outputs = [
+ _stamp_file,
+ ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--stamp",
+ rebase_path(_stamp_file, root_build_dir),
+ "--dest",
+ rebase_path(invoker.dest, root_build_dir),
+ ]
+ rebased_sources = rebase_path(sources, root_build_dir)
+ args += [ "--files=$rebased_sources" ]
+
+ if (defined(invoker.clear_dir) && invoker.clear_dir) {
+ args += [ "--clear" ]
+ }
+
+ if (defined(invoker.args)) {
+ args += invoker.args
+ }
+
+ if (defined(invoker.renaming_sources) &&
+ defined(invoker.renaming_destinations)) {
+ sources += invoker.renaming_sources
+ rebased_renaming_sources =
+ rebase_path(invoker.renaming_sources, root_build_dir)
+ args += [ "--renaming-sources=$rebased_renaming_sources" ]
+
+ renaming_destinations = invoker.renaming_destinations
+ args += [ "--renaming-destinations=$renaming_destinations" ]
+ }
+ }
+}
+
+# Generates a script in the build bin directory which runs the test
+# target using the test runner script in build/android/test_runner.py.
+template("test_runner_script") {
+ testonly = true
+ _test_name = invoker.test_name
+ _test_type = invoker.test_type
+ _incremental_install =
+ defined(invoker.incremental_install) && invoker.incremental_install
+
+ _runtime_deps =
+ !defined(invoker.ignore_all_data_deps) || !invoker.ignore_all_data_deps
+
+ if (_runtime_deps) {
+ # This runtime_deps file is used at runtime and thus cannot go in
+ # target_gen_dir.
+ _target_dir_name = get_label_info(":$target_name", "dir")
+ _runtime_deps_file =
+ "$root_out_dir/gen.runtime/$_target_dir_name/$target_name.runtime_deps"
+ _runtime_deps_target = "${target_name}__write_deps"
+ group(_runtime_deps_target) {
+ forward_variables_from(invoker,
+ [
+ "data",
+ "data_deps",
+ "deps",
+ "public_deps",
+ ])
+ write_runtime_deps = _runtime_deps_file
+ }
+ }
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "data_deps",
+ "deps",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ if (!defined(data_deps)) {
+ data_deps = []
+ }
+
+ script = "//build/android/gyp/create_test_runner_script.py"
+ depfile = "$target_gen_dir/$target_name.d"
+
+ data_deps += [
+ "//build/android:test_runner_py",
+ "//build/android:logdog_wrapper_py",
+ ]
+
+ data = []
+
+ test_runner_args = [
+ _test_type,
+ "--output-directory",
+ rebase_path(root_build_dir, root_build_dir),
+ ]
+
+ if (_runtime_deps) {
+ deps += [ ":$_runtime_deps_target" ]
+ data += [ _runtime_deps_file ]
+ test_runner_args += [
+ "--runtime-deps-path",
+ rebase_path(_runtime_deps_file, root_build_dir),
+ ]
+ }
+
+ # apk_target is not used for native executable tests
+ # (e.g. breakpad_unittests).
+ if (defined(invoker.apk_target)) {
+ assert(!defined(invoker.executable_dist_dir))
+ deps += [ "${invoker.apk_target}__build_config" ]
+ _apk_build_config =
+ get_label_info(invoker.apk_target, "target_gen_dir") + "/" +
+ get_label_info(invoker.apk_target, "name") + ".build_config"
+ _rebased_apk_build_config = rebase_path(_apk_build_config, root_build_dir)
+ assert(_rebased_apk_build_config != "") # Mark as used.
+ } else if (_test_type == "gtest") {
+ assert(
+ defined(invoker.executable_dist_dir),
+ "Must define either apk_target or executable_dist_dir for test_runner_script()")
+ test_runner_args += [
+ "--executable-dist-dir",
+ rebase_path(invoker.executable_dist_dir, root_build_dir),
+ ]
+ }
+
+ _device_test = true
+ if (_test_type == "gtest") {
+ assert(defined(invoker.test_suite))
+ test_runner_args += [
+ "--suite",
+ invoker.test_suite,
+ ]
+ } else if (_test_type == "instrumentation") {
+ _test_apk = "@FileArg($_rebased_apk_build_config:deps_info:apk_path)"
+ if (_incremental_install) {
+ _test_apk = "@FileArg($_rebased_apk_build_config:deps_info:incremental_apk_path)"
+ }
+ test_runner_args += [
+ "--test-apk=$_test_apk",
+ "--test-jar",
+ rebase_path(invoker.test_jar, root_build_dir),
+ ]
+ if (defined(invoker.apk_under_test)) {
+ deps += [ "${invoker.apk_under_test}__build_config" ]
+ _apk_under_test_build_config =
+ get_label_info(invoker.apk_under_test, "target_gen_dir") + "/" +
+ get_label_info(invoker.apk_under_test, "name") + ".build_config"
+ _rebased_apk_under_test_build_config =
+ rebase_path(_apk_under_test_build_config, root_build_dir)
+ _apk_under_test =
+ "@FileArg($_rebased_apk_under_test_build_config:deps_info:apk_path)"
+ if (_incremental_install) {
+ _apk_under_test = "@FileArg($_rebased_apk_under_test_build_config:deps_info:incremental_apk_path)"
+ }
+ test_runner_args += [ "--apk-under-test=$_apk_under_test" ]
+ }
+ if (emma_coverage) {
+ # Set a default coverage output directory (can be overridden by user
+ # passing the same flag).
+ test_runner_args += [
+ "--coverage-dir",
+ rebase_path("$root_out_dir/coverage", root_build_dir),
+ ]
+ }
+ } else if (_test_type == "junit") {
+ assert(defined(invoker.test_suite))
+ _device_test = false
+ test_runner_args += [
+ "--test-suite",
+ invoker.test_suite,
+ ]
+ if (defined(invoker.android_manifest_path)) {
+ test_runner_args += [
+ "--android-manifest-path",
+ rebase_path(invoker.android_manifest_path, root_build_dir),
+ ]
+ }
+
+ if (defined(invoker.package_name)) {
+ test_runner_args += [
+ "--package-name",
+ invoker.package_name,
+ ]
+
+ deps += [ ":${invoker.test_suite}__build_config" ]
+ _junit_binary_build_config =
+ "${target_gen_dir}/${invoker.test_suite}.build_config"
+ _rebased_build_config =
+ rebase_path("$_junit_binary_build_config", root_build_dir)
+ test_runner_args += [
+ "--resource-zips",
+ "@FileArg($_rebased_build_config:resources:dependency_zips)",
+ ]
+ }
+
+ test_runner_args += [
+ "--robolectric-runtime-deps-dir",
+ rebase_path("$root_build_dir/lib.java/third_party/robolectric",
+ root_build_dir),
+ ]
+ } else if (_test_type == "linker") {
+ test_runner_args += [
+ "--test-apk",
+ "@FileArg($_rebased_apk_build_config:deps_info:apk_path)",
+ ]
+ } else {
+ assert(false, "Invalid test type: $_test_type.")
+ }
+
+ if (defined(invoker.additional_apks)) {
+ foreach(additional_apk, invoker.additional_apks) {
+ deps += [ "${additional_apk}__build_config" ]
+ _build_config = get_label_info(additional_apk, "target_gen_dir") + "/" +
+ get_label_info(additional_apk, "name") + ".build_config"
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ test_runner_args += [
+ "--additional-apk",
+ "@FileArg($_rebased_build_config:deps_info:apk_path)",
+ "--additional-apk-incremental",
+ "@FileArg($_rebased_build_config:deps_info:incremental_apk_path)",
+ ]
+ }
+ }
+ if (defined(invoker.shard_timeout)) {
+ test_runner_args += [ "--shard-timeout=${invoker.shard_timeout}" ]
+ }
+ if (_incremental_install) {
+ test_runner_args += [
+ "--test-apk-incremental-install-script",
+ "@FileArg($_rebased_apk_build_config:deps_info:incremental_install_script_path)",
+ ]
+ if (defined(invoker.apk_under_test)) {
+ test_runner_args += [
+ "--apk-under-test-incremental-install-script",
+ "@FileArg($_rebased_apk_under_test_build_config:deps_info:incremental_install_script_path)",
+ ]
+ }
+ test_runner_args += [ "--fast-local-dev" ]
+ }
+ if (_device_test && is_asan) {
+ test_runner_args += [ "--tool=asan" ]
+ }
+
+ if (defined(invoker.generated_script)) {
+ assert(_test_name != "" || true) # Mark _test_name as used.
+ generated_script = invoker.generated_script
+ } else {
+ generated_script = "$root_build_dir/bin/run_${_test_name}"
+ }
+ outputs = [
+ generated_script,
+ ]
+ data += [ generated_script ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--script-output-path",
+ rebase_path(generated_script, root_build_dir),
+ ]
+ if (defined(android_test_runner_script)) {
+ args += [
+ "--test-runner-path",
+ android_test_runner_script,
+ ]
+ }
+
+ args += test_runner_args
+ }
+}
+
+template("stack_script") {
+ forward_variables_from(invoker, [ "testonly" ])
+
+ _stack_target_name = invoker.stack_target_name
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "data_deps",
+ "deps",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ if (!defined(data_deps)) {
+ data_deps = []
+ }
+
+ data_deps +=
+ [ "//third_party/android_platform/development/scripts:stack_py" ]
+
+ script = "//build/android/gyp/create_stack_script.py"
+ depfile = "$target_gen_dir/$target_name.d"
+
+ _stack_script = "//third_party/android_platform/development/scripts/stack"
+
+ _generated_script = "$root_build_dir/bin/stack_${_stack_target_name}"
+
+ outputs = [
+ _generated_script,
+ ]
+ data = [
+ _generated_script,
+ ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--output-directory",
+ rebase_path(root_build_dir, root_build_dir),
+ "--script-path",
+ rebase_path(_stack_script, root_build_dir),
+ "--script-output-path",
+ rebase_path(_generated_script, root_build_dir),
+ "--arch=$target_cpu",
+ ]
+ if (defined(invoker.packed_libraries)) {
+ args += [
+ "--packed-libs",
+ invoker.packed_libraries,
+ ]
+ }
+ }
+}
+
+if (enable_java_templates) {
+ import("//build/config/zip.gni")
+ import("//third_party/ijar/ijar.gni")
+ import("//third_party/android_platform/config.gni")
+
+ rebased_android_sdk = rebase_path(android_sdk, root_build_dir)
+ rebased_android_sdk_build_tools =
+ rebase_path(android_sdk_build_tools, root_build_dir)
+
+ android_sdk_jar = "$android_sdk/android.jar"
+ rebased_android_sdk_jar = rebase_path(android_sdk_jar, root_build_dir)
+ android_default_aapt_path = "$rebased_android_sdk_build_tools/aapt"
+
+ android_configuration_name = "Release"
+ if (is_debug) {
+ android_configuration_name = "Debug"
+ }
+
+ template("android_lint") {
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "data_deps",
+ "public_deps",
+ "testonly",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+
+ if (!defined(lint_suppressions_file)) {
+ lint_suppressions_file = "//build/android/lint/suppressions.xml"
+ }
+
+ _cache_dir = "$root_build_dir/android_lint_cache"
+ _result_path = "$target_gen_dir/$target_name/result.xml"
+ _config_path = "$target_gen_dir/$target_name/config.xml"
+ _suppressions_file = lint_suppressions_file
+ _platform_xml_path =
+ "${android_sdk_root}/platform-tools/api/api-versions.xml"
+ _rebased_lint_android_sdk_root =
+ rebase_path(lint_android_sdk_root, root_build_dir)
+
+ script = "//build/android/gyp/lint.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ inputs = [
+ _platform_xml_path,
+ _suppressions_file,
+ invoker.android_manifest,
+ ]
+
+ outputs = [
+ _result_path,
+ _config_path,
+ ]
+
+ args = [
+ "--lint-path=$_rebased_lint_android_sdk_root/tools-lint/bin/lint",
+ "--cache-dir",
+ rebase_path(_cache_dir, root_build_dir),
+ "--platform-xml-path",
+ rebase_path(_platform_xml_path, root_build_dir),
+ "--android-sdk-version=${lint_android_sdk_version}",
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--config-path",
+ rebase_path(_suppressions_file, root_build_dir),
+ "--manifest-path",
+ rebase_path(invoker.android_manifest, root_build_dir),
+ "--product-dir=.",
+ "--processed-config-path",
+ rebase_path(_config_path, root_build_dir),
+ "--result-path",
+ rebase_path(_result_path, root_build_dir),
+ ]
+
+ if (defined(invoker.disable)) {
+ args += [ "--disable=${invoker.disable}" ]
+ }
+
+ if (defined(invoker.create_cache) && invoker.create_cache) {
+ args += [
+ "--create-cache",
+ "--silent",
+ ]
+ } else {
+ inputs += invoker.java_files
+ inputs += [
+ invoker.jar_path,
+ invoker.build_config,
+ ]
+ if (invoker.java_files != []) {
+ inputs += [ invoker.java_sources_file ]
+ _rebased_java_sources_file =
+ rebase_path(invoker.java_sources_file, root_build_dir)
+ args += [ "--java-sources-file=$_rebased_java_sources_file" ]
+ }
+ deps += [ "//build/android:prepare_android_lint_cache" ]
+
+ _rebased_build_config =
+ rebase_path(invoker.build_config, root_build_dir)
+ args += [
+ "--jar-path",
+ rebase_path(invoker.jar_path, root_build_dir),
+ "--classpath=@FileArg($_rebased_build_config:javac:interface_classpath)",
+ "--resource-sources=@FileArg($_rebased_build_config:deps_info:owned_resources_dirs)",
+ "--resource-sources=@FileArg($_rebased_build_config:deps_info:owned_resources_zips)",
+ "--can-fail-build",
+ ]
+ }
+ }
+ }
+
+ template("proguard") {
+ action(target_name) {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "data_deps",
+ "public_deps",
+ "testonly",
+ ])
+ script = "//build/android/gyp/proguard.py"
+ if (defined(invoker.proguard_jar_path)) {
+ _proguard_jar_path = invoker.proguard_jar_path
+ } else {
+ _proguard_jar_path = _default_proguard_jar_path
+ }
+ _output_jar_path = invoker.output_jar_path
+ inputs = [
+ _proguard_jar_path,
+ ]
+ if (defined(invoker.alternative_android_sdk_jar)) {
+ inputs += [ invoker.alternative_android_sdk_jar ]
+ _rebased_android_sdk_jar =
+ rebase_path(invoker.alternative_android_sdk_jar)
+ } else {
+ inputs += [ android_sdk_jar ]
+ _rebased_android_sdk_jar = rebased_android_sdk_jar
+ }
+ if (defined(invoker.inputs)) {
+ inputs += invoker.inputs
+ }
+ depfile = "${target_gen_dir}/${target_name}.d"
+ outputs = [
+ _output_jar_path,
+ "$_output_jar_path.flags",
+ "$_output_jar_path.mapping",
+ "$_output_jar_path.seeds",
+ "$_output_jar_path.usage",
+ ]
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--proguard-path",
+ rebase_path(_proguard_jar_path, root_build_dir),
+ "--output-path",
+ rebase_path(_output_jar_path, root_build_dir),
+ "--classpath",
+ _rebased_android_sdk_jar,
+ ]
+ if (proguard_verbose) {
+ args += [ "--verbose" ]
+ }
+ if (defined(invoker.args)) {
+ args += invoker.args
+ }
+ if (defined(invoker.proguard_jar_path)) {
+ # We assume that if we are using a different ProGuard, this new version
+ # can handle the 'dangerous' optimizaions.
+ args += [ "--enable-dangerous-optimizations" ]
+ }
+ }
+ }
+
+ template("findbugs") {
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "testonly",
+ ])
+ script = "//build/android/findbugs_diff.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ _result_path = "$target_gen_dir/$target_name/result.xml"
+ _exclusions_file = "//build/android/findbugs_filter/findbugs_exclude.xml"
+
+ _rebased_build_config = rebase_path(invoker.build_config, root_build_dir)
+
+ inputs = [
+ "//build/android/pylib/utils/findbugs.py",
+ _exclusions_file,
+ invoker.jar_path,
+ invoker.build_config,
+ ]
+
+ outputs = [
+ _result_path,
+ ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--exclude",
+ rebase_path(_exclusions_file, root_build_dir),
+ "--auxclasspath-gyp",
+ "@FileArg($_rebased_build_config:javac:classpath)",
+ "--output-file",
+ rebase_path(_result_path, root_build_dir),
+ rebase_path(invoker.jar_path, root_build_dir),
+ ]
+
+ if (findbugs_verbose) {
+ args += [ "-vv" ]
+ }
+ }
+ }
+
+ # Generates a script in the build bin directory to run a java binary.
+ #
+ # Variables
+ # main_class: The class containing the program entry point.
+ # jar_path: The path to the jar to run.
+ # script_name: Name of the script to generate.
+ # build_config: Path to .build_config for the jar (contains classpath).
+ # wrapper_script_args: List of extra arguments to pass to the executable.
+ #
+ template("java_binary_script") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ _main_class = invoker.main_class
+ _build_config = invoker.build_config
+ _jar_path = invoker.jar_path
+ _script_name = invoker.script_name
+
+ action(target_name) {
+ script = "//build/android/gyp/create_java_binary_script.py"
+ depfile = "$target_gen_dir/$_script_name.d"
+ java_script = "$root_build_dir/bin/$_script_name"
+ inputs = [
+ _build_config,
+ ]
+ outputs = [
+ java_script,
+ ]
+ forward_variables_from(invoker, [ "deps" ])
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--output",
+ rebase_path(java_script, root_build_dir),
+ "--classpath=@FileArg($_rebased_build_config:deps_info:java:full_classpath)",
+ "--jar-path",
+ rebase_path(_jar_path, root_build_dir),
+ "--main-class",
+ _main_class,
+ ]
+ if (emma_coverage) {
+ args += [
+ "--classpath",
+ rebase_path("//third_party/android_tools/sdk/tools/lib/emma.jar",
+ root_build_dir),
+ ]
+ args += [ "--noverify" ]
+ }
+ if (defined(invoker.wrapper_script_args)) {
+ args += [ "--" ] + invoker.wrapper_script_args
+ }
+ if (defined(invoker.bootclasspath)) {
+ args += [
+ "--bootclasspath",
+ rebase_path(invoker.bootclasspath, root_build_dir),
+ ]
+ }
+ }
+ }
+
+ template("dex") {
+ set_sources_assignment_filter([])
+
+ _enable_multidex =
+ defined(invoker.enable_multidex) && invoker.enable_multidex
+
+ if (_enable_multidex) {
+ _main_dex_list_path = invoker.output + ".main_dex_list"
+ _main_dex_list_target_name = "${target_name}__main_dex_list"
+ action(_main_dex_list_target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "inputs",
+ "sources",
+ "testonly",
+ ])
+
+ script = "//build/android/gyp/main_dex_list.py"
+ depfile = "$target_gen_dir/$target_name.d"
+
+ main_dex_rules = "//build/android/main_dex_classes.flags"
+
+ if (defined(invoker.proguard_jar_path)) {
+ _proguard_jar_path = invoker.proguard_jar_path
+ } else {
+ _proguard_jar_path = _default_proguard_jar_path
+ }
+
+ if (!defined(inputs)) {
+ inputs = []
+ }
+ inputs += [
+ main_dex_rules,
+ _proguard_jar_path,
+ ]
+
+ outputs = [
+ _main_dex_list_path,
+ ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--android-sdk-tools",
+ rebased_android_sdk_build_tools,
+ "--main-dex-list-path",
+ rebase_path(_main_dex_list_path, root_build_dir),
+ "--main-dex-rules-path",
+ rebase_path(main_dex_rules, root_build_dir),
+ "--proguard-path",
+ rebase_path(_proguard_jar_path, root_build_dir),
+ ]
+
+ if (defined(invoker.extra_main_dex_proguard_config)) {
+ inputs += [ invoker.extra_main_dex_proguard_config ]
+ args += [
+ "--main-dex-rules-path",
+ rebase_path(invoker.extra_main_dex_proguard_config, root_build_dir),
+ ]
+ }
+
+ if (defined(invoker.args)) {
+ args += invoker.args
+ }
+
+ if (defined(invoker.sources)) {
+ args += rebase_path(invoker.sources, root_build_dir)
+ }
+ }
+ }
+
+ assert(defined(invoker.output))
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "inputs",
+ "sources",
+ "testonly",
+ ])
+ script = "//build/android/gyp/dex.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ outputs = [
+ invoker.output,
+ ]
+
+ rebased_output = rebase_path(invoker.output, root_build_dir)
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--android-sdk-tools",
+ rebased_android_sdk_build_tools,
+ "--dex-path",
+ rebased_output,
+ ]
+
+ if (enable_incremental_dx) {
+ args += [ "--incremental" ]
+ }
+
+ # EMMA requires --no-locals.
+ if (emma_coverage) {
+ args += [ "--no-locals=1" ]
+ }
+
+ if (_enable_multidex) {
+ args += [
+ "--multi-dex",
+ "--main-dex-list-path",
+ rebase_path(_main_dex_list_path, root_build_dir),
+ ]
+ deps += [ ":${_main_dex_list_target_name}" ]
+ inputs += [ _main_dex_list_path ]
+ }
+
+ if (defined(invoker.args)) {
+ args += invoker.args
+ }
+
+ if (defined(invoker.sources)) {
+ args += rebase_path(invoker.sources, root_build_dir)
+ }
+ }
+ }
+
+ template("process_java_prebuilt") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ assert(invoker.build_config != "")
+ _build_config = invoker.build_config
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ assert(_rebased_build_config != "" || true) # Mark used.
+
+ _input_jar_path = invoker.input_jar_path
+ _output_jar_path = invoker.output_jar_path
+
+ _jar_excluded_patterns = []
+ if (defined(invoker.jar_excluded_patterns)) {
+ _jar_excluded_patterns = invoker.jar_excluded_patterns
+ }
+ _strip_resource_classes = defined(invoker.strip_resource_classes) &&
+ invoker.strip_resource_classes
+ _filter_jar = _jar_excluded_patterns != [] || _strip_resource_classes
+
+ _enable_assert =
+ defined(invoker.supports_android) && invoker.supports_android &&
+ (is_java_debug || dcheck_always_on)
+
+ _retrolambda = defined(invoker.supports_android) &&
+ invoker.supports_android && use_java8
+
+ _deps = []
+ _previous_output_jar = _input_jar_path
+
+ if (_filter_jar) {
+ _filter_target = "${target_name}__filter"
+ _filter_input_jar = _previous_output_jar
+ _filter_output_jar = "$target_out_dir/$target_name-filtered.jar"
+
+ action(_filter_target) {
+ script = "//build/android/gyp/jar.py"
+ deps = _deps
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ if (defined(invoker.public_deps)) {
+ public_deps = invoker.public_deps
+ }
+ inputs = [
+ _build_config,
+ _filter_input_jar,
+ ]
+ outputs = [
+ _filter_output_jar,
+ ]
+ args = [
+ "--input-jar",
+ rebase_path(_filter_input_jar, root_build_dir),
+ "--jar-path",
+ rebase_path(_filter_output_jar, root_build_dir),
+ "--excluded-classes=$_jar_excluded_patterns",
+ ]
+ if (_strip_resource_classes) {
+ args += [ "--strip-resource-classes-for=@FileArg($_rebased_build_config:javac:resource_packages)" ]
+ }
+ }
+
+ _deps = []
+ _deps = [ ":$_filter_target" ]
+ _previous_output_jar = _filter_output_jar
+ }
+
+ if (_enable_assert) {
+ _assert_target = "${target_name}__assert"
+ _assert_input_jar = _previous_output_jar
+ _assert_output_jar = "$target_out_dir/$target_name-asserted.jar"
+
+ action(_assert_target) {
+ script = "$root_build_dir/bin/helper/java_assertion_enabler"
+ deps = [
+ "//build/android/java_assertion_enabler($default_toolchain)",
+ ]
+ deps += _deps
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ if (defined(invoker.public_deps)) {
+ public_deps = invoker.public_deps
+ }
+ inputs = [
+ _assert_input_jar,
+ ]
+ outputs = [
+ _assert_output_jar,
+ ]
+ args = [
+ rebase_path(_assert_input_jar, root_build_dir),
+ rebase_path(_assert_output_jar, root_build_dir),
+ ]
+ }
+
+ _deps = []
+ _deps = [ ":$_assert_target" ]
+ _previous_output_jar = _assert_output_jar
+ }
+
+ if (_retrolambda) {
+ _retrolambda_target = "${target_name}__retrolambda"
+ _retrolambda_input_jar = _previous_output_jar
+ _retrolambda_output_jar = "$target_out_dir/$target_name-retrolambda.jar"
+
+ android_sdk_jar = "$android_sdk/android.jar"
+ action(_retrolambda_target) {
+ script = "//build/android/gyp/retrolambda.py"
+ deps = _deps
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ if (defined(invoker.public_deps)) {
+ public_deps = invoker.public_deps
+ }
+ inputs = [
+ _build_config,
+ _retrolambda_input_jar,
+ ]
+ outputs = [
+ _retrolambda_output_jar,
+ ]
+ args = [
+ "--input-jar",
+ rebase_path(_retrolambda_input_jar, root_build_dir),
+ "--output-jar",
+ rebase_path(_retrolambda_output_jar, root_build_dir),
+ "--classpath=@FileArg($_rebased_build_config:javac:classpath)",
+ "--android-sdk-jar",
+ rebase_path(android_sdk_jar, root_build_dir),
+ ]
+ }
+
+ _deps = []
+ _deps = [ ":$_retrolambda_target" ]
+ _previous_output_jar = _retrolambda_output_jar
+ }
+
+ _output_jar_target = "${target_name}__copy"
+ copy(_output_jar_target) {
+ deps = _deps
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ if (defined(invoker.public_deps)) {
+ public_deps = invoker.public_deps
+ }
+ sources = [
+ _previous_output_jar,
+ ]
+ outputs = [
+ _output_jar_path,
+ ]
+ }
+
+ group(target_name) {
+ forward_variables_from(invoker,
+ [
+ "data_deps",
+ "visibility",
+ ])
+ public_deps = [
+ ":$_output_jar_target",
+ ]
+ }
+ }
+
+ template("emma_instr") {
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "testonly",
+ ])
+
+ _coverage_file = "$target_out_dir/${target_name}.em"
+ _source_dirs_listing_file = "$target_out_dir/${target_name}_sources.txt"
+ _emma_jar = "${android_sdk_root}/tools/lib/emma.jar"
+
+ script = "//build/android/gyp/emma_instr.py"
+ depfile = "${target_gen_dir}/${target_name}.d"
+ inputs = invoker.java_files + [
+ _emma_jar,
+ invoker.input_jar_path,
+ ]
+ outputs = [
+ _coverage_file,
+ _source_dirs_listing_file,
+ invoker.output_jar_path,
+ ]
+ args = [
+ "instrument_jar",
+ "--input-path",
+ rebase_path(invoker.input_jar_path, root_build_dir),
+ "--output-path",
+ rebase_path(invoker.output_jar_path, root_build_dir),
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--coverage-file",
+ rebase_path(_coverage_file, root_build_dir),
+ "--sources-list-file",
+ rebase_path(_source_dirs_listing_file, root_build_dir),
+ "--src-root",
+ rebase_path("//", root_build_dir),
+ "--emma-jar",
+ rebase_path(_emma_jar, root_build_dir),
+ ]
+ _rebased_java_sources_file =
+ rebase_path(invoker.java_sources_file, root_build_dir)
+ args += [ "--java-sources-file=$_rebased_java_sources_file" ]
+
+ if (emma_filter != "") {
+ args += [
+ "--filter-string",
+ emma_filter,
+ ]
+ }
+ }
+ }
+
+ # Creates an unsigned .apk.
+ #
+ # Variables
+ # assets_build_config: Path to android_apk .build_config containing merged
+ # asset information.
+ # deps: Specifies the dependencies of this target.
+ # dex_path: Path to classes.dex file to include (optional).
+ # resource_packaged_apk_path: Path to .ap_ to use.
+ # output_apk_path: Output path for the generated .apk.
+ # native_lib_placeholders: List of placeholder filenames to add to the apk
+ # (optional).
+ # native_libs: List of native libraries.
+ # native_libs_filearg: @FileArg() of additionaly native libraries.
+ # write_asset_list: Adds an extra file to the assets, which contains a list of
+ # all other asset files.
+ template("package_apk") {
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "public_deps",
+ "testonly",
+ ])
+ _native_lib_placeholders = []
+ if (defined(invoker.native_lib_placeholders)) {
+ _native_lib_placeholders = invoker.native_lib_placeholders
+ }
+
+ script = "//build/android/gyp/apkbuilder.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ data_deps = [
+ "//tools/android/md5sum",
+ ] # Used when deploying APKs
+
+ inputs = invoker.native_libs + [ invoker.resource_packaged_apk_path ]
+ if (defined(invoker.dex_path)) {
+ inputs += [ invoker.dex_path ]
+ }
+
+ outputs = [
+ invoker.output_apk_path,
+ ]
+
+ _rebased_resource_packaged_apk_path =
+ rebase_path(invoker.resource_packaged_apk_path, root_build_dir)
+ _rebased_packaged_apk_path =
+ rebase_path(invoker.output_apk_path, root_build_dir)
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--resource-apk=$_rebased_resource_packaged_apk_path",
+ "--output-apk=$_rebased_packaged_apk_path",
+ ]
+ if (defined(invoker.assets_build_config)) {
+ inputs += [ invoker.assets_build_config ]
+ _rebased_build_config =
+ rebase_path(invoker.assets_build_config, root_build_dir)
+ args += [
+ "--assets=@FileArg($_rebased_build_config:assets)",
+ "--uncompressed-assets=@FileArg($_rebased_build_config:uncompressed_assets)",
+ ]
+
+ # TODO(mlopatkin) We are relying on the fact that assets_build_config is
+ # an APK build_config.
+ args += [ "--java-resources=@FileArg($_rebased_build_config:java_resources_jars)" ]
+ }
+ if (defined(invoker.write_asset_list) && invoker.write_asset_list) {
+ args += [ "--write-asset-list" ]
+ }
+ if (defined(invoker.dex_path)) {
+ _rebased_dex_path = rebase_path(invoker.dex_path, root_build_dir)
+ args += [ "--dex-file=$_rebased_dex_path" ]
+ }
+ if (invoker.native_libs != [] || defined(invoker.native_libs_filearg) ||
+ _native_lib_placeholders != []) {
+ args += [ "--android-abi=$android_app_abi" ]
+ }
+ if (invoker.native_libs != []) {
+ _rebased_native_libs = rebase_path(invoker.native_libs, root_build_dir)
+ args += [ "--native-libs=$_rebased_native_libs" ]
+ }
+ if (defined(invoker.native_libs_filearg)) {
+ args += [ "--native-libs=${invoker.native_libs_filearg}" ]
+ }
+ if (_native_lib_placeholders != []) {
+ args += [ "--native-lib-placeholders=$_native_lib_placeholders" ]
+ }
+
+ # TODO (michaelbai): Remove the secondary_native_libs variable.
+ if (defined(invoker.secondary_abi_native_libs_filearg)) {
+ assert(defined(android_app_secondary_abi))
+ args += [
+ "--secondary-native-libs=${invoker.secondary_abi_native_libs_filearg}",
+ "--secondary-android-abi=$android_app_secondary_abi",
+ ]
+ } else if (defined(invoker.secondary_native_libs) &&
+ invoker.secondary_native_libs != []) {
+ assert(defined(android_app_secondary_abi))
+ inputs += invoker.secondary_native_libs
+ _secondary_native_libs = rebase_path(invoker.secondary_native_libs)
+ args += [
+ "--secondary-native-libs=$_secondary_native_libs",
+ "--secondary-android-abi=$android_app_secondary_abi",
+ ]
+ }
+
+ if (defined(invoker.uncompress_shared_libraries) &&
+ invoker.uncompress_shared_libraries) {
+ args += [ "--uncompress-shared-libraries" ]
+ }
+ }
+ }
+
+ # Signs & zipaligns an apk.
+ #
+ # Variables
+ # input_apk_path: Path of the .apk to be finalized.
+ # output_apk_path: Output path for the generated .apk.
+ # keystore_path: Path to keystore to use for signing.
+ # keystore_name: Key alias to use.
+ # keystore_password: Keystore password.
+ template("finalize_apk") {
+ action(target_name) {
+ deps = []
+ script = "//build/android/gyp/finalize_apk.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "data_deps",
+ "public_deps",
+ "testonly",
+ ])
+
+ sources = [
+ invoker.input_apk_path,
+ ]
+ inputs = [
+ invoker.keystore_path,
+ ]
+ outputs = [
+ invoker.output_apk_path,
+ ]
+ data = [
+ invoker.output_apk_path,
+ ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--zipalign-path",
+ rebase_path(zipalign_path, root_build_dir),
+ "--unsigned-apk-path",
+ rebase_path(invoker.input_apk_path, root_build_dir),
+ "--final-apk-path",
+ rebase_path(invoker.output_apk_path, root_build_dir),
+ "--key-path",
+ rebase_path(invoker.keystore_path, root_build_dir),
+ "--key-name",
+ invoker.keystore_name,
+ "--key-passwd",
+ invoker.keystore_password,
+ ]
+ }
+ }
+
+ # Packages resources, assets, dex, and native libraries into an apk. Signs and
+ # zipaligns the apk.
+ template("create_apk") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ _android_manifest = invoker.android_manifest
+ _base_path = invoker.base_path
+ _final_apk_path = invoker.apk_path
+ _incremental_final_apk_path_helper =
+ process_file_template(
+ [ _final_apk_path ],
+ "{{source_dir}}/{{source_name_part}}_incremental.apk")
+ _incremental_final_apk_path = _incremental_final_apk_path_helper[0]
+
+ if (defined(invoker.resources_zip)) {
+ _resources_zip = invoker.resources_zip
+ assert(_resources_zip != "") # Mark as used.
+ }
+ if (defined(invoker.dex_path)) {
+ _dex_path = invoker.dex_path
+ }
+ _load_library_from_apk = invoker.load_library_from_apk
+
+ _deps = []
+ if (defined(invoker.deps)) {
+ _deps = invoker.deps
+ }
+ _incremental_deps = []
+ if (defined(invoker.incremental_deps)) {
+ _incremental_deps = invoker.incremental_deps
+ }
+ _native_libs = []
+ if (defined(invoker.native_libs)) {
+ _native_libs = invoker.native_libs
+ }
+ _native_libs_even_when_incremental = []
+ if (defined(invoker.native_libs_even_when_incremental)) {
+ _native_libs_even_when_incremental =
+ invoker.native_libs_even_when_incremental
+ }
+
+ _version_code = invoker.version_code
+ _version_name = invoker.version_name
+ assert(_version_code != -1) # Mark as used.
+ assert(_version_name != "") # Mark as used.
+
+ _base_apk_path = _base_path + ".apk_intermediates"
+
+ _resource_packaged_apk_path = _base_apk_path + ".ap_"
+ _incremental_resource_packaged_apk_path =
+ _base_apk_path + "_incremental.ap_"
+ _packaged_apk_path = _base_apk_path + ".unfinished.apk"
+ _incremental_packaged_apk_path =
+ _base_apk_path + "_incremental.unfinished.apk"
+ _shared_resources =
+ defined(invoker.shared_resources) && invoker.shared_resources
+ assert(_shared_resources || true) # Mark as used.
+ _app_as_shared_lib =
+ defined(invoker.app_as_shared_lib) && invoker.app_as_shared_lib
+ assert(_app_as_shared_lib || true) # Mark as used.
+ assert(!(_shared_resources && _app_as_shared_lib))
+
+ _keystore_path = invoker.keystore_path
+ _keystore_name = invoker.keystore_name
+ _keystore_password = invoker.keystore_password
+
+ _split_densities = []
+ if (defined(invoker.create_density_splits) &&
+ invoker.create_density_splits) {
+ _split_densities = [
+ "hdpi",
+ "xhdpi",
+ "xxhdpi",
+ "xxxhdpi",
+ "tvdpi",
+ ]
+ }
+
+ _split_languages = []
+ if (defined(invoker.language_splits)) {
+ _split_languages = invoker.language_splits
+ }
+
+ template("package_resources_helper") {
+ action(target_name) {
+ deps = invoker.deps
+
+ script = "//build/android/gyp/package_resources.py"
+ depfile = "${target_gen_dir}/${target_name}.d"
+ inputs = [
+ invoker.android_manifest,
+ ]
+ if (defined(_resources_zip)) {
+ inputs += [ _resources_zip ]
+ }
+ outputs = [
+ invoker.resource_packaged_apk_path,
+ ]
+
+ if (defined(invoker.android_aapt_path)) {
+ _android_aapt_path = invoker.android_aapt_path
+ } else {
+ _android_aapt_path = android_default_aapt_path
+ }
+
+ if (defined(invoker.alternative_android_sdk_jar)) {
+ _rebased_android_sdk_jar =
+ rebase_path(invoker.alternative_android_sdk_jar)
+ } else {
+ _rebased_android_sdk_jar = rebased_android_sdk_jar
+ }
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--android-sdk-jar",
+ _rebased_android_sdk_jar,
+ "--aapt-path",
+ _android_aapt_path,
+ "--configuration-name=$android_configuration_name",
+ "--android-manifest",
+ rebase_path(invoker.android_manifest, root_build_dir),
+ "--version-code",
+ _version_code,
+ "--version-name",
+ _version_name,
+ "--apk-path",
+ rebase_path(invoker.resource_packaged_apk_path, root_build_dir),
+ ]
+
+ if (defined(_resources_zip)) {
+ args += [
+ "--resource-zips",
+ rebase_path(_resources_zip, root_build_dir),
+ ]
+ }
+ if (_shared_resources) {
+ args += [ "--shared-resources" ]
+ }
+ if (_app_as_shared_lib) {
+ args += [ "--app-as-shared-lib" ]
+ }
+ if (_split_densities != []) {
+ args += [ "--create-density-splits" ]
+ foreach(_density, _split_densities) {
+ outputs += [ "${invoker.resource_packaged_apk_path}_${_density}" ]
+ }
+ }
+ if (_split_languages != []) {
+ args += [ "--language-splits=$_split_languages" ]
+ foreach(_language, _split_languages) {
+ outputs += [ "${invoker.resource_packaged_apk_path}_${_language}" ]
+ }
+ }
+ if (defined(invoker.aapt_locale_whitelist)) {
+ args += [ "--locale-whitelist=${invoker.aapt_locale_whitelist}" ]
+ }
+ if (defined(invoker.extensions_to_not_compress)) {
+ args += [
+ "--no-compress",
+ invoker.extensions_to_not_compress,
+ ]
+ }
+ }
+ }
+
+ _package_resources_target_name = "${target_name}__package_resources"
+ package_resources_helper(_package_resources_target_name) {
+ forward_variables_from(invoker,
+ [
+ "aapt_locale_whitelist",
+ "alternative_android_sdk_jar",
+ "android_aapt_path",
+ "extensions_to_not_compress",
+ ])
+ deps = _deps
+ android_manifest = _android_manifest
+ resource_packaged_apk_path = _resource_packaged_apk_path
+ }
+
+ _generate_incremental_manifest_target_name =
+ "${target_name}_incremental_generate_manifest"
+ _incremental_android_manifest =
+ get_label_info(_generate_incremental_manifest_target_name,
+ "target_gen_dir") + "/AndroidManifest.xml"
+ action(_generate_incremental_manifest_target_name) {
+ deps = _incremental_deps
+ script =
+ "//build/android/incremental_install/generate_android_manifest.py"
+ depfile = "${target_gen_dir}/${target_name}.d"
+ inputs = [
+ _android_manifest,
+ ]
+ outputs = [
+ _incremental_android_manifest,
+ ]
+
+ _rebased_src_manifest = rebase_path(_android_manifest, root_build_dir)
+ _rebased_incremental_manifest =
+ rebase_path(_incremental_android_manifest, root_build_dir)
+ _rebased_depfile = rebase_path(depfile, root_build_dir)
+ args = [
+ "--src-manifest=$_rebased_src_manifest",
+ "--out-manifest=$_rebased_incremental_manifest",
+ "--depfile=$_rebased_depfile",
+ ]
+ if (disable_incremental_isolated_processes) {
+ args += [ "--disable-isolated-processes" ]
+ }
+ }
+
+ _incremental_package_resources_target_name =
+ "${target_name}_incremental__package_resources"
+
+ # TODO(agrieve): See if we can speed up this step by swapping the manifest
+ # from the result of the main package_resources step.
+ package_resources_helper(_incremental_package_resources_target_name) {
+ forward_variables_from(invoker,
+ [
+ "aapt_locale_whitelist",
+ "alternative_android_sdk_jar",
+ "android_aapt_path",
+ "extensions_to_not_compress",
+ ])
+ deps =
+ _incremental_deps + [ ":$_generate_incremental_manifest_target_name" ]
+ android_manifest = _incremental_android_manifest
+ resource_packaged_apk_path = _incremental_resource_packaged_apk_path
+ }
+
+ package_target = "${target_name}__package"
+ package_apk(package_target) {
+ forward_variables_from(invoker,
+ [
+ "assets_build_config",
+ "native_lib_placeholders",
+ "native_libs_filearg",
+ "secondary_abi_native_libs_filearg",
+ "secondary_native_libs",
+ "uncompress_shared_libraries",
+ "write_asset_list",
+ ])
+ if (!defined(uncompress_shared_libraries)) {
+ uncompress_shared_libraries = _load_library_from_apk
+ }
+ deps = _deps + [ ":${_package_resources_target_name}" ]
+ native_libs = _native_libs + _native_libs_even_when_incremental
+
+ if (defined(_dex_path)) {
+ dex_path = _dex_path
+ }
+
+ output_apk_path = _packaged_apk_path
+ resource_packaged_apk_path = _resource_packaged_apk_path
+ }
+
+ _incremental_package_target = "${target_name}_incremental__package"
+ package_apk(_incremental_package_target) {
+ forward_variables_from(invoker,
+ [
+ "assets_build_config",
+ "secondary_native_libs",
+ "uncompress_shared_libraries",
+ ])
+ if (!defined(uncompress_shared_libraries)) {
+ uncompress_shared_libraries = _load_library_from_apk
+ }
+ _dex_target = "//build/android/incremental_install:bootstrap_java__dex"
+ deps = _incremental_deps + [
+ ":${_incremental_package_resources_target_name}",
+ _dex_target,
+ ]
+
+ if (defined(_dex_path)) {
+ dex_path =
+ get_label_info(_dex_target, "target_gen_dir") + "/bootstrap.dex"
+ }
+
+ native_libs = _native_libs_even_when_incremental
+
+ # http://crbug.com/384638
+ _has_native_libs =
+ defined(invoker.native_libs_filearg) || _native_libs != []
+ if (_has_native_libs && _native_libs_even_when_incremental == []) {
+ native_lib_placeholders = [ "libfix.crbug.384638.so" ]
+ }
+
+ output_apk_path = _incremental_packaged_apk_path
+ resource_packaged_apk_path = _incremental_resource_packaged_apk_path
+ }
+
+ _finalize_apk_rule_name = "${target_name}__finalize"
+ finalize_apk(_finalize_apk_rule_name) {
+ input_apk_path = _packaged_apk_path
+ output_apk_path = _final_apk_path
+ keystore_path = _keystore_path
+ keystore_name = _keystore_name
+ keystore_password = _keystore_password
+
+ public_deps = [
+ # Generator of the _packaged_apk_path this target takes as input.
+ ":$package_target",
+ ]
+ }
+
+ _incremental_finalize_apk_rule_name = "${target_name}_incremental__finalize"
+ finalize_apk(_incremental_finalize_apk_rule_name) {
+ input_apk_path = _incremental_packaged_apk_path
+ output_apk_path = _incremental_final_apk_path
+ keystore_path = _keystore_path
+ keystore_name = _keystore_name
+ keystore_password = _keystore_password
+
+ public_deps = [
+ ":$_incremental_package_target",
+ ]
+ }
+
+ _split_deps = []
+
+ template("finalize_split") {
+ finalize_apk(target_name) {
+ _config = invoker.split_config
+ _type = invoker.split_type
+ input_apk_path = "${_resource_packaged_apk_path}_${_config}"
+ _output_paths = process_file_template(
+ [ _final_apk_path ],
+ "{{source_dir}}/{{source_name_part}}-${_type}-${_config}.apk")
+ output_apk_path = _output_paths[0]
+ keystore_path = _keystore_path
+ keystore_name = _keystore_name
+ keystore_password = _keystore_password
+ deps = [
+ ":${_package_resources_target_name}",
+ ]
+ }
+ }
+
+ foreach(_split, _split_densities) {
+ _split_rule = "${target_name}__finalize_${_split}_split"
+ finalize_split(_split_rule) {
+ split_type = "density"
+ split_config = _split
+ }
+ _split_deps += [ ":$_split_rule" ]
+ }
+ foreach(_split, _split_languages) {
+ _split_rule = "${target_name}__finalize_${_split}_split"
+ finalize_split(_split_rule) {
+ split_type = "lang"
+ split_config = _split
+ }
+ _split_deps += [ ":$_split_rule" ]
+ }
+
+ group(target_name) {
+ public_deps = [ ":${_finalize_apk_rule_name}" ] + _split_deps
+ }
+ group("${target_name}_incremental") {
+ public_deps = [ ":${_incremental_finalize_apk_rule_name}" ] + _split_deps
+ }
+ }
+
+ template("java_prebuilt_impl") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+ _supports_android =
+ defined(invoker.supports_android) && invoker.supports_android
+
+ assert(defined(invoker.jar_path))
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ } else {
+ _output_name = get_path_info(invoker.jar_path, "name")
+ }
+ _base_path = "${target_gen_dir}/$target_name"
+
+ # Jar files can be needed at runtime (by Robolectric tests or java binaries),
+ # so do not put them under gen/.
+ _target_dir_name = get_label_info(":$target_name", "dir")
+ _jar_path = "$root_out_dir/lib.java$_target_dir_name/$_output_name.jar"
+ _ijar_path =
+ "$root_out_dir/lib.java$_target_dir_name/$_output_name.interface.jar"
+ _build_config = _base_path + ".build_config"
+
+ if (_supports_android) {
+ _dex_path = _base_path + ".dex.jar"
+ }
+ _deps = []
+ if (defined(invoker.deps)) {
+ _deps = invoker.deps
+ }
+ _jar_deps = []
+ if (defined(invoker.jar_dep)) {
+ _jar_deps = [ invoker.jar_dep ]
+ }
+
+ _template_name = target_name
+
+ _build_config_target_name = "${_template_name}__build_config"
+ _process_jar_target_name = "${_template_name}__process_jar"
+ _ijar_target_name = "${_template_name}__ijar"
+ if (_supports_android) {
+ _dex_target_name = "${_template_name}__dex"
+ }
+
+ write_build_config(_build_config_target_name) {
+ type = "java_prebuilt"
+ is_prebuilt_binary = defined(invoker.main_class)
+ forward_variables_from(invoker,
+ [
+ "input_jars_paths",
+ "proguard_configs",
+ ])
+ supports_android = _supports_android
+ requires_android =
+ defined(invoker.requires_android) && invoker.requires_android
+
+ if (defined(invoker.deps)) {
+ possible_config_deps = _deps
+ }
+ build_config = _build_config
+ jar_path = _jar_path
+ if (_supports_android) {
+ dex_path = _dex_path
+ }
+ if (defined(invoker.include_java_resources) &&
+ invoker.include_java_resources) {
+ # Use original jar_path because _jar_path points to a library without
+ # resources.
+ java_resources_jar = invoker.jar_path
+ }
+ }
+
+ process_java_prebuilt(_process_jar_target_name) {
+ forward_variables_from(invoker,
+ [
+ "jar_excluded_patterns",
+ "strip_resource_classes",
+ ])
+
+ visibility = [
+ ":$_ijar_target_name",
+ ":$_template_name",
+ ]
+ if (_supports_android) {
+ visibility += [ ":$_dex_target_name" ]
+ }
+
+ supports_android = _supports_android
+ build_config = _build_config
+ input_jar_path = invoker.jar_path
+ output_jar_path = _jar_path
+
+ deps = [ ":$_build_config_target_name" ] + _deps + _jar_deps
+ }
+
+ generate_interface_jar(_ijar_target_name) {
+ # Always used the unfiltered .jar to create the interface jar so that
+ # other targets will resolve filtered classes when depending on
+ # BuildConfig, NativeLibraries, etc.
+ input_jar = invoker.jar_path
+ deps = _deps + _jar_deps
+ output_jar = _ijar_path
+ }
+
+ if (_supports_android) {
+ dex(_dex_target_name) {
+ sources = [
+ _jar_path,
+ ]
+ output = _dex_path
+ deps = [ ":$_process_jar_target_name" ] + _deps + _jar_deps
+ }
+ }
+
+ if (defined(invoker.main_class)) {
+ _binary_script_target_name = "${_template_name}__java_binary_script"
+ java_binary_script(_binary_script_target_name) {
+ forward_variables_from(invoker,
+ [
+ "bootclasspath",
+ "deps",
+ "main_class",
+ "wrapper_script_args",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ build_config = _build_config
+ jar_path = _jar_path
+ script_name = _template_name
+ if (defined(invoker.wrapper_script_name)) {
+ script_name = invoker.wrapper_script_name
+ }
+ deps += [ ":$_build_config_target_name" ]
+ }
+ }
+
+ group(target_name) {
+ forward_variables_from(invoker, [ "data_deps" ])
+ public_deps = [
+ ":$_ijar_target_name",
+ ":$_process_jar_target_name",
+ ]
+ if (_supports_android) {
+ public_deps += [ ":$_dex_target_name" ]
+ }
+ if (defined(invoker.main_class)) {
+ # Some targets use the generated script while building, so make it a dep
+ # rather than a data_dep.
+ public_deps += [ ":$_binary_script_target_name" ]
+ }
+ }
+ }
+
+ # Compiles and jars a set of java files.
+ #
+ # Outputs:
+ # $jar_path.jar
+ # $jar_path.interface.jar
+ #
+ # Variables
+ # java_files: List of .java files to compile (same as exists in java_sources_file)
+ # java_sources_file: Path to file containing list of files to compile.
+ # chromium_code: If true, enable extra warnings.
+ # srcjar_deps: List of srcjar dependencies. The .java files contained in the
+ # dependencies srcjar outputs will be compiled and added to the output jar.
+ # jar_path: Use this to explicitly set the output jar path. Defaults to
+ # "${target_gen_dir}/${target_name}.jar.
+ template("compile_java") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ assert(defined(invoker.build_config))
+ assert(defined(invoker.jar_path))
+
+ _build_config = invoker.build_config
+
+ _chromium_code = false
+ if (defined(invoker.chromium_code)) {
+ _chromium_code = invoker.chromium_code
+ }
+
+ _supports_android = true
+ if (defined(invoker.supports_android)) {
+ _supports_android = invoker.supports_android
+ }
+
+ _requires_android =
+ defined(invoker.requires_android) && invoker.requires_android
+
+ _enable_errorprone = use_errorprone_java_compiler
+ if (!_chromium_code) {
+ _enable_errorprone = false
+ } else if (defined(invoker.enable_errorprone)) {
+ _enable_errorprone = invoker.enable_errorprone
+ }
+
+ _provider_configurations = []
+ if (defined(invoker.provider_configurations)) {
+ _provider_configurations = invoker.provider_configurations
+ }
+
+ _processors = []
+ _enable_interface_jars_javac = true
+ if (defined(invoker.processors_javac)) {
+ _processors = invoker.processors_javac
+ _enable_interface_jars_javac = _processors == []
+ }
+
+ _processor_args = []
+ if (defined(invoker.processor_args_javac)) {
+ _processor_args = invoker.processor_args_javac
+ }
+
+ _additional_jar_files = []
+ if (defined(invoker.additional_jar_files)) {
+ _additional_jar_files = invoker.additional_jar_files
+ }
+
+ if (defined(invoker.enable_incremental_javac_override)) {
+ # Use invoker-specified override.
+ _enable_incremental_javac = invoker.enable_incremental_javac_override
+ } else {
+ # Default to build arg if not overridden.
+ _enable_incremental_javac = enable_incremental_javac
+ }
+
+ _manifest_entries = []
+ if (defined(invoker.manifest_entries)) {
+ _manifest_entries = invoker.manifest_entries
+ }
+
+ _srcjar_deps = []
+ if (defined(invoker.srcjar_deps)) {
+ _srcjar_deps += invoker.srcjar_deps
+ }
+
+ _java_srcjars = []
+ if (defined(invoker.srcjars)) {
+ _java_srcjars = invoker.srcjars
+ }
+ foreach(dep, _srcjar_deps) {
+ _dep_gen_dir = get_label_info(dep, "target_gen_dir")
+ _dep_name = get_label_info(dep, "name")
+ _java_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ]
+ }
+
+ # Mark srcjar_deps as used.
+ assert(_srcjar_deps == [] || true)
+
+ _javac_target_name = "${target_name}__javac"
+ _process_prebuilt_target_name = "${target_name}__process_prebuilt"
+ _ijar_target_name = "${target_name}__ijar"
+ _final_target_name = target_name
+
+ _final_jar_path = invoker.jar_path
+ _javac_jar_path = "$target_gen_dir/$target_name.javac.jar"
+ _process_prebuilt_jar_path = _final_jar_path
+ _final_ijar_path = get_path_info(_final_jar_path, "dir") + "/" +
+ get_path_info(_final_jar_path, "name") + ".interface.jar"
+
+ _emma_instrument = defined(invoker.emma_instrument) &&
+ invoker.emma_instrument && invoker.java_files != []
+ if (_emma_instrument) {
+ _emma_instr_target_name = "${target_name}__emma_instr"
+ _process_prebuilt_jar_path =
+ "$target_gen_dir/$target_name.process_prebuilt.jar"
+ }
+
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ _rebased_jar_path = rebase_path(_javac_jar_path, root_build_dir)
+
+ action(_javac_target_name) {
+ script = "//build/android/gyp/javac.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ deps = _srcjar_deps
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+
+ outputs = [
+ _javac_jar_path,
+ _javac_jar_path + ".md5.stamp",
+ ]
+ sources = invoker.java_files + _java_srcjars
+ inputs = [
+ _build_config,
+ ]
+ if (invoker.java_files != []) {
+ inputs += [ invoker.java_sources_file ]
+ }
+
+ _rebased_java_srcjars = rebase_path(_java_srcjars, root_build_dir)
+ _rebased_depfile = rebase_path(depfile, root_build_dir)
+ args = [
+ "--depfile=$_rebased_depfile",
+ "--jar-path=$_rebased_jar_path",
+ "--java-srcjars=$_rebased_java_srcjars",
+ "--java-srcjars=@FileArg($_rebased_build_config:javac:srcjars)",
+ ]
+ if (_enable_interface_jars_javac) {
+ args += [ "--classpath=@FileArg($_rebased_build_config:javac:interface_classpath)" ]
+ } else {
+ args +=
+ [ "--classpath=@FileArg($_rebased_build_config:javac:classpath)" ]
+ }
+ if (_enable_incremental_javac) {
+ args += [ "--incremental" ]
+ deps += [ "//third_party/jmake($default_toolchain)" ]
+ inputs += [ "$root_build_dir/bin/jmake" ]
+ outputs += [ "${_javac_jar_path}.pdb" ]
+ }
+ if (_requires_android) {
+ if (defined(invoker.alternative_android_sdk_ijar)) {
+ deps += [ invoker.alternative_android_sdk_ijar_dep ]
+ _android_sdk_ijar = invoker.alternative_android_sdk_ijar
+ } else {
+ deps += [ "//build/android:android_ijar" ]
+ _android_sdk_ijar = "$root_out_dir/lib.java/android.interface.jar"
+ }
+ inputs += [ _android_sdk_ijar ]
+ _rebased_android_sdk_ijar =
+ rebase_path(_android_sdk_ijar, root_build_dir)
+ args += [ "--bootclasspath=$_rebased_android_sdk_ijar" ]
+ }
+ if (use_java8) {
+ args += [ "--java-version=1.8" ]
+ } else if (_supports_android) {
+ args += [ "--java-version=1.7" ]
+ }
+ foreach(e, _manifest_entries) {
+ args += [ "--manifest-entry=" + e ]
+ }
+ if (_chromium_code) {
+ args += [ "--chromium-code=1" ]
+ }
+ if (_enable_errorprone) {
+ deps += [ "//third_party/errorprone:chromium_errorprone" ]
+ args += [
+ "--use-errorprone-path",
+ "bin/chromium_errorprone",
+ ]
+ }
+ foreach(e, _provider_configurations) {
+ args += [ "--provider-configuration=" + rebase_path(e, root_build_dir) ]
+ }
+ foreach(e, _processors) {
+ args += [ "--processor=" + e ]
+ }
+ foreach(e, _processor_args) {
+ args += [ "--processor-arg=" + e ]
+ }
+ foreach(file_tuple, _additional_jar_files) {
+ # Each element is of length two, [ path_to_file, path_to_put_in_jar ]
+ inputs += [ file_tuple[0] ]
+ args +=
+ [ "--additional-jar-file=" + file_tuple[0] + ":" + file_tuple[1] ]
+ }
+ if (invoker.java_files != []) {
+ args += [ "@" + rebase_path(invoker.java_sources_file, root_build_dir) ]
+ }
+ }
+
+ process_java_prebuilt(_process_prebuilt_target_name) {
+ forward_variables_from(invoker, [ "jar_excluded_patterns" ])
+ supports_android = _supports_android
+ build_config = _build_config
+ input_jar_path = _javac_jar_path
+ output_jar_path = _process_prebuilt_jar_path
+
+ deps = [
+ ":$_javac_target_name",
+ ]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ }
+
+ if (_emma_instrument) {
+ emma_instr(_emma_instr_target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "java_files",
+ "java_sources_file",
+ ])
+
+ input_jar_path = _process_prebuilt_jar_path
+ output_jar_path = _final_jar_path
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_process_prebuilt_target_name" ]
+ }
+ }
+
+ generate_interface_jar(_ijar_target_name) {
+ # Always used the unfiltered .jar to create the interface jar so that
+ # other targets will resolve filtered classes when depending on
+ # BuildConfig, NativeLibraries, etc.
+ input_jar = _javac_jar_path
+ deps = [
+ ":$_javac_target_name",
+ ]
+ output_jar = _final_ijar_path
+ }
+
+ group(_final_target_name) {
+ forward_variables_from(invoker, [ "visibility" ])
+ public_deps = [
+ ":$_ijar_target_name",
+ ":$_javac_target_name",
+ ]
+ if (_emma_instrument) {
+ public_deps += [ ":$_emma_instr_target_name" ]
+ } else {
+ public_deps += [ ":$_process_prebuilt_target_name" ]
+ }
+ }
+ }
+
+ template("java_library_impl") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+ _accumulated_deps = []
+ if (defined(invoker.deps)) {
+ _accumulated_deps = invoker.deps
+ }
+
+ # Caller overriding build config must have valid java sources file if it has
+ # java files.
+ assert(!defined(invoker.override_build_config) ||
+ !defined(invoker.java_files) || defined(invoker.java_sources_file))
+
+ assert(defined(invoker.java_files) || defined(invoker.srcjars) ||
+ defined(invoker.srcjar_deps))
+ _base_path = "$target_gen_dir/$target_name"
+
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ } else {
+ _output_name = target_name
+ }
+
+ # Jar files can be needed at runtime (by Robolectric tests or java binaries),
+ # so do not put them under gen/.
+ target_dir_name = get_label_info(":$target_name", "dir")
+ _jar_path = "$root_out_dir/lib.java$target_dir_name/$_output_name.jar"
+ if (defined(invoker.jar_path)) {
+ _jar_path = invoker.jar_path
+ }
+ _template_name = target_name
+
+ _final_deps = []
+
+ _supports_android =
+ defined(invoker.supports_android) && invoker.supports_android
+ _requires_android =
+ defined(invoker.requires_android) && invoker.requires_android
+ assert(_requires_android || true) # Mark as used.
+ _android_manifest = "//build/android/AndroidManifest.xml"
+ if (defined(invoker.android_manifest)) {
+ _android_manifest = invoker.android_manifest
+ }
+ assert(_android_manifest != "") # Mark as used.
+
+ if (defined(invoker.run_findbugs_override)) {
+ _run_findbugs = invoker.run_findbugs_override
+ } else {
+ _run_findbugs = run_findbugs # Default to build arg if not overridden.
+ }
+ assert(_run_findbugs || true) # Mark as used.
+
+ # Don't enable coverage, lint, findbugs unless the target has some
+ # non-generated files.
+ if (defined(invoker.chromium_code)) {
+ _chromium_code = invoker.chromium_code
+ } else {
+ _chromium_code = defined(invoker.java_files) && invoker.java_files != []
+ if (_chromium_code) {
+ # Make chromium_code = false be the default for targets within
+ # third_party which contain no chromium-namespaced java files.
+ set_sources_assignment_filter([ "*\bthird_party\b*" ])
+ sources = [
+ get_label_info(":$target_name", "dir"),
+ ]
+ if (sources == []) {
+ set_sources_assignment_filter([ "*\bchromium\b*" ])
+ sources = invoker.java_files
+ _chromium_code = invoker.java_files != sources
+ }
+ set_sources_assignment_filter([])
+ sources = []
+ }
+ }
+
+ _emma_never_instrument = !_chromium_code
+ if (defined(invoker.emma_never_instrument)) {
+ _emma_never_instrument = invoker.emma_never_instrument
+ }
+ assert(_emma_never_instrument || true) # Mark as used
+ _emma_instrument = emma_coverage && !_emma_never_instrument
+
+ if (_supports_android) {
+ _dex_path = _base_path + ".dex.jar"
+ if (defined(invoker.dex_path)) {
+ _dex_path = invoker.dex_path
+ }
+ }
+
+ _java_files = []
+ if (defined(invoker.java_files)) {
+ _java_files += invoker.java_files
+ }
+ if (_java_files != []) {
+ if (defined(invoker.java_sources_file)) {
+ _java_sources_file = invoker.java_sources_file
+ } else {
+ _java_sources_file = "$_base_path.sources"
+ }
+ write_file(_java_sources_file, rebase_path(_java_files, root_build_dir))
+ }
+
+ # Define build_config_deps which will be a list of targets required to
+ # build the _build_config.
+ if (defined(invoker.override_build_config)) {
+ _build_config = invoker.override_build_config
+ } else {
+ _build_config = _base_path + ".build_config"
+ build_config_target_name = "${_template_name}__build_config"
+
+ write_build_config(build_config_target_name) {
+ forward_variables_from(invoker,
+ [
+ "alternative_android_sdk_ijar",
+ "gradle_treat_as_prebuilt",
+ "input_jars_paths",
+ "main_class",
+ "proguard_configs",
+ ])
+ if (defined(invoker.is_java_binary) && invoker.is_java_binary) {
+ type = "java_binary"
+ } else {
+ type = "java_library"
+ }
+ if (defined(invoker.deps)) {
+ possible_config_deps = invoker.deps
+ }
+ supports_android = _supports_android
+ requires_android = _requires_android
+ bypass_platform_checks = defined(invoker.bypass_platform_checks) &&
+ invoker.bypass_platform_checks
+
+ build_config = _build_config
+ jar_path = _jar_path
+ if (_supports_android) {
+ dex_path = _dex_path
+ }
+ if (_java_files != []) {
+ java_sources_file = _java_sources_file
+ }
+
+ if (defined(invoker.srcjar_deps)) {
+ bundled_srcjars = []
+ foreach(d, invoker.srcjar_deps) {
+ _dep_gen_dir = get_label_info(d, "target_gen_dir")
+ _dep_name = get_label_info(d, "name")
+ bundled_srcjars += [ "$_dep_gen_dir/$_dep_name.srcjar" ]
+ }
+ }
+ }
+ _accumulated_deps += [ ":$build_config_target_name" ]
+ }
+
+ _srcjar_deps = []
+ if (defined(invoker.srcjar_deps)) {
+ _srcjar_deps = invoker.srcjar_deps
+ }
+
+ _srcjars = []
+ if (defined(invoker.srcjars)) {
+ _srcjars = invoker.srcjars
+ }
+
+ assert(_java_files != [] || _srcjar_deps != [] || _srcjars != [])
+
+ _compile_java_target = "${_template_name}__compile_java"
+ _final_deps += [ ":$_compile_java_target" ]
+ compile_java(_compile_java_target) {
+ forward_variables_from(invoker,
+ [
+ "additional_jar_files",
+ "alternative_android_sdk_ijar",
+ "alternative_android_sdk_ijar_dep",
+ "dist_jar_path",
+ "enable_errorprone",
+ "enable_incremental_javac_override",
+ "jar_excluded_patterns",
+ "manifest_entries",
+ "processors_javac",
+ "processor_args_javac",
+ "provider_configurations",
+ ])
+ jar_path = _jar_path
+ build_config = _build_config
+ java_files = _java_files
+ if (_java_files != []) {
+ java_sources_file = _java_sources_file
+ }
+ srcjar_deps = _srcjar_deps
+ srcjars = _srcjars
+ chromium_code = _chromium_code
+ supports_android = _supports_android
+ requires_android = _requires_android
+ emma_instrument = _emma_instrument
+ deps = _accumulated_deps
+ }
+ _accumulated_deps += [ ":$_compile_java_target" ]
+ assert(_accumulated_deps != []) # Mark used.
+
+ if (defined(invoker.main_class)) {
+ # Targets might use the generated script while building, so make it a dep
+ # rather than a data_dep.
+ _final_deps += [ ":${_template_name}__java_binary_script" ]
+ java_binary_script("${_template_name}__java_binary_script") {
+ forward_variables_from(invoker,
+ [
+ "bootclasspath",
+ "main_class",
+ "wrapper_script_args",
+ ])
+ build_config = _build_config
+ jar_path = _jar_path
+ script_name = _template_name
+ if (defined(invoker.wrapper_script_name)) {
+ script_name = invoker.wrapper_script_name
+ }
+ deps = _accumulated_deps
+ }
+ }
+
+ _has_lint_target = false
+ if (_supports_android) {
+ if (_chromium_code) {
+ _has_lint_target = true
+ android_lint("${_template_name}__lint") {
+ android_manifest = _android_manifest
+ build_config = _build_config
+
+ # Run lint on javac output.
+ jar_path = "$target_gen_dir/$_compile_java_target.javac.jar"
+
+ java_files = _java_files
+ if (_java_files != []) {
+ java_sources_file = _java_sources_file
+ }
+ deps = _accumulated_deps
+ if (_emma_instrument) {
+ # Disable the NewApi lint warning when building with coverage
+ # enabled. Coverage seems to mess with how the linter detects
+ # the usages of a new API within a conditional. See
+ # crbug.com/677320 for more.
+ disable = [ "NewApi" ]
+ }
+ }
+
+ if (_run_findbugs) {
+ findbugs("${_template_name}__findbugs") {
+ build_config = _build_config
+ jar_path = _jar_path
+ deps = _accumulated_deps
+ }
+ }
+
+ # Use an intermediate group() rather as the data_deps target in order to
+ # avoid lint artifacts showing up as runtime_deps (while still having lint
+ # run in parallel to other targets).
+ group("${_template_name}__analysis") {
+ public_deps = [
+ ":${_template_name}__lint",
+ ]
+ if (_run_findbugs) {
+ public_deps += [ ":${_template_name}__findbugs" ]
+ }
+ }
+ }
+
+ _final_deps += [ ":${_template_name}__dex" ]
+ dex("${_template_name}__dex") {
+ sources = [
+ _jar_path,
+ ]
+ output = _dex_path
+ deps = [
+ ":$_compile_java_target",
+ ]
+ }
+ }
+
+ group(target_name) {
+ forward_variables_from(invoker,
+ [
+ "data",
+ "data_deps",
+ "visibility",
+ ])
+ if (!defined(data_deps)) {
+ data_deps = []
+ }
+ public_deps = _final_deps
+ if (_has_lint_target) {
+ data_deps += [ ":${_template_name}__analysis" ]
+ }
+ }
+ }
+
+ # Runs process_resources.py
+ template("process_resources") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ zip_path = invoker.zip_path
+ srcjar_path = invoker.srcjar_path
+ r_text_out_path = invoker.r_text_out_path
+ build_config = invoker.build_config
+ android_manifest = invoker.android_manifest
+
+ non_constant_id = true
+ if (defined(invoker.generate_constant_ids) &&
+ invoker.generate_constant_ids) {
+ non_constant_id = false
+ }
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "visibility",
+ ])
+ script = "//build/android/gyp/process_resources.py"
+
+ depfile = "$target_gen_dir/$target_name.d"
+ outputs = [
+ zip_path,
+ srcjar_path,
+ r_text_out_path,
+ ]
+
+ _all_resource_dirs = []
+ sources = []
+
+ if (defined(invoker.resource_dirs)) {
+ _all_resource_dirs += invoker.resource_dirs
+
+ # Speed up "gn gen" by short-circuiting the empty directory.
+ if (invoker.resource_dirs != [ "//build/android/ant/empty/res" ] &&
+ invoker.resource_dirs != []) {
+ _sources_build_rel =
+ exec_script("//build/android/gyp/find.py",
+ rebase_path(invoker.resource_dirs, root_build_dir),
+ "list lines")
+ sources += rebase_path(_sources_build_rel, ".", root_build_dir)
+ }
+ }
+
+ if (defined(invoker.generated_resource_dirs)) {
+ assert(defined(invoker.generated_resource_files))
+ _all_resource_dirs += invoker.generated_resource_dirs
+ sources += invoker.generated_resource_files
+ }
+
+ inputs = [
+ build_config,
+ android_manifest,
+ ]
+
+ _rebased_all_resource_dirs =
+ rebase_path(_all_resource_dirs, root_build_dir)
+ rebase_build_config = rebase_path(build_config, root_build_dir)
+
+ if (defined(invoker.android_aapt_path)) {
+ _android_aapt_path = invoker.android_aapt_path
+ } else {
+ _android_aapt_path = android_default_aapt_path
+ }
+
+ if (defined(invoker.alternative_android_sdk_jar)) {
+ _rebased_android_sdk_jar =
+ rebase_path(invoker.alternative_android_sdk_jar)
+ } else {
+ _rebased_android_sdk_jar = rebased_android_sdk_jar
+ }
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--android-sdk-jar",
+ _rebased_android_sdk_jar,
+ "--aapt-path",
+ _android_aapt_path,
+ "--android-manifest",
+ rebase_path(android_manifest, root_build_dir),
+ "--resource-dirs=$_rebased_all_resource_dirs",
+ "--srcjar-out",
+ rebase_path(srcjar_path, root_build_dir),
+ "--resource-zip-out",
+ rebase_path(zip_path, root_build_dir),
+ "--r-text-out",
+ rebase_path(r_text_out_path, root_build_dir),
+ "--dependencies-res-zips=@FileArg($rebase_build_config:resources:dependency_zips)",
+ "--extra-res-packages=@FileArg($rebase_build_config:resources:extra_package_names)",
+ "--extra-r-text-files=@FileArg($rebase_build_config:resources:extra_r_text_files)",
+ ]
+
+ if (defined(invoker.r_text_in_path)) {
+ _r_text_in_path = invoker.r_text_in_path
+ inputs += [ _r_text_in_path ]
+ args += [
+ "--r-text-in",
+ rebase_path(_r_text_in_path, root_build_dir),
+ ]
+ }
+
+ if (non_constant_id) {
+ args += [ "--non-constant-id" ]
+ }
+
+ if (defined(invoker.custom_package)) {
+ args += [
+ "--custom-package",
+ invoker.custom_package,
+ ]
+ }
+
+ if (defined(invoker.v14_skip) && invoker.v14_skip) {
+ args += [ "--v14-skip" ]
+ }
+
+ if (defined(invoker.shared_resources) && invoker.shared_resources) {
+ args += [ "--shared-resources" ]
+ }
+
+ if (defined(invoker.app_as_shared_lib) && invoker.app_as_shared_lib) {
+ args += [ "--app-as-shared-lib" ]
+ }
+
+ if (defined(invoker.include_all_resources) &&
+ invoker.include_all_resources) {
+ args += [ "--include-all-resources" ]
+ }
+
+ if (defined(invoker.all_resources_zip_path)) {
+ all_resources_zip = invoker.all_resources_zip_path
+ outputs += [ all_resources_zip ]
+ args += [
+ "--all-resources-zip-out",
+ rebase_path(all_resources_zip, root_build_dir),
+ ]
+ }
+
+ if (defined(invoker.proguard_file)) {
+ outputs += [ invoker.proguard_file ]
+ args += [
+ "--proguard-file",
+ rebase_path(invoker.proguard_file, root_build_dir),
+ ]
+ }
+
+ if (defined(invoker.proguard_file_main_dex)) {
+ outputs += [ invoker.proguard_file_main_dex ]
+ args += [
+ "--proguard-file-main-dex",
+ rebase_path(invoker.proguard_file_main_dex, root_build_dir),
+ ]
+ }
+
+ if (defined(invoker.args)) {
+ args += invoker.args
+ }
+ }
+ }
+
+ # Produces a single .dex.jar out of a set of Java dependencies.
+ template("deps_dex") {
+ set_sources_assignment_filter([])
+ build_config = "$target_gen_dir/${target_name}.build_config"
+ build_config_target_name = "${target_name}__build_config"
+
+ write_build_config(build_config_target_name) {
+ forward_variables_from(invoker, [ "dex_path" ])
+ if (defined(invoker.deps)) {
+ possible_config_deps = invoker.deps
+ }
+ type = "deps_dex"
+ build_config = build_config
+ }
+
+ rebased_build_config = rebase_path(build_config, root_build_dir)
+ dex(target_name) {
+ inputs = [
+ build_config,
+ ]
+ output = invoker.dex_path
+ dex_arg_key = "${rebased_build_config}:final_dex:dependency_dex_files"
+ args = [ "--inputs=@FileArg($dex_arg_key)" ]
+ if (defined(invoker.excluded_jars)) {
+ excluded_jars = rebase_path(invoker.excluded_jars, root_build_dir)
+ args += [ "--excluded-paths=${excluded_jars}" ]
+ }
+ deps = [
+ ":$build_config_target_name",
+ ]
+ }
+ }
+
+ # Creates an AndroidManifest.xml for an APK split.
+ template("generate_split_manifest") {
+ assert(defined(invoker.main_manifest))
+ assert(defined(invoker.out_manifest))
+ assert(defined(invoker.split_name))
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "testonly",
+ ])
+ depfile = "$target_gen_dir/$target_name.d"
+ args = [
+ "--main-manifest",
+ rebase_path(invoker.main_manifest, root_build_dir),
+ "--out-manifest",
+ rebase_path(invoker.out_manifest, root_build_dir),
+ "--split",
+ invoker.split_name,
+ ]
+ if (defined(invoker.version_code)) {
+ args += [
+ "--version-code",
+ invoker.version_code,
+ ]
+ }
+ if (defined(invoker.version_name)) {
+ args += [
+ "--version-name",
+ invoker.version_name,
+ ]
+ }
+ if (defined(invoker.has_code)) {
+ args += [
+ "--has-code",
+ invoker.has_code,
+ ]
+ }
+ args += [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ ]
+
+ script = "//build/android/gyp/generate_split_manifest.py"
+ outputs = [
+ invoker.out_manifest,
+ ]
+ inputs = [
+ invoker.main_manifest,
+ ]
+ }
+ }
+
+ template("pack_relocation_section") {
+ assert(defined(invoker.file_list_json))
+ assert(defined(invoker.libraries_filearg))
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "public_deps",
+ "inputs",
+ "testonly",
+ ])
+ script = "//build/android/gyp/pack_relocations.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ _packed_libraries_dir = "$target_gen_dir/$target_name/packed-libs"
+ outputs = [
+ invoker.file_list_json,
+ ]
+ deps += [ relocation_packer_target ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--enable-packing=1",
+ "--android-pack-relocations",
+ rebase_path(relocation_packer_exe, root_build_dir),
+ "--stripped-libraries-dir",
+ rebase_path(root_build_dir, root_build_dir),
+ "--packed-libraries-dir",
+ rebase_path(_packed_libraries_dir, root_build_dir),
+ "--libraries=${invoker.libraries_filearg}",
+ "--filelistjson",
+ rebase_path(invoker.file_list_json, root_build_dir),
+ ]
+ }
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/android/rules.gni b/third_party/libwebrtc/webrtc/build/config/android/rules.gni
new file mode 100644
index 0000000000..ccb895ac0d
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/android/rules.gni
@@ -0,0 +1,2970 @@
+# 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.
+
+# Do not add any imports to non-//build directories here.
+# Some projects (e.g. V8) do not have non-build directories DEPS'ed in.
+import("//build/config/android/config.gni")
+if (!build_with_mozilla) {
+ import("//build/config/android/internal_rules.gni")
+}
+import("//build/config/compiler/compiler.gni")
+import("//build/config/dcheck_always_on.gni")
+import("//build/toolchain/toolchain.gni")
+
+assert(is_android)
+
+# Creates a dist directory for a native executable.
+#
+# Running a native executable on a device requires all the shared library
+# dependencies of that executable. To make it easier to install and run such an
+# executable, this will create a directory containing the native exe and all
+# it's library dependencies.
+#
+# Note: It's usually better to package things as an APK than as a native
+# executable.
+#
+# Variables
+# dist_dir: Directory for the exe and libraries. Everything in this directory
+# will be deleted before copying in the exe and libraries.
+# binary: Path to (stripped) executable.
+# extra_files: List of extra files to copy in (optional).
+#
+# Example
+# create_native_executable_dist("foo_dist") {
+# dist_dir = "$root_build_dir/foo_dist"
+# binary = "$root_build_dir/foo"
+# deps = [ ":the_thing_that_makes_foo" ]
+# }
+template("create_native_executable_dist") {
+ forward_variables_from(invoker, [ "testonly" ])
+
+ _libraries_list = "${target_gen_dir}/${target_name}_library_dependencies.list"
+
+ _find_deps_target_name = "${target_name}__find_library_dependencies"
+
+ # TODO(agrieve): Extract dependent libs from GN rather than readelf.
+ action(_find_deps_target_name) {
+ forward_variables_from(invoker, [ "deps" ])
+
+ script = "//build/android/gyp/write_ordered_libraries.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ inputs = [
+ invoker.binary,
+ android_readelf,
+ ]
+ outputs = [
+ _libraries_list,
+ ]
+ rebased_binaries = rebase_path([ invoker.binary ], root_build_dir)
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--input-libraries=$rebased_binaries",
+ "--libraries-dir",
+ rebase_path(root_shlib_dir, root_build_dir),
+ "--output",
+ rebase_path(_libraries_list, root_build_dir),
+ "--readelf",
+ rebase_path(android_readelf, root_build_dir),
+ ]
+ }
+
+ copy_ex(target_name) {
+ clear_dir = true
+
+ inputs = [
+ _libraries_list,
+ invoker.binary,
+ ]
+
+ dest = invoker.dist_dir
+ data = [
+ "${invoker.dist_dir}/",
+ ]
+
+ _rebased_libraries_list = rebase_path(_libraries_list, root_build_dir)
+ _rebased_binaries_list = rebase_path([ invoker.binary ], root_build_dir)
+ args = [
+ "--files=@FileArg($_rebased_libraries_list:lib_paths)",
+ "--files=$_rebased_binaries_list",
+ ]
+ if (defined(invoker.extra_files)) {
+ _rebased_extra_files = rebase_path(invoker.extra_files, root_build_dir)
+ args += [ "--files=$_rebased_extra_files" ]
+ }
+
+ deps = [
+ ":$_find_deps_target_name",
+ ]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ }
+}
+
+# Writes a script to root_out_dir/bin that passes --output-directory to the
+# wrapped script, in addition to forwarding arguments. Most / all of these
+# wrappers should be made deps of //tools/android:android_tools.
+#
+# Variables
+# target: Script to wrap.
+# flag_name: Default is "--output-directory"
+#
+# Example
+# wrapper_script("foo_wrapper") {
+# target = "//pkg/foo.py"
+# }
+template("wrapper_script") {
+ action(target_name) {
+ _name = get_path_info(invoker.target, "name")
+ _output = "$root_out_dir/bin/$_name"
+
+ script = "//build/android/gyp/create_tool_wrapper.py"
+ outputs = [
+ _output,
+ ]
+
+ # The target isn't actually used by the script, but it's nice to have GN
+ # check that it exists.
+ inputs = [
+ invoker.target,
+ ]
+ args = [
+ "--output",
+ rebase_path(_output, root_build_dir),
+ "--target",
+ rebase_path(invoker.target, root_build_dir),
+ "--output-directory",
+ rebase_path(root_out_dir, root_build_dir),
+ ]
+ if (defined(invoker.flag_name)) {
+ args += [ "--flag-name=${invoker.flag_name}" ]
+ }
+ }
+}
+
+if (enable_java_templates) {
+ import("//build/config/sanitizers/sanitizers.gni")
+
+ if (!build_with_mozilla) {
+ import("//tools/grit/grit_rule.gni")
+ }
+
+ # Declare a jni target
+ #
+ # This target generates the native jni bindings for a set of .java files.
+ #
+ # See base/android/jni_generator/jni_generator.py for more info about the
+ # format of generating JNI bindings.
+ #
+ # Variables
+ # sources: list of .java files to generate jni for
+ # jni_package: subdirectory path for generated bindings
+ #
+ # Example
+ # generate_jni("foo_jni") {
+ # sources = [
+ # "android/java/src/org/chromium/foo/Foo.java",
+ # "android/java/src/org/chromium/foo/FooUtil.java",
+ # ]
+ # jni_package = "foo"
+ # }
+ template("generate_jni") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ assert(defined(invoker.sources))
+ assert(defined(invoker.jni_package))
+ jni_package = invoker.jni_package
+ base_output_dir = "${target_gen_dir}/${target_name}"
+ package_output_dir = "${base_output_dir}/${jni_package}"
+ jni_output_dir = "${package_output_dir}/jni"
+
+ jni_generator_include =
+ "//base/android/jni_generator/jni_generator_helper.h"
+
+ foreach_target_name = "${target_name}__jni_gen"
+ action_foreach(foreach_target_name) {
+ script = "//base/android/jni_generator/jni_generator.py"
+ depfile = "$target_gen_dir/$target_name.{{source_name_part}}.d"
+ sources = invoker.sources
+ outputs = [
+ "${jni_output_dir}/{{source_name_part}}_jni.h",
+ ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--input_file={{source}}",
+ "--optimize_generation=1",
+ "--ptr_type=long",
+ "--output_dir",
+ rebase_path(jni_output_dir, root_build_dir),
+ "--includes",
+ rebase_path(jni_generator_include, jni_output_dir),
+ "--native_exports_optional",
+ ]
+
+ if (enable_profiling) {
+ args += [ "--enable_profiling" ]
+ }
+ }
+
+ config("jni_includes_${target_name}") {
+ # TODO(cjhopman): #includes should probably all be relative to
+ # base_output_dir. Remove that from this config once the includes are
+ # updated.
+ include_dirs = [
+ base_output_dir,
+ package_output_dir,
+ ]
+ }
+
+ group(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "public_deps",
+ "visibility",
+ ])
+ if (!defined(public_deps)) {
+ public_deps = []
+ }
+ public_deps += [ ":$foreach_target_name" ]
+ public_configs = [ ":jni_includes_${target_name}" ]
+ }
+ }
+
+ # Declare a jni target for a prebuilt jar
+ #
+ # This target generates the native jni bindings for a set of classes in a .jar.
+ #
+ # See base/android/jni_generator/jni_generator.py for more info about the
+ # format of generating JNI bindings.
+ #
+ # Variables
+ # classes: list of .class files in the jar to generate jni for. These should
+ # include the full path to the .class file.
+ # jni_package: subdirectory path for generated bindings
+ # jar_file: the path to the .jar. If not provided, will default to the sdk's
+ # android.jar
+ #
+ # deps, public_deps: As normal
+ #
+ # Example
+ # generate_jar_jni("foo_jni") {
+ # classes = [
+ # "android/view/Foo.class",
+ # ]
+ # jni_package = "foo"
+ # }
+ template("generate_jar_jni") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ assert(defined(invoker.classes))
+ assert(defined(invoker.jni_package))
+
+ if (defined(invoker.jar_file)) {
+ jar_file = invoker.jar_file
+ } else {
+ jar_file = android_sdk_jar
+ }
+
+ jni_package = invoker.jni_package
+ base_output_dir = "${root_gen_dir}/${target_name}/${jni_package}"
+ jni_output_dir = "${base_output_dir}/jni"
+
+ jni_generator_include =
+ "//base/android/jni_generator/jni_generator_helper.h"
+
+ # TODO(cjhopman): make jni_generator.py support generating jni for multiple
+ # .class files from a .jar.
+ jni_actions = []
+ foreach(class, invoker.classes) {
+ _classname_list = []
+ _classname_list = process_file_template([ class ], "{{source_name_part}}")
+ classname = _classname_list[0]
+ jni_target_name = "${target_name}__jni_${classname}"
+ jni_actions += [ ":$jni_target_name" ]
+ action(jni_target_name) {
+ # The sources aren't compiled so don't check their dependencies.
+ check_includes = false
+ depfile = "$target_gen_dir/$target_name.d"
+ script = "//base/android/jni_generator/jni_generator.py"
+ sources = [
+ jar_file,
+ ]
+ outputs = [
+ "${jni_output_dir}/${classname}_jni.h",
+ ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--jar_file",
+ rebase_path(jar_file, root_build_dir),
+ "--input_file",
+ class,
+ "--optimize_generation=1",
+ "--ptr_type=long",
+ "--output_dir",
+ rebase_path(jni_output_dir, root_build_dir),
+ "--includes",
+ rebase_path(jni_generator_include, jni_output_dir),
+ "--native_exports_optional",
+ ]
+
+ if (enable_profiling) {
+ args += [ "--enable_profiling" ]
+ }
+ }
+ }
+
+ config("jni_includes_${target_name}") {
+ include_dirs = [ base_output_dir ]
+ }
+
+ group(target_name) {
+ public_deps = []
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "public_deps",
+ "visibility",
+ ])
+ public_deps += jni_actions
+ public_configs = [ ":jni_includes_${target_name}" ]
+ }
+ }
+
+ # Declare a target for c-preprocessor-generated java files
+ #
+ # NOTE: For generating Java conterparts to enums prefer using the java_cpp_enum
+ # rule instead.
+ #
+ # This target generates java files using the host C pre-processor. Each file in
+ # sources will be compiled using the C pre-processor. If include_path is
+ # specified, it will be passed (with --I) to the pre-processor.
+ #
+ # This target will create a single .srcjar. Adding this target to an
+ # android_library target's srcjar_deps will make the generated java files be
+ # included in that library's final outputs.
+ #
+ # Variables
+ # sources: list of files to be processed by the C pre-processor. For each
+ # file in sources, there will be one .java file in the final .srcjar. For a
+ # file named FooBar.template, a java file will be created with name
+ # FooBar.java.
+ # inputs: additional compile-time dependencies. Any files
+ # `#include`-ed in the templates should be listed here.
+ # package_path: this will be the subdirectory for each .java file in the
+ # .srcjar.
+ #
+ # Example
+ # java_cpp_template("foo_generated_enum") {
+ # sources = [
+ # "android/java/templates/Foo.template",
+ # ]
+ # inputs = [
+ # "android/java/templates/native_foo_header.h",
+ # ]
+ #
+ # package_path = "org/chromium/base/library_loader"
+ # include_path = "android/java/templates"
+ # }
+ template("java_cpp_template") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ _include_path = "//"
+ if (defined(invoker.include_path)) {
+ _include_path = invoker.include_path
+ }
+
+ _apply_gcc_target_name = "${target_name}__apply_gcc"
+ _base_gen_dir = "${target_gen_dir}/${target_name}/java_cpp_template"
+
+ if (defined(invoker.package_path)) {
+ package_path = invoker.package_path
+ } else {
+ # TODO(jbudorick): Back this out once all clients have been switched to
+ # package_path.
+ assert(defined(invoker.package_name))
+ package_path = invoker.package_name
+ }
+
+ action_foreach(_apply_gcc_target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "public_deps",
+ "data_deps",
+ ])
+ script = "//build/android/gyp/gcc_preprocess.py"
+ if (defined(invoker.inputs)) {
+ inputs = invoker.inputs + []
+ }
+ depfile =
+ "${target_gen_dir}/${invoker.target_name}_{{source_name_part}}.d"
+
+ sources = invoker.sources
+
+ outputs = [
+ "$_base_gen_dir/${package_path}/{{source_name_part}}.java",
+ ]
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--include-path",
+ rebase_path(_include_path, root_build_dir),
+ "--output",
+ rebase_path(outputs[0], root_build_dir),
+ "--template={{source}}",
+ ]
+
+ if (defined(invoker.defines)) {
+ foreach(def, invoker.defines) {
+ args += [
+ "--defines",
+ def,
+ ]
+ }
+ }
+ }
+
+ # Filter out .d files.
+ set_sources_assignment_filter([ "*.d" ])
+ sources = get_target_outputs(":$_apply_gcc_target_name")
+
+ zip(target_name) {
+ forward_variables_from(invoker, [ "visibility" ])
+ inputs = sources
+ output = "${target_gen_dir}/${target_name}.srcjar"
+ base_dir = _base_gen_dir
+ deps = [
+ ":$_apply_gcc_target_name",
+ ]
+ }
+ }
+
+ # Declare a target for generating Java classes from C++ enums.
+ #
+ # This target generates Java files from C++ enums using a script.
+ #
+ # This target will create a single .srcjar. Adding this target to an
+ # android_library target's srcjar_deps will make the generated java files be
+ # included in that library's final outputs.
+ #
+ # Variables
+ # sources: list of files to be processed by the script. For each annotated
+ # enum contained in the sources files the script will generate a .java
+ # file with the same name as the name of the enum.
+ #
+ # Example
+ # java_cpp_enum("foo_generated_enum") {
+ # sources = [
+ # "src/native_foo_header.h",
+ # ]
+ # }
+ template("java_cpp_enum") {
+ action(target_name) {
+ # The sources aren't compiled so don't check their dependencies.
+ check_includes = false
+ set_sources_assignment_filter([])
+
+ assert(defined(invoker.sources))
+ forward_variables_from(invoker,
+ [
+ "sources",
+ "testonly",
+ "visibility",
+ ])
+
+ script = "//build/android/gyp/java_cpp_enum.py"
+ depfile = "$target_gen_dir/$target_name.d"
+
+ _srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
+ _rebased_srcjar_path = rebase_path(_srcjar_path, root_build_dir)
+ _rebased_sources = rebase_path(invoker.sources, root_build_dir)
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--srcjar=$_rebased_srcjar_path",
+ ] + _rebased_sources
+ outputs = [
+ _srcjar_path,
+ ]
+ }
+ }
+
+ # Declare a target for processing a Jinja template.
+ #
+ # Variables
+ # input: The template file to be processed.
+ # output: Where to save the result.
+ # variables: (Optional) A list of variables to make available to the template
+ # processing environment, e.g. ["name=foo", "color=red"].
+ #
+ # Example
+ # jinja_template("chrome_public_manifest") {
+ # input = "java/AndroidManifest.xml"
+ # output = "$target_gen_dir/AndroidManifest.xml"
+ # }
+ template("jinja_template") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ assert(defined(invoker.input))
+ assert(defined(invoker.output))
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "deps",
+ ])
+
+ sources = [
+ invoker.input,
+ ]
+ script = "//build/android/gyp/jinja_template.py"
+ depfile = "$target_gen_dir/$target_name.d"
+
+ outputs = [
+ invoker.output,
+ ]
+
+ args = [
+ "--loader-base-dir",
+ rebase_path("//", root_build_dir),
+ "--inputs",
+ rebase_path(invoker.input, root_build_dir),
+ "--output",
+ rebase_path(invoker.output, root_build_dir),
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ ]
+ if (defined(invoker.variables)) {
+ variables = invoker.variables
+ args += [ "--variables=${variables}" ]
+ }
+ }
+ }
+
+ # Declare a target for processing Android resources as Jinja templates.
+ #
+ # This takes an Android resource directory where each resource is a Jinja
+ # template, processes each template, then packages the results in a zip file
+ # which can be consumed by an android resources, library, or apk target.
+ #
+ # If this target is included in the deps of an android resources/library/apk,
+ # the resources will be included with that target.
+ #
+ # Variables
+ # resources: The list of resources files to process.
+ # res_dir: The resource directory containing the resources.
+ # variables: (Optional) A list of variables to make available to the template
+ # processing environment, e.g. ["name=foo", "color=red"].
+ #
+ # Example
+ # jinja_template_resources("chrome_public_template_resources") {
+ # res_dir = "res_template"
+ # resources = ["res_template/xml/syncable.xml"]
+ # variables = ["color=red"]
+ # }
+ template("jinja_template_resources") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ assert(defined(invoker.resources))
+ assert(defined(invoker.res_dir))
+
+ _base_path = "$target_gen_dir/$target_name"
+
+ # JUnit tests use resource zip files. These must not be put in gen/
+ # directory or they will not be available to tester bots.
+ _resources_zip_rebased_path = rebase_path(target_gen_dir, root_gen_dir)
+ _resources_zip = "${root_out_dir}/resource_zips/${_resources_zip_rebased_path}/${target_name}.resources.zip"
+ _build_config = _base_path + ".build_config"
+
+ write_build_config("${target_name}__build_config") {
+ build_config = _build_config
+ resources_zip = _resources_zip
+ type = "android_resources"
+ if (defined(invoker.deps)) {
+ possible_config_deps = invoker.deps
+ }
+ }
+
+ action("${target_name}__template") {
+ forward_variables_from(invoker, [ "deps" ])
+ sources = invoker.resources
+ script = "//build/android/gyp/jinja_template.py"
+ depfile = "$target_gen_dir/$target_name.d"
+
+ outputs = [
+ _resources_zip,
+ ]
+
+ rebased_resources = rebase_path(invoker.resources, root_build_dir)
+ args = [
+ "--inputs=${rebased_resources}",
+ "--inputs-base-dir",
+ rebase_path(invoker.res_dir, root_build_dir),
+ "--outputs-zip",
+ rebase_path(_resources_zip, root_build_dir),
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ ]
+ if (defined(invoker.variables)) {
+ variables = invoker.variables
+ args += [ "--variables=${variables}" ]
+ }
+ }
+
+ group(target_name) {
+ public_deps = [
+ ":${target_name}__build_config",
+ ":${target_name}__template",
+ ]
+ }
+ }
+
+ # Declare an Android resources target
+ #
+ # This creates a resources zip file that will be used when building an Android
+ # library or apk and included into a final apk.
+ #
+ # To include these resources in a library/apk, this target should be listed in
+ # the library's deps. A library/apk will also include any resources used by its
+ # own dependencies.
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target. Any Android resources
+ # listed in deps will be included by libraries/apks that depend on this
+ # target.
+ # resource_dirs: List of directories containing resources for this target.
+ # generated_resource_dirs: List of directories containing resources for this
+ # target which are *generated* by a dependency. |generated_resource_files|
+ # must be specified if |generated_resource_dirs| is specified.
+ # generated_resource_files: List of all files in |generated_resource_dirs|.
+ # |generated_resource_dirs| must be specified in |generated_resource_files|
+ # is specified.
+ # android_manifest: AndroidManifest.xml for this target. Defaults to
+ # //build/android/AndroidManifest.xml.
+ # android_manifest_dep: Target that generates AndroidManifest (if applicable)
+ # custom_package: java package for generated .java files.
+ # v14_skip: If true, don't run v14 resource generator on this. Defaults to
+ # false. (see build/android/gyp/generate_v14_compatible_resources.py)
+ # shared_resources: If true make a resource package that can be loaded by a
+ # different application at runtime to access the package's resources.
+ # app_as_shared_lib: If true make a resource package that can be loaded as
+ # both shared_resources and normal application.
+ # r_text_file: (optional) path to pre-generated R.txt to be used when
+ # generating R.java instead of resource-based aapt-generated one.
+
+ # Example:
+ # android_resources("foo_resources") {
+ # deps = [":foo_strings_grd"]
+ # resource_dirs = ["res"]
+ # custom_package = "org.chromium.foo"
+ # }
+ #
+ # android_resources("foo_resources_overrides") {
+ # deps = [":foo_resources"]
+ # resource_dirs = ["res_overrides"]
+ # }
+ template("android_resources") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ assert(defined(invoker.resource_dirs))
+
+ base_path = "$target_gen_dir/$target_name"
+
+ # JUnit tests use resource zip files. These must not be put in gen/
+ # directory or they will not be available to tester bots.
+ _resources_zip_rebased_path = rebase_path(target_gen_dir, root_gen_dir)
+ zip_path = "${root_out_dir}/resource_zips/${_resources_zip_rebased_path}/${target_name}.resources.zip"
+ srcjar_path = base_path + ".srcjar"
+ r_text_out_path = base_path + "_R.txt"
+ build_config = base_path + ".build_config"
+
+ build_config_target_name = "${target_name}__build_config"
+ process_resources_target_name = "${target_name}__process_resources"
+ final_target_name = target_name
+
+ write_build_config(build_config_target_name) {
+ type = "android_resources"
+ forward_variables_from(invoker,
+ [
+ "android_manifest",
+ "custom_package",
+ ])
+ resource_dirs = []
+ if (defined(invoker.resource_dirs)) {
+ resource_dirs += invoker.resource_dirs
+ }
+ if (defined(invoker.generated_resource_dirs)) {
+ resource_dirs += invoker.generated_resource_dirs
+ }
+
+ if (defined(invoker.deps)) {
+ possible_config_deps = invoker.deps
+ }
+ if (defined(invoker.android_manifest_dep)) {
+ deps = [
+ invoker.android_manifest_dep,
+ ]
+ }
+
+ # No package means resources override their deps.
+ if (defined(custom_package) || defined(android_manifest)) {
+ r_text = r_text_out_path
+ } else {
+ assert(defined(invoker.deps),
+ "Must specify deps when custom_package is omitted.")
+ }
+
+ resources_zip = zip_path
+ srcjar = srcjar_path
+ }
+
+ process_resources(process_resources_target_name) {
+ forward_variables_from(invoker,
+ [
+ "app_as_shared_lib",
+ "android_manifest",
+ "custom_package",
+ "deps",
+ "generated_resource_dirs",
+ "generated_resource_files",
+ "resource_dirs",
+ "shared_resources",
+ "v14_skip",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$build_config_target_name" ]
+ if (defined(invoker.android_manifest_dep)) {
+ deps += [ invoker.android_manifest_dep ]
+ }
+
+ if (defined(invoker.r_text_file)) {
+ r_text_in_path = invoker.r_text_file
+ }
+
+ # Always generate R.onResourcesLoaded() method, it is required for
+ # compiling ResourceRewriter, there is no side effect because the
+ # generated R.class isn't used in final apk.
+ shared_resources = true
+ if (!defined(android_manifest)) {
+ android_manifest = "//build/android/AndroidManifest.xml"
+ }
+ }
+
+ group(final_target_name) {
+ forward_variables_from(invoker, [ "visibility" ])
+ public_deps = [
+ ":${target_name}__process_resources",
+ ]
+ }
+ }
+
+ # Declare an Android assets target.
+ #
+ # Defines a set of files to include as assets in a dependent apk.
+ #
+ # To include these assets in an apk, this target should be listed in
+ # the apk's deps, or in the deps of a library target used by an apk.
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target. Any Android assets
+ # listed in deps will be included by libraries/apks that depend on this
+ # target.
+ # sources: List of files to include as assets.
+ # renaming_sources: List of files to include as assets and be renamed.
+ # renaming_destinations: List of asset paths for files in renaming_sources.
+ # disable_compression: Whether to disable compression for files that are
+ # known to be compressable (default: false).
+ #
+ # Example:
+ # android_assets("content_shell_assets") {
+ # deps = [
+ # ":generates_foo",
+ # ":other_assets",
+ # ]
+ # sources = [
+ # "//path/asset1.png",
+ # "//path/asset2.png",
+ # "$target_gen_dir/foo.dat",
+ # ]
+ # }
+ #
+ # android_assets("overriding_content_shell_assets") {
+ # deps = [ ":content_shell_assets" ]
+ # # Override foo.dat from content_shell_assets.
+ # sources = [ "//custom/foo.dat" ]
+ # renaming_sources = [ "//path/asset2.png" ]
+ # renaming_destinations = [ "renamed/asset2.png" ]
+ # }
+ template("android_assets") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ _build_config = "$target_gen_dir/$target_name.build_config"
+ _build_config_target_name = "${target_name}__build_config"
+
+ write_build_config(_build_config_target_name) {
+ type = "android_assets"
+ build_config = _build_config
+
+ forward_variables_from(invoker, [ "disable_compression" ])
+
+ if (defined(invoker.deps)) {
+ possible_config_deps = invoker.deps
+ }
+
+ if (defined(invoker.sources)) {
+ asset_sources = invoker.sources
+ }
+ if (defined(invoker.renaming_sources)) {
+ assert(defined(invoker.renaming_destinations))
+ _source_count = 0
+ foreach(_, invoker.renaming_sources) {
+ _source_count += 1
+ }
+ _dest_count = 0
+ foreach(_, invoker.renaming_destinations) {
+ _dest_count += 1
+ }
+ assert(
+ _source_count == _dest_count,
+ "android_assets() renaming_sources.length != renaming_destinations.length")
+ asset_renaming_sources = invoker.renaming_sources
+ asset_renaming_destinations = invoker.renaming_destinations
+ }
+ }
+
+ group(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "visibility",
+ ])
+ public_deps = [
+ ":$_build_config_target_name",
+ ]
+ }
+ }
+
+ # Declare a group() that supports forwarding java dependency information.
+ #
+ # Example
+ # java_group("conditional_deps") {
+ # if (enable_foo) {
+ # deps = [":foo_java"]
+ # }
+ # }
+ template("java_group") {
+ forward_variables_from(invoker, [ "testonly" ])
+ write_build_config("${target_name}__build_config") {
+ type = "group"
+ build_config = "$target_gen_dir/${invoker.target_name}.build_config"
+ if (defined(invoker.deps)) {
+ possible_config_deps = invoker.deps
+ }
+ }
+ group(target_name) {
+ forward_variables_from(invoker, "*")
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":${target_name}__build_config" ]
+ }
+ }
+
+ # Declare a target that generates localized strings.xml from a .grd file.
+ #
+ # If this target is included in the deps of an android resources/library/apk,
+ # the strings.xml will be included with that target.
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target.
+ # grd_file: Path to the .grd file to generate strings.xml from.
+ # outputs: Expected grit outputs (see grit rule).
+ #
+ # Example
+ # java_strings_grd("foo_strings_grd") {
+ # grd_file = "foo_strings.grd"
+ # }
+ template("java_strings_grd") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ base_path = "$target_gen_dir/$target_name"
+
+ # JUnit tests use resource zip files. These must not be put in gen/
+ # directory or they will not be available to tester bots.
+ _resources_zip_rebased_path = rebase_path(target_gen_dir, root_gen_dir)
+ resources_zip = "${root_out_dir}/resource_zips/${_resources_zip_rebased_path}/${target_name}.resources.zip"
+ build_config = base_path + ".build_config"
+
+ write_build_config("${target_name}__build_config") {
+ type = "android_resources"
+ }
+
+ # Put grit files into this subdirectory of target_gen_dir.
+ extra_output_path = target_name + "_grit_output"
+
+ grit_target_name = "${target_name}__grit"
+ grit_output_dir = "$target_gen_dir/$extra_output_path"
+
+ grit(grit_target_name) {
+ forward_variables_from(invoker, [ "deps" ])
+ grit_flags = [
+ "-E",
+ "ANDROID_JAVA_TAGGED_ONLY=false",
+ ]
+ output_dir = grit_output_dir
+ resource_ids = ""
+ source = invoker.grd_file
+ outputs = invoker.outputs
+ }
+
+ # This needs to get outputs from grit's internal target, not the final
+ # source_set.
+ generate_strings_outputs = get_target_outputs(":${grit_target_name}_grit")
+
+ zip("${target_name}__zip") {
+ base_dir = grit_output_dir
+ inputs = generate_strings_outputs
+ output = resources_zip
+ deps = [
+ ":$grit_target_name",
+ ]
+ }
+
+ group(target_name) {
+ public_deps = [
+ ":${target_name}__build_config",
+ ":${target_name}__zip",
+ ]
+ }
+ }
+
+ # Declare a target that packages strings.xml generated from a grd file.
+ #
+ # If this target is included in the deps of an android resources/library/apk,
+ # the strings.xml will be included with that target.
+ #
+ # Variables
+ # grit_output_dir: directory containing grit-generated files.
+ # generated_files: list of android resource files to package.
+ #
+ # Example
+ # java_strings_grd_prebuilt("foo_strings_grd") {
+ # grit_output_dir = "$root_gen_dir/foo/grit"
+ # generated_files = [
+ # "values/strings.xml"
+ # ]
+ # }
+ template("java_strings_grd_prebuilt") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ base_path = "$target_gen_dir/$target_name"
+
+ # JUnit tests use resource zip files. These must not be put in gen/
+ # directory or they will not be available to tester bots.
+ _resources_zip_rebased_path = rebase_path(target_gen_dir, root_gen_dir)
+ resources_zip = "${root_out_dir}/resource_zips/${_resources_zip_rebased_path}/${target_name}.resources.zip"
+ build_config = base_path + ".build_config"
+
+ build_config_target_name = "${target_name}__build_config"
+ zip_target_name = "${target_name}__zip"
+ final_target_name = target_name
+
+ write_build_config(build_config_target_name) {
+ type = "android_resources"
+ }
+
+ zip(zip_target_name) {
+ visibility = [ ":$final_target_name" ]
+
+ base_dir = invoker.grit_output_dir
+ inputs = rebase_path(invoker.generated_files, ".", base_dir)
+ output = resources_zip
+ deps = [
+ ":$build_config_target_name",
+ ]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ }
+
+ group(final_target_name) {
+ forward_variables_from(invoker, [ "visibility" ])
+ public_deps = [
+ ":$zip_target_name",
+ ]
+ }
+ }
+
+ # Declare a Java executable target
+ #
+ # This target creates an executable from java code and libraries. The executable
+ # will be in the output folder's /bin/ directory.
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target. Java targets in this list
+ # will be included in the executable (and the javac classpath).
+ # java_files: List of .java files included in this library.
+ # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
+ # will be added to java_files and be included in this library.
+ # srcjars: List of srcjars to be included in this library, together with the
+ # ones obtained from srcjar_deps.
+ # bypass_platform_checks: Disables checks about cross-platform (Java/Android)
+ # dependencies for this target. This will allow depending on an
+ # android_library target, for example.
+ # chromium_code: If true, extra analysis warning/errors will be enabled.
+ # enable_errorprone: If true, enables the errorprone compiler.
+ # enable_incremental_javac_override: Overrides the
+ # global enable_incremental_javac.
+ # main_class: When specified, a wrapper script is created within
+ # $root_build_dir/bin to launch the binary with the given class as the
+ # entrypoint.
+ # wrapper_script_args: List of additional arguments for the wrapper script.
+ #
+ # data_deps, testonly
+ #
+ # Example
+ # java_binary("foo") {
+ # java_files = [ "org/chromium/foo/FooMain.java" ]
+ # deps = [ ":bar_java" ]
+ # main_class = "org.chromium.foo.FooMain"
+ # }
+ template("java_binary") {
+ set_sources_assignment_filter([])
+
+ java_library_impl(target_name) {
+ forward_variables_from(invoker, "*")
+ supports_android = false
+ main_class = invoker.main_class
+ is_java_binary = true
+ }
+ }
+
+ # Declare a Junit executable target
+ #
+ # This target creates an executable from java code for running as a junit test
+ # suite. The executable will be in the output folder's /bin/ directory.
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target. Java targets in this list
+ # will be included in the executable (and the javac classpath).
+ #
+ # java_files: List of .java files included in this library.
+ # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
+ # will be added to java_files and be included in this library.
+ # srcjars: List of srcjars to be included in this library, together with the
+ # ones obtained from srcjar_deps.
+ #
+ # chromium_code: If true, extra analysis warning/errors will be enabled.
+ #
+ # Example
+ # junit_binary("foo") {
+ # java_files = [ "org/chromium/foo/FooTest.java" ]
+ # deps = [ ":bar_java" ]
+ # }
+ template("junit_binary") {
+ set_sources_assignment_filter([])
+ testonly = true
+
+ _java_binary_target_name = "${target_name}__java_binary"
+ _test_runner_target_name = "${target_name}__test_runner_script"
+
+ _build_config = "$target_gen_dir/$target_name.build_config"
+ _build_config_target_name = "${target_name}__build_config"
+ write_build_config(_build_config_target_name) {
+ type = "junit_binary"
+ build_config = _build_config
+ if (defined(invoker.deps)) {
+ possible_config_deps = invoker.deps
+ }
+ }
+
+ test_runner_script(_test_runner_target_name) {
+ test_name = invoker.target_name
+ test_suite = invoker.target_name
+ test_type = "junit"
+ ignore_all_data_deps = true
+ forward_variables_from(invoker,
+ [
+ "android_manifest_path",
+ "package_name",
+ ])
+ }
+
+ java_binary(_java_binary_target_name) {
+ deps = []
+ output_name = invoker.target_name
+ forward_variables_from(invoker, "*")
+ testonly = true
+ bypass_platform_checks = true
+ main_class = "org.chromium.testing.local.JunitTestMain"
+ wrapper_script_name = "helper/$target_name"
+ deps += [
+ "//testing/android/junit:junit_test_support",
+ "//third_party/junit",
+ "//third_party/mockito:mockito_java",
+ "//third_party/robolectric:robolectric_all_java",
+ ]
+ }
+ group(target_name) {
+ public_deps = [
+ ":$_build_config_target_name",
+ ":$_java_binary_target_name",
+ ":$_test_runner_target_name",
+ ]
+ }
+ }
+
+ # Declare a java library target
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target. Java targets in this list
+ # will be added to the javac classpath.
+ #
+ # java_files: List of .java files included in this library.
+ # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
+ # will be added to java_files and be included in this library.
+ # srcjars: List of srcjars to be included in this library, together with the
+ # ones obtained from srcjar_deps.
+ #
+ # input_jars_paths: A list of paths to the jars that should be included
+ # in the classpath. These are in addition to library .jars that
+ # appear in deps.
+ #
+ # chromium_code: If true, extra analysis warning/errors will be enabled.
+ # enable_errorprone: If true, enables the errorprone compiler.
+ # enable_incremental_javac_override: Overrides the global
+ # enable_incremental_javac.
+ #
+ # jar_excluded_patterns: List of patterns of .class files to exclude from the
+ # final jar.
+ #
+ # output_name: File name for the output .jar (not including extension).
+ # Defaults to the input .jar file name.
+ #
+ # proguard_configs: List of proguard configs to use in final apk step for
+ # any apk that depends on this library.
+ #
+ # supports_android: If true, Android targets (android_library, android_apk)
+ # may depend on this target. Note: if true, this target must only use the
+ # subset of Java available on Android.
+ # bypass_platform_checks: Disables checks about cross-platform (Java/Android)
+ # dependencies for this target. This will allow depending on an
+ # android_library target, for example.
+ #
+ # additional_jar_files: Use to package additional files into the output jar.
+ # Pass a list of length-2 lists with format
+ # [ [ path_to_file, path_to_put_in_jar ] ]
+ #
+ #
+ # data_deps, testonly
+ #
+ # Example
+ # java_library("foo_java") {
+ # java_files = [
+ # "org/chromium/foo/Foo.java",
+ # "org/chromium/foo/FooInterface.java",
+ # "org/chromium/foo/FooService.java",
+ # ]
+ # deps = [
+ # ":bar_java"
+ # ]
+ # srcjar_deps = [
+ # ":foo_generated_enum"
+ # ]
+ # jar_excluded_patterns = [
+ # "*/FooService.class", "*/FooService\$*.class"
+ # ]
+ # }
+ template("java_library") {
+ set_sources_assignment_filter([])
+ java_library_impl(target_name) {
+ forward_variables_from(invoker, "*")
+ }
+ }
+
+ # Declare a java library target for a prebuilt jar
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target. Java targets in this list
+ # will be added to the javac classpath.
+ # jar_path: Path to the prebuilt jar.
+ # jar_dep: Target that builds jar_path (optional).
+ # main_class: When specified, a wrapper script is created within
+ # $root_build_dir/bin to launch the binary with the given class as the
+ # entrypoint.
+ # output_name: File name for the output .jar (not including extension).
+ # Defaults to the input .jar file name.
+ # proguard_configs: List of proguard configs to use in final apk step for
+ # any apk that depends on this library.
+ # supports_android: If true, Android targets (android_library, android_apk)
+ # may depend on this target. Note: if true, this target must only use the
+ # subset of Java available on Android.
+ #
+ # Example
+ # java_prebuilt("foo_java") {
+ # jar_path = "foo.jar"
+ # deps = [
+ # ":foo_resources",
+ # ":bar_java"
+ # ]
+ # }
+ template("java_prebuilt") {
+ set_sources_assignment_filter([])
+ java_prebuilt_impl(target_name) {
+ forward_variables_from(invoker, "*")
+ }
+ }
+
+ # Combines all dependent .jar files into a single .jar file.
+ #
+ # Variables:
+ # output: Path to the output jar.
+ # override_build_config: Use a pre-existing .build_config. Must be of type
+ # "apk".
+ # use_interface_jars: Use all dependent interface .jars rather than
+ # implementation .jars.
+ # direct_deps_only: Do not recurse on deps.
+ # data, deps, testonly, visibility: Usual meaning.
+ #
+ # Example
+ # dist_jar("lib_fatjar") {
+ # deps = [ ":my_java_lib" ]
+ # }
+ template("dist_jar") {
+ if (defined(invoker.override_build_config)) {
+ _build_config = invoker.override_build_config
+ } else {
+ _build_config = "$target_gen_dir/$target_name.build_config"
+ _build_config_target_name = "${target_name}__build_config"
+
+ write_build_config(_build_config_target_name) {
+ forward_variables_from(invoker, [ "testonly" ])
+ type = "dist_jar"
+ if (defined(invoker.deps)) {
+ possible_config_deps = invoker.deps
+ }
+ build_config = _build_config
+ }
+ }
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "data",
+ "deps",
+ "testonly",
+ "visibility",
+ ])
+ script = "//build/android/gyp/create_dist_jar.py"
+ depfile = "$target_gen_dir/$target_name.d"
+
+ inputs = [
+ _build_config,
+ ]
+
+ outputs = [
+ invoker.output,
+ ]
+
+ if (defined(_build_config_target_name)) {
+ deps += [ ":$_build_config_target_name" ]
+ }
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--output",
+ rebase_path(invoker.output, root_build_dir),
+ ]
+
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ if (defined(invoker.direct_deps_only) && invoker.direct_deps_only) {
+ if (defined(invoker.use_interface_jars) && invoker.use_interface_jars) {
+ args += [ "--inputs=@FileArg($_rebased_build_config:javac:interface_classpath)" ]
+ } else {
+ args +=
+ [ "--inputs=@FileArg($_rebased_build_config:javac:classpath)" ]
+ }
+ } else {
+ if (defined(invoker.use_interface_jars) && invoker.use_interface_jars) {
+ args += [ "--inputs=@FileArg($_rebased_build_config:dist_jar:all_interface_jars)" ]
+ } else {
+ args += [ "--inputs=@FileArg($_rebased_build_config:dist_jar:dependency_jars)" ]
+ }
+ }
+ }
+ }
+
+ # Declare an Android library target
+ #
+ # This target creates an Android library containing java code and Android
+ # resources.
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target. Java targets in this list
+ # will be added to the javac classpath. Android resources in dependencies
+ # will be used when building this library.
+ #
+ # java_files: List of .java files included in this library.
+ # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
+ # will be added to java_files and be included in this library.
+ # srcjars: List of srcjars to be included in this library, together with the
+ # ones obtained from srcjar_deps.
+ #
+ # input_jars_paths: A list of paths to the jars that should be included
+ # in the classpath. These are in addition to library .jars that
+ # appear in deps.
+ #
+ # chromium_code: If true, extra analysis warning/errors will be enabled.
+ # enable_errorprone: If true, enables the errorprone compiler.
+ # enable_incremental_javac_override: Overrides the global
+ # enable_incremental_javac.
+ #
+ # jar_excluded_patterns: List of patterns of .class files to exclude from the
+ # final jar.
+ #
+ # proguard_configs: List of proguard configs to use in final apk step for
+ # any apk that depends on this library.
+ #
+ # output_name: File name for the output .jar (not including extension).
+ # Defaults to the input .jar file name.
+ # dex_path: If set, the resulting .dex.jar file will be placed under this
+ # path.
+ #
+ # alternative_android_sdk_ijar: if set, the given android_sdk_ijar file
+ # replaces the default android_sdk_ijar.
+ #
+ # alternative_android_sdk_ijar_dep: the target that generates
+ # alternative_android_sdk_ijar, must be set if alternative_android_sdk_ijar
+ # is used.
+ #
+ # emma_never_instrument: Disables EMMA Java code coverage for this target.
+ #
+ # Example
+ # android_library("foo_java") {
+ # java_files = [
+ # "android/org/chromium/foo/Foo.java",
+ # "android/org/chromium/foo/FooInterface.java",
+ # "android/org/chromium/foo/FooService.java",
+ # ]
+ # deps = [
+ # ":bar_java"
+ # ]
+ # srcjar_deps = [
+ # ":foo_generated_enum"
+ # ]
+ # jar_excluded_patterns = [
+ # "*/FooService.class", "*/FooService\$*.class"
+ # ]
+ # }
+ template("android_library") {
+ set_sources_assignment_filter([])
+ assert(!defined(invoker.jar_path),
+ "android_library does not support a custom jar path")
+
+ if (defined(invoker.alternative_android_sdk_ijar)) {
+ assert(defined(invoker.alternative_android_sdk_ijar_dep))
+ }
+
+ java_library_impl(target_name) {
+ forward_variables_from(invoker, "*")
+
+ supports_android = true
+ requires_android = true
+
+ if (!defined(jar_excluded_patterns)) {
+ jar_excluded_patterns = []
+ }
+ jar_excluded_patterns += [
+ "*/R.class",
+ "*/R\$*.class",
+ "*/Manifest.class",
+ "*/Manifest\$*.class",
+ ]
+ }
+ }
+
+ # Declare a target that packages a set of Java dependencies into a standalone
+ # .dex.jar.
+ #
+ # Variables
+ # deps: specifies the dependencies of this target. Android libraries in deps
+ # will be packaged into the resulting .dex.jar file.
+ # dex_path: location at which the output file will be put
+ template("android_standalone_library") {
+ set_sources_assignment_filter([])
+ deps_dex(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "dex_path",
+ "excluded_jars",
+ ])
+ }
+ }
+
+ # Declare an Android library target for a prebuilt jar
+ #
+ # This target creates an Android library containing java code and Android
+ # resources.
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target. Java targets in this list
+ # will be added to the javac classpath. Android resources in dependencies
+ # will be used when building this library.
+ # jar_path: Path to the prebuilt jar.
+ # output_name: File name for the output .jar (not including extension).
+ # Defaults to the input .jar file name.
+ # proguard_configs: List of proguard configs to use in final apk step for
+ # any apk that depends on this library.
+ #
+ # Example
+ # android_java_prebuilt("foo_java") {
+ # jar_path = "foo.jar"
+ # deps = [
+ # ":foo_resources",
+ # ":bar_java"
+ # ]
+ # }
+ template("android_java_prebuilt") {
+ set_sources_assignment_filter([])
+ java_prebuilt_impl(target_name) {
+ forward_variables_from(invoker, "*")
+ supports_android = true
+ requires_android = true
+ strip_resource_classes = true
+ }
+ }
+
+ # Declare an Android apk target
+ #
+ # This target creates an Android APK containing java code, resources, assets,
+ # and (possibly) native libraries.
+ #
+ # Variables
+ # alternative_android_sdk_jar: The alternative android sdk jar used in
+ # proguard.
+ # android_aapt_path: Android aapt tool to replace default one to build
+ # resource.
+ # android_manifest: Path to AndroidManifest.xml.
+ # android_manifest_dep: Target that generates AndroidManifest (if applicable)
+ # chromium_code: If true, extra analysis warning/errors will be enabled.
+ # dist_ijar_path: Path to create "${target_name}_dist_ijar" target
+ # (used by instrumentation_test_apk).
+ # data_deps: List of dependencies needed at runtime. These will be built but
+ # won't change the generated .apk in any way (in fact they may be built
+ # after the .apk is).
+ # deps: List of dependencies. All Android java resources and libraries in the
+ # "transitive closure" of these dependencies will be included in the apk.
+ # Note: this "transitive closure" actually only includes such targets if
+ # they are depended on through android_library or android_resources targets
+ # (and so not through builtin targets like 'action', 'group', etc).
+ # install_script_name: Name of wrapper script (default=target_name).
+ # java_files: List of .java files to include in the apk.
+ # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
+ # will be added to java_files and be included in this apk.
+ # apk_name: Name for final apk.
+ # final_apk_path: Path to final built apk. Default is
+ # $root_out_dir/apks/$apk_name.apk. Setting this will override apk_name.
+ # loadable_modules: List of paths to native libraries to include. Different
+ # from |shared_libraries| in that:
+ # * dependencies of this .so are not automatically included
+ # * ".cr.so" is never added
+ # * they are not side-loaded for _incremental targets.
+ # * load_library_from_apk, use_chromium_linker,
+ # and enable_relocation_packing do not apply
+ # Use this instead of shared_libraries when you are going to load the library
+ # conditionally, and only when shared_libraries doesn't work for you.
+ # shared_libraries: List shared_library targets to bundle. If these
+ # libraries depend on other shared_library targets, those dependencies will
+ # also be included in the apk (e.g. for is_component_build).
+ # secondary_abi_shared_libraries: secondary abi shared_library targets to
+ # bundle. If these libraries depend on other shared_library targets, those
+ # dependencies will also be included in the apk (e.g. for is_component_build).
+ # native_lib_placeholders: List of placeholder filenames to add to the apk
+ # (optional).
+ # apk_under_test: For an instrumentation test apk, this is the target of the
+ # tested apk.
+ # include_all_resources - If true include all resource IDs in all generated
+ # R.java files.
+ # testonly: Marks this target as "test-only".
+ # write_asset_list: Adds an extra file to the assets, which contains a list of
+ # all other asset files.
+ # generate_buildconfig_java: If defined and false, skip generating the
+ # BuildConfig java class describing the build configuration. The default
+ # is true for non-test APKs.
+ # requires_sdk_api_level_23: If defined and true, the apk is intended for
+ # installation only on Android M or later. In these releases the system
+ # linker does relocation unpacking, so we can enable it unconditionally.
+ # secondary_native_libs (deprecated): The path of native libraries for secondary
+ # app abi.
+ # run_findbugs_override: Forces run_findbugs on or off. If undefined, the
+ # default will use the build arg run_findbugs.
+ # proguard_jar_path: The path to proguard.jar you wish to use. If undefined,
+ # the proguard used will be the checked in one in //third_party/proguard.
+ # never_incremental: If true, |incremental_apk_by_default| will be ignored.
+ # aapt_locale_whitelist: If set, all locales not in this list will be
+ # stripped from resources.arsc.
+ #
+ # Example
+ # android_apk("foo_apk") {
+ # android_manifest = "AndroidManifest.xml"
+ # java_files = [
+ # "android/org/chromium/foo/FooApplication.java",
+ # "android/org/chromium/foo/FooActivity.java",
+ # ]
+ # deps = [
+ # ":foo_support_java"
+ # ":foo_resources"
+ # ]
+ # srcjar_deps = [
+ # ":foo_generated_enum"
+ # ]
+ # shared_libraries = [
+ # ":my_shared_lib",
+ # ]
+ # }
+ template("android_apk") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ assert(defined(invoker.final_apk_path) || defined(invoker.apk_name))
+ assert(defined(invoker.android_manifest))
+ gen_dir = "$target_gen_dir/$target_name"
+ base_path = "$gen_dir/$target_name"
+ _build_config = "$target_gen_dir/$target_name.build_config"
+
+ # JUnit tests use resource zip files. These must not be put in gen/
+ # directory or they will not be available to tester bots.
+ _resources_zip_rebased_path = rebase_path(target_gen_dir, root_gen_dir)
+ resources_zip_path = "${root_out_dir}/resource_zips/${_resources_zip_rebased_path}/${target_name}.resources.zip"
+ _all_resources_zip_path = "$base_path.resources.all.zip"
+ _jar_path = "$base_path.jar"
+ _lib_dex_path = "$base_path.dex.jar"
+ _rebased_lib_dex_path = rebase_path(_lib_dex_path, root_build_dir)
+ _template_name = target_name
+ if (defined(invoker.java_files)) {
+ _java_sources_file = "$base_path.sources"
+ }
+
+ enable_multidex =
+ defined(invoker.enable_multidex) && invoker.enable_multidex
+ if (enable_multidex) {
+ final_dex_path = "$gen_dir/classes.dex.zip"
+ } else {
+ final_dex_path = "$gen_dir/classes.dex"
+ }
+ final_dex_target_name = "${_template_name}__final_dex"
+
+ _final_apk_path = ""
+ if (defined(invoker.final_apk_path)) {
+ _final_apk_path = invoker.final_apk_path
+ } else if (defined(invoker.apk_name)) {
+ _final_apk_path = "$root_build_dir/apks/" + invoker.apk_name + ".apk"
+ }
+ _final_apk_path_no_ext_list =
+ process_file_template([ _final_apk_path ],
+ "{{source_dir}}/{{source_name_part}}")
+ _final_apk_path_no_ext = _final_apk_path_no_ext_list[0]
+ assert(_final_apk_path_no_ext != "") # Mark as used.
+
+ _install_script_name = "install_$_template_name"
+ if (defined(invoker.install_script_name)) {
+ _install_script_name = invoker.install_script_name
+ }
+ _incremental_install_script_path =
+ "${root_out_dir}/bin/${_install_script_name}"
+ if (!incremental_apk_by_default) {
+ _incremental_install_script_path =
+ "${_incremental_install_script_path}_incremental"
+ }
+
+ _version_code = android_default_version_code
+ if (defined(invoker.version_code)) {
+ _version_code = invoker.version_code
+ }
+
+ _version_name = android_default_version_name
+ if (defined(invoker.version_name)) {
+ _version_name = invoker.version_name
+ }
+ _keystore_path = android_keystore_path
+ _keystore_name = android_keystore_name
+ _keystore_password = android_keystore_password
+
+ if (defined(invoker.keystore_path)) {
+ _keystore_path = invoker.keystore_path
+ _keystore_name = invoker.keystore_name
+ _keystore_password = invoker.keystore_password
+ }
+
+ _srcjar_deps = []
+ if (defined(invoker.srcjar_deps)) {
+ _srcjar_deps += invoker.srcjar_deps
+ }
+
+ _use_chromium_linker =
+ defined(invoker.use_chromium_linker) && invoker.use_chromium_linker
+ _enable_relocation_packing = defined(invoker.enable_relocation_packing) &&
+ invoker.enable_relocation_packing
+ _load_library_from_apk =
+ defined(invoker.load_library_from_apk) && invoker.load_library_from_apk
+ _requires_sdk_api_level_23 = defined(invoker.requires_sdk_api_level_23) &&
+ invoker.requires_sdk_api_level_23
+
+ assert(_use_chromium_linker || true) # Mark as used.
+ assert(_requires_sdk_api_level_23 || true)
+ if (_enable_relocation_packing) {
+ assert(_use_chromium_linker || _requires_sdk_api_level_23,
+ "enable_relocation_packing requires either use_chromium_linker " +
+ "or requires_sdk_api_level_23")
+ }
+ if (_load_library_from_apk) {
+ assert(_use_chromium_linker || _requires_sdk_api_level_23,
+ "load_library_from_apk requires use_chromium_linker " +
+ "or requires_sdk_api_level_23")
+ }
+
+ # The dependency that makes the chromium linker, if any is needed.
+ _native_libs_deps = []
+ _shared_libraries_is_valid =
+ defined(invoker.shared_libraries) && invoker.shared_libraries != []
+ _secondary_abi_native_libs_deps = []
+ assert(_secondary_abi_native_libs_deps == []) # mark as used.
+ _secondary_abi_shared_libraries_is_valid =
+ defined(invoker.secondary_abi_shared_libraries) &&
+ invoker.secondary_abi_shared_libraries != []
+
+ if (is_component_build || is_asan) {
+ if (_shared_libraries_is_valid) {
+ _native_libs_deps += [ "//build/android:cpplib_stripped" ]
+ }
+ if (_secondary_abi_shared_libraries_is_valid) {
+ _secondary_abi_native_libs_deps += [ "//build/android:cpplib_stripped($android_secondary_abi_toolchain)" ]
+ }
+ }
+
+ if (_shared_libraries_is_valid) {
+ _native_libs_deps += invoker.shared_libraries
+
+ # To determine the filenames of all dependent shared libraries, write the
+ # runtime deps of |shared_libraries| to a file during "gn gen".
+ # write_build_config.py will then grep this file for *.so to obtain the
+ # complete list.
+ _runtime_deps_file =
+ "$target_gen_dir/${_template_name}.native.runtimedeps"
+ group("${_template_name}__runtime_deps") {
+ deps = _native_libs_deps
+ write_runtime_deps = _runtime_deps_file
+ }
+
+ _native_lib_version_rule = ""
+ if (defined(invoker.native_lib_version_rule)) {
+ _native_lib_version_rule = invoker.native_lib_version_rule
+ }
+ _native_lib_version_arg = "\"\""
+ if (defined(invoker.native_lib_version_arg)) {
+ _native_lib_version_arg = invoker.native_lib_version_arg
+ }
+ }
+
+ if (_secondary_abi_shared_libraries_is_valid) {
+ _secondary_abi_native_libs_deps += invoker.secondary_abi_shared_libraries
+
+ # To determine the filenames of all dependent shared libraries, write the
+ # runtime deps of |shared_libraries| to a file during "gn gen".
+ # write_build_config.py will then grep this file for *.so to obtain the
+ # complete list.
+ _secondary_abi_runtime_deps_file =
+ "$target_gen_dir/${_template_name}.secondary.abi.native.runtimedeps"
+ group("${_template_name}_secondary_abi__runtime_deps") {
+ deps = _secondary_abi_native_libs_deps
+ write_runtime_deps = _secondary_abi_runtime_deps_file
+ }
+ }
+
+ if (defined(invoker.deps)) {
+ set_sources_assignment_filter([ "*manifest*" ])
+ sources = invoker.deps
+ set_sources_assignment_filter([])
+ if (sources != invoker.deps) {
+ _bad_deps = invoker.deps - sources
+ assert(
+ false,
+ "Possible manifest-generating dep found in deps. Use android_manifest_dep for this instead. Found: $_bad_deps")
+ }
+ sources = []
+ }
+ _android_manifest_deps = []
+ if (defined(invoker.android_manifest_dep)) {
+ _android_manifest_deps = [ invoker.android_manifest_dep ]
+ }
+ _android_manifest = invoker.android_manifest
+
+ _rebased_build_config = rebase_path(_build_config, root_build_dir)
+ _create_abi_split =
+ defined(invoker.create_abi_split) && invoker.create_abi_split
+ _create_density_splits =
+ defined(invoker.create_density_splits) && invoker.create_density_splits
+ _create_language_splits =
+ defined(invoker.language_splits) && invoker.language_splits != []
+ _generate_buildconfig_java = !defined(invoker.apk_under_test)
+ if (defined(invoker.generate_buildconfig_java)) {
+ _generate_buildconfig_java = invoker.generate_buildconfig_java
+ }
+
+ # Help GN understand that _create_abi_split is not unused (bug in GN).
+ assert(_create_abi_split || true)
+
+ _proguard_enabled =
+ defined(invoker.proguard_enabled) && invoker.proguard_enabled
+ if (_proguard_enabled) {
+ _proguard_output_jar_path = "$base_path.proguard.jar"
+ }
+
+ _emma_never_instrument = defined(invoker.testonly) && invoker.testonly
+ _incremental_allowed =
+ !(defined(invoker.never_incremental) && invoker.never_incremental)
+
+ build_config_target = "${_template_name}__build_config"
+ write_build_config(build_config_target) {
+ forward_variables_from(invoker, [ "apk_under_test" ])
+ type = "android_apk"
+ jar_path = _jar_path
+ dex_path = final_dex_path
+ apk_path = _final_apk_path
+ incremental_allowed = _incremental_allowed
+ incremental_apk_path = "${_final_apk_path_no_ext}_incremental.apk"
+ incremental_install_script_path = _incremental_install_script_path
+ resources_zip = resources_zip_path
+ build_config = _build_config
+ android_manifest = _android_manifest
+
+ if (defined(_java_sources_file)) {
+ java_sources_file = _java_sources_file
+ }
+
+ deps = _android_manifest_deps
+
+ if (defined(invoker.deps)) {
+ possible_config_deps = invoker.deps
+ }
+
+ # Added emma to the target's classpath via its .build_config.
+ if (emma_coverage && !_emma_never_instrument) {
+ possible_config_deps +=
+ [ "//third_party/android_tools:emma_device_java" ]
+ }
+
+ proguard_enabled = _proguard_enabled
+ if (_proguard_enabled) {
+ proguard_info = "$_proguard_output_jar_path.info"
+ }
+
+ # Don't depend on the runtime_deps target in order to avoid having to
+ # build the native libraries just to create the .build_config file.
+ # The dep is unnecessary since the runtime_deps file is created by gn gen
+ # and the runtime_deps file is added to write_build_config.py's depfile.
+ if (_native_libs_deps != []) {
+ shared_libraries_runtime_deps_file = _runtime_deps_file
+ }
+ if (_secondary_abi_native_libs_deps != []) {
+ secondary_abi_shared_libraries_runtime_deps_file =
+ _secondary_abi_runtime_deps_file
+ }
+ }
+
+ _final_deps = []
+
+ if (enable_multidex) {
+ _generated_proguard_main_dex_config =
+ "$base_path.resources.main-dex-proguard.txt"
+ }
+ _generated_proguard_config = "$base_path.resources.proguard.txt"
+ process_resources_target = "${_template_name}__process_resources"
+ process_resources(process_resources_target) {
+ forward_variables_from(invoker,
+ [
+ "alternative_android_sdk_jar",
+ "android_aapt_path",
+ "app_as_shared_lib",
+ "include_all_resources",
+ "shared_resources",
+ ])
+ srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
+ r_text_out_path = "${target_gen_dir}/${target_name}_R.txt"
+ android_manifest = _android_manifest
+ resource_dirs = [ "//build/android/ant/empty/res" ]
+ zip_path = resources_zip_path
+ all_resources_zip_path = _all_resources_zip_path
+ generate_constant_ids = true
+ proguard_file = _generated_proguard_config
+ if (enable_multidex) {
+ proguard_file_main_dex = _generated_proguard_main_dex_config
+ }
+
+ build_config = _build_config
+ deps = _android_manifest_deps + [ ":$build_config_target" ]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ }
+ _srcjar_deps += [ ":$process_resources_target" ]
+
+ if (_native_libs_deps != []) {
+ _enable_chromium_linker_tests = false
+ if (defined(invoker.enable_chromium_linker_tests)) {
+ _enable_chromium_linker_tests = invoker.enable_chromium_linker_tests
+ }
+ _ordered_libraries_json =
+ "$target_gen_dir/$target_name.ordered_libararies.json"
+ _rebased_ordered_libraries_json =
+ rebase_path(_ordered_libraries_json, root_build_dir)
+ _ordered_libraries_target = "${_template_name}__write_ordered_libraries"
+
+ # TODO(agrieve): Make GN write runtime deps in dependency order so as to
+ # not need this manual sorting step.
+ action(_ordered_libraries_target) {
+ script = "//build/android/gyp/write_ordered_libraries.py"
+ deps = _native_libs_deps + [ ":$build_config_target" ]
+ outputs = [
+ _ordered_libraries_json,
+ ]
+ _rebased_android_readelf = rebase_path(android_readelf, root_build_dir)
+ args = [
+ "--readelf=$_rebased_android_readelf",
+ "--output=$_rebased_ordered_libraries_json",
+ "--libraries-dir=.",
+ "--input-libraries=@FileArg($_rebased_build_config:native:libraries)",
+ ]
+ }
+
+ java_cpp_template("${_template_name}__native_libraries_java") {
+ package_path = "org/chromium/base/library_loader"
+ sources = [
+ "//base/android/java/templates/NativeLibraries.template",
+ ]
+ inputs = [
+ _ordered_libraries_json,
+ ]
+ deps = [
+ ":${_ordered_libraries_target}",
+ ]
+ if (_native_lib_version_rule != "") {
+ deps += [ _native_lib_version_rule ]
+ }
+
+ defines = [
+ "NATIVE_LIBRARIES_LIST=" +
+ "@FileArg($_rebased_ordered_libraries_json:java_libraries_list)",
+ "NATIVE_LIBRARIES_VERSION_NUMBER=$_native_lib_version_arg",
+ ]
+ if (_use_chromium_linker) {
+ defines += [ "ENABLE_CHROMIUM_LINKER" ]
+ }
+ if (_load_library_from_apk) {
+ defines += [ "ENABLE_CHROMIUM_LINKER_LIBRARY_IN_ZIP_FILE" ]
+ }
+ if (_enable_chromium_linker_tests) {
+ defines += [ "ENABLE_CHROMIUM_LINKER_TESTS" ]
+ }
+ }
+ _srcjar_deps += [ ":${_template_name}__native_libraries_java" ]
+ }
+
+ if (_generate_buildconfig_java) {
+ java_cpp_template("${_template_name}__build_config_java") {
+ package_path = "org/chromium/base"
+ sources = [
+ "//base/android/java/templates/BuildConfig.template",
+ ]
+ deps = [
+ ":$build_config_target",
+ ]
+
+ defines = []
+ if (enable_multidex) {
+ defines += [ "ENABLE_MULTIDEX" ]
+ }
+ if (is_java_debug || dcheck_always_on) {
+ defines += [ "_DCHECK_IS_ON" ]
+ }
+ defines += [
+ "COMPRESSED_LOCALE_LIST=" +
+ "@FileArg($_rebased_build_config:compressed_locales_java_list)",
+ "UNCOMPRESSED_LOCALE_LIST=" +
+ "@FileArg($_rebased_build_config:uncompressed_locales_java_list)",
+ ]
+ }
+ _srcjar_deps += [ ":${_template_name}__build_config_java" ]
+ }
+
+ java_target = "${_template_name}__java"
+ java_library_impl(java_target) {
+ forward_variables_from(invoker,
+ [
+ "chromium_code",
+ "java_files",
+ "run_findbugs_override",
+ ])
+ supports_android = true
+ requires_android = true
+ override_build_config = _build_config
+ deps = _android_manifest_deps + [ ":$build_config_target" ]
+
+ android_manifest = _android_manifest
+ srcjar_deps = _srcjar_deps
+ jar_path = _jar_path
+ dex_path = _lib_dex_path
+ emma_never_instrument = _emma_never_instrument
+ if (defined(_java_sources_file)) {
+ java_sources_file = _java_sources_file
+ }
+
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ if (defined(invoker.apk_under_test)) {
+ deps += [ "${invoker.apk_under_test}__java" ]
+ }
+ if (emma_coverage && !_emma_never_instrument) {
+ deps += [ "//third_party/android_tools:emma_device_java" ]
+ }
+ }
+
+ # TODO(cjhopman): This is only ever needed to calculate the list of tests to
+ # run. See build/android/pylib/instrumentation/test_jar.py. We should be
+ # able to just do that calculation at build time instead.
+ if (defined(invoker.dist_ijar_path)) {
+ _dist_ijar_path = invoker.dist_ijar_path
+ dist_jar("${_template_name}_dist_ijar") {
+ override_build_config = _build_config
+ output = _dist_ijar_path
+ data = [
+ _dist_ijar_path,
+ ]
+ use_interface_jars = true
+ deps = [
+ ":$build_config_target",
+ ":$java_target",
+ ]
+ }
+ }
+
+ if (_proguard_enabled) {
+ _proguard_configs = [ _generated_proguard_config ]
+ if (defined(invoker.proguard_configs)) {
+ _proguard_configs += invoker.proguard_configs
+ }
+ if (enable_multidex) {
+ _proguard_configs += [ "//build/android/multidex.flags" ]
+ }
+ assert(_proguard_configs != []) # Mark as used.
+ _proguard_target = "${_template_name}__proguard"
+ proguard(_proguard_target) {
+ forward_variables_from(invoker,
+ [
+ "alternative_android_sdk_jar",
+ "deps",
+ "proguard_jar_path",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [
+ ":$build_config_target",
+ ":$java_target",
+ ":$process_resources_target",
+ ]
+ inputs = [
+ _build_config,
+ _jar_path,
+ ] + _proguard_configs
+
+ output_jar_path = _proguard_output_jar_path
+ _rebased_proguard_configs =
+ rebase_path(_proguard_configs, root_build_dir)
+ args = [
+ "--proguard-configs=$_rebased_proguard_configs",
+ "--proguard-configs=@FileArg($_rebased_build_config:proguard:lib_configs)",
+ "--input-paths=@FileArg($_rebased_build_config:proguard:input_paths)",
+ "--classpath=@FileArg($_rebased_build_config:proguard:lib_paths)",
+ ]
+ if (defined(invoker.apk_under_test)) {
+ deps += [
+ "${invoker.apk_under_test}__build_config",
+ "${invoker.apk_under_test}__proguard",
+ ]
+ _apk_under_test_build_config =
+ get_label_info(invoker.apk_under_test, "target_gen_dir") + "/" +
+ get_label_info(invoker.apk_under_test, "name") + ".build_config"
+ _rebased_apk_under_test_build_config =
+ rebase_path(_apk_under_test_build_config, root_build_dir)
+ args += [ "--tested-apk-info=@FileArg($_rebased_apk_under_test_build_config:deps_info:proguard_info)" ]
+ }
+ }
+ _dex_sources = [ _proguard_output_jar_path ]
+ _dex_deps = [ ":$_proguard_target" ]
+
+ _copy_proguard_mapping_target = "${_template_name}__copy_proguard_mapping"
+ copy(_copy_proguard_mapping_target) {
+ sources = [
+ "$_proguard_output_jar_path.mapping",
+ ]
+ outputs = [
+ "$_final_apk_path.mapping",
+ ]
+ deps = [
+ ":$_proguard_target",
+ ]
+ }
+ } else {
+ if (enable_multidex) {
+ _dex_sources = [ _jar_path ]
+ } else {
+ _dex_sources = [ _lib_dex_path ]
+ }
+ _dex_deps = [ ":$java_target" ]
+ }
+
+ dex("$final_dex_target_name") {
+ deps = _dex_deps + [ ":$build_config_target" ]
+ inputs = [
+ _build_config,
+ ]
+ sources = _dex_sources
+ output = final_dex_path
+
+ # All deps are already included in _dex_sources when proguard is used.
+ if (!_proguard_enabled) {
+ if (enable_multidex) {
+ _dex_arg_key = "${_rebased_build_config}:dist_jar:dependency_jars"
+ extra_main_dex_proguard_config = _generated_proguard_main_dex_config
+ deps += [ ":$process_resources_target" ]
+ } else {
+ _dex_arg_key =
+ "${_rebased_build_config}:final_dex:dependency_dex_files"
+ }
+ args = [ "--inputs=@FileArg($_dex_arg_key)" ]
+ }
+ }
+
+ _native_libs_file_arg_dep = ":$build_config_target"
+ _native_libs_file_arg = "@FileArg($_rebased_build_config:native:libraries)"
+ _secondary_abi_native_libs_file_arg_dep = ":$build_config_target"
+ _secondary_abi_native_libs_file_arg =
+ "@FileArg($_rebased_build_config:native:secondary_abi_libraries)"
+ assert(_secondary_abi_native_libs_file_arg != "" &&
+ _secondary_abi_native_libs_file_arg_dep != "") # Mark as used.
+
+ if (_native_libs_deps != [] && _enable_relocation_packing) {
+ _prepare_native_target_name = "${_template_name}__prepare_native"
+ _native_libs_json = "$gen_dir/packed-libs/filelist.json"
+ _rebased_native_libs_json = rebase_path(_native_libs_json, root_build_dir)
+ _native_libs_file_arg_dep = ":$_prepare_native_target_name"
+ _native_libs_file_arg = "@FileArg($_rebased_native_libs_json:files)"
+
+ pack_relocation_section(_prepare_native_target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "public_deps",
+ ])
+ file_list_json = _native_libs_json
+ libraries_filearg =
+ "@FileArg(${_rebased_build_config}:native:libraries)"
+ inputs = [
+ _build_config,
+ ]
+
+ deps += _native_libs_deps
+ deps += [ ":$build_config_target" ]
+ }
+ if (_secondary_abi_native_libs_deps != []) {
+ _prepare_native_target_name =
+ "${_template_name}_secondary_abi__prepare_native"
+ _native_libs_json =
+ "$gen_dir/packed-libs/$android_secondary_abi_cpu/filelist.json"
+ _rebased_native_libs_json =
+ rebase_path(_native_libs_json, root_build_dir)
+ _secondary_abi_native_libs_file_arg_dep =
+ ":$_prepare_native_target_name"
+ _secondary_abi_native_libs_file_arg =
+ "@FileArg($_rebased_native_libs_json:files)"
+
+ pack_relocation_section(_prepare_native_target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "public_deps",
+ ])
+ file_list_json = _native_libs_json
+ libraries_filearg = "@FileArg(${_rebased_build_config}:native:secondary_abi_libraries)"
+ inputs = [
+ _build_config,
+ ]
+
+ deps += _secondary_abi_native_libs_deps
+ deps += [ ":$build_config_target" ]
+ }
+ }
+ }
+
+ _extra_native_libs = []
+ _extra_native_libs_deps = []
+ assert(_extra_native_libs_deps == []) # Mark as used.
+ _extra_native_libs_even_when_incremental = []
+ if (_native_libs_deps != []) {
+ if (_use_chromium_linker) {
+ _extra_native_libs =
+ [ "$root_shlib_dir/libchromium_android_linker$shlib_extension" ]
+ _extra_native_libs_deps +=
+ [ "//base/android/linker:chromium_android_linker" ]
+ }
+
+ _create_stack_script_rule_name = "${_template_name}__stack_script"
+ _final_deps += [ ":${_create_stack_script_rule_name}" ]
+ stack_script(_create_stack_script_rule_name) {
+ stack_target_name = invoker.target_name
+ deps = _native_libs_deps
+ if (_native_libs_deps != [] && _enable_relocation_packing) {
+ packed_libraries = _native_libs_file_arg
+ deps += [ _native_libs_file_arg_dep ]
+ }
+ }
+ }
+ if (defined(invoker.loadable_modules) && invoker.loadable_modules != []) {
+ _extra_native_libs_even_when_incremental += invoker.loadable_modules
+ }
+
+ _final_deps += [ ":${_template_name}__create" ]
+ create_apk("${_template_name}__create") {
+ forward_variables_from(invoker,
+ [
+ "aapt_locale_whitelist",
+ "alternative_android_sdk_jar",
+ "android_aapt_path",
+ "app_as_shared_lib",
+ "deps",
+ "extensions_to_not_compress",
+ "language_splits",
+ "public_deps",
+ "secondary_native_libs",
+ "shared_resources",
+ "uncompress_shared_libraries",
+ "write_asset_list",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ apk_path = _final_apk_path
+ android_manifest = _android_manifest
+ assets_build_config = _build_config
+ resources_zip = _all_resources_zip_path
+ dex_path = final_dex_path
+ load_library_from_apk = _load_library_from_apk
+ create_density_splits = _create_density_splits
+
+ if (!defined(extensions_to_not_compress)) {
+ # Allow icu data, v8 snapshots, and pak files to be loaded directly from
+ # the .apk.
+ # Note: These are actually suffix matches, not necessarily extensions.
+ extensions_to_not_compress = ".dat,.bin,.pak"
+ }
+
+ version_code = _version_code
+ version_name = _version_name
+
+ keystore_name = _keystore_name
+ keystore_path = _keystore_path
+ keystore_password = _keystore_password
+
+ # Incremental apk does not use native libs nor final dex.
+ incremental_deps = deps + _android_manifest_deps + [
+ ":$build_config_target",
+ ":$process_resources_target",
+ ]
+
+ # This target generates the input file _all_resources_zip_path.
+ deps += _android_manifest_deps + [
+ ":$build_config_target",
+ ":$process_resources_target",
+ ":$final_dex_target_name",
+ ]
+
+ if ((_native_libs_deps != [] ||
+ _extra_native_libs_even_when_incremental != []) &&
+ !_create_abi_split) {
+ deps += _native_libs_deps + _extra_native_libs_deps +
+ [ _native_libs_file_arg_dep ]
+ native_libs_filearg = _native_libs_file_arg
+ native_libs = _extra_native_libs
+ native_libs_even_when_incremental =
+ _extra_native_libs_even_when_incremental
+ }
+
+ if (_secondary_abi_native_libs_deps != [] && !_create_abi_split) {
+ deps += _secondary_abi_native_libs_deps +
+ [ _secondary_abi_native_libs_file_arg_dep ]
+ secondary_abi_native_libs_filearg = _secondary_abi_native_libs_file_arg
+ }
+
+ # Placeholders necessary for some older devices.
+ # http://crbug.com/395038
+ forward_variables_from(invoker, [ "native_lib_placeholders" ])
+ }
+
+ if ((_native_libs_deps != [] ||
+ _extra_native_libs_even_when_incremental != []) && _create_abi_split) {
+ _manifest_rule =
+ "${_template_name}__split_manifest_abi_${android_app_abi}"
+ generate_split_manifest(_manifest_rule) {
+ main_manifest = _android_manifest
+ out_manifest =
+ "$gen_dir/split-manifests/${android_app_abi}/AndroidManifest.xml"
+ split_name = "abi_${android_app_abi}"
+ deps = _android_manifest_deps
+ }
+
+ _apk_rule = "${_template_name}__split_apk_abi_${android_app_abi}"
+ _final_deps += [ ":$_apk_rule" ]
+
+ create_apk(_apk_rule) {
+ apk_path = "${_final_apk_path_no_ext}-abi-${android_app_abi}.apk"
+ base_path = "$gen_dir/$_apk_rule"
+
+ manifest_outputs = get_target_outputs(":${_manifest_rule}")
+ android_manifest = manifest_outputs[1]
+ load_library_from_apk = _load_library_from_apk
+
+ version_code = _version_code
+ version_name = _version_name
+
+ keystore_name = _keystore_name
+ keystore_path = _keystore_path
+ keystore_password = _keystore_password
+
+ # Placeholders necessary for some older devices.
+ # http://crbug.com/395038
+ deps = []
+ forward_variables_from(invoker,
+ [
+ "alternative_android_sdk_jar",
+ "android_aapt_path",
+ "deps",
+ "native_lib_placeholders",
+ "public_deps",
+ ])
+
+ incremental_deps = deps + [ ":$_manifest_rule" ]
+ deps = []
+ deps = incremental_deps + _native_libs_deps + _extra_native_libs_deps +
+ [ _native_libs_file_arg_dep ]
+ native_libs_filearg = _native_libs_file_arg
+ native_libs = _extra_native_libs
+ native_libs_even_when_incremental =
+ _extra_native_libs_even_when_incremental
+ }
+ }
+
+ _create_incremental_script_rule_name =
+ "${_template_name}__incremental_script"
+ action(_create_incremental_script_rule_name) {
+ script = "//build/android/incremental_install/create_install_script.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ deps = [
+ _native_libs_file_arg_dep,
+ ]
+
+ outputs = [
+ _incremental_install_script_path,
+ ]
+
+ _rebased_apk_path_no_ext =
+ rebase_path(_final_apk_path_no_ext, root_build_dir)
+ _rebased_incremental_install_script_path =
+ rebase_path(_incremental_install_script_path, root_build_dir)
+ _rebased_depfile = rebase_path(depfile, root_build_dir)
+ _dex_arg_key = "${_rebased_build_config}:final_dex:dependency_dex_files"
+ args = [
+ "--apk-path=${_rebased_apk_path_no_ext}_incremental.apk",
+ "--script-output-path=$_rebased_incremental_install_script_path",
+ "--dex-file=$_rebased_lib_dex_path",
+ "--dex-file-list=@FileArg($_dex_arg_key)",
+ "--depfile=$_rebased_depfile",
+ ]
+ if (_proguard_enabled) {
+ args += [ "--show-proguard-warning" ]
+ }
+ if (defined(_native_libs_file_arg)) {
+ args += [ "--native-libs=$_native_libs_file_arg" ]
+ }
+ if (_extra_native_libs != []) {
+ # Don't pass in _extra_native_libs_even_when_incremental, since these are
+ # end up in the apk and are not side-loaded.
+ _rebased_extra_native_libs =
+ rebase_path(_extra_native_libs, root_build_dir)
+ args += [ "--native-libs=$_rebased_extra_native_libs" ]
+ }
+ if (_create_density_splits) {
+ args += [ "--split=${_rebased_apk_path_no_ext}-density-*.apk" ]
+ }
+ if (_create_language_splits) {
+ args += [ "--split=${_rebased_apk_path_no_ext}-language-*.apk" ]
+ }
+ if (_load_library_from_apk) {
+ args += [ "--dont-even-try=Incremental builds do not work with load_library_from_apk. Try setting is_component_build=true in your GN args." ]
+ }
+ }
+
+ group(target_name) {
+ if (_incremental_allowed && incremental_apk_by_default) {
+ deps = [
+ ":${target_name}_incremental",
+ ]
+ } else {
+ forward_variables_from(invoker,
+ [
+ "data",
+ "data_deps",
+ ])
+ public_deps = _final_deps
+
+ # Make the proguard .mapping file easy to find by putting it beside the .apk.
+ if (_proguard_enabled) {
+ deps = [
+ ":$_copy_proguard_mapping_target",
+ ]
+ }
+ }
+ }
+
+ if (_incremental_allowed) {
+ group("${target_name}_incremental") {
+ forward_variables_from(invoker,
+ [
+ "data",
+ "data_deps",
+ ])
+ if (!defined(data_deps)) {
+ data_deps = []
+ }
+
+ # device/commands is used by the installer script to push files via .zip.
+ data_deps += [ "//build/android/pylib/device/commands" ] +
+ _native_libs_deps + _extra_native_libs_deps
+
+ # Since the _incremental.apk does not include use .so nor .dex from the
+ # actual target, but instead loads them at runtime, we need to explicitly
+ # depend on them here.
+ public_deps = [
+ ":${_create_incremental_script_rule_name}",
+ ":${_template_name}__create_incremental",
+ ":${java_target}",
+ ]
+ }
+ }
+ }
+
+ # Declare an Android instrumentation test apk
+ #
+ # This target creates an Android instrumentation test apk.
+ #
+ # Variables
+ # android_manifest: Path to AndroidManifest.xml.
+ # data_deps: List of dependencies needed at runtime. These will be built but
+ # won't change the generated .apk in any way (in fact they may be built
+ # after the .apk is).
+ # deps: List of dependencies. All Android java resources and libraries in the
+ # "transitive closure" of these dependencies will be included in the apk.
+ # Note: this "transitive closure" actually only includes such targets if
+ # they are depended on through android_library or android_resources targets
+ # (and so not through builtin targets like 'action', 'group', etc).
+ # java_files: List of .java files to include in the apk.
+ # srcjar_deps: List of srcjar dependencies. The .java files in the srcjars
+ # will be added to java_files and be included in this apk.
+ # apk_name: Name for final apk.
+ # final_apk_path: Path to final built apk. Default is
+ # $root_out_dir/apks/$apk_name.apk. Setting this will override apk_name.
+ # shared_libraries: List shared_library targets to bundle. If these
+ # libraries depend on other shared_library targets, those dependencies will
+ # also be included in the apk (e.g. for is_component_build).
+ # apk_under_test: The apk being tested.
+ #
+ # Example
+ # instrumentation_test_apk("foo_test_apk") {
+ # android_manifest = "AndroidManifest.xml"
+ # apk_name = "FooTest"
+ # apk_under_test = "Foo"
+ # java_files = [
+ # "android/org/chromium/foo/FooTestCase.java",
+ # "android/org/chromium/foo/FooExampleTest.java",
+ # ]
+ # deps = [
+ # ":foo_test_support_java"
+ # ]
+ # }
+ template("instrumentation_test_apk") {
+ assert(defined(invoker.apk_name))
+ testonly = true
+ _apk_target_name = "${target_name}__apk"
+ _test_runner_target_name = "${target_name}__test_runner_script"
+ _install_script_name = "install_$target_name"
+ _dist_ijar_path =
+ "$root_build_dir/test.lib.java/" + invoker.apk_name + ".jar"
+ _incremental_test_runner_target_name =
+ "${_test_runner_target_name}_incremental"
+ _incremental_test_name = "${invoker.target_name}_incremental"
+ if (incremental_apk_by_default) {
+ _incremental_test_runner_target_name = _test_runner_target_name
+ _incremental_test_name = invoker.target_name
+ }
+
+ if (!incremental_apk_by_default) {
+ test_runner_script(_test_runner_target_name) {
+ forward_variables_from(invoker,
+ [
+ "additional_apks",
+ "apk_under_test",
+ "data",
+ "data_deps",
+ "deps",
+ "ignore_all_data_deps",
+ "public_deps",
+ ])
+ test_name = invoker.target_name
+ test_type = "instrumentation"
+ apk_target = ":$_apk_target_name"
+ test_jar = _dist_ijar_path
+ }
+ }
+ test_runner_script(_incremental_test_runner_target_name) {
+ forward_variables_from(invoker,
+ [
+ "additional_apks",
+ "apk_under_test",
+ "data",
+ "data_deps",
+ "deps",
+ "ignore_all_data_deps",
+ "public_deps",
+ ])
+ test_name = _incremental_test_name
+ test_type = "instrumentation"
+ apk_target = ":$_apk_target_name"
+ test_jar = _dist_ijar_path
+ incremental_install = true
+ }
+
+ android_apk(_apk_target_name) {
+ deps = []
+ data_deps = []
+ forward_variables_from(invoker, "*")
+ install_script_name = _install_script_name
+ deps += [ "//testing/android/broker:broker_java" ]
+ data_deps += [
+ "//build/android/pylib/device/commands",
+ "//tools/android/forwarder2",
+ "//tools/android/md5sum",
+ ]
+ if (defined(invoker.additional_apks)) {
+ data_deps += invoker.additional_apks
+ }
+
+ if (defined(invoker.proguard_enabled) && invoker.proguard_enabled) {
+ # When ProGuard is on, we use ProGuard to combine the under test java
+ # code and the test java code. This is to allow us to apply all ProGuard
+ # optimizations that we ship with, but not have them break tests. The
+ # apk under test will still have the same resources, assets, and
+ # manifest, all of which are the ones used in the tests.
+ if (!defined(invoker.proguard_configs)) {
+ proguard_configs = []
+ }
+ proguard_configs += [ "//testing/android/proguard_for_test.flags" ]
+ }
+
+ dist_ijar_path = _dist_ijar_path
+ if (defined(invoker.run_findbugs_override)) {
+ # Only allow findbugs when there are java files.
+ run_findbugs_override =
+ invoker.run_findbugs_override && defined(invoker.java_files)
+ }
+ }
+
+ group(target_name) {
+ if (incremental_apk_by_default) {
+ deps = [
+ ":${target_name}_incremental",
+ ]
+ } else {
+ public_deps = [
+ ":$_apk_target_name",
+ ":$_test_runner_target_name",
+
+ # Required by test runner to enumerate test list.
+ ":${_apk_target_name}_dist_ijar",
+ ]
+ if (defined(invoker.apk_under_test)) {
+ public_deps += [ invoker.apk_under_test ]
+ }
+ }
+ }
+
+ # TODO: Delete once recipes no longer use this target.
+ group("${target_name}_run") {
+ public_deps = [
+ ":${invoker.target_name}",
+ ]
+ }
+ group("${target_name}_incremental") {
+ public_deps = [
+ ":$_incremental_test_runner_target_name",
+ ":${_apk_target_name}_dist_ijar",
+ ":${_apk_target_name}_incremental",
+ ]
+ if (defined(invoker.apk_under_test)) {
+ public_deps += [ "${invoker.apk_under_test}_incremental" ]
+ }
+ }
+ }
+
+ # Declare an Android gtest apk
+ #
+ # This target creates an Android apk for running gtest-based unittests.
+ #
+ # Variables
+ # deps: Specifies the dependencies of this target. These will be passed to
+ # the underlying android_apk invocation and should include the java and
+ # resource dependencies of the apk.
+ # shared_library: shared_library target that contains the unit tests.
+ # apk_name: The name of the produced apk. If unspecified, it uses the name
+ # of the shared_library target suffixed with "_apk"
+ # use_default_launcher: Whether the default activity (NativeUnitTestActivity)
+ # should be used for launching tests.
+ # use_native_activity: Test implements ANativeActivity_onCreate().
+ #
+ # Example
+ # unittest_apk("foo_unittests_apk") {
+ # deps = [ ":foo_java", ":foo_resources" ]
+ # shared_library = ":foo_unittests"
+ # }
+ template("unittest_apk") {
+ _use_native_activity =
+ defined(invoker.use_native_activity) && invoker.use_native_activity
+ _android_manifest = "$target_gen_dir/$target_name/AndroidManifest.xml"
+ assert(invoker.shared_library != "")
+
+ # This trivial assert is needed in case android_manifest is defined,
+ # as otherwise _use_native_activity and _android_manifest would not be used.
+ assert(_use_native_activity != "" && _android_manifest != "")
+
+ if (!defined(invoker.android_manifest)) {
+ jinja_template("${target_name}_manifest") {
+ _native_library_name = get_label_info(invoker.shared_library, "name")
+ input = "//testing/android/native_test/java/AndroidManifest.xml.jinja2"
+ output = _android_manifest
+ variables = [
+ "is_component_build=${is_component_build}",
+ "native_library_name=${_native_library_name}",
+ "use_native_activity=${_use_native_activity}",
+ ]
+ }
+ }
+
+ android_apk(target_name) {
+ set_sources_assignment_filter([])
+ data_deps = []
+ deps = []
+ forward_variables_from(invoker, "*")
+ testonly = true
+
+ assert(!defined(invoker.proguard_enabled) || !invoker.proguard_enabled ||
+ invoker.proguard_configs != [])
+
+ if (!defined(apk_name)) {
+ apk_name = get_label_info(invoker.shared_library, "name")
+ }
+
+ if (!defined(android_manifest)) {
+ android_manifest_dep = ":${target_name}_manifest"
+ android_manifest = _android_manifest
+ }
+
+ final_apk_path = "$root_build_dir/${apk_name}_apk/${apk_name}-debug.apk"
+
+ if (!defined(use_default_launcher) || use_default_launcher) {
+ deps += [ "//testing/android/native_test:native_test_java" ]
+ }
+ shared_libraries = [ invoker.shared_library ]
+ deps += [
+ "//base:base_java",
+ "//testing/android/appurify_support:appurify_support_java",
+ "//testing/android/reporter:reporter_java",
+ ]
+ data_deps += [
+ "//build/android/pylib/device/commands",
+ "//tools/android/md5sum",
+ ]
+ if (host_os == "linux") {
+ data_deps += [ "//tools/android/forwarder2" ]
+ }
+ }
+ }
+
+ # Generate .java files from .aidl files.
+ #
+ # This target will store the .java files in a srcjar and should be included in
+ # an android_library or android_apk's srcjar_deps.
+ #
+ # Variables
+ # sources: Paths to .aidl files to compile.
+ # import_include: Path to directory containing .java files imported by the
+ # .aidl files.
+ # interface_file: Preprocessed aidl file to import.
+ #
+ # Example
+ # android_aidl("foo_aidl") {
+ # import_include = "java/src"
+ # sources = [
+ # "java/src/com/foo/bar/FooBarService.aidl",
+ # "java/src/com/foo/bar/FooBarServiceCallback.aidl",
+ # ]
+ # }
+ template("android_aidl") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+
+ srcjar_path = "${target_gen_dir}/${target_name}.srcjar"
+ aidl_path = "${android_sdk_build_tools}/aidl"
+ framework_aidl = "$android_sdk/framework.aidl"
+
+ action(target_name) {
+ script = "//build/android/gyp/aidl.py"
+ sources = invoker.sources
+
+ imports = [ framework_aidl ]
+ if (defined(invoker.interface_file)) {
+ assert(invoker.interface_file != "")
+ imports += [ invoker.interface_file ]
+ }
+
+ inputs = [ aidl_path ] + imports
+
+ depfile = "${target_gen_dir}/${target_name}.d"
+ outputs = [
+ srcjar_path,
+ ]
+ rebased_imports = rebase_path(imports, root_build_dir)
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--aidl-path",
+ rebase_path(aidl_path, root_build_dir),
+ "--imports=$rebased_imports",
+ "--srcjar",
+ rebase_path(srcjar_path, root_build_dir),
+ ]
+ if (defined(invoker.import_include) && invoker.import_include != []) {
+ # TODO(cjhopman): aidl supports creating a depfile. We should be able to
+ # switch to constructing a depfile for the overall action from that
+ # instead of having all the .java files in the include paths as inputs.
+ rebased_import_paths = []
+ foreach(import_path, invoker.import_include) {
+ _rebased_import_path = []
+ _rebased_import_path += rebase_path([ import_path ], root_build_dir)
+ rebased_import_paths += _rebased_import_path
+ _java_files_build_rel = []
+ _java_files_build_rel = exec_script("//build/android/gyp/find.py",
+ _rebased_import_path,
+ "list lines")
+ inputs += rebase_path(_java_files_build_rel, ".", root_build_dir)
+ }
+ args += [ "--includes=$rebased_import_paths" ]
+ }
+ args += rebase_path(sources, root_build_dir)
+ }
+ }
+
+ # Compile a protocol buffer to java.
+ #
+ # This generates java files from protocol buffers and creates an Android library
+ # containing the classes.
+ #
+ # Variables
+ # sources: Paths to .proto files to compile.
+ # proto_path: Root directory of .proto files.
+ #
+ # Example:
+ # proto_java_library("foo_proto_java") {
+ # proto_path = "src/foo"
+ # sources = [ "$proto_path/foo.proto" ]
+ # }
+ template("proto_java_library") {
+ set_sources_assignment_filter([])
+ forward_variables_from(invoker, [ "testonly" ])
+ _protoc_dep =
+ "//third_party/android_protobuf:android_protoc($host_toolchain)"
+ _protoc_out_dir = get_label_info(_protoc_dep, "root_out_dir")
+ _protoc_bin = "$_protoc_out_dir/android_protoc"
+ _proto_path = invoker.proto_path
+
+ _template_name = target_name
+
+ action("${_template_name}__protoc_java") {
+ srcjar_path = "$target_gen_dir/$target_name.srcjar"
+ script = "//build/protoc_java.py"
+
+ deps = [
+ _protoc_dep,
+ ]
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+
+ sources = invoker.sources
+ depfile = "$target_gen_dir/$target_name.d"
+ outputs = [
+ srcjar_path,
+ ]
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--protoc",
+ rebase_path(_protoc_bin, root_build_dir),
+ "--proto-path",
+ rebase_path(_proto_path, root_build_dir),
+ "--srcjar",
+ rebase_path(srcjar_path, root_build_dir),
+ ] + rebase_path(sources, root_build_dir)
+ }
+
+ android_library(target_name) {
+ chromium_code = false
+ java_files = []
+ srcjar_deps = [ ":${_template_name}__protoc_java" ]
+ deps = [
+ "//third_party/android_protobuf:protobuf_nano_javalib",
+ ]
+ }
+ }
+
+ # Declare an Android library target for a prebuilt AAR.
+ #
+ # This target creates an Android library containing java code and Android
+ # resources. For libraries without resources, it will not generate
+ # corresponding android_resources targets.
+ #
+ # Variables
+ # aar_path: Path to the AAR.
+ # proguard_configs: List of proguard configs to use in final apk step for
+ # any apk that depends on this library.
+ # ignore_aidl: Whether to ignore .aidl files found with the .aar.
+ # ignore_assets: Whether to ignore assets found in the .aar.
+ # ignore_manifest: Whether to ignore merging of AndroidManifest.xml.
+ # ignore_native_libraries: Whether to ignore .so files found in the .aar.
+ # TODO(jbudorick@): remove this arguments after crbug.com/522043 is fixed.
+ # requires_android: Whether this target can only be used for compiling Android related targets.
+ #
+ # Example
+ # android_aar_prebuilt("foo_java") {
+ # aar_path = "foo.aar"
+ # }
+ template("android_aar_prebuilt") {
+ _output_path = "${target_gen_dir}/${target_name}"
+ _unpack_target_name = "${target_name}__unpack_aar"
+ _ignore_aidl = defined(invoker.ignore_aidl) && invoker.ignore_aidl
+ _ignore_assets = defined(invoker.ignore_assets) && invoker.ignore_assets
+ _ignore_manifest =
+ defined(invoker.ignore_manifest) && invoker.ignore_manifest
+ _ignore_native_libraries = defined(invoker.ignore_native_libraries) &&
+ invoker.ignore_native_libraries
+
+ # Scan the AAR file and determine the resources and jar files.
+ # Some libraries might not have resources; others might have two jars.
+ _scanned_files =
+ exec_script("//build/android/gyp/aar.py",
+ [
+ "--input-file",
+ rebase_path(invoker.aar_path, root_build_dir),
+ "--list",
+ ],
+ "scope")
+
+ assert(_ignore_aidl || _scanned_files.aidl == [],
+ "android_aar_prebuilt() aidl not yet supported." +
+ " Implement or use ignore_aidl = true." +
+ " http://crbug.com/644439")
+ assert(_ignore_assets || _scanned_files.assets == [],
+ "android_aar_prebuilt() assets not yet supported." +
+ " Implement or use ignore_assets = true." +
+ " http://crbug.com/643966")
+ assert(_ignore_native_libraries || !_scanned_files.has_native_libraries,
+ "android_aar_prebuilt() with .so files is not supported." +
+ " Use ignore_native_libraries = true to silence this error.")
+ assert(_ignore_manifest || _scanned_files.is_manifest_empty,
+ "android_aar_prebuilt() manifest merging not yet supported and" +
+ " non-trivial AndroidManifest.xml detected." +
+ " Implement or use ignore_manifest = true." +
+ " http://crbug.com/643967")
+ assert(_scanned_files.has_classes_jar || _scanned_files.subjars == [])
+
+ action(_unpack_target_name) {
+ script = "//build/android/gyp/aar.py" # Unzips the AAR
+ args = [
+ "--input-file",
+ rebase_path(invoker.aar_path, root_build_dir),
+ "--output-dir",
+ rebase_path(_output_path, root_build_dir),
+ "--extract",
+ ]
+ inputs = [
+ invoker.aar_path,
+ ]
+ outputs = [
+ "${_output_path}/AndroidManifest.xml",
+ ]
+
+ if (_scanned_files.has_r_text_file) {
+ # Certain packages, in particular Play Services have no R.txt even
+ # though its presence is mandated by AAR spec. Such packages cause
+ # spurious rebuilds if this output is specified unconditionally.
+ outputs += [ "${_output_path}/R.txt" ]
+ }
+
+ if (_scanned_files.resources != []) {
+ outputs += get_path_info(
+ rebase_path(_scanned_files.resources, "", _output_path),
+ "abspath")
+ }
+ if (_scanned_files.has_classes_jar) {
+ outputs += [ "${_output_path}/classes.jar" ]
+ }
+ outputs +=
+ get_path_info(rebase_path(_scanned_files.subjars, "", _output_path),
+ "abspath")
+ if (_scanned_files.has_proguard_flags) {
+ outputs += [ "${_output_path}/proguard.txt" ]
+ }
+ }
+
+ # Create the android_resources target for resources.
+ if (_scanned_files.resources != [] || _scanned_files.has_r_text_file) {
+ _res_target_name = "${target_name}__res"
+ android_resources(_res_target_name) {
+ forward_variables_from(invoker, [ "deps" ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_unpack_target_name" ]
+ resource_dirs = []
+ generated_resource_dirs = []
+ if (_scanned_files.resources != []) {
+ generated_resource_dirs += [ "${_output_path}/res" ]
+ }
+ generated_resource_files =
+ rebase_path(_scanned_files.resources, "", _output_path)
+ android_manifest_dep = ":$_unpack_target_name"
+ android_manifest = "${_output_path}/AndroidManifest.xml"
+ if (_scanned_files.has_r_text_file) {
+ r_text_file = "${_output_path}/R.txt"
+ }
+ v14_skip = true
+ }
+ }
+
+ # Create android_java_prebuilt target for extra jars within jars/.
+ _subjar_targets = []
+ foreach(_tuple, _scanned_files.subjar_tuples) {
+ _current_target = "${target_name}__subjar_${_tuple[0]}"
+ _subjar_targets += [ ":$_current_target" ]
+ java_prebuilt(_current_target) {
+ forward_variables_from(invoker,
+ [
+ "jar_excluded_patterns",
+ "requires_android",
+ ])
+ deps = [
+ ":$_unpack_target_name",
+ ]
+ if (!defined(requires_android)) {
+ requires_android = true
+ }
+ supports_android = true
+ jar_path = "$_output_path/${_tuple[1]}"
+ _base_output_name = get_path_info(jar_path, "name")
+ output_name = "${invoker.target_name}-$_base_output_name"
+ }
+ }
+
+ # Create android_java_prebuilt target for classes.jar.
+ if (_scanned_files.has_classes_jar) {
+ _jar_target_name = "${target_name}__classes"
+ java_prebuilt(_jar_target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "input_jars_paths",
+ "jar_excluded_patterns",
+ "proguard_configs",
+ "requires_android",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += _subjar_targets + [ ":$_unpack_target_name" ]
+ if (defined(_res_target_name)) {
+ deps += [ ":$_res_target_name" ]
+ }
+ if (!defined(requires_android)) {
+ requires_android = true
+ }
+ supports_android = true
+ jar_path = "$_output_path/classes.jar"
+ output_name = invoker.target_name
+
+ if (_scanned_files.has_proguard_flags) {
+ if (!defined(proguard_configs)) {
+ proguard_configs = []
+ }
+ proguard_configs += [ "$_output_path/proguard.txt" ]
+ }
+ }
+ }
+
+ java_group(target_name) {
+ deps = []
+ if (defined(_jar_target_name)) {
+ deps += [ ":$_jar_target_name" ]
+
+ # Although subjars are meant to be private, we add them as deps here
+ # because in practice they seem to contain classes required to be in the
+ # classpath.
+ deps += _subjar_targets
+ }
+ if (defined(_res_target_name)) {
+ deps += [ ":$_res_target_name" ]
+ }
+ }
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/arm.gni b/third_party/libwebrtc/webrtc/build/config/arm.gni
new file mode 100644
index 0000000000..8de0bcd25c
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/arm.gni
@@ -0,0 +1,126 @@
+# 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/v8_target_cpu.gni")
+
+# These are primarily relevant in current_cpu == "arm" contexts, where
+# ARM code is being compiled. But they can also be relevant in the
+# other contexts when the code will change its behavior based on the
+# cpu it wants to generate code for.
+if (current_cpu == "arm" || v8_current_cpu == "arm") {
+ declare_args() {
+ # Version of the ARM processor when compiling on ARM. Ignored on non-ARM
+ # platforms.
+ arm_version = 7
+
+ # The ARM architecture. This will be a string like "armv6" or "armv7-a".
+ # An empty string means to use the default for the arm_version.
+ arm_arch = ""
+
+ # The ARM floating point hardware. This will be a string like "neon" or
+ # "vfpv3". An empty string means to use the default for the arm_version.
+ arm_fpu = ""
+
+ # The ARM floating point mode. This is either the string "hard", "soft", or
+ # "softfp". An empty string means to use the default one for the
+ # arm_version.
+ arm_float_abi = ""
+
+ # The ARM variant-specific tuning mode. This will be a string like "armv6"
+ # or "cortex-a15". An empty string means to use the default for the
+ # arm_version.
+ arm_tune = ""
+
+ # Whether to use the neon FPU instruction set or not.
+ arm_use_neon = ""
+
+ # Whether to enable optional NEON code paths.
+ arm_optionally_use_neon = false
+
+ # Thumb is a reduced instruction set available on some ARM processors that
+ # has increased code density.
+ arm_use_thumb = true
+ }
+
+ assert(arm_float_abi == "" || arm_float_abi == "hard" ||
+ arm_float_abi == "soft" || arm_float_abi == "softfp")
+
+ if (arm_use_neon == "") {
+ if (current_os == "linux" && target_cpu != v8_target_cpu && !build_with_mozilla) {
+ # Don't use neon on V8 simulator builds as a default.
+ arm_use_neon = false
+ } else {
+ arm_use_neon = true
+ }
+ }
+
+ if (arm_version == 6) {
+ if (arm_arch == "") {
+ arm_arch = "armv6"
+ }
+ if (arm_tune != "") {
+ arm_tune = ""
+ }
+ if (arm_float_abi == "") {
+ arm_float_abi = "softfp"
+ }
+ if (arm_fpu == "") {
+ arm_fpu = "vfp"
+ }
+ arm_use_thumb = false
+ } else if (arm_version == 7) {
+ if (arm_arch == "") {
+ arm_arch = "armv7-a"
+ }
+ if (arm_tune == "") {
+ arm_tune = "generic-armv7-a"
+ }
+
+ if (arm_float_abi == "") {
+ if (current_os == "android" || target_os == "android") {
+ arm_float_abi = "softfp"
+ } else if (current_os == "linux" && target_cpu != v8_target_cpu) {
+ # Default to the same as Android for V8 simulator builds.
+ arm_float_abi = "softfp"
+ } else {
+ arm_float_abi = "hard"
+ }
+ }
+
+ if (arm_fpu == "") {
+ if (arm_use_neon) {
+ arm_fpu = "neon"
+ } else {
+ arm_fpu = "vfpv3-d16"
+ }
+ }
+ } else if (arm_version == 8) {
+ if (arm_arch == "") {
+ arm_arch = "armv8-a"
+ }
+ if (arm_tune == "") {
+ arm_tune = "generic-armv8-a"
+ }
+
+ if (arm_float_abi == "") {
+ if (current_os == "android" || target_os == "android") {
+ arm_float_abi = "softfp"
+ } else {
+ arm_float_abi = "hard"
+ }
+ }
+
+ if (arm_fpu == "") {
+ if (arm_use_neon) {
+ arm_fpu = "neon"
+ } else {
+ arm_fpu = "vfpv3-d16"
+ }
+ }
+ }
+} else if (current_cpu == "arm64" || v8_current_cpu == "arm64") {
+ # arm64 supports only "hard".
+ arm_float_abi = "hard"
+ arm_use_neon = true
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/chrome_build.gni b/third_party/libwebrtc/webrtc/build/config/chrome_build.gni
new file mode 100644
index 0000000000..c649018a7a
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/chrome_build.gni
@@ -0,0 +1,22 @@
+# Copyright 2015 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.
+
+declare_args() {
+ # Select the desired branding flavor. False means normal Chromium branding,
+ # true means official Google Chrome branding (requires extra Google-internal
+ # resources).
+ is_chrome_branded = false
+
+ # Break chrome.dll into multple pieces based on process type. Only available
+ # on Windows.
+ is_multi_dll_chrome = is_win && !is_component_build
+}
+
+# Refers to the subdirectory for branding in various places including
+# chrome/app/theme.
+if (is_chrome_branded) {
+ branding_path_component = "google_chrome"
+} else {
+ branding_path_component = "chromium"
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/chromecast/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/chromecast/BUILD.gn
new file mode 100644
index 0000000000..c8b2989c42
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/chromecast/BUILD.gn
@@ -0,0 +1,85 @@
+# Copyright 2015 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")
+
+assert(is_chromecast)
+
+config("static_config") {
+ if (!is_clang) {
+ ldflags = [
+ # Don't allow visible symbols from libraries that contain
+ # assembly code with symbols that aren't hidden properly.
+ # http://b/26390825
+ "-Wl,--exclude-libs=libffmpeg.a",
+ ]
+
+ if (!is_android) {
+ ldflags += [
+ # We want to statically link libstdc++/libgcc on Linux.
+ # (On Android, libstdc++ and libgcc aren't used.)
+ "-static-libstdc++",
+ "-static-libgcc",
+ ]
+ }
+ }
+}
+
+config("ldconfig") {
+ visibility = [ ":*" ]
+
+ # Chromecast executables depend on several shared libraries in
+ # /oem_cast_shlib, $ORIGIN, and $ORIGIN/lib. Add these rpaths to each binary.
+ # This is explicitly disabled in Chrome for security reasons (see comments in
+ # //build/config/gcc/BUILD.gn), but necessary on Chromecast so that OEM's may
+ # override the default libraries shipped in the Cast receiver package.
+ ldflags = [
+ "-Wl,-rpath=/oem_cast_shlib",
+ "-Wl,-rpath=\$ORIGIN/lib",
+ "-Wl,-rpath=\$ORIGIN",
+ ]
+
+ # Binaries which don't live in the same directory as Chrome component
+ # libraries may still depend on them. Explicitly add the component library
+ # directory to the rpath for the component build.
+ if (is_component_build) {
+ ldflags += [ "-Wl,-rpath=/system/chrome" ]
+ }
+}
+
+config("executable_config") {
+ configs = [ ":ldconfig" ]
+
+ if (!is_clang && current_cpu == "arm") {
+ ldflags = [
+ # Export stdlibc++ and libgcc symbols to force shlibs to refer to these
+ # symbols from the executable.
+ "-Wl,--export-dynamic",
+
+ "-lm", # stdlibc++ requires math.h
+
+ # In case we redefined stdlibc++ symbols (e.g. tc_malloc)
+ "-Wl,--allow-multiple-definition",
+
+ "-Wl,--whole-archive",
+ "-l:libstdc++.a",
+ "-l:libgcc.a",
+ "-Wl,--no-whole-archive",
+ ]
+
+ # Despite including libstdc++/libgcc archives, we still need to specify
+ # static linking for them in order to prevent the executable from having a
+ # dynamic dependency on them.
+ configs += [ ":static_config" ]
+ }
+}
+
+# Shared libaries should not have RPATH or RUNPATH set. This allows the
+# shared libs to inherit RPATH from the parent executable that is loading
+# the shared library. (See internal b/37514052 for more details.)
+config("shared_library_config") {
+ if (current_cpu == "arm") {
+ configs = [ ":static_config" ]
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/chromecast_build.gni b/third_party/libwebrtc/webrtc/build/config/chromecast_build.gni
new file mode 100644
index 0000000000..6c61dbc084
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/chromecast_build.gni
@@ -0,0 +1,36 @@
+# Copyright 2015 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.
+
+# The args declared in this file should be referenced by components outside of
+# //chromecast. Args needed only in //chromecast should be declared in
+# //chromecast/chromecast.gni.
+declare_args() {
+ # Set this true for a Chromecast build. Chromecast builds are supported on
+ # Linux and Android.
+ is_chromecast = false
+
+ # Set this true for an audio-only Chromecast build.
+ is_cast_audio_only = false
+}
+
+# Note(slan): This arg depends on the value of is_chromecast, and thus must be
+# declared in a separate block. These blocks can be combined when/if
+# crbug.com/542846 is resolved.
+declare_args() {
+ # True if Chromecast build is targeted for linux desktop. This type of build
+ # is useful for testing and development, but currently supports only a subset
+ # of Cast functionality. Though this defaults to true for x86 Linux devices,
+ # this should be overriden manually for an embedded x86 build.
+ # TODO(slan): Remove instances of this when x86 is a fully supported platform.
+ is_cast_desktop_build = is_chromecast && target_os == "linux" &&
+ (target_cpu == "x86" || target_cpu == "x64")
+}
+
+# Assert that Chromecast is being built for a supported platform.
+assert(is_linux || is_android || !is_chromecast,
+ "Chromecast builds are not supported on $target_os")
+
+# Assert that is_cast_audio_only and is_cast_desktop_build are both false on a
+# non-Chromecast build.
+assert(is_chromecast || (!is_cast_audio_only && !is_cast_desktop_build))
diff --git a/third_party/libwebrtc/webrtc/build/config/clang/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/clang/BUILD.gn
new file mode 100644
index 0000000000..940c1829d5
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/clang/BUILD.gn
@@ -0,0 +1,65 @@
+# 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("clang.gni")
+
+config("find_bad_constructs") {
+ if (clang_use_chrome_plugins) {
+ cflags = []
+
+ # On Windows, the plugin is built directly into clang, so there's
+ # no need to load it dynamically.
+
+ if (is_mac || is_ios) {
+ cflags += [
+ "-Xclang",
+ "-load",
+ "-Xclang",
+ rebase_path("${clang_base_path}/lib/libFindBadConstructs.dylib",
+ root_build_dir),
+ ]
+ } else if (is_linux || is_android) {
+ cflags += [
+ "-Xclang",
+ "-load",
+ "-Xclang",
+ rebase_path("${clang_base_path}/lib/libFindBadConstructs.so",
+ root_build_dir),
+ ]
+ }
+
+ cflags += [
+ "-Xclang",
+ "-add-plugin",
+ "-Xclang",
+ "find-bad-constructs",
+ "-Xclang",
+ "-plugin-arg-find-bad-constructs",
+ "-Xclang",
+ "check-auto-raw-pointer",
+ ]
+
+ if (is_linux || is_android) {
+ cflags += [
+ "-Xclang",
+ "-plugin-arg-find-bad-constructs",
+ "-Xclang",
+ "check-ipc",
+ ]
+ }
+ }
+}
+
+# Enables some extra Clang-specific warnings. Some third-party code won't
+# compile with these so may want to remove this config.
+config("extra_warnings") {
+ cflags = [
+ "-Wheader-hygiene",
+
+ # Warns when a const char[] is converted to bool.
+ "-Wstring-conversion",
+
+ "-Wtautological-overlap-compare",
+ ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/clang/clang.gni b/third_party/libwebrtc/webrtc/build/config/clang/clang.gni
new file mode 100644
index 0000000000..7026f65207
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/clang/clang.gni
@@ -0,0 +1,13 @@
+# 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/toolchain/toolchain.gni")
+
+declare_args() {
+ # Indicates if the build should use the Chrome-specific plugins for enforcing
+ # coding guidelines, etc. Only used when compiling with Clang.
+ clang_use_chrome_plugins = is_clang && !is_nacl && !use_xcode_clang
+
+ clang_base_path = "//third_party/llvm-build/Release+Asserts"
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/compiler/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/compiler/BUILD.gn
new file mode 100644
index 0000000000..4ae4ce2f22
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/compiler/BUILD.gn
@@ -0,0 +1,1766 @@
+# 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/android/config.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromecast_build.gni")
+import("//build/config/compiler/compiler.gni")
+import("//build/toolchain/cc_wrapper.gni")
+import("//build/toolchain/toolchain.gni")
+import("//build_overrides/build.gni")
+
+if (current_cpu == "arm" || current_cpu == "arm64") {
+ import("//build/config/arm.gni")
+}
+if (current_cpu == "mipsel" || current_cpu == "mips64el") {
+ import("//build/config/mips.gni")
+}
+if (is_mac) {
+ import("//build/config/mac/symbols.gni")
+}
+if (is_ios) {
+ import("//build/config/ios/ios_sdk.gni")
+}
+if (is_nacl) {
+ # To keep NaCl variables out of builds that don't include NaCl, all
+ # variables defined in nacl/config.gni referenced here should be protected by
+ # is_nacl conditions.
+ import("//build/config/nacl/config.gni")
+}
+
+declare_args() {
+ # Default to warnings as errors for default workflow, where we catch
+ # warnings with known toolchains. Allow overriding this e.g. for Chromium
+ # builds on Linux that could use a different version of the compiler.
+ # With GCC, warnings in no-Chromium code are always not treated as errors.
+ treat_warnings_as_errors = true
+
+ # Normally, Android builds are lightly optimized, even for debug builds, to
+ # keep binary size down. Setting this flag to true disables such optimization
+ android_full_debug = false
+
+ # Whether to use the binary binutils checked into third_party/binutils.
+ # These are not multi-arch so cannot be used except on x86 and x86-64 (the
+ # only two architectures that are currently checked in). Turn this off when
+ # you are using a custom toolchain and need to control -B in cflags.
+ linux_use_bundled_binutils =
+ linux_use_bundled_binutils_override && is_linux &&
+ (current_cpu == "x64" || current_cpu == "x86")
+ binutils_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin",
+ root_build_dir)
+
+ # Compile in such a way as to make it possible for the profiler to unwind full
+ # stack frames. Setting this flag has a large effect on the performance of the
+ # generated code than just setting profiling, but gives the profiler more
+ # information to analyze.
+ # Requires profiling to be set to true.
+ enable_full_stack_frames_for_profiling = false
+
+ # When we are going to use gold we need to find it.
+ # This is initialized below, after use_gold might have been overridden.
+ gold_path = false
+
+ if (is_win) {
+ # Whether the VS xtree header has been patched to disable warning 4702. If
+ # it has, then we don't need to disable 4702 (unreachable code warning).
+ # The patch is preapplied to the internal toolchain and hence all bots.
+ msvs_xtree_patched = false
+ }
+
+ # Omit unwind support in official builds to save space.
+ # We can use breakpad for these builds.
+ exclude_unwind_tables = (is_chrome_branded && is_official_build) ||
+ (is_chromecast && !is_cast_desktop_build && !is_debug)
+
+ # If true, optimize for size. Does not affect windows builds.
+ # Linux & Mac favor speed over size.
+ # TODO(brettw) it's weird that Mac and desktop Linux are different. We should
+ # explore favoring size over speed in this case as well.
+ optimize_for_size = is_android || is_ios
+
+ # Enable fatal linker warnings. Building Chromium with certain versions
+ # of binutils can cause linker warning.
+ # See: https://bugs.chromium.org/p/chromium/issues/detail?id=457359
+ fatal_linker_warnings = true
+
+ # Build with C++ RTTI enabled. Chromium builds without RTTI by default,
+ # but some sanitizers are known to require it, like CFI diagnostics
+ # and UBsan variants.
+ use_rtti = use_cfi_diag || is_ubsan_vptr || is_ubsan_security
+
+ # AFDO (Automatic Feedback Directed Optimizer) is a form of profile-guided
+ # optimization that GCC supports. It used by ChromeOS in their official
+ # builds. To use it, set auto_profile_path to the path to a file containing
+ # the needed gcov profiling data.
+ auto_profile_path = ""
+
+ # Optimize for coverage guided fuzzing (balance between speed and number of
+ # branches)
+ optimize_for_fuzzing = false
+
+ # Optimize symbol files for maximizing goma cache hit rate. This isn't
+ # on by default when goma is enabled because setting this to true may make
+ # it harder to debug binaries.
+ strip_absolute_paths_from_debug_symbols = false
+}
+
+#if (is_clang && !is_nacl) {
+# update_args = [ "--print-revision" ]
+# if (llvm_force_head_revision) {
+# update_args += [ "--llvm-force-head-revision" ]
+# }
+# clang_revision =
+# exec_script("//tools/clang/scripts/update.py", update_args, "trim string")
+#}
+
+## Apply the default logic for these values if they were not set explicitly.
+#if (gold_path == false) {
+# if (use_gold) {
+# gold_path = rebase_path("//third_party/binutils/Linux_x64/Release/bin",
+# root_build_dir)
+# } else {
+# gold_path = ""
+# }
+#}
+
+if (use_debug_fission == "default") {
+ use_debug_fission =
+ is_debug && !is_android && !is_win && use_gold && cc_wrapper == ""
+}
+
+# default_include_dirs ---------------------------------------------------------
+#
+# This is a separate config so that third_party code (which would not use the
+# source root and might have conflicting versions of some headers) can remove
+# this and specify their own include paths.
+config("default_include_dirs") {
+ include_dirs = [
+ "//",
+ root_gen_dir,
+ ]
+}
+
+# compiler ---------------------------------------------------------------------
+#
+# Base compiler configuration.
+#
+# See also "runtime_library" below for related stuff and a discussion about
+# where stuff should go. Put warning related stuff in the "warnings" config.
+
+config("compiler") {
+ asmflags = []
+ cflags = []
+ cflags_c = []
+ cflags_cc = []
+ cflags_objc = []
+ cflags_objcc = []
+ ldflags = []
+ defines = []
+ configs = []
+
+ # System-specific flags. If your compiler flags apply to one of the
+ # categories here, add it to the associated file to keep this shared config
+ # smaller.
+ if (is_win) {
+ configs += [ "//build/config/win:compiler" ]
+ } else if (is_android) {
+ configs += [ "//build/config/android:compiler" ]
+ } else if (is_linux) {
+ configs += [ "//build/config/linux:compiler" ]
+ } else if (is_nacl) {
+ configs += [ "//build/config/nacl:compiler" ]
+ } else if (is_mac) {
+ configs += [ "//build/config/mac:compiler" ]
+ } else if (is_ios) {
+ configs += [ "//build/config/ios:compiler" ]
+ } else if (is_fuchsia) {
+ configs += [ "//build/config/fuchsia:compiler" ]
+ } else if (current_os == "aix") {
+ configs += [ "//build/config/aix:compiler" ]
+ }
+
+ # See the definitions below.
+ configs += [
+ ":compiler_cpu_abi",
+ ":compiler_codegen",
+ ]
+
+ # In general, Windows is totally different, but all the other builds share
+ # some common GCC configuration.
+ if (!is_win) {
+ # Common GCC compiler flags setup.
+ # --------------------------------
+ cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204
+
+ # Stack protection.
+ if (is_mac) {
+ # The strong variant of the stack protector significantly increases
+ # binary size, so only enable it in debug mode.
+ if (is_debug) {
+ cflags += [ "-fstack-protector-strong" ]
+ } else {
+ cflags += [ "-fstack-protector" ]
+ }
+ } else if (is_posix && !is_chromeos && !is_nacl) {
+ # TODO(phajdan.jr): Use -fstack-protector-strong when our gcc supports it.
+ # See also https://crbug.com/533294
+ cflags += [ "--param=ssp-buffer-size=4" ]
+
+ # The x86 toolchain currently has problems with stack-protector.
+ if (is_android && current_cpu == "x86") {
+ cflags += [ "-fno-stack-protector" ]
+ } else if (current_os != "aix") {
+ # Not available on aix.
+ cflags += [ "-fstack-protector" ]
+ }
+ }
+
+ # Linker warnings.
+ if (fatal_linker_warnings && !(is_chromeos && current_cpu == "arm") &&
+ !(is_android && use_order_profiling) && !is_mac && !is_ios &&
+ current_os != "aix") {
+ # TODO(jochen): Enable this on chromeos on arm. http://crbug.com/356580
+ # TODO(lizeb,pasko): Fix link errors when linking with order_profiling=1
+ # crbug.com/485542
+ ldflags += [ "-Wl,--fatal-warnings" ]
+ }
+ }
+
+ # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for
+ # deterministic build. See https://crbug.com/314403
+ if (!is_official_build) {
+ if (is_win && !is_clang) {
+ cflags += [
+ "/wd4117", # Trying to define or undefine a predefined macro.
+ "/D__DATE__=",
+ "/D__TIME__=",
+ "/D__TIMESTAMP__=",
+ ]
+ } else {
+ cflags += [
+ "-Wno-builtin-macro-redefined",
+ "-D__DATE__=",
+ "-D__TIME__=",
+ "-D__TIMESTAMP__=",
+ ]
+ }
+ }
+
+ if (is_clang && is_debug) {
+ # Allow comparing the address of references and 'this' against 0
+ # in debug builds. Technically, these can never be null in
+ # well-defined C/C++ and Clang can optimize such checks away in
+ # release builds, but they may be used in asserts in debug builds.
+ cflags_cc += [
+ "-Wno-undefined-bool-conversion",
+ "-Wno-tautological-undefined-compare",
+ ]
+ }
+
+ if (is_clang && !is_nacl) {
+ # This is here so that all files get recompiled after a clang roll and
+ # when turning clang on or off. (defines are passed via the command line,
+ # and build system rebuild things when their commandline changes). Nothing
+ # should ever read this define.
+ #defines += [ "CR_CLANG_REVISION=\"$clang_revision\"" ]
+ }
+
+ # Non-Mac Posix compiler flags setup.
+ # -----------------------------------
+ if (is_posix && !(is_mac || is_ios)) {
+ if (enable_profiling) {
+ if (!is_debug) {
+ cflags += [ "-g" ]
+
+ if (enable_full_stack_frames_for_profiling) {
+ cflags += [
+ "-fno-inline",
+ "-fno-optimize-sibling-calls",
+ ]
+ }
+ }
+ }
+
+ if (is_official_build) {
+ # Explicitly pass --build-id to ld. Compilers used to always pass this
+ # implicitly but don't any more (in particular clang when built without
+ # ENABLE_LINKER_BUILD_ID=ON). The crash infrastructure does need a build
+ # id, so explicitly enable it in official builds. It's not needed in
+ # unofficial builds and computing it does slow down the link, so go with
+ # faster links in unofficial builds.
+ ldflags += [ "-Wl,--build-id=sha1" ]
+ }
+
+ defines += [ "_FILE_OFFSET_BITS=64" ]
+
+ if (!is_android && !build_with_mozilla) {
+ defines += [
+ "_LARGEFILE_SOURCE",
+ "_LARGEFILE64_SOURCE",
+ ]
+ }
+
+ if (!is_nacl) {
+ if (exclude_unwind_tables) {
+ cflags += [
+ "-fno-unwind-tables",
+ "-fno-asynchronous-unwind-tables",
+ ]
+ defines += [ "NO_UNWIND_TABLES" ]
+ } else {
+ cflags += [ "-funwind-tables" ]
+ }
+ }
+ }
+
+ # Linux/Android common flags setup.
+ # ---------------------------------
+ if (is_linux || is_android || is_fuchsia) {
+ if (use_pic) {
+ cflags += [ "-fPIC" ]
+ ldflags += [ "-fPIC" ]
+ }
+
+ # Use pipes for communicating between sub-processes. Faster.
+ cflags += [ "-pipe" ]
+
+ ldflags += [
+ "-Wl,-z,noexecstack",
+ "-Wl,-z,now",
+ "-Wl,-z,relro",
+ ]
+ if (!using_sanitizer) {
+ if (!use_cfi_diag) {
+ ldflags += [ "-Wl,-z,defs" ]
+ }
+
+ # Functions interposed by the sanitizers can make ld think
+ # that some libraries aren't needed when they actually are,
+ # http://crbug.com/234010. As workaround, disable --as-needed.
+ if (!is_nacl && !is_android) {
+ # TODO(pcc): Fix linker bug which requires us to link pthread
+ # unconditionally here (crbug.com/623236).
+ ldflags += [
+ "-Wl,--no-as-needed",
+ "-lpthread",
+ ]
+ }
+ ldflags += [ "-Wl,--as-needed" ]
+ }
+ }
+
+ # Linux-specific compiler flags setup.
+ # ------------------------------------
+ if (is_android && is_clang) {
+ _rebased_android_toolchain_root =
+ rebase_path(android_toolchain_root, root_build_dir)
+
+ # Let clang find the linker in the NDK.
+ ldflags += [ "--gcc-toolchain=$_rebased_android_toolchain_root" ]
+ }
+
+ if (is_posix && use_lld && !is_nacl) {
+ ldflags += [ "-fuse-ld=lld" ]
+ } else if (use_gold) {
+ ldflags += [ "-fuse-ld=gold" ]
+ if (is_android) {
+ # Use -mstackrealign due to a bug on ia32 Jelly Bean.
+ # See crbug.com/521527
+ if (current_cpu == "x86") {
+ cflags += [ "-mstackrealign" ]
+ }
+ } else {
+ # On Android, this isn't needed. gcc in the NDK knows to look next to
+ # it with -fuse-ld=gold, and clang gets a --gcc-toolchain flag passed
+ # above.
+ ldflags += [ "-B$gold_path" ]
+
+ if (linux_use_bundled_binutils) {
+ ldflags += [
+ # Experimentation found that using four linking threads
+ # saved ~20% of link time.
+ # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
+ # Only apply this to the target linker, since the host
+ # linker might not be gold, but isn't used much anyway.
+ "-Wl,--threads",
+ "-Wl,--thread-count=4",
+ ]
+ }
+ }
+
+ # TODO(thestig): Make this flag work with GN.
+ #if (!is_official_build && !is_chromeos && !(is_asan || is_lsan || is_tsan || is_msan)) {
+ # ldflags += [
+ # "-Wl,--detect-odr-violations",
+ # ]
+ #}
+ } else if (linux_use_bundled_binutils) {
+ # Gold is the default linker for the bundled binutils so we explicitly
+ # enable the bfd linker when use_gold is not set.
+ ldflags += [ "-fuse-ld=bfd" ]
+ }
+
+ if (is_posix && (use_gold || (use_lld && !is_nacl)) && !using_sanitizer &&
+ !(is_android && use_order_profiling)) {
+ # TODO(thakis): Remove `!is_android` below once NDK gold has been rolled
+ # with the fix for https://sourceware.org/bugzilla/show_bug.cgi?id=17704
+ # merged. See also https://crbug.com/663886
+ # `linux_use_bundled_binutils` is to avoid breaking Linux distros which may
+ # still have a buggy gold.
+ # The bug only affects x86 and x64, so we can still use ICF when targeting
+ # other architectures.
+ if ((!is_android && linux_use_bundled_binutils) ||
+ !(current_cpu == "x86" || current_cpu == "x64")) {
+ ldflags += [ "-Wl,--icf=all" ]
+ }
+ }
+
+ if (linux_use_bundled_binutils) {
+ cflags += [ "-B$binutils_path" ]
+ }
+
+ # Clang-specific compiler flags setup.
+ # ------------------------------------
+ if (is_clang) {
+ cflags += [ "-fcolor-diagnostics" ]
+ }
+
+ # Print absolute paths in diagnostics. There is no precedent for doing this
+ # on Linux/Mac (GCC doesn't support it), but MSVC does this with /FC and
+ # Windows developers rely on it (crbug.com/636109) so only do this on Windows.
+ if (is_clang && is_win) {
+ cflags += [ "-fdiagnostics-absolute-paths" ]
+ }
+
+ # Makes builds independent of absolute file path.
+ # clang-cl (used if is_win) doesn't expose this flag.
+ # Currently disabled for nacl since its toolchain lacks this flag (too old).
+ # TODO(zforman): Once nacl's toolchain is updated, remove check.
+ if (is_clang && is_linux && strip_absolute_paths_from_debug_symbols) {
+ absolute_path = rebase_path("//.")
+ cflags += [ "-fdebug-prefix-map=$absolute_path=." ]
+ }
+
+ # C++11 compiler flags setup.
+ # ---------------------------
+ if (is_linux || is_android || (is_nacl && is_clang) || current_os == "aix") {
+ # gnu++11 instead of c++11 is needed because some code uses typeof() (a
+ # GNU extension).
+ # TODO(thakis): Eventually switch this to c++11 instead,
+ # http://crbug.com/427584
+ cflags_cc += [ "-std=gnu++11" ]
+ } else if (!is_win && !is_nacl) {
+ # TODO(mcgrathr) - the NaCl GCC toolchain doesn't support either gnu++11
+ # or c++11; we technically don't need this toolchain any more, but there
+ # are still a few buildbots using it, so until those are turned off
+ # we need the !is_nacl clause and the (is_nacl && is_clang) clause, above.
+ cflags_cc += [ "-std=c++11" ]
+ }
+
+ if (is_mac) {
+ cflags_cc += [ "-stdlib=libc++" ]
+ ldflags += [ "-stdlib=libc++" ]
+ }
+
+ # Add flags for link-time optimization. These flags enable
+ # optimizations/transformations that require whole-program visibility at link
+ # time, so they need to be applied to all translation units, and we may end up
+ # with miscompiles if only part of the program is compiled with LTO flags. For
+ # that reason, we cannot allow targets to enable or disable these flags, for
+ # example by disabling the optimize configuration.
+ # TODO(pcc): Make this conditional on is_official_build rather than on gn
+ # flags for specific features.
+ if (!is_debug && (allow_posix_link_time_opt || is_cfi) && !is_nacl) {
+ if (use_thin_lto) {
+ cflags += [ "-flto=thin" ]
+ ldflags += [ "-flto=thin" ]
+
+ # Limit the parallelism to avoid too agressive competition between
+ # linker jobs. This is still suboptimal to a potential dynamic
+ # resource allocation scheme, but should be good enough.
+ if (use_lld) {
+ ldflags += [
+ "-Wl,--thinlto-jobs=8",
+ "-Wl,--thinlto-cache-dir=" +
+ rebase_path("$root_out_dir/thinlto-cache", root_build_dir),
+ ]
+ } else {
+ ldflags += [ "-Wl,-plugin-opt,jobs=8" ]
+ }
+ } else {
+ cflags += [ "-flto" ]
+ ldflags += [ "-flto" ]
+
+ # Apply a lower LTO optimization level as the default is too slow.
+ if (is_linux) {
+ if (use_lld) {
+ ldflags += [ "-Wl,--lto-O1" ]
+ } else {
+ ldflags += [ "-Wl,-plugin-opt,O1" ]
+ }
+ } else if (is_mac) {
+ ldflags += [ "-Wl,-mllvm,-O1" ]
+ }
+ }
+
+ cflags += [ "-fwhole-program-vtables" ]
+ ldflags += [ "-fwhole-program-vtables" ]
+
+ # Work-around for http://openradar.appspot.com/20356002
+ if (is_mac) {
+ ldflags += [ "-Wl,-all_load" ]
+ }
+
+ # Allows the linker to apply --gc-sections and ICF to the LTO object file.
+ # Also, when targeting ARM, without this flag, LTO produces a .text section
+ # that is larger than the maximum call displacement, preventing the linker
+ # from relocating calls (http://llvm.org/PR22999).
+ if (is_linux) {
+ if (use_lld) {
+ ldflags += [
+ "-Wl,-mllvm,-function-sections",
+ "-Wl,-mllvm,-data-sections",
+ ]
+ } else {
+ ldflags += [
+ "-Wl,-plugin-opt,-function-sections",
+ "-Wl,-plugin-opt,-data-sections",
+ ]
+ }
+ }
+ }
+
+ # Pass the same C/C++ flags to the objective C/C++ compiler.
+ cflags_objc += cflags_c
+ cflags_objcc += cflags_cc
+
+ # Assign any flags set for the C compiler to asmflags so that they are sent
+ # to the assembler. The Windows assembler takes different types of flags
+ # so only do so for posix platforms.
+ if (is_posix) {
+ asmflags += cflags
+ asmflags += cflags_c
+ }
+}
+
+# This is separate from :compiler (and not even a sub-config there)
+# so that some targets can remove it from the list with:
+# configs -= [ "//build/config/compiler:pthread" ]
+config("pthread") {
+ if (is_linux) {
+ cflags = [ "-pthread" ]
+ ldflags = [ "-pthread" ]
+ }
+}
+
+# This provides the basic options to select the target CPU and ABI.
+# It is factored out of "compiler" so that special cases can use this
+# without using everything that "compiler" brings in. Options that
+# tweak code generation for a particular CPU do not belong here!
+# See "compiler_codegen", below.
+config("compiler_cpu_abi") {
+ cflags = []
+ ldflags = []
+
+ if (is_posix && !(is_mac || is_ios)) {
+ # CPU architecture. We may or may not be doing a cross compile now, so for
+ # simplicity we always explicitly set the architecture.
+ if (current_cpu == "x64") {
+ cflags += [
+ "-m64",
+ "-march=x86-64",
+ ]
+ ldflags += [ "-m64" ]
+ } else if (current_cpu == "x86") {
+ cflags += [ "-m32" ]
+ ldflags += [ "-m32" ]
+ if (!is_nacl) {
+ cflags += [
+ "-msse2",
+ "-mfpmath=sse",
+ "-mmmx",
+ ]
+ }
+ } else if (current_cpu == "arm") {
+ if (is_clang && !is_android && !is_nacl) {
+ cflags += [ "--target=arm-linux-gnueabihf" ]
+ ldflags += [ "--target=arm-linux-gnueabihf" ]
+ }
+ if (!is_nacl) {
+ cflags += [
+ "-march=$arm_arch",
+ "-mfloat-abi=$arm_float_abi",
+ ]
+ }
+ if (arm_tune != "") {
+ cflags += [ "-mtune=$arm_tune" ]
+ }
+ } else if (current_cpu == "arm64") {
+ if (is_clang && !is_android && !is_nacl) {
+ cflags += [ "--target=aarch64-linux-gnu" ]
+ ldflags += [ "--target=aarch64-linux-gnu" ]
+ }
+ } else if (current_cpu == "mipsel" && !is_nacl) {
+ if (mips_arch_variant == "r6") {
+ if (is_clang) {
+ cflags += [
+ "--target=mipsel-linux-gnu",
+ "-march=mips32r6",
+ ]
+ ldflags += [ "--target=mipsel-linux-gnu" ]
+ } else {
+ cflags += [
+ "-mips32r6",
+ "-Wa,-mips32r6",
+ ]
+ if (is_android) {
+ ldflags += [
+ "-mips32r6",
+ "-Wl,-melf32ltsmip",
+ ]
+ }
+ }
+ if (mips_use_msa == true) {
+ cflags += [
+ "-mmsa",
+ "-mfp64",
+ ]
+ }
+ } else if (mips_arch_variant == "r2") {
+ if (is_clang) {
+ if (is_android) {
+ cflags += [
+ "--target=mipsel-linux-android",
+ "-march=mipsel",
+ "-mcpu=mips32r2",
+ ]
+ ldflags += [ "--target=mipsel-linux-android" ]
+ } else {
+ cflags += [
+ "--target=mipsel-linux-gnu",
+ "-march=mipsel",
+ "-mcpu=mips32r2",
+ ]
+ ldflags += [ "--target=mipsel-linux-gnu" ]
+ }
+ } else {
+ cflags += [
+ "-mips32r2",
+ "-Wa,-mips32r2",
+ ]
+ if (mips_float_abi == "hard" && mips_fpu_mode != "") {
+ cflags += [ "-m$mips_fpu_mode" ]
+ }
+ }
+ } else if (mips_arch_variant == "r1") {
+ if (is_clang) {
+ if (is_android) {
+ cflags += [
+ "--target=mipsel-linux-android",
+ "-march=mipsel",
+ "-mcpu=mips32",
+ ]
+ ldflags += [ "--target=mipsel-linux-android" ]
+ } else {
+ cflags += [
+ "--target=mipsel-linux-gnu",
+ "-march=mipsel",
+ "-mcpu=mips32",
+ ]
+ ldflags += [ "--target=mipsel-linux-gnu" ]
+ }
+ } else {
+ cflags += [
+ "-mips32",
+ "-Wa,-mips32",
+ ]
+ }
+ }
+
+ if (mips_dsp_rev == 1) {
+ cflags += [ "-mdsp" ]
+ } else if (mips_dsp_rev == 2) {
+ cflags += [ "-mdspr2" ]
+ }
+
+ cflags += [ "-m${mips_float_abi}-float" ]
+ } else if (current_cpu == "mips64el") {
+ if (mips_arch_variant == "r6") {
+ if (is_clang) {
+ if (is_android) {
+ cflags += [
+ "--target=mips64el-linux-android",
+ "-march=mips64el",
+ "-mcpu=mips64r6",
+ ]
+ ldflags += [ "--target=mips64el-linux-android" ]
+ }
+ } else {
+ cflags += [
+ "-mips64r6",
+ "-Wa,-mips64r6",
+ ]
+ ldflags += [ "-mips64r6" ]
+ }
+ if (mips_use_msa == true) {
+ cflags += [
+ "-mmsa",
+ "-mfp64",
+ ]
+ }
+ } else if (mips_arch_variant == "r2") {
+ cflags += [
+ "-mips64r2",
+ "-Wa,-mips64r2",
+ ]
+ ldflags += [ "-mips64r2" ]
+ }
+ } else if (current_cpu == "pnacl" && is_nacl_nonsfi) {
+ if (target_cpu == "x86" || target_cpu == "x64") {
+ cflags += [
+ "-arch",
+ "x86-32-nonsfi",
+ "--pnacl-bias=x86-32-nonsfi",
+ "--target=i686-unknown-nacl",
+ ]
+ ldflags += [
+ "-arch",
+ "x86-32-nonsfi",
+ "--target=i686-unknown-nacl",
+ ]
+ } else if (target_cpu == "arm") {
+ cflags += [
+ "-arch",
+ "arm-nonsfi",
+ "-mfloat-abi=hard",
+ "--pnacl-bias=arm-nonsfi",
+ "--target=armv7-unknown-nacl-gnueabihf",
+ ]
+ ldflags += [
+ "-arch",
+ "arm-nonsfi",
+ "--target=armv7-unknown-nacl-gnueabihf",
+ ]
+ }
+ }
+ }
+
+ asmflags = cflags
+}
+
+# This provides options to tweak code generation that are necessary
+# for particular Chromium code or for working around particular
+# compiler bugs (or the combination of the two).
+config("compiler_codegen") {
+ configs = []
+ cflags = []
+
+ if (is_nacl) {
+ configs += [ "//build/config/nacl:compiler_codegen" ]
+ } else if (is_posix && !is_mac && !is_ios) {
+ if (current_cpu == "x86") {
+ if (is_clang) {
+ cflags += [
+ # Else building libyuv gives clang's register allocator issues,
+ # see llvm.org/PR15798 / crbug.com/233709
+ "-momit-leaf-frame-pointer",
+ ]
+ }
+ } else if (current_cpu == "arm") {
+ if (is_android && !is_clang) {
+ # Clang doesn't support these flags.
+ cflags += [
+ # The tree-sra optimization (scalar replacement for
+ # aggregates enabling subsequent optimizations) leads to
+ # invalid code generation when using the Android NDK's
+ # compiler (r5-r7). This can be verified using
+ # webkit_unit_tests' WTF.Checked_int8_t test.
+ "-fno-tree-sra",
+
+ # The following option is disabled to improve binary
+ # size and performance in gcc 4.9.
+ "-fno-caller-saves",
+ ]
+ }
+ }
+ }
+
+ asmflags = cflags
+}
+
+# This is separate from :compiler_codegen (and not even a sub-config there)
+# so that some targets can remove it from the list with:
+# configs -= [ "//build/config/compiler:clang_stackrealign" ]
+# See https://crbug.com/556393 for details of where it must be avoided.
+config("clang_stackrealign") {
+ if (is_clang && current_cpu == "x86" && is_linux) {
+ cflags = [
+ # Align the stack on 16-byte boundaries, http://crbug.com/418554.
+ "-mstack-alignment=16",
+ "-mstackrealign",
+ ]
+ }
+}
+
+config("compiler_arm_fpu") {
+ if (current_cpu == "arm" && !is_ios && !is_nacl) {
+ cflags = [ "-mfpu=$arm_fpu" ]
+ asmflags = cflags
+ }
+}
+
+config("compiler_arm_thumb") {
+ if (current_cpu == "arm" && arm_use_thumb && is_posix &&
+ !(is_mac || is_ios || is_nacl)) {
+ cflags = [ "-mthumb" ]
+ if (is_android && !is_clang) {
+ # Clang doesn't support this option.
+ cflags += [ "-mthumb-interwork" ]
+ }
+ }
+}
+
+config("compiler_arm") {
+ if (current_cpu == "arm" && is_chromeos) {
+ # arm is normally the default mode for clang, but on chromeos a wrapper
+ # is used to pass -mthumb, and therefor change the default.
+ cflags = [ "-marm" ]
+ }
+}
+
+# runtime_library -------------------------------------------------------------
+#
+# Sets the runtime library and associated options.
+#
+# How do you determine what should go in here vs. "compiler" above? Consider if
+# a target might choose to use a different runtime library (ignore for a moment
+# if this is possible or reasonable on your system). If such a target would want
+# to change or remove your option, put it in the runtime_library config. If a
+# target wants the option regardless, put it in the compiler config.
+
+config("runtime_library") {
+ defines = []
+ configs = []
+
+ # System-specific flags. If your compiler flags apply to one of the
+ # categories here, add it to the associated file to keep this shared config
+ # smaller.
+ if (is_win) {
+ configs += [ "//build/config/win:runtime_library" ]
+ } else if (is_linux) {
+ configs += [ "//build/config/linux:runtime_library" ]
+ } else if (is_ios) {
+ configs += [ "//build/config/ios:runtime_library" ]
+ } else if (is_mac) {
+ configs += [ "//build/config/mac:runtime_library" ]
+ } else if (is_android) {
+ configs += [ "//build/config/android:runtime_library" ]
+ }
+
+ if (is_posix) {
+ configs += [ "//build/config/posix:runtime_library" ]
+ }
+
+ if (is_component_build) {
+ defines += [ "COMPONENT_BUILD" ]
+ }
+}
+
+# default_warnings ------------------------------------------------------------
+#
+# Collects all warning flags that are used by default. This is used as a
+# subconfig of both chromium_code and no_chromium_code. This way these
+# flags are guaranteed to appear on the compile command line after -Wall.
+config("default_warnings") {
+ cflags = []
+ cflags_cc = []
+ ldflags = []
+
+ if (is_win) {
+ if (treat_warnings_as_errors) {
+ cflags += [ "/WX" ]
+ }
+ if (fatal_linker_warnings) {
+ ldflags += [ "/WX" ]
+ }
+
+ cflags += [
+ # Assume UTF-8 by default to avoid code page dependencies.
+ "/utf-8",
+ ]
+
+ cflags += [
+ # Warnings permanently disabled:
+
+ # C4091: 'typedef ': ignored on left of 'X' when no variable is
+ # declared.
+ # This happens in a number of Windows headers. Dumb.
+ "/wd4091",
+
+ # C4127: conditional expression is constant
+ # This warning can in theory catch dead code and other problems, but
+ # triggers in far too many desirable cases where the conditional
+ # expression is either set by macros or corresponds some legitimate
+ # compile-time constant expression (due to constant template args,
+ # conditionals comparing the sizes of different types, etc.). Some of
+ # these can be worked around, but it's not worth it.
+ "/wd4127",
+
+ # C4251: 'identifier' : class 'type' needs to have dll-interface to be
+ # used by clients of class 'type2'
+ # This is necessary for the shared library build.
+ "/wd4251",
+
+ # C4312 is a VS 2015 64-bit warning for integer to larger pointer.
+ # TODO(brucedawson): fix warnings, crbug.com/554200
+ "/wd4312",
+
+ # C4351: new behavior: elements of array 'array' will be default
+ # initialized
+ # This is a silly "warning" that basically just alerts you that the
+ # compiler is going to actually follow the language spec like it's
+ # supposed to, instead of not following it like old buggy versions did.
+ # There's absolutely no reason to turn this on.
+ "/wd4351",
+
+ # C4355: 'this': used in base member initializer list
+ # It's commonly useful to pass |this| to objects in a class' initializer
+ # list. While this warning can catch real bugs, most of the time the
+ # constructors in question don't attempt to call methods on the passed-in
+ # pointer (until later), and annotating every legit usage of this is
+ # simply more hassle than the warning is worth.
+ "/wd4355",
+
+ # C4503: 'identifier': decorated name length exceeded, name was
+ # truncated
+ # This only means that some long error messages might have truncated
+ # identifiers in the presence of lots of templates. It has no effect on
+ # program correctness and there's no real reason to waste time trying to
+ # prevent it.
+ "/wd4503",
+
+ # Warning C4589 says: "Constructor of abstract class ignores
+ # initializer for virtual base class." Disable this warning because it
+ # is flaky in VS 2015 RTM. It triggers on compiler generated
+ # copy-constructors in some cases.
+ "/wd4589",
+
+ # C4611: interaction between 'function' and C++ object destruction is
+ # non-portable
+ # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN
+ # suggests using exceptions instead of setjmp/longjmp for C++, but
+ # Chromium code compiles without exception support. We therefore have to
+ # use setjmp/longjmp for e.g. JPEG decode error handling, which means we
+ # have to turn off this warning (and be careful about how object
+ # destruction happens in such cases).
+ "/wd4611",
+
+ # Warnings to evaluate and possibly fix/reenable later:
+
+ "/wd4100", # Unreferenced formal function parameter.
+ "/wd4121", # Alignment of a member was sensitive to packing.
+ "/wd4244", # Conversion: possible loss of data.
+ "/wd4505", # Unreferenced local function has been removed.
+ "/wd4510", # Default constructor could not be generated.
+ "/wd4512", # Assignment operator could not be generated.
+ "/wd4610", # Class can never be instantiated, constructor required.
+ "/wd4838", # Narrowing conversion. Doesn't seem to be very useful.
+ "/wd4995", # 'X': name was marked as #pragma deprecated
+ "/wd4996", # Deprecated function warning.
+
+ # These are variable shadowing warnings that are new in VS2015. We
+ # should work through these at some point -- they may be removed from
+ # the RTM release in the /W4 set.
+ "/wd4456",
+ "/wd4457",
+ "/wd4458",
+ "/wd4459",
+ ]
+
+ cflags_cc += [
+ # Allow "noexcept" annotations even though we compile with exceptions
+ # disabled.
+ "/wd4577",
+ ]
+
+ if (current_cpu == "x86") {
+ cflags += [
+ # VC++ 2015 changes 32-bit size_t truncation warnings from 4244 to
+ # 4267. Example: short TruncTest(size_t x) { return x; }
+ # Since we disable 4244 we need to disable 4267 during migration.
+ # TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
+ "/wd4267",
+ ]
+ }
+
+ # VS xtree header file needs to be patched or 4702 (unreachable code
+ # warning) is reported if _HAS_EXCEPTIONS=0. Disable the warning if xtree is
+ # not patched.
+ if (!msvs_xtree_patched &&
+ exec_script("../../win_is_xtree_patched.py", [], "value") == 0) {
+ cflags += [ "/wd4702" ] # Unreachable code.
+ }
+
+ # Building with Clang on Windows is a work in progress and very
+ # experimental. See crbug.com/82385.
+ if (is_clang) {
+ cflags += [
+ # TODO(hans): Make this list shorter eventually, http://crbug.com/504657
+ "-Wno-microsoft-enum-value", # http://crbug.com/505296
+ "-Wno-unknown-pragmas", # http://crbug.com/505314
+ "-Wno-microsoft-cast", # http://crbug.com/550065
+ "-Wno-microsoft-enum-forward-reference", # http://crbug.com/718880
+ ]
+ }
+ } else {
+ if (is_mac && !is_nacl) {
+ # When compiling Objective-C, warns if a method is used whose
+ # availability is newer than the deployment target. This is not
+ # required when compiling Chrome for iOS.
+ cflags += [ "-Wpartial-availability" ]
+ }
+
+ if (is_ios) {
+ # When compiling Objective-C, warns if a selector named via @selector has
+ # not been defined in any visible interface.
+ cflags += [ "-Wundeclared-selector" ]
+ }
+
+ # Suppress warnings about ABI changes on ARM (Clang doesn't give this
+ # warning).
+ if (current_cpu == "arm" && !is_clang) {
+ cflags += [ "-Wno-psabi" ]
+ }
+
+ if (!is_clang) {
+ cflags_cc += [
+ # See comment for -Wno-c++11-narrowing.
+ "-Wno-narrowing",
+ ]
+
+ # Don't warn about the "typedef 'foo' locally defined but not used"
+ # for gcc 4.8.
+ # TODO: remove this flag once all builds work. See crbug.com/227506
+ cflags += [ "-Wno-unused-local-typedefs" ]
+
+ # Don't warn about "maybe" uninitialized. Clang doesn't include this
+ # in -Wall but gcc does, and it gives false positives.
+ cflags += [ "-Wno-maybe-uninitialized" ]
+ }
+ }
+
+ # Common Clang and GCC warning setup.
+ if (!is_win || is_clang) {
+ cflags += [
+ # Disables.
+ "-Wno-missing-field-initializers", # "struct foo f = {0};"
+ "-Wno-unused-parameter", # Unused function parameters.
+ ]
+ }
+
+ if (is_chromeos && is_clang && !is_nacl) {
+ # TODO(thakis): Enable this, crbug.com/507717
+ cflags += [ "-Wno-shift-negative-value" ]
+ }
+
+ if (is_clang) {
+ cflags += [
+ # TODO(thakis): Consider -Wloop-analysis (turns on
+ # -Wrange-loop-analysis too).
+
+ # This warns on using ints as initializers for floats in
+ # initializer lists (e.g. |int a = f(); CGSize s = { a, a };|),
+ # which happens in several places in chrome code. Not sure if
+ # this is worth fixing.
+ "-Wno-c++11-narrowing",
+
+ # Warns on switches on enums that cover all enum values but
+ # also contain a default: branch. Chrome is full of that.
+ "-Wno-covered-switch-default",
+
+ # TODO(thakis): This used to be implied by -Wno-unused-function,
+ # which we no longer use. Check if it makes sense to remove
+ # this as well. http://crbug.com/316352
+ "-Wno-unneeded-internal-declaration",
+
+ # TODO(hans): Get this cleaned up, http://crbug.com/428099
+ "-Wno-inconsistent-missing-override",
+ ]
+
+ if (is_linux && target_cpu == "x86") {
+ cflags += [
+ # TODO(thakis): Remove from 32-bit Linux eventually, https://707084
+ "-Wno-deprecated-register",
+ ]
+ }
+
+ # use_xcode_clang only refers to the iOS toolchain, host binaries use
+ # chromium's clang always.
+ if (!is_nacl && (!use_xcode_clang || current_toolchain == host_toolchain)) {
+ # Flags NaCl (Clang 3.7) and Xcode 7.3 (Clang clang-703.0.31) do not
+ # recognize.
+ cflags += [
+ # TODO(thakis): https://crbug.com/604888
+ "-Wno-undefined-var-template",
+
+ # TODO(thakis): https://crbug.com/617318
+ "-Wno-nonportable-include-path",
+
+ # TODO(hans): https://crbug.com/637306
+ "-Wno-address-of-packed-member",
+
+ # TODO(hans): https://crbug.com/681136
+ "-Wno-unused-lambda-capture",
+
+ # TODO(thakis ): https://crbug.com/683349
+ "-Wno-user-defined-warnings",
+ ]
+ } else if (use_xcode_clang &&
+ (xcode_version == "0830" || xcode_version == "0831" ||
+ xcode_version == "0832")) {
+ # This is necessary to allow a progressive transition from using xcode 8 to 8.3. Remove when all bots are migrated to 8.3.
+ cflags += [
+ # TODO(thakis): https://crbug.com/604888
+ "-Wno-undefined-var-template",
+
+ # TODO(hans): https://crbug.com/637306
+ "-Wno-address-of-packed-member",
+ ]
+ }
+ }
+}
+
+# chromium_code ---------------------------------------------------------------
+#
+# Toggles between higher and lower warnings for code that is (or isn't)
+# part of Chromium.
+
+config("chromium_code") {
+ if (is_win) {
+ cflags = [ "/W4" ] # Warning level 4.
+ } else {
+ cflags = [ "-Wall" ]
+ if (treat_warnings_as_errors) {
+ cflags += [ "-Werror" ]
+
+ # The compiler driver can sometimes (rarely) emit warnings before calling
+ # the actual linker. Make sure these warnings are treated as errors as
+ # well.
+ ldflags = [ "-Werror" ]
+ }
+ if (is_clang) {
+ # Enable -Wextra for chromium_code when we control the compiler.
+ cflags += [ "-Wextra" ]
+ }
+
+ # In Chromium code, we define __STDC_foo_MACROS in order to get the
+ # C99 macros on Mac and Linux.
+ defines = []
+ if (!build_with_mozilla) {
+ defines += [
+ "__STDC_CONSTANT_MACROS",
+ "__STDC_FORMAT_MACROS",
+ ]
+ }
+
+ if (!is_debug && !using_sanitizer &&
+ (!is_linux || !is_clang || is_official_build) &&
+ current_cpu != "s390x" && current_cpu != "s390" &&
+ current_cpu != "ppc64" && current_cpu != "ppc64") {
+ # _FORTIFY_SOURCE isn't really supported by Clang now, see
+ # http://llvm.org/bugs/show_bug.cgi?id=16821.
+ # It seems to work fine with Ubuntu 12 headers though, so use it in
+ # official builds.
+ #
+ # Non-chromium code is not guaranteed to compile cleanly with
+ # _FORTIFY_SOURCE. Also, fortified build may fail when optimizations are
+ # disabled, so only do that for Release build.
+ defines += [ "_FORTIFY_SOURCE=2" ]
+ }
+
+ if (is_mac || is_ios) {
+ cflags_objc = [ "-Wobjc-missing-property-synthesis" ]
+ cflags_objcc = [ "-Wobjc-missing-property-synthesis" ]
+ }
+ }
+
+ configs = [ ":default_warnings" ]
+}
+
+config("no_chromium_code") {
+ cflags = []
+ cflags_cc = []
+ defines = []
+
+ if (is_win) {
+ cflags += [
+ "/W3", # Warning level 3.
+ "/wd4800", # Disable warning when forcing value to bool.
+ "/wd4267", # TODO(jschuh): size_t to int.
+ "/wd4996", # Deprecated function warning.
+ ]
+ defines += [
+ "_CRT_NONSTDC_NO_WARNINGS",
+ "_CRT_NONSTDC_NO_DEPRECATE",
+ ]
+ } else {
+ # GCC may emit unsuppressible warnings so don't add -Werror for no chromium
+ # code. crbug.com/589724
+ if (treat_warnings_as_errors && is_clang) {
+ cflags += [ "-Werror" ]
+ ldflags = [ "-Werror" ]
+ }
+ if (is_clang && !is_nacl) {
+ # TODO(thakis): Remove !is_nacl once
+ # https://codereview.webrtc.org/1552863002/ made its way into chromium.
+ cflags += [ "-Wall" ]
+ }
+ }
+
+ if (is_clang) {
+ cflags += [
+ # Lots of third-party libraries have unused variables. Instead of
+ # suppressing them individually, we just blanket suppress them here.
+ "-Wno-unused-variable",
+ ]
+ }
+
+ configs = [ ":default_warnings" ]
+}
+
+# rtti ------------------------------------------------------------------------
+#
+# Allows turning Run-Time Type Identification on or off.
+
+config("rtti") {
+ if (is_win) {
+ cflags_cc = [ "/GR" ]
+ } else {
+ cflags_cc = [ "-frtti" ]
+ }
+}
+
+config("no_rtti") {
+ # Some sanitizer configs may require RTTI to be left enabled globally
+ if (!use_rtti) {
+ if (is_win) {
+ cflags_cc = [ "/GR-" ]
+ } else {
+ cflags_cc = [ "-fno-rtti" ]
+ cflags_objcc = cflags_cc
+ }
+ }
+}
+
+# Warnings ---------------------------------------------------------------------
+
+# This will generate warnings when using Clang if code generates exit-time
+# destructors, which will slow down closing the program.
+# TODO(thakis): Make this a blacklist instead, http://crbug.com/101600
+config("wexit_time_destructors") {
+ # TODO: Enable on Windows too, http://crbug.com/404525
+ if (is_clang && !is_win) {
+ cflags = [ "-Wexit-time-destructors" ]
+ }
+}
+
+# On Windows compiling on x64, VC will issue a warning when converting
+# size_t to int because it will truncate the value. Our code should not have
+# these warnings and one should use a static_cast or a checked_cast for the
+# conversion depending on the case. However, a lot of code still needs to be
+# fixed. Apply this config to such targets to disable the warning.
+#
+# Note that this can be applied regardless of platform and architecture to
+# clean up the call sites. This will only apply the flag when necessary.
+#
+# TODO(jschuh): crbug.com/167187 fix this and delete this config.
+config("no_size_t_to_int_warning") {
+ if (is_win && current_cpu == "x64") {
+ cflags = [ "/wd4267" ]
+ }
+}
+
+# Some code presumes that pointers to structures/objects are compatible
+# regardless of whether what they point to is already known to be valid.
+# gcc 4.9 and earlier had no way of suppressing this warning without
+# supressing the rest of them. Here we centralize the identification of
+# the gcc 4.9 toolchains.
+config("no_incompatible_pointer_warnings") {
+ cflags = []
+ if (is_clang) {
+ cflags += [ "-Wno-incompatible-pointer-types" ]
+ } else if (current_cpu == "mipsel") {
+ cflags += [ "-w" ]
+ } else if (is_chromeos && current_cpu == "arm") {
+ cflags += [ "-w" ]
+ }
+}
+
+# Optimization -----------------------------------------------------------------
+#
+# The BUILDCONFIG file sets the "default_optimization" config on targets by
+# default. It will be equivalent to either "optimize" (release) or
+# "no_optimize" (debug) optimization configs.
+#
+# You can override the optimization level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+# configs -= [ "//build/config/compiler:default_optimization" ]
+# configs += [ "//build/config/compiler:optimize_max" ]
+
+# Shared settings for both "optimize" and "optimize_max" configs.
+# IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags.
+if (is_win) {
+ common_optimize_on_cflags = [
+ "/Ob2", # Both explicit and auto inlining.
+ "/Oy-", # Disable omitting frame pointers, must be after /O2.
+ "/d2Zi+", # Improve debugging of optimized code.
+ "/Zc:inline", # Remove unreferenced COMDAT (faster links).
+ ]
+ if (!is_asan) {
+ common_optimize_on_cflags += [
+ # Put data in separate COMDATs. This allows the linker
+ # to put bit-identical constants at the same address even if
+ # they're unrelated constants, which saves binary size.
+ # This optimization can't be used when ASan is enabled because
+ # it is not compatible with the ASan ODR checker.
+ "/Gw",
+ ]
+ }
+ common_optimize_on_ldflags = []
+
+ # /OPT:ICF is not desirable in Debug builds, since code-folding can result in
+ # misleading symbols in stack traces. It is also incompatible with
+ # incremental linking, which we enable for both Debug and component builds.
+ if (!is_debug && !is_component_build) {
+ common_optimize_on_ldflags += [ "/OPT:ICF" ] # Redundant COMDAT folding.
+ }
+
+ if (is_official_build) {
+ common_optimize_on_ldflags += [ "/OPT:REF" ] # Remove unreferenced data.
+ if (!use_lld) {
+ common_optimize_on_ldflags += [
+ # Set the number of LTCG code-gen threads to eight. The default is four.
+ # This gives a 5-10% link speedup.
+ "/cgthreads:8",
+ ]
+ if (use_incremental_wpo) {
+ # Incremental Link-time code generation.
+ common_optimize_on_ldflags += [ "/LTCG:INCREMENTAL" ]
+ } else {
+ common_optimize_on_ldflags += [ "/LTCG" ] # Link-time code generation.
+ }
+ if (full_wpo_on_official) {
+ if (use_incremental_wpo) {
+ arflags = [ "/LTCG:INCREMENTAL" ]
+ } else {
+ arflags = [ "/LTCG" ]
+ }
+ }
+ }
+ }
+} else {
+ common_optimize_on_cflags = []
+ common_optimize_on_ldflags = []
+
+ if (is_android) {
+ # TODO(jdduke) Re-enable on mips after resolving linking
+ # issues with libc++ (crbug.com/456380).
+ if (current_cpu != "mipsel" && current_cpu != "mips64el") {
+ common_optimize_on_ldflags += [
+ # Warn in case of text relocations.
+ "-Wl,--warn-shared-textrel",
+ ]
+ }
+ }
+
+ if (is_mac || is_ios) {
+ if (symbol_level == 2) {
+ # Mac dead code stripping requires symbols.
+ common_optimize_on_ldflags += [ "-Wl,-dead_strip" ]
+ }
+ } else if (current_os != "aix") {
+ # Non-Mac Posix flags.
+ # Aix does not support these.
+
+ common_optimize_on_cflags += [
+ # Don't emit the GCC version ident directives, they just end up in the
+ # .comment section taking up binary size.
+ "-fno-ident",
+
+ # Put data and code in their own sections, so that unused symbols
+ # can be removed at link time with --gc-sections.
+ "-fdata-sections",
+ "-ffunction-sections",
+ ]
+
+ common_optimize_on_ldflags += [
+ # Specifically tell the linker to perform optimizations.
+ # See http://lwn.net/Articles/192624/ .
+ "-Wl,-O1",
+ "-Wl,--gc-sections",
+ ]
+ }
+}
+
+config("default_stack_frames") {
+ if (is_posix) {
+ if (enable_frame_pointers) {
+ cflags = [ "-fno-omit-frame-pointer" ]
+ } else {
+ cflags = [ "-fomit-frame-pointer" ]
+ }
+ }
+ # On Windows, the flag to enable framepointers "/Oy-" must always come after
+ # the optimization flag [e.g. "/O2"]. The optimization flag is set by one of
+ # the "optimize" configs, see rest of this file. The ordering that cflags are
+ # applied is well-defined by the GN spec, and there is no way to ensure that
+ # cflags set by "default_stack_frames" is applied after those set by an
+ # "optimize" config. Similarly, there is no way to propagate state from this
+ # config into the "optimize" config. We always apply the "/Oy-" config in the
+ # definition for common_optimize_on_cflags definition, even though this may
+ # not be correct.
+}
+
+# Default "optimization on" config.
+config("optimize") {
+ if (is_win) {
+ # TODO(thakis): Remove is_clang here, https://crbug.com/598772
+ if (is_official_build && full_wpo_on_official && !is_clang) {
+ common_optimize_on_cflags += [
+ "/GL", # Whole program optimization.
+
+ # Disable Warning 4702 ("Unreachable code") for the WPO/PGO builds.
+ # Probably anything that this would catch that wouldn't be caught in a
+ # normal build isn't going to actually be a bug, so the incremental
+ # value of C4702 for PGO builds is likely very small.
+ "/wd4702",
+ ]
+ }
+
+ # Favor size over speed, /O1 must be before the common flags. The GYP
+ # build also specifies /Os and /GF but these are implied by /O1.
+ cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
+ } else if (optimize_for_size && !is_nacl) {
+ # Favor size over speed.
+ # TODO(crbug.com/718650): Fix -Os in PNaCl compiler and remove the is_nacl
+ # guard above.
+ if (is_clang) {
+ cflags = [ "-Oz" ] + common_optimize_on_cflags
+ } else {
+ cflags = [ "-Os" ] + common_optimize_on_cflags
+ }
+ } else {
+ cflags = [ "-O2" ] + common_optimize_on_cflags
+ }
+ ldflags = common_optimize_on_ldflags
+}
+
+# Same config as 'optimize' but without the WPO flag.
+config("optimize_no_wpo") {
+ if (is_win) {
+ # Favor size over speed, /O1 must be before the common flags. The GYP
+ # build also specifies /Os and /GF but these are implied by /O1.
+ cflags = [ "/O1" ] + common_optimize_on_cflags + [ "/Oi" ]
+ } else if (optimize_for_size && !is_nacl) {
+ # Favor size over speed.
+ # TODO(crbug.com/718650): Fix -Os in PNaCl compiler and remove the is_nacl
+ # guard above.
+ if (is_clang) {
+ cflags = [ "-Oz" ] + common_optimize_on_cflags
+ } else {
+ cflags = [ "-Os" ] + common_optimize_on_cflags
+ }
+ } else if (optimize_for_fuzzing) {
+ cflags = [ "-O1" ] + common_optimize_on_cflags
+ } else {
+ cflags = [ "-O2" ] + common_optimize_on_cflags
+ }
+ ldflags = common_optimize_on_ldflags
+}
+
+# Turn off optimizations.
+config("no_optimize") {
+ if (is_win) {
+ cflags = [
+ "/Od", # Disable optimization.
+ "/Ob0", # Disable all inlining (on by default).
+ "/GF", # Enable string pooling (off by default).
+ ]
+ } else if (is_android && !android_full_debug) {
+ # On Android we kind of optimize some things that don't affect debugging
+ # much even when optimization is disabled to get the binary size down.
+ if (is_clang) {
+ cflags = [ "-Oz" ] + common_optimize_on_cflags
+ } else {
+ cflags = [ "-Os" ] + common_optimize_on_cflags
+ }
+ } else {
+ cflags = [ "-O0" ]
+ ldflags = []
+ }
+}
+
+# Turns up the optimization level. On Windows, this implies whole program
+# optimization and link-time code generation which is very expensive and should
+# be used sparingly.
+config("optimize_max") {
+ if (is_nacl && is_nacl_irt) {
+ # The NaCl IRT is a special case and always wants its own config.
+ # Various components do:
+ # if (!is_debug) {
+ # configs -= [ "//build/config/compiler:default_optimization" ]
+ # configs += [ "//build/config/compiler:optimize_max" ]
+ # }
+ # So this config has to have the selection logic just like
+ # "default_optimization", below.
+ configs = [ "//build/config/nacl:irt_optimize" ]
+ } else {
+ ldflags = common_optimize_on_ldflags
+ if (is_win) {
+ # Favor speed over size, /O2 must be before the common flags. The GYP
+ # build also specifies /Ot, /Oi, and /GF, but these are implied by /O2.
+ cflags = [ "/O2" ] + common_optimize_on_cflags
+
+ if (is_official_build) {
+ if (!is_clang) {
+ cflags += [
+ "/GL", # Whole program optimization.
+
+ # Disable Warning 4702 ("Unreachable code") for the WPO/PGO builds.
+ # Probably anything that this would catch that wouldn't be caught
+ # in a normal build isn't going to actually be a bug, so the
+ # incremental value of C4702 for PGO builds is likely very small.
+ "/wd4702",
+ ]
+ }
+ # TODO(crbug.com/598772): Enable -flto for Clang.
+ }
+ } else if (optimize_for_fuzzing) {
+ cflags = [ "-O1" ] + common_optimize_on_cflags
+ } else {
+ cflags = [ "-O2" ] + common_optimize_on_cflags
+ }
+ }
+}
+
+# This config can be used to override the default settings for per-component
+# and whole-program optimization, optimizing the particular target for speed
+# instead of code size. This config is exactly the same as "optimize_max"
+# except that we use -O3 instead of -O2 on non-win, non-IRT platforms.
+#
+# TODO(crbug.com/621335) - rework how all of these configs are related
+# so that we don't need this disclaimer.
+config("optimize_speed") {
+ if (is_nacl && is_nacl_irt) {
+ # The NaCl IRT is a special case and always wants its own config.
+ # Various components do:
+ # if (!is_debug) {
+ # configs -= [ "//build/config/compiler:default_optimization" ]
+ # configs += [ "//build/config/compiler:optimize_max" ]
+ # }
+ # So this config has to have the selection logic just like
+ # "default_optimization", below.
+ configs = [ "//build/config/nacl:irt_optimize" ]
+ } else {
+ ldflags = common_optimize_on_ldflags
+ if (is_win) {
+ # Favor speed over size, /O2 must be before the common flags. The GYP
+ # build also specifies /Ot, /Oi, and /GF, but these are implied by /O2.
+ cflags = [ "/O2" ] + common_optimize_on_cflags
+
+ # TODO(thakis): Remove is_clang here, https://crbug.com/598772
+ if (is_official_build && !is_clang) {
+ cflags += [
+ "/GL", # Whole program optimization.
+
+ # Disable Warning 4702 ("Unreachable code") for the WPO/PGO builds.
+ # Probably anything that this would catch that wouldn't be caught in a
+ # normal build isn't going to actually be a bug, so the incremental
+ # value of C4702 for PGO builds is likely very small.
+ "/wd4702",
+ ]
+ }
+ } else if (optimize_for_fuzzing) {
+ cflags = [ "-O1" ] + common_optimize_on_cflags
+ } else {
+ cflags = [ "-O3" ] + common_optimize_on_cflags
+ }
+ }
+}
+
+config("optimize_fuzzing") {
+ cflags = [ "-O1" ] + common_optimize_on_cflags
+ ldflags = common_optimize_on_ldflags
+ visibility = [ ":default_optimization" ]
+}
+
+# The default optimization applied to all targets. This will be equivalent to
+# either "optimize" or "no_optimize", depending on the build flags.
+config("default_optimization") {
+ if (is_nacl && is_nacl_irt) {
+ # The NaCl IRT is a special case and always wants its own config.
+ # It gets optimized the same way regardless of the type of build.
+ configs = [ "//build/config/nacl:irt_optimize" ]
+ } else if (is_debug) {
+ configs = [ ":no_optimize" ]
+ } else if (optimize_for_fuzzing) {
+ assert(!is_win, "Fuzzing optimize level not supported on Windows")
+ configs = [ ":optimize_fuzzing" ]
+ } else {
+ configs = [ ":optimize" ]
+ }
+}
+
+# GCC supports a form of profile-guided optimization called AFDO, which
+# is used by ChromeOS in their official builds. However,
+# //base/allocator:tcmalloc currently doesn't work correctly with AFDO
+# so we provide separate config so that the flag can be disabled per-target.
+# TODO(crbug.com/633719): Remove this config once tcmalloc works with AFDO
+# or we remove tcmalloc or we stop using AFDO.
+config("afdo") {
+ if (auto_profile_path != "" && current_toolchain == default_toolchain) {
+ cflags = [ "-fauto-profile=${auto_profile_path}" ]
+ }
+}
+
+# Symbols ----------------------------------------------------------------------
+
+# The BUILDCONFIG file sets the "default_symbols" config on targets by
+# default. It will be equivalent to one the three specific symbol levels.
+#
+# You can override the symbol level on a per-target basis by removing the
+# default config and then adding the named one you want:
+#
+# configs -= [ "//build/config/compiler:default_symbols" ]
+# configs += [ "//build/config/compiler:symbols" ]
+
+# Full symbols.
+config("symbols") {
+ if (is_win) {
+ if (use_goma) {
+ # Note that this requires is_win_fastlink, enforced elsewhere.
+ cflags = [ "/Z7" ] # Debug information in the .obj files.
+ } else {
+ cflags = [ "/Zi" ] # Produce PDB file, no edit and continue.
+ }
+
+ if (is_win_fastlink) {
+ # Tell VS 2015+ to create a PDB that references debug
+ # information in .obj and .lib files instead of copying
+ # it all. This flag is incompatible with /PROFILE
+ ldflags = [ "/DEBUG:FASTLINK" ]
+ } else {
+ ldflags = [ "/DEBUG" ]
+ }
+
+ if (is_clang) {
+ # /DEBUG:FASTLINK requires every object file to have standalone debug
+ # information.
+ if (is_win_fastlink) {
+ cflags += [ "-fstandalone-debug" ]
+ } else {
+ cflags += [ "-fno-standalone-debug" ]
+ }
+ }
+ } else {
+ if (is_mac || is_ios) {
+ cflags = [ "-gdwarf-2" ]
+ if (is_mac && enable_dsyms) {
+ # If generating dSYMs, specify -fno-standalone-debug. This was
+ # originally specified for https://crbug.com/479841 because dsymutil
+ # could not handle a 4GB dSYM file. But dsymutil from Xcodes prior to
+ # version 7 also produces debug data that is incompatible with Breakpad
+ # dump_syms, so this is still required (https://crbug.com/622406).
+ cflags += [ "-fno-standalone-debug" ]
+ }
+ } else if (is_android) {
+ # Breakpad can't handle DWARF 4 symbols properly yet, so use DWARF 3
+ # explicitly on android where we are hitting https://crbug.com/638485.
+ # The arguments MUST be in this order because of a gcc arg parsing bug.
+ cflags = [
+ "-gdwarf-3",
+ "-g2",
+ ]
+ } else {
+ cflags = [ "-g2" ]
+ }
+ if (use_debug_fission) {
+ cflags += [ "-gsplit-dwarf" ]
+ }
+ asmflags = cflags
+ ldflags = []
+
+ # TODO(thakis): Figure out if there's a way to make this go for 32-bit,
+ # currently we get "warning:
+ # obj/native_client/src/trusted/service_runtime/sel_asm/nacl_switch_32.o:
+ # DWARF info may be corrupt; offsets in a range list entry are in different
+ # sections" there. Maybe just a bug in nacl_switch_32.S.
+ # TODO(thakis): Figure out if there's a way to make this go for official
+ # builds, currently get
+ # "third_party/binutils/Linux_x64/Release/bin/ld.gold: warning:
+ # /tmp/lto-llvm-0b5201.o: corrupt debug info in .debug_info"
+ if (!is_mac && !is_ios && !is_nacl && target_cpu != "x86" &&
+ (use_gold || use_lld) && !allow_posix_link_time_opt &&
+ !is_official_build) {
+ ldflags += [ "-Wl,--gdb-index" ]
+ }
+ }
+}
+
+# Minimal symbols.
+config("minimal_symbols") {
+ if (is_win) {
+ # Linker symbols for backtraces only.
+ cflags = []
+ ldflags = [ "/DEBUG" ]
+ } else {
+ if (is_android) {
+ # Breakpad can't handle DWARF 4 symbols properly yet, so use DWARF 3
+ # explicitly on android where we are hitting https://crbug.com/638485.
+ # The arguments MUST be in this order because of a gcc arg parsing bug.
+ cflags = [
+ "-gdwarf-3",
+ "-g1",
+ ]
+ } else {
+ cflags = [ "-g1" ]
+ }
+
+ # Note: -gsplit-dwarf implicitly turns on -g2 with clang, so don't pass it.
+ asmflags = cflags
+ ldflags = []
+ }
+}
+
+# No symbols.
+config("no_symbols") {
+ if (!is_win) {
+ cflags = [ "-g0" ]
+ asmflags = cflags
+ }
+}
+
+# Default symbols.
+config("default_symbols") {
+ if (symbol_level == 0) {
+ configs = [ ":no_symbols" ]
+ } else if (symbol_level == 1) {
+ configs = [ ":minimal_symbols" ]
+ } else if (symbol_level == 2) {
+ configs = [ ":symbols" ]
+ } else {
+ assert(false)
+ }
+}
+
+if (is_ios || is_mac) {
+ # On Mac and iOS, this enables support for ARC (automatic ref-counting).
+ # See http://clang.llvm.org/docs/AutomaticReferenceCounting.html.
+ config("enable_arc") {
+ common_flags = [ "-fobjc-arc" ]
+ cflags_objc = common_flags
+ cflags_objcc = common_flags
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/compiler/compiler.gni b/third_party/libwebrtc/webrtc/build/config/compiler/compiler.gni
new file mode 100644
index 0000000000..46b048f3ec
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/compiler/compiler.gni
@@ -0,0 +1,182 @@
+# Copyright 2015 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/android/config.gni")
+import("//build/config/arm.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromecast_build.gni")
+import("//build/config/compiler/pgo/pgo.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/toolchain/goma.gni")
+import("//build/toolchain/toolchain.gni")
+import("//build_overrides/build.gni")
+
+declare_args() {
+ # How many symbols to include in the build. This affects the performance of
+ # the build since the symbols are large and dealing with them is slow.
+ # 2 means regular build with symbols.
+ # 1 means minimal symbols, usually enough for backtraces only. Symbols with
+ # internal linkage (static functions or those in anonymous namespaces) may not
+ # appear when using this level.
+ # 0 means no symbols.
+ # -1 means auto-set according to debug/release and platform.
+ symbol_level = -1
+
+ # Compile in such a way as to enable profiling of the generated code. For
+ # example, don't omit the frame pointer and leave in symbols.
+ enable_profiling = false
+
+ # use_debug_fission: whether to use split DWARF debug info
+ # files. This can reduce link time significantly, but is incompatible
+ # with some utilities such as icecc and ccache. Requires gold and
+ # gcc >= 4.8 or clang.
+ # http://gcc.gnu.org/wiki/DebugFission
+ #
+ # This is a placeholder value indicating that the code below should set
+ # the default. This is necessary to delay the evaluation of the default
+ # value expression until after its input values such as use_gold have
+ # been set, e.g. by a toolchain_args() block.
+ use_debug_fission = "default"
+
+ # Tell VS to create a PDB that references information in .obj files rather
+ # than copying it all. This should improve linker performance. mspdbcmf.exe
+ # can be used to convert a fastlink pdb to a normal one.
+ is_win_fastlink = false
+
+ # Whether or not we should turn on incremental WPO. Only affects the VS
+ # Windows build.
+ use_incremental_wpo = false
+
+ # Root directory that will store the MSVC link repro. This should only be
+ # used for debugging purposes on the builders where a MSVC linker flakyness
+ # has been observed. The targets for which a link repro should be generated
+ # should add somethink like this to their configuration:
+ # if (linkrepro_root_dir != "") {
+ # ldflags = ["/LINKREPRO:" + linkrepro_root_dir + "/" + target_name]
+ # }
+ #
+ # Note that doing a link repro uses a lot of disk space and slows down the
+ # build, so this shouldn't be enabled on too many targets.
+ #
+ # See crbug.com/669854.
+ linkrepro_root_dir = ""
+
+ # Whether or not we should use position independent code.
+ use_pic = true
+}
+
+# Determine whether to enable or disable frame pointers, based on the platform
+# and build arguments.
+if (is_mac || is_ios) {
+ enable_frame_pointers = true
+} else if (is_win) {
+ # 64-bit Windows ABI doesn't support frame pointers.
+ if (target_cpu == "x64") {
+ enable_frame_pointers = false
+ } else {
+ enable_frame_pointers = true
+ }
+} else if (is_chromeos) {
+ # ChromeOS requires frame pointers in x64 builds, to support CWP.
+ # TODO(711784): Building ARM Thumb without frame pointers can lead to code
+ # in ChromeOS which triggers some ARM A12/A17 errata. They can be disabled
+ # on non-x64 once that is resolved.
+ enable_frame_pointers = true
+} else if (current_cpu == "arm64") {
+ # Ensure that stacks from arm64 crash dumps are usable (crbug.com/391706).
+ enable_frame_pointers = true
+} else {
+ # Explicitly ask for frame pointers, otherwise:
+ # * Stacks may be missing for sanitizer and profiling builds.
+ # * Debug tcmalloc can crash (crbug.com/636489).
+ enable_frame_pointers = using_sanitizer || enable_profiling || is_debug
+}
+
+# In general assume that if we have frame pointers then we can use them to
+# unwind the stack. However, this requires that they are enabled by default for
+# most translation units, that they are emitted correctly, and that the
+# compiler or platform provides a way to access them.
+can_unwind_with_frame_pointers = enable_frame_pointers
+if (current_cpu == "arm" && arm_use_thumb) {
+ # We cannot currently unwind ARM Thumb frame pointers correctly.
+ can_unwind_with_frame_pointers = false
+} else if (is_win) {
+ # Windows 32-bit does provide frame pointers, but the compiler does not
+ # provide intrinsics to access them, so we don't use them.
+ can_unwind_with_frame_pointers = false
+}
+
+assert(!can_unwind_with_frame_pointers || enable_frame_pointers)
+
+declare_args() {
+ # Whether or not the official builds should be built with full WPO. Enabled by
+ # default for the PGO and the x64 builds.
+ if (chrome_pgo_phase > 0) {
+ full_wpo_on_official = true
+ } else {
+ full_wpo_on_official = false
+ }
+}
+
+declare_args() {
+ # Whether to use the gold linker from binutils instead of lld or bfd.
+ use_gold =
+ !use_lld && !(is_chromecast && is_linux &&
+ (current_cpu == "arm" || current_cpu == "mipsel")) &&
+ ((is_linux && (current_cpu == "x64" || current_cpu == "x86" ||
+ current_cpu == "arm" || current_cpu == "mipsel")) ||
+ (is_android && (current_cpu == "x86" || current_cpu == "x64" ||
+ current_cpu == "arm" || current_cpu == "arm64")) ||
+ is_fuchsia)
+}
+
+# If it wasn't manually set, set to an appropriate default.
+assert(symbol_level >= -1 && symbol_level <= 2, "Invalid symbol_level")
+if (symbol_level == -1) {
+ if (is_android && use_order_profiling) {
+ # With instrumentation enabled, debug info puts libchrome.so over 4gb, which
+ # causes the linker to produce an invalid ELF. http://crbug.com/574476
+ symbol_level = 0
+ } else if (is_android && !is_component_build &&
+ !(android_64bit_target_cpu && !build_apk_secondary_abi)) {
+ # Reduce symbol level when it will cause invalid elf files to be created
+ # (due to file size). https://crbug.com/648948.
+ symbol_level = 1
+ } else if (is_win && use_goma && !is_clang) {
+ # goma doesn't support PDB files, so we disable symbols during goma
+ # compilation because otherwise the redundant debug information generated
+ # by visual studio (repeated in every .obj file) makes linker
+ # memory consumption and link times unsustainable (crbug.com/630074).
+ # Clang on windows does not have this issue.
+ # If you use is_win_fastlink = true then you can set symbol_level = 2 when
+ # using goma.
+ symbol_level = 1
+ } else if ((!is_nacl && !is_linux) || is_debug || is_official_build ||
+ is_chromecast) {
+ # Linux builds slower by having symbols as part of the target binary,
+ # whereas Mac and Windows have them separate, so in Release Linux, default
+ # them off, but keep them on for Official builds and Chromecast builds.
+ symbol_level = 2
+ } else if (using_sanitizer) {
+ # Sanitizers require symbols for filename suppressions to work.
+ symbol_level = 1
+ } else {
+ symbol_level = 0
+ }
+} else if (symbol_level == 2) {
+ if (is_win) {
+ # See crbug.com/630074
+ assert(is_win_fastlink || !use_goma,
+ "Goma builds that use symbol_level 2 must use is_win_fastlink.")
+ }
+}
+
+# Assert that the configuration isn't going to hit https://crbug.com/648948.
+assert(ignore_elf32_limitations || !is_android ||
+ (android_64bit_target_cpu && !build_apk_secondary_abi) ||
+ is_component_build || symbol_level < 2,
+ "Android 32-bit non-component builds cannot have symbol_level=2 " +
+ "due to 4GiB file size limit, see https://crbug.com/648948. " +
+ "If you really want to try this out, " +
+ "set ignore_elf32_limitations=true.")
diff --git a/third_party/libwebrtc/webrtc/build/config/compiler/pgo/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/compiler/pgo/BUILD.gn
new file mode 100644
index 0000000000..bb147a6ecc
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/compiler/pgo/BUILD.gn
@@ -0,0 +1,101 @@
+# 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/clang/clang.gni")
+import("//build/config/compiler/compiler.gni")
+import("//build/config/compiler/pgo/pgo.gni")
+
+# Configuration that enables PGO instrumentation.
+config("pgo_instrumentation_flags") {
+ visibility = [ ":default_pgo_flags" ]
+ cflags = []
+ ldflags = []
+
+ # Only add flags when chrome_pgo_phase == 1, so that variables we would use
+ # are not required to be defined when we're not actually using PGO.
+ if (chrome_pgo_phase == 1) {
+ if (is_clang) {
+ cflags = [ "-fprofile-instr-generate" ]
+ if (is_win) {
+ # Normally, we pass -fprofile-instr-generate to the compiler and it
+ # automatically passes the right flags to the linker.
+ # However, on Windows, we call the linker directly, without going
+ # through the compiler driver. This means we need to pass the right
+ # flags ourselves.
+ _clang_rt_base_path =
+ "$clang_base_path/lib/clang/$clang_version/lib/windows"
+ if (target_cpu == "x86") {
+ _clang_rt_suffix = "-i386.lib"
+ } else if (target_cpu == "x64") {
+ _clang_rt_suffix = "-x86_64.lib"
+ }
+ assert(_clang_rt_suffix != "", "target CPU $target_cpu not supported")
+ ldflags += [ "$_clang_rt_base_path/clang_rt.profile$_clang_rt_suffix" ]
+ } else {
+ ldflags += [ "-fprofile-instr-generate" ]
+ }
+ } else if (is_win) {
+ ldflags = [
+ # In MSVC, we must use /LTCG when using PGO.
+ "/LTCG",
+
+ # Make sure that enough memory gets allocated for the PGO profiling
+ # buffers and also cap this memory. Usually a PGI instrumented build
+ # of chrome_child.dll requires ~55MB of memory for storing its counter
+ # etc, normally the linker should automatically choose an appropriate
+ # amount of memory but it doesn't always do a good estimate and
+ # sometime allocates too little or too much (and so the instrumented
+ # image fails to start). Making sure that the buffer has a size in the
+ # [128 MB, 512 MB] range should prevent this from happening.
+ "/GENPROFILE:MEMMIN=134217728",
+ "/GENPROFILE:MEMMAX=536870912",
+ "/PogoSafeMode",
+ ]
+ }
+ }
+}
+
+# Configuration that enables optimization using profile data.
+config("pgo_optimization_flags") {
+ visibility = [ ":default_pgo_flags" ]
+ cflags = []
+ ldflags = []
+
+ # Only add flags when chrome_pgo_phase == 2, so that variables we would use
+ # are not required to be defined when we're not actually using PGO.
+ if (chrome_pgo_phase == 2) {
+ if (is_clang) {
+ assert(pgo_data_path != "",
+ "Please set pgo_data_path to point at the profile data")
+ cflags += [
+ "-fprofile-instr-use=$pgo_data_path",
+
+ # It's possible to have some profile data legitimately missing,
+ # and at least some profile data always ends up being considered
+ # out of date, so make sure we don't error for those cases.
+ "-Wno-profile-instr-unprofiled",
+ "-Wno-error=profile-instr-out-of-date",
+ ]
+ } else if (is_win) {
+ ldflags += [
+ # In MSVC, we must use /LTCG when using PGO.
+ "/LTCG",
+ "/USEPROFILE",
+ ]
+ }
+ }
+}
+
+# Applies flags necessary when profile-guided optimization is used.
+# Flags are only added if PGO is enabled, so that this config is safe to
+# include by default.
+config("default_pgo_flags") {
+ if (chrome_pgo_phase == 0) {
+ # Nothing. This config should be a no-op when chrome_pgo_phase == 0.
+ } else if (chrome_pgo_phase == 1) {
+ configs = [ ":pgo_instrumentation_flags" ]
+ } else if (chrome_pgo_phase == 2) {
+ configs = [ ":pgo_optimization_flags" ]
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/compiler/pgo/pgo.gni b/third_party/libwebrtc/webrtc/build/config/compiler/pgo/pgo.gni
new file mode 100644
index 0000000000..5da004d28f
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/compiler/pgo/pgo.gni
@@ -0,0 +1,17 @@
+# 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.
+
+declare_args() {
+ # Specify the current PGO phase.
+ # Here's the different values that can be used:
+ # 0 : Means that PGO is turned off.
+ # 1 : Used during the PGI (instrumentation) phase.
+ # 2 : Used during the PGO (optimization) phase.
+ #
+ # TODO(sebmarchand): Add support for the PGU (update) phase.
+ chrome_pgo_phase = 0
+
+ # When using chrome_pgo_phase = 2, read profile data from this path.
+ pgo_data_path = ""
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/crypto.gni b/third_party/libwebrtc/webrtc/build/config/crypto.gni
new file mode 100644
index 0000000000..0196e873e5
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/crypto.gni
@@ -0,0 +1,23 @@
+# 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.
+
+# This file declares build flags for the SSL library configuration.
+#
+# TODO(brettw) this should probably be moved to src/crypto or somewhere, and
+# the global build dependency on it should be removed.
+#
+# PLEASE TRY TO AVOID ADDING FLAGS TO THIS FILE in cases where grit isn't
+# required. See the declare_args block of BUILDCONFIG.gn for advice on how
+# to set up feature flags.
+
+# True when we're using OpenSSL for representing certificates. When targeting
+# Android, the platform certificate library is used for certificate
+# verification. On NaCl, verification isn't supported. On other targets, this
+# flag also enables OpenSSL for certificate verification, but this configuration
+# is unsupported.
+use_openssl_certs = is_android || is_nacl
+
+# True if NSS is used for certificate handling. It is possible to use OpenSSL
+# for the crypto library, but NSS for the platform certificate library.
+use_nss_certs = is_linux
diff --git a/third_party/libwebrtc/webrtc/build/config/dcheck_always_on.gni b/third_party/libwebrtc/webrtc/build/config/dcheck_always_on.gni
new file mode 100644
index 0000000000..60672cdf50
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/dcheck_always_on.gni
@@ -0,0 +1,8 @@
+# Copyright (c) 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.
+
+declare_args() {
+ # Set to true to enable dcheck in Release builds.
+ dcheck_always_on = false
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/features.gni b/third_party/libwebrtc/webrtc/build/config/features.gni
new file mode 100644
index 0000000000..0c846898c0
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/features.gni
@@ -0,0 +1,73 @@
+# 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.
+
+# =============================================
+# PLEASE DO NOT ADD MORE FLAGS TO THIS FILE
+# =============================================
+#
+# These flags are effectively global. Your feature flag should go near the
+# code it controls. Most of these items are here now because they control
+# legacy global #defines passed to the compiler (now replaced with generated
+# buildflag headers -- see //build/buildflag_header.gni).
+#
+# There is more advice on where to put build flags in the "Build flag" section
+# of //build/config/BUILDCONFIG.gn.
+
+import("//build/config/chrome_build.gni")
+import("//build/config/chromecast_build.gni")
+if (is_android) {
+ import("//build/config/android/config.gni")
+}
+
+declare_args() {
+ # Enables Native Client support.
+ # Temporarily disable nacl on arm64 linux to get rid of compilation errors.
+ # TODO(mcgrathr): When mipsel-nacl-clang is available, drop the exclusion.
+ enable_nacl = !is_ios && !is_android && !is_chromecast &&
+ current_cpu != "mipsel" && !(is_linux && target_cpu == "arm64")
+
+ # Non-SFI is not yet supported on mipsel
+ enable_nacl_nonsfi = current_cpu != "mipsel"
+
+ # Enables proprietary codecs and demuxers; e.g. H264, AAC, MP3, and MP4.
+ # We always build Google Chrome and Chromecast with proprietary codecs.
+ #
+ # Note: this flag is used by WebRTC which is DEPSed into Chrome. Moving it
+ # out of //build will require using the build_overrides directory.
+ proprietary_codecs = is_chrome_branded || is_chromecast
+
+ # Variable safe_browsing is used to control the build time configuration for
+ # safe browsing feature. Safe browsing can be compiled in 3 different levels:
+ # 0 disables it, 1 enables it fully, and 2 enables mobile protection via an
+ # external API.
+ if (is_ios || is_chromecast || build_with_mozilla) {
+ safe_browsing_mode = 0
+ } else if (is_android) {
+ safe_browsing_mode = 2
+ } else {
+ safe_browsing_mode = 1
+ }
+
+ # Set to true make a build that disables activation of field trial tests
+ # specified in testing/variations/fieldtrial_testing_config_*.json.
+ # Note: this setting is ignored if is_chrome_branded.
+ fieldtrial_testing_like_official_build = is_chrome_branded
+
+ # libudev usage. This currently only affects the content layer.
+ use_udev = is_linux && !is_chromecast && !build_with_mozilla
+
+ use_dbus = is_linux && !is_chromecast
+
+ # Option controlling the use of GConf (the classic GNOME configuration
+ # system).
+ use_gconf = is_linux && !is_chromeos && !is_chromecast
+
+ use_gio = is_linux && !is_chromeos && !is_chromecast
+}
+#
+# =============================================
+# PLEASE DO NOT ADD MORE FLAGS TO THIS FILE
+# =============================================
+#
+# See comment at the top.
diff --git a/third_party/libwebrtc/webrtc/build/config/freetype/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/freetype/BUILD.gn
new file mode 100644
index 0000000000..991419c9f3
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/freetype/BUILD.gn
@@ -0,0 +1,16 @@
+# 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/features.gni")
+import("//build/config/freetype/freetype.gni")
+
+group("freetype") {
+ if (use_system_freetype) {
+ public_configs = [ "//build/linux:freetype_from_pkgconfig" ]
+ } else {
+ public_deps = [
+ "//third_party/freetype",
+ ]
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/freetype/OWNERS b/third_party/libwebrtc/webrtc/build/config/freetype/OWNERS
new file mode 100644
index 0000000000..3277f87312
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/freetype/OWNERS
@@ -0,0 +1,2 @@
+bungeman@chromium.org
+drott@chromium.org
diff --git a/third_party/libwebrtc/webrtc/build/config/freetype/freetype.gni b/third_party/libwebrtc/webrtc/build/config/freetype/freetype.gni
new file mode 100644
index 0000000000..b4eced2d65
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/freetype/freetype.gni
@@ -0,0 +1,14 @@
+# 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.
+
+declare_args() {
+ # Blink needs a recent and properly build-configured FreeType version to
+ # support OpenType variations, color emoji and avoid security bugs. By default
+ # we ship and link such a version as part of Chrome. For distributions that
+ # prefer to keep linking to the version the system, FreeType must be newer
+ # than version 2.7.1 and have color bitmap support compiled in. WARNING:
+ # System FreeType configurations other than as described WILL INTRODUCE TEXT
+ # RENDERING AND SECURITY REGRESSIONS.
+ use_system_freetype = false
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/fuchsia/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/fuchsia/BUILD.gn
new file mode 100644
index 0000000000..1f8ee1a0e1
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/fuchsia/BUILD.gn
@@ -0,0 +1,40 @@
+# 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/fuchsia/config.gni")
+import("//build/config/sysroot.gni")
+
+assert(is_fuchsia)
+assert(is_posix)
+
+config("compiler") {
+ defines = [ "SYSROOT_VERSION=$sysroot_version" ]
+ cflags = []
+ ldflags = []
+ if (current_cpu == "arm64") {
+ cflags += [ "--target=aarch64-fuchsia" ]
+ ldflags += [ "--target=aarch64-fuchsia" ]
+ } else if (current_cpu == "x64") {
+ cflags += [ "--target=x86_64-fuchsia" ]
+ ldflags += [ "--target=x86_64-fuchsia" ]
+ } else {
+ assert(false, "Unsupported architecture")
+ }
+ asmflags = cflags
+
+ # TODO(thakis): Once Fuchsia's libclang_rt.builtin no longer has upstream
+ # patches, we might want to make tools/clang/scripts/update.py build it
+ # and bundle it with the clang package instead of using the library from
+ # the SDK, https://crbug.com/724204
+ ldflags += [
+ "-resource-dir",
+ rebase_path(fuchsia_sdk, root_build_dir) + "/toolchain_libs/clang/5.0.0",
+ ]
+
+ libs = [
+ "mxio",
+ "magenta",
+ "unwind",
+ ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/fuchsia/OWNERS b/third_party/libwebrtc/webrtc/build/config/fuchsia/OWNERS
new file mode 100644
index 0000000000..3f809e82b1
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/fuchsia/OWNERS
@@ -0,0 +1 @@
+scottmg@chromium.org
diff --git a/third_party/libwebrtc/webrtc/build/config/fuchsia/config.gni b/third_party/libwebrtc/webrtc/build/config/fuchsia/config.gni
new file mode 100644
index 0000000000..d1d1104817
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/fuchsia/config.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.
+
+assert(current_os == "fuchsia")
+
+declare_args() {
+ # Path to Fuchsia SDK.
+ fuchsia_sdk = "//third_party/fuchsia-sdk"
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/gcc/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/gcc/BUILD.gn
new file mode 100644
index 0000000000..433497e135
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/gcc/BUILD.gn
@@ -0,0 +1,151 @@
+# 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/compiler/compiler.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/sysroot.gni")
+import("//build/toolchain/toolchain.gni")
+
+declare_args() {
+ # When non empty, overrides the target rpath value. This allows a user to
+ # make a Chromium build where binaries and shared libraries are meant to be
+ # installed into separate directories, like /usr/bin/chromium and
+ # /usr/lib/chromium for instance. It is useful when a build system that
+ # generates a whole target root filesystem (like Yocto) is used on top of gn,
+ # especially when cross-compiling.
+ # Note: this gn arg is similar to gyp target_rpath generator flag.
+ gcc_target_rpath = ""
+}
+
+# This config causes functions not to be automatically exported from shared
+# libraries. By default, all symbols are exported but this means there are
+# lots of exports that slow everything down. In general we explicitly mark
+# which functiosn we want to export from components.
+#
+# Some third_party code assumes all functions are exported so this is separated
+# into its own config so such libraries can remove this config to make symbols
+# public again.
+#
+# See http://gcc.gnu.org/wiki/Visibility
+config("symbol_visibility_hidden") {
+ # Note that -fvisibility-inlines-hidden is set globally in the compiler
+ # config since that can almost always be applied.
+ cflags = [ "-fvisibility=hidden" ]
+
+ # Visibility attribute is not supported on AIX.
+ if (current_os != "aix") {
+ cflags_cc = [
+ # Not exporting C++ inline functions can generally be applied anywhere
+ # so we do so here. Normal function visibility is controlled by
+ # //build/config/gcc:symbol_visibility_hidden.
+ "-fvisibility-inlines-hidden",
+ ]
+ }
+}
+
+# This config is usually set when :symbol_visibility_hidden is removed.
+# It's often a good idea to set visibility explicitly, as there're flags
+# which would error out otherwise (e.g. -fsanitize=cfi-unrelated-cast)
+config("symbol_visibility_default") {
+ cflags = [ "-fvisibility=default" ]
+}
+
+# The rpath is the dynamic library search path. Setting this config on a link
+# step will put the directory where the build generates shared libraries into
+# the rpath.
+#
+# It's important that this *not* be used for release builds we push out.
+# Chrome uses some setuid binaries, and hard links preserve setuid bits. An
+# unprivileged user could gain root privileges by hardlinking a setuid
+# executable and then adding in whatever binaries they want to run into the lib
+# directory.
+#
+# Example bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=520126
+#
+# This is required for component builds since the build generates many shared
+# libraries in the build directory that we expect to be automatically loaded.
+# It will be automatically applied in this case by :executable_ldconfig.
+#
+# In non-component builds, certain test binaries may expect to load dynamic
+# libraries from the current directory. As long as these aren't distributed,
+# this is OK. For these cases use something like this:
+#
+# if (is_linux && !is_component_build) {
+# configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
+# }
+config("rpath_for_built_shared_libraries") {
+ if (!is_android) {
+ # Note: Android doesn't support rpath.
+ if (shlib_subdir != ".") {
+ rpath_link = "${shlib_subdir}/"
+ } else {
+ rpath_link = "."
+ }
+ if (current_toolchain != default_toolchain || gcc_target_rpath == "") {
+ ldflags = [
+ # Want to pass "\$". GN will re-escape as required for ninja.
+ "-Wl,-rpath=\$ORIGIN/${rpath_link}",
+ "-Wl,-rpath-link=${rpath_link}",
+ ]
+ } else {
+ ldflags = [
+ "-Wl,-rpath=${gcc_target_rpath}",
+ "-Wl,-rpath-link=${rpath_link}",
+ ]
+ }
+ }
+}
+
+# Settings for executables.
+config("executable_ldconfig") {
+ # WARNING! //sandbox/linux:chrome_sandbox will not pick up this
+ # config, because it is a setuid binary that needs special flags.
+ # If you add things to this config, make sure you check to see
+ # if they should be added to that target as well.
+ ldflags = []
+ if (is_android) {
+ ldflags += [
+ "-Bdynamic",
+ "-Wl,-z,nocopyreloc",
+ ]
+ } else {
+ # See the rpath_for... config above for why this is necessary for component
+ # builds. Sanitizers use a custom libc++ where this is also necessary.
+ if (is_component_build || using_sanitizer) {
+ configs = [ ":rpath_for_built_shared_libraries" ]
+ }
+ if (current_cpu == "mipsel") {
+ ldflags += [ "-pie" ]
+ }
+ }
+
+ if ((!is_android || !use_gold) && current_os != "aix") {
+ # Find the path containing shared libraries for this toolchain
+ # relative to the build directory. ${root_out_dir} will be a
+ # subdirectory of ${root_build_dir} when cross compiling.
+ _rpath_link = rebase_path(root_out_dir, root_build_dir)
+ if (shlib_subdir != ".") {
+ _rpath_link += "/$shlib_subdir"
+ }
+ if (is_android) {
+ _rebased_sysroot = rebase_path(sysroot, root_build_dir)
+ _rpath_link += ":$_rebased_sysroot/usr/lib"
+ }
+
+ ldflags += [
+ "-Wl,-rpath-link=$_rpath_link",
+
+ # TODO(GYP): Do we need a check on the binutils version here?
+ #
+ # Newer binutils don't set DT_RPATH unless you disable "new" dtags
+ # and the new DT_RUNPATH doesn't work without --no-as-needed flag.
+ "-Wl,--disable-new-dtags",
+ ]
+ }
+}
+
+config("no_exceptions") {
+ cflags_cc = [ "-fno-exceptions" ]
+ cflags_objcc = cflags_cc
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/get_host_byteorder.py b/third_party/libwebrtc/webrtc/build/config/get_host_byteorder.py
new file mode 100644
index 0000000000..c8fcf1f352
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/get_host_byteorder.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+# 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.
+
+"""Get Byteorder of host architecture"""
+
+
+import sys
+
+print sys.byteorder
diff --git a/third_party/libwebrtc/webrtc/build/config/host_byteorder.gni b/third_party/libwebrtc/webrtc/build/config/host_byteorder.gni
new file mode 100644
index 0000000000..48a1a7f1e3
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/host_byteorder.gni
@@ -0,0 +1,27 @@
+# Copyright (c) 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.
+
+# This header file defines the "host_byteorder" variable.
+# Not that this is currently used only for building v8.
+# The chromium code generally assumes little-endianness.
+declare_args() {
+ host_byteorder = "undefined"
+}
+
+# Detect host byteorder
+# ppc64 can be either BE or LE
+if (host_cpu == "ppc64") {
+ if (current_os == "aix") {
+ host_byteorder = "big"
+ } else {
+ # Only use the script when absolutely necessary
+ host_byteorder =
+ exec_script("//build/config/get_host_byteorder.py", [], "trim string")
+ }
+} else if (host_cpu == "ppc" || host_cpu == "s390" || host_cpu == "s390x" ||
+ host_cpu == "mips" || host_cpu == "mips64") {
+ host_byteorder = "big"
+} else {
+ host_byteorder = "little"
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/ios/BUILD.gn
new file mode 100644
index 0000000000..f8091d155b
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/BUILD.gn
@@ -0,0 +1,155 @@
+# 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/ios/ios_sdk.gni")
+import("//build/config/sysroot.gni")
+import("//build/toolchain/toolchain.gni")
+
+declare_args() {
+ # Enabling this option makes clang compile to an intermediate
+ # representation ("bitcode"), and not to native code. This is preferred
+ # when including WebRTC in the apps that will be sent to Apple's App Store
+ # and mandatory for the apps that run on watchOS or tvOS.
+ # The option only works when building with Xcode (use_xcode_clang = true).
+ # Mimicking how Xcode handles it, the production builds (is_debug = false)
+ # get real bitcode sections added, while the debug builds (is_debug = true)
+ # only get bitcode-section "markers" added in them.
+ # NOTE: This option is ignored when building versions for the iOS simulator,
+ # where a part of libvpx is compiled from the assembly code written using
+ # Intel assembly syntax; Yasm / Nasm do not support emitting bitcode parts.
+ # That is not a limitation for now as Xcode mandates the presence of bitcode
+ # only when building bitcode-enabled projects for real devices (ARM CPUs).
+ enable_ios_bitcode = false
+}
+
+# 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.
+config("compiler") {
+ # These flags are shared between the C compiler and linker.
+ common_ios_flags = []
+
+ # CPU architecture.
+ if (current_cpu == "x64") {
+ common_ios_flags += [
+ "-arch",
+ "x86_64",
+ ]
+ } else if (current_cpu == "x86") {
+ common_ios_flags += [
+ "-arch",
+ "i386",
+ ]
+ } else if (current_cpu == "armv7" || current_cpu == "arm") {
+ common_ios_flags += [
+ "-arch",
+ "armv7",
+ ]
+ } else if (current_cpu == "arm64") {
+ common_ios_flags += [
+ "-arch",
+ "arm64",
+ ]
+ }
+
+ # This is here so that all files get recompiled after an Xcode update.
+ # (defines are passed via the command line, and build system rebuild things
+ # when their commandline changes). Nothing should ever read this define.
+ defines = [ "CR_XCODE_VERSION=$xcode_version" ]
+
+ asmflags = common_ios_flags
+ cflags = common_ios_flags
+
+ # Without this, the constructors and destructors of a C++ object inside
+ # an Objective C struct won't be called, which is very bad.
+ cflags_objcc = [ "-fobjc-call-cxx-cdtors" ]
+
+ cflags_c = [ "-std=c99" ]
+ cflags_objc = cflags_c
+
+ ldflags = common_ios_flags
+}
+
+# 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 iOS-only. Please see that target for advice on what should go in
+# :runtime_library vs. :compiler.
+config("runtime_library") {
+ common_flags = [
+ "-isysroot",
+ sysroot,
+
+ "-stdlib=libc++",
+ ]
+
+ if (use_ios_simulator) {
+ common_flags += [ "-mios-simulator-version-min=$ios_deployment_target" ]
+ } else {
+ common_flags += [ "-miphoneos-version-min=$ios_deployment_target" ]
+ }
+
+ if (use_xcode_clang && enable_ios_bitcode && !use_ios_simulator) {
+ if (is_debug) {
+ common_flags += [ "-fembed-bitcode-marker" ]
+ } else {
+ common_flags += [ "-fembed-bitcode" ]
+ }
+ }
+
+ asmflags = common_flags
+ cflags = common_flags
+ ldflags = common_flags
+
+ # TODO(crbug.com/634373): Remove once Xcode's libc++ has LLVM r256325. Most
+ # likely this means one Xcode 8 is released and required.
+ if (use_xcode_clang && get_path_info(ios_sdk_version, "name") != "10") {
+ common_cc_flags = [
+ "-isystem",
+ rebase_path("//third_party/llvm-build/Release+Asserts/include/c++/v1",
+ root_build_dir),
+ ]
+
+ cflags_cc = common_cc_flags
+ cflags_objcc = common_cc_flags
+ }
+
+ if (ios_enable_coverage) {
+ configs = [ ":enable_coverage" ]
+ }
+}
+
+config("ios_executable_flags") {
+}
+
+config("ios_dynamic_flags") {
+ ldflags = [ "-Wl,-ObjC" ] # Always load Objective-C categories and class.
+}
+
+config("xctest_config") {
+ common_flags = [
+ "-F",
+ "$ios_sdk_platform_path/Developer/Library/Frameworks",
+ ]
+
+ cflags = common_flags
+ ldflags = common_flags
+
+ libs = [
+ "Foundation.framework",
+ "XCTest.framework",
+ ]
+}
+
+# This enables support for LLVM code coverage. See
+# http://llvm.org/docs/CoverageMappingFormat.html.
+config("enable_coverage") {
+ cflags = [
+ "-fprofile-instr-generate",
+ "-fcoverage-mapping",
+ ]
+ ldflags = [ "-fprofile-instr-generate" ]
+}
+
+group("xctest") {
+ public_configs = [ ":xctest_config" ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/BuildInfo.plist b/third_party/libwebrtc/webrtc/build/config/ios/BuildInfo.plist
new file mode 100644
index 0000000000..3595e5aefb
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/BuildInfo.plist
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>BuildMachineOSBuild</key>
+ <string>${BUILD_MACHINE_OS_BUILD}</string>
+ <key>CFBundleSupportedPlatforms</key>
+ <array>
+ <string>${IOS_SUPPORTED_PLATFORM}</string>
+ </array>
+ <key>DTCompiler</key>
+ <string>${GCC_VERSION}</string>
+ <key>DTPlatformName</key>
+ <string>${IOS_PLATFORM_NAME}</string>
+ <key>DTPlatformVersion</key>
+ <string>${IOS_PLATFORM_VERSION}</string>
+ <key>DTPlatformBuild</key>
+ <string>${IOS_PLATFORM_BUILD}</string>
+ <key>DTSDKBuild</key>
+ <string>${IOS_SDK_BUILD}</string>
+ <key>DTSDKName</key>
+ <string>${IOS_SDK_NAME}</string>
+ <key>MinimumOSVersion</key>
+ <string>${IOS_DEPLOYMENT_TARGET}</string>
+ <key>DTXcode</key>
+ <string>${XCODE_VERSION}</string>
+ <key>DTXcodeBuild</key>
+ <string>${XCODE_BUILD}</string>
+ <key>UIDeviceFamily</key>
+ <array>
+ <integer>1</integer>
+ <integer>2</integer>
+ </array>
+</dict>
+</plist>
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/Host-Info.plist b/third_party/libwebrtc/webrtc/build/config/ios/Host-Info.plist
new file mode 100644
index 0000000000..9f6f5deef9
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/Host-Info.plist
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${IOS_BUNDLE_ID_PREFIX}.test.${EXECUTABLE_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>NSAppTransportSecurity</key>
+ <dict>
+ <key>NSAllowsArbitraryLoads</key>
+ <true/>
+ </dict>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UILaunchImages</key>
+ <array>
+ <dict>
+ <key>UILaunchImageMinimumOSVersion</key>
+ <string>7.0</string>
+ <key>UILaunchImageName</key>
+ <string>Default</string>
+ <key>UILaunchImageOrientation</key>
+ <string>Portrait</string>
+ <key>UILaunchImageSize</key>
+ <string>{320, 480}</string>
+ </dict>
+ <dict>
+ <key>UILaunchImageMinimumOSVersion</key>
+ <string>7.0</string>
+ <key>UILaunchImageName</key>
+ <string>Default</string>
+ <key>UILaunchImageOrientation</key>
+ <string>Portrait</string>
+ <key>UILaunchImageSize</key>
+ <string>{320, 568}</string>
+ </dict>
+ <dict>
+ <key>UILaunchImageMinimumOSVersion</key>
+ <string>8.0</string>
+ <key>UILaunchImageName</key>
+ <string>Default</string>
+ <key>UILaunchImageOrientation</key>
+ <string>Portrait</string>
+ <key>UILaunchImageSize</key>
+ <string>{375, 667}</string>
+ </dict>
+ <dict>
+ <key>UILaunchImageMinimumOSVersion</key>
+ <string>8.0</string>
+ <key>UILaunchImageName</key>
+ <string>Default</string>
+ <key>UILaunchImageOrientation</key>
+ <string>Portrait</string>
+ <key>UILaunchImageSize</key>
+ <string>{414, 736}</string>
+ </dict>
+ <dict>
+ <key>UILaunchImageMinimumOSVersion</key>
+ <string>8.0</string>
+ <key>UILaunchImageName</key>
+ <string>Default</string>
+ <key>UILaunchImageOrientation</key>
+ <string>Landscape</string>
+ <key>UILaunchImageSize</key>
+ <string>{414, 736}</string>
+ </dict>
+ </array>
+ <key>UILaunchImages~ipad</key>
+ <array>
+ <dict>
+ <key>UILaunchImageMinimumOSVersion</key>
+ <string>7.0</string>
+ <key>UILaunchImageName</key>
+ <string>Default</string>
+ <key>UILaunchImageOrientation</key>
+ <string>Portrait</string>
+ <key>UILaunchImageSize</key>
+ <string>{768, 1024}</string>
+ </dict>
+ <dict>
+ <key>UILaunchImageMinimumOSVersion</key>
+ <string>7.0</string>
+ <key>UILaunchImageName</key>
+ <string>Default</string>
+ <key>UILaunchImageOrientation</key>
+ <string>Landscape</string>
+ <key>UILaunchImageSize</key>
+ <string>{768, 1024}</string>
+ </dict>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/Module-Info.plist b/third_party/libwebrtc/webrtc/build/config/ios/Module-Info.plist
new file mode 100644
index 0000000000..63953d6211
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/Module-Info.plist
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>${MODULE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>${IOS_BUNDLE_ID_PREFIX}.test.${EXECUTABLE_NAME:rfc1034identifier}.${MODULE_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/OWNERS b/third_party/libwebrtc/webrtc/build/config/ios/OWNERS
new file mode 100644
index 0000000000..0e726c6a2c
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/OWNERS
@@ -0,0 +1 @@
+file://build/config/mac/OWNERS
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/codesign.py b/third_party/libwebrtc/webrtc/build/config/ios/codesign.py
new file mode 100644
index 0000000000..b197bac7e9
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/codesign.py
@@ -0,0 +1,437 @@
+# 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 argparse
+import datetime
+import fnmatch
+import glob
+import os
+import plistlib
+import shutil
+import subprocess
+import sys
+import tempfile
+
+
+def GetProvisioningProfilesDir():
+ """Returns the location of the installed mobile provisioning profiles.
+
+ Returns:
+ The path to the directory containing the installed mobile provisioning
+ profiles as a string.
+ """
+ return os.path.join(
+ os.environ['HOME'], 'Library', 'MobileDevice', 'Provisioning Profiles')
+
+
+def LoadPlistFile(plist_path):
+ """Loads property list file at |plist_path|.
+
+ Args:
+ plist_path: path to the property list file to load.
+
+ Returns:
+ The content of the property list file as a python object.
+ """
+ return plistlib.readPlistFromString(subprocess.check_output([
+ 'xcrun', 'plutil', '-convert', 'xml1', '-o', '-', plist_path]))
+
+
+class Bundle(object):
+ """Wraps a bundle."""
+
+ def __init__(self, bundle_path):
+ """Initializes the Bundle object with data from bundle Info.plist file."""
+ self._path = bundle_path
+ self._data = LoadPlistFile(os.path.join(self._path, 'Info.plist'))
+
+ @property
+ def path(self):
+ return self._path
+
+ @property
+ def identifier(self):
+ return self._data['CFBundleIdentifier']
+
+ @property
+ def binary_path(self):
+ return os.path.join(self._path, self._data['CFBundleExecutable'])
+
+
+class ProvisioningProfile(object):
+ """Wraps a mobile provisioning profile file."""
+
+ def __init__(self, provisioning_profile_path):
+ """Initializes the ProvisioningProfile with data from profile file."""
+ self._path = provisioning_profile_path
+ self._data = plistlib.readPlistFromString(subprocess.check_output([
+ 'xcrun', 'security', 'cms', '-D', '-u', 'certUsageAnyCA',
+ '-i', provisioning_profile_path]))
+
+ @property
+ def path(self):
+ return self._path
+
+ @property
+ def application_identifier_pattern(self):
+ return self._data.get('Entitlements', {}).get('application-identifier', '')
+
+ @property
+ def team_identifier(self):
+ return self._data.get('TeamIdentifier', [''])[0]
+
+ @property
+ def entitlements(self):
+ return self._data.get('Entitlements', {})
+
+ @property
+ def expiration_date(self):
+ return self._data.get('ExpirationDate', datetime.datetime.now())
+
+ def ValidToSignBundle(self, bundle_identifier):
+ """Checks whether the provisioning profile can sign bundle_identifier.
+
+ Args:
+ bundle_identifier: the identifier of the bundle that needs to be signed.
+
+ Returns:
+ True if the mobile provisioning profile can be used to sign a bundle
+ with the corresponding bundle_identifier, False otherwise.
+ """
+ return fnmatch.fnmatch(
+ '%s.%s' % (self.team_identifier, bundle_identifier),
+ self.application_identifier_pattern)
+
+ def Install(self, installation_path):
+ """Copies mobile provisioning profile info to |installation_path|."""
+ shutil.copy2(self.path, installation_path)
+
+
+class Entitlements(object):
+ """Wraps an Entitlement plist file."""
+
+ def __init__(self, entitlements_path):
+ """Initializes Entitlements object from entitlement file."""
+ self._path = entitlements_path
+ self._data = LoadPlistFile(self._path)
+
+ @property
+ def path(self):
+ return self._path
+
+ def ExpandVariables(self, substitutions):
+ self._data = self._ExpandVariables(self._data, substitutions)
+
+ def _ExpandVariables(self, data, substitutions):
+ if isinstance(data, str):
+ for key, substitution in substitutions.iteritems():
+ data = data.replace('$(%s)' % (key,), substitution)
+ return data
+
+ if isinstance(data, dict):
+ for key, value in data.iteritems():
+ data[key] = self._ExpandVariables(value, substitutions)
+ return data
+
+ if isinstance(data, list):
+ for i, value in enumerate(data):
+ data[i] = self._ExpandVariables(value, substitutions)
+
+ return data
+
+ def LoadDefaults(self, defaults):
+ for key, value in defaults.iteritems():
+ if key not in self._data:
+ self._data[key] = value
+
+ def WriteTo(self, target_path):
+ plistlib.writePlist(self._data, target_path)
+
+
+def FindProvisioningProfile(bundle_identifier, required):
+ """Finds mobile provisioning profile to use to sign bundle.
+
+ Args:
+ bundle_identifier: the identifier of the bundle to sign.
+
+ Returns:
+ The ProvisioningProfile object that can be used to sign the Bundle
+ object or None if no matching provisioning profile was found.
+ """
+ provisioning_profile_paths = glob.glob(
+ os.path.join(GetProvisioningProfilesDir(), '*.mobileprovision'))
+
+ # Iterate over all installed mobile provisioning profiles and filter those
+ # that can be used to sign the bundle, ignoring expired ones.
+ now = datetime.datetime.now()
+ valid_provisioning_profiles = []
+ one_hour = datetime.timedelta(0, 3600)
+ for provisioning_profile_path in provisioning_profile_paths:
+ provisioning_profile = ProvisioningProfile(provisioning_profile_path)
+ if provisioning_profile.expiration_date - now < one_hour:
+ sys.stderr.write(
+ 'Warning: ignoring expired provisioning profile: %s.\n' %
+ provisioning_profile_path)
+ continue
+ if provisioning_profile.ValidToSignBundle(bundle_identifier):
+ valid_provisioning_profiles.append(provisioning_profile)
+
+ if not valid_provisioning_profiles:
+ if required:
+ sys.stderr.write(
+ 'Error: no mobile provisioning profile found for "%s".\n' %
+ bundle_identifier)
+ sys.exit(1)
+ return None
+
+ # Select the most specific mobile provisioning profile, i.e. the one with
+ # the longest application identifier pattern (prefer the one with the latest
+ # expiration date as a secondary criteria).
+ selected_provisioning_profile = max(
+ valid_provisioning_profiles,
+ key=lambda p: (len(p.application_identifier_pattern), p.expiration_date))
+
+ one_week = datetime.timedelta(7)
+ if selected_provisioning_profile.expiration_date - now < 2 * one_week:
+ sys.stderr.write(
+ 'Warning: selected provisioning profile will expire soon: %s' %
+ selected_provisioning_profile.path)
+ return selected_provisioning_profile
+
+
+def CodeSignBundle(bundle_path, identity, extra_args):
+ process = subprocess.Popen(['xcrun', 'codesign', '--force', '--sign',
+ identity, '--timestamp=none'] + list(extra_args) + [bundle_path],
+ stderr=subprocess.PIPE)
+ _, stderr = process.communicate()
+ if process.returncode:
+ sys.stderr.write(stderr)
+ sys.exit(process.returncode)
+ for line in stderr.splitlines():
+ if line.endswith(': replacing existing signature'):
+ # Ignore warning about replacing existing signature as this should only
+ # happen when re-signing system frameworks (and then it is expected).
+ continue
+ sys.stderr.write(line)
+ sys.stderr.write('\n')
+
+
+def InstallSystemFramework(framework_path, bundle_path, args):
+ """Install framework from |framework_path| to |bundle| and code-re-sign it."""
+ installed_framework_path = os.path.join(
+ bundle_path, 'Frameworks', os.path.basename(framework_path))
+
+ if os.path.exists(installed_framework_path):
+ shutil.rmtree(installed_framework_path)
+
+ shutil.copytree(framework_path, installed_framework_path)
+ CodeSignBundle(installed_framework_path, args.identity,
+ ['--deep', '--preserve-metadata=identifier,entitlements'])
+
+
+def GenerateEntitlements(path, provisioning_profile, bundle_identifier):
+ """Generates an entitlements file.
+
+ Args:
+ path: path to the entitlements template file
+ provisioning_profile: ProvisioningProfile object to use, may be None
+ bundle_identifier: identifier of the bundle to sign.
+ """
+ entitlements = Entitlements(path)
+ if provisioning_profile:
+ entitlements.LoadDefaults(provisioning_profile.entitlements)
+ app_identifier_prefix = provisioning_profile.team_identifier + '.'
+ else:
+ app_identifier_prefix = '*.'
+ entitlements.ExpandVariables({
+ 'CFBundleIdentifier': bundle_identifier,
+ 'AppIdentifierPrefix': app_identifier_prefix,
+ })
+ return entitlements
+
+
+class Action(object):
+ """Class implementing one action supported by the script."""
+
+ @classmethod
+ def Register(cls, subparsers):
+ parser = subparsers.add_parser(cls.name, help=cls.help)
+ parser.set_defaults(func=cls._Execute)
+ cls._Register(parser)
+
+
+class CodeSignBundleAction(Action):
+ """Class implementing the code-sign-bundle action."""
+
+ name = 'code-sign-bundle'
+ help = 'perform code signature for a bundle'
+
+ @staticmethod
+ def _Register(parser):
+ parser.add_argument(
+ '--entitlements', '-e', dest='entitlements_path',
+ help='path to the entitlements file to use')
+ parser.add_argument(
+ 'path', help='path to the iOS bundle to codesign')
+ parser.add_argument(
+ '--identity', '-i', required=True,
+ help='identity to use to codesign')
+ parser.add_argument(
+ '--binary', '-b', required=True,
+ help='path to the iOS bundle binary')
+ parser.add_argument(
+ '--framework', '-F', action='append', default=[], dest='frameworks',
+ help='install and resign system framework')
+ parser.add_argument(
+ '--disable-code-signature', action='store_true', dest='no_signature',
+ help='disable code signature')
+ parser.add_argument(
+ '--platform', '-t', required=True,
+ help='platform the signed bundle is targetting')
+ parser.set_defaults(no_signature=False)
+
+ @staticmethod
+ def _Execute(args):
+ if not args.identity:
+ args.identity = '-'
+
+ bundle = Bundle(args.path)
+
+ # Delete existing embedded mobile provisioning.
+ embedded_provisioning_profile = os.path.join(
+ bundle.path, 'embedded.mobileprovision')
+ if os.path.isfile(embedded_provisioning_profile):
+ os.unlink(embedded_provisioning_profile)
+
+ # Delete existing code signature.
+ signature_file = os.path.join(args.path, '_CodeSignature', 'CodeResources')
+ if os.path.isfile(signature_file):
+ shutil.rmtree(os.path.dirname(signature_file))
+
+ # Install system frameworks if requested.
+ for framework_path in args.frameworks:
+ InstallSystemFramework(framework_path, args.path, args)
+
+ # Copy main binary into bundle.
+ if os.path.isfile(bundle.binary_path):
+ os.unlink(bundle.binary_path)
+ shutil.copy(args.binary, bundle.binary_path)
+
+ if args.no_signature:
+ return
+
+ codesign_extra_args = []
+
+ # Find mobile provisioning profile and embeds it into the bundle (if a code
+ # signing identify has been provided, fails if no valid mobile provisioning
+ # is found).
+ provisioning_profile_required = args.identity != '-'
+ provisioning_profile = FindProvisioningProfile(
+ bundle.identifier, provisioning_profile_required)
+ if provisioning_profile and args.platform != 'iphonesimulator':
+ provisioning_profile.Install(embedded_provisioning_profile)
+
+ temporary_entitlements_file = tempfile.NamedTemporaryFile(suffix='.xcent')
+ codesign_extra_args.extend(
+ ['--entitlements', temporary_entitlements_file.name])
+
+ entitlements = GenerateEntitlements(
+ args.entitlements_path, provisioning_profile, bundle.identifier)
+ entitlements.WriteTo(temporary_entitlements_file.name)
+
+ CodeSignBundle(bundle.path, args.identity, codesign_extra_args)
+
+
+class CodeSignFileAction(Action):
+ """Class implementing code signature for a single file."""
+
+ name = 'code-sign-file'
+ help = 'code-sign a single file'
+
+ @staticmethod
+ def _Register(parser):
+ parser.add_argument(
+ 'path', help='path to the file to codesign')
+ parser.add_argument(
+ '--identity', '-i', required=True,
+ help='identity to use to codesign')
+ parser.add_argument(
+ '--output', '-o',
+ help='if specified copy the file to that location before signing it')
+ parser.set_defaults(sign=True)
+
+ @staticmethod
+ def _Execute(args):
+ if not args.identity:
+ args.identity = '-'
+
+ install_path = args.path
+ if args.output:
+
+ if os.path.isfile(args.output):
+ os.unlink(args.output)
+ elif os.path.isdir(args.output):
+ shutil.rmtree(args.output)
+
+ if os.path.isfile(args.path):
+ shutil.copy(args.path, args.output)
+ elif os.path.isdir(args.path):
+ shutil.copytree(args.path, args.output)
+
+ install_path = args.output
+
+ CodeSignBundle(install_path, args.identity,
+ ['--deep', '--preserve-metadata=identifier,entitlements'])
+
+
+class GenerateEntitlementsAction(Action):
+ """Class implementing the generate-entitlements action."""
+
+ name = 'generate-entitlements'
+ help = 'generate entitlements file'
+
+ @staticmethod
+ def _Register(parser):
+ parser.add_argument(
+ '--entitlements', '-e', dest='entitlements_path',
+ help='path to the entitlements file to use')
+ parser.add_argument(
+ 'path', help='path to the entitlements file to generate')
+ parser.add_argument(
+ '--info-plist', '-p', required=True,
+ help='path to the bundle Info.plist')
+
+ @staticmethod
+ def _Execute(args):
+ info_plist = LoadPlistFile(args.info_plist)
+ bundle_identifier = info_plist['CFBundleIdentifier']
+ provisioning_profile = FindProvisioningProfile(bundle_identifier, False)
+ entitlements = GenerateEntitlements(
+ args.entitlements_path, provisioning_profile, bundle_identifier)
+ entitlements.WriteTo(args.path)
+
+
+def Main():
+ parser = argparse.ArgumentParser('codesign iOS bundles')
+ parser.add_argument('--developer_dir', required=False,
+ help='Path to Xcode.')
+ subparsers = parser.add_subparsers()
+
+ actions = [
+ CodeSignBundleAction,
+ CodeSignFileAction,
+ GenerateEntitlementsAction,
+ ]
+
+ for action in actions:
+ action.Register(subparsers)
+
+ args = parser.parse_args()
+ if args.developer_dir:
+ os.environ['DEVELOPER_DIR'] = args.developer_dir
+ args.func(args)
+
+
+if __name__ == '__main__':
+ sys.exit(Main())
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/entitlements.plist b/third_party/libwebrtc/webrtc/build/config/ios/entitlements.plist
new file mode 100644
index 0000000000..429762e3a3
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/entitlements.plist
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>application-identifier</key>
+ <string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
+ <key>keychain-access-groups</key>
+ <array>
+ <string>$(AppIdentifierPrefix)$(CFBundleIdentifier)</string>
+ </array>
+</dict>
+</plist>
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/find_signing_identity.py b/third_party/libwebrtc/webrtc/build/config/ios/find_signing_identity.py
new file mode 100644
index 0000000000..7add474b9c
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/find_signing_identity.py
@@ -0,0 +1,47 @@
+# Copyright (c) 2015 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 argparse
+import os
+import subprocess
+import sys
+import re
+
+def ListIdentities():
+ return subprocess.check_output([
+ 'xcrun',
+ 'security',
+ 'find-identity',
+ '-v',
+ '-p',
+ 'codesigning',
+ ])
+
+
+def FindValidIdentity(identity_description):
+ lines = list(map(str.strip, ListIdentities().splitlines()))
+ # Look for something like "2) XYZ "iPhone Developer: Name (ABC)""
+ exp = re.compile('[0-9]+\) ([A-F0-9]+) "([^"]*)"')
+ for line in lines:
+ res = exp.match(line)
+ if res is None:
+ continue
+ if identity_description in res.group(2):
+ yield res.group(1)
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser('codesign iOS bundles')
+ parser.add_argument(
+ '--developer_dir', required=False,
+ help='Path to Xcode.')
+ parser.add_argument(
+ '--identity-description', required=True,
+ help='Text description used to select the code signing identity.')
+ args = parser.parse_args()
+ if args.developer_dir:
+ os.environ['DEVELOPER_DIR'] = args.developer_dir
+
+ for identity in FindValidIdentity(args.identity_description):
+ print identity
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/ios_sdk.gni b/third_party/libwebrtc/webrtc/build/config/ios/ios_sdk.gni
new file mode 100644
index 0000000000..1a4543370e
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/ios_sdk.gni
@@ -0,0 +1,168 @@
+# Copyright 2015 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/toolchain/toolchain.gni")
+
+declare_args() {
+ # SDK path to use. When empty this will use the default SDK based on the
+ # value of use_ios_simulator.
+ ios_sdk_path = ""
+ ios_sdk_name = ""
+ ios_sdk_version = ""
+ ios_sdk_platform = ""
+ ios_sdk_platform_path = ""
+ xcode_version = ""
+ xcode_build = ""
+ machine_os_build = ""
+
+ # Version of iOS that we're targeting.
+ ios_deployment_target = "9.0"
+
+ # The iOS Code signing identity to use
+ # TODO(GYP), TODO(sdfresne): Consider having a separate
+ # ios_enable_code_signing_flag=<bool> flag to make the invocation clearer.
+ ios_enable_code_signing = true
+ ios_code_signing_identity = ""
+ ios_code_signing_identity_description = "iPhone Developer"
+
+ # Prefix for CFBundleIdentifier property of iOS bundles (correspond to the
+ # "Organization Identifier" in Xcode). Code signing will fail if no mobile
+ # provisioning for the selected code signing identify support that prefix.
+ ios_app_bundle_id_prefix = "org.chromium"
+
+ # If true, then allow using Xcode to automatically manage certificates. This
+ # requires loading a separate Xcode project and enable automatically managed
+ # certificates. When true, all test application will use the same bundle id
+ # to avoid running out of certificates if using a free account.
+ ios_automatically_manage_certs = true
+
+ # Enabling this option makes clang compile for profiling to gather code
+ # coverage metrics.
+ ios_enable_coverage = false
+
+ # If non-empty, this list must contain valid cpu architecture, and the final
+ # build will be a multi-architecture build (aka fat build) supporting the
+ # main $target_cpu architecture and all of $additional_target_cpus.
+ #
+ # For example to build an application that will run on both arm64 and armv7
+ # devices, you would use the following in args.gn file when running "gn args":
+ #
+ # target_os = "ios"
+ # target_cpu = "arm64"
+ # additional_target_cpus = [ "arm" ]
+ #
+ # You can also pass the value via "--args" parameter for "gn gen" command by
+ # using the syntax --args='additional_target_cpus=["arm"] target_cpu="arm64"'.
+ additional_target_cpus = []
+}
+
+assert(custom_toolchain == "" || additional_target_cpus == [],
+ "cannot define both custom_toolchain and additional_target_cpus")
+
+use_ios_simulator = current_cpu == "x86" || current_cpu == "x64"
+
+ios_generic_test_bundle_id_suffix = "generic-unit-test"
+
+# Initialize additional_toolchains from additional_target_cpus. Assert here
+# that the list does not contains $target_cpu nor duplicates as this would
+# cause weird errors during the build.
+additional_toolchains = []
+if (additional_target_cpus != []) {
+ foreach(_additional_target_cpu, additional_target_cpus) {
+ assert(_additional_target_cpu != target_cpu,
+ "target_cpu must not be listed in additional_target_cpus")
+
+ _toolchain = "//build/toolchain/mac:ios_clang_$_additional_target_cpu"
+ foreach(_additional_toolchain, additional_toolchains) {
+ assert(_toolchain != _additional_toolchain,
+ "additional_target_cpus must not contains duplicate values")
+ }
+
+ additional_toolchains += [ _toolchain ]
+ }
+}
+
+if (ios_sdk_path == "") {
+ # Compute default target.
+ if (use_ios_simulator) {
+ ios_sdk_name = "iphonesimulator"
+ ios_sdk_platform = "iPhoneSimulator"
+ } else {
+ ios_sdk_name = "iphoneos"
+ ios_sdk_platform = "iPhoneOS"
+ }
+
+ ios_sdk_info_args = []
+ if (!use_system_xcode) {
+ ios_sdk_info_args += [
+ "--developer_dir",
+ hermetic_xcode_path,
+ ]
+ }
+ ios_sdk_info_args += [ ios_sdk_name ]
+ script_name = "//build/config/mac/sdk_info.py"
+ _ios_sdk_result = exec_script(script_name, ios_sdk_info_args, "scope")
+ ios_sdk_path = _ios_sdk_result.sdk_path
+ ios_sdk_version = _ios_sdk_result.sdk_version
+ ios_sdk_platform_path = _ios_sdk_result.sdk_platform_path
+ ios_sdk_build = _ios_sdk_result.sdk_build
+ xcode_version = _ios_sdk_result.xcode_version
+ xcode_build = _ios_sdk_result.xcode_build
+ machine_os_build = _ios_sdk_result.machine_os_build
+ if (use_ios_simulator) {
+ # This is weird, but Xcode sets DTPlatformBuild to an empty field for
+ # simulator builds.
+ ios_platform_build = ""
+ } else {
+ ios_platform_build = ios_sdk_build
+ }
+}
+
+if (ios_enable_code_signing && !use_ios_simulator) {
+ find_signing_identity_args = [
+ "--identity-description",
+ ios_code_signing_identity_description,
+ ]
+ if (!use_system_xcode) {
+ find_signing_identity_args += [
+ "--developer_dir",
+ hermetic_xcode_path,
+ ]
+ }
+
+ # If an identity is not provided, look for one on the host
+ if (ios_code_signing_identity == "") {
+ _ios_identities = exec_script("find_signing_identity.py",
+ find_signing_identity_args,
+ "list lines")
+ if (_ios_identities == []) {
+ print("Tried to prepare a device build without specifying a code signing")
+ print("identity and could not detect one automatically either.")
+ print("TIP: Simulator builds don't require code signing...")
+ assert(false)
+ } else {
+ _ios_identities_len = 0
+ foreach(_, _ios_identities) {
+ _ios_identities_len += 1
+ }
+
+ ios_code_signing_identity = _ios_identities[0]
+ if (_ios_identities_len != 1) {
+ print("Warning: Multiple codesigning identities match " +
+ "\"$ios_code_signing_identity_description\"")
+ foreach(_ios_identity, _ios_identities) {
+ _selected = ""
+ if (ios_code_signing_identity == _ios_identity) {
+ _selected = " (selected)"
+ }
+ print("Warning: - $_ios_identity$_selected")
+ }
+ print("Warning: Please use either ios_code_signing_identity or ")
+ print("Warning: ios_code_signing_identity_description variable to ")
+ print("Warning: control which identity is selected.")
+ print()
+ }
+ }
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/rules.gni b/third_party/libwebrtc/webrtc/build/config/ios/rules.gni
new file mode 100644
index 0000000000..5be23dd519
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/rules.gni
@@ -0,0 +1,1509 @@
+# Copyright 2015 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/ios/ios_sdk.gni")
+import("//build/config/mac/base_rules.gni")
+import("//build/config/mac/symbols.gni")
+import("//build/toolchain/toolchain.gni")
+
+# Invokes lipo on multiple arch-specific binaries to create a fat binary.
+#
+# Arguments
+#
+# arch_binary_target
+# name of the target generating the arch-specific binaries, they must
+# be named $target_out_dir/$toolchain_cpu/$arch_binary_output.
+#
+# arch_binary_output
+# (optional, defaults to the name of $arch_binary_target) base name of
+# the arch-specific binary generated by arch_binary_target.
+#
+# output_name
+# (optional, defaults to $target_name) base name of the target output,
+# the full path will be $target_out_dir/$output_name.
+#
+# configs
+# (optional) a list of configurations, this is used to check whether
+# the binary should be stripped, when "enable_stripping" is true.
+#
+template("lipo_binary") {
+ assert(defined(invoker.arch_binary_target),
+ "arch_binary_target must be defined for $target_name")
+
+ _target_name = target_name
+ _output_name = target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ _all_target_cpu = [ current_cpu ] + additional_target_cpus
+ _all_toolchains = [ current_toolchain ] + additional_toolchains
+
+ _arch_binary_target = invoker.arch_binary_target
+ _arch_binary_output = get_label_info(_arch_binary_target, "name")
+ if (defined(invoker.arch_binary_output)) {
+ _arch_binary_output = invoker.arch_binary_output
+ }
+
+ action(_target_name) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "arch_binary_output",
+ "arch_binary_target",
+ "configs",
+ "output_name",
+ ])
+
+ script = "//build/toolchain/mac/linker_driver.py"
+
+ outputs = [
+ "$target_out_dir/$_output_name",
+ ]
+
+ deps = []
+ _index = 0
+ inputs = []
+ foreach(_cpu, _all_target_cpu) {
+ _toolchain = _all_toolchains[_index]
+ _index = _index + 1
+
+ inputs +=
+ [ get_label_info("$_arch_binary_target($_toolchain)",
+ "target_out_dir") + "/$_cpu/$_arch_binary_output" ]
+
+ deps += [ "$_arch_binary_target($_toolchain)" ]
+ }
+
+ args = []
+ if (!use_system_xcode) {
+ args += [
+ "--developer_dir",
+ hermetic_xcode_path,
+ ]
+ }
+ args += [
+ "xcrun",
+ "lipo",
+ "-create",
+ "-output",
+ rebase_path("$target_out_dir/$_output_name", root_build_dir),
+ ] + rebase_path(inputs, root_build_dir)
+
+ if (enable_dsyms) {
+ _dsyms_output_dir = "$root_out_dir/$_output_name.dSYM"
+ outputs += [
+ "$_dsyms_output_dir/",
+ "$_dsyms_output_dir/Contents/Info.plist",
+ "$_dsyms_output_dir/Contents/Resources/DWARF/$_output_name",
+ ]
+ args += [ "-Wcrl,dsym," + rebase_path("$root_out_dir/.", root_build_dir) ]
+ }
+
+ if (enable_stripping) {
+ args += [ "-Wcrl,strip,-x,-S" ]
+ if (save_unstripped_output) {
+ outputs += [ "$root_out_dir/$_output_name.unstripped" ]
+ args += [ "-Wcrl,unstripped," +
+ rebase_path("$root_out_dir/.", root_build_dir) ]
+ }
+ }
+ }
+}
+
+# Wrapper around create_bundle taking care of code signature settings.
+#
+# Arguments
+#
+# product_type
+# string, product type for the generated Xcode project.
+#
+# bundle_deps
+# (optional) list of additional dependencies
+#
+# bundle_deps_filter
+# (optional) list of dependencies to filter (for more information
+# see "gn help bundle_deps_filter")
+#
+# bundle_extension
+# string, extension of the bundle, used to generate bundle name.
+#
+# bundle_binary_target
+# string, label of the target generating the bundle main binary.
+#
+# bundle_binary_output
+# (optional) string, base name of the binary generated by the
+# bundle_binary_target target, defaults to the target name.
+#
+# extra_system_frameworks
+# (optional) list of system framework to copy to the bundle.
+#
+# enable_code_signing
+# (optional) boolean, control whether code signing is enabled or not,
+# default to ios_enable_code_signing if not defined.
+#
+# entitlements_path:
+# (optional) path to the template to use to generate the application
+# entitlements by performing variable substitutions, defaults to
+# //build/config/ios/entitlements.plist.
+#
+# entitlements_target:
+# (optional) label of the target generating the application
+# entitlements (must generate a single file as output); cannot be
+# defined if entitlements_path is set.
+#
+template("create_signed_bundle") {
+ assert(defined(invoker.product_type),
+ "product_type must be defined for $target_name")
+ assert(defined(invoker.bundle_extension),
+ "bundle_extension must be defined for $target_name")
+ assert(defined(invoker.bundle_binary_target),
+ "bundle_binary_target must be defined for $target_name")
+
+ _target_name = target_name
+ _output_name = target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ _bundle_binary_target = invoker.bundle_binary_target
+ _bundle_binary_output = get_label_info(_bundle_binary_target, "name")
+ if (defined(invoker.bundle_binary_output)) {
+ _bundle_binary_output = invoker.bundle_binary_output
+ }
+
+ _bundle_extension = invoker.bundle_extension
+ _bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension"
+
+ if (!defined(invoker.entitlements_target)) {
+ _entitlements_path = "//build/config/ios/entitlements.plist"
+ if (defined(invoker.entitlements_path)) {
+ _entitlements_path = invoker.entitlements_path
+ }
+ } else {
+ assert(!defined(invoker.entitlements_path),
+ "Cannot define both entitlements_path and entitlements_target " +
+ "for $target_name")
+
+ _entitlements_target_outputs =
+ get_target_outputs(invoker.entitlements_target)
+ _entitlements_path = _entitlements_target_outputs[0]
+ }
+
+ _enable_code_signing = ios_enable_code_signing
+ if (defined(invoker.enable_code_signing)) {
+ _enable_code_signing = invoker.enable_code_signing
+ }
+
+ create_bundle(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "bundle_deps_filter",
+ "data_deps",
+ "deps",
+ "product_type",
+ "public_configs",
+ "public_deps",
+ "testonly",
+ "visibility",
+ ])
+
+ bundle_root_dir = _bundle_root_dir
+ bundle_resources_dir = _bundle_root_dir
+ bundle_executable_dir = _bundle_root_dir
+ bundle_plugins_dir = "$_bundle_root_dir/PlugIns"
+
+ if (!defined(public_deps)) {
+ public_deps = []
+ }
+ public_deps += [ _bundle_binary_target ]
+
+ if (defined(invoker.bundle_deps)) {
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += invoker.bundle_deps
+ }
+ if (defined(invoker.entitlements_target)) {
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ invoker.entitlements_target ]
+ }
+
+ code_signing_script = "//build/config/ios/codesign.py"
+ code_signing_sources = [
+ _entitlements_path,
+ get_label_info(_bundle_binary_target, "target_out_dir") +
+ "/$_bundle_binary_output",
+ ]
+ code_signing_outputs = [ "$_bundle_root_dir/$_output_name" ]
+ if (_enable_code_signing) {
+ code_signing_outputs +=
+ [ "$_bundle_root_dir/_CodeSignature/CodeResources" ]
+ }
+ if (ios_code_signing_identity != "" && !use_ios_simulator) {
+ code_signing_outputs += [ "$_bundle_root_dir/embedded.mobileprovision" ]
+ }
+
+ if (defined(invoker.extra_system_frameworks)) {
+ foreach(_framework, invoker.extra_system_frameworks) {
+ code_signing_outputs += [ "$bundle_root_dir/Frameworks/" +
+ get_path_info(_framework, "file") ]
+ }
+ }
+
+ code_signing_args = []
+ if (!use_system_xcode) {
+ code_signing_args += [
+ "--developer_dir",
+ hermetic_xcode_path,
+ ]
+ }
+ code_signing_args += [
+ "code-sign-bundle",
+ "-t=" + ios_sdk_name,
+ "-i=" + ios_code_signing_identity,
+ "-e=" + rebase_path(_entitlements_path, root_build_dir),
+ "-b=" + rebase_path("$target_out_dir/$_output_name", root_build_dir),
+ rebase_path(bundle_root_dir, root_build_dir),
+ ]
+ if (!_enable_code_signing) {
+ code_signing_args += [ "--disable-code-signature" ]
+ }
+ if (defined(invoker.extra_system_frameworks)) {
+ # All framework in extra_system_frameworks are expected to be
+ # system framework and the path to be already system absolute
+ # so do not use rebase_path here.
+ foreach(_framework, invoker.extra_system_frameworks) {
+ code_signing_args += [ "-F=" + _framework ]
+ }
+ }
+ }
+}
+
+# Generates Info.plist files for Mac apps and frameworks.
+#
+# Arguments
+#
+# info_plist:
+# (optional) string, path to the Info.plist file that will be used for
+# the bundle.
+#
+# info_plist_target:
+# (optional) string, if the info_plist is generated from an action,
+# rather than a regular source file, specify the target name in lieu
+# of info_plist. The two arguments are mutually exclusive.
+#
+# executable_name:
+# string, name of the generated target used for the product
+# and executable name as specified in the output Info.plist.
+#
+# extra_substitutions:
+# (optional) string array, 'key=value' pairs for extra fields which are
+# specified in a source Info.plist template.
+template("ios_info_plist") {
+ assert(defined(invoker.info_plist) != defined(invoker.info_plist_target),
+ "Only one of info_plist or info_plist_target may be specified in " +
+ target_name)
+
+ if (defined(invoker.info_plist)) {
+ _info_plist = invoker.info_plist
+ } else {
+ _info_plist_target_output = get_target_outputs(invoker.info_plist_target)
+ _info_plist = _info_plist_target_output[0]
+ }
+
+ info_plist(target_name) {
+ format = "binary1"
+ extra_substitutions = []
+ if (defined(invoker.extra_substitutions)) {
+ extra_substitutions = invoker.extra_substitutions
+ }
+ extra_substitutions += [
+ "IOS_BUNDLE_ID_PREFIX=$ios_app_bundle_id_prefix",
+ "IOS_DEPLOYMENT_TARGET=$ios_deployment_target",
+ "IOS_PLATFORM_BUILD=$ios_platform_build",
+ "IOS_PLATFORM_NAME=$ios_sdk_name",
+ "IOS_PLATFORM_VERSION=$ios_sdk_version",
+ "IOS_SDK_BUILD=$ios_sdk_build",
+ "IOS_SDK_NAME=$ios_sdk_name$ios_sdk_version",
+ "IOS_SUPPORTED_PLATFORM=$ios_sdk_platform",
+ ]
+ plist_templates = [
+ "//build/config/ios/BuildInfo.plist",
+ _info_plist,
+ ]
+ if (defined(invoker.info_plist_target)) {
+ deps = [
+ invoker.info_plist_target,
+ ]
+ }
+ forward_variables_from(invoker,
+ [
+ "executable_name",
+ "output_name",
+ "visibility",
+ ])
+ }
+}
+
+# Template to build an application bundle for iOS.
+#
+# This should be used instead of "executable" built-in target type on iOS.
+# As the template forward the generation of the application executable to
+# an "executable" target, all arguments supported by "executable" targets
+# are also supported by this template.
+#
+# Arguments
+#
+# output_name:
+# (optional) string, name of the generated application, if omitted,
+# defaults to the target_name.
+#
+# extra_substitutions:
+# (optional) list of string in "key=value" format, each value will
+# be used as an additional variable substitution rule when generating
+# the application Info.plist
+#
+# info_plist:
+# (optional) string, path to the Info.plist file that will be used for
+# the bundle.
+#
+# info_plist_target:
+# (optional) string, if the info_plist is generated from an action,
+# rather than a regular source file, specify the target name in lieu
+# of info_plist. The two arguments are mutually exclusive.
+#
+# entitlements_path:
+# (optional) path to the template to use to generate the application
+# entitlements by performing variable substitutions, defaults to
+# //build/config/ios/entitlements.plist.
+#
+# entitlements_target:
+# (optional) label of the target generating the application
+# entitlements (must generate a single file as output); cannot be
+# defined if entitlements_path is set.
+#
+# bundle_extension:
+# (optional) bundle extension including the dot, default to ".app".
+#
+# product_type
+# (optional) string, product type for the generated Xcode project,
+# default to "com.apple.product-type.application". Should generally
+# not be overridden.
+#
+# enable_code_signing
+# (optional) boolean, control whether code signing is enabled or not,
+# default to ios_enable_code_signing if not defined.
+#
+# For more information, see "gn help executable".
+template("ios_app_bundle") {
+ _output_name = target_name
+ _target_name = target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ _arch_executable_source = _target_name + "_arch_executable_sources"
+ _arch_executable_target = _target_name + "_arch_executable"
+ _lipo_executable_target = _target_name + "_executable"
+
+ source_set(_arch_executable_source) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "bundle_deps",
+ "bundle_deps_filter",
+ "bundle_extension",
+ "enable_code_signing",
+ "entitlements_path",
+ "entitlements_target",
+ "extra_substitutions",
+ "extra_system_frameworks",
+ "info_plist",
+ "info_plist_target",
+ "output_name",
+ "product_type",
+ "visibility",
+ ])
+
+ visibility = [ ":$_arch_executable_target" ]
+ }
+
+ if (current_toolchain == default_toolchain || use_ios_simulator) {
+ _generate_entitlements_target = _target_name + "_gen_entitlements"
+ _generate_entitlements_output =
+ get_label_info(":$_generate_entitlements_target($default_toolchain)",
+ "target_out_dir") + "/$_output_name.xcent"
+ }
+
+ executable(_arch_executable_target) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "bundle_deps",
+ "bundle_deps_filter",
+ "bundle_extension",
+ "enable_code_signing",
+ "entitlements_path",
+ "entitlements_target",
+ "extra_substitutions",
+ "extra_system_frameworks",
+ "info_plist",
+ "info_plist_target",
+ "output_name",
+ "product_type",
+ "sources",
+ "visibility",
+ ])
+
+ visibility = [ ":$_lipo_executable_target($default_toolchain)" ]
+ if (current_toolchain != default_toolchain) {
+ visibility += [ ":$_target_name" ]
+ }
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_arch_executable_source" ]
+
+ if (!defined(libs)) {
+ libs = []
+ }
+ libs += [ "UIKit.framework" ]
+
+ if (!defined(ldflags)) {
+ ldflags = []
+ }
+ ldflags += [
+ "-Xlinker",
+ "-rpath",
+ "-Xlinker",
+ "@executable_path/Frameworks",
+ "-Xlinker",
+ "-objc_abi_version",
+ "-Xlinker",
+ "2",
+ ]
+
+ if (use_ios_simulator) {
+ deps += [ ":$_generate_entitlements_target($default_toolchain)" ]
+
+ if (!defined(inputs)) {
+ inputs = []
+ }
+ inputs += [ _generate_entitlements_output ]
+
+ if (!defined(ldflags)) {
+ ldflags = []
+ }
+ ldflags += [
+ "-Xlinker",
+ "-sectcreate",
+ "-Xlinker",
+ "__TEXT",
+ "-Xlinker",
+ "__entitlements",
+ "-Xlinker",
+ rebase_path(_generate_entitlements_output, root_build_dir),
+ ]
+ }
+
+ output_name = _output_name
+ output_prefix_override = true
+ output_dir = "$target_out_dir/$current_cpu"
+ }
+
+ if (current_toolchain != default_toolchain) {
+ # For fat builds, only the default toolchain will generate an application
+ # bundle. For the other toolchains, the template is only used for building
+ # the arch-specific binary, thus the default target is just a group().
+
+ group(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "testonly",
+ ])
+ public_deps = [
+ ":$_arch_executable_target",
+ ]
+ }
+ } else {
+ lipo_binary(_lipo_executable_target) {
+ forward_variables_from(invoker,
+ [
+ "configs",
+ "testonly",
+ ])
+
+ visibility = [ ":$_target_name" ]
+ output_name = _output_name
+ arch_binary_target = ":$_arch_executable_target"
+ arch_binary_output = _output_name
+ }
+
+ _generate_info_plist = target_name + "_generate_info_plist"
+ ios_info_plist(_generate_info_plist) {
+ forward_variables_from(invoker,
+ [
+ "extra_substitutions",
+ "info_plist",
+ "info_plist_target",
+ ])
+
+ executable_name = _output_name
+ }
+
+ if (current_toolchain == default_toolchain) {
+ if (!defined(invoker.entitlements_target)) {
+ _entitlements_path = "//build/config/ios/entitlements.plist"
+ if (defined(invoker.entitlements_path)) {
+ _entitlements_path = invoker.entitlements_path
+ }
+ } else {
+ assert(!defined(invoker.entitlements_path),
+ "Cannot define both entitlements_path and entitlements_target" +
+ "for $_target_name")
+
+ _entitlements_target_outputs =
+ get_target_outputs(invoker.entitlements_target)
+ _entitlements_path = _entitlements_target_outputs[0]
+ }
+
+ action(_generate_entitlements_target) {
+ _gen_info_plist_outputs = get_target_outputs(":$_generate_info_plist")
+ _info_plist_path = _gen_info_plist_outputs[0]
+
+ script = "//build/config/ios/codesign.py"
+ deps = [
+ ":$_generate_info_plist",
+ ]
+ if (defined(invoker.entitlements_target)) {
+ deps += [ invoker.entitlements_target ]
+ }
+ sources = [
+ _entitlements_path,
+ _info_plist_path,
+ ]
+ outputs = [
+ _generate_entitlements_output,
+ ]
+
+ args = []
+ if (!use_system_xcode) {
+ args += [
+ "--developer_dir",
+ hermetic_xcode_path,
+ ]
+ }
+ args += [
+ "generate-entitlements",
+ "-e=" + rebase_path(_entitlements_path, root_build_dir),
+ "-p=" + rebase_path(_info_plist_path, root_build_dir),
+ ] + rebase_path(outputs, root_build_dir)
+ }
+ }
+
+ _bundle_data_info_plist = target_name + "_bundle_data_info_plist"
+ bundle_data(_bundle_data_info_plist) {
+ forward_variables_from(invoker, [ "testonly" ])
+
+ sources = get_target_outputs(":$_generate_info_plist")
+ outputs = [
+ "{{bundle_root_dir}}/Info.plist",
+ ]
+ public_deps = [
+ ":$_generate_info_plist",
+ ]
+ }
+
+ _app_product_type = "com.apple.product-type.application"
+ _product_type = _app_product_type
+ if (defined(invoker.product_type)) {
+ _product_type = invoker.product_type
+ }
+
+ _app_bundle_extension = ".app"
+ _bundle_extension = _app_bundle_extension
+ if (defined(invoker.bundle_extension)) {
+ _bundle_extension = invoker.bundle_extension
+ }
+
+ # Only write PkgInfo for real application, not application extension (they
+ # have the same product type but a different extension).
+ _write_pkg_info = _product_type == _app_product_type &&
+ _bundle_extension == _app_bundle_extension
+
+ if (_write_pkg_info) {
+ _create_pkg_info = target_name + "_pkg_info"
+ action(_create_pkg_info) {
+ forward_variables_from(invoker, [ "testonly" ])
+ script = "//build/config/mac/write_pkg_info.py"
+ sources = get_target_outputs(":$_generate_info_plist")
+ outputs = [
+ # Cannot name the output PkgInfo as the name will not be unique if
+ # multiple ios_app_bundle are defined in the same BUILD.gn file. The
+ # file is renamed in the bundle_data outputs to the correct name.
+ "$target_gen_dir/$target_name",
+ ]
+ args = [ "--plist" ] + rebase_path(sources, root_build_dir) +
+ [ "--output" ] + rebase_path(outputs, root_build_dir)
+ deps = [
+ ":$_generate_info_plist",
+ ]
+ }
+
+ _bundle_data_pkg_info = target_name + "_bundle_data_pkg_info"
+ bundle_data(_bundle_data_pkg_info) {
+ forward_variables_from(invoker, [ "testonly" ])
+ sources = get_target_outputs(":$_create_pkg_info")
+ outputs = [
+ "{{bundle_resources_dir}}/PkgInfo",
+ ]
+ public_deps = [
+ ":$_create_pkg_info",
+ ]
+ }
+ }
+
+ create_signed_bundle(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "bundle_deps",
+ "bundle_deps_filter",
+ "data_deps",
+ "deps",
+ "enable_code_signing",
+ "entitlements_path",
+ "entitlements_target",
+ "extra_system_frameworks",
+ "public_configs",
+ "public_deps",
+ "testonly",
+ "visibility",
+ ])
+
+ output_name = _output_name
+ bundle_binary_target = ":$_lipo_executable_target"
+ bundle_binary_output = _output_name
+ bundle_extension = _bundle_extension
+ product_type = _product_type
+
+ if (!defined(bundle_deps)) {
+ bundle_deps = []
+ }
+ bundle_deps += [ ":$_bundle_data_info_plist" ]
+ if (_write_pkg_info) {
+ bundle_deps += [ ":$_bundle_data_pkg_info" ]
+ }
+
+ if (use_ios_simulator) {
+ if (!defined(data_deps)) {
+ data_deps = []
+ }
+ data_deps += [ "//testing/iossim" ]
+ }
+ }
+ }
+}
+
+set_defaults("ios_app_bundle") {
+ configs = default_executable_configs
+}
+
+# Template to build an application extension bundle for iOS.
+#
+# This should be used instead of "executable" built-in target type on iOS.
+# As the template forward the generation of the application executable to
+# an "executable" target, all arguments supported by "executable" targets
+# are also supported by this template.
+#
+# Arguments
+#
+# output_name:
+# (optional) string, name of the generated application, if omitted,
+# defaults to the target_name.
+#
+# extra_substitutions:
+# (optional) list of string in "key=value" format, each value will
+# be used as an additional variable substitution rule when generating
+# the application Info.plist
+#
+# info_plist:
+# (optional) string, path to the Info.plist file that will be used for
+# the bundle.
+#
+# info_plist_target:
+# (optional) string, if the info_plist is generated from an action,
+# rather than a regular source file, specify the target name in lieu
+# of info_plist. The two arguments are mutually exclusive.
+#
+# For more information, see "gn help executable".
+template("ios_appex_bundle") {
+ ios_app_bundle(target_name) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "bundle_extension",
+ "product_type",
+ ])
+ bundle_extension = ".appex"
+ product_type = "com.apple.product-type.app-extension"
+
+ # Add linker flags required for an application extension (determined by
+ # inspecting the link command-line when using Xcode 9.0+).
+ if (!defined(ldflags)) {
+ ldflags = []
+ }
+ ldflags += [
+ "-e",
+ "_NSExtensionMain",
+ "-fapplication-extension",
+ ]
+ }
+}
+
+set_defaults("ios_appex_bundle") {
+ configs = default_executable_configs
+}
+
+# Compile a xib or storyboard file and add it to a bundle_data so that it is
+# available at runtime in the bundle.
+#
+# Arguments
+#
+# source:
+# string, path of the xib or storyboard to compile.
+#
+# Forwards all variables to the bundle_data target.
+template("bundle_data_ib_file") {
+ assert(defined(invoker.source), "source needs to be defined for $target_name")
+
+ _source_extension = get_path_info(invoker.source, "extension")
+ assert(_source_extension == "xib" || _source_extension == "storyboard",
+ "source must be a .xib or .storyboard for $target_name")
+
+ _target_name = target_name
+ if (_source_extension == "xib") {
+ _compile_ib_file = target_name + "_compile_xib"
+ _output_extension = "nib"
+ } else {
+ _compile_ib_file = target_name + "_compile_storyboard"
+ _output_extension = "storyboardc"
+ }
+
+ compile_ib_files(_compile_ib_file) {
+ sources = [
+ invoker.source,
+ ]
+ output_extension = _output_extension
+ visibility = [ ":$_target_name" ]
+ ibtool_flags = [
+ "--minimum-deployment-target",
+ ios_deployment_target,
+ "--auto-activate-custom-fonts",
+ "--target-device",
+ "iphone",
+ "--target-device",
+ "ipad",
+ ]
+ }
+
+ bundle_data(_target_name) {
+ forward_variables_from(invoker, "*", [ "source" ])
+
+ if (!defined(public_deps)) {
+ public_deps = []
+ }
+ public_deps += [ ":$_compile_ib_file" ]
+
+ sources = get_target_outputs(":$_compile_ib_file")
+
+ outputs = [
+ "{{bundle_resources_dir}}/{{source_file_part}}",
+ ]
+ }
+}
+
+# Compile a strings file and add it to a bundle_data so that it is available
+# at runtime in the bundle.
+#
+# Arguments
+#
+# source:
+# string, path of the strings file to compile.
+#
+# output:
+# string, path of the compiled file in the final bundle.
+#
+# Forwards all variables to the bundle_data target.
+template("bundle_data_strings") {
+ assert(defined(invoker.source), "source needs to be defined for $target_name")
+ assert(defined(invoker.output), "output needs to be defined for $target_name")
+
+ _source_extension = get_path_info(invoker.source, "extension")
+ assert(_source_extension == "strings",
+ "source must be a .strings for $target_name")
+
+ _target_name = target_name
+ _convert_target = target_name + "_compile_strings"
+
+ convert_plist(_convert_target) {
+ visibility = [ ":$_target_name" ]
+ source = invoker.source
+ output =
+ "$target_gen_dir/$_target_name/" + get_path_info(invoker.source, "file")
+ format = "binary1"
+ }
+
+ bundle_data(_target_name) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "source",
+ "output",
+ ])
+
+ if (!defined(public_deps)) {
+ public_deps = []
+ }
+ public_deps += [ ":$_convert_target" ]
+
+ sources = get_target_outputs(":$_convert_target")
+
+ outputs = [
+ invoker.output,
+ ]
+ }
+}
+
+# Template to package a shared library into an iOS framework bundle.
+#
+# By default, the bundle target this template generates does not link the
+# resulting framework into anything that depends on it. If a dependency wants
+# a link-time (as well as build-time) dependency on the framework bundle,
+# depend against "$target_name+link". If only the build-time dependency is
+# required (e.g., for copying into another bundle), then use "$target_name".
+#
+# Arguments
+#
+# output_name:
+# (optional) string, name of the generated framework without the
+# .framework suffix. If omitted, defaults to target_name.
+#
+# public_headers:
+# (optional) list of paths to header file that needs to be copied
+# into the framework bundle Headers subdirectory. If omitted or
+# empty then the Headers subdirectory is not created.
+#
+# sources
+# (optional) list of files. Needs to be defined and non-empty if
+# public_headers is defined and non-empty.
+#
+# enable_code_signing
+# (optional) boolean, control whether code signing is enabled or not,
+# default to ios_enable_code_signing if not defined.
+#
+# This template provides two targets for the resulting framework bundle. The
+# link-time behavior varies depending on which of the two targets below is
+# added as a dependency:
+# - $target_name only adds a build-time dependency. Targets that depend on
+# it will not link against the framework.
+# - $target_name+link adds a build-time and link-time dependency. Targets
+# that depend on it will link against the framework.
+#
+# The build-time-only dependency is used for when a target needs to use the
+# framework either only for resources, or because the target loads it at run-
+# time, via dlopen() or NSBundle. The link-time dependency will cause the
+# dependee to have the framework loaded by dyld at launch.
+#
+# Example of build-time only dependency:
+#
+# framework_bundle("CoreTeleportation") {
+# sources = [ ... ]
+# }
+#
+# bundle_data("core_teleportation_bundle_data") {
+# deps = [ ":CoreTeleportation" ]
+# sources = [ "$root_out_dir/CoreTeleportation.framework" ]
+# outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ]
+# }
+#
+# app_bundle("GoatTeleporter") {
+# sources = [ ... ]
+# deps = [
+# ":core_teleportation_bundle_data",
+# ]
+# }
+#
+# The GoatTeleporter.app will not directly link against
+# CoreTeleportation.framework, but it will be included in the bundle's
+# Frameworks directory.
+#
+# Example of link-time dependency:
+#
+# framework_bundle("CoreTeleportation") {
+# sources = [ ... ]
+# ldflags = [
+# "-install_name",
+# "@executable_path/../Frameworks/$target_name.framework"
+# ]
+# }
+#
+# bundle_data("core_teleportation_bundle_data") {
+# deps = [ ":CoreTeleportation+link" ]
+# sources = [ "$root_out_dir/CoreTeleportation.framework" ]
+# outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ]
+# }
+#
+# app_bundle("GoatTeleporter") {
+# sources = [ ... ]
+# deps = [
+# ":core_teleportation_bundle_data",
+# ]
+# }
+#
+# Note that the framework is still copied to the app's bundle, but dyld will
+# load this library when the app is launched because it uses the "+link"
+# target as a dependency. This also requires that the framework set its
+# install_name so that dyld can locate it.
+#
+# See "gn help shared_library" for more information on arguments supported
+# by shared library target.
+template("ios_framework_bundle") {
+ _target_name = target_name
+ _output_name = target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ _has_public_headers =
+ defined(invoker.public_headers) && invoker.public_headers != []
+
+ # Public configs are not propagated across toolchain (see crbug.com/675224)
+ # so some configs have to be defined for both default_toolchain and all others
+ # toolchains when performing a fat build. Use "get_label_info" to construct
+ # the path since they need to be relative to the default_toolchain.
+
+ _default_toolchain_root_out_dir =
+ get_label_info("$_target_name($default_toolchain)", "root_out_dir")
+ _default_toolchain_target_gen_dir =
+ get_label_info("$_target_name($default_toolchain)", "target_gen_dir")
+
+ if (_has_public_headers) {
+ _framework_headers_target = _target_name + "_framework_headers"
+ _framework_headers_config = _target_name + "_framework_headers_config"
+ config(_framework_headers_config) {
+ # The link settings are inherited from the framework_bundle config.
+ cflags = [
+ "-F",
+ rebase_path("$_default_toolchain_root_out_dir/.", root_build_dir),
+ ]
+ }
+
+ _headers_map_config = _target_name + "_headers_map"
+ _header_map_filename =
+ "$_default_toolchain_target_gen_dir/$_output_name.headers.hmap"
+ config(_headers_map_config) {
+ visibility = [ ":$_target_name" ]
+ include_dirs = [ _header_map_filename ]
+ }
+ }
+
+ _arch_shared_library_source = _target_name + "_arch_shared_library_sources"
+ _arch_shared_library_target = _target_name + "_arch_shared_library"
+ _lipo_shared_library_target = _target_name + "_shared_library"
+ _link_target_name = _target_name + "+link"
+
+ _framework_public_config = _target_name + "_public_config"
+ config(_framework_public_config) {
+ # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs
+ # and include_dirs to avoid duplicate values on the command-line.
+ visibility = [ ":$_target_name" ]
+ ldflags = [
+ "-F",
+ rebase_path("$_default_toolchain_root_out_dir/.", root_build_dir),
+ ]
+ lib_dirs = [ root_out_dir ]
+ libs = [ "$_output_name.framework" ]
+ }
+
+ source_set(_arch_shared_library_source) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "bundle_deps",
+ "bundle_deps_filter",
+ "data_deps",
+ "enable_code_signing",
+ "info_plist",
+ "info_plist_target",
+ "output_name",
+ "visibility",
+ ])
+
+ visibility = [ ":$_arch_shared_library_target" ]
+
+ if (_has_public_headers) {
+ configs += [
+ ":$_framework_headers_config",
+ ":$_headers_map_config",
+ ]
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_framework_headers_target($default_toolchain)" ]
+ }
+ }
+
+ shared_library(_arch_shared_library_target) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "bundle_deps",
+ "bundle_deps_filter",
+ "data_deps",
+ "enable_code_signing",
+ "info_plist",
+ "info_plist_target",
+ "output_name",
+ "sources",
+ "visibility",
+ ])
+
+ visibility = [ ":$_lipo_shared_library_target($default_toolchain)" ]
+ if (current_toolchain != default_toolchain) {
+ visibility += [ ":$_target_name" ]
+ }
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_arch_shared_library_source" ]
+
+ if (!defined(ldflags)) {
+ ldflags = []
+ }
+ ldflags += [
+ "-Xlinker",
+ "-install_name",
+ "-Xlinker",
+ "@rpath/$_output_name.framework/$_output_name",
+ "-Xlinker",
+ "-objc_abi_version",
+ "-Xlinker",
+ "2",
+ ]
+
+ output_extension = ""
+ output_name = _output_name
+ output_prefix_override = true
+ output_dir = "$target_out_dir/$current_cpu"
+ }
+
+ if (current_toolchain != default_toolchain) {
+ # For fat builds, only the default toolchain will generate a framework
+ # bundle. For the other toolchains, the template is only used for building
+ # the arch-specific binary, thus the default target is just a group().
+
+ group(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "testonly",
+ ])
+ public_deps = [
+ ":$_arch_shared_library_target",
+ ]
+ }
+
+ group(_link_target_name) {
+ forward_variables_from(invoker,
+ [
+ "public_configs",
+ "visibility",
+ "testonly",
+ ])
+ public_deps = [
+ ":$_link_target_name($default_toolchain)",
+ ]
+
+ if (_has_public_headers) {
+ if (!defined(public_configs)) {
+ public_configs = []
+ }
+ public_configs += [ ":$_framework_headers_config" ]
+ }
+ if (!defined(all_dependent_configs)) {
+ all_dependent_configs = []
+ }
+ all_dependent_configs += [ ":$_framework_public_config" ]
+ }
+
+ if (defined(invoker.bundle_deps)) {
+ assert(invoker.bundle_deps != [], "mark bundle_deps as used")
+ }
+ } else {
+ if (_has_public_headers) {
+ _public_headers = invoker.public_headers
+ _framework_root = "$root_out_dir/$_output_name.framework"
+
+ _compile_headers_map_target = _target_name + "_compile_headers_map"
+ action(_compile_headers_map_target) {
+ visibility = [ ":$_framework_headers_target" ]
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "public_deps",
+ "testonly",
+ ])
+ script = "//build/config/ios/write_framework_hmap.py"
+ outputs = [
+ _header_map_filename,
+ ]
+
+ # The header map generation only wants the list of headers, not all of
+ # sources, so filter any non-header source files from "sources". It is
+ # less error prone that having the developer duplicate the list of all
+ # headers in addition to "sources".
+ set_sources_assignment_filter([
+ "*.c",
+ "*.cc",
+ "*.cpp",
+ "*.m",
+ "*.mm",
+ ])
+ sources = invoker.sources
+ set_sources_assignment_filter([])
+
+ args = [
+ rebase_path(_header_map_filename),
+ rebase_path(_framework_root, root_build_dir),
+ ] + rebase_path(sources, root_build_dir)
+ }
+
+ _create_module_map_target = _target_name + "_module_map"
+ action(_create_module_map_target) {
+ visibility = [ ":$_framework_headers_target" ]
+ script = "//build/config/ios/write_framework_modulemap.py"
+ outputs = [
+ "$_framework_root/Modules/module.modulemap",
+ ]
+ args = [ rebase_path("$_framework_root", root_build_dir) ]
+ }
+
+ _copy_public_headers_target = _target_name + "_copy_public_headers"
+ copy(_copy_public_headers_target) {
+ visibility = [ ":$_framework_headers_target" ]
+ sources = _public_headers
+ outputs = [
+ "$_framework_root/Headers/{{source_file_part}}",
+ ]
+ }
+
+ group(_framework_headers_target) {
+ forward_variables_from(invoker, [ "testonly" ])
+ deps = [
+ ":$_compile_headers_map_target",
+ ":$_copy_public_headers_target",
+ ":$_create_module_map_target",
+ ]
+ }
+ }
+
+ lipo_binary(_lipo_shared_library_target) {
+ forward_variables_from(invoker,
+ [
+ "configs",
+ "testonly",
+ ])
+
+ visibility = [ ":$_target_name" ]
+ output_name = _output_name
+ arch_binary_target = ":$_arch_shared_library_target"
+ arch_binary_output = _output_name
+ }
+
+ _info_plist_target = _target_name + "_info_plist"
+ _info_plist_bundle = _target_name + "_info_plist_bundle"
+ ios_info_plist(_info_plist_target) {
+ visibility = [ ":$_info_plist_bundle" ]
+ executable_name = _output_name
+ forward_variables_from(invoker,
+ [
+ "extra_substitutions",
+ "info_plist",
+ "info_plist_target",
+ ])
+ }
+
+ bundle_data(_info_plist_bundle) {
+ visibility = [ ":$_target_name" ]
+ forward_variables_from(invoker, [ "testonly" ])
+ sources = get_target_outputs(":$_info_plist_target")
+ outputs = [
+ "{{bundle_root_dir}}/Info.plist",
+ ]
+ public_deps = [
+ ":$_info_plist_target",
+ ]
+ }
+
+ create_signed_bundle(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "bundle_deps",
+ "bundle_deps_filter",
+ "data_deps",
+ "deps",
+ "enable_code_signing",
+ "public_configs",
+ "public_deps",
+ "testonly",
+ "visibility",
+ ])
+
+ product_type = "com.apple.product-type.framework"
+ bundle_extension = ".framework"
+
+ output_name = _output_name
+ bundle_binary_target = ":$_lipo_shared_library_target"
+ bundle_binary_output = _output_name
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_info_plist_bundle" ]
+ }
+
+ group(_link_target_name) {
+ forward_variables_from(invoker,
+ [
+ "public_configs",
+ "public_deps",
+ "testonly",
+ "visibility",
+ ])
+ if (!defined(public_deps)) {
+ public_deps = []
+ }
+ public_deps += [ ":$_target_name" ]
+
+ if (_has_public_headers) {
+ if (!defined(public_configs)) {
+ public_configs = []
+ }
+ public_configs += [ ":$_framework_headers_config" ]
+ }
+ if (!defined(all_dependent_configs)) {
+ all_dependent_configs = []
+ }
+ all_dependent_configs += [ ":$_framework_public_config" ]
+ }
+
+ bundle_data(_target_name + "+bundle") {
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "visibility",
+ ])
+ public_deps = [
+ ":$_target_name",
+ ]
+ sources = [
+ "$root_out_dir/$_output_name.framework",
+ ]
+ outputs = [
+ "{{bundle_resources_dir}}/Frameworks/$_output_name.framework",
+ ]
+ }
+ }
+}
+
+set_defaults("ios_framework_bundle") {
+ configs = default_shared_library_configs
+}
+
+# For Chrome on iOS we want to run XCTests for all our build configurations
+# (Debug, Release, ...). In addition, the symbols visibility is configured to
+# private by default. To simplify testing with those constraints, our tests are
+# compiled in the TEST_HOST target instead of the .xctest bundle.
+template("ios_xctest_test") {
+ _target_name = target_name
+ _output_name = target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ _xctest_target = _target_name + "_module"
+ _xctest_output = _output_name + "_module"
+
+ _host_target = _target_name
+ _host_output = _output_name
+
+ _xctest_arch_loadable_module_target = _xctest_target + "_arch_loadable_module"
+ _xctest_lipo_loadable_module_target = _xctest_target + "_loadable_module"
+
+ loadable_module(_xctest_arch_loadable_module_target) {
+ visibility = [ ":$_xctest_lipo_loadable_module_target($default_toolchain)" ]
+ if (current_toolchain != default_toolchain) {
+ visibility += [ ":$_xctest_target" ]
+ }
+
+ sources = [
+ "//build/config/ios/xctest_shell.mm",
+ ]
+ configs += [ "//build/config/ios:xctest_config" ]
+
+ output_dir = "$target_out_dir/$current_cpu"
+ output_name = _xctest_output
+ output_prefix_override = true
+ output_extension = ""
+ }
+
+ if (current_toolchain != default_toolchain) {
+ # For fat builds, only the default toolchain will generate a test bundle.
+ # For the other toolchains, the template is only used for building the
+ # arch-specific binary, thus the default target is just a group().
+ group(_xctest_target) {
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "testonly",
+ ])
+ public_deps = [
+ ":$_xctest_arch_loadable_module_target",
+ ]
+ }
+ } else {
+ _xctest_info_plist_target = _xctest_target + "_info_plist"
+ _xctest_info_plist_bundle = _xctest_target + "_info_plist_bundle"
+ ios_info_plist(_xctest_info_plist_target) {
+ visibility = [ ":$_xctest_info_plist_bundle" ]
+ info_plist = "//build/config/ios/Module-Info.plist"
+ executable_name = _host_output
+ if (ios_automatically_manage_certs) {
+ # Use the same bundle identifier for EarlGrey tests as for unit tests
+ # when managing certificates as the number of free certs is limited.
+ extra_substitutions = [
+ "EXECUTABLE_NAME=gtest.${ios_generic_test_bundle_id_suffix}",
+ "MODULE_NAME=${ios_generic_test_bundle_id_suffix}-module",
+ ]
+ } else {
+ extra_substitutions = [ "MODULE_NAME=$_xctest_output" ]
+ }
+ }
+
+ bundle_data(_xctest_info_plist_bundle) {
+ visibility = [ ":$_xctest_target" ]
+ public_deps = [
+ ":$_xctest_info_plist_target",
+ ]
+ sources = get_target_outputs(":$_xctest_info_plist_target")
+ outputs = [
+ "{{bundle_root_dir}}/Info.plist",
+ ]
+ }
+
+ lipo_binary(_xctest_lipo_loadable_module_target) {
+ forward_variables_from(invoker,
+ [
+ "configs",
+ "testonly",
+ ])
+
+ visibility = [ ":$_xctest_target" ]
+ output_name = _xctest_output
+ arch_binary_target = ":$_xctest_arch_loadable_module_target"
+ arch_binary_output = _xctest_output
+ }
+
+ _xctest_bundle = _xctest_target + "_bundle"
+ create_signed_bundle(_xctest_target) {
+ forward_variables_from(invoker, [ "enable_code_signing" ])
+ visibility = [ ":$_xctest_bundle" ]
+
+ product_type = "com.apple.product-type.bundle.unit-test"
+ bundle_extension = ".xctest"
+
+ output_name = _xctest_output
+ bundle_binary_target = ":$_xctest_lipo_loadable_module_target"
+ bundle_binary_output = _xctest_output
+
+ deps = [
+ ":$_xctest_info_plist_bundle",
+ ]
+ }
+
+ bundle_data(_xctest_bundle) {
+ visibility = [ ":$_host_target" ]
+ public_deps = [
+ ":$_xctest_target",
+ ]
+ sources = [
+ "$root_out_dir/$_xctest_output.xctest",
+ ]
+ outputs = [
+ "{{bundle_plugins_dir}}/$_xctest_output.xctest",
+ ]
+ }
+ }
+
+ ios_app_bundle(_host_target) {
+ forward_variables_from(invoker, "*", [ "testonly" ])
+
+ testonly = true
+ output_name = _host_output
+ configs += [ "//build/config/ios:xctest_config" ]
+
+ if (!defined(invoker.info_plist) && !defined(invoker.info_plist_target)) {
+ info_plist = "//build/config/ios/Host-Info.plist"
+ if (ios_automatically_manage_certs) {
+ # Use the same bundle identifier for EarlGrey tests as for unit tests
+ # when managing certificates as the number of free certs is limited.
+ if (!defined(extra_substitutions)) {
+ extra_substitutions = []
+ }
+ extra_substitutions +=
+ [ "EXECUTABLE_NAME=gtest.${ios_generic_test_bundle_id_suffix}" ]
+ }
+ }
+
+ # Xcode needs those two framework installed in the application (and signed)
+ # for the XCTest to run, so install them using extra_system_frameworks.
+ _ios_platform_library = "$ios_sdk_platform_path/Developer/Library"
+ extra_system_frameworks = [
+ "$_ios_platform_library/Frameworks/XCTest.framework",
+ "$_ios_platform_library/PrivateFrameworks/IDEBundleInjection.framework",
+ ]
+
+ if (current_toolchain == default_toolchain) {
+ if (!defined(bundle_deps)) {
+ bundle_deps = []
+ }
+ bundle_deps += [ ":$_xctest_bundle" ]
+ }
+
+ if (!defined(ldflags)) {
+ ldflags = []
+ }
+ ldflags += [
+ "-Xlinker",
+ "-rpath",
+ "-Xlinker",
+ "@executable_path/Frameworks",
+ "-Xlinker",
+ "-rpath",
+ "-Xlinker",
+ "@loader_path/Frameworks",
+ ]
+ }
+}
+
+set_defaults("ios_xctest_test") {
+ configs = default_executable_configs
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/write_framework_hmap.py b/third_party/libwebrtc/webrtc/build/config/ios/write_framework_hmap.py
new file mode 100644
index 0000000000..8f6b1439d0
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/write_framework_hmap.py
@@ -0,0 +1,97 @@
+# 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 os
+import struct
+import sys
+
+def Main(args):
+ if len(args) < 4:
+ print >> sys.stderr, "Usage: %s output.hmap Foo.framework header1.h..." %\
+ (args[0])
+ return 1
+
+ (out, framework, all_headers) = args[1], args[2], args[3:]
+
+ framework_name = os.path.basename(framework).split('.')[0]
+ all_headers = map(os.path.abspath, all_headers)
+ filelist = {}
+ for header in all_headers:
+ filename = os.path.basename(header)
+ filelist[filename] = header
+ filelist[os.path.join(framework_name, filename)] = header
+ WriteHmap(out, filelist)
+ return 0
+
+
+def NextGreaterPowerOf2(x):
+ return 2**(x).bit_length()
+
+
+def WriteHmap(output_name, filelist):
+ """Generates a header map based on |filelist|.
+
+ Per Mark Mentovai:
+ A header map is structured essentially as a hash table, keyed by names used
+ in #includes, and providing pathnames to the actual files.
+
+ The implementation below and the comment above comes from inspecting:
+ http://www.opensource.apple.com/source/distcc/distcc-2503/distcc_dist/include_server/headermap.py?txt
+ while also looking at the implementation in clang in:
+ https://llvm.org/svn/llvm-project/cfe/trunk/lib/Lex/HeaderMap.cpp
+ """
+ magic = 1751998832
+ version = 1
+ _reserved = 0
+ count = len(filelist)
+ capacity = NextGreaterPowerOf2(count)
+ strings_offset = 24 + (12 * capacity)
+ max_value_length = len(max(filelist.items(), key=lambda (k,v):len(v))[1])
+
+ out = open(output_name, 'wb')
+ out.write(struct.pack('<LHHLLLL', magic, version, _reserved, strings_offset,
+ count, capacity, max_value_length))
+
+ # Create empty hashmap buckets.
+ buckets = [None] * capacity
+ for file, path in filelist.items():
+ key = 0
+ for c in file:
+ key += ord(c.lower()) * 13
+
+ # Fill next empty bucket.
+ while buckets[key & capacity - 1] is not None:
+ key = key + 1
+ buckets[key & capacity - 1] = (file, path)
+
+ next_offset = 1
+ for bucket in buckets:
+ if bucket is None:
+ out.write(struct.pack('<LLL', 0, 0, 0))
+ else:
+ (file, path) = bucket
+ key_offset = next_offset
+ prefix_offset = key_offset + len(file) + 1
+ suffix_offset = prefix_offset + len(os.path.dirname(path) + os.sep) + 1
+ next_offset = suffix_offset + len(os.path.basename(path)) + 1
+ out.write(struct.pack('<LLL', key_offset, prefix_offset, suffix_offset))
+
+ # Pad byte since next offset starts at 1.
+ out.write(struct.pack('<x'))
+
+ for bucket in buckets:
+ if bucket is not None:
+ (file, path) = bucket
+ out.write(struct.pack('<%ds' % len(file), file))
+ out.write(struct.pack('<s', '\0'))
+ base = os.path.dirname(path) + os.sep
+ out.write(struct.pack('<%ds' % len(base), base))
+ out.write(struct.pack('<s', '\0'))
+ path = os.path.basename(path)
+ out.write(struct.pack('<%ds' % len(path), path))
+ out.write(struct.pack('<s', '\0'))
+
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv))
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/write_framework_modulemap.py b/third_party/libwebrtc/webrtc/build/config/ios/write_framework_modulemap.py
new file mode 100644
index 0000000000..b6da571282
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/write_framework_modulemap.py
@@ -0,0 +1,26 @@
+# 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 os
+import sys
+
+def Main(framework):
+ # Find the name of the binary based on the part before the ".framework".
+ binary = os.path.basename(framework).split('.')[0]
+ module_path = os.path.join(framework, 'Modules');
+ if not os.path.exists(module_path):
+ os.mkdir(module_path)
+ module_template = 'framework module %s {\n' \
+ ' umbrella header "%s.h"\n' \
+ '\n' \
+ ' export *\n' \
+ ' module * { export * }\n' \
+ '}\n' % (binary, binary)
+
+ module_file = open(os.path.join(module_path, 'module.modulemap'), 'w')
+ module_file.write(module_template)
+ module_file.close()
+
+if __name__ == '__main__':
+ Main(sys.argv[1])
diff --git a/third_party/libwebrtc/webrtc/build/config/ios/xctest_shell.mm b/third_party/libwebrtc/webrtc/build/config/ios/xctest_shell.mm
new file mode 100644
index 0000000000..dcf5bad5e7
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ios/xctest_shell.mm
@@ -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 <UIKit/UIKit.h>
+#import <XCTest/XCTest.h>
+
+// For Chrome on iOS we want to run EarlGrey tests (that are XCTests) for all
+// our build configurations (Debug, Release, ...). In addition, the symbols
+// visibility is configured to private by default. To simplify testing with
+// those constraints, our tests are compiled in the TEST_HOST target instead
+// of the .xctest bundle that all link against this single test (just there to
+// ensure that the bundle is not empty).
+
+@interface XCTestShellEmptyClass : NSObject
+@end
+
+@implementation XCTestShellEmptyClass
+@end
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/linux/BUILD.gn
new file mode 100644
index 0000000000..c3eb34fcc0
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/BUILD.gn
@@ -0,0 +1,102 @@
+# 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/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") {
+}
+
+# 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" ]
+ }
+}
+
+config("x11") {
+ libs = [
+ "X11",
+ "X11-xcb",
+ "xcb",
+ "Xcomposite",
+ "Xcursor",
+ "Xdamage",
+ "Xext",
+ "Xfixes",
+ "Xi",
+ "Xrender",
+ ]
+
+ if (!build_with_mozilla) {
+ libs += [
+ "Xtst",
+ ]
+ }
+}
+
+config("xcomposite") {
+ libs = [ "Xcomposite" ]
+}
+
+config("xext") {
+ libs = [ "Xext" ]
+}
+
+config("xrandr") {
+ libs = [ "Xrandr" ]
+}
+
+config("xscrnsaver") {
+ libs = [ "Xss" ]
+}
+
+config("xfixes") {
+ libs = [ "Xfixes" ]
+}
+
+config("libcap") {
+ libs = [ "cap" ]
+}
+
+config("xi") {
+ libs = [ "Xi" ]
+}
+
+if (!build_with_mozilla) {
+ config("xtst") {
+ libs = [ "Xtst" ]
+ }
+}
+
+config("libresolv") {
+ libs = [ "resolv" ]
+}
+
+if (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_32",
+ "GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_26",
+ ]
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/atk/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/linux/atk/BUILD.gn
new file mode 100644
index 0000000000..27e8f41a52
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/atk/BUILD.gn
@@ -0,0 +1,47 @@
+# 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")
+import("//build/config/ui.gni")
+
+# CrOS doesn't install GTK, gconf or any gnome packages.
+assert(!is_chromeos)
+
+# These packages should _only_ be expected when building for a target.
+# If these extra checks are not run, gconf is required when building host
+# tools for a CrOS build.
+assert(current_toolchain == default_toolchain)
+
+if (use_atk) {
+ assert(use_glib, "use_atk=true requires that use_glib=true")
+}
+
+pkg_config("atk_base") {
+ packages = [ "atk" ]
+ atk_lib_dir = exec_script(pkg_config_script,
+ pkg_config_args + [
+ "--libdir",
+ "atk",
+ ],
+ "string")
+ defines = [ "ATK_LIB_DIR=\"$atk_lib_dir\"" ]
+}
+
+# gn orders flags on a target before flags from configs. The default config
+# adds -Wall, and these flags have to be after -Wall -- so they need to
+# come from a config and can't be on the target directly.
+config("atk") {
+ configs = [ ":atk_base" ]
+
+ cflags = [
+ # glib uses the pre-c++11 typedef-as-static_assert hack.
+ "-Wno-unused-local-typedef",
+
+ # G_DEFINE_TYPE automatically generates a *get_instance_private
+ # inline function after glib 2.37. That's unused. Prevent to
+ # complain about it.
+ "-Wno-unused-function",
+ ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/dbus/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/linux/dbus/BUILD.gn
new file mode 100644
index 0000000000..f11cf7101c
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/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/webrtc/build/config/linux/gconf/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/linux/gconf/BUILD.gn
new file mode 100644
index 0000000000..262e96aa8e
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/gconf/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/features.gni")
+import("//build/config/linux/pkg_config.gni")
+
+# CrOS doesn't install GTK, gconf or any gnome packages.
+assert(!is_chromeos && use_gconf)
+
+# These packages should _only_ be expected when building for a target.
+# If these extra checks are not run, gconf is required when building host
+# tools for a CrOS build.
+assert(current_toolchain == default_toolchain)
+
+pkg_config("gconf") {
+ packages = [ "gconf-2.0" ]
+ defines = [ "USE_GCONF" ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/gtk/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/linux/gtk/BUILD.gn
new file mode 100644
index 0000000000..95345c878a
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/gtk/BUILD.gn
@@ -0,0 +1,39 @@
+# 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")
+
+# The target in this file will automatically reference GTK2 or GTK3 depending
+# on the state of the build flag. Some builds reference both 2 and 3, and some
+# builds reference neither, so both need to be available but in different
+# directories so pkg-config is only run when necessary.
+
+# Basically no parts of Chrome should depend on GTK. To prevent accidents, the
+# parts that explicitly need GTK are whitelisted on this target.
+group("gtk") {
+ visibility = [
+ "//chrome/test:interactive_ui_tests",
+ "//gpu/gles2_conform_support:gles2_conform_test_windowless",
+ "//remoting/host",
+ "//remoting/host/linux",
+ "//remoting/host/it2me:common",
+ "//remoting/host/it2me:remote_assistance_host",
+ "//remoting/host:remoting_me2me_host_static",
+ "//remoting/test:it2me_standalone_host_main",
+ "//webrtc/examples:peerconnection_client",
+ ]
+
+ if (use_gtk3) {
+ public_deps = [
+ "//build/config/linux/gtk3",
+ ]
+ } else {
+ public_deps = [
+ "//build/config/linux/gtk2",
+ ]
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/gtk/gtk.gni b/third_party/libwebrtc/webrtc/build/config/linux/gtk/gtk.gni
new file mode 100644
index 0000000000..53e943e14d
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/gtk/gtk.gni
@@ -0,0 +1,12 @@
+# 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.
+
+# Include this file if you need to know at build time whether we're compiling
+# against GTK 2 or 3. But in most cases you can just depend on
+# //build/config/linux/gtk and it will switch for you.
+
+declare_args() {
+ # Whether to compile against GTKv3 instead of GTKv2.
+ use_gtk3 = true
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/gtk2/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/linux/gtk2/BUILD.gn
new file mode 100644
index 0000000000..58af02a9b1
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/gtk2/BUILD.gn
@@ -0,0 +1,44 @@
+# Copyright 2015 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")
+
+# Depend on //build/config/linux/gtk2 to use GTKv2. Depend on
+# //build/config/linux/gtk to get GTK 2 or 3 depending on the build flags.
+#
+# 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("gtk2_internal_config") {
+ # Gtk requires gmodule, but it does not list it as a dependency in some
+ # misconfigured systems.
+ packages = [
+ "gmodule-2.0",
+ "gtk+-2.0",
+ "gthread-2.0",
+ ]
+}
+
+# Basically no parts of Chrome should depend on GTK. To prevent accidents, the
+# parts that explicitly need GTK2 are whitelisted on this target.
+group("gtk2") {
+ visibility = [
+ "//gpu/gles2_conform_support:gles2_conform_test_windowless",
+ "//build/config/linux/gtk",
+ "//chrome/browser/ui/libgtkui:*",
+ ]
+ public_configs = [ ":gtk2_internal_config" ]
+}
+
+# Depend on "gtkprint" to get this.
+pkg_config("gtkprint2_internal_config") {
+ packages = [ "gtk+-unix-print-2.0" ]
+}
+
+group("gtkprint2") {
+ visibility = [ "//chrome/browser/ui/libgtkui:libgtk2ui" ]
+ public_configs = [ ":gtkprint2_internal_config" ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/gtk3/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/linux/gtk3/BUILD.gn
new file mode 100644
index 0000000000..0cfd05f319
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/gtk3/BUILD.gn
@@ -0,0 +1,43 @@
+# Copyright 2015 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")
+
+# Depend on //build/config/linux/gtk3 to use GTKv3. Depend on
+# //build/config/linux/gtk to get GTK 2 or 3 depending on the build flags.
+#
+# 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("gtk3_internal_config") {
+ # Gtk requires gmodule, but it does not list it as a dependency in some
+ # misconfigured systems.
+ packages = [
+ "gmodule-2.0",
+ "gtk+-3.0",
+ "gthread-2.0",
+ ]
+}
+
+# Basically no parts of Chrome should depend on GTK. To prevent accidents, the
+# parts that explicitly need GTK3 are whitelisted on this target.
+group("gtk3") {
+ visibility = [
+ "//build/config/linux/gtk",
+ "//chrome/browser/ui/libgtkui:*",
+ ]
+ public_configs = [ ":gtk3_internal_config" ]
+}
+
+# Depend on "gtkprint3" to get this.
+pkg_config("gtkprint3_internal_config") {
+ packages = [ "gtk+-unix-print-3.0" ]
+}
+
+group("gtkprint3") {
+ visibility = [ "//chrome/browser/ui/libgtkui:libgtk3ui" ]
+ public_configs = [ ":gtkprint3_internal_config" ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/libffi/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/linux/libffi/BUILD.gn
new file mode 100644
index 0000000000..a4041727b1
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/libffi/BUILD.gn
@@ -0,0 +1,9 @@
+# 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")
+
+pkg_config("libffi") {
+ packages = [ "libffi" ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/pangocairo/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/linux/pangocairo/BUILD.gn
new file mode 100644
index 0000000000..d0d506a9a7
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/pangocairo/BUILD.gn
@@ -0,0 +1,16 @@
+# 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")
+
+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/webrtc/build/config/linux/pkg-config.py b/third_party/libwebrtc/webrtc/build/config/linux/pkg-config.py
new file mode 100644
index 0000000000..d63b2d65b9
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/pkg-config.py
@@ -0,0 +1,219 @@
+#!/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.
+
+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(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(["pkg-config", "--variable=prefix"] + args,
+ env=os.environ)
+ 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')
+ (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(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.libdir:
+ cmd = [options.pkg_config, "--variable=libdir"] + args
+ if options.debug:
+ sys.stderr.write('Running: %s\n' % cmd)
+ try:
+ libdir = subprocess.check_output(cmd)
+ except:
+ print "Error from pkg-config."
+ return 1
+ sys.stdout.write(libdir.strip())
+ return 0
+
+ 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)
+ 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 = []
+ ldflags = []
+
+ 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':
+ ldflags.append(flag)
+ 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, ldflags])
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/third_party/libwebrtc/webrtc/build/config/linux/pkg_config.gni b/third_party/libwebrtc/webrtc/build/config/linux/pkg_config.gni
new file mode 100644
index 0000000000..23cec376f0
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/linux/pkg_config.gni
@@ -0,0 +1,117 @@
+# 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.
+if (sysroot != "") {
+ # Pass the sysroot if we're using one (it requires the CPU arch also).
+ pkg_config_args = [
+ "-s",
+ rebase_path(sysroot),
+ "-a",
+ current_cpu,
+ ]
+} else if (pkg_config != "") {
+ pkg_config_args = [
+ "-p",
+ pkg_config,
+ ]
+} else {
+ pkg_config_args = []
+}
+
+# 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")
+ include_dirs = pkgresult[0]
+ cflags = pkgresult[1]
+
+ if (!defined(invoker.ignore_libs) || !invoker.ignore_libs) {
+ libs = pkgresult[2]
+ lib_dirs = pkgresult[3]
+ ldflags = pkgresult[4]
+ }
+
+ forward_variables_from(invoker,
+ [
+ "defines",
+ "visibility",
+ ])
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/locales.gni b/third_party/libwebrtc/webrtc/build/config/locales.gni
new file mode 100644
index 0000000000..2b608b7e7c
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/locales.gni
@@ -0,0 +1,187 @@
+# 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.
+
+# Android doesn't ship all locales in order to save space (but webview does).
+# http://crbug.com/369218
+if (is_android) {
+ android_chrome_omitted_locales = [
+ "bn",
+ "et",
+ "gu",
+ "kn",
+ "ml",
+ "mr",
+ "ms",
+ "ta",
+ "te",
+ ]
+}
+
+# Chrome on iOS only ships with a subset of the locales supported by other
+# version of Chrome as the corresponding locales are not supported by the
+# operating system (but for simplicity, the corresponding .pak files are
+# still generated).
+if (is_ios) {
+ ios_unsupported_locales = [
+ "am",
+ "bn",
+ "et",
+ "fil",
+ "gu",
+ "kn",
+ "lv",
+ "ml",
+ "mr",
+ "sl",
+ "sw",
+ "ta",
+ "te",
+ ]
+}
+
+# Note: keep in sync with below.
+locales = [
+ "am",
+ "ar",
+ "bg",
+ "bn",
+ "ca",
+ "cs",
+ "da",
+ "de",
+ "el",
+ "en-GB",
+ "en-US",
+ "es",
+ "et",
+ "fa",
+ "fi",
+ "fil",
+ "fr",
+ "gu",
+ "he",
+ "hi",
+ "hr",
+ "hu",
+ "id",
+ "it",
+ "ja",
+ "kn",
+ "ko",
+ "lt",
+ "lv",
+ "ml",
+ "mr",
+ "ms",
+ "nb",
+ "nl",
+ "pl",
+ "pt-PT",
+ "ro",
+ "ru",
+ "sk",
+ "sl",
+ "sr",
+ "sv",
+ "sw",
+ "ta",
+ "te",
+ "th",
+ "tr",
+ "uk",
+ "vi",
+ "zh-CN",
+ "zh-TW",
+]
+
+# Chrome on iOS uses different names for "es-419" and "pt-BR" (called
+# respectively "es-MX" and "pt" on iOS).
+if (!is_ios) {
+ locales += [
+ "es-419",
+ "pt-BR",
+ ]
+} else {
+ locales += [
+ "es-MX",
+ "pt",
+ ]
+
+ ios_packed_locales = locales - ios_unsupported_locales
+}
+
+locales_with_fake_bidi = locales + [ "fake-bidi" ]
+
+# Same as the locales list but in the format Mac expects for output files:
+# it uses underscores instead of hyphens, and "en" instead of "en-US".
+locales_as_mac_outputs = [
+ "am",
+ "ar",
+ "bg",
+ "bn",
+ "ca",
+ "cs",
+ "da",
+ "de",
+ "el",
+ "en_GB",
+ "en",
+ "es",
+ "et",
+ "fa",
+ "fi",
+ "fil",
+ "fr",
+ "gu",
+ "he",
+ "hi",
+ "hr",
+ "hu",
+ "id",
+ "it",
+ "ja",
+ "kn",
+ "ko",
+ "lt",
+ "lv",
+ "ml",
+ "mr",
+ "ms",
+ "nb",
+ "nl",
+ "pl",
+ "pt_PT",
+ "ro",
+ "ru",
+ "sk",
+ "sl",
+ "sr",
+ "sv",
+ "sw",
+ "ta",
+ "te",
+ "th",
+ "tr",
+ "uk",
+ "vi",
+ "zh_CN",
+ "zh_TW",
+]
+
+# Chrome on iOS uses different names for "es-419" and "pt-BR" (called
+# respectively "es-MX" and "pt" on iOS).
+if (!is_ios) {
+ locales_as_mac_outputs += [
+ "es_419",
+ "pt_BR",
+ ]
+} else {
+ locales_as_mac_outputs += [
+ "es_MX",
+ "pt",
+ ]
+
+ ios_packed_locales_as_mac_outputs =
+ locales_as_mac_outputs - ios_unsupported_locales
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/mac/BUILD.gn
new file mode 100644
index 0000000000..eb5f45b5f9
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/BUILD.gn
@@ -0,0 +1,104 @@
+# 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")
+import("//build/config/mac/mac_sdk.gni")
+import("//build/config/mac/symbols.gni")
+
+# 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.
+config("compiler") {
+ # These flags are shared between the C compiler and linker.
+ common_mac_flags = []
+
+ # CPU architecture.
+ if (current_cpu == "x64") {
+ common_mac_flags += [
+ "-arch",
+ "x86_64",
+ ]
+ } else if (current_cpu == "x86") {
+ common_mac_flags += [
+ "-arch",
+ "i386",
+ ]
+ }
+
+ # This is here so that all files get recompiled after an Xcode update.
+ # (defines are passed via the command line, and build system rebuild things
+ # when their commandline changes). Nothing should ever read this define.
+ defines = [ "CR_XCODE_VERSION=$xcode_version" ]
+
+ asmflags = common_mac_flags
+ cflags = common_mac_flags
+
+ # Without this, the constructors and destructors of a C++ object inside
+ # an Objective C struct won't be called, which is very bad.
+ cflags_objcc = [ "-fobjc-call-cxx-cdtors" ]
+
+ cflags_c = [ "-std=c99" ]
+ cflags_objc = cflags_c
+
+ ldflags = common_mac_flags
+
+ if (save_unstripped_output) {
+ ldflags += [ "-Wcrl,unstripped," + rebase_path(root_out_dir) ]
+ }
+}
+
+# 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 Mac-only. Please see that target for advice on what should go in
+# :runtime_library vs. :compiler.
+config("runtime_library") {
+ common_flags = [
+ "-isysroot",
+ rebase_path(sysroot, root_build_dir),
+ "-mmacosx-version-min=$mac_deployment_target",
+ ]
+
+ asmflags = common_flags
+ cflags = common_flags
+ ldflags = common_flags
+
+ # Prevent Mac OS X AssertMacros.h (included by system header) from defining
+ # macros that collide with common names, like 'check', 'require', and
+ # 'verify'.
+ # http://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/AssertMacros.h
+ defines = [ "__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0" ]
+}
+
+# On Mac, this is used for everything except static libraries.
+config("mac_dynamic_flags") {
+ ldflags = [ "-Wl,-ObjC" ] # Always load Objective-C categories and classes.
+
+ if (is_component_build) {
+ ldflags += [
+ # Path for loading shared libraries for unbundled binaries.
+ "-Wl,-rpath,@loader_path/.",
+
+ # Path for loading shared libraries for bundled binaries. Get back from
+ # Binary.app/Contents/MacOS.
+ "-Wl,-rpath,@loader_path/../../..",
+ ]
+ }
+}
+
+# On Mac, this is used only for executables.
+config("mac_executable_flags") {
+ # Remove this when targeting >=10.7 since it is the default in that config.
+ ldflags = [ "-Wl,-pie" ] # Position independent.
+}
+
+# The ldflags referenced below are handled by
+# //build/toolchain/mac/linker_driver.py.
+# Remove this config if a target wishes to change the arguments passed to the
+# strip command during linking. This config by default strips all symbols
+# from a binary, but some targets may wish to specify a saves file to preserve
+# specific symbols.
+config("strip_all") {
+ if (enable_stripping) {
+ ldflags = [ "-Wcrl,strip,-x,-S" ]
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/BuildInfo.plist b/third_party/libwebrtc/webrtc/build/config/mac/BuildInfo.plist
new file mode 100644
index 0000000000..b0856e3591
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/BuildInfo.plist
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>BuildMachineOSBuild</key>
+ <string>${BUILD_MACHINE_OS_BUILD}</string>
+ <key>DTCompiler</key>
+ <string>${GCC_VERSION}</string>
+ <key>DTSDKBuild</key>
+ <string>${MAC_SDK_BUILD}</string>
+ <key>DTSDKName</key>
+ <string>${MAC_SDK_NAME}</string>
+ <key>DTXcode</key>
+ <string>${XCODE_VERSION}</string>
+ <key>DTXcodeBuild</key>
+ <string>${XCODE_BUILD}</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${VERSION}</string>
+ <key>CFBundleVersion</key>
+ <string>${VERSION_BUILD}</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.chromium.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>SCM_REVISION</key>
+ <string>${COMMIT_HASH}</string>
+</dict>
+</plist>
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/OWNERS b/third_party/libwebrtc/webrtc/build/config/mac/OWNERS
new file mode 100644
index 0000000000..14747a0025
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/OWNERS
@@ -0,0 +1,4 @@
+rsesek@chromium.org
+sdefresne@chromium.org
+
+# COMPONENT: Build
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/base_rules.gni b/third_party/libwebrtc/webrtc/build/config/mac/base_rules.gni
new file mode 100644
index 0000000000..341c7508a4
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/base_rules.gni
@@ -0,0 +1,253 @@
+# 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.
+
+# This file contains rules that are shared between Mac and iOS.
+
+import("//build/toolchain/toolchain.gni")
+import("//build/config/mac/symbols.gni")
+
+if (is_mac) {
+ import("//build/config/mac/mac_sdk.gni")
+} else if (is_ios) {
+ import("//build/config/ios/ios_sdk.gni")
+}
+
+# Convert plist file to given format.
+#
+# Arguments
+#
+# source:
+# string, path to the plist file to convert
+#
+# output:
+# string, path to the converted plist, must be under $root_build_dir
+#
+# format:
+# string, the format to `plutil -convert` the plist to.
+template("convert_plist") {
+ assert(defined(invoker.source), "source must be defined for $target_name")
+ assert(defined(invoker.output), "output must be defined for $target_name")
+ assert(defined(invoker.format), "format must be defined for $target_name")
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "visibility",
+ "testonly",
+ "deps",
+ ])
+
+ script = "//build/config/mac/xcrun.py"
+ sources = [
+ invoker.source,
+ ]
+ outputs = [
+ invoker.output,
+ ]
+ args = []
+ if (!use_system_xcode) {
+ args += [
+ "--developer_dir",
+ hermetic_xcode_path,
+ ]
+ }
+ args += [
+ "plutil",
+ "-convert",
+ invoker.format,
+ "-o",
+ rebase_path(invoker.output, root_build_dir),
+ rebase_path(invoker.source, root_build_dir),
+ ]
+ }
+}
+
+# Template to merge multiple plist files and perform variable substitutions.
+#
+# Arguments
+#
+# plist_templates:
+# string array, paths to plist files which will be used for the bundle.
+#
+# format:
+# string, the format to `plutil -convert` the plist to when
+# generating the output.
+#
+# substitutions:
+# string array, 'key=value' pairs used to replace ${key} by value
+# when generating the output plist file.
+#
+# output_name:
+# string, name of the generated plist file.
+template("compile_plist") {
+ assert(defined(invoker.plist_templates),
+ "A list of template plist files must be specified for $target_name")
+ assert(defined(invoker.format),
+ "The plist format must be specified for $target_name")
+ assert(defined(invoker.substitutions),
+ "A list of key=value pairs must be specified for $target_name")
+ assert(defined(invoker.output_name),
+ "The name of the output file must be specified for $target_name")
+
+ _output_name = invoker.output_name
+ _merged_name = get_path_info(_output_name, "dir") + "/" +
+ get_path_info(_output_name, "name") + "_merged." +
+ get_path_info(_output_name, "extension")
+
+ _merge_target = target_name + "_merge"
+
+ action(_merge_target) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "testonly",
+ ])
+
+ script = "//build/config/mac/plist_util.py"
+ sources = invoker.plist_templates
+ outputs = [
+ _merged_name,
+ ]
+ args = [
+ "merge",
+ "-f=" + invoker.format,
+ "-o=" + rebase_path(_merged_name, root_build_dir),
+ ] + rebase_path(invoker.plist_templates, root_build_dir)
+ }
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "visibility",
+ ])
+ script = "//build/config/mac/plist_util.py"
+ sources = [
+ _merged_name,
+ ]
+ outputs = [
+ _output_name,
+ ]
+ args = [
+ "substitute",
+ "-f=" + invoker.format,
+ "-o=" + rebase_path(_output_name, root_build_dir),
+ "-t=" + rebase_path(_merged_name, root_build_dir),
+ ]
+ foreach(_substitution, invoker.substitutions) {
+ args += [ "-s=$_substitution" ]
+ }
+ deps = [
+ ":$_merge_target",
+ ]
+ }
+}
+
+# The base template used to generate Info.plist files for iOS and Mac apps and
+# frameworks.
+#
+# Arguments
+#
+# plist_templates:
+# string array, paths to plist files which will be used for the bundle.
+#
+# executable_name:
+# string, name of the generated target used for the product
+# and executable name as specified in the output Info.plist.
+#
+# format:
+# string, the format to `plutil -convert` the plist to when
+# generating the output.
+#
+# extra_substitutions:
+# (optional) string array, 'key=value' pairs for extra fields which are
+# specified in a source Info.plist template.
+#
+# output_name:
+# (optional) string, name of the generated plist file, default to
+# "$target_gen_dir/$target_name.plist".
+template("info_plist") {
+ assert(defined(invoker.executable_name),
+ "The executable_name must be specified for $target_name")
+ executable_name = invoker.executable_name
+
+ compile_plist(target_name) {
+ forward_variables_from(invoker,
+ [
+ "plist_templates",
+ "testonly",
+ "deps",
+ "visibility",
+ "format",
+ ])
+
+ if (defined(invoker.output_name)) {
+ output_name = invoker.output_name
+ } else {
+ output_name = "$target_gen_dir/$target_name.plist"
+ }
+
+ substitutions = [
+ "BUILD_MACHINE_OS_BUILD=$machine_os_build",
+ "EXECUTABLE_NAME=$executable_name",
+ "GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
+ "PRODUCT_NAME=$executable_name",
+ "XCODE_BUILD=$xcode_build",
+ "XCODE_VERSION=$xcode_version",
+ ]
+ if (defined(invoker.extra_substitutions)) {
+ substitutions += invoker.extra_substitutions
+ }
+ }
+}
+
+# Template to compile .xib and .storyboard files.
+#
+# Arguments
+#
+# sources:
+# list of string, sources to compile
+#
+# ibtool_flags:
+# (optional) list of string, additional flags to pass to the ibtool
+template("compile_ib_files") {
+ action_foreach(target_name) {
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "visibility",
+ ])
+ assert(defined(invoker.sources),
+ "sources must be specified for $target_name")
+ assert(defined(invoker.output_extension),
+ "output_extension must be specified for $target_name")
+
+ ibtool_flags = []
+ if (defined(invoker.ibtool_flags)) {
+ ibtool_flags = invoker.ibtool_flags
+ }
+
+ _output_extension = invoker.output_extension
+
+ script = "//build/config/mac/compile_ib_files.py"
+ sources = invoker.sources
+ outputs = [
+ "$target_gen_dir/$target_name/{{source_name_part}}.$_output_extension",
+ ]
+ args = [
+ "--input",
+ "{{source}}",
+ "--output",
+ rebase_path(
+ "$target_gen_dir/$target_name/{{source_name_part}}.$_output_extension"),
+ ]
+ if (!use_system_xcode) {
+ args += [
+ "--developer_dir",
+ hermetic_xcode_path,
+ ]
+ }
+ args += ibtool_flags
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/compile_ib_files.py b/third_party/libwebrtc/webrtc/build/config/mac/compile_ib_files.py
new file mode 100644
index 0000000000..4923d82984
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/compile_ib_files.py
@@ -0,0 +1,57 @@
+# 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 argparse
+import logging
+import os
+import re
+import subprocess
+import sys
+
+
+def main():
+ parser = argparse.ArgumentParser(
+ description='A script to compile xib and storyboard.',
+ fromfile_prefix_chars='@')
+ parser.add_argument('-o', '--output', required=True,
+ help='Path to output bundle.')
+ parser.add_argument('-i', '--input', required=True,
+ help='Path to input xib or storyboard.')
+ parser.add_argument('--developer_dir', required=False,
+ help='Path to Xcode.')
+ args, unknown_args = parser.parse_known_args()
+
+ if args.developer_dir:
+ os.environ['DEVELOPER_DIR'] = args.developer_dir
+
+ ibtool_args = [
+ 'xcrun', 'ibtool',
+ '--errors', '--warnings', '--notices',
+ '--output-format', 'human-readable-text'
+ ]
+ ibtool_args += unknown_args
+ ibtool_args += [
+ '--compile',
+ os.path.abspath(args.output),
+ os.path.abspath(args.input)
+ ]
+
+ ibtool_section_re = re.compile(r'/\*.*\*/')
+ ibtool_re = re.compile(r'.*note:.*is clipping its content')
+ ibtoolout = subprocess.Popen(ibtool_args, stdout=subprocess.PIPE)
+ current_section_header = None
+ for line in ibtoolout.stdout:
+ if ibtool_section_re.match(line):
+ current_section_header = line
+ elif not ibtool_re.match(line):
+ if current_section_header:
+ sys.stdout.write(current_section_header)
+ current_section_header = None
+ sys.stdout.write(line)
+ return ibtoolout.returncode
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/mac_sdk.gni b/third_party/libwebrtc/webrtc/build/config/mac/mac_sdk.gni
new file mode 100644
index 0000000000..2b2501c7a3
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/mac_sdk.gni
@@ -0,0 +1,105 @@
+# 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/chrome_build.gni")
+import("//build/toolchain/toolchain.gni")
+
+# See https://bugs.chromium.org/p/webrtc/issues/detail?id=5453.
+# We can drop the rtc_require_mac_10_7_deployment flag when Chromium
+# also requires a 10.7 deployment target.
+import("//build_overrides/build.gni")
+
+declare_args() {
+ # Minimum supported version of the Mac SDK.
+ mac_sdk_min = mac_sdk_min_build_override
+
+ # Minimum supported version of OSX.
+ mac_deployment_target = "10.9"
+
+ # Path to a specific version of the Mac SDK, not including a slash at the end.
+ # If empty, the path to the lowest version greater than or equal to
+ # mac_sdk_min is used.
+ mac_sdk_path = ""
+
+ # The SDK name as accepted by xcodebuild.
+ mac_sdk_name = "macosx"
+}
+
+# Check that the version of macOS SDK used is the one requested when building
+# a version of Chrome shipped to the users. Disable the check if building for
+# iOS as the version macOS SDK used is not relevant for the tool build for the
+# host (they are not shipped) --- this is required as Chrome on iOS is usually
+# build with the latest version of Xcode that may not ship with the version of
+# the macOS SDK used to build Chrome on mac.
+# TODO(crbug.com/635745): the check for target_os should be replaced by a
+# check that current_toolchain is default_toolchain, and the file should
+# assert that current_os is "mac" once this file is no longer included by
+# iOS toolchains.
+_verify_sdk = is_chrome_branded && is_official_build && target_os != "ios"
+
+find_sdk_args = [ "--print_sdk_path" ]
+if (!use_system_xcode) {
+ find_sdk_args += [
+ "--developer_dir",
+ hermetic_xcode_path,
+ ]
+}
+if (_verify_sdk) {
+ find_sdk_args += [
+ "--verify",
+ mac_sdk_min,
+ "--sdk_path=" + mac_sdk_path,
+ ]
+} else {
+ find_sdk_args += [ mac_sdk_min ]
+}
+
+# The tool will print the SDK path on the first line, and the version on the
+# second line.
+find_sdk_lines =
+ exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines")
+mac_sdk_version = find_sdk_lines[1]
+if (mac_sdk_path == "") {
+ mac_sdk_path = find_sdk_lines[0]
+}
+
+script_name = "//build/config/mac/sdk_info.py"
+sdk_info_args = []
+if (!use_system_xcode) {
+ sdk_info_args += [
+ "--developer_dir",
+ hermetic_xcode_path,
+ ]
+}
+sdk_info_args += [ mac_sdk_name ]
+
+_mac_sdk_result = exec_script(script_name, sdk_info_args, "scope")
+xcode_version = _mac_sdk_result.xcode_version
+xcode_build = _mac_sdk_result.xcode_build
+machine_os_build = _mac_sdk_result.machine_os_build
+
+if (mac_sdk_version != mac_sdk_min_build_override &&
+ exec_script("//build/check_return_value.py",
+ [
+ "test",
+ xcode_version,
+ "-ge",
+ "0730",
+ ],
+ "value") != 1) {
+ print(
+ "********************************************************************************")
+ print(
+ " WARNING: The Mac OS X SDK is incompatible with the version of Xcode. To fix,")
+ print(
+ " either upgrade Xcode to the latest version or install the Mac OS X")
+ print(
+ " $mac_sdk_min_build_override SDK. For more information, see https://crbug.com/620127.")
+ print()
+ print(" Current SDK Version: $mac_sdk_version")
+ print(" Current Xcode Version: $xcode_version ($xcode_build)")
+ print(
+ "********************************************************************************")
+ assert(false, "SDK is incompatible with Xcode")
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/package_framework.py b/third_party/libwebrtc/webrtc/build/config/mac/package_framework.py
new file mode 100644
index 0000000000..f669528fe5
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/package_framework.py
@@ -0,0 +1,60 @@
+# 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 argparse
+import errno
+import os
+import shutil
+import sys
+
+def Main():
+ parser = argparse.ArgumentParser(description='Create Mac Framework symlinks')
+ parser.add_argument('--framework', action='store', type=str, required=True)
+ parser.add_argument('--version', action='store', type=str)
+ parser.add_argument('--contents', action='store', type=str, nargs='+')
+ parser.add_argument('--stamp', action='store', type=str, required=True)
+ args = parser.parse_args()
+
+ VERSIONS = 'Versions'
+ CURRENT = 'Current'
+
+ # Ensure the Foo.framework/Versions/A/ directory exists and create the
+ # Foo.framework/Versions/Current symlink to it.
+ if args.version:
+ try:
+ os.makedirs(os.path.join(args.framework, VERSIONS, args.version), 0744)
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise e
+ _Relink(os.path.join(args.version),
+ os.path.join(args.framework, VERSIONS, CURRENT))
+
+ # Establish the top-level symlinks in the framework bundle. The dest of
+ # the symlinks may not exist yet.
+ if args.contents:
+ for item in args.contents:
+ _Relink(os.path.join(VERSIONS, CURRENT, item),
+ os.path.join(args.framework, item))
+
+ # Write out a stamp file.
+ if args.stamp:
+ with open(args.stamp, 'w') as f:
+ f.write(str(args))
+
+ return 0
+
+
+def _Relink(dest, link):
+ """Creates a symlink to |dest| named |link|. If |link| already exists,
+ it is overwritten."""
+ try:
+ os.remove(link)
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ shutil.rmtree(link)
+ os.symlink(dest, link)
+
+
+if __name__ == '__main__':
+ sys.exit(Main())
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/plist_util.py b/third_party/libwebrtc/webrtc/build/config/mac/plist_util.py
new file mode 100644
index 0000000000..0928fa138d
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/plist_util.py
@@ -0,0 +1,254 @@
+# 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 argparse
+import plistlib
+import os
+import re
+import subprocess
+import sys
+import tempfile
+import shlex
+
+
+# Xcode substitutes variables like ${PRODUCT_NAME} when compiling Info.plist.
+# It also supports supports modifiers like :identifier or :rfc1034identifier.
+# SUBST_RE matches a variable substitution pattern with an optional modifier,
+# while IDENT_RE matches all characters that are not valid in an "identifier"
+# value (used when applying the modifier).
+SUBST_RE = re.compile(r'\$\{(?P<id>[^}]*?)(?P<modifier>:[^}]*)?\}')
+IDENT_RE = re.compile(r'[_/\s]')
+
+
+def InterpolateList(values, substitutions):
+ """Interpolates variable references into |value| using |substitutions|.
+
+ Inputs:
+ values: a list of values
+ substitutions: a mapping of variable names to values
+
+ Returns:
+ A new list of values with all variables references ${VARIABLE} replaced
+ by their value in |substitutions| or None if any of the variable has no
+ subsitution.
+ """
+ result = []
+ for value in values:
+ interpolated = InterpolateValue(value, substitutions)
+ if interpolated is None:
+ return None
+ result.append(interpolated)
+ return result
+
+
+def InterpolateString(value, substitutions):
+ """Interpolates variable references into |value| using |substitutions|.
+
+ Inputs:
+ value: a string
+ substitutions: a mapping of variable names to values
+
+ Returns:
+ A new string with all variables references ${VARIABLES} replaced by their
+ value in |substitutions| or None if any of the variable has no substitution.
+ """
+ result = value
+ for match in reversed(list(SUBST_RE.finditer(value))):
+ variable = match.group('id')
+ if variable not in substitutions:
+ return None
+ # Some values need to be identifier and thus the variables references may
+ # contains :modifier attributes to indicate how they should be converted
+ # to identifiers ("identifier" replaces all invalid characters by '_' and
+ # "rfc1034identifier" replaces them by "-" to make valid URI too).
+ modifier = match.group('modifier')
+ if modifier == ':identifier':
+ interpolated = IDENT_RE.sub('_', substitutions[variable])
+ elif modifier == ':rfc1034identifier':
+ interpolated = IDENT_RE.sub('-', substitutions[variable])
+ else:
+ interpolated = substitutions[variable]
+ result = result[:match.start()] + interpolated + result[match.end():]
+ return result
+
+
+def InterpolateValue(value, substitutions):
+ """Interpolates variable references into |value| using |substitutions|.
+
+ Inputs:
+ value: a value, can be a dictionary, list, string or other
+ substitutions: a mapping of variable names to values
+
+ Returns:
+ A new value with all variables references ${VARIABLES} replaced by their
+ value in |substitutions| or None if any of the variable has no substitution.
+ """
+ if isinstance(value, dict):
+ return Interpolate(value, substitutions)
+ if isinstance(value, list):
+ return InterpolateList(value, substitutions)
+ if isinstance(value, str):
+ return InterpolateString(value, substitutions)
+ return value
+
+
+def Interpolate(plist, substitutions):
+ """Interpolates variable references into |value| using |substitutions|.
+
+ Inputs:
+ plist: a dictionary representing a Property List (.plist) file
+ substitutions: a mapping of variable names to values
+
+ Returns:
+ A new plist with all variables references ${VARIABLES} replaced by their
+ value in |substitutions|. All values that contains references with no
+ substitutions will be removed and the corresponding key will be cleared
+ from the plist (not recursively).
+ """
+ result = {}
+ for key in plist:
+ value = InterpolateValue(plist[key], substitutions)
+ if value is not None:
+ result[key] = value
+ return result
+
+
+def LoadPList(path):
+ """Loads Plist at |path| and returns it as a dictionary."""
+ fd, name = tempfile.mkstemp()
+ try:
+ subprocess.check_call(['plutil', '-convert', 'xml1', '-o', name, path])
+ with os.fdopen(fd, 'r') as f:
+ return plistlib.readPlist(f)
+ finally:
+ os.unlink(name)
+
+
+def SavePList(path, format, data):
+ """Saves |data| as a Plist to |path| in the specified |format|."""
+ fd, name = tempfile.mkstemp()
+ try:
+ with os.fdopen(fd, 'w') as f:
+ plistlib.writePlist(data, f)
+ subprocess.check_call(['plutil', '-convert', format, '-o', path, name])
+ finally:
+ os.unlink(name)
+
+
+def MergePList(plist1, plist2):
+ """Merges |plist1| with |plist2| recursively.
+
+ Creates a new dictionary representing a Property List (.plist) files by
+ merging the two dictionary |plist1| and |plist2| recursively (only for
+ dictionary values). List value will be concatenated.
+
+ Args:
+ plist1: a dictionary representing a Property List (.plist) file
+ plist2: a dictionary representing a Property List (.plist) file
+
+ Returns:
+ A new dictionary representing a Property List (.plist) file by merging
+ |plist1| with |plist2|. If any value is a dictionary, they are merged
+ recursively, otherwise |plist2| value is used. If values are list, they
+ are concatenated.
+ """
+ if not isinstance(plist1, dict) or not isinstance(plist2, dict):
+ if plist2 is not None:
+ return plist2
+ else:
+ return plist1
+ result = {}
+ for key in set(plist1) | set(plist2):
+ if key in plist2:
+ value = plist2[key]
+ else:
+ value = plist1[key]
+ if isinstance(value, dict):
+ value = MergePList(plist1.get(key, None), plist2.get(key, None))
+ if isinstance(value, list):
+ value = plist1.get(key, []) + plist2.get(key, [])
+ result[key] = value
+ return result
+
+
+class Action(object):
+ """Class implementing one action supported by the script."""
+
+ @classmethod
+ def Register(cls, subparsers):
+ parser = subparsers.add_parser(cls.name, help=cls.help)
+ parser.set_defaults(func=cls._Execute)
+ cls._Register(parser)
+
+
+class MergeAction(Action):
+ """Class to merge multiple plist files."""
+
+ name = 'merge'
+ help = 'merge multiple plist files'
+
+ @staticmethod
+ def _Register(parser):
+ parser.add_argument(
+ '-o', '--output', required=True,
+ help='path to the output plist file')
+ parser.add_argument(
+ '-f', '--format', required=True, choices=('xml1', 'binary1', 'json'),
+ help='format of the plist file to generate')
+ parser.add_argument(
+ 'path', nargs="+",
+ help='path to plist files to merge')
+
+ @staticmethod
+ def _Execute(args):
+ data = {}
+ for filename in args.path:
+ data = MergePList(data, LoadPList(filename))
+ SavePList(args.output, args.format, data)
+
+
+class SubstituteAction(Action):
+ """Class implementing the variable substitution in a plist file."""
+
+ name = 'substitute'
+ help = 'perform pattern substitution in a plist file'
+
+ @staticmethod
+ def _Register(parser):
+ parser.add_argument(
+ '-o', '--output', required=True,
+ help='path to the output plist file')
+ parser.add_argument(
+ '-t', '--template', required=True,
+ help='path to the template file')
+ parser.add_argument(
+ '-s', '--substitution', action='append', default=[],
+ help='substitution rule in the format key=value')
+ parser.add_argument(
+ '-f', '--format', required=True, choices=('xml1', 'binary1', 'json'),
+ help='format of the plist file to generate')
+
+ @staticmethod
+ def _Execute(args):
+ substitutions = {}
+ for substitution in args.substitution:
+ key, value = substitution.split('=', 1)
+ substitutions[key] = value
+ data = Interpolate(LoadPList(args.template), substitutions)
+ SavePList(args.output, args.format, data)
+
+
+def Main():
+ parser = argparse.ArgumentParser(description='manipulate plist files')
+ subparsers = parser.add_subparsers()
+
+ for action in [MergeAction, SubstituteAction]:
+ action.Register(subparsers)
+
+ args = parser.parse_args()
+ args.func(args)
+
+
+if __name__ == '__main__':
+ sys.exit(Main())
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/prepare_framework_version.py b/third_party/libwebrtc/webrtc/build/config/mac/prepare_framework_version.py
new file mode 100644
index 0000000000..5e8a53f20a
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/prepare_framework_version.py
@@ -0,0 +1,42 @@
+# 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 os
+import shutil
+import sys
+
+# Ensures that the current version matches the last-produced version, which is
+# stored in the version_file. If it does not, then the framework_root_dir is
+# obliterated.
+# Usage: python prepare_framework_version.py out/obj/version_file \
+# out/Framework.framework \
+# 'A'
+
+def PrepareFrameworkVersion(version_file, framework_root_dir, version):
+ # Test what the current framework version is. Stop if it is up-to-date.
+ try:
+ with open(version_file, 'r') as f:
+ current_version = f.read()
+ if current_version == version:
+ return
+ except IOError:
+ pass
+
+ # The framework version has changed, so clobber the framework.
+ if os.path.exists(framework_root_dir):
+ shutil.rmtree(framework_root_dir)
+
+ # Write out the new framework version file, making sure its containing
+ # directory exists.
+ dirname = os.path.dirname(version_file)
+ if not os.path.isdir(dirname):
+ os.makedirs(dirname, 0700)
+
+ with open(version_file, 'w+') as f:
+ f.write(version)
+
+
+if __name__ == '__main__':
+ PrepareFrameworkVersion(sys.argv[1], sys.argv[2], sys.argv[3])
+ sys.exit(0)
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/rules.gni b/third_party/libwebrtc/webrtc/build/config/mac/rules.gni
new file mode 100644
index 0000000000..dd7b4a5550
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/rules.gni
@@ -0,0 +1,692 @@
+# Copyright 2015 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/mac/base_rules.gni")
+
+# Generates Info.plist files for Mac apps and frameworks.
+#
+# Arguments
+#
+# info_plist:
+# (optional) string, path to the Info.plist file that will be used for
+# the bundle.
+#
+# info_plist_target:
+# (optional) string, if the info_plist is generated from an action,
+# rather than a regular source file, specify the target name in lieu
+# of info_plist. The two arguments are mutually exclusive.
+#
+# executable_name:
+# string, name of the generated target used for the product
+# and executable name as specified in the output Info.plist.
+#
+# extra_substitutions:
+# (optional) string array, 'key=value' pairs for extra fields which are
+# specified in a source Info.plist template.
+template("mac_info_plist") {
+ assert(defined(invoker.info_plist) != defined(invoker.info_plist_target),
+ "Only one of info_plist or info_plist_target may be specified in " +
+ target_name)
+
+ if (defined(invoker.info_plist)) {
+ _info_plist = invoker.info_plist
+ } else {
+ _info_plist_target_output = get_target_outputs(invoker.info_plist_target)
+ _info_plist = _info_plist_target_output[0]
+ }
+
+ info_plist(target_name) {
+ format = "xml1"
+ extra_substitutions = []
+ if (defined(invoker.extra_substitutions)) {
+ extra_substitutions = invoker.extra_substitutions
+ }
+ extra_substitutions += [
+ "MAC_SDK_BUILD=$mac_sdk_version",
+ "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version",
+ ]
+ plist_templates = [
+ "//build/config/mac/BuildInfo.plist",
+ _info_plist,
+ ]
+ if (defined(invoker.info_plist_target)) {
+ deps = [
+ invoker.info_plist_target,
+ ]
+ }
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "executable_name",
+ ])
+ }
+}
+
+# Template to compile and package Mac XIB files as bundle data.
+#
+# Arguments
+#
+# sources:
+# list of string, sources to comiple
+#
+# output_path:
+# (optional) string, the path to use for the outputs list in the
+# bundle_data step. If unspecified, defaults to bundle_resources_dir.
+template("mac_xib_bundle_data") {
+ _target_name = target_name
+ _compile_target_name = _target_name + "_compile_ibtool"
+
+ compile_ib_files(_compile_target_name) {
+ forward_variables_from(invoker, [ "testonly" ])
+ visibility = [ ":$_target_name" ]
+ sources = invoker.sources
+ output_extension = "nib"
+ ibtool_flags = [
+ "--minimum-deployment-target",
+ mac_deployment_target,
+
+ # TODO(rsesek): Enable this once all the bots are on Xcode 7+.
+ # "--target-device",
+ # "mac",
+ ]
+ }
+
+ bundle_data(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "visibility",
+ ])
+
+ public_deps = [
+ ":$_compile_target_name",
+ ]
+ sources = get_target_outputs(":$_compile_target_name")
+
+ _output_path = "{{bundle_resources_dir}}"
+ if (defined(invoker.output_path)) {
+ _output_path = invoker.output_path
+ }
+
+ outputs = [
+ "$_output_path/{{source_file_part}}",
+ ]
+ }
+}
+
+# Template to package a shared library into a Mac framework bundle.
+#
+# By default, the bundle target this template generates does not link the
+# resulting framework into anything that depends on it. If a dependency wants
+# a link-time (as well as build-time) dependency on the framework bundle,
+# depend against "$target_name+link". If only the build-time dependency is
+# required (e.g., for copying into another bundle), then use "$target_name".
+#
+# Arguments
+#
+# info_plist:
+# (optional) string, path to the Info.plist file that will be used for
+# the bundle.
+#
+# info_plist_target:
+# (optional) string, if the info_plist is generated from an action,
+# rather than a regular source file, specify the target name in lieu
+# of info_plist. The two arguments are mutually exclusive.
+#
+# output_name:
+# (optional) string, name of the generated framework without the
+# .framework suffix. If omitted, defaults to target_name.
+#
+# framework_version:
+# (optional) string, version of the framework. Typically this is a
+# single letter, like "A". If omitted, the Versions/ subdirectory
+# structure will not be created, and build output will go directly
+# into the framework subdirectory.
+#
+# framework_contents:
+# (optional) list of string, top-level items in the framework. For
+# frameworks with a framework_version, this is the list of symlinks to
+# create in the .framework directory that link into Versions/Current/.
+#
+# extra_substitutions:
+# (optional) string array, 'key=value' pairs for extra fields which are
+# specified in a source Info.plist template.
+#
+# This template provides two targets for the resulting framework bundle. The
+# link-time behavior varies depending on which of the two targets below is
+# added as a dependency:
+# - $target_name only adds a build-time dependency. Targets that depend on
+# it will not link against the framework.
+# - $target_name+link adds a build-time and link-time dependency. Targets
+# that depend on it will link against the framework.
+#
+# The build-time-only dependency is used for when a target needs to use the
+# framework either only for resources, or because the target loads it at run-
+# time, via dlopen() or NSBundle. The link-time dependency will cause the
+# dependee to have the framework loaded by dyld at launch.
+#
+# Example of build-time only dependency:
+#
+# mac_framework_bundle("CoreTeleportation") {
+# sources = [ ... ]
+# }
+#
+# bundle_data("core_teleportation_bundle_data") {
+# deps = [ ":CoreTeleportation" ]
+# sources = [ "$root_out_dir/CoreTeleportation.framework" ]
+# outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ]
+# }
+#
+# app_bundle("GoatTeleporter") {
+# sources = [ ... ]
+# deps = [
+# ":core_teleportation_bundle_data",
+# ]
+# }
+#
+# The GoatTeleporter.app will not directly link against
+# CoreTeleportation.framework, but it will be included in the bundle's
+# Frameworks directory.
+#
+# Example of link-time dependency:
+#
+# mac_framework_bundle("CoreTeleportation") {
+# sources = [ ... ]
+# ldflags = [
+# "-install_name",
+# "@executable_path/../Frameworks/$target_name.framework"
+# ]
+# }
+#
+# bundle_data("core_teleportation_bundle_data") {
+# deps = [ ":CoreTeleportation+link" ]
+# sources = [ "$root_out_dir/CoreTeleportation.framework" ]
+# outputs = [ "{{bundle_root_dir}}/Frameworks/{{source_file_part}}" ]
+# }
+#
+# app_bundle("GoatTeleporter") {
+# sources = [ ... ]
+# deps = [
+# ":core_teleportation_bundle_data",
+# ]
+# }
+#
+# Note that the framework is still copied to the app's bundle, but dyld will
+# load this library when the app is launched because it uses the "+link"
+# target as a dependency. This also requires that the framework set its
+# install_name so that dyld can locate it.
+#
+# See "gn help shared_library" for more information on arguments supported
+# by shared library target.
+template("mac_framework_bundle") {
+ assert(defined(invoker.deps),
+ "Dependencies must be specified for $target_name")
+ assert(!defined(invoker.framework_contents) ||
+ defined(invoker.framework_version),
+ "framework_contents requres a versioned framework")
+
+ _info_plist_target = target_name + "_info_plist"
+
+ mac_info_plist(_info_plist_target) {
+ executable_name = target_name
+ if (defined(invoker.output_name)) {
+ executable_name = invoker.output_name
+ }
+ forward_variables_from(invoker,
+ [
+ "extra_substitutions",
+ "info_plist",
+ "info_plist_target",
+ "testonly",
+ ])
+ }
+
+ _info_plist_bundle_data = _info_plist_target + "_bundle_data"
+
+ bundle_data(_info_plist_bundle_data) {
+ forward_variables_from(invoker, [ "testonly" ])
+ sources = get_target_outputs(":$_info_plist_target")
+ outputs = [
+ "{{bundle_resources_dir}}/Info.plist",
+ ]
+ public_deps = [
+ ":$_info_plist_target",
+ ]
+ }
+
+ _target_name = target_name
+ _output_name = target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ # Create a file to track the build dependency on the framework_version and
+ # framework_contents variables.
+ _framework_toc = []
+ if (defined(invoker.framework_version)) {
+ _framework_toc += [
+ "Version=" + invoker.framework_version,
+ _output_name,
+ ]
+ _framework_contents = [ _output_name ]
+ }
+ if (defined(invoker.framework_contents)) {
+ _framework_toc += invoker.framework_contents
+ _framework_contents += invoker.framework_contents
+ }
+ _framework_toc_file = "$target_out_dir/${target_name}.toc"
+ write_file(_framework_toc_file, _framework_toc)
+
+ # Create local variables for referencing different parts of the bundle.
+ _framework_target = _target_name
+ _framework_name = _output_name + ".framework"
+ _framework_base_dir = "$root_out_dir/$_framework_name"
+ if (defined(invoker.framework_version) && invoker.framework_version != "") {
+ _framework_version = invoker.framework_version
+ _framework_root_dir = _framework_base_dir + "/Versions/$_framework_version"
+ } else {
+ _framework_root_dir = _framework_base_dir
+ }
+
+ # Clean the entire framework if the framework_version changes.
+ _version_arg = "''"
+ if (defined(invoker.framework_version)) {
+ _version_arg = _framework_version
+ }
+ _version_file = "$target_out_dir/${target_name}_version"
+ exec_script("//build/config/mac/prepare_framework_version.py",
+ [
+ rebase_path(_version_file),
+ rebase_path(_framework_base_dir),
+ _version_arg,
+ ])
+
+ # Create the symlinks.
+ _framework_package_target = target_name + "_package"
+ action(_framework_package_target) {
+ script = "//build/config/mac/package_framework.py"
+
+ # The TOC file never needs to be read, since its contents are the values
+ # of GN variables. It is only used to trigger this rule when the values
+ # change.
+ inputs = [
+ _framework_toc_file,
+ ]
+
+ _stamp_file = "$target_out_dir/run_${_framework_package_target}.stamp"
+ outputs = [
+ _stamp_file,
+ ]
+
+ visibility = [ ":$_framework_target" ]
+
+ args = [
+ "--framework",
+ rebase_path(_framework_base_dir, root_build_dir),
+ "--stamp",
+ rebase_path(_stamp_file, root_build_dir),
+ ]
+
+ if (defined(invoker.framework_version)) {
+ args += [
+ "--version",
+ invoker.framework_version,
+ "--contents",
+ ] + _framework_contents
+ # It is not possible to list _framework_contents as outputs, since
+ # ninja does not properly stat symbolic links.
+ # https://github.com/ninja-build/ninja/issues/1186
+ }
+ }
+
+ _link_shared_library_target = target_name + "_shared_library"
+ _shared_library_bundle_data = target_name + "_shared_library_bundle_data"
+
+ shared_library(_link_shared_library_target) {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "assert_no_deps",
+ "bundle_deps",
+ "code_signing_enabled",
+ "data_deps",
+ "info_plist",
+ "info_plist_target",
+ "output_name",
+ "visibility",
+ ])
+ visibility = [ ":$_shared_library_bundle_data" ]
+ output_name = _output_name
+ output_prefix_override = true
+ output_extension = ""
+ output_dir = "$target_out_dir/$_link_shared_library_target"
+ }
+
+ bundle_data(_shared_library_bundle_data) {
+ visibility = [ ":$_framework_target" ]
+ forward_variables_from(invoker, [ "testonly" ])
+ sources = [
+ "$target_out_dir/$_link_shared_library_target/$_output_name",
+ ]
+ outputs = [
+ "{{bundle_executable_dir}}/$_output_name",
+ ]
+ public_deps = [
+ ":$_link_shared_library_target",
+ ]
+ }
+
+ _framework_public_config = _target_name + "_public_config"
+ config(_framework_public_config) {
+ # TODO(sdefresne): should we have a framework_dirs similar to lib_dirs
+ # and include_dirs to avoid duplicate values on the command-line.
+ visibility = [ ":$_framework_target" ]
+ ldflags = [
+ "-F",
+ rebase_path("$root_out_dir/.", root_build_dir),
+ ]
+ lib_dirs = [ root_out_dir ]
+ libs = [ _framework_name ]
+ }
+
+ create_bundle(_framework_target) {
+ forward_variables_from(invoker,
+ [
+ "data_deps",
+ "deps",
+ "public_deps",
+ "testonly",
+ ])
+
+ if (defined(invoker.visibility)) {
+ visibility = invoker.visibility
+ visibility += [ ":$_target_name+link" ]
+ }
+
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_info_plist_bundle_data" ]
+
+ if (defined(invoker.bundle_deps)) {
+ deps += invoker.bundle_deps
+ }
+
+ if (!defined(public_deps)) {
+ public_deps = []
+ }
+ public_deps += [
+ ":$_framework_package_target",
+ ":$_shared_library_bundle_data",
+ ]
+
+ bundle_root_dir = _framework_root_dir
+ bundle_resources_dir = "$bundle_root_dir/Resources"
+ bundle_executable_dir = "$bundle_root_dir"
+ }
+
+ group(_target_name + "+link") {
+ forward_variables_from(invoker,
+ [
+ "public_configs",
+ "testonly",
+ "visibility",
+ ])
+ public_deps = [
+ ":$_target_name",
+ ]
+ if (!defined(public_configs)) {
+ public_configs = []
+ }
+ public_configs += [ ":$_framework_public_config" ]
+ }
+}
+
+set_defaults("mac_framework_bundle") {
+ configs = default_shared_library_configs
+}
+
+# Template to create a Mac executable application bundle.
+#
+# Arguments
+#
+# package_type:
+# (optional) string, the product package type to create. Options are:
+# "app" to create a .app bundle (default)
+# "xpc" to create an .xpc service bundle
+#
+# info_plist:
+# (optional) string, path to the Info.plist file that will be used for
+# the bundle.
+#
+# info_plist_target:
+# (optional) string, if the info_plist is generated from an action,
+# rather than a regular source file, specify the target name in lieu
+# of info_plist. The two arguments are mutually exclusive.
+#
+# output_name:
+# (optional) string, name of the generated app without the
+# .app suffix. If omitted, defaults to target_name.
+#
+# extra_configs:
+# (optional) list of label, additional configs to apply to the
+# executable target.
+#
+# remove_configs:
+# (optional) list of label, default configs to remove from the target.
+#
+# extra_substitutions:
+# (optional) string array, 'key=value' pairs for extra fields which are
+# specified in a source Info.plist template.
+template("mac_app_bundle") {
+ _target_name = target_name
+ _output_name = target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ _package_type = "app"
+ if (defined(invoker.package_type)) {
+ _package_type = invoker.package_type
+ }
+
+ if (_package_type == "app") {
+ _output_extension = "app"
+ _product_type = "com.apple.product-type.application"
+ _write_pkg_info = true
+ } else if (_package_type == "xpc") {
+ _output_extension = "xpc"
+ _product_type = "com.apple.product-type.xpc-service"
+ _write_pkg_info = false
+ } else {
+ assert(false, "Unsupported packge_type: " + packge_type)
+ }
+
+ _executable_target = target_name + "_executable"
+ _executable_bundle_data = _executable_target + "_bundle_data"
+
+ _info_plist_target = target_name + "_info_plist"
+
+ mac_info_plist(_info_plist_target) {
+ executable_name = _output_name
+ forward_variables_from(invoker,
+ [
+ "extra_substitutions",
+ "info_plist",
+ "info_plist_target",
+ "testonly",
+ ])
+ }
+
+ if (_write_pkg_info) {
+ _pkg_info_target = target_name + "_pkg_info"
+
+ action(_pkg_info_target) {
+ forward_variables_from(invoker, [ "testonly" ])
+ script = "//build/config/mac/write_pkg_info.py"
+ sources = get_target_outputs(":$_info_plist_target")
+ outputs = [
+ "$target_gen_dir/$_pkg_info_target",
+ ]
+ args = [ "--plist" ] + rebase_path(sources, root_build_dir) +
+ [ "--output" ] + rebase_path(outputs, root_build_dir)
+ deps = [
+ ":$_info_plist_target",
+ ]
+ }
+ }
+
+ executable(_executable_target) {
+ visibility = [ ":$_executable_bundle_data" ]
+ forward_variables_from(invoker,
+ "*",
+ [
+ "assert_no_deps",
+ "data_deps",
+ "info_plist",
+ "output_name",
+ "visibility",
+ ])
+ if (defined(extra_configs)) {
+ configs += extra_configs
+ }
+ if (defined(remove_configs)) {
+ configs -= remove_configs
+ }
+ output_name = _output_name
+ output_dir = "$target_out_dir/$_executable_target"
+ }
+
+ bundle_data(_executable_bundle_data) {
+ visibility = [ ":$_target_name" ]
+ forward_variables_from(invoker, [ "testonly" ])
+ sources = [
+ "$target_out_dir/$_executable_target/$_output_name",
+ ]
+ outputs = [
+ "{{bundle_executable_dir}}/$_output_name",
+ ]
+ public_deps = [
+ ":$_executable_target",
+ ]
+ }
+
+ _info_plist_bundle_data = _info_plist_target + "_bundle_data"
+
+ bundle_data(_info_plist_bundle_data) {
+ forward_variables_from(invoker, [ "testonly" ])
+ visibility = [ ":$_target_name" ]
+ sources = get_target_outputs(":$_info_plist_target")
+ outputs = [
+ "{{bundle_root_dir}}/Info.plist",
+ ]
+ public_deps = [
+ ":$_info_plist_target",
+ ]
+ }
+
+ if (_write_pkg_info) {
+ _pkg_info_bundle_data = _pkg_info_target + "_bundle_data"
+
+ bundle_data(_pkg_info_bundle_data) {
+ forward_variables_from(invoker, [ "testonly" ])
+ visibility = [ ":$_target_name" ]
+ sources = get_target_outputs(":$_pkg_info_target")
+ outputs = [
+ "{{bundle_root_dir}}/PkgInfo",
+ ]
+ public_deps = [
+ ":$_pkg_info_target",
+ ]
+ }
+ }
+
+ create_bundle(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "data_deps",
+ "deps",
+ "public_deps",
+ "testonly",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [
+ ":$_executable_bundle_data",
+ ":$_info_plist_bundle_data",
+ ]
+ if (_write_pkg_info) {
+ deps += [ ":$_pkg_info_bundle_data" ]
+ }
+ product_type = _product_type
+ bundle_root_dir =
+ "$root_out_dir/${_output_name}.${_output_extension}/Contents"
+ bundle_resources_dir = "$bundle_root_dir/Resources"
+ bundle_executable_dir = "$bundle_root_dir/MacOS"
+ }
+}
+
+# Template to package a loadable_module into a .plugin bundle.
+#
+# This takes no extra arguments that differ from a loadable_module.
+template("mac_plugin_bundle") {
+ assert(defined(invoker.deps),
+ "Dependencies must be specified for $target_name")
+
+ _target_name = target_name
+ _loadable_module_target = _target_name + "_loadable_module"
+ _loadable_module_bundle_data = _loadable_module_target + "_bundle_data"
+
+ _output_name = _target_name
+ if (defined(invoker.output_name)) {
+ _output_name = invoker.output_name
+ }
+
+ loadable_module(_loadable_module_target) {
+ visibility = [ ":$_loadable_module_bundle_data" ]
+ forward_variables_from(invoker,
+ "*",
+ [
+ "assert_no_deps",
+ "data_deps",
+ "output_name",
+ "visibility",
+ ])
+ output_dir = "$target_out_dir"
+ output_name = _output_name
+ }
+
+ bundle_data(_loadable_module_bundle_data) {
+ forward_variables_from(invoker, [ "testonly" ])
+ visibility = [ ":$_target_name" ]
+ sources = [
+ "$target_out_dir/${_output_name}.so",
+ ]
+ outputs = [
+ "{{bundle_executable_dir}}/$_output_name",
+ ]
+ public_deps = [
+ ":$_loadable_module_target",
+ ]
+ }
+
+ create_bundle(_target_name) {
+ forward_variables_from(invoker,
+ [
+ "data_deps",
+ "deps",
+ "public_deps",
+ "testonly",
+ "visibility",
+ ])
+ if (!defined(deps)) {
+ deps = []
+ }
+ deps += [ ":$_loadable_module_bundle_data" ]
+
+ bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents"
+ bundle_executable_dir = "$bundle_root_dir/MacOS"
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/sdk_info.py b/third_party/libwebrtc/webrtc/build/config/mac/sdk_info.py
new file mode 100644
index 0000000000..e63ac0bd19
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/sdk_info.py
@@ -0,0 +1,73 @@
+# 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 argparse
+import os
+import subprocess
+import sys
+
+# This script prints information about the build system, the operating
+# system and the iOS or Mac SDK (depending on the platform "iphonesimulator",
+# "iphoneos" or "macosx" generally).
+#
+# In the GYP build, this is done inside GYP itself based on the SDKROOT
+# variable.
+
+def FormatVersion(version):
+ """Converts Xcode version to a format required for Info.plist."""
+ version = version.replace('.', '')
+ version = version + '0' * (3 - len(version))
+ return version.zfill(4)
+
+
+def FillXcodeVersion(settings):
+ """Fills the Xcode version and build number into |settings|."""
+ lines = subprocess.check_output(['xcodebuild', '-version']).splitlines()
+ settings['xcode_version'] = FormatVersion(lines[0].split()[-1])
+ settings['xcode_build'] = lines[-1].split()[-1]
+
+
+def FillMachineOSBuild(settings):
+ """Fills OS build number into |settings|."""
+ settings['machine_os_build'] = subprocess.check_output(
+ ['sw_vers', '-buildVersion']).strip()
+
+
+def FillSDKPathAndVersion(settings, platform, xcode_version):
+ """Fills the SDK path and version for |platform| into |settings|."""
+ settings['sdk_path'] = subprocess.check_output([
+ 'xcrun', '-sdk', platform, '--show-sdk-path']).strip()
+ settings['sdk_version'] = subprocess.check_output([
+ 'xcrun', '-sdk', platform, '--show-sdk-version']).strip()
+ settings['sdk_platform_path'] = subprocess.check_output([
+ 'xcrun', '-sdk', platform, '--show-sdk-platform-path']).strip()
+ # TODO: unconditionally use --show-sdk-build-version once Xcode 7.2 or
+ # higher is required to build Chrome for iOS or OS X.
+ if xcode_version >= '0720':
+ settings['sdk_build'] = subprocess.check_output([
+ 'xcrun', '-sdk', platform, '--show-sdk-build-version']).strip()
+ else:
+ settings['sdk_build'] = settings['sdk_version']
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser()
+ parser.add_argument("--developer_dir", required=False)
+ args, unknownargs = parser.parse_known_args()
+ if args.developer_dir:
+ os.environ['DEVELOPER_DIR'] = args.developer_dir
+
+ if len(unknownargs) != 1:
+ sys.stderr.write(
+ 'usage: %s [iphoneos|iphonesimulator|macosx]\n' %
+ os.path.basename(sys.argv[0]))
+ sys.exit(1)
+
+ settings = {}
+ FillMachineOSBuild(settings)
+ FillXcodeVersion(settings)
+ FillSDKPathAndVersion(settings, unknownargs[0], settings['xcode_version'])
+
+ for key in sorted(settings):
+ print '%s="%s"' % (key, settings[key])
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/symbols.gni b/third_party/libwebrtc/webrtc/build/config/mac/symbols.gni
new file mode 100644
index 0000000000..6166b123d1
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/symbols.gni
@@ -0,0 +1,30 @@
+# 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/chrome_build.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+
+# This file declares arguments and configs that control whether dSYM debug
+# info is produced and whether build products are stripped.
+
+declare_args() {
+ # Produce dSYM files for targets that are configured to do so. dSYM
+ # generation is controlled globally as it is a linker output (produced via
+ # the //build/toolchain/mac/linker_driver.py. Enabling this will result in
+ # all shared library, loadable module, and executable targets having a dSYM
+ # generated.
+ enable_dsyms = is_official_build || using_sanitizer
+
+ # Strip symbols from linked targets by default. If this is enabled, the
+ # //build/config/mac:strip_all config will be applied to all linked targets.
+ # If custom stripping parameters are required, remove that config from a
+ # linked target and apply custom -Wcrl,strip flags. See
+ # //build/toolchain/mac/linker_driver.py for more information.
+ enable_stripping = is_official_build
+}
+
+# Save unstripped copies of targets with a ".unstripped" suffix. This is
+# useful to preserve the original output when enable_stripping=true but
+# we're not actually generating real dSYMs.
+save_unstripped_output = enable_stripping && !enable_dsyms
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/write_pkg_info.py b/third_party/libwebrtc/webrtc/build/config/mac/write_pkg_info.py
new file mode 100644
index 0000000000..3e2c3c930e
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/write_pkg_info.py
@@ -0,0 +1,47 @@
+# 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 argparse
+import os
+import plist_util
+import sys
+
+# This script creates a PkgInfo file for an OS X .app bundle's plist.
+# Usage: python write_pkg_info.py --plist Foo.app/Contents/Info.plist \
+# --output Foo.app/Contents/PkgInfo
+
+def Main():
+ parser = argparse.ArgumentParser(
+ description='A script to write PkgInfo files for .app bundles.')
+ parser.add_argument('--plist', required=True,
+ help='Path to the Info.plist for the .app.')
+ parser.add_argument('--output', required=True,
+ help='Path to the desired output file.')
+ args = parser.parse_args()
+
+ # Remove the output if it exists already.
+ if os.path.exists(args.output):
+ os.unlink(args.output)
+
+ plist = plist_util.LoadPList(args.plist)
+ package_type = plist['CFBundlePackageType']
+ if package_type != 'APPL':
+ raise ValueError('Expected CFBundlePackageType to be %s, got %s' % \
+ ('AAPL', package_type))
+
+ # The format of PkgInfo is eight characters, representing the bundle type
+ # and bundle signature, each four characters. If that is missing, four
+ # '?' characters are used instead.
+ signature_code = plist.get('CFBundleSignature', '????')
+ if len(signature_code) != 4:
+ raise ValueError('CFBundleSignature should be exactly four characters, ' +
+ 'got %s' % signature_code)
+
+ with open(args.output, 'w') as fp:
+ fp.write('%s%s' % (package_type, signature_code))
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(Main())
diff --git a/third_party/libwebrtc/webrtc/build/config/mac/xcrun.py b/third_party/libwebrtc/webrtc/build/config/mac/xcrun.py
new file mode 100644
index 0000000000..1f8dc203b6
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mac/xcrun.py
@@ -0,0 +1,28 @@
+# 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 argparse
+import os
+import subprocess
+import sys
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(
+ description='A script to execute a command via xcrun.')
+ parser.add_argument('--stamp', action='store', type=str,
+ help='Write a stamp file to this path on success.')
+ parser.add_argument('--developer_dir', required=False,
+ help='Path to Xcode.')
+ args, unknown_args = parser.parse_known_args()
+
+ if args.developer_dir:
+ os.environ['DEVELOPER_DIR'] = args.developer_dir
+
+ rv = subprocess.check_call(['xcrun'] + unknown_args)
+ if rv == 0 and args.stamp:
+ if os.path.exists(args.stamp):
+ os.unlink(args.stamp)
+ open(args.stamp, 'w+').close()
+
+ sys.exit(rv)
diff --git a/third_party/libwebrtc/webrtc/build/config/mips.gni b/third_party/libwebrtc/webrtc/build/config/mips.gni
new file mode 100644
index 0000000000..5604ca66f2
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/mips.gni
@@ -0,0 +1,58 @@
+# Copyright 2015 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/v8_target_cpu.gni")
+
+# These are primarily relevant in current_cpu == "mips*" contexts, where
+# MIPS code is being compiled. But they can also be relevant in the
+# other contexts when the code will change its behavior based on the
+# cpu it wants to generate code for.
+if (current_cpu == "mipsel" || v8_current_cpu == "mipsel") {
+ declare_args() {
+ # MIPS arch variant. Possible values are:
+ # "r1"
+ # "r2"
+ # "r6"
+ mips_arch_variant = "r1"
+
+ # MIPS DSP ASE revision. Possible values are:
+ # 0: unavailable
+ # 1: revision 1
+ # 2: revision 2
+ mips_dsp_rev = 0
+
+ # MIPS SIMD Arch compilation flag.
+ mips_use_msa = false
+
+ # MIPS floating-point ABI. Possible values are:
+ # "hard": sets the GCC -mhard-float option.
+ # "soft": sets the GCC -msoft-float option.
+ mips_float_abi = "hard"
+
+ # MIPS32 floating-point register width. Possible values are:
+ # "fp32": sets the GCC -mfp32 option.
+ # "fp64": sets the GCC -mfp64 option.
+ # "fpxx": sets the GCC -mfpxx option.
+ mips_fpu_mode = "fp32"
+ }
+} else if (current_cpu == "mips64el" || v8_current_cpu == "mips64el") {
+ # MIPS arch variant. Possible values are:
+ # "r2"
+ # "r6"
+ if (current_os == "android" || target_os == "android") {
+ declare_args() {
+ mips_arch_variant = "r6"
+
+ # MIPS SIMD Arch compilation flag.
+ mips_use_msa = true
+ }
+ } else {
+ declare_args() {
+ mips_arch_variant = "r2"
+
+ # MIPS SIMD Arch compilation flag.
+ mips_use_msa = false
+ }
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/nacl/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/nacl/BUILD.gn
new file mode 100644
index 0000000000..d7b22ecf2c
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/nacl/BUILD.gn
@@ -0,0 +1,143 @@
+# Copyright (c) 2014 The Native Client 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/nacl/config.gni")
+
+# Native Client Definitions
+config("nacl_defines") {
+ if (is_linux || is_android || is_nacl) {
+ defines = [
+ "_POSIX_C_SOURCE=199506",
+ "_XOPEN_SOURCE=600",
+ "_GNU_SOURCE=1",
+ "__STDC_LIMIT_MACROS=1",
+ ]
+ } else if (is_win) {
+ defines = [ "__STDC_LIMIT_MACROS=1" ]
+ }
+
+ if (current_cpu == "pnacl" && !is_nacl_nonsfi) {
+ # TODO: Remove the following definition once NACL_BUILD_ARCH and
+ # NACL_BUILD_SUBARCH are defined by the PNaCl toolchain.
+ defines += [ "NACL_BUILD_ARCH=pnacl" ]
+ }
+}
+
+config("nexe_defines") {
+ defines = [
+ "DYNAMIC_ANNOTATIONS_ENABLED=1",
+ "DYNAMIC_ANNOTATIONS_PREFIX=NACL_",
+ ]
+}
+
+config("nacl_warnings") {
+ if (is_win) {
+ # Some NaCl code uses forward declarations of static const variables,
+ # with initialized definitions later on. (The alternative would be
+ # many, many more forward declarations of everything used in that
+ # const variable's initializer before the definition.) The Windows
+ # compiler is too stupid to notice that there is an initializer later
+ # in the file, and warns about the forward declaration.
+ cflags = [ "/wd4132" ]
+ }
+}
+
+# The base target that all targets in the NaCl build should depend on.
+# This allows configs to be modified for everything in the NaCl build, even when
+# the NaCl build is composed into the Chrome build. (GN has no functionality to
+# add flags to everything in //native_client, having a base target works around
+# that limitation.)
+source_set("nacl_base") {
+ public_configs = [
+ ":nacl_defines",
+ ":nacl_warnings",
+ ]
+ if (current_os == "nacl") {
+ public_configs += [ ":nexe_defines" ]
+ }
+}
+
+config("compiler") {
+ configs = []
+ cflags = []
+ ldflags = []
+ libs = []
+
+ if (is_clang && current_cpu != "pnacl") {
+ # -no-integrated-as is the default in nacl-clang for historical
+ # compatibility with inline assembly code and so forth. But there
+ # are no such cases in Chromium code, and -integrated-as is nicer in
+ # general. Moreover, the IRT must be built using LLVM's assembler
+ # on x86-64 to preserve sandbox base address hiding. Use it
+ # everywhere for consistency (and possibly quicker builds).
+ cflags += [ "-integrated-as" ]
+ }
+ if (is_nacl_nonsfi) {
+ cflags += [ "--pnacl-allow-translate" ]
+ ldflags += [
+ "--pnacl-allow-translate",
+ "--pnacl-allow-native",
+ "-Wl,--noirt",
+ "-Wt,--noirt",
+ "-Wt,--noirtshim",
+
+ # The clang driver automatically injects -lpthread when using libc++, but
+ # the toolchain doesn't have it yet. To get around this, use
+ # -nodefaultlibs and make each executable target depend on
+ # "//native_client/src/nonsfi/irt:nacl_sys_private".
+ "-nodefaultlibs",
+ ]
+ libs += [
+ "c++",
+ "m",
+ "c",
+ "pnaclmm",
+ ]
+ include_dirs = [ "//native_client/src/public/linux_syscalls" ]
+ }
+
+ asmflags = cflags
+}
+
+config("compiler_codegen") {
+ cflags = []
+
+ if (is_nacl_irt) {
+ cflags += [
+ # A debugger should be able to unwind IRT call frames. This is
+ # the default behavior on x86-64 and when compiling C++ with
+ # exceptions enabled; the change is for the benefit of x86-32 C.
+ # The frame pointer is unnecessary when unwind tables are used.
+ "-fasynchronous-unwind-tables",
+ "-fomit-frame-pointer",
+ ]
+
+ if (current_cpu == "x86") {
+ # The x86-32 IRT needs to be callable with an under-aligned
+ # stack; so we disable SSE instructions, which can fault on
+ # misaligned addresses. See
+ # https://code.google.com/p/nativeclient/issues/detail?id=3935
+ cflags += [
+ "-mstackrealign",
+ "-mno-sse",
+ ]
+ }
+ }
+
+ asmflags = cflags
+}
+
+config("irt_optimize") {
+ cflags = [
+ # Optimize for space, keep the IRT nexe small.
+ "-Os",
+
+ # These are omitted from non-IRT libraries to keep the libraries
+ # themselves small.
+ "-ffunction-sections",
+ "-fdata-sections",
+ ]
+
+ ldflags = [ "-Wl,--gc-sections" ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/nacl/config.gni b/third_party/libwebrtc/webrtc/build/config/nacl/config.gni
new file mode 100644
index 0000000000..ad8936ed98
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/nacl/config.gni
@@ -0,0 +1,52 @@
+# Copyright 2015 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")
+
+declare_args() {
+ # Native Client supports both Newlib and Glibc C libraries where Newlib
+ # is assumed to be the default one; use this to determine whether Glibc
+ # is being used instead.
+ is_nacl_glibc = false
+}
+
+is_nacl_irt = false
+is_nacl_nonsfi = false
+
+if (enable_nacl) {
+ nacl_toolchain_dir = "//native_client/toolchain/${host_os}_x86"
+
+ if (is_nacl_glibc) {
+ if (current_cpu == "x86" || current_cpu == "x64") {
+ nacl_toolchain_package = "nacl_x86_glibc"
+ } else if (current_cpu == "arm") {
+ nacl_toolchain_package = "nacl_arm_glibc"
+ }
+ } else {
+ nacl_toolchain_package = "pnacl_newlib"
+ }
+
+ if (current_cpu == "pnacl") {
+ _nacl_tuple = "pnacl"
+ } else if (current_cpu == "x86" || current_cpu == "x64") {
+ _nacl_tuple = "x86_64-nacl"
+ } else if (current_cpu == "arm") {
+ _nacl_tuple = "arm-nacl"
+ } else if (current_cpu == "mipsel") {
+ _nacl_tuple = "mipsel-nacl"
+ }
+
+ nacl_toolchain_bindir = "${nacl_toolchain_dir}/${nacl_toolchain_package}/bin"
+ nacl_toolchain_tooldir =
+ "${nacl_toolchain_dir}/${nacl_toolchain_package}/${_nacl_tuple}"
+ nacl_toolprefix = "${nacl_toolchain_bindir}/${_nacl_tuple}-"
+
+ nacl_irt_toolchain = "//build/toolchain/nacl:irt_" + target_cpu
+ is_nacl_irt = current_toolchain == nacl_irt_toolchain
+
+ # Non-SFI mode is a lightweight sandbox used by Chrome OS for running ARC
+ # applications.
+ nacl_nonsfi_toolchain = "//build/toolchain/nacl:newlib_pnacl_nonsfi"
+ is_nacl_nonsfi = current_toolchain == nacl_nonsfi_toolchain
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/nacl/rules.gni b/third_party/libwebrtc/webrtc/build/config/nacl/rules.gni
new file mode 100644
index 0000000000..c8956b4e6d
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/nacl/rules.gni
@@ -0,0 +1,185 @@
+# Copyright 2015 The Native Client 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/nacl/config.gni")
+
+# Generate a nmf file
+#
+# Native Client Manifest (nmf) is a JSON file that tells the browser where to
+# download and load Native Client application files and libraries.
+#
+# Variables:
+# executables: .nexe/.pexe/.bc executables to generate nmf for
+# lib_prefix: path to prepend to shared libraries in the nmf
+# nmf: the name and the path of the output file
+# nmfflags: additional flags for the nmf generator
+# stage_dependencies: directory for staging libraries
+template("generate_nmf") {
+ assert(defined(invoker.executables), "Must define executables")
+ assert(defined(invoker.nmf), "Must define nmf")
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "data_deps",
+ "executables",
+ "lib_prefix",
+ "nmf",
+ "nmfflags",
+ "public_deps",
+ "stage_dependencies",
+ "testonly",
+ "visibility",
+ ])
+ if (!defined(nmfflags)) {
+ nmfflags = []
+ }
+
+ # TODO(phosek): Remove this conditional once
+ # https://bugs.chromium.org/p/nativeclient/issues/detail?id=4339 is
+ # resolved.
+ if (current_cpu == "pnacl") {
+ objdump = rebase_path("${nacl_toolchain_bindir}/x86_64-nacl-objdump")
+ } else {
+ objdump = rebase_path("${nacl_toolprefix}objdump")
+ }
+ if (host_os == "win") {
+ objdump += ".exe"
+ }
+
+ script = "//native_client_sdk/src/tools/create_nmf.py"
+ inputs = [
+ objdump,
+ ]
+ sources = executables
+ outputs = [
+ nmf,
+ ]
+ if (is_nacl_glibc) {
+ if (defined(stage_dependencies)) {
+ nmfflags += [ "--stage-dependencies=" +
+ rebase_path(stage_dependencies, root_build_dir) ]
+ lib_path = stage_dependencies
+ } else {
+ lib_path = root_build_dir
+ }
+ if (defined(lib_prefix)) {
+ nmfflags += [ "--lib-prefix=" + lib_prefix ]
+ lib_path += "/${lib_prefix}"
+ }
+
+ # Starts empty so the code below can use += everywhere.
+ data = []
+
+ nmfflags += [ "--library-path=" + rebase_path(root_out_dir) ]
+
+ # NOTE: There is no explicit dependency for the lib directory
+ # (lib32 and lib64 for x86/x64) created in the product directory.
+ # They are created as a side-effect of nmf creation.
+ if (current_cpu != "x86" && current_cpu != "x64") {
+ nmfflags +=
+ [ "--library-path=" + rebase_path("${nacl_toolchain_tooldir}/lib") ]
+ if (current_cpu == "arm") {
+ data += [ "${lib_path}/libarm/" ]
+ } else {
+ data += [ "${lib_path}/lib/" ]
+ }
+ } else {
+ # For x86-32, the lib/ directory is called lib32/ instead.
+ if (current_cpu == "x86") {
+ nmfflags += [ "--library-path=" +
+ rebase_path("${nacl_toolchain_tooldir}/lib32") ]
+ data += [ "${lib_path}/lib32/" ]
+ }
+
+ # x86-32 Windows needs to build both x86-32 and x86-64 NaCl
+ # binaries into the same nmf covering both architectures. That
+ # gets handled at a higher level (see the nacl_test_data template),
+ # so a single generate_nmf invocation gets both x86-32 and x86-64
+ # nexes listed in executables.
+ if (current_cpu == "x64" || target_os == "win") {
+ # For x86-64, the lib/ directory is called lib64/ instead
+ # when copied by create_nmf.py.
+ glibc_tc = "//build/toolchain/nacl:glibc"
+ assert(current_toolchain == "${glibc_tc}_${current_cpu}")
+ if (current_cpu == "x64") {
+ x64_out_dir = root_out_dir
+ } else {
+ x64_out_dir = get_label_info(":${target_name}(${glibc_tc}_x64)",
+ "root_out_dir")
+ }
+ nmfflags += [
+ "--library-path=" + rebase_path(x64_out_dir),
+ "--library-path=" + rebase_path("${nacl_toolchain_tooldir}/lib"),
+ ]
+ data += [ "${lib_path}/lib64/" ]
+ }
+ }
+ }
+ args = [
+ "--no-default-libpath",
+ "--objdump=" + objdump,
+ "--output=" + rebase_path(nmf, root_build_dir),
+ ] + nmfflags + rebase_path(sources, root_build_dir)
+ if (is_nacl_glibc && current_cpu == "arm") {
+ deps += [ "//native_client/src/untrusted/elf_loader:elf_loader" ]
+ }
+ }
+}
+
+# Generate a nmf file for Non-SFI tests
+#
+# Non-SFI tests use a different manifest format from regular Native Client and
+# as such requires a different generator.
+#
+# Variables:
+# executable: Non-SFI .nexe executable to generate nmf for
+# nmf: the name and the path of the output file
+# nmfflags: additional flags for the nmf generator
+template("generate_nonsfi_test_nmf") {
+ assert(defined(invoker.executable), "Must define executable")
+ assert(defined(invoker.nmf), "Must define nmf")
+
+ action(target_name) {
+ forward_variables_from(invoker,
+ [
+ "deps",
+ "data_deps",
+ "executable",
+ "nmf",
+ "testonly",
+ "public_deps",
+ "visibility",
+ ])
+
+ script = "//ppapi/tests/create_nonsfi_test_nmf.py"
+ sources = [
+ executable,
+ ]
+ outputs = [
+ nmf,
+ ]
+
+ # NOTE: We use target_cpu rather than current_cpu on purpose because
+ # current_cpu is always going to be pnacl for Non-SFI, but the Non-SFI
+ # .nexe executable is always translated to run on the target machine.
+ if (target_cpu == "x86") {
+ arch = "x86-32"
+ } else if (target_cpu == "x64") {
+ arch = "x86-64"
+ } else {
+ arch = target_cpu
+ }
+ args = [
+ "--program=" + rebase_path(executable, root_build_dir),
+ "--arch=${arch}",
+ "--output=" + rebase_path(nmf, root_build_dir),
+ ]
+ if (defined(invoker.nmfflags)) {
+ args += invoker.nmfflags
+ }
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/pch.gni b/third_party/libwebrtc/webrtc/build/config/pch.gni
new file mode 100644
index 0000000000..93bd2fedc3
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/pch.gni
@@ -0,0 +1,12 @@
+# 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/toolchain/goma.gni")
+
+declare_args() {
+ # Precompiled header file support is by default available,
+ # but for distributed build system uses (like goma) or when
+ # doing official builds.
+ enable_precompiled_headers = !is_official_build && !use_goma
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/posix/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/posix/BUILD.gn
new file mode 100644
index 0000000000..46d296a129
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/posix/BUILD.gn
@@ -0,0 +1,43 @@
+# Copyright 2015 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/clang/clang.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/sysroot.gni")
+import("//build/toolchain/toolchain.gni")
+
+assert(is_posix)
+
+group("posix") {
+ visibility = [ "//:optimize_gn_gen" ]
+}
+
+# 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 Posix-only. Please see that target for advice on what should go in
+# :runtime_library vs. :compiler.
+config("runtime_library") {
+ if (!is_mac && !is_ios && sysroot != "" && !build_with_mozilla) {
+ # Pass the sysroot to all C compiler variants, the assembler, and linker.
+ cflags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
+ asmflags = cflags
+ ldflags = cflags
+
+ # Need to get some linker flags out of the sysroot.
+ ld_paths = exec_script("sysroot_ld_path.py",
+ [
+ rebase_path("//build/linux/sysroot_ld_path.sh",
+ root_build_dir),
+ rebase_path(sysroot),
+ ],
+ "list lines")
+ foreach(ld_path, ld_paths) {
+ ld_path = rebase_path(ld_path, root_build_dir)
+ ldflags += [
+ "-L" + ld_path,
+ "-Wl,-rpath-link=" + ld_path,
+ ]
+ }
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/posix/sysroot_ld_path.py b/third_party/libwebrtc/webrtc/build/config/posix/sysroot_ld_path.py
new file mode 100644
index 0000000000..7056207a23
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/posix/sysroot_ld_path.py
@@ -0,0 +1,21 @@
+# 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.
+
+# This file takes two arguments, the relative location of the shell script that
+# does the checking, and the name of the sysroot.
+
+# TODO(brettw) the build/linux/sysroot_ld_path.sh script should be rewritten in
+# Python in this file.
+
+import subprocess
+import sys
+
+if len(sys.argv) != 3:
+ print "Need two arguments"
+ sys.exit(1)
+
+result = subprocess.check_output([sys.argv[1], sys.argv[2]]).strip()
+result = result.replace(" ", "\n")
+if result != "":
+ print result
diff --git a/third_party/libwebrtc/webrtc/build/config/sanitizers/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/sanitizers/BUILD.gn
new file mode 100644
index 0000000000..67d9568c22
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/sanitizers/BUILD.gn
@@ -0,0 +1,579 @@
+# 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_overrides/build.gni")
+import("//build/config/chrome_build.gni")
+import("//build/config/chromecast_build.gni")
+import("//build/config/clang/clang.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/toolchain/toolchain.gni")
+
+if (is_ios) {
+ import("//build/config/ios/ios_sdk.gni")
+}
+
+# Contains the dependencies needed for sanitizers to link into
+# executables and shared_libraries. Unconditionally depend upon
+# "//build/config:exe_and_shlib_deps" to pull in this target.
+group("deps") {
+ visibility = [ "//build/config:exe_and_shlib_deps" ]
+ if (using_sanitizer) {
+ public_configs = [
+ ":sanitizer_options_link_helper",
+
+ # Even when a target removes default_sanitizer_flags, it may be depending
+ # on a library that did not remove default_sanitizer_flags. Thus, we need
+ # to add the ldflags here as well as in default_sanitizer_flags.
+ ":default_sanitizer_ldflags",
+ ]
+ deps = [
+ ":options_sources",
+ ]
+ if (is_win) {
+ exe = ".exe"
+ } else {
+ exe = ""
+ }
+ data = [
+ "//tools/valgrind/asan/",
+ "$clang_base_path/bin/llvm-symbolizer${exe}",
+ ]
+ if (is_linux) {
+ # llvm-symbolizer needs this.
+ data += [ "$clang_base_path/lib/libstdc++.so.6" ]
+ }
+
+ if (use_prebuilt_instrumented_libraries ||
+ use_locally_built_instrumented_libraries) {
+ deps += [ "//third_party/instrumented_libraries:deps" ]
+ }
+
+ # ASAN is supported on iOS but the runtime library depends on the compiler
+ # used (Chromium version of clang versus Xcode version of clang). Only copy
+ # the ASAN runtime on iOS if building with Chromium clang.
+ if (is_win || is_mac || (is_ios && !use_xcode_clang)) {
+ data_deps = [
+ ":copy_asan_runtime",
+ ]
+ }
+ if (is_mac || (is_ios && !use_xcode_clang)) {
+ public_deps = [
+ ":asan_runtime_bundle_data",
+ ]
+ }
+ }
+}
+
+if ((is_mac || is_win || (is_ios && !use_xcode_clang)) && using_sanitizer) {
+ if (is_mac) {
+ _clang_rt_dso_path = "darwin/libclang_rt.asan_osx_dynamic.dylib"
+ } else if (is_ios) {
+ _clang_rt_dso_path = "darwin/libclang_rt.asan_iossim_dynamic.dylib"
+ } else if (is_win && target_cpu == "x86") {
+ _clang_rt_dso_path = "windows/clang_rt.asan_dynamic-i386.dll"
+ } else if (is_win && target_cpu == "x64") {
+ _clang_rt_dso_path = "windows/clang_rt.asan_dynamic-x86_64.dll"
+ }
+
+ _clang_rt_dso_full_path =
+ "$clang_base_path/lib/clang/$clang_version/lib/$_clang_rt_dso_path"
+
+ if (!is_ios) {
+ copy("copy_asan_runtime") {
+ sources = [
+ _clang_rt_dso_full_path,
+ ]
+ outputs = [
+ "$root_out_dir/{{source_file_part}}",
+ ]
+ }
+ } else {
+ # On iOS, the runtime library need to be code signed (adhoc signature)
+ # starting with Xcode 8, so use an action instead of a copy on iOS.
+ action("copy_asan_runtime") {
+ script = "//build/config/ios/codesign.py"
+ sources = [
+ _clang_rt_dso_full_path,
+ ]
+ outputs = [
+ "$root_out_dir/" + get_path_info(sources[0], "file"),
+ ]
+ args = [
+ "code-sign-file",
+ "--identity=" + ios_code_signing_identity,
+ "--output=" + rebase_path(outputs[0], root_build_dir),
+ rebase_path(sources[0], root_build_dir),
+ ]
+ }
+ }
+
+ if (is_mac || is_ios) {
+ bundle_data("asan_runtime_bundle_data") {
+ sources = get_target_outputs(":copy_asan_runtime")
+ outputs = [
+ "{{bundle_executable_dir}}/{{source_file_part}}",
+ ]
+ public_deps = [
+ ":copy_asan_runtime",
+ ]
+ }
+ }
+}
+
+config("sanitizer_options_link_helper") {
+ if (is_mac || is_ios) {
+ ldflags = [ "-Wl,-U,_sanitizer_options_link_helper" ]
+ } else if (!is_win) {
+ ldflags = [ "-Wl,-u_sanitizer_options_link_helper" ]
+ }
+}
+
+static_library("options_sources") {
+ # This is a static_library instead of a source_set, as it shouldn't be
+ # unconditionally linked into targets.
+ visibility = [
+ ":deps",
+ "//:gn_visibility",
+ ]
+ sources = [
+ "//build/sanitizers/sanitizer_options.cc",
+ ]
+
+ # Don't compile this target with any sanitizer code. It can be called from
+ # the sanitizer runtimes, so instrumenting these functions could cause
+ # recursive calls into the runtime if there is an error.
+ configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]
+
+ if (is_asan) {
+ if (!defined(asan_suppressions_file)) {
+ asan_suppressions_file = "//build/sanitizers/asan_suppressions.cc"
+ }
+ sources += [ asan_suppressions_file ]
+ }
+
+ if (is_lsan) {
+ if (!defined(lsan_suppressions_file)) {
+ lsan_suppressions_file = "//build/sanitizers/lsan_suppressions.cc"
+ }
+ sources += [ lsan_suppressions_file ]
+ }
+
+ if (is_tsan) {
+ if (!defined(tsan_suppressions_file)) {
+ tsan_suppressions_file = "//build/sanitizers/tsan_suppressions.cc"
+ }
+ sources += [ tsan_suppressions_file ]
+ }
+}
+
+# Applies linker flags necessary when either :deps or :default_sanitizer_flags
+# are used.
+config("default_sanitizer_ldflags") {
+ visibility = [
+ ":default_sanitizer_flags",
+ ":deps",
+ ]
+
+ if (is_posix) {
+ ldflags = []
+ if (is_asan) {
+ ldflags += [ "-fsanitize=address" ]
+ if (is_mac) {
+ # https://crbug.com/708707
+ ldflags += [ "-fno-sanitize-address-use-after-scope" ]
+ } else {
+ ldflags += [ "-fsanitize-address-use-after-scope" ]
+ }
+ }
+ if (is_lsan) {
+ ldflags += [ "-fsanitize=leak" ]
+ }
+ if (is_tsan) {
+ ldflags += [ "-fsanitize=thread" ]
+ }
+ if (is_msan) {
+ ldflags += [ "-fsanitize=memory" ]
+ }
+ if (is_ubsan || is_ubsan_security) {
+ ldflags += [ "-fsanitize=undefined" ]
+ }
+ if (is_ubsan_null) {
+ ldflags += [ "-fsanitize=null" ]
+ }
+ if (is_ubsan_vptr) {
+ ldflags += [ "-fsanitize=vptr" ]
+ }
+
+ if (use_sanitizer_coverage) {
+ ldflags += [ "-fsanitize-coverage=$sanitizer_coverage_flags" ]
+ }
+
+ if (is_cfi && !is_nacl) {
+ ldflags += [ "-fsanitize=cfi-vcall" ]
+ if (use_cfi_cast) {
+ ldflags += [
+ "-fsanitize=cfi-derived-cast",
+ "-fsanitize=cfi-unrelated-cast",
+ ]
+ }
+ if (use_cfi_diag) {
+ ldflags += [
+ "-fno-sanitize-trap=cfi",
+ "-fsanitize-recover=cfi",
+ ]
+ }
+ }
+ } else if (is_win && is_asan) {
+ # Windows directly calls link.exe instead of the compiler driver when
+ # linking. Hence, pass the runtime libraries instead of -fsanitize=address.
+ # In the static-library build, libraries are different for executables
+ # and dlls, see link_executable and link_shared_library below.
+ # This here handles only the component build.
+ if (target_cpu == "x64") {
+ # Windows 64-bit. TODO(etienneb): Remove the assert when this is ready.
+ if (is_component_build) {
+ assert(false, "win/asan does not work in 64-bit yet")
+ libs = [
+ "clang_rt.asan_dynamic-x86_64.lib",
+ "clang_rt.asan_dynamic_runtime_thunk-x86_64.lib",
+ ]
+ }
+ } else {
+ assert(target_cpu == "x86", "WinASan unsupported architecture")
+ if (is_component_build) {
+ libs = [
+ "clang_rt.asan_dynamic-i386.lib",
+ "clang_rt.asan_dynamic_runtime_thunk-i386.lib",
+ ]
+ }
+ }
+ }
+}
+
+config("common_sanitizer_flags") {
+ cflags = []
+
+ # Sanitizers need line table info for stack traces. They don't need type info
+ # or variable info, so we can leave that out to speed up the build (unless
+ # it's explicitly asked for by setting |sanitizer_keep_symbols| to true).
+ if (using_sanitizer) {
+ assert(is_clang, "sanitizers only supported with clang")
+ if (!sanitizer_keep_symbols) {
+ cflags += [ "-gline-tables-only" ]
+ }
+
+ cflags += [
+ # Column info in debug data confuses Visual Studio's debugger, so don't
+ # use this by default. However, clusterfuzz needs it for good attribution
+ # of reports to CLs, so turn it on there.
+ "-gcolumn-info",
+ ]
+ }
+
+ # Common options for AddressSanitizer, LeakSanitizer, ThreadSanitizer,
+ # MemorySanitizer and non-official CFI builds.
+ if (using_sanitizer || (is_cfi && !is_official_build)) {
+ if (is_posix) {
+ cflags += [ "-fno-omit-frame-pointer" ]
+ } else {
+ cflags += [ "/Oy-" ]
+ }
+ }
+}
+
+# TODO(thomasanderson): Move this out of build/config/sanitizers.
+config("libcxx_flags") {
+ if (use_custom_libcxx) {
+ prefix = "//buildtools/third_party"
+ include = "trunk/include"
+ cflags_cc = [
+ "-nostdinc++",
+ "-isystem" + rebase_path("$prefix/libc++/$include", root_build_dir),
+ "-isystem" + rebase_path("$prefix/libc++abi/$include", root_build_dir),
+ ]
+ }
+}
+
+config("asan_flags") {
+ cflags = []
+ if (is_asan) {
+ cflags += [ "-fsanitize=address" ]
+ if (!is_mac) {
+ cflags += [ "-fsanitize-address-use-after-scope" ]
+ } else {
+ # https://crbug.com/708707
+ cflags += [ "-fno-sanitize-address-use-after-scope" ]
+ }
+ if (!asan_globals) {
+ cflags += [
+ "-mllvm",
+ "-asan-globals=0",
+ ]
+ }
+ if (is_win) {
+ if (!defined(asan_win_blacklist_path)) {
+ asan_win_blacklist_path =
+ rebase_path("//tools/memory/asan/blacklist_win.txt", root_build_dir)
+ }
+ cflags += [ "-fsanitize-blacklist=$asan_win_blacklist_path" ]
+ } else {
+ # TODO(rnk): Remove this as discussed in http://crbug.com/427202.
+ if (!defined(asan_blacklist_path)) {
+ asan_blacklist_path =
+ rebase_path("//tools/memory/asan/blacklist.txt", root_build_dir)
+ }
+ cflags += [ "-fsanitize-blacklist=$asan_blacklist_path" ]
+ }
+ }
+}
+
+config("link_executable") {
+ if (is_asan && is_win && !is_component_build) {
+ if (target_cpu == "x64") {
+ # Windows 64-bit. TODO(etienneb): Remove the assert when this is ready.
+ assert(false, "win/asan does not work in 64-bit yet")
+ libs = [ "clang_rt.asan-x86_64.lib" ]
+ ldflags = [ "-wholearchive:clang_rt.asan-x86_64.lib" ]
+ } else {
+ assert(target_cpu == "x86", "WinASan unsupported architecture")
+ libs = [ "clang_rt.asan-i386.lib" ]
+ ldflags = [ "-wholearchive:clang_rt.asan-i386.lib" ]
+ }
+ }
+}
+
+config("link_shared_library") {
+ if (is_asan && is_win && !is_component_build) {
+ if (target_cpu == "x64") {
+ # Windows 64-bit. TODO(etienneb): Remove the assert when this is ready.
+ assert(false, "win/asan does not work in 64-bit yet")
+ libs = [ "clang_rt.asan_dll_thunk-x86_64.lib" ]
+ } else {
+ assert(target_cpu == "x86", "WinASan unsupported architecture")
+ libs = [ "clang_rt.asan_dll_thunk-i386.lib" ]
+ }
+ }
+}
+
+config("cfi_flags") {
+ cflags = []
+ if (is_cfi && !is_nacl) {
+ if (!defined(cfi_blacklist_path)) {
+ cfi_blacklist_path =
+ rebase_path("//tools/cfi/blacklist.txt", root_build_dir)
+ }
+ cflags += [
+ "-fsanitize=cfi-vcall",
+ "-fsanitize-blacklist=$cfi_blacklist_path",
+ ]
+
+ if (use_cfi_cast) {
+ cflags += [
+ "-fsanitize=cfi-derived-cast",
+ "-fsanitize=cfi-unrelated-cast",
+ ]
+ }
+
+ if (use_cfi_icall) {
+ cflags += [ "-fsanitize=cfi-icall" ]
+ }
+
+ if (use_cfi_diag) {
+ cflags += [
+ "-fno-sanitize-trap=cfi",
+ "-fsanitize-recover=cfi",
+ "-fno-inline-functions",
+ "-fno-inline",
+ "-fno-omit-frame-pointer",
+ "-O1",
+ ]
+ } else {
+ defines = [ "CFI_ENFORCEMENT" ]
+ }
+ }
+}
+
+config("coverage_flags") {
+ cflags = []
+
+ if (use_sanitizer_coverage) {
+ cflags += [
+ "-fsanitize-coverage=$sanitizer_coverage_flags",
+ "-mllvm",
+ "-sanitizer-coverage-prune-blocks=1",
+ ]
+ if (current_cpu == "arm") {
+ # http://crbug.com/517105
+ cflags += [
+ "-mllvm",
+ "-sanitizer-coverage-block-threshold=0",
+ ]
+ }
+ defines = [ "SANITIZER_COVERAGE" ]
+ }
+}
+
+config("lsan_flags") {
+ if (is_lsan) {
+ cflags = [ "-fsanitize=leak" ]
+ }
+}
+
+config("msan_flags") {
+ if (is_msan) {
+ assert(is_linux, "msan only supported on linux x86_64")
+ if (!defined(msan_blacklist_path)) {
+ msan_blacklist_path =
+ rebase_path("//tools/msan/blacklist.txt", root_build_dir)
+ }
+ cflags = [
+ "-fsanitize=memory",
+ "-fsanitize-memory-track-origins=$msan_track_origins",
+ "-fsanitize-blacklist=$msan_blacklist_path",
+ ]
+ }
+}
+
+config("tsan_flags") {
+ if (is_tsan) {
+ assert(is_linux, "tsan only supported on linux x86_64")
+ if (!defined(tsan_blacklist_path)) {
+ tsan_blacklist_path =
+ rebase_path("//tools/memory/tsan_v2/ignores.txt", root_build_dir)
+ }
+ cflags = [
+ "-fsanitize=thread",
+ "-fsanitize-blacklist=$tsan_blacklist_path",
+ ]
+ }
+}
+
+config("ubsan_flags") {
+ cflags = []
+ if (is_ubsan) {
+ if (!defined(ubsan_blacklist_path)) {
+ ubsan_blacklist_path =
+ rebase_path("//tools/ubsan/blacklist.txt", root_build_dir)
+ }
+ cflags += [
+ # Yasm dies with an "Illegal instruction" error when bounds checking is
+ # enabled. See http://crbug.com/489901
+ # "-fsanitize=bounds",
+ "-fsanitize=float-divide-by-zero",
+ "-fsanitize=integer-divide-by-zero",
+ "-fsanitize=null",
+ "-fsanitize=object-size",
+ "-fsanitize=return",
+ "-fsanitize=returns-nonnull-attribute",
+ "-fsanitize=shift-exponent",
+ "-fsanitize=signed-integer-overflow",
+ "-fsanitize=unreachable",
+ "-fsanitize=vla-bound",
+ "-fsanitize-blacklist=$ubsan_blacklist_path",
+ ]
+
+ # Chromecast ubsan builds fail to compile with these
+ # experimental flags, so only add them to non-chromecast ubsan builds.
+ if (!is_chromecast) {
+ cflags += [
+ # Employ the experimental PBQP register allocator to avoid slow
+ # compilation on files with too many basic blocks.
+ # See http://crbug.com/426271.
+ "-mllvm",
+ "-regalloc=pbqp",
+
+ # Speculatively use coalescing to slightly improve the code generated
+ # by PBQP regallocator. May increase compile time.
+ "-mllvm",
+ "-pbqp-coalescing",
+ ]
+ }
+ }
+}
+
+config("ubsan_no_recover") {
+ if (is_ubsan_no_recover) {
+ cflags = [ "-fno-sanitize-recover=undefined" ]
+ }
+}
+
+config("ubsan_security_flags") {
+ if (is_ubsan_security) {
+ if (!defined(ubsan_security_blacklist_path)) {
+ ubsan_security_blacklist_path =
+ rebase_path("//tools/ubsan/security_blacklist.txt", root_build_dir)
+ }
+ cflags = [
+ "-fsanitize=signed-integer-overflow,shift,vptr,function,vla-bound",
+ "-fsanitize-blacklist=$ubsan_security_blacklist_path",
+ ]
+ }
+}
+
+config("ubsan_null_flags") {
+ if (is_ubsan_null) {
+ cflags = [ "-fsanitize=null" ]
+ }
+}
+
+config("ubsan_vptr_flags") {
+ if (is_ubsan_vptr) {
+ if (!defined(ubsan_vptr_blacklist_path)) {
+ ubsan_vptr_blacklist_path =
+ rebase_path("//tools/ubsan/vptr_blacklist.txt", root_build_dir)
+ }
+ cflags = [
+ "-fsanitize=vptr",
+ "-fsanitize-blacklist=$ubsan_vptr_blacklist_path",
+ ]
+ }
+}
+
+config("fuzzing_build_mode") {
+ if (use_libfuzzer || use_afl) {
+ defines = [ "FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION" ]
+ }
+}
+
+all_sanitizer_configs = [
+ ":common_sanitizer_flags",
+ ":libcxx_flags",
+ ":coverage_flags",
+ ":default_sanitizer_ldflags",
+ ":asan_flags",
+ ":cfi_flags",
+ ":lsan_flags",
+ ":msan_flags",
+ ":tsan_flags",
+ ":ubsan_flags",
+ ":ubsan_no_recover",
+ ":ubsan_null_flags",
+ ":ubsan_security_flags",
+ ":ubsan_vptr_flags",
+ ":fuzzing_build_mode",
+]
+
+# This config is applied by default to all targets. It sets the compiler flags
+# for sanitizer usage, or, if no sanitizer is set, does nothing.
+#
+# This needs to be in a separate config so that targets can opt out of
+# sanitizers (by removing the config) if they desire. Even if a target
+# removes this config, executables & shared libraries should still depend on
+# :deps if any of their dependencies have not opted out of sanitizers.
+# Keep this list in sync with default_sanitizer_flags_but_ubsan_vptr.
+config("default_sanitizer_flags") {
+ configs = all_sanitizer_configs
+}
+
+# This config is equivalent to default_sanitizer_flags, but excludes ubsan_vptr.
+# This allows to selectively disable ubsan_vptr, when needed. In particular,
+# if some third_party code is required to be compiled without rtti, which
+# is a requirement for ubsan_vptr.
+config("default_sanitizer_flags_but_ubsan_vptr") {
+ configs = all_sanitizer_configs - [ ":ubsan_vptr_flags" ]
+}
+
+config("default_sanitizer_flags_but_coverage") {
+ configs = all_sanitizer_configs - [ ":coverage_flags" ]
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/sanitizers/OWNERS b/third_party/libwebrtc/webrtc/build/config/sanitizers/OWNERS
new file mode 100644
index 0000000000..7ab46b14cb
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/sanitizers/OWNERS
@@ -0,0 +1,2 @@
+mmoroz@chromium.org
+ochang@chromium.org
diff --git a/third_party/libwebrtc/webrtc/build/config/sanitizers/sanitizers.gni b/third_party/libwebrtc/webrtc/build/config/sanitizers/sanitizers.gni
new file mode 100644
index 0000000000..17f4d9633f
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/sanitizers/sanitizers.gni
@@ -0,0 +1,203 @@
+# Copyright 2015 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/chrome_build.gni")
+import("//build/toolchain/toolchain.gni")
+
+declare_args() {
+ # Compile for Address Sanitizer to find memory bugs.
+ is_asan = false
+
+ # Compile for Leak Sanitizer to find leaks.
+ is_lsan = false
+
+ # Compile for Memory Sanitizer to find uninitialized reads.
+ is_msan = false
+
+ # Compile for Thread Sanitizer to find threading bugs.
+ is_tsan = false
+
+ # Compile for Undefined Behaviour Sanitizer to find various types of
+ # undefined behaviour (excludes vptr checks).
+ is_ubsan = false
+
+ # Halt the program if a problem is detected.
+ is_ubsan_no_recover = false
+
+ # Compile for Undefined Behaviour Sanitizer's null pointer checks.
+ is_ubsan_null = false
+
+ # Compile for Undefined Behaviour Sanitizer's vptr checks.
+ is_ubsan_vptr = false
+
+ # Track where uninitialized memory originates from. From fastest to slowest:
+ # 0 - no tracking, 1 - track only the initial allocation site, 2 - track the
+ # chain of stores leading from allocation site to use site.
+ msan_track_origins = 2
+
+ # Use dynamic libraries instrumented by one of the sanitizers instead of the
+ # standard system libraries. Set this flag to download prebuilt binaries from
+ # GCS.
+ use_prebuilt_instrumented_libraries = false
+
+ # Use dynamic libraries instrumented by one of the sanitizers instead of the
+ # standard system libraries. Set this flag to build the libraries from source.
+ use_locally_built_instrumented_libraries = false
+
+ # Enable building with SyzyAsan which can find certain types of memory
+ # errors. Only works on Windows. See
+ # https://github.com/google/syzygy/wiki/SyzyASanHowTo
+ is_syzyasan = false
+
+ # Compile with Control Flow Integrity to protect virtual calls and casts.
+ # See http://clang.llvm.org/docs/ControlFlowIntegrity.html
+ #
+ # TODO(pcc): Remove this flag if/when CFI is enabled in all official builds.
+ is_cfi = target_os == "linux" && !is_chromeos && target_cpu == "x64" &&
+ is_official_build && allow_posix_link_time_opt
+
+ # Enable checks for bad casts: derived cast and unrelated cast.
+ # TODO(krasin): remove this, when we're ready to add these checks by default.
+ # https://crbug.com/626794
+ use_cfi_cast = false
+
+ # Enable checks for indirect function calls via a function pointer.
+ # TODO(pcc): remove this when we're ready to add these checks by default.
+ # https://crbug.com/701919
+ use_cfi_icall = false
+
+ # By default, Control Flow Integrity will crash the program if it detects a
+ # violation. Set this to true to print detailed diagnostics instead.
+ use_cfi_diag = false
+
+ # Compile for fuzzing with LLVM LibFuzzer.
+ # See http://www.chromium.org/developers/testing/libfuzzer
+ use_libfuzzer = false
+
+ # Compile for fuzzing with AFL.
+ use_afl = false
+
+ # Enables core ubsan security features. Will later be removed once it matches
+ # is_ubsan.
+ is_ubsan_security = false
+
+ # Compile for fuzzing with Dr. Fuzz
+ # See http://www.chromium.org/developers/testing/dr-fuzz
+ use_drfuzz = false
+
+ # Helper variable for testing builds with disabled libfuzzer.
+ # Not for client use.
+ disable_libfuzzer = false
+
+ # Value for -fsanitize-coverage flag. Setting this causes
+ # use_sanitizer_coverage to be enabled.
+ # Default value when unset and use_afl=true or use_libfuzzer=true:
+ # trace-pc-guard
+ # Default value when unset and use_sanitizer_coverage=true:
+ # trace-pc-guard,indirect-calls
+ sanitizer_coverage_flags = ""
+
+ # Keep symbol level when building with sanitizers. When sanitizers are
+ # enabled, the default is to compile with the minimum debug info level
+ # necessary, overriding any other symbol level arguments that may be set.
+ # Setting this to true prevents this.
+ sanitizer_keep_symbols = false
+}
+
+# Disable sanitizers for non-default toolchains.
+if (current_toolchain != default_toolchain) {
+ is_asan = false
+ is_cfi = false
+ is_lsan = false
+ is_msan = false
+ is_syzyasan = false
+ is_tsan = false
+ is_ubsan = false
+ is_ubsan_null = false
+ is_ubsan_no_recover = false
+ is_ubsan_security = false
+ is_ubsan_vptr = false
+ msan_track_origins = 0
+ sanitizer_coverage_flags = ""
+ use_afl = false
+ use_cfi_diag = false
+ use_custom_libcxx = false
+ use_drfuzz = false
+ use_libfuzzer = false
+ use_prebuilt_instrumented_libraries = false
+ use_locally_built_instrumented_libraries = false
+ use_sanitizer_coverage = false
+}
+
+# Args that are in turn dependent on other args must be in a separate
+# declare_args block. User overrides are only applied at the end of a
+# declare_args block.
+declare_args() {
+ # Use libc++ (buildtools/third_party/libc++ and
+ # buildtools/third_party/libc++abi) instead of stdlibc++ as standard library.
+ # This is intended to be used for instrumented builds.
+ use_custom_libcxx =
+ (is_asan && is_linux && !is_chromeos) || is_tsan || is_msan || is_ubsan ||
+ is_ubsan_security || use_libfuzzer || use_afl
+
+ # Enable -fsanitize-coverage.
+ use_sanitizer_coverage =
+ use_libfuzzer || use_afl || sanitizer_coverage_flags != ""
+
+ # Detect overflow/underflow for global objects.
+ #
+ # Mac: http://crbug.com/352073
+ asan_globals = !is_mac
+}
+
+if ((use_afl || use_libfuzzer) && sanitizer_coverage_flags == "") {
+ sanitizer_coverage_flags = "trace-pc-guard"
+} else if (use_sanitizer_coverage && sanitizer_coverage_flags == "") {
+ sanitizer_coverage_flags = "trace-pc-guard,indirect-calls"
+}
+
+using_sanitizer =
+ is_asan || is_lsan || is_tsan || is_msan || is_ubsan || is_ubsan_null ||
+ is_ubsan_vptr || is_ubsan_security || use_sanitizer_coverage
+
+assert(!using_sanitizer || is_clang,
+ "Sanitizers (is_*san) require setting is_clang = true in 'gn args'")
+
+prebuilt_instrumented_libraries_available =
+ is_msan && (msan_track_origins == 0 || msan_track_origins == 2)
+
+if (use_libfuzzer && is_linux) {
+ if (is_asan) {
+ # We do leak checking with libFuzzer on Linux. Set is_lsan for code that
+ # relies on LEAK_SANITIZER define to avoid false positives.
+ is_lsan = true
+ }
+ if (is_msan) {
+ use_prebuilt_instrumented_libraries = true
+ }
+}
+
+# MSan only links Chrome properly in release builds (brettw -- 9/1/2015). The
+# same is possibly true for the other non-ASan sanitizers. But regardless of
+# whether it links, one would normally never run a sanitizer in debug mode.
+# Running in debug mode probably indicates you forgot to set the "is_debug =
+# false" flag in the build args. ASan seems to run fine in debug mode.
+#
+# If you find a use-case where you want to compile a sanitizer in debug mode
+# and have verified it works, ask brettw and we can consider removing it from
+# this condition. We may also be able to find another way to enable your case
+# without having people accidentally get broken builds by compiling an
+# unsupported or unadvisable configurations.
+#
+# For one-off testing, just comment this assertion out.
+assert(!is_debug || !(is_msan || is_ubsan || is_ubsan_null || is_ubsan_vptr),
+ "Sanitizers should generally be used in release (set is_debug=false).")
+
+assert(!is_msan || (is_linux && current_cpu == "x64"),
+ "MSan currently only works on 64-bit Linux and ChromeOS builds.")
+
+# ASAN build on Windows is not working in debug mode. Intercepting memory
+# allocation functions is hard on Windows and not yet implemented in LLVM.
+assert(!is_win || !is_debug || !is_asan,
+ "ASan on Windows doesn't work in debug (set is_debug=false).")
diff --git a/third_party/libwebrtc/webrtc/build/config/sysroot.gni b/third_party/libwebrtc/webrtc/build/config/sysroot.gni
new file mode 100644
index 0000000000..0b72e9ccd9
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/sysroot.gni
@@ -0,0 +1,92 @@
+# 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.
+
+# This header file defines the "sysroot" variable which is the absolute path
+# of the sysroot. If no sysroot applies, the variable will be an empty string.
+
+import("//build/config/chrome_build.gni")
+
+declare_args() {
+ # The absolute path of the sysroot that is applied when compiling using
+ # the target toolchain.
+ target_sysroot = ""
+
+ # The absolute path to directory containing linux sysroot images
+ target_sysroot_dir = "//build/linux"
+
+ use_sysroot = current_cpu != "s390x" && current_cpu != "s390" &&
+ current_cpu != "ppc64" && current_cpu != "ppc" &&
+ !build_with_mozilla
+}
+
+if (current_os == target_os && current_cpu == target_cpu &&
+ target_sysroot != "") {
+ sysroot = target_sysroot
+} else if (is_android) {
+ import("//build/config/android/config.gni")
+ if (current_cpu == "x86") {
+ sysroot = "$android_ndk_root/$x86_android_sysroot_subdir"
+ } else if (current_cpu == "arm") {
+ sysroot = "$android_ndk_root/$arm_android_sysroot_subdir"
+ } else if (current_cpu == "mipsel") {
+ sysroot = "$android_ndk_root/$mips_android_sysroot_subdir"
+ } else if (current_cpu == "x64") {
+ sysroot = "$android_ndk_root/$x86_64_android_sysroot_subdir"
+ } else if (current_cpu == "arm64") {
+ sysroot = "$android_ndk_root/$arm64_android_sysroot_subdir"
+ } else if (current_cpu == "mips64el") {
+ sysroot = "$android_ndk_root/$mips64_android_sysroot_subdir"
+ } else {
+ assert(false, "No android sysroot for cpu: $target_cpu")
+ }
+} else if (is_linux && use_sysroot) {
+ # By default build against a sysroot image downloaded from Cloud Storage
+ # during gclient runhooks.
+ if (current_cpu == "x64") {
+ sysroot = "$target_sysroot_dir/debian_jessie_amd64-sysroot"
+ } else if (current_cpu == "x86") {
+ sysroot = "$target_sysroot_dir/debian_jessie_i386-sysroot"
+ } else if (current_cpu == "mipsel") {
+ sysroot = "$target_sysroot_dir/debian_jessie_mips-sysroot"
+ } else if (current_cpu == "arm") {
+ sysroot = "$target_sysroot_dir/debian_jessie_arm-sysroot"
+ } else if (current_cpu == "arm64") {
+ sysroot = "$target_sysroot_dir/debian_jessie_arm64-sysroot"
+ } else {
+ assert(false, "No linux sysroot for cpu: $target_cpu")
+ }
+
+ if (sysroot != "") {
+ _script_arch = current_cpu
+ if (_script_arch == "x86") {
+ _script_arch = "i386"
+ } else if (_script_arch == "x64") {
+ _script_arch = "amd64"
+ }
+ assert(
+ exec_script("//build/dir_exists.py",
+ [ rebase_path(sysroot) ],
+ "string") == "True",
+ "Missing sysroot ($sysroot). To fix, run: build/linux/sysroot_scripts/install-sysroot.py --arch=$_script_arch")
+ }
+} else if (is_mac) {
+ import("//build/config/mac/mac_sdk.gni")
+ sysroot = mac_sdk_path
+} else if (is_ios) {
+ import("//build/config/ios/ios_sdk.gni")
+ sysroot = ios_sdk_path
+} else if (is_fuchsia) {
+ import("//build/config/fuchsia/config.gni")
+ if (current_cpu == "arm64") {
+ sysroot = fuchsia_sdk + "/sysroot/aarch64-fuchsia"
+ } else if (current_cpu == "x64") {
+ sysroot = fuchsia_sdk + "/sysroot/x86_64-fuchsia"
+ } else {
+ sysroot = ""
+ }
+ sysroot_stamp = rebase_path("$sysroot/.stamp")
+ sysroot_version = read_file(sysroot_stamp, "trim string")
+} else {
+ sysroot = ""
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/ui.gni b/third_party/libwebrtc/webrtc/build/config/ui.gni
new file mode 100644
index 0000000000..f9e5515498
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/ui.gni
@@ -0,0 +1,72 @@
+# 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.
+
+# =============================================
+# PLEASE DO NOT ADD MORE FLAGS TO THIS FILE
+# =============================================
+#
+# These flags are effectively global. Your feature flag should go near the
+# code it controls. Most of these items are here now because they control
+# legacy global #defines passed to the compiler (now replaced with generated
+# buildflag headers -- see //build/buildflag_header.gni).
+#
+# These flags are ui-related so should eventually be moved to various places
+# in //ui/*.
+#
+# There is more advice on where to put build flags in the "Build flag" section
+# of //build/config/BUILDCONFIG.gn.
+
+import("//build/config/chromecast_build.gni")
+
+declare_args() {
+ # Indicates if Ash is enabled. Ash is the Aura Shell which provides a
+ # desktop-like environment for Aura. Requires use_aura = true
+ use_ash = is_chromeos && !is_chromecast
+
+ # Indicates if Ozone is enabled. Ozone is a low-level library layer for Linux
+ # that does not require X11. Enabling this feature disables use of glib, x11,
+ # Pango, and Cairo. Default to false on non-Chromecast builds.
+ use_ozone = is_chromeos || (is_chromecast && !is_android)
+
+ # Indicates if Aura is enabled. Aura is a low-level windowing library, sort
+ # of a replacement for GDI or GTK.
+ use_aura = (is_win || is_linux) && !build_with_mozilla
+
+ # Whether we should use glib, a low level C utility library.
+ use_glib = is_linux && !build_with_mozilla
+}
+
+declare_args() {
+ # True means the UI is built using the "views" framework.
+ toolkit_views =
+ (is_mac || is_win || is_chromeos || use_aura) && !is_chromecast
+}
+
+# Additional dependent variables -----------------------------------------------
+#
+# These variables depend on other variables and can't be set externally.
+
+# Indicates if the UI toolkit depends on X11.
+use_x11 = (is_linux || is_bsd) && !use_ozone
+
+# Turn off glib if Ozone is enabled.
+if (use_ozone) {
+ use_glib = false
+}
+
+if (is_linux && !use_ozone && !build_with_mozilla) {
+ use_cairo = true
+ use_pango = true
+} else {
+ use_cairo = false
+ use_pango = false
+}
+
+# Whether to use atk, the Accessibility ToolKit library
+use_atk = is_desktop_linux && use_x11
+# =============================================
+# PLEASE DO NOT ADD MORE FLAGS TO THIS FILE
+# =============================================
+#
+# See comment at the top.
diff --git a/third_party/libwebrtc/webrtc/build/config/v8_target_cpu.gni b/third_party/libwebrtc/webrtc/build/config/v8_target_cpu.gni
new file mode 100644
index 0000000000..13755d2be5
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/v8_target_cpu.gni
@@ -0,0 +1,61 @@
+# 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/sanitizers/sanitizers.gni")
+
+declare_args() {
+ # This arg is used when we want to tell the JIT-generating v8 code
+ # that we want to have it generate for an architecture that is different
+ # than the architecture that v8 will actually run on; we then run the
+ # code under an emulator. For example, we might run v8 on x86, but
+ # generate arm code and run that under emulation.
+ #
+ # This arg is defined here rather than in the v8 project because we want
+ # some of the common architecture-specific args (like arm_float_abi or
+ # mips_arch_variant) to be set to their defaults either if the current_cpu
+ # applies *or* if the v8_current_cpu applies.
+ #
+ # As described below, you can also specify the v8_target_cpu to use
+ # indirectly by specifying a `custom_toolchain` that contains v8_$cpu in the
+ # name after the normal toolchain.
+ #
+ # For example, `gn gen --args="custom_toolchain=...:clang_x64_v8_arm64"`
+ # is equivalent to setting --args=`v8_target_cpu="arm64"`. Setting
+ # `custom_toolchain` is more verbose but makes the toolchain that is
+ # (effectively) being used explicit.
+ #
+ # v8_target_cpu can only be used to target one architecture in a build,
+ # so if you wish to build multiple copies of v8 that are targetting
+ # different architectures, you will need to do something more
+ # complicated involving multiple toolchains along the lines of
+ # custom_toolchain, above.
+ v8_target_cpu = ""
+}
+
+if (v8_target_cpu == "") {
+ if (current_toolchain == "//build/toolchain/linux:clang_x64_v8_arm64") {
+ v8_target_cpu = "arm64"
+ } else if (current_toolchain == "//build/toolchain/linux:clang_x86_v8_arm") {
+ v8_target_cpu = "arm"
+ } else if (current_toolchain ==
+ "//build/toolchain/linux:clang_x86_v8_mips64el") {
+ v8_target_cpu = "mips64el"
+ } else if (current_toolchain ==
+ "//build/toolchain/linux:clang_x86_v8_mipsel") {
+ v8_target_cpu = "mipsel"
+ } else if (is_msan) {
+ # If we're running under a sanitizer, if we configure v8 to generate
+ # code that will be run under a simulator, then the generated code
+ # also gets the benefits of the sanitizer.
+ v8_target_cpu = "arm64"
+ } else {
+ v8_target_cpu = target_cpu
+ }
+}
+
+declare_args() {
+ # This argument is declared here so that it can be overridden in toolchains.
+ # It should never be explicitly set by the user.
+ v8_current_cpu = v8_target_cpu
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/win/BUILD.gn b/third_party/libwebrtc/webrtc/build/config/win/BUILD.gn
new file mode 100644
index 0000000000..940e55c6c2
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/win/BUILD.gn
@@ -0,0 +1,438 @@
+# 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/clang/clang.gni")
+import("//build/config/compiler/compiler.gni")
+import("//build/config/sanitizers/sanitizers.gni")
+import("//build/config/win/visual_studio_version.gni")
+import("//build/toolchain/toolchain.gni")
+
+assert(is_win)
+
+declare_args() {
+ # Set this to true to enable static analysis through Visual Studio's
+ # /analyze. This dramatically slows compiles and reports thousands of
+ # warnings, so normally this is done on a build machine and only the new
+ # warnings are examined.
+ use_vs_code_analysis = false
+
+ # Turn this on to have the linker output extra timing information.
+ win_linker_timing = false
+}
+
+# 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
+# Windows-only.
+config("compiler") {
+ if (current_cpu == "x86") {
+ asmflags = [
+ # When /safeseh is specified, the linker will only produce an image if it
+ # can also produce a table of the image's safe exception handlers. This
+ # table specifies for the operating system which exception handlers are
+ # valid for the image. Note that /SAFESEH isn't accepted on the command
+ # line, only /safeseh. This is only accepted by ml.exe, not ml64.exe.
+ "/safeseh",
+ ]
+ }
+
+ cflags = [
+ "/Gy", # Enable function-level linking.
+ "/FS", # Preserve previous PDB behavior.
+ "/bigobj", # Some of our files are bigger than the regular limits.
+ ]
+
+ # Force C/C++ mode for the given GN detected file type. This is necessary
+ # for precompiled headers where the same source file is compiled in both
+ # modes.
+ cflags_c = [ "/TC" ]
+ cflags_cc = [ "/TP" ]
+
+ cflags += [
+ # Tell the compiler to crash on failures. This is undocumented
+ # and unsupported but very handy.
+ "/d2FastFail",
+
+ # Work around crbug.com/526851, bug in VS 2015 RTM compiler.
+ "/Zc:sizedDealloc-",
+ ]
+
+ # Building with Clang on Windows is a work in progress and very
+ # experimental. See crbug.com/82385.
+ if (is_clang) {
+ cflags += [ "-fmsc-version=1900" ]
+
+ if (current_cpu == "x86") {
+ cflags += [ "-m32" ]
+ } else {
+ cflags += [ "-m64" ]
+ }
+
+ if (exec_script("//build/win/use_ansi_codes.py", [], "trim string") ==
+ "True") {
+ cflags += [
+ # cmd.exe doesn't understand ANSI escape codes by default,
+ # so only enable them if something emulating them is around.
+ "-fansi-escape-codes",
+ ]
+ }
+
+ # Clang runtime libraries, such as the sanitizer runtimes, live here.
+ lib_dirs = [ "$clang_base_path/lib/clang/$clang_version/lib/windows" ]
+ }
+
+ # /PROFILE ensures that the PDB file contains FIXUP information (growing the
+ # PDB file by about 5%) but does not otherwise alter the output binary. This
+ # information is used by the Syzygy optimization tool when decomposing the
+ # release image. It is enabled for syzyasan builds and opportunistically for
+ # other builds where it is not prohibited (not supported when incrementally
+ # linking, or using /debug:fastlink).
+ if (is_syzyasan) {
+ assert(!is_win_fastlink)
+ ldflags = [ "/PROFILE" ]
+ } else {
+ if (!is_debug && !is_component_build) {
+ if (is_win_fastlink) {
+ # /PROFILE implies the following linker flags. Therefore if we are
+ # skipping /PROFILE because it is incompatible with /DEBUG:FASTLINK
+ # we should explicitly add these flags in order to avoid unintended
+ # consequences such as larger binaries.
+ ldflags = [
+ "/OPT:REF",
+ "/OPT:ICF",
+ "/INCREMENTAL:NO",
+ "/FIXED:NO",
+ ]
+ } else {
+ ldflags = [ "/PROFILE" ]
+ }
+ }
+ }
+
+ # arflags apply only to static_libraries. The normal linker configs are only
+ # set for executable and shared library targets so arflags must be set
+ # elsewhere. Since this is relatively contained, we just apply them in this
+ # more general config and they will only have an effect on static libraries.
+ arflags = [
+ # "No public symbols found; archive member will be inaccessible." This
+ # means that one or more object files in the library can never be
+ # pulled in to targets that link to this library. It's just a warning that
+ # the source file is a no-op.
+ "/ignore:4221",
+ ]
+}
+
+config("vs_code_analysis") {
+ if (use_vs_code_analysis && !is_clang) {
+ # When use_vs_code_analysis is specified add the /analyze switch to enable
+ # static analysis. Specifying /analyze:WX- says that /analyze warnings
+ # should not be treated as errors.
+ cflags = [ "/analyze:WX-" ]
+
+ # Also, disable various noisy warnings that have low value.
+ cflags += [
+ "/wd6011", # Dereferencing NULL pointer
+
+ # C6285 is ~16% of raw warnings and has low value
+ "/wd6285", # non-zero constant || non-zero constant
+ "/wd6308", # realloc might return null pointer
+
+ # Possible infinite loop: use of the constant
+ # EXCEPTION_CONTINUE_EXECUTION in the exception-filter
+ "/wd6312",
+
+ "/wd6322", # Empty _except block
+ "/wd6330", # 'char' used instead of 'unsigned char' for istype() call
+
+ # C6334 is ~80% of raw warnings and has low value
+ "/wd6334", # sizeof applied to an expression with an operator
+ "/wd6326", # Potential comparison of constant with constant
+ "/wd6340", # Sign mismatch in function parameter
+ "/wd28159", # Consider using 'GetTickCount64'
+ "/wd28196", # The precondition is not satisfied
+ "/wd28204", # Inconsistent SAL annotations
+ "/wd28251", # Inconsistent SAL annotations
+ "/wd28252", # Inconsistent SAL annotations
+ "/wd28253", # Inconsistent SAL annotations
+ "/wd28278", # Function appears with no prototype in scope
+ "/wd28285", # syntax error in SAL annotation (in algorithm)
+ "/wd28301", # Inconsistent SAL annotations
+ "/wd28182", # Dereferencing NULL pointer
+ ]
+ }
+}
+
+# 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 Windows-only. Please see that target for advice on what should go in
+# :runtime_library vs. :compiler.
+config("runtime_library") {
+ cflags = []
+
+ # Defines that set up the CRT.
+ defines = [
+ "__STD_C",
+ "_CRT_RAND_S",
+ "_CRT_SECURE_NO_DEPRECATE",
+ "_HAS_EXCEPTIONS=0",
+ "_SCL_SECURE_NO_DEPRECATE",
+ ]
+
+ # Defines that set up the Windows SDK.
+ defines += [
+ "_ATL_NO_OPENGL",
+ "_WINDOWS",
+ "CERT_CHAIN_PARA_HAS_EXTRA_FIELDS",
+ "PSAPI_VERSION=1",
+ "WIN32",
+ "_SECURE_ATL",
+ ]
+
+ if (!use_vs_code_analysis) {
+ # This is required for ATL to use XP-safe versions of its functions.
+ # However it is prohibited when using /analyze
+ defines += [ "_USING_V110_SDK71_" ]
+ }
+}
+
+# Sets the default Windows build version. This is separated because some
+# targets need to manually override it for their compiles.
+config("winver") {
+ defines = [
+ "NTDDI_VERSION=0x0A000000",
+ "_WIN32_WINNT=0x0A00",
+ "WINVER=0x0A00",
+ ]
+}
+
+# Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs.
+config("sdk_link") {
+ if (current_cpu == "x64") {
+ ldflags = [ "/MACHINE:X64" ]
+ lib_dirs = [
+ "$windows_sdk_path\Lib\winv6.3\um\x64",
+ "$visual_studio_path\VC\lib\amd64",
+ "$visual_studio_path\VC\atlmfc\lib\amd64",
+ ]
+ } else {
+ ldflags = [
+ "/MACHINE:X86",
+ "/SAFESEH", # Not compatible with x64 so use only for x86.
+ "/largeaddressaware",
+ ]
+ lib_dirs = [
+ "$windows_sdk_path\Lib\winv6.3\um\x86",
+ "$visual_studio_path\VC\lib",
+ "$visual_studio_path\VC\atlmfc\lib",
+ ]
+ }
+}
+
+# This default linker setup is provided separately from the SDK setup so
+# targets who want different library configurations can remove this and specify
+# their own.
+config("common_linker_setup") {
+ ldflags = [
+ "/fastfail",
+ "/FIXED:NO",
+ "/ignore:4199",
+ "/ignore:4221",
+ "/NXCOMPAT",
+ ]
+
+ # ASLR makes debugging with windbg difficult because Chrome.exe and
+ # Chrome.dll share the same base name. As result, windbg will name the
+ # Chrome.dll module like chrome_<base address>, where <base address>
+ # typically changes with each launch. This in turn means that breakpoints in
+ # Chrome.dll don't stick from one launch to the next. For this reason, we
+ # turn ASLR off in debug builds.
+ if (is_debug) {
+ ldflags += [ "/DYNAMICBASE:NO" ]
+ } else {
+ ldflags += [ "/DYNAMICBASE" ]
+ }
+
+ if (win_linker_timing) {
+ ldflags += [
+ "/time",
+ "/verbose:incr",
+ ]
+ }
+}
+
+config("cfi_linker") {
+ # Control Flow Guard (CFG)
+ # https://msdn.microsoft.com/en-us/library/windows/desktop/mt637065.aspx
+ # /DYNAMICBASE (ASLR) is turned off in debug builds, therefore CFG can’t be
+ # turned on either.
+ # TODO(thakis): Turn this on with lld once supported, https://crbug.com/693709
+ if (!is_debug && !use_lld) {
+ # Turn on CFG in msvc linker, regardless of compiler used.
+ ldflags = [ "/guard:cf" ]
+ }
+}
+
+# CRT --------------------------------------------------------------------------
+
+# Configures how the runtime library (CRT) is going to be used.
+# See https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx for a reference of
+# what each value does.
+config("default_crt") {
+ if (is_component_build) {
+ # Component mode: dynamic CRT. Since the library is shared, it requires
+ # exceptions or will give errors about things not matching, so keep
+ # exceptions on.
+ configs = [ ":dynamic_crt" ]
+ } else {
+ if (current_os != "win") {
+ # WindowsRT: use the dynamic CRT.
+ configs = [ ":dynamic_crt" ]
+ } else {
+ # Desktop Windows: static CRT.
+ configs = [ ":static_crt" ]
+ }
+ }
+}
+
+# Use this to force the debug CRT for when building perf-critical build tools
+# that need to be fully optimized even in debug builds, for those times when the
+# debug CRT is part of the bottleneck. This also avoids *implicitly* defining
+# _DEBUG.
+config("release_crt") {
+ if (is_component_build) {
+ cflags = [ "/MD" ]
+ } else {
+ cflags = [ "/MT" ]
+ }
+}
+
+config("dynamic_crt") {
+ if (is_debug) {
+ # This pulls in the DLL debug CRT and defines _DEBUG
+ cflags = [ "/MDd" ]
+ } else {
+ cflags = [ "/MD" ]
+ }
+}
+
+config("static_crt") {
+ if (is_debug) {
+ # This pulls in the static debug CRT and defines _DEBUG
+ cflags = [ "/MTd" ]
+ } else {
+ cflags = [ "/MT" ]
+ }
+}
+
+# Subsystem --------------------------------------------------------------------
+
+# This is appended to the subsystem to specify a minimum version.
+if (current_cpu == "x64") {
+ # The number after the comma is the minimum required OS version.
+ # 5.02 = Windows Server 2003.
+ subsystem_version_suffix = ",5.02"
+} else {
+ # 5.01 = Windows XP.
+ subsystem_version_suffix = ",5.01"
+}
+
+config("console") {
+ ldflags = [ "/SUBSYSTEM:CONSOLE$subsystem_version_suffix" ]
+}
+config("windowed") {
+ ldflags = [ "/SUBSYSTEM:WINDOWS$subsystem_version_suffix" ]
+}
+
+# Incremental linking ----------------------------------------------------------
+
+incremental_linking_on_switch = [ "/INCREMENTAL" ]
+incremental_linking_off_switch = [ "/INCREMENTAL:NO" ]
+
+# Disable incremental linking for syzyasan, enable for debug builds and all
+# component builds - any builds where performance is not job one.
+if ((is_debug || is_component_build) && !is_syzyasan) {
+ default_incremental_linking_switch = incremental_linking_on_switch
+} else {
+ default_incremental_linking_switch = incremental_linking_off_switch
+}
+
+# Applies incremental linking or not depending on the current configuration.
+config("default_incremental_linking") {
+ ldflags = default_incremental_linking_switch
+}
+
+# Explicitly on or off incremental linking
+config("incremental_linking") {
+ ldflags = incremental_linking_on_switch
+}
+config("no_incremental_linking") {
+ ldflags = incremental_linking_off_switch
+}
+
+# Some large modules can't handle incremental linking in some situations. This
+# config should be applied to large modules to turn off incremental linking
+# when it won't work.
+config("default_large_module_incremental_linking") {
+ if (symbol_level > 0 && (current_cpu == "x86" || !is_component_build)) {
+ # When symbols are on, things get so large that the tools fail due to the
+ # size of the .ilk files.
+ ldflags = incremental_linking_off_switch
+ } else {
+ # Otherwise just do the default incremental linking for this build type.
+ ldflags = default_incremental_linking_switch
+ }
+}
+
+# Character set ----------------------------------------------------------------
+
+# Not including this config means "ansi" (8-bit system codepage).
+config("unicode") {
+ defines = [
+ "_UNICODE",
+ "UNICODE",
+ ]
+}
+
+# Lean and mean ----------------------------------------------------------------
+
+# Some third party code might not compile with WIN32_LEAN_AND_MEAN so we have
+# to have a separate config for it. Remove this config from your target to
+# get the "bloaty and accomodating" version of windows.h.
+config("lean_and_mean") {
+ defines = [ "WIN32_LEAN_AND_MEAN" ]
+}
+
+# Nominmax --------------------------------------------------------------------
+
+# Some third party code defines NOMINMAX before including windows.h, which
+# then causes warnings when it's been previously defined on the command line.
+# For such targets, this config can be removed.
+
+config("nominmax") {
+ defines = [ "NOMINMAX" ]
+}
+
+# Target WinRT ----------------------------------------------------------------
+
+# When targeting Windows Runtime, certain compiler/linker flags are necessary.
+
+config("target_winrt") {
+ defines = [
+ "WINRT",
+ "WINAPI_FAMILY=WINAPI_FAMILY_PC_APP",
+ ]
+ cflags_cc = [
+ "/ZW",
+ "/EHsc",
+ ]
+}
+
+# Internal stuff --------------------------------------------------------------
+
+# Config used by the MIDL template to disable warnings.
+config("midl_warnings") {
+ if (is_clang) {
+ # MIDL generates code like "#endif !_MIDL_USE_GUIDDEF_".
+ cflags = [ "-Wno-extra-tokens" ]
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/win/console_app.gni b/third_party/libwebrtc/webrtc/build/config/win/console_app.gni
new file mode 100644
index 0000000000..cac2ef5d73
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/win/console_app.gni
@@ -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/sanitizers/sanitizers.gni")
+
+declare_args() {
+ # If true, builds as a console app (rather than a windowed app), which allows
+ # logging to be printed to the user. This will cause a terminal window to pop
+ # up when the executable is not run from the command line, so should only be
+ # used for development. Only has an effect on Windows builds.
+ win_console_app = false
+}
+
+if (is_win && is_asan) {
+ # AddressSanitizer build should be a console app since it writes to stderr.
+ win_console_app = true
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/win/manifest.gni b/third_party/libwebrtc/webrtc/build/config/win/manifest.gni
new file mode 100644
index 0000000000..515764c531
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/win/manifest.gni
@@ -0,0 +1,191 @@
+# Copyright 2015 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.
+
+# HOW MANIFESTS WORK IN THE GN BUILD
+#
+# Use the windows_manifest template to declare a manifest generation step.
+# This will combine all listed .manifest files and generate a resource file
+# referencing the resulting manifest. To link this manifest, just depend on
+# the manifest target from your executable or shared library.
+#
+# This will define an empty placeholder target on non-Windows platforms so
+# the manifest declarations and dependencies do not need to be inside of OS
+# conditionals.
+#
+# Manifests uses different resource IDs for EXE and DLL targets. You will need
+# to specify this in the manifest target declaration and only use that manifest
+# target from the correct type of binary target.
+#
+# A binary can depend on only one manifest target, but the manifest target
+# can depend on many individual .manifest files which will be merged. As a
+# result, only executables and shared libraries should depend on manifest
+# targets. If you want to add a manifest to a component, put the dependency
+# behind a "if (is_component_build)" conditional.
+#
+# Generally you will just want the defaults for the Chrome build. In this case
+# the binary should just depend on one of the targets in //build/win/. There
+# are also individual manifest files in that directory you can reference via
+# the *_manifest variables defined below to pick and choose only some defaults.
+# You might combine these with a custom manifest file to get specific behavior.
+
+# Reference this manifest as a source from windows_manifest targets to get
+# the default Chrome OS compatibility list.
+default_compatibility_manifest = "//build/win/compatibility.manifest"
+
+# Reference this manifest as a source from windows_manifest targets to get
+# the default Chrome common constrols compatibility.
+common_controls_manifest = "//build/win/common_controls.manifest"
+
+# Reference this manifest to request that Windows not perform any elevation
+# when running your program. Otherwise, it might do some autodetection and
+# request elevated privileges from the user. This is normally what you want.
+as_invoker_manifest = "//build/win/as_invoker.manifest"
+
+# An alternative to as_invoker_manifest when you want the application to always
+# elevate.
+require_administrator_manifest = "//build/win/require_administrator.manifest"
+
+# Construct a target to combine the given manifest files into a .rc file.
+#
+# Variables for the windows_manifest template:
+#
+# sources: (required)
+# List of source .manifest files to add.
+#
+# type: "dll" or "exe" (required)
+# Indicates the type of target that this manifest will be used for.
+# DLLs and EXEs have different manifest resource IDs.
+#
+# deps: (optional)
+# visibility: (optional)
+# Normal meaning.
+#
+# Example:
+#
+# windows_manifest("doom_melon_manifest") {
+# sources = [
+# "doom_melon.manifest", # Custom values in here.
+# default_compatibility_manifest, # Want the normal OS compat list.
+# ]
+# type = "exe"
+# }
+#
+# executable("doom_melon") {
+# deps = [ ":doom_melon_manifest" ]
+# ...
+# }
+
+if (is_win) {
+ # This is the environment file that tool_wrapper.py will use for the current
+ # toolchain. It is placed in root_build_dir by the toolchain setup. This
+ # variable is the path relative to the root_build_dir which is what
+ # tool_wrapper.py expects as an argument.
+ _environment_file = "environment.$current_cpu"
+
+ template("windows_manifest") {
+ manifest_action_name = "${target_name}__gen_manifest"
+ rc_action_name = "${target_name}__gen_rc"
+ source_set_name = target_name
+
+ output_manifest = "$target_gen_dir/$source_set_name.manifest"
+ rcfile = "$output_manifest.rc"
+
+ # Make the final .manifest file.
+ action(manifest_action_name) {
+ visibility = [
+ ":$source_set_name",
+ ":$rc_action_name",
+ ]
+
+ script = "//build/toolchain/win/tool_wrapper.py"
+
+ assert(defined(invoker.sources),
+ "\"sources\" must be defined for a windows_manifest target")
+ inputs = invoker.sources
+
+ outputs = [
+ output_manifest,
+ ]
+
+ args = [
+ "manifest-wrapper",
+ _environment_file,
+ "mt.exe",
+ "-nologo",
+ "-manifest",
+ ]
+ args += rebase_path(invoker.sources, root_build_dir)
+ args += [ "-out:" + rebase_path(output_manifest, root_build_dir) ]
+
+ # Apply any dependencies from the invoker to this target, since those
+ # dependencies may have created the input manifest files.
+ forward_variables_from(invoker, [ "deps" ])
+ }
+
+ # Make the .rc file that references the final manifest file.
+ #
+ # This could easily be combined into one step, but this current separation
+ # of .manifest and .rc matches GYP and allows us to re-use tool_wrapper.py.
+ action(rc_action_name) {
+ visibility = [ ":$source_set_name" ]
+
+ script = "//build/toolchain/win/tool_wrapper.py"
+
+ outputs = [
+ rcfile,
+ ]
+
+ # EXEs have a resource ID of 1 for their manifest, DLLs use 2.
+ assert(defined(invoker.type),
+ "\"type\" must be defined for a windows_manifest")
+ if (invoker.type == "exe") {
+ manifest_resource_id = "1"
+ } else if (invoker.type == "dll") {
+ manifest_resource_id = "2"
+ } else {
+ assert(false, "Bad value of \"type\", Must be \"exe\" or \"dll\"")
+ }
+
+ args = [
+ "manifest-to-rc",
+ "$_environment_file",
+ rebase_path(output_manifest),
+ rebase_path(rcfile, root_build_dir),
+ manifest_resource_id,
+ ]
+
+ # Although generating this file doesn't technically depend on the
+ # generated manifest, this dependency causes the .rc timestamp to be
+ # updated every time the manifest is updated. Otherwise, updating the
+ # manifest will not cause a recompilation of the .rc file.
+ deps = [
+ ":$manifest_action_name",
+ ]
+ }
+
+ # This source set only exists to compile and link the resource file.
+ source_set(source_set_name) {
+ forward_variables_from(invoker, [ "visibility" ])
+ sources = [
+ rcfile,
+ ]
+ deps = [
+ ":$manifest_action_name",
+ ":$rc_action_name",
+ ]
+ }
+ }
+} else {
+ # Make a no-op group on non-Windows platforms so windows_manifest
+ # instantiations don't need to be inside windows blocks.
+ template("windows_manifest") {
+ group(target_name) {
+ # Prevent unused variable warnings on non-Windows platforms.
+ assert(invoker.type == "exe" || invoker.type == "dll")
+ assert(invoker.sources != "")
+ assert(!defined(invoker.deps) || invoker.deps != "")
+ assert(!defined(invoker.visibility) || invoker.visibility != "")
+ }
+ }
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/win/visual_studio_version.gni b/third_party/libwebrtc/webrtc/build/config/win/visual_studio_version.gni
new file mode 100644
index 0000000000..61afb6f64a
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/win/visual_studio_version.gni
@@ -0,0 +1,39 @@
+# 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.
+
+declare_args() {
+ # Path to Visual Studio. If empty, the default is used which is to use the
+ # automatic toolchain in depot_tools. If set, you must also set the
+ # visual_studio_version and wdk_path.
+ visual_studio_path = "."
+
+ # Version of Visual Studio pointed to by the visual_studio_path.
+ # Currently always "2015".
+ visual_studio_version = "2015"
+
+ # Directory of the Windows driver kit. If visual_studio_path is empty, this
+ # will be auto-filled.
+ wdk_path = "."
+
+ # Full path to the Windows SDK, not including a backslash at the end.
+ # This value is the default location, override if you have a different
+ # installation location.
+ windows_sdk_path = "C:\Program Files (x86)\Windows Kits\10"
+}
+
+if (visual_studio_path == "") {
+ toolchain_data =
+ exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope")
+ visual_studio_path = toolchain_data.vs_path
+ windows_sdk_path = toolchain_data.sdk_path
+ visual_studio_version = toolchain_data.vs_version
+ wdk_path = toolchain_data.wdk_dir
+ visual_studio_runtime_dirs = toolchain_data.runtime_dirs
+} else {
+ assert(visual_studio_version != "",
+ "You must set the visual_studio_version if you set the path")
+ assert(wdk_path != "",
+ "You must set the wdk_path if you set the visual studio path")
+ visual_studio_runtime_dirs = []
+}
diff --git a/third_party/libwebrtc/webrtc/build/config/zip.gni b/third_party/libwebrtc/webrtc/build/config/zip.gni
new file mode 100644
index 0000000000..8265e1dabf
--- /dev/null
+++ b/third_party/libwebrtc/webrtc/build/config/zip.gni
@@ -0,0 +1,55 @@
+# 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.
+
+# Creates a zip archive of the inputs.
+#
+# inputs (required)
+# List of input files relative to the current directory.
+#
+# output (required)
+# File name to write.
+#
+# base_dir (optional)
+# If provided, the archive paths will be relative to this directory.
+#
+# deps, public_deps, data_deps, testonly, visibility (optional)
+# Normal meaning.
+template("zip") {
+ action(target_name) {
+ script = "//build/android/gn/zip.py"
+ depfile = "$target_gen_dir/$target_name.d"
+ inputs = invoker.inputs
+ outputs = [
+ invoker.output,
+ ]
+
+ assert(defined(invoker.inputs))
+ rebase_inputs = rebase_path(invoker.inputs, root_build_dir)
+
+ assert(defined(invoker.output))
+ rebase_output = rebase_path(invoker.output, root_build_dir)
+
+ args = [
+ "--depfile",
+ rebase_path(depfile, root_build_dir),
+ "--inputs=$rebase_inputs",
+ "--output=$rebase_output",
+ ]
+ if (defined(invoker.base_dir)) {
+ args += [
+ "--base-dir",
+ rebase_path(invoker.base_dir, root_build_dir),
+ ]
+ }
+
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "deps",
+ "public_deps",
+ "data_deps",
+ "visibility",
+ ])
+ }
+}