summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/webrtc/build/toolchain/toolchain.gni
blob: 8513f83fd4b331a29f19530e03cddcac02fa45ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# 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.

# Toolchain-related configuration that may be needed outside the context of the
# toolchain() rules themselves.

import("//build_overrides/build.gni")
import("//build/config/chrome_build.gni")

declare_args() {
  # Enable Link Time Optimization in optimized builds (output programs run
  # faster, but linking is up to 5-20x slower).
  # Note: use target_os == "linux" rather than is_linux so that it does not
  # apply to host_toolchain when target_os="android".
  allow_posix_link_time_opt =
      is_clang && target_os == "linux" && !is_chromeos && target_cpu == "x64" &&
      is_official_build

  # If used with allow_posix_link_time_opt, it enables the experimental support
  # of ThinLTO that links 3x-10x faster but (as of now) does not have all the
  # important optimizations such us devirtualization implemented. See also
  # http://blog.llvm.org/2016/06/thinlto-scalable-and-incremental-lto.html
  use_thin_lto = false

  # If this is set to true, or if LLVM_FORCE_HEAD_REVISION is set to 1
  # in the environment, we use the revision in the llvm repo to determine
  # the CLANG_REVISION to use, instead of the version hard-coded into
  # //tools/clang/scripts/update.py. This should only be used in
  # conjunction with setting LLVM_FORCE_HEAD_REVISION in the
  # environment when `gclient runhooks` is run as well.
  llvm_force_head_revision = false

  # Compile with Xcode version of clang instead of hermetic version shipped
  # with the build. Used on iOS to ship official builds (as they are built
  # with the version of clang shipped with Xcode).
  use_xcode_clang = is_ios && is_official_build

  # Used for binary size analysis.
  # Currently disabled on LLD because of a bug (fixed upstream).
  # See https://crbug.com/716209.
  generate_linker_map = is_android && is_official_build
}

if (generate_linker_map) {
  assert(
      is_official_build,
      "Linker map files should only be generated when is_official_build = true")
  assert(target_os == "android" || target_os == "linux",
         "Linker map files should only be generated for Android and Linux")
}

# The path to the hermetic install of Xcode. Only relevant when
# use_system_xcode = false.
hermetic_xcode_path =
    rebase_path("//build/${target_os}_files/Xcode.app", "", root_build_dir)

declare_args() {
  if (is_clang) {
    # Clang compiler version. Clang files are placed at version-dependent paths.
    clang_version = "5.0.0"
  }

  # Set to true to use lld, the LLVM linker. This flag may be used on Windows
  # or Linux.
  use_lld = (is_win && host_os != "win") ||
            (allow_posix_link_time_opt && target_os == "linux" &&
             !is_chromeos && target_cpu == "x64")
}

# Check target_os here instead of is_ios as this file is loaded for secondary
# toolchain (host toolchain in particular) but the argument is the same for
# all toolchains.
assert(!use_xcode_clang || target_os == "ios",
       "Using Xcode's clang is only supported in iOS builds")

# Subdirectory within root_out_dir for shared library files.
# TODO(agrieve): GYP sets this to "lib" for Linux & Android, but this won't work
#     in GN until support for loadable_module() is added.
#     See: https://codereview.chromium.org/1236503002/
shlib_subdir = "."

# Root out dir for shared library files.
root_shlib_dir = root_out_dir
if (shlib_subdir != ".") {
  root_shlib_dir += "/$shlib_subdir"
}

# Extension for shared library files (including leading dot).
if (is_mac || is_ios) {
  shlib_extension = ".dylib"
} else if (is_android && is_component_build) {
  # By appending .cr, we prevent name collisions with libraries already
  # loaded by the Android zygote.
  shlib_extension = ".cr.so"
} else if (is_posix) {
  shlib_extension = ".so"
} else if (is_win) {
  shlib_extension = ".dll"
} else {
  assert(false, "Platform not supported")
}

# Prefix for shared library files.
if (is_posix) {
  shlib_prefix = "lib"
} else {
  shlib_prefix = ""
}

# While other "tool"s in a toolchain are specific to the target of that
# toolchain, the "stamp" and "copy" tools are really generic to the host;
# but each toolchain must define them separately.  GN doesn't allow a
# template instantiation inside a toolchain definition, so some boilerplate
# has to be repeated in each toolchain to define these two tools.  These
# four variables reduce the duplication in that boilerplate.
stamp_description = "STAMP {{output}}"
copy_description = "COPY {{source}} {{output}}"
if (host_os == "win") {
  _tool_wrapper_path =
      rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir)

  stamp_command = "$python_path $_tool_wrapper_path stamp {{output}}"
  copy_command =
      "$python_path $_tool_wrapper_path recursive-mirror {{source}} {{output}}"
} else {
  stamp_command = "touch {{output}}"
  copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
}