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 = "12.0.1" 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} else if (is_ohos && is_component_build) { 65 # By appending .z, we prevent name collisions with libraries already loaded by the ohos. 66 shlib_extension = ".z.so" 67} else if (is_mingw) { 68 shlib_extension = ".dll" 69 executable_extension = ".exe" 70} else if (is_posix) { 71 shlib_extension = ".so" 72} else if (is_win) { 73 shlib_extension = ".dll" 74} else { 75 assert(false, "Platform not supported") 76} 77 78# Prefix for shared library files. 79if (is_posix) { 80 shlib_prefix = "lib" 81} else { 82 shlib_prefix = "" 83} 84 85# While other "tool"s in a toolchain are specific to the target of that 86# toolchain, the "stamp" and "copy" tools are really generic to the host; 87# but each toolchain must define them separately. GN doesn't allow a 88# template instantiation inside a toolchain definition, so some boilerplate 89# has to be repeated in each toolchain to define these two tools. These 90# four variables reduce the duplication in that boilerplate. 91stamp_description = "STAMP {{output}}" 92copy_description = "COPY {{source}} {{output}}" 93if (host_os == "win") { 94 _tool_wrapper_path = 95 rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir) 96 stamp_command = "cmd /c type nul > \"{{output}}\"" 97 copy_command = 98 "$python_path $_tool_wrapper_path recursive-mirror {{source}} {{output}}" 99} else { 100 stamp_command = "touch {{output}}" 101 copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" 102} 103