• 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  # Used for binary size analysis.
25  # Currently disabled on LLD because of a bug (fixed upstream).
26  # See https://crbug.com/716209.
27  generate_linker_map = is_ohos && is_official_build
28
29  # Use absolute file paths in the compiler diagnostics and __FILE__ macro
30  # if needed.
31  msvc_use_absolute_paths = false
32}
33
34if (generate_linker_map) {
35  assert(
36      is_official_build,
37      "Linker map files should only be generated when is_official_build = true")
38  assert(current_os == "ohos" || target_os == "linux",
39         "Linker map files should only be generated for ohos and Linux")
40}
41
42# The path to the hermetic install of Xcode. Only relevant when
43hermetic_xcode_path =
44    rebase_path("//build/${target_os}_files/Xcode.app", "", root_build_dir)
45
46declare_args() {
47  if (is_clang) {
48    # Clang compiler version. Clang files are placed at version-dependent paths.
49    clang_version = "15.0.4"
50  }
51  use_custom_clang = true
52}
53
54# Check target_os here instead of is_ios as this file is loaded for secondary
55# toolchain (host toolchain in particular) but the argument is the same for
56# all toolchains.
57assert(!use_xcode_clang || target_os == "ios",
58       "Using Xcode's clang is only supported in iOS builds")
59
60# Extension for shared library files (including leading dot).
61executable_extension = ""
62if (is_mac) {
63  shlib_extension = ".dylib"
64  dylib_extension = ".dylib.so"
65  rlib_extension = ".rlib"
66} else if (is_ohos && is_component_build) {
67  # By appending .z, we prevent name collisions with libraries already loaded by the ohos.
68  shlib_extension = ".z.so"
69  dylib_extension = ".dylib.so"
70  rlib_extension = ".rlib"
71} else if (is_mingw) {
72  shlib_extension = ".dll"
73  executable_extension = ".exe"
74} else if (is_posix) {
75  shlib_extension = ".so"
76  dylib_extension = ".dylib.so"
77  rlib_extension = ".rlib"
78} else if (is_win) {
79  shlib_extension = ".dll"
80} else {
81  assert(false, "Platform not supported")
82}
83
84# Prefix for shared library files.
85if (is_posix) {
86  shlib_prefix = "lib"
87} else {
88  shlib_prefix = ""
89}
90
91# While other "tool"s in a toolchain are specific to the target of that
92# toolchain, the "stamp" and "copy" tools are really generic to the host;
93# but each toolchain must define them separately.  GN doesn't allow a
94# template instantiation inside a toolchain definition, so some boilerplate
95# has to be repeated in each toolchain to define these two tools.  These
96# four variables reduce the duplication in that boilerplate.
97stamp_description = "STAMP {{output}}"
98copy_description = "COPY {{source}} {{output}}"
99if (host_os == "win") {
100  _tool_wrapper_path =
101      rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir)
102  stamp_command = "cmd /c type nul > \"{{output}}\""
103  copy_command =
104      "$python_path $_tool_wrapper_path recursive-mirror {{source}} {{output}}"
105} else {
106  stamp_command = "touch {{output}}"
107  copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
108}
109