• 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
8declare_args() {
9  # Enable Link Time Optimization in optimized builds (output programs run
10  # faster, but linking is up to 5-20x slower).
11  #
12  # TODO(pcc): Remove this flag if/when LTO is enabled in official builds.
13  allow_posix_link_time_opt = false
14
15  # Set to true to use lld, the LLVM linker. This flag may be used on Windows
16  # with the shipped LLVM toolchain, or on Linux with a self-built top-of-tree
17  # LLVM toolchain (see llvm_force_head_revision in
18  # build/config/compiler/BUILD.gn).
19  use_lld = false
20
21  if (is_clang) {
22    # Clang compiler version. Clang files are placed at version-dependent paths.
23    clang_version = "3.9.0"
24  }
25}
26
27# Subdirectory within root_out_dir for shared library files.
28# TODO(agrieve): GYP sets this to "lib" for Linux & Android, but this won't work
29#     in GN until support for loadable_module() is added.
30#     See: https://codereview.chromium.org/1236503002/
31shlib_subdir = "."
32
33# Root out dir for shared library files.
34root_shlib_dir = root_out_dir
35if (shlib_subdir != ".") {
36  root_shlib_dir += "/$shlib_subdir"
37}
38
39# Extension for shared library files (including leading dot).
40if (is_mac || is_ios) {
41  shlib_extension = ".dylib"
42} else if (is_android && is_component_build) {
43  # By appending .cr, we prevent name collisions with libraries already
44  # loaded by the Android zygote.
45  shlib_extension = ".cr.so"
46} else if (is_posix) {
47  shlib_extension = ".so"
48} else if (is_win) {
49  shlib_extension = ".dll"
50} else {
51  assert(false, "Platform not supported")
52}
53
54# Prefix for shared library files.
55if (is_posix) {
56  shlib_prefix = "lib"
57} else {
58  shlib_prefix = ""
59}
60
61# While other "tool"s in a toolchain are specific to the target of that
62# toolchain, the "stamp" and "copy" tools are really generic to the host;
63# but each toolchain must define them separately.  GN doesn't allow a
64# template instantiation inside a toolchain definition, so some boilerplate
65# has to be repeated in each toolchain to define these two tools.  These
66# four variables reduce the duplication in that boilerplate.
67stamp_description = "STAMP {{output}}"
68copy_description = "COPY {{source}} {{output}}"
69if (host_os == "win") {
70  stamp_command = "$python_path gyp-win-tool stamp {{output}}"
71  copy_command =
72      "$python_path gyp-win-tool recursive-mirror {{source}} {{output}}"
73} else {
74  stamp_command = "touch {{output}}"
75  copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
76}
77