tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

toolchain.gni (5362B)


      1 # Copyright 2015 The Chromium Authors
      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 
      8 import("//chromium/build/config/cast.gni")
      9 import("//chromium/build/config/chrome_build.gni")
     10 import("//build_overrides/build.gni")
     11 
     12 declare_args() {
     13   # If this is set to true, we use the revision in the llvm repo to determine
     14   # the CLANG_REVISION to use, instead of the version hard-coded into
     15   # //tools/clang/scripts/update.py. This should only be used in
     16   # conjunction with setting the llvm_force_head_revision DEPS variable when
     17   # `gclient runhooks` is run as well.
     18   llvm_force_head_revision = false
     19 
     20   # Cronet is shipped in AOSP, where it is built using the Android Mainline
     21   # Clang. Please refer to go/cronet-builders-with-mainline-clang-design for
     22   # more information.
     23   # If this arg is set to true, we use the Android Mainline LLVM.
     24   llvm_android_mainline = false
     25 
     26   # Used for binary size analysis.
     27   generate_linker_map = is_android && is_official_build
     28 
     29   # Whether this toolchain is to be used for building host tools that are
     30   # consumed during the build process. That includes proc macros and Cargo build
     31   # scripts.
     32   toolchain_for_rust_host_build_tools = false
     33 
     34   # If false, the toolchain overrides `use_partition_alloc_as_malloc` in
     35   # PartitionAlloc, to allow use of the system allocator.
     36   toolchain_allows_use_partition_alloc_as_malloc = true
     37 }
     38 
     39 if (generate_linker_map) {
     40   assert(is_official_build || is_castos || is_cast_android,
     41          "Linker map files should only be generated when is_official_build = " +
     42              "true or is_castos = true or is_cast_android = true")
     43   assert(current_os == "android" || current_os == "linux" ||
     44              target_os == "android" || target_os == "linux" ||
     45              target_os == "chromeos",
     46          "Linker map files should only be generated for Android, Linux, " +
     47              "or ChromeOS.")
     48 }
     49 
     50 declare_args() {
     51   if (llvm_android_mainline) {  # https://crbug.com/1481060
     52     clang_version = "17"
     53   } else {
     54     clang_version = "21"
     55   }
     56 }
     57 
     58 # Extension for shared library files (including leading dot).
     59 if (is_apple) {
     60   shlib_extension = ".dylib"
     61 } else if (is_posix || is_fuchsia) {
     62   shlib_extension = ".so"
     63 } else if (is_win) {
     64   shlib_extension = ".dll"
     65 } else if (is_wasm) {
     66   # WebAssembly does not stably support shared libraries. (as of Oct 2019)
     67   shlib_extension = ".wasm"
     68 } else {
     69   assert(false, "Platform not supported")
     70 }
     71 
     72 # Same extension but for the host platform. We have significantly fewer host
     73 # platforms.
     74 if (host_os == "mac") {
     75   host_shlib_extension = ".dylib"
     76 } else if (host_os == "win") {
     77   host_shlib_extension = ".dll"
     78 } else if (host_os == "linux" || host_os == "aix" || host_os == "zos") {
     79   host_shlib_extension = ".so"
     80 } else {
     81   assert(false, "Host platform not supported")
     82 }
     83 
     84 # Prefix for shared library files.
     85 if (is_posix || is_fuchsia) {
     86   shlib_prefix = "lib"
     87 } else {
     88   shlib_prefix = ""
     89 }
     90 
     91 # Directory for shared library files.
     92 if (is_fuchsia) {
     93   shlib_subdir = "/lib"
     94 } else {
     95   shlib_subdir = ""
     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.
    104 stamp_description = "STAMP {{output}}"
    105 copy_description = "COPY {{source}} {{output}}"
    106 if (host_os == "win") {
    107   _tool_wrapper_path =
    108       rebase_path("//chromium/build/toolchain/win/tool_wrapper.py", root_build_dir)
    109 
    110   stamp_command = "cmd /c type nul > \"{{output}}\""
    111   copy_command = "\"$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 
    117 # This variable is true if the current toolchain is one of the target
    118 # toolchains, i.e. a toolchain which is being used to build the main Chrome
    119 # binary. This generally means "not the host toolchain", but in the case where
    120 # we're targeting the host it's true then as well. We do require current_os to
    121 # match target_os so that for example we avoid considering Android as a target
    122 # toolchain when targeting CrOS.
    123 is_a_target_toolchain =
    124     (current_toolchain != host_toolchain ||
    125      default_toolchain == host_toolchain) && current_os == target_os
    126 
    127 # A toolchain for building tools that run on the host machine and need to use
    128 # the system allocator. This toolchain does not use PartitionAlloc-Everywhere by
    129 # design. We use a name with `_host` injected into it to avoid colliding with
    130 # toolchains of the same name (but different path) between different OSes.
    131 host_system_allocator_toolchain = "${host_toolchain}_host_with_system_allocator"
    132 
    133 # A toolchain for building tools that run on the default target machine and need
    134 # to use the system allocator. This toolchain does not use
    135 # PartitionAlloc-Everywhere by design.
    136 default_system_allocator_toolchain =
    137     "${default_toolchain}_with_system_allocator"