• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
5import("//build/config/sysroot.gni")
6
7# This build configuration is used by both Fuchsia and POSIX systems.
8assert(is_posix || is_fuchsia)
9
10group("posix") {
11  visibility = [ "//:optimize_gn_gen" ]
12}
13
14# This is included by reference in the //build/config/compiler:runtime_library
15# config that is applied to all targets. It is here to separate out the logic
16# that is Posix-only. Please see that target for advice on what should go in
17# :runtime_library vs. :compiler.
18config("runtime_library") {
19  asmflags = []
20  cflags = []
21  cflags_c = []
22  cflags_cc = []
23  cflags_objc = []
24  cflags_objcc = []
25  defines = []
26  ldflags = []
27
28  if (!is_apple && sysroot != "" && current_os != "zos") {
29    # Pass the sysroot to all C compiler variants, the assembler, and linker.
30    sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ]
31    if (is_linux || is_chromeos) {
32      # This is here so that all files get recompiled after a sysroot roll and
33      # when turning the sysroot on or off. (defines are passed via the command
34      # line, and build system rebuilds things when their commandline
35      # changes). Nothing should ever read this define.
36      sysroot_key =
37          exec_script("//build/linux/sysroot_scripts/install-sysroot.py",
38                      [ "--print-key=$current_cpu" ],
39                      "trim string",
40                      [ "//build/linux/sysroot_scripts/sysroots.json" ])
41      defines += [ "CR_SYSROOT_KEY=$sysroot_key" ]
42    }
43    asmflags += sysroot_flags
44    ldflags += sysroot_flags
45
46    # When use_custom_libcxx=true, some -isystem flags get passed to
47    # cflags_cc to set up libc++ include paths.  We want to make sure
48    # the sysroot includes take lower precendence than the libc++
49    # ones, so they must appear later in the command line.  However,
50    # the gn reference states "These variant-specific versions of
51    # cflags* will be appended on the compiler command line after
52    # 'cflags'."  Because of this, we must set the sysroot flags for
53    # all cflags variants instead of using 'cflags' directly.
54    cflags_c += sysroot_flags
55    cflags_cc += sysroot_flags
56    cflags_objc += sysroot_flags
57    cflags_objcc += sysroot_flags
58  }
59}
60