xref: /aosp_15_r20/external/angle/build/config/posix/BUILD.gn (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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      import("//build/linux/sysroot_scripts/sysroot.gni")
37      defines += [ "CR_SYSROOT_KEY=$cr_sysroot_key" ]
38    }
39    asmflags += sysroot_flags
40    ldflags += sysroot_flags
41
42    # When use_custom_libcxx=true, some -isystem flags get passed to
43    # cflags_cc to set up libc++ include paths.  We want to make sure
44    # the sysroot includes take lower precendence than the libc++
45    # ones, so they must appear later in the command line.  However,
46    # the gn reference states "These variant-specific versions of
47    # cflags* will be appended on the compiler command line after
48    # 'cflags'."  Because of this, we must set the sysroot flags for
49    # all cflags variants instead of using 'cflags' directly.
50    cflags_c += sysroot_flags
51    cflags_cc += sysroot_flags
52    cflags_objc += sysroot_flags
53    cflags_objcc += sysroot_flags
54  }
55}
56