• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2015 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5# Toolchain-related configuration that may be needed outside the context of the
6# toolchain() rules themselves.
7
8import("//build/misc/overrides/build.gni")
9
10declare_args() {
11  # If this is set to true, or if LLVM_FORCE_HEAD_REVISION is set to 1
12  # in the environment, we use the revision in the llvm repo to determine
13  # the CLANG_REVISION to use, instead of the version hard-coded into
14  # //tools/clang/scripts/update.py. This should only be used in
15  # conjunction with setting LLVM_FORCE_HEAD_REVISION in the
16  # environment when `gclient runhooks` is run as well.
17  llvm_force_head_revision = false
18
19  # Compile with Xcode version of clang instead of hermetic version shipped
20  # with the build. Used on iOS to ship official builds (as they are built
21  # with the version of clang shipped with Xcode).
22  use_xcode_clang = false
23
24  # Compile with Android SDK version of clang instead of hermetic version shipped
25  # with the build. Used on Android to ship official builds (as they are built
26  # with the version of clang shipped with Android SDK).
27  use_android_clang = false
28
29  # Used for binary size analysis.
30  # Currently disabled on LLD because of a bug (fixed upstream).
31  # See https://crbug.com/716209.
32  generate_linker_map = is_ohos && is_official_build
33
34  # Use absolute file paths in the compiler diagnostics and __FILE__ macro
35  # if needed.
36  msvc_use_absolute_paths = false
37}
38
39if (generate_linker_map) {
40  assert(
41      is_official_build,
42      "Linker map files should only be generated when is_official_build = true")
43  assert(current_os == "ohos" || target_os == "linux",
44         "Linker map files should only be generated for ohos and Linux")
45}
46
47# The path to the hermetic install of Xcode. Only relevant when
48hermetic_xcode_path =
49    rebase_path("//build/${target_os}_files/Xcode.app", "", root_build_dir)
50
51declare_args() {
52  if (is_clang) {
53    # Clang compiler version. Clang files are placed at version-dependent paths.
54    clang_version = "15.0.4"
55  }
56  use_custom_clang = true
57}
58
59# Check target_os here instead of is_ios as this file is loaded for secondary
60# toolchain (host toolchain in particular) but the argument is the same for
61# all toolchains.
62assert(!use_xcode_clang || target_os == "ios",
63       "Using Xcode's clang is only supported in iOS builds")
64
65# Extension for shared library files (including leading dot).
66executable_extension = ""
67if (is_mac) {
68  shlib_extension = ".dylib"
69  dylib_extension = ".dylib.so"
70  rlib_extension = ".rlib"
71} else if (is_ohos && is_component_build) {
72  # By appending .z, we prevent name collisions with libraries already loaded by the ohos.
73  shlib_extension = ".z.so"
74  dylib_extension = ".dylib.so"
75  rlib_extension = ".rlib"
76} else if (is_mingw) {
77  shlib_extension = ".dll"
78  executable_extension = ".exe"
79  dylib_extension = ".dll"
80  rlib_extension = ".rlib"
81} else if (is_posix) {
82  shlib_extension = ".so"
83  dylib_extension = ".dylib.so"
84  rlib_extension = ".rlib"
85} else if (is_win) {
86  shlib_extension = ".dll"
87} else {
88  assert(false, "Platform not supported")
89}
90
91# Prefix for shared library files.
92if (is_posix) {
93  shlib_prefix = "lib"
94} else {
95  shlib_prefix = ""
96}
97
98# While other "tool"s in a toolchain are specific to the target of that
99# toolchain, the "stamp" and "copy" tools are really generic to the host;
100# but each toolchain must define them separately.  GN doesn't allow a
101# template instantiation inside a toolchain definition, so some boilerplate
102# has to be repeated in each toolchain to define these two tools.  These
103# four variables reduce the duplication in that boilerplate.
104stamp_description = "STAMP {{output}}"
105copy_description = "COPY {{source}} {{output}}"
106if (host_os == "win") {
107  _tool_wrapper_path =
108      rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir)
109  stamp_command = "cmd /c type nul > \"{{output}}\""
110  copy_command =
111      "$python_path $_tool_wrapper_path recursive-mirror {{source}} {{output}}"
112} else {
113  stamp_command = "touch {{output}}"
114  copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
115}
116