1*8975f5c5SAndroid Build Coastguard Worker# Copyright 2015 The Chromium Authors 2*8975f5c5SAndroid Build Coastguard Worker# Use of this source code is governed by a BSD-style license that can be 3*8975f5c5SAndroid Build Coastguard Worker# found in the LICENSE file. 4*8975f5c5SAndroid Build Coastguard Worker 5*8975f5c5SAndroid Build Coastguard Workerimport("//build/config/sysroot.gni") 6*8975f5c5SAndroid Build Coastguard Worker 7*8975f5c5SAndroid Build Coastguard Worker# This build configuration is used by both Fuchsia and POSIX systems. 8*8975f5c5SAndroid Build Coastguard Workerassert(is_posix || is_fuchsia) 9*8975f5c5SAndroid Build Coastguard Worker 10*8975f5c5SAndroid Build Coastguard Workergroup("posix") { 11*8975f5c5SAndroid Build Coastguard Worker visibility = [ "//:optimize_gn_gen" ] 12*8975f5c5SAndroid Build Coastguard Worker} 13*8975f5c5SAndroid Build Coastguard Worker 14*8975f5c5SAndroid Build Coastguard Worker# This is included by reference in the //build/config/compiler:runtime_library 15*8975f5c5SAndroid Build Coastguard Worker# config that is applied to all targets. It is here to separate out the logic 16*8975f5c5SAndroid Build Coastguard Worker# that is Posix-only. Please see that target for advice on what should go in 17*8975f5c5SAndroid Build Coastguard Worker# :runtime_library vs. :compiler. 18*8975f5c5SAndroid Build Coastguard Workerconfig("runtime_library") { 19*8975f5c5SAndroid Build Coastguard Worker asmflags = [] 20*8975f5c5SAndroid Build Coastguard Worker cflags = [] 21*8975f5c5SAndroid Build Coastguard Worker cflags_c = [] 22*8975f5c5SAndroid Build Coastguard Worker cflags_cc = [] 23*8975f5c5SAndroid Build Coastguard Worker cflags_objc = [] 24*8975f5c5SAndroid Build Coastguard Worker cflags_objcc = [] 25*8975f5c5SAndroid Build Coastguard Worker defines = [] 26*8975f5c5SAndroid Build Coastguard Worker ldflags = [] 27*8975f5c5SAndroid Build Coastguard Worker 28*8975f5c5SAndroid Build Coastguard Worker if (!is_apple && sysroot != "" && current_os != "zos") { 29*8975f5c5SAndroid Build Coastguard Worker # Pass the sysroot to all C compiler variants, the assembler, and linker. 30*8975f5c5SAndroid Build Coastguard Worker sysroot_flags = [ "--sysroot=" + rebase_path(sysroot, root_build_dir) ] 31*8975f5c5SAndroid Build Coastguard Worker if (is_linux || is_chromeos) { 32*8975f5c5SAndroid Build Coastguard Worker # This is here so that all files get recompiled after a sysroot roll and 33*8975f5c5SAndroid Build Coastguard Worker # when turning the sysroot on or off. (defines are passed via the command 34*8975f5c5SAndroid Build Coastguard Worker # line, and build system rebuilds things when their commandline 35*8975f5c5SAndroid Build Coastguard Worker # changes). Nothing should ever read this define. 36*8975f5c5SAndroid Build Coastguard Worker import("//build/linux/sysroot_scripts/sysroot.gni") 37*8975f5c5SAndroid Build Coastguard Worker defines += [ "CR_SYSROOT_KEY=$cr_sysroot_key" ] 38*8975f5c5SAndroid Build Coastguard Worker } 39*8975f5c5SAndroid Build Coastguard Worker asmflags += sysroot_flags 40*8975f5c5SAndroid Build Coastguard Worker ldflags += sysroot_flags 41*8975f5c5SAndroid Build Coastguard Worker 42*8975f5c5SAndroid Build Coastguard Worker # When use_custom_libcxx=true, some -isystem flags get passed to 43*8975f5c5SAndroid Build Coastguard Worker # cflags_cc to set up libc++ include paths. We want to make sure 44*8975f5c5SAndroid Build Coastguard Worker # the sysroot includes take lower precendence than the libc++ 45*8975f5c5SAndroid Build Coastguard Worker # ones, so they must appear later in the command line. However, 46*8975f5c5SAndroid Build Coastguard Worker # the gn reference states "These variant-specific versions of 47*8975f5c5SAndroid Build Coastguard Worker # cflags* will be appended on the compiler command line after 48*8975f5c5SAndroid Build Coastguard Worker # 'cflags'." Because of this, we must set the sysroot flags for 49*8975f5c5SAndroid Build Coastguard Worker # all cflags variants instead of using 'cflags' directly. 50*8975f5c5SAndroid Build Coastguard Worker cflags_c += sysroot_flags 51*8975f5c5SAndroid Build Coastguard Worker cflags_cc += sysroot_flags 52*8975f5c5SAndroid Build Coastguard Worker cflags_objc += sysroot_flags 53*8975f5c5SAndroid Build Coastguard Worker cflags_objcc += sysroot_flags 54*8975f5c5SAndroid Build Coastguard Worker } 55*8975f5c5SAndroid Build Coastguard Worker} 56